aboutsummaryrefslogtreecommitdiffstats
path: root/src/regex.h
diff options
context:
space:
mode:
authorEli Zaretskii2011-04-16 21:26:30 +0300
committerEli Zaretskii2011-04-16 21:26:30 +0300
commitd1dfb56cc84a6d70262d979face230a71e98d479 (patch)
tree8204edb64962a875b368dd248c00e127f9584b73 /src/regex.h
parent10472dd0d62d986e048c01a3d37627b843a321d2 (diff)
downloademacs-d1dfb56cc84a6d70262d979face230a71e98d479.tar.gz
emacs-d1dfb56cc84a6d70262d979face230a71e98d479.zip
Fix regex.c, syntax.c and friends for buffers > 2GB.
src/syntax.h (struct gl_state_s): Declare character position members EMACS_INT. src/syntax.c (update_syntax_table): Declare 2nd argument EMACS_INT. src/textprop.c (verify_interval_modification, interval_of): Declare arguments EMACS_INT. src/intervals.c (adjust_intervals_for_insertion): Declare arguments EMACS_INT. src/intervals.h (CHECK_TOTAL_LENGTH): Cast to EMACS_INT, not `int'. src/indent.c (Fvertical_motion): Local variable it_start is now EMACS_INT. src/regex.c (re_match, re_match_2, re_match_2_internal) (bcmp_translate, regcomp, regexec, print_double_string) (group_in_compile_stack, re_search, re_search_2, regex_compile) (re_compile_pattern, re_exec): Declare arguments and local variables `size_t' and `ssize_t' and return values `regoff_t', as appropriate. (POP_FAILURE_REG_OR_COUNT) <pfreg>: Declare `long'. (CHECK_INFINITE_LOOP) <failure>: Declare `ssize_t'. <compile_stack_type>: `size' and `avail' are now `size_t'. src/regex.h <regoff_t>: Use ssize_t, not int. (re_search, re_search_2, re_match, re_match_2): Arguments that specify buffer/string position and length are now ssize_t and size_t. Return type is regoff_t.
Diffstat (limited to 'src/regex.h')
-rw-r--r--src/regex.h47
1 files changed, 27 insertions, 20 deletions
diff --git a/src/regex.h b/src/regex.h
index 990606da4cc..7747ec57629 100644
--- a/src/regex.h
+++ b/src/regex.h
@@ -414,8 +414,12 @@ struct re_pattern_buffer
414 414
415typedef struct re_pattern_buffer regex_t; 415typedef struct re_pattern_buffer regex_t;
416 416
417/* Type for byte offsets within the string. POSIX mandates this. */ 417/* Type for byte offsets within the string. POSIX mandates this to be an int,
418typedef int regoff_t; 418 but the Open Group has signalled its intention to change the requirement to
419 be that regoff_t be at least as wide as ptrdiff_t and ssize_t. Current
420 gnulib sources also use ssize_t, and we need this for supporting buffers and
421 strings > 2GB on 64-bit hosts. */
422typedef ssize_t regoff_t;
419 423
420 424
421/* This is the structure we store register match data in. See 425/* This is the structure we store register match data in. See
@@ -486,31 +490,33 @@ extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer));
486 characters. Return the starting position of the match, -1 for no 490 characters. Return the starting position of the match, -1 for no
487 match, or -2 for an internal error. Also return register 491 match, or -2 for an internal error. Also return register
488 information in REGS (if REGS and BUFFER->no_sub are nonzero). */ 492 information in REGS (if REGS and BUFFER->no_sub are nonzero). */
489extern int re_search 493extern regoff_t re_search
490 _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, 494 _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
491 int length, int start, int range, struct re_registers *regs)); 495 size_t length, ssize_t start, ssize_t range,
496 struct re_registers *regs));
492 497
493 498
494/* Like `re_search', but search in the concatenation of STRING1 and 499/* Like `re_search', but search in the concatenation of STRING1 and
495 STRING2. Also, stop searching at index START + STOP. */ 500 STRING2. Also, stop searching at index START + STOP. */
496extern int re_search_2 501extern regoff_t re_search_2
497 _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, 502 _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
498 int length1, const char *string2, int length2, 503 size_t length1, const char *string2, size_t length2,
499 int start, int range, struct re_registers *regs, int stop)); 504 ssize_t start, ssize_t range, struct re_registers *regs,
505 ssize_t stop));
500 506
501 507
502/* Like `re_search', but return how many characters in STRING the regexp 508/* Like `re_search', but return how many characters in STRING the regexp
503 in BUFFER matched, starting at position START. */ 509 in BUFFER matched, starting at position START. */
504extern int re_match 510extern regoff_t re_match
505 _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, 511 _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
506 int length, int start, struct re_registers *regs)); 512 size_t length, ssize_t start, struct re_registers *regs));
507 513
508 514
509/* Relates to `re_match' as `re_search_2' relates to `re_search'. */ 515/* Relates to `re_match' as `re_search_2' relates to `re_search'. */
510extern int re_match_2 516extern regoff_t re_match_2
511 _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, 517 _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
512 int length1, const char *string2, int length2, 518 size_t length1, const char *string2, size_t length2,
513 int start, struct re_registers *regs, int stop)); 519 ssize_t start, struct re_registers *regs, ssize_t stop));
514 520
515 521
516/* Set REGS to hold NUM_REGS registers, storing them in STARTS and 522/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
@@ -556,14 +562,15 @@ extern int re_exec _RE_ARGS ((const char *));
556#endif 562#endif
557 563
558/* POSIX compatibility. */ 564/* POSIX compatibility. */
559extern int regcomp _RE_ARGS ((regex_t *__restrict __preg, 565extern reg_errcode_t regcomp _RE_ARGS ((regex_t *__restrict __preg,
560 const char *__restrict __pattern, 566 const char *__restrict __pattern,
561 int __cflags)); 567 int __cflags));
562 568
563extern int regexec _RE_ARGS ((const regex_t *__restrict __preg, 569extern reg_errcode_t regexec _RE_ARGS ((const regex_t *__restrict __preg,
564 const char *__restrict __string, size_t __nmatch, 570 const char *__restrict __string,
565 regmatch_t __pmatch[__restrict_arr], 571 size_t __nmatch,
566 int __eflags)); 572 regmatch_t __pmatch[__restrict_arr],
573 int __eflags));
567 574
568extern size_t regerror _RE_ARGS ((int __errcode, const regex_t *__preg, 575extern size_t regerror _RE_ARGS ((int __errcode, const regex_t *__preg,
569 char *__errbuf, size_t __errbuf_size)); 576 char *__errbuf, size_t __errbuf_size));