Commit 53b2623d authored by Paul Eggert's avatar Paul Eggert

* indent.c (sane_tab_width): New function.

(current_column, scan_for_column, Findent_to, position_indentation)
(compute_motion): Use it.  This is just for clarity.
parent 45aebb64
2011-06-18 Paul Eggert <eggert@cs.ucla.edu>
* indent.c (sane_tab_width): New function.
(current_column, scan_for_column, Findent_to, position_indentation)
(compute_motion): Use it. This is just for clarity.
* image.c (xbm_image_p): Don't assume stated width and height fit in int.
* lisp.h (lint_assume): New macro.
......
......@@ -318,6 +318,15 @@ invalidate_current_column (void)
last_known_column_point = 0;
}
/* Return a non-outlandish value for the tab width. */
static int
sane_tab_width (void)
{
EMACS_INT n = XFASTINT (BVAR (current_buffer, tab_width));
return 0 < n && n <= 1000 ? n : 8;
}
EMACS_INT
current_column (void)
{
......@@ -326,7 +335,7 @@ current_column (void)
register int tab_seen;
EMACS_INT post_tab;
register int c;
register EMACS_INT tab_width = XINT (BVAR (current_buffer, tab_width));
int tab_width = sane_tab_width ();
int ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow));
register struct Lisp_Char_Table *dp = buffer_display_table ();
......@@ -356,9 +365,6 @@ current_column (void)
else
stop = GAP_END_ADDR;
if (tab_width <= 0 || tab_width > 1000)
tab_width = 8;
col = 0, tab_seen = 0, post_tab = 0;
while (1)
......@@ -509,7 +515,7 @@ check_display_width (EMACS_INT pos, EMACS_INT col, EMACS_INT *endpos)
static void
scan_for_column (EMACS_INT *endpos, EMACS_INT *goalcol, EMACS_INT *prevcol)
{
register EMACS_INT tab_width = XINT (BVAR (current_buffer, tab_width));
int tab_width = sane_tab_width ();
register int ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow));
register struct Lisp_Char_Table *dp = buffer_display_table ();
int multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters));
......@@ -535,7 +541,6 @@ scan_for_column (EMACS_INT *endpos, EMACS_INT *goalcol, EMACS_INT *prevcol)
window = Fget_buffer_window (Fcurrent_buffer (), Qnil);
w = ! NILP (window) ? XWINDOW (window) : NULL;
if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
memset (&cmp_it, 0, sizeof cmp_it);
cmp_it.id = -1;
composition_compute_stop_pos (&cmp_it, scan, scan_byte, end, Qnil);
......@@ -728,7 +733,7 @@ string_display_width (string, beg, end)
register int tab_seen;
int post_tab;
register int c;
register int tab_width = XINT (current_buffer->tab_width);
int tab_width = sane_tab_width ();
int ctl_arrow = !NILP (current_buffer->ctl_arrow);
register struct Lisp_Char_Table *dp = buffer_display_table ();
int b, e;
......@@ -755,8 +760,6 @@ string_display_width (string, beg, end)
going backwards from point. */
stop = SDATA (string) + b;
if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
col = 0, tab_seen = 0, post_tab = 0;
while (1)
......@@ -806,7 +809,7 @@ The return value is COLUMN. */)
{
EMACS_INT mincol;
register EMACS_INT fromcol;
register EMACS_INT tab_width = XINT (BVAR (current_buffer, tab_width));
int tab_width = sane_tab_width ();
CHECK_NUMBER (column);
if (NILP (minimum))
......@@ -820,8 +823,6 @@ The return value is COLUMN. */)
if (fromcol == mincol)
return make_number (mincol);
if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
if (indent_tabs_mode)
{
Lisp_Object n;
......@@ -867,15 +868,13 @@ static EMACS_INT
position_indentation (register int pos_byte)
{
register EMACS_INT column = 0;
register EMACS_INT tab_width = XINT (BVAR (current_buffer, tab_width));
int tab_width = sane_tab_width ();
register unsigned char *p;
register unsigned char *stop;
unsigned char *start;
EMACS_INT next_boundary_byte = pos_byte;
EMACS_INT ceiling = next_boundary_byte;
if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
p = BYTE_POS_ADDR (pos_byte);
/* STOP records the value of P at which we will need
to think about the gap, or about invisible text,
......@@ -1118,7 +1117,7 @@ compute_motion (EMACS_INT from, EMACS_INT fromvpos, EMACS_INT fromhpos, int did_
register EMACS_INT pos;
EMACS_INT pos_byte;
register int c = 0;
register EMACS_INT tab_width = XFASTINT (BVAR (current_buffer, tab_width));
int tab_width = sane_tab_width ();
register int ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow));
register struct Lisp_Char_Table *dp = window_display_table (win);
EMACS_INT selective
......@@ -1173,9 +1172,6 @@ compute_motion (EMACS_INT from, EMACS_INT fromvpos, EMACS_INT fromhpos, int did_
run cache, because that's based on the buffer's display table. */
width_table = 0;
if (tab_width <= 0 || tab_width > 1000)
tab_width = 8;
/* Negative width means use all available text columns. */
if (width < 0)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment