Re: mcedit position remember bug
- From: Christian Hamar <krics linuxforum hu>
- To: mc-devel gnome org
- Subject: Re: mcedit position remember bug
- Date: Mon, 21 Mar 2005 12:51:37 +0100
> I found maybe a bug (or just a bad configuration) in mcedit postition
> remember option.
I create a small patch for this (just change one line and one little
value). The main problem is in the src/util.c code.
I viewed mc4.6.1pre1 which contains a segfaultable code with atol. That
was fixed in 4.6.1pre4 to use strtoll and check if
The old code in 4.6.1pre1:
*line = atol(p);
p = strchr (buf, ';');
*column = atol (&p[1]);
The new code in 4.6.1pre4:
*line = strtol(p, const_cast(char **, &p), 10);
if (*p == ';') {
*column = strtol(p, const_cast(char **, &p), 10);
if (*p != '\n')
*column = 0;
} else
*line = 1;
We see that there is a check for ; . If found then go and strtol p to
column. But. With this code the column got something like this as
value : (if in filepos : /xx.txt 12;20)
;20
So the bad ; stays there and column goes to 0 and editor can not set
cursor to ';20'
The fix is included. Need *column = strtol(p+1, const_cast(char **, &p),
10);
I attached this small patch against 4.6.1pre4
I hope this is good way to fix this problem, if not, please someone
correct out that :)
Regards
Christian Hamar alias krix
Hungary
diff -Naur mc-4.6.1-pre4a.old/src/util.c mc-4.6.1-pre4a/src/util.c
--- mc-4.6.1-pre4a.old/src/util.c 2005-03-21 12:32:16.000000000 +0100
+++ mc-4.6.1-pre4a/src/util.c 2005-03-21 12:32:26.000000000 +0100
@@ -1364,7 +1364,7 @@
*line = strtol(p, const_cast(char **, &p), 10);
if (*p == ';') {
- *column = strtol(p, const_cast(char **, &p), 10);
+ *column = strtol(p+1, const_cast(char **, &p), 10);
if (*p != '\n')
*column = 0;
} else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]