nmh-workers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nmh-workers] Portability issues in nmh 1.5-RC2


From: Tom Lane
Subject: [Nmh-workers] Portability issues in nmh 1.5-RC2
Date: Mon, 07 May 2012 16:34:12 -0400

I've been trying to get 1.5-RC2 working on an ancient HPUX box, and I've
run into a couple of portability issues that perhaps you'd be interested
in taking back patches for.

The first problem I hit is that there are some places in the code relying
on the C99-ism of declarations in the midst of a code block.  This is
relatively painless to fix, and it will hit anyone else trying to use a
strict-ANSI-C compiler, so please consider the attached patch for that.
I'm not sure if nmh has any formal policy about what compilers are being
targeted, but the code is otherwise C89 compatible, so I'm hoping this is
just an oversight.  (BTW, I think you could check for this sort of issue
with a modern gcc version, if you tried building with CFLAGS=-ansi.)

Another problem I ran into is that the regression test scripts use some
shell features that the bare-bones /bin/sh on this machine doesn't
recognize.  My first hack at making that work was to edit all the
"#! /bin/sh" lines in the test scripts, which was a real PITA.  After
a bit of reflection I realized it could be solved much more simply,
along the lines of

diff -c nmh-1.5-RC2.orig/Makefile.in nmh-1.5-RC2/Makefile.in
*** nmh-1.5-RC2.orig/Makefile.in        Sun May  6 13:43:02 2012
--- nmh-1.5-RC2/Makefile.in     Mon May  7 16:12:33 2012
***************
*** 657,662 ****
--- 657,663 ----
                    address@hidden@/test/testdir \
                    auxexecdir=$(auxexecdir) bindir=$(bindir) \
                    mandir=$(mandir) sysconfdir=$(sysconfdir)
+ TESTS_SHELL = /bin/sh
  
  TESTS = test/bad-input/test-header \
        test/burst/test-burst \
***************
*** 3657,3663 ****
            if test -f ./$$tst; then dir=./; \
            elif test -f $$tst; then dir=; \
            else dir="$(srcdir)/"; fi; \
!           if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
              all=`expr $$all + 1`; \
              case " $(XFAIL_TESTS) " in \
              *$$ws$$tst$$ws*) \
--- 3658,3664 ----
            if test -f ./$$tst; then dir=./; \
            elif test -f $$tst; then dir=; \
            else dir="$(srcdir)/"; fi; \
!           if $(TESTS_ENVIRONMENT) $(TESTS_SHELL) $${dir}$$tst; then \
              all=`expr $$all + 1`; \
              case " $(XFAIL_TESTS) " in \
              *$$ws$$tst$$ws*) \

which then means only one line has to be patched to point to a different
shell.  I didn't find exactly where these lines are coming from in the
pre-Makefile.in files, but please consider doing something like that.

                        regards, tom lane

