]> diplodocus.org Git - nmh/blobdiff - uip/mhlsbr.c
Add basic support for the STLS command in POP
[nmh] / uip / mhlsbr.c
index ef9f8305040dcbd2bdc45789da279dd1fccf03b5..86a1f41d3215a861db2d65e308d48987ad9b45b2 100644 (file)
@@ -5,13 +5,34 @@
  * complete copyright information.
  */
 
-#include <h/mh.h>
-#include <h/signals.h>
-#include <h/addrsbr.h>
-#include <h/fmt_scan.h>
-#include <h/tws.h>
+#include "h/mh.h"
+#include "sbr/fmt_new.h"
+#include "mhlsbr.h"
+#include "sbr/m_getfld.h"
+#include "sbr/getarguments.h"
+#include "sbr/concat.h"
+#include "sbr/smatch.h"
+#include "sbr/r1bindex.h"
+#include "sbr/snprintb.h"
+#include "sbr/copyip.h"
+#include "sbr/discard.h"
+#include "sbr/trimcpy.h"
+#include "sbr/vfgets.h"
+#include "sbr/check_charset.h"
+#include "sbr/getcpy.h"
+#include "sbr/brkstring.h"
+#include "sbr/ambigsw.h"
+#include "sbr/pidstatus.h"
+#include "sbr/print_version.h"
+#include "sbr/print_help.h"
+#include "sbr/arglist.h"
+#include "sbr/error.h"
+#include "h/signals.h"
+#include "h/addrsbr.h"
+#include "h/fmt_scan.h"
+#include "h/tws.h"
 #include "h/done.h"
-#include <h/utils.h>
+#include "h/utils.h"
 #include "sbr/m_popen.h"
 #include <setjmp.h>
 #include <sys/types.h>
@@ -1057,8 +1078,9 @@ mhlfile (FILE *fp, char *mname, int ofilen, int ofilec)
                                                        formatproc != NULL) {
                            filterbody(c1, buf, sizeof(buf), state, gstate);
                        } else {
-                           holder.c_text = mh_xmalloc (sizeof(buf));
-                           strncpy (holder.c_text, buf, sizeof(buf));
+                            bufsz = sizeof buf;
+                            holder.c_text = mh_xmalloc(bufsz);
+                            strncpy(holder.c_text, buf, bufsz);
                            while (state == BODY) {
                                putcomp (c1, &holder, BODYCOMP);
                                bufsz = sizeof buf;
@@ -1596,7 +1618,8 @@ putch (char ch, unsigned long flags)
  * Either way, the result depends on ASCII LF, either from typing Enter
  * or an escaped Ctrl-J, being amongst the read characters.
  */
-static bool linefeed_typed(void)
+static bool
+linefeed_typed(void)
 {
     char buf[128];
     ssize_t n;
@@ -1815,7 +1838,7 @@ filterbody (struct mcomp *c1, char *buf, int bufsz, int state,
     switch (filterpid = fork()) {
         char **args, *program;
        struct arglist *a;
-       int i, dat[5], s, argp;
+       int i, dat[5], argp;
 
     case 0:
        /*
@@ -1840,14 +1863,9 @@ filterbody (struct mcomp *c1, char *buf, int bufsz, int state,
            fmt_scan(a->a_fmt, scanl, BUFSIZ, dat, NULL);
            args[i] = charstring_buffer_copy (scanl);
            charstring_free (scanl);
-           /*
-            * fmt_scan likes to put a trailing newline at the end of the
-            * format string.  If we have one, get rid of it.
-            */
-           s = strlen(args[i]);
-           if (args[i][s - 1] == '\n')
-               args[i][s - 1] = '\0';
-
+           /* Trim a trailing linefeed that fmt_scan() likes to put at
+             * the end of the format string. */
+            trim_suffix_c(args[i], '\n');
            if (mhldebug)
                fprintf(stderr, "filterarg: fmt=\"%s\", output=\"%s\"\n",
                        a->a_nfs, args[i]);