mirror of git://git.sv.gnu.org/nano.git
tweaks: make a comment more accurate, and unabbreviate a variable name
This commit is contained in:
parent
e9c7dfa992
commit
2334dedba6
21
src/utils.c
21
src/utils.c
|
@ -126,29 +126,30 @@ bool parse_num(const char *string, ssize_t *result)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read two numbers, separated by a comma, from str, and store them in
|
/* Read one number (or two numbers separated by comma, period, or colon)
|
||||||
* *line and *column. Return FALSE on error, and TRUE otherwise. */
|
* from the given string and store the number(s) in *line (and *column).
|
||||||
bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
|
* Return FALSE on a failed parsing, and TRUE otherwise. */
|
||||||
|
bool parse_line_column(const char *string, ssize_t *line, ssize_t *column)
|
||||||
{
|
{
|
||||||
const char *comma;
|
const char *comma;
|
||||||
char *firstpart;
|
char *firstpart;
|
||||||
bool retval;
|
bool retval;
|
||||||
|
|
||||||
while (*str == ' ')
|
while (*string == ' ')
|
||||||
str++;
|
string++;
|
||||||
|
|
||||||
comma = strpbrk(str, ",.:");
|
comma = strpbrk(string, ",.:");
|
||||||
|
|
||||||
if (comma == NULL)
|
if (comma == NULL)
|
||||||
return parse_num(str, line);
|
return parse_num(string, line);
|
||||||
|
|
||||||
retval = parse_num(comma + 1, column);
|
retval = parse_num(comma + 1, column);
|
||||||
|
|
||||||
if (comma == str)
|
if (comma == string)
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
firstpart = copy_of(str);
|
firstpart = copy_of(string);
|
||||||
firstpart[comma - str] = '\0';
|
firstpart[comma - string] = '\0';
|
||||||
|
|
||||||
retval = parse_num(firstpart, line) && retval;
|
retval = parse_num(firstpart, line) && retval;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue