summaryrefslogtreecommitdiff
path: root/src/casetab.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2011-03-15 00:04:00 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2011-03-15 00:04:00 -0700
commit15206ed9236f4957cb62a0cfbd5397cf8f0cb76b (patch)
treec5b79dc24fd900342aaed46555ef28480014f502 /src/casetab.c
parent4a6bea268fbac2fd64018374652f5b2c9b04b4fd (diff)
downloademacs-15206ed9236f4957cb62a0cfbd5397cf8f0cb76b.tar.gz
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.
Diffstat (limited to 'src/casetab.c')
-rw-r--r--src/casetab.c6
1 files changed, 0 insertions, 6 deletions
diff --git a/src/casetab.c b/src/casetab.c
index 5207e5315ae..56f6b065358 100644
--- a/src/casetab.c
+++ b/src/casetab.c
@@ -28,11 +28,6 @@ Lisp_Object Qcase_table_p, Qcase_table;
Lisp_Object Vascii_downcase_table, Vascii_upcase_table;
Lisp_Object Vascii_canon_table, Vascii_eqv_table;
-/* Used as a temporary in DOWNCASE and other macros in lisp.h. No
- need to mark it, since it is used only very temporarily. */
-int case_temp1;
-Lisp_Object case_temp2;
-
static void set_canon (Lisp_Object case_table, Lisp_Object range, Lisp_Object elt);
static void set_identity (Lisp_Object table, Lisp_Object c, Lisp_Object elt);
static void shuffle (Lisp_Object table, Lisp_Object c, Lisp_Object elt);
@@ -302,4 +297,3 @@ syms_of_casetab (void)
defsubr (&Sset_case_table);
defsubr (&Sset_standard_case_table);
}
-