From cae118e406151da7dc1008045b9908ced76526d9 Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Fri, 20 Apr 2018 10:40:00 +0100 Subject: various fixes in indexing --- main.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 0599575..4fb2175 100644 --- a/main.c +++ b/main.c @@ -58,7 +58,9 @@ int get_addr(const char **cmd){ break; case ',': comma = 1; - if (addr1 < addr2){ + if (addr1 ==-1) + addr2 = 1, addr1=num; + else if (addr1 < addr2){ *cmd = c; return -1; } @@ -82,6 +84,10 @@ int get_addr(const char **cmd){ return 0; } if (addr2 == -1){ + if (comma){ + addr2 = addr1; + return 2; + } addr2 = pos; return 1; } @@ -103,9 +109,9 @@ void main_loop(){ ret = get_addr((const char **) &cmd); - printf(">>> *** pos: %d address: %d ***\n", pos, ret); + fprintf(stderr,">>> *** pos: %d address: %d ***\n", pos, ret); if (ret) { - printf(">>> *** addr1: %d, addr2= %d***\n", addr1, addr2); + fprintf(stderr, ">>> *** addr1: %d, addr2= %d***\n", addr1, addr2); } switch(cmd[0]){ @@ -157,8 +163,8 @@ void main_loop(){ print_lineno(); break; default: - printf(">>> **** unknown command: '%c'****\n", cmd[0]) - ; + fprintf(stderr, ">>> **** unknown command: '%c'****\n", cmd[0]); + printf("?\n"); } } } -- cgit v1.2.3