summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1993-05-01 20:31:22 +0000
committerJim Meyering <jim@meyering.net>1993-05-01 20:31:22 +0000
commitd7fcb354de9387e778645abe75492786788f5381 (patch)
tree9021eabb2a3818d88881581caf14724fb26d7028
parentcd3f5c47d5cc6ff344b763a24b33316d97c92a50 (diff)
downloadcoreutils-d7fcb354de9387e778645abe75492786788f5381.tar.xz
merge with 1.4.2.
-rw-r--r--lib/regex.c69
-rw-r--r--old/textutils/ChangeLog19
-rw-r--r--old/textutils/NEWS2
-rw-r--r--src/od.c15
-rw-r--r--src/uniq.c9
5 files changed, 82 insertions, 32 deletions
diff --git a/lib/regex.c b/lib/regex.c
index 032b4d022..5bd4cf654 100644
--- a/lib/regex.c
+++ b/lib/regex.c
@@ -543,6 +543,8 @@ print_partial_compiled_pattern (start, end)
/* Loop over pattern commands. */
while (p < pend)
{
+ printf ("%d:\t", p - start);
+
switch ((re_opcode_t) *p++)
{
case no_op:
@@ -581,27 +583,45 @@ print_partial_compiled_pattern (start, end)
case charset:
case charset_not:
{
- register int c;
+ register int c, last = -100;
+ register int in_range = 0;
- printf ("/charset%s",
- (re_opcode_t) *(p - 1) == charset_not ? "_not" : "");
+ printf ("/charset [%s",
+ (re_opcode_t) *(p - 1) == charset_not ? "^" : "");
assert (p + *p < pend);
- for (c = 0; c < *p; c++)
+ for (c = 0; c < 256; c++)
+ if (c / 8 < *p
+ && (p[1 + (c/8)] & (1 << (c % 8))))
+ {
+ /* Are we starting a range? */
+ if (last + 1 == c && ! in_range)
+ {
+ putchar ('-');
+ in_range = 1;
+ }
+ /* Have we broken a range? */
+ else if (last + 1 != c && in_range)
{
- unsigned bit;
- unsigned char map_byte = p[1 + c];
+ printchar (last);
+ in_range = 0;
+ }
- putchar ('/');
+ if (! in_range)
+ printchar (c);
- for (bit = 0; bit < BYTEWIDTH; bit++)
- if (map_byte & (1 << bit))
- printchar (c * BYTEWIDTH + bit);
+ last = c;
}
+
+ if (in_range)
+ printchar (last);
+
+ putchar (']');
+
p += 1 + *p;
- break;
}
+ break;
case begline:
printf ("/begline");
@@ -613,17 +633,17 @@ print_partial_compiled_pattern (start, end)
case on_failure_jump:
extract_number_and_incr (&mcnt, &p);
- printf ("/on_failure_jump/0/%d", mcnt);
+ printf ("/on_failure_jump to %d", p + mcnt - start);
break;
case on_failure_keep_string_jump:
extract_number_and_incr (&mcnt, &p);
- printf ("/on_failure_keep_string_jump/0/%d", mcnt);
+ printf ("/on_failure_keep_string_jump to %d", p + mcnt - start);
break;
case dummy_failure_jump:
extract_number_and_incr (&mcnt, &p);
- printf ("/dummy_failure_jump/0/%d", mcnt);
+ printf ("/dummy_failure_jump to %d", p + mcnt - start);
break;
case push_dummy_failure:
@@ -632,40 +652,40 @@ print_partial_compiled_pattern (start, end)
case maybe_pop_jump:
extract_number_and_incr (&mcnt, &p);
- printf ("/maybe_pop_jump/0/%d", mcnt);
+ printf ("/maybe_pop_jump to %d", p + mcnt - start);
break;
case pop_failure_jump:
extract_number_and_incr (&mcnt, &p);
- printf ("/pop_failure_jump/0/%d", mcnt);
+ printf ("/pop_failure_jump to %d", p + mcnt - start);
break;
case jump_past_alt:
extract_number_and_incr (&mcnt, &p);
- printf ("/jump_past_alt/0/%d", mcnt);
+ printf ("/jump_past_alt to %d", p + mcnt - start);
break;
case jump:
extract_number_and_incr (&mcnt, &p);
- printf ("/jump/0/%d", mcnt);
+ printf ("/jump to %d", p + mcnt - start);
break;
case succeed_n:
extract_number_and_incr (&mcnt, &p);
extract_number_and_incr (&mcnt2, &p);
- printf ("/succeed_n/0/%d/0/%d", mcnt, mcnt2);
+ printf ("/succeed_n to %d, %d times", p + mcnt - start, mcnt2);
break;
case jump_n:
extract_number_and_incr (&mcnt, &p);
extract_number_and_incr (&mcnt2, &p);
- printf ("/jump_n/0/%d/0/%d", mcnt, mcnt2);
+ printf ("/jump_n to %d, %d times", p + mcnt - start, mcnt2);
break;
case set_number_at:
extract_number_and_incr (&mcnt, &p);
extract_number_and_incr (&mcnt2, &p);
- printf ("/set_number_at/0/%d/0/%d", mcnt, mcnt2);
+ printf ("/set_number_at location %d to %d", p + mcnt - start, mcnt2);
break;
case wordbound:
@@ -728,8 +748,11 @@ print_partial_compiled_pattern (start, end)
default:
printf ("?%d", *(p-1));
}
+
+ putchar ('\n');
}
- printf ("/\n");
+
+ printf ("%d:\tend of pattern.\n", p - start);
}
@@ -2058,7 +2081,7 @@ regex_compile (pattern, size, syntax, bufp)
#ifdef DEBUG
if (debug)
{
- DEBUG_PRINT1 ("\nCompiled pattern: ");
+ DEBUG_PRINT1 ("\nCompiled pattern: \n");
print_compiled_pattern (bufp);
}
#endif /* DEBUG */
diff --git a/old/textutils/ChangeLog b/old/textutils/ChangeLog
index dd191a0f6..c885dc8bc 100644
--- a/old/textutils/ChangeLog
+++ b/old/textutils/ChangeLog
@@ -1,3 +1,22 @@
+Sat May 1 09:03:19 1993 Jim Meyering (meyering@comco.com)
+
+ * uniq.c (main.c): Interpret non-option arguments with a leading `+'
+ only if we haven't seen `--'.
+
+Fri Apr 30 20:16:03 1993 Jim Meyering (meyering@comco.com)
+
+ * configure.in [AC_HAVE_HEADERS]: Add limits.h and unistd.h.
+
+ * configure.in [CFLAGS, LDFLAGS]: Assign reasonable defaults.
+
+ * od.c (parse_old_offset): Don't use prototype in function
+ definition. Remove unnecessary conjunct from test for hexadecimal
+ prefix.
+
+ * od.c: Depend on __GNUC__ || HAVE_LONG_DOUBLE rather than __STDC__
+ for long double support; there are compilers (Stardent Vistra svr4)
+ without long double but still define __STDC__.
+
Thu Apr 29 02:01:27 1993 Jim Meyering (meyering@comco.com)
* src/*.c and man/*.c except for sort: Add --help and --version
diff --git a/old/textutils/NEWS b/old/textutils/NEWS
index 96729c49c..4b98a3c10 100644
--- a/old/textutils/NEWS
+++ b/old/textutils/NEWS
@@ -1,4 +1,6 @@
Major changes in release 1.5:
+* sort is 8-bit clean
+* several bugs in sort have been fixed
* all programs accept --help and --version options
* od --compatible accepts pre-POSIX arguments
* pr -2a terminates
diff --git a/src/od.c b/src/od.c
index f79b3cce3..a6967d1fb 100644
--- a/src/od.c
+++ b/src/od.c
@@ -43,7 +43,7 @@ char *alloca ();
#include <float.h>
#endif
-#ifdef __STDC__
+#if defined (__GNUC__) || defined (HAVE_LONG_DOUBLE)
typedef long double LONG_DOUBLE;
#else
typedef double LONG_DOUBLE;
@@ -553,7 +553,7 @@ print_double (n_bytes, block, fmt_string)
}
}
-#ifdef __STDC__
+#if defined (__GNUC__) || defined (HAVE_LONG_DOUBLE)
static void
print_long_double (n_bytes, block, fmt_string)
long unsigned int n_bytes;
@@ -885,7 +885,7 @@ decode_one_format (s, next, tspec)
DBL_DIG + 8, DBL_DIG);
break;
-#ifdef __STDC__
+#if defined (__GNUC__) || defined (HAVE_LONG_DOUBLE)
case FP_LONG_DOUBLE:
print_function = print_long_double;
pre_fmt_string = "%%%d.%dle%%c";
@@ -1348,7 +1348,8 @@ get_lcm ()
return the offset it denotes. Otherwise, return -1. */
long int
-parse_old_offset (const char *s)
+parse_old_offset (s)
+ const char *s;
{
int radix;
char *suffix;
@@ -1362,13 +1363,13 @@ parse_old_offset (const char *s)
++s;
/* Determine the radix we'll use to interpret S. If there is a `.',
- it's decimal, otherwise, if the string begins with `0x', it's
- hexadecimal, else octal. */
+ it's decimal, otherwise, if the string begins with `0X'or `0x',
+ it's hexadecimal, else octal. */
if (index (s, '.') != NULL)
radix = 10;
else
{
- if (strlen (s) >= 2 && s[0] == '0' && (s[1] == 'x' || s[1] == 'X'))
+ if (s[0] == '0' && (s[1] == 'x' || s[1] == 'X'))
radix = 16;
else
radix = 8;
diff --git a/src/uniq.c b/src/uniq.c
index b902602a5..20fa6d565 100644
--- a/src/uniq.c
+++ b/src/uniq.c
@@ -159,8 +159,13 @@ main (argc, argv)
if (flag_help)
usage ();
- while (optind < argc && argv[optind][0] == '+')
- skip_chars = atoi (argv[optind++]);
+ if (optind >= 2 && strcmp (argv[optind - 1], "--") != 0)
+ {
+ /* Interpret non-option arguments with leading `+' only
+ if we haven't seen `--'. */
+ while (optind < argc && argv[optind][0] == '+')
+ skip_chars = atoi (argv[optind++]);
+ }
if (optind < argc)
infile = argv[optind++];