summaryrefslogtreecommitdiff
path: root/bin/expr/expr.y
AgeCommit message (Collapse)Author
2023-08-16Remove $FreeBSD$: two-line .h patternWarner Losh
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2018-04-14expr(1): Fix overflow detection when operand is INTMAX_MINConrad Meyer
PR: 227329 Submitted by: Tobias Stoeckmann <tobias AT stoeckmann.org> Notes: svn path=/head/; revision=332499
2015-01-27Fix overflow check for multiplication:Stefan Eßer
- Add special test to detect the case of -1 * INTMAX_MIN - Protect against elimination of the test division by the optimizer Garrett Cooper noticed that the overflow checks were incomplete, and Bruce Evans suggested the use of the "volatile" qualifier to counter the effect of the undefined behaviour, when the prior multiplication caused overflow, and he also suggested improvements to the comments. Reviewed by: bde MFC after: 1 week Notes: svn path=/head/; revision=277798
2012-05-22Remove redundant declaration of yyparseKevin Lo
Reported by: tinderbox Notes: svn path=/head/; revision=235771
2012-03-19rm[0].rm_so must be zero (an explicit check is made for zero in theEitan Adler
outer if condition) Reviewed by: se Approved by: cperciva Notes: svn path=/head/; revision=233137
2011-07-09Fix style, since this file has just been touched in a major way.Stefan Eßer
No actual code changes. Notes: svn path=/head/; revision=223883
2011-07-09Some refactoring for easier maintenance of the code. This is a follow-upStefan Eßer
to re-establishment of 64bit arithmetic, but is committed separately, to not obscure that conversion. This commit does not change the observed behaviour of expr in any way. Style will be fixed in a follow-up commit. Notes: svn path=/head/; revision=223882
2011-07-09Make /bin/expr support 64bit numeric range and range checks by default,Stefan Eßer
again. This brings back the behaviour of expr in FreeBSD-4, which had been reverted due to an assumed incompatbility with POSIX.1 for FreeBSD-5. This issue has been discussed in the freebsd-standards list, and the consensus was, that POSIX.1 is in fact not violated by this extension, since it affects only cases of POSIX undefined behaviour (overflow of signed long). Other operating systems did upgrade their versions of expr to support 64bit range, after it had been initially brought to FreeBSD. They have used it for a decade without problems, meanwhile. The -e option is retained, but it will only select less strict checking of numeric parameters (leading white-space, leading "+" are allowed and skipped, an empty string is considered to represent 0 in numeric context.) The call of check_utility_compat() as a means of establishing backwards compatibility with FreeBSD-4 is considered obsolete, but preserved in this commit. It is expected to be removed in a later revision of this file. Reviewed by: bde, das, jilles MFC after: 2 month (those parts that do not violate POLA) Notes: svn path=/head/; revision=223881
2007-02-18Correct typos containing my login name (plus one more in expr.y).Ceri Davies
Found courtesy of a recursive grep in the wrong directory. Notes: svn path=/head/; revision=166813
2005-01-10/*- or .\"- or #- to begin license clauses.Warner Losh
Notes: svn path=/head/; revision=139969
2002-10-28Create a small library function, check_utility_compat(3), to determineGarrett Wollman
whether a named utility should behave in FreeBSD 4.x-compatible mode or in a standard mode (default standard). The configuration is done malloc(3)-style, with either an environment variable or a symlink. Update expr(1) to use this new interface. Notes: svn path=/head/; revision=106065
2002-05-11EXPR_COMPAT should imply -e, since there is no way to specify it otherwise,Garrett Wollman
and -e reflects the historic behavior of FreeBSD's expr. Notes: svn path=/head/; revision=96382
2002-05-10The response to my POSIX interpretation request says that `expr'Garrett Wollman
is required to be oblivious to overflow and to use the data type `long'. (Division by zero is undefined in ISO C so it's still OK to check for it here.) Add a new `-e' flag to get the old, more useful behavior. Notes: svn path=/head/; revision=96367
2002-04-22Provide an environment variabloe, EXPR_COMPAT, which disables optionGarrett Wollman
parsing for compatibility with old implementations. Notes: svn path=/head/; revision=95278
2002-03-22Make expr POSIX-compliant, and fix some bugs. Specifically:Garrett Wollman
- expr must conform to the Utility Syntax Guidelines, so use getopt() to eat the (non-existent) options. - Use the Standard type intmax_t for arithmetic. - If an argument cannot be *completely* converted to an integer, then it is a string. Additionally make some style cleanups near the modified lines. This utility is still not completely style-compliant. Notes: svn path=/head/; revision=92979
2002-02-02o __P has been reovedWarner Losh
o Old-style K&R declarations have been converted to new C89 style o register has been removed o prototype for main() has been removed (gcc3 makes it an error) o int main(int argc, char *argv[]) is the preferred main definition. o Attempt to not break style(9) conformance for declarations more than they already are. o gc some #ifdef sun ... #endif code Approved by: arch@, new style(9) Notes: svn path=/head/; revision=90109
2001-05-26Fix warnings to compile with WARNS=2 on i386 and alphaKris Kennaway
Reviewed by: bde Notes: svn path=/head/; revision=77244
2000-07-22Add overflow testsStefan Eßer
Notes: svn path=/head/; revision=63755
2000-07-10Extend numeric operations to support 64 bit numbers.Stefan Eßer
Notes: svn path=/head/; revision=62926
1999-08-27$Id$ -> $FreeBSD$Peter Wemm
Notes: svn path=/head/; revision=50471
1997-02-22Revert $FreeBSD$ to $Id$Peter Wemm
Notes: svn path=/head/; revision=22988
1997-01-14Make the long-awaited change from $Id$ to $FreeBSD$Jordan K. Hubbard
This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so long. Boy, I'm glad we're not using sup anymore. This update would have been insane otherwise. Notes: svn path=/head/; revision=21673
1995-11-18Fix my own brokeness for the colon operator, when one of the argumentsJoerg Wunsch
was a valid integer. The actual decision between integer and string is now context-dependant on the operator being used. Notes: svn path=/head/; revision=12378
1995-08-04expr(1) didn't comply to Posix.2 and its own man page: anyJoerg Wunsch
comparisions have been made as string comparisions, even in cases where both operands clearly qualified as integers. The fix is to make the parser properly analyzing whether an operand is a valid integer or not. Notes: svn path=/head/; revision=9909
1995-03-19You will find enclosed some changes to make gcc -Wall more happy inJoerg Wunsch
/usr/src/bin. Note that some patches are still needed in that directory. I (Joerg) finished most of Philippe's cleanup. /bin/sh will still need *allot* of work, however. Submitted by: charnier@lirmm.fr (Philippe Charnier) Notes: svn path=/head/; revision=7165
1994-09-24Added $Id$David Greenman
Notes: svn path=/head/; revision=3044
1994-09-05Explicitly include <sys/types.h> before including <regex.h>. This isBruce Evans
apparently required by POSIX. It will be required in practice when the bogus inclusion of <sys/types.h> is removed from <stdio.h>. Notes: svn path=/head/; revision=2502
1993-10-04Allow expressions like "expr 'ABC' : '^.*$' to work as is done in otherJ.T. Conklin
expr implementations. Notes: svn path=/head/; revision=539
1993-09-14Fix grammar to eliminate support for unary minus expressions -- theyJ.T. Conklin
weren't supported, they aren't standard, and they caused expr to dump core. Notes: svn path=/head/; revision=468
1993-08-171003.2 requires that lexical comparisons be done in locale specific manner,J.T. Conklin
so we have to use strcoll() instead of strcmp(). 1003.2 requires that a null string be returned if a string does not match a \( \) subexpression. Replaced fprintf/exit with calls to err and errx as appropriate. Notes: svn path=/head/; revision=295
1993-07-21Update to my latest expr (fixes bugs with comparison and matching operators)J.T. Conklin
Add man page I wrote. Notes: svn path=/head/; revision=181
1993-06-19added POSIX regex to exprAndrew Moore
Notes: svn path=/head/; revision=31
1993-06-12Initial import, 0.1 + pk 0.2.4-B1Rodney W. Grimes
Notes: svn path=/cvs2svn/branches/unlabeled-1.1.1/; revision=4