*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
{ "decodecomp", TF_COMP, FT_LS_DECODECOMP, 0, TFL_PUTS },
{ "decode", TF_EXPR, FT_LS_DECODE, 0, TFL_PUTS },
{ "trim", TF_EXPR, FT_LS_TRIM, 0, 0 },
{ "decodecomp", TF_COMP, FT_LS_DECODECOMP, 0, TFL_PUTS },
{ "decode", TF_EXPR, FT_LS_DECODE, 0, TFL_PUTS },
{ "trim", TF_EXPR, FT_LS_TRIM, 0, 0 },
{ "kilo", TF_EXPR, FT_LS_KILO, 0, TFL_PUTS },
{ "kibi", TF_EXPR, FT_LS_KIBI, 0, TFL_PUTS },
{ "compval", TF_COMP, FT_LV_COMP, 0, TFL_PUTN },
{ "kilo", TF_EXPR, FT_LS_KILO, 0, TFL_PUTS },
{ "kibi", TF_EXPR, FT_LS_KIBI, 0, TFL_PUTS },
{ "compval", TF_COMP, FT_LV_COMP, 0, TFL_PUTN },
-#define FINDCOMP(comp,name) \
- for (comp = wantcomp[CHASH(name)]; \
- comp && strcmp(comp->c_name,name); \
- comp = comp->c_next) \
- ;
+#define FINDCOMP(comp,name) do { \
+ for (comp = wantcomp[CHASH(name)]; \
+ comp && strcmp(comp->c_name,name); \
+ comp = comp->c_next) \
+ ; \
+ } while (0)
/* Add new component to the hash table */
#define NEWCOMP(cm,name) do { \
/* Add new component to the hash table */
#define NEWCOMP(cm,name) do { \
-#define NEWFMT (next_fp++)
-#define NEW(type,fill,wid) do {\
- fp=NEWFMT; fp->f_type=(type); fp->f_fill=(fill); fp->f_width=(wid); \
+#define NEW_FP(type,fill,wid) do {\
+ fp=next_fp++; fp->f_type=(type); fp->f_fill=(fill); fp->f_width=(wid); \
-#define LV(type, value) do { NEW(type,0,0); fp->f_value = (value); } while (0)
-#define LS(type, str) do { NEW(type,0,0); fp->f_text = getcpy(str); fp->f_flags |= FF_STRALLOC; } while (0)
+#define LV(type, value) do { NEW_FP(type,0,0); fp->f_value = (value); } while (0)
+#define LS(type, str) do { NEW_FP(type,0,0); fp->f_text = getcpy(str); fp->f_flags |= FF_STRALLOC; } while (0)
-#define PUTCOMP(comp) do { NEW(FT_COMP,0,0); ADDC(comp); } while (0)
-#define PUTLIT(str) do { NEW(FT_LIT,0,0); fp->f_text = getcpy(str); fp->f_flags |= FF_STRALLOC; } while (0)
-#define PUTC(c) do { NEW(FT_CHAR,0,0); fp->f_char = (c); } while (0)
+#define PUTCOMP(comp) do { NEW_FP(FT_COMP,0,0); ADDC(comp); } while (0)
+#define PUTLIT(str) do { NEW_FP(FT_LIT,0,0); fp->f_text = getcpy(str); fp->f_flags |= FF_STRALLOC; } while (0)
+#define PUTC(c) do { NEW_FP(FT_CHAR,0,0); fp->f_char = (c); } while (0)
- next_fp = formatvec = (struct format *)mh_xcalloc ((size_t) i,
- sizeof(struct format));
- if (next_fp == NULL)
- adios (NULL, "unable to allocate format storage");
-
+ next_fp = formatvec = mh_xcalloc(i, sizeof *next_fp);
if ((c = *cp++) == '{') {
cp = do_name (cp, preprocess);
if ((c = *cp++) == '{') {
cp = do_name (cp, preprocess);
} else if (c == '%' && *cp == '<') {
cp = do_if (cp+1);
} else {
CERROR ("'(', '{', '%<' or ')' expected");
}
} else if (c == '%' && *cp == '<') {
cp = do_if (cp+1);
} else {
CERROR ("'(', '{', '%<' or ')' expected");
}
*
* 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
*
* 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
*
* In this case (scan, formatsbr) it has to do with an extension to
* the mh-format syntax to allow for looping.
*
* In this case (scan, formatsbr) it has to do with an extension to
* the mh-format syntax to allow for looping.
{
if (--cm->c_refcount <= 0) {
/* Shouldn't ever be NULL, but just in case ... */
{
if (--cm->c_refcount <= 0) {
/* Shouldn't ever be NULL, but just in case ... */