nmh-commits
[Top][All Lists]
Advanced

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

[Nmh-commits] nmh ./configure.in sbr/fmt_scan.c


From: Oliver Kiddle
Subject: [Nmh-commits] nmh ./configure.in sbr/fmt_scan.c
Date: Wed, 18 Jan 2006 17:07:28 +0000

CVSROOT:        /cvsroot/nmh
Module name:    nmh
Branch:         
Changes by:     Oliver Kiddle <address@hidden>  06/01/18 17:07:28

Modified files:
        .              : configure.in 
        sbr            : fmt_scan.c 

Log message:
        add autoconf magic to support old systems that don't support multibyte 
charsets

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/configure.in.diff?tr1=1.75&tr2=1.76&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/sbr/fmt_scan.c.diff?tr1=1.21&tr2=1.22&r1=text&r2=text

Patches:
Index: nmh/configure.in
diff -u nmh/configure.in:1.75 nmh/configure.in:1.76
--- nmh/configure.in:1.75       Sat Jan  7 15:22:20 2006
+++ nmh/configure.in    Wed Jan 18 17:07:28 2006
@@ -1,7 +1,7 @@
 dnl
 dnl configure.in -- autoconf template for nmh
 dnl
-dnl $Id: configure.in,v 1.75 2006/01/07 15:22:20 bress Exp $
+dnl $Id: configure.in,v 1.76 2006/01/18 17:07:28 opk Exp $
 dnl
 
 dnl 2.13 definitely chokes; 2.53 is the earliest version I've tested. 
@@ -448,9 +448,9 @@
 AC_HEADER_STAT
 AC_CHECK_HEADERS(string.h memory.h stdlib.h unistd.h errno.h fcntl.h \
                  limits.h crypt.h termcap.h termio.h termios.h locale.h \
-                 langinfo.h netdb.h sys/param.h sys/time.h sys/utsname.h \
-                 iconv.h sys/stream.h arpa/inet.h arpa/ftp.h)
-
+                 langinfo.h wchar.h wctype.h iconv.h netdb.h \
+                 sys/param.h sys/time.h sys/utsname.h sys/stream.h \
+                 arpa/inet.h arpa/ftp.h)
 
 AC_CACHE_CHECK(POSIX termios, nmh_cv_sys_posix_termios,
 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
@@ -505,7 +505,7 @@
 AC_CHECK_LIB(mkstemp,mkstemp)
 AC_CHECK_FUNCS(waitpid wait3 sigaction sigprocmask sigblock sigsetmask \
                sighold sigrelse writev lstat uname tzset killpg mkstemp \
-               sethostent getutent nl_langinfo)
+               sethostent getutent nl_langinfo mbtowc wcwidth)
 
 dnl solaris screws this up
 AC_CHECK_FUNC(gethostbyname, [AC_DEFINE(HAVE_GETHOSTBYNAME)],
@@ -539,6 +539,13 @@
 dnl prototype. 
 AC_EGREP_HEADER(snprintf, stdio.h, AC_DEFINE(HAVE_SNPRINTF_PROTOTYPE))
 
+dnl Check for multibyte character set support
+if test "x$ac_cv_header_wchar_h" = "xyes" -a "x$ac_cv_header_wctype_h" = 
"xyes" \
+    -a "x$ac_cv_func_wcwidth" = "xyes" -a "x$ac_cv_func_mbtowc" = "xyes"; then
+  AC_DEFINE(MULTIBYTE_SUPPORT, 1,
+    [Define to enable support for multibyte character sets])
+fi
+
 dnl -------------------
 dnl CHECK FOR LIBRARIES
 dnl -------------------
Index: nmh/sbr/fmt_scan.c
diff -u nmh/sbr/fmt_scan.c:1.21 nmh/sbr/fmt_scan.c:1.22
--- nmh/sbr/fmt_scan.c:1.21     Wed Jan 18 16:43:27 2006
+++ nmh/sbr/fmt_scan.c  Wed Jan 18 17:07:28 2006
@@ -2,7 +2,7 @@
 /*
  * fmt_scan.c -- format string interpretation
  *
- * $Id: fmt_scan.c,v 1.21 2006/01/18 16:43:27 opk Exp $
+ * $Id: fmt_scan.c,v 1.22 2006/01/18 17:07:28 opk Exp $
  *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
@@ -25,7 +25,10 @@
 #  include <time.h>
 # endif
 #endif
-#include <wchar.h>
+#ifdef MULTIBYTE_SUPPORT
+#  include <wctype.h>
+#  include <wchar.h>
+#endif
 
 #define        NFMTS MAXARGS
 
@@ -127,8 +130,10 @@
     int remaining;     /* remaining output width available */
     int c, ljust, w;
     int end;           /* number of input bytes remaining in str */
+#ifdef MULTIBYTE_SUPPORT
     int char_len;      /* bytes in current character */
     wchar_t wide_char;
+#endif
     char *sp;          /* current position in source string */
     char *cp = *dest;  /* current position in destination string */
     char *ep = cp + n; /* end of destination buffer */
@@ -144,6 +149,7 @@
        mbtowc(NULL, NULL, 0); /* reset shift state */
        end = strlen(str);
        while (*sp && remaining > 0 && end > 0) {
+#ifdef MULTIBYTE_SUPPORT
            char_len = mbtowc(&wide_char, sp, end);
            if (char_len <= 0 || (cp + char_len > ep))
                break;
@@ -152,6 +158,11 @@
 
            if (iswcntrl(wide_char) || iswspace(wide_char)) {
                sp += char_len;
+#else
+           end--;
+           if (iscntrl(*sp) || isspace(*sp)) {
+               sp++;
+#endif
                if (!prevCtrl) {
                    *cp++ = ' ';
                    remaining--;
@@ -162,6 +173,7 @@
            }
            prevCtrl = 0;
 
+#ifdef MULTIBYTE_SUPPORT
            w = wcwidth(wide_char);
            if (w >= 0 && remaining >= w) {
                strncpy(cp, sp, char_len);
@@ -169,6 +181,10 @@
                remaining -= w;
            }
            sp += char_len;
+#else
+           *cp++ = *sp++;
+           remaining--;
+#endif
        }
     }
 




reply via email to

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