mirror of
git://git.sv.gnu.org/nano.git
synced 2024-11-22 12:51:23 +03:00
tweaks: condense the code that searches for a colon plus line number
This commit is contained in:
parent
5290a85afd
commit
f1e238a9af
24
src/nano.c
24
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))
|
||||
|
Loading…
Reference in New Issue
Block a user