Skip to content

Commit

Permalink
add suffix support between fields in sinfo/squeue long format
Browse files Browse the repository at this point in the history
This change adds the ability to add suffix value between fields in the
long formats of sinfo and squeue so that we can duplicate the behavior
of the short options. For example, there was no way to replicate something
like "%P %V" in squeue as something like "partition:9,cluster:8" would
just run the two fields together without a space and something like
"partition:9 ,cluster:8" would generate an error. This change treats
anything between the number and comma as a suffix to be included in
the output and make this work.

bug 7186
  • Loading branch information
jette committed Jun 6, 2019
1 parent 8b6685f commit 9ea6c94
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/sinfo/opts.c
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@ static void
_parse_long_token( char *token, char *sep, int *field_size, bool *right_justify,
char **suffix)
{
char *ptr;
char *end_ptr = NULL, *ptr;

xassert(token);
ptr = strchr(token, ':');
Expand All @@ -1261,7 +1261,9 @@ _parse_long_token( char *token, char *sep, int *field_size, bool *right_justify,
} else {
*right_justify = false;
}
*field_size = atoi(ptr + 1);
*field_size = strtol(ptr + 1, &end_ptr, 10);
if (end_ptr[0] != '\0')
*suffix = xstrdup(end_ptr);
} else {
*right_justify = false;
*field_size = 20;
Expand Down
6 changes: 4 additions & 2 deletions src/squeue/opts.c
Original file line number Diff line number Diff line change
Expand Up @@ -1787,7 +1787,7 @@ static void
_parse_long_token( char *token, char *sep, int *field_size, bool *right_justify,
char **suffix)
{
char *ptr;
char *end_ptr = NULL, *ptr;

xassert(token);
ptr = strchr(token, ':');
Expand All @@ -1799,7 +1799,9 @@ _parse_long_token( char *token, char *sep, int *field_size, bool *right_justify,
} else {
*right_justify = false;
}
*field_size = atoi(ptr + 1);
*field_size = strtol(ptr + 1, &end_ptr, 10);
if (end_ptr[0] != '\0')
*suffix = xstrdup(end_ptr);
} else {
*right_justify = false;
*field_size = 20;
Expand Down

0 comments on commit 9ea6c94

Please sign in to comment.