comparison lib/regcomp.c @ 16912:1591c84dbb2d

regex: avoid warning when pointers are not long * lib/regcomp.c (parse_dup_op, mark_opt_subexp): Cast between void * and uintptr_t, not long, for portability to hosts where pointers and long have different sizes. Issue noted by Daniel P. Berrange in <http://lists.gnu.org/archive/html/bug-gnulib/2012-06/msg00122.html> and fix suggested by Bruno Haible in <http://lists.gnu.org/archive/html/bug-gnulib/2012-06/msg00128.html>.
author Paul Eggert <eggert@cs.ucla.edu>
date Sun, 17 Jun 2012 09:55:15 -0700
parents 551fb0402288
children 87796549f866
comparison
equal deleted inserted replaced
16911:9b4a647b7727 16912:1591c84dbb2d
2619 } 2619 }
2620 else 2620 else
2621 old_tree = NULL; 2621 old_tree = NULL;
2622 2622
2623 if (elem->token.type == SUBEXP) 2623 if (elem->token.type == SUBEXP)
2624 postorder (elem, mark_opt_subexp, (void *) (long) elem->token.opr.idx); 2624 {
2625 uintptr_t subidx = elem->token.opr.idx;
2626 postorder (elem, mark_opt_subexp, (void *) subidx);
2627 }
2625 2628
2626 tree = create_tree (dfa, elem, NULL, 2629 tree = create_tree (dfa, elem, NULL,
2627 (end == REG_MISSING ? OP_DUP_ASTERISK : OP_ALT)); 2630 (end == REG_MISSING ? OP_DUP_ASTERISK : OP_ALT));
2628 if (BE (tree == NULL, 0)) 2631 if (BE (tree == NULL, 0))
2629 goto parse_dup_op_espace; 2632 goto parse_dup_op_espace;
3854 To be called from preorder or postorder. */ 3857 To be called from preorder or postorder. */
3855 3858
3856 static reg_errcode_t 3859 static reg_errcode_t
3857 mark_opt_subexp (void *extra, bin_tree_t *node) 3860 mark_opt_subexp (void *extra, bin_tree_t *node)
3858 { 3861 {
3859 Idx idx = (Idx) (long) extra; 3862 Idx idx = (uintptr_t) extra;
3860 if (node->token.type == SUBEXP && node->token.opr.idx == idx) 3863 if (node->token.type == SUBEXP && node->token.opr.idx == idx)
3861 node->token.opt_subexp = 1; 3864 node->token.opt_subexp = 1;
3862 3865
3863 return REG_NOERROR; 3866 return REG_NOERROR;
3864 } 3867 }