diff options
author | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2009-06-25 15:08:18 +0000 |
---|---|---|
committer | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2009-06-25 15:08:18 +0000 |
commit | dda296202055420d3c36dd9e8ca8f70e06fe60a0 (patch) | |
tree | 2f3746cbb8aa1785db0390b38f113fe5d2181c60 | |
parent | 55cab3a6605436e2650d6be920866c88d86e8c20 (diff) | |
download | navit-svn-dda296202055420d3c36dd9e8ca8f70e06fe60a0.tar.gz |
Fix:map_textfile:Fixed pipe mode
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/navit@2373 ffa7fe5e-494d-0410-b361-a75ebd5db220
-rw-r--r-- | map/textfile/textfile.c | 12 | ||||
-rw-r--r-- | map/textfile/textfile.h | 1 |
2 files changed, 12 insertions, 1 deletions
diff --git a/map/textfile/textfile.c b/map/textfile/textfile.c index 67d58582..2bdf07d9 100644 --- a/map/textfile/textfile.c +++ b/map/textfile/textfile.c @@ -95,8 +95,12 @@ static void get_line(struct map_rect_priv *mr) { if(mr->f) { - mr->pos=ftell(mr->f); + if (!mr->m->is_pipe) + mr->pos=ftell(mr->f); + else + mr->pos+=mr->lastlen; fgets(mr->line, SIZE, mr->f); + mr->lastlen=strlen(mr->line)+1; if (strlen(mr->line) >= SIZE-1) printf("line too long\n"); } @@ -235,6 +239,8 @@ map_rect_new_textfile(struct map_priv *map, struct map_selection *sel) dbg(1,"popen args %s\n", args); mr->args=args; mr->f=popen(mr->args, "r"); + mr->pos=0; + mr->lastlen=0; } else { mr->f=fopen(map->filename, "r"); } @@ -280,6 +286,8 @@ map_rect_get_item_textfile(struct map_rect_priv *mr) if (mr->m->is_pipe) { pclose(mr->f); mr->f=popen(mr->args, "r"); + mr->pos=0; + mr->lastlen=0; } else fseek(mr->f, 0, SEEK_SET); get_line(mr); @@ -333,6 +341,8 @@ map_rect_get_item_byid_textfile(struct map_rect_priv *mr, int id_hi, int id_lo) if (mr->m->is_pipe) { pclose(mr->f); mr->f=popen(mr->args, "r"); + mr->pos=0; + mr->lastlen=0; } else fseek(mr->f, id_lo, SEEK_SET); get_line(mr); diff --git a/map/textfile/textfile.h b/map/textfile/textfile.h index b7a77be0..ef97e33a 100644 --- a/map/textfile/textfile.h +++ b/map/textfile/textfile.h @@ -46,5 +46,6 @@ struct map_rect_priv { struct map_priv *m; struct item item; char *args; + int lastlen; }; |