forked from github/server
removing a strdup() call and a buffer from rparagraph.
This commit is contained in:
parent
6c6c1174d8
commit
cf996bc5fb
7 changed files with 58 additions and 40 deletions
|
@ -225,7 +225,7 @@ rpsnr(FILE * F, const char * s, int offset)
|
||||||
if (*(x - 1) && indent && *x == ' ') indent += 2;
|
if (*(x - 1) && indent && *x == ' ') indent += 2;
|
||||||
if (!indent) indent = offset;
|
if (!indent) indent = offset;
|
||||||
x = s;
|
x = s;
|
||||||
memset(inset, 32, indent * sizeof(char));
|
memset(inset, ' ', indent * sizeof(char));
|
||||||
inset[indent] = 0;
|
inset[indent] = 0;
|
||||||
while (s <= x+len) {
|
while (s <= x+len) {
|
||||||
size_t line = min(len-(s-x), REPORTWIDTH - indent*ui);
|
size_t line = min(len-(s-x), REPORTWIDTH - indent*ui);
|
||||||
|
@ -349,27 +349,39 @@ centre(FILE * F, const char *s, boolean breaking)
|
||||||
static void
|
static void
|
||||||
rparagraph(FILE *F, const char *s, int indent, char mark)
|
rparagraph(FILE *F, const char *s, int indent, char mark)
|
||||||
{
|
{
|
||||||
static char mbuf[BUFSIZE+1];
|
static const char * spaces = " ";
|
||||||
/* static size_t bsize = 0; */
|
size_t length = REPORTWIDTH - indent;
|
||||||
size_t size;
|
const char * end = s;
|
||||||
char inset[REPORTWIDTH];
|
|
||||||
|
|
||||||
if (indent) {
|
while (*s) {
|
||||||
memset(inset, ' ', indent);
|
const char * last_space = s;
|
||||||
inset[indent]=0;
|
|
||||||
if (mark)
|
if (mark && indent>=2) {
|
||||||
inset[indent - 2] = mark;
|
fwrite(spaces, sizeof(char), indent-2, F);
|
||||||
} else {
|
fputc(mark, F);
|
||||||
assert(mark == 0);
|
fputc(' ', F);
|
||||||
inset[0] = 0;
|
mark = 0;
|
||||||
}
|
} else {
|
||||||
inset[indent]=0;
|
fwrite(spaces, sizeof(char), indent, F);
|
||||||
size = strlen(s)+indent+1;
|
}
|
||||||
if (size==1) return;
|
while (*end && end!=s+length) {
|
||||||
strcpy(mbuf, inset);
|
if (*end==' ') {
|
||||||
strncpy(mbuf+indent, s, BUFSIZE-indent);
|
last_space = end;
|
||||||
*(mbuf+size-1)=0;
|
}
|
||||||
rps(F, mbuf);
|
++end;
|
||||||
|
}
|
||||||
|
if (last_space==s) {
|
||||||
|
/* there was no space in this line. clip it */
|
||||||
|
last_space = end;
|
||||||
|
}
|
||||||
|
fwrite(s, sizeof(char), last_space-s, F);
|
||||||
|
s = last_space;
|
||||||
|
while (*s==' ') {
|
||||||
|
++s;
|
||||||
|
}
|
||||||
|
if (s>end) end = s;
|
||||||
|
fputc('\n', F);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1700,9 +1712,12 @@ guards(FILE * F, const region * r, const faction * see)
|
||||||
static void
|
static void
|
||||||
rpline(FILE * F)
|
rpline(FILE * F)
|
||||||
{
|
{
|
||||||
rpc(F, ' ', 1);
|
static char line[REPORTWIDTH+1];
|
||||||
rpc(F, '-', REPORTWIDTH);
|
if (line[0]!='-') {
|
||||||
rnl(F);
|
memset(line, '-', sizeof(line));
|
||||||
|
line[REPORTWIDTH] = '\n';
|
||||||
|
}
|
||||||
|
fwrite(line, sizeof(char), sizeof(line), F);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -27,11 +27,12 @@
|
||||||
#include "save.h"
|
#include "save.h"
|
||||||
|
|
||||||
/* util includes */
|
/* util includes */
|
||||||
#include <base36.h>
|
#include <util/base36.h>
|
||||||
#include <functions.h>
|
#include <util/event.h>
|
||||||
#include <resolve.h>
|
#include <util/functions.h>
|
||||||
#include <event.h>
|
#include <util/language.h>
|
||||||
#include <language.h>
|
#include <util/resolve.h>
|
||||||
|
#include <util/umlaut.h>
|
||||||
|
|
||||||
/* libc includes */
|
/* libc includes */
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
|
@ -98,7 +98,6 @@ struct building_type;
|
||||||
#include <util/language.h>
|
#include <util/language.h>
|
||||||
#include <util/lists.h>
|
#include <util/lists.h>
|
||||||
#include <util/log.h>
|
#include <util/log.h>
|
||||||
#include <util/umlaut.h>
|
|
||||||
#include <util/variant.h>
|
#include <util/variant.h>
|
||||||
#include <util/vmap.h>
|
#include <util/vmap.h>
|
||||||
#include <util/vset.h>
|
#include <util/vset.h>
|
||||||
|
@ -1067,12 +1066,6 @@ extern void guard(struct unit * u, unsigned int mask);
|
||||||
* 'mask' kann einzelne flags zusätzlich und-maskieren.
|
* 'mask' kann einzelne flags zusätzlich und-maskieren.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct local_names {
|
|
||||||
struct local_names * next;
|
|
||||||
const struct locale * lang;
|
|
||||||
struct tnode names;
|
|
||||||
} local_names;
|
|
||||||
|
|
||||||
extern boolean hunger(int number, struct unit * u);
|
extern boolean hunger(int number, struct unit * u);
|
||||||
extern int lifestyle(const struct unit*);
|
extern int lifestyle(const struct unit*);
|
||||||
extern int besieged(const struct unit * u);
|
extern int besieged(const struct unit * u);
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include <util/functions.h>
|
#include <util/functions.h>
|
||||||
#include <util/goodies.h>
|
#include <util/goodies.h>
|
||||||
#include <util/message.h>
|
#include <util/message.h>
|
||||||
|
#include <util/umlaut.h>
|
||||||
|
|
||||||
/* libc includes */
|
/* libc includes */
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
|
@ -24,10 +24,11 @@
|
||||||
#include "skill.h"
|
#include "skill.h"
|
||||||
|
|
||||||
/* util includes */
|
/* util includes */
|
||||||
#include <base36.h>
|
#include <util/base36.h>
|
||||||
#include <event.h>
|
#include <util/event.h>
|
||||||
#include <xml.h>
|
#include <util/language.h>
|
||||||
#include <language.h>
|
#include <util/umlaut.h>
|
||||||
|
#include <util/xml.h>
|
||||||
|
|
||||||
/* libc includes */
|
/* libc includes */
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
/* util includes */
|
/* util includes */
|
||||||
#include <util/goodies.h>
|
#include <util/goodies.h>
|
||||||
#include <util/language.h>
|
#include <util/language.h>
|
||||||
|
#include <util/umlaut.h>
|
||||||
|
|
||||||
/* Bitte die Sprüche nach Gebieten und Stufe ordnen, denn in derselben
|
/* Bitte die Sprüche nach Gebieten und Stufe ordnen, denn in derselben
|
||||||
* Reihenfolge wie in Spelldaten tauchen sie auch im Report auf
|
* Reihenfolge wie in Spelldaten tauchen sie auch im Report auf
|
||||||
|
|
|
@ -35,6 +35,12 @@ typedef struct tnode {
|
||||||
int findtoken(const struct tnode * tk, const char * str, variant* result);
|
int findtoken(const struct tnode * tk, const char * str, variant* result);
|
||||||
void addtoken(struct tnode * root, const char* str, variant id);
|
void addtoken(struct tnode * root, const char* str, variant id);
|
||||||
|
|
||||||
|
typedef struct local_names {
|
||||||
|
struct local_names * next;
|
||||||
|
const struct locale * lang;
|
||||||
|
struct tnode names;
|
||||||
|
} local_names;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue