-
-/*
- * fmt_compile.c -- "compile" format strings for fmt_scan
+/* fmt_compile.c -- "compile" format strings for fmt_scan
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
/* Add new component to the hash table */
#define NEWCOMP(cm,name) do { \
NEW0(cm);\
- cm->c_name = getcpy(name);\
+ cm->c_name = mh_xstrdup(name);\
cm->c_refcount++;\
ncomp++;\
i = CHASH(name);\
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)
int i, errpos, errctx;
errpos = cp - format_string;
- errctx = errpos > 20 ? 20 : errpos;
+ errctx = min(errpos, 20);
usr_fstring[errpos] = '\0';
for (i = errpos-errctx; i < errpos; i++) {
usr_fstring[i] = '_';
}
- advise(NULL, "\"%s\": format compile error - %s",
+ inform("\"%s\": format compile error - %s",
&usr_fstring[errpos-errctx], str);
adios (NULL, "%*s", errctx+1, "^");
}
int
fmt_compile(char *fstring, struct format **fmt, int reset_comptable)
{
- register char *cp;
+ char *cp;
size_t i;
static int comptable_initialized = 0;
- format_string = getcpy (fstring);
+ format_string = mh_xstrdup(fstring);
usr_fstring = fstring;
if (reset_comptable || !comptable_initialized) {
static char *
compile (char *sp)
{
- register char *cp = sp;
- register int c;
+ char *cp = sp;
+ int c;
for (;;) {
sp = cp;
static char *
do_spec(char *sp)
{
- register char *cp = sp;
- register int c;
+ char *cp = sp;
+ int c;
#ifndef lint
- register int ljust = 0;
+ int ljust = 0;
#endif /* not lint */
- register int wid = 0;
- register char fill = ' ';
+ int wid = 0;
+ char fill = ' ';
c = *cp++;
if (c == '-') {
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 == '_')
ismymbox ((struct mailname *) 0);
primed++;
}
- /* fall through */
+ /* FALLTHRU */
case FT_PARSEADDR:
if (cm->c_type & CT_DATE) {
CERROR("component used as both date and address");
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++;
case TF_EXPR_SV:
LV(FT_SAVESTR, 0);
- /* fall through */
+ /* FALLTHRU */
case TF_EXPR:
*--cp = c;
cp = do_expr(cp, t->extra);
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);
*
* Okay, got some more information on this from John L. Romine! From an
* email he sent to the nmh-workers mailing list on December 2, 2010, he
- * explains it thusly:
+ * explains it so:
*
* In this case (scan, formatsbr) it has to do with an extension to
* the mh-format syntax to allow for looping.
static char *
do_loop(char *sp)
{
- register char *cp = sp;
+ char *cp = sp;
struct format *floop;
floop = next_fp;
static char *
do_if(char *sp)
{
- register char *cp = sp;
- register struct format *fexpr,
+ char *cp = sp;
+ struct format *fexpr,
*fif = (struct format *)NULL;
- register int c = '<';
+ int c = '<';
for (;;) {
if (c == '<') { /* doing an IF */
struct comp *cm;
for (i = 0; i < sizeof(wantcomp)/sizeof(wantcomp[0]); i++)
- for (cm = wantcomp[i]; cm; cm = cm->c_next)
- if (cm->c_text) {
- free(cm->c_text);
- cm->c_text = NULL;
- }
+ for (cm = wantcomp[i]; cm; cm = cm->c_next) {
+ mh_xfree(cm->c_text);
+ cm->c_text = NULL;
+ }
}
/*
struct comp *cm;
for (cm = wantcomp[CHASH(component)]; cm; cm = cm->c_next)
- if (strcasecmp(component, cm->c_name ? cm->c_name : "") == 0)
+ if (strcasecmp(component, FENDNULL(cm->c_name)) == 0)
break;
return cm;
char *cp;
while (cptr) {
- if (strcasecmp(component, cptr->c_name ? cptr->c_name : "") == 0) {
+ if (strcasecmp(component, FENDNULL(cptr->c_name)) == 0) {
found++;
if (! cptr->c_text) {
cptr->c_text = getcpy(text);
if (bucket != -1) {
for (cptr = wantcomp[bucket]; cptr; cptr = cptr->c_next)
- if (strcasecmp(component, cptr->c_name ? cptr->c_name : "") == 0)
+ if (strcasecmp(component, FENDNULL(cptr->c_name)) == 0)
cptr->c_text = add(text, cptr->c_text);
}
}
{
if (--cm->c_refcount <= 0) {
/* Shouldn't ever be NULL, but just in case ... */
- if (cm->c_name)
- free(cm->c_name);
- if (cm->c_text)
- free(cm->c_text);
+ mh_xfree(cm->c_name);
+ mh_xfree(cm->c_text);
if (cm->c_type & CT_DATE)
free(cm->c_tws);
if (cm->c_type & CT_ADDR && cm->c_mn && cm->c_mn != &fmt_mnull)