home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / gnufind.zip / patches.os2 < prev    next >
Text File  |  1996-04-20  |  25KB  |  965 lines

  1. Only in new: exe
  2. Only in new: Makefile.os2
  3. Only in new: patches.os2
  4. Only in new: config.h
  5. Only in new/lib: gnufind.def
  6. Only in new/lib: gnuregex.def
  7. Only in new/lib: Makefile.os2
  8. Only in new/find: Makefile.os2
  9. Only in new/locate: Makefile.os2
  10. Only in new/xargs: Makefile.os2
  11. diff -cbr orig/find/find.c new/find/find.c
  12. *** orig/find/find.c    Wed Oct 12 22:21:10 1994
  13. --- new/find/find.c    Mon Jan 01 19:41:10 1996
  14. ***************
  15. *** 34,39 ****
  16. --- 34,43 ----
  17.   #include "defs.h"
  18.   #include "modetype.h"
  19.   
  20. + #ifdef OS2
  21. + #define chdir(p) _chdir2(p)
  22. + #endif
  23.   #ifndef S_IFLNK
  24.   #define lstat stat
  25.   #endif
  26. ***************
  27. *** 131,136 ****
  28. --- 135,160 ----
  29.   }
  30.   #endif /* DEBUG_STAT */
  31.   
  32. + #ifdef OS2
  33. + #include <sys/dir.h>
  34. + static int
  35. + os2_stat (file, bufp)
  36. +      char *file;
  37. +      struct stat *bufp;
  38. + {
  39. +   int rc = stat(file, bufp);
  40. +   bufp->st_mode &= ~S_IRWXO;
  41. +   if (bufp->st_attr & A_HIDDEN)
  42. +     bufp->st_mode |= S_IROTH;
  43. +   if (bufp->st_attr & A_SYSTEM)
  44. +     bufp->st_mode |= S_IWOTH;
  45. +   if (bufp->st_attr & A_ARCHIVE)
  46. +     bufp->st_mode |= S_IXOTH;
  47. +   return rc;
  48. + }
  49. + #endif
  50.   void
  51.   main (argc, argv)
  52.        int argc;
  53. ***************
  54. *** 142,147 ****
  55. --- 166,174 ----
  56.     char *predicate_name;        /* Name of predicate being parsed. */
  57.   
  58.     program_name = argv[0];
  59. + #ifdef __EMX__
  60. +   os2init(&argc, &argv);
  61. + #endif
  62.   
  63.     predicates = NULL;
  64.     last_pred = NULL;
  65. ***************
  66. *** 156,168 ****
  67. --- 183,202 ----
  68.   #ifdef DEBUG_STAT
  69.     xstat = debug_stat;
  70.   #else /* !DEBUG_STAT */
  71. + #ifdef OS2
  72. +   xstat = os2_stat;
  73. + #else
  74.     xstat = lstat;
  75. + #endif
  76.   #endif /* !DEBUG_STAT */
  77.   
  78.   #ifdef DEBUG
  79.     printf ("cur_day_start = %s", ctime (&cur_day_start));
  80.   #endif /* DEBUG */
  81.   
  82. +   if ( argc == 1 )
  83. +     usage(NULL);
  84.     /* Find where in ARGV the predicates begin. */
  85.     for (i = 1; i < argc && strchr ("-!(),", argv[i][0]) == NULL; i++)
  86.       /* Do nothing. */ ;
  87. ***************
  88. *** 447,453 ****
  89. --- 481,493 ----
  90.         register unsigned file_len; /* Length of each path to process. */
  91.         register unsigned pathname_len; /* PATHLEN plus trailing '/'. */
  92.   
  93. + #ifdef OS2
  94. +       if (!strcmp (pathname + 1, ":/") || !strcmp (pathname + 1, ":\\"))
  95. +         pathname_len = 4;
  96. +       else if (pathname[pathlen - 1] == '/' || pathname[pathlen - 1] == '\\')
  97. + #else
  98.         if (pathname[pathlen - 1] == '/')
  99. + #endif
  100.       pathname_len = pathlen + 1; /* For '\0'; already have '/'. */
  101.         else
  102.       pathname_len = pathlen + 2; /* For '/' and '\0'. */
  103. diff -cbr orig/find/parser.c new/find/parser.c
  104. *** orig/find/parser.c    Wed Nov 02 21:59:18 1994
  105. --- new/find/parser.c    Mon Jan 01 20:47:50 1996
  106. ***************
  107. *** 573,578 ****
  108. --- 573,581 ----
  109.        char *argv[];
  110.        int *arg_ptr;
  111.   {
  112. + #ifdef OS2
  113. +   return (false);
  114. + #else
  115.     struct group *cur_gr;
  116.     struct predicate *our_pred;
  117.     gid_t gid;
  118. ***************
  119. *** 595,600 ****
  120. --- 598,604 ----
  121.     our_pred->args.gid = gid;
  122.     (*arg_ptr)++;
  123.     return (true);
  124. + #endif
  125.   }
  126.   
  127.   static boolean
  128. ***************
  129. *** 602,612 ****
  130.        char *argv[];
  131.        int *arg_ptr;
  132.   {
  133.     printf ("\
  134.   Usage: %s [path...] [expression]\n", program_name);
  135. !   printf ("\
  136.   default path is the current directory; default expression is -print\n\
  137. ! expression may consist of:\n\
  138.   operators (decreasing precedence; -and is implicit where no others are given):\n\
  139.         ( EXPR ) ! EXPR -not EXPR EXPR1 -a EXPR2 EXPR1 -and EXPR2\n");
  140.     printf ("\
  141. --- 606,618 ----
  142.        char *argv[];
  143.        int *arg_ptr;
  144.   {
  145. +   extern char *version_string;
  146. +   printf ("\nGNU find version %s\n\n", version_string);
  147.     printf ("\
  148.   Usage: %s [path...] [expression]\n", program_name);
  149. !   printf ("\n\
  150.   default path is the current directory; default expression is -print\n\
  151. ! expression may consist of:\n\n\
  152.   operators (decreasing precedence; -and is implicit where no others are given):\n\
  153.         ( EXPR ) ! EXPR -not EXPR EXPR1 -a EXPR2 EXPR1 -and EXPR2\n");
  154.     printf ("\
  155. ***************
  156. *** 1272,1277 ****
  157. --- 1278,1286 ----
  158.        char *argv[];
  159.        int *arg_ptr;
  160.   {
  161. + #ifdef OS2
  162. +   return (false);
  163. + #else
  164.     struct passwd *cur_pwd;
  165.     struct predicate *our_pred;
  166.     uid_t uid;
  167. ***************
  168. *** 1294,1299 ****
  169. --- 1303,1309 ----
  170.     our_pred->args.uid = uid;
  171.     (*arg_ptr)++;
  172.     return (true);
  173. + #endif
  174.   }
  175.   
  176.   static boolean
  177. ***************
  178. *** 1339,1347 ****
  179. --- 1349,1359 ----
  180.       return (false);
  181.     switch (argv[*arg_ptr][0])
  182.       {
  183. + #ifndef OS2
  184.       case 'b':            /* block special */
  185.         type_cell = S_IFBLK;
  186.         break;
  187. + #endif
  188.       case 'c':            /* character special */
  189.         type_cell = S_IFCHR;
  190.         break;
  191. diff -cbr orig/find/pred.c new/find/pred.c
  192. *** orig/find/pred.c    Wed Nov 02 21:59:22 1994
  193. --- new/find/pred.c    Mon Jan 01 14:15:34 1996
  194. ***************
  195. *** 27,32 ****
  196. --- 27,37 ----
  197.   #include "modetype.h"
  198.   #include "wait.h"
  199.   
  200. + #ifdef OS2
  201. + #include <process.h>
  202. + #define chdir(p) _chdir2(p)
  203. + #endif
  204.   #if !defined(SIGCHLD) && defined(SIGCLD)
  205.   #define SIGCHLD SIGCLD
  206.   #endif
  207. ***************
  208. *** 69,75 ****
  209.      (including indirect blocks).
  210.      HP-UX, perhaps uniquely, counts st_blocks in 1024-byte units.
  211.      This workaround loses when mixing HP-UX and 4BSD filesystems, though.  */
  212. ! #ifdef _POSIX_SOURCE
  213.   # define ST_NBLOCKS(statp) (((statp)->st_size + 512 - 1) / 512)
  214.   #else
  215.   # ifndef HAVE_ST_BLOCKS
  216. --- 74,80 ----
  217.      (including indirect blocks).
  218.      HP-UX, perhaps uniquely, counts st_blocks in 1024-byte units.
  219.      This workaround loses when mixing HP-UX and 4BSD filesystems, though.  */
  220. ! #if defined(_POSIX_SOURCE) || defined(OS2)
  221.   # define ST_NBLOCKS(statp) (((statp)->st_size + 512 - 1) / 512)
  222.   #else
  223.   # ifndef HAVE_ST_BLOCKS
  224. ***************
  225. *** 432,437 ****
  226. --- 437,445 ----
  227.     int path_pos;
  228.     struct exec_val *execp;    /* Pointer for efficiency. */
  229.   
  230. +   if ( strncmp(pathname, "./", 2) == 0 )
  231. +     pathname += 2;
  232.     execp = &pred_ptr->args.exec_vec;
  233.   
  234.     /* Replace "{}" with the real path in each affected arg. */
  235. ***************
  236. *** 578,583 ****
  237. --- 586,592 ----
  238.              filesystem_type (pathname, rel_pathname, stat_buf));
  239.         break;
  240.       case 'g':        /* group name */
  241. + #ifndef OS2
  242.         {
  243.           struct group *g;
  244.   
  245. ***************
  246. *** 590,595 ****
  247. --- 599,605 ----
  248.             }
  249.           /* else fallthru */
  250.         }
  251. + #endif
  252.       case 'G':        /* GID number */
  253.         segment->text[segment->text_len] = 'u';
  254.         fprintf (fp, segment->text, stat_buf->st_gid);
  255. ***************
  256. *** 676,681 ****
  257. --- 686,692 ----
  258.         fprintf (fp, segment->text, cp);
  259.         break;
  260.       case 'u':        /* user name */
  261. + #ifndef OS2
  262.         {
  263.           struct passwd *p;
  264.   
  265. ***************
  266. *** 688,693 ****
  267. --- 699,705 ----
  268.             }
  269.           /* else fallthru */
  270.         }
  271. + #endif
  272.       case 'U':        /* UID number */
  273.         segment->text[segment->text_len] = 'u';
  274.         fprintf (fp, segment->text, stat_buf->st_uid);
  275. ***************
  276. *** 978,985 ****
  277. --- 990,1001 ----
  278.   
  279.     return gid_unused[(unsigned) stat_buf->st_gid];
  280.   #else
  281. + #ifdef OS2
  282. +   return 1;
  283. + #else
  284.     return getgrgid (stat_buf->st_gid) == NULL;
  285.   #endif
  286. + #endif
  287.   }
  288.   
  289.   boolean
  290. ***************
  291. *** 993,1000 ****
  292. --- 1009,1020 ----
  293.   
  294.     return uid_unused[(unsigned) stat_buf->st_uid];
  295.   #else
  296. + #ifdef OS2
  297. +   return 1;
  298. + #else
  299.     return getpwuid (stat_buf->st_uid) == NULL;
  300.   #endif
  301. + #endif
  302.   }
  303.   
  304.   boolean
  305. ***************
  306. *** 1102,1108 ****
  307.        struct stat *stat_buf;
  308.        struct predicate *pred_ptr;
  309.   {
  310. !   puts (pathname);
  311.     return (true);
  312.   }
  313.   
  314. --- 1122,1128 ----
  315.        struct stat *stat_buf;
  316.        struct predicate *pred_ptr;
  317.   {
  318. !   puts (strncmp(pathname, "./", 2) == 0 ? pathname + 2 : pathname);
  319.     return (true);
  320.   }
  321.   
  322. ***************
  323. *** 1112,1118 ****
  324.        struct stat *stat_buf;
  325.        struct predicate *pred_ptr;
  326.   {
  327. !   fputs (pathname, stdout);
  328.     putc (0, stdout);
  329.     return (true);
  330.   }
  331. --- 1132,1138 ----
  332.        struct stat *stat_buf;
  333.        struct predicate *pred_ptr;
  334.   {
  335. !   fputs (strncmp(pathname, "./", 2) == 0 ? pathname + 2 : pathname, stdout);
  336.     putc (0, stdout);
  337.     return (true);
  338.   }
  339. ***************
  340. *** 1319,1324 ****
  341. --- 1339,1390 ----
  342.   launch (pred_ptr)
  343.        struct predicate *pred_ptr;
  344.   {
  345. + #ifdef OS2
  346. +   int status, arg;
  347. +   char *buf;
  348. +   struct exec_val *execp;    /* Pointer for efficiency. */
  349. +   char *current_dir;
  350. +   execp = &pred_ptr->args.exec_vec;
  351. +   /* Make sure output of command doesn't get mixed with find output. */
  352. +   fflush (stdout);
  353. +   fflush (stderr);
  354. +   current_dir = xgetcwd ();
  355. +   if (current_dir == NULL)
  356. +   {
  357. +     error (1, errno, "cannot get current directory");
  358. +     _exit (1);
  359. +   }
  360. +   if (chdir (starting_dir) < 0)
  361. +   {
  362. +     error (0, errno, "%s", starting_dir);
  363. +     _exit (1);
  364. +   }
  365. +   if ((status = spawnvp(P_WAIT, execp->vec[0], execp->vec)) == -1)
  366. +   {
  367. +     buf = malloc(32768);
  368. +     buf[0] = 0;
  369. +     for (arg = 0; execp->vec[arg] != NULL; arg++)
  370. +       strcat(strcat(buf, execp->vec[arg]), " ");
  371. +     status = system(buf);
  372. +     free(buf);
  373. +   }
  374. +   if (chdir (current_dir) < 0)
  375. +   {
  376. +     error (0, errno, "%s", current_dir);
  377. +     _exit (1);
  378. +   }
  379. +   return (status == 0);
  380. + #else
  381.     int status;
  382.     pid_t wait_ret, child_pid;
  383.     struct exec_val *execp;    /* Pointer for efficiency. */
  384. ***************
  385. *** 1389,1394 ****
  386. --- 1455,1461 ----
  387.         return (false);
  388.       }
  389.     return (!WEXITSTATUS (status));
  390. + #endif
  391.   }
  392.   
  393.   /* Return a static string formatting the time WHEN according to the
  394. diff -cbr orig/find/util.c new/find/util.c
  395. *** orig/find/util.c    Thu Oct 20 05:49:46 1994
  396. --- new/find/util.c    Mon Jan 01 20:47:34 1996
  397. ***************
  398. *** 150,158 ****
  399. --- 150,161 ----
  400.   usage (msg)
  401.        char *msg;
  402.   {
  403. +   extern char *version_string;
  404.     if (msg)
  405.       fprintf (stderr, "%s: %s\n", program_name, msg);
  406. +   fprintf (stderr, "\nGNU find %s\n\n", version_string);
  407.     fprintf (stderr, "\
  408.   Usage: %s [path...] [expression]\n", program_name);
  409. +   fprintf (stderr, "\nUse --help to get a short description.\n");
  410.     exit (1);
  411.   }
  412. diff -cbr orig/lib/filemode.c new/lib/filemode.c
  413. *** orig/lib/filemode.c    Sun Oct 02 00:34:34 1994
  414. --- new/lib/filemode.c    Mon Jan 01 21:08:12 1996
  415. ***************
  416. *** 122,127 ****
  417. --- 122,139 ----
  418.   /* Like filemodestring, but only the relevant part of the `struct stat'
  419.      is given as an argument.  */
  420.   
  421. + #ifdef OS2
  422. + static void
  423. + hsa (bits, chars)
  424. +      unsigned short bits;
  425. +      char *chars;
  426. + {
  427. +   chars[0] = (bits & S_IREAD) ? 'h' : '-';
  428. +   chars[1] = (bits & S_IWRITE) ? 's' : '-';
  429. +   chars[2] = (bits & S_IEXEC) ? 'a' : '-';
  430. + }
  431. + #endif
  432.   void
  433.   mode_string (mode, str)
  434.        unsigned short mode;
  435. ***************
  436. *** 130,136 ****
  437. --- 142,152 ----
  438.     str[0] = ftypelet ((long) mode);
  439.     rwx ((mode & 0700) << 0, &str[1]);
  440.     rwx ((mode & 0070) << 3, &str[4]);
  441. + #ifdef OS2
  442. +   hsa ((mode & 0007) << 6, &str[7]);
  443. + #else
  444.     rwx ((mode & 0007) << 6, &str[7]);
  445. + #endif
  446.     setst (mode, str);
  447.   }
  448.   
  449. diff -cbr orig/lib/listfile.c new/lib/listfile.c
  450. *** orig/lib/listfile.c    Wed Nov 02 21:59:24 1994
  451. --- new/lib/listfile.c    Mon Jan 01 14:40:04 1996
  452. ***************
  453. *** 75,81 ****
  454.      (including indirect blocks).
  455.      HP-UX, perhaps uniquely, counts st_blocks in 1024-byte units.
  456.      This workaround loses when mixing HP-UX and 4BSD filesystems, though.  */
  457. ! #ifdef _POSIX_SOURCE
  458.   # define ST_NBLOCKS(statp) (((statp)->st_size + 512 - 1) / 512)
  459.   #else
  460.   # ifndef HAVE_ST_BLOCKS
  461. --- 75,81 ----
  462.      (including indirect blocks).
  463.      HP-UX, perhaps uniquely, counts st_blocks in 1024-byte units.
  464.      This workaround loses when mixing HP-UX and 4BSD filesystems, though.  */
  465. ! #if defined(_POSIX_SOURCE) || defined(OS2)
  466.   # define ST_NBLOCKS(statp) (((statp)->st_size + 512 - 1) / 512)
  467.   #else
  468.   # ifndef HAVE_ST_BLOCKS
  469. ***************
  470. *** 153,158 ****
  471. --- 153,163 ----
  472.       }
  473.     timebuf[16] = 0;
  474.   
  475. + #ifdef OS2
  476. +   fprintf (stream, "%s ", modebuf);
  477. +   fprintf (stream, "%4u ", convert_blocks (ST_NBLOCKS (statp), kilobytes));
  478. + #else
  479.     fprintf (stream, "%6lu ", statp->st_ino);
  480.   
  481.     fprintf (stream, "%4u ", convert_blocks (ST_NBLOCKS (statp), kilobytes));
  482. ***************
  483. *** 172,181 ****
  484. --- 177,192 ----
  485.       fprintf (stream, "         ");
  486.   #endif
  487.     else
  488. + #endif
  489.       fprintf (stream, "%8lu ", statp->st_size);
  490.   
  491.     fprintf (stream, "%s ", timebuf + 4);
  492.   
  493. + #ifdef OS2
  494. +   if (strncmp(name, "./", 2) == 0)
  495. +     name += 2;
  496. + #endif
  497.     print_name_with_quoting (name, stream);
  498.   
  499.   #ifdef S_ISLNK
  500. ***************
  501. *** 205,213 ****
  502. --- 216,226 ----
  503.       {
  504.         switch (c)
  505.       {
  506. + #ifndef OS2
  507.       case '\\':
  508.         fprintf (stream, "\\\\");
  509.         break;
  510. + #endif
  511.   
  512.       case '\n':
  513.         fprintf (stream, "\\n");
  514. ***************
  515. *** 238,244 ****
  516. --- 251,261 ----
  517.         break;
  518.   
  519.       default:
  520. + #ifdef OS2
  521. +           if (c > 040 && c < 0377 && c != 0177)
  522. + #else
  523.         if (c > 040 && c < 0177)
  524. + #endif
  525.           putc (c, stream);
  526.         else
  527.           fprintf (stream, "\\%03o", (unsigned int) c);
  528. diff -cbr orig/lib/modechange.c new/lib/modechange.c
  529. *** orig/lib/modechange.c    Fri Oct 07 18:21:32 1994
  530. --- new/lib/modechange.c    Mon Jan 01 20:57:24 1996
  531. ***************
  532. *** 191,200 ****
  533. --- 191,215 ----
  534.             case 'x':
  535.           change->value |= 00111 & affected_masked;
  536.           break;
  537. + #ifdef OS2
  538. +           case 'h':
  539. +         /* Set the other/r bit, i.e. OS/2's "hidden". */
  540. +         change->value |= 00004;
  541. +         break;
  542. +           case 's':
  543. +         /* Set the other/w bit, i.e. OS/2's "system". */
  544. +         change->value |= 00002;
  545. +         break;
  546. +           case 'a':
  547. +         /* Set the other/x bit, i.e. OS/2's "archive". */
  548. +         change->value |= 00001;
  549. +         break;
  550. + #else
  551.             case 's':
  552.           /* Set the setuid/gid bits if `u' or `g' is selected. */
  553.           change->value |= 06000 & affected_masked;
  554.           break;
  555. + #endif
  556.             case 't':
  557.           /* Set the "save text image" bit if `o' is selected. */
  558.           change->value |= 01000 & affected_masked;
  559. diff -cbr orig/lib/nextelem.c new/lib/nextelem.c
  560. *** orig/lib/nextelem.c    Tue Sep 27 14:02:44 1994
  561. --- new/lib/nextelem.c    Mon Jan 01 11:45:40 1996
  562. ***************
  563. *** 73,79 ****
  564. --- 73,83 ----
  565.     start = end;
  566.     final_colon = 1;        /* Maybe there will be one.  */
  567.   
  568. + #ifdef OS2
  569. +   end = strchr (start, ';');
  570. + #else
  571.     end = strchr (start, ':');
  572. + #endif
  573.     if (end == start)
  574.       {
  575.         /* An empty path element.  */
  576. diff -cbr orig/lib/regex.h new/lib/regex.h
  577. *** orig/lib/regex.h    Wed Oct 26 23:43:44 1994
  578. --- new/lib/regex.h    Mon Jan 01 20:06:10 1996
  579. ***************
  580. *** 1,3 ****
  581. --- 1,5 ----
  582. + #define _REGEX_RE_COMP
  583.   /* Definitions for data structures and routines for the regular
  584.      expression library, version 0.12.
  585.   
  586. diff -cbr orig/lib/savedir.c new/lib/savedir.c
  587. *** orig/lib/savedir.c    Fri Oct 07 18:21:34 1994
  588. --- new/lib/savedir.c    Mon Jan 01 11:20:26 1996
  589. ***************
  590. *** 115,121 ****
  591.             closedir (dirp);
  592.             return NULL;
  593.           }
  594. !           namep += new_name_space - name_space;
  595.             name_space = new_name_space;
  596.           }
  597.         namep = stpcpy (namep, dp->d_name) + 1;
  598. --- 115,123 ----
  599.             closedir (dirp);
  600.             return NULL;
  601.           }
  602. !               /* namep += new_name_space - name_space; */
  603. !               /* previous statement assumes nonsegmented address space */
  604. !               /* better: */ namep = new_name_space + (namep - name_space);
  605.             name_space = new_name_space;
  606.           }
  607.         namep = stpcpy (namep, dp->d_name) + 1;
  608. diff -cbr orig/lib/version.c new/lib/version.c
  609. *** orig/lib/version.c    Fri Nov 04 05:19:16 1994
  610. --- new/lib/version.c    Mon Jan 01 20:47:06 1996
  611. ***************
  612. *** 1 ****
  613. --- 1,20 ----
  614.   char *version_string = "4.1";
  615. + #ifdef __EMX__
  616. + #include <stdio.h>
  617. + #include <sys/nls.h>
  618. + char *program_name;
  619. + void os2init(int *pargc, char ***pargv)
  620. + {
  621. +   _response(pargc, pargv);
  622. +   /* _wildcard(pargc, pargv); */
  623. +   program_name = **pargv;
  624. +   setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
  625. +   _nls_init();
  626. + }
  627. + #endif
  628. diff -cbr orig/lib/xgetcwd.c new/lib/xgetcwd.c
  629. *** orig/lib/xgetcwd.c    Tue Sep 27 14:02:46 1994
  630. --- new/lib/xgetcwd.c    Mon Jan 01 14:14:48 1996
  631. ***************
  632. *** 36,41 ****
  633. --- 36,45 ----
  634.   char *getcwd ();
  635.   #endif
  636.   
  637. + #ifdef OS2
  638. + #define getcwd(b, s) _getcwd2(b, s)
  639. + #endif
  640.   /* Amount to increase buffer size by in each try. */
  641.   #define PATH_INCR 32
  642.   
  643. diff -cbr orig/locate/bigram.c new/locate/bigram.c
  644. *** orig/locate/bigram.c    Fri Oct 07 18:21:34 1994
  645. --- new/locate/bigram.c    Mon Jan 01 20:48:04 1996
  646. ***************
  647. *** 81,86 ****
  648. --- 81,99 ----
  649.        prefix count to 0.  */
  650.     strcpy (oldpath, " ");
  651.   
  652. +   if (isatty(0))
  653. +     {
  654. +       extern char *version_string;
  655. +       fprintf (stderr, "\nGNU locate/bigram %s\n"
  656. +                    "\nUsage: %s common_bigrams < list > coded_list\n",
  657. +                version_string, program_name);
  658. +       exit (2);
  659. +     }
  660. + #ifdef __EMX__
  661. +   os2init(&argc, &argv);
  662. + #endif
  663.     while ((line_len = getstr (&path, &pathsize, stdin, '\n', 0)) > 0)
  664.       {
  665.         register int count;    /* The prefix length.  */
  666. diff -cbr orig/locate/code.c new/locate/code.c
  667. *** orig/locate/code.c    Mon Sep 26 23:06:08 1994
  668. --- new/locate/code.c    Mon Jan 01 20:48:14 1996
  669. ***************
  670. *** 120,127 ****
  671. --- 120,133 ----
  672.   
  673.     bigram[2] = '\0';
  674.   
  675. + #ifdef __EMX__
  676. +   os2init(&argc, &argv);
  677. + #endif
  678.     if (argc != 2)
  679.       {
  680. +       extern char *version_string;
  681. +       fprintf (stderr, "\nGNU locate/code %s\n\n", version_string);
  682.         fprintf (stderr, "Usage: %s most_common_bigrams < list > coded_list\n",
  683.              argv[0]);
  684.         exit (2);
  685. diff -cbr orig/locate/frcode.c new/locate/frcode.c
  686. *** orig/locate/frcode.c    Mon Sep 26 23:06:10 1994
  687. --- new/locate/frcode.c    Mon Jan 01 20:48:18 1996
  688. ***************
  689. *** 119,124 ****
  690. --- 119,137 ----
  691.   
  692.     program_name = argv[0];
  693.   
  694. +   if (isatty(0))
  695. +     {
  696. +       extern char *version_string;
  697. +       fprintf (stderr, "\nGNU locate/frcode %s\n"
  698. +                    "\nUsage: %s < sorted-list > compressed-list\n",
  699. +                version_string, program_name);
  700. +       exit (2);
  701. +     }
  702. + #ifdef __EMX__
  703. +   os2init(&argc, &argv);
  704. + #endif
  705.     pathsize = oldpathsize = 1026; /* Increased as necessary by getstr.  */
  706.     path = xmalloc (pathsize);
  707.     oldpath = xmalloc (oldpathsize);
  708. diff -cbr orig/locate/locate.c new/locate/locate.c
  709. *** orig/locate/locate.c    Mon Sep 26 23:06:14 1994
  710. --- new/locate/locate.c    Mon Jan 01 20:48:24 1996
  711. ***************
  712. *** 78,83 ****
  713. --- 78,90 ----
  714.   extern int errno;
  715.   #endif
  716.   
  717. + #ifdef OS2
  718. + #include <sys/nls.h>
  719. + #define MAPCHAR(c) _nls_tolower(c)
  720. + #else
  721. + #define MAPCHAR(c) (c)
  722. + #endif
  723.   #include "locatedb.h"
  724.   
  725.   typedef enum {false, true} boolean;
  726. ***************
  727. *** 294,305 ****
  728.        in PATHPART.  */
  729.         for (prev_fast_match = false; s >= cutoff; s--)
  730.       /* Fast first char check. */
  731. !     if (*s == *patend)
  732.         {
  733.           char *s2;        /* Scan the path we read in. */
  734.           register char *p2;    /* Scan `patend'.  */
  735.   
  736. !         for (s2 = s - 1, p2 = patend - 1; *p2 != '\0' && *s2 == *p2;
  737.                              s2--, p2--)
  738.             ;
  739.           if (*p2 == '\0')
  740. --- 301,313 ----
  741.        in PATHPART.  */
  742.         for (prev_fast_match = false; s >= cutoff; s--)
  743.       /* Fast first char check. */
  744. !     if (MAPCHAR(*s) == MAPCHAR(*patend))
  745.         {
  746.           char *s2;        /* Scan the path we read in. */
  747.           register char *p2;    /* Scan `patend'.  */
  748.   
  749. !         for (s2 = s - 1, p2 = patend - 1; 
  750. !          *p2 != '\0' && MAPCHAR(*s2) == MAPCHAR(*p2);
  751.            s2--, p2--)
  752.             ;
  753.           if (*p2 == '\0')
  754. ***************
  755. *** 341,346 ****
  756. --- 349,356 ----
  757.        FILE *stream;
  758.        int status;
  759.   {
  760. +   extern char *version_string;
  761. +   fprintf (stream, "\nGNU locate %s\n\n", version_string);
  762.     fprintf (stream, "\
  763.   Usage: %s [-d path] [--database=path] [--version] [--help] pattern...\n",
  764.          program_name);
  765. ***************
  766. *** 362,367 ****
  767. --- 372,381 ----
  768.   {
  769.     char *dbpath;
  770.     int found = 0, optc;
  771. + #ifdef __EMX__
  772. +   os2init(&argc, &argv);
  773. + #endif
  774.   
  775.     program_name = argv[0];
  776.   
  777. diff -cbr orig/xargs/xargs.c new/xargs/xargs.c
  778. *** orig/xargs/xargs.c    Fri Oct 07 18:21:38 1994
  779. --- new/xargs/xargs.c    Mon Jan 01 20:48:42 1996
  780. ***************
  781. *** 81,86 ****
  782. --- 81,95 ----
  783.   #define SIGCHLD SIGCLD
  784.   #endif
  785.   
  786. + #ifdef OS2
  787. + #include <process.h>
  788. + #define ARG_MAX  (31*1024)
  789. + #define CMD_EXE_LIMIT 1024
  790. + #define CONSOLE "con"
  791. + #else
  792. + #define CONSOLE "/dev/tty"
  793. + #endif
  794.   /* COMPAT:  SYSV version defaults size (and has a max value of) to 470.
  795.      We try to make it as large as possible. */
  796.   #if !defined(ARG_MAX) && defined(_SC_ARG_MAX)
  797. ***************
  798. *** 112,118 ****
  799. --- 121,129 ----
  800.   /* Return nonzero if S is the EOF string.  */
  801.   #define EOF_STR(s) (eof_str && *eof_str == *s && !strcmp (eof_str, s))
  802.   
  803. + #ifndef OS2
  804.   extern char **environ;
  805. + #endif
  806.   
  807.   /* Not char because of type promotion; NeXT gcc can't handle it.  */
  808.   typedef int boolean;
  809. ***************
  810. *** 256,265 ****
  811. --- 267,283 ----
  812.     int optc;
  813.     int always_run_command = 1;
  814.     long orig_arg_max;
  815. + #ifdef OS2
  816. +   char *default_cmd = "echo";
  817. + #else
  818.     char *default_cmd = "/bin/echo";
  819. + #endif
  820.     int (*read_args) P_ ((void)) = read_line;
  821.   
  822.     program_name = argv[0];
  823. + #ifdef __EMX__
  824. +   os2init(&argc, &argv);
  825. + #endif
  826.   
  827.     orig_arg_max = ARG_MAX - 2048; /* POSIX.2 requires subtracting 2048.  */
  828.     arg_max = orig_arg_max;
  829. ***************
  830. *** 359,364 ****
  831. --- 377,387 ----
  832.     if (replace_pat || lines_per_exec)
  833.       exit_if_size_exceeded = true;
  834.   
  835. + #ifdef OS2
  836. +   if ( isatty(fileno(stdin)) )
  837. +     usage(stdout, 0);
  838. + #endif
  839.     if (optind == argc)
  840.       {
  841.         optind = 0;
  842. ***************
  843. *** 717,725 ****
  844.   
  845.         if (!tty_stream)
  846.       {
  847. !       tty_stream = fopen ("/dev/tty", "r");
  848.         if (!tty_stream)
  849. !         error (1, errno, "/dev/tty");
  850.       }
  851.         fputs ("?...", stderr);
  852.         fflush (stderr);
  853. --- 740,748 ----
  854.   
  855.         if (!tty_stream)
  856.       {
  857. !       tty_stream = fopen (CONSOLE, "r");
  858.         if (!tty_stream)
  859. !         error (1, errno, CONSOLE);
  860.       }
  861.         fputs ("?...", stderr);
  862.         fflush (stderr);
  863. ***************
  864. *** 750,755 ****
  865. --- 773,814 ----
  866.       wait_for_proc (false);
  867.         if (!query_before_executing && print_command)
  868.       print_args (false);
  869. + #ifdef OS2
  870. +       if ( (child = spawnvp (P_NOWAIT, cmd_argv[0], cmd_argv)) == -1 )
  871. +       {
  872. +     char **new_argv;
  873. +     int new_argc, new_ncargs, cnt;
  874. +     char msg[256];
  875. +     new_argc = cmd_argc + 2;
  876. +     new_argv = (char **)
  877. +       xmalloc ((unsigned) (sizeof (char *) * (new_argc + 1)));
  878. +     new_argv[0] = getenv("COMSPEC");
  879. +     new_argv[1] = "/c";
  880. +     memcpy ((char *) (new_argv + 2), (char *) cmd_argv,
  881. +         sizeof (char *) * (cmd_argc + 1));
  882. +     for (cnt = 0, new_ncargs = 0;
  883. +          cnt < new_argc && new_argv[cnt];
  884. +          cnt++ )
  885. +       new_ncargs += strlen (new_argv[cnt]);
  886. +     if ( new_ncargs > CMD_EXE_LIMIT )
  887. +     {
  888. +       sprintf(msg, "\tcommand line for CMD.EXE longer than %d characters\n"
  889. +           "\tuse the \"-s %d\" option",  CMD_EXE_LIMIT, CMD_EXE_LIMIT);
  890. +           error (1, 0, msg);
  891. +     }
  892. +     if ( (child = spawnvp (P_NOWAIT, new_argv[0], new_argv)) == -1 )
  893. +           error (1, errno, "cannot spawn");
  894. +     free (new_argv);
  895. +       }
  896. +       if ( _osmode != DOS_MODE )
  897. +         add_proc (child);
  898. + #else
  899.         /* If we run out of processes, wait for a child to return and
  900.            try again.  */
  901.         while ((child = fork ()) < 0 && errno == EAGAIN && procs_executing)
  902. ***************
  903. *** 765,770 ****
  904. --- 824,830 ----
  905.         _exit (errno == ENOENT ? 127 : 126);
  906.       }
  907.         add_proc (child);
  908. + #endif
  909.       }
  910.   
  911.     cmd_argc = initial_argc;
  912. ***************
  913. *** 906,911 ****
  914. --- 966,973 ----
  915.        FILE *stream;
  916.        int status;
  917.   {
  918. +   extern char *version_string;
  919. +   fprintf (stream, "\nGNU xargs %s\n\n", version_string);
  920.     fprintf (stream, "\
  921.   Usage: %s [-0prtx] [-e[eof-str]] [-i[replace-str]] [-l[max-lines]]\n\
  922.          [-n max-args] [-s max-chars] [-P max-procs] [--null] [--eof[=eof-str]]\n\
  923.