diff options
author | KatolaZ <[email protected]> | 2018-04-25 19:17:37 +0100 |
---|---|---|
committer | KatolaZ <[email protected]> | 2018-04-25 19:17:37 +0100 |
commit | f6d4aa13577c2f7d8c18458123f83ea6de9712d7 (patch) | |
tree | daff87b1340b3aeb1eb82bb062e686b62f922a8e | |
parent | d46fc59c8713fdc2805ed613132f5cfabbcca1c2 (diff) |
Minor changes
-rw-r--r-- | TODO.org | 7 | ||||
-rw-r--r-- | buff.c | 17 | ||||
-rw-r--r-- | main.c | 2 | ||||
-rw-r--r-- | obf.ed | 6 |
4 files changed, 17 insertions, 15 deletions
@@ -3,17 +3,18 @@ * 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...) +** DONE Change read_lines to use __get_lines (let fin point to the file to read from...) -* IN-PROGRESS Commands [3/20] +* IN-PROGRESS Commands [3/21] ** DONE c ** DONE w -** TODO e +** IN-PROGRESS e ** TODO W ** TODO E ** TODO j ** TODO r +** TODO # ** TODO t ** TODO m ** TODO s @@ -21,13 +21,13 @@ int __get_lines(FILE *fin, line_t **first, line_t **last, int *tot){ *first = *last = NULL; while(feof(fin) == 0){ if (!fgets(buff, 4095, fin)) break; - if (buff[0] == '.') + if (*buff == '.') break; s = strlen(buff) + 1; *tot += s -1; l = malloc(sizeof(line_t)); l->c = malloc(s * sizeof(char)); - num_alloc +=1; + num_alloc++; memcpy(l->c, buff, s); l->s = s; if (*first == NULL){ @@ -42,7 +42,7 @@ int __get_lines(FILE *fin, line_t **first, line_t **last, int *tot){ l->next = NULL; *last = l; } - n += 1; + n++; } fprintf(stderr, " >>>> get_lines: num_alloc: %d\n", num_alloc); return n; @@ -95,12 +95,11 @@ void print_lines(char lineno){ for (i=1; i<addr2; i++) p = p->next; pos = i; cur = p; - while(pos < addr1){ + while(pos++ < addr1){ if (lineno) printf("%d\t", pos); printf("%s", cur->c); cur = cur->next; - pos += 1; } if (lineno) printf("%d\t", pos); @@ -205,7 +204,7 @@ void insert_lines(){ first -> prev = cur -> prev; last -> next = cur; num += n; - pos -=1 ; + pos-- ; cur = last; } } @@ -226,14 +225,16 @@ void delete_lines(){ if (addr1 < addr2){ return; } + move_to_line(addr2,0); fprintf(stderr, " >>> delete: addr1: %d addr2: %d pos: %d\n", addr1, addr2, pos); if (addr2 <= 1){ /* we are deleting the first line */ while(pos <= addr1){ + pos ++; free(cur->c); - num_free += 1; + num_free++; if (cur -> next){ cur = cur -> next; free(cur -> prev); @@ -241,10 +242,8 @@ void delete_lines(){ else { free(cur); cur = NULL; - pos ++; break; } - pos ++; } fprintf(stderr, " >>>> delete_lines: num_free: %d\n", num_free); @@ -181,7 +181,7 @@ void main_loop(){ delete_lines(); break; case 'e': - cmd += 1; + cmd++; skip_blank((const char**)&cmd); if (cmd[0] == '!') //read_command(); @@ -7,7 +7,7 @@ H 1,$s/prev/p/g 1,$s/first/f/g 1,$s/last/ll/g -1,$s/move_to_line/mtl/g +1,$s/move_to_line/ml/g 1,$s/skip_blank/sb/g 1,$s/get_addr/ga/g 1,$s/main_loop/mp/g @@ -16,7 +16,7 @@ H 1,$s/read_lines/rl/g 1,$s/insert_lines/il/g 1,$s/print_lines/pl/g -1,$s/print_cur_line/pcl/g +1,$s/print_cur_line/pc/g 1,$s/print_lineno/pn/g 1,$s/search_pos/sp/g 1,$s/get_lines/gl/g @@ -24,6 +24,8 @@ H 1,$s/pos/p/g 1,$s/cur/c/g 1,$s/fprintf.*//g +1,$s/printf/P/g +1,$s/num_alloc/na/g 1,$s/ -> /->/g 1,$s/; */;/g 1,$s/ = /=/g |