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

View File

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

View File

@ -163,7 +163,7 @@ write_order(const order * ord, const struct locale * lang, char * buffer, size_t
} else {
char * s = getcommand(ord);
strncpy(buffer, s, size);
free(s);
free(s);
}
return buffer;
}

View File

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