summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* getopt: harmonize comments with glibcZack Weinberg2017-04-062-31/+29
| | | | | | | | | The comments explaining how the behavior of 'getopt' varies depending on whether it's the standalone version and whether there are special characters at the beginning of the options string were inconsistent between gnulib and glibc, and also out of sync with the code. * lib/getopt.c, lib/getopt_int.h: Harmonize comments with glibc.
* getopt: remove USE_NONOPTION_FLAGSZack Weinberg2017-04-062-100/+2
| | | | | | | | | | | | | | | | | | | | | | | getopt includes code to parse an environment variable named _XXX_GNU_nonoption_argv_flags_ (where XXX is the current process's PID in decimal); but all of it has been #ifdefed out since 2001, with no official way to turn it back on. According to commentary in glibc's config.h.in, bash version 2.0 set this environment variable to indicate argv elements that were the result of glob expansion and therefore should not be treated as options, but the feature was "disabled later" because "it caused problems". According to bash's CHANGES file, "later" was release 2.01; it gives no more detail about what the problems were. Version 2.0 of bash was released on the last day of 1996, and version 2.01 in June of 1997. Twenty years later, I think it is safe to assume that this environment variable isn't coming back. * lib/getopt_int.h: Remove all #ifdef USE_NONOPTION_FLAGS blocks. * lib/getopt.c: Likewise. Also remove SWAP_FLAGS and the __libc_argc and __libc_argv externs, which were only used by
* getopt: tabify, in preparation for merge with glibcZack Weinberg2017-04-063-751/+751
| | | | | | | | | | glibc sticks to the GNU default of indenting with a mix of 8-column tabs and spaces; make the gnulib copy match. getopt.h is not included because it is *not* going to be merged in its present form. * getopt.c, getopt1.c, getopt_int.h: Tabify.
* glob: Fix invalid free() call.Bruno Haible2017-03-311-1/+4
| | | | | | * lib/glob.c (glob): Reset malloc_home_dir when assigning a pointer to static storage to home_dir. Reported by Coverity via Tim Rühsen.
* glob: Fix memory leaks.Bruno Haible2017-03-311-2/+11
| | | | | * lib/glob.c (glob): Free allocated memory before returning. Reported by Coverity via Tim Rühsen.
* md5, sha1, sha256, sha512: Add comments regarding correctness.Bruno Haible2017-03-318-12/+24
| | | | | | | | | | | | * lib/md5.h (buflen): Add comments regarding range. * lib/sha1.h (buflen): Likewise. * lib/sha256.h (buflen): Likewise. * lib/sha512.h (buflen): Likewise. * lib/md5.c (md5_process_bytes): Add comment why memmove is not needed. * lib/sha1.c (sha1_process_bytes): Likewise. * lib/sha256.c (sha256_process_bytes): Likewise. * lib/sha512.c (sha512_process_bytes): Likewise. Reported by Coverity via Tim Rühsen.
* getopt: merge from glibcPaul Eggert2017-03-224-68/+87
| | | | | | | | | | | | This does not change anything substantial; it merely simplifies hypothetical merges back to glibc. * lib/getopt.c, lib/getopt.in.h, lib/getopt1.c, lib/getopt_int.h: Change copyright notice to match what is in glibc. * lib/getopt.c: Reorder includes to match glibc. Remove uses of USE_IN_LIBIO. Remove 'register'. In __LIBC code, use __open_memstream rather than open_memstream and __glibc_likely instead of __builtin_expect. * lib/getopt.in.h (__posix_getopt) [!__GETOPT_PREFIX]: New decl.
* dfa: make [0-9] faster in non-C localesPaul Eggert2017-03-211-23/+12
| | | | | | | | Problem reported by John P. Linderman (Bug#26193). * lib/dfa.c (parse_bracket_exp): Remove redundant assignment. If both ends of the range are ASCII digits, do not worry about multi-character collating sequences and the like. Be consistent about using isalpha as a precondition for setbit_case_fold_c.
* lock: Fix compilation error with HP-UX IA64 cc.Bruno Haible2017-03-191-1/+3
| | | | | * lib/glthread/lock.h (pthread_rwlockattr_setkind_np): Don't declare weak on non-glibc platforms.
* stdalign: tweak version# and test for HP-UX IA64Paul Eggert2017-03-191-1/+1
| | | | | | | | | | | Problems reported by Bruno Haible in: http://lists.gnu.org/archive/html/bug-gnulib/2017-03/msg00078.html * lib/stdalign.in.h (_Alignas): * m4/stdalign.m4 (gl_STDALIGN_H): Use octal, not decimal, for __HP_cc version. Perhaps HP formerly used octal (as that is how they document it), but it is decimal in practice now and the ancient implementations no longer matter. * tests/test-stdalign.c (main) [__HP_cc && __ia64]: Skip test.
* vma-iter: Add support for Solaris.Bruno Haible2017-03-194-4/+260
| | | | | | | | * lib/vma-iter.c (vma_iterate): On Solaris, use the /proc filesystem approach. * lib/vma-iter.h (VMA_ITERATE_SUPPORTED): Define also on Solaris. * lib/get-rusage-as.c: Update comment about Solaris. * lib/get-rusage-data.c: Likewise.
* vma-iter: Prefer HP-UX specific API on HP-UX.Bruno Haible2017-03-192-34/+34
| | | | | | * lib/vma-iter.c (vma_iterate): Move HP-UX specific implementation up. * lib/vma-iter.h: Update. Just in case HP-UX ever implements mquery().
* stdalign: restore previous behavior for HP-UX IA64Paul Eggert2017-03-181-1/+1
| | | | | | | | | See Bruno Haible's email in: http://lists.gnu.org/archive/html/bug-gnulib/2017-03/msg00066.html which cites p 150 of a manual saying that 'aligned' works on Itanium. * lib/stdalign.in.h (_Alignas): Assume the '061200' applies to Itanium, not to PA-RISC. * m4/stdalign.m4 (gl_STDALIGN_H): Adjust to match stdalign.in.h.
* stat-time, timespec: Support use of the header files in C++ mode.Bruno Haible2017-03-182-0/+16
| | | | | * lib/stat-time.h: Add "C" linkage declaration. * lib/timespec.h: Likewise.
* stdalign: Make it work with HP-UX cc.Bruno Haible2017-03-171-1/+1
| | | | | | * lib/stdalign.in.h (_Alignas): Don't define for HP-UX cc. * m4/stdalign.m4 (gl_STDALIGN_H): No need to enable the extra test for HP-UX cc.
* stdint: Fix test compilation failure with HP-UX 11 cc.Bruno Haible2017-03-171-12/+31
| | | | | | | * lib/stdint.in.h (_STDINT_MIN): Remove macro. (_STDINT_UNSIGNED_MIN, _STDINT_SIGNED_MIN): New macros. (PTRDIFF_MIN, SIG_ATOMIC_MIN, WCHAR_MIN, WINT_MIN): Define using _STDINT_UNSIGNED_MIN, _STDINT_SIGNED_MIN.
* vma-iter: Add support for HP-UX.Bruno Haible2017-03-154-4/+44
| | | | | | | | | * modules/vma-iter (configure.ac): Check for 'pstat_getprocvm'. * lib/vma-iter.c (vma_iterate): On HP-UX, use pstat_getprocvm(). * lib/vma-iter.h (VMA_ITERATE_SUPPORTED): Define also on HP-UX. * lib/get-rusage-as.c: Update comment about HP-UX. * lib/get-rusage-data.c: Likewise. (get_rusage_data): Use get_rusage_data_via_setrlimit.
* limits-h: Make it work with HP-UX cc.Bruno Haible2017-03-151-0/+11
| | | | | * lib/limits.in.h (LLONG_MIN, LLONG_MAX, ULLONG_MAX): Define if not defined.
* freadahead: Silence warning on DragonFlyBSD.Bruno Haible2017-03-151-0/+5
| | | | * lib/freadahead.c (__sreadahead): Declare ourselves.
* vma-iter: Add comment about AIX.Bruno Haible2017-03-151-0/+4
| | | | | * lib/vma-iter.c: Add comment about why this module is not implemented on AIX.
* snippets: move unadjusted snippet sources to libPaul Eggert2017-03-145-0/+497
| | | | | | | | | | | | | | | | | Problem reported by Michal Privoznik in: http://lists.gnu.org/archive/html/bug-gnulib/2017-03/msg00039.html * lib/_Noreturn.h: Rename from build-aux/snippet/_Noreturn.h. * lib/arg-nonnull.h: Rename from build-aux/snippet/arg-nonnull.h. * lib/c++defs.h: Rename from build-aux/snippet/c++defs.h. * lib/unused-parameter.h: Rename from build-aux/snippet/unused-parameter.h. * lib/warn-on-use.h: Rename from build-aux/snippet/warn-on-use.h. * modules/snippet/_Noreturn (Files:, _NORETURN_H): * modules/snippet/arg-nonnull (Files:, ARG_NONNULL_H): * modules/snippet/c++defs (Files:, CXXDEFS_H): * modules/snippet/unused-parameter (Files:, UNUSED_PARAMETER_H): * modules/snippet/warn-on-use (Files: WARN_ON_USE_H): Adjust to file renamings.
* vma-iter: Let callers know about error.Bruno Haible2017-03-102-8/+20
| | | | | * lib/vma-iter.h (vma_iterate): Return 'int', not 'void'. * lib/vma-iter.c (vma_iterate): Return -1 in case of error.
* dtotimespec: simplifyPaul Eggert2017-03-041-8/+2
| | | | * lib/dtotimespec.c (dtotimespec): Simplify.
* nproc: Refactor large function.Bruno Haible2017-02-261-63/+74
| | | | | | * lib/nproc.c (num_processors_ignoring_omp): New function, extracted from num_processors. (num_processors): In this function, only deal with OMP.
* nproc: adjust handling of OpenMP environment variablesPádraig Brady2017-02-261-29/+18
| | | | | | | | | | | | | | | | Adjust to match the return value from omp_get_num_threads(), i.e.: - honor OMP_THREAD_LIMIT without OMP_NUM_THREADS - Treat 0 as an invalid value and ignore Also remove the call to omp_get_num_threads() added in the previous recent commit, because it's ineffective without the omp pragmas in place. * lib/nproc.c (parse_omp_threads): Return 0 if specified, so that it can be ignored. (num_processors): Honor OMP_THREAD_LIMIT even without OMP_NUM_THREADS being set. Also fix a typo in the environment variable being checked, from the previous recent commit.
* nproc: support nested OMP_NUM_THREADS, and OMP_THREAD_LIMITPádraig Brady2017-02-261-22/+60
| | | | | | | | | | | | * lib/nproc.c (parse_omp_threads): A new function refactored from num_processors() to support parsing both of the above environment variables. (num_processors): Prefer using omp_get_num_threads() with [_OPENMP] to accurately reflect the current OpenMP nesting level. Also support the OMP_THREAD_LIMIT environment variable to limit the max value determined from OMP_NUM_THREADS. * modules/nproc: Depend on minmax header. Suggested by Oliver Heimlich.
* ftoastr: port to -Wdouble-promotionPaul Eggert2017-02-241-3/+8
| | | | | | Work around -Wdouble-promotion false alarm in recent GCCs. * lib/ftoastr.c (PROMOTED_FLOAT): New macro. (ftoastr_snprintf, FTOASTR): Use it.
* lock tests: Fix build failure on GNU/Hurd (regression from 2017-01-05).Bruno Haible2017-02-212-2/+2
| | | | | | | | | Reported by Rene Saavedra <rennes@openmailbox.org> in https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25821 via Paul Eggert. * lib/glthread/lock.h: On glibc systems without PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP, use the fallback implementation of rwlocks. * lib/glthread/lock.c: Likewise.
* xbinary-io: Fix inlining.Bruno Haible2017-02-161-1/+1
| | | | * lib/xbinary-io.c: Set XBINARY_IO_INLINE, not XSETMODE_INLINE.
* xbinary-io: rename from xsetmodePaul Eggert2017-02-164-16/+25
| | | | | | | | | | | | | | | | | | This patch is taken from suggestions by Bruno Haible in: http://lists.gnu.org/archive/html/bug-gnulib/2017-02/msg00060.html http://lists.gnu.org/archive/html/bug-gnulib/2017-02/msg00061.html * lib/binary-io.c (__gl_setmode_check): Set errno to EINVAL, not ENOTTY, when it is an inappropriate device. * lib/binary-io.h (SET_BINARY): Resurrect. * lib/xbinary-io.c: Rename from lib/xsetmode.c. (xset_binary_mode_error): Rename from xsetmode_error. * lib/xbinary-io.h: Rename from lib/xsetmode.h. (xset_binary_mode): Rename from xsetmode. All uses changed. * modules/xbinary-io: Rename from modules/xsetmode. Update file names. * tests/test-binary-io.sh (tmpfiles): Remove no-longer-used file name. * NEWS: Update to match revised behavior.
* xsetmode: new modulePaul Eggert2017-02-154-15/+133
| | | | | | | | | | | | | This is to fix a problem noted by Eric Blake. Code was using xfreopen to change files to binary mode, but this fails for stdout when in append mode. Such code should use xsetmode instead. * NEWS: Document incompatible changes to binary-io module. * lib/binary-io.c (__gl_setmode_check) [__DJGPP__ || __EMX__]: New function. * lib/binary-io.h (__gl_setmode): Rename from set_binary_mode. (set_binary_mode): New function, which also checks for tty. * lib/xsetmode.c, lib/xsetmode.h, modules/xsetmode: New files.
* headers: fix begin-end typosPaul Eggert2017-02-142-8/+2
| | | | | * lib/mbfile.h, lib/se-selinux.in.h: Fix typos by replacing _GL_INLINE_HEADER_BEGIN with _GL_INLINE_HEADER_END.
* selinux-h: port to PGI 16.10Paul Eggert2017-02-141-14/+13
| | | | | * lib/se-selinux.in.h: Don't assume that include_next skips over duplicate -I DIR options.
* argp: port to PGI 16.10Paul Eggert2017-02-141-0/+7
| | | | * lib/argp-pin.c (dummy): Declare as needed to make file nonempty.
* unicase: Update function protoype to match definitionDarshit Shah2017-02-131-1/+2
| | | | | | | * lib/unicase/special-casing.h (gl_unicase_special_lookup): Gperf 3.1 uses 'size_t' as the datatype for the 'len' parameter in the functions it generates. Update the prototype specified here to match the newly generated function.
* glob: port better to emscriptenPaul Eggert2017-02-121-3/+3
| | | | | | Problem reported by Bruno Haible in: http://lists.gnu.org/archive/html/bug-gnulib/2017-02/msg00031.html * lib/glob.c (glob): Don't assume HAVE_GETPWNAM_R || _LIBC.
* search: Don't assume that tsearch() exists if 'VISIT' is defined.Bruno Haible2017-02-111-1/+1
| | | | | | * m4/search_h.m4 (gl_SEARCH_H): Determine HAVE_TYPE_VISIT. * modules/search (Makefile.am): Substitute HAVE_TYPE_VISIT. * lib/search.in.h (VISIT): Define if HAVE_TYPE_VISIT is 0.
* lock: Fix link error (regression from 2017-01-05).Bruno Haible2017-02-011-0/+3
| | | | | | | * lib/glthread/lock.h [USE_POSIX_THREADS_WEAK]: Declare also pthread_rwlockattr_init, pthread_rwlockattr_setkind_np, pthread_rwlockattr_destroy weak. Reported by Tom G. Christensen <tgc@jupiterrise.com>.
* Port to PGI 16.10 x86-64Paul Eggert2017-01-304-13/+20
| | | | | | | | | | | | | | | | | | | | This patch fixes one real bug in gl_anylinked_list2.h, along with some minor glitches that are not bugs. It does not silence PGI’s thousands of bogus warnings when compiling test-intprops.c. Fortunately, the warnings do not cause a failure. * lib/c-ctype.h (_C_CTYPE_LOWER_A_THRU_F_N, _C_CTYPE_LOWER_N): Rename parameter to avoid PGI warning about ‘#define f(n) 'n'’. My goodness, PGI goes back a long ways - this predates C89! * lib/gl_anylinked_list2.h (ASYNCSAFE): Fix bug caught by PGI. For example, ASYNCSAFE (const void *) should expand to ‘const void *volatile’, not to ‘volatile const void *’. * lib/spawn.in.h (POSIX_SPAWN_USEVFORK): Don't define if already defined. * lib/verify.h (verify) [!__GNUC__]: Use shorter albeit meaningless string to bypass silly compiler limits. * tests/infinity.h (Infinityf, Infinityd, Infinityl) [__PGI]: * tests/nan.h (NaNf, NaNd, NaNl): Use static functions to avoid misguided compiler diagnostics. Is there some reason we don’t use static functions on all platforms?
* parse-datetime: handle timezones reentrantlyPaul Eggert2017-01-202-119/+111
| | | | | | | | | | | | | | | | | | This API change was prompted by a report by Pádraig Brady in: https://bug.debian.org/851934#10 To help fix the bug, make parse_datetime2 more reentrant. * NEWS: Document this incompatible change. * lib/parse-datetime.h, lib/parse-datetime.y (parse_datetime2): Add two arguments, the timezone and the timezone name. All callers changed. If TZ="..." is specified, use it for calculating defaults. * lib/parse-datetime.y: Don't include xalloc.h or use xmalloc, as this code should be usable in a library. (mktime_ok, get_effective_timezone): Accept timezone arg too. All callers changed. (get_tz): Remove. (get_effective_timezone): Check for failures. * modules/parse-datetime: Add time_r, time_rz. Remove xalloc.
* time_rz: fix comment typoPaul Eggert2017-01-201-2/+2
|
* localename: port to cygwin 2.6Eric Blake2017-01-201-0/+13
| | | | | | | | | | | | | | | | | | Cygwin 2.6 introduced uselocale() and thread-local locales in general, but lacks any way to get at the name of each portion of a locale_t object short of peeking behind an opaque object. Cygwin has just been patched to add NL_LOCALE_NAME() patterned after glibc's extension of the same name[1], but as that version of Cygwin has not yet been released, we might as well work around it in the meantime. [1] https://sourceware.org/ml/newlib/2017/msg00071.html * lib/localename.c (gl_locale_name_thread_unsafe): Add clause for Cygwin. * modules/localename (Depends-on): Add extensions, since NL_LOCALE_NAME() is not visible without it. Signed-off-by: Eric Blake <eblake@redhat.com>
* dfa: fix memory leak in parseNorihiro Tanaka2017-01-181-0/+1
| | | | | | | Problem reported by Arnold Robbins in: http://lists.gnu.org/archive/html/bug-grep/2017-01/msg00006.html * lib/dfa.c (epsclosure): Do it.
* localeinfo: case_folded_counterparts and WEOFPaul Eggert2017-01-152-3/+3
| | | | | | | * NEWS: Document this. * lib/localeinfo.c (case_folded_counterparts): First arg is now wint_t, not wchar_t. This generalizes the function to also work on WEOF, where it returns 0.
* dfa: port to gcc -fsanitize=undefinedPaul Eggert2017-01-151-1/+2
| | | | | * lib/dfa.c (copy): Don’t pass NULL with size 0 to memcpy, as this runs afoul of gcc -fsanitize=undefined.
* strftime: %z is -00 if unknownPaul Eggert2017-01-141-6/+6
| | | | | | | | | * lib/strftime.c (DO_TZ_OFFSET): Omit arg 'negative'; it's now the caller's responsibility to set 'negative_number'. All uses changed. (__strftime_internal): Put '-' before a zero UTC offset if the time zone abbreviation starts with "-", which is the recently-introduced tzdb convention for an unknown UTC offset that is arbitrarily set to 0. * tests/test-strftime.c: Test for this.
* dfa: minor simplification with emptysetPaul Eggert2017-01-101-4/+1
| | | | * lib/dfa.c (build_state): Simplify by using emptyset.
* dfa: shrink constraints from 4 bits to 3Paul Eggert2017-01-101-16/+16
| | | | | | | | | | * lib/dfa.c (newline_constraint, letter_constraint) (other_constraint, prev_newline_dependent) (prev_letter_dependent, NO_CONSTRAINT, BEGLINE_CONSTRAINT) (ENDLINE_CONSTRAINT, BEGWORD_CONSTRAINT, ENDWORD_CONSTRAINT) (LIMWORD_CONSTRAINT, NOTLIMWORD_CONSTRAINT): Constraints need only 3 bits, not 4. Using smaller integers shrinks the code a bit and makes grep a tad faster on x86-64.
* dfa: omit unnecessary ptrdiff_t checkPaul Eggert2017-01-101-2/+0
| | | | | * lib/dfa.c (alloc_position_set): Do not worry about ptrdiff_t overflow, since xnmalloc does that now.
* dfa: omit unnecessary allocationPaul Eggert2017-01-101-2/+0
| | | | | * lib/dfa.c (dfaanalyze): Do not allocate follow set, since an all-zero follow set works just fine.