diff options
author | Pierre Ossman <ossman@cendio.se> | 2025-03-06 11:23:11 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2025-03-13 17:13:59 +0100 |
commit | 6730ff9d1ae6792b8d50e86fd90d7e44ce13bb42 (patch) | |
tree | a6cb11f5f518f229f047a972a4e15502db63374e | |
parent | b7130138513ffca4fca53178a3740ab4a6d13228 (diff) | |
download | tigervnc-6730ff9d1ae6792b8d50e86fd90d7e44ce13bb42.tar.gz tigervnc-6730ff9d1ae6792b8d50e86fd90d7e44ce13bb42.zip |
Also split help output lines on comma
This is needed when we have very long defaults for list parameters.
Note that the logic gets a bit more convoluted as we want to keep the
comma with the word, unlike the whitespace.
-rw-r--r-- | common/core/Configuration.cxx | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/common/core/Configuration.cxx b/common/core/Configuration.cxx index 5a4bf121..129d1b9e 100644 --- a/common/core/Configuration.cxx +++ b/common/core/Configuration.cxx @@ -91,17 +91,28 @@ void Configuration::list(int width, int nameWidth) { if (column < nameWidth) column = nameWidth; column += 4; while (true) { - int wordLen = strcspn(desc, " \f\n\r\t\v"); + if (desc[0] == '\0') + break; + + int wordLen = strcspn(desc, " \f\n\r\t\v,"); + if (wordLen == 0) { + desc++; + continue; + } + + if (desc[wordLen] == ',') + wordLen++; if (column + wordLen + 1 > width) { fprintf(stderr,"\n%*s",nameWidth+4,""); column = nameWidth+4; } - fprintf(stderr," %.*s",wordLen,desc); - if (desc[wordLen] == '\0') - break; - column += wordLen + 1; - desc += wordLen + 1; + fprintf(stderr, " "); + column++; + + fprintf(stderr, "%.*s", wordLen, desc); + column += wordLen; + desc += wordLen; } fprintf(stderr,"\n"); } |