Changeset - r18708:683e5888dbd3
[Not reviewed]
master
0 1 0
rubidium - 12 years ago 2011-12-17 12:19:22
rubidium@openttd.org
(svn r23566) -Fix (r23565): hopefully fix MSVC compilation error
1 file changed with 1 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/strgen/strgen.cpp
Show inline comments
 
@@ -909,49 +909,48 @@ struct FileWriter {
 
	/**
 
	 * Open a file to write to.
 
	 * @param filename The file to open.
 
	 */
 
	FileWriter(const char *filename)
 
	{
 
		this->filename = strdup(filename);
 
		this->fh = fopen(this->filename, "wb");
 

	
 
		if (this->fh == NULL) {
 
			error("Could not open %s", this->filename);
 
		}
 
	}
 

	
 
	/** Finalise the writing. */
 
	void Finalise()
 
	{
 
		fclose(this->fh);
 
		this->fh = NULL;
 
	}
 

	
 
	/** Make sure the file is closed. */
 
	virtual ~FileWriter()
 
	{
 
		printf("close %s %p\n", this->filename, this->fh);
 
		/* If we weren't closed an exception was thrown, so remove the termporary file. */
 
		if (fh != NULL) {
 
			fclose(this->fh);
 
			unlink(this->filename);
 
		}
 
		free(this->filename);
 
	}
 
};
 

	
 
/** Base class for writing the header. */
 
struct HeaderWriter {
 
	/**
 
	 * Write the string ID.
 
	 * @param name     The name of the string.
 
	 * @param stringid The ID of the string.
 
	 */
 
	virtual void WriteStringID(const char *name, int stringid) = 0;
 

	
 
	/**
 
	 * Finalise writing the file.
 
	 */
 
	virtual void Finalise() = 0;
 

	
 
	/** Especially destroy the subclasses. */
 
@@ -1002,49 +1001,49 @@ struct HeaderFileWriter : HeaderWriter, 
 
		/* Find the plural form with the most amount of cases. */
 
		int max_plural_forms = 0;
 
		for (uint i = 0; i < lengthof(_plural_forms); i++) {
 
			max_plural_forms = max(max_plural_forms, _plural_forms[i].plural_count);
 
		}
 

	
 
		fprintf(this->fh,
 
			"\n"
 
			"static const uint LANGUAGE_PACK_VERSION     = 0x%X;\n"
 
			"static const uint LANGUAGE_MAX_PLURAL       = %d;\n"
 
			"static const uint LANGUAGE_MAX_PLURAL_FORMS = %d;\n\n",
 
			(uint)_hash, (uint)lengthof(_plural_forms), max_plural_forms
 
		);
 

	
 
		fprintf(this->fh, "#endif /* TABLE_STRINGS_H */\n");
 

	
 
		this->FileWriter::Finalise();
 

	
 
		if (CompareFiles(this->filename, this->real_filename)) {
 
			/* files are equal. tmp.xxx is not needed */
 
			unlink(this->filename);
 
		} else {
 
			/* else rename tmp.xxx into filename */
 
	#if defined(WIN32) || defined(WIN64)
 
			unlink(filename);
 
			unlink(this->real_filename);
 
	#endif
 
			if (rename(this->filename, this->real_filename) == -1) error("rename() failed");
 
		}
 
	}
 
};
 

	
 
static int TranslateArgumentIdx(int argidx, int offset)
 
{
 
	int sum;
 

	
 
	if (argidx < 0 || (uint)argidx >= lengthof(_cur_pcs.cmd)) {
 
		error("invalid argidx %d", argidx);
 
	}
 
	const CmdStruct *cs = _cur_pcs.cmd[argidx];
 
	if (cs != NULL && cs->consumes <= offset) {
 
		error("invalid argidx offset %d:%d", argidx, offset);
 
	}
 

	
 
	if (_cur_pcs.cmd[argidx] == NULL) {
 
		error("no command for this argidx %d", argidx);
 
	}
 

	
 
	for (int i = sum = 0; i < argidx; i++) {
 
		const CmdStruct *cs = _cur_pcs.cmd[i];
0 comments (0 inline, 0 general)