Commit Graph

151 Commits

Author SHA1 Message Date
Nobody 790298dd8d glibc with MCST patches (25.014.1) 2022-08-11 21:25:08 +03:00
Joseph Myers 04277e02d7 Update copyright dates with scripts/update-copyrights.
* All files with FSF copyright notices: Update copyright dates
	using scripts/update-copyrights.
	* locale/programs/charmap-kw.h: Regenerated.
	* locale/programs/locfile-kw.h: Likewise.
2019-01-01 00:11:28 +00:00
Paul Eggert c0feb731d5 regex: simplify Gnulib port
This simplifies the code, by removing stuff intended for porting
to Gnulib but no longer needed there.
* posix/regcomp.c [!_LIBC]: No need to put #ifdef _LIBC around
uses of libc_hidden_def, weak_alias.
* posix/regcomp.c, posix/regexec.c: Use __restrict rather than
_Restrict_ except for public-facing headers.
* posix/regex_internal.h (attribute_hidden) [!_LIBC]:
Remove; already defined elsewhere.
* posix/regex.c, posix/regex_internal.h:
Use __GNUC_PREREQ instead of rolling our own.
* posix/regex_internal.h (__GNUC_PREREQ): Remove duplicate defn.
2018-12-27 11:17:06 -08:00
Paul Eggert f4efbdfb44 regex: __builtin_expect → __glibc_unlikely
[BZ#23744]
This refactoring was prompted by a problem when the regex code is
used as part of Gnulib and when the builder’s compiler does not grok
__builtin_expect.  Problem reported for Gawk by Nelson H.F. Beebe in:
https://lists.gnu.org/r/bug-gnulib/2018-09/msg00137.html
Although this refactoring does not fix the problem directly,
we might as well have Gawk use the now-preferred glibc style for when
__builtin_expect is unavailable.
* posix/regex_internal.h (BE): Remove.
All uses replaced by __glibc_unlikely or __glibc_likely.
2018-10-14 23:36:55 -05:00
Paul Eggert c77bf91b43 regex: Gnulib unibyte RRI uses bytes not chars
Adjust the non-glibc code to agree with what Gawk needs for
rational range interpretation (RRI) for regular expression ranges.
In unibyte locales, Gawk wants ranges to use the underlying byte
rather than the character code point.  This change does not affect
glibc proper.
* posix/regcomp.c (parse_byte) [!LIBC && RE_ENABLE_I18N]:
In unibyte locales, use the byte value rather than
running it through btowc.
2018-08-10 14:27:56 -07:00
Paul Eggert fa67ba06ee regex: fix memory leak in Gnulib
Problem and fix reported by Assaf Gordon in:
https://lists.gnu.org/r/bug-gnulib/2018-07/txtqLKNwBdefE.txt
* posix/regcomp.c (free_charset) [!_LIBC]: Free range_starts and
range_ends members too, as they are defined in 'struct
re_charset_t' even if not _LIBC.  This affects only Gnulib.
2018-08-01 13:22:58 -07:00
Florian Weimer 786658a088 regcomp: Fix off-by-one bug in build_equiv_class [BZ #23396]
This bug is very similar to bug 23036: The existing code assumed that
the length count included the length byte itself.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-07-20 11:58:51 +02:00
Adhemerval Zanella eb04c21373 posix: Sync gnulib regex implementation
This patch syncs the regex implementation with gnulib (commit 0ee5212).
Only two changes in GLIBC regex testing are required:

  1. posix/bug-regex28.c: as previously discussed [1] the change of
     expected results on the pattern should be safe.

  2. posix/PCRE.tests: the ERE (a)|\1 is malformed (in the sense that
     the \1 doesn't mean anything) and although current GLIBC accepts
     it has undefined behavior.  This patch removes the specific test.

This sync contains some patches from thread 'Regex: Make libc regex
more usable outside GLIBC.' [2] which have been pushed upstream in
gnulib.  This patches also fixes some regex issues (BZ #23233,
BZ #21163, BZ #18986, BZ #13762) and I did not add testcases for
both #23233 and #13762 because I couldn't think a simple way to
trigger the expected failure path to trigger them.

Checked on x86_64-linux-gnu and i686-linux-gnu.

	[BZ #23233]
	[BZ #21163]
	[BZ #18986]
	[BZ #13762]
	* posix/Makefile (tests): Add bug-regex37 and bug-regex38.
	* posix/PCRE.tests: Remove invalid test.
	* posix/bug-regex28.c: Fix expected values for used syntax.
	* posix/bug-regex37.c: New file.
	* posix/bug-regex38.c: Likewise.
	* posix/regcomp.c: Sync with gnulib.
	* posix/regex.c: Likewise.
	* posix/regex.h: Likewise.
	* posix/regex_internal.c: Likewise.
	* posix/regex_internal.h: Likewise.
	* posix/regexec.c: Likewise.

[1] https://sourceware.org/ml/libc-alpha/2017-12/msg00807.html
[2] https://sourceware.org/ml/libc-alpha/2017-12/msg00237.html
2018-07-04 09:54:45 -03:00
Joseph Myers 688903eb3e Update copyright dates with scripts/update-copyrights.
* All files with FSF copyright notices: Update copyright dates
	using scripts/update-copyrights.
	* locale/programs/charmap-kw.h: Regenerated.
	* locale/programs/locfile-kw.h: Likewise.
2018-01-01 00:32:25 +00:00
Arnold Robbins 5069ff3284 regex: Fix spelling in comments.
Fix the spelling in various comments throughout the
regex implementation. These changes are also present
in gnulib and will be integrated there also, see:
https://sourceware.org/ml/libc-alpha/2017-12/msg00688.html
2017-12-19 19:28:21 -08:00
Paul Eggert 0285e6bdf2 * posix/regcomp.c (init_word_char): Add comments. 2017-11-22 11:22:30 -08:00
Paul Eggert 567d8c1f68 regex: don't assume uint64_t or uint32_t
This avoids -Werror=overflow errors for 32-bit systems in
the 64-bit case.  Problem reported by Joseph Myers in:
https://sourceware.org/ml/libc-alpha/2017-11/msg00694.html
Also, when this code is used in Gnulib it ports to platforms
that lack uint64_t and uint32_t.  The C standard doesn't guarantee
them, and on some 32-bit compilers there is no uint64_t.
Problem reported by Gianluigi Tiesi in:
http://lists.gnu.org/archive/html/bug-gnulib/2012-03/msg00154.html
* posix/regcomp.c (init_word_char): Don't assume that the types
uint64_t and uint32_t exist.  Adapted from Gnulib patch
2012-05-27T06:40:00!eggert@cs.ucla.edu.  See:
https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=252b52457da7887667c036d18cc5169777615bb0
2017-11-20 20:40:17 -08:00
H.J. Lu b68f862056 Hide internal regex functions [BZ #18822]
Hide internal regex functions to allow direct access within libc.so and
libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/regex.h (__re_compile_fastmap): Add attribute_hidden.
	(__regcomp): Add libc_hidden_proto.
	(__regexec): Likewise.
	(__regfree): Likewise.
	* posix/regcomp.c (__regcomp): Add libc_hidden_def.
	(__regfree): Likewise.
	* posix/regexec.c (__regexec): Likewise.
2017-10-01 15:53:15 -07:00
Florian Weimer b41bd5bc83 posix: Remove internal_function attribute 2017-08-31 18:52:00 +02:00
Joseph Myers bfff8b1bec Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
Joseph Myers f7a9f785e5 Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
Joseph Myers 80d9be8122 Convert miscellaneous function definitions to prototype style.
This patch converts various miscellaneous functions definitions in
glibc, found with grep and not covered by my previous scripted
conversions, from old-style K&R to prototype-style.  These changes
were made manually.  This is not necessarily exhaustive as formatting
variants may have prevented my grep from finding some such
definitions.

Regarding the changes to files from GMP, they may originally have been
omitted when removing __STDC__ conditionals because of the files
coming from another package, but (a) GMP no longer has __STDC__
conditionals there anyway and (b) we don't try to keep these files
verbatim in sync with GMP (and there are licensing differences), so
making the change to them in glibc seems reasonable.

Tested for x86_64 and x86 (testsuite - this patch affects files
containing assertions).

	* debug/fortify_fail.c (__fortify_fail): Convert to
	prototype-style function definition.  Use internal_function.
	* libio/genops.c (save_for_backup): Convert to prototype-style
	function definition.
	* libio/wgenops.c (save_for_wbackup): Likewise.
	* login/grantpt.c (grantpt): Likewise.
	* login/ptsname.c (ptsname): Likewise.
	(__ptsname_r): Likewise.
	* login/unlockpt.c (unlockpt): Likewise.
	* mach/msgserver.c (__mach_msg_server): Likewise.
	* misc/efgcvt.c (__APPEND (FUNC_PREFIX, fcvt)): Likewise.
	(__APPEND (FUNC_PREFIX, ecvt)): Likewise.
	(__APPEND (FUNC_PREFIX, gcvt)): Likewise.
	* misc/efgcvt_r.c (__APPEND (FUNC_PREFIX, fcvt_r)): Likewise.
	(__APPEND (FUNC_PREFIX, ecvt_r)): Likewise.
	* nptl/cleanup_compat.c (_pthread_cleanup_push): Likewise.
	* nptl/cleanup_defer_compat.c (_pthread_cleanup_push_defer):
	Likewise.
	* nptl/libc_pthread_init.c (__libc_pthread_init): Likewise.  Use
	internal_function.
	* nptl/pthread_atfork.c (__pthread_atfork): Convert to
	prototype-style function definition.
	* nptl/pthread_create.c (__pthread_create_2_1): Likewise.
	[SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_1)]
	(__pthread_create_2_0): Likewise.
	* nptl/pthread_key_create.c (__pthread_key_create): Likewise.
	* nptl/register-atfork.c (__register_atfork): Likewise.
	* posix/glob.c (glob): Likewise.
	* posix/regcomp.c (re_comp): Likewise.
	* posix/regexec.c (re_exec): Likewise.
	* stdlib/add_n.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/cmp.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/divmod_1.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/divrem.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/lshift.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/mod_1.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/mul.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/mul_n.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/rshift.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/strtod.c (INTERNAL (STRTOF)): Convert to prototype-style
	function definition.
	(STRTOF): Likewise.
	* stdlib/strtod_l.c (__STRTOF): Likewise.
	* stdlib/strtol.c (INTERNAL (strtol)): Likewise.
	* stdlib/strtol_l.c (INTERNAL (__strtol_l)): Likewise.
	(__strtol_l): Likewise.
	* stdlib/sub_n.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* string/memrchr.c (MEMRCHR): Convert to prototype-style function
	definition.
	* string/strcasecmp.c (LOCALE_PARAM_DECL): Remove macro.
	[USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include argument
	type.
	(__strcasecmp): Convert to prototype-style function definition.
	* string/strncase.c (LOCALE_PARAM_DECL): Remove macro.
	[USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include argument
	type.
	(__strncasecmp): Convert to prototype-style function definition.
	* sunrpc/pm_getport.c (__libc_rpc_getport): Likewise.
	* sunrpc/xdr.c (xdr_union): Likewise.
	* sunrpc/xdr_array.c (xdr_array): Likewise.
	* sunrpc/xdr_ref.c (xdr_reference): Likewise.
	* sysdeps/m68k/m680x0/fpu/s_atan.c (__CONCATX(__,FUNC)): Likewise.
	* sysdeps/m68k/m680x0/fpu/s_isinf.c (__CONCATX(__,FUNC)):
	Likewise.
	* sysdeps/m68k/m680x0/fpu/s_scalbn.c (__CONCATX(__scalbn,suffix):
	Likewise.
	* sysdeps/m68k/m680x0/fpu/s_sincos.c (CONCATX(__,FUNC)): Likewise.
	* sysdeps/unix/sysv/linux/i386/scandir64.c (__old_scandir64):
	Likewise.
	* time/strftime_l.c (LOCALE_PARAM_DECL): Remove macro.
	(LOCALE_PARAM_PROTO): Likewise.
	[_LIBC && USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include
	argument type.
	(ut_argument_spec): Remove macro.
	(ut_argument_spec_iso): Rename to ut_argument_spec.
	(memcpy_lowcase): Use LOCALE_PARAM in declaration.  Convert to
	prototype-style function definition.
	(memcpy_uppcase): Likewise.
	(__strftime_internal): Likewise.
	(my_strftime): Likewise.
	* time/strptime_l.c (LOCALE_PARAM_PROTO): Remove macro.
	(LOCALE_PARAM_DECL): Likewise.
	[_LIBC] (LOCALE_PARAM): Include argument type.
	(__strptime_internal): Convert to prototype-style function
	definition.
	(strptime): Likewise.
	* wcsmbs/wcscasecmp.c (LOCALE_PARAM_DECL): Remove macro.
	[USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include argument
	type.
	(__wcscasecmp): Convert to prototype-style function definition.
	* wcsmbs/wcsncase.c (LOCALE_PARAM_DECL): Remove macro.
	[USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include argument
	type.
	(__wcsncasecmp): Convert to prototype-style function definition.
2015-10-20 21:27:22 +00:00
Joseph Myers 9dd346ff43 Convert 113 more function definitions to prototype style (files with assertions).
This mostly automatically-generated patch converts 113 function
definitions in glibc from old-style K&R to prototype-style.  Following
my other recent such patches, this one deals with the case of function
definitions in files that either contain assertions or where grep
suggested they might contain assertions - and thus where it isn't
possible to use a simple object code comparison as a sanity check on
the correctness of the patch, because line numbers are changed.

A few such automatically-generated changes needed to be supplemented
by manual changes for the result to compile.  openat64 had a prototype
declaration with "..." but an old-style definition in
sysdeps/unix/sysv/linux/dl-openat64.c, and "..." needed adding to the
generated prototype in the definition (I've filed
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68024> for diagnosing
such cases in GCC; the old state was undefined behavior not requiring
a diagnostic, but one seems a good idea).  In addition, as Florian has
noted regparm attribute mismatches between declaration and definition
are only diagnosed for prototype definitions, and five functions
needed internal_function added to their definitions (in the case of
__pthread_mutex_cond_lock, via the macro definition of
__pthread_mutex_lock) to compile on i386.

After this patch is in, remaining old-style definitions are probably
most readily fixed manually before we can turn on
-Wold-style-definition for all builds.

Tested for x86_64 and x86 (testsuite).

	* crypt/md5-crypt.c (__md5_crypt_r): Convert to prototype-style
	function definition.
	* crypt/sha256-crypt.c (__sha256_crypt_r): Likewise.
	* crypt/sha512-crypt.c (__sha512_crypt_r): Likewise.
	* debug/backtracesyms.c (__backtrace_symbols): Likewise.
	* elf/dl-minimal.c (_itoa): Likewise.
	* hurd/hurdmalloc.c (malloc): Likewise.
	(free): Likewise.
	(realloc): Likewise.
	* inet/inet6_option.c (inet6_option_space): Likewise.
	(inet6_option_init): Likewise.
	(inet6_option_append): Likewise.
	(inet6_option_alloc): Likewise.
	(inet6_option_next): Likewise.
	(inet6_option_find): Likewise.
	* io/ftw.c (FTW_NAME): Likewise.
	(NFTW_NAME): Likewise.
	(NFTW_NEW_NAME): Likewise.
	(NFTW_OLD_NAME): Likewise.
	* libio/iofwide.c (_IO_fwide): Likewise.
	* libio/strops.c (_IO_str_init_static_internal): Likewise.
	(_IO_str_init_static): Likewise.
	(_IO_str_init_readonly): Likewise.
	(_IO_str_overflow): Likewise.
	(_IO_str_underflow): Likewise.
	(_IO_str_count): Likewise.
	(_IO_str_seekoff): Likewise.
	(_IO_str_pbackfail): Likewise.
	(_IO_str_finish): Likewise.
	* libio/wstrops.c (_IO_wstr_init_static): Likewise.
	(_IO_wstr_overflow): Likewise.
	(_IO_wstr_underflow): Likewise.
	(_IO_wstr_count): Likewise.
	(_IO_wstr_seekoff): Likewise.
	(_IO_wstr_pbackfail): Likewise.
	(_IO_wstr_finish): Likewise.
	* locale/programs/localedef.c (normalize_codeset): Likewise.
	* locale/programs/locarchive.c (add_locale_to_archive): Likewise.
	(add_locales_to_archive): Likewise.
	(delete_locales_from_archive): Likewise.
	* malloc/malloc.c (__libc_mallinfo): Likewise.
	* math/gen-auto-libm-tests.c (init_fp_formats): Likewise.
	* misc/tsearch.c (__tfind): Likewise.
	* nptl/pthread_attr_destroy.c (__pthread_attr_destroy): Likewise.
	* nptl/pthread_attr_getdetachstate.c
	(__pthread_attr_getdetachstate): Likewise.
	* nptl/pthread_attr_getguardsize.c (pthread_attr_getguardsize):
	Likewise.
	* nptl/pthread_attr_getinheritsched.c
	(__pthread_attr_getinheritsched): Likewise.
	* nptl/pthread_attr_getschedparam.c
	(__pthread_attr_getschedparam): Likewise.
	* nptl/pthread_attr_getschedpolicy.c
	(__pthread_attr_getschedpolicy): Likewise.
	* nptl/pthread_attr_getscope.c (__pthread_attr_getscope):
	Likewise.
	* nptl/pthread_attr_getstack.c (__pthread_attr_getstack):
	Likewise.
	* nptl/pthread_attr_getstackaddr.c (__pthread_attr_getstackaddr):
	Likewise.
	* nptl/pthread_attr_getstacksize.c (__pthread_attr_getstacksize):
	Likewise.
	* nptl/pthread_attr_init.c (__pthread_attr_init_2_1): Likewise.
	(__pthread_attr_init_2_0): Likewise.
	* nptl/pthread_attr_setdetachstate.c
	(__pthread_attr_setdetachstate): Likewise.
	* nptl/pthread_attr_setguardsize.c (pthread_attr_setguardsize):
	Likewise.
	* nptl/pthread_attr_setinheritsched.c
	(__pthread_attr_setinheritsched): Likewise.
	* nptl/pthread_attr_setschedparam.c
	(__pthread_attr_setschedparam): Likewise.
	* nptl/pthread_attr_setschedpolicy.c
	(__pthread_attr_setschedpolicy): Likewise.
	* nptl/pthread_attr_setscope.c (__pthread_attr_setscope):
	Likewise.
	* nptl/pthread_attr_setstack.c (__pthread_attr_setstack):
	Likewise.
	* nptl/pthread_attr_setstackaddr.c (__pthread_attr_setstackaddr):
	Likewise.
	* nptl/pthread_attr_setstacksize.c (__pthread_attr_setstacksize):
	Likewise.
	* nptl/pthread_condattr_setclock.c (pthread_condattr_setclock):
	Likewise.
	* nptl/pthread_create.c (__find_in_stack_list): Likewise.
	* nptl/pthread_getattr_np.c (pthread_getattr_np): Likewise.
	* nptl/pthread_mutex_cond_lock.c (__pthread_mutex_lock): Define to
	use internal_function.
	* nptl/pthread_mutex_init.c (__pthread_mutex_init): Convert to
	prototype-style function definition.
	* nptl/pthread_mutex_lock.c (__pthread_mutex_lock): Likewise.
	(__pthread_mutex_cond_lock_adjust): Likewise.  Use
	internal_function.
	* nptl/pthread_mutex_timedlock.c (pthread_mutex_timedlock):
	Convert to prototype-style function definition.
	* nptl/pthread_mutex_trylock.c (__pthread_mutex_trylock):
	Likewise.
	* nptl/pthread_mutex_unlock.c (__pthread_mutex_unlock_usercnt):
	Likewise.
	(__pthread_mutex_unlock): Likewise.
	* nptl_db/td_ta_clear_event.c (td_ta_clear_event): Likewise.
	* nptl_db/td_ta_set_event.c (td_ta_set_event): Likewise.
	* nptl_db/td_thr_clear_event.c (td_thr_clear_event): Likewise.
	* nptl_db/td_thr_event_enable.c (td_thr_event_enable): Likewise.
	* nptl_db/td_thr_set_event.c (td_thr_set_event): Likewise.
	* nss/makedb.c (process_input): Likewise.
	* posix/fnmatch.c (__strchrnul): Likewise.
	(__wcschrnul): Likewise.
	(fnmatch): Likewise.
	* posix/fnmatch_loop.c (FCT): Likewise.
	* posix/glob.c (globfree): Likewise.
	(__glob_pattern_type): Likewise.
	(__glob_pattern_p): Likewise.
	* posix/regcomp.c (re_compile_pattern): Likewise.
	(re_set_syntax): Likewise.
	(re_compile_fastmap): Likewise.
	(regcomp): Likewise.
	(regerror): Likewise.
	(regfree): Likewise.
	* posix/regexec.c (regexec): Likewise.
	(re_match): Likewise.
	(re_search): Likewise.
	(re_match_2): Likewise.
	(re_search_2): Likewise.
	(re_search_stub): Likewise.  Use internal_function
	(re_copy_regs): Likewise.
	(re_set_registers): Convert to prototype-style function
	definition.
	(prune_impossible_nodes): Likewise.  Use internal_function.
	* resolv/inet_net_pton.c (inet_net_pton): Convert to
	prototype-style function definition.
	(inet_net_pton_ipv4): Likewise.
	* stdlib/strtod_l.c (____STRTOF_INTERNAL): Likewise.
	* sysdeps/pthread/aio_cancel.c (aio_cancel): Likewise.
	* sysdeps/pthread/aio_suspend.c (aio_suspend): Likewise.
	* sysdeps/pthread/timer_delete.c (timer_delete): Likewise.
	* sysdeps/unix/sysv/linux/dl-openat64.c (openat64): Likewise.
	Make variadic.
	* time/strptime_l.c (localtime_r): Convert to prototype-style
	function definition.
	* wcsmbs/mbsnrtowcs.c (__mbsnrtowcs): Likewise.
	* wcsmbs/mbsrtowcs_l.c (__mbsrtowcs_l): Likewise.
	* wcsmbs/wcsnrtombs.c (__wcsnrtombs): Likewise.
	* wcsmbs/wcsrtombs.c (__wcsrtombs): Likewise.
2015-10-20 11:54:09 +00:00
Joseph Myers 2f44ee08db Fix regcomp wcscoll, wcscmp namespace (bug 18497).
regcomp brings in references to wcscoll, which isn't in all the
standards that contain regcomp.  In turn, wcscoll brings in references
to wcscmp, also not in all those standards.  This patch fixes this by
making those functions into weak aliases of __wcscoll and __wcscmp and
calling those names instead as needed.

Tested for x86_64 and x86 (testsuite, and that disassembly of
installed shared libraries is unchanged by the patch).

	[BZ #18497]
	* wcsmbs/wcscmp.c [!WCSCMP] (WCSCMP): Define as __wcscmp instead
	of wcscmp.
	(wcscmp): Define as weak alias of WCSCMP.
	* wcsmbs/wcscoll.c (STRCOLL): Define as __wcscoll instead of
	wcscoll.
	(USE_HIDDEN_DEF): Define.
	[!USE_IN_EXTENDED_LOCALE_MODEL] (wcscoll): Define as weak alias of
	__wcscoll.  Don't use libc_hidden_weak.
	* wcsmbs/wcscoll_l.c (STRCMP): Define as __wcscmp instead of
	wcscmp.
	* sysdeps/i386/i686/multiarch/wcscmp-c.c
	[SHARED] (libc_hidden_def): Define __GI___wcscmp instead of
	__GI_wcscmp.
	(weak_alias): Undefine and redefine.
	* sysdeps/i386/i686/multiarch/wcscmp.S (wcscmp): Rename to
	__wcscmp and define as weak alias of __wcscmp.
	* sysdeps/x86_64/wcscmp.S (wcscmp): Likewise.
	* include/wchar.h (__wcscmp): Declare.  Use libc_hidden_proto.
	(__wcscoll): Likewise.
	(wcscmp): Don't use libc_hidden_proto.
	(wcscoll): Likewise.
	* posix/regcomp.c (build_range_exp): Call __wcscoll instead of
	wcscoll.
	* posix/regexec.c (check_node_accept_bytes): Likewise.
	* conform/Makefile (test-xfail-XPG3/regex.h/linknamespace): Remove
	variable.
	(test-xfail-XPG4/regex.h/linknamespace): Likewise.
	(test-xfail-POSIX/regex.h/linknamespace): Likewise.
2015-06-09 21:07:30 +00:00
Joseph Myers 9dd6b7799a Fix regex wctype namespace (bug 18495).
regcomp brings in references to various wctype functions that aren't
in all the standards including regcomp.  This patch fixes this in the
usual way by using the __* versions of these functions (which already
exist, but some didn't have libc_hidden_proto / libc_hidden_def
before).

Tested for x86_64 and x86 (testsuite, and that installed stripped
shared libraries are unchanged by the patch).  (Other wide character
function references from the regex code mean that this patch by itself
doesn't fix any XFAILed linknamespace test failures; further patches
will be needed for that.)

	[BZ #18495]
	* wctype/wcfuncs.c (__iswalnum): Use libc_hidden_def.
	(__iswlower): Likewise.
	* include/wctype.h (__iswalnum): Declare.  Use libc_hidden_proto.
	(__iswlower): Likewise.
	* posix/regcomp.c (re_compile_fastmap_iter): Call __towlower
	instead of towlower.
	* posix/regex_internal.c (build_wcs_upper_buffer): Call __iswlower
	instead of iswlower.  Call __towupper instead of towupper.
	* posix/regex_internal.h (IS_WIDE_WORD_CHAR): Call __iswalnum
	instead of iswalnum.
2015-06-05 20:04:47 +00:00
Roland McGrath d3821ab0ac Harmonize posix/regcomp.c with gnulib: comment formatting 2015-03-10 13:53:34 -07:00
Chris Metcalf 39a12f8db4 posix/regcomp: initialize union structure tag to avoid warning
We see some surprising warnings on tilegx with gcc 4.8.2:

In file included from regex.c:66:0:
regcomp.c: In function ‘parse_expression’:
regcomp.c:2849:15: error: ‘end_elem’ may be used uninitialized in this
function [-Werror=maybe-uninitialized]
       else if (br_elem->type == COLL_SYM)
               ^
regcomp.c:3109:34: note: ‘end_elem’ was declared here
       bracket_elem_t start_elem, end_elem;
                                  ^
regcomp.c:3109:22: error: ‘start_elem’ may be used uninitialized in
this function [-Werror=maybe-uninitialized]
       bracket_elem_t start_elem, end_elem;
                      ^

These warnings are not seen on x86, and in fact if I compile the
preprocessed tile sources with the x86 gcc 4.8.2, I don't see the
warnings.  I do see eqiuvalent warnings if I compile the
x86-preprocessed source code with tilegx gcc 4.8.2.

The fix here is to initialize the union type field appropriately in
a couple of places where we pass a union pointer to a subroutine that
"knows" what type the union is.  Setting the type explicitly seems like
a more robust way to manage such a data structure in any case.
2015-01-07 12:32:40 -05:00
Joseph Myers b168057aaa Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
Roland McGrath 8c0ab919f6 Move findidx nested functions to top-level. 2014-09-11 16:02:17 -07:00
Jim Meyering 7ee03f0018 regex: don't deref NULL upon heap allocation failure
* posix/regcomp.c: (parse_dup_op): Handle duplicate_tree
failure in one more place.
To trigger the segfault, configure grep -with-included-regex,
build it, and run these commands:
( ulimit -v 300000; echo a|src/grep -E a+++++++++++++++++++++ )
2014-07-13 21:25:22 -07:00
Andreas Schwab aa6ec754f3 Fix another memory leak in regexp compiler (BZ #17069) 2014-06-20 14:03:40 +02:00
Andreas Schwab 4d43ef1e74 Fix memory leak in regexp compiler (BZ #17069) 2014-06-19 19:00:03 +02:00
Allan McRae d4697bc93d Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
Ryan S. Arnold e054f49430 Add #include <stdint.h> for uint[32|64]_t usage (except installed headers). 2013-05-16 11:32:54 -05:00
Andreas Schwab 7e2f0d2d77 Fix handling of collating symbols in regexps 2013-02-12 09:25:34 +01:00
Joseph Myers 568035b787 Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
Roland McGrath 329bc01868 Suppress regcomp.c warnings in 32-bit builds. 2012-08-15 16:03:58 -07:00
Paul Eggert 59ba27a63a Replace FSF snail mail address with URLs. 2012-02-09 23:18:22 +00:00
Ulrich Drepper 9f1151705e Optimize regex a bit 2012-01-03 07:54:15 -05:00
Andreas Schwab f3a6cc0a56 Fix access after end of search string in regex matcher 2011-11-30 11:03:20 +01:00
Ulrich Drepper b833d51fbb One more regex memory leak fixed. 2010-10-12 09:00:33 -04:00
Ulrich Drepper e9b9cbf5e9 More regex memory leak fixes and tests. 2010-10-11 22:46:44 -04:00
Ulrich Drepper a129c80d54 Fix memory leak for some invalid regular expressions. 2010-10-11 11:46:22 -04:00
Ulrich Drepper aa732e2b2b One forgotten checkin from regex changes. 2010-01-15 12:20:55 -08:00
Ulrich Drepper 2da42bc065 Fix a few more cases of ignored return values in regex. 2010-01-15 12:03:16 -08:00
Paul Eggert 21f5de55ec regcomp.c: do not ignore memory allocation failure 2010-01-14 21:35:15 -08:00
Paolo Bonzini 815d8147a3 Fix ranges with multibyte characters as endpoints.
This is another bug in computing the fastmap.  It was reported by a user
of sed because it usually does not happen with !_LIBC.  However, it is
there in that case too.

The bug is that whenever we have a range at the beginning of the regex,
the regex must be tested on any possible multibyte character.  The reason
why _LIBC masks it, is that in general there is a collation symbol for
each possible multibyte-character lead byte, so all the lead bytes are
in general already part of the fastmap.

The tests use cyrillic characters as an example.  With _LIBC, they pass
without the patch too, but you can make them fail by removing collation
symbols handling.
2009-11-17 16:23:24 -08:00
Ulrich Drepper 52db8039f5 Recognize ill-formed { } expressions in regcomp. 2009-08-23 15:22:00 -07:00
Ulrich Drepper bdb56bacd5 [BZ 9697]
* posix/bug-regex17.c: Add testcases.
	* posix/regcomp.c (re_compile_fastmap_iter): Rewrite COMPLEX_BRACKET
	handling.
2009-01-08 00:42:51 +00:00
Ulrich Drepper b3918c7d7f * posix/regcomp.c (re_compile_fastmap_iter): Use __mbrtowc.
* posix/regex_internal.c (build_wcs_buffer, build_wcs_upper_buffer,
	re_string_skip_chars, re_string_reconstruct): Likewise.
	* posix/regex_internal.h [!_LIBC] (__mbrtowc): New #define.
2009-01-08 00:23:09 +00:00
Ulrich Drepper 0caca71ac9 * string/Makefile (distribute): Add str-two-way.h.
2008-03-29  Eric Blake	<ebb9@byu.net>

	Rewrite string searches to O(n) rather than O(n^2).
	* string/str-two-way.h: New file.  For linear fixed-allocation
	string searching.
	* string/memmem.c: New implementation.
	* string/strstr.c: New implementation.
	* string/strcasestr.c: New implementation.

	* sysdeps/posix/getaddrinfo.c (getaddrinfo): Call _res_hconf_init
2008-05-15 04:42:20 +00:00
Ulrich Drepper bc3e1c1273 * locale/nl_langinfo.c (nl_langinfo): Just call __nl_langinfo_l.
* locale/nl_langinfo_l.c: Real implementation, copied from
	nl_langinfo.c.
	* include/langinfo.h: Add libc_hidden_proto for __nl_langinfo_l.
2007-12-14 03:54:07 +00:00
Ulrich Drepper 77751669d7 * posix/regcomp.c (optimize_utf8): Fix a typo, s/idx/ctx_type/,
that would inhibit utf8-optimization of a regexp containing line-
	or buffer-anchors, e.g., `^', `$'.
2007-12-12 18:28:58 +00:00
Ulrich Drepper b7d1c5fa30 * posix/fnmatch_loop.c: Take rule index returned as part of
findidx return value into account when accessing weights.
	* posix/regcomp.c: Likewise.
	* posix/regexec.c: Likewise.
2007-10-12 17:47:19 +00:00
Ulrich Drepper a532a41df5 * posix/regcomp.c (lookup_collation_sequence_value): check that
nrules != 0 for multibyte chars.
2007-09-24 03:31:47 +00:00