bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Implementing color support for DJGPP's port of grep


From: Juan Manuel Guerrero
Subject: Implementing color support for DJGPP's port of grep
Date: Tue, 22 Jan 2008 17:38:03 +0100
User-agent: KMail/1.9.5

OSs like DOS/WINDOWS do not provide the capability of using SGR (a.k.a. ANSI)
color escape sequences without having loaded a driver like ANSI.SYS or its
work-alike.  The goal of this patch is to implement color support using DJGPP's
capability of hoocking low-level filesystem functions.  The hole code required
for this task is stored in dosbuf.c and enclosed by #ifdef __DJGPP__/#endif.
The handler will check for writing to STDOUT and if colorization has been
enabled and the output really goes to the screen, the SGR command sequences
are decoded, the terminal attributes changed accordingly and the text is printed
directly to video ram.  If the output does not go to the screen or no
colorization is wanted, then the text is passed to the normal libc's low-level
functions that will do the job as usual.  All required initialisation is
performed by the provided constructor.  IMHO it makes no much sense to tell
more details because this is very DJGPP specific and cannot be fully understood
without reading DJGPP's filesystem extension documentation and the proposed
modificationes have no impact in the rest of grep's code anyway.


If compiled with DJGPP, to really get color support as described in the grep
documentation one change to grep.c is required.  In main(), there are following
code lines:

  if(color_option == 2) {
   if(isatty(STDOUT_FILENO) && getenv("TERM") &&
      strcmp(getenv("TERM"), "dumb"))
          color_option = 1;
   else
     color_option = 0;
  }

That is completely unix-centric.  It cannot be assumed that every OS will have
a TERM environment variable and that it will be set to "dumb".  I would suggest
to replace the above lines with the following ones:

  if(color_option == 2) {
     color_option = (IS_TERMINAL) ? 1 : 0;
  }

where the IS_TERMINAL macro is defined as:

  #ifdef __DJGPP__
  # define IS_TERMINAL (isatty(STDOUT_FILENO))
  #else
  # define IS_TERMINAL (isatty(STDOUT_FILENO) && getenv("TERM") && 
strcmp(getenv("TERM"), "dumb"))
  #endif

at some adequate place in grep.c.  Of course, the macros name is arbitrary and
can be changed if something else is prefered.


To be able to configure the grep sources with DJGPP some additional files are
required and provided.  These are:
   djgpp/Makefile.maint: DJGPP maintainer Makefile to produce djgpp/readme from
   djgpp/readme.in.
   djgpp/config.bat: DJGPP specific configuration file that set some environment
   variables and makes some editing of configure and the Makefile.ins.
   djgpp/config.sed: sed script to perform DJGPP specific editing to configure.
   djgpp/config.site: DJGPP specific configuration hints.
   djgpp/isdir.sed: sed script to perform DJGPP specific editing to lib/isdir.c.
   djgpp/readme.in: Template to produce djgpp/readme file.

I have also modified the EXTRA_DIST variable in Makefile.am adding the new
files.  Here I am following the way DJGPP support is handled in other GNU
programs like Texinfo and bison and may be someone else.

The submited patch is against today's CVS head and has been tested on my linux
and dos box.
Suggestions, objections, comments are welcome.


Regards,
Juan M. Guerrero





2008-01-22  Juan Manuel Guerrero <address@hidden>

        * djgpp/Makefile.maint: DJGPP maintainer Makefile to
        produce djgpp/readme from djgpp/readme.in.

        * djgpp/config.bat: DJGPP specific configuration file.

        * djgpp/config.sed: sed script to perform DJGPP specific
        editing to configure.

        * djgpp/config.site: DJGPP specific configuration hints.

        * djgpp/isdir.sed: sed script to perform DJGPP specific
        editing to lib/isdir.c.

        * djgpp/readme.in: Template to produce djgpp/readme file.

        * Makefile.am (EXTRA_DIST): Added djgpp/Makefile.maint djgpp/config.bat
        djgpp/config.sed djgpp/config.site djgpp/isdir.sed djgpp/README.in

        * src/dosbuf.c (restore_blink_bit, screen_puts, msdos_screen_write)
        (djgpp_grep_startup) [__DJGPP__]: New functions to support colorization
        without requiring ANSI.SYS driver (or its work-alike) to be loaded.

        * src/grep.c [__DJGPP__]: New macro IS_TERMINAL defined.  If compiled
        with DJGPP do not check for the TERM environment variable to decided
        which value should color_option have.
        (main): Use IS_TERMINAL.

        * src/system.h [__DJGPP__]: Depend on __DJGPP__ and __DJGPP_MINOR__
        to define HAVE_DIR_EACCES_BUG.




Index: Makefile.am
===================================================================
RCS file: /sources/grep/grep/Makefile.am,v
retrieving revision 1.19
diff -U 5 -r1.19 Makefile.am
--- Makefile.am 29 Apr 2005 10:37:09 -0000      1.19
+++ Makefile.am 22 Jan 2008 16:32:37 -0000
@@ -1,11 +1,13 @@
 ## Process this file with automake to create Makefile.in
 AUTOMAKE_OPTIONS = no-dependencies
 
 SUBDIRS = intl po lib doc src tests m4 vms bootstrap
 
-EXTRA_DIST = TODO README README-alpha
+EXTRA_DIST = TODO README README-alpha \
+  djgpp/Makefile.maint djgpp/config.bat djgpp/config.sed \
+  djgpp/config.site djgpp/isdir.sed djgpp/README.in
 
 # We should be able to just define `ACLOCAL_AMFLAGS = --acdir=m4',
 # but this runs afoul of a bug in automake 1.
 # The following hack works around this bug by creating acinclude.m4 manually.
 ACLOCAL_AMFLAGS =
Index: src/dosbuf.c
===================================================================
RCS file: /sources/grep/grep/src/dosbuf.c,v
retrieving revision 1.5
diff -U 5 -r1.5 dosbuf.c
--- src/dosbuf.c        20 Jan 2000 04:43:03 -0000      1.5
+++ src/dosbuf.c        22 Jan 2008 16:32:39 -0000
@@ -1,14 +1,17 @@
 /* Messy DOS-specific code for correctly treating binary, Unix text
-   and DOS text files.
+   and DOS text files, and for emulating a Posix terminal driver
+   wrt SGR (a.k.a. ANSI) color escape sequences.
 
    This has several aspects:
 
      * Guessing the file type (unless the user tells us);
      * Stripping CR characters from DOS text files (otherwise regex
        functions won't work correctly);
      * Reporting correct byte count with -b for any kind of file.
+     * Redirecting output with ANSI color commands to direct screen
+       writes.
 
 */
 
 typedef enum {
   UNKNOWN, DOS_BINARY, DOS_TEXT, UNIX_TEXT
@@ -177,5 +180,347 @@
         out_map_idx--;
     }
 
   return byteno + dos_pos_map[out_map_idx].add;
 }
