From 3199663613a885327e17aa314f6f42e66af5068a Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Fri, 5 Aug 2011 14:37:36 +0000 Subject: [PATCH] Correctly handle the case of mixes of character-based names and all-number names This commit was SVN r24998. --- orte/util/regex.c | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/orte/util/regex.c b/orte/util/regex.c index 190815c02d..fd325f350a 100644 --- a/orte/util/regex.c +++ b/orte/util/regex.c @@ -229,29 +229,35 @@ int orte_regex_create(char *nodelist, char **regexp) OBJ_RELEASE(ndreg); continue; } - /* must be at least one */ - range = (orte_regex_range_t*)opal_list_get_first(&ndreg->ranges); - /* if there is only one node in the range, then - * just add its name + /* if there is only one range, and it has only one node in it, + * then we don't want to use bracket notation - so treat that + * case separately */ - if (1 == range->cnt) { - if (NULL != ndreg->suffix) { - if (NULL != ndreg->prefix) { - asprintf(&tmp, "%s%d%s", ndreg->prefix, range->start, ndreg->suffix); + if (1 == opal_list_get_size(&ndreg->ranges)) { + /* must be at least one */ + range = (orte_regex_range_t*)opal_list_get_first(&ndreg->ranges); + /* if there is only one node in the range, then + * just add its name + */ + if (1 == range->cnt) { + if (NULL != ndreg->suffix) { + if (NULL != ndreg->prefix) { + asprintf(&tmp, "%s%d%s", ndreg->prefix, range->start, ndreg->suffix); + } else { + asprintf(&tmp, "%d%s", range->start, ndreg->suffix); + } } else { - asprintf(&tmp, "%d%s", range->start, ndreg->suffix); - } - } else { - if (NULL != ndreg->prefix) { - asprintf(&tmp, "%s%d", ndreg->prefix, range->start); - } else { - asprintf(&tmp, "%d", range->start); + if (NULL != ndreg->prefix) { + asprintf(&tmp, "%s%d", ndreg->prefix, range->start); + } else { + asprintf(&tmp, "%d", range->start); + } } + opal_argv_append_nosize(®exargs, tmp); + free(tmp); + OBJ_RELEASE(ndreg); + continue; } - opal_argv_append_nosize(®exargs, tmp); - free(tmp); - OBJ_RELEASE(ndreg); - continue; } /* start the regex for this nodeid with the prefix */ if (NULL != ndreg->prefix) { @@ -423,6 +429,8 @@ int orte_regex_extract_node_names(char *regexp, char ***names) free(orig); return ret; } + /* step over the comma */ + i++; /* set base equal to the (possible) next base to look at */ base = &base[i]; }