* bug #23163: various minor fixes for the benefit of older Unixes
authorPeter Maydell <pmaydell@chiark.greenend.org.uk>
Sun, 4 May 2008 16:09:08 +0000 (16:09 +0000)
committerPeter Maydell <pmaydell@chiark.greenend.org.uk>
Sun, 4 May 2008 16:09:08 +0000 (16:09 +0000)
(specifically SunOS 4): reintroduce strerror() substitute implementation;
provide memmove() substitute implementation
* bug #23163: fix broken 'build outside source directory' feature
* bug #23162: sbr/dtime.c: fix stray HAVE_TM_GMTOFF that wasn't updated
to the new macro name.

ChangeLog
config/Makefile.in
configure.in
sbr/Makefile.in
sbr/dtime.c
sbr/memmove.c [new file with mode: 0644]
sbr/strerror.c [new file with mode: 0644]

index 620f47e..d4efbc6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2008-05-04  Peter Maydell  <pmaydell@chiark.greenend.org.uk>
+
+       * bug #23163: various minor fixes for the benefit of
+       older Unixes (specifically SunOS 4):
+       reintroduce strerror() substitute implementation
+       provide memmove() substitute implementation
+
+       * bug #23163: fix accidentally broken 'build outside
+       source directory' feature
+       
+       * bug #23162: sbr/dtime.c: fix stray HAVE_TM_GMTOFF that
+       wasn't updated to the new macro name.
+
 2008-04-30  Peter Maydell  <pmaydell@chiark.greenend.org.uk>
 
        * mts/smtp/smtp.c: provide a callback for SASL_CB_AUTHNAME
index 6ca8308..482bca2 100644 (file)
@@ -58,7 +58,7 @@ version.c:
        ${srcdir}/version.sh $(VERSION) > version.c
 
 config.o: config.c
-       $(COMPILE2) config.c
+       $(COMPILE2) $<
 
 install:
 
index 6b21a32..c5a9050 100644 (file)
@@ -534,7 +534,7 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <setjmp.h>]],
     [Define to 1 if you have the `sigsetjmp'.]) AC_MSG_RESULT(yes)],
   [AC_MSG_RESULT(no)])
 
-AC_REPLACE_FUNCS(snprintf strdup)
+AC_REPLACE_FUNCS(memmove snprintf strerror strdup)
 
 dnl Look for the initgroups() declaration.  On AIX 4.[13], Solaris 4.1.3, and
 dnl ULTRIX 4.2A the function is defined in libc but there's no declaration in
index 37434d9..2927e3c 100644 (file)
@@ -34,6 +34,8 @@ GNU_LIBTOOL = @GNU_LIBTOOL@
 LINT   = @LINT@
 LINTFLAGS = @LINTFLAGS@ 
 
+LIBOBJS = @LIBOBJS@
+
 mailspool    = @mailspool@
 sendmailpath = @sendmailpath@
 
@@ -78,9 +80,9 @@ SRCS = addrsbr.c ambigsw.c atooi.c brkstring.c                        \
        m_msgdef.c mf.c utils.c
 
 # source for compatibility functions
-COMPAT = snprintf.c strdup.c
+COMPAT = memmove.c snprintf.c strdup.c strerror.c
 
-OBJS = $(SRCS:.c=.o)
+OBJS = $(SRCS:.c=.o) $(LIBOBJS)
 
 # auxiliary files
 AUX = Makefile.in sigmsg.awk dtimep.lex
@@ -102,13 +104,13 @@ lint: sigmsg.h
 # Note that some lexes (for example flex 2.5.4) require that there
 # be no space between -o and the output filename.
 dtimep.c: dtimep.lex
-       $(LEX) -o$@ dtimep.lex
+       $(LEX) -o$@ $<
 
 client.o: client.c
-       $(COMPILE2) client.c
+       $(COMPILE2) $<
 
 mts.o: mts.c
-       $(COMPILE2) mts.c
+       $(COMPILE2) $<
 
 pidstatus.o: sigmsg.h
 
index 8cb4c79..1435955 100644 (file)
@@ -169,7 +169,7 @@ dlocaltime (time_t *clock)
     if (tm->tm_isdst)
        tw.tw_flags |= TW_DST;
 
-#ifdef HAVE_TM_GMTOFF
+#ifdef HAVE_STRUCT_TM_TM_GMTOFF
     tw.tw_zone = tm->tm_gmtoff / 60;
     if (tm->tm_isdst)                  /* if DST is in effect */
        tw.tw_zone -= 60;               /* reset to normal offset */
diff --git a/sbr/memmove.c b/sbr/memmove.c
new file mode 100644 (file)
index 0000000..62a303f
--- /dev/null
@@ -0,0 +1,11 @@
+/* public domain function from Jan Wolter Unix Incompatibility Notes */
+/* http://unixpapa.com/incnote/ */
+char *memmove(char *dst, char *src, int n)
+{
+  if (src > dst)
+    for ( ; n > 0; n--)
+      *(dst++)= *(src++);
+  else
+    for (dst+= n-1, src+= n-1; n > 0; n--)
+      *(dst--)= *(src--);
+}
diff --git a/sbr/strerror.c b/sbr/strerror.c
new file mode 100644 (file)
index 0000000..d780955
--- /dev/null
@@ -0,0 +1,21 @@
+
+/*
+ * strerror.c -- get error message string
+ *
+ * $Id$
+ */
+
+#include <h/mh.h>
+
+extern int sys_nerr;
+extern char *sys_errlist[];
+
+
+char *
+strerror (int errnum)
+{
+   if (errnum > 0 && errnum < sys_nerr)
+       return sys_errlist[errnum];
+   else
+       return NULL;
+}