Commit d5158e06 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

Code cleanup.

* src/server/conf-file.c (check_trailer): New function.
(convert_to_long): Use it to simplify the code.
(convert_to_ulong): Ditto.
parent 64852bbd
2006-07-26 Per Cederqvist <ceder@lysator.liu.se>
 
Code cleanup.
* src/server/conf-file.c (check_trailer): New function.
(convert_to_long): Use it to simplify the code.
(convert_to_ulong): Ditto.
Use strtol instead of atol in more places, and avoid a compiler
warning. (Bug 143).
* src/server/conf-file.c (convert_to_ulong): New function.
......
......@@ -258,12 +258,9 @@ free_config(const struct parameter *par)
static Success
convert_to_long(const char *val,
long *res)
check_trailer(const char *val,
const char *end)
{
char *end;
*res = strtol(val, &end, 10);
if (end == val)
return FAILURE;
while (*end == ' ' || *end == '\t') /* Ignore trailing whitespace. */
......@@ -274,6 +271,17 @@ convert_to_long(const char *val,
}
static Success
convert_to_long(const char *val,
long *res)
{
char *end;
*res = strtol(val, &end, 10);
return check_trailer(val, end);
}
static Success
convert_to_ulong(const char *val,
unsigned long *res)
......@@ -281,13 +289,7 @@ convert_to_ulong(const char *val,
char *end;
*res = strtoul(val, &end, 10);
if (end == val)
return FAILURE;
while (*end == ' ' || *end == '\t') /* Ignore trailing whitespace. */
end++;
if (*end != '\0')
return FAILURE;
return OK;
return check_trailer(val, end);
}
......
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