summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatolaZ <katolaz@freaknet.org>2018-04-23 14:34:59 +0100
committerKatolaZ <katolaz@freaknet.org>2018-04-23 14:34:59 +0100
commit2bf7cce2ac5df3a6793c3124da9d7d5639769e04 (patch)
treee1ae7a7375c099d16a3e4a3056aee421bc5625d6
parent771b998ba5d1f451586aef0562d0012442d6bf23 (diff)
Patched ';'
-rw-r--r--TODO.org11
-rw-r--r--main.c23
2 files changed, 28 insertions, 6 deletions
diff --git a/TODO.org b/TODO.org
index b0a6e36..1af5a23 100644
--- a/TODO.org
+++ b/TODO.org
@@ -3,6 +3,7 @@
* IN-PROGRESS FIXME
** DONE check file name input in 'f' and 'w'
+** TODO Change read_lines to use __get_lines (let fin point to the file to read from...)
* IN-PROGRESS Commands [3/20]
@@ -27,6 +28,12 @@
** TODO w !
** DONE f
-* TODO Addresses
+
+* IN-PROGRESS Addresses [4/7]
+** TODO Test , extensively
+** DONE numbers
+** DONE ,
+** DONE $
+** TODO .
+** DONE ;
** TODO Offsets (+-)
-** TODO ;
diff --git a/main.c b/main.c
index 57c3b0e..74bd93c 100644
--- a/main.c
+++ b/main.c
@@ -26,7 +26,7 @@ const char* skip_blank(const char **c){
int get_addr(const char **cmd){
int addr, n, got;
- char sign = 0, comma = 0;
+ char sign = 0, comma = 0, semic = 0;
const char *c;
addr1 = addr2 = -1;
@@ -63,19 +63,29 @@ int get_addr(const char **cmd){
if (addr1 ==-1)
addr2 = 1, addr1=num;
else if (addr1 < addr2){
- *cmd = c;
+ *cmd = c++;
return -1;
}
break;
+ case ';':
+ semic = 1;
+ if (addr1 == -1)
+ addr2 = pos, addr1=num;
+ else if (addr1 < addr2){
+ *cmd = c++;
+ return -1;
+ }
+ break;
default:
goto check;
}
c++;
}
}
+
check:
*cmd = c;
-
+
fprintf(stderr, " >>> get_addr: addr1: %d addr2: %d\n", addr1, addr2);
if (addr1 == -1){
@@ -84,11 +94,16 @@ int get_addr(const char **cmd){
addr2 = 1;
return 2;
}
+ if (semic){
+ addr1 = num;
+ addr2 = pos;
+ return 2;
+ }
addr1 = addr2 = pos;
return 0;
}
if (addr2 == -1){
- if (comma){
+ if (comma || semic){
addr2 = addr1;
return 2;
}