Skip to content

Commit 2e32495

Browse files
committed
patch 8.0.1709: some non-C89 code may slip through
Problem: Some non-C89 code may slip through. Solution: Enforce C89 in configure. Fix detected problems. (James McCoy, closes #2735)
1 parent 78a16b0 commit 2e32495

6 files changed

Lines changed: 122 additions & 12 deletions

File tree

‎src/auto/configure‎

Lines changed: 98 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3449,6 +3449,97 @@ ac_cpp='$CPP $CPPFLAGS'
34493449
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
34503450
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
34513451
ac_compiler_gnu=$ac_cv_c_compiler_gnu
3452+
3453+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
3454+
$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
3455+
if ${ac_cv_prog_cc_c89+:} false; then :
3456+
$as_echo_n "(cached) " >&6
3457+
else
3458+
ac_cv_prog_cc_c89=no
3459+
ac_save_CC=$CC
3460+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3461+
/* end confdefs.h. */
3462+
#include <stdarg.h>
3463+
#include <stdio.h>
3464+
struct stat;
3465+
/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
3466+
struct buf { int x; };
3467+
FILE * (*rcsopen) (struct buf *, struct stat *, int);
3468+
static char *e (p, i)
3469+
char **p;
3470+
int i;
3471+
{
3472+
return p[i];
3473+
}
3474+
static char *f (char * (*g) (char **, int), char **p, ...)
3475+
{
3476+
char *s;
3477+
va_list v;
3478+
va_start (v,p);
3479+
s = g (p, va_arg (v,int));
3480+
va_end (v);
3481+
return s;
3482+
}
3483+
3484+
/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
3485+
function prototypes and stuff, but not '\xHH' hex character constants.
3486+
These don't provoke an error unfortunately, instead are silently treated
3487+
as 'x'. The following induces an error, until -std is added to get
3488+
proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
3489+
array size at least. It's necessary to write '\x00'==0 to get something
3490+
that's true only with -std. */
3491+
int osf4_cc_array ['\x00' == 0 ? 1 : -1];
3492+
3493+
/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
3494+
inside strings and character constants. */
3495+
#define FOO(x) 'x'
3496+
int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
3497+
3498+
int test (int i, double x);
3499+
struct s1 {int (*f) (int a);};
3500+
struct s2 {int (*f) (double a);};
3501+
int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
3502+
int argc;
3503+
char **argv;
3504+
int
3505+
main ()
3506+
{
3507+
return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
3508+
;
3509+
return 0;
3510+
}
3511+
_ACEOF
3512+
for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
3513+
-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
3514+
do
3515+
CC="$ac_save_CC $ac_arg"
3516+
if ac_fn_c_try_compile "$LINENO"; then :
3517+
ac_cv_prog_cc_c89=$ac_arg
3518+
fi
3519+
rm -f core conftest.err conftest.$ac_objext
3520+
test "x$ac_cv_prog_cc_c89" != "xno" && break
3521+
done
3522+
rm -f conftest.$ac_ext
3523+
CC=$ac_save_CC
3524+
3525+
fi
3526+
# AC_CACHE_VAL
3527+
case "x$ac_cv_prog_cc_c89" in
3528+
x)
3529+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
3530+
$as_echo "none needed" >&6; } ;;
3531+
xno)
3532+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
3533+
$as_echo "unsupported" >&6; } ;;
3534+
*)
3535+
CC="$CC $ac_cv_prog_cc_c89"
3536+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
3537+
$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
3538+
esac
3539+
if test "x$ac_cv_prog_cc_c89" != xno; then :
3540+
3541+
fi
3542+
34523543
ac_ext=c
34533544
ac_cpp='$CPP $CPPFLAGS'
34543545
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -4115,6 +4206,8 @@ if test "$GCC" = yes; then
41154206
CFLAGS="$CFLAGS -fno-strength-reduce"
41164207
fi
41174208
fi
4209+
4210+
CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700"
41184211
fi
41194212

41204213
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for clang version" >&5
@@ -4187,7 +4280,7 @@ if test "`(uname) 2>/dev/null`" = Darwin; then
41874280
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
41884281
$as_echo "yes" >&6; }
41894282
MACOS_X=yes
4190-
CPPFLAGS="$CPPFLAGS -DMACOS_X"
4283+
CPPFLAGS="$CPPFLAGS -D_DARWIN_C_SOURCE -DMACOS_X"
41914284

41924285
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking --disable-darwin argument" >&5
41934286
$as_echo_n "checking --disable-darwin argument... " >&6; }
@@ -14341,6 +14434,10 @@ if test "$zOSUnix" = "yes"; then
1434114434
CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
1434214435
fi
1434314436

14437+
if test "$GCC" = yes -a "$GUITYPE" != "GTK"; then
14438+
CFLAGS="$CFLAGS -ansi"
14439+
fi
14440+
1434414441
ac_config_files="$ac_config_files auto/config.mk:config.mk.in"
1434514442

1434614443
cat >confcache <<\_ACEOF

‎src/channel.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -672,9 +672,9 @@ channel_open(
672672
{
673673
char *p;
674674

675-
/* When using host->h_addr directly ubsan warns for it to not be
676-
* aligned. First copy the pointer to aviod that. */
677-
memcpy(&p, &host->h_addr, sizeof(p));
675+
/* When using host->h_addr_list[0] directly ubsan warns for it to not
676+
* be aligned. First copy the pointer to avoid that. */
677+
memcpy(&p, &host->h_addr_list[0], sizeof(p));
678678
memcpy((char *)&server.sin_addr, p, host->h_length);
679679
}
680680

‎src/configure.ac‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ AC_DEFINE(UNIX)
1111
AC_PROG_MAKE_SET
1212

1313
dnl Checks for programs.
14-
AC_PROG_CC dnl required by almost everything
14+
AC_PROG_CC_C89 dnl required by almost everything
1515
AC_PROG_CPP dnl required by header file checks
1616
AC_PROGRAM_EGREP dnl required by AC_EGREP_CPP
1717
AC_PROG_FGREP dnl finds working grep -F
@@ -61,6 +61,9 @@ if test "$GCC" = yes; then
6161
CFLAGS="$CFLAGS -fno-strength-reduce"
6262
fi
6363
fi
64+
65+
dnl Declare what standards the code should comply with
66+
CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700"
6467
fi
6568

6669
dnl clang-500.2.75 or around has abandoned -f[no-]strength-reduce and issues a
@@ -135,7 +138,7 @@ AC_MSG_CHECKING([for Darwin (Mac OS X)])
135138
if test "`(uname) 2>/dev/null`" = Darwin; then
136139
AC_MSG_RESULT(yes)
137140
MACOS_X=yes
138-
CPPFLAGS="$CPPFLAGS -DMACOS_X"
141+
CPPFLAGS="$CPPFLAGS -D_DARWIN_C_SOURCE -DMACOS_X"
139142

140143
AC_MSG_CHECKING(--disable-darwin argument)
141144
AC_ARG_ENABLE(darwin,
@@ -4400,6 +4403,12 @@ if test "$zOSUnix" = "yes"; then
44004403
CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
44014404
fi
44024405

4406+
dnl Declare what standards the code should comply with. But not when using
4407+
dnl GTK, the header files cause all kinds of warnings.
4408+
if test "$GCC" = yes -a "$GUITYPE" != "GTK"; then
4409+
CFLAGS="$CFLAGS -ansi"
4410+
fi
4411+
44034412
dnl write output files
44044413
AC_OUTPUT(auto/config.mk:config.mk.in)
44054414

‎src/gui_gtk_x11.c‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5607,15 +5607,17 @@ gui_mch_free_font(GuiFont font)
56075607
guicolor_T
56085608
gui_mch_get_color(char_u *name)
56095609
{
5610+
guicolor_T color = INVALCOLOR;
5611+
56105612
if (!gui.in_use) /* can't do this when GUI not running */
5611-
return INVALCOLOR;
5613+
return color;
5614+
5615+
if (name != NULL)
5616+
color = gui_get_color_cmn(name);
56125617

56135618
#if GTK_CHECK_VERSION(3,0,0)
5614-
return name != NULL ? gui_get_color_cmn(name) : INVALCOLOR;
5619+
return color;
56155620
#else
5616-
guicolor_T color;
5617-
5618-
color = (name != NULL) ? gui_get_color_cmn(name) : INVALCOLOR;
56195621
if (color == INVALCOLOR)
56205622
return INVALCOLOR;
56215623

‎src/if_python3.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ python3_end(void)
815815
#endif
816816
if (Py_IsInitialized())
817817
{
818-
// acquire lock before finalizing
818+
/* acquire lock before finalizing */
819819
PyGILState_Ensure();
820820

821821
Py_Finalize();

‎src/version.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,8 @@ static char *(features[]) =
762762

763763
static int included_patches[] =
764764
{ /* Add new patch number below this line */
765+
/**/
766+
1709,
765767
/**/
766768
1708,
767769
/**/

0 commit comments

Comments
 (0)