+
+#ifdef __DJGPP__
+/*  Screen write redirection.  We need this to support colorization
+    without requiring ANSI.SYS driver (or its work-alike) to be loaded.
+
+    This function uses the DJGPP filesystem extensions mechanism.  It is
+    installed as a handler for handle-based functions (read/write/close)
+    for the standard output (but actually only handles writes, only if
+    the standard output is connected to the terminal, and only if user
+    asked for colorization).  When a buffer is written to the screen by
+    low-level functions of the DJGPP C library, our handler will be
+    called.  For any request that doesn't require colored screen writes
+    we return a zero to the caller, in which case the caller will handle
+    the output in the usual way (by eventually calling DOS).
+
+    When colorization *is* required, the buffer is written directly to
+    the screen while converting the ANSI escape sequences into calls to
+    DJGPP conio functions which change text attributes.  A non-zero value is
+    then returned to the caller to signal that the output has been handled.
+*/
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <errno.h>
+#include <unistd.h>
+#include <conio.h>
+#include <sys/fsext.h>
+#include <go32.h> /* for `_dos_ds' */
+#include <sys/farptr.h>
+
+static int norm_blink = -1, cur_blink = -1;
+static unsigned char norm_attr = 0, cur_attr = 0;
+static int isatty_stdout = -1;
+static size_t leftover = 0;
+
+/* Restore the BIOS blinking bit to its original value.  Called at exit.  */
+static void
+restore_blink_bit (void)
+{
+  if (cur_blink != norm_blink)
+    {
+      if (norm_blink > 0)
+        blinkvideo ();
+      else
+        intensevideo ();
+    }
+}
+
+/* Write a buffer to the screen video memory.  This expands the TAB
+   characters to the appropriate number of spaces, and also does TRT
+   with null characters and other non-printable characters, if
+   any.  */
+static void
+screen_puts (char *buf, char *buf_end)
+{
+  register char *p = buf, *q = p;
+  int row, col;
+  unsigned char c;
+
+  while (p < buf_end)
+    {
+      if (*p < ' ')
+        {
+          switch (*p)
+            {
+              case '\b':
+              case '\r':
+              case '\n':
+                /* nothing: cputs already does TRT with these */
+                break;
+              case '\t':
+                *p = '\0';
+                cputs (q);
+                ScreenGetCursor (&row, &col);
+                for (cputs (" "), col += 1; col % 8; col++)
+                  cputs (" ");
+                q = p + 1;
+                *p = '\t';
+                break;
+              default:
+                c = *p;
+                *p = '\0';
+                cputs (q);
+                cputs ("^");
+                putch (c | 0x40);
+                q = p + 1;
+                *p = c;
+                break;
+            }
+        }
+      p++;
+    }
+  /* Output whatever is left.  */
+  cputs (q);
+}
+
+#define ESC '\033'
+#define IS_SGR(s) (((s)[1] == '[') && ((s)[2] == 'm'))
+#define IS_EL(s)  (((s)[1] == '[') && ((s)[2] == 'K'))
+
+/* Screen writes redirector function.  */
+static int
+msdos_screen_write (__FSEXT_Fnumber func, int *retval, va_list rest_args)
+{
+  static char *cbuf = NULL;
+  static size_t cbuf_len = 0;
+  /* Only dark colors mentioned here, so that bold has visible effect.  */
+  static enum COLORS screen_color[] = {
+    BLACK,
+    RED,
+    GREEN,
+    BROWN,
+    BLUE,
+    MAGENTA,
+    CYAN,
+    LIGHTGRAY
+  };
+  char *anchor, *p_next;
+  unsigned char fg, bg;
+
+  int handle;
+  char *buf, *buf_end;
+  size_t buflen;
+
+  /* Avoid direct screen writes unless colorization was actually requested.
+     Otherwise, we will break programs that catch I/O from their children.  */
+  handle = va_arg (rest_args, int);
+  if (!color_option || func != __FSEXT_write ||
+       !(handle == STDOUT_FILENO ? isatty_stdout : isatty (handle)))
+    return 0;
+
+  buf = va_arg (rest_args, char *);
+  if (!buf)
+    {
+      errno = EINVAL;
+      *retval = -1;
+      return 1;
+    }
+
+  /* Allocate a sufficiently large buffer to hold the output.  */
+  buflen = va_arg (rest_args, size_t);
+  if (!cbuf)
+    {
+      struct text_info txtinfo;
+
+      cbuf_len = buflen + 1;
+      cbuf = (char *)xmalloc (cbuf_len);
+      gettextinfo (&txtinfo);
+      norm_attr = txtinfo.attribute; /* save the original text attribute */
+      cur_attr = norm_attr;
+      /* Does it normally blink when bg has its 3rd bit set?  */
+      norm_blink = (_farpeekb (_dos_ds, 0x465) & 0x20) ? 1 : 0;
+      cur_blink = norm_blink;
+    }
+  else if (buflen >= cbuf_len)
+    {
+      cbuf_len = buflen + 1 + leftover;
+      cbuf = (char *)xrealloc (cbuf, cbuf_len);
+    }
+  memcpy (cbuf + leftover, buf, buflen);
+  buf_end = cbuf + buflen + leftover;
+  *buf_end = '\0';
+
+  /* Current text attributes are used as baseline.  */
+  fg = cur_attr & 15;
+  bg = (cur_attr >> 4) & 15;
+
+  /* Walk the buffer, writing text directly to video RAM,
+     changing color attributes when an escape sequence is seen.  */
+  for (anchor = p_next = cbuf;
+       (p_next = memchr (p_next, ESC, buflen - (p_next - cbuf))) != 0; )
+    {
+      char *p = p_next;
+
+
+      /* If some chars seen since the last escape sequence,
+         write it out to the screen using current text attributes.  */
+      if (p > anchor)
+        {
+          *p = '\0'; /* `cputs' needs ASCIIZ string */
+          screen_puts (anchor, p);
+          *p = ESC; /* restore the ESC character */
+          anchor = p;
+        }
+
+      /* Handle the null escape sequence (ESC-[m), which is used to
+         restore the original color. */
+      if (IS_SGR(p))
+        {
+          textattr (norm_attr);
+          p += 3;
+          anchor = p_next = p;
+          continue;
+        }
+
+      /* Handle the erase in line to the right escape sequence (ESC-[K). */
+      if (IS_EL(p))
+        {
+          clreol();
+          p += 3;
+          anchor = p_next = p;
+          continue;
+        }
+
+      if (p[1] == '[') /* "Esc-[" sequence */
+        {
+          p += 2; /* get past "Esc-[" sequence */
+          p_next = p;
+          while (*p != 'm') /* `m' ends the escape sequence */
+            {
+              char *q;
+              long code = strtol (p, &q, 10);
+
+              if (!*q)
+                {
+                  /* Incomplete escape sequence.  Remember the part
+                     we've seen for the next time.  */
+                  leftover = q - anchor;
+                  if (leftover >= cbuf_len)
+                    {
+                      cbuf_len += 1 + leftover;
+                      cbuf = (char *)xrealloc (cbuf, cbuf_len);
+                    }
+                  strcpy (cbuf, anchor);
+                  *retval = buflen; /* that's a lie, but we have to! */
+                  return 1;
+                }
+
+              /* 
+                 Sanity checks:
+
+                 q > p unless p doesn't point to a number;
+                 SGR codes supported by ANSI.SYS are between 0 and 49;
+                 Each SGR code ends with a `;' or an `m'.
+
+                 If any of the above is violated, we just ignore the bogon.
+              */
+              if (q == p || code > 49 || code < 0 || (*q != 'm' && *q != ';'))
+                {
+                  p_next = q;
+                  break;
+                }
+              if (*q == ';') /* more codes to follow */
+                q++;
+
+              /* Convert ANSI codes to color fore- and background.  */
+              switch (code)
+                {
+                  case 0: /* all attributes off */
+                    fg = norm_attr & 15;
+                    bg = (norm_attr >> 4) & 15;
+                    break;
+                  case 1: /* intensity on */
+                    fg |= 8;
+                    break;
+                  case 4: /* underline on */
+                    fg |= 8; /* we can't, so make it bold instead */
+                    break;
+                  case 5: /* blink */
+                    if (cur_blink != 1)
+                      {
+                        blinkvideo (); /* ensure we are'nt in bright bg mode */
+                        cur_blink = 1;
+                      }
+                    bg |= 8;
+                    break;
+                  case 7: /* reverse video */
+                    {
+                      unsigned char t = fg;
+                      fg = bg;
+                      bg = t;
+
+                      /* If it was blinking before, let it blink after.  */
+                      if (fg & 8)
+                        bg |= 8;
+
+                      /* If the fg was bold, let the background be bold.  */
+                      if ((t & 8) && cur_blink != 0)
+                        {
+                          intensevideo ();
+                          cur_blink = 0;
+                        }
+                    }
+                    break;
+                  case 8: /* concealed on */
+                    fg = (bg & 7) | 8; /* make fg be like bg, only bright */
+                    break;
+                  case 30: case 31: case 32: case 33: /* foreground color */
+                  case 34: case 35: case 36: case 37:
+                    fg = (fg & 8) | (screen_color[code - 30] & 15);
+                    break;
+                  case 40: case 41: case 42: case 43: /* background color */
+                  case 44: case 45: case 46: case 47:
+                    bg = (bg & 8) | (screen_color[code - 40] & 15);
+                    break;
+                  case 39: /* default fg */
+                    fg = norm_attr & 15;
+                    break;
+                  case 49:
+                    bg = (norm_attr >> 4) & 15;
+                    break;
+                  default:
+                    p_next = q; /* ignore unknown codes */
+                    break;
+                }
+              p = q;
+            } /* while loop */
+
+          if (*p == 'm' && p > p_next)
+            {
+              /* They don't *really* want it invisible, do they?  */
+              if (fg == (bg & 7))
+                fg |= 8; /* make it concealed instead */
+
+              /* Construct the text attribute and set it.  */
+              cur_attr = (bg << 4) | fg;
+              textattr (cur_attr);
+              p_next = anchor = p + 1;
+            }
+          else
+            break;
+        }
+      else
+        p_next++;
+    }  /* for loop */
+
+  /* Output what's left in the buffer.  */
+  screen_puts (anchor, buf_end);
+  leftover = 0;
+  *retval = buflen;
+  return 1;
+}
+
+/* This is called before `main' to install our STDOUT redirector.  */
+static void __attribute__((constructor))
+djgpp_grep_startup (void)
+{
+  __FSEXT_set_function (STDOUT_FILENO, msdos_screen_write);
+  isatty_stdout = isatty (STDOUT_FILENO);
+  atexit (restore_blink_bit);
+}
+#endif  /* __DJGPP__ */
Index: src/grep.c
===================================================================
RCS file: /sources/grep/grep/src/grep.c,v
retrieving revision 1.125
diff -U 5 -r1.125 grep.c
--- src/grep.c  10 Oct 2007 04:29:47 -0000      1.125
+++ src/grep.c  22 Jan 2008 16:32:43 -0000
@@ -53,10 +53,16 @@
 
 #define SEP_CHAR_SELECTED ':'
 #define SEP_CHAR_REJECTED '-'
 #define SEP_STR_GROUP    "--"
 
