Ver código fonte

Remove some dependencies

localtime.c and difftime.c do not need stdio to compile, so remove
those dependencies.  This makes the runtime more portable to
freestanding implementations that lack stdio.  Similarly, remove
the sys/wait dependencies for .c files other than zic.c.
* NEWS: Mention this.
* asctime.c, date.c, strftime.c, zdump.c, zic.c: Include <stdio.h>.
* private.h: Do not include <stdio.h> or <sys/wait.h>.
Move declarations of WIFEXITED and WEXITSTATUS to zic.c.
(F_OK): Remove; unused.
* zic.c: Include <sys/wait.h>.
Paul Eggert 8 anos atrás
pai
commit
4f92a69f4f
7 arquivos alterados com 20 adições e 16 exclusões
  1. 3 0
      NEWS
  2. 1 0
      asctime.c
  3. 1 0
      date.c
  4. 1 16
      private.h
  5. 1 0
      strftime.c
  6. 1 0
      zdump.c
  7. 12 0
      zic.c

+ 3 - 0
NEWS

@@ -83,6 +83,9 @@ Unreleased, experimental changes
 
     Y2K runtime checks have been removed, as Y2K was years ago.
 
+    localtime.c and difftime.c no longer require stdio.h, and .c files
+    other than zic.c no longer require sys/wait.h.
+
     Several minor changes have been made to the code to make it a
     bit easier to port to MS-Windows and Solaris.  (Thanks to Kees
     Dekker for reporting the problems.)

+ 1 - 0
asctime.c

@@ -12,6 +12,7 @@
 /*LINTLIBRARY*/
 
 #include "private.h"
+#include <stdio.h>
 
 /*
 ** Some systems only handle "%.2d"; others only handle "%02d";

+ 1 - 0
date.c

@@ -29,6 +29,7 @@
 
 #include "private.h"
 #include <locale.h>
+#include <stdio.h>
 
 /*
 ** The two things date knows about time are. . .

+ 1 - 16
private.h

@@ -109,7 +109,6 @@
 #undef tzfree
 
 #include <sys/types.h>	/* for time_t */
-#include <stdio.h>
 #include <string.h>
 #include <limits.h>	/* for CHAR_BIT et al. */
 #include <stdlib.h>
@@ -130,19 +129,8 @@
 #include <libintl.h>
 #endif /* HAVE_GETTEXT */
 
-#if HAVE_SYS_WAIT_H
-#include <sys/wait.h>	/* for WIFEXITED and WEXITSTATUS */
-#endif /* HAVE_SYS_WAIT_H */
-
-#ifndef WIFEXITED
-#define WIFEXITED(status)	(((status) & 0xff) == 0)
-#endif /* !defined WIFEXITED */
-#ifndef WEXITSTATUS
-#define WEXITSTATUS(status)	(((status) >> 8) & 0xff)
-#endif /* !defined WEXITSTATUS */
-
 #if HAVE_UNISTD_H
-#include <unistd.h>	/* for F_OK, R_OK, and other POSIX goodness */
+#include <unistd.h>	/* for R_OK, and other POSIX goodness */
 #endif /* HAVE_UNISTD_H */
 
 #ifndef HAVE_STRFTIME_L
@@ -169,9 +157,6 @@
 # endif
 #endif
 
-#ifndef F_OK
-#define F_OK	0
-#endif /* !defined F_OK */
 #ifndef R_OK
 #define R_OK	4
 #endif /* !defined R_OK */

+ 1 - 0
strftime.c

@@ -37,6 +37,7 @@
 
 #include <fcntl.h>
 #include <locale.h>
+#include <stdio.h>
 
 struct lc_time_T {
 	const char *	mon[MONSPERYEAR];

+ 1 - 0
zdump.c

@@ -20,6 +20,7 @@
 #endif
 
 #include "private.h"
+#include <stdio.h>
 
 #ifndef HAVE_LOCALTIME_R
 # define HAVE_LOCALTIME_R 1

+ 12 - 0
zic.c

@@ -11,6 +11,7 @@
 #include <locale.h>
 #include <stdarg.h>
 #include <stddef.h>
+#include <stdio.h>
 
 #define	ZIC_VERSION_PRE_2013 '2'
 #define	ZIC_VERSION	'3'
@@ -41,6 +42,17 @@ typedef int_fast64_t	zic_t;
 #define MKDIR_UMASK 0755
 #endif
 
+#if HAVE_SYS_WAIT_H
+#include <sys/wait.h>	/* for WIFEXITED and WEXITSTATUS */
+#endif /* HAVE_SYS_WAIT_H */
+
+#ifndef WIFEXITED
+#define WIFEXITED(status)	(((status) & 0xff) == 0)
+#endif /* !defined WIFEXITED */
+#ifndef WEXITSTATUS
+#define WEXITSTATUS(status)	(((status) >> 8) & 0xff)
+#endif /* !defined WEXITSTATUS */
+
 /* The maximum ptrdiff_t value, for pre-C99 platforms.  */
 #ifndef PTRDIFF_MAX
 static ptrdiff_t const PTRDIFF_MAX = MAXVAL(ptrdiff_t, TYPE_BIT(ptrdiff_t));