Mercurial > hg > early-roguelike
annotate rogue3/acinclude.m4 @ 280:70aa5808c782
Fix potential segfaults at restore related to ctime().
In some games, restore() passes the result of ctime() to mvprintw() or
some other variadic message-formatting function. If ctime() has not
been declared properly, its return type is inferred to be int instead
of char *. This does not cause a warning because the compiler does not
know the correct type of variadic arguments.
On platforms where ints and pointers are not the same size, this can,
probably depending on alignment, result in a segfault that is not easy
to trace.
Including time.h fixes the problem. Some games manually declared
ctime() and avoided the bug. These declarations have also been
replaced with the include.
author | John "Elwin" Edwards |
---|---|
date | Fri, 15 Sep 2017 20:51:10 -0400 |
parents | 07c4d4883ef2 |
children | 029c1f5c5588 |
rev | line source |
---|---|
88 | 1 AC_DEFUN([MP_WITH_CURSES], |
2 [AC_ARG_WITH(ncurses, [ --with-ncurses Force the use of ncurses over curses],,) | |
3 mp_save_LIBS="$LIBS" | |
4 CURSES_LIB="" | |
5 if test "$with_ncurses" != yes | |
6 then | |
7 AC_CACHE_CHECK([for working curses], mp_cv_curses, | |
8 [LIBS="$LIBS -lcurses" | |
9 AC_TRY_LINK( | |
10 [#include <curses.h>], | |
11 [chtype a; int b=A_STANDOUT, c=KEY_LEFT; initscr(); ], | |
12 mp_cv_curses=yes, mp_cv_curses=no)]) | |
13 if test "$mp_cv_curses" = yes | |
14 then | |
15 AC_DEFINE(HAVE_CURSES_H, 1, [Define to 1 if libcurses is requested]) | |
16 #AC_DEFINE(HAVE_CURSES_H) | |
17 CURSES_LIB="-lcurses" | |
18 fi | |
19 fi | |
20 if test ! "$CURSES_LIB" | |
21 then | |
22 AC_CACHE_CHECK([for working ncurses], mp_cv_ncurses, | |
23 [LIBS="$mp_save_LIBS -lncurses" | |
24 AC_TRY_LINK( | |
25 [#include <ncurses.h>], | |
26 [chtype a; int b=A_STANDOUT, c=KEY_LEFT; initscr(); ], | |
27 mp_cv_ncurses=yes, mp_cv_ncurses=no)]) | |
28 if test "$mp_cv_ncurses" = yes | |
29 then | |
30 AC_DEFINE(HAVE_NCURSES_H, 1, [Define to 1 if libncurses is requested]) | |
31 CURSES_LIB="-lncurses" | |
32 fi | |
33 fi | |
34 if test ! "$CURSES_LIB" | |
35 then | |
36 AC_CACHE_CHECK([for working pdcurses], mp_cv_pdcurses, | |
37 [LIBS="$mp_save_LIBS -lpdcurses" | |
38 AC_TRY_LINK( | |
39 [#include <curses.h>], | |
40 [chtype a; int b=A_STANDOUT, c=KEY_LEFT; initscr(); ], | |
41 mp_cv_pdcurses=yes, mp_cv_pdcurses=no)]) | |
42 if test "$mp_cv_pdcurses" = yes | |
43 then | |
44 AC_DEFINE(HAVE_CURSES_H, 1, [Define to 1 if libcurses is requested]) | |
45 CURSES_LIB="-lpdcurses" | |
46 fi | |
47 fi | |
48 if test ! "$CURSES_LIB" | |
49 then | |
50 AC_CACHE_CHECK([for working pdcur], mp_cv_pdcur, | |
51 [LIBS="$mp_save_LIBS -lpdcur" | |
52 AC_TRY_LINK( | |
53 [#include <curses.h>], | |
54 [chtype a; int b=A_STANDOUT, c=KEY_LEFT; initscr(); ], | |
55 mp_cv_pdcur=yes, mp_cv_pdcur=no)]) | |
56 if test "$mp_cv_pdcur" = yes | |
57 then | |
58 AC_DEFINE(HAVE_CURSES_H, 1, [Define to 1 if libcurses is requested]) | |
59 CURSES_LIB="-lpdcur" | |
60 fi | |
61 fi | |
62 if test ! "$CURSES_LIB" | |
63 then | |
64 AC_CACHE_CHECK([for working peer pdcurses], mp_cv_lpdcurses, | |
65 [LIBS="$mp_save_LIBS ../pdcurses/pdcurses.a" | |
66 AC_TRY_LINK( | |
67 [#include "../pdcurses/curses.h"], | |
68 [chtype a; int b=A_STANDOUT, c=KEY_LEFT; initscr(); ], | |
69 mp_cv_lpdcurses=yes, mp_cv_lpdcurses=no)]) | |
70 if test "$mp_cv_lpdcurses" = yes | |
71 then | |
72 AC_DEFINE(HAVE_CURSES_H, 1, [Define to 1 if libcurses is requested]) | |
73 CURSES_LIB="../pdcurses/pdcurses.a" | |
74 RF_ADDTO(CPPFLAGS,"-I../pdcurses") | |
75 fi | |
76 fi | |
77 AC_CACHE_CHECK([for ESCDELAY variable], | |
78 [mc_cv_ncurses_escdelay], | |
79 [AC_TRY_LINK([], [ | |
80 extern int ESCDELAY; | |
81 ESCDELAY = 0; | |
82 ], | |
83 [mc_cv_ncurses_escdelay=yes], | |
84 [mc_cv_ncurses_escdelay=no]) | |
85 ]) | |
86 if test "$mc_cv_ncurses_escdelay" = yes; then | |
87 AC_DEFINE(HAVE_ESCDELAY, 1, | |
88 [Define if ncurses has ESCDELAY variable]) | |
89 fi | |
90 if test ! "$CURSES_LIB" ; then | |
91 LIBS="$mp_save_LIBS" | |
92 fi | |
93 ])dnl | |
94 | |
07c4d4883ef2
rogue3: begin porting to autoconf.
John "Elwin" Edwards |