diff options
author | rubidium <rubidium@openttd.org> | 2007-01-10 18:56:51 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-01-10 18:56:51 +0000 |
commit | a7d0cdf95fd8847ab76b35446e1c9b77f8ef1cb7 (patch) | |
tree | 1a1c59c13ddb1d152052f3a3a0bcffe4fb531173 /src/strgen/strgen.cpp | |
parent | ce75f6549dd379b506c9f1e9383bd881aa7cf5c7 (diff) | |
download | openttd-a7d0cdf95fd8847ab76b35446e1c9b77f8ef1cb7.tar.xz |
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
Diffstat (limited to 'src/strgen/strgen.cpp')
-rw-r--r-- | src/strgen/strgen.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp index 640ac3c63..4268f0bbb 100644 --- a/src/strgen/strgen.cpp +++ b/src/strgen/strgen.cpp @@ -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 @@ static const char *_cur_ident; typedef struct CmdPair { const CmdStruct *a; - char *v; + const char *v; } CmdPair; typedef struct ParsedCommandStruct { @@ -842,7 +845,7 @@ static void HandleString(char *str, bool master) } // 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 @@ static void HandleString(char *str, bool master) } 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 @@ static void HandleString(char *str, bool master) 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 @@ static void WriteStringsH(const char *filename) 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; } |