From 3d58795d0f16afecf974fae600c2377bce027234 Mon Sep 17 00:00:00 2001 From: Olaf Barthel Date: Sun, 26 Jun 2005 10:23:05 +0000 Subject: [PATCH] - Repaired the pattern matching code which expands command line arguments: it no longer requires that any parameters are quoted and it is automatically enabled if you link against libunix.a, without libc.a standing a chance to accidentally override it. git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14990 87f5fb63-7c3d-0410-a384-fd976d0f7a62 --- library/GNUmakefile.68k | 4 ++-- library/GNUmakefile.os4 | 4 ++-- library/changes | 5 +++++ library/stdlib_arg.c | 24 ++++++++++++++++-------- library/unistd_wildcard_expand.c | 13 ++++++++----- 5 files changed, 33 insertions(+), 17 deletions(-) diff --git a/library/GNUmakefile.68k b/library/GNUmakefile.68k index 1227e29..6415e1f 100644 --- a/library/GNUmakefile.68k +++ b/library/GNUmakefile.68k @@ -1,5 +1,5 @@ # -# $Id: GNUmakefile.68k,v 1.63 2005-06-26 09:06:09 obarthel Exp $ +# $Id: GNUmakefile.68k,v 1.64 2005-06-26 10:23:05 obarthel Exp $ # # :ts=8 # @@ -362,7 +362,6 @@ C_LIB = \ stdlib_udivsi4.o \ stdlib_umodsi3.o \ stdlib_unsetenv.o \ - stdlib_wildcard_expand.o \ strings_ffs.o \ strings_strcasecmp.o \ strings_strncasecmp.o \ @@ -483,6 +482,7 @@ UNIX_LIB = \ stdio_record_locking.o \ stdio_remove.o \ stdio_rename.o \ + stdlib_arg.o \ stdlib_main.o \ stdlib_mkdtemp.o \ stdlib_mkstemp.o \ diff --git a/library/GNUmakefile.os4 b/library/GNUmakefile.os4 index 035d798..03af0ca 100644 --- a/library/GNUmakefile.os4 +++ b/library/GNUmakefile.os4 @@ -1,5 +1,5 @@ # -# $Id: GNUmakefile.os4,v 1.69 2005-06-26 09:06:10 obarthel Exp $ +# $Id: GNUmakefile.os4,v 1.70 2005-06-26 10:23:05 obarthel Exp $ # # :ts=8 # @@ -373,7 +373,6 @@ C_LIB = \ stdlib_udivsi4.o \ stdlib_umodsi3.o \ stdlib_unsetenv.o \ - stdlib_wildcard_expand.o \ strings_ffs.o \ strings_strcasecmp.o \ strings_strncasecmp.o \ @@ -495,6 +494,7 @@ UNIX_LIB = \ stdio_record_locking.o \ stdio_remove.o \ stdio_rename.o \ + stdlib_arg.o \ stdlib_main.o \ stdlib_mkdtemp.o \ stdlib_mkstemp.o \ diff --git a/library/changes b/library/changes index 5f8cd5e..fd7c32f 100644 --- a/library/changes +++ b/library/changes @@ -21,6 +21,11 @@ it with a backtick ("`"), which is the wildcard pattern escape character used on AmigaOS. +- Repaired the pattern matching code which expands command line arguments: + it no longer requires that any parameters are quoted and it is automatically + enabled if you link against libunix.a, without libc.a standing a chance to + accidentally override it. + c.lib 1.193 (4.6.2005) diff --git a/library/stdlib_arg.c b/library/stdlib_arg.c index e77ba70..ca72c17 100644 --- a/library/stdlib_arg.c +++ b/library/stdlib_arg.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_arg.c,v 1.6 2005-03-18 12:38:23 obarthel Exp $ + * $Id: stdlib_arg.c,v 1.7 2005-06-26 10:23:05 obarthel Exp $ * * :ts=4 * @@ -231,9 +231,13 @@ ARG_CONSTRUCTOR(arg_init) { char * arg; - /* If necessary, indicate that this parameter was quoted. */ - if(__wildcard_quote_parameter(__argc) < 0) - goto out; + #if defined(UNIX_PATH_SEMANTICS) + { + /* If necessary, indicate that this parameter was quoted. */ + if(__wildcard_quote_parameter(__argc) < 0) + goto out; + } + #endif /* UNIX_PATH_SEMANTICS */ str++; @@ -311,10 +315,14 @@ ARG_CONSTRUCTOR(arg_init) __argv[__argc] = NULL; - /* If necessary, expand wildcard patterns found in the command - line string into file and directory names. */ - if(__wildcard_expand_init() < 0) - goto out; + #if defined(UNIX_PATH_SEMANTICS) + { + /* If necessary, expand wildcard patterns found in the command + line string into file and directory names. */ + if(__wildcard_expand_init() < 0) + goto out; + } + #endif /* UNIX_PATH_SEMANTICS */ } else { diff --git a/library/unistd_wildcard_expand.c b/library/unistd_wildcard_expand.c index 61a4071..dffe8d3 100644 --- a/library/unistd_wildcard_expand.c +++ b/library/unistd_wildcard_expand.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_wildcard_expand.c,v 1.13 2005-06-26 09:57:52 obarthel Exp $ + * $Id: unistd_wildcard_expand.c,v 1.14 2005-06-26 10:23:05 obarthel Exp $ * * :ts=4 * @@ -173,7 +173,7 @@ __wildcard_expand_init(void) old_window_pointer = __set_process_window((APTR)-1); /* No work to be done? */ - if(quote_vector == NULL || __argc == 0 || __argv == NULL) + if(__argc == 0 || __argv == NULL) { error = OK; goto out; @@ -230,7 +230,7 @@ __wildcard_expand_init(void) match_made = FALSE; /* Check if the string is quoted. Quoted strings are never expanded. */ - if(i > 0 && (quote_vector[i / 8] & (1 << (7 - (i % 8)))) == 0) + if(i > 0 && (quote_vector == NULL || (quote_vector[i / 8] & (1 << (7 - (i % 8)))) == 0)) { size_t arg_len,star_count,j; char last_c; @@ -505,8 +505,11 @@ __wildcard_expand_init(void) if(replacement_arg != NULL) free(replacement_arg); - free(quote_vector); - quote_vector = NULL; + if(quote_vector != NULL) + { + free(quote_vector); + quote_vector = NULL; + } quote_vector_size = 0;