summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d7a166e)
raw | patch | inline | side by side (parent: d7a166e)
author | Max Kellermann <max@duempel.org> | |
Thu, 25 Dec 2008 13:29:38 +0000 (14:29 +0100) | ||
committer | Max Kellermann <max@duempel.org> | |
Thu, 25 Dec 2008 13:29:38 +0000 (14:29 +0100) |
We have a null-terminated string, no need to pass the length around.
src/conf.c | patch | blob | history |
diff --git a/src/conf.c b/src/conf.c
index bc66967b1092cb9cb6722794850fc42c7f4e95ee..e3875e3af314cfb13d5c0ca7de77f8f49ca973e3 100644 (file)
--- a/src/conf.c
+++ b/src/conf.c
}
static int
-parse_key_value(char *str, size_t len, char **end)
+parse_key_value(char *str, char **end)
{
+ size_t len = strlen(str);
size_t i;
int value;
key_parser_state_t state;
parse_key_definition(char *str)
{
char buf[MAX_LINE_LENGTH];
- char *p, *end;
+ char *p;
size_t len = strlen(str), i;
int j,key;
int keys[MAX_COMMAND_KEYS];
/* get the value part */
memset(buf, 0, MAX_LINE_LENGTH);
g_strlcpy(buf, str+i, MAX_LINE_LENGTH);
- len = strlen(buf);
- if (len == 0) {
+ if (*buf == 0) {
print_error(_("Incomplete key definition"), str);
return -1;
}
/* parse key values */
i = 0;
key = 0;
- len = strlen(buf);
p = buf;
- end = buf+len;
memset(keys, 0, sizeof(int)*MAX_COMMAND_KEYS);
- while (i < MAX_COMMAND_KEYS && p < end &&
- (key = parse_key_value(p, len + 1, &p)) >= 0) {
+ while (i < MAX_COMMAND_KEYS && *p != 0 &&
+ (key = parse_key_value(p, &p)) >= 0) {
keys[i++] = key;
- while (p < end && (*p==',' || *p==' ' || *p=='\t'))
+ while (*p==',' || *p==' ' || *p=='\t')
p++;
- len = strlen(p);
}
if (key < 0) {