nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/3] files: avoid mistakenly setting the column number to a given


From: Benno Schulenberg
Subject: [PATCH 3/3] files: avoid mistakenly setting the column number to a given line number
Date: Sun, 12 May 2024 11:12:24 +0200

When the file 'foo:24' exists (but not 'foo') and the user wants to
use the colon notation to place the cursor on a certain line, then
nano would first interpret the given line number as a column number,
before noticing that 'foo' does not exist and then skipping the first
colon.  So, when such a misinterpretation occurs, the column number
needs to be reset to zero.
---
 src/nano.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/nano.c b/src/nano.c
index 0821dfaf..b1fe2bec 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -2509,8 +2509,10 @@ int main(int argc, char **argv)
                                                memmove(colon - 1, colon, 
strlen(colon) + 1);
                                        else if (parse_line_column(colon + 1, 
&givenline, &givencol)) {
                                                *colon = '\0';
-                                               if (stat(filename, &fileinfo) < 
0)
+                                               if (stat(filename, &fileinfo) < 
0) {
                                                        *colon++ = ':';
+                                                       givencol = 0;
+                                               }
                                        } else
                                                ++colon;
                                }
-- 
2.42.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]