[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
DJGPP build
From: |
fabrizio gennari |
Subject: |
DJGPP build |
Date: |
Mon, 5 Mar 2012 23:21:11 +0100 (GMT+01:00) |
Hello.
I tried to build bash-4.2 for the DJGPP (GNU for MS-DOS)
platform. It had been done before, but the latest available version was
2.04.
Something interesting has been found in the process. First:
version.c protects the use of snprintf with #if defined
(HAVE_SNPRINTF). But HAVE_SNPRINTF is always defined, only it is
defined as 0 if snprintf is not available. Here is a patch to fix that.
diff -ru bash-4.2/version.c bash-4.2-new/version.c
--- bash-4.2
/version.c 2011-01-28 17:32:36.000000000 +0100
+++ bash-4.2-new/version.
c 2012-03-05 08:05:18.778875000 +0100
@@ -64,13 +64,13 @@
if (tt[0]
== '\0')
{
if (release_status)
-#if defined (HAVE_SNPRINTF)
+#if (HAVE_SNPRINTF)
snprintf (tt, sizeof (tt), "%s.%d(%d)-%s",
dist_version, patch_level, build_version, release_status);
#else
sprintf (tt, "%s.%d(%d)-%s", dist_version, patch_level, build_version,
release_status);
#endif
else
-#if defined (HAVE_SNPRINTF)
+#if
(HAVE_SNPRINTF)
snprintf (tt, sizeof (tt), "%s.%d(%d)", dist_version,
patch_level, build_version);
#else
sprintf (tt, "%s.%d(%d)",
dist_version, patch_level, build_version);
Second, the variable
job_control is only declared when JOB_CONTROL is #define'd. Yet, there
is one case where its use is not protected by a suitable #if. Here's a
patch to fix that.
diff -ru bash-4.2/execute_cmd.c bash-4.2-
new/execute_cmd.c
--- bash-4.2/execute_cmd.c 2011-02-09 23:32:
25.000000000 +0100
+++ bash-4.2-new/execute_cmd.c 2012-03-05 08:08:
31.982000000 +0100
@@ -2202,7 +2202,11 @@
/* If the `lastpipe'
option is set with shopt, and job control is not
enabled, execute
the last element of non-async pipelines in the
current shell
environment. */
- if (lastpipe_opt && job_control == 0 && asynchronous
== 0 && pipe_out == NO_PIPE && prev > 0)
+ if (lastpipe_opt
+#if
defined (JOB_CONTROL)
+ && job_control == 0
+#endif /*defined
(JOB_CONTROL)*/
+ && asynchronous == 0 && pipe_out == NO_PIPE && prev
> 0)
{
lstdin = move_to_high_fd (0, 0, 255);
if
(lstdin > 0)
Third, a comment in posixdir.h says "Posix does not
require that the d_ino field be present, and some systems do not
provide it". But the #if statement immediately above seems to implay
that all non-Posix systems have it, because it assumes that it is
always present if _POSIX_SOURCE is not defined. The following patch
conditions the use of d_ino to the fact that configure successfully
tests it, independently of _POSIX_SOURCE. Also, it avoids using
d_fileno not only when d_ino is broken, but also when it is missing
altogether.
diff -ru bash-4.2/include/posixdir.h bash-4.2-
new/include/posixdir.h
--- bash-4.2/include/posixdir.h 2008-08-12 16:01:
57.000000000 +0200
+++ bash-4.2-new/include/posixdir.h 2012-03-05 19:28:
05.732000000 +0100
@@ -50,7 +50,7 @@
# define d_fileno d_ino
#endif
-#if defined (_POSIX_SOURCE) && (!defined (HAVE_STRUCT_DIRENT_D_INO)
|| defined (BROKEN_DIRENT_D_INO))
+#if (!defined
(HAVE_STRUCT_DIRENT_D_INO) || defined (BROKEN_DIRENT_D_INO))
/* Posix
does not require that the d_ino field be present, and some
systems
do not provide it. */
# define REAL_DIR_ENTRY(dp) 1
diff -ru bash-4.2
/lib/sh/getcwd.c bash-4.2-new/lib/sh/getcwd.c
--- bash-4.2
/lib/sh/getcwd.c 2009-06-17 02:16:55.000000000 +0200
+++ bash-4.2-
new/lib/sh/getcwd.c 2012-03-05 21:08:28.263250000 +0100
@@ -48,7 +48,7
@@
#include <bashansi.h>
-#if defined (BROKEN_DIRENT_D_INO)
+#if
defined (BROKEN_DIRENT_D_INO) || (!defined (HAVE_STRUCT_DIRENT_D_INO)
&& !defined (HAVE_STRUCT_DIRENT_D_FILENO))
# include "command.h"
#
include "general.h"
# include "externs.h"
@@ -71,7 +71,7 @@
/* If
the d_fileno member of a struct dirent doesn't return anything useful,
we need to check inode number equivalence the hard way. Return 1
if
the inode corresponding to PATH/DIR is identical to THISINO. */
-
#if defined (BROKEN_DIRENT_D_INO)
+#if defined (BROKEN_DIRENT_D_INO) ||
(!defined (HAVE_STRUCT_DIRENT_D_INO) && !defined
(HAVE_STRUCT_DIRENT_D_FILENO))
static int
_path_checkino (dotp, name,
thisino)
char *dotp;
@@ -206,7 +206,7 @@
(d->d_name[1] ==
'\0' ||
(d->d_name[1] == '.' && d->d_name[2] == '\0')))
continue;
-#if !defined (BROKEN_DIRENT_D_INO)
+#if !defined
(BROKEN_DIRENT_D_INO) && (defined (HAVE_STRUCT_DIRENT_D_INO) || defined
(HAVE_STRUCT_DIRENT_D_FILENO))
if (mount_point || d->d_fileno ==
thisino)
#else
if (mount_point || _path_checkino (dotp, d->d_name,
thisino))
If the above patches were applied, it would be a big step
towards having a new version of bash for DJGPP. It wouldn't be enough,
because DJGPP does not support the signals SIGCHLD and SIGWINCH and the
flag SA_RESTART. And the code would improve anyway, because they fixed
some little-tested cases.
Regards,
Fabrizio
E' nata indoona: chiama, videochiama e messaggia Gratis. Scarica indoona per
iPhone, Android e PC: http://www.indoona.com/
- DJGPP build,
fabrizio gennari <=