From 62b366e5e839aee729a9f97d3c4c38bca4aaddab Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 27 May 2013 18:39:47 +0300 Subject: Replace obsolete AC_STRUCT_ST_BLKSIZE macro. --- extension/filefuncs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'extension/filefuncs.c') diff --git a/extension/filefuncs.c b/extension/filefuncs.c index 5117b32f..9d4b2258 100644 --- a/extension/filefuncs.c +++ b/extension/filefuncs.c @@ -351,11 +351,11 @@ fill_stat_array(const char *name, awk_array_t array, struct stat *sbuf) array_set_numeric(array, "minor", minor(sbuf->st_rdev)); } -#ifdef HAVE_ST_BLKSIZE +#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE array_set_numeric(array, "blksize", sbuf->st_blksize); #elif defined(_WIN32) array_set_numeric(array, "blksize", 4096); -#endif /* HAVE_ST_BLKSIZE */ +#endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */ pmode = format_mode(sbuf->st_mode); array_set(array, "pmode", make_const_string(pmode, strlen(pmode), & tmp)); -- cgit v1.2.3 From 407dddb6e9b24c2ca139ec84f8e3f541fbb18451 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Wed, 29 May 2013 22:15:50 +0300 Subject: Add "devbsize" to stat extension and doc. --- extension/filefuncs.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'extension/filefuncs.c') diff --git a/extension/filefuncs.c b/extension/filefuncs.c index 9d4b2258..0afed056 100644 --- a/extension/filefuncs.c +++ b/extension/filefuncs.c @@ -45,6 +45,9 @@ #include #include +#ifdef HAVE_SYS_PARAM_H +#include +#endif /* HAVE_SYS_PARAM_H */ #include "gawkapi.h" @@ -265,6 +268,31 @@ read_symlink(const char *fname, size_t bufsize, ssize_t *linksize) return NULL; } + +/* device_blocksize --- try to figure out units of st_blocks */ + +static int +device_blocksize() +{ + /* some of this derived from GNULIB stat-size.h */ +#if defined(DEV_BSIZE) + /* , most systems */ + return DEV_BSIZE; +#elif defined(S_BLKSIZE) + /* , BSD systems */ + return S_BLKSIZE; +#elif defined hpux || defined __hpux__ || defined __hpux + return 1024; +#elif defined _AIX && defined _I386 + /* AIX PS/2 counts st_blocks in 4K units. */ + return 4 * 1024; +#elif defined __MINGW32__ + return 1024; +#else + return 512; +#endif +} + /* array_set --- set an array element */ static void @@ -357,6 +385,9 @@ fill_stat_array(const char *name, awk_array_t array, struct stat *sbuf) array_set_numeric(array, "blksize", 4096); #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */ + /* the size of a block for st_blocks */ + array_set_numeric(array, "devbsize", device_blocksize()); + pmode = format_mode(sbuf->st_mode); array_set(array, "pmode", make_const_string(pmode, strlen(pmode), & tmp)); -- cgit v1.2.3 From 5482bf19246965d6839fe9df1aec0785f0b1a329 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 1 Jun 2013 13:03:29 +0300 Subject: Support |& on MS-Windows, both for sockets and for pipes. io.c (SHUT_RD) [SD_RECEIVE]: Define to SD_RECEIVE. (SHUT_WR) [SD_SEND]: Define to SD_SEND. (SHUT_RDWR) [SD_BOTH]: Define to SD_BOTH. (FD_TO_SOCKET, closemaybesocket) [!FD_TO_SOCKET]: New macros. (SOCKET_TO_FD, SOCKET) [!SOCKET_TO_FD]: New macros. (PIPES_SIMULATED): Define only for DJGPP. (pipe) [__MINGW32__]: Define to call _pipe, unless PIPES_SIMULATED is defined. (init_io) [HAVE_SOCKETS]: Call init_sockets. (iop_close, socketopen): Call closemaybesocket instead of close. (redirect) [__MINGW32__]: Call wait_any with a non-zero argument. (devopen) [__EMX__ || __MINGW32__]: Don't call stat on network pseudo-filenames. (two_way_open) [HAVE_SOCKETS]: Switch input and output to binary mode if appropriate. (two_way_open) [!PIPES_SIMULATED]: Use the __EMX__ code for MinGW as well. [__MINGW32__] Call spawnl to invoke $ComSpec and pass it a suitably quoted command line. (two_way_open) [__MINGW32__]: Wait only for a specified process ID. If successful, update the exit status of the exited process. Don't use signals that are undefined on MinGW. (two_way_open) [!PIPES_SIMULATED]: Use the __EMX__ code for MinGW as well. (min): Define only if not already defined. (read_with_timeout) [__MINGW32__]: Allow reading from sockets with timeout. (gawk_fclose) [__MINGW32__]: Close the underlying socket as well. getopt.c: Include stdlib.h for MinGW as well. pc/popen.h (SIGKILL) [__MINGW32__]: Define. (kill, quote_cmd): New prototypes. pc/popen.c: Include popen.h and errno.h. (popen, pclose, system): Undefine macros. (WIN32_LEAN_AND_MEAN) [__MINGW32__]: Define and include windows.h. (kill, quote_cmd) [!PIPES_SIMULATED]: New functions. (os_popen): Make the function definition match its prototype exactly. pc/gawkmisc.pc [HAVE_SOCKETS]: Include socket.h and windows.h. (socket, setsockopt, bind, connect, listen, accept, recvfrom) (shutdown): Undefine macros. (os_close_on_exec) [__MINGW32__]: Non-trivial implementation. (init_sockets, socket_to_fd, w32_socket, w32_setsockopt) (w32_bind, w32_connect, w32_listen, w32_accept, valid_socket) (w32_closesocket, w32_recvfrom, w32_shutdown) [HAVE_SOCKETS]: New functions for MinGW, emulate Posix sockets specified by file descriptors. pc/config.h (HAVE_GETADDRINFO, HAVE_SOCKADDR_STORAGE) (HAVE_SOCKETS) [__MINGW32__]: Define. pc/config.sed (HAVE_GETADDRINFO, HAVE_SOCKADDR_STORAGE) (HAVE_SOCKETS) [__MINGW32__]: Define. pc/Makefile.tst (fmtspcl): Announce expected failure only if not built with MPFR. (inetecht, inetdayt): For MinGW, warn about time-outs. (beginfile1, clos1way, getlndir): Announce expected failure only with DJGPP. (exit): Describe the failure on MinGW. (readdir): Explain why test might fail with bad ls.exe. pc/Makefile (mingw32, mingw32-readline, mingw32-mpfr) (mingw32-readline-mpfr): Add -lws2_32 to the link flags. (gawkmisc$O): Depend on socket.h. (io$O): Depend on socket.h and in.h. (popen$O): New dependency. posix/gawkmisc.c (init_sockets): New dummy function. extension/filefuncs.c [_WIN32]: Define WIN32_LEAN_AND_MEAN before including windows.h. extension/readdir.c [__MINGW32__]: Define WIN32_LEAN_AND_MEAN before including windows.h. extension/filefuncs.c [HAVE_GETSYSTEMTIMEASFILETIME]: Define WIN32_LEAN_AND_MEAN before including windows.h. test/clos1way.awk: Don't use features of Posix shells, to allow this test to work on Windows. test/beginfile2.sh: Leave one blank between the left quote and the following slash. Use non-absolute name for a non-existent file. This is to avoid breakage on Windows due to MSYS transformation of Posix style /foo/bar absolute file names. test/beginfile2.ok: Adapt to changes in beginfile2.sh. --- extension/filefuncs.c | 1 + 1 file changed, 1 insertion(+) (limited to 'extension/filefuncs.c') diff --git a/extension/filefuncs.c b/extension/filefuncs.c index 0afed056..5ef0e61b 100644 --- a/extension/filefuncs.c +++ b/extension/filefuncs.c @@ -77,6 +77,7 @@ #define major(s) (s) #define minor(s) (0) +#define WIN32_LEAN_AND_MEAN #include /* get_inode --- get the inode of a file */ -- cgit v1.2.3