Commit Graph

28 Commits

Author SHA1 Message Date
wiz 7a64806dbc Use {g,s}etprogname, and some other KNF stuff. Patch by Petri Koistinen. 2001-09-16 13:42:10 +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 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
mycroft abe60a1e07 Clean up deleted files. 1994-07-16 00:17:15 +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 bff56be25a Fix insignificant memory leak. 1993-11-16 23:08:49 +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 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 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
jtc 6a320fc0a3 Now truely POSIX 1003.2 (D11.2) compliant. 1993-07-20 01:10:55 +00:00
jtc aabfaec2f5 Don't coerce strings to int in comparisons. 1993-07-20 00:52:57 +00:00
jtc 476e1b5964 integer arguments were not coerced to strings for the `:' operator.
bad things: core dumps, etc. will happen if integer values make it
up the parse tree.
1993-07-20 00:29:41 +00:00
jtc 68028dc2de Updated to POSIX regular expression routines.
(Previous checkin was aborted by stray ^C)
1993-06-14 19:59:07 +00:00
cgd ac2edf58ea update for latest version of patches from jtconklin@kaleida.com 1993-06-05 22:25:44 +00:00
cgd a5668e87e6 added J.T. Conklin's changes to get parens working fine, etc. 1993-03-23 20:19:35 +00:00
cgd 06be60083d changed "Id" to "Header" for rcsids 1993-03-23 00:22:59 +00:00
cgd 346aa5dd48 added rcs ids to all files 1993-03-22 08:04:00 +00:00
cgd 61f282557f initial import of 386bsd-0.1 sources 1993-03-21 09:45:37 +00:00