commit 7e3a9c3aa6b44f4be9891e83ccadf61c1fd34a40
parent a730b25ef955010fc1653c6316f1a2ba2d5af7ff
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Mon, 4 Jul 2016 17:55:25 +0200
utils: don't bother to check line and column for NULL
When parsing a line and a column number, of course the found values
need to be passed back, otherwise it would be pointless to parse them.
Diffstat:
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/src/utils.c b/src/utils.c
@@ -77,9 +77,8 @@ 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
- * *line and *column (if they're not both NULL). Return FALSE on error,
- * or TRUE otherwise. */
+/* Read two numbers, separated by a comma, from str, and store them in
+ * *line and *column. Return FALSE on error, and TRUE otherwise. */
bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
{
bool retval = TRUE;
@@ -89,12 +88,11 @@ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
comma = strchr(str, ',');
- if (comma != NULL && column != NULL) {
+ if (comma != NULL) {
if (!parse_num(comma + 1, column))
- retval = FALSE;
+ return FALSE;
}
- if (line != NULL) {
if (comma != NULL) {
char *str_line = mallocstrncpy(NULL, str, comma - str + 1);
str_line[comma - str] = '\0';
@@ -103,9 +101,8 @@ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
retval = FALSE;
free(str_line);
- } else if (!parse_num(str, line))
- retval = FALSE;
- }
+ } else
+ return parse_num(str, line);
return retval;
}