Skip to content

Commit

Permalink
regex: Fix cast error on VC2015 x64
Browse files Browse the repository at this point in the history
`long` is 32 bits on 64-bit VC, so casting a pointer to `long` causes a
warning on VC2015 x64 and it becomes an error by the `/WX` flag.
This fixes the casting errors by using `intptr_t`.

Old MinGW needs to include `stdint.h` to use `intptr_t`.
  • Loading branch information
k-takata committed Jul 24, 2019
1 parent 915fbdb commit cb61888
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions gnu_regex/regcomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2527,7 +2527,7 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
old_tree = NULL;

if (elem->token.type == SUBEXP)
postorder (elem, mark_opt_subexp, (void *) (long) elem->token.opr.idx);
postorder (elem, mark_opt_subexp, (void *) (intptr_t) elem->token.opr.idx);

tree = create_tree (dfa, elem, NULL, (end == -1 ? OP_DUP_ASTERISK : OP_ALT));
if (BE (tree == NULL, 0))
Expand Down Expand Up @@ -3740,7 +3740,7 @@ create_token_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
static reg_errcode_t
mark_opt_subexp (void *extra, bin_tree_t *node)
{
int idx = (int) (long) extra;
int idx = (int) (intptr_t) extra;
if (node->token.type == SUBEXP && node->token.opr.idx == idx)
node->token.opt_subexp = 1;

Expand Down
2 changes: 1 addition & 1 deletion mk_mingw.mak
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

include source.mak

REGEX_DEFINES = -DHAVE_REGCOMP -D__USE_GNU -DHAVE_STDBOOL_H -Dstrcasecmp=stricmp
REGEX_DEFINES = -DHAVE_REGCOMP -D__USE_GNU -DHAVE_STDBOOL_H -DHAVE_STDINT_H -Dstrcasecmp=stricmp

CFLAGS = -Wall -std=gnu99
# sizeof (size_t) == sizeof(unsigned long) == 4 on i686-w64-mingw32-gcc.
Expand Down

0 comments on commit cb61888

Please sign in to comment.