From 5e90054f208028909dec2c5b3d66994fa2c189db Mon Sep 17 00:00:00 2001 From: rubidium Date: Fri, 25 Apr 2014 17:43:09 +0000 Subject: (svn r26511) -Codechange: use strecpy in game_text --- src/strgen/strgen.cpp | 4 ++-- src/strgen/strgen.h | 4 ++-- src/strgen/strgen_base.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/strgen') diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp index 7769ca242..606f82518 100644 --- a/src/strgen/strgen.cpp +++ b/src/strgen/strgen.cpp @@ -122,9 +122,9 @@ struct FileStringReader : StringReader { fclose(this->fh); } - /* virtual */ char *ReadLine(char *buffer, size_t size) + /* virtual */ char *ReadLine(char *buffer, const char *last) { - return fgets(buffer, size, this->fh); + return fgets(buffer, last - buffer + 1, this->fh); } /* virtual */ void HandlePragma(char *str); diff --git a/src/strgen/strgen.h b/src/strgen/strgen.h index 22b24a266..ecae71a72 100644 --- a/src/strgen/strgen.h +++ b/src/strgen/strgen.h @@ -72,10 +72,10 @@ struct StringReader { /** * Read a single line from the source of strings. * @param buffer The buffer to read the data in to. - * @param size The size of the buffer. + * @param last The last element in the buffer. * @return The buffer, or NULL if at the end of the file. */ - virtual char *ReadLine(char *buffer, size_t size) = 0; + virtual char *ReadLine(char *buffer, const char *last) = 0; /** * Handle the pragma of the file. diff --git a/src/strgen/strgen_base.cpp b/src/strgen/strgen_base.cpp index ef30a4c8a..95d3291e4 100644 --- a/src/strgen/strgen_base.cpp +++ b/src/strgen/strgen_base.cpp @@ -821,7 +821,7 @@ void StringReader::ParseFile() strecpy(_lang.digit_decimal_separator, ".", lastof(_lang.digit_decimal_separator)); _cur_line = 1; - while (this->ReadLine(buf, sizeof(buf)) != NULL) { + while (this->ReadLine(buf, lastof(buf)) != NULL) { rstrip(buf); this->HandleString(buf); _cur_line++; -- cgit v1.2.3-70-g09d2