Fix a race condition diagnosed by gcc -Wsequence-point (Bug#8254).
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 15 Mar 2011 07:04:00 +0000 (00:04 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 15 Mar 2011 07:04:00 +0000 (00:04 -0700)
commit15206ed9236f4957cb62a0cfbd5397cf8f0cb76b
treec5b79dc24fd900342aaed46555ef28480014f502
parent4a6bea268fbac2fd64018374652f5b2c9b04b4fd
Fix a race condition diagnosed by gcc -Wsequence-point (Bug#8254).

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.
src/ChangeLog
src/buffer.h
src/casetab.c
src/character.h
src/lisp.h