aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorPaul Eggert2016-09-30 12:14:04 -0700
committerPaul Eggert2016-09-30 12:38:52 -0700
commitf4eb8900295d75c4afec256f75aea22494376fde (patch)
tree70203645e9b0b603ef8dbca6c50c01795a081512 /lib-src
parentd1890a3a4a18f79cabf4caf8d194cdc29ea4bf05 (diff)
downloademacs-f4eb8900295d75c4afec256f75aea22494376fde.tar.gz
emacs-f4eb8900295d75c4afec256f75aea22494376fde.zip
Limit <config.h>’s includes
This follows up on recent problems with the fact that config.h includes stdlib.h etc.; some files need to include stdlib.h later. config.h generally should limit itself to includes that are universally safe; outside of MS-Windows, only stdbool.h makes the cut among the files currently included. So, move the other includes to just the files that need them (Bug#24506). * configure.ac (config_opsysfile): Remove, as this generic hook is no longer needed. * lib-src/etags.c, src/unexmacosx.c, src/w32.c, src/w32notify.c: * src/w32proc.c (_GNU_SOURCE): Remove, as it’s OK for config.h to do this now. * src/conf_post.h: Include <ms-w32.h>, instead of the generic config_opsysfile, for simplicity as this old way of configuring is now done only for the MS-Windows port. Do not include <ms-w32.h> if DEFER_MS_W32_H, for the benefit of the few files that want its effects later. Do not include <alloca.h>, <string.h>, or <stdlib.h>. Other files modified to include these headers as needed, or to not include headers that are no longer needed. * src/lisp.h: Include <alloca.h> and <string.h> here, since some of the inline functions need them. * src/regex.c: Include <alloca.h> if not emacs. (If emacs, we can rely on SAFE_ALLOCA.) There is no longer any need to worry about HAVE_ALLOCA_H. * src/unexmacosx.c: Rely on config.h not including stdlib.h. * src/w32.c, src/w32notify.c, src/w32proc.c (DEFER_MS_W32_H): Define before including <config.h> first, and include <ms-w32.h> after the troublesome headers.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/emacsclient.c1
-rw-r--r--lib-src/etags.c4
-rw-r--r--lib-src/hexl.c2
-rw-r--r--lib-src/make-docfile.c4
-rw-r--r--lib-src/movemail.c2
-rw-r--r--lib-src/pop.c2
-rw-r--r--lib-src/profile.c1
-rw-r--r--lib-src/update-game-score.c1
8 files changed, 9 insertions, 8 deletions
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 458519d25fd..59b6ac97a05 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -74,6 +74,7 @@ char *w32_getenv (const char *);
74#include <stdarg.h> 74#include <stdarg.h>
75#include <ctype.h> 75#include <ctype.h>
76#include <stdio.h> 76#include <stdio.h>
77#include <stdlib.h>
77#include <getopt.h> 78#include <getopt.h>
78#include <unistd.h> 79#include <unistd.h>
79 80
diff --git a/lib-src/etags.c b/lib-src/etags.c
index a81b46d2e07..0479f8e4ebd 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -90,10 +90,6 @@ char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4";
90 90
91#include <config.h> 91#include <config.h>
92 92
93#ifndef _GNU_SOURCE
94# define _GNU_SOURCE 1 /* enables some compiler checks on GNU */
95#endif
96
97/* WIN32_NATIVE is for XEmacs. 93/* WIN32_NATIVE is for XEmacs.
98 MSDOS, WINDOWSNT, DOS_NT are for Emacs. */ 94 MSDOS, WINDOWSNT, DOS_NT are for Emacs. */
99#ifdef WIN32_NATIVE 95#ifdef WIN32_NATIVE
diff --git a/lib-src/hexl.c b/lib-src/hexl.c
index 9a5ca7e1543..5bd8579d258 100644
--- a/lib-src/hexl.c
+++ b/lib-src/hexl.c
@@ -22,6 +22,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
22#include <config.h> 22#include <config.h>
23 23
24#include <stdio.h> 24#include <stdio.h>
25#include <stdlib.h>
26#include <string.h>
25#include <ctype.h> 27#include <ctype.h>
26 28
27#include <binary-io.h> 29#include <binary-io.h>
diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c
index f463f13699b..9ba9b6e9af8 100644
--- a/lib-src/make-docfile.c
+++ b/lib-src/make-docfile.c
@@ -37,11 +37,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
37#include <config.h> 37#include <config.h>
38 38
39#include <stdarg.h> 39#include <stdarg.h>
40#include <stdbool.h>
41#include <stddef.h> 40#include <stddef.h>
42#include <stdint.h> 41#include <stdint.h>
43#include <stdio.h> 42#include <stdio.h>
44#include <stdlib.h> /* config.h unconditionally includes this anyway */ 43#include <stdlib.h>
44#include <string.h>
45 45
46#ifdef WINDOWSNT 46#ifdef WINDOWSNT
47/* Defined to be sys_fopen in ms-w32.h, but only #ifdef emacs, so this 47/* Defined to be sys_fopen in ms-w32.h, but only #ifdef emacs, so this
diff --git a/lib-src/movemail.c b/lib-src/movemail.c
index 45779dae5c2..8111c8721bb 100644
--- a/lib-src/movemail.c
+++ b/lib-src/movemail.c
@@ -59,8 +59,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
59#include <sys/types.h> 59#include <sys/types.h>
60#include <sys/stat.h> 60#include <sys/stat.h>
61#include <sys/file.h> 61#include <sys/file.h>
62#include <stdbool.h>
63#include <stdio.h> 62#include <stdio.h>
63#include <stdlib.h>
64#include <errno.h> 64#include <errno.h>
65#include <time.h> 65#include <time.h>
66 66
diff --git a/lib-src/pop.c b/lib-src/pop.c
index 99ec1cf824a..99424c584c2 100644
--- a/lib-src/pop.c
+++ b/lib-src/pop.c
@@ -63,10 +63,12 @@ void sys_freeaddrinfo (struct addrinfo * ai);
63extern struct servent *hes_getservbyname (/* char *, char * */); 63extern struct servent *hes_getservbyname (/* char *, char * */);
64#endif 64#endif
65 65
66#include <alloca.h>
66#include <pwd.h> 67#include <pwd.h>
67#include <netdb.h> 68#include <netdb.h>
68#include <errno.h> 69#include <errno.h>
69#include <stdio.h> 70#include <stdio.h>
71#include <stdlib.h>
70#include <string.h> 72#include <string.h>
71#include <unistd.h> 73#include <unistd.h>
72 74
diff --git a/lib-src/profile.c b/lib-src/profile.c
index 0e603776049..edd36cafd37 100644
--- a/lib-src/profile.c
+++ b/lib-src/profile.c
@@ -35,6 +35,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
35 35
36#include <inttypes.h> 36#include <inttypes.h>
37#include <stdio.h> 37#include <stdio.h>
38#include <stdlib.h>
38 39
39#include <intprops.h> 40#include <intprops.h>
40#include <systime.h> 41#include <systime.h>
diff --git a/lib-src/update-game-score.c b/lib-src/update-game-score.c
index 7675e9bdd4c..7e1b332bdcd 100644
--- a/lib-src/update-game-score.c
+++ b/lib-src/update-game-score.c
@@ -37,7 +37,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
37#include <errno.h> 37#include <errno.h>
38#include <inttypes.h> 38#include <inttypes.h>
39#include <limits.h> 39#include <limits.h>
40#include <stdbool.h>
41#include <string.h> 40#include <string.h>
42#include <stdlib.h> 41#include <stdlib.h>
43#include <stdio.h> 42#include <stdio.h>