diff options
author | KatolaZ <katolaz@freaknet.org> | 2018-07-16 11:23:36 +0100 |
---|---|---|
committer | KatolaZ <katolaz@freaknet.org> | 2018-07-16 11:23:36 +0100 |
commit | d3d5d96e6c17a4eaf409212b806e4d6a9d04f6c5 (patch) | |
tree | fc3030a0dd489770f960926a38e3f816d4408fd6 | |
parent | 973479aa7fc254b887aed5fe6a57935648ee883c (diff) |
-rw-r--r-- | TODO.org | 8 | ||||
-rw-r--r-- | buff.c | 18 | ||||
-rw-r--r-- | buff.h | 1 | ||||
-rw-r--r-- | main.c | 14 | ||||
-rw-r--r-- | obf.ed | 9 | ||||
-rw-r--r-- | tests/test_exec.ed | 5 | ||||
-rw-r--r-- | tests/test_mark.ed | 4 | ||||
-rw-r--r-- | tests/testlist.txt | 1 |
8 files changed, 48 insertions, 12 deletions
@@ -2,7 +2,7 @@ * IN-PROGRESS FIXME -** TODO Implement check on file modified +** DONE Implement check on file modified ** TODO Check for marks in delete_lines ** DONE Reimplement delete_lines ** DONE Re-check insert/append (test_insapp failing with a double-free) @@ -11,19 +11,19 @@ ** DONE Change read_lines to use __get_lines (let fin point to the file to read from...) -* IN-PROGRESS Commands [11/24] +* IN-PROGRESS Commands [12/24] ** DONE e ** IN-PROGRESS ! ** TODO e ! ** TODO E ! -** IN-PROGRESS W +** DONE W ** TODO w ! ** TODO j ** TODO r ** TODO s ** IN-PROGRESS k [0/1] *** TODO Check clear marks upon delete, change, move lines -** TODO g,G,v,V +** TODO (?) g,G,v,V ** TODO h ** TODO H ** TODO r ! @@ -297,7 +297,7 @@ int write_lines(char app){ l = l->next; } fclose(fout); - printf("%d\n", tot); + fprintf(stderr, "%d\n", tot); return 0; } @@ -389,3 +389,19 @@ void transfer_lines(int addr, char move){ move_to_line(addr+n,0); mod = 1; } + + +void exec_command(char *s, FILE *fout){ + + char buff[4096]; + FILE *fin; + + fin = popen(s, "r"); + while(feof(fin) == 0){ + if (!fgets(buff, 4095, fin)) break; + fputs(buff, fout); + } + pclose(fin); + printf("!\n"); + +} @@ -41,6 +41,7 @@ int match(char **, char); int mark(char *c); int get_lineno(line_t*); void transfer_lines(int, char); +void exec_command(char*, FILE*); #endif /* __BUFF_H__ */ @@ -27,7 +27,7 @@ const char* skip_blank(const char **c){ int get_addr(const char **cmd){ - int addr, n, got; + int addr, n, got, d; char sign = 1, comma = 0, semic = 0, DIR = FW; const char *c; line_t *p; @@ -86,6 +86,11 @@ int get_addr(const char **cmd){ case '\'': /* mark */ fprintf(stderr, " >>>> address is a mark!!!\n"); c++; + d = *c - 'a'; + if (d < 0 || d > 26){ + E; + return -1; + } p = marks[*c - 'a']; if (!p) E; @@ -347,7 +352,10 @@ void main_loop(){ break; case '!': cmd += 1; - //exec_command(); + system(cmd); + printf("!\n"); + /* exec_command(cmd, stdout); */ + break; case '=': if (addr1 == -1) addr1 = num; @@ -385,7 +393,7 @@ int main(int argc, char *argv[]){ } main_loop(); addr1 = num, addr2 = 1; - delete_lines(); + if (num>0) delete_lines(); free(fname); } @@ -26,10 +26,13 @@ H 1,$s/fprintf.*//g 1,$s/printf/P/g 1,$s/num_alloc/na/g -1,$s/ -> /->/g +1,$s/\ ->\ /->/g 1,$s/; */;/g -1,$s/ = /=/g -1,$s/ == /==/g +1,$s/\ =\ /=/g +1,$s/\ ==\ /==/g +1,$s/\ <=\ /<=/g 1,$s/sizeof/S/g +1,$s/malloc/M/g +1,$s/\ +/\ /g ,p Q diff --git a/tests/test_exec.ed b/tests/test_exec.ed new file mode 100644 index 0000000..935bd78 --- /dev/null +++ b/tests/test_exec.ed @@ -0,0 +1,5 @@ +!ls +!ls -l +! head pippo.c +q +q diff --git a/tests/test_mark.ed b/tests/test_mark.ed index df53f50..478bc3a 100644 --- a/tests/test_mark.ed +++ b/tests/test_mark.ed @@ -4,8 +4,10 @@ 40kd 'a,'bn 'b,'dp -'c','bn +'c,'bn 'a+3 'b-4 'c++-- +'c' +''a,'b'n Q diff --git a/tests/testlist.txt b/tests/testlist.txt index 73a345c..d5f6d2a 100644 --- a/tests/testlist.txt +++ b/tests/testlist.txt @@ -7,3 +7,4 @@ test_tm.ed pippo.c test_ew.ed pippo.c test_comment.ed pippo.c test_mark.ed pippo.c +test_exec.ed pippo.c |