Skip to content
Snippets Groups Projects
Commit bc5b82cf authored by Moe Jette's avatar Moe Jette
Browse files

correct sview name sorting for BGL with more than 10 elements in a dimension

(previous code used atoi function, which does not work with 'A', etc.).
parent 778906b1
No related branches found
No related tags found
No related merge requests found
...@@ -353,37 +353,53 @@ cleanup: ...@@ -353,37 +353,53 @@ cleanup:
return ret; return ret;
} }
/* Translate a three-digit alpha-numeric value into it's
* base 36 equivalent number */
static int _xlate_bp_coord(const char *name)
{
int i, rc = 0;
for (i=0; i<3; i++) {
rc *= 36;
if ((name[i] >= '0') && (name[i] <= '9'))
rc += (name[i] - '0');
else if ((name[i] >= 'A') && (name[i] <= 'Z'))
rc += ((name[i] - 'A') + 10);
}
return rc;
}
/* Make a BlueGene node name into a numeric representation of /* Make a BlueGene node name into a numeric representation of
* its location. * its location.
* Value is low_coordinate * 1,000,000 + * Value is low_node_coordinate * 1,000 + I/O node (999 if none)
* high_coordinate * 1,000 + I/O node (999 if none) * with use of base 36 for the node coordinate:
* (e.g. bg123[4] -> 123,123,004, bg[234x235] -> 234,235,999) * (e.g. bg123[4] -> 1,371,004
* bg[234x235] -> 2,704,999
* bglZZZ -> 46,655,999
*/ */
static int _bp_coordinate(const char *name) static int _bp_coordinate(const char *name)
{ {
int i, io_val = 999, low_val = -1, high_val = -1; int i, io_val = 999, low_val = -1;
for (i=0; name[i]; i++) { for (i=0; name[i]; i++) {
if (name[i] == '[') { if (name[i] == '[') {
i++; i++;
if (low_val < 0) { if (low_val < 0)
char *end_ptr; low_val = _xlate_bp_coord(name+i);
low_val = strtol(name+i, &end_ptr, 10); else
if ((end_ptr[0] != '\0') &&
(isdigit(end_ptr[1])))
high_val = atoi(end_ptr + 1);
else
high_val = low_val;
} else
io_val = atoi(name+i); io_val = atoi(name+i);
break; break;
} else if ((low_val < 0) && (isdigit(name[i]))) } else if ((low_val < 0) &&
low_val = high_val = atoi(name+i); ((name[i] >= '0' && (name[i] <= '9')) ||
(name[i] >= 'A' && (name[i] <= 'Z')))) {
low_val = _xlate_bp_coord(name+i);
i += 2;
}
} }
if (low_val < 0) if (low_val < 0)
return low_val; return low_val;
return ((low_val * 1000000) + (high_val * 1000) + io_val); return ((low_val * 1000) + io_val);
} }
static int _sort_iter_compare_func_bp_list(GtkTreeModel *model, static int _sort_iter_compare_func_bp_list(GtkTreeModel *model,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment