* befehle einlesen: space am ende des befehles

* datenfile: Befehle haben die " nicht escaped

* cr: rendered-strings sind nicht escaped.
This commit is contained in:
Enno Rehling 2004-07-02 19:08:53 +00:00
parent 7a036598fe
commit f0f97913e9
5 changed files with 19 additions and 27 deletions

View File

@ -489,9 +489,8 @@ render_messages(FILE * F, faction * f, message_list *msgs)
if (nr_render(m->msg, f->locale, nrbuffer, sizeof(nrbuffer), f)==0 && nrbuffer[0]) { if (nr_render(m->msg, f->locale, nrbuffer, sizeof(nrbuffer), f)==0 && nrbuffer[0]) {
fprintf(F, "MESSAGE %u\n", (unsigned int)m->msg);/*++msgno); */ fprintf(F, "MESSAGE %u\n", (unsigned int)m->msg);/*++msgno); */
fprintf(F, "%d;type\n", hash); fprintf(F, "%d;type\n", hash);
fputs("\"", F); fwritestr(F, nrbuffer);
fputs(nrbuffer, F); fputs(";rendered\n", F);
fputs("\";rendered\n", F);
printed = true; printed = true;
} }
#endif #endif
@ -700,7 +699,6 @@ cr_output_unit(FILE * F, const region * r,
if (u->faction == f || omniscient(f)) { if (u->faction == f || omniscient(f)) {
order * ord; order * ord;
const char *c; const char *c;
char * cmd;
int i; int i;
const attrib * a; const attrib * a;
@ -738,15 +736,13 @@ cr_output_unit(FILE * F, const region * r,
/* default commands */ /* default commands */
fprintf(F, "COMMANDS\n"); fprintf(F, "COMMANDS\n");
if (u->lastorder) { if (u->lastorder) {
cmd = getcommand(u->lastorder); fwriteorder(F, u->lastorder, f->locale);
fprintf(F, "\"%s\"\n", cmd); fputc('\n', F);
free(cmd);
} }
for (ord = u->orders; ord; ord = ord->next) { for (ord = u->orders; ord; ord = ord->next) {
if (is_persistent(ord) && ord!=u->lastorder) { if (is_persistent(ord) && ord!=u->lastorder) {
cmd = getcommand(ord); fwriteorder(F, ord, f->locale);
fprintf(F, "\"%s\"\n", cmd); fputc('\n', F);
free(cmd);
} }
} }

View File

@ -3356,6 +3356,7 @@ fwritestr(FILE * F, const char * str)
while (*str) { while (*str) {
int c = (int)(unsigned char)*str++; int c = (int)(unsigned char)*str++;
switch (c) { switch (c) {
case '"':
case '\\': case '\\':
fputc('\\', F); fputc('\\', F);
fputc(c, F); fputc(c, F);

View File

@ -988,18 +988,10 @@ write_faction_reference(const faction * f, FILE * F)
} }
void void
fwrite_order(const order * ord, const struct locale * lang, FILE * F) fwriteorder(FILE * F, const order * ord, const struct locale * lang)
{ {
write_order(ord, lang, buf, sizeof(buf)); write_order(ord, lang, buf, sizeof(buf));
fputs(buf, F); fwritestr(F, buf);
}
static void
writeorder(const order * ord, const struct locale * lang, FILE * F)
{
fputc('\"', F);
fwrite_order(ord, lang, F);
fputs("\" ", F);
} }
unit * unit *
@ -1093,11 +1085,11 @@ readunit(FILE * F)
u->flags = ri(F) & ~UFL_DEBUG; u->flags = ri(F) & ~UFL_DEBUG;
/* Kurze persistente Befehle einlesen */ /* Kurze persistente Befehle einlesen */
free_orders(&u->orders); free_orders(&u->orders);
rs(F, buf); freadstr(F, buf, sizeof(buf));
while(*buf != 0) { while(*buf != 0) {
order * ord = parse_order(buf, u->faction->locale); order * ord = parse_order(buf, u->faction->locale);
if (ord!=NULL) addlist(&u->orders, ord); if (ord!=NULL) addlist(&u->orders, ord);
rs(F, buf); freadstr(F, buf, sizeof(buf));
} }
rs(F, buf); rs(F, buf);
u->lastorder = parse_order(buf, u->faction->locale); u->lastorder = parse_order(buf, u->faction->locale);
@ -1202,11 +1194,12 @@ writeunit(FILE * F, const unit * u)
wnl(F); wnl(F);
for (ord = u->orders; ord; ord=ord->next) { for (ord = u->orders; ord; ord=ord->next) {
if (is_persistent(ord)) { if (is_persistent(ord)) {
writeorder(ord, u->faction->locale, F); fwriteorder(F, ord, u->faction->locale);
fputc(' ', F);
} }
} }
ws(F, ""); /* Abschluß der persistenten Befehle */ wnl(F);
writeorder(u->lastorder, u->faction->locale, F); fwriteorder(F, u->lastorder, u->faction->locale);
wnl(F); wnl(F);
assert(u->number >= 0); assert(u->number >= 0);

View File

@ -74,6 +74,8 @@ extern struct region * readregion(FILE * stream, int x, int y);
extern void writefaction(FILE * stream, const struct faction * f); extern void writefaction(FILE * stream, const struct faction * f);
extern struct faction * readfaction(FILE * stream); extern struct faction * readfaction(FILE * stream);
extern void fwriteorder(FILE * F, const struct order * ord, const struct locale * lang);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif