From 42dba39aef5d927cdbbf21ad3252a770e6de7e31 Mon Sep 17 00:00:00 2001 From: Olaf Barthel Date: Fri, 15 Sep 2006 06:58:17 +0000 Subject: [PATCH] - Added a new callback function which can be used in programs which want to avoid that the command line wildcard expansion takes place. git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15132 87f5fb63-7c3d-0410-a384-fd976d0f7a62 --- library/GNUmakefile.68k | 3 +- library/GNUmakefile.os4 | 3 +- library/changes | 5 +++- library/include/dos.h | 13 ++++++++- library/stdlib_arg.c | 19 ++++++++++-- library/stdlib_expand_wildcard_check.c | 40 ++++++++++++++++++++++++++ 6 files changed, 76 insertions(+), 7 deletions(-) create mode 100644 library/stdlib_expand_wildcard_check.c diff --git a/library/GNUmakefile.68k b/library/GNUmakefile.68k index fe9e372..66b607f 100644 --- a/library/GNUmakefile.68k +++ b/library/GNUmakefile.68k @@ -1,5 +1,5 @@ # -# $Id: GNUmakefile.68k,v 1.94 2006-08-06 08:31:05 obarthel Exp $ +# $Id: GNUmakefile.68k,v 1.95 2006-09-15 06:58:16 obarthel Exp $ # # :ts=8 # @@ -496,6 +496,7 @@ UNIX_LIB = \ stdlib_alloca_trap.o \ stdlib_arg.o \ stdlib_expand_wildcard.o \ + stdlib_expand_wildcard_check.o \ stdlib_getmemstats.o \ stdlib_main.o \ stdlib_main_stub.o \ diff --git a/library/GNUmakefile.os4 b/library/GNUmakefile.os4 index b7820d3..52985b0 100644 --- a/library/GNUmakefile.os4 +++ b/library/GNUmakefile.os4 @@ -1,5 +1,5 @@ # -# $Id: GNUmakefile.os4,v 1.107 2006-08-06 08:31:05 obarthel Exp $ +# $Id: GNUmakefile.os4,v 1.108 2006-09-15 06:58:16 obarthel Exp $ # # :ts=8 # @@ -538,6 +538,7 @@ UNIX_LIB = \ stdlib_alloca_trap.o \ stdlib_arg.o \ stdlib_expand_wildcard.o \ + stdlib_expand_wildcard_check.o \ stdlib_getmemstats.o \ stdlib_main.o \ stdlib_main_stub.o \ diff --git a/library/changes b/library/changes index 9a39adf..45bbbcd 100644 --- a/library/changes +++ b/library/changes @@ -1,9 +1,12 @@ -- updated m68k specs file in /documentation to contain an own __CLIB2__ +- Updated m68k specs file in /documentation to contain an own __CLIB2__ define so that existing m68k compilers also have this define. In addition, the common "-noixemul" option can now also be specified but will do a NOP so that Makefiles sharing multiple runtime lib setups work without a warning. +- Added a new callback function which can be used in programs which want + to avoid that the command line wildcard expansion takes place. + - __get_default_file() now dynamically fills in file handles for the stdin/stdout/stderr streams if it's part of the thread-safe library. diff --git a/library/include/dos.h b/library/include/dos.h index f40ff36..bf83f08 100644 --- a/library/include/dos.h +++ b/library/include/dos.h @@ -1,5 +1,5 @@ /* - * $Id: dos.h,v 1.24 2006-08-06 08:15:42 obarthel Exp $ + * $Id: dos.h,v 1.25 2006-09-15 06:58:17 obarthel Exp $ * * :ts=4 * @@ -487,6 +487,17 @@ extern BOOL __thread_safe_errno_h_errno; */ extern BOOL __expand_wildcard_args; +/* + * Similar to the boolean flag value __expand_wildcard_args described above, + * a function can be called which may be used to enable/disable wildcard + * expansion at runtime. The function is undefined by default, which means + * that the __expand_wildcard_args value will take precedence. If you want + * to override the effects of the __expand_wildcard_args variable, declare + * your own check function and then assign it to the + * __expand_wildcard_args_check pointer. + */ +extern BOOL (*__expand_wildcard_args_check)(void); + /****************************************************************************/ /* diff --git a/library/stdlib_arg.c b/library/stdlib_arg.c index ffaa59a..b774244 100644 --- a/library/stdlib_arg.c +++ b/library/stdlib_arg.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_arg.c,v 1.11 2006-05-04 08:01:47 obarthel Exp $ + * $Id: stdlib_arg.c,v 1.12 2006-09-15 06:58:16 obarthel Exp $ * * :ts=4 * @@ -121,12 +121,25 @@ ARG_CONSTRUCTOR(arg_init) /* Shell startup? */ if(__WBenchMsg == NULL) { + BOOL expand_wildcard_args; size_t number_of_arguments; unsigned char * arg_str; size_t arg_len; unsigned char * command_line; unsigned char * str; + /* Check if wildcard expansion of command line parameters + should be enabled. Note that the callback function, if + declared, takes precedence over the global variable. */ + #if defined(UNIX_PATH_SEMANTICS) + { + expand_wildcard_args = __expand_wildcard_args; + + if(__expand_wildcard_args_check != NULL) + expand_wildcard_args = (*__expand_wildcard_args_check)(); + } + #endif /* UNIX_PATH_SEMANTICS */ + /* Get the shell parameter string and find out how long it is, stripping a trailing line feed and blank spaces if necessary. */ @@ -234,7 +247,7 @@ ARG_CONSTRUCTOR(arg_init) #if defined(UNIX_PATH_SEMANTICS) { /* If necessary, indicate that this parameter was quoted. */ - if(__expand_wildcard_args && __wildcard_quote_parameter(__argc) < 0) + if(expand_wildcard_args && __wildcard_quote_parameter(__argc) < 0) goto out; } #endif /* UNIX_PATH_SEMANTICS */ @@ -319,7 +332,7 @@ ARG_CONSTRUCTOR(arg_init) { /* If necessary, expand wildcard patterns found in the command line string into file and directory names. */ - if(__expand_wildcard_args && __wildcard_expand_init() < 0) + if(expand_wildcard_args && __wildcard_expand_init() < 0) goto out; } #endif /* UNIX_PATH_SEMANTICS */ diff --git a/library/stdlib_expand_wildcard_check.c b/library/stdlib_expand_wildcard_check.c new file mode 100644 index 0000000..6f25126 --- /dev/null +++ b/library/stdlib_expand_wildcard_check.c @@ -0,0 +1,40 @@ +/* + * $Id: stdlib_expand_wildcard_check.c,v 1.1 2006-09-15 06:58:16 obarthel Exp $ + * + * :ts=4 + * + * Portable ISO 'C' (1994) runtime library for the Amiga computer + * Copyright (c) 2002-2006 by Olaf Barthel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Neither the name of Olaf Barthel nor the names of contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _STDLIB_HEADERS_H +#include "stdlib_headers.h" +#endif /* _STDLIB_HEADERS_H */ + +/****************************************************************************/ + +BOOL (*__expand_wildcard_args_check)(void);