home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 22 gnu
/
22-gnu.zip
/
gnufind.zip
/
patches.os2
< prev
next >
Wrap
Text File
|
1996-04-20
|
25KB
|
965 lines
Only in new: exe
Only in new: Makefile.os2
Only in new: patches.os2
Only in new: config.h
Only in new/lib: gnufind.def
Only in new/lib: gnuregex.def
Only in new/lib: Makefile.os2
Only in new/find: Makefile.os2
Only in new/locate: Makefile.os2
Only in new/xargs: Makefile.os2
diff -cbr orig/find/find.c new/find/find.c
*** orig/find/find.c Wed Oct 12 22:21:10 1994
--- new/find/find.c Mon Jan 01 19:41:10 1996
***************
*** 34,39 ****
--- 34,43 ----
#include "defs.h"
#include "modetype.h"
+ #ifdef OS2
+ #define chdir(p) _chdir2(p)
+ #endif
+
#ifndef S_IFLNK
#define lstat stat
#endif
***************
*** 131,136 ****
--- 135,160 ----
}
#endif /* DEBUG_STAT */
+ #ifdef OS2
+ #include <sys/dir.h>
+ static int
+ os2_stat (file, bufp)
+ char *file;
+ struct stat *bufp;
+ {
+ int rc = stat(file, bufp);
+ bufp->st_mode &= ~S_IRWXO;
+ if (bufp->st_attr & A_HIDDEN)
+ bufp->st_mode |= S_IROTH;
+ if (bufp->st_attr & A_SYSTEM)
+ bufp->st_mode |= S_IWOTH;
+ if (bufp->st_attr & A_ARCHIVE)
+ bufp->st_mode |= S_IXOTH;
+ return rc;
+ }
+ #endif
+
+
void
main (argc, argv)
int argc;
***************
*** 142,147 ****
--- 166,174 ----
char *predicate_name; /* Name of predicate being parsed. */
program_name = argv[0];
+ #ifdef __EMX__
+ os2init(&argc, &argv);
+ #endif
predicates = NULL;
last_pred = NULL;
***************
*** 156,168 ****
--- 183,202 ----
#ifdef DEBUG_STAT
xstat = debug_stat;
#else /* !DEBUG_STAT */
+ #ifdef OS2
+ xstat = os2_stat;
+ #else
xstat = lstat;
+ #endif
#endif /* !DEBUG_STAT */
#ifdef DEBUG
printf ("cur_day_start = %s", ctime (&cur_day_start));
#endif /* DEBUG */
+ if ( argc == 1 )
+ usage(NULL);
+
/* Find where in ARGV the predicates begin. */
for (i = 1; i < argc && strchr ("-!(),", argv[i][0]) == NULL; i++)
/* Do nothing. */ ;
***************
*** 447,453 ****
--- 481,493 ----
register unsigned file_len; /* Length of each path to process. */
register unsigned pathname_len; /* PATHLEN plus trailing '/'. */
+ #ifdef OS2
+ if (!strcmp (pathname + 1, ":/") || !strcmp (pathname + 1, ":\\"))
+ pathname_len = 4;
+ else if (pathname[pathlen - 1] == '/' || pathname[pathlen - 1] == '\\')
+ #else
if (pathname[pathlen - 1] == '/')
+ #endif
pathname_len = pathlen + 1; /* For '\0'; already have '/'. */
else
pathname_len = pathlen + 2; /* For '/' and '\0'. */
diff -cbr orig/find/parser.c new/find/parser.c
*** orig/find/parser.c Wed Nov 02 21:59:18 1994
--- new/find/parser.c Mon Jan 01 20:47:50 1996
***************
*** 573,578 ****
--- 573,581 ----
char *argv[];
int *arg_ptr;
{
+ #ifdef OS2
+ return (false);
+ #else
struct group *cur_gr;
struct predicate *our_pred;
gid_t gid;
***************
*** 595,600 ****
--- 598,604 ----
our_pred->args.gid = gid;
(*arg_ptr)++;
return (true);
+ #endif
}
static boolean
***************
*** 602,612 ****
char *argv[];
int *arg_ptr;
{
printf ("\
Usage: %s [path...] [expression]\n", program_name);
! printf ("\
default path is the current directory; default expression is -print\n\
! expression may consist of:\n\
operators (decreasing precedence; -and is implicit where no others are given):\n\
( EXPR ) ! EXPR -not EXPR EXPR1 -a EXPR2 EXPR1 -and EXPR2\n");
printf ("\
--- 606,618 ----
char *argv[];
int *arg_ptr;
{
+ extern char *version_string;
+ printf ("\nGNU find version %s\n\n", version_string);
printf ("\
Usage: %s [path...] [expression]\n", program_name);
! printf ("\n\
default path is the current directory; default expression is -print\n\
! expression may consist of:\n\n\
operators (decreasing precedence; -and is implicit where no others are given):\n\
( EXPR ) ! EXPR -not EXPR EXPR1 -a EXPR2 EXPR1 -and EXPR2\n");
printf ("\
***************
*** 1272,1277 ****
--- 1278,1286 ----
char *argv[];
int *arg_ptr;
{
+ #ifdef OS2
+ return (false);
+ #else
struct passwd *cur_pwd;
struct predicate *our_pred;
uid_t uid;
***************
*** 1294,1299 ****
--- 1303,1309 ----
our_pred->args.uid = uid;
(*arg_ptr)++;
return (true);
+ #endif
}
static boolean
***************
*** 1339,1347 ****
--- 1349,1359 ----
return (false);
switch (argv[*arg_ptr][0])
{
+ #ifndef OS2
case 'b': /* block special */
type_cell = S_IFBLK;
break;
+ #endif
case 'c': /* character special */
type_cell = S_IFCHR;
break;
diff -cbr orig/find/pred.c new/find/pred.c
*** orig/find/pred.c Wed Nov 02 21:59:22 1994
--- new/find/pred.c Mon Jan 01 14:15:34 1996
***************
*** 27,32 ****
--- 27,37 ----
#include "modetype.h"
#include "wait.h"
+ #ifdef OS2
+ #include <process.h>
+ #define chdir(p) _chdir2(p)
+ #endif
+
#if !defined(SIGCHLD) && defined(SIGCLD)
#define SIGCHLD SIGCLD
#endif
***************
*** 69,75 ****
(including indirect blocks).
HP-UX, perhaps uniquely, counts st_blocks in 1024-byte units.
This workaround loses when mixing HP-UX and 4BSD filesystems, though. */
! #ifdef _POSIX_SOURCE
# define ST_NBLOCKS(statp) (((statp)->st_size + 512 - 1) / 512)
#else
# ifndef HAVE_ST_BLOCKS
--- 74,80 ----
(including indirect blocks).
HP-UX, perhaps uniquely, counts st_blocks in 1024-byte units.
This workaround loses when mixing HP-UX and 4BSD filesystems, though. */
! #if defined(_POSIX_SOURCE) || defined(OS2)
# define ST_NBLOCKS(statp) (((statp)->st_size + 512 - 1) / 512)
#else
# ifndef HAVE_ST_BLOCKS
***************
*** 432,437 ****
--- 437,445 ----
int path_pos;
struct exec_val *execp; /* Pointer for efficiency. */
+ if ( strncmp(pathname, "./", 2) == 0 )
+ pathname += 2;
+
execp = &pred_ptr->args.exec_vec;
/* Replace "{}" with the real path in each affected arg. */
***************
*** 578,583 ****
--- 586,592 ----
filesystem_type (pathname, rel_pathname, stat_buf));
break;
case 'g': /* group name */
+ #ifndef OS2
{
struct group *g;
***************
*** 590,595 ****
--- 599,605 ----
}
/* else fallthru */
}
+ #endif
case 'G': /* GID number */
segment->text[segment->text_len] = 'u';
fprintf (fp, segment->text, stat_buf->st_gid);
***************
*** 676,681 ****
--- 686,692 ----
fprintf (fp, segment->text, cp);
break;
case 'u': /* user name */
+ #ifndef OS2
{
struct passwd *p;
***************
*** 688,693 ****
--- 699,705 ----
}
/* else fallthru */
}
+ #endif
case 'U': /* UID number */
segment->text[segment->text_len] = 'u';
fprintf (fp, segment->text, stat_buf->st_uid);
***************
*** 978,985 ****
--- 990,1001 ----
return gid_unused[(unsigned) stat_buf->st_gid];
#else
+ #ifdef OS2
+ return 1;
+ #else
return getgrgid (stat_buf->st_gid) == NULL;
#endif
+ #endif
}
boolean
***************
*** 993,1000 ****
--- 1009,1020 ----
return uid_unused[(unsigned) stat_buf->st_uid];
#else
+ #ifdef OS2
+ return 1;
+ #else
return getpwuid (stat_buf->st_uid) == NULL;
#endif
+ #endif
}
boolean
***************
*** 1102,1108 ****
struct stat *stat_buf;
struct predicate *pred_ptr;
{
! puts (pathname);
return (true);
}
--- 1122,1128 ----
struct stat *stat_buf;
struct predicate *pred_ptr;
{
! puts (strncmp(pathname, "./", 2) == 0 ? pathname + 2 : pathname);
return (true);
}
***************
*** 1112,1118 ****
struct stat *stat_buf;
struct predicate *pred_ptr;
{
! fputs (pathname, stdout);
putc (0, stdout);
return (true);
}
--- 1132,1138 ----
struct stat *stat_buf;
struct predicate *pred_ptr;
{
! fputs (strncmp(pathname, "./", 2) == 0 ? pathname + 2 : pathname, stdout);
putc (0, stdout);
return (true);
}
***************
*** 1319,1324 ****
--- 1339,1390 ----
launch (pred_ptr)
struct predicate *pred_ptr;
{
+ #ifdef OS2
+ int status, arg;
+ char *buf;
+ struct exec_val *execp; /* Pointer for efficiency. */
+ char *current_dir;
+
+ execp = &pred_ptr->args.exec_vec;
+
+ /* Make sure output of command doesn't get mixed with find output. */
+ fflush (stdout);
+ fflush (stderr);
+
+ current_dir = xgetcwd ();
+ if (current_dir == NULL)
+ {
+ error (1, errno, "cannot get current directory");
+ _exit (1);
+ }
+
+ if (chdir (starting_dir) < 0)
+ {
+ error (0, errno, "%s", starting_dir);
+ _exit (1);
+ }
+
+ if ((status = spawnvp(P_WAIT, execp->vec[0], execp->vec)) == -1)
+ {
+ buf = malloc(32768);
+ buf[0] = 0;
+
+ for (arg = 0; execp->vec[arg] != NULL; arg++)
+ strcat(strcat(buf, execp->vec[arg]), " ");
+
+ status = system(buf);
+
+ free(buf);
+ }
+
+ if (chdir (current_dir) < 0)
+ {
+ error (0, errno, "%s", current_dir);
+ _exit (1);
+ }
+
+ return (status == 0);
+ #else
int status;
pid_t wait_ret, child_pid;
struct exec_val *execp; /* Pointer for efficiency. */
***************
*** 1389,1394 ****
--- 1455,1461 ----
return (false);
}
return (!WEXITSTATUS (status));
+ #endif
}
/* Return a static string formatting the time WHEN according to the
diff -cbr orig/find/util.c new/find/util.c
*** orig/find/util.c Thu Oct 20 05:49:46 1994
--- new/find/util.c Mon Jan 01 20:47:34 1996
***************
*** 150,158 ****
--- 150,161 ----
usage (msg)
char *msg;
{
+ extern char *version_string;
if (msg)
fprintf (stderr, "%s: %s\n", program_name, msg);
+ fprintf (stderr, "\nGNU find %s\n\n", version_string);
fprintf (stderr, "\
Usage: %s [path...] [expression]\n", program_name);
+ fprintf (stderr, "\nUse --help to get a short description.\n");
exit (1);
}
diff -cbr orig/lib/filemode.c new/lib/filemode.c
*** orig/lib/filemode.c Sun Oct 02 00:34:34 1994
--- new/lib/filemode.c Mon Jan 01 21:08:12 1996
***************
*** 122,127 ****
--- 122,139 ----
/* Like filemodestring, but only the relevant part of the `struct stat'
is given as an argument. */
+ #ifdef OS2
+ static void
+ hsa (bits, chars)
+ unsigned short bits;
+ char *chars;
+ {
+ chars[0] = (bits & S_IREAD) ? 'h' : '-';
+ chars[1] = (bits & S_IWRITE) ? 's' : '-';
+ chars[2] = (bits & S_IEXEC) ? 'a' : '-';
+ }
+ #endif
+
void
mode_string (mode, str)
unsigned short mode;
***************
*** 130,136 ****
--- 142,152 ----
str[0] = ftypelet ((long) mode);
rwx ((mode & 0700) << 0, &str[1]);
rwx ((mode & 0070) << 3, &str[4]);
+ #ifdef OS2
+ hsa ((mode & 0007) << 6, &str[7]);
+ #else
rwx ((mode & 0007) << 6, &str[7]);
+ #endif
setst (mode, str);
}
diff -cbr orig/lib/listfile.c new/lib/listfile.c
*** orig/lib/listfile.c Wed Nov 02 21:59:24 1994
--- new/lib/listfile.c Mon Jan 01 14:40:04 1996
***************
*** 75,81 ****
(including indirect blocks).
HP-UX, perhaps uniquely, counts st_blocks in 1024-byte units.
This workaround loses when mixing HP-UX and 4BSD filesystems, though. */
! #ifdef _POSIX_SOURCE
# define ST_NBLOCKS(statp) (((statp)->st_size + 512 - 1) / 512)
#else
# ifndef HAVE_ST_BLOCKS
--- 75,81 ----
(including indirect blocks).
HP-UX, perhaps uniquely, counts st_blocks in 1024-byte units.
This workaround loses when mixing HP-UX and 4BSD filesystems, though. */
! #if defined(_POSIX_SOURCE) || defined(OS2)
# define ST_NBLOCKS(statp) (((statp)->st_size + 512 - 1) / 512)
#else
# ifndef HAVE_ST_BLOCKS
***************
*** 153,158 ****
--- 153,163 ----
}
timebuf[16] = 0;
+ #ifdef OS2
+ fprintf (stream, "%s ", modebuf);
+
+ fprintf (stream, "%4u ", convert_blocks (ST_NBLOCKS (statp), kilobytes));
+ #else
fprintf (stream, "%6lu ", statp->st_ino);
fprintf (stream, "%4u ", convert_blocks (ST_NBLOCKS (statp), kilobytes));
***************
*** 172,181 ****
--- 177,192 ----
fprintf (stream, " ");
#endif
else
+ #endif
fprintf (stream, "%8lu ", statp->st_size);
fprintf (stream, "%s ", timebuf + 4);
+ #ifdef OS2
+ if (strncmp(name, "./", 2) == 0)
+ name += 2;
+ #endif
+
print_name_with_quoting (name, stream);
#ifdef S_ISLNK
***************
*** 205,213 ****
--- 216,226 ----
{
switch (c)
{
+ #ifndef OS2
case '\\':
fprintf (stream, "\\\\");
break;
+ #endif
case '\n':
fprintf (stream, "\\n");
***************
*** 238,244 ****
--- 251,261 ----
break;
default:
+ #ifdef OS2
+ if (c > 040 && c < 0377 && c != 0177)
+ #else
if (c > 040 && c < 0177)
+ #endif
putc (c, stream);
else
fprintf (stream, "\\%03o", (unsigned int) c);
diff -cbr orig/lib/modechange.c new/lib/modechange.c
*** orig/lib/modechange.c Fri Oct 07 18:21:32 1994
--- new/lib/modechange.c Mon Jan 01 20:57:24 1996
***************
*** 191,200 ****
--- 191,215 ----
case 'x':
change->value |= 00111 & affected_masked;
break;
+ #ifdef OS2
+ case 'h':
+ /* Set the other/r bit, i.e. OS/2's "hidden". */
+ change->value |= 00004;
+ break;
+ case 's':
+ /* Set the other/w bit, i.e. OS/2's "system". */
+ change->value |= 00002;
+ break;
+ case 'a':
+ /* Set the other/x bit, i.e. OS/2's "archive". */
+ change->value |= 00001;
+ break;
+ #else
case 's':
/* Set the setuid/gid bits if `u' or `g' is selected. */
change->value |= 06000 & affected_masked;
break;
+ #endif
case 't':
/* Set the "save text image" bit if `o' is selected. */
change->value |= 01000 & affected_masked;
diff -cbr orig/lib/nextelem.c new/lib/nextelem.c
*** orig/lib/nextelem.c Tue Sep 27 14:02:44 1994
--- new/lib/nextelem.c Mon Jan 01 11:45:40 1996
***************
*** 73,79 ****
--- 73,83 ----
start = end;
final_colon = 1; /* Maybe there will be one. */
+ #ifdef OS2
+ end = strchr (start, ';');
+ #else
end = strchr (start, ':');
+ #endif
if (end == start)
{
/* An empty path element. */
diff -cbr orig/lib/regex.h new/lib/regex.h
*** orig/lib/regex.h Wed Oct 26 23:43:44 1994
--- new/lib/regex.h Mon Jan 01 20:06:10 1996
***************
*** 1,3 ****
--- 1,5 ----
+ #define _REGEX_RE_COMP
+
/* Definitions for data structures and routines for the regular
expression library, version 0.12.
diff -cbr orig/lib/savedir.c new/lib/savedir.c
*** orig/lib/savedir.c Fri Oct 07 18:21:34 1994
--- new/lib/savedir.c Mon Jan 01 11:20:26 1996
***************
*** 115,121 ****
closedir (dirp);
return NULL;
}
! namep += new_name_space - name_space;
name_space = new_name_space;
}
namep = stpcpy (namep, dp->d_name) + 1;
--- 115,123 ----
closedir (dirp);
return NULL;
}
! /* namep += new_name_space - name_space; */
! /* previous statement assumes nonsegmented address space */
! /* better: */ namep = new_name_space + (namep - name_space);
name_space = new_name_space;
}
namep = stpcpy (namep, dp->d_name) + 1;
diff -cbr orig/lib/version.c new/lib/version.c
*** orig/lib/version.c Fri Nov 04 05:19:16 1994
--- new/lib/version.c Mon Jan 01 20:47:06 1996
***************
*** 1 ****
--- 1,20 ----
char *version_string = "4.1";
+
+ #ifdef __EMX__
+
+ #include <stdio.h>
+ #include <sys/nls.h>
+
+ char *program_name;
+
+ void os2init(int *pargc, char ***pargv)
+ {
+ _response(pargc, pargv);
+ /* _wildcard(pargc, pargv); */
+ program_name = **pargv;
+ setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
+ _nls_init();
+ }
+
+ #endif
+
diff -cbr orig/lib/xgetcwd.c new/lib/xgetcwd.c
*** orig/lib/xgetcwd.c Tue Sep 27 14:02:46 1994
--- new/lib/xgetcwd.c Mon Jan 01 14:14:48 1996
***************
*** 36,41 ****
--- 36,45 ----
char *getcwd ();
#endif
+ #ifdef OS2
+ #define getcwd(b, s) _getcwd2(b, s)
+ #endif
+
/* Amount to increase buffer size by in each try. */
#define PATH_INCR 32
diff -cbr orig/locate/bigram.c new/locate/bigram.c
*** orig/locate/bigram.c Fri Oct 07 18:21:34 1994
--- new/locate/bigram.c Mon Jan 01 20:48:04 1996
***************
*** 81,86 ****
--- 81,99 ----
prefix count to 0. */
strcpy (oldpath, " ");
+ if (isatty(0))
+ {
+ extern char *version_string;
+ fprintf (stderr, "\nGNU locate/bigram %s\n"
+ "\nUsage: %s common_bigrams < list > coded_list\n",
+ version_string, program_name);
+ exit (2);
+ }
+
+ #ifdef __EMX__
+ os2init(&argc, &argv);
+ #endif
+
while ((line_len = getstr (&path, &pathsize, stdin, '\n', 0)) > 0)
{
register int count; /* The prefix length. */
diff -cbr orig/locate/code.c new/locate/code.c
*** orig/locate/code.c Mon Sep 26 23:06:08 1994
--- new/locate/code.c Mon Jan 01 20:48:14 1996
***************
*** 120,127 ****
--- 120,133 ----
bigram[2] = '\0';
+ #ifdef __EMX__
+ os2init(&argc, &argv);
+ #endif
+
if (argc != 2)
{
+ extern char *version_string;
+ fprintf (stderr, "\nGNU locate/code %s\n\n", version_string);
fprintf (stderr, "Usage: %s most_common_bigrams < list > coded_list\n",
argv[0]);
exit (2);
diff -cbr orig/locate/frcode.c new/locate/frcode.c
*** orig/locate/frcode.c Mon Sep 26 23:06:10 1994
--- new/locate/frcode.c Mon Jan 01 20:48:18 1996
***************
*** 119,124 ****
--- 119,137 ----
program_name = argv[0];
+ if (isatty(0))
+ {
+ extern char *version_string;
+ fprintf (stderr, "\nGNU locate/frcode %s\n"
+ "\nUsage: %s < sorted-list > compressed-list\n",
+ version_string, program_name);
+ exit (2);
+ }
+
+ #ifdef __EMX__
+ os2init(&argc, &argv);
+ #endif
+
pathsize = oldpathsize = 1026; /* Increased as necessary by getstr. */
path = xmalloc (pathsize);
oldpath = xmalloc (oldpathsize);
diff -cbr orig/locate/locate.c new/locate/locate.c
*** orig/locate/locate.c Mon Sep 26 23:06:14 1994
--- new/locate/locate.c Mon Jan 01 20:48:24 1996
***************
*** 78,83 ****
--- 78,90 ----
extern int errno;
#endif
+ #ifdef OS2
+ #include <sys/nls.h>
+ #define MAPCHAR(c) _nls_tolower(c)
+ #else
+ #define MAPCHAR(c) (c)
+ #endif
+
#include "locatedb.h"
typedef enum {false, true} boolean;
***************
*** 294,305 ****
in PATHPART. */
for (prev_fast_match = false; s >= cutoff; s--)
/* Fast first char check. */
! if (*s == *patend)
{
char *s2; /* Scan the path we read in. */
register char *p2; /* Scan `patend'. */
! for (s2 = s - 1, p2 = patend - 1; *p2 != '\0' && *s2 == *p2;
s2--, p2--)
;
if (*p2 == '\0')
--- 301,313 ----
in PATHPART. */
for (prev_fast_match = false; s >= cutoff; s--)
/* Fast first char check. */
! if (MAPCHAR(*s) == MAPCHAR(*patend))
{
char *s2; /* Scan the path we read in. */
register char *p2; /* Scan `patend'. */
! for (s2 = s - 1, p2 = patend - 1;
! *p2 != '\0' && MAPCHAR(*s2) == MAPCHAR(*p2);
s2--, p2--)
;
if (*p2 == '\0')
***************
*** 341,346 ****
--- 349,356 ----
FILE *stream;
int status;
{
+ extern char *version_string;
+ fprintf (stream, "\nGNU locate %s\n\n", version_string);
fprintf (stream, "\
Usage: %s [-d path] [--database=path] [--version] [--help] pattern...\n",
program_name);
***************
*** 362,367 ****
--- 372,381 ----
{
char *dbpath;
int found = 0, optc;
+
+ #ifdef __EMX__
+ os2init(&argc, &argv);
+ #endif
program_name = argv[0];
diff -cbr orig/xargs/xargs.c new/xargs/xargs.c
*** orig/xargs/xargs.c Fri Oct 07 18:21:38 1994
--- new/xargs/xargs.c Mon Jan 01 20:48:42 1996
***************
*** 81,86 ****
--- 81,95 ----
#define SIGCHLD SIGCLD
#endif
+ #ifdef OS2
+ #include <process.h>
+ #define ARG_MAX (31*1024)
+ #define CMD_EXE_LIMIT 1024
+ #define CONSOLE "con"
+ #else
+ #define CONSOLE "/dev/tty"
+ #endif
+
/* COMPAT: SYSV version defaults size (and has a max value of) to 470.
We try to make it as large as possible. */
#if !defined(ARG_MAX) && defined(_SC_ARG_MAX)
***************
*** 112,118 ****
--- 121,129 ----
/* Return nonzero if S is the EOF string. */
#define EOF_STR(s) (eof_str && *eof_str == *s && !strcmp (eof_str, s))
+ #ifndef OS2
extern char **environ;
+ #endif
/* Not char because of type promotion; NeXT gcc can't handle it. */
typedef int boolean;
***************
*** 256,265 ****
--- 267,283 ----
int optc;
int always_run_command = 1;
long orig_arg_max;
+ #ifdef OS2
+ char *default_cmd = "echo";
+ #else
char *default_cmd = "/bin/echo";
+ #endif
int (*read_args) P_ ((void)) = read_line;
program_name = argv[0];
+ #ifdef __EMX__
+ os2init(&argc, &argv);
+ #endif
orig_arg_max = ARG_MAX - 2048; /* POSIX.2 requires subtracting 2048. */
arg_max = orig_arg_max;
***************
*** 359,364 ****
--- 377,387 ----
if (replace_pat || lines_per_exec)
exit_if_size_exceeded = true;
+ #ifdef OS2
+ if ( isatty(fileno(stdin)) )
+ usage(stdout, 0);
+ #endif
+
if (optind == argc)
{
optind = 0;
***************
*** 717,725 ****
if (!tty_stream)
{
! tty_stream = fopen ("/dev/tty", "r");
if (!tty_stream)
! error (1, errno, "/dev/tty");
}
fputs ("?...", stderr);
fflush (stderr);
--- 740,748 ----
if (!tty_stream)
{
! tty_stream = fopen (CONSOLE, "r");
if (!tty_stream)
! error (1, errno, CONSOLE);
}
fputs ("?...", stderr);
fflush (stderr);
***************
*** 750,755 ****
--- 773,814 ----
wait_for_proc (false);
if (!query_before_executing && print_command)
print_args (false);
+ #ifdef OS2
+ if ( (child = spawnvp (P_NOWAIT, cmd_argv[0], cmd_argv)) == -1 )
+ {
+ char **new_argv;
+ int new_argc, new_ncargs, cnt;
+ char msg[256];
+
+ new_argc = cmd_argc + 2;
+ new_argv = (char **)
+ xmalloc ((unsigned) (sizeof (char *) * (new_argc + 1)));
+ new_argv[0] = getenv("COMSPEC");
+ new_argv[1] = "/c";
+ memcpy ((char *) (new_argv + 2), (char *) cmd_argv,
+ sizeof (char *) * (cmd_argc + 1));
+
+ for (cnt = 0, new_ncargs = 0;
+ cnt < new_argc && new_argv[cnt];
+ cnt++ )
+ new_ncargs += strlen (new_argv[cnt]);
+
+ if ( new_ncargs > CMD_EXE_LIMIT )
+ {
+ sprintf(msg, "\tcommand line for CMD.EXE longer than %d characters\n"
+ "\tuse the \"-s %d\" option", CMD_EXE_LIMIT, CMD_EXE_LIMIT);
+ error (1, 0, msg);
+ }
+
+ if ( (child = spawnvp (P_NOWAIT, new_argv[0], new_argv)) == -1 )
+ error (1, errno, "cannot spawn");
+
+ free (new_argv);
+ }
+
+ if ( _osmode != DOS_MODE )
+ add_proc (child);
+ #else
/* If we run out of processes, wait for a child to return and
try again. */
while ((child = fork ()) < 0 && errno == EAGAIN && procs_executing)
***************
*** 765,770 ****
--- 824,830 ----
_exit (errno == ENOENT ? 127 : 126);
}
add_proc (child);
+ #endif
}
cmd_argc = initial_argc;
***************
*** 906,911 ****
--- 966,973 ----
FILE *stream;
int status;
{
+ extern char *version_string;
+ fprintf (stream, "\nGNU xargs %s\n\n", version_string);
fprintf (stream, "\
Usage: %s [-0prtx] [-e[eof-str]] [-i[replace-str]] [-l[max-lines]]\n\
[-n max-args] [-s max-chars] [-P max-procs] [--null] [--eof[=eof-str]]\n\