]> diplodocus.org Git - nmh/blobdiff - sbr/fmt_compile.c
make writeQuoted() work correctly with content containing NULs
[nmh] / sbr / fmt_compile.c
index 970e71e5abd3d489bd7f66ff765c32b37670bcd8..200d738d79203627413e666ccfe5dacd45d9a9d5 100644 (file)
@@ -159,6 +159,7 @@ static struct ftable functable[] = {
      { "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 },
+     { "units",      TF_EXPR,  FT_LS_UNITS,    0,              TFL_PUTS  },
      { "compval",    TF_COMP,  FT_LV_COMP,     0,              TFL_PUTN },
      { "compflag",   TF_COMP,  FT_LV_COMPFLAG, 0,              TFL_PUTN },
      { "num",        TF_NUM,   FT_LV_LIT,      0,              TFL_PUTN },
@@ -1087,6 +1088,25 @@ fmt_appendcomp(int bucket, char *component, char *text)
     }
 }
 
+/*
+ * Iterate over our component hash table
+ */
+
+struct comp *
+fmt_nextcomp(struct comp *comp, unsigned int *bucket)
+{
+    if (comp == NULL)
+       *bucket = 0;
+    else
+       comp = comp->c_next;
+
+    while (comp == NULL && *bucket < sizeof(wantcomp)/sizeof(wantcomp[0])) {
+       comp = wantcomp[(*bucket)++];
+    }
+
+    return comp;
+}
+
 /*
  * Free and reset our component hash table
  */