help-gengetopt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [help-gengetopt] cmdline_file_save accepts file handler instead


From: Papp Gyozo (VBuster)
Subject: Re: [help-gengetopt] cmdline_file_save accepts file handler instead
Date: Tue, 30 Oct 2007 18:32:29 +0100

Hi,

> >> that would be a very nice compromise: this way " is still use to
> >> (optionally) enclose arguments, and if " is part of the argument it
> >> should be escaped.  While ' can be used as it is (which is what you
> >> need, I seem to understand).
> 
> so are you working on this modified patch?

Yes, I think it is actually quite simple (follow where > missing from the 
beginning of the line):

> @@ -574,8 +572,11 @@
>              }
>          }
>        else
> -        { /* read up the remaining part up to a delimiter */
> -          next_token = strcspn (farg, " \t\r\n#\'\"");
> +        { /* read up the remaining part up to end of line or comment sign */
  +          char *ch = (str_index + (next_token = strcspn (farg, "\r\n\"#")));
> +          /* remove trailing whitespaces */
> +          for ( --ch; (*ch >= 0x09 && *ch <= 0x0D) || *ch == ' '; --ch )
> +            --next_token;
>            str_index += next_token;
>          }

Changes (against what you can see in CVS)  in brief:
- allow ' ', '\t' and '\'' in option value, that is,
- those are removed from the strcspn's character set.
- adjust str_index and next_token after removing trailing whitespaces

So if we disallow '"' then strcspn above stops on the first ", so strings like 
mal"formed will be malformed again. Please note this code is activated only if 
the value starts with neither ' nor ".




reply via email to

[Prev in Thread] Current Thread [Next in Thread]