]> diplodocus.org Git - nmh/blobdiff - sbr/fmt_compile.c
Add basic support for the STLS command in POP
[nmh] / sbr / fmt_compile.c
index bea76e6c5969a1510998230815053748827520ec..3ada1d41dbfee2fd62843ccaee5b5d717014dbb1 100644 (file)
  *
  */
 
-#include <h/mh.h>
-#include <h/addrsbr.h>
-#include <h/tws.h>
-#include <h/fmt_scan.h>
-#include <h/fmt_compile.h>
-#include <h/mts.h>
-#include <h/utils.h>
+#include "h/mh.h"
+#include "getcpy.h"
+#include "error.h"
+#include "h/addrsbr.h"
+#include "h/tws.h"
+#include "h/fmt_scan.h"
+#include "h/fmt_compile.h"
+#include "h/mts.h"
+#include "h/utils.h"
 #include "terminal.h"
 
 #ifdef HAVE_SYS_TIME_H
@@ -158,6 +160,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 },
+     { "trimr",      TF_EXPR,  FT_LS_TRIM,     0,              TFL_PUTS },
      { "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 },
@@ -390,14 +393,14 @@ fmt_compile(char *fstring, struct format **fmt, int reset_comptable)
 {
     char *cp;
     size_t i;
-    static int comptable_initialized = 0;
+    static bool comptable_initialized;
 
     format_string = mh_xstrdup(fstring);
     usr_fstring = fstring;
 
     if (reset_comptable || !comptable_initialized) {
        free_comptable();
-       comptable_initialized = 1;
+       comptable_initialized = true;
     }
 
     /* it takes at least 4 char to generate one format so we
@@ -488,13 +491,13 @@ do_spec(char *sp)
 {
     char *cp = sp;
     int c;
-    int ljust = 0;
+    bool ljust = false;
     int wid = 0;
     char fill = ' ';
 
     c = *cp++;
     if (c == '-') {
-       ljust++;
+       ljust = true;
        c = *cp++;
     }
     if (c == '0') {
@@ -543,7 +546,7 @@ do_name(char *sp, int preprocess)
     char *cp = sp;
     int c;
     int i;
-    static int primed = 0;
+    static bool primed;
 
     while (isalnum(c = *cp++) || c == '-' || c == '_')
        ;
@@ -573,7 +576,7 @@ do_name(char *sp, int preprocess)
     case FT_GETMYADDR:
        if (!primed) {
            ismymbox(NULL);
-           primed++;
+           primed = true;
        }
        /* FALLTHRU */
     case FT_PARSEADDR:
@@ -1044,13 +1047,15 @@ fmt_addcompentry(char *component)
 int
 fmt_addcomptext(char *component, char *text)
 {
-    int i, found = 0, bucket = CHASH(component);
+    int i;
+    bool found = false;
+    int bucket = CHASH(component);
     struct comp *cptr = wantcomp[bucket];
     char *cp;
 
     while (cptr) {
        if (strcasecmp(component, FENDNULL(cptr->c_name)) == 0) {
-           found++;
+           found = true;
            if (! cptr->c_text) {
                cptr->c_text = getcpy(text);
            } else {