Skip to content

Commit

Permalink
Few more build fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperrealm committed Nov 22, 2022
1 parent 03cdf23 commit ba33788
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 24 deletions.
23 changes: 11 additions & 12 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dnl Process this file with autoconf to produce a configure script.

AC_INIT(libconfig, 1.7.4, [email protected], libconfig,
[https://hyperrealm.github.io/libconfig/])
AC_INIT([libconfig],[1.7.4],[[email protected]],[libconfig],
[https://hyperrealm.github.io/libconfig/])
AC_CONFIG_AUX_DIR([aux-build])
AC_CONFIG_MACRO_DIR([m4])
AC_CANONICAL_TARGET
Expand All @@ -16,18 +16,16 @@ sleep 3
AC_DEFINE_UNQUOTED(TARGET, "${target}", [Configured target name.])

# Enable GNU extensions.
AC_GNU_SOURCE
AC_USE_SYSTEM_EXTENSIONS

LT_INIT()
LT_INIT(win32-dll)

dnl Checks for programs.
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_CXX
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL

AM_PROG_LEX
AM_PROG_LEX(noyywrap)
if test Z"$LEX" != Zflex; then
cat <<EOF
*******************************************************************
Expand All @@ -38,7 +36,7 @@ the scanner.l file.
EOF
fi

AC_PROG_YACC
AC_PROG_YACC(noyywrap)
if test Z"$YACC" != "Zbison -y"; then
cat <<EOF
*******************************************************************
Expand Down Expand Up @@ -75,7 +73,8 @@ fi;


dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_INCLUDES_DEFAULT

AC_CHECK_HEADERS(unistd.h stdint.h xlocale.h)

dnl Checks for typedefs, structures, and compiler characteristics.
Expand Down Expand Up @@ -146,8 +145,7 @@ AM_CONDITIONAL(GNU_WIN, test x$gnuwin = xyes)

dnl Checks for library functions.

AC_OUTPUT(
Makefile
AC_CONFIG_FILES([Makefile
lib/Makefile
lib/libconfig.pc
lib/libconfig++.pc
Expand All @@ -160,4 +158,5 @@ AC_OUTPUT(
tinytest/Makefile
tests/Makefile
libconfig.spec
)
])
AC_OUTPUT
5 changes: 4 additions & 1 deletion examples/c/example4.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ static const char **include_func(config_t *config,
{
while((dir_entry = readdir(dp)) != NULL)
{
snprintf(file_path, PATH_MAX, "%s/%s", include_path, dir_entry->d_name);
int r = snprintf(file_path, PATH_MAX, "%s/%s", include_path,
dir_entry->d_name);
if(r < 0) abort(); // Handle possible truncation of very long path

if(lstat(file_path, &stat_buf) != 0) continue;
if(!S_ISREG(stat_buf.st_mode)) continue;
if(fnmatch(path, file_path, FNM_PATHNAME) != 0) continue;
Expand Down
6 changes: 3 additions & 3 deletions lib/libconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ int config_read_file(config_t *config, const char *filename)
if(stream != NULL)
{
// On some operating systems, fopen() succeeds on a directory.
int fd = fileno(stream);
int fd = posix_fileno(stream);
struct stat statbuf;

if(fstat(fd, &statbuf) == 0)
Expand Down Expand Up @@ -696,11 +696,11 @@ int config_write_file(config_t *config, const char *filename)

if(config_get_option(config, CONFIG_OPTION_FSYNC))
{
int fd = fileno(stream);
int fd = posix_fileno(stream);

if(fd >= 0)
{
if(fsync(fd) != 0)
if(posix_fsync(fd) != 0)
{
fclose(stream);
config->error_text = __io_error;
Expand Down
2 changes: 1 addition & 1 deletion lib/wincompat.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <errno.h>
#include <io.h>

int fsync(int fd)
int posix_fsync(int fd)
{
HANDLE h = (HANDLE)_get_osfhandle(fd);
if(h == INVALID_HANDLE_VALUE)
Expand Down
19 changes: 12 additions & 7 deletions lib/wincompat.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,13 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

#define fileno _fileno
#define posix_write _write
#define posix_fileno _fileno
#define posix_write _write

/* Might be able to replace this with:
#define posix_fsync _commit
*/
extern int posix_fsync(int fd);

#if _MSC_VER <= 1800
#define snprintf _snprintf
Expand Down Expand Up @@ -107,20 +112,20 @@
#define IS_RELATIVE_PATH(P) \
(PathIsRelativeA(P))

extern int fsync(int fd);

#else /* !( defined(WIN32/WIN64) && ! defined(__MINGW32__) ) */

#define posix_write write
#include <unistd.h> /* for fsync() */

#define posix_fileno fileno
#define posix_fsync fsync
#define posix_write write

#define INT64_CONST(I) (I ## LL)
#define UINT64_CONST(I) (I ## ULL)

#define IS_RELATIVE_PATH(P) \
((P)[0] != '/')

#include <unistd.h> /* for fsync() */

#endif /* defined(WIN32/WIN64) && ! defined(__MINGW32__) */

#endif /* __wincompat_h */

0 comments on commit ba33788

Please sign in to comment.