Skip to content

Commit 4fc83e3

Browse files
ggouaillardetjjhursey
authored andcommitted
preg/native: correctly handle node names with multiple set of digits
Refs. open-mpi/ompi#4689 Refs. open-mpi/ompi#4748 Signed-off-by: Gilles Gouaillardet <[email protected]> (cherry picked from commit 98073d7) Signed-off-by: Joshua Hursey <[email protected]>
1 parent afe8ace commit 4fc83e3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/mca/preg/native/preg_native.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/*
22
* Copyright (c) 2015-2017 Intel, Inc. All rights reserved.
33
* Copyright (c) 2016 IBM Corporation. All rights reserved.
4+
* Copyright (c) 2018 Research Organization for Information Science
5+
* and Technology (RIST). All rights reserved.
46
*
57
* $COPYRIGHT$
68
*
@@ -106,7 +108,6 @@ static pmix_status_t generate_node_regex(const char *input,
106108
len = strlen(vptr);
107109
startnum = -1;
108110
memset(prefix, 0, PMIX_MAX_NODE_PREFIX);
109-
numdigits = 0;
110111
for (i=0, j=0; i < len; i++) {
111112
if (!isalpha(vptr[i])) {
112113
/* found a non-alpha char */
@@ -120,7 +121,6 @@ static pmix_status_t generate_node_regex(const char *input,
120121
/* count the size of the numeric field - but don't
121122
* add the digits to the prefix
122123
*/
123-
numdigits++;
124124
if (startnum < 0) {
125125
/* okay, this defines end of the prefix */
126126
startnum = i;
@@ -147,8 +147,10 @@ static pmix_status_t generate_node_regex(const char *input,
147147
vnum = strtol(&vptr[startnum], &sfx, 10);
148148
if (NULL != sfx) {
149149
suffix = strdup(sfx);
150+
numdigits = (int)(sfx - &vptr[startnum]);
150151
} else {
151152
suffix = NULL;
153+
numdigits = (int)strlen(&vptr[startnum]);
152154
}
153155
/* is this value already on our list? */
154156
found = false;

0 commit comments

Comments
 (0)