aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--properties.y12
1 files changed, 10 insertions, 2 deletions
diff --git a/properties.y b/properties.y
index 0f8c8d4..7bdd864 100644
--- a/properties.y
+++ b/properties.y
@@ -4,6 +4,15 @@
#include <stdlib.h>
#include "utils/string.h"
+char *
+cpyval(size_t number,
+ size_t size,
+ char *value)
+{
+ char *dest = calloc(number, size);
+ return strcat(dest, value);
+}
+
%}
%token KEY DIV VALUE
@@ -28,8 +37,7 @@ property: KEY DIV value {
;
value: VALUE {
- $$.value = calloc(2, sizeof(char));
- strcat($$.value, $1.value);
+ $$.value = cpyval(2, sizeof(char), $1.value);
}
| value VALUE {
char *s = strdup($$.value);