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.
master
Benno Schulenberg 2016-07-04 17:55:25 +02:00
parent a730b25ef9
commit 7e3a9c3aa6
1 changed files with 6 additions and 9 deletions

View File

@ -77,9 +77,8 @@ bool parse_num(const char *str, ssize_t *val)
return TRUE; return TRUE;
} }
/* Read two ssize_t's, separated by a comma, from str, and store them in /* Read two numbers, separated by a comma, from str, and store them in
* *line and *column (if they're not both NULL). Return FALSE on error, * *line and *column. Return FALSE on error, and TRUE otherwise. */
* or TRUE otherwise. */
bool parse_line_column(const char *str, ssize_t *line, ssize_t *column) bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
{ {
bool retval = TRUE; bool retval = TRUE;
@ -89,12 +88,11 @@ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
comma = strchr(str, ','); comma = strchr(str, ',');
if (comma != NULL && column != NULL) { if (comma != NULL) {
if (!parse_num(comma + 1, column)) if (!parse_num(comma + 1, column))
retval = FALSE; return FALSE;
} }
if (line != NULL) {
if (comma != NULL) { if (comma != NULL) {
char *str_line = mallocstrncpy(NULL, str, comma - str + 1); char *str_line = mallocstrncpy(NULL, str, comma - str + 1);
str_line[comma - str] = '\0'; str_line[comma - str] = '\0';
@ -103,9 +101,8 @@ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
retval = FALSE; retval = FALSE;
free(str_line); free(str_line);
} else if (!parse_num(str, line)) } else
retval = FALSE; return parse_num(str, line);
}
return retval; return retval;
} }