tweaks: rename two variables and improve two comments

master
Benno Schulenberg 2020-10-21 12:24:52 +02:00
parent de313586ab
commit 3c2eb96243
1 changed files with 7 additions and 7 deletions

View File

@ -108,19 +108,19 @@ int digits(ssize_t n)
}
#endif
/* Read an integer from str. If it parses okay, store it in *result
* and return TRUE; otherwise, return FALSE. */
bool parse_num(const char *str, ssize_t *result)
/* Read an integer from the given string. If it parses okay,
* store it in *result and return TRUE; otherwise, return FALSE. */
bool parse_num(const char *string, ssize_t *result)
{
char *first_error;
ssize_t value;
char *excess;
/* The manual page for strtol() says this is required. */
/* Clear the error number so that we can check it afterward. */
errno = 0;
value = (ssize_t)strtol(str, &first_error, 10);
value = (ssize_t)strtol(string, &excess, 10);
if (errno == ERANGE || *str == '\0' || *first_error != '\0')
if (errno == ERANGE || *string == '\0' || *excess != '\0')
return FALSE;
*result = value;