aboutsummaryrefslogtreecommitdiff
path: root/src/loadsave.c
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2013-08-25 16:31:34 +0200
committerThomas White <taw@bitwiz.org.uk>2013-08-25 16:31:34 +0200
commitd7e83b802aea36f5ac24fd1bfe20fa8d038f51f9 (patch)
treeb227bc519642d365f0990693a2da64a2e62a36e8 /src/loadsave.c
parent14f80ecac9ecf5881fa589b88033c82aefec4a8b (diff)
Use the whole value if no quotes
Diffstat (limited to 'src/loadsave.c')
-rw-r--r--src/loadsave.c39
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);