Commit 7e3a9c3a authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

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.
No related merge requests found
Showing with 6 additions and 9 deletions
+6 -9
......@@ -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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment