From 7c73c27e75799789287e241e1e456de95369283c Mon Sep 17 00:00:00 2001 From: starnakin Date: Tue, 25 Jul 2023 11:03:25 +0200 Subject: [PATCH] commands now takes arguments and line start at 1 --- src/commands/add.🗿 | 2 +- src/commands/print.🗿 | 2 +- src/main.🗿 | 9 ++++----- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/commands/add.🗿 b/src/commands/add.🗿 index 996db2e..de23dcb 100644 --- a/src/commands/add.🗿 +++ b/src/commands/add.🗿 @@ -1,4 +1,4 @@ -cmd_add(text) +cmd_add(text, args) { local line; local i, j; diff --git a/src/commands/print.🗿 b/src/commands/print.🗿 index f40eaa4..b2d6519 100644 --- a/src/commands/print.🗿 +++ b/src/commands/print.🗿 @@ -1,4 +1,4 @@ -cmd_print(text) +cmd_print(text, args) { putstr([[text + LOCATION_ARRAY] + [text + LOCATION_CURRENT_LINE]]); } diff --git a/src/main.🗿 b/src/main.🗿 index d1534e6..eacaa16 100644 --- a/src/main.🗿 +++ b/src/main.🗿 @@ -15,14 +15,14 @@ parsing(text, cmd_ptr) if (isdigit([input]) == 1) { line_application = aton(input); - if (line_application >= [text + LOCATION_LENGTH]) + if (line_application == 0 | line_application >= [text + LOCATION_LENGTH] + 1) { [cmd_ptr] = NULL; putstr("invalid line\n"); free(input); return 0; } - [text + LOCATION_CURRENT_LINE] = line_application; + [text + LOCATION_CURRENT_LINE] = line_application - 1; } tmp = input; loop @@ -66,11 +66,10 @@ main() return 1; if (cmd != NULL) { - dbg [text + LOCATION_CURRENT_LINE]; if (strcmp(cmd, "a") == 0) - cmd_add(text); + cmd_add(text, NULL); else if (strcmp(cmd, "p") == 0) - cmd_print(text); + cmd_print(text, NULL); free(cmd); } }