From: Ramsay Jones <ramsay@ramsayjones.plus.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Junio C Hamano <gitster@pobox.com>,
GIT Mailing-list <git@vger.kernel.org>,
Johannes Sixt <j6t@kdbg.org>
Subject: Re: [PATCH] regex: fix a SIZE_MAX macro redefinition warning
Date: Sun, 5 Jun 2016 14:35:01 +0100 [thread overview]
Message-ID: <57542A85.3040206@ramsayjones.plus.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1606050815360.4250@virtualbox>
On 05/06/16 08:15, Johannes Schindelin wrote:
> Hi Ramsay,
>
> thanks for working on this!
>
> On Sat, 4 Jun 2016, Ramsay Jones wrote:
>
>> diff --git a/Makefile b/Makefile
>> index 0d59718..3f6c70a 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -1987,7 +1987,7 @@ endif
>>
>> ifdef NO_REGEX
>> compat/regex/regex.sp compat/regex/regex.o: EXTRA_CPPFLAGS = \
>> - -DGAWK -DNO_MBSUPPORT
>> + -DGAWK -DNO_MBSUPPORT -DHAVE_STDINT_H
>
> Maybe a comment here, something like "the fallback regex implementation
> *requires* stdint.h"?
The original version of this patch looked like this:
diff --git a/compat/regex/regcomp.c b/compat/regex/regcomp.c
index fba5986..d8bde06 100644
--- a/compat/regex/regcomp.c
+++ b/compat/regex/regcomp.c
@@ -18,8 +18,6 @@
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA. */
-#include <stdint.h>
-
static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern,
size_t length, reg_syntax_t syntax);
static void re_compile_fastmap_iter (regex_t *bufp,
diff --git a/compat/regex/regex.c b/compat/regex/regex.c
index 6aaae00..5cb23e5 100644
--- a/compat/regex/regex.c
+++ b/compat/regex/regex.c
@@ -60,6 +60,7 @@
GNU regex allows. Include it before <regex.h>, which correctly
#undefs RE_DUP_MAX and sets it to the right value. */
#include <limits.h>
+#include <stdint.h>
#ifdef GAWK
#undef alloca
So, just move the unconditional inclusion to the start of the compilation
unit root file, before the #include of the regex_internal.h header.
In some ways this is a better fix, because it makes it clear that, currently,
the compat/regex code requires <stdint.h>. This would remove the need for
such a comment.
This effectively makes the conditional inclusion of <stdint.h>, and the SIZE_MAX
fallback, in regex_internal.h dead code. (The C99 standard _requires_ the
definition of SIZE_MAX in <stdint.h>, thankfully! ;-). So, I was tempted to
remove them as part of the patch. However, I also wanted to minimize the changes
to the regex code, just in case we ever wanted to re-import a newer version
from upstream. Setting HAVE_STDINT_H seemed like a good solution, but maybe the
first patch would be more honest?
As I said earlier, I was a little concerned about the 'unconditional' aspect of
the inclusion of <stdint.h>. At one time we wanted to support systems that didn't
have <stdint.h> (or didn't have <inttypes.h> but did have <stdint.h>). However,
it has been several months and we have not heard anyone scream, so ...
It is slightly amusing that the reason you #included <stdint.h> was to get the
definition of 'intptr_t' and the C standard states that this type is optional.
In practice, I suspect that the number of platforms which do not define 'intptr_t'
and 'uintptr_t' in the <stdint.h> header is rather small.
Having said that ... If I'm reading the code/config correctly, HP-NONSTOP would
be failing to compile at the moment. (Although it has <stdint.h>, it does not
define 'intptr_t' - ie it defines 'NO_REGEX = YesPlease' and 'NO_INTPTR_T = \
UnfortunatelyYes').
> Other than that, I think this patch is an improvement.
Thanks. What do you think of replacing it with the original patch (above)?
ATB,
Ramsay Jones
next prev parent reply other threads:[~2016-06-05 13:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-03 23:29 [PATCH] regex: fix a SIZE_MAX macro redefinition warning Ramsay Jones
2016-06-05 7:15 ` Johannes Schindelin
2016-06-05 13:35 ` Ramsay Jones [this message]
2016-06-06 6:57 ` Johannes Schindelin
2016-06-06 18:10 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=57542A85.3040206@ramsayjones.plus.com \
--to=ramsay@ramsayjones.plus.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=j6t@kdbg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).