src/strgen/strgen.cpp
changeset 5587 167d9a91ef02
parent 5584 1111b4d36e35
child 5609 dc6a58930ba4
--- a/src/strgen/strgen.cpp	Wed Jan 10 18:44:52 2007 +0000
+++ b/src/strgen/strgen.cpp	Wed Jan 10 18:56:51 2007 +0000
@@ -4,6 +4,7 @@
 #include "../macros.h"
 #include "../string.h"
 #include "../table/control_codes.h"
+#include "../helpers.hpp"
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
@@ -11,6 +12,8 @@
 
 #if (!defined(WIN32) && !defined(WIN64)) || defined(__CYGWIN__)
 #include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 #endif
 
 #if defined WIN32 || defined __WATCOMC__
@@ -113,7 +116,7 @@
 
 typedef struct CmdPair {
 	const CmdStruct *a;
-	char *v;
+	const char *v;
 } CmdPair;
 
 typedef struct ParsedCommandStruct {
@@ -842,7 +845,7 @@
 			}
 
 			// Allocate a new LangString
-			ent = calloc(1, sizeof(*ent));
+			CallocT(&ent, 1);
 			_strings[_next_string_id] = ent;
 			ent->index = _next_string_id++;
 			ent->name = strdup(str);
@@ -852,7 +855,8 @@
 		}
 
 		if (casep != NULL) {
-			Case* c = malloc(sizeof(*c));
+			Case* c;
+			MallocT(&c, 1);
 
 			c->caseidx = ResolveCaseName(casep, strlen(casep));
 			c->string = strdup(s);
@@ -881,7 +885,8 @@
 			if (!CheckCommandsMatch(s, ent->english, str)) return;
 
 			if (casep != NULL) {
-				Case* c = malloc(sizeof(*c));
+				Case* c;
+				MallocT(&c, 1);
 
 				c->caseidx = ResolveCaseName(casep, strlen(casep));
 				c->string = strdup(s);
@@ -1021,17 +1026,12 @@
 	out = fopen("tmp.xxx", "w");
 	if (out == NULL) fatal("can't open tmp.xxx");
 
-	fprintf(out, "enum {");
+	fprintf(out, "enum StringIdEnum {");
 
 	lastgrp = 0;
 
 	for (i = 0; i != lengthof(_strings); i++) {
 		if (_strings[i] != NULL) {
-			if (lastgrp != (i >> 11)) {
-				lastgrp = (i >> 11);
-				fprintf(out, "};\n\nenum {");
-			}
-
 			fprintf(out, next == i ? "\t%s,\n" : "\n\t%s = 0x%X,\n", _strings[i]->name, i);
 			next = i + 1;
 		}