diff --git a/src/nano.c b/src/nano.c index 296f22dc..bd069cd3 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2486,23 +2486,17 @@ int main(int argc, char **argv) char *filename = argv[optind++]; char *colon = filename + (*filename ? 1 : 0); - /* Search for a colon, to open the file on a specific line. */ + /* 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 the colon is escaped, unescape it and skip it. */ - if (*(colon - 1) == '\\') { + if (*(colon - 1) == '\\') memmove(colon - 1, colon, strlen(colon) + 1); - continue; - } - - /* If parsing succeeds, cut off the line suffix. */ - if (parse_line_column(colon + 1, &givenline, &givencol)) { - *colon = 0; - break; - } - - /* Parsing failed; skip this colon. */ - ++colon; + else if (parse_line_column(colon + 1, &givenline, &givencol)) + *colon = '\0'; + else + ++colon; } if (!open_buffer(filename, TRUE))