2004-06-27 Tomas Ebenlendr <ebik@ucw.cz>

* normal/cmdline.c (grub_set_history): Fix off by one bug.  Fixed
	the history buffer logic.
This commit is contained in:
marco_g 2004-06-27 11:03:24 +00:00
parent 6eabba74e7
commit cfb12aff28
2 changed files with 17 additions and 14 deletions

View file

@ -1,3 +1,8 @@
2004-06-27 Tomas Ebenlendr <ebik@ucw.cz>
* normal/cmdline.c (grub_set_history): Fix off by one bug. Fixed
the history buffer logic.
2004-06-27 Tomas Ebenlendr <ebik@ucw.cz> 2004-06-27 Tomas Ebenlendr <ebik@ucw.cz>
* fs/ext2.c (FILETYPE_INO_MASK, FILETYPE_INO_DIRECTORY) * fs/ext2.c (FILETYPE_INO_MASK, FILETYPE_INO_DIRECTORY)

View file

@ -52,33 +52,31 @@ grub_set_history (int newsize)
int delsize = hist_used - newsize; int delsize = hist_used - newsize;
hist_used = newsize; hist_used = newsize;
for (i = 0; i < delsize; i++) for (i = 1; i <= delsize; i++)
{ {
int pos = hist_end - i; int pos = hist_end - i;
if (pos > hist_size) if (pos < 0)
pos -= hist_size; pos += hist_size;
grub_free (old_hist_lines[pos]); grub_free (old_hist_lines[pos]);
} }
hist_end -= delsize; hist_end -= delsize;
if (hist_end < 0) if (hist_end < 0)
hist_end = hist_size - hist_end; hist_end += hist_size;
} }
if (hist_pos < hist_end) if (hist_pos < hist_end)
grub_memmove (hist_lines, old_hist_lines + hist_pos, grub_memmove (hist_lines, old_hist_lines + hist_pos,
(hist_end - hist_pos) * sizeof (char *)); (hist_end - hist_pos) * sizeof (char *));
else else if (hist_used)
{ {
/* Copy the first part. */ /* Copy the older part. */
grub_memmove (hist_lines, old_hist_lines, grub_memmove (hist_lines, old_hist_lines + hist_pos,
hist_pos * sizeof (char *)); (hist_size - hist_pos) * sizeof (char *));
/* Copy the newer part. */
/* Copy the last part. */ grub_memmove (hist_lines + hist_size - hist_pos, old_hist_lines,
grub_memmove (hist_lines + hist_pos, old_hist_lines + hist_pos, hist_end * sizeof (char *));
(hist_size - hist_pos) * sizeof (char *));
} }
} }