From 8b7d2475bb90289c47e0597365988b9a49aac602 Mon Sep 17 00:00:00 2001 From: David Shaw Date: Fri, 3 May 2002 13:20:00 +0000 Subject: [PATCH] * argparse.c (optfile_parse): Remove quotes only if they totally enclose the string, and do not occur within the string. This makes specifying a program under Win32 easier when you need quotes around part of a string, but not around the whole string. --- util/ChangeLog | 7 +++++++ util/argparse.c | 17 +++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/util/ChangeLog b/util/ChangeLog index aad8eb107..f70bf0a1e 100644 --- a/util/ChangeLog +++ b/util/ChangeLog @@ -1,3 +1,10 @@ +2002-05-03 David Shaw + + * argparse.c (optfile_parse): Remove quotes only if they totally + enclose the string, and do not occur within the string. This + makes specifying a program under Win32 easier when you need quotes + around part of a string, but not around the whole string. + 2002-05-02 Werner Koch * memory.c (alloc): Malloc at least 1 byte. Noted by Winona Brown. diff --git a/util/argparse.c b/util/argparse.c index 8d54de9da..c3cc3d709 100644 --- a/util/argparse.c +++ b/util/argparse.c @@ -327,10 +327,19 @@ optfile_parse( FILE *fp, const char *filename, unsigned *lineno, trim_spaces( buffer ); p = buffer; - if( *p == '"' ) { /* remove quotes */ - p++; - if( *p && p[strlen(p)-1] == '"' ) - p[strlen(p)-1] = 0; + /* remove quotes if they totally enclose the + string, and do not occur within the string */ + if( *p == '"' && p[strlen(p)-1]=='"') { + char *i=p; + + while(*(++i)) + if(*i=='"') + break; + + if(*i=='"' && *(i+1)=='\0') { + p[strlen(p)-1] = 0; + p++; + } } if( !set_opt_arg(arg, opts[idx].flags, p) ) m_free(buffer);