summaryrefslogtreecommitdiff
path: root/src/character.h
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2011-07-18 14:57:37 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2011-07-18 14:57:37 -0700
commita2271ba21087837896098f97663efaa60eab943e (patch)
tree69175b766600cf348b87cf8f774b249e0c592315 /src/character.h
parent18c525570121d8d3df377f85ec5b6f44fe39524a (diff)
downloademacs-a2271ba21087837896098f97663efaa60eab943e.tar.gz
Don't assume that tab-width fits in int.
* character.h (sanitize_width): New inline function. (SANE_TAB_WIDTH): New macro. (ASCII_CHAR_WIDTH): Use it. * indent.c (sane_tab_width): Remove. All uses replaced by SANE_TAB_WIDTH (current_buffer). * xdisp.c (init_iterator): Use SANE_TAB_WIDTH.
Diffstat (limited to 'src/character.h')
-rw-r--r--src/character.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/character.h b/src/character.h
index 063b5147dc9..0c207113c1e 100644
--- a/src/character.h
+++ b/src/character.h
@@ -556,6 +556,16 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
} while (0)
+/* Return a non-outlandish value for the tab width. */
+
+#define SANE_TAB_WIDTH(buf) sanitize_width (XFASTINT (BVAR (buf, tab_width)))
+
+static inline int
+sanitize_width (EMACS_INT width)
+{
+ return 0 < width && width <= 1000 ? width : 8;
+}
+
/* Return the width of ASCII character C. The width is measured by
how many columns C will occupy on the screen when displayed in the
current buffer. */
@@ -563,7 +573,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#define ASCII_CHAR_WIDTH(c) \
(c < 0x20 \
? (c == '\t' \
- ? XFASTINT (BVAR (current_buffer, tab_width)) \
+ ? SANE_TAB_WIDTH (current_buffer) \
: (c == '\n' ? 0 : (NILP (BVAR (current_buffer, ctl_arrow)) ? 4 : 2))) \
: (c < 0x7f \
? 1 \