aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/rc
AgeCommit message (Collapse)AuthorFilesLines
2013-03-19rc: avoid undefined CXi Wang1-4/+4
There are two bugs in pdec() on INT_MIN: * wrong output. `n = 1-n' should be `n = -1-n' when n is INT_MIN. * infinite loop. gcc optimizes `if(n>=0)' into `if(true)' because `-INT_MIN' (signed integer overflow) is undefined behavior in C, and gcc assumes the negation of a negative number must be positive. The resulting binary keeps printing '-' forever given INT_MIN. Try the simplified pdec.c below. $ gcc pdec.c $ ./a.out -2147483648 --214748364* $ gcc pdec.c -O2 $ ./a.out -2147483648 <infinite loop> $ gcc pdec.c -O2 -D__PATCH__ $ ./a.out -2147483648 -2147483648 === pdec.c === #include <stdio.h> #include <stdlib.h> #include <limits.h> #define io void void pchr(io *f, int c) { putchar(c); } void pdec(io *f, int n) { if(n<0){ #ifndef __PATCH__ n=-n; if(n>=0){ pchr(f, '-'); pdec(f, n); return; } /* n is two's complement minimum integer */ n = 1-n; #else if(n!=INT_MIN){ pchr(f, '-'); pdec(f, -n); return; } /* n is two's complement minimum integer */ n = -(INT_MIN+1); #endif pchr(f, '-'); pdec(f, n/10); pchr(f, n%10+'1'); return; } if(n>9) pdec(f, n/10); pchr(f, n%10+'0'); } int main(int argc, char **argv) { int n = atoi(argv[1]); pdec(NULL, n); putchar('\n'); } R=rsc CC=plan9port.codebot https://codereview.appspot.com/7241055
2011-08-02rc: silence lion roarRuss Cox1-0/+1
R=rsc http://codereview.appspot.com/4835048
2011-02-16rc: fix $ifs bug introduced with utf-8 codeRuss Cox1-2/+4
R=rsc http://codereview.appspot.com/4187050
2011-01-02rc: handle 4-byte utf-8Russ Cox3-0/+20
R=rsc http://codereview.appspot.com/3833043
2011-01-02rc: handle utf-8 in $ifsRuss Cox1-8/+16
R=rsc http://codereview.appspot.com/3798046
2009-09-13rc: implement and document <>{cmd} notationMichael Teichgräber1-17/+47
http://codereview.appspot.com/105061
2009-08-23rc: make read not ignore interrupts/errors (again)Michael Teichgräber1-2/+7
http://codereview.appspot.com/110042
2009-08-08rc: fix segfault when SIGINT is receivedMichael Teichgräber1-1/+2
Save the value of `runq' at the start of the function, so that the `pc' update at the end does work on that original value, and not on a probably modified value of `runq'. fixes #14 http://code.swtch.com/plan9port/issue/14/ http://codereview.appspot.com/104066
2008-08-14rc: fix local variables in functionsRuss Cox2-4/+4
reported by micah stetson: fn foo { echo $bar } bar=baz foo
2008-07-20rc: add subscript sequences (Erik Quanstrom)Russ Cox1-5/+35
2007-03-28keep path and PATH in syncrsc1-0/+2
2007-03-26do not redefine rewindrsc1-1/+1
2007-03-26more memory errors (valgrind)rsc3-1/+3
2007-03-26fix waitrsc5-251/+97
2007-03-26fix phantom rc crashesrsc1-0/+1
2007-03-26sync with plan 9rsc23-1232/+1967
2007-03-25cope with programs that leave fd in non-blocking mode (Tim Wiess)rsc2-1/+27
2006-06-27experiment - allow = in words late in the command linersc1-0/+3
2006-04-08add exitcodersc1-0/+11
2006-04-01Use gcc -ansi -pedantic in 9c. Fix many non-C89-isms.rsc2-3/+3
2006-03-20update lucidarsc1-1/+1
2006-02-14shut up about signals in scriptsrsc1-1/+1
2005-08-11Add rfork builtin.rsc1-0/+53
2005-08-11make sure errors cause non-zero exit statusrsc1-0/+2
2005-07-26fixes from bengt for sunrsc1-2/+2
2005-07-14ignore window size changersc1-0/+1
2005-07-13stupid sunrsc1-0/+3
2005-05-19set $PLAN9 if necessaryrsc1-0/+3
2005-03-18try harder to put background jobs in background; do not print in response to ↵rsc4-1/+45
SIGPIPE
2005-03-18correct command-printing bugrsc1-1/+3
2005-02-13handle /dev/stdin alwaysrsc2-3/+3
2005-02-11set pid=-1 explicitlyrsc1-0/+1
2005-01-23more searchpath-related changesrsc2-1/+2
2005-01-19use correct yaccrsc1-1/+0
2005-01-13Many small edits.rsc1-0/+1
2005-01-12maintain $path and $PATH simultaneouslyrsc5-4/+74
2005-01-07success on the sunrsc1-0/+16
2004-12-28FreeBSD tweaksrsc1-4/+2
2004-10-17print out signalled exitsrsc1-0/+5
2004-10-17add ulimit and umask as builtinsrsc3-0/+202
2004-05-16Supress line noise.wkj1-0/+3
2004-05-14More little bug fixesrsc1-1/+0
2004-05-11Fix small bugs.rsc1-1/+1
2004-04-30Little fixes.rsc1-0/+1
2004-04-24fixrsc1-1/+0
2004-04-24Add scat. Temporary fix to rc r.e. note groups.rsc1-1/+1
2004-04-19clean up when finished.rsc1-1/+0
don't set PLAN9 don't set PLAN9
2004-03-26handle interrupts and backgrounded processes a little better.rsc3-1/+11
2004-03-26SunOS can rot in hell.rsc1-4/+3
2004-03-25Today's changes.rsc1-12/+2
More changes.