diff options
author | KatolaZ <katolaz@freaknet.org> | 2018-05-22 14:50:59 +0100 |
---|---|---|
committer | KatolaZ <katolaz@freaknet.org> | 2018-05-22 14:50:59 +0100 |
commit | 3a10703698af22f44a44d0a1bdd5fda28e4a4712 (patch) | |
tree | db583ce30df1d0f9d4ebc953f02911ed84bfd01d /buff.c | |
parent | e5fc4ed9fb277d92ee24cd8e1bf5e305eb8e18f4 (diff) |
fixed several issues in offsets -- still incomplete
Diffstat (limited to 'buff.c')
-rw-r--r-- | buff.c | 29 |
1 files changed, 28 insertions, 1 deletions
@@ -1,5 +1,6 @@ #include "buff.h" #include <regex.h> +#include <ctype.h> line_t* __search_pos(int addr){ @@ -11,6 +12,20 @@ line_t* __search_pos(int addr){ return cur; } +int get_lineno(line_t *l){ + + line_t *t = b_start; + int i = 1; + while (t && t != l) + t = t->next, i+=1; + if (!l) + return -1; + else + return i; + +} + + int __get_lines(FILE *fin, line_t **first, line_t **last, int *tot){ char buff[4096]; @@ -49,6 +64,7 @@ int __get_lines(FILE *fin, line_t **first, line_t **last, int *tot){ return n; } + int read_file(){ FILE *fin; @@ -96,11 +112,12 @@ 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 ++; } if (lineno) printf("%d\t", pos); @@ -365,4 +382,14 @@ int match(char **c, char bw){ } +int mark(char *c){ + + fprintf (stderr, " >>>> mark: label: '%c'\n", *c); + if (!islower(*c)) + return -1; + if (*(c+1) != '\n') + return -1; + marks[*c - 'a'] = __search_pos(addr1); + return 0; +} |