lib/quotearg.c


Log

Author Commit Date CI Message
Jim Meyering 6c720446 2017-05-25T21:25:37 quotearg: fix compilation failure due to FALLTHROUGH misuse * lib/quotearg.c (quotearg_buffer_restyled): Revert one FALLTHROUGH macro back to /* fall through */ comment. The macro can apply only to a following case statement. Reported by Assaf Gordon.
Bernhard Voelker 949b6cc6 2017-05-22T12:45:45 fallthrough: reinstate a FALLTHROUGH instance in quotearg quotearg.c: Reinstate this instance which is significant when the if branch is not taken.
Jim Meyering 11fdf80b 2017-05-18T08:36:27 fallthrough: update for GCC 7/8 * lib/quotearg.c (FALLTHROUGH): New macro. Use it whenever one switch case falls through into the next, replacing "/* Fall through */" comments. This exposed one instance of an unwarranted "fall through" comment: unwarranted because it preceded a "goto" label not a case statement. * lib/freopen-safer.c (freopen_safer): Likewise. * lib/fts.c (leaf_optimization_applies): Likewise. * lib/unistr/u8-uctomb-aux.c (u8_uctomb_aux): Likewise. * tests/test-getopt_long.h (getopt_long_loop): Likewise. * tests/test-tsearch.c (mangle_tree): Likewise. Also include tests/macros.h for the definition. * tests/test-argp.c (group1_parser): Likewise. * tests/test-getopt.h (getopt_loop): Likewise.
Paul Eggert a3fd683d 2017-01-01T02:59:23 version-etc: new year * build-aux/gendocs.sh (version): * doc/gendocs_template: * doc/gendocs_template_min: * doc/gnulib.texi: * lib/version-etc.c (COPYRIGHT_YEAR): Update copyright dates by hand in templates and the like. * all files: Run 'make update-copyright'.
Paul Eggert cb4e027f 2016-12-15T09:53:45 quotearg: pacify GCC better * modules/quotearg (Depends-on): Add minmax, stdint. * lib/quotearg.c: Include minmax.h, stdint.h. (nslots): Now int, as there seems little point to going to extra work merely to support the INT_MAX slot, which nobody ever uses. (quotearg_n_options): Redo size-overflow checks to pacify GCC and to catch (mostly-theoretical) ptrdiff_t problems too. This can be done via one comparison.
Pádraig Brady 8c70d237 2016-10-18T13:00:07 quotearg: never write beyond the returned length * lib/quotearg.c (quotearg_buffer_restyled): Switch to a read-only scan of the string when we initially encounter a single quote when shell quoting, so that if we then switch to a more concise quoting method we will not have written beyond that returned length. This is significant for sh-quote, which has separate routines to determine the length and do the actual quoting. * tests/test-quotearg.h: Reinstate the buffer bounds checking now that we never write more than the returned length.
Pádraig Brady 2ed5c11d 2016-09-26T15:13:34 quotearg: minimize shell quoting using double quotes I.E. 'it'\''s awkward like this'; "it's better like this" * lib/quotearg.c (quotearg_buffer_restyled): If an ASCII single quote in encountered then use double quotes (c style quoting) when possible, as it simplifies the quoting. * tests/test-quotearg-simple.c: Add test cases. * tests/test-quotearg.h (use_quotearg_buffer): Adjust to account for the fact we now may write beyond the returned length.
Paul Eggert 71090a2a 2016-01-01T00:56:19 version-etc: new year * build-aux/gendocs.sh (version): * doc/gendocs_template: * doc/gendocs_template_min: * doc/gnulib.texi: * lib/version-etc.c (COPYRIGHT_YEAR): Update copyright dates by hand in templates and the like. * all files: Run 'make update-copyright'.
Pádraig Brady 3e4ade27 2015-11-04T23:01:25 quotearg: add quotearg_n_style_colon() This quotes with default options of the specified style, but with quoting enabled for instances of ':'. While this can be simulated by temporarily modifying the default quoting style, this is a little awkward, and care must be taken with such an implementation to avoid inlining leading to bloated text. * lib/quotearg.h (quotearg_n_style_colon): Description and declaration. * lib/quotearg.c (quotearg_n_style_colon): New function implementation.
Pádraig Brady 77d70206 2015-11-03T10:59:55 quotearg: constify get_quoting_style parameters * lib/quotearg.h (get_quoting_style): Mark parameter as const. * lib/quotearg.c (get_quoting_style): Likewise.
Pádraig Brady df3cd268 2015-10-30T22:49:16 quotearg: add support for $'' shell escaping * lib/quotearg.h: Add "shell-escape" and "shell-escape-always" items and descriptions. * lib/quotearg.c (quotearg_buffer_restyled): Add support for the above types by quoting like "shell", but using $'...' syntax for non printable characters, which should provide unambiguous printable output for any input. * tests/test-quotearg-simple.c: Update accordingly.
Paul Eggert b9bfe784 2015-01-01T01:38:23 version-etc: new year * doc/gnulib.texi: * lib/version-etc.c (COPYRIGHT_YEAR): Update copyright date. * all files: Run 'make update-copyright'.
Paul Eggert 94ee0381 2014-05-11T00:36:37 mbsstr, quotearg, xstrtol: pacify IRIX 6.5 cc These were found when building the latest grep snapshot on IRIX 6.5. * lib/mbsstr.c (knuth_morris_pratt_multibyte): Break "a=b=c;" into "b=c; a=b;", since IRIX 6.5 cc complains about the former if b is never used later. * lib/quotearg.c (quoting_options_from_style): * lib/xstrtol.c (__xstrtol): Use enum instead of 0, to pacify IRIX 6.5 cc.
Eric Blake 1276a2c5 2014-01-01T00:04:40 maint: update copyright I ran 'make update-copyright'. Signed-off-by: Eric Blake <eblake@redhat.com>
Jim Meyering 831b84c5 2013-11-18T17:35:01 quotearg: don't attempt to store 1 << 31 into an "int" * lib/quotearg.c (quotearg_buffer_restyled): Building coreutils with gcc's new -fsanitize=undefined and running its tests triggered some new test failures due to undefined behavior, all with this diagnostic: lib/quotearg.c:629:62: runtime error: left shift of 1 by 31 places \ cannot be represented in type int Rather than shifting "1" left to form a mask, shift the bits right and simply use "1" as the mask. Co-authored-by: Paul Eggert <eggert@cs.ucla.edu>
Jim Meyering 26c6620f 2013-05-11T18:43:50 quotearg: do not read beyond end of buffer * lib/quotearg.c (quotearg_buffer_restyled): Do not read beyond the end of an ARG for which no length was specified. With an N-byte quote string, (e.g., N is 3 in the fr_FR.UTF-8 locale), this function would read N-2 bytes beyond ARG's trailing NUL. This was triggered via coreutils' misc/sort-debug-keys.sh test and detected by running the test against a binary compiled with gcc-4.8.0's -fsanitize=address. * tests/test-quotearg-simple.c (main): Add a test to trigger the bug. * modules/quotearg-simple-tests (Files): Add tests/zerosize-ptr.h. Introduced via the 2000-01-15 commit, c4b7f3f8, "Quote multibyte characters correctly."
Eric Blake 9fc81090 2013-01-01T00:50:58 maint: update all copyright year number ranges Run "make update-copyright". Compare to commit 1602f0a from last year. Signed-off-by: Eric Blake <eblake@redhat.com>
Akim Demaille 0dbbe3f5 2012-11-01T06:47:03 quote: provide a means to escape strings with nul characters * lib/quote.h, lib/quotearg.c (quote_mem, quote_n_mem): New functions. (quote, quote_n): Rename formal arguments for consistency with quotearg.
Akim Demaille 64174766 2012-03-06T23:35:28 quote: fuse into quotearg This patch is made for the benefit of Bison. quote does not leave the choice of the quoting style to the user. quoting_style provides poor customizability, yet quoting_options, which is very rich, is hidden inside quotearg.c. So in order to allow quote customization, move its implementation to quotearg.c. * lib/quote.c: Remove. * modules/quote: Adjust. * lib/quotearg.c (quoting_options_from_style): Fix a compiler warning: provide all the members of literal structs. (quote_quoting_options): New. (quote, quote_n): Import implementation from quote.c. * lib/quote.h: Import the comments from quote.c. (quote_quoting_options): New.
Paolo Bonzini 1a43a982 2011-12-18T15:44:17 quotearg: do not use grave accent for left quote * lib/quotearg.c (gettext_quote): Map "`" to "'" for locale_quoting_style. (quotearg_buffer_restyled): Fix example. * tests/test-quotearg-simple.c (results_g): Adjust test vectors.
Paolo Bonzini a7b66296 2011-12-18T15:33:53 quotearg: fall back to Unicode single quotes in UTF-8 and GB-18030 locales Most programs do not have translation catalogs for English and much less separate catalogs for British and American English. Drop the suggestion to translators about these two, and provide it automatically for Unicode locales. Like most programs, even those using American English, we use single quotation marks. This conflicts with the American typographic convention, but works better when you cite the entire error message within double quotes. It also tries not to clash with established practice and with what non-gnulib programs will usually do. * lib/quotearg.c (gettext_quote): Hard-code U+2018 and U+2019 when using an UTF-8 or GB-18030 locale. The list of other locales with quotes was provided by Bruno Haible. (quotearg_buffer_restyled): Adjust instructions to translators. * lib/quotearg.h (locale_quoting_style): Do not put an example in the text, since this would be wrong when using Unicode. * modules/quotearg: Depend on c-strcaseeq.
Paolo Bonzini cacad9e8 2011-12-18T15:31:23 quotearg: fix Wikipedia link * lib/quotearg.c (quotearg_buffer_restyled): Fix link to Wikipedia.
Paul Eggert 51e801f2 2012-01-05T23:53:49 In commentary, do not use ` to quote.
Jim Meyering 1602f0af 2012-01-01T10:04:58 maint: update all copyright year number ranges Run "make update-copyright".
Jim Meyering 2ae12d77 2011-11-29T10:09:41 quotearg, propername: correct pragma guard expression * lib/quotearg.c: Enable pragma for gcc-4.6 and newer, not 4.3 and newer. * lib/propername.c: Likewise. Reported by Bernhard Voelker.
Jim Meyering 9e62d63e 2011-06-02T10:05:59 mark functions with const and pure attributes Mark functions per suggestions from gcc-4.6 when using these options: -Wsuggest-attribute=pure -Wsuggest-attribute=const. Use gnulib's _GL_ATTRIBUTE_PURE and _GL_ATTRIBUTE_CONST macros. Follow these guidelines: when possible, apply the attribute to an extern declaration, not to its definition. Apply it to the definition only when the definition is static. * lib/argmatch.h (argmatch, argmatch_to_argument): Mark. * lib/argv-iter.h (argv_iter_n_args): Likewise. * lib/base64.h (isbase64): Likewise. * lib/basename-lgpl.c (last_component, base_len): Likewise. * lib/c-ctype.h (c_isascii, c_isalnum, c_isalpha): Likewise. (c_isblank, c_iscntrl, c_isdigit, c_islower, c_isgraph): Likewise. (c_isprint, c_ispunct, c_isspace, c_isupper, c_isxdigit): Likewise. (c_tolower, c_toupper): Likewise. * lib/c-strcase.h (c_strcasecmp, c_strncasecmp): Likewise. * lib/chdir-long.c (find_non_slash): Likewise. * lib/dirname.h (base_len, dir_len, last_component): Likewise. * lib/exclude.h (fnmatch_pattern_has_wildcards): Likewise. * lib/file-type.h (file_type): Likewise. * lib/filenamecat-lgpl.c (longest_relative_suffix): Likewise. * lib/filevercmp.c (verrevcmp): Likewise. * lib/freadahead.h (freadahead): Likewise. * lib/fts.c (fts_maxarglen): Likewise. * lib/hash-pjw.h (hash_pjw): Likewise. * lib/hash-triple.h (triple_hash_no_name, triple_compare_ino_str): * lib/hash.c (is_prime, next_prime): Likewise. * lib/hash.c (hash_get_n_buckets, hash_get_n_buckets_used): Likewise. (hash_get_n_entries, hash_get_max_bucket_length): Likewise. (hash_table_ok, hash_get_first, hash_string): Likewise. (compute_bucket_size): Likewise. * lib/i-ring.h (i_ring_empty): Likewise. * lib/isnan.c (isnanl): Likewise. * lib/math.h (isnanl, rpl_isnanl): Likewise. * lib/memcasecmp.h (memcasecmp): Likewise. * lib/memchr2.h (memchr2): Likewise. * lib/memcmp2.h (memcmp2): Likewise. * lib/parse-datetime.y (lookup_zone): Likewise. * lib/sockets.h (gl_sockets_startup, gl_sockets_cleanup) [!WINDOWS_SOCKETS]: Likewise. * lib/strnlen1.h (strnlen1): Likewise. * lib/uniwidth.in.h (uc_width): Likewise, but since this is installed as a public header by libunistring, it cannot depend on the macro definitions of gnulib-common.m4, so open-code the __attribute__... * lib/quotearg.c: Add pragma to avoid unwarranted suggestion from gcc's -Wsuggest-attribute=pure for quoting_options_from_style. (quoting_options_from_style): Add a comment. * lib/propername.h (proper_name): Add a comment.
Eric Blake aaf62c6a 2011-04-28T17:25:49 quotearg: avoid uninitialized variable use Coverity correctly deduced: Error: UNINIT: m4-1.4.16/lib/quotearg.c:171: var_decl: Declaring variable "o" without initializer. m4-1.4.16/lib/quotearg.c:175: uninit_use: Using uninitialized value "o": field "o".right_quote is uninitialized. When custom_quoting_style was introduced in commit 12247f77, this method was not updated, and any caller that passed the new enum value to any of the existing quotearg_*style functions could trigger a crash from the uninitialized memory. That was already documented as unspecified behavior, though, so changing to an abort makes it easier to spot bad code that passes the wrong enum value, rather than waiting for the eventual bad memory dereference later on. Most callers of quotearg_*style were using quoting_style_args and quoting_style_vals to map strings to particular enum values, and custom_quoting_style is (intentionally) not covered by these arrays, so the pre-patch bug/post-patch abort are not possible with those callers. * lib/quotearg.c (quoting_options_from_style): Initialize remaining fields, and ensure that custom styles are only used via quoting_options rather than quoting_style. Signed-off-by: Eric Blake <eblake@redhat.com>
Jim Meyering 6829a6c0 2011-04-25T10:38:33 Revert "use _GL_ATTRIBUTE_CONST and _GL_ATTRIBUTE_PURE" This reverts commit 349d7fe0e307d59d508b3579317ee8d4eacfeb9c. Revert accidentally-pushed patch. Not yet ready.
Jim Meyering 349d7fe0 2011-04-24T19:02:10 use _GL_ATTRIBUTE_CONST and _GL_ATTRIBUTE_PURE
Jim Meyering d60f3b0c 2011-01-01T20:17:23 maint: update almost all copyright ranges to include 2011 Run the new "make update-copyright" rule.
Jim Meyering b2e2010c 2010-01-01T10:31:12 update nearly all FSF copyright year lists to include 2010 Use the same procedure as for 2009, outlined in http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/20081
Jim Meyering 3030c5b5 2009-12-28T10:50:36 update nearly all FSF copyright year lists to include 2009 The files named by the following are exempted: grep -v '^#' config/srclist.txt|grep -v '^$' \ | while read src dst; do test -f "$dst" && { echo "$dst"; continue; } test -d "$dst" || continue echo "$dst"/$(basename "$src") done > exempt git ls-files tests/unictype >> exempt In the remaining files, convert to all-interval notation if - there is already at least one year interval like 2000-2003 - the file is maintained by me - the file is in lib/uni*/, where that style already prevails Otherwise, use update-copyright's default.
Bruno Haible 441aa304 2009-12-10T20:28:30 Use spaces for indentation, not tabs.
Joel E. Denny 98bf7f3d 2009-08-22T20:55:17 quotearg: document limitations of quote_these_too * lib/quotearg.c (quotearg_buffer_restyled): Add comments where those limitations are created. * lib/quotearg.h (set_char_quoting): Document that digits and letters that are special after backslash are not permitted. (quotearg_char): Cross-reference set_char_quoting documentation.
Joel E. Denny 12247f77 2009-08-23T18:24:53 quotearg: implement custom_quoting_style * lib/quotearg.c: (struct quoting_options): Add left_quote and right_quote fields. (set_custom_quoting): New public function. (quotearg_buffer_restyled): Add left_quote and right_quote arguments, handle them very much like locale quoting, and update all uses. (quotearg_n_custom): New public function. (quotearg_n_custom_mem): New public function. (quotearg_custom): New public function. (quotearg_custom_mem): New public function. * lib/quotearg.h: Prototype and document new public functions. (enum quoting_style): For escape_quoting_style and clocale_quoting_style, comment that QA_SPLIT_TRIGRAPHS is ignored even though they're otherwise like c_quoting_style. Add custom_quoting_style member and document with comparison to clocale_quoting_style. * tests/test-quotearg.c (custom_quotes): New array. (custom_results): New array. (main): Extend to test custom quoting.
Joel E. Denny f6fe750d 2009-08-22T20:26:46 quotearg: fix right quote escaping when it's in quote_these_too * lib/quotearg.c (quotearg_buffer_restyled): Upon seeing a right quote, be sure to prepend only one backslash. * tests/test-quotearg.c (use_quote_double_quotes): New function. (main): Test it.
Bruno Haible 4eda4ba5 2008-12-22T12:11:44 Remove HAVE_MBRTOWC conditionals. Use mbrtowc unconditionally.
Eric Blake 3d986f52 2008-02-16T07:40:47 Avoid doubling \ in common case of "c-maybe" quoting style. * lib/quotearg.c (quotearg_buffer_restyled): Don't escape \ when eliding outer quotes. * lib/quotearg.h: Document this. * tests/test-quotearg.c (result_strings, inputs, results_g) (flag_results, locale_results): Test it by adding a new string to each test group. (compare_strings): Test new string. Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake df4e570b 2008-02-13T21:46:03 Avoid trigraph quoting in default output. * lib/quotearg.h (enum quoting_flags): Add QA_SPLIT_TRIGRAPHS. * lib/quotearg.c (quotearg_buffer_restyled): Don't quote trigraphs unless explicitly requested. * tests/test-quotearg.c (flag_results, main): Add additional tests. Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake cbfa4bf0 2008-02-12T21:05:57 Silence warning in last patch. * lib/quotearg.c (quotearg_buffer_restyled): Add missing const. Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake 05230b80 2008-02-12T11:42:29 Quotearg part 4: add tests, fix c-maybe colon quoting. * lib/quotearg.h: Improve documentation. * lib/quotearg.c (quotearg_buffer_restyled): Don't add extra escapes when adding outer quotes. When quoting trigraphs, use valid C notation. When quoting NUL, omit extra characters if next character is not digit. Alter prototype. (quotearg_buffer, quotearg_alloc_mem, quotearg_n_options): Adjust callers. * modules/quotearg-tests: New module. * tests/test-quotearg.c: New test. Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake 74dd1966 2008-02-07T16:44:01 Quotearg part 3: add flag to control outer quote elision. * lib/quotearg.h (c_maybe_quoting_style): New style. (enum quoting_flags): Better documentation of flags. * lib/quotearg.c (quoting_style_args, quoting_style_vals): Add c-maybe style. (quotearg_buffer_restyled): Handle new flag to elide outer quotes. Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake 71e66c91 2008-02-07T14:35:51 Quotearg part 2: add flag that can control NUL elision. * lib/quotearg.h (set_quoting_flags): New prototype. * lib/quotearg.c (struct quoting_options): Add flag field. (set_quoting_flags): New function. (quotearg_buffer_restyled): Add flags parameter. (quotearg_alloc_mem): Set the flag if length cannot be returned. (quotearg_n_options): Set the flag, since length cannot be returned. (quoting_options_from_style): Default flags correctly. Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake 2aa21ba3 2008-02-07T06:39:57 Quotearg part 1: more wrappers, restore quotearg_char state. * lib/quotearg.h (quotearg_alloc_mem, quotearg_n_mem) (quotearg_mem, quotearg_style_mem, quotearg_char_mem) (quotearg_colon_mem): New wrappers. * lib/quotearg.c (quotearg_alloc, quotearg_char): Rewrite... (quotearg_alloc_mem, quotearg_char_mem): ...in terms of these new functions. (quotearg_n_mem, quotearg_mem, quotearg_style_mem) (quotearg_colon_mem): New functions. Signed-off-by: Eric Blake <ebb9@byu.net>
Bruno Haible 57fdfd3f 2007-10-07T19:14:58 Change copyright notice from GPLv2+ to GPLv3+.
Paul Eggert eee00907 2007-03-15T22:58:36 * lib/quotearg.c: Include <wctype.h> early, before the definition of the iswprint macro. Needed on Solaris 2.5.1. 2007-03-12 Bruno Haible <bruno@clisp.org> * tests/test-printf-frexp.c (main): Declare x as volatile. 2007-03-12 Simon Josefsson <simon@josefsson.org> * doc/gnulib.texi (Build robot for gnulib): New section. 2007-03-12 Jim Meyering <jim@meyering.net> * build-aux/bootstrap: New file. * build-aux/bootstrap.conf: New file, from coreutils. 2007-03-11 Bruno Haible <bruno@clisp.org> * m4/cycle-check.m4 (gl_CYCLE_CHECK): Require AC_C_INLINE. 2007-03-12 Simon Josefsson <simon@josefsson.org> * lib/des.h, lib/des.c, lib/gc-gnulib.c: Use gl_ namespace, to avoid collisions with 'des_setkey'. Reported by Bruno Haible <bruno@clisp.org>. Also change 'tripledes_' to '3des_'. 2007-03-11 Bruno Haible <bruno@clisp.org> * m4/locale-tr.m4 (gt_LOCALE_TR_UTF8): If the test program fails to compile, set LOCALE_TR_UTF8 to 'none' instead of empty. 2007-03-11 Bruno Haible <bruno@clisp.org> * lib/stdint_.h (INT64_MIN, INTMAX_MIN): Avoid using the ~INT..._MAX formula. Needed for SunPRO C 5.0.
Eric Blake 96f7b7d9 2007-01-16T16:31:23 * modules/fnmatch (Depends-on): Depend on wchar. * lib/fnmatch.c (WIDE_CHAR_SUPPORT): Assume <wchar.h>. * m4/fnmatch.m4: Likewise. * modules/mbchar (Makefile.am): Assume <wchar.h>. * m4/mbchar.m4: Likewise. * modules/mbswidth (Depends-on): Depend on wchar. * lib/mbswidth.c: Assume <wchar.h>. * m4/mbswidth.m4: Likewise. * modules/quotearg (Depends-on): Depend on wchar. * lib/quotearg.c: Assume <wchar.h>. * m4/quotearg.m4: Likewise. * modules/regex (Depends-on): Depend on wchar. * lib/regex_internal.h: Assume <wchar.h>. * m4/regex.m4: Likewise. * modules/stdint (Depends-on): Depend on wchar. * lib/stdint_.h [!defined WCHAR_MIN]: Assume <wchar.h>. * m4/stdint.m4: Likewise. * tests/test-stdint.c [HAVE_WINT_T]: Likewise. * modules/strftime (Depends-on): Depend on wchar. * lib/strftime.c (DO_MULTIBYTE): Assume <wchar.h>. * modules/strtol (Depends-on): Depend on wchar. * lib/strtol.c: Assume <wchar.h>. * modules/wcwidth (Depends-on): Depend on wchar. * lib/wcwidth.h: Assume <wchar.h>. * m4/wcwidth.m4: Likewise.
Paul Eggert 44fa0d78 2006-12-22T00:21:54 * MODULES.html.sh: New module wctype. * lib/wctype_.h, m4/wctype.m4, modules/wctype: New files. * lib/fnmatch.c: Don't bother to include <wchar.h> before <wctype.h>, since the new wctype module should fix this. * lib/quotearg.c: Include <wctype.h> unconditionally, since the wctype module should arrange for it. * lib/regex_internal.h: Likewise. * m4/quotearg.m4 (gl_QUOTEARG): Don't check for wctype.h or iswprint, since the wctype module should handle this now. * m4/regex.m4 (gl_PREREQ_REGEX): Don't check for wctype.h. * modules/fnmatch (Depends-on): Add wctype. * modules/quotearg (Depends-on): Likewise. * modules/regex (Depends-on): Likewise.
Paul Eggert 96159f3a 2006-11-08T20:13:12 * lib/quotearg.h (quotearg_free): New decl. * lib/quotearg.c (quotearg_free): New function. (slot0, nslots, slotvec0, slotvec): Now file-scope so that quotearg_free can get at them.
Paul Eggert 08262434 2006-10-31T21:51:45 Avoid some C++ diagnostics reported by Bruno Haible. * lib/quotearg.c (clone_quoting_options): Use xmemdup rather than xmalloc. (quotearg_alloc): Use xcharalloc rather than xmalloc. (struct slotvec): Move to top level. (quotearg_n_options): Rewrite to avoid xmalloc. * lib/xalloc.h (xcharalloc): New function. * (xrealloc, xnrealloc, x2realloc, x2nrealloc, xmemdup): [defined __cplusplus]: Add function template that provides result type propagation. This part of the change is from Bruno Haible.
Paul Eggert 241622b8 2006-10-03T06:33:39 * quotearg.c (mbstate_t) [!HAVE_MBRTOWC]: #define to int.
Paul Eggert 0632e115 2006-09-13T22:38:14 * _fpending.c: Include <config.h> unconditionally, since we no longer worry about uses that don't define HAVE_CONFIG_H. * acl.c, alloca.c, argmatch.c, atexit.c, backupfile.c: * basename.c, c-stack.c, c-strtod.c, calloc.c, canon-host.c: * canonicalize.c, chdir-long.c, chdir-safer.c, chown.c: * cloexec.c, close-stream.c, closeout.c, creat-safer.c: * cycle-check.c, diacrit.c, dirchownmod.c, dirfd.c, dirname.c: * dup-safer.c, dup2.c, error.c, euidaccess.c, exclude.c: * exitfail.c, fchmodat.c, fchown-stub.c, fd-safer.c: * file-type.c, fileblocks.c, filemode.c, filenamecat.c: * fnmatch.c, fopen-safer.c, fprintftime.c, free.c, fsusage.c: * ftruncate.c, fts-cycle.c, fts.c, full-write.c, gai_strerror.c: * getcwd.c, getdate.y, getdomainname.c, getgroups.c: * gethostname.c, gethrxtime.c, getloadavg.c, getlogin_r.c: * getndelim2.c, getnline.c, getopt.c, getopt1.c, getpass.c: * gettime.c, gettimeofday.c, getugroups.c, getusershell.c: * glob.c, group-member.c, hard-locale.c, hash-pjw.c, hash.c: * human.c, idcache.c, inet_ntop.c, inet_pton.c, inttostr.c: * isdir.c, lchown.c, linebuffer.c, long-options.c, lstat.c: * malloc.c, md5.c, memcasecmp.c, memchr.c, memcmp.c, memcoll.c: * memcpy.c, memmove.c, memrchr.c, mkancesdirs.c, mkdir-p.c: * mkdir.c, mkdirat.c, mkstemp-safer.c, mkstemp.c, modechange.c: * mountlist.c, nanosleep.c, obstack.c, open-safer.c: * openat-die.c, openat.c, pagealign_alloc.c, physmem.c: * pipe-safer.c, posixtm.c, posixver.c, putenv.c, quote.c: * quotearg.c, raise.c, readtokens.c, readtokens0.c, readutmp.c: * realloc.c, regex.c, rename.c, rmdir.c, rpmatch.c, safe-read.c: * same.c, save-cwd.c, savedir.c, setenv.c, settime.c, sha1.c: * sig2str.c, snprintf.c, strdup.c, strerror.c, strftime.c: * stripslash.c, strndup.c, strnlen.c, strpbrk.c, strtod.c: * strtoimax.c, strtol.c, strverscmp.c, tempname.c, time_r.c: * timegm.c, tmpfile-safer.c, unlinkdir.c, userspec.c, utime.c: * utimecmp.c, utimens.c, version-etc-fsf.c, version-etc.c: * xalloc-die.c, xgetcwd.c, xgethostname.c, xmalloc.c: * xmemcoll.c, xnanosleep.c, xreadlink.c, xstrtod.c: * xstrtoimax.c, xstrtol.c, xstrtoumax.c, yesno.c: Likewise.
Paul Eggert b35c0cb9 2006-01-22T08:46:02 * quotearg.c (quotearg_buffer_restyled): Add "default: break;" to pacify gcc -Wswitch-default.
Paul Eggert 7c3f8da8 2005-09-23T04:15:13 Sync from coreutils. * .cppi-disable: Add regcomp.c, regex_internal.c, regex_internal.h, stat-time.h. * argmatch.h: Include verify.h (ARGMATCH_VERIFY): Use verify rather than rolling our own. (ARGMATCH_ASSERT): Remove; unused. * canonicalize.c: Assume STDC_HEADERS. * exclude.c: Include "strcase.h". * regex_internal.h [!defined _LIBC]: Likewise. * getusershell.c: Include stdio--.h rather than stdio.h and stdio-safer.h. (getusershell): Call fopen, not fopen_safer. * save-cwd.c: Include fcntl--.h rather than fcntl.h. Do not include unistd-safer.h. (save_cwd): Don't call fd_safer; no longer needed now that we include fcntl--.h. * modules/argmatch (Depends-on): Add verify. * modules/getloadavg (Depends-on): Depend on fcntl-safer, not unistd-safer. * modules/save-cwd (Depends-on): Likewise. * backupfile.m4, calloc.m4, chown.m4, cloexec.m4, dup2.m4: * fileblocks.m4, free.m4, ftruncate.m4, getcwd.m4, getpagesize.m4: * getugroups.m4, group-member.m4, idcache.m4, link-follow.m4: * mkstemp.m4, mktime.m4, mountlist.m4, nanosleep.m4, pathmax.m4: * physmem.m4, posixver.m4, putenv.m4, safe-read.m4, same.m4: * save-cwd.m4, stdio-safer.m4, unistd-safer.m4, unlinkdir.m4: * userspec.m4, xgetcwd.m4, xreadlink.m4: Don't bother checking for string.h, stdlib.h, unistd.h. * fts.m4 (gl_FUNC_FTS_CORE): Don't require AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK; that's now the lstat module's job. * jm-macros.m4 (gl_MACROS): Likewise. * prereq.m4 (gl_PREREQ): Add gl_FUNC_LSTAT. * backupfile.c: Use ARGMATCH_VERIFY, just in case. * posixtm.c (posixtime) [lint]: Initialize *all* of tm0, not just the .tm_year member, since otherwise gcc-4.0 would now warn about tm_zone, tm_gmtoff, tm_isdst, tm_yday, tm_wday. * quotearg.c (quotearg_n_options): Change code to be suboptimal, in order to avoid an unsuppressible warning from gcc on 64-bit systems. * lstat.m4 (gl_FUNC_LSTAT): Use AC_LIBSOURCES to require lstat.c and lstat.h. Remove obsolete comment. * xreadlink.m4: Use AC_LIBSOURCES and AC_LIBOBJ. * xstrtod.m4: Likewise.
Paul Eggert 222b0486 2005-09-19T17:28:14 Use a consistent style for including <config.h>. * __fpending.c, acl.c, argmatch.c, argp-help.c, argp-parse.c, argp-pvh.c, backupfile.c, basename.c, c-stack.c, calloc.c, check-version.c, cloexec.c, closeout.c, copy-file.c, creat-safer.c, cycle-check.c, dirfd.c, dirname.c, dup-safer.c, dup2.c, euidaccess.c, exclude.c, exitfail.c, fatal-signal.c, fd-safer.c, file-type.c, fileblocks.c, filemode.c, filenamecat.c, findprog.c, fnmatch.c, fopen-safer.c, free.c, fsusage.c, ftruncate.c, full-write.c, fwriteerror.c, getaddrinfo.c, getcwd.c, getdelim.c, getline.c, getlogin_r.c, getndelim2.c, getnline.c, getopt1.c, getpass.c, group-member.c, hard-locale.c, hash-pjw.c, hash.c, human.c, idcache.c, inet_ntop.c, isdir.c, long-options.c, malloc.c, memcasecmp.c, memcmp.c, memcoll.c, memcpy.c, memmove.c, mkdir-p.c, modechange.c, mountlist.c, open-safer.c, physmem.c, pipe-safer.c, pipe.c, poll.c, posixver.c, progname.c, progreloc.c, putenv.c, quote.c, quotearg.c, readline.c, readlink.c, realloc.c, regex.c, rename.c, rmdir.c, rpmatch.c, safe-read.c, same.c, save-cwd.c, savedir.c, sig2str.c, strcspn.c, strerror.c, stripslash.c, strncasecmp.c, strndup.c, strnlen.c, strnlen1.c, strsep.c, strstr.c, strtod.c, strtoimax.c, strtol.c, strverscmp.c, tempname.c, time_r.c, userspec.c, utimecmp.c, version-etc-fsf.c, version-etc.c, wait-process.c, xalloc-die.c, xgetcwd.c, xmalloc.c, xmemcoll.c, xnanosleep.c, xreadlink.c, xsetenv.c, xstrndup.c, xstrtoimax.c, xstrtol.c, xstrtoumax.c, yesno.c: Standardize inclusion of config.h. * __fpending.h, dirfd.h, getdate.h, human.h, inttostr.h: Removed inclusion of config.h from header files. * inttostr.c: Adjusted in-tree users. * timespec.h: Remove superfluous warning to include config.h. * atexit.c, chdir-long.c chown.c, fchown-stub.c, getgroups.c, gettimeofday.c, lchown.c, lstat.c, mkdir.c, mkstemp.c, nanosleep.c, openat.c, raise.c, readtokens0.c, readutmp.c, unlinkdir.c: Guard inclusion of config.h with HAVE_CONFIG_H.
Paul Eggert 922fa4cc 2005-07-15T21:01:41 Add translator comment suggested by Bruno Haible, with a minor change.
Paul Eggert 267a39ba 2005-05-14T06:03:57 *** empty log message ***
Paul Eggert 2b13c71b 2004-11-11T05:58:47 (struct quoting_options): Use unsigned int for quote_these_too, so that right shifts are well defined. All uses changed.
Paul Eggert a62be9f4 2004-08-07T00:09:38 Merge from coreutils.
Paul Eggert 3056a566 2004-02-05T19:05:52 New function quotearg_alloc. Treat { } = as special sometimes. Work around bug in multibyte handling in older shells.
Paul Eggert fdb6eb33 2003-10-30T06:33:39 Revamp xalloc_oversized so that its count arg need not fit into size_t. Fix up group-member, quotearg accordingly.
Paul Eggert 3105da51 2003-10-29T17:33:05 (quotearg_n_options): Use free/xmalloc rather than xrealloc. Use a simpler test for size overflow. Don't use xalloc_oversized because unsigned int might be wider than size_t (!); this suggests that we should switch from unsigned int to size_t for slot numbers.
Paul Eggert cb7716e2 2002-11-23T06:45:49 Include quotearg.h immediately after config.h. No need to include stddef.h or sys/types.h any more. Surround local include files with "", not "<>". Assume HAVE_LIMITS_H unconditionally, as we assume C89. Similarly, assume HAVE_C_BACKSLASH_A, CHAR_BIT, UCHAR_MAX, UINT_MAX, HAVE_STDLIB_H, HAVE_STRING_H, STDC_HEADERS. (HAVE_MBSINIT): Undef if !HAVE_MBRTOWC. (mbsinit): Define to 1 if !defined mbsinit && !HAVE_MBSINIT. (ISPRINT): Remove; no longer needed now that we assume C89. (clone_quoting_options, quotearg_buffer, quotearg_n_options): Preserve errno. (quotearg_buffer_restyled, quotearg_n, quotearg_n_style, quotearg_char): Use SIZE_MAX rather than (size_t) -1 when we are talking about "infinity". (quotearg_buffer_restyled): Fix bug when quoting trigraphs.
Bruno Haible f9fa25dc 2002-11-05T21:45:29 Include gettext.h instead of <libintl.h> with #ifdefs.
Jim Meyering 3f511862 2002-01-22T08:02:22 (quotearg_buffer_restyled): Fix bug with quoting buffers containing NUL when backslashing escapes. This bug was exposed by the other changes in this patch. (quotearg_n_options): New arg ARGSIZE. All callers changed. (quoting_options_from_style): New function. (quotearg_n_style): Use it. (quotearg_n_style_mem): New function.
Jim Meyering 870fb0df 2001-11-28T06:57:02 (quotearg_n, quotearg_n_style): Likewise. (SIZE_MAX, UINT_MAX): New macros. (quotearg_n_options): Abort if N is negative. Avoid overflow check on hosts where size_t is 64 bits and int is 32 bits, as overflow is impossible there. Fix off-by-one typo that caused unnecessary reallocation.
Jim Meyering 3e3c7925 2001-08-31T07:51:13 BSD/OS 4.1 wchar.h requires FILE and struct tm to be declared.
Jim Meyering db5283c7 2001-02-17T10:39:17 (mbrtowc, mbsinit): Remove workaround macros for hosts that have mbrtowc but not mbstate_t, as we now insist on proper declarations for both before using mbrtowc.
Jim Meyering 4d00eea9 2001-01-26T11:15:37 Include stddef.h.
Jim Meyering 3bd332e0 2000-09-09T15:56:26 Rename ISASCII to IN_CTYPE_DOMAIN.
Jim Meyering 28c9a4ad 2000-07-31T18:30:21 (quotearg_n_options): Don't make the initial slot vector a constant, since it might get modified.
Jim Meyering 62a3c6b1 2000-07-31T07:23:01 (quotearg_n_options): Preallocate a slot 0 buffer, so that the caller can always quote one small component of a "memory exhausted" message in slot 0. From a suggestion by Jim Meyering.
Jim Meyering 8ed25ee6 2000-07-24T06:14:19 Include <wchar.h> even if ! (HAVE_MBRTOWC && 1 < MB_LEN_MAX), so that mbstate_t is always defined. Do not inspect MB_LEN_MAX, since it's incorrectly defined to be 1 in at least one GCC installation, and this configuration error is likely to be common. Ignoring MB_LEN_MAX hurts performance on hosts that have mbrtowc but have only unibyte locales, but I assume these hosts are rare.
Jim Meyering f7d4132b 2000-07-23T21:48:17 Streamline by invoking multibyte code only if needed. <wchar.h>: Include only if HAVE_MBRTOWC && 1 < MB_LEN_MAX. (MB_CUR_MAX): Redefine to 1 if ! (HAVE_MBRTOWC && 1 < MB_LEN_MAX). (quotearg_buffer_restyled): If a unibyte locale, don't bother to invoke multibyte primitives.
Jim Meyering a62b804c 2000-07-23T08:38:25 When the system forces us to redefine mbstate_t, shadow its mbsinit function.
Jim Meyering a618b12d 2000-07-14T13:56:07 (mbrtowc): Do not use HAVE_WCHAR_H in the definition. Use defined mbstate_t, not HAVE_MBSTATE_T_OBJECT, to decide whether to define the BeOS workaround macro; this adjusts to the change to AC_MBSTATE_T.
Jim Meyering d98c6d36 2000-07-14T11:26:28 (quoting_style_args, quoting_style_vals, quotearg_buffer_restyled): Add support for clocale_quoting_style. Undo previous change to locale_quoting_style behavior, and undo the "{LEFT QUOTATION MARK}" and "{RIGHT QUOTATION MARK}" msgids.
Jim Meyering 12cdbeb9 2000-07-09T15:46:46 The old behavior of quoting `like this' doesn't look good with newer, ISO-style fonts. See: http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html Instead, quote "like this" by default. Let the translator tailor the locale-specific quoting behavior by providing translations for {LEFT QUOTATION MARK} and {RIGHT QUOTATION MARK}. (N_): New macro. (gettext_default): New function. (quotearg_buffer_restyled): Use gettext_default ("{LEFT QUOTATION MARK}", "\"") for left quote, and gettext_default ("{RIGHT QUOTATION MARK}", "\"") for right quote.
Jim Meyering 1f1d0940 2000-07-06T04:47:28 (mbrtowc): Declare returned type, since BeOS doesn't.
Jim Meyering 2793141d 2000-07-06T04:31:59 (struct quoting_options): Simplify quote_these_too dimension.
Jim Meyering 38254f7f 2000-07-04T17:31:56 Make inclusion of <wchar.h> independent of whether HAVE_MBRTOWC is set. Required at least for irix-5.6, which lacks mbrtowc.
Jim Meyering 9c9a405b 2000-07-04T07:03:16 (mbrtowc): Assign to *pwc, and return 1 only if result is nonzero. (iswprint): Use ISPRINT when substituting our own mbrtowc.
Jim Meyering c69e9127 2000-07-02T18:32:05 (mbstate_t): Don't define here.
Jim Meyering e986b397 2000-06-23T21:05:50 Include <wctype.h> after <wchar.h>, for Solaris 2.5. (mbrtowc, mbstate_t): Define substitutes if HAVE_MBRTOWC && HAVE_WCHAR_H && !HAVE_MBSTATE_T_OBJECT. (iswprint): Define to 1 if !defined iswprint && !HAVE_ISWPRINT, not if ! (HAVE_MBRTOWC && HAVE_WCHAR_H).
Jim Meyering 02b27c92 2000-02-28T20:45:28 (ALERT_CHAR): New macro. (quotearg_buffer_restyled): Use it.
Jim Meyering f0fcee86 2000-01-31T08:42:45 fix typo. sheesh
Jim Meyering 017cf285 2000-01-31T08:27:51 (ISASCII): Add #undef and move definition to follow inclusion of wctype.h to work around solaris2.6 namespace pollution. (ISPRINT): Likewise.
Jim Meyering cbdd6c8a 2000-01-22T22:19:48 [HAVE_WCTYPE_H]: Include <wctype.h>.
Jim Meyering 35c6eecd 2000-01-17T08:01:40 (quotearg_buffer_restyled): Do not quote alert, backslash, formfeed, and vertical tab unnecessarily in shell quoting style.
Jim Meyering c4b7f3f8 2000-01-15T11:57:11 Quote multibyte characters correctly. (ISGRAPH): Remove. (ISPRINT): New macro. (<wchar.h>): Include if HAVE_MBRTOWC && HAVE_WCHAR_H. (isprint, mbrtowc, mbsinit, mbstate_t): New macros, defined if ! (HAVE_MBRTOWC && HAVE_WCHAR_H). (quotearg_buffer_restyled): New function, with most of the old quotearg_buffer's contents. Major rewrite to support multibyte characters. (quotearg_buffer): Now just calls quotearg_buffer_restyled.
Jim Meyering 66bec62b 1999-08-10T10:50:18 Include <libintl.h> if ENABLE_NLS. (_): New macro. (quoting_style_args, quoting_style_v, quotearg_buffer): Add support for locale_quoting_style, using _("`") and _("'") for open and close quote symbols. Do not quote spaces in escape_quoting_style. (quotearg_n_style, quotearg_style): New functions.
Jim Meyering 3c3d25cd 1999-08-01T07:44:39 (quotearg_buffer): Don't quote spaces if C quoting style.
Jim Meyering 06e76561 1999-01-25T00:17:22 (quotearg_n_options): Revert type of parameter `n' (and hence that of the local `n1', too) to `int' at Paul's request.
Jim Meyering c5779c09 1999-01-16T15:55:20 (quotearg_n_options): Declare n1 to be of type unsigned int, not just int.
Jim Meyering 8b1764e8 1999-01-11T03:11:15 (quotearg_buffer): Change escape_quoting_style so that it no longer escapes ` '. Suggestion from Paul Eggert.
Jim Meyering 5f3336eb 1999-01-01T07:03:16 (quotearg_n_options): Make `options' parameter be `const'.
Jim Meyering 94a2786e 1999-01-01T07:02:16 (quotearg_buffer): Cast -1 to size_t before comparing. (quotearg_n): Change type of 1st parameter from int to unsigned int. (quotearg_n_options): Likewise. From Akim Demaille.
Jim Meyering e4d36862 1998-12-11T14:14:16 (quotearg_buffer): Use `7' as the mask, not `3'. From Bruno Haible.
Jim Meyering d56026b4 1998-03-21T08:49:00 Update from patch-2.5.3.
Jim Meyering 0402072d 1998-02-23T10:16:53 .