home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / gnututil.zip / patches.os2 < prev    next >
Text File  |  1996-08-07  |  43KB  |  1,710 lines

  1. Only in new: README.OS2
  2. Only in new: FILE_ID.DIZ
  3. Only in new: Makefile.os2
  4. Only in new: config.h.os2
  5. Only in new: patches.os2
  6. Only in new/intl: Makefile.os2
  7. Only in new/intl: gnuintl.def
  8. Only in new/lib: Makefile.os2
  9. Only in new/lib: gnuregex.def
  10. Only in new/lib: gnurx.def
  11. Only in new/lib: gnutu.def
  12. Only in new/lib: strcase.c
  13. Only in new/src: Makefile.os2
  14. Only in new/src: gnututil.def
  15. Only in new/src: os2main.c
  16. diff -cbr orig/intl/bindtextdom.c new/intl/bindtextdom.c
  17. *** orig/intl/bindtextdom.c    Sat Jul 06 03:52:36 1996
  18. --- new/intl/bindtextdom.c    Sun Jul 28 12:46:06 1996
  19. ***************
  20. *** 46,52 ****
  21.   /* @@ end of prolog @@ */
  22.   
  23.   /* Contains the default location of the message catalogs.  */
  24. ! extern const char _nl_default_dirname[];
  25.   
  26.   /* List with bindings of specific domains.  */
  27.   extern struct binding *_nl_domain_bindings;
  28. --- 46,52 ----
  29.   /* @@ end of prolog @@ */
  30.   
  31.   /* Contains the default location of the message catalogs.  */
  32. ! extern const char *_nl_default_dirname;
  33.   
  34.   /* List with bindings of specific domains.  */
  35.   extern struct binding *_nl_domain_bindings;
  36. ***************
  37. *** 70,75 ****
  38. --- 70,78 ----
  39.        const char *dirname;
  40.   {
  41.     struct binding *binding;
  42. +   if (_nl_default_dirname == NULL)
  43. +     _nl_default_dirname = GNULOCALEDIR;
  44.   
  45.     /* Some sanity checks.  */
  46.     if (domainname == NULL || domainname[0] == '\0')
  47. diff -cbr orig/intl/dcgettext.c new/intl/dcgettext.c
  48. *** orig/intl/dcgettext.c    Sat Jul 06 03:52:36 1996
  49. --- new/intl/dcgettext.c    Wed Aug 07 17:47:18 1996
  50. ***************
  51. *** 151,157 ****
  52.   const char *_nl_current_default_domain = _nl_default_default_domain;
  53.   
  54.   /* Contains the default location of the message catalogs.  */
  55. ! const char _nl_default_dirname[] = GNULOCALEDIR;
  56.   
  57.   /* List with bindings of specific domains created by bindtextdomain()
  58.      calls.  */
  59. --- 151,157 ----
  60.   const char *_nl_current_default_domain = _nl_default_default_domain;
  61.   
  62.   /* Contains the default location of the message catalogs.  */
  63. ! const char *_nl_default_dirname = NULL;
  64.   
  65.   /* List with bindings of specific domains created by bindtextdomain()
  66.      calls.  */
  67. ***************
  68. *** 235,240 ****
  69. --- 234,242 ----
  70.     if (msgid == NULL)
  71.       return NULL;
  72.   
  73. +   if (_nl_default_dirname == NULL)
  74. +     _nl_default_dirname = GNULOCALEDIR;
  75.     /* If DOMAINNAME is NULL, we are interested in the default domain.  If
  76.        CATEGORY is not LC_MESSAGES this might not make much sense but the
  77.        defintion left this undefined.  */
  78. ***************
  79. *** 258,264 ****
  80. --- 260,273 ----
  81.   
  82.     if (binding == NULL)
  83.       dirname = (char *) _nl_default_dirname;
  84. + #ifdef OS2
  85. + #define getcwd _getcwd2
  86. +   /* we have to deal with drive letters here and with getcwd below */
  87. +   else if (binding->dirname[0] == '/' || 
  88. +        isalpha(binding->dirname[0]) && binding->dirname[1] == ':')
  89. + #else
  90.     else if (binding->dirname[0] == '/')
  91. + #endif
  92.       dirname = binding->dirname;
  93.     else
  94.       {
  95. diff -cbr orig/intl/gettext.h new/intl/gettext.h
  96. *** orig/intl/gettext.h    Sat Jul 06 03:52:38 1996
  97. --- new/intl/gettext.h    Wed Aug 07 15:34:46 1996
  98. ***************
  99. *** 25,30 ****
  100. --- 25,36 ----
  101.   # include <limits.h>
  102.   #endif
  103.   
  104. + #ifdef OS2
  105. + #define PATH_SEPARATOR ';'
  106. + #else
  107. + #define PATH_SEPARATOR ':'
  108. + #endif
  109.   /* @@ end of prolog @@ */
  110.   
  111.   /* The magic number of the GNU message catalog format.  */
  112. diff -cbr orig/intl/libgettext.h new/intl/libgettext.h
  113. *** orig/intl/libgettext.h    Sat Jul 06 03:52:38 1996
  114. --- new/intl/libgettext.h    Wed Aug 07 17:41:38 1996
  115. ***************
  116. *** 36,41 ****
  117. --- 36,49 ----
  118.   # include <locale.h>
  119.   #endif
  120.   
  121. + #ifdef OS2
  122. + #define CheckEnv(e, d) ({char *v = getenv(e); v ? v : (d);})
  123. + #define StrCat(s1, s2) ({int l = strlen(s1) + strlen(s2);  \
  124. +   char *r = malloc(l); strcpy(r, s1); strcat(r, s2); r;})
  125. + #define GNULOCALEDIR CheckEnv("GNULOCALEDIR","/lib/glocale")
  126. + #define LOCALE_ALIAS_PATH StrCat(GNULOCALEDIR, ";.")
  127. + #define LOCALEDIR CheckEnv("LOCALEDIR","/lib/locale")
  128. + #endif
  129.   
  130.   #ifdef __cplusplus
  131.   extern "C" {
  132. diff -cbr orig/intl/loadmsgcat.c new/intl/loadmsgcat.c
  133. *** orig/intl/loadmsgcat.c    Sat Jul 06 03:52:40 1996
  134. --- new/intl/loadmsgcat.c    Wed Aug 07 17:49:48 1996
  135. ***************
  136. *** 38,43 ****
  137. --- 38,47 ----
  138.   #include "gettext.h"
  139.   #include "gettextP.h"
  140.   
  141. + #ifndef O_BINARY
  142. + #define O_BINARY 0
  143. + #endif
  144.   /* @@ end of prolog @@ */
  145.   
  146.   #ifdef _LIBC
  147. ***************
  148. *** 58,63 ****
  149. --- 62,92 ----
  150.   int _nl_msg_cat_cntr;
  151.   
  152.   
  153. + #ifdef OS2
  154. + #include <string.h>
  155. + /* quick hack to at least translate german umlauts from Latin-1 to
  156. +    Codepage 850/437 - needs to be extended to other NLS characters */
  157. + static char *cp850  = "\x84\x94\x81\x8E\x99\x9A\xE1";
  158. + static char *latin1 = "\xE4\xF6\xFC\xC4\xD6\xDC\xDF";
  159. + static void recode_msg (char *msg)
  160. + {
  161. +   char *ptr = msg;
  162. +   int len = strlen (msg), pos;
  163. +   while ((pos = strcspn(ptr, latin1)) < len)
  164. +   {
  165. +     ptr[pos] = cp850[strchr(latin1, ptr[pos]) - latin1];
  166. +     ptr += pos + 1;
  167. +     len -= pos + 1;
  168. +   }
  169. + }
  170. + #endif
  171.   /* Load the message catalogs specified by FILENAME.  If it is no valid
  172.      message catalog do nothing.  */
  173.   void
  174. ***************
  175. *** 84,90 ****
  176.       return;
  177.   
  178.     /* Try to open the addressed file.  */
  179. !   fd = open (domain_file->filename, O_RDONLY);
  180.     if (fd == -1)
  181.       return;
  182.   
  183. --- 113,119 ----
  184.       return;
  185.   
  186.     /* Try to open the addressed file.  */
  187. !   fd = open (domain_file->filename, O_RDONLY | O_BINARY);
  188.     if (fd == -1)
  189.       return;
  190.   
  191. ***************
  192. *** 192,197 ****
  193. --- 221,235 ----
  194.         domain_file->data = NULL;
  195.         return;
  196.       }
  197. + #ifdef OS2
  198. +   {
  199. +     int i;
  200. +     for (i = 0; i < domain->nstrings; i++)
  201. +       recode_msg ((char *) domain->data + W (domain->must_swap,
  202. +                          domain->trans_tab[i].offset));
  203. +   }
  204. + #endif
  205.   
  206.     /* Show that one domain is changed.  This might make some cached
  207.        translations invalid.  */
  208. diff -cbr orig/intl/localealias.c new/intl/localealias.c
  209. *** orig/intl/localealias.c    Sat Jul 06 03:52:40 1996
  210. --- new/intl/localealias.c    Wed Aug 07 15:54:34 1996
  211. ***************
  212. *** 65,70 ****
  213. --- 65,75 ----
  214.   # endif
  215.   #endif
  216.   
  217. + #ifdef _LIBC
  218. + # include <libintl.h>
  219. + #else
  220. + # include "libgettext.h"
  221. + #endif
  222.   #include "gettext.h"
  223.   #include "gettextP.h"
  224.   
  225. ***************
  226. *** 137,146 ****
  227.   _nl_expand_alias (name)
  228.       const char *name;
  229.   {
  230. !   static const char *locale_alias_path = LOCALE_ALIAS_PATH;
  231.     struct alias_map *retval;
  232.     size_t added;
  233.   
  234.     do
  235.       {
  236.         struct alias_map item;
  237. --- 142,154 ----
  238.   _nl_expand_alias (name)
  239.       const char *name;
  240.   {
  241. !   static const char *locale_alias_path = NULL;
  242.     struct alias_map *retval;
  243.     size_t added;
  244.   
  245. +   if (locale_alias_path == NULL)
  246. +     locale_alias_path = LOCALE_ALIAS_PATH;
  247.     do
  248.       {
  249.         struct alias_map item;
  250. ***************
  251. *** 166,176 ****
  252.       {
  253.         const char *start;
  254.   
  255. !       while (locale_alias_path[0] == ':')
  256.           ++locale_alias_path;
  257.         start = locale_alias_path;
  258.   
  259. !       while (locale_alias_path[0] != '\0' && locale_alias_path[0] != ':')
  260.           ++locale_alias_path;
  261.   
  262.         if (start < locale_alias_path)
  263. --- 174,184 ----
  264.       {
  265.         const char *start;
  266.   
  267. !       while (locale_alias_path[0] == PATH_SEPARATOR)
  268.           ++locale_alias_path;
  269.         start = locale_alias_path;
  270.   
  271. !       while (locale_alias_path[0] != '\0' && locale_alias_path[0] != PATH_SEPARATOR)
  272.           ++locale_alias_path;
  273.   
  274.         if (start < locale_alias_path)
  275. diff -cbr orig/lib/error.c new/lib/error.c
  276. *** orig/lib/error.c    Fri Apr 19 00:01:12 1996
  277. --- new/lib/error.c    Sun Jul 28 12:51:22 1996
  278. ***************
  279. *** 80,90 ****
  280.   private_strerror (errnum)
  281.        int errnum;
  282.   {
  283.     extern char *sys_errlist[];
  284.     extern int sys_nerr;
  285.   
  286.     if (errnum > 0 && errnum <= sys_nerr)
  287. !     return sys_errlist[errnum];
  288.     return _("Unknown system error");
  289.   }
  290.   #  define strerror private_strerror
  291. --- 80,92 ----
  292.   private_strerror (errnum)
  293.        int errnum;
  294.   {
  295. + #ifndef __EMX__
  296.     extern char *sys_errlist[];
  297.     extern int sys_nerr;
  298. + #endif
  299.   
  300.     if (errnum > 0 && errnum <= sys_nerr)
  301. !     return (char *) sys_errlist[errnum];
  302.     return _("Unknown system error");
  303.   }
  304.   #  define strerror private_strerror
  305. ***************
  306. *** 96,101 ****
  307. --- 98,111 ----
  308.      If ERRNUM is nonzero, print its corresponding system error message.
  309.      Exit with status STATUS if it is nonzero.  */
  310.   /* VARARGS */
  311. + #ifdef __EMX__
  312. + char *program_name;
  313. + void set_program_name(char *name)
  314. + {
  315. +   program_name = name;
  316. + }
  317. + #endif
  318.   
  319.   void
  320.   #if defined(VA_START) && __STDC__
  321. diff -cbr orig/src/cat.c new/src/cat.c
  322. *** orig/src/cat.c    Sun May 26 23:53:28 1996
  323. --- new/src/cat.c    Sun Jul 28 12:50:06 1996
  324. ***************
  325. *** 82,87 ****
  326. --- 82,88 ----
  327.            program_name);
  328.     else
  329.       {
  330. +       print_version("cat");
  331.         printf (_("\
  332.   Usage: %s [OPTION] [FILE]...\n\
  333.   "),
  334. ***************
  335. *** 270,275 ****
  336. --- 271,279 ----
  337.             if (use_fionread
  338.             && ioctl (input_desc, FIONREAD, &n_to_read) < 0)
  339.           {
  340. + #ifdef __EMX__
  341. +           use_fionread = 0;
  342. + #else
  343.             /* Ultrix returns EOPNOTSUPP on NFS;
  344.                HP-UX returns ENOTTY on pipes.
  345.                SunOS returns EINVAL and
  346. ***************
  347. *** 290,298 ****
  348.                 newlines2 = newlines;
  349.                 return;
  350.               }
  351.           }
  352.             if (n_to_read == 0)
  353. - #endif
  354.           {
  355.             int n_write = bpout - outbuf;
  356.   
  357. --- 294,302 ----
  358.                 newlines2 = newlines;
  359.                 return;
  360.               }
  361. + #endif
  362.           }
  363.             if (n_to_read == 0)
  364.           {
  365.             int n_write = bpout - outbuf;
  366.   
  367. ***************
  368. *** 621,626 ****
  369. --- 625,633 ----
  370.     infile = "-";
  371.     argind = optind;
  372.   
  373. +   if (optind == argc && isatty (0))
  374. +     usage (0);
  375.     do
  376.       {
  377.         if (argind < argc)
  378. ***************
  379. *** 642,647 ****
  380. --- 649,663 ----
  381.           }
  382.       }
  383.   
  384. + #ifdef OS2
  385. +       /* We will not set the binary mode if we have
  386. +      another (verbose) option active.  */
  387. +       if (options == 0)
  388. +         {
  389. +       setmode (input_desc, O_BINARY);
  390. +       setmode (output_desc, O_BINARY);
  391. +         }
  392. + #endif
  393.         if (fstat (input_desc, &stat_buf) < 0)
  394.       {
  395.         error (0, errno, "%s", infile);
  396. ***************
  397. *** 655,660 ****
  398. --- 671,677 ----
  399.        stdout, and skip this input file if they coincide.  Input
  400.        files cannot be redirected to themselves.  */
  401.   
  402. + #ifndef OS2
  403.         if (check_redirection
  404.         && stat_buf.st_dev == out_dev && stat_buf.st_ino == out_ino
  405.         && (input_desc != STDIN_FILENO || output_desc != STDOUT_FILENO))
  406. ***************
  407. *** 663,668 ****
  408. --- 680,686 ----
  409.         exit_status = 1;
  410.         goto contin;
  411.       }
  412. + #endif
  413.   
  414.         /* Select which version of `cat' to use. If any options (more than -u,
  415.        --version, or --help) were specified, use `cat', otherwise use
  416. ***************
  417. *** 677,682 ****
  418. --- 695,703 ----
  419.       }
  420.         else
  421.       {
  422. + #ifdef OS2            /* the user wants it slow, he can get it! */
  423. +       insize = outsize = 0x1000;
  424. + #endif
  425.         inbuf = (unsigned char *) xmalloc (insize + 1);
  426.   
  427.         /* Why are (OUTSIZE  - 1 + INSIZE * 4 + 13) bytes allocated for
  428. ***************
  429. *** 712,717 ****
  430. --- 733,739 ----
  431.         error (0, errno, "%s", infile);
  432.         exit_status = 1;
  433.       }
  434. + #endif
  435.       }
  436.     while (++argind < argc);
  437.   
  438. diff -cbr orig/src/cksum.c new/src/cksum.c
  439. *** orig/src/cksum.c    Wed Apr 24 05:50:28 1996
  440. --- new/src/cksum.c    Sun Jul 28 12:50:06 1996
  441. ***************
  442. *** 209,215 ****
  443.       }
  444.     else
  445.       {
  446. !       fp = fopen (file, "r");
  447.         if (fp == NULL)
  448.       {
  449.         error (0, errno, "%s", file);
  450. --- 209,215 ----
  451.       }
  452.     else
  453.       {
  454. !       fp = fopen (file, "rb");
  455.         if (fp == NULL)
  456.       {
  457.         error (0, errno, "%s", file);
  458. ***************
  459. *** 265,270 ****
  460. --- 265,271 ----
  461.            program_name);
  462.     else
  463.       {
  464. +       print_version("cksum");
  465.         printf (_("\
  466.   Usage: %s [OPTION]... [FILE]...\n\
  467.   "),
  468. ***************
  469. *** 315,320 ****
  470. --- 316,323 ----
  471.   
  472.     if (optind >= argc)
  473.       {
  474. +       if (isatty (0))
  475. +         usage (0);
  476.         if (cksum ("-", 0) < 0)
  477.       errors = 1;
  478.       }
  479. diff -cbr orig/src/comm.c new/src/comm.c
  480. *** orig/src/comm.c    Wed Apr 24 05:50:28 1996
  481. --- new/src/comm.c    Sun Jul 28 12:50:08 1996
  482. ***************
  483. *** 65,70 ****
  484. --- 65,71 ----
  485.            program_name);
  486.     else
  487.       {
  488. +       print_version("comm");
  489.         printf (_("\
  490.   Usage: %s [OPTION]... LEFT_FILE RIGHT_FILE\n\
  491.   "),
  492. ***************
  493. *** 257,263 ****
  494.       usage (0);
  495.   
  496.     if (optind + 2 != argc)
  497. !     usage (1);
  498.   
  499.     exit (compare_files (argv + optind) == 0
  500.       ? EXIT_SUCCESS : EXIT_FAILURE);
  501. --- 258,264 ----
  502.       usage (0);
  503.   
  504.     if (optind + 2 != argc)
  505. !     usage (0);
  506.   
  507.     exit (compare_files (argv + optind) == 0
  508.       ? EXIT_SUCCESS : EXIT_FAILURE);
  509. diff -cbr orig/src/csplit.c new/src/csplit.c
  510. *** orig/src/csplit.c    Wed Apr 24 05:50:28 1996
  511. --- new/src/csplit.c    Sun Jul 28 12:50:08 1996
  512. ***************
  513. *** 1527,1534 ****
  514. --- 1527,1538 ----
  515.   
  516.     if (argc - optind < 2)
  517.       {
  518. + #ifdef OS2
  519. +       usage (0);
  520. + #else
  521.         error (0, 0, _("too few arguments"));
  522.         usage (1);
  523. + #endif
  524.       }
  525.   
  526.     if (suffix)
  527. ***************
  528. *** 1559,1564 ****
  529. --- 1563,1569 ----
  530.            program_name);
  531.     else
  532.       {
  533. +       print_version("csplit");
  534.         printf (_("\
  535.   Usage: %s [OPTION]... FILE PATTERN...\n\
  536.   "),
  537. diff -cbr orig/src/cut.c new/src/cut.c
  538. *** orig/src/cut.c    Wed Apr 24 05:49:18 1996
  539. --- new/src/cut.c    Sun Jul 28 12:50:08 1996
  540. ***************
  541. *** 194,199 ****
  542. --- 194,200 ----
  543.            program_name);
  544.     else
  545.       {
  546. +       print_version("cut");
  547.         printf (_("\
  548.   Usage: %s [OPTION]... [FILE]...\n\
  549.   "),
  550. ***************
  551. *** 744,750 ****
  552. --- 745,755 ----
  553.       usage (0);
  554.   
  555.     if (operating_mode == undefined_mode)
  556. + #ifdef OS2
  557. +     usage (0);
  558. + #else
  559.       FATAL_ERROR (_("you must specify a list of bytes, characters, or fields"));
  560. + #endif
  561.   
  562.     if (delim != '\0' && operating_mode != field_mode)
  563.       FATAL_ERROR (_("a delimiter may be specified only when operating on fields"));
  564. diff -cbr orig/src/expand.c new/src/expand.c
  565. *** orig/src/expand.c    Wed Apr 24 05:50:28 1996
  566. --- new/src/expand.c    Sun Jul 28 12:50:08 1996
  567. ***************
  568. *** 112,117 ****
  569. --- 112,118 ----
  570.            program_name);
  571.     else
  572.       {
  573. +       print_version("expand");
  574.         printf (_("\
  575.   Usage: %s [OPTION]... [FILE]...\n\
  576.   "),
  577. ***************
  578. *** 386,392 ****
  579. --- 387,397 ----
  580.       tab_size = 0;
  581.   
  582.     if (optind == argc)
  583. +     {
  584. +       if (isatty (0))
  585. +         usage (0);
  586.       file_list = stdin_argv;
  587. +     }
  588.     else
  589.       file_list = &argv[optind];
  590.   
  591. diff -cbr orig/src/fmt.c new/src/fmt.c
  592. *** orig/src/fmt.c    Wed Jul 10 02:22:52 1996
  593. --- new/src/fmt.c    Sun Jul 28 12:50:10 1996
  594. ***************
  595. *** 283,288 ****
  596. --- 283,289 ----
  597.            program_name);
  598.     else
  599.       {
  600. +       print_version("fmt");
  601.         printf (_("Usage: %s [-DIGITS] [OPTION]... [FILE]...\n"), program_name);
  602.         fputs (_("\
  603.   Reformat each paragraph in the FILE(s), writing to standard output.\n\
  604. ***************
  605. *** 407,413 ****
  606. --- 408,418 ----
  607.     best_width = max_width * (2 * (100 - LEEWAY) + 1) / 200;
  608.   
  609.     if (optind == argc)
  610. +   {
  611. +     if (isatty (0))
  612. +       usage (0);
  613.       fmt (stdin);
  614. +   }
  615.     else
  616.       for (; optind < argc; optind++)
  617.         if (strcmp (argv[optind], "-") == 0)
  618. diff -cbr orig/src/fold.c new/src/fold.c
  619. *** orig/src/fold.c    Wed Apr 24 05:50:28 1996
  620. --- new/src/fold.c    Sun Jul 28 12:50:10 1996
  621. ***************
  622. *** 81,86 ****
  623. --- 81,87 ----
  624.            program_name);
  625.     else
  626.       {
  627. +       print_version("fold");
  628.         printf (_("\
  629.   Usage: %s [OPTION]... [FILE]...\n\
  630.   "),
  631. ***************
  632. *** 317,323 ****
  633. --- 318,328 ----
  634.       usage (0);
  635.   
  636.     if (argc == optind)
  637. +     {
  638. +       if (isatty (0))
  639. +         usage (0);
  640.       errs |= fold_file ("-", width);
  641. +     }
  642.     else
  643.       for (i = optind; i < argc; i++)
  644.         errs |= fold_file (argv[i], width);
  645. diff -cbr orig/src/head.c new/src/head.c
  646. *** orig/src/head.c    Wed Apr 24 05:50:28 1996
  647. --- new/src/head.c    Sun Jul 28 12:50:10 1996
  648. ***************
  649. *** 29,34 ****
  650. --- 29,38 ----
  651.   #include <stdio.h>
  652.   #include <getopt.h>
  653.   #include <sys/types.h>
  654. + #ifdef OS2
  655. + #include <string.h>
  656. + #include <stdarg.h>
  657. + #endif
  658.   #include "system.h"
  659.   #include "error.h"
  660.   
  661. ***************
  662. *** 85,90 ****
  663. --- 89,95 ----
  664.            program_name);
  665.     else
  666.       {
  667. +       print_version("head");
  668.         printf (_("\
  669.   Usage: %s [OPTION]... [FILE]...\n\
  670.   "),
  671. ***************
  672. *** 211,220 ****
  673. --- 216,238 ----
  674.   static int
  675.   head (const char *filename, int fd, long int number)
  676.   {
  677. + #ifdef OS2
  678. +   int errors;
  679. +   _fsetmode (stdout, "b");
  680. +   setmode (fd, O_BINARY);
  681. +   if (unit_size)
  682. +     errors = head_bytes (filename, fd, number);
  683. +   else
  684. +     errors = head_lines (filename, fd, number);
  685. +   fflush (stdout);
  686. +   _fsetmode (stdout, "t");
  687. +   return errors;
  688. + #else
  689.     if (unit_size)
  690.       return head_bytes (filename, fd, number);
  691.     else
  692.       return head_lines (filename, fd, number);
  693. + #endif
  694.   }
  695.   
  696.   static int
  697. ***************
  698. *** 370,376 ****
  699. --- 388,398 ----
  700.       print_headers = 1;
  701.   
  702.     if (optind == argc)
  703. +   {
  704. +     if (isatty (0))
  705. +       usage (0);
  706.       exit_status |= head_file ("-", number);
  707. +   }
  708.   
  709.     for (; optind < argc; ++optind)
  710.       exit_status |= head_file (argv[optind], number);
  711. diff -cbr orig/src/join.c new/src/join.c
  712. *** orig/src/join.c    Wed Apr 24 05:50:28 1996
  713. --- new/src/join.c    Sun Jul 28 12:54:02 1996
  714. ***************
  715. *** 168,173 ****
  716. --- 168,174 ----
  717.            program_name);
  718.     else
  719.       {
  720. +       print_version("join");
  721.         printf (_("\
  722.   Usage: %s [OPTION]... FILE1 FILE2\n\
  723.   "),
  724. ***************
  725. *** 865,872 ****
  726. --- 866,877 ----
  727.   
  728.     if (nfiles != 2)
  729.       {
  730. + #ifdef OS2
  731. +       usage (0);
  732. + #else
  733.         error (0, 0, _("too few non-option arguments"));
  734.         usage (1);
  735. + #endif
  736.       }
  737.   
  738.     fp1 = strcmp (names[0], "-") ? fopen (names[0], "r") : stdin;
  739. diff -cbr orig/src/md5sum.c new/src/md5sum.c
  740. *** orig/src/md5sum.c    Thu Jul 04 23:50:12 1996
  741. --- new/src/md5sum.c    Sun Jul 28 12:50:12 1996
  742. ***************
  743. *** 34,43 ****
  744.   
  745.   /* Most systems do not distinguish between external and internal
  746.      text representations.  */
  747. ! #if UNIX || __UNIX__ || unix || __unix__ || _POSIX_VERSION
  748.   # define OPENOPTS(BINARY) "r"
  749.   #else
  750. ! # ifdef MSDOS
  751.   #  define TEXT1TO1 "rb"
  752.   #  define TEXTCNVT "r"
  753.   # else
  754. --- 34,43 ----
  755.   
  756.   /* Most systems do not distinguish between external and internal
  757.      text representations.  */
  758. ! #if !defined(OS2) && (UNIX || __UNIX__ || unix || __unix__ || _POSIX_VERSION)
  759.   # define OPENOPTS(BINARY) "r"
  760.   #else
  761. ! # if defined(MSDOS) || defined(OS2)
  762.   #  define TEXT1TO1 "rb"
  763.   #  define TEXTCNVT "r"
  764.   # else
  765. ***************
  766. *** 100,105 ****
  767. --- 100,107 ----
  768.       fprintf (stderr, _("Try `%s --help' for more information.\n"),
  769.            program_name);
  770.     else
  771. +   {
  772. +     print_version("md5sum");
  773.       printf (_("\
  774.   Usage: %s [OPTION] [FILE]...\n\
  775.     or:  %s [OPTION] --check [FILE]\n\
  776. ***************
  777. *** 124,129 ****
  778. --- 126,132 ----
  779.   a line with checksum, a character indicating type (`*' for binary, ` ' for\n\
  780.   text), and name for each FILE.\n"),
  781.           program_name, program_name, program_name);
  782. +   }
  783.   
  784.     exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
  785.   }
  786. ***************
  787. *** 558,564 ****
  788. --- 561,571 ----
  789.     else
  790.       {
  791.         if (optind == argc)
  792. +         {
  793. +           if (isatty (fileno (stdin)))
  794. +             usage (0);
  795.       argv[argc++] = "-";
  796. +     }
  797.   
  798.         for (; optind < argc; ++optind)
  799.       {
  800. diff -cbr orig/src/nl.c new/src/nl.c
  801. *** orig/src/nl.c    Wed Apr 24 05:50:28 1996
  802. --- new/src/nl.c    Sun Jul 28 12:50:14 1996
  803. ***************
  804. *** 191,196 ****
  805. --- 191,197 ----
  806.            program_name);
  807.     else
  808.       {
  809. +       print_version("nl");
  810.         printf (_("\
  811.   Usage: %s [OPTION]... [FILE]...\n\
  812.   "),
  813. ***************
  814. *** 617,623 ****
  815. --- 618,628 ----
  816.     /* Main processing. */
  817.   
  818.     if (optind == argc)
  819. +   {
  820. +     if (isatty (0))
  821. +       usage (0);
  822.       exit_status |= nl_file ("-");
  823. +   }
  824.     else
  825.       for (; optind < argc; optind++)
  826.         exit_status |= nl_file (argv[optind]);
  827. diff -cbr orig/src/od.c new/src/od.c
  828. *** orig/src/od.c    Thu May 30 08:40:24 1996
  829. --- new/src/od.c    Sun Jul 28 12:50:14 1996
  830. ***************
  831. *** 332,337 ****
  832. --- 332,338 ----
  833.            program_name);
  834.     else
  835.       {
  836. +       print_version("od");
  837.         printf (_("\
  838.   Usage: %s [OPTION]... [FILE]...\n\
  839.     or:  %s --traditional [FILE] [[+]OFFSET [[+]LABEL]]\n\
  840. ***************
  841. *** 983,993 ****
  842.         input_filename = _("standard input");
  843.         in_stream = stdin;
  844.         have_read_stdin = 1;
  845.       }
  846.         else
  847.       {
  848.         input_filename = *file_list;
  849. !       in_stream = fopen (input_filename, "r");
  850.         if (in_stream == NULL)
  851.           {
  852.             error (0, errno, "%s", input_filename);
  853. --- 984,997 ----
  854.         input_filename = _("standard input");
  855.         in_stream = stdin;
  856.         have_read_stdin = 1;
  857. + #ifdef __EMX__
  858. +       _fsetmode (in_stream, "b");
  859. + #endif
  860.       }
  861.         else
  862.       {
  863.         input_filename = *file_list;
  864. !       in_stream = fopen (input_filename, "rb");
  865.         if (in_stream == NULL)
  866.           {
  867.             error (0, errno, "%s", input_filename);
  868. ***************
  869. *** 1233,1243 ****
  870.             input_filename = _("standard input");
  871.             in_stream = stdin;
  872.             have_read_stdin = 1;
  873.           }
  874.         else
  875.           {
  876.             input_filename = *file_list;
  877. !           in_stream = fopen (input_filename, "r");
  878.             if (in_stream == NULL)
  879.           {
  880.             error (0, errno, "%s", input_filename);
  881. --- 1237,1250 ----
  882.             input_filename = _("standard input");
  883.             in_stream = stdin;
  884.             have_read_stdin = 1;
  885. + #ifdef __EMX__
  886. +           _fsetmode (in_stream, "b");
  887. + #endif
  888.           }
  889.         else
  890.           {
  891.             input_filename = *file_list;
  892. !           in_stream = fopen (input_filename, "rb");
  893.             if (in_stream == NULL)
  894.           {
  895.             error (0, errno, "%s", input_filename);
  896. ***************
  897. *** 1306,1316 ****
  898.             input_filename = _("standard input");
  899.             in_stream = stdin;
  900.             have_read_stdin = 1;
  901.           }
  902.         else
  903.           {
  904.             input_filename = *file_list;
  905. !           in_stream = fopen (input_filename, "r");
  906.             if (in_stream == NULL)
  907.           {
  908.             error (0, errno, "%s", input_filename);
  909. --- 1313,1326 ----
  910.             input_filename = _("standard input");
  911.             in_stream = stdin;
  912.             have_read_stdin = 1;
  913. + #ifdef __EMX__
  914. +           _fsetmode (in_stream, "b");
  915. + #endif
  916.           }
  917.         else
  918.           {
  919.             input_filename = *file_list;
  920. !           in_stream = fopen (input_filename, "rb");
  921.             if (in_stream == NULL)
  922.           {
  923.             error (0, errno, "%s", input_filename);
  924. ***************
  925. *** 1929,1934 ****
  926. --- 1939,1947 ----
  927.         static char const *const default_file_list[] = {"-", NULL};
  928.   
  929.         file_list = default_file_list;
  930. +       if (isatty (0))
  931. +         usage (0);
  932.       }
  933.   
  934.     err |= skip (n_bytes_to_skip);
  935. diff -cbr orig/src/paste.c new/src/paste.c
  936. *** orig/src/paste.c    Sun Mar 24 16:01:36 1996
  937. --- new/src/paste.c    Sun Jul 28 12:50:14 1996
  938. ***************
  939. *** 410,415 ****
  940. --- 410,416 ----
  941.            program_name);
  942.     else
  943.       {
  944. +       print_version("paste");
  945.         printf (_("\
  946.   Usage: %s [OPTION]... [FILE]...\n\
  947.   "),
  948. ***************
  949. *** 480,486 ****
  950. --- 481,491 ----
  951.       usage (0);
  952.   
  953.     if (optind == argc)
  954. +   {
  955. +     if (isatty (0))
  956. +       usage (0);
  957.       argv[argc++] = "-";
  958. +   }
  959.   
  960.     delim_end = collapse_escapes (delims);
  961.   
  962. diff -cbr orig/src/pr.c new/src/pr.c
  963. *** orig/src/pr.c    Wed Apr 24 05:50:28 1996
  964. --- new/src/pr.c    Sun Jul 28 12:50:14 1996
  965. ***************
  966. *** 638,643 ****
  967. --- 638,645 ----
  968.   
  969.     if (n_files == 0)
  970.       {
  971. +       if (isatty (0))
  972. +         usage (0);
  973.         /* No file arguments specified;  read from standard input.  */
  974.         print_files (0, (char **) 0);
  975.       }
  976. ***************
  977. *** 1851,1856 ****
  978. --- 1853,1859 ----
  979.            program_name);
  980.     else
  981.       {
  982. +       print_version("pr");
  983.         printf (_("\
  984.   Usage: %s [OPTION]... [FILE]...\n\
  985.   "),
  986. diff -cbr orig/src/sort.c new/src/sort.c
  987. *** orig/src/sort.c    Fri May 31 04:00:26 1996
  988. --- new/src/sort.c    Sun Jul 28 12:50:14 1996
  989. ***************
  990. *** 211,216 ****
  991. --- 211,217 ----
  992.            program_name);
  993.     else
  994.       {
  995. +       print_version("sort");
  996.         printf (_("\
  997.   Usage: %s [OPTION]... [FILE]...\n\
  998.   "),
  999. ***************
  1000. *** 408,414 ****
  1001. --- 409,419 ----
  1002.   
  1003.     node = (struct tempnode *) xmalloc (sizeof (struct tempnode));
  1004.     sprintf (name,
  1005. + #ifdef OS2
  1006. +        "%s%ssort%4.4x.%3.3x",
  1007. + #else
  1008.          "%s%ssort%5.5d%5.5d",
  1009. + #endif
  1010.          temp_file_prefix,
  1011.          (len && temp_file_prefix[len - 1] != '/') ? "/" : "",
  1012.          (unsigned int) getpid () & 0xffff, seq);
  1013. ***************
  1014. *** 1648,1654 ****
  1015. --- 1653,1663 ----
  1016.     signal (sig, SIG_DFL);
  1017.   #endif                /* SA_INTERRUPT */
  1018.     cleanup ();
  1019. + #ifdef OS2
  1020. +   raise (SIGINT);
  1021. + #else
  1022.     kill (getpid (), sig);
  1023. + #endif
  1024.   }
  1025.   
  1026.   /* Set the ordering options for KEY specified in S.
  1027. ***************
  1028. *** 1726,1732 ****
  1029. --- 1735,1745 ----
  1030.     have_read_stdin = 0;
  1031.     inittables ();
  1032.   
  1033. + #ifdef OS2
  1034. +   temp_file_prefix = getenv ("TMP");
  1035. + #else
  1036.     temp_file_prefix = getenv ("TMPDIR");
  1037. + #endif
  1038.     if (temp_file_prefix == NULL)
  1039.       temp_file_prefix = DEFAULT_TMPDIR;
  1040.   
  1041. ***************
  1042. *** 1750,1755 ****
  1043. --- 1763,1770 ----
  1044.   #else                /* !SA_INTERRUPT */
  1045.     if (signal (SIGINT, SIG_IGN) != SIG_IGN)
  1046.       signal (SIGINT, sighandler);
  1047. +   if (signal (SIGQUIT, SIG_IGN) != SIG_IGN)
  1048. +     signal (SIGQUIT, sighandler);
  1049.     if (signal (SIGHUP, SIG_IGN) != SIG_IGN)
  1050.       signal (SIGHUP, sighandler);
  1051.     if (signal (SIGPIPE, SIG_IGN) != SIG_IGN)
  1052. ***************
  1053. *** 2049,2054 ****
  1054. --- 2064,2071 ----
  1055.   
  1056.     if (nfiles == 0)
  1057.       {
  1058. +       if (isatty (0))
  1059. +         usage (0);
  1060.         nfiles = 1;
  1061.         files = −
  1062.       }
  1063. diff -cbr orig/src/split.c new/src/split.c
  1064. *** orig/src/split.c    Wed Apr 24 05:50:28 1996
  1065. --- new/src/split.c    Sun Jul 28 12:50:14 1996
  1066. ***************
  1067. *** 101,106 ****
  1068. --- 101,107 ----
  1069.            program_name);
  1070.     else
  1071.       {
  1072. +       print_version("split");
  1073.         printf (_("\
  1074.   Usage: %s [OPTION] [INPUT [PREFIX]]\n\
  1075.   "),
  1076. ***************
  1077. *** 181,187 ****
  1078.         next_file_name ();
  1079.         if (verbose)
  1080.       fprintf (stderr, _("creating file `%s'\n"), outfile);
  1081. !       output_desc = open (outfile, O_WRONLY | O_CREAT | O_TRUNC, 0666);
  1082.         if (output_desc < 0)
  1083.       error (EXIT_FAILURE, errno, "%s", outfile);
  1084.       }
  1085. --- 182,188 ----
  1086.         next_file_name ();
  1087.         if (verbose)
  1088.       fprintf (stderr, _("creating file `%s'\n"), outfile);
  1089. !       output_desc = open (outfile, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
  1090.         if (output_desc < 0)
  1091.       error (EXIT_FAILURE, errno, "%s", outfile);
  1092.       }
  1093. ***************
  1094. *** 484,493 ****
  1095.   
  1096.     /* Open the input file.  */
  1097.     if (!strcmp (infile, "-"))
  1098.       input_desc = 0;
  1099.     else
  1100.       {
  1101. !       input_desc = open (infile, O_RDONLY);
  1102.         if (input_desc < 0)
  1103.       error (EXIT_FAILURE, errno, "%s", infile);
  1104.       }
  1105. --- 485,498 ----
  1106.   
  1107.     /* Open the input file.  */
  1108.     if (!strcmp (infile, "-"))
  1109. +   {
  1110. +     if (isatty (0))
  1111. +       usage (0, (char *)0);
  1112.       input_desc = 0;
  1113. +   }
  1114.     else
  1115.       {
  1116. !       input_desc = open (infile, O_RDONLY | O_BINARY);
  1117.         if (input_desc < 0)
  1118.       error (EXIT_FAILURE, errno, "%s", infile);
  1119.       }
  1120. diff -cbr orig/src/sum.c new/src/sum.c
  1121. *** orig/src/sum.c    Wed Apr 24 05:50:28 1996
  1122. --- new/src/sum.c    Sun Jul 28 12:50:14 1996
  1123. ***************
  1124. *** 60,65 ****
  1125. --- 60,66 ----
  1126.            program_name);
  1127.     else
  1128.       {
  1129. +       print_version("sum");
  1130.         printf (_("\
  1131.   Usage: %s [OPTION]... [FILE]...\n\
  1132.   "),
  1133. ***************
  1134. *** 96,105 ****
  1135.       {
  1136.         fp = stdin;
  1137.         have_read_stdin = 1;
  1138.       }
  1139.     else
  1140.       {
  1141. !       fp = fopen (file, "r");
  1142.         if (fp == NULL)
  1143.       {
  1144.         error (0, errno, "%s", file);
  1145. --- 97,109 ----
  1146.       {
  1147.         fp = stdin;
  1148.         have_read_stdin = 1;
  1149. + #ifdef OS2
  1150. +       _fsetmode(stdin, "b");
  1151. + #endif
  1152.       }
  1153.     else
  1154.       {
  1155. !       fp = fopen (file, "rb");
  1156.         if (fp == NULL)
  1157.       {
  1158.         error (0, errno, "%s", file);
  1159. ***************
  1160. *** 155,164 ****
  1161.       {
  1162.         fd = 0;
  1163.         have_read_stdin = 1;
  1164.       }
  1165.     else
  1166.       {
  1167. !       fd = open (file, O_RDONLY);
  1168.         if (fd == -1)
  1169.       {
  1170.         error (0, errno, "%s", file);
  1171. --- 159,171 ----
  1172.       {
  1173.         fd = 0;
  1174.         have_read_stdin = 1;
  1175. + #ifdef OS2
  1176. +       setmode(0, O_BINARY);
  1177. + #endif
  1178.       }
  1179.     else
  1180.       {
  1181. !       fd = open (file, O_RDONLY | O_BINARY);
  1182.         if (fd == -1)
  1183.       {
  1184.         error (0, errno, "%s", file);
  1185. ***************
  1186. *** 244,249 ****
  1187. --- 251,258 ----
  1188.     files_given = argc - optind;
  1189.     if (files_given == 0)
  1190.       {
  1191. +       if (isatty (0))
  1192. +         usage (0);
  1193.         if ((*sum_func) ("-", files_given) < 0)
  1194.       errors = 1;
  1195.       }
  1196. diff -cbr orig/src/system.h new/src/system.h
  1197. *** orig/src/system.h    Sun May 05 02:48:00 1996
  1198. --- new/src/system.h    Sun Jul 28 13:01:24 1996
  1199. ***************
  1200. *** 138,143 ****
  1201. --- 138,146 ----
  1202.   
  1203.   /* Get or fake the disk device blocksize.
  1204.      Usually defined by sys/param.h (if at all).  */
  1205. + #ifdef OS2
  1206. + #define DEV_BSIZE 0x4000
  1207. + #endif /* OS2 */
  1208.   #if !defined(DEV_BSIZE) && defined(BSIZE)
  1209.   #define DEV_BSIZE BSIZE
  1210.   #endif
  1211. ***************
  1212. *** 214,223 ****
  1213.   #endif
  1214.   
  1215.   #if ENABLE_NLS
  1216. ! # include <libintl.h>
  1217.   # define _(Text) gettext (Text)
  1218.   #else
  1219.   # define bindtextdomain(Domain, Directory) /* empty */
  1220.   # define textdomain(Domain) /* empty */
  1221.   # define _(Text) Text
  1222.   #endif
  1223. --- 217,258 ----
  1224.   #endif
  1225.   
  1226.   #if ENABLE_NLS
  1227. ! # include <libgettext.h>
  1228.   # define _(Text) gettext (Text)
  1229.   #else
  1230.   # define bindtextdomain(Domain, Directory) /* empty */
  1231.   # define textdomain(Domain) /* empty */
  1232.   # define _(Text) Text
  1233. + #endif
  1234. + #define print_version(name) \
  1235. +   printf("\n%s - %s\n\n", PACKAGE_VERSION, name)
  1236. + #ifdef OS2
  1237. + #ifdef SIGHUP
  1238. + #undef SIGHUP
  1239. + #endif
  1240. + #define SIGHUP  SIGBREAK
  1241. + #define main(c, v) os2main(c, v)
  1242. + #undef islower
  1243. + #define islower(c) IsLower (c)
  1244. + #undef isupper
  1245. + #define isupper(c) IsUpper (c)
  1246. + #undef isalpha
  1247. + #define isalpha(c) (IsLower (c) || IsUpper (c))
  1248. + #undef isalnum
  1249. + #define isalnum(c) (IsLower (c) || IsUpper (c) || isdigit (c))
  1250. + #undef isprint
  1251. + #define isprint(c) IsPrint (c)
  1252. + #undef isgraph
  1253. + #define isgraph(c) (isprint (c) && !isspace (c))
  1254. + #undef tolower
  1255. + #define tolower(c) ToLower (c)
  1256. + #undef toupper
  1257. + #define toupper(c) ToUpper (c)
  1258. + #include <io.h>
  1259. + #endif
  1260. + #ifndef O_BINARY
  1261. + #define O_BINARY 0
  1262.   #endif
  1263. diff -cbr orig/src/tac.c new/src/tac.c
  1264. *** orig/src/tac.c    Wed Apr 24 05:50:28 1996
  1265. --- new/src/tac.c    Sun Jul 28 12:50:14 1996
  1266. ***************
  1267. *** 130,135 ****
  1268. --- 130,136 ----
  1269.            program_name);
  1270.     else
  1271.       {
  1272. +       print_version("tac");
  1273.         printf (_("\
  1274.   Usage: %s [OPTION]... [FILE]...\n\
  1275.   "),
  1276. ***************
  1277. *** 426,432 ****
  1278.   {
  1279.     int fd, errors;
  1280.   
  1281. !   fd = open (file, O_RDONLY);
  1282.     if (fd == -1)
  1283.       {
  1284.         error (0, errno, "%s", file);
  1285. --- 427,433 ----
  1286.   {
  1287.     int fd, errors;
  1288.   
  1289. !   fd = open (file, O_RDONLY | O_BINARY);
  1290.     if (fd == -1)
  1291.       {
  1292.         error (0, errno, "%s", file);
  1293. ***************
  1294. *** 453,458 ****
  1295. --- 454,474 ----
  1296.   
  1297.     if (template == NULL)
  1298.       {
  1299. + #ifdef OS2
  1300. +       tempdir = getenv ("TMP");
  1301. +       if (tempdir == NULL)
  1302. +         tempdir = getenv ("TEMP");
  1303. +       if (tempdir == NULL)
  1304. +     tempdir = DEFAULT_TMPDIR;
  1305. +       template = xmalloc (strlen (tempdir) + 10);
  1306. +     }
  1307. +   sprintf (template, "%s%stcXXXXXX", tempdir,
  1308. +        (tempdir[strlen (tempdir) - 1] != '/' &&
  1309. +         tempdir[strlen (tempdir) - 1] != '\\') ? "/" : "");
  1310. +   tempfile = mktemp (template);
  1311. +   fd = open (tempfile, O_CREAT|O_TRUNC|O_RDWR|O_BINARY, S_IWRITE|S_IREAD);
  1312. + #else
  1313.         tempdir = getenv ("TMPDIR");
  1314.         if (tempdir == NULL)
  1315.       tempdir = DEFAULT_TMPDIR;
  1316. ***************
  1317. *** 462,467 ****
  1318. --- 478,484 ----
  1319.     tempfile = mktemp (template);
  1320.   
  1321.     fd = creat (tempfile, 0600);
  1322. + #endif
  1323.     if (fd == -1)
  1324.       {
  1325.         error (0, errno, "%s", tempfile);
  1326. ***************
  1327. *** 656,661 ****
  1328. --- 673,686 ----
  1329.       }
  1330.     else
  1331.       ++buffer;
  1332. +   if (optind == argc && isatty (0))
  1333. +     usage (0);
  1334. + #ifdef OS2
  1335. +   setmode (0, O_BINARY);
  1336. +   setmode (1, O_BINARY);
  1337. + #endif /* OS2 */
  1338.   
  1339.     if (optind == argc)
  1340.       {
  1341. diff -cbr orig/src/tail.c new/src/tail.c
  1342. *** orig/src/tail.c    Fri May 31 04:30:32 1996
  1343. --- new/src/tail.c    Sun Jul 28 12:54:56 1996
  1344. ***************
  1345. *** 64,69 ****
  1346. --- 64,70 ----
  1347.         assert ((n_bytes) >= 0);                        \
  1348.         if (n_bytes > 0 && fwrite ((buffer), 1, (n_bytes), stdout) == 0)    \
  1349.       error (EXIT_FAILURE, errno, _("write error"));            \
  1350. +       fflush(stdout);                                                   \
  1351.       }                                    \
  1352.     while (0)
  1353.   
  1354. ***************
  1355. *** 139,144 ****
  1356. --- 140,146 ----
  1357.            program_name);
  1358.     else
  1359.       {
  1360. +       print_version("tail");
  1361.         printf (_("\
  1362.   Usage: %s [OPTION]... [FILE]...\n\
  1363.   "),
  1364. ***************
  1365. *** 736,745 ****
  1366. --- 738,760 ----
  1367.   static int
  1368.   tail (const char *filename, int fd, off_t n_units)
  1369.   {
  1370. + #ifdef OS2
  1371. +   int errors;
  1372. +   _fsetmode (stdout, "b");
  1373. +   setmode (fd, O_BINARY);
  1374. +   if (count_lines)
  1375. +     errors = tail_lines (filename, fd, n_units);
  1376. +   else
  1377. +     errors = tail_bytes (filename, fd, n_units);
  1378. +   fflush (stdout);
  1379. +   _fsetmode (stdout, "t");
  1380. +   return errors;
  1381. + #else
  1382.     if (count_lines)
  1383.       return tail_lines (filename, fd, (long) n_units);
  1384.     else
  1385.       return tail_bytes (filename, fd, n_units);
  1386. + #endif
  1387.   }
  1388.   
  1389.   /* Display the last N_UNITS units of file FILENAME.
  1390. ***************
  1391. *** 1012,1017 ****
  1392. --- 1027,1034 ----
  1393.   
  1394.     if (n_files == 0)
  1395.       {
  1396. +       if (isatty (0))
  1397. +         usage (0);
  1398.         exit_status |= tail_file ("-", n_units, 0);
  1399.       }
  1400.     else
  1401. diff -cbr orig/src/tr.c new/src/tr.c
  1402. *** orig/src/tr.c    Wed Apr 24 05:50:26 1996
  1403. --- new/src/tr.c    Sun Jul 28 13:09:32 1996
  1404. ***************
  1405. *** 354,359 ****
  1406. --- 354,360 ----
  1407.            program_name);
  1408.     else
  1409.       {
  1410. +       print_version("tr");
  1411.         printf (_("\
  1412.   Usage: %s [OPTION]... SET1 [SET2]\n\
  1413.   "),
  1414. ***************
  1415. *** 1815,1820 ****
  1416. --- 1816,1824 ----
  1417.     bindtextdomain (PACKAGE, LOCALEDIR);
  1418.     textdomain (PACKAGE);
  1419.   
  1420. +   if (argc == 1 && isatty (0))
  1421. +     usage (0);
  1422.     while ((c = getopt_long (argc, argv, "cdst", long_options,
  1423.                  (int *) 0)) != EOF)
  1424.       {
  1425. ***************
  1426. *** 1977,1982 ****
  1427. --- 1981,2008 ----
  1428.         for (;;)
  1429.           {
  1430.             c1 = get_next (s1, &class_s1);
  1431. + #ifdef OS2
  1432. + #define has_upper_or_lower(s) (s->has_char_class && !s->has_restricted_char_class)
  1433. +           if (has_upper_or_lower(s1) && has_upper_or_lower(s2))
  1434. +           {
  1435. +         /* The original approach does not work on OS/2 because
  1436. +          * the order of lower and upper case characters is not
  1437. +          * identical for the national language characters beyond
  1438. +          * the ASCII a-z/A-Z. (There are even more lower case
  1439. +          * than upper case characters!). 
  1440. +          *
  1441. +          * Fortunately, OS/2 provides a case mapping function we
  1442. +          * can use here (it is wrapped into lib/strcase.c and
  1443. +          * mapped to the standard ctype.h macros in system.h).  
  1444. +          */
  1445. +         c2 = (class_s1 == UL_UPPER) ? tolower(c1) : toupper (c1);
  1446. +         /* The following should have been checked by validate...  */
  1447. +         if (c1 == -1)
  1448. +           break;
  1449. +           }
  1450. +           else
  1451. + #endif
  1452. +           {
  1453.             c2 = get_next (s2, &class_s2);
  1454.             if (!class_ok[(int) class_s1][(int) class_s2])
  1455.           error (EXIT_FAILURE, 0,
  1456. ***************
  1457. *** 1984,1993 ****
  1458. --- 2010,2024 ----
  1459.             /* The following should have been checked by validate...  */
  1460.             if (c2 == -1)
  1461.           break;
  1462. +           }
  1463.             xlate[c1] = c2;
  1464.           }
  1465.         assert (c1 == -1 || truncate_set1);
  1466.       }
  1467. + #ifdef __EMX__
  1468. +       setmode (0, O_BINARY);
  1469. +       _fsetmode (stdout, "b");
  1470. + #endif
  1471.         if (squeeze_repeats)
  1472.       {
  1473.         set_initialize (s2, 0, in_squeeze_set);
  1474. diff -cbr orig/src/unexpand.c new/src/unexpand.c
  1475. *** orig/src/unexpand.c    Wed Apr 24 05:50:26 1996
  1476. --- new/src/unexpand.c    Sun Jul 28 12:50:14 1996
  1477. ***************
  1478. *** 356,361 ****
  1479. --- 356,362 ----
  1480.            program_name);
  1481.     else
  1482.       {
  1483. +       print_version("unexpand");
  1484.         printf (_("\
  1485.   Usage: %s [OPTION]... [FILE]...\n\
  1486.   "),
  1487. ***************
  1488. *** 443,449 ****
  1489. --- 444,454 ----
  1490.       tab_size = 0;
  1491.   
  1492.     if (optind == argc)
  1493. +     {
  1494. +       if (isatty (0))
  1495. +         usage (0);
  1496.       file_list = stdin_argv;
  1497. +     }
  1498.     else
  1499.       file_list = &argv[optind];
  1500.   
  1501. diff -cbr orig/src/uniq.c new/src/uniq.c
  1502. *** orig/src/uniq.c    Fri Jul 05 03:21:40 1996
  1503. --- new/src/uniq.c    Sun Jul 28 12:50:14 1996
  1504. ***************
  1505. *** 111,116 ****
  1506. --- 111,117 ----
  1507.            program_name);
  1508.     else
  1509.       {
  1510. +       print_version("uniq");
  1511.         printf (_("\
  1512.   Usage: %s [OPTION]... [INPUT [OUTPUT]]\n\
  1513.   "),
  1514. ***************
  1515. *** 406,411 ****
  1516. --- 407,415 ----
  1517.         skip_chars = (int) tmp_long;
  1518.       }
  1519.       }
  1520. +   if (optind == argc && isatty (0))
  1521. +     usage (0);            /* No arguments. */
  1522.   
  1523.     if (optind < argc)
  1524.       infile = argv[optind++];
  1525. diff -cbr orig/src/wc.c new/src/wc.c
  1526. *** orig/src/wc.c    Wed Apr 24 05:50:24 1996
  1527. --- new/src/wc.c    Sun Jul 28 12:50:14 1996
  1528. ***************
  1529. *** 52,60 ****
  1530.   /* If nonzero, print the version on standard output then exits.  */
  1531.   static int show_version;
  1532.   
  1533.   static struct option const longopts[] =
  1534.   {
  1535. !   {"bytes", no_argument, NULL, 'c'},
  1536.     {"chars", no_argument, NULL, 'c'},
  1537.     {"lines", no_argument, NULL, 'l'},
  1538.     {"words", no_argument, NULL, 'w'},
  1539. --- 52,63 ----
  1540.   /* If nonzero, print the version on standard output then exits.  */
  1541.   static int show_version;
  1542.   
  1543. + /* read in binary mode? */
  1544. + static int bin_mode;
  1545.   static struct option const longopts[] =
  1546.   {
  1547. !   {"bytes", no_argument, NULL, 'b'},
  1548.     {"chars", no_argument, NULL, 'c'},
  1549.     {"lines", no_argument, NULL, 'l'},
  1550.     {"words", no_argument, NULL, 'w'},
  1551. ***************
  1552. *** 71,87 ****
  1553.            program_name);
  1554.     else
  1555.       {
  1556.         printf (_("\
  1557.   Usage: %s [OPTION]... [FILE]...\n\
  1558.   "),
  1559.             program_name);
  1560. !       printf (_("\
  1561.   Print line, word, and byte counts for each FILE, and a total line if\n\
  1562.   more than one FILE is specified.  With no FILE, or when FILE is -,\n\
  1563. ! read standard input.\n\
  1564.     -l, --lines            print the newline counts\n\
  1565.     -w, --words            print the word counts\n\
  1566. !   -c, --bytes, --chars   print the byte counts\n\
  1567.         --help             display this help and exit\n\
  1568.         --version          output version information and exit\n\
  1569.   "));
  1570. --- 74,92 ----
  1571.            program_name);
  1572.     else
  1573.       {
  1574. +       print_version("wc");
  1575.         printf (_("\
  1576.   Usage: %s [OPTION]... [FILE]...\n\
  1577.   "),
  1578.             program_name);
  1579. !       printf (_("\n\
  1580.   Print line, word, and byte counts for each FILE, and a total line if\n\
  1581.   more than one FILE is specified.  With no FILE, or when FILE is -,\n\
  1582. ! read standard input.\n\n\
  1583.     -l, --lines            print the newline counts\n\
  1584.     -w, --words            print the word counts\n\
  1585. !   -b, --bytes            print the byte counts
  1586. !   -c, --chars            print the character counts\n\
  1587.         --help             display this help and exit\n\
  1588.         --version          output version information and exit\n\
  1589.   "));
  1590. ***************
  1591. *** 121,126 ****
  1592. --- 126,134 ----
  1593.     register unsigned long lines, words, chars;
  1594.   
  1595.     lines = words = chars = 0;
  1596. + #ifdef OS2
  1597. +   setmode (fd, bin_mode ? O_BINARY : O_TEXT);
  1598. + #endif
  1599.   
  1600.     /* When counting only bytes, save some line- and word-counting
  1601.        overhead.  If FD is a `regular' Unix file, using lseek is enough
  1602. ***************
  1603. *** 132,138 ****
  1604.        `(dd ibs=99k skip=1 count=0; ./wc -c) < /etc/group'
  1605.        should make wc report `0' bytes.  */
  1606.   
  1607. !   if (print_chars && !print_words && !print_lines)
  1608.       {
  1609.         off_t current_pos, end_pos;
  1610.         struct stat stats;
  1611. --- 140,146 ----
  1612.        `(dd ibs=99k skip=1 count=0; ./wc -c) < /etc/group'
  1613.        should make wc report `0' bytes.  */
  1614.   
  1615. !   if (print_chars && !print_words && !print_lines && bin_mode)
  1616.       {
  1617.         off_t current_pos, end_pos;
  1618.         struct stat stats;
  1619. ***************
  1620. *** 268,281 ****
  1621.     print_lines = print_words = print_chars = 0;
  1622.     total_lines = total_words = total_chars = 0;
  1623.   
  1624. !   while ((optc = getopt_long (argc, argv, "clw", longopts, (int *) 0)) != EOF)
  1625.       switch (optc)
  1626.         {
  1627.         case 0:
  1628.       break;
  1629.   
  1630.         case 'c':
  1631.       print_chars = 1;
  1632.       break;
  1633.   
  1634.         case 'l':
  1635. --- 276,295 ----
  1636.     print_lines = print_words = print_chars = 0;
  1637.     total_lines = total_words = total_chars = 0;
  1638.   
  1639. !   while ((optc = getopt_long (argc, argv, "bclw", longopts, (int *) 0)) != EOF)
  1640.       switch (optc)
  1641.         {
  1642.         case 0:
  1643.       break;
  1644.   
  1645. +       case 'b':
  1646. +     print_chars = 1;
  1647. +         bin_mode = 1;
  1648. +     break;
  1649.         case 'c':
  1650.       print_chars = 1;
  1651. +         bin_mode = 0;
  1652.       break;
  1653.   
  1654.         case 'l':
  1655. ***************
  1656. *** 300,311 ****
  1657.       usage (0);
  1658.   
  1659.     if (print_lines + print_words + print_chars == 0)
  1660. !     print_lines = print_words = print_chars = 1;
  1661.   
  1662.     nfiles = argc - optind;
  1663.   
  1664.     if (nfiles == 0)
  1665.       {
  1666.         have_read_stdin = 1;
  1667.         wc (0, "");
  1668.       }
  1669. --- 314,327 ----
  1670.       usage (0);
  1671.   
  1672.     if (print_lines + print_words + print_chars == 0)
  1673. !     print_lines = print_words = print_chars = bin_mode = 1;
  1674.   
  1675.     nfiles = argc - optind;
  1676.   
  1677.     if (nfiles == 0)
  1678.       {
  1679. +       if (isatty (0))
  1680. +         usage (0);
  1681.         have_read_stdin = 1;
  1682.         wc (0, "");
  1683.       }
  1684.