[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: normal/cmdline bug & patch
From: |
Tomas Ebenlendr |
Subject: |
Re: normal/cmdline bug & patch |
Date: |
Tue, 15 Jun 2004 20:03:41 +0200 |
User-agent: |
Mutt/1.5.6i |
Oh sorry, another bug found. I will wait at least one hour before
submitting any patch, so I won't post too many messages.
Here is complete patch of normal/cmdline.c (grub_history_set)
>
> Ok here is another version of the patch with two more bugs fixed:
>
> bug1 ... hist_end does not point to last entry but to first empty.
> bug2 ... pos can underflow, but not overflow
> bug3 ... correction must act as 'modulo' so adding modulo value is right
> way
> bug4 ... if hist_pos == hist_end, we need ot copy nothing, all lines were
> copied.
>
- now it is fixed the right way. Before I fixed it, so another bug
occur when buffer is full.
bug5 ... something was copied when hist_end < hist_pos, but it was
definitely not what should be copied.
I think this function must have been written very late at nigt.
Now I will try to write 'chain' module (normal mode command for
'_chain').
---------
diff -ur grub2_x/ChangeLog grub2_work_xxx/ChangeLog
--- grub2_x/ChangeLog 2004-06-15 19:19:04.000000000 +0200
+++ grub2_work_xxx/ChangeLog 2004-06-15 19:24:42.000000000 +0200
@@ -1,3 +1,10 @@
+2004-06-15 Tomas Ebenlendr <address@hidden>
+
+ Bugfix of cmdline history (normal mode).
+
+ * normal/commandline.c (grub_set_history): History reallocating
+ was completely bad (about 5 brainos), all fixed.
+
2004-05-24 Marco Gerards <address@hidden>
Add support for UFS version 1 and 2. Add support for the minix
diff -ur grub2_x/normal/cmdline.c grub2_work_xxx/normal/cmdline.c
--- grub2_x/normal/cmdline.c 2004-06-15 19:18:52.000000000 +0200
+++ grub2_work_xxx/normal/cmdline.c 2004-06-15 19:14:15.000000000 +0200
@@ -52,33 +52,35 @@
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 *));
+ /* old_hist_lines: 0 <older part> hist_end <empty> hist_pos <newer
part> */
+ /* entry at hist_end is empty, at hist_pos contains first entry */
-
- /* Copy the last part. */
- grub_memmove (hist_lines + hist_pos, old_hist_lines + hist_pos,
+ /* 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 *));
+
}
}
--
Tomas 'ebi' Ebenlendr
http://get.to/ebik
PF 2004.45578118675
- normal/cmdline bug & patch, Tomas Ebenlendr, 2004/06/15
- Re: normal/cmdline bug & patch, Tomas Ebenlendr, 2004/06/15
- Re: normal/cmdline bug & patch, Tomas Ebenlendr, 2004/06/15
- Re: normal/cmdline bug & patch, Marco Gerards, 2004/06/15
- Re: normal/cmdline bug & patch, Tomas Ebenlendr, 2004/06/15
- Re: normal/cmdline bug & patch,
Tomas Ebenlendr <=
- Re: normal/cmdline bug & patch, Marco Gerards, 2004/06/15
- Re: normal/cmdline bug & patch, Tomas Ebenlendr, 2004/06/16
- Re: normal/cmdline bug & patch, Marco Gerards, 2004/06/18
- Re: normal/cmdline bug & patch, Tomas Ebenlendr, 2004/06/18
- Re: normal/cmdline bug & patch, Marco Gerards, 2004/06/27
- Re: normal/cmdline bug & patch, Yoshinori K. Okuji, 2004/06/16
- Re: normal/cmdline bug & patch, Marco Gerards, 2004/06/16
- Marco Gerards <address@hidden>, Tomas Ebenlendr, 2004/06/16
- sorry, Tomas Ebenlendr, 2004/06/16
- Re: normal/cmdline bug & patch, Marco Gerards, 2004/06/15