From 070da67034ff86d1dc7ecaffcebd593e1825ce21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Wed, 30 Nov 2011 13:44:27 +0100 Subject: [PATCH] Slight cleanup. Remove a build error (too many initialisers for struct ParserState). Explicit instantiation of read_vector_from_file() for 'int's and 'double's . Suppress various warnings. --- common/io/readvector.cpp | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/common/io/readvector.cpp b/common/io/readvector.cpp index c73cb8b8..6b59ef35 100644 --- a/common/io/readvector.cpp +++ b/common/io/readvector.cpp @@ -36,8 +36,6 @@ static void readvector(FILE *fp, struct ParserState *s, std::vector& v) { T value; int count, i; - int ret; - int ok; count = 1; s->error = 0; @@ -60,7 +58,7 @@ static void readvector(FILE *fp, struct ParserState *s, std::vector& v) template static void parse_next_token(FILE *fp, struct ParserState *s, T *v, int *r) { - char str[bufsz], *ptr; + char str[bufsz]; char rstr[bufsz]; char vstr[bufsz]; @@ -111,9 +109,9 @@ static void split_token_string(char *str, char *rstr, char *vstr) rstr[0]='\0'; } - while(*vstr++=*str++) + while((*vstr++=*str++) ) { - ; + continue ; } *vstr='\0'; } @@ -224,11 +222,12 @@ static char *get_token_string(FILE *fp, struct ParserState *s, char *str) static void skip_line(FILE *fp, struct ParserState *s) { + static_cast(s); int c; while((c = fgetc(fp))!=EOF && c != '\n') { ; } - +} /* ------------------------------------------------------------------ */ @@ -255,28 +254,11 @@ template void read_vector_from_file(const char *fn, std::vector& v) { FILE *fp = fopen(fn, "r"); - struct ParserState s = {1, 0}; + struct ParserState s = { 0 }; readvector(fp, &s, v); fclose(fp); } - -#if 1 -int main() -{ - std::vector v; - read_vector_from_file("example/zcorn.txt", zcorn); - std::vector actnum; - read_vector_from_file("example/actnum.txt", actnum); - for (int i=0; i(const char *fn, std::vector& v); +template void read_vector_from_file(const char *fn, std::vector& v);