summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* parse-datetime: avoid a compiler warning with byaccTim Rühsen2014-12-141-1/+1
| | | | | | * lib/parse-datetime.y (yylex): Use the same prototype in the function definition as the declaration, to avoid a -Wstrict-prototypes warning seen when using byacc.
* stddef: support C11's max_align_tPaul Eggert2014-12-121-15/+26
| | | | | | | | | | | | | * doc/posix-headers/stddef.texi (stddef.h): Document max_align_t. * lib/stddef.in.h (_@GUARD_PREFIX@_STDDEF_H) [__need_wint_t]: Do not undef, as that might cause max_align_t to be defined twice. Instead, change use to check for _GL_STDDEF_WINT_T too. (max_align_t) [!HAVE_MAX_ALIGN_T]: New decl. * m4/stddef_h.m4 (gl_STDDEF_H, gl_STDDEF_H_DEFAULTS): Check for max_align_t. * modules/stddef (stddef.h): Substitute HAVE_MAX_ALIGN_T. * modules/stddef-tests (Depends-on): Add stdalign. * tests/test-stddef.c: Test max_align_t.
* unistd: fix iOS check conditionalDaiki Ueno2014-12-121-1/+1
| | | | | | | | | On Mac OS X 10.8, the TARGET_* macros are unconditonally defined as 0 or 1 in <TargetConditionals.h>, and the previous check always yielded true on non-iOS environment. * lib/unistd.in.h (environ) [__APPLE__]: Check the values of TARGET_OS_IPHONE and TARGET_IPHONE_SIMULATOR, instead of whether they are defined.
* posixtm: avoid compiler warning in a better wayPaul Eggert2014-12-091-48/+32
| | | | | | | * lib/posixtm.c (IF_LINT): Remove. (year, posix_time_parse): Return true (not 0) if successful. All callers changed. (posix_time_parse): Simplify to pacify GCC without need for IF_LINT.
* relocatable: support UNIXROOT in relocate() on EMXKO Myung-Hun2014-12-081-0/+21
| | | | | | | | UNIXROOT is used to specify a drive of a root of FHS. So if a path is started with '/', then it should be translated to "$UNIXROOT/". * lib/relocatable.c (relocate): Prepend $UNIXROOT to pathname if it is started with '/' on EMX.
* freopen: workaround freopen() on OS/2 kLIBCKO Myung-Hun2014-12-081-1/+17
| | | | | | | | On OS/2 kLIBC, freopen() returns NULL even if it is successful if filename is NULL. * lib/freopen.c (rpl_freopen): Workaround. * m4/freopen.m4: Add os2* case.
* get_shared_library_fullname: port to EMXKO Myung-Hun2014-12-081-3/+51
| | | | | | | | | * lib/relocatable.c: Define strcmp and strncmp to stricmp and strnicmp on EMX, respectively. (_DLL_InitTerm): New on EMX. (get_shared_library_fullname): Implement on EMX. Signed-off-by: Eric Blake <eblake@redhat.com>
* find_executable: port to EMXKO Myung-Hun2014-12-081-0/+22
| | | | | | * lib/progreloc.c (find_executable): Implement on EMX. Signed-off-by: Eric Blake <eblake@redhat.com>
* sched: check struct sched_param in spawn.h as wellKO Myung-Hun2014-12-081-0/+7
| | | | | | | | On OS/2 kLIBC, struct sched_param is in spawn.h. So without this a redefinition error occurs when sched.h is inclued by spawn.h. * lib/sched.in.h: Include spawn.h on kLIBC. * lib/sched_h.m4: Check struct sched_param in spawn.h as well.
* apply _GL_ATTRIBUTE_PURE to some inline functionsPádraig Brady2014-12-084-12/+12
| | | | | | | | | clang 3.4.2 flagged these inline functions as pure * lib/savewd.h (savewd_errno): Set _GL_ATTRIBUTE_PURE. * lib/sig-handler.h (get_handler): Likewise. * lib/stat-time.h (get_stat_{a,c,m,birth}time{,_ns}): Likewise. * lib/timespec.h (timespec_cmp, timespec_sign): Likewise.
* vasnprintf: fix potential incorrect errnoPádraig Brady2014-12-081-6/+9
| | | | | | | | An adjustment of the previous commit c5c4f53b. * lib/vasnprintf.c (VASNPRINTF): free() generally doesn't set errno, but it can potentially in certain edge cases. Reported by Eric Blake.
* vasnprintf: fix potential use after freePádraig Brady2014-12-061-1/+1
| | | | | * lib/vasnprintf.c (VASNPRINTF): Fix free-memory read, flagged by clang-analyzer 3.4.2.
* filevercmp, posixtm: avoid compiler warnings with -O3Pádraig Brady2014-12-052-1/+10
| | | | | | | * lib/filevercmp.h (filevercmp): Tag with _GL_ATTRIBUTE_PURE * lib/posixtm.c: (IF_LINT): Define. (posix_time_parse): Use it to void a "may be used uninitialized" warning, seen only with -O3.
* argp: avoid extraneous translation and mem leak with empty pre docAndrei Borzenkov2014-12-021-2/+6
| | | | | | | | | * lib/argp-help.c (argp_doc): Never translate the empty string, when "\v" is the first or last character of the string, as that has a reserved meaning to return the header info from a po file. This also fixes a small memory leak in the !post case. The issue can be seen with this command for example: LC_MESSAGES=en_US grub2-mknetdir --help
* pipe-filter-gi, pipe-filter-ii: port to AIXDaiki Ueno2014-11-223-27/+21
| | | | | | | | | On AIX 7.1, 'select' is defined as static and cannot be referred to from inline function. * lib/pipe-filter-aux.h (nointr_select): Remove, manually expand the definition... * lib/pipe-filter-gi.c (filter_loop): ...here, and... * lib/pipe-filter-ii.c (pipe_filter_ii_execute): ...here.
* gen-uni-tables: untabifyDaiki Ueno2014-11-131-6/+6
| | | | * lib/gen-uni-tables.c: Untabify.
* gen-uni-tables: check out-of-range values added to 3-level tablesDaiki Ueno2014-11-131-0/+9
| | | | | | * lib/gen-uni-tables.c (output_category, output_bidi_category) (output_joining_type, output_ident_category): Check out-of-range values added to 3-level tables.
* gen-uni-tables: utilize 'assert'Daiki Ueno2014-11-131-86/+46
| | | | | | | | | | | | | | | | | | | | * lib/gen-uni-tables.c: Include <assert.h>. (output_category, output_combclass, output_decimal_digit_test) (output_decimal_digit, output_digit_test, output_digit) (output_numeric, get_mirror_value, fill_properties) (fill_property30, is_property_alphabetic) (is_property_default_ignorable_code_point) (is_property_uppercase, is_property_lowercase) (is_property_cased, is_property_case_ignorable) (is_property_changes_when_lowercased, is_property_iso_control) (is_property_math, fill_arabicshaping, output_joining_group) (fill_scripts, fill_blocks, output_lbp, fill_org_wbp) (output_wbp, fill_org_gbp, get_decomposition) (output_decomposition, fill_composition_exclusions) (debug_output_composition_tables, output_composition_tables) (redistribute_casefolding_rules, output_casing_rules): Use 'assert (EXPR);' instead of 'if (!EXPR) abort ();' for better error reporting.
* gen-uni-tables: cosmetic improvementsDaiki Ueno2014-11-131-27/+20
| | | | | | * lib/gen-uni-tables.c: Escape newlines in the Emacs file local variables specification. (is_outdigit): Remove unused function.
* fts: port to C89Paul Eggert2014-11-101-2/+2
| | | | | | Problem reported for MSVC 16 by Gisle Vanem in: http://lists.gnu.org/archive/html/bug-gnulib/2014-11/msg00027.html * lib/fts.c (fts_build): Avoid declaration before statement.
* unistd: port to iOSPaul Eggert2014-11-061-0/+6
| | | | | | Problem reported by André Klitzing in: http://lists.gnu.org/archive/html/bug-gnulib/2014-11/msg00013.html * lib/unistd.in.h (environ): Do not include crt_externs.h on iOS.
* obstack: do not reject malloc-style obstack_chunkfun, obstack_freefunPaul Eggert2014-11-051-4/+2
| | | | | | | | Problem reported by Alan Modra in: http://lists.gnu.org/archive/html/bug-gnulib/2014-11/msg00007.html * lib/obstack.h (obstack_chunkfun, obstack_freefun): Always cast the function arg, reverting this part of the previous change.
* obstack: avoid potentially-nonportable function castsPaul Eggert2014-11-042-55/+62
| | | | | | | | | | | | | | | | * lib/obstack.c (CALL_CHUNKFUN, CALL_FREEFUN): Remove, replacing with ... (call_chunkfun, call_freefun): New static functions. All uses changed. Avoid potentially-nonportable casts. (chunkfun_type, freefun_type): Remove typedefs; no longer used. (_obstack_begin_worker): Omit last two args, since they rely on potentially-nonportable casts. All callers changed. * lib/obstack.h (_OBSTACK_CAST): New macro. Use it everywhere the old API used a potentially-nonportable cast. The new API doesn't cast. (struct obstack): Use unions rather than requiring potentially-nonportable casts. (obstack_chunkfun, obstack_freefun): Return void.
* obstack: fix macro return valuesAlan Modra2014-11-041-12/+15
| | | | | | | | | | * lib/obstack.h (obstack_next_free): Return void *. (obstack_1grow_fast, obstack_blank_fast): Return void. For __GNUC__ macros: (obstack_1grow, obstack_blank): Remove now unnecessary (void) 0. For !__GNUC__ macros: (obstack_make_room, obstack_grow, obstack_grow0) (obstack_ptr_grow_fast, obstack_int_grow_fast): Return void.
* obstack: port to platforms that #define __alignof__Paul Eggert2014-11-041-1/+4
| | | | | | | * lib/obstack.c: Include <alignof.h> if !defined __alignof__, not if !_LIBC. We don't know of any platforms that #define __alignof__, but it might be useful in tests. Conversely, glibc assumes GCC.
* linkat: wrap to handle symlinks on OS X 10.10Pádraig Brady2014-11-031-2/+16
| | | | | | | * m4/linkat.m4 (gl_FUNC_LINKAT): linkat() is available on Yosemite but not usable because it doesn't support creating hardlinks to symlinks. Therefore add a generic test for this capability and fallback to our emulation if linkat() fails with ENOTSUP.
* mountlist: don't use libmount to decide on dummy/remotePádraig Brady2014-10-301-6/+13
| | | | | | | | | | * lib/mountlist.c (read_file_system_list): Don't use the libmount routines to determine whether a file system is dummy or remote, as they're not currently compatible. For example the remoteness is determined on file system type (for which the list seems incomplete), rather than simply checking for a ':' in the device name. Also libmount currently determines that 'tmpfs' is a dummy file system even though it has associated storage.
* obstack: prefer __alignof__ to alignofPaul Eggert2014-10-291-14/+18
| | | | | | | | | | | | This is for portability to pre-4.7 GCC when compiling glibc. See Joseph S. Myers in: http://sourceware.org/ml/libc-alpha/2014-10/msg00703.html * lib/obstack.c (__alignof__) [!_LIBC && !__GNUC__]: New macro, defined by including and using <alignof.h>. (MAX): New macro. (DEFAULT_ALIGNMENT, DEFAULT_ROUNDING): Redefine in terms of these. Do not use enums as they are not portable to some broken compilers. * modules/obstack (Depends-on): Depend on alignof, not stdalign.
* obstack: prefer alignof to calculating alignments by handPaul Eggert2014-10-291-6/+2
| | | | | | | * lib/obstack.c: Include <stdalign.h>. (struct fooalign): Remove. (DEFAULT_ALIGNMENT): Use alignof rather than the old offsetof hack. * modules/obstack (Depends-on): Add stdalign.
* obstack: use size_t alignments and check for overflowPaul Eggert2014-10-292-10/+16
| | | | | | | | | * lib/obstack.c, lib/obstack.h (_obstack_begin, _obstack_begin_1): * lib/obstack.c (_obstack_begin_worker, _obstack_newchunk): * lib/obstack.h (struct obstack.alignment_mask): Use _OBSTACK_SIZE_T, not int, for alignments. * lib/obstack.c (_obstack_newchunk): Fail if the size calculation overflows, e.g., when adding the alignment.
* obstack: 64-bit obstack support, part 3Alan Modra2014-10-292-55/+49
| | | | | | | | | | | | | | | | | | | | This finally enables full 64-bit obstack support. The glibc shared library specific code is removed from obstack.c too, and the error handling code conditionally compiled under control of another macro, _OBSTACK_NO_ERROR_HANDLER. * lib/obstack.h: Include string.h earlier. (_OBSTACK_INTERFACE_VERSION): Define. (_OBSTACK_SIZE_T, _CHUNK_SIZE_T): Define as size_t for version 2. * lib/obstack.c: Don't include shlib-compat.h. (OBSTACK_INTERFACE_VERSION): Delete. (_OBSTACK_ELIDE_CODE): Rename from ELIDE_CODE. Define when version 1 glibc code is compatible with version 2. Don't include stdio.h for __GNU_LIBRARY. (obstack_exit_failure, print_and_abort, obstack_alloc_failed_handler): Omit when _OBSTACK_NO_ERROR_HANDLER defined. Include stdio.h here. (_obstack_compat, _obstack, _obstack_newchunk, obstack_free): Delete glibc shared library specific source.
* obstack: 64-bit obstack support, part 2Alan Modra2014-10-292-50/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This gets us 4G obstack support, without changing ABI compatibility, apart from possibly introducing some signed/unsigned comparison warnings in code that uses obstack.h. a) Replace "int" size parameters, return values, and macro local vars with _OBSTACK_SIZE_T, an "unsigned int" for now. b) Make obstack.chunk_size a _CHUNK_SIZE_T, an "unsigned long" for now. c) Make all obstack macros checking available room use obstack_room. "next_free + desired > chunk_limit" may wrap the lhs for chunks allocated near the top of memory. d) Use unsigned comparisons, and macro locals to support >2G on 32-bit. * lib/obstack.h (_OBSTACK_SIZE_T): Define. Use throughout in place of "int" size parameters, return values and local vars. (_CHUNK_SIZE_T): Define. (struct obstack): Make chunk_size a _CHUNK_SIZE_T. Make temp union use an _OBSTACK_SIZE_T integer type. For __GNUC__ versions of the following macros... (obstack_room): Rename local var. (obstack_make_room): Use obstack_room. (obstack_grow, obstack_grow0, obstack_1grow, obstack_ptr_grow, obstack_int_grow, obstack_blank): Likewise. (obstack_finish): Use unsigned comparison when comparing aligned next_free against chunk_limit. (obstack_free): Cast OBJ to remove possible const qualifier. For !__GNUC__ versions of the following macros... (obstack_make_room): Use obstack_room. (obstack_grow, obstack_grow0, obstack_1grow, obstack_ptr_grow, obstack_int_grow, obstack_blank): Likewise. (obstack_finish): Use unsigned comparision when comparing aligned next_free against chunk_limit. (obstack_free): Use temp.p and same comparisons as __GNUC__ version. * lib/obstack.c (_obstack_begin_worker): Make "size" parameter _OBSTACK_SIZE_T. (_obstack_begin, _obstack_begin_1): Likewise. (_obstack_newchunk): Likewise for length parameter. Use size_t locals. (_obstack_memory_used): Return and use _OBSTACK_SIZE_T local.
* obstack: 64-bit obstack support, part 1Alan Modra2014-10-292-57/+36
| | | | | | | | | | | | | | | | | a) Correct calls to alloc function, to use a size_t arg. "long" is just wrong on targets like x86_64-mingw64 where "long" is 32 bits and "size_t" 64 bits. b) Consolidate _obstack_begin and _obstack_begin1 code. * lib/obstack.h (struct obstack <chunkfun>): Correct prototype to use "size_t" rather than "long". (_obstack_begin, _obstack_begin1): Likewise. (obstack_init, obstack_begin, obstack_specify_allocation_with_arg, obstack_chunkfun): Update alloc function casts. * lib/obstack.c (CALL_CHUNKFUN): Update chunkfun cast. (chunkfun_type, freefun_type): New typdefs. (_obstack_begin_worker): Split out from .. (_obstack_begin, _obstack_begin_1): ..here.
* obstack: tidy part 2Alan Modra2014-10-292-74/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | a) Don't be concerned about "not polluting the namespace with stddef.h symbols" in obstack.h, since gnulib string.h includes stddef.h anyway, and it seems unlikely that anyone would care. b) Don't roll our own slow memcpy in _obstack_newchunk. c) Rename obstack_free to _obstack_free. This makes the naming consistent with other obstack functions and obviates the need for __obstack_free. Ancient obstack.c defined both obstack_free and _obstack_free. We continue to do that for _LIBC via an alias. d) Miscellaneous macro fixes. The expression used to test for gcc-2.8 is clever, but nowadays gcc warns on undefined macros. You'll get an undefined macro warning if simulating an old gcc with -U__GNUC__ -U__GNUC_MINOR__ -D__GNUC__=1. * lib/obstack.h: Include stddef.h unconditionally. Formatting fixes. (PTR_INT_TYPE): Delete, replace with ptrdiff_t. (__obstack_free): Delete, update refs. (_obstack_free): Rename from obstack_free. (__extension__): Avoid undefined macro warning for __GNUC_MINOR__. (obstack_object_size, obstack_room): Parenthesise !__GNUC__ versions. * lib/obstack.c: Don't include stddef.h. (COPYING_UNIT): Delete. (_obstack_begin): Formatting fix. (_obstack_newchunk): Use memcpy to move existing object to new chunk. (_obstack_free): Rename from __obstack_free, update alias. Move undef of obstack_free to where it is needed.
* obstack: tidy part 1Alan Modra2014-10-292-44/+43
| | | | | | | | | | | | | | a) Rename temp fields. temp.tempint and temp.tempptr just looks ugly to me, and result in overlong lines after later patches. b) Move error handling code, to avoid a forward declaration and to simplify later patches in this series. * lib/obstack.h (struct obstack <temp>): Rename fields of union and update all uses. * lib/obstack.c: Include stdlib.h earlier. (obstack_exit_failure, obstack_alloc_failed_handler): Move later in file. (print_and_abort): Remove now redundant forward declaration.
* symlinkat: port to AIX 7.1Paul Eggert2014-10-182-5/+34
| | | | | | | | | | | | | * doc/posix-functions/symlinkat.texi (symlinkat): Mention AIX porting problem. * lib/symlinkat.c: Always include errno.h. (rpl_symlinkat) [HAVE_SYMLINKAT]: New function. * lib/unistd.in.h (symlinkat): Add replacement machinery. * m4/symlinkat.m4 (gl_FUNC_SYMLINKAT): Check symlinkat behavior. * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Add REPLACE_SYMLINKAT. * modules/symlinkat (Depends-on): Add fstatat if REPLACE_SYMLINKAT. (configure.ac): Also compile replacement if REPLACE_SYMLINKAT. * modules/unistd (unistd.h): Substitute REPLACE_SYMLINKAT.
* readlinkat: port to AIX 7.1Paul Eggert2014-10-182-13/+38
| | | | | | | | | | | | | | * doc/posix-functions/readlink.texi (readlink): * doc/posix-functions/readlinkat.texi (readlinkat): Mention AIX porting problem. * lib/readlinkat.c (rpl_readlinkat) [HAVE_READLINKAT]: New function. * lib/unistd.in.h (readlinkat): Add replacement machinery. * m4/readlinkat.m4 (gl_FUNC_READLINKAT): Check readlinkat signature. * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Add REPLACE_READLINKAT. * modules/readlinkat (configure.ac): Also compile replacement if REPLACE_READLINKAT. * modules/unistd (unistd.h): Substitute REPLACE_READLINKAT.
* modules/fcntl: fix error reporting by dupfdEli Zaretskii2014-10-071-3/+19
| | | | | | * lib/fcntl.c (dupfd) [_WIN32]: Don't overwrite the value of errno set by _open_osfhandle by EMFILE. Convert errors returned by DuplicateHandle to corresponding errno values.
* exclude: declare exclude_patopts staticJim Meyering2014-09-261-1/+1
| | | | | | | * lib/exclude.c (exclude_patopts): Declare static, to avoid triggering a -Wmissing-prototypes warning. The alternative (declaring it in the .h file) would require publicizing the private "struct patopts".
* dirname: support compilation with C++Werner LEMBERG2014-09-211-0/+8
| | | | * lib/dirname.h: Add necessary C linkage declarations.
* qsort_r: include <config.h>Paul Eggert2014-09-161-0/+4
| | | | | | Problem reported by Tom G. Christensen in: http://lists.gnu.org/archive/html/bug-gnulib/2014-09/msg00071.html * lib/qsort.c [!_LIBC]: Include <config.h> first.
* avltree-list: avoid compiler warningsDylan Cali2014-09-163-11/+14
| | | | | | | | | | | | | | * lib/gl_anytree_list2.h: Add _GL_ATTRIBUTE_PURE to avoid -Werror=suggest-attribute=pure. * lib/gl_array_list.c: Likewise. * lib/gl_avltree_list.c (gl_avltree_list_check_invariants): Add extern declaration to avoid -Werror=missing-prototypes. This is not added to a header as only exported for tests. Add (void) to the check_invariants() call to indicate we're discarding the result in this context which avoids -Werror=unused-value. Note we don't use ignore_value here to avoid a dependency as we know we'll not be adding __attribute__((warn_unused_result)) to check_invariants(). Add _GL_ATTRIBUTE_CONST to avoid -Werror=suggest-attribute=const.
* strerror_r-posix: support compilation with C++Werner LEMBERG2014-09-151-1/+13
| | | | * lib/strerror_r.c: Add necessary C linkage declarations.
* fcntl-h: fix compilation with Intel C++ compilerJohannes Zarl2014-09-111-2/+2
| | | | * lib/fcntl.in.h: ICC has the same issue as GCC <= 4.2.
* mountlist: use /proc/self/mountinfo when availableFridolin Pokorny2014-09-091-20/+62
| | | | | | | | | | | | | | Use libmount to propagate device IDs provided by Linux in /proc/self/mountinfo. This will give more accurate output when using df in chroot'ed environments as the device IDs are not determined by stat() which may be inaccurate within the chroot. * lib/mountlist.c (read_file_system_list): Use the libmount routines from util-linux to parse "/proc/self/mountinfo" or fall back to standard getmntent() processing. * m4/ls-mntd-fs.m4: Check for libmount only when 1-argument getmntent() is used, as is the case on GNU/Linux. * DEPENDENCIES: Mention the optional util-linux dependency.
* error: drop spurious semicolonEric Blake2014-09-041-1/+1
| | | | | | * lib/error.c (__error_at_line): Fix ';;'. Signed-off-by: Eric Blake <eblake@redhat.com>
* vasnprintf: fix bugs in width computationPaul Eggert2014-08-311-93/+81
| | | | | | | | * lib/vasnprintf.c (VASNPRINTF): Rework previous change, which introduced a bug, to avoid the warning in a different way. Avoid undefined behavior if the width arg is less than -INT_MAX. Avoid unnecessary use of HAS_WIDTH local.
* vasnprintf: Avoid signed/unsigned comparison warning.Thien-Thi Nguyen2014-08-311-1/+1
| | | | | * lib/vasnprintf.c (VASNPRINTF): To calculate padding, compare end addr of generated string w/ maximum end addr.
* parse-datetime: Avoid signed/unsigned comparison warningMats Erik Andersson2014-08-301-1/+1
| | | | | | * lib/parse-datetime.y (yylex): Compare pointer to end of buffer, instead of calculating difference of pointers. This removes an annoying warning, devoid of any use.
* qsort_r: new module, for GNU-style qsort_rPaul Eggert2014-08-293-0/+328
| | | | | | | | | | | | | | | This works even on FreeBSD, which has an incompatible qsort_r API. * MODULES.html.sh: Add it. * doc/glibc-functions/qsort_r.texi: It's now supported. * lib/qsort.c: New file, taken from glibc with minor changes inside "#ifndef _LIBC" and with an unnecessary "#include <alloca.h>" removed. * lib/qsort_r.c: New file, compiled only on FreeBSD. * lib/stdlib.in.h (qsort_r): Declare in the usual way. * m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): * modules/qsort_r, modules/qsort_r-tests: New files. * modules/stdlib (Makefile): Set up its defaults. * tests/test-qsort_r.c: New file.