• Paul Eggert's avatar
    Fix some integer issues in regex-emacs · b7a98993
    Paul Eggert authored
    Also, remove some duplicate comments related to thread.h.
    * src/regex-emacs.h (struct re_registers):
    * src/regex-emacs.c (SIGN_EXTEND_CHAR): Remove.
    (TALLOC, RETALLOC): Remove.  All uses replaced by usual
    allocators, which check for integer overflow.
    (extract_number): Redo without using ‘unsigned’.
    (CHARSET_RANGE_TABLE_EXISTS_P): Clearly return a boolean.
    (print_fastmap, print_partial_compiled_pattern, CHECK_INFINITE_LOOP)
    (regex_compile, analyze_first, bcmp_translate, mutually_exclusive_p)
    (re_match_2_internal):
    Use bool for booleans.
    (print_fastmap, regex_compile, execute_charset):
    Prefer int to unsigned where either will do.
    (print_double_string): Prefer ptrdiff_t to ssize_t, since the
    latter can in theory be narrower than the former.  Use fwrite
    instead of repeated putchar.
    (emacs_re_max_failures, fail_stack_type, compile_stack_type)
    (re_wctype_parse, regex_compile, re_search, re_search_2)
    (re_match_2, re_match_2_internal, re_compile_pattern):
    Prefer ptrdiff_t to size_t where either will do.
    (union fail_stack_elt, PUSH_FAILURE_REG, POP_FAILURE_REG_OR_COUNT):
    Make the integer an intptr_t, not long.
    (GET_BUFFER_SPACE, EXTEND_BUFFER, regex_compile):
    Use xpalloc to simplify allocation.
    (regex_compile): Check for integer overflow when calculating
    register numbers.
    * src/regex-emacs.c (re_set_registers, re_match_2_internal):
    * src/regex-emacs.h (struct re_registers, struct re_pattern_buffer):
    * src/search.c (Freplace_match):
    Prefer ptrdiff_t to unsigned where either will do.
    * src/regex-emacs.h (struct re_pattern_buffer):
    Prefer bool_bf to unsigned where either will do.
    b7a98993
regex-emacs.c 148 KB