home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 22 gnu
/
22-gnu.zip
/
gnututil.zip
/
patches.os2
< prev
next >
Wrap
Text File
|
1996-08-07
|
43KB
|
1,710 lines
Only in new: README.OS2
Only in new: FILE_ID.DIZ
Only in new: Makefile.os2
Only in new: config.h.os2
Only in new: patches.os2
Only in new/intl: Makefile.os2
Only in new/intl: gnuintl.def
Only in new/lib: Makefile.os2
Only in new/lib: gnuregex.def
Only in new/lib: gnurx.def
Only in new/lib: gnutu.def
Only in new/lib: strcase.c
Only in new/src: Makefile.os2
Only in new/src: gnututil.def
Only in new/src: os2main.c
diff -cbr orig/intl/bindtextdom.c new/intl/bindtextdom.c
*** orig/intl/bindtextdom.c Sat Jul 06 03:52:36 1996
--- new/intl/bindtextdom.c Sun Jul 28 12:46:06 1996
***************
*** 46,52 ****
/* @@ end of prolog @@ */
/* Contains the default location of the message catalogs. */
! extern const char _nl_default_dirname[];
/* List with bindings of specific domains. */
extern struct binding *_nl_domain_bindings;
--- 46,52 ----
/* @@ end of prolog @@ */
/* Contains the default location of the message catalogs. */
! extern const char *_nl_default_dirname;
/* List with bindings of specific domains. */
extern struct binding *_nl_domain_bindings;
***************
*** 70,75 ****
--- 70,78 ----
const char *dirname;
{
struct binding *binding;
+
+ if (_nl_default_dirname == NULL)
+ _nl_default_dirname = GNULOCALEDIR;
/* Some sanity checks. */
if (domainname == NULL || domainname[0] == '\0')
diff -cbr orig/intl/dcgettext.c new/intl/dcgettext.c
*** orig/intl/dcgettext.c Sat Jul 06 03:52:36 1996
--- new/intl/dcgettext.c Wed Aug 07 17:47:18 1996
***************
*** 151,157 ****
const char *_nl_current_default_domain = _nl_default_default_domain;
/* Contains the default location of the message catalogs. */
! const char _nl_default_dirname[] = GNULOCALEDIR;
/* List with bindings of specific domains created by bindtextdomain()
calls. */
--- 151,157 ----
const char *_nl_current_default_domain = _nl_default_default_domain;
/* Contains the default location of the message catalogs. */
! const char *_nl_default_dirname = NULL;
/* List with bindings of specific domains created by bindtextdomain()
calls. */
***************
*** 235,240 ****
--- 234,242 ----
if (msgid == NULL)
return NULL;
+ if (_nl_default_dirname == NULL)
+ _nl_default_dirname = GNULOCALEDIR;
+
/* If DOMAINNAME is NULL, we are interested in the default domain. If
CATEGORY is not LC_MESSAGES this might not make much sense but the
defintion left this undefined. */
***************
*** 258,264 ****
--- 260,273 ----
if (binding == NULL)
dirname = (char *) _nl_default_dirname;
+ #ifdef OS2
+ #define getcwd _getcwd2
+ /* we have to deal with drive letters here and with getcwd below */
+ else if (binding->dirname[0] == '/' ||
+ isalpha(binding->dirname[0]) && binding->dirname[1] == ':')
+ #else
else if (binding->dirname[0] == '/')
+ #endif
dirname = binding->dirname;
else
{
diff -cbr orig/intl/gettext.h new/intl/gettext.h
*** orig/intl/gettext.h Sat Jul 06 03:52:38 1996
--- new/intl/gettext.h Wed Aug 07 15:34:46 1996
***************
*** 25,30 ****
--- 25,36 ----
# include <limits.h>
#endif
+ #ifdef OS2
+ #define PATH_SEPARATOR ';'
+ #else
+ #define PATH_SEPARATOR ':'
+ #endif
+
/* @@ end of prolog @@ */
/* The magic number of the GNU message catalog format. */
diff -cbr orig/intl/libgettext.h new/intl/libgettext.h
*** orig/intl/libgettext.h Sat Jul 06 03:52:38 1996
--- new/intl/libgettext.h Wed Aug 07 17:41:38 1996
***************
*** 36,41 ****
--- 36,49 ----
# include <locale.h>
#endif
+ #ifdef OS2
+ #define CheckEnv(e, d) ({char *v = getenv(e); v ? v : (d);})
+ #define StrCat(s1, s2) ({int l = strlen(s1) + strlen(s2); \
+ char *r = malloc(l); strcpy(r, s1); strcat(r, s2); r;})
+ #define GNULOCALEDIR CheckEnv("GNULOCALEDIR","/lib/glocale")
+ #define LOCALE_ALIAS_PATH StrCat(GNULOCALEDIR, ";.")
+ #define LOCALEDIR CheckEnv("LOCALEDIR","/lib/locale")
+ #endif
#ifdef __cplusplus
extern "C" {
diff -cbr orig/intl/loadmsgcat.c new/intl/loadmsgcat.c
*** orig/intl/loadmsgcat.c Sat Jul 06 03:52:40 1996
--- new/intl/loadmsgcat.c Wed Aug 07 17:49:48 1996
***************
*** 38,43 ****
--- 38,47 ----
#include "gettext.h"
#include "gettextP.h"
+ #ifndef O_BINARY
+ #define O_BINARY 0
+ #endif
+
/* @@ end of prolog @@ */
#ifdef _LIBC
***************
*** 58,63 ****
--- 62,92 ----
int _nl_msg_cat_cntr;
+ #ifdef OS2
+
+ #include <string.h>
+
+ /* quick hack to at least translate german umlauts from Latin-1 to
+ Codepage 850/437 - needs to be extended to other NLS characters */
+
+ static char *cp850 = "\x84\x94\x81\x8E\x99\x9A\xE1";
+ static char *latin1 = "\xE4\xF6\xFC\xC4\xD6\xDC\xDF";
+
+ static void recode_msg (char *msg)
+ {
+ char *ptr = msg;
+ int len = strlen (msg), pos;
+
+ while ((pos = strcspn(ptr, latin1)) < len)
+ {
+ ptr[pos] = cp850[strchr(latin1, ptr[pos]) - latin1];
+ ptr += pos + 1;
+ len -= pos + 1;
+ }
+ }
+
+ #endif
+
/* Load the message catalogs specified by FILENAME. If it is no valid
message catalog do nothing. */
void
***************
*** 84,90 ****
return;
/* Try to open the addressed file. */
! fd = open (domain_file->filename, O_RDONLY);
if (fd == -1)
return;
--- 113,119 ----
return;
/* Try to open the addressed file. */
! fd = open (domain_file->filename, O_RDONLY | O_BINARY);
if (fd == -1)
return;
***************
*** 192,197 ****
--- 221,235 ----
domain_file->data = NULL;
return;
}
+
+ #ifdef OS2
+ {
+ int i;
+ for (i = 0; i < domain->nstrings; i++)
+ recode_msg ((char *) domain->data + W (domain->must_swap,
+ domain->trans_tab[i].offset));
+ }
+ #endif
/* Show that one domain is changed. This might make some cached
translations invalid. */
diff -cbr orig/intl/localealias.c new/intl/localealias.c
*** orig/intl/localealias.c Sat Jul 06 03:52:40 1996
--- new/intl/localealias.c Wed Aug 07 15:54:34 1996
***************
*** 65,70 ****
--- 65,75 ----
# endif
#endif
+ #ifdef _LIBC
+ # include <libintl.h>
+ #else
+ # include "libgettext.h"
+ #endif
#include "gettext.h"
#include "gettextP.h"
***************
*** 137,146 ****
_nl_expand_alias (name)
const char *name;
{
! static const char *locale_alias_path = LOCALE_ALIAS_PATH;
struct alias_map *retval;
size_t added;
do
{
struct alias_map item;
--- 142,154 ----
_nl_expand_alias (name)
const char *name;
{
! static const char *locale_alias_path = NULL;
struct alias_map *retval;
size_t added;
+ if (locale_alias_path == NULL)
+ locale_alias_path = LOCALE_ALIAS_PATH;
+
do
{
struct alias_map item;
***************
*** 166,176 ****
{
const char *start;
! while (locale_alias_path[0] == ':')
++locale_alias_path;
start = locale_alias_path;
! while (locale_alias_path[0] != '\0' && locale_alias_path[0] != ':')
++locale_alias_path;
if (start < locale_alias_path)
--- 174,184 ----
{
const char *start;
! while (locale_alias_path[0] == PATH_SEPARATOR)
++locale_alias_path;
start = locale_alias_path;
! while (locale_alias_path[0] != '\0' && locale_alias_path[0] != PATH_SEPARATOR)
++locale_alias_path;
if (start < locale_alias_path)
diff -cbr orig/lib/error.c new/lib/error.c
*** orig/lib/error.c Fri Apr 19 00:01:12 1996
--- new/lib/error.c Sun Jul 28 12:51:22 1996
***************
*** 80,90 ****
private_strerror (errnum)
int errnum;
{
extern char *sys_errlist[];
extern int sys_nerr;
if (errnum > 0 && errnum <= sys_nerr)
! return sys_errlist[errnum];
return _("Unknown system error");
}
# define strerror private_strerror
--- 80,92 ----
private_strerror (errnum)
int errnum;
{
+ #ifndef __EMX__
extern char *sys_errlist[];
extern int sys_nerr;
+ #endif
if (errnum > 0 && errnum <= sys_nerr)
! return (char *) sys_errlist[errnum];
return _("Unknown system error");
}
# define strerror private_strerror
***************
*** 96,101 ****
--- 98,111 ----
If ERRNUM is nonzero, print its corresponding system error message.
Exit with status STATUS if it is nonzero. */
/* VARARGS */
+
+ #ifdef __EMX__
+ char *program_name;
+ void set_program_name(char *name)
+ {
+ program_name = name;
+ }
+ #endif
void
#if defined(VA_START) && __STDC__
diff -cbr orig/src/cat.c new/src/cat.c
*** orig/src/cat.c Sun May 26 23:53:28 1996
--- new/src/cat.c Sun Jul 28 12:50:06 1996
***************
*** 82,87 ****
--- 82,88 ----
program_name);
else
{
+ print_version("cat");
printf (_("\
Usage: %s [OPTION] [FILE]...\n\
"),
***************
*** 270,275 ****
--- 271,279 ----
if (use_fionread
&& ioctl (input_desc, FIONREAD, &n_to_read) < 0)
{
+ #ifdef __EMX__
+ use_fionread = 0;
+ #else
/* Ultrix returns EOPNOTSUPP on NFS;
HP-UX returns ENOTTY on pipes.
SunOS returns EINVAL and
***************
*** 290,298 ****
newlines2 = newlines;
return;
}
}
if (n_to_read == 0)
- #endif
{
int n_write = bpout - outbuf;
--- 294,302 ----
newlines2 = newlines;
return;
}
+ #endif
}
if (n_to_read == 0)
{
int n_write = bpout - outbuf;
***************
*** 621,626 ****
--- 625,633 ----
infile = "-";
argind = optind;
+ if (optind == argc && isatty (0))
+ usage (0);
+
do
{
if (argind < argc)
***************
*** 642,647 ****
--- 649,663 ----
}
}
+ #ifdef OS2
+ /* We will not set the binary mode if we have
+ another (verbose) option active. */
+ if (options == 0)
+ {
+ setmode (input_desc, O_BINARY);
+ setmode (output_desc, O_BINARY);
+ }
+ #endif
if (fstat (input_desc, &stat_buf) < 0)
{
error (0, errno, "%s", infile);
***************
*** 655,660 ****
--- 671,677 ----
stdout, and skip this input file if they coincide. Input
files cannot be redirected to themselves. */
+ #ifndef OS2
if (check_redirection
&& stat_buf.st_dev == out_dev && stat_buf.st_ino == out_ino
&& (input_desc != STDIN_FILENO || output_desc != STDOUT_FILENO))
***************
*** 663,668 ****
--- 680,686 ----
exit_status = 1;
goto contin;
}
+ #endif
/* Select which version of `cat' to use. If any options (more than -u,
--version, or --help) were specified, use `cat', otherwise use
***************
*** 677,682 ****
--- 695,703 ----
}
else
{
+ #ifdef OS2 /* the user wants it slow, he can get it! */
+ insize = outsize = 0x1000;
+ #endif
inbuf = (unsigned char *) xmalloc (insize + 1);
/* Why are (OUTSIZE - 1 + INSIZE * 4 + 13) bytes allocated for
***************
*** 712,717 ****
--- 733,739 ----
error (0, errno, "%s", infile);
exit_status = 1;
}
+ #endif
}
while (++argind < argc);
diff -cbr orig/src/cksum.c new/src/cksum.c
*** orig/src/cksum.c Wed Apr 24 05:50:28 1996
--- new/src/cksum.c Sun Jul 28 12:50:06 1996
***************
*** 209,215 ****
}
else
{
! fp = fopen (file, "r");
if (fp == NULL)
{
error (0, errno, "%s", file);
--- 209,215 ----
}
else
{
! fp = fopen (file, "rb");
if (fp == NULL)
{
error (0, errno, "%s", file);
***************
*** 265,270 ****
--- 265,271 ----
program_name);
else
{
+ print_version("cksum");
printf (_("\
Usage: %s [OPTION]... [FILE]...\n\
"),
***************
*** 315,320 ****
--- 316,323 ----
if (optind >= argc)
{
+ if (isatty (0))
+ usage (0);
if (cksum ("-", 0) < 0)
errors = 1;
}
diff -cbr orig/src/comm.c new/src/comm.c
*** orig/src/comm.c Wed Apr 24 05:50:28 1996
--- new/src/comm.c Sun Jul 28 12:50:08 1996
***************
*** 65,70 ****
--- 65,71 ----
program_name);
else
{
+ print_version("comm");
printf (_("\
Usage: %s [OPTION]... LEFT_FILE RIGHT_FILE\n\
"),
***************
*** 257,263 ****
usage (0);
if (optind + 2 != argc)
! usage (1);
exit (compare_files (argv + optind) == 0
? EXIT_SUCCESS : EXIT_FAILURE);
--- 258,264 ----
usage (0);
if (optind + 2 != argc)
! usage (0);
exit (compare_files (argv + optind) == 0
? EXIT_SUCCESS : EXIT_FAILURE);
diff -cbr orig/src/csplit.c new/src/csplit.c
*** orig/src/csplit.c Wed Apr 24 05:50:28 1996
--- new/src/csplit.c Sun Jul 28 12:50:08 1996
***************
*** 1527,1534 ****
--- 1527,1538 ----
if (argc - optind < 2)
{
+ #ifdef OS2
+ usage (0);
+ #else
error (0, 0, _("too few arguments"));
usage (1);
+ #endif
}
if (suffix)
***************
*** 1559,1564 ****
--- 1563,1569 ----
program_name);
else
{
+ print_version("csplit");
printf (_("\
Usage: %s [OPTION]... FILE PATTERN...\n\
"),
diff -cbr orig/src/cut.c new/src/cut.c
*** orig/src/cut.c Wed Apr 24 05:49:18 1996
--- new/src/cut.c Sun Jul 28 12:50:08 1996
***************
*** 194,199 ****
--- 194,200 ----
program_name);
else
{
+ print_version("cut");
printf (_("\
Usage: %s [OPTION]... [FILE]...\n\
"),
***************
*** 744,750 ****
--- 745,755 ----
usage (0);
if (operating_mode == undefined_mode)
+ #ifdef OS2
+ usage (0);
+ #else
FATAL_ERROR (_("you must specify a list of bytes, characters, or fields"));
+ #endif
if (delim != '\0' && operating_mode != field_mode)
FATAL_ERROR (_("a delimiter may be specified only when operating on fields"));
diff -cbr orig/src/expand.c new/src/expand.c
*** orig/src/expand.c Wed Apr 24 05:50:28 1996
--- new/src/expand.c Sun Jul 28 12:50:08 1996
***************
*** 112,117 ****
--- 112,118 ----
program_name);
else
{
+ print_version("expand");
printf (_("\
Usage: %s [OPTION]... [FILE]...\n\
"),
***************
*** 386,392 ****
--- 387,397 ----
tab_size = 0;
if (optind == argc)
+ {
+ if (isatty (0))
+ usage (0);
file_list = stdin_argv;
+ }
else
file_list = &argv[optind];
diff -cbr orig/src/fmt.c new/src/fmt.c
*** orig/src/fmt.c Wed Jul 10 02:22:52 1996
--- new/src/fmt.c Sun Jul 28 12:50:10 1996
***************
*** 283,288 ****
--- 283,289 ----
program_name);
else
{
+ print_version("fmt");
printf (_("Usage: %s [-DIGITS] [OPTION]... [FILE]...\n"), program_name);
fputs (_("\
Reformat each paragraph in the FILE(s), writing to standard output.\n\
***************
*** 407,413 ****
--- 408,418 ----
best_width = max_width * (2 * (100 - LEEWAY) + 1) / 200;
if (optind == argc)
+ {
+ if (isatty (0))
+ usage (0);
fmt (stdin);
+ }
else
for (; optind < argc; optind++)
if (strcmp (argv[optind], "-") == 0)
diff -cbr orig/src/fold.c new/src/fold.c
*** orig/src/fold.c Wed Apr 24 05:50:28 1996
--- new/src/fold.c Sun Jul 28 12:50:10 1996
***************
*** 81,86 ****
--- 81,87 ----
program_name);
else
{
+ print_version("fold");
printf (_("\
Usage: %s [OPTION]... [FILE]...\n\
"),
***************
*** 317,323 ****
--- 318,328 ----
usage (0);
if (argc == optind)
+ {
+ if (isatty (0))
+ usage (0);
errs |= fold_file ("-", width);
+ }
else
for (i = optind; i < argc; i++)
errs |= fold_file (argv[i], width);
diff -cbr orig/src/head.c new/src/head.c
*** orig/src/head.c Wed Apr 24 05:50:28 1996
--- new/src/head.c Sun Jul 28 12:50:10 1996
***************
*** 29,34 ****
--- 29,38 ----
#include <stdio.h>
#include <getopt.h>
#include <sys/types.h>
+ #ifdef OS2
+ #include <string.h>
+ #include <stdarg.h>
+ #endif
#include "system.h"
#include "error.h"
***************
*** 85,90 ****
--- 89,95 ----
program_name);
else
{
+ print_version("head");
printf (_("\
Usage: %s [OPTION]... [FILE]...\n\
"),
***************
*** 211,220 ****
--- 216,238 ----
static int
head (const char *filename, int fd, long int number)
{
+ #ifdef OS2
+ int errors;
+ _fsetmode (stdout, "b");
+ setmode (fd, O_BINARY);
+ if (unit_size)
+ errors = head_bytes (filename, fd, number);
+ else
+ errors = head_lines (filename, fd, number);
+ fflush (stdout);
+ _fsetmode (stdout, "t");
+ return errors;
+ #else
if (unit_size)
return head_bytes (filename, fd, number);
else
return head_lines (filename, fd, number);
+ #endif
}
static int
***************
*** 370,376 ****
--- 388,398 ----
print_headers = 1;
if (optind == argc)
+ {
+ if (isatty (0))
+ usage (0);
exit_status |= head_file ("-", number);
+ }
for (; optind < argc; ++optind)
exit_status |= head_file (argv[optind], number);
diff -cbr orig/src/join.c new/src/join.c
*** orig/src/join.c Wed Apr 24 05:50:28 1996
--- new/src/join.c Sun Jul 28 12:54:02 1996
***************
*** 168,173 ****
--- 168,174 ----
program_name);
else
{
+ print_version("join");
printf (_("\
Usage: %s [OPTION]... FILE1 FILE2\n\
"),
***************
*** 865,872 ****
--- 866,877 ----
if (nfiles != 2)
{
+ #ifdef OS2
+ usage (0);
+ #else
error (0, 0, _("too few non-option arguments"));
usage (1);
+ #endif
}
fp1 = strcmp (names[0], "-") ? fopen (names[0], "r") : stdin;
diff -cbr orig/src/md5sum.c new/src/md5sum.c
*** orig/src/md5sum.c Thu Jul 04 23:50:12 1996
--- new/src/md5sum.c Sun Jul 28 12:50:12 1996
***************
*** 34,43 ****
/* Most systems do not distinguish between external and internal
text representations. */
! #if UNIX || __UNIX__ || unix || __unix__ || _POSIX_VERSION
# define OPENOPTS(BINARY) "r"
#else
! # ifdef MSDOS
# define TEXT1TO1 "rb"
# define TEXTCNVT "r"
# else
--- 34,43 ----
/* Most systems do not distinguish between external and internal
text representations. */
! #if !defined(OS2) && (UNIX || __UNIX__ || unix || __unix__ || _POSIX_VERSION)
# define OPENOPTS(BINARY) "r"
#else
! # if defined(MSDOS) || defined(OS2)
# define TEXT1TO1 "rb"
# define TEXTCNVT "r"
# else
***************
*** 100,105 ****
--- 100,107 ----
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
+ {
+ print_version("md5sum");
printf (_("\
Usage: %s [OPTION] [FILE]...\n\
or: %s [OPTION] --check [FILE]\n\
***************
*** 124,129 ****
--- 126,132 ----
a line with checksum, a character indicating type (`*' for binary, ` ' for\n\
text), and name for each FILE.\n"),
program_name, program_name, program_name);
+ }
exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
***************
*** 558,564 ****
--- 561,571 ----
else
{
if (optind == argc)
+ {
+ if (isatty (fileno (stdin)))
+ usage (0);
argv[argc++] = "-";
+ }
for (; optind < argc; ++optind)
{
diff -cbr orig/src/nl.c new/src/nl.c
*** orig/src/nl.c Wed Apr 24 05:50:28 1996
--- new/src/nl.c Sun Jul 28 12:50:14 1996
***************
*** 191,196 ****
--- 191,197 ----
program_name);
else
{
+ print_version("nl");
printf (_("\
Usage: %s [OPTION]... [FILE]...\n\
"),
***************
*** 617,623 ****
--- 618,628 ----
/* Main processing. */
if (optind == argc)
+ {
+ if (isatty (0))
+ usage (0);
exit_status |= nl_file ("-");
+ }
else
for (; optind < argc; optind++)
exit_status |= nl_file (argv[optind]);
diff -cbr orig/src/od.c new/src/od.c
*** orig/src/od.c Thu May 30 08:40:24 1996
--- new/src/od.c Sun Jul 28 12:50:14 1996
***************
*** 332,337 ****
--- 332,338 ----
program_name);
else
{
+ print_version("od");
printf (_("\
Usage: %s [OPTION]... [FILE]...\n\
or: %s --traditional [FILE] [[+]OFFSET [[+]LABEL]]\n\
***************
*** 983,993 ****
input_filename = _("standard input");
in_stream = stdin;
have_read_stdin = 1;
}
else
{
input_filename = *file_list;
! in_stream = fopen (input_filename, "r");
if (in_stream == NULL)
{
error (0, errno, "%s", input_filename);
--- 984,997 ----
input_filename = _("standard input");
in_stream = stdin;
have_read_stdin = 1;
+ #ifdef __EMX__
+ _fsetmode (in_stream, "b");
+ #endif
}
else
{
input_filename = *file_list;
! in_stream = fopen (input_filename, "rb");
if (in_stream == NULL)
{
error (0, errno, "%s", input_filename);
***************
*** 1233,1243 ****
input_filename = _("standard input");
in_stream = stdin;
have_read_stdin = 1;
}
else
{
input_filename = *file_list;
! in_stream = fopen (input_filename, "r");
if (in_stream == NULL)
{
error (0, errno, "%s", input_filename);
--- 1237,1250 ----
input_filename = _("standard input");
in_stream = stdin;
have_read_stdin = 1;
+ #ifdef __EMX__
+ _fsetmode (in_stream, "b");
+ #endif
}
else
{
input_filename = *file_list;
! in_stream = fopen (input_filename, "rb");
if (in_stream == NULL)
{
error (0, errno, "%s", input_filename);
***************
*** 1306,1316 ****
input_filename = _("standard input");
in_stream = stdin;
have_read_stdin = 1;
}
else
{
input_filename = *file_list;
! in_stream = fopen (input_filename, "r");
if (in_stream == NULL)
{
error (0, errno, "%s", input_filename);
--- 1313,1326 ----
input_filename = _("standard input");
in_stream = stdin;
have_read_stdin = 1;
+ #ifdef __EMX__
+ _fsetmode (in_stream, "b");
+ #endif
}
else
{
input_filename = *file_list;
! in_stream = fopen (input_filename, "rb");
if (in_stream == NULL)
{
error (0, errno, "%s", input_filename);
***************
*** 1929,1934 ****
--- 1939,1947 ----
static char const *const default_file_list[] = {"-", NULL};
file_list = default_file_list;
+
+ if (isatty (0))
+ usage (0);
}
err |= skip (n_bytes_to_skip);
diff -cbr orig/src/paste.c new/src/paste.c
*** orig/src/paste.c Sun Mar 24 16:01:36 1996
--- new/src/paste.c Sun Jul 28 12:50:14 1996
***************
*** 410,415 ****
--- 410,416 ----
program_name);
else
{
+ print_version("paste");
printf (_("\
Usage: %s [OPTION]... [FILE]...\n\
"),
***************
*** 480,486 ****
--- 481,491 ----
usage (0);
if (optind == argc)
+ {
+ if (isatty (0))
+ usage (0);
argv[argc++] = "-";
+ }
delim_end = collapse_escapes (delims);
diff -cbr orig/src/pr.c new/src/pr.c
*** orig/src/pr.c Wed Apr 24 05:50:28 1996
--- new/src/pr.c Sun Jul 28 12:50:14 1996
***************
*** 638,643 ****
--- 638,645 ----
if (n_files == 0)
{
+ if (isatty (0))
+ usage (0);
/* No file arguments specified; read from standard input. */
print_files (0, (char **) 0);
}
***************
*** 1851,1856 ****
--- 1853,1859 ----
program_name);
else
{
+ print_version("pr");
printf (_("\
Usage: %s [OPTION]... [FILE]...\n\
"),
diff -cbr orig/src/sort.c new/src/sort.c
*** orig/src/sort.c Fri May 31 04:00:26 1996
--- new/src/sort.c Sun Jul 28 12:50:14 1996
***************
*** 211,216 ****
--- 211,217 ----
program_name);
else
{
+ print_version("sort");
printf (_("\
Usage: %s [OPTION]... [FILE]...\n\
"),
***************
*** 408,414 ****
--- 409,419 ----
node = (struct tempnode *) xmalloc (sizeof (struct tempnode));
sprintf (name,
+ #ifdef OS2
+ "%s%ssort%4.4x.%3.3x",
+ #else
"%s%ssort%5.5d%5.5d",
+ #endif
temp_file_prefix,
(len && temp_file_prefix[len - 1] != '/') ? "/" : "",
(unsigned int) getpid () & 0xffff, seq);
***************
*** 1648,1654 ****
--- 1653,1663 ----
signal (sig, SIG_DFL);
#endif /* SA_INTERRUPT */
cleanup ();
+ #ifdef OS2
+ raise (SIGINT);
+ #else
kill (getpid (), sig);
+ #endif
}
/* Set the ordering options for KEY specified in S.
***************
*** 1726,1732 ****
--- 1735,1745 ----
have_read_stdin = 0;
inittables ();
+ #ifdef OS2
+ temp_file_prefix = getenv ("TMP");
+ #else
temp_file_prefix = getenv ("TMPDIR");
+ #endif
if (temp_file_prefix == NULL)
temp_file_prefix = DEFAULT_TMPDIR;
***************
*** 1750,1755 ****
--- 1763,1770 ----
#else /* !SA_INTERRUPT */
if (signal (SIGINT, SIG_IGN) != SIG_IGN)
signal (SIGINT, sighandler);
+ if (signal (SIGQUIT, SIG_IGN) != SIG_IGN)
+ signal (SIGQUIT, sighandler);
if (signal (SIGHUP, SIG_IGN) != SIG_IGN)
signal (SIGHUP, sighandler);
if (signal (SIGPIPE, SIG_IGN) != SIG_IGN)
***************
*** 2049,2054 ****
--- 2064,2071 ----
if (nfiles == 0)
{
+ if (isatty (0))
+ usage (0);
nfiles = 1;
files = −
}
diff -cbr orig/src/split.c new/src/split.c
*** orig/src/split.c Wed Apr 24 05:50:28 1996
--- new/src/split.c Sun Jul 28 12:50:14 1996
***************
*** 101,106 ****
--- 101,107 ----
program_name);
else
{
+ print_version("split");
printf (_("\
Usage: %s [OPTION] [INPUT [PREFIX]]\n\
"),
***************
*** 181,187 ****
next_file_name ();
if (verbose)
fprintf (stderr, _("creating file `%s'\n"), outfile);
! output_desc = open (outfile, O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (output_desc < 0)
error (EXIT_FAILURE, errno, "%s", outfile);
}
--- 182,188 ----
next_file_name ();
if (verbose)
fprintf (stderr, _("creating file `%s'\n"), outfile);
! output_desc = open (outfile, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
if (output_desc < 0)
error (EXIT_FAILURE, errno, "%s", outfile);
}
***************
*** 484,493 ****
/* Open the input file. */
if (!strcmp (infile, "-"))
input_desc = 0;
else
{
! input_desc = open (infile, O_RDONLY);
if (input_desc < 0)
error (EXIT_FAILURE, errno, "%s", infile);
}
--- 485,498 ----
/* Open the input file. */
if (!strcmp (infile, "-"))
+ {
+ if (isatty (0))
+ usage (0, (char *)0);
input_desc = 0;
+ }
else
{
! input_desc = open (infile, O_RDONLY | O_BINARY);
if (input_desc < 0)
error (EXIT_FAILURE, errno, "%s", infile);
}
diff -cbr orig/src/sum.c new/src/sum.c
*** orig/src/sum.c Wed Apr 24 05:50:28 1996
--- new/src/sum.c Sun Jul 28 12:50:14 1996
***************
*** 60,65 ****
--- 60,66 ----
program_name);
else
{
+ print_version("sum");
printf (_("\
Usage: %s [OPTION]... [FILE]...\n\
"),
***************
*** 96,105 ****
{
fp = stdin;
have_read_stdin = 1;
}
else
{
! fp = fopen (file, "r");
if (fp == NULL)
{
error (0, errno, "%s", file);
--- 97,109 ----
{
fp = stdin;
have_read_stdin = 1;
+ #ifdef OS2
+ _fsetmode(stdin, "b");
+ #endif
}
else
{
! fp = fopen (file, "rb");
if (fp == NULL)
{
error (0, errno, "%s", file);
***************
*** 155,164 ****
{
fd = 0;
have_read_stdin = 1;
}
else
{
! fd = open (file, O_RDONLY);
if (fd == -1)
{
error (0, errno, "%s", file);
--- 159,171 ----
{
fd = 0;
have_read_stdin = 1;
+ #ifdef OS2
+ setmode(0, O_BINARY);
+ #endif
}
else
{
! fd = open (file, O_RDONLY | O_BINARY);
if (fd == -1)
{
error (0, errno, "%s", file);
***************
*** 244,249 ****
--- 251,258 ----
files_given = argc - optind;
if (files_given == 0)
{
+ if (isatty (0))
+ usage (0);
if ((*sum_func) ("-", files_given) < 0)
errors = 1;
}
diff -cbr orig/src/system.h new/src/system.h
*** orig/src/system.h Sun May 05 02:48:00 1996
--- new/src/system.h Sun Jul 28 13:01:24 1996
***************
*** 138,143 ****
--- 138,146 ----
/* Get or fake the disk device blocksize.
Usually defined by sys/param.h (if at all). */
+ #ifdef OS2
+ #define DEV_BSIZE 0x4000
+ #endif /* OS2 */
#if !defined(DEV_BSIZE) && defined(BSIZE)
#define DEV_BSIZE BSIZE
#endif
***************
*** 214,223 ****
#endif
#if ENABLE_NLS
! # include <libintl.h>
# define _(Text) gettext (Text)
#else
# define bindtextdomain(Domain, Directory) /* empty */
# define textdomain(Domain) /* empty */
# define _(Text) Text
#endif
--- 217,258 ----
#endif
#if ENABLE_NLS
! # include <libgettext.h>
# define _(Text) gettext (Text)
#else
# define bindtextdomain(Domain, Directory) /* empty */
# define textdomain(Domain) /* empty */
# define _(Text) Text
+ #endif
+
+ #define print_version(name) \
+ printf("\n%s - %s\n\n", PACKAGE_VERSION, name)
+
+ #ifdef OS2
+ #ifdef SIGHUP
+ #undef SIGHUP
+ #endif
+ #define SIGHUP SIGBREAK
+ #define main(c, v) os2main(c, v)
+ #undef islower
+ #define islower(c) IsLower (c)
+ #undef isupper
+ #define isupper(c) IsUpper (c)
+ #undef isalpha
+ #define isalpha(c) (IsLower (c) || IsUpper (c))
+ #undef isalnum
+ #define isalnum(c) (IsLower (c) || IsUpper (c) || isdigit (c))
+ #undef isprint
+ #define isprint(c) IsPrint (c)
+ #undef isgraph
+ #define isgraph(c) (isprint (c) && !isspace (c))
+ #undef tolower
+ #define tolower(c) ToLower (c)
+ #undef toupper
+ #define toupper(c) ToUpper (c)
+ #include <io.h>
+ #endif
+
+ #ifndef O_BINARY
+ #define O_BINARY 0
#endif
diff -cbr orig/src/tac.c new/src/tac.c
*** orig/src/tac.c Wed Apr 24 05:50:28 1996
--- new/src/tac.c Sun Jul 28 12:50:14 1996
***************
*** 130,135 ****
--- 130,136 ----
program_name);
else
{
+ print_version("tac");
printf (_("\
Usage: %s [OPTION]... [FILE]...\n\
"),
***************
*** 426,432 ****
{
int fd, errors;
! fd = open (file, O_RDONLY);
if (fd == -1)
{
error (0, errno, "%s", file);
--- 427,433 ----
{
int fd, errors;
! fd = open (file, O_RDONLY | O_BINARY);
if (fd == -1)
{
error (0, errno, "%s", file);
***************
*** 453,458 ****
--- 454,474 ----
if (template == NULL)
{
+ #ifdef OS2
+ tempdir = getenv ("TMP");
+ if (tempdir == NULL)
+ tempdir = getenv ("TEMP");
+ if (tempdir == NULL)
+ tempdir = DEFAULT_TMPDIR;
+ template = xmalloc (strlen (tempdir) + 10);
+ }
+ sprintf (template, "%s%stcXXXXXX", tempdir,
+ (tempdir[strlen (tempdir) - 1] != '/' &&
+ tempdir[strlen (tempdir) - 1] != '\\') ? "/" : "");
+ tempfile = mktemp (template);
+
+ fd = open (tempfile, O_CREAT|O_TRUNC|O_RDWR|O_BINARY, S_IWRITE|S_IREAD);
+ #else
tempdir = getenv ("TMPDIR");
if (tempdir == NULL)
tempdir = DEFAULT_TMPDIR;
***************
*** 462,467 ****
--- 478,484 ----
tempfile = mktemp (template);
fd = creat (tempfile, 0600);
+ #endif
if (fd == -1)
{
error (0, errno, "%s", tempfile);
***************
*** 656,661 ****
--- 673,686 ----
}
else
++buffer;
+
+ if (optind == argc && isatty (0))
+ usage (0);
+
+ #ifdef OS2
+ setmode (0, O_BINARY);
+ setmode (1, O_BINARY);
+ #endif /* OS2 */
if (optind == argc)
{
diff -cbr orig/src/tail.c new/src/tail.c
*** orig/src/tail.c Fri May 31 04:30:32 1996
--- new/src/tail.c Sun Jul 28 12:54:56 1996
***************
*** 64,69 ****
--- 64,70 ----
assert ((n_bytes) >= 0); \
if (n_bytes > 0 && fwrite ((buffer), 1, (n_bytes), stdout) == 0) \
error (EXIT_FAILURE, errno, _("write error")); \
+ fflush(stdout); \
} \
while (0)
***************
*** 139,144 ****
--- 140,146 ----
program_name);
else
{
+ print_version("tail");
printf (_("\
Usage: %s [OPTION]... [FILE]...\n\
"),
***************
*** 736,745 ****
--- 738,760 ----
static int
tail (const char *filename, int fd, off_t n_units)
{
+ #ifdef OS2
+ int errors;
+ _fsetmode (stdout, "b");
+ setmode (fd, O_BINARY);
+ if (count_lines)
+ errors = tail_lines (filename, fd, n_units);
+ else
+ errors = tail_bytes (filename, fd, n_units);
+ fflush (stdout);
+ _fsetmode (stdout, "t");
+ return errors;
+ #else
if (count_lines)
return tail_lines (filename, fd, (long) n_units);
else
return tail_bytes (filename, fd, n_units);
+ #endif
}
/* Display the last N_UNITS units of file FILENAME.
***************
*** 1012,1017 ****
--- 1027,1034 ----
if (n_files == 0)
{
+ if (isatty (0))
+ usage (0);
exit_status |= tail_file ("-", n_units, 0);
}
else
diff -cbr orig/src/tr.c new/src/tr.c
*** orig/src/tr.c Wed Apr 24 05:50:26 1996
--- new/src/tr.c Sun Jul 28 13:09:32 1996
***************
*** 354,359 ****
--- 354,360 ----
program_name);
else
{
+ print_version("tr");
printf (_("\
Usage: %s [OPTION]... SET1 [SET2]\n\
"),
***************
*** 1815,1820 ****
--- 1816,1824 ----
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ if (argc == 1 && isatty (0))
+ usage (0);
+
while ((c = getopt_long (argc, argv, "cdst", long_options,
(int *) 0)) != EOF)
{
***************
*** 1977,1982 ****
--- 1981,2008 ----
for (;;)
{
c1 = get_next (s1, &class_s1);
+ #ifdef OS2
+ #define has_upper_or_lower(s) (s->has_char_class && !s->has_restricted_char_class)
+ if (has_upper_or_lower(s1) && has_upper_or_lower(s2))
+ {
+ /* The original approach does not work on OS/2 because
+ * the order of lower and upper case characters is not
+ * identical for the national language characters beyond
+ * the ASCII a-z/A-Z. (There are even more lower case
+ * than upper case characters!).
+ *
+ * Fortunately, OS/2 provides a case mapping function we
+ * can use here (it is wrapped into lib/strcase.c and
+ * mapped to the standard ctype.h macros in system.h).
+ */
+ c2 = (class_s1 == UL_UPPER) ? tolower(c1) : toupper (c1);
+ /* The following should have been checked by validate... */
+ if (c1 == -1)
+ break;
+ }
+ else
+ #endif
+ {
c2 = get_next (s2, &class_s2);
if (!class_ok[(int) class_s1][(int) class_s2])
error (EXIT_FAILURE, 0,
***************
*** 1984,1993 ****
--- 2010,2024 ----
/* The following should have been checked by validate... */
if (c2 == -1)
break;
+ }
xlate[c1] = c2;
}
assert (c1 == -1 || truncate_set1);
}
+ #ifdef __EMX__
+ setmode (0, O_BINARY);
+ _fsetmode (stdout, "b");
+ #endif
if (squeeze_repeats)
{
set_initialize (s2, 0, in_squeeze_set);
diff -cbr orig/src/unexpand.c new/src/unexpand.c
*** orig/src/unexpand.c Wed Apr 24 05:50:26 1996
--- new/src/unexpand.c Sun Jul 28 12:50:14 1996
***************
*** 356,361 ****
--- 356,362 ----
program_name);
else
{
+ print_version("unexpand");
printf (_("\
Usage: %s [OPTION]... [FILE]...\n\
"),
***************
*** 443,449 ****
--- 444,454 ----
tab_size = 0;
if (optind == argc)
+ {
+ if (isatty (0))
+ usage (0);
file_list = stdin_argv;
+ }
else
file_list = &argv[optind];
diff -cbr orig/src/uniq.c new/src/uniq.c
*** orig/src/uniq.c Fri Jul 05 03:21:40 1996
--- new/src/uniq.c Sun Jul 28 12:50:14 1996
***************
*** 111,116 ****
--- 111,117 ----
program_name);
else
{
+ print_version("uniq");
printf (_("\
Usage: %s [OPTION]... [INPUT [OUTPUT]]\n\
"),
***************
*** 406,411 ****
--- 407,415 ----
skip_chars = (int) tmp_long;
}
}
+
+ if (optind == argc && isatty (0))
+ usage (0); /* No arguments. */
if (optind < argc)
infile = argv[optind++];
diff -cbr orig/src/wc.c new/src/wc.c
*** orig/src/wc.c Wed Apr 24 05:50:24 1996
--- new/src/wc.c Sun Jul 28 12:50:14 1996
***************
*** 52,60 ****
/* If nonzero, print the version on standard output then exits. */
static int show_version;
static struct option const longopts[] =
{
! {"bytes", no_argument, NULL, 'c'},
{"chars", no_argument, NULL, 'c'},
{"lines", no_argument, NULL, 'l'},
{"words", no_argument, NULL, 'w'},
--- 52,63 ----
/* If nonzero, print the version on standard output then exits. */
static int show_version;
+ /* read in binary mode? */
+ static int bin_mode;
+
static struct option const longopts[] =
{
! {"bytes", no_argument, NULL, 'b'},
{"chars", no_argument, NULL, 'c'},
{"lines", no_argument, NULL, 'l'},
{"words", no_argument, NULL, 'w'},
***************
*** 71,87 ****
program_name);
else
{
printf (_("\
Usage: %s [OPTION]... [FILE]...\n\
"),
program_name);
! printf (_("\
Print line, word, and byte counts for each FILE, and a total line if\n\
more than one FILE is specified. With no FILE, or when FILE is -,\n\
! read standard input.\n\
-l, --lines print the newline counts\n\
-w, --words print the word counts\n\
! -c, --bytes, --chars print the byte counts\n\
--help display this help and exit\n\
--version output version information and exit\n\
"));
--- 74,92 ----
program_name);
else
{
+ print_version("wc");
printf (_("\
Usage: %s [OPTION]... [FILE]...\n\
"),
program_name);
! printf (_("\n\
Print line, word, and byte counts for each FILE, and a total line if\n\
more than one FILE is specified. With no FILE, or when FILE is -,\n\
! read standard input.\n\n\
-l, --lines print the newline counts\n\
-w, --words print the word counts\n\
! -b, --bytes print the byte counts
! -c, --chars print the character counts\n\
--help display this help and exit\n\
--version output version information and exit\n\
"));
***************
*** 121,126 ****
--- 126,134 ----
register unsigned long lines, words, chars;
lines = words = chars = 0;
+ #ifdef OS2
+ setmode (fd, bin_mode ? O_BINARY : O_TEXT);
+ #endif
/* When counting only bytes, save some line- and word-counting
overhead. If FD is a `regular' Unix file, using lseek is enough
***************
*** 132,138 ****
`(dd ibs=99k skip=1 count=0; ./wc -c) < /etc/group'
should make wc report `0' bytes. */
! if (print_chars && !print_words && !print_lines)
{
off_t current_pos, end_pos;
struct stat stats;
--- 140,146 ----
`(dd ibs=99k skip=1 count=0; ./wc -c) < /etc/group'
should make wc report `0' bytes. */
! if (print_chars && !print_words && !print_lines && bin_mode)
{
off_t current_pos, end_pos;
struct stat stats;
***************
*** 268,281 ****
print_lines = print_words = print_chars = 0;
total_lines = total_words = total_chars = 0;
! while ((optc = getopt_long (argc, argv, "clw", longopts, (int *) 0)) != EOF)
switch (optc)
{
case 0:
break;
case 'c':
print_chars = 1;
break;
case 'l':
--- 276,295 ----
print_lines = print_words = print_chars = 0;
total_lines = total_words = total_chars = 0;
! while ((optc = getopt_long (argc, argv, "bclw", longopts, (int *) 0)) != EOF)
switch (optc)
{
case 0:
break;
+ case 'b':
+ print_chars = 1;
+ bin_mode = 1;
+ break;
+
case 'c':
print_chars = 1;
+ bin_mode = 0;
break;
case 'l':
***************
*** 300,311 ****
usage (0);
if (print_lines + print_words + print_chars == 0)
! print_lines = print_words = print_chars = 1;
nfiles = argc - optind;
if (nfiles == 0)
{
have_read_stdin = 1;
wc (0, "");
}
--- 314,327 ----
usage (0);
if (print_lines + print_words + print_chars == 0)
! print_lines = print_words = print_chars = bin_mode = 1;
nfiles = argc - optind;
if (nfiles == 0)
{
+ if (isatty (0))
+ usage (0);
have_read_stdin = 1;
wc (0, "");
}