Re: [ANNOUNCE] nano-8.0 is released
Chris Allegretta <[email protected]>
| Newsgroups | gmane.editors.nano.devel |
|---|---|
| Message-ID | <[email protected]> |
I like this feature a lot as well! Benno what about the following: only run the check if there is exactly one colon in the filename? Patch attached. On 5/1/24 12:06, Big Jango wrote: > Hello Ralph, > > I agree that there are some issues with the filename:number syntax, however > I believe that it should stay. > In my opinion it is great for copying the error output of many programs, > which is often already in the filename:number format. > I think instead of being completely removed, it should be configurable, > along with the problems you mentioned being fixed of course! > > Cheers, Max >
onecolonforfilename.diff
(text/x-patch, 1.3 KB)
diff --git a/src/nano.c b/src/nano.c
index 973054f0..eef54017 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -2498,17 +2498,21 @@ int main(int argc, char **argv)
/* Search the filename for a colon. If the colon is preceded by
* a backslash, elide the backslash and skip the colon. If there
- * is a valid number after the colon, chop colon and number off.
- * The number is later used to place the cursor on that line. */
- while ((colon = strchr(colon, ':'))) {
- if (*(colon - 1) == '\\')
- memmove(colon - 1, colon, strlen(colon) + 1);
- else if (parse_line_column(colon + 1, &givenline, &givencol))
- *colon = '\0';
- else
- ++colon;
+ * is a valid number after the colon (and no further colons),
+ * chop colon and number off. The number is later used to place
+ * the cursor on that line. */
+ char *fc = copy_of(filename);
+ if (strtok(fc, ":") && strtok(NULL, ":") && strtok(NULL, ":") == NULL) {
+ while ((colon = strchr(colon, ':'))) {
+ if (*(colon - 1) == '\\')
+ memmove(colon - 1, colon, strlen(colon) + 1);
+ else if (parse_line_column(colon + 1, &givenline, &givencol))
+ *colon = '\0';
+ else
+ ++colon;
+ }
}
-
+ free(fc);
if (!open_buffer(filename, TRUE))
continue;
}