Changeset - r2069:2512dd1a3f46
[Not reviewed]
master
0 1 0
ludde - 19 years ago 2005-07-15 17:59:55
ludde@openttd.org
(svn r2579) Change some strgen errors into warnings to prevent build from stopping.
1 file changed with 9 insertions and 9 deletions:
0 comments (0 inline, 0 general)
strgen/strgen.c
Show inline comments
 
@@ -86,25 +86,25 @@ static void CDECL Warning(const char *s,
 
{
 
	char buf[1024];
 
	va_list va;
 
	va_start(va, s);
 
	vsprintf(buf, s, va);
 
	va_end(va);
 
	fprintf(stderr, "%d: Warning: %s\n", _cur_line, buf);
 
	fprintf(stderr, "Warning:(%d): %s\n", _cur_line, buf);
 
	_warnings++;
 
}
 

	
 

	
 
static void CDECL Error(const char *s, ...)
 
{
 
	char buf[1024];
 
	va_list va;
 
	va_start(va, s);
 
	vsprintf(buf, s, va);
 
	va_end(va);
 
	fprintf(stderr, "%d: Error: %s\n", _cur_line, buf);
 
	fprintf(stderr, "Error:(%d): %s\n", _cur_line, buf);
 
	_errors++;
 
}
 

	
 

	
 
static void NORETURN CDECL Fatal(const char *s, ...)
 
{
 
@@ -238,12 +238,13 @@ static const CmdStruct _cmd_structs[] = 
 
	{"STRING2", EmitEscapedByte, 6, 2},				// included string that consumes TWO arguments
 
	{"STRING3", EmitEscapedByte, 7, 3},				// included string that consumes THREE arguments
 
	{"STRING4", EmitEscapedByte, 8, 4},				// included string that consumes FOUR arguments
 
	{"STRING5", EmitEscapedByte, 9, 5},				// included string that consumes FIVE arguments
 

	
 
	{"STATIONFEATURES", EmitEscapedByte, 10, 1},				// station features string, icons of the features
 
	{"INDUSTRY", EmitEscapedByte, 11, 1},			// industry, takes an industry #
 

	
 
	{"DATE_LONG", EmitSingleByte, 0x82, 1},
 
	{"DATE_SHORT", EmitSingleByte, 0x83, 1},
 

	
 
	{"VELOCITY", EmitSingleByte, 0x84, 1},
 

	
 
@@ -438,25 +439,25 @@ static const CmdStruct *TranslateCmdForC
 
		return NULL;
 

	
 
	return a;
 
}
 

	
 

	
 
static bool CheckCommandsMatch(char *a, char *b)
 
static bool CheckCommandsMatch(char *a, char *b, const char *name)
 
{
 
	ParsedCommandStruct templ;
 
	ParsedCommandStruct lang;
 
	int i,j;
 
	bool result = true;
 

	
 
	ExtractCommandString(&templ, b, true);
 
	ExtractCommandString(&lang, a, true);
 

	
 
	// For each string in templ, see if we find it in lang
 
	if (templ.np != lang.np) {
 
		Error("template string and language string have a different # of commands");
 
		Warning("%s: template string and language string have a different # of commands", name);
 
		result = false;
 
	}
 

	
 
	for(i = 0; i < templ.np; i++) {
 
		// see if we find it in lang, and zero it out
 
		bool found = false;
 
@@ -468,22 +469,22 @@ static bool CheckCommandsMatch(char *a, 
 
				found = true;
 
				break;
 
			}
 
		}
 

	
 
		if (!found) {
 
			Error("Command '%s' exists in template file but not in language file", templ.pairs[i].a->cmd);
 
			Warning("%s: command '%s' exists in template file but not in language file", name, templ.pairs[i].a->cmd);
 
			result = false;
 
		}
 
	}
 

	
 
	// if we reach here, all non consumer commands match up.
 
	// Check if the non consumer commands match up also.
 
	for(i = 0; i < lengthof(templ.cmd); i++) {
 
		if (TranslateCmdForCompare(templ.cmd[i]) != TranslateCmdForCompare(lang.cmd[i])) {
 
			Error("Param idx #%d '%s' doesn't match with template command '%s'", i,
 
			Warning("%s: Param idx #%d '%s' doesn't match with template command '%s'", name, i,
 
				!lang.cmd[i] ? "<empty>" : lang.cmd[i]->cmd,
 
				!templ.cmd[i] ? "<empty>" : templ.cmd[i]->cmd);
 
			result = false;
 
		}
 
	}
 

	
 
@@ -536,13 +537,13 @@ static void HandleString(char *str, bool
 
		_master[ent] = strdup(s);
 

	
 
		// add to hash table
 
		HashAdd(str, ent);
 
	} else {
 
		if (ent == -1) {
 
			Error("String name '%s' does not exist in master file", str);
 
			Warning("String name '%s' does not exist in master file", str);
 
			return;
 
		}
 

	
 
		if (_translated[ent]) {
 
			Error("String name '%s' is used multiple times", str);
 
			return;
 
@@ -550,14 +551,13 @@ static void HandleString(char *str, bool
 

	
 
		if (s[0] == ':' && s[1] == '\0') {
 
			// Special syntax :: means we should just inherit the master string
 
			_translated[ent] = strdup(_master[ent]);
 
		} else {
 
			// check that the commands match
 
			if (!CheckCommandsMatch(s, _master[ent])) {
 
				Error("String name '%s' does not match the layout of the master string\n", str);
 
			if (!CheckCommandsMatch(s, _master[ent], str)) {
 
				return;
 
			}
 
			_translated[ent] = strdup(s);
 
		}
 
	}
 
}
0 comments (0 inline, 0 general)