summaryrefslogtreecommitdiff
path: root/compat/regex
Commit message (Collapse)AuthorAgeFilesLines
* DONTMERGE compat/regex: make it compile with -Werror=int-to-pointer-castab/compat-regex-updateJunio C Hamano2017-05-121-4/+2
| | | | | | | | | | The change by 56a1a3ab ("Silence GCC's "cast of pointer to integer of a different size" warning", 2015-10-26) may need resurrecting; I do not think an unprotected #include <stdint.h> is the best way to do this, but for the purpose of places that needs further work, thishsould do. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* compat/regex: update the gawk regex engine from upstreamÆvar Arnfjörð Bjarmason2017-05-109-422/+1158
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Update the gawk regex engine from the upstream gawk.git as detailed in the README added in a previous change. This is from gawk.git's gawk-4.1.0-2558-gb2651a80 which is the same code as in the stable gawk-4.1.4 release, but with one trivial change on top added in commit 725d2f78 ("Add small regex fix. Add support directory.", 2016-12-22)[1] The two patches applied on top of the upstream engine are to, respectively: * Add a notice at the top of each file saying that this copy is maintained by the Git project. * Remove the dependency on gawk's verify.h. The library compiles as-is when this header file is present, but unfortunately it's under GPL v3, unlike the rest of the files which is under LGPL 2.1 or later. The changes made in commit a997bf423d ("compat/regex: get the gawk regex engine to compile within git", 2010-08-17) turned out to be redundant to achieving the same with defining a few flags to make the code itself do similar things. In addition the -DNO_MBSUPPORT flag is not needed, upstream removed the code that relied on that. It's possible that either -DHAVE_BTOWC or -D_GNU_SOURCE could cause some problems on non-GNU systems. The -DHAVE_BTOWC flag indicates that wchar.h has a btowc(3). This function is defined in POSIX.1-2001 & C99 and later. The -D_GNU_SOURCE flag is needed because the library itself does: #ifndef _LIBC #define __USE_GNU 1 #endif Which is subsequently picked up by GNU C library headers: In file included from compat/regex/regex_internal.h:32:0, from compat/regex/regex.c:76: /usr/include/stdio.h:316:6: error: unknown type name ‘_IO_cookie_io_functions_t’; did you mean ‘__fortify_function’? _IO_cookie_io_functions_t __io_funcs) __THROW __wur; ^~~~~~~~~~~~~~~~~~~~~~~~~ 1. http://git.savannah.gnu.org/cgit/gawk.git/commit/?id=725d2f78 Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* compat/regex: add a README with a maintenance guideÆvar Arnfjörð Bjarmason2017-05-081-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a README file to compat/regex describing how the copy of the gawk engine should be maintained. Since gawk's regex engine was originally imported in git.git in commit d18f76dccf ("compat/regex: use the regex engine from gawk for compat", 2010-08-17) the Git project has forked the upstream code. Most of the changes that have been made in that time have been made redundant by similar changes made upstream. Out of all the modifications made to it since then, which can be found via: $ git log --oneline d18f76dccf..v2.13.0-rc2 -- compat/regex/ These are the only real code changes that aren't made fully redundant by upstream patches: ce518bbd6c ("Fix compat/regex ANSIfication on MinGW", 2010-08-26) 5b62e6374a ("compat/regex/regexec.c: Fix some sparse warnings", 2013-04-27) d099b7173d ("Fix some sparse warnings", 2013-07-18) These look to me like they might be a non-issue due to subsequent changes, or perhaps aren't needed anymore due to compiler updates. In addition a few style & typo changes have been made in that time: ce9171cd63 ("compat/regex: fix spelling and grammar in comments", 2013-04-12) 749f763dbb ("typofix: in-code comments", 2013-07-22) c01499ef69 ("C: have space around && and || operators", 2013-10-16) Some of these could still be applied, but I don't see any point in doing so. These are typo & style nits, if anyone really cares that much they should send updates to gawk.git instead of making the re-merging of code into git.git harder over such trivial issues. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* regex: fix a SIZE_MAX macro redefinition warningrj/compat-regex-size-max-fixRamsay Jones2016-06-062-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since commit 56a1a3ab ("Silence GCC's \"cast of pointer to integer of a different size\" warning", 26-10-2015), sparse has been issuing a macro redefinition warning for the SIZE_MAX macro. However, gcc did not issue any such warning. After commit 56a1a3ab, in terms of the order of #includes and #defines, the code looked something like: $ cat -n junk.c 1 #include <stddef.h> 2 3 #define SIZE_MAX ((size_t) -1) 4 5 #include <stdint.h> 6 7 int main(int argc, char *argv[]) 8 { 9 return 0; 10 } $ $ gcc junk.c $ However, if you compile that file with -Wsystem-headers, then it will also issue a warning. Having set -Wsystem-headers in CFLAGS, using the config.mak file, then (on cygwin): $ make compat/regex/regex.o CC compat/regex/regex.o In file included from /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/include/stdint.h:9:0, from compat/regex/regcomp.c:21, from compat/regex/regex.c:77: /usr/include/stdint.h:362:0: warning: "SIZE_MAX" redefined #define SIZE_MAX (__SIZE_MAX__) ^ In file included from compat/regex/regex.c:69:0: compat/regex/regex_internal.h:108:0: note: this is the location of the previous definition # define SIZE_MAX ((size_t) -1) ^ $ The compilation of the compat/regex code is somewhat unusual in that the regex.c file directly #includes the other c files (regcomp.c, regexec.c and regex_internal.c). Commit 56a1a3ab added an #include of <stdint.h> to the regcomp.c file, which results in the redefinition, since this is included after the regex_internal.h header. This header file contains a 'fallback' definition for SIZE_MAX, in order to support systems which do not have the <stdint.h> header (the HAVE_STDINT_H macro is not defined). In order to suppress the warning, we move the #include of <stdint.h> from regcomp.c to the start of the compilation unit, close to the top of regex.c, prior to the #include of the regex_internal.h header. Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Silence GCC's "cast of pointer to integer of a different size" warningJohannes Schindelin2015-10-261-2/+4
| | | | | | | | | | | | When calculating hashes from pointers, it actually makes sense to cut off the most significant bits. In that case, said warning does not make a whole lot of sense. So let's just work around it by casting the pointer first to intptr_t and then casting up/down to the final integral type. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* C: have space around && and || operatorsJunio C Hamano2013-10-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Correct all hits from git grep -e '\(&&\|||\)[^ ]' -e '[^ ]\(&&\|||\)' -- '*.c' i.e. && or || operators that are followed by anything but a SP, or that follow something other than a SP or a HT, so that these operators have a SP around it when necessary. We usually refrain from making this kind of a tree-wide change in order to avoid unnecessary conflicts with other "real work" patches, but in this case, the end result does not have a potentially cumbersome tree-wide impact, while this is a tree-wide cleanup. Fixes to compat/regex/regcomp.c and xdiff/xemit.c are to replace a HT immediately after && with a SP. This is based on Felipe's patch to bultin/symbolic-ref.c; I did all the finding out what other files in the whole tree need to be fixed and did the fix and also the log message while reviewing that single liner, so any screw-ups in this version are mine. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* typofix: in-code commentsOndřej Bílka2013-07-222-11/+11
| | | | | Signed-off-by: Ondřej Bílka <neleai@seznam.cz> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* compat/regex/regexec.c: Fix some sparse warningsRamsay Jones2013-04-281-3/+3
| | | | | | | | | | | | | Sparse issues an "Using plain integer as NULL pointer" warning along with two "symbol was not declared. Should it be static?" type warnings for the 'merge_state_with_log' and 'find_recover_state' functions. In order to suppress the warnings, we replace the use of '0' as a null pointer constant with NULL and add the static modifier to the function definitions. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* compat/regex: fix spelling and grammar in commentsStefano Lattarini2013-04-123-6/+6
| | | | | | | | | | | Some of these were found using Lucas De Marchi's codespell tool. Others noticed by Eric Sunshine. Helped-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Acked-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Fix compat/regex ANSIfication on MinGWJohannes Sixt2010-08-261-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | compat/regexec.c had a weird combination of function declaration in ANSI style and function definition in K&R style, for example: static unsigned re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, int nregs, int regs_allocated) internal_function; static unsigned re_copy_regs (regs, pmatch, nregs, regs_allocated) struct re_registers *regs; regmatch_t *pmatch; int nregs, regs_allocated; { ... } with this #define: #ifndef _LIBC # ifdef __i386__ # define internal_function __attribute ((regparm (3), stdcall)) # else # define internal_function # endif #endif The original version as shown above was fine, but with the ANSIfied function definition and in the case where internal_function is not empty, gcc identifies the declaration and definition as different and bails out. Adding internal_function to the definition doesn't help (it results in a syntax error); hence, remove it from the subset of declarations that gcc flags as erroneous. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* compat/regex: get rid of old-style definitionJunio C Hamano2010-08-192-69/+55
| | | | | | | These files mostly used ANSI style function definitions, but with small number of old-style ones. Convert them to consistently use ANSI style. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* compat/regex: define out variables only used under RE_ENABLE_I18NÆvar Arnfjörð Bjarmason2010-08-192-1/+3
| | | | | | | | | Wrap variables that were only used RE_ENABLE_I18N in `#ifdef RE_ENABLE_I18N`. This eliminates compiler warnings when compiling with NO_REGEX=YesPlease. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Change regerror() declaration from K&R style to ANSI C (C89)Frank Li2010-08-181-5/+2
| | | | | | | | | | | | | | | | The MSVC headers typedef errcode as int, and thus confused the compiler in the K&R style definition. ANSI style deconfuses it. This patch was originally applied as v1.6.5-rc2~23 but needs to be re-applied since compat/regex was overwritten by Ævar Arnfjörð Bjarmason with the gawk regex engine. Signed-off-by: Frank Li <lznuaa@gmail.com> Signed-off-by: Marius Storm-Olsen <mstormo@gmail.com> Acked-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* compat/regex: get the gawk regex engine to compile within gitÆvar Arnfjörð Bjarmason2010-08-181-0/+3
| | | | | | | | | | We need to define -DGAWK -DNO_MBSUPPORT so that the gawk regex engine will compile, and include stdio.h and stddef.h in regex.h. Gawk itself includes these headers before it includes the regex.h header. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Acked-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* compat/regex: use the regex engine from gawk for compatÆvar Arnfjörð Bjarmason2010-08-186-5104/+11179
| | | | | | | | | | | | | | | | | | | | Change the regex engine in compat to use the gawk engine from the gawk-devel module in gawk CVS. This engine supports the REG_STARTEND flag, which was optionally available in Git since v1.7.2-rc0~77^2~1. The source was grabbed from cvs.savannah.gnu.org:/sources/gawk, and these are the upstream versions of the files being included: regcomp.c 1.4 regex.h 1.3 regex.h 1.3 regex_internal.c 1.3 regex_internal.h 1.3 regexec.c 1.3 Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Acked-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* msvc: Fix a compiler warning due to an incorrect pointer castRamsay Jones2010-01-221-1/+1
| | | | | | Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Acked-by: Sebastian Schuberth <sschuberth@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Change regerror() declaration from K&R style to ANSI C (C89)Frank Li2009-09-181-5/+2
| | | | | | | | | | The MSVC headers typedef errcode as int, and thus confused the compiler in the K&R style definition. ANSI style deconfuses it. Signed-off-by: Frank Li <lznuaa@gmail.com> Signed-off-by: Marius Storm-Olsen <mstormo@gmail.com> Acked-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Fix typos / spelling in commentsMike Ralphson2009-04-221-2/+2
| | | | | Signed-off-by: Mike Ralphson <mike@abacus.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Use compatibility regex library for OSX/DarwinArjen Laarhoven2008-09-102-0/+5417
The standard libc regex library on OSX does not support alternation in POSIX Basic Regular Expression mode. This breaks the diff.funcname functionality on OSX. To fix this, we use the GNU regex library which is already present in the compat/ diretory for the MinGW port. However, simply adding compat/ to the COMPAT_CFLAGS variable causes a conflict between the system fnmatch.h and the one present in compat/. To remedy this, move the regex and fnmatch functionality to their own subdirectories in compat/ so they can be included seperately. Signed-off-by: Arjen Laarhoven <arjen@yaph.org> Tested-by: Mike Ralphson <mike@abacus.co.uk> (AIX) Tested-by: Johannes Sixt <johannes.sixt@telecom.at> (MinGW) Signed-off-by: Junio C Hamano <gitster@pobox.com>