sed -e $SDBMX -e $SDBHASH ext/GDBM_File/t/gdbm.t >s; mv -f s ext/GDBM_File/t/gdbm.t
sed -e $SSTAT -e $STMP2 t/op/stat.t >s; mv -f s t/op/stat.t
sed -e $SLIST x2p/Makefile.SH |tr -d '\r' >s; mv -f s x2p/Makefile.SH
-sed -e 's=^#define.\([A-Z]\+\)_EXP.*$=#define \1_EXP djgpp_pathexp("\1")=g' config_h.SH >s; mv -f s config_h.SH
+#sed -e 's=^#define.\([A-Z]\+\)_EXP.*$=#define \1_EXP djgpp_pathexp("\1")=g' config_h.SH >s; mv -f s config_h.SH
sed -e 's=:^/:={^([a-z]:)?[\\\\/]}=g' lib/termcap.pl >s; mv -f s lib/termcap.pl
sed -e $SPACKLIST installman >s; mv -f s installman
sed -e $SPACKLIST lib/ExtUtils/Installed.pm >s; mv -f s lib/ExtUtils/Installed.pm
# define HAS_WAIT
# define HAS_CHOWN
#endif /* WIN32 */
+
+/*
+ * <rich@phekda.freeserve.co.uk>: The DJGPP port has code that converts
+ * the return code of system() into the form that Unixy wait usually
+ * returns:
+ *
+ * - signal number in bits 0-6;
+ * - core dump flag in bit 7;
+ * - exit code in bits 8-15.
+ *
+ * Bits 0-7 are always zero for DJGPP, because it uses system().
+ * See djgpp.c.
+ *
+ * POSIX::W* use the W* macros from <sys/wait.h> to decode
+ * the return code. Unfortunately the W* macros for DJGPP use
+ * a different format than Unixy wait does. So there's a mismatch
+ * and, say, WEXITSTATUS($?) will return bogus values.
+ *
+ * So here we add hack to redefine the W* macros from DJGPP's <sys/wait.h>
+ * to work with our return-code conversion.
+ */
+
+#ifdef DJGPP
+
+#include <sys/wait.h>
+
+#undef WEXITSTATUS
+#undef WIFEXITED
+#undef WIFSIGNALED
+#undef WIFSTOPPED
+#undef WNOHANG
+#undef WSTOPSIG
+#undef WTERMSIG
+#undef WUNTRACED
+
+#define WEXITSTATUS(stat_val) ((stat_val) >> 8)
+#define WIFEXITED(stat_val) 0
+#define WIFSIGNALED(stat_val) 0
+#define WIFSTOPPED(stat_val) 0
+#define WNOHANG 0
+#define WSTOPSIG(stat_val) 0
+#define WTERMSIG(stat_val) 0
+#define WUNTRACED 0
+
+#endif