diff options
author | Thomas White <taw@bitwiz.org.uk> | 2013-08-25 16:31:34 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2013-08-25 16:31:34 +0200 |
commit | d7e83b802aea36f5ac24fd1bfe20fa8d038f51f9 (patch) | |
tree | b227bc519642d365f0990693a2da64a2e62a36e8 /src/loadsave.c | |
parent | 14f80ecac9ecf5881fa589b88033c82aefec4a8b (diff) |
Use the whole value if no quotes
Diffstat (limited to 'src/loadsave.c')
-rw-r--r-- | src/loadsave.c | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/src/loadsave.c b/src/loadsave.c index 32782ff..8fee31d 100644 --- a/src/loadsave.c +++ b/src/loadsave.c @@ -552,29 +552,32 @@ int get_field_s(struct ds_node *root, const char *key, char **val) } if ( !hq ) { fprintf(stderr, "No quotes in '%s'\n", node->value); - return 1; - } + v = strdup(node->value); /* Use the whole thing */ + } else { - for ( i=len-1; i>=0; i-- ) { - if ( node->value[i] == '"' ) { - s2 = i; - break; + for ( i=len-1; i>=0; i-- ) { + if ( node->value[i] == '"' ) { + s2 = i; + break; + } } - } - if ( s1 == s2 ) { - fprintf(stderr, "Mismatched quotes in '%s'\n", node->value); - return 1; - } + if ( s1 == s2 ) { + fprintf(stderr, "Mismatched quotes in '%s'\n", + node->value); + return 1; + } - v = malloc(s2-s1+1); - if ( v == NULL ) { - fprintf(stderr, "Failed to allocate space for '%s'\n", key); - return 1; - } + v = malloc(s2-s1+1); + if ( v == NULL ) { + fprintf(stderr, "Failed to allocate space for '%s'\n", + key); + return 1; + } - strncpy(v, node->value+s1+1, s2-s1-1); - v[s2-s1-1] = '\0'; + strncpy(v, node->value+s1+1, s2-s1-1); + v[s2-s1-1] = '\0'; + } *val = unescape_text(v); free(v); |