summaryrefslogtreecommitdiffstats
path: root/src/bvrcommands.c
diff options
context:
space:
mode:
authorsijanec <anton@sijanec.eu>2021-01-19 20:23:45 +0100
committersijanec <anton@sijanec.eu>2021-01-19 20:23:45 +0100
commit59b099ee82477ffd8ad12948dd4601234563d0e4 (patch)
tree4cc421c4ac8a0c069beaca7079b3da75bd824b8f /src/bvrcommands.c
parentadded an abstraction of accessing variables through file streams - possible to make functions (diff)
downloadbverbose-59b099ee82477ffd8ad12948dd4601234563d0e4.tar
bverbose-59b099ee82477ffd8ad12948dd4601234563d0e4.tar.gz
bverbose-59b099ee82477ffd8ad12948dd4601234563d0e4.tar.bz2
bverbose-59b099ee82477ffd8ad12948dd4601234563d0e4.tar.lz
bverbose-59b099ee82477ffd8ad12948dd4601234563d0e4.tar.xz
bverbose-59b099ee82477ffd8ad12948dd4601234563d0e4.tar.zst
bverbose-59b099ee82477ffd8ad12948dd4601234563d0e4.zip
Diffstat (limited to 'src/bvrcommands.c')
-rw-r--r--src/bvrcommands.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/bvrcommands.c b/src/bvrcommands.c
index a44954f..a1738dc 100644
--- a/src/bvrcommands.c
+++ b/src/bvrcommands.c
@@ -449,10 +449,13 @@ int bvr_handle_join(FILE * input, FILE * output) {
char * value = bvr_commands_get_value(input, chars_to_break_value);
char * stvar1 = bvr_var_get(item);
char * stvar2 = bvr_var_get(value);
- strncat(stvar1, stvar2, (BVR_MAX_VARIABLE_SIZE-strlen(stvar1))-1);
- return_value = bvr_var_set(item, stvar1);
+ char * temp = malloc(sizeof(char)*(strlen(stvar1)+strlen(stvar2)+1));
+ sprintf(temp, "%s%s", stvar1, stvar2);
+ return_value = bvr_var_set(item, temp);
free(item);
free(value);
+ free(temp);
+ temp = NULL;
item = NULL;
value = NULL;
return return_value;
@@ -517,12 +520,12 @@ int bvr_handle_explode(FILE * input, FILE * output) {
index = 0;
while ((token = strtok_r(rest, string2, &rest))) {
charpointer = strrchr(item, BVR_ARRAY_INDEX_CHAR);
- snprintf(charpointer+1, (BVR_MAX_VARIABLE_SIZE-(charpointer-string1))-4, "%d" BVR_ARRAY_AFTER_INDEX, index++);
+ sprintf(charpointer+1, "%d" BVR_ARRAY_AFTER_INDEX, index++); /* keys must always have 128 bytes more space allocated */
return_value = return_value != SUCCESS ? return_value : bvr_var_set(item, token); // če je bila prej napaka pač ne poskušamo več!
len++;
}
charpointer = strrchr(item, BVR_ARRAY_INDEX_CHAR);
- snprintf(charpointer+1, (BVR_MAX_VARIABLE_SIZE-(charpointer-string1))-4, "#" BVR_ARRAY_AFTER_INDEX, index++);
+ sprintf(charpointer+1, "#" BVR_ARRAY_AFTER_INDEX, index++);
snprintf(lenst, 69-1, "%lu", len);
return_value = return_value != SUCCESS ? return_value : bvr_var_set(item, lenst);
free(item);