From fc34db7df7a5992eed6d416a86d77789aeb6b143 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 24 Oct 2011 05:22:37 +0200 Subject: A number of pc related fixes. --- ChangeLog | 4 ++++ builtin.c | 4 ++++ pc/ChangeLog | 14 ++++++++++++++ pc/Makefile | 6 ++++-- pc/gawkmisc.pc | 22 ++++++++++++++++++++++ pc/popen.h | 4 ++++ 6 files changed, 52 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2393ac3e..d66eb6ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-10-21 Eli Zaretskii + + * builtin.c [HAVE_POPEN_H]: Include "popen.h". + 2011-10-21 Arnold D. Robbins * Makefile.am (distcleancheck_listfiles): Added, per advice from diff --git a/builtin.c b/builtin.c index bae02f4d..04627a1c 100644 --- a/builtin.c +++ b/builtin.c @@ -32,6 +32,10 @@ #include "random.h" #include "floatmagic.h" +#if defined(HAVE_POPEN_H) +#include "popen.h" +#endif + #ifndef CHAR_BIT # define CHAR_BIT 8 #endif diff --git a/pc/ChangeLog b/pc/ChangeLog index 08ed2bf6..3a7b3be3 100644 --- a/pc/ChangeLog +++ b/pc/ChangeLog @@ -1,3 +1,17 @@ +2011-10-24 Eli Zaretskii + + * gawkmisc.pc (wctob) [__MINGW32__]: A replacement for the + function of the same name in MS runtime, which does a better job + with 8-bit characters that have their high bit set. + Original supplied by Jim Meyering . + + * popen.h (system) [__MINGW32__]: Redirect to os_system. + + * Makefile (./doc/awkcard.tr): Don't use Unixy forward slashes in + redirection. + (builtin$O): Depend on popen.h. + (random$O): New target, separated from builtin$O. + 2011-10-18 Juan Manuel Guerrero * Makefile: doc target to create all documentation files. diff --git a/pc/Makefile b/pc/Makefile index c6845c38..6156ce96 100644 --- a/pc/Makefile +++ b/pc/Makefile @@ -240,7 +240,9 @@ $(DRSPFILE) : $(DGAWKOBJS) $(ALLOBJS) $(LIBOBJS) eval_p$O profile_p$O: \ awk.h regex.h config.h gettext.h mbsupport.h protos.h dfa.h getopt.h -builtin$O random$O: floatmagic.h random.h +builtin$O: floatmagic.h random.h popen.h + +random$O: floatmagic.h random.h debug$O: floatmagic.h @@ -359,7 +361,7 @@ SEDME2 = sed "/%%Page: 10 10/,/0 Cg EP/d" ./doc/awkcard.tr: ./doc/awkcard.in cd doc - sed "s,SRCDIR,.," < ./awkcard.in > ./awkcard.tr + sed "s,SRCDIR,.," < awkcard.in > awkcard.tr cd .. ./doc/awkcard.nc: export GROFF_TMPDIR ?= . diff --git a/pc/gawkmisc.pc b/pc/gawkmisc.pc index 43f81ff9..64b42396 100644 --- a/pc/gawkmisc.pc +++ b/pc/gawkmisc.pc @@ -547,6 +547,28 @@ usleep(unsigned int usec) return usec - msecf * 1000 < 0 ? 0 : (int)(usec - msecf * 1000); } +/* The implementation of wctob in the MS runtime is problematic + because it doesn't allow to distinguish between WEOF and 0xff, due + to integer sign extension. It also causes failures in dfa.c when + characters with the 8th bit set are involved. This replacement + version fixes that. */ + +#include + +int +wctob (wint_t wc) +{ + char buf[64]; + + if (!(MB_CUR_MAX <= sizeof (buf))) + abort (); + /* Handle the case where WEOF is a value that does not fit in a wchar_t. */ + if (wc == (wchar_t)wc) + if (wctomb (buf, (wchar_t)wc) == 1) + return (unsigned char) buf[0]; + return EOF; +} + #endif /* __MINGW32__ */ #ifdef __DJGPP__ diff --git a/pc/popen.h b/pc/popen.h index 99f00169..9a04299c 100644 --- a/pc/popen.h +++ b/pc/popen.h @@ -10,4 +10,8 @@ # define pclose(f) os_pclose(f) extern FILE *os_popen( const char *, const char * ); extern int os_pclose( FILE * ); +# ifdef __MINGW32__ +# define system(c) os_system(c) + extern int os_system( const char * ); +# endif /* __MINGW32__ */ #endif /* !__DJGPP__ */ -- cgit v1.2.3