|
24 | 24 | #include "orte_config.h"
|
25 | 25 |
|
26 | 26 | #include <string.h>
|
| 27 | +#include <ctype.h> |
27 | 28 |
|
28 | 29 | #include "orte/constants.h"
|
29 | 30 | #include "orte/types.h"
|
@@ -515,25 +516,31 @@ int orte_util_filter_dash_host_nodes(opal_list_t *nodes,
|
515 | 516 | /* we are looking for a specific node on the list. The
|
516 | 517 | * parser will have substituted our local name for any
|
517 | 518 | * alias, so we only have to do a strcmp here. */
|
518 |
| - lmn = strtol(mapped_nodes[i], &cptr, 10); |
519 |
| - if (orte_managed_allocation && NULL != cptr) { |
520 |
| - /* if we are only given a number, then we only test the |
521 |
| - * number of matching characters starting from the rear |
522 |
| - * of the mapped_nodes entry. This allows support for |
523 |
| - * launch_id-based environments. For example, a hostname |
524 |
| - * of "nid0015" can be referenced by "--host 15" */ |
525 |
| - lmn = strlen(mapped_nodes[i]); |
526 |
| - } else { |
527 |
| - lmn = 0; |
528 |
| - } |
| 519 | + cptr = NULL; |
| 520 | + lmn = strtoul(mapped_nodes[i], &cptr, 10); |
529 | 521 | item = opal_list_get_first(nodes);
|
530 | 522 | while (item != opal_list_get_end(nodes)) {
|
531 | 523 | next = opal_list_get_next(item); /* save this position */
|
532 | 524 | node = (orte_node_t*)item;
|
533 | 525 | /* search -host list to see if this one is found */
|
534 |
| - if (0 < lmn) { |
535 |
| - lst = strlen(node->name); |
536 |
| - test = strncmp(node->name + lst - lmn, mapped_nodes[i], lmn); |
| 526 | + if (orte_managed_allocation && |
| 527 | + (NULL == cptr || 0 == strlen(cptr))) { |
| 528 | + /* if we are only given a number, then we test the |
| 529 | + * value against the number in the node name. This allows support for |
| 530 | + * launch_id-based environments. For example, a hostname |
| 531 | + * of "nid0015" can be referenced by "--host 15" */ |
| 532 | + for (j=strlen(node->name)-1; 0 < j; j--) { |
| 533 | + if (!isdigit(node->name[j])) { |
| 534 | + j++; |
| 535 | + break; |
| 536 | + } |
| 537 | + } |
| 538 | + if (j >= (int)(strlen(node->name) - 1)) { |
| 539 | + test = 0; |
| 540 | + } else { |
| 541 | + lst = strtoul(&node->name[j], NULL, 10); |
| 542 | + test = (lmn == lst) ? 0 : 1; |
| 543 | + } |
537 | 544 | } else {
|
538 | 545 | test = strcmp(node->name, mapped_nodes[i]);
|
539 | 546 | }
|
|
0 commit comments