summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatolaZ <[email protected]>2018-04-20 10:40:00 +0100
committerKatolaZ <[email protected]>2018-04-20 10:40:00 +0100
commitcae118e406151da7dc1008045b9908ced76526d9 (patch)
treefe6b0bebcc91c34d79442e95c482017cee4d91f7
parent8f936bc6c89163e3984ac619612c0ce76a51a74e (diff)
various fixes in indexing
-rw-r--r--buff.c2
-rw-r--r--main.c16
-rw-r--r--problems.txt2
3 files changed, 14 insertions, 6 deletions
diff --git a/buff.c b/buff.c
index 91593bb..1a358e8 100644
--- a/buff.c
+++ b/buff.c
@@ -59,7 +59,7 @@ void print_lines(char lineno){
p = b_start;
- printf(">>> *** addr1: %d addr2: %d ***\n", addr1, addr2);
+ fprintf(stderr, ">>> *** addr1: %d addr2: %d ***\n", addr1, addr2);
for (i=1; i<addr2; i++) p = p->next;
pos = i;
cur = p;
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");
}
}
}
diff --git a/problems.txt b/problems.txt
new file mode 100644
index 0000000..139597f
--- /dev/null
+++ b/problems.txt
@@ -0,0 +1,2 @@
+
+