diff --git a/src/commands/add.🗿 b/src/commands/add.🗿 index de23dcb..2f0c141 100644 --- a/src/commands/add.🗿 +++ b/src/commands/add.🗿 @@ -9,31 +9,29 @@ cmd_add(text, args) line = geadline("(add)"); if (line == NULL) return 1; - if (strcmp(line, ".\n") == 0) - { - [text + LOCATION_CURRENT_LINE] = [text + LOCATION_CURRENT_LINE] - 1; + if (strcmp(line, ".") == 0) return 0; - } - [text + LOCATION_LENGTH] = [text + LOCATION_LENGTH] + 1; - tmp = galloc([text + LOCATION_LENGTH]); + tmp = galloc([text + LOCATION_LENGTH] + 1); if (tmp == NULL) return 1; i = 0; j = 0; loop { - if (i == [text + LOCATION_CURRENT_LINE]) + if (i == [text + LOCATION_CURRENT_LINE] + 1 | i == [text + LOCATION_LENGTH]) { [tmp + i] = line; j++; } - if (i + j == [text + LOCATION_LENGTH]) - break; [tmp + i + j] = [[text + LOCATION_ARRAY] + i]; + if (i + j == [text + LOCATION_LENGTH] | i == [text + LOCATION_LENGTH]) + break; i++; } - free([[text + LOCATION_ARRAY]]); + puttab_str(tmp); + free([text + LOCATION_ARRAY]); [text + LOCATION_ARRAY] = tmp; + [text + LOCATION_LENGTH] = [text + LOCATION_LENGTH] + 1; [text + LOCATION_CURRENT_LINE] = [text + LOCATION_CURRENT_LINE] + 1; } }