/* text.c -- text handling commands for readline. */
-/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2010 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
if (_rl_doing_an_undo == 0)
rl_add_undo (UNDO_DELETE, from, to, text);
else
- free (text);
+ xfree (text);
rl_end -= diff;
rl_line_buffer[rl_end] = '\0';
if (count > 0)
{
- int end = rl_point + count;
+ int end, lend;
+
+ end = rl_point + count;
#if defined (VI_MODE)
- int lend = rl_end > 0 ? rl_end - (VI_COMMAND_MODE()) : rl_end;
+ lend = rl_end > 0 ? rl_end - (VI_COMMAND_MODE()) : rl_end;
#else
- int lend = rl_end;
+ lend = rl_end;
#endif
if (end > lend)
return 0;
}
+int
+_rl_forward_char_internal (count)
+ int count;
+{
+ int point;
+
+#if defined (HANDLE_MULTIBYTE)
+ point = _rl_find_next_mbchar (rl_line_buffer, rl_point, count, MB_FIND_NONZERO);
+
+#if defined (VI_MODE)
+ if (point >= rl_end && VI_COMMAND_MODE())
+ point = _rl_find_prev_mbchar (rl_line_buffer, rl_end, MB_FIND_NONZERO);
+#endif
+
+ if (rl_end < 0)
+ rl_end = 0;
+#else
+ point = rl_point + count;
+ if (point > rl_end)
+ point = rl_end;
+#endif
+
+ return (point);
+}
+
#if defined (HANDLE_MULTIBYTE)
/* Move forward COUNT characters. */
int
return 0;
}
- point = _rl_find_next_mbchar (rl_line_buffer, rl_point, count, MB_FIND_NONZERO);
-
-#if defined (VI_MODE)
- if (point >= rl_end && VI_COMMAND_MODE())
- point = _rl_find_prev_mbchar (rl_line_buffer, rl_end, MB_FIND_NONZERO);
-#endif
+ point = _rl_forward_char_internal (count);
if (rl_point == point)
rl_ding ();
rl_point = point;
-
- if (rl_end < 0)
- rl_end = 0;
}
return 0;
string[i] = '\0';
rl_insert_text (string);
- free (string);
+ xfree (string);
return 0;
}
count -= decreaser;
}
- free (string);
+ xfree (string);
incoming_length = 0;
stored_count = 0;
#else /* !HANDLE_MULTIBYTE */
/* We are inserting a single character.
If there is pending input, then make a string of all of the
pending characters that are bound to rl_insert, and insert
- them all. */
- if (_rl_any_typein ())
+ them all. Don't do this if we're current reading input from
+ a macro. */
+ if ((RL_ISSTATE (RL_STATE_MACROINPUT) == 0) && _rl_any_typein ())
_rl_insert_typein (c);
else
{
/* I think that does it. */
rl_end_undo_group ();
- free (word1);
- free (word2);
+ xfree (word1);
+ xfree (word2);
return 0;
}
rl_end_undo_group ();
#if defined (HANDLE_MULTIBYTE)
- free (dummy);
+ xfree (dummy);
#endif
return 0;
int prepos;
#endif
+ if (dir == 0)
+ return -1;
+
pos = rl_point;
inc = (dir < 0) ? -1 : 1;
while (count)