summaryrefslogtreecommitdiff
path: root/src/character.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2011-07-18 17:42:24 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2011-07-18 17:42:24 -0700
commit5637687fead7d57f73ea9a7677d25b93fb785dc7 (patch)
treee74204022166de1a8a17ed8860aa9197ce01428e /src/character.c
parenta2271ba21087837896098f97663efaa60eab943e (diff)
downloademacs-5637687fead7d57f73ea9a7677d25b93fb785dc7.tar.gz
Don't assume that stated character widths fit in int.
* character.c (Fchar_width, c_string_width, lisp_string_width): * character.h (CHAR_WIDTH): * indent.c (MULTIBYTE_BYTES_WIDTH): Use sanitize_char_width to avoid undefined and/or bad behavior with outlandish widths. * character.h (sanitize_tab_width): Renamed from sanitize_width, now that we have two such functions. All uses changed. (sanitize_char_width): New inline function.
Diffstat (limited to 'src/character.c')
-rw-r--r--src/character.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/character.c b/src/character.c
index 8e9b3e3775e..c2f23e0d8ec 100644
--- a/src/character.c
+++ b/src/character.c
@@ -326,7 +326,7 @@ usage: (char-width CHAR) */)
disp = dp ? DISP_CHAR_VECTOR (dp, c) : Qnil;
if (VECTORP (disp))
- width = ASIZE (disp);
+ width = sanitize_char_width (ASIZE (disp));
else
width = CHAR_WIDTH (c);
@@ -358,7 +358,7 @@ c_string_width (const unsigned char *str, EMACS_INT len, int precision,
{
val = DISP_CHAR_VECTOR (dp, c);
if (VECTORP (val))
- thiswidth = ASIZE (val);
+ thiswidth = sanitize_char_width (ASIZE (val));
else
thiswidth = CHAR_WIDTH (c);
}
@@ -451,7 +451,7 @@ lisp_string_width (Lisp_Object string, EMACS_INT precision,
{
val = DISP_CHAR_VECTOR (dp, c);
if (VECTORP (val))
- thiswidth = ASIZE (val);
+ thiswidth = sanitize_char_width (ASIZE (val));
else
thiswidth = CHAR_WIDTH (c);
}