Commit Graph

63 Commits

Author SHA1 Message Date
pooka 2b1fe1903a rewritten in NetBSD 1.6 -> rewritten for NetBSD 1.6 2002-02-19 21:14:45 +00:00
ross dc5571b22e Generate <>& symbolically. I'm avoiding .../dist/... directories for now. 2002-02-08 01:21:55 +00:00
wiz e0ab876efe Use standard headers, sort sections. 2001-12-20 20:05:12 +00:00
wiz 880b4d21b9 Quote `:' correctly. 2001-10-18 11:00:03 +00:00
wiz 7a64806dbc Use {g,s}etprogname, and some other KNF stuff. Patch by Petri Koistinen. 2001-09-16 13:42:10 +00:00
jdolecek 3b932d2fe1 Fix the operator precedence list to match reality. Operators were incorrectly
grouped there.
2001-05-07 10:14:43 +00:00
jmc 64e6a11adc Various cleanups/fixes.
Change the add/subtract overflow checks to use an unsigned to do the op
and then cast back into the signed var to check the signs.

Make multiply shortcut on either right or left being 0.
Make multiply's overflow test not fail on simple cases like 1 * -1
Make the multiple overflow test pass all the regress tests.
2001-05-06 06:20:39 +00:00
jmc a7755cce7c Various changes to fix bugs in PR bin/12838.
Make sure all precendence is spelled out correctly (comparison does not
have the same level as the arithmetic operators..)
Break the arithemtic operators into 2 classes (+- are lower than */%)
Restructure the arithmetic code into a function either class above can call.
Finally, add a whole suite of regression tests (checked in separately) which
the previous code failed on 3 of them.
2001-05-05 06:57:57 +00:00
simonb 6f6fe2f3ad Spell occurred correctly. 2001-04-25 02:33:08 +00:00
christos a66a2e0ad0 remove redundant declaration of yyparse 2001-02-04 19:51:14 +00:00
jdolecek 9ad5bf10de list parenthesis usage similar way as other operators
document operator precedence
rename section BUGS to COMPATIBILITY, add paragraph about -- handling
2000-10-30 16:20:12 +00:00
jdolecek 5888f4d21c add a hack to properly handle '--' as first argument -
it's ignored if it would cause syntax error, otherwise treated as common
string; this is so that both 'expr -- : .' and 'expr -- foo : .' works
This addresses standards/11230 by Ben Harris.

while here, make all global variables but main() static, use const more
2000-10-30 14:55:02 +00:00
thorpej 401ea1afda The "&" operator has a higer precedence than "|". 2000-10-29 17:16:02 +00:00
jdolecek c13c5901f2 also credit J.T. Conklin in copyright message 2000-10-27 21:40:02 +00:00
jdolecek fb2525abf5 fix operator precedence - | or & have lower priority than
arithmetic operations, compare, or :
This should fix bin/11318 by Love <lha@stacken.kth.se>
2000-10-26 23:10:21 +00:00
jdolecek fd6eeb2e1d in regexp handling code, fix the format passed to asprintf() to be
actually in intended form - use "%.*s" and not incorrect "%*s"

Bug found by Launey Thomas <ljt@alum.mit.edu> and reported in private e-mail.
2000-09-29 17:49:21 +00:00
jdolecek a82fc402d8 Fix bug in regexp handling, caused not quite complete conversion
from old expr.c. This fixes PR # 11060.

While here, convert the code to use asprintf() instead of strdup()
followed by truncating of new string and move definition of errstr
to block where it's used.
2000-09-21 20:32:24 +00:00
jdolecek 3a4441e3d4 reimplement expr using lexical parser generated by yacc
highlights:
* / is treated correctly depending upon context (addresses PR # 10995)
* use 64 bit arithmetic, so expr is able to process integer values from
	-(2**63) to (2**63 - 1)
* checks for integer over- & underflows added
* error messages improved, more error checking added

add AUTHOR section to manpage
add BUGS section, and mention possible drawbacks with other expr implementations

XXX the old expr treated empty string in arithmetic expressions as if it was 0
XXX this behaviour has been retained
2000-09-19 17:20:00 +00:00
kleink 2caf6aacdd For commands and utilities, use EXIT STATUS rather than RETURN VALUES as
appropriate (and documented in mdoc(7)).
2000-09-04 07:30:07 +00:00
hubertf 1cb54f68ac Add 'RETURN VALUE' section header. 2000-08-28 02:11:04 +00:00
mjl 5a14e8cac6 On memory allocation failure, return 3 as per POSIX. (from OpenBSD) 2000-01-14 07:14:41 +00:00
drochner 85cbf55d16 Since our gcc doesn't warn about NULL format strings anymore, we can
fix the incorrect err(1, "%s", "") et al.
Closes PR bin/7592 by cgd.
1999-11-09 15:06:30 +00:00
christos cdd6e9ea70 cast is*() to unsigned char 1998-11-04 14:11:12 +00:00
mycroft ee9e50eacb Be more retentive about use of NOTREACHED and noreturn. 1998-07-28 11:41:40 +00:00
mycroft 1381f68431 Delint. 1998-07-28 05:15:46 +00:00
mycroft ac70c0c5ed Slight code reduction. 1998-07-27 17:55:17 +00:00
mycroft 0e2f9ea923 __AUDIT__ cleanup. 1998-07-27 17:06:48 +00:00
enami c3872193cf Fix .Nm usage. 1997-10-20 08:50:59 +00:00
christos 23edbe3557 Remove WARNS=1 from all the subdirectory Makefiles, and add it to Makefile.inc
now that all /bin has been cleaned.
1997-07-20 22:36:20 +00:00
christos 1ebc470e07 Fix compiler warnings; add WARNS=1 1997-07-20 17:32:57 +00:00
cgd ad8b41fa2a don't spew an error message if setlocale(LC_ALL, ""); fails. This is for
consistency with other programs, and because currently it can never
actually succeeed if LANG is set to something other than "C".  Sent
in by me in PR 2486, approved by jtc).
1996-06-04 20:41:15 +00:00
jtc 528957a005 Winning Strategies has placed this code into the Public Domain 1995-04-28 23:19:22 +00:00
cgd 49f0ad8601 convert to new RCS id conventions. 1995-03-21 09:01:59 +00:00
mycroft 4c34be6b52 Clean up deleted files. 1995-03-01 00:00:00 +00:00
mycroft abe60a1e07 Clean up deleted files. 1994-07-16 00:17:15 +00:00
jtc b9e9314bd7 Re-implemented with a recursive descent parser.
Fixed subtle bug wrt. comparing integers when either one hasn't been
coersed from a string --- while avoiding an even subtler bug found in
GNU expr.
1994-07-16 00:17:03 +00:00
cgd 00dc18214f don't forget a cast, and thereby fix the regexp problems on big-endian machines 1994-07-10 23:51:11 +00:00
jtc 42f840d29d Fix spelling error in Copyright notice 1994-01-29 01:43:03 +00:00
jtc e04c8e0705 Fix spelling errors. 1994-01-11 02:10:48 +00:00
jtc bff56be25a Fix insignificant memory leak. 1993-11-16 23:08:49 +00:00
jtc 5ce3d664fb Use new POSIX.2 compatible regex routines in C library instead of -lgnuregex. 1993-11-11 01:29:52 +00:00
jtc 441c51a9d5 Document the new, less restrictive, behavior of the matching operator. 1993-10-04 22:06:59 +00:00
jtc d143e6f175 Allow expressions like "expr 'ABC' : '^.*$' to work as is done in other
expr implementations.
1993-10-04 21:57:27 +00:00
jtc 74b68a49cf Fix grammar to eliminate support for unary minus expressions -- they
weren't supported, they aren't standard, and they caused expr to dump
core.
1993-09-14 22:45:57 +00:00
jtc a5102d01b8 Document the fact that expr is POSIX.2 compliant. 1993-08-28 04:21:00 +00:00
jtc 3ed5680e46 Use err() routine for error messages.
If string does not match \( \) subexpression, return a null string.
1993-08-17 16:01:23 +00:00
jtc 04b0d37be1 Document that string comparisons are done using the locale specific
collation sequence.
1993-08-16 23:22:49 +00:00
jtc e9c8ee33b0 expr is supposed to do string comparisons using the locale specific
collation sequence, so use strcoll instead of strcmp.
1993-08-16 23:20:22 +00:00
mycroft 57b5a6be2d Oops. This one does need a single-entry SRCS, because it's generated at
compile time.  Lose.
1993-08-06 01:20:44 +00:00
mycroft 210cab4541 Add RCS identifiers, remove some completely useless RCS logs and patchkit
headers, and a few other insignificant changes.
1993-08-02 17:18:41 +00:00