summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ChangeLog25
-rw-r--r--src/bytecode.c2
-rw-r--r--src/cmds.c13
-rw-r--r--src/indent.c49
-rw-r--r--src/keymap.c2
-rw-r--r--src/lisp.h4
-rw-r--r--src/minibuf.c4
-rw-r--r--src/xdisp.c15
8 files changed, 68 insertions, 46 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 4955966ad8..d0380e42e4 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,30 @@
2011-03-06 Paul Eggert <eggert@cs.ucla.edu>
+ current_column: Now returns EMACS_INT, fixing some iftc.
+ * bytecode.c (Fbyte_code): Don't cast current_column () to int.
+ * cmds.c (internal_self_insert): Likewise.
+ * indent.c (Fcurrent_column): Likewise.
+ * keymap.c (describe_command): Likewise.
+ * minibuf.c (read_minibuf): Likewise.
+ * indent.c (Fcurrent_indentation): Don't cast position_indentation ()
+ to int.
+ * xdisp.c (redisplay_internal, redisplay_window, decode_mode_spec):
+ Likewise.
+ * cmds.c (internal_self_insert): Declare locals to be EMACS_INT,
+ not int or double, if they might contain a column number.
+ * indent.c (current_column, Findent_to, indented_beyond_p):
+ (compute_motion, vmotion): Likewise.
+ * keymap.c (describe_command): Likewise.
+ * xdisp.c (pint2str): Likewise.
+ * indent.c (last_known_column): Now EMACS_INT, not int.
+ * minibuf.c (minibuf_prompt_width): Likewise.
+ * indent.c (current_column, current_column_1, position_indentation):
+ Return EMACS_INT, not double.
+ * lisp.h (current_column): Likewise.
+ * indent.c (indented_beyond_p): Last arg is now EMACS_INT, not double.
+ All callers changed.
+ * lisp.h (indented_beyond_p): Likewise.
+
* minibuf.c (minibuf_prompt, minibuf_prompt_width): Move here
from xdisp.c, and make static, since these are used only here.
* window.h, xdisp.c (minibuf_prompt, minibuf_prompt_width):
diff --git a/src/bytecode.c b/src/bytecode.c
index cf4a1fc225..bb4e87c019 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -1323,7 +1323,7 @@ If the third argument is incorrect, Emacs may crash. */)
{
Lisp_Object v1;
BEFORE_POTENTIAL_GC ();
- XSETFASTINT (v1, (int) current_column ()); /* iftc */
+ XSETFASTINT (v1, current_column ());
AFTER_POTENTIAL_GC ();
PUSH (v1);
break;
diff --git a/src/cmds.c b/src/cmds.c
index 7e0eec99be..5e6884c080 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -381,19 +381,22 @@ internal_self_insert (int c, EMACS_INT n)
{
EMACS_INT pos = PT;
EMACS_INT pos_byte = PT_BYTE;
+
+ /* FIXME: Check for integer overflow when calculating
+ target_clm and actual_clm. */
+
/* Column the cursor should be placed at after this insertion.
The correct value should be calculated only when necessary. */
- int target_clm = ((int) current_column () /* iftc */
- + n * (int) XINT (Fchar_width (make_number (c))));
+ EMACS_INT target_clm = (current_column ()
+ + n * XINT (Fchar_width (make_number (c))));
/* The actual cursor position after the trial of moving
to column TARGET_CLM. It is greater than TARGET_CLM
if the TARGET_CLM is middle of multi-column
character. In that case, the new point is set after
that character. */
- int actual_clm
- = (int) XFASTINT (Fmove_to_column (make_number (target_clm),
- Qnil));
+ EMACS_INT actual_clm
+ = XFASTINT (Fmove_to_column (make_number (target_clm), Qnil));
chars_to_delete = PT - pos;
diff --git a/src/indent.c b/src/indent.c
index 85d26520cf..37ce647556 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -45,7 +45,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
Some things in set last_known_column_point to -1
to mark the memorized value as invalid. */
-static double last_known_column;
+static EMACS_INT last_known_column;
/* Value of point when current_column was called. */
@@ -55,8 +55,8 @@ EMACS_INT last_known_column_point;
static int last_known_column_modified;
-static double current_column_1 (void);
-static double position_indentation (int);
+static EMACS_INT current_column_1 (void);
+static EMACS_INT position_indentation (int);
/* Cache of beginning of line found by the last call of
current_column. */
@@ -309,7 +309,7 @@ Text that has an invisible property is considered as having width 0, unless
(void)
{
Lisp_Object temp;
- XSETFASTINT (temp, (int) current_column ()); /* iftc */
+ XSETFASTINT (temp, current_column ());
return temp;
}
@@ -321,15 +321,15 @@ invalidate_current_column (void)
last_known_column_point = 0;
}
-double
+EMACS_INT
current_column (void)
{
- register int col;
+ register EMACS_INT col;
register unsigned char *ptr, *stop;
register int tab_seen;
- int post_tab;
+ EMACS_INT post_tab;
register int c;
- register int tab_width = XINT (BVAR (current_buffer, tab_width));
+ register EMACS_INT tab_width = XINT (BVAR (current_buffer, tab_width));
int ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow));
register struct Lisp_Char_Table *dp = buffer_display_table ();
@@ -705,7 +705,7 @@ scan_for_column (EMACS_INT *endpos, EMACS_INT *goalcol, EMACS_INT *prevcol)
This function handles characters that are invisible
due to text properties or overlays. */
-static double
+static EMACS_INT
current_column_1 (void)
{
EMACS_INT col = MOST_POSITIVE_FIXNUM;
@@ -807,9 +807,9 @@ even if that goes past COLUMN; by default, MINIMUM is zero.
The return value is COLUMN. */)
(Lisp_Object column, Lisp_Object minimum)
{
- int mincol;
- register int fromcol;
- register int tab_width = XINT (BVAR (current_buffer, tab_width));
+ EMACS_INT mincol;
+ register EMACS_INT fromcol;
+ register EMACS_INT tab_width = XINT (BVAR (current_buffer, tab_width));
CHECK_NUMBER (column);
if (NILP (minimum))
@@ -849,8 +849,6 @@ The return value is COLUMN. */)
}
-static double position_indentation (int);
-
DEFUN ("current-indentation", Fcurrent_indentation, Scurrent_indentation,
0, 0, 0,
doc: /* Return the indentation of the current line.
@@ -863,12 +861,12 @@ following any initial whitespace. */)
scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -1, 1);
- XSETFASTINT (val, (int) position_indentation (PT_BYTE)); /* iftc */
+ XSETFASTINT (val, position_indentation (PT_BYTE));
SET_PT_BOTH (opoint, opoint_byte);
return val;
}
-static double
+static EMACS_INT
position_indentation (register int pos_byte)
{
register EMACS_INT column = 0;
@@ -958,9 +956,9 @@ position_indentation (register int pos_byte)
preceding line. */
int
-indented_beyond_p (EMACS_INT pos, EMACS_INT pos_byte, double column)
+indented_beyond_p (EMACS_INT pos, EMACS_INT pos_byte, EMACS_INT column)
{
- double val;
+ EMACS_INT val;
EMACS_INT opoint = PT, opoint_byte = PT_BYTE;
SET_PT_BOTH (pos, pos_byte);
@@ -969,7 +967,7 @@ indented_beyond_p (EMACS_INT pos, EMACS_INT pos_byte, double column)
val = position_indentation (PT_BYTE);
SET_PT_BOTH (opoint, opoint_byte);
- return val >= column; /* hmm, float comparison */
+ return val >= column;
}
DEFUN ("move-to-column", Fmove_to_column, Smove_to_column, 1, 2, "p",
@@ -1126,7 +1124,7 @@ compute_motion (EMACS_INT from, EMACS_INT fromvpos, EMACS_INT fromhpos, int did_
register EMACS_INT tab_width = XFASTINT (BVAR (current_buffer, tab_width));
register int ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow));
register struct Lisp_Char_Table *dp = window_display_table (win);
- int selective
+ EMACS_INT selective
= (INTEGERP (BVAR (current_buffer, selective_display))
? XINT (BVAR (current_buffer, selective_display))
: !NILP (BVAR (current_buffer, selective_display)) ? -1 : 0);
@@ -1590,8 +1588,7 @@ compute_motion (EMACS_INT from, EMACS_INT fromvpos, EMACS_INT fromhpos, int did_
else if (c == '\n')
{
if (selective > 0
- && indented_beyond_p (pos, pos_byte,
- (double) selective)) /* iftc */
+ && indented_beyond_p (pos, pos_byte, selective))
{
/* If (pos == to), we don't have to take care of
selective display. */
@@ -1607,7 +1604,7 @@ compute_motion (EMACS_INT from, EMACS_INT fromvpos, EMACS_INT fromhpos, int did_
}
while (pos < to
&& indented_beyond_p (pos, pos_byte,
- (double) selective)); /* iftc */
+ selective));
/* Allow for the " ..." that is displayed for them. */
if (selective_rlen)
{
@@ -1837,7 +1834,7 @@ vmotion (register EMACS_INT from, register EMACS_INT vtarget, struct window *w)
register EMACS_INT first;
EMACS_INT from_byte;
EMACS_INT lmargin = hscroll > 0 ? 1 - hscroll : 0;
- int selective
+ EMACS_INT selective
= (INTEGERP (BVAR (current_buffer, selective_display))
? XINT (BVAR (current_buffer, selective_display))
: !NILP (BVAR (current_buffer, selective_display)) ? -1 : 0);
@@ -1872,7 +1869,7 @@ vmotion (register EMACS_INT from, register EMACS_INT vtarget, struct window *w)
&& ((selective > 0
&& indented_beyond_p (prevline,
CHAR_TO_BYTE (prevline),
- (double) selective)) /* iftc */
+ selective))
/* Watch out for newlines with `invisible' property.
When moving upward, check the newline before. */
|| (propval = Fget_char_property (make_number (prevline - 1),
@@ -1929,7 +1926,7 @@ vmotion (register EMACS_INT from, register EMACS_INT vtarget, struct window *w)
&& ((selective > 0
&& indented_beyond_p (prevline,
CHAR_TO_BYTE (prevline),
- (double) selective)) /* iftc */
+ selective))
/* Watch out for newlines with `invisible' property.
When moving downward, check the newline after. */
|| (propval = Fget_char_property (make_number (prevline),
diff --git a/src/keymap.c b/src/keymap.c
index 1fbb40f127..4459ef07d6 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -3219,7 +3219,7 @@ static void
describe_command (Lisp_Object definition, Lisp_Object args)
{
register Lisp_Object tem1;
- int column = (int) current_column (); /* iftc */
+ EMACS_INT column = current_column ();
int description_column;
/* If column 16 is no good, go to col 32;
diff --git a/src/lisp.h b/src/lisp.h
index 82c4f65613..e38d6a8ec3 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3145,9 +3145,9 @@ extern char *push_key_description (unsigned int, char *, int);
EXFUN (Fvertical_motion, 2);
EXFUN (Findent_to, 2);
EXFUN (Fmove_to_column, 2);
-extern double current_column (void);
+extern EMACS_INT current_column (void);
extern void invalidate_current_column (void);
-extern int indented_beyond_p (EMACS_INT, EMACS_INT, double);
+extern int indented_beyond_p (EMACS_INT, EMACS_INT, EMACS_INT);
extern void syms_of_indent (void);
/* Defined in frame.c */
diff --git a/src/minibuf.c b/src/minibuf.c
index a56ed679a5..83587b53b7 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -89,7 +89,7 @@ static Lisp_Object minibuf_prompt;
/* Width of current mini-buffer prompt. Only set after display_line
of the line that contains the prompt. */
-static int minibuf_prompt_width;
+static EMACS_INT minibuf_prompt_width;
/* Put minibuf on currently selected frame's minibuffer.
@@ -632,7 +632,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
unbind_to (count1, Qnil);
}
- minibuf_prompt_width = (int) current_column (); /* iftc */
+ minibuf_prompt_width = current_column ();
/* Put in the initial input. */
if (!NILP (initial))
diff --git a/src/xdisp.c b/src/xdisp.c
index c8ec74ea7b..44cb713011 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -762,7 +762,7 @@ static Lisp_Object get_it_property (struct it *it, Lisp_Object prop);
static void handle_line_prefix (struct it *);
-static void pint2str (char *, int, int);
+static void pint2str (char *, int, EMACS_INT);
static void pint2hrstr (char *, int, int);
static struct text_pos run_window_scroll_functions (Lisp_Object,
struct text_pos);
@@ -11579,8 +11579,7 @@ redisplay_internal (int preserve_echo_area)
&& !(PT == XFASTINT (w->last_point)
&& XFASTINT (w->last_modified) >= MODIFF
&& XFASTINT (w->last_overlay_modified) >= OVERLAY_MODIFF)
- && (XFASTINT (w->column_number_displayed)
- != (int) current_column ())) /* iftc */
+ && (XFASTINT (w->column_number_displayed) != current_column ()))
w->update_mode_line = Qt;
unbind_to (count1, Qnil);
@@ -13819,8 +13818,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
&& !(PT == XFASTINT (w->last_point)
&& XFASTINT (w->last_modified) >= MODIFF
&& XFASTINT (w->last_overlay_modified) >= OVERLAY_MODIFF)
- && (XFASTINT (w->column_number_displayed)
- != (int) current_column ())) /* iftc */
+ && (XFASTINT (w->column_number_displayed) != current_column ()))
update_mode_line = 1;
/* Count number of windows showing the selected buffer. An indirect
@@ -14328,8 +14326,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
|| INTEGERP (w->base_line_pos)
/* Column number is displayed and different from the one displayed. */
|| (!NILP (w->column_number_displayed)
- && (XFASTINT (w->column_number_displayed)
- != (int) current_column ()))) /* iftc */
+ && (XFASTINT (w->column_number_displayed) != current_column ())))
/* This means that the window has a mode line. */
&& (WINDOW_WANTS_MODELINE_P (w)
|| WINDOW_WANTS_HEADER_LINE_P (w)))
@@ -18983,7 +18980,7 @@ are the selected window and the WINDOW's buffer). */)
the positive integer D to BUF using a minimal field width WIDTH. */
static void
-pint2str (register char *buf, register int width, register int d)
+pint2str (register char *buf, register int width, register EMACS_INT d)
{
register char *p = buf;
@@ -19312,7 +19309,7 @@ decode_mode_spec (struct window *w, register int c, int field_width,
return "";
else
{
- int col = (int) current_column (); /* iftc */
+ EMACS_INT col = current_column ();
w->column_number_displayed = make_number (col);
pint2str (decode_mode_spec_buf, field_width, col);
return decode_mode_spec_buf;