+#ifdef __DJGPP__
+# define IS_TERMINAL (isatty(STDOUT_FILENO))
+#else
+# define IS_TERMINAL (isatty(STDOUT_FILENO) && getenv("TERM") && 
strcmp(getenv("TERM"), "dumb"))
+#endif
+
 struct stats
 {
   struct stats const *parent;
   struct stat stat;
 };
@@ -2094,15 +2100,11 @@
           else
             show_help = 1;
         } else
           color_option = 2;
         if(color_option == 2) {
-          if(isatty(STDOUT_FILENO) && getenv("TERM") &&
-            strcmp(getenv("TERM"), "dumb"))
-                  color_option = 1;
-          else
-            color_option = 0;
+          color_option = (IS_TERMINAL) ? 1 : 0;
         }
        break;
 
       case EXCLUDE_OPTION:
        if (!excluded_patterns)
Index: src/system.h
===================================================================
RCS file: /sources/grep/grep/src/system.h,v
retrieving revision 1.18
diff -U 5 -r1.18 system.h
--- src/system.h        28 Jun 2007 19:10:46 -0000      1.18
+++ src/system.h        22 Jan 2008 16:32:43 -0000
@@ -78,10 +78,14 @@
 # define FILESYSTEM_PREFIX_LEN(f) 0
 #endif
 
 int isdir PARAMS ((char const *));
 
+#if __DJGPP__ == 2 && __DJGPP_MINOR__ < 4
+# define HAVE_DIR_EACCES_BUG
+#endif
+
 #ifdef HAVE_DIR_EACCES_BUG
 # ifdef EISDIR
 #  define is_EISDIR(e, f) \
      ((e) == EISDIR \
       || ((e) == EACCES && isdir (f) && ((e) = EISDIR, 1)))