diff -cr nmh-1.5-RC2.orig/mts/smtp/smtp.c nmh-1.5-RC2/mts/smtp/smtp.c
*** nmh-1.5-RC2.orig/mts/smtp/smtp.c    Mon Apr  2 19:36:37 2012
--- nmh-1.5-RC2/mts/smtp/smtp.c Sun May  6 18:44:59 2012
***************
*** 196,201 ****
--- 196,202 ----
           int debug, int onex, int queued,
             int sasl, int saslssf, char *saslmech, char *user, int tls)
  {
+     int result, sd1, sd2;
  #ifdef CYRUS_SASL
      char *server_mechs;
  #else  /* CYRUS_SASL */
***************
*** 204,210 ****
      NMH_UNUSED (saslmech);
      NMH_UNUSED (user);
  #endif /* CYRUS_SASL */
-     int result, sd1, sd2;
  
      if (watch)
        verbose = TRUE;
--- 205,210 ----
***************
*** 454,459 ****
--- 454,462 ----
                 int debug, int onex, int queued,
                 int sasl, int saslssf, char *saslmech, char *user)
  {
+     unsigned int i, result, vecp;
+     int pdi[2], pdo[2];
+     char *vec[15];
  #ifdef CYRUS_SASL
      char *server_mechs;
  #else  /* CYRUS_SASL */
***************
*** 463,471 ****
      NMH_UNUSED (saslmech);
      NMH_UNUSED (user);
  #endif /* CYRUS_SASL */
-     unsigned int i, result, vecp;
-     int pdi[2], pdo[2];
-     char *vec[15];
  
      if (watch)
        verbose = TRUE;
--- 466,471 ----
diff -cr nmh-1.5-RC2.orig/sbr/fmt_scan.c nmh-1.5-RC2/sbr/fmt_scan.c
*** nmh-1.5-RC2.orig/sbr/fmt_scan.c     Sat Mar 24 01:47:36 2012
--- nmh-1.5-RC2/sbr/fmt_scan.c  Sun May  6 18:44:59 2012
***************
*** 152,161 ****
            if (iswcntrl(wide_char) || iswspace(wide_char)) {
                sp += char_len;
  #else
            end--;
              /* isnctrl(), etc., take an int argument.  Cygwin's ctype.h
                 intentionally warns if they are passed a char. */
!             int c = *sp;
            if (iscntrl(c) || isspace(c)) {
                sp++;
  #endif
--- 152,162 ----
            if (iswcntrl(wide_char) || iswspace(wide_char)) {
                sp += char_len;
  #else
+             int c;
            end--;
              /* isnctrl(), etc., take an int argument.  Cygwin's ctype.h
                 intentionally warns if they are passed a char. */
!             c = *sp;
            if (iscntrl(c) || isspace(c)) {
                sp++;
  #endif
diff -cr nmh-1.5-RC2.orig/sbr/lock_file.c nmh-1.5-RC2/sbr/lock_file.c
*** nmh-1.5-RC2.orig/sbr/lock_file.c    Sat Feb  4 23:17:00 2012
--- nmh-1.5-RC2/sbr/lock_file.c Sun May  6 18:44:59 2012
***************
*** 586,595 ****
  static void
  alrmser (int sig)
  {
-     NMH_UNUSED (sig);
- 
      char *lockfile;
      struct lock *lp;
  
      /* update the ctime of all the lock files */
      for (lp = l_top; lp; lp = lp->l_next) {
--- 586,594 ----
  static void
  alrmser (int sig)
  {
      char *lockfile;
      struct lock *lp;
+     NMH_UNUSED (sig);
  
      /* update the ctime of all the lock files */
      for (lp = l_top; lp; lp = lp->l_next) {
diff -cr nmh-1.5-RC2.orig/sbr/mts.c nmh-1.5-RC2/sbr/mts.c
*** nmh-1.5-RC2.orig/sbr/mts.c  Fri Mar 30 20:54:09 2012
--- nmh-1.5-RC2/sbr/mts.c       Sun May  6 18:44:59 2012
***************
*** 127,137 ****
  void
  mts_init (char *name)
  {
-     NMH_UNUSED (name);
- 
      const char *cp;
      FILE *fp;
      static int inited = 0;
  
      if (inited++ || (fp = fopen (get_mtsconf_pathname(), "r")) == NULL)
        return;
--- 127,136 ----
  void
  mts_init (char *name)
  {
      const char *cp;
      FILE *fp;
      static int inited = 0;
+     NMH_UNUSED (name);
  
      if (inited++ || (fp = fopen (get_mtsconf_pathname(), "r")) == NULL)
        return;
diff -cr nmh-1.5-RC2.orig/uip/folder.c nmh-1.5-RC2/uip/folder.c
*** nmh-1.5-RC2.orig/uip/folder.c       Sat Feb  4 23:17:00 2012
--- nmh-1.5-RC2/uip/folder.c    Sun May  6 18:44:59 2012
***************
*** 457,465 ****
  static boolean
  get_folder_info_callback (char *fold, void *baton)
  {
      NMH_UNUSED (baton);
  
-     boolean crawl_children;
      get_folder_info_body (fold, NULL, &crawl_children);
      fflush (stdout);
      return crawl_children;
--- 457,465 ----
  static boolean
  get_folder_info_callback (char *fold, void *baton)
  {
+     boolean crawl_children;
      NMH_UNUSED (baton);
  
      get_folder_info_body (fold, NULL, &crawl_children);
      fflush (stdout);
      return crawl_children;
diff -cr nmh-1.5-RC2.orig/uip/mhlsbr.c nmh-1.5-RC2/uip/mhlsbr.c
*** nmh-1.5-RC2.orig/uip/mhlsbr.c       Thu Apr 12 19:05:50 2012
--- nmh-1.5-RC2/uip/mhlsbr.c    Sun May  6 18:44:59 2012
***************
*** 338,344 ****
  mhl (int argc, char **argv)
  {
      int length = 0, nomore = 0;
!     unsigned int i, vecp = 0;;
      int width = 0;
      char *cp, *folder = NULL, *form = NULL;
      char buf[BUFSIZ], *files[MAXARGS];
--- 338,344 ----
  mhl (int argc, char **argv)
  {
      int length = 0, nomore = 0;
!     unsigned int i, vecp = 0;
      int width = 0;
      char *cp, *folder = NULL, *form = NULL;
      char buf[BUFSIZ], *files[MAXARGS];
diff -cr nmh-1.5-RC2.orig/uip/mhshowsbr.c nmh-1.5-RC2/uip/mhshowsbr.c
*** nmh-1.5-RC2.orig/uip/mhshowsbr.c    Thu Apr 12 19:05:50 2012
--- nmh-1.5-RC2/uip/mhshowsbr.c Sun May  6 18:44:59 2012
***************
*** 529,538 ****
  
        if (xpause && isatty (fileno (stdout))) {
            int intr;
  
            if (SOprintf ("Press <return> to show content..."))
                printf ("Press <return> to show content...");
-           SIGNAL_HANDLER istat;
  
            istat = SIGNAL (SIGINT, intrser);
            if ((intr = sigsetjmp (intrenv, 1)) == OK) {
--- 529,538 ----
  
        if (xpause && isatty (fileno (stdout))) {
            int intr;
+           SIGNAL_HANDLER istat;
  
            if (SOprintf ("Press <return> to show content..."))
                printf ("Press <return> to show content...");
  
            istat = SIGNAL (SIGINT, intrser);
            if ((intr = sigsetjmp (intrenv, 1)) == OK) {
diff -cr nmh-1.5-RC2.orig/uip/msh.c nmh-1.5-RC2/uip/msh.c
*** nmh-1.5-RC2.orig/uip/msh.c  Thu Apr 12 19:05:50 2012
--- nmh-1.5-RC2/uip/msh.c       Sun May  6 18:44:59 2012
***************
*** 801,810 ****
  FILE *
  msh_ready (int msgnum, int full)
  {
-     NMH_UNUSED (full);
      register int msgp;
      int fd;
      char *cp;
  
      if (yp) {
        fclose (yp);
--- 801,810 ----
  FILE *
  msh_ready (int msgnum, int full)
  {
      register int msgp;
      int fd;
      char *cp;
+     NMH_UNUSED (full);
  
      if (yp) {
        fclose (yp);
diff -cr nmh-1.5-RC2.orig/uip/mshcmds.c nmh-1.5-RC2/uip/mshcmds.c
*** nmh-1.5-RC2.orig/uip/mshcmds.c      Wed Feb 29 21:12:57 2012
--- nmh-1.5-RC2/uip/mshcmds.c   Sun May  6 18:44:59 2012
***************
*** 1075,1083 ****
  void
  helpcmd (char **args)
  {
-     NMH_UNUSED (args);
- 
      int i;
  
      for (i = 0; hlpmsg[i]; i++) {
        printf (hlpmsg[i], invo_name);
--- 1075,1082 ----
  void
  helpcmd (char **args)
  {
      int i;
+     NMH_UNUSED (args);
  
      for (i = 0; hlpmsg[i]; i++) {
        printf (hlpmsg[i], invo_name);
diff -cr nmh-1.5-RC2.orig/uip/picksbr.c nmh-1.5-RC2/uip/picksbr.c
*** nmh-1.5-RC2.orig/uip/picksbr.c      Thu Mar 15 21:00:56 2012
--- nmh-1.5-RC2/uip/picksbr.c   Sun May  6 18:45:00 2012
***************
*** 656,667 ****
  GREPaction (params)
  plist
  {
-     NMH_UNUSED (msgnum);
- 
      int c, body, lf;
      long pos = start;
      register char *p1, *p2, *ebp, *cbp;
      char ibuf[BUFSIZ];
  
      fseek (fp, start, SEEK_SET);
      body = 0;
--- 656,666 ----
  GREPaction (params)
  plist
  {
      int c, body, lf;
      long pos = start;
      register char *p1, *p2, *ebp, *cbp;
      char ibuf[BUFSIZ];
+     NMH_UNUSED (msgnum);
  
      fseek (fp, start, SEEK_SET);
      body = 0;
***************
*** 931,942 ****
  TWSaction (params)
  plist
  {
-     NMH_UNUSED (stop);
- 
      int state;
      register char *bp;
      char buf[BUFSIZ], name[NAMESZ];
      register struct tws *tw;
  
      fseek (fp, start, SEEK_SET);
      for (state = FLD, bp = NULL;;) {
--- 930,940 ----
  TWSaction (params)
  plist
  {
      int state;
      register char *bp;
      char buf[BUFSIZ], name[NAMESZ];
      register struct tws *tw;
+     NMH_UNUSED (stop);
  
      fseek (fp, start, SEEK_SET);
      for (state = FLD, bp = NULL;;) {
diff -cr nmh-1.5-RC2.orig/uip/popsbr.c nmh-1.5-RC2/uip/popsbr.c
*** nmh-1.5-RC2.orig/uip/popsbr.c       Fri Feb 17 19:53:46 2012
--- nmh-1.5-RC2/uip/popsbr.c    Sun May  6 18:45:00 2012
***************
*** 418,431 ****
  pop_init (char *host, char *port, char *user, char *pass, char *proxy,
          int snoop, int sasl, char *mech)
  {
  #ifndef CYRUS_SASL
      NMH_UNUSED (sasl);
      NMH_UNUSED (mech);
  #endif /* ! CYRUS_SASL */
  
-     int fd1, fd2;
-     char buffer[BUFSIZ];
- 
      if (proxy && *proxy) {
         int pid;
         int inpipe[2];   /* for reading from the server */
--- 418,430 ----
  pop_init (char *host, char *port, char *user, char *pass, char *proxy,
          int snoop, int sasl, char *mech)
  {
+     int fd1, fd2;
+     char buffer[BUFSIZ];
  #ifndef CYRUS_SASL
      NMH_UNUSED (sasl);
      NMH_UNUSED (mech);
  #endif /* ! CYRUS_SASL */
  
      if (proxy && *proxy) {
         int pid;
         int inpipe[2];   /* for reading from the server */
diff -cr nmh-1.5-RC2.orig/uip/replsbr.c nmh-1.5-RC2/uip/replsbr.c
*** nmh-1.5-RC2.orig/uip/replsbr.c      Thu Apr 12 19:05:51 2012
--- nmh-1.5-RC2/uip/replsbr.c   Sun May  6 18:45:00 2012
***************
*** 71,78 ****
  replout (FILE *inb, char *msg, char *drft, struct msgs *mp, int outputlinelen,
        int mime, char *form, char *filter, char *fcc, int fmtproc)
  {
-     NMH_UNUSED (msg);
- 
      register int state, i;
      register struct comp *cptr;
      register char *tmpbuf;
--- 71,76 ----
***************
*** 83,88 ****
--- 81,87 ----
      char name[NAMESZ], *scanl;
      unsigned char *cp;
      FILE *out;
+     NMH_UNUSED (msg);
  
      mask = umask(~m_gmprot());
      if ((out = fopen (drft, "w")) == NULL)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]