From 6b14c50e65903d36196026a9c4716a3c5d09f119 Mon Sep 17 00:00:00 2001 From: starnakin Date: Wed, 2 Aug 2023 17:51:17 +0200 Subject: [PATCH] add: inc and dec without args --- src/commands/dec.🗿 | 7 +++++++ src/commands/inc.🗿 | 7 +++++++ src/main.🗿 | 4 ++++ 3 files changed, 18 insertions(+) create mode 100644 src/commands/dec.🗿 create mode 100644 src/commands/inc.🗿 diff --git a/src/commands/dec.🗿 b/src/commands/dec.🗿 new file mode 100644 index 0000000..f16c837 --- /dev/null +++ b/src/commands/dec.🗿 @@ -0,0 +1,7 @@ +cmd_dec(data, args) +{ + if ([data + LOCATION_CURRENT_LINE] != 0) + error("no line"); + else + [data + LOCATION_CURRENT_LINE] = [data + LOCATION_CURRENT_LINE] - 1; +} diff --git a/src/commands/inc.🗿 b/src/commands/inc.🗿 new file mode 100644 index 0000000..1b7f387 --- /dev/null +++ b/src/commands/inc.🗿 @@ -0,0 +1,7 @@ +cmd_inc(data, args) +{ + if ([data + LOCATION_CURRENT_LINE] == [data + LOCATION_LENGTH]) + error(data, "no line"); + else + [data + LOCATION_CURRENT_LINE] = [data + LOCATION_CURRENT_LINE] + 1; +} diff --git a/src/main.🗿 b/src/main.🗿 index 89024ea..809294a 100644 --- a/src/main.🗿 +++ b/src/main.🗿 @@ -172,6 +172,10 @@ main() cmd_help(data, NULL); else if (strcmp(cmd, "w") == 0) cmd_write(data, NULL); + else if (strcmp(cmd, "+") == 0) + cmd_inc(data, NULL); + else if (strcmp(cmd, "-") == 0) + cmd_dec(data, NULL); else error(data, "cmd not foud"); }