aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2011-06-18 11:24:12 -0700
committerPaul Eggert2011-06-18 11:24:12 -0700
commit53b2623dc0426c52b4adff4b2ddae85fd23fbc26 (patch)
tree00a53db42e15742662b8fc6db3870878d2c507f6 /src
parent45aebb64558b304b7bff7ccce370f801663291d5 (diff)
downloademacs-53b2623dc0426c52b4adff4b2ddae85fd23fbc26.tar.gz
emacs-53b2623dc0426c52b4adff4b2ddae85fd23fbc26.zip
* 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.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog4
-rw-r--r--src/indent.c34
2 files changed, 19 insertions, 19 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index c034bba6fa8..a8fc8a8a217 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,9 @@
12011-06-18 Paul Eggert <eggert@cs.ucla.edu> 12011-06-18 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 * indent.c (sane_tab_width): New function.
4 (current_column, scan_for_column, Findent_to, position_indentation)
5 (compute_motion): Use it. This is just for clarity.
6
3 * image.c (xbm_image_p): Don't assume stated width and height fit in int. 7 * image.c (xbm_image_p): Don't assume stated width and height fit in int.
4 8
5 * lisp.h (lint_assume): New macro. 9 * lisp.h (lint_assume): New macro.
diff --git a/src/indent.c b/src/indent.c
index 57a4548ef3c..809631786fc 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -318,6 +318,15 @@ invalidate_current_column (void)
318 last_known_column_point = 0; 318 last_known_column_point = 0;
319} 319}
320 320
321/* Return a non-outlandish value for the tab width. */
322
323static int
324sane_tab_width (void)
325{
326 EMACS_INT n = XFASTINT (BVAR (current_buffer, tab_width));
327 return 0 < n && n <= 1000 ? n : 8;
328}
329
321EMACS_INT 330EMACS_INT
322current_column (void) 331current_column (void)
323{ 332{
@@ -326,7 +335,7 @@ current_column (void)
326 register int tab_seen; 335 register int tab_seen;
327 EMACS_INT post_tab; 336 EMACS_INT post_tab;
328 register int c; 337 register int c;
329 register EMACS_INT tab_width = XINT (BVAR (current_buffer, tab_width)); 338 int tab_width = sane_tab_width ();
330 int ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow)); 339 int ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow));
331 register struct Lisp_Char_Table *dp = buffer_display_table (); 340 register struct Lisp_Char_Table *dp = buffer_display_table ();
332 341
@@ -356,9 +365,6 @@ current_column (void)
356 else 365 else
357 stop = GAP_END_ADDR; 366 stop = GAP_END_ADDR;
358 367
359 if (tab_width <= 0 || tab_width > 1000)
360 tab_width = 8;
361
362 col = 0, tab_seen = 0, post_tab = 0; 368 col = 0, tab_seen = 0, post_tab = 0;
363 369
364 while (1) 370 while (1)
@@ -509,7 +515,7 @@ check_display_width (EMACS_INT pos, EMACS_INT col, EMACS_INT *endpos)
509static void 515static void
510scan_for_column (EMACS_INT *endpos, EMACS_INT *goalcol, EMACS_INT *prevcol) 516scan_for_column (EMACS_INT *endpos, EMACS_INT *goalcol, EMACS_INT *prevcol)
511{ 517{
512 register EMACS_INT tab_width = XINT (BVAR (current_buffer, tab_width)); 518 int tab_width = sane_tab_width ();
513 register int ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow)); 519 register int ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow));
514 register struct Lisp_Char_Table *dp = buffer_display_table (); 520 register struct Lisp_Char_Table *dp = buffer_display_table ();
515 int multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); 521 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)
535 window = Fget_buffer_window (Fcurrent_buffer (), Qnil); 541 window = Fget_buffer_window (Fcurrent_buffer (), Qnil);
536 w = ! NILP (window) ? XWINDOW (window) : NULL; 542 w = ! NILP (window) ? XWINDOW (window) : NULL;
537 543
538 if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
539 memset (&cmp_it, 0, sizeof cmp_it); 544 memset (&cmp_it, 0, sizeof cmp_it);
540 cmp_it.id = -1; 545 cmp_it.id = -1;
541 composition_compute_stop_pos (&cmp_it, scan, scan_byte, end, Qnil); 546 composition_compute_stop_pos (&cmp_it, scan, scan_byte, end, Qnil);
@@ -728,7 +733,7 @@ string_display_width (string, beg, end)
728 register int tab_seen; 733 register int tab_seen;
729 int post_tab; 734 int post_tab;
730 register int c; 735 register int c;
731 register int tab_width = XINT (current_buffer->tab_width); 736 int tab_width = sane_tab_width ();
732 int ctl_arrow = !NILP (current_buffer->ctl_arrow); 737 int ctl_arrow = !NILP (current_buffer->ctl_arrow);
733 register struct Lisp_Char_Table *dp = buffer_display_table (); 738 register struct Lisp_Char_Table *dp = buffer_display_table ();
734 int b, e; 739 int b, e;
@@ -755,8 +760,6 @@ string_display_width (string, beg, end)
755 going backwards from point. */ 760 going backwards from point. */
756 stop = SDATA (string) + b; 761 stop = SDATA (string) + b;
757 762
758 if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
759
760 col = 0, tab_seen = 0, post_tab = 0; 763 col = 0, tab_seen = 0, post_tab = 0;
761 764
762 while (1) 765 while (1)
@@ -806,7 +809,7 @@ The return value is COLUMN. */)
806{ 809{
807 EMACS_INT mincol; 810 EMACS_INT mincol;
808 register EMACS_INT fromcol; 811 register EMACS_INT fromcol;
809 register EMACS_INT tab_width = XINT (BVAR (current_buffer, tab_width)); 812 int tab_width = sane_tab_width ();
810 813
811 CHECK_NUMBER (column); 814 CHECK_NUMBER (column);
812 if (NILP (minimum)) 815 if (NILP (minimum))
@@ -820,8 +823,6 @@ The return value is COLUMN. */)
820 if (fromcol == mincol) 823 if (fromcol == mincol)
821 return make_number (mincol); 824 return make_number (mincol);
822 825
823 if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
824
825 if (indent_tabs_mode) 826 if (indent_tabs_mode)
826 { 827 {
827 Lisp_Object n; 828 Lisp_Object n;
@@ -867,15 +868,13 @@ static EMACS_INT
867position_indentation (register int pos_byte) 868position_indentation (register int pos_byte)
868{ 869{
869 register EMACS_INT column = 0; 870 register EMACS_INT column = 0;
870 register EMACS_INT tab_width = XINT (BVAR (current_buffer, tab_width)); 871 int tab_width = sane_tab_width ();
871 register unsigned char *p; 872 register unsigned char *p;
872 register unsigned char *stop; 873 register unsigned char *stop;
873 unsigned char *start; 874 unsigned char *start;
874 EMACS_INT next_boundary_byte = pos_byte; 875 EMACS_INT next_boundary_byte = pos_byte;
875 EMACS_INT ceiling = next_boundary_byte; 876 EMACS_INT ceiling = next_boundary_byte;
876 877
877 if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
878
879 p = BYTE_POS_ADDR (pos_byte); 878 p = BYTE_POS_ADDR (pos_byte);
880 /* STOP records the value of P at which we will need 879 /* STOP records the value of P at which we will need
881 to think about the gap, or about invisible text, 880 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_
1118 register EMACS_INT pos; 1117 register EMACS_INT pos;
1119 EMACS_INT pos_byte; 1118 EMACS_INT pos_byte;
1120 register int c = 0; 1119 register int c = 0;
1121 register EMACS_INT tab_width = XFASTINT (BVAR (current_buffer, tab_width)); 1120 int tab_width = sane_tab_width ();
1122 register int ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow)); 1121 register int ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow));
1123 register struct Lisp_Char_Table *dp = window_display_table (win); 1122 register struct Lisp_Char_Table *dp = window_display_table (win);
1124 EMACS_INT selective 1123 EMACS_INT selective
@@ -1173,9 +1172,6 @@ compute_motion (EMACS_INT from, EMACS_INT fromvpos, EMACS_INT fromhpos, int did_
1173 run cache, because that's based on the buffer's display table. */ 1172 run cache, because that's based on the buffer's display table. */
1174 width_table = 0; 1173 width_table = 0;
1175 1174
1176 if (tab_width <= 0 || tab_width > 1000)
1177 tab_width = 8;
1178
1179 /* Negative width means use all available text columns. */ 1175 /* Negative width means use all available text columns. */
1180 if (width < 0) 1176 if (width < 0)
1181 { 1177 {