diff -aprNU5 grep-2.5.4.orig/djgpp/Makefile.maint 
grep-2.5.4/djgpp/Makefile.maint
--- grep-2.5.4.orig/djgpp/Makefile.maint        1970-01-01 00:00:00 +0000
+++ grep-2.5.4/djgpp/Makefile.maint     2008-01-22 16:49:04 +0000
@@ -0,0 +1,38 @@
+# DJGPP Maintainer's Makefile                                    -*-Makefile-*-
+# Requires GNU sed
+
+## Copyright (C) 2008 Free Software Foundation, Inc.
+
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2, or (at your option)
+## any later version.
+
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software Foundation,
+## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+top_srcdir = ..
+srcdir = .
+
+SHELL = /bin/sh
+
+all: readme
+
+readme: readme.in $(top_srcdir)/configure
+       PACKAGE=`grep "^PACKAGE_TARNAME=" $(top_srcdir)/configure | sed -e 
's/^PACKAGE.*=//' -e s/[\"\']//g`; \
+       VERSION=`grep "^PACKAGE_VERSION=" $(top_srcdir)/configure | sed -e 
's/^PACKAGE.*=//' -e s/[\"\']//g`; \
+       package_version=`echo "$${VERSION}" | sed 's/\.//g'`; \
+       dir_version=`echo "$${VERSION}" | sed 's/\./-/2g'`; \
+       sed \
+           -e "s/@V@/$${PACKAGE}-$${VERSION}/g" \
+           -e "s/@VERSION@/$${VERSION}/g" \
+           -e "s/@PACKAGE_VERSION@/$$package_version/g" \
+           -e "s/@DIR_VERSION@/$$dir_version/g" \
+         $(srcdir)/readme.in > t-$@
+       mv t-$@ $@
diff -aprNU5 grep-2.5.4.orig/djgpp/config.bat grep-2.5.4/djgpp/config.bat
--- grep-2.5.4.orig/djgpp/config.bat    1970-01-01 00:00:00 +0000
+++ grep-2.5.4/djgpp/config.bat 2008-01-22 16:49:04 +0000
@@ -0,0 +1,326 @@
address@hidden off
+Rem WARNING WARNING WARNING: This file needs to have DOS CRLF end-of-line
+Rem format, or else stock DOS/Windows shells will refuse to run it.
+
+Rem Copyright (C) 2008 Free Software Foundation, Inc.
+
+Rem This program is free software; you can redistribute it and/or modify
+Rem it under the terms of the GNU General Public License as published by
+Rem the Free Software Foundation; either version 3, or (at your option)
+Rem any later version.
+
+Rem This program is distributed in the hope that it will be useful,
+Rem but WITHOUT ANY WARRANTY; without even the implied warranty of
+Rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+Rem GNU General Public License for more details.
+
+Rem You should have received a copy of the GNU General Public License
+Rem along with this program; if not, write to the Free Software Foundation,
+Rem Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+echo Configuring GNU Grep for DJGPP v2.x...
+
+Rem The small_env tests protect against fixed and too small size
+Rem of the environment in stock DOS shell.
+
+Rem Find out if NLS is wanted or not,
+Rem if dependency-tracking is wanted or not,
+Rem if caching is wanted or not
+Rem and where the sources are.
+Rem We always default to NLS support,
+Rem no dependency tracking
+Rem and to in place configuration.
+set ARGS=
+set NLS=disabled
+if not "%NLS%" == "disabled" goto SmallEnv
+set CACHING=enabled
+if not "%CACHING%" == "enabled" goto SmallEnv
+set DEPENDENCY_TRACKING=disabled
+if not "%DEPENDENCY_TRACKING%" == "disabled" goto SmallEnv
+set LIBICONV_PREFIX=disabled
+if not "%LIBICONV_PREFIX%" == "disabled" goto SmallEnv
+set LIBINTL_PREFIX=disabled
+if not "%LIBINTL_PREFIX%" == "disabled" goto SmallEnv
+set HTML=enabled
+if not "%HTML%" == "enabled" goto SmallEnv
+set XSRC=.
+if not "%XSRC%" == "." goto SmallEnv
+
+Rem Loop over all arguments.
+Rem Special arguments are: NLS, XSRC, CACHE, STATIC_LIBS, LIBICONV_PREFIX, 
LIBINTL_PREFIX and DEPS.
+Rem All other arguments are stored into ARGS.
+:ArgLoop
+if "%1" == "nls" goto NextArgument
+if "%1" == "NLS" goto NextArgument
+if "%1" == "no-nls" goto NoNLS
+if "%1" == "no-NLS" goto NoNLS
+if "%1" == "NO-NLS" goto NoNLS
+goto CachingOption
+:NoNLS
+if "%1" == "no-nls" set NLS=disabled
+if "%1" == "no-NLS" set NLS=disabled
+if "%1" == "NO-NLS" set NLS=disabled
+if not "%NLS%" == "disabled" goto SmallEnv
+goto NextArgument
+:CachingOption
+if "%1" == "cache" goto NextArgument
+if "%1" == "CACHE" goto NextArgument
+if "%1" == "no-cache" goto NoCaching
+if "%1" == "no-CACHE" goto NoCaching
+if "%1" == "NO-CACHE" goto NoCaching
+goto DependencyOption
+:NoCaching
+if "%1" == "no-cache" set CACHING=disabled
+if "%1" == "no-CACHE" set CACHING=disabled
+if "%1" == "NO-CACHE" set CACHING=disabled
+if not "%CACHING%" == "disabled" goto SmallEnv
+goto NextArgument
+:DependencyOption
+if "%1" == "no-dep" goto NextArgument
+if "%1" == "no-DEP" goto NextArgument
+if "%1" == "NO-DEP" goto NextArgument
+if "%1" == "dep" goto DependecyTraking
+if "%1" == "DEP" goto DependecyTraking
+goto LibiconvPrefixOption
+:DependecyTraking
+if "%1" == "dep" set DEPENDENCY_TRACKING=enabled
+if "%1" == "DEP" set DEPENDENCY_TRACKING=enabled
+if not "%DEPENDENCY_TRACKING%" == "enabled" goto SmallEnv
+goto NextArgument
+:LibiconvPrefixOption
+if "%1" == "no-libiconvprefix" goto NextArgument
+if "%1" == "no-LIBICONVPREFIX" goto NextArgument
+if "%1" == "NO-LIBICONVPREFIX" goto NextArgument
+if "%1" == "libiconvprefix" goto WithLibiconvPrefix
+if "%1" == "LIBICONVPREFIX" goto WithLibiconvPrefix
+goto LibintlPrefixOption
+:WithLibiconvPrefix
+if "%1" == "libiconvprefix" set LIBICONV_PREFIX=enabled
+if "%1" == "LIBICONVPREFIX" set LIBICONV_PREFIX=enabled
+if not "%LIBICONV_PREFIX%" == "enabled" goto SmallEnv
+goto NextArgument
+:LibintlPrefixOption
+if "%1" == "no-libiconvprefix" goto NextArgument
+if "%1" == "no-LIBICONVPREFIX" goto NextArgument
+if "%1" == "NO-LIBICONVPREFIX" goto NextArgument
+if "%1" == "libintlprefix" goto _WithLibintlPrefix
+if "%1" == "LIBINTLPREFIX" goto _WithLibintlPrefix
+goto HTMLOption
+:_WithLibintlPrefix
+if "%1" == "libintlprefix" set LIBINTL_PREFIX=enabled
+if "%1" == "LIBINTLPREFIX" set LIBINTL_PREFIX=enabled
+if not "%LIBINTL_PREFIX%" == "enabled" goto SmallEnv
+:HTMLOption
+if "%1" == "withhtml" goto NextArgument
+if "%1" == "withHTML" goto NextArgument
+if "%1" == "WITHHTML" goto NextArgument
+if "%1" == "withouthtml" goto _WithoutHTML
+if "%1" == "withoutHTML" goto _WithoutHTML
+if "%1" == "WITHOUTHTML" goto _WithoutHTML
+goto SrcDirOption
+:_WithoutHTML
+if "%1" == "withouthtml" set HTML=disabled
+if "%1" == "withoutHTML" set HTML=disabled
+if "%1" == "WITHOUTHTML" set HTML=disabled
+if not "%HTML%" == "disabled" goto SmallEnv
+goto NextArgument
+:SrcDirOption
+echo %1 | grep -q "/"
+if errorlevel 1 goto CollectArgument
+set XSRC=%1
+if not "%XSRC%" == "%1" goto SmallEnv
+goto NextArgument
+:CollectArgument
+set _ARGS=%ARGS% %1
+if not "%_ARGS%" == "%ARGS% %1" if not "%_ARGS%" == "%ARGS%%1" goto SmallEnv
+echo %_ARGS% | grep -q "[^ ]"
+if not errorlevel 0 set ARGS=%_ARGS%
+set _ARGS=
+:NextArgument
+shift
+if not "%1" == "" goto ArgLoop
+
+Rem Create an arguments file for the configure script.
+echo --srcdir=%XSRC% > arguments
+if "%CACHING%" == "enabled"              echo 
--cache-file=%XSRC%/djgpp/config.cache >> arguments
+if "%DEPENDENCY_TRACKING%" == "enabled"  echo --enable-dependency-tracking >> 
arguments
+if "%DEPENDENCY_TRACKING%" == "disabled" echo --disable-dependency-tracking >> 
arguments
+if "%LIBICONV_PREFIX%" == "enabled"      echo --with-libiconv-prefix >> 
arguments
+if "%LIBICONV_PREFIX%" == "disabled"     echo --without-libiconv-prefix >> 
arguments
+if "%LIBINTL_PREFIX%" == "enabled"       echo --with-libintl-prefix >> 
arguments
+if "%LIBINTL_PREFIX%" == "disabled"      echo --without-libintl-prefix >> 
arguments
+if "%HTML%" == "enabled"                 echo --enable-html >> arguments
+if "%HTML%" == "disabled"                echo --disable-html >> arguments
+if not "%ARGS%" == ""                    echo %ARGS% >> arguments
+set ARGS=
+set CACHING=
+set DEPENDENCY_TRACKING=
+set LIBICONV_PREFIX=
+set LIBINTL_PREFIX=
+set HTML=
+
+if "%XSRC%" == "." goto in_place
+
+:not_in_place
+redir -e /dev/null update %XSRC%/configure.org ./configure
+test -f ./configure
+if errorlevel 1 update %XSRC%/configure ./configure
+
+:in_place
+Rem Update configuration files
+echo Updating configuration scripts...
+test -f ./configure.org
+if errorlevel 1 update configure configure.org
+sed -f %XSRC%/djgpp/config.sed configure.org > configure
+if errorlevel 1 goto sed_error
+
+Rem Make sure they have a config.site file
+set CONFIG_SITE=%XSRC%/djgpp/config.site
+if not "%CONFIG_SITE%" == "%XSRC%/djgpp/config.site" goto small_env
+
+Rem Make sure crucial file names are not munged by unpacking
+
+test -f %XSRC%/po/Makefile.in.in
+if not errorlevel 1 mv -f %XSRC%/po/Makefile.in.in %XSRC%/po/Makefile.in-in
+test -f %XSRC%/po/Makefile.am.in
+if not errorlevel 1 mv -f %XSRC%/po/Makefile.am.in %XSRC%/po/Makefile.am-in
+test -f %XSRC%/configure.ac.in
+if not errorlevel 1 mv -f %XSRC%/configure.ac.in %XSRC%/configure.ac-in
+
+Rem Fix lib/isdir.c
+echo Fixing lib/isdir....
+test -f %XSRC%/lib/isdir.org
+if errorlevel 1 update %XSRC%/lib/isdir.c %XSRC%/lib/isdir.org
+sed -f %XSRC%/djgpp/isdir.sed %XSRC%/lib/isdir.org > isdir.c
+if errorlevel 1 goto isdir_error
+mv -f isdir.c %XSRC%/lib/isdir.c
+
+Rem This is required because DOS/Windows are case-insensitive
+Rem to file names, and "make install" will do nothing if Make
+Rem finds a file called `install'.
+if exist INSTALL if not exist INSTALL.txt ren INSTALL INSTALL.txt
+
+Rem Set HOME to a sane default so configure stops complaining.
+if not "%HOME%" == "" goto host_name
+set HOME=%XSRC%/djgpp
+if not "%HOME%" == "%XSRC%/djgpp" goto small_env
+echo No HOME found in the environment, using default value
+
+:host_name
+Rem Set HOSTNAME so it shows in config.status
+if not "%HOSTNAME%" == "" goto hostdone
+if "%windir%" == "" goto msdos
+set OS=MS-Windows
+if not "%OS%" == "MS-Windows" goto small_env
+goto haveos
+:msdos
+set OS=MS-DOS
+if not "%OS%" == "MS-DOS" goto small_env
+:haveos
+if not "%USERNAME%" == "" goto haveuname
+if not "%USER%" == "" goto haveuser
+echo No USERNAME and no USER found in the environment, using default values
+set HOSTNAME=Unknown PC
+if not "%HOSTNAME%" == "Unknown PC" goto small_env
+goto userdone
+:haveuser
+set HOSTNAME=%USER%'s PC
+if not "%HOSTNAME%" == "%USER%'s PC" goto small_env
+goto userdone
+:haveuname
+set HOSTNAME=%USERNAME%'s PC
+if not "%HOSTNAME%" == "%USERNAME%'s PC" goto small_env
+:userdone
+set _HOSTNAME=%HOSTNAME%, %OS%
+if not "%_HOSTNAME%" == "%HOSTNAME%, %OS%" goto small_env
+set HOSTNAME=%_HOSTNAME%
+:hostdone
+set _HOSTNAME=
+set OS=
+
+Rem install-sh is required by the configure script but clashes with the
+Rem various Makefile install-foo targets, so we MUST have it before the
+Rem script runs and rename it afterwards
+test -f %XSRC%/install-sh
+if not errorlevel 1 goto no_ren0
+test -f %XSRC%/install-sh.sh
+if not errorlevel 1 mv -f %XSRC%/install-sh.sh %XSRC%/install-sh
+:no_ren0
+
+if "%NLS%" == "disabled" goto without_NLS
+
+:with_NLS
+Rem Check for the needed libraries and binaries.
+test -x /dev/env/DJDIR/bin/msgfmt.exe
+if not errorlevel 0 goto missing_NLS_tools
+test -x /dev/env/DJDIR/bin/xgettext.exe
+if not errorlevel 0 goto missing_NLS_tools
+test -f /dev/env/DJDIR/include/libcharset.h
+if not errorlevel 0 goto missing_NLS_tools
+test -f /dev/env/DJDIR/lib/libcharset.a
+if not errorlevel 0 goto missing_NLS_tools
+test -f /dev/env/DJDIR/include/iconv.h
+if not errorlevel 0 goto missing_NLS_tools
+test -f /dev/env/DJDIR/lib/libiconv.a
+if not errorlevel 0 goto missing_NLS_tools
+test -f /dev/env/DJDIR/include/libintl.h
+if not errorlevel 0 goto missing_NLS_tools
+test -f /dev/env/DJDIR/lib/libintl.a
+if not errorlevel 0 goto missing_NLS_tools
+
+Rem Recreate the files in the %XSRC%/po subdir with our ported tools.
+redir -e /dev/null rm %XSRC%/po/*.gmo
+redir -e /dev/null rm %XSRC%/po/grep.pot
+redir -e /dev/null rm %XSRC%/po/cat-id-tbl.c
+redir -e /dev/null rm %XSRC%/po/stamp-cat-id
+
+Rem Update the arguments file for the configure script.
+Rem We prefer without-included-gettext because libintl.a from gettext package
+Rem is the only one that is guaranteed to have been ported to DJGPP.
+echo --enable-nls --without-included-gettext >> args
+goto configure_package
+
+:missing_NLS_tools
+echo Needed libs/tools for NLS not found.  Configuring without NLS.
+:without_NLS
+Rem Update the arguments file for the configure script.
+echo --disable-nls >> args
+
+:configure_package
+echo Running the ./configure script...
+sh ./configure @args
+if errorlevel 1 goto cfg_error
+rm args
+echo Done.
+goto End
+
+:isdir_error
+echo %XSRC%/lib/isdir.c editing failed!
+goto End
+
+:sed_error
+echo ./configure script editing failed!
+goto End
+
+:cfg_error
+echo ./configure script exited abnormally!
+goto End
+
+:small_env
+echo Your environment size is too small.  Enlarge it and run me again.
+echo Configuration NOT done!
+
+:End
+test -f %XSRC%/install-sh.sh
+if not errorlevel 1 goto no_ren1
+test -f %XSRC%/install-sh
+if not errorlevel 1 mv -f %XSRC%/install-sh %XSRC%/install-sh.sh
+:no_ren1
+if "%HOME%" == "%XSRC%/djgpp" set HOME=
+set ARGS=
+set CONFIG_SITE=
+set HOSTNAME=
+set NLS=
+set CACHE=
+set DEPTRAK=
+set XSRC=
diff -aprNU5 grep-2.5.4.orig/djgpp/config.sed grep-2.5.4/djgpp/config.sed
--- grep-2.5.4.orig/djgpp/config.sed    1970-01-01 00:00:00 +0000
+++ grep-2.5.4/djgpp/config.sed 2008-01-22 16:49:04 +0000
@@ -0,0 +1,139 @@
+# DJGPP specific configuration file.
+# Sed script for additional DJGPP specific editing
+# of the configure script generated by autoconf 2.61.
+
+# Copyright (C) 2008 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+
+# Additional editing of Makefiles
+/^".*ac_file_inputs.*tmp\/out$/ a\
+cat > "$tmp/subs-djgpp.sed" << eof_djgpp\
+# DJGPP specific Makefile changes.\
+/^aliaspath *  *=/s,:,";",g\
+/TEXINPUTS=/s,:,";",g\
+/PATH=/s,:,";",g\
+s,\\.deps,_deps,g\
+s,\\.libs,_libs,g\
+s,\\.new\\.,_new.,g\
+s,\\.old\\.,_old.,g\
+s,\\.tab\\.,_tab.,g\
+s,configure\\.ac\\.in,configure.ac-in,g\
+s,Makefile\\.in\\.in,Makefile.in-in,g\
+/^SUBDIRS/s/ tests//\
+/^\\.y\\.c:/,/^$/ {\
+  /\\\$(YACCCOMPILE)/ {\
+    a\\\
+       address@hidden -f y.tab.c && mv -f y.tab.c y_tab.c\\\
+       address@hidden -f y.tab.h && mv -f y.tab.h y_tab.h\
+  }\
+}\
+eof_djgpp\
+sed -f "\$tmp/subs-djgpp.sed" \$tmp/out > \$tmp/out.djgpp\
+mv -f \$tmp/out.djgpp \$tmp/out
+
+# Makefile.in.in is renamed to Makefile.in-in.
+/ac_config_files=/,/_ACEOF/ {
+  s|po/Makefile\.in|&:po/Makefile.in-in|
+}
+/CONFIG_FILES=/ s|po/Makefile\.in|&:po/Makefile.in-in|2
+
+
+# We always use _deps and _libs instead of .deps and .libs, because
+# the latter is an invalid name on 8+3 MS-DOS filesystem.  This makes
+# the generated Makefiles good for every DJGPP installation, not only
+# the one where the package was configured (which could happen to be
+# a Windows box, where leading dots in file names are allowed).
+/^rmdir[       ]*\.tst/ i\
+am__leading_dot=_
+
+# Replace (command) > /dev/null with `command > /dev/null`, since
+# parenthesized commands always return zero status in the ported Bash,
+# even if the named command doesn't exist
+/if ([^|;`]*null/{
+  s,(,`,
+  s,),,
+  /null[       ]*2>&1/ s,2>&1,&`,
+  /null.*null/ s,null.*null,&`,
+  /null.*null/ !{
+    /null[     ]*2>&1/ !s,null,&`,
+  }
+}
+
+# DOS-style absolute file names should be supported as well
+/\*) top_srcdir=/s,/\*,[\\\\/]* | ?:[\\\\/]*,
+
+# The following two items are changes needed for configuring
+# and compiling across partitions.
+# 1) The given srcdir value is always translated from the
+#    "x:" syntax into "/dev/x" syntax while we run configure.
+/^[    ]*-srcdir=\*.*$/ a\
+    ac_optarg=`echo "$ac_optarg" | sed "s,^\\([A-Za-z]\\):,/dev/\\1,"`
+/set X `ls -Lt \$srcdir/ i\
+   if `echo $srcdir | grep "^/dev/" - > /dev/null`; then\
+     srcdir=`echo "$srcdir" | sed -e "s%^/dev/%%" -e "s%/%:/%"`\
+   fi
+
+# Autoconf 2.52e generated configure scripts
+# write absolute paths into Makefiles making
+# them useless for DJGPP installations for which
+# the package has not been configured for.
+/MISSING=/,/^$/ {
+  /^fi$/ a\
+am_missing_run=`echo "$am_missing_run" | sed 
's%/dev.*/grep[-_0-9]\\{1,1\\}[-.0-9A-z+]*%${top_srcdir}%;s%.:.*/grep[-_0-9]\\{1,1\\}[-.0-9A-z+]*%${top_srcdir}%'`
+}
+/^install_sh=/a\
+install_sh=`echo "$install_sh" | sed 
's%/dev.*/grep[-_0-9]\\{1,1\\}[-.0-9A-z+]*%${top_srcdir}%;s%.:.*/grep[-_0-9]\\{1,1\\}[-.0-9A-z+]*%${top_srcdir}%'`
+
+# This will only work if the assumption that the
+# testsuite is ran from the following path:
+#   ${top_srcdir}/tests/testsuite.dir
+# holds. The explicit names are of no importance.
+#   ../../. == ${top_srcdir}
+#/^esac$/,/^ac_abs_srcdir=/ {
+/^ac_abs_srcdir=/ i\
+ac_abs_builddir=`echo "$ac_abs_builddir" | sed 
"s%/dev/.*/grep[-_0-9]\\{1,1\\}[-.0-9A-Za-z+]*%../../.%;s%.:.*/grep[-_0-9]\\{1,1\\}[-.0-9A-Za-z+]*%../../.%"`\
+ac_abs_top_builddir=`echo "$ac_abs_top_builddir" | sed 
"s%/dev/.*/grep[-_0-9]\\{1,1\\}[-.0-9A-Za-z+]*%../../..%;s%.:.*/grep[-_0-9]\\{1,1\\}[-.0-9A-Za-z+]*%../../..%"`\
+ac_abs_top_srcdir=`echo "$ac_abs_top_srcdir" | sed 
"s%/dev/.*/grep[-_0-9]\\{1,1\\}[-.0-9A-Za-z+]*%../../..%;s%.:.*/grep[-_0-9]\\{1,1\\}[-.0-9A-Za-z+]*%../../..%"`
+#ac_abs_srcdir=`echo "$ac_abs_srcdir" | sed 
"s%/dev/.*/grep[-_0-9]\\{1,1\\}[-.0-9A-Za-z+]*%../../.%;s%.:.*/grep[-_0-9]\\{1,1\\}[-.0-9A-Za-z+]*%../../.%"`
+/^ac_abs_srcdir=/ a\
+for dj_dir in $ac_abs_builddir $ac_abs_top_builddir $ac_abs_top_srcdir 
$ac_abs_srcdir\
+do\
+  ac_abs_builddir=`echo "$ac_abs_builddir" | sed "s%//%/%g"`\
+  ac_abs_top_builddir=`echo "$ac_abs_top_builddir" | sed "s%//%/%g"`\
+  ac_abs_top_srcdir=`echo "$ac_abs_top_srcdir" | sed "s%//%/%g"`\
+  ac_abs_srcdir=`echo "$ac_abs_srcdir" | sed "s%//%/%g"`\
+done
+
+# Add DJGPP version information.
+/^#define VERSION/ s/\$VERSION/&  (DJGPP port (r1))/
+
+# We need makeinfo to make the html formated docs.
+/\$am_missing_run[     ]*makeinfo/ s,\$am_missing_run,,
+
+# The path to the FORTRAN compiler and libraries
+# shall contain no absolute path reference so it
+# will be good for all djgpp installations.
+/^FLIBS="\$ac_cv_flibs"/ i\
+ac_djgpp_path=`echo "$DJDIR" | sed 's%\\\\\\%/%g' | tr $as_cr_LETTERS 
$as_cr_letters`\
+ac_cv_flibs=`echo "$ac_cv_flibs" | sed "s%-L$ac_djgpp_path%-L/dev/env/DJDIR%g"`
+
+# Do not split info output.
+/^MAKEINFO=.*$/s:=.*$:&" --no-split":
+
+# Force the test for 'ln -s' to report 'cp -pf'.
+/^LN_S=\$as_ln_s$/ i\
+as_ln_s='cp -pf'
diff -aprNU5 grep-2.5.4.orig/djgpp/config.site grep-2.5.4/djgpp/config.site
--- grep-2.5.4.orig/djgpp/config.site   1970-01-01 00:00:00 +0000
+++ grep-2.5.4/djgpp/config.site        2008-01-22 16:49:40 +0000
@@ -0,0 +1,99 @@
+#! /bin/sh
+
+# This is the config.site file for configuring GNU packages
+# which are to be built with DJGPP tools.
+
+# Copyright (C) 2008 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+
+# Include the djgpp subdirectory in PATH, so that getconf is found
+PATH="$srcdir/djgpp:$PATH"
+
+# These two variables are required, otherwise looking for
+# programs along the PATH will not work.
+PATH_SEPARATOR=:
+PATH_EXPAND=y
+
+# This is required in for "test -f foo" to find foo.exe
+export TEST_FINDS_EXE=y
+
+# The root of the DJGPP tree serves as the default prefix
+test "x$prefix" = xNONE && prefix='/dev/env/DJDIR'
+
+# This is required for config.status script to be run, since
+# ./configure runs it by invoking ${CONFIG_SHELL-/bin/sh}
+CONFIG_SHELL=${CONFIG_SHELL='sh'}
+
+# These are set here so the generated Makefile's will be good
+# for every DJGPP installation, not only the one where the
+# package was configured.
+# $INSTALL must be an absolute path name, otherwise config.status
+# will try to prepend ./ and ../ to it when it goes into subdirs.
+INSTALL=${INSTALL='/dev/env/DJDIR/bin/ginstall -c'}
+RANLIB=${RANLIB='ranlib'}
+#GMSGFMT=${GMSGFMT='/dev/env/DJDIR/bin/msgfmt'}
+#MSGFMT=${MSGFMT='/dev/env/DJDIR/bin/msgfmt'}
+#XGETTEXT=${XGETTEXT='/dev/env/DJDIR/bin/xgettext'}
+AWK=${AWK='gawk'}
+
+# A sane default for emacs.
+ac_cv_path_EMACS=${EMACS='/dev/env/DJDIR/gnu/emacs/bin/emacs'}
+
+# A sane default for m4.
+ac_cv_path_M4=${M4='/dev/env/DJDIR/bin/m4'}
+
+# A sane default for grep.
+ac_cv_path_GREP=${GREP='/dev/env/DJDIR/bin/grep'}
+
+# A sane default for egrep.
+ac_cv_path_EGREP=${EGREP='/dev/env/DJDIR/bin/egrep'}
+
+# A sane default for fgrep.
+ac_cv_path_FGREP=${FGREP='/dev/env/DJDIR/bin/fgrep'}
+
+# A sane default for sed.
+ac_cv_path_SED=${SED='/dev/env/DJDIR/bin/sed'}
+
+# A sane default for mkdir.
+ac_cv_path_mkdir=${MKDIR_P='/dev/env/DJDIR/bin/mkdir -p'}
+
+# These are set here so the generated libtool will be good
+# for every DJGPP installation, not only the one where the
+# package was configured.
+NM=${NM='nm'}
+LD=${LD='ld'}
+
+# These are set here so the generated config.h will be good
+# for every DJGPP installation, not only the one where the
+# package was configured.
+gl_cv_absolute_stdint_h=${gl_cv_absolute_stdint_h='/dev/env/DJDIR/include/stdint.h'}
+gl_cv_absolute_string_h=${gl_cv_absolute_string_h='/dev/env/DJDIR/include/string.h'}
+gl_cv_absolute_sys_stat_h=${gl_cv_absolute_sys_stat_h='/dev/env/DJDIR/include/sys/stat.h'}
+gl_cv_absolute_sys_time_h=${gl_cv_absolute_sys_time_h='/dev/env/DJDIR/include/sys/time.h'}
+gl_cv_absolute_inttypes_h=${gl_cv_absolute_inttypes_h='/dev/env/DJDIR/include/inttypes.h'}
+gl_cv_absolute_unistd_h=${gl_cv_absolute_unistd_h='/dev/env/DJDIR/include/unistd.h'}
+gl_cv_absolute_wchar_h=${gl_cv_absolute_wchar_h='/dev/env/DJDIR/include/wchar.h'}
+gl_cv_absolute_wctype_h=${gl_cv_absolute_wctype_h='/dev/env/DJDIR/include/wctype.h'}
+gl_cv_absolute_stdlib_h=${gl_cv_absolute_stdlib_h='/dev/env/DJDIR/include/stdlib.h'}
+
+# Force the test for 'ln -s' to report 'cp -pf'.
+ac_cv_prog_LN_S='cp -pf'
+
+# There is no fork and vfork functionality.
+ac_cv_func_fork=no
+ac_cv_func_vfork=no
+ac_cv_func_pipe=no
diff -aprNU5 grep-2.5.4.orig/djgpp/isdir.sed grep-2.5.4/djgpp/isdir.sed
--- grep-2.5.4.orig/djgpp/isdir.sed     1970-01-01 00:00:00 +0000
+++ grep-2.5.4/djgpp/isdir.sed  2008-01-22 16:49:04 +0000
@@ -0,0 +1,39 @@
+# DJGPP specific editing file.
+# Sed script for additional DJGPP specific editing of lib/isdir.c
+
+# Copyright (C) 2008 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+
+/#include <sys\/types.h>/ i\
+#ifdef __DJGPP__\
+# include <unistd.h>\
+#endif
+
+/return stat/ {
+i\
+#ifdef __DJGPP__\
+  /*\
+   *  Computation of stat is very expensive.\
+   *  To determinate if PATH is an existing\
+   *  directory, access on DOS platforms is\
+   *  mostly a fast system call.\
+   */\
+  return (access (path, D_OK) == 0);\
+#else
+a\
+#endif
+}
diff -aprNU5 grep-2.5.4.orig/djgpp/readme.in grep-2.5.4/djgpp/readme.in
--- grep-2.5.4.orig/djgpp/readme.in     1970-01-01 00:00:00 +0000
+++ grep-2.5.4/djgpp/readme.in  2008-01-22 16:49:04 +0000
@@ -0,0 +1,136 @@
+This is a port of GNU grep @VERSION@ to MSDOS/DJGPP.
+
+Copyright (C) 2008 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software Foundation,
+Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+
+1.:     DJGPP specific changes.
+        =======================
+
+        When paths are checked to be directories, the code has been changed to
+        use access() instead of stat().  Due to amount of work that it is to
+        compute the stat of the file, using access() should give certain speed
+        improvement.
+        This port offers colorization support without requiring ANSI.SYS driver
+        (or its work-alike) to be loaded.  Because the colorization support is
+        implemented by writting to video ram there will be no color output if
+        the output is redirected to a file or a pipe.  Please read the documen-
+        tation to learn how the default colors used can be changed.
+
+        ATTENTION: When compiling this package do *not* follow the instructions
+        in README.DOS.  Do *not* try to use autoconf and automake to remake the
+        configure script and the Makefile.ins.  It is not needed and it will
+        not work.  Proceed as usual using the files provided in the /djgpp dir.
+
+        Please **read** the docs.
+
+
+2.:     Installing the binary package.
+        ==============================
+
+2.1.:   Copy the binary distribution into the top DJGPP installation directory,
+        just unzip it preserving the directory structure running *ONE* of the
+        following commands:
+          unzip32 address@hidden@b.zip      or
+          djtarx address@hidden@b.zip       or
+          pkunzip -d address@hidden@b.zip
+
+
+3.:     Building the binaries from sources.
+        ===================================
+
+3.1.:   Create a temporary directory and copy the source package into the
+        directory.  If you download the source distribution from one of the
+        DJGPP sites, just unzip it preserving the directory structure
+        running *ONE* of the following commands:
+          unzip32 address@hidden@s.zip      or
+          djtarx address@hidden@s.zip       or
+          pkunzip -d address@hidden@s.zip
+
+3.2.:   To build the binaries you will need the following binary packages:
+          djdev203.zip (or a later but NOT a prior version)
+          bsh204b.zip  (or a later but NOT a prior version)
+          gccNNNb.zip, gppNNN.zip, bnuNNNb.zip, makNNNb.zip, filNNNb.zip,
+          shlNNNb.zip, txtNNNb.zip, txiNNNb.zip, grepNNNb.zip, sedNNNb.zip.
+
+        If you want to run the check you will need also:
+          difNNNb.zip
+
+        NNN represents the latest version number of the binary packages.  All
+        this packages can be found in the /v2gnu directory of any
+        ftp.delorie.com mirror.
+        You will need bsh204b.zip or later and *NOT* a prior version or
+        the build will fail.  The same applies to djdev203.zip.
+
+3.3.:   If for some reason you want to reconfigure the package cd into the top
+        srcdir (address@hidden@) and run the following commands:
+          del djgpp\config.cache
+          make clean
+          djgpp\config
+
+        Please note that you *MUST* delete the config.cache file in the djgpp
+        subdir or you will not really reconfigure the sources because the
+        configuration informations will be read from the cache file instead
+        of being newly computed.
+        To build the programs in a directory other than where the sources are,
+        you must add the parameter that specifies the source directory,
+        e.g:
+          x:address@hidden@\djgpp\config x:/src/gnu/address@hidden@
+
+        Lets assume you want to build the binaries in a directory placed on a
+        different drive (z:\build in this case) from where the sources are,
+        then you will run the following commands:
+          z:
+          md \build
+          cd \build
+          x:address@hidden@\djgpp\config x:/src/gnu/address@hidden@
+
+        The order of the options and the srcdir option does not matter.  You
+        *MUST* use forward slashes to specify the source directory.
+
+        The batch file will set same environment variables, make MSDOS specific
+        modifications to the Makefile.in's and supply all other needed options
+        to the configure script.
+
+3.4.:   To compile the package run from the top srcdir the command:
+          make
+
+3.5.:   Now you can run the tests if you like.  From the top srcdir run the
+        command:
+          make check
+
+        No test should fail.
+
+3.6.:   To install the binaries, and info docs run the following command from
+        the top srcdir:
+          make install
+
+        This will install the products into your DJGPP installation tree given
+        by the default prefix "/dev/env/DJDIR".  If you prefer to install them
+        into some other directory you will have to set prefix to the appropiate
+        value:
+          make install prefix=z:/some/other/place
+
+
+
+        Send GNU grep specific bug reports to <address@hidden>.
+        Send suggestions and bug reports concerning the DJGPP port to
+        comp.os.msdos.djgpp or <address@hidden>.
+
+
+Enjoy.
+
+        Guerrero, Juan Manuel <address@hidden>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]