From f3e2a313afee50582e12d30ac974bca180271351 Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Fri, 15 Dec 2017 15:28:50 +0900 Subject: [PATCH] orte/nidmap: correctly handle '-' as a valid hostname character '-' is not an alpha character nor a digit, but it is a valid hostname character and should be handled as an alpha character, otherwise, nodes such as node-001 do not get "compressed" in the regex. Refs open-mpi/ompi#4621 Signed-off-by: Gilles Gouaillardet --- orte/util/nidmap.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/orte/util/nidmap.c b/orte/util/nidmap.c index 30d0c0e8b05..06d0a28c71f 100644 --- a/orte/util/nidmap.c +++ b/orte/util/nidmap.c @@ -270,22 +270,15 @@ int orte_util_nidmap_create(opal_pointer_array_t *pool, char **regex) } } node = nptr->name; - /* determine this node's prefix by looking for first non-alpha char */ + /* determine this node's prefix by looking for first digit char */ fullname = false; len = strlen(node); startnum = -1; memset(prefix, 0, ORTE_MAX_NODE_PREFIX); numdigits = 0; for (i=0, j=0; i < len; i++) { - if (!isalpha(node[i])) { - /* found a non-alpha char */ - if (!isdigit(node[i])) { - /* if it is anything but a digit, we just use - * the entire name - */ - fullname = true; - break; - } + /* valid hostname characters are ascii letters, digits and the '-' character. */ + if (isdigit(node[i])) { /* count the size of the numeric field - but don't * add the digits to the prefix */ @@ -296,6 +289,13 @@ int orte_util_nidmap_create(opal_pointer_array_t *pool, char **regex) } continue; } + if ('.' == node[i]) { + /* just use the entire name */ + fullname = true; + break; + } + /* this is either an alpha or '-' */ + assert(isalpha(node[i]) || '-' == node[i]); if (startnum < 0) { prefix[j++] = node[i]; }