From da3d822149ae96321b0e37b3ecd2b62f96db8003 Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Mon, 4 Jul 2016 19:26:43 +0530 Subject: [PATCH] utils: allow more separators at Go To Line At Go To Line between line and column numbers allow separators other than comma, specifically - the letter m, period, slash, space and semicolon. Also rename variable comma as separator. This accomplishes http://savannah.gnu.org/bugs/?48305. Signed-off-by: Rishabh Dave --- src/utils.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/utils.c b/src/utils.c index 4411499..21147c0 100644 --- a/src/utils.c +++ b/src/utils.c @@ -77,27 +77,30 @@ bool parse_num(const char *str, ssize_t *val) return TRUE; } -/* Read two ssize_t's, separated by a comma, from str, and store them in +/* Read two ssize_t's, separated by a separator, from str, and store them in * *line and *column (if they're not both NULL). Return FALSE on error, * or TRUE otherwise. */ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column) { bool retval = TRUE; - const char *comma; + const char *separator; assert(str != NULL); - comma = strchr(str, ','); + while (*str== ' ') + ++str; - if (comma != NULL && column != NULL) { - if (!parse_num(comma + 1, column)) + separator = strpbrk(str, "m,./ ;"); + + if (separator != NULL && column != NULL) { + if (!parse_num(separator + 1, column)) retval = FALSE; } if (line != NULL) { - if (comma != NULL) { - char *str_line = mallocstrncpy(NULL, str, comma - str + 1); - str_line[comma - str] = '\0'; + if (separator != NULL) { + char *str_line = mallocstrncpy(NULL, str, separator - str + 1); + str_line[separator - str] = '\0'; if (str_line[0] != '\0' && !parse_num(str_line, line)) retval = FALSE; -- 2.9.0