• Paul Eggert's avatar
    Fix a race condition diagnosed by gcc -Wsequence-point (Bug#8254). · 15206ed9
    Paul Eggert authored
    An expression of the form (DOWNCASE (x) == DOWNCASE (y)), found in
    dired.c's scmp function, had undefined behavior.
    * lisp.h (DOWNCASE_TABLE, UPCASE_TABLE, DOWNCASE, UPPERCASEP):
    (NOCASEP, LOWERCASEP, UPCASE, UPCASE1): Move from here ...
    * buffer.h: ... to here, because these macros use current_buffer,
    and the new implementation with inline functions needs to have
    current_buffer in scope now, rather than later when the macros
    are used.
    (downcase, upcase1): New static inline functions.
    (DOWNCASE, UPCASE1): Reimplement using these functions.
    This avoids undefined behavior in expressions like
    DOWNCASE (x) == DOWNCASE (y), which previously suffered
    from race conditions in accessing the global variables
    case_temp1 and case_temp2.
    * casetab.c (case_temp1, case_temp2): Remove; no longer needed.
    * lisp.h (case_temp1, case_temp2): Remove their decls.
    * character.h (ASCII_CHAR_P): Move from here ...
    * lisp.h: ... to here, so that the inline functions mentioned
    above can use them.
    15206ed9
casetab.c 8.67 KB