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: Lorenzo Bettini
Subject: Re: [help-gengetopt] cmdline_file_save accepts file handler instead
Date: Wed, 31 Oct 2007 11:08:22 +0100
User-agent: Thunderbird 2.0.0.6 (X11/20071022)

Papp Gyozo (VBuster) wrote:
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 ".


Hi

sorry, I'm not sure I understood which is the correct patch...

--
Lorenzo Bettini, PhD in Computer Science, DSI, Univ. di Firenze
ICQ# lbetto, 16080134     (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com  http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net




reply via email to

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