Only in new: patches.os2 Only in new: Makefile Only in new/find: Makefile Only in new/xargs: Makefile Only in new/locate: Makefile Only in new/lib: Makefile Only in new/lib: dllmain.c Only in new/lib: find.def Only in new/lib: gnufind.def Only in new/lib: gnuregex.def diff -cbr orig/find/find.c new/find/find.c *** orig/find/find.c Fri Mar 26 23:23:00 1993 --- new/find/find.c Sat Apr 03 12:54:26 1993 *************** *** 124,129 **** --- 124,132 ---- char *predicate_name; /* Name of predicate being parsed. */ program_name = argv[0]; + #ifdef __EMX__ + os2init(&argc, &argv); + #endif predicates = NULL; last_pred = NULL; *************** *** 144,149 **** --- 147,155 ---- 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 && index ("-!(),", argv[i][0]) == NULL; i++) /* Do nothing. */ ; *************** *** 339,345 **** --- 345,357 ---- 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 Fri Mar 26 23:44:20 1993 --- new/find/parser.c Sat Apr 03 12:54:26 1993 *************** *** 19,26 **** --- 19,28 ---- #include #include #include + #ifndef OS2 #include #include + #endif #ifndef isascii #define isascii(c) 1 *************** *** 606,611 **** --- 608,616 ---- char *argv[]; int *arg_ptr; { + #ifdef OS2 + return (false); + #else struct group *cur_gr; struct predicate *our_pred; int gid, gid_len; *************** *** 627,632 **** --- 632,638 ---- our_pred->args.gid = (short) gid; (*arg_ptr)++; return (true); + #endif } static boolean *************** *** 1263,1268 **** --- 1269,1277 ---- char *argv[]; int *arg_ptr; { + #ifdef OS2 + return (false); + #else struct passwd *cur_pwd; struct predicate *our_pred; int uid, uid_len; *************** *** 1284,1289 **** --- 1293,1299 ---- our_pred->args.uid = (short) uid; (*arg_ptr)++; return (true); + #endif } static boolean *************** *** 1330,1338 **** --- 1340,1350 ---- 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 Fri Mar 26 23:54:04 1993 --- new/find/pred.c Sun Apr 04 00:28:12 1993 *************** *** 24,40 **** #include #endif #include #include - #ifndef _POSIX_VERSION struct passwd *getpwuid (); struct group *getgrgid (); #endif #include "defs.h" #include "modetype.h" #include "wait.h" #if defined(DIRENT) || defined(_POSIX_VERSION) #include --- 24,46 ---- #include #endif + #ifndef OS2 #include #include #ifndef _POSIX_VERSION struct passwd *getpwuid (); struct group *getgrgid (); #endif + #endif + #include "defs.h" #include "modetype.h" + #ifdef OS2 + #include + #else #include "wait.h" + #endif #if defined(DIRENT) || defined(_POSIX_VERSION) #include *************** *** 67,73 **** /* Extract or fake data from a `struct stat'. ST_NBLOCKS: Number of 512-byte blocks in the file (including indirect blocks). */ ! #ifdef _POSIX_SOURCE #define ST_NBLOCKS(statp) (((statp)->st_size + 512 - 1) / 512) #else /* !_POSIX_SOURCE */ #ifndef HAVE_ST_BLOCKS --- 73,79 ---- /* Extract or fake data from a `struct stat'. ST_NBLOCKS: Number of 512-byte blocks in the file (including indirect blocks). */ ! #if defined(_POSIX_SOURCE) || defined(OS2) #define ST_NBLOCKS(statp) (((statp)->st_size + 512 - 1) / 512) #else /* !_POSIX_SOURCE */ #ifndef HAVE_ST_BLOCKS *************** *** 497,502 **** --- 503,511 ---- 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. */ *************** *** 629,634 **** --- 638,644 ---- fprintf (fp, segment->text, filesystem_type (pathname, stat_buf)); break; case 'g': /* group name */ + #ifndef OS2 { struct group *g; *************** *** 641,646 **** --- 651,657 ---- } /* else fallthru */ } + #endif case 'G': /* GID number */ segment->text[segment->text_len] = 'u'; fprintf (fp, segment->text, stat_buf->st_gid); *************** *** 733,738 **** --- 744,750 ---- fprintf (fp, segment->text, cp); break; case 'u': /* user name */ + #ifndef OS2 { struct passwd *p; *************** *** 745,750 **** --- 757,763 ---- } /* else fallthru */ } + #endif case 'U': /* UID number */ segment->text[segment->text_len] = 'u'; fprintf (fp, segment->text, stat_buf->st_uid); *************** *** 932,938 **** struct stat *stat_buf; struct predicate *pred_ptr; { ! list_file (pathname, stat_buf); return (true); } --- 945,951 ---- struct stat *stat_buf; struct predicate *pred_ptr; { ! list_file (strncmp(pathname, "./", 2) == 0 ? pathname + 2 : pathname, stat_buf); return (true); } *************** *** 1045,1052 **** --- 1058,1069 ---- return gid_unused[(unsigned) stat_buf->st_gid]; #else + #ifdef OS2 + return 1; + #else return getgrgid (stat_buf->st_gid) == NULL; #endif + #endif } boolean *************** *** 1060,1067 **** --- 1077,1088 ---- return uid_unused[(unsigned) stat_buf->st_uid]; #else + #ifdef OS2 + return 1; + #else return getpwuid (stat_buf->st_uid) == NULL; #endif + #endif } boolean *************** *** 1170,1176 **** struct stat *stat_buf; struct predicate *pred_ptr; { ! puts (pathname); return (true); } --- 1191,1197 ---- struct stat *stat_buf; struct predicate *pred_ptr; { ! puts (strncmp(pathname, "./", 2) == 0 ? pathname + 2 : pathname); return (true); } *************** *** 1180,1186 **** struct stat *stat_buf; struct predicate *pred_ptr; { ! fputs (pathname, stdout); putc (0, stdout); return (true); } --- 1201,1207 ---- struct stat *stat_buf; struct predicate *pred_ptr; { ! fputs (strncmp(pathname, "./", 2) == 0 ? pathname + 2 : pathname, stdout); putc (0, stdout); return (true); } *************** *** 1387,1392 **** --- 1408,1438 ---- launch (pred_ptr) struct predicate *pred_ptr; { + #ifdef OS2 + int rc, arg; + char *buf; + extern char *getenv(); + + if ( (rc = spawnvp(P_WAIT, pred_ptr->args.exec_vec.vec[0], + pred_ptr->args.exec_vec.vec)) == -1 ) + { + buf = malloc(2048); + buf[0] = 0; + + for ( arg = 0; pred_ptr->args.exec_vec.vec[arg] != NULL; arg++ ) + { + strcat(buf, pred_ptr->args.exec_vec.vec[arg]); + strcat(buf, " "); + } + + rc = system(buf); + free(buf); + + return rc; + } + else + return rc; + #else int status, wait_ret, child_pid; struct exec_val *execp; /* Pointer for efficiency. */ *************** *** 1439,1444 **** --- 1485,1491 ---- 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 Fri Mar 26 03:06:10 1993 --- new/find/util.c Sat Apr 03 12:54:30 1993 *************** *** 152,160 **** usage (msg) char *msg; { if (msg) fprintf (stderr, "%s: %s\n", program_name, msg); ! fprintf (stderr, "\ ! Usage: %s [path...] [expression]\n", program_name); exit (1); } --- 152,161 ---- usage (msg) char *msg; { + extern char *version_string; if (msg) fprintf (stderr, "%s: %s\n", program_name, msg); ! fprintf (stderr, "\n%s\n\ ! Usage: %s [path...] [expression]\n", version_string, program_name); exit (1); } diff -cbr orig/lib/listfile.c new/lib/listfile.c *** orig/lib/listfile.c Sun Dec 13 12:59:22 1992 --- new/lib/listfile.c Sat Apr 03 12:54:34 1993 *************** *** 55,66 **** --- 55,68 ---- #include #endif + #ifndef OS2 #include #include #ifndef _POSIX_VERSION struct passwd *getpwuid (); struct group *getgrgid (); #endif + #endif #include *************** *** 140,145 **** --- 142,150 ---- } timebuf[16] = 0; + #ifdef OS2 + printf ("%s ", modebuf); + #else printf ("%6u ", statp->st_ino); printf ("%4u ", convert_blocks (ST_NBLOCKS (statp), kilobytes)); *************** *** 159,164 **** --- 164,170 ---- printf (" "); #endif else + #endif printf ("%8lu ", statp->st_size); printf ("%s ", timebuf + 4); *************** *** 191,199 **** --- 197,207 ---- { switch (c) { + #ifndef OS2 case '\\': printf ("\\\\"); break; + #endif case '\n': printf ("\\n"); *************** *** 224,230 **** --- 232,242 ---- break; default: + #ifdef OS2 + if (c > 040 && c < 0377 && c != 0177) + #else if (c > 040 && c < 0177) + #endif putchar (c); else printf ("\\%03o", (unsigned int) c); diff -cbr orig/lib/nextelem.c new/lib/nextelem.c *** orig/lib/nextelem.c Fri Mar 26 03:01:48 1993 --- new/lib/nextelem.c Sat Apr 03 12:54:34 1993 *************** *** 69,75 **** --- 69,79 ---- start = end; final_colon = 1; /* Maybe there will be one. */ + #ifdef OS2 + end = index (start, ';'); + #else end = index (start, ':'); + #endif if (end == start) { /* An empty path element. */ diff -cbr orig/lib/savedir.c new/lib/savedir.c *** orig/lib/savedir.c Tue Nov 24 13:57:38 1992 --- new/lib/savedir.c Sat Apr 03 12:54:34 1993 *************** *** 111,117 **** closedir (dirp); return NULL; } ! namep += new_name_space - name_space; name_space = new_name_space; } namep = stpcpy (namep, dp->d_name) + 1; --- 111,119 ---- 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 Mon Mar 29 21:57:46 1993 --- new/lib/version.c Sat Apr 03 12:56:52 1993 *************** *** 1 **** --- 1,17 ---- char *version_string = "GNU find version 3.8\n"; + + #ifdef __EMX__ + + #include + + char *program_name; + + void os2init(int *pargc, char ***pargv) + { + _response(pargc, pargv); + /* _wildcard(pargc, pargv); */ + program_name = **pargv; + setvbuf(stdout, NULL, _IOLBF, BUFSIZ); + } + + #endif diff -cbr orig/locate/bigram.c new/locate/bigram.c *** orig/locate/bigram.c Sun Dec 13 12:59:22 1992 --- new/locate/bigram.c Sat Apr 03 12:57:00 1993 *************** *** 46,51 **** --- 46,64 ---- path[path_max] = '\0'; strcpy (oldpath, " "); + if (isatty(0)) + { + extern char *version_string; + fprintf (stderr, "\nGNU locate/bigram %s" + "\nUsage: %s common_bigrams < list > coded_list\n", + version_string + 9, program_name); + exit (2); + } + + #ifdef __EMX__ + os2init(&argc, &argv); + #endif + while (fgets (path, path_max, stdin) != NULL) { line_length = strlen (path); diff -cbr orig/locate/code.c new/locate/code.c *** orig/locate/code.c Sun Dec 13 12:59:22 1992 --- new/locate/code.c Sat Apr 03 12:57:00 1993 *************** *** 65,78 **** unsigned line_length; int path_max; program_name = argv[0]; oldcount = 0; bigram[2] = '\0'; if (argc != 2) { ! fprintf (stderr, "Usage: %s common_bigrams < list > coded_list\n", ! argv[0]); exit (2); } --- 65,84 ---- unsigned line_length; int path_max; + #ifdef __EMX__ + os2init(&argc, &argv); + #endif + program_name = argv[0]; oldcount = 0; bigram[2] = '\0'; if (argc != 2) { ! extern char *version_string; ! fprintf (stderr, "\nGNU locate/code %s" ! "\nUsage: %s common_bigrams < list > coded_list\n", ! version_string + 9, argv[0]); exit (2); } diff -cbr orig/locate/locate.c new/locate/locate.c *** orig/locate/locate.c Sun Dec 13 12:59:24 1992 --- new/locate/locate.c Sat Apr 03 12:57:00 1993 *************** *** 32,37 **** --- 32,41 ---- Modified by David MacKenzie (djm@gnu.ai.mit.edu) Public domain. */ + #ifdef OS2 + #define LOCATE_DB "d:/bin/locate/locate.db" + #endif + #include #include #include *************** *** 54,59 **** --- 58,66 ---- #else extern int errno; #endif + #ifdef OS2 + #include + #endif #include #include "pathmax.h" *************** *** 130,140 **** --- 137,155 ---- cutoff += count; for (found = FALSE, s = p; s >= cutoff; s--) + #ifdef OS2 + if (tolower(*s) == tolower(*patend)) + #else if (*s == *patend) + #endif { /* Fast first char check. */ for (p = patend - 1, q = s - 1; *p != '\0'; p--, q--) + #ifdef OS2 + if (tolower(*q) != tolower(*p)) + #else if (*q != *p) + #endif break; if (*p == '\0') { *************** *** 204,211 **** static void usage () { ! fprintf (stderr, "Usage: %s [-d path] [--database=path] pattern...\n", ! program_name); exit (1); } --- 219,228 ---- static void usage () { ! extern char *version_string; ! fprintf (stderr, "\nGNU locate %s" ! "\nUsage: %s [-d path] [--database=path] pattern...\n", ! version_string + 9, program_name); exit (1); } *************** *** 223,228 **** --- 240,249 ---- char *dbpath, *e; int found = 0, optc; + #ifdef __EMX__ + os2init(&argc, &argv); + #endif + program_name = argv[0]; dbpath = getenv ("LOCATE_PATH"); diff -cbr orig/xargs/xargs.c new/xargs/xargs.c *** orig/xargs/xargs.c Thu Mar 25 00:18:26 1993 --- new/xargs/xargs.c Sat Apr 03 13:00:20 1993 *************** *** 73,78 **** --- 73,87 ---- #define ARG_MAX sysconf (_SC_ARG_MAX) #endif + #ifdef OS2 + #include + #define ARG_MAX (31*1024) + #define CMD_EXE_LIMIT 1024 + #define CONSOLE "con" + #else + #define CONSOLE "/dev/tty" + #endif + #ifndef ARG_MAX #define ARG_MAX NCARGS #endif *************** *** 119,125 **** --- 128,136 ---- static void usage (); static void wait_for_proc (); + #ifndef OS2 extern char **environ; + #endif /* The name this program was run with. */ char *program_name; *************** *** 172,178 **** --- 183,193 ---- static int procs_executing = 0; /* Default program to run. */ + #ifdef OS2 + static char def_prog[] = "echo"; + #else static char def_prog[] = "/bin/echo"; + #endif /* Buffer for reading arguments from stdin. */ static char *linebuf; *************** *** 238,243 **** --- 253,261 ---- int (*read_args) () = read_line; program_name = argv[0]; + #ifdef __EMX__ + os2init(&argc, &argv); + #endif orig_arg_max = arg_max = ARG_MAX; *************** *** 328,342 **** if (query_before_executing) { print_command++; ! tty_stream = fopen ("/dev/tty", "r"); if (!tty_stream) ! error (1, errno, "/dev/tty"); } if (replace_pat || lines_per_exec) exit_if_size_exceeded++; linebuf = xmalloc ((unsigned) arg_max + 1); if (optind == argc) { optind = 0; --- 346,365 ---- if (query_before_executing) { print_command++; ! tty_stream = fopen (CONSOLE, "r"); if (!tty_stream) ! error (1, errno, CONSOLE); } if (replace_pat || lines_per_exec) exit_if_size_exceeded++; linebuf = xmalloc ((unsigned) arg_max + 1); + #ifdef OS2 + if ( isatty(fileno(stdin)) ) + usage(); + #endif + if (optind == argc) { optind = 0; *************** *** 694,699 **** --- 717,760 ---- wait_for_proc (0); if (!query_before_executing && print_command) print_args (0); + #ifdef OS2 + if ( (child = spawnvp ((_osmode == DOS_MODE) ? P_WAIT : 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"; + bcopy ((char *) cmd_argv, (char *) (new_argv + 2), + 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 ((_osmode == DOS_MODE) ? P_WAIT : 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) *************** *** 709,714 **** --- 770,776 ---- _exit (errno == ENOENT ? 127 : 126); } add_proc (child); + #endif processes_executed++; } *************** *** 731,736 **** --- 793,803 ---- int pid; int status; + #ifdef OS2 + if ( _osmode == DOS_MODE ) + return; + #endif + while (procs_executing) { do *************** *** 853,858 **** --- 920,927 ---- static void usage () { + extern char *version_string; + fprintf (stderr, "\nGNU xargs %s\n", version_string + 9); fprintf (stderr, "\ 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\