]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2004-06-27 Tomas Ebenlendr <ebik@ucw.cz>
authormarco_g <marco_g@localhost>
Sun, 27 Jun 2004 11:03:24 +0000 (11:03 +0000)
committermarco_g <marco_g@localhost>
Sun, 27 Jun 2004 11:03:24 +0000 (11:03 +0000)
* normal/cmdline.c (grub_set_history): Fix off by one bug.  Fixed
the history buffer logic.

ChangeLog
normal/cmdline.c

index 450f70592927ff0119006d5f02c4b97f092c7808..05fc4b5a424c17a5e121c44ac2d1e6200ae84a69 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
 
        * fs/ext2.c (FILETYPE_INO_MASK, FILETYPE_INO_DIRECTORY)
index b4d2a16f34737b118ed71347b57dbdee55d7db13..b53a630f1f4779318dccdc5527d77a7c9e343f5e 100644 (file)
@@ -52,33 +52,31 @@ grub_set_history (int newsize)
          int delsize = hist_used - newsize;
          hist_used = newsize;
 
-         for (i = 0; i < delsize; i++)
+         for (i = 1; i <= delsize; i++)
            {
              int pos = hist_end - i;
-             if (pos > hist_size)
-               pos -= hist_size;
+             if (pos < 0)
+               pos += hist_size;
              grub_free (old_hist_lines[pos]);
            }
 
          hist_end -= delsize;
          if (hist_end < 0)
-           hist_end = hist_size - hist_end;
+           hist_end += hist_size;
        }
 
       if (hist_pos < hist_end)
        grub_memmove (hist_lines, old_hist_lines + hist_pos,
                      (hist_end - hist_pos) * sizeof (char *));
-      else
+      else if (hist_used)
        {
-         /* Copy the first part.  */
-         grub_memmove (hist_lines, old_hist_lines,
-                       hist_pos * sizeof (char *));
-
-
-         /* Copy the last part.  */
-         grub_memmove (hist_lines + hist_pos, old_hist_lines + hist_pos,
-                       (hist_size - hist_pos) * sizeof (char *));
-
+         /* Copy the older part.  */
+         grub_memmove (hist_lines, old_hist_lines + hist_pos,
+                       (hist_size - hist_pos) * sizeof (char *));
+         
+         /* Copy the newer part. */
+         grub_memmove (hist_lines + hist_size - hist_pos, old_hist_lines,
+                       hist_end * sizeof (char *));
        }
     }