X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=sbr%2Ffmt_compile.c;h=096f7dd62a46d1b31b696b0888ae14c8143a14ae;hp=dd0b52af2374295afd2ecc57c466a266259e6ab8;hb=56f27eb41e0171f34585b8ae2e232ae13fe08dc0;hpb=d5b5e6e4813b7fd77dc1664df4304537f3002cf3 diff --git a/sbr/fmt_compile.c b/sbr/fmt_compile.c index dd0b52a..096f7dd 100644 --- a/sbr/fmt_compile.c +++ b/sbr/fmt_compile.c @@ -39,10 +39,13 @@ */ #include +#include #include #include #include #include +#include +#include #ifdef HAVE_SYS_TIME_H # include @@ -206,7 +209,7 @@ static struct ftable functable[] = { /* Add new component to the hash table */ #define NEWCOMP(cm,name) do { \ - cm = ((struct comp *) calloc(1, sizeof (struct comp)));\ + cm = ((struct comp *) mh_xcalloc(1, sizeof (struct comp)));\ cm->c_name = name;\ ncomp++;\ i = CHASH(name);\ @@ -260,9 +263,9 @@ static char *do_if(char *); static struct ftable * lookup(char *name) { - register struct ftable *t = functable; - register char *nm; - register char c = *name; + struct ftable *t = functable; + char *nm; + char c = *name; while ((nm = t->name)) { if (*nm == c && strcmp(nm, name) == 0) @@ -289,8 +292,8 @@ compile_error(char *str, char *cp) } advise(NULL, "\"%s\": format compile error - %s", - &usr_fstring[errpos-errctx], str); - adios(NULL, "%*s", errctx+1, "^"); + &usr_fstring[errpos-errctx], str); + adios(EX_SOFTWARE, NULL, "%*s", errctx+1, "^"); } /* @@ -301,7 +304,7 @@ compile_error(char *str, char *cp) int fmt_compile(char *fstring, struct format **fmt) { - register char *cp; + char *cp; size_t i; if (format_string) @@ -325,10 +328,10 @@ fmt_compile(char *fstring, struct format **fmt) i = strlen(fstring)/2 + 1; if (i == 1) i++; - next_fp = formatvec = (struct format *)calloc((size_t) i, + next_fp = formatvec = (struct format *)mh_xcalloc((size_t) i, sizeof(struct format)); if (next_fp == NULL) - adios(NULL, "unable to allocate format storage"); + adios(EX_OSERR, NULL, "unable to allocate format storage"); ncomp = 0; infunction = 0; @@ -346,8 +349,8 @@ fmt_compile(char *fstring, struct format **fmt) static char * compile(char *sp) { - register char *cp = sp; - register int c; + char *cp = sp; + int c; for (;;) { sp = cp; @@ -407,13 +410,11 @@ compile(char *sp) static char * do_spec(char *sp) { - register char *cp = sp; - register int c; -#ifndef lint - register int ljust = 0; -#endif /* not lint */ - register int wid = 0; - register char fill = ' '; + char *cp = sp; + int c; + int ljust = 0; + int wid = 0; + char fill = ' '; c = *cp++; if (c == '-') { @@ -461,9 +462,9 @@ do_spec(char *sp) static char * do_name(char *sp, int preprocess) { - register char *cp = sp; - register int c; - register int i; + char *cp = sp; + int c; + int i; static int primed = 0; while (isalnum(c = *cp++) || c == '-' || c == '_') @@ -480,7 +481,7 @@ do_name(char *sp, int preprocess) CERROR("component used as both date and address"); } cm->c_tws = (struct tws *) - calloc((size_t) 1, sizeof(*cm->c_tws)); + mh_xcalloc((size_t) 1, sizeof(*cm->c_tws)); fp->f_type = preprocess; PUTCOMP(sp); cm->c_type |= CT_DATE; @@ -520,10 +521,10 @@ do_name(char *sp, int preprocess) static char * do_func(char *sp) { - register char *cp = sp; - register int c; - register struct ftable *t; - register int n; + char *cp = sp; + int c; + struct ftable *t; + int n; int mflag; /* minus sign in NUM */ infunction++; @@ -617,8 +618,8 @@ do_func(char *sp) static char * do_expr(char *sp, int preprocess) { - register char *cp = sp; - register int c; + char *cp = sp; + int c; if ((c = *cp++) == '{') { cp = do_name(cp, preprocess); @@ -648,7 +649,7 @@ do_expr(char *sp, int preprocess) static char * do_loop(char *sp) { - register char *cp = sp; + char *cp = sp; struct format *floop; floop = next_fp; @@ -673,9 +674,9 @@ do_loop(char *sp) static char * do_if(char *sp) { - register char *cp = sp; - register struct format *fexpr, *fif = (struct format *)NULL; - register int c = '<'; + char *cp = sp; + struct format *fexpr, *fif = (struct format *)NULL; + int c = '<'; for (;;) { if (c == '<') { /* doing an IF */