#include "grammar.h"
static char* unquote(const char* input) {
- size_t length = strlen(input);
+ char* output = NULL;
- // Check whether the first character is "
- if (*input != '"')
- goto COPY;
-
- // Check whether the last characters is "
- if (input[length] != '"')
- goto COPY;
+ // Do nothing if there is no input
+ if (!input)
+ return NULL;
- char* output = malloc(length - 1);
+ // Copy the string
+ output = strdup(input);
if (!output)
return NULL;
- // Copy everything except the first and last character
- snprintf(output, length - 2, "%s", input + 1);
+ // Unquote the string
+ pakfire_string_unquote(output);
return output;
-COPY:
- return strdup(input);
}
// Forward declaration