main: add support for HAVE_STRICT_MODE compiler define (and define it in the build system) (issue #25)
parent
4c82d02e99
commit
3035b0ba6b
15
configure.ac
15
configure.ac
|
@ -1,9 +1,22 @@
|
|||
AC_PREREQ([2.68])
|
||||
AC_INIT([pkgconf], [0.8], [http://github.com/nenolod/pkgconf/issues])
|
||||
AC_INIT([pkgconf], [0.8.1], [http://github.com/nenolod/pkgconf/issues])
|
||||
AC_CONFIG_SRCDIR([pkg.c])
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
AC_CHECK_FUNCS([strlcpy strlcat strndup])
|
||||
|
||||
AC_ARG_ENABLE([strict],
|
||||
[AC_HELP_STRING([--enable-strict],
|
||||
[enable POSIX-strict argument checking and disable some workarounds])],
|
||||
[ac_cv_use_strict=$enableval], [ac_cv_use_strict=no])
|
||||
AC_CACHE_CHECK([whether to enable strict mode],
|
||||
[ac_cv_use_strict], [ac_cv_use_strict=no])
|
||||
|
||||
if test "x$ac_cv_use_strict" = "xyes"; then
|
||||
AC_DEFINE([HAVE_STRICT_MODE], [1], [Define if strict mode is requested.])
|
||||
else
|
||||
AC_DEFINE([HAVE_STRICT_MODE], [0], [Define if strict mode is requested.])
|
||||
fi
|
||||
|
||||
AC_PROG_CPP
|
||||
AC_PROG_CC
|
||||
AC_PROG_INSTALL
|
||||
|
|
|
@ -68,7 +68,9 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if HAVE_STRICT_MODE > 0
|
||||
# define GNU_COMPATIBLE /* Be more compatible, configure's use us! */
|
||||
#endif
|
||||
|
||||
int pkg_opterr = 1; /* if error message should be printed */
|
||||
int pkg_optind = 1; /* index into parent argv vector */
|
||||
|
@ -378,6 +380,9 @@ getopt_internal(int nargc, char * const *nargv, const char *options,
|
|||
flags &= ~FLAG_PERMUTE;
|
||||
else if (*options == '-')
|
||||
flags |= FLAG_ALLARGS;
|
||||
#endif
|
||||
#if HAVE_STRICT_MODE >= 1
|
||||
flags &= ~FLAG_PERMUTE;
|
||||
#endif
|
||||
if (*options == '+' || *options == '-')
|
||||
options++;
|
||||
|
|
2
main.c
2
main.c
|
@ -407,7 +407,7 @@ out:
|
|||
static void
|
||||
version(void)
|
||||
{
|
||||
printf("%s %s\n", PACKAGE_NAME, PACKAGE_VERSION);
|
||||
printf("%s %s%s\n", PACKAGE_NAME, PACKAGE_VERSION, HAVE_STRICT_MODE ? " [strict]" : " [pkg-config compatible]");
|
||||
printf("Copyright (c) 2011 - 2012 William Pitcock <nenolod@dereferenced.org>.\n\n");
|
||||
printf("Permission to use, copy, modify, and/or distribute this software for any\n");
|
||||
printf("purpose with or without fee is hereby granted, provided that the above\n");
|
||||
|
|
Loading…
Reference in New Issue