diff options
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 40 |
1 files changed, 29 insertions, 11 deletions
@@ -4,7 +4,8 @@ #include "buff.h" #include <ctype.h> - +#define FW 0 +#define BW 1 line_t *b_start = NULL; line_t *b_end = NULL; @@ -26,7 +27,7 @@ const char* skip_blank(const char **c){ int get_addr(const char **cmd){ int addr, n, got; - char sign = 0, comma = 0, semic = 0; + char sign = 0, comma = 0, semic = 0, DIR = FW; const char *c; addr1 = addr2 = -1; @@ -76,6 +77,20 @@ int get_addr(const char **cmd){ return -1; } break; + case '?': DIR = BW; + case '/': + c++; + addr = match((char**) &c, DIR); + DIR = FW; + if (addr == -1){ + return -1; + } + if (addr1 == -1) + addr1 = addr; + else + addr2 = addr1, addr1 = addr; + fprintf(stderr, " match (%d): addr1: %d addr2: %d pos: %d\n", DIR, addr1, addr2, pos); + break; default: goto check; } @@ -231,13 +246,19 @@ void main_loop(){ else E; break; + case '\0': case '\n': - if (addr1 > -1 && addr1 <=pos) - move_to_line(addr1, 1); - else if (addr2 <=pos) - print_cur_line(p); - else + fprintf(stderr, ">>>> void command\n"); + if (ret < -1 ) E; + else { + if (addr1 > -1 && addr1 <=num) + move_to_line(addr1, 1); + else if (addr2 <=pos) + print_cur_line(p); + else + E; + } break; case 'q': goto cleanup; @@ -280,11 +301,8 @@ int main(int argc, char *argv[]){ if (argc > 1){ fname = malloc((strlen(argv[1])+1) * sizeof(char)); memcpy(fname, argv[1], strlen(argv[1]) + 1); - if (!read_file()) - fclose(fin); - else{ + if (read_file()) perror(fname); - } } main_loop(); addr1 = pos, addr2 = 1; |