nano-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v2] startup: add support for <file>:<line> format


From: Benno Schulenberg
Subject: Re: [PATCH v2] startup: add support for <file>:<line> format
Date: Tue, 28 Feb 2023 17:03:38 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1


Op 26-02-2023 om 01:58 schreef Benjamin Valentin:
+               {
+                       char *filename = argv[optind++];
+
+                       /* search for : to open file on a specific line */

Adjust the comment style to that of the rest of nano: start with a
capital, and end with a period.


+                       char *colon = filename;

Keep declarations together -- put it right after the previous one.


+                               /* if file starts with : skip that */
+                               if (colon == filename) {
+                                       ++colon;
+                                       continue;
+                               };

When starting the search from filename + 1, this fragment is unneeded.


+                               if (*(colon - 1) == '\\') {
+                                       size_t len = strlen(colon);
+                                       memmove(colon - 1, colon, len);
+                                       colon[len - 1] = 0;

When moving strlen(colon) + 1 bytes, the terminating zero is included,
and you don't need to poke it, and don't need an additional variable.


+                               /* if parsing succeeds, cut of the line suffix 
*/
+                               if (parse_line_column(colon + 1, &givenline, 
&givencol))
+                                       *colon = 0;

But if parsing fails, maybe there is a colon with proper numbers further
down the name.  So it should continue in that case.  That will allow
using filenames with embedded colons without needing to escape them
in most cases.

If you really wish your patch to be included in nano, you should
sign it off, as it says in README.hacking.

Benno

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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