From 3a10703698af22f44a44d0a1bdd5fda28e4a4712 Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Tue, 22 May 2018 14:50:59 +0100 Subject: fixed several issues in offsets -- still incomplete --- buff.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'buff.c') diff --git a/buff.c b/buff.c index aa66a67..78bee0a 100644 --- a/buff.c +++ b/buff.c @@ -1,5 +1,6 @@ #include "buff.h" #include +#include 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; inext; 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; +} -- cgit v1.2.3