[PATCH 2/3] tweaks: reshuffle a declaration, adjust a comment, normalize indentation

Benno Schulenberg <[email protected]>
Newsgroups gmane.editors.nano.devel
Message-ID <[email protected]>
---
 src/nano.c | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/src/nano.c b/src/nano.c
index 0467504f..0821dfaf 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -2494,24 +2494,26 @@ int main(int argc, char **argv)
 #endif
 		{
 			char *filename = argv[optind++];
-			char *colon = filename + (*filename ? 1 : 0);
 			struct stat fileinfo;
 
-			/* 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.
+			/* If the filename contains a colon and this file does not exist,
+			 * then check if the filename ends with a number (while skipping
+			 * any colon preceded by a backslash and eliding the backslash).
+			 * If there is a valid trailing number, chop colon and number off.
 			 * The number is later used to place the cursor on that line. */
 			if (strchr(filename, ':') && stat(filename, &fileinfo) < 0) {
-			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';
-					if (stat(filename, &fileinfo) < 0)
-						*colon++ = ':';
-				} else
-					++colon;
-			}
+				char *colon = filename + (*filename ? 1 : 0);
+
+				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';
+						if (stat(filename, &fileinfo) < 0)
+							*colon++ = ':';
+					} else
+						++colon;
+				}
 			}
 
 			if (!open_buffer(filename, TRUE))
-- 
2.42.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.