~exec64/imv-devel

imv: title_text: remove trailing whitespace typo v1 PROPOSED

Johannes Knoll: 1
 title_text: remove trailing whitespace typo

 1 files changed, 1 insertions(+), 1 deletions(-)
#669324 fedora.yml success
#669325 debian.yml success
#669326 ubuntu.yml success
#669327 archlinux.yml success
> Thanks for the patch, though this isn't actually a typo. The
> whitespace here is re-inserting the separator between each word after
> the word has been expanded.
Since we set IFS variable above to "", I think the whole for loop will
execute no more than once. Wordexp won't separate the expansion result
into words and will keep all the whitespace intact.

So I think the proposed patch will work correctly, but this piece of
code still needs to be modified for readability: the for loop can make
one think it can be executed multiple times. We could do something like
this in place of for loop to show that the we_wordc is always 0 or 1:

assert(word.we_wordc <= 1); // or replace assert by a comment
if (word.we_wordc == 1) {
  strncpy(buf, word.we_wordv[0], buf_len);
} else {
  buf[0] = '\0';
}

What do you think?
I was wrong, the IFS='' still produces multiple words. I'll send a new
patch that removes the trailing whitespace preserving the spaces between
the words.
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~exec64/imv-devel/patches/28160/mbox | git am -3
Learn more about email & git

[PATCH imv] title_text: remove trailing whitespace typo Export this patch

src/imv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/imv.c b/src/imv.c
index 8380a12..0f52df8 100644
--- a/src/imv.c
+++ b/src/imv.c
@@ -2002,7 +2002,7 @@ static size_t generate_env_text(struct imv *imv, char *buf, size_t buf_len, cons
  setenv("IFS", "", 1);
  if (wordexp(format, &word, 0) == 0) {
    for (size_t i = 0; i < word.we_wordc; ++i) {
      len += snprintf(buf + len, buf_len - len, "%s ", word.we_wordv[i]);
      len += snprintf(buf + len, buf_len - len, "%s", word.we_wordv[i]);
    }
    wordfree(&word);
  } else {
imv/patches: SUCCESS in 3m59s

[title_text: remove trailing whitespace typo][0] from [Johannes Knoll][1]

[0]: https://lists.sr.ht/~exec64/imv-devel/patches/28160
[1]: mailto:Johannes.Knoll@hs-augsburg.de

✓ #669326 SUCCESS imv/patches/ubuntu.yml    https://builds.sr.ht/~exec64/job/669326
✓ #669324 SUCCESS imv/patches/fedora.yml    https://builds.sr.ht/~exec64/job/669324
✓ #669325 SUCCESS imv/patches/debian.yml    https://builds.sr.ht/~exec64/job/669325
✓ #669327 SUCCESS imv/patches/archlinux.yml https://builds.sr.ht/~exec64/job/669327
Hi Johannes,

Thanks for the patch, though this isn't actually a typo. The whitespace 
here is re-inserting the separator between each word after the word has 
been expanded. This does result in an extra whitespace at the end of the 
output, which could be addressed, but we do still need to keep the 
whitespace between words.

Harry

On 2022-01-11 11:54, Johannes Knoll wrote: