various comments. (DLR)
- Add the ability to open a file on a specified column as well
as a specified line, by allowing an argument of the form
- +LINE,COLUMN. Changes to main(), nano.1, and nano.texi. (DLR,
- suggested by PFTank)
+ +LINE,COLUMN. New function parse_line_column(); changes to
+ main(), nano.1, and nano.texi. (DLR, suggested by PFTank)
- cut.c:
cut_line()
- Set placewewant properly after cutting a line, to avoid a
* non-option argument, and it is followed by at least one other
* argument, the filename it applies to. */
if (0 < optind && optind < argc - 1 && argv[optind][0] == '+') {
- char *comma = strchr(&argv[optind][1], ',');
-
- if (comma != NULL)
- parse_num(&argv[optind][comma - argv[optind] + 1],
- &startcol);
-
- startline = atoi(&argv[optind][1]);
+ parse_line_column(&argv[optind][1], &startline, &startcol);
optind++;
}
* applies to. */
if (i < argc - 1 && argv[i][0] == '+' && iline == 1 &&
icol == 1) {
- char *comma = strchr(&argv[i][1], ',');
-
- if (comma != NULL)
- parse_num(&argv[i][comma - argv[i] + 1], &icol);
-
- iline = atoi(&argv[i][1]);
+ parse_line_column(&argv[i][1], &iline, &icol);
} else {
load_buffer(argv[i]);
int digits(size_t n);
void get_homedir(void);
bool parse_num(const char *str, ssize_t *val);
+void parse_line_column(const char *str, int *line, ssize_t *column);
void align(char **strp);
void null_at(char **data, size_t index);
void unsunder(char *str, size_t true_len);
return TRUE;
}
+void parse_line_column(const char *str, int *line, ssize_t *column)
+{
+ char *comma;
+
+ assert(str != NULL);
+
+ comma = strchr(str, ',');
+
+ if (comma != NULL && column != NULL)
+ parse_num(&str[comma - str + 1], column);
+
+ if (line != NULL)
+ *line = atoi(str);
+}
+
/* Fix the memory allocation for a string. */
void align(char **strp)
{