Age | Commit message (Collapse) | Author | Files | Lines |
|
|
|
You are right, this is also a remnant of the old function design
that I completely missed. Here is the follow-up patch for that.
Thanks for pointing it out.
Costas
On Tue, 6 Jun 2023 at 04:12, Jeff Law <jeffreyalaw@gmail.com> wrote:
On 6/5/23 08:37, Costas Argyris via Gcc-patches wrote:
> writeargv can be simplified by getting rid of the error exit mode
> that was only relevant many years ago when the function used
> to open the file descriptor internally.
[ ... ]
Thanks. I've pushed this to the trunk.
You could (as a follow-up) simplify it even further. There's no need
for the status variable as far as I can tell. You could just have the
final return be "return 0;" instead of "return status;".
libiberty/
* argv.c (writeargv): Constant propagate "0" for "status",
simplifying the code slightly.
|
|
writeargv can be simplified by getting rid of the error exit mode
that was only relevant many years ago when the function used
to open the file descriptor internally.
0001-libiberty-writeargv-Simplify-function-error-mode.patch
From 1271552baee5561fa61652f4ca7673c9667e4f8f Mon Sep 17 00:00:00 2001
From: Costas Argyris <costas.argyris@gmail.com>
Date: Mon, 5 Jun 2023 15:02:06 +0100
Subject: [PATCH] libiberty: writeargv: Simplify function error mode.
The goto-based error mode was based on a previous version
of the function where it was responsible for opening the
file, so it had to close it upon any exit:
https://inbox.sourceware.org/gcc-patches/20070417200340.GM9017@sparrowhawk.codesourcery.com/
(thanks pinskia)
This is no longer the case though since now the function
takes the file descriptor as input, so the exit mode on
error can be just a simple return 1 statement.
libiberty/
* argv.c (writeargv): Simplify & remove gotos.
Signed-off-by: Costas Argyris <costas.argyris@gmail.com>
|
|
|
|
|
|
libiberty:
* argv.c (expandargv): free allocated buffer if read fails.
|
|
|
|
writeargv writes out empty arguments in a way that expandargv skips
them instead of preserving them. Fixed by writing out a pair of
quotes for them.
for libiberty/ChangeLog
* argv.c (writeargv): Output empty args as "".
|
|
From-SVN: r279813
|
|
From-SVN: r267494
|
|
* argv.c (expandargv): Fix memory leak for expanded
arguments.
From-SVN: r259775
|
|
2018-01-10 Daniel van Gerpen <daniel@vangerpen.de>
* argv.c (expandargv): Correct check for dynamically
allocated argv.
From-SVN: r256460
|
|
From-SVN: r256169
|
|
From-SVN: r244052
|
|
From-SVN: r243280
|
|
Would be more useful if we could use "const char * const *", but there's
a long standing bug where gcc warns about incompatible pointers when you
try to pass in "char **". We can at least constify the array itself as
gcc will not warn in that case.
From-SVN: r232089
|
|
This func is basically open coding the xstrdup function, so gut it
and use that directly.
From-SVN: r232086
|
|
* argv.c (dupargv): Replace malloc with xmalloc. Don't check
xmalloc return.
(buildargv): Likewise. Also replace strdup with xstrdup.
(expandargv): Don't check dupargv return.
From-SVN: r190767
|
|
PR binutils/14526
* argv.c (buildargv): Replace alloca with xmalloc/free.
From-SVN: r190766
|
|
include/
* libiberty.h (countargv): Declare.
libiberty/
* argv.c (countargv): New function.
From-SVN: r179318
|
|
opened in order to prevent...
* argv.c (expandargv): Limit the number of times that response
files are opened in order to prevent infinite recursion.
From-SVN: r163222
|
|
2009-10-08 Daniel Gutson <dgutson@codesourcery.com>
Daniel Jacobowitz <dan@codesourcery.com>
Pedro Alves <pedro@codesourcery.com>
libiberty/
* argv.c (consume_whitespace): New function.
(only_whitespace): New function.
(buildargv): Always use ISSPACE by calling consume_whitespace.
(expandargv): Skip empty files. Do not stop at the first empty
argument (calling only_whitespace)..
* testsuite/test-expandargv.c: (test_data): Test empty lines
and empty arguments.
(run_tests): Fix false positives due to shorter arguments.
Co-Authored-By: Daniel Jacobowitz <dan@codesourcery.com>
Co-Authored-By: Pedro Alves <pedro@codesourcery.com>
From-SVN: r152560
|
|
* argv.c (writeargv): Fix typo in inline documentation.
* functions.texi: Regenerate.
From-SVN: r126855
|
|
2007-07-02 Simon Baldwin <simonb@google.com>
* argv.c (writeargv): Removed declaration of unused variable.
From-SVN: r126217
|
|
include/
2007-05-07 Nathan Froyd <froydnj@codesourcery.com>
* libiberty.h (writeargv): Declare.
libiberty/
2007-05-07 Nathan Froyd <froydnj@codesourcery.com>
* argv.c (writeargv): New function.
gcc/
2007-05-07 Nathan Froyd <froydnj@codesourcery.com>
* gcc.c (at_file_supplied): New variable.
(main): Set it if we expanded argv.
(do_spec_1): Pass an @-file to the linker if we were called with
an @-file argument and HAVE_GNU_LD.
* collect2.c (at_file_supplied): New variable.
(response_file): New variable.
(collect_exit): Unlink response_file if necessary.
(handler): Likewise.
(do_wait): Likewise.
(main): Set at_file_supplied if we expanded argv.
(collect_execute): Pass an @-file to subprocesses if we were called
with an @-file argument.
* configure.ac: Add define for HAVE_GNU_LD.
* configure: Regenerate.
* config.in: Regenerate.
From-SVN: r124532
|
|
* argv.c: Use ANSI C declarations.
* make-relative-prefix.c: Likewise.
From-SVN: r123722
|
|
libiberty/
2006-01-20 Carlos O'Donell <carlos@codesourcery.com>
* testsuite/Makefile.in: Add test-expandargv test.
* testsuite/test-expandargv.c: New test.
* argv.c (expandargv): Check for errors with ferror,
rather than just by looking at return value from fread.
From-SVN: r110047
|
|
From-SVN: r104695
|
|
* libiberty.h (expandargv): New function.
* argv.c (safe-ctype.h): Include it.
(ISBLANK): Remove.
(stdio.h): Include.
(buildargv): Use ISSPACE instead of ISBLANK.
(expandargv): New function.
From-SVN: r104664
|
|
From-SVN: r99519
|
|
* asprintf.c: Include config.h.
* basename.c: Likewise.
* fdmatch.c: Likewise.
* hex.c: Likewise.
* lbasename.c: Likewise.
* spaces.c: Likewise.
* xatexit.c:Likewise.
* configure.ac: Do check declarations for basename, ffs, asprintf
and vasprintf for real.
* configure: Regenerate.
From-SVN: r98218
|
|
amuont.
* argv.c (dupargv): Mallocate space of argv[argc], not
sizeof(char *) of that amuont. Cast result to char *.
From-SVN: r98083
|
|
include/
2005-03-26 Gabriel Dos Reis <gdr@integrable-solutions.net>
* demangle.h: Remove uses of PARAMS.
* libiberty.h (ANSI_PROTOTYPES): Remove guard since
ANSI_PROTOTYPES is always assumed.
Remove uses of PARAMS throughout.
libiberty/
2005-03-26 Gabriel Dos Reis <gdr@integrable-solutions.net>
Convert libiberty to use ISO C prototype style 2/n.
* cp-demangle.h: Remove uses of PARAMS.
* cp-demangle.c: Likewise.
(d_dump, cplus_demangle_fill_name,
cplus_demangle_fill_extended_operator,
cplus_demangle_fill_ctor,
cplus_demangle_fill_dtor, d_make_empty, d_make_comp,
d_make_name,
d_make_builtin_type, d_make_operator,
d_make_extended_operator,
d_make_ctor, d_make_dtor, d_make_template_param, d_make_sub,
cplus_demangle_mangled_name, has_return_type,
is_ctor_dtor_or_conversion, d_encoding, d_name, d_nested_name,
d_prefix, d_unqualified_name, d_source_name, d_number,
d_identifier, d_operator_name, d_special_name, d_call_offset,
d_ctor_dtor_name, cplus_demangle_type, d_cv_qualifiers,
d_function_type, d_bare_function_type, d_class_enum_type,
d_array_type, d_pointer_to_member_type, d_template_param,
d_template_args, d_template_arg, d_expression, d_expr_primary,
d_local_name, d_discriminator, d_add_substitution,
d_substitution, d_print_resize, d_print_append_char,
d_print_append_buffer, d_print_error, cplus_demangle_print,
d_print_comp, d_print_java_identifier, d_print_mod_list,
d_print_mod, d_print_function_type, d_print_array_type,
d_print_expr_op, d_print_cast, cplus_demangle_init_info,
d_demangle, __cxa_demangle, cplus_demangle_v3,
java_demangle_v3,
is_ctor_or_dtor, is_gnu_v3_mangled_ctor,
is_gnu_v3_mangled_dtor,
print_usage, main):
2005-03-26 Gabriel Dos Reis <gdr@integrable-solutions.net>
Convert libiberty to ISO C prototype style 1/n.
* _doprnt.c: Remove conditional #include <varargs.h> on
ANSI_PROTOTYPES as the latter is always assumed.
(_doprnt, checkit, main): Use ISO C prototype.
* alloca.c (find_stack_direction, C_alloca): Use ISO C
prototype.
* argv.c: Remove conditional #includes on ANSI_PROTOTYPES.
(dupargv, freeargv, buildargv, main): Use ISO C prototype.
* atexit.c (atexit): Likewise
* asprintf.c: Remove conditional include on ANSI_PROTOTYPES.
(asprintf): Use ISO C prototype.
* basename.c (basename): Likewise
* bcmp.c (bcmp): Likewise.
* bcopy.c (bcopy): Likewise.
* bzero.c (bzero): Likewise.
* bsearch.c (bsearch): Likewise. Improve const-correctness.
* choose-temp.c (choose_temp_base): Likewise.
* calloc.c: Remove conditional #include on ANSI_PROTOTYPES.
(calloc): Use ISO C prototype.
* clock.c (clock): Likewise.
* concat.c: Remove conditional #include on ANSI_PROTOTYPES.
(vconcat_length, vconcat_copy, concat_length, concat_copy,
concat_copy2, concat, reconcat, main): Use ISO C prototype.
* copysign.c (copysign): Likewise.
From-SVN: r97085
|
|
* argv.c: Fix comments.
* calloc.c: Don't unnecessarily include "libiberty.h".
(bzero): Add prototype.
* floatformat.c: Include "ansidecl.h", rely on ANSI_PROTOTYPES.
* getcwd.c (getcwd): Use standard definition to avoid conflicts
with system headers.
* hashtab.c (htab_traverse): Delete unused variables.
* rename.c: Include "ansidecl.h".
(rename): Use standard definition to avoid conflicts with system
headers.
* strsignal.c: Rely on ANSI_PROTOTYPES.
* strstr.c: Check GNUC >= 2, not GNUC == 2.
* vfprintf.c: Include "ansidecl.h", rely on ANSI_PROTOTYPES.
* vprintf.c: Include "ansidecl.h" earlier, rely on
ANSI_PROTOTYPES.
* vsprintf.c: Include "ansidecl.h" earlier, rely on
ANSI_PROTOTYPES and possibly include <stdarg.h>.
* Makefile.in: Regenerate dependencies.
From-SVN: r65659
|
|
* argv.c: Use ANSI_PROTOTYPES instead of __STDC__.
* memchr.c: Likewise.
* strcasecmp.c: Likewise.
* strncasecmp.c: Likewise.
* strncmp.c: Likewise.
* xatexit.c: Likewise.
* xmalloc.c: Likewise.
* copysign.c: Use traditional function declaration instead of DEFUN.
* sigsetmask.c: Likewise.
* memcmp.c: Both of the above, ANSI_PROTOTYPES and DEFUN.
* memset.c: Likewise.
* memcpy.c: ANSI_PROTOTYPES, DEFUN and prototype bcopy.
* memmove.c: Likewise.
From-SVN: r65619
|
|
* argv.c, asprintf.c, choose-temp.c, concat.c, cplus-dem.c,
ffs.c, fnmatch.txh, getruntime.c, make-temp-file.c,
mkstemps.c, pexecute.c, random.c, strsitnal.c, vasprintf.c:
Improve manual formatting.
* functions.texi: Regenerate.
From-SVN: r46323
|
|
* Makefile.in (TEXIFILES): Add fnmatch.txh.
(maint-undoc): New.
maint-tool: Add "undoc" tool.
* alloca.c, argv.c, asprintf.c, choose-temp.c, concat.c,
fdmatch.c, ffs.c, getruntime.c, insque.c, lbasename.c,
make-temp-file.c, mkstemps.c, pexecute.c, random.c, spaces.c,
strerror.s, strsignal.c, strtol.c, vasprintf.c: Add or update
documentation.
* fnmatch.txh: New.
* functions.texi: Regenerate.
From-SVN: r46274
|
|
include:
* demangle.h (demangler_engine): Const-ify.
* libiberty.h (buildargv): Likewise.
libiberty:
* argv.c (buildargv, tests, main): Const-ify.
* cp-demangle.c (operator_code): Likewise.
* cplus-dem.c (optable, libiberty_demanglers,
cplus_demangle_set_style, cplus_demangle_name_to_style,
print_demangler_list): Likewise.
* hashtab.c (higher_prime_number): Likewise.
* strcasecmp.c (charmap): Likewise.
* strerror.c (error_info, strerror, main): Likewise.
* strncasecmp.c (charmap): Likewise.
* strsignal.c (signal_info): Likewise.
From-SVN: r46060
|
|
libiberty:
* aclocal.m4 (libiberty_AC_FUNC_C_ALLOCA): New.
* configure.in: Replace all alloca logic with a simple use of
the above new macro.
* config.table: Kill *-*-beos* entry.
* config/mh-beos: Delete.
* configure, config.in: Regenerate.
* Makefile.in (ALLOCA, HFILES): Kill.
(REQUIRED_OFILES): Add alloca.o.
(alloca.o): Depend on libiberty.h.
(argv.o): Don't depend on alloca-conf.h.
* alloca-conf.h: Delete.
* alloca.c: Include libiberty.h. Kill all #ifdef emacs
blocks. Provide the C alloca unconditionally. Use PTR where
appropriate. Make i00afunc static.
* argv.c: Don't include alloca-conf.h.
include:
* libiberty.h: Prototype C_alloca; define alloca to either
__builtin_alloca or C_alloca as appropriate.
gcc:
* aclocal.m4 (AM_GNU_GETTEXT): Don't AC_REQUIRE
AC_FUNC_ALLOCA.
* configure, config.in: Regenerate.
* config.gcc: Remove references to deleted files.
* genattr.c, genattrtab.c, genextract.c, genoutput.c,
genrecog.c, rtl.c: Do not use alloca anywhere.
* Makefile.in, build-make, system.h, config/x-interix,
config/x-svr4, config/xm-interix.h, config/xm-openbsd.h,
config/alpha/xm-alpha.h, config/alpha/xm-vms.h,
config/arc/xm-arc.h, config/arm/xm-arm.h,
config/d30v/xm-d30v.h, config/dsp16xx/xm-dsp16xx.h,
config/h8300/xm-h8300.h, config/i370/x-oe,
config/i370/xm-linux.h, config/i386/x-aix, config/i386/x-beos,
config/i386/x-ncr3000, config/i386/x-sco5,
config/i386/xm-dgux.h, config/i860/x-sysv4,
config/i960/xm-i960.h, config/m32r/xm-m32r.h,
config/m68k/x-crds, config/m68k/x-dpx2, config/m68k/x-hp320,
config/m68k/x-hp320g, config/m69k/x-mot3300,
config/m68k/x-mot3300-gas, config/m68k/xm-amix.h,
config/m68k/xm-hp320.h, config/m68k/xm-m68kv.h,
config/m68k/xm-mot3300.h, config/m88k/x-dolph,
config/m88k/x-sysv4, config/m88k/x-tekXD88,
config/m88k/xm-m88k.h, config/mcore/xm-mcore.h,
config/mips/x-iris, config/mips/x-iris3,
config/mips/x-sni-svr4, config/mips/x-sysv,
config/mips/xm-iris6.h, config/mips/xm-mips.h,
config/mips/xm-nws3250v4.h, config/pa/x-hpux,
config/pa/x-pa-mpeix, config/pa/xm-pa.h,
config/pa/xm-pa64hpux.h, config/pa/xm-pahpux.h,
config/pa/xm-papro.h, config/romp/xm-romp.h,
config/rs6000/x-aix31, config/rs6000/x-aix41,
config/rs6000/x-beos, config/rs6000/x-lynx,
config/rs6000/x-mach, config/rs6000/x-rs6000,
config/rs6000/x-sysv4, config/rs6000/xm-rs6000.h,
config/rs6000/xm-sysv4.h, config/sh/xm-sh.h,
config/sparc/x-sysv4, config/sparc/xm-linux.h,
config/sparc/xm-pbd.h, config/sparc/xm-sparc.h,
config/vax/xm-vms.h: Eradicate all references to alloca and
related stuff.
* config/xm-alloca.h, config/clipper/x-clix,
config/i386/xm-sysv4.h, config/i860/x-fx2800,
config/i860/x-sysv3, config/m88k/x-sysv3,
config/sparc/xm-sol2.h, config/we32k/x-we32k: Delete
(contained only alloca related hacks).
* config/i386/xm-beos.h, config/rs6000/xm-beos.h: Just define
USE_C_ALLOCA.
From-SVN: r40259
|
|
include:
* safe-ctype.h: New file.
libiberty:
* safe-ctype.c: New file.
* Makefile.in (CFILES): Add safe-ctype.c.
(REQUIRED_OFILES): Add safe-ctype.o.
* argv.c: Define ISBLANK and use it, not isspace.
* basename.c, cplus-dem.c, fnmatch.c, pexecute.c, strtod.c,
strtol.c, strtoul.c: Include safe-ctype.h, not ctype.h. Use
uppercase ctype macros. Don't test ISUPPER(c)/ISLOWER(c)
before calling TOLOWER(c)/TOUPPER(c).
gcc:
* Makefile.in (HOST_RTL): Add safe-ctype.o.
(safe-ctype.o): New rule.
* system.h: Include safe-ctype.h, not ctype.h. No need to
wrap ctype macros.
* cpphash.h: Zap IStable and related macros. Define is_* in
terms of safe-ctype.h macros.
* cppinit.c: Delete the IStable and all related code.
* tradcpp.c: Delete is_idchar, is_idstart, is_hor_space, and
is_space arrays. Delete initialize_char_syntax. Change all
references to the above arrays to use macros instead.
* tradcpp.h: Define is_idchar, is_idstart, is_space, and
is_nvspace in terms of safe_ctype.h's macros.
* tradcif.y: is_idchar, is_idstart are macros not arrays.
* config/i370/i370.c, config/winnt/dirent.c,
config/winnt/fixinc-nt.c, config/winnt/ld.c:
Use uppercase ctype macros. If we included ctype.h,
include safe-ctype.h instead.
* fixinc/fixfixes.c: Use uppercase ctype macros. Don't test
ISLOWER(c) before calling TOUPPER(c).
* fixinc/fixincl.c (extract_quoted_files): Simplify out some gunk.
* fixinc/gnu-regex.c: Include safe-ctype.h, not ctype.h. No need to
wrap ctype macros. Don't test ISUPPER(x) before calling TOLOWER(x).
gcc/ch:
* lex.c: Don't bother checking whether ISUPPER(c) before
calling TOLOWER(c). Don't bother checking whether isascii(c)
before testing ISSPACE(c); ISSPACE(c) includes '\n'.
gcc/f:
* Make-lang.in: Link f/fini with safe-ctype.o.
* bad.c: Don't test ISUPPER(c) || ISLOWER(c) before calling TOUPPER(c).
* com.c: Use TOUPPER, not ffesrc_toupper.
* fini.c: Don't test ISALPHA(c) before calling TOUPPER(c)/TOLOWER(c).
* intrin.c: Don't test IN_CTYPE_DOMAIN(c).
* src.c: Delete ffesrc_toupper_ and ffesrc_tolower_ and their
initializing code; use TOUPPER and TOLOWER instead of
ffesrc_toupper and ffesrc_tolower.
* src.h: Don't declare ffesrc_toupper_ or ffesrc_tolower_.
Don't define ffesrc_toupper or ffesrc_tolower.
gcc/java:
* jvgenmain.c: Use ISPRINT not isascii.
From-SVN: r38124
|
|
* argv.c: Include stdlib.h and string.h instead of
prototyping directly.
* choose-temp.c: Conditionally include string.h.
From-SVN: r28099
|
|
* argv.c (buildargv): Cast the result of alloca in assignment.
* choose-temp.c: Include stdlib.h.
* cplus-dem.c (demangle_arm_pt): Remove unused prototype.
(snarf_numeric_literal): Constify first parameter.
(code_for_qualifier): Avoid a gcc extension, make the parameter an
int, not a char.
(demangle_qualifier): Likewise.
(demangle_signature): Cast the argument of a ctype function to
unsigned char.
(arm_pt): Add parens around assignment used as truth value.
(demangle_arm_hp_template): Constify variable `args'.
(do_hpacc_template_const_value): Cast the argument of a ctype
function to unsigned char.
(do_hpacc_template_literal): Remove unused variable `i'.
(snarf_numeric_literal): Constify parameter `args'.
Cast the argument of a ctype function to unsigned char.
* floatformat.c (floatformat_to_double): Add explicit braces to
avoid ambiguous `else'.
* fnmatch.c (fnmatch): Change type of variables `c', `c1',
`cstart' and `cend' to unsigned char. Cast the argument of macro
`FOLD', which uses ctype functions, to unsigned char.
* objalloc.c (free): Add prototype.
From-SVN: r24392
|
|
From-SVN: r19601
|
|
Tue Oct 14 12:01:00 1997 Mark Mitchell <mmitchell@usa.net>
* cplus-dem.c (demangle_signature): Don't look for return types on
constructors. Handle member template constructors.
and update from devo.
From-SVN: r15901
|
|
From-SVN: r14877
|