Commit graph

67 commits

Author SHA1 Message Date
Russ Cox
3ccd61629b sam: avoid out-of-bounds read in rterm
Usually r->nused < r->nalloc and the read is in bounds.
But it could in theory be right on the line and reading
past the end of the allocation.

Make it safe but preserve as much of the old semantics
as possible. This use of rterm appears to be only for
optimization purposes so the result does not matter
for correctness.
2021-01-14 10:05:50 -05:00
Russ Cox
6a80119eb5 sam: remove backward ?:
The exit code here is ignored anyway.
2021-01-14 10:01:25 -05:00
Russ Cox
1c845e0bd5 acme, sam, samterm: remove weird switch usage
For whatever reason all three of these programs
contain switches like:

	switch(x) {
	case 1:
		if(cond)
	case 2:
			f();
	}

Like Duff's device, this is legal C but more obscure
than it really needs to be.

This commit assumes those are intended as written
and simply writes them more clearly. I did consider
that maybe they are mistakes, but in the case of sam/regexp.c,
my rewrite in this commit matches the acme/regx.c that
has been in plan9port since I added acme in 2003.
(I didn't bother to dig up the old Plan 9 releases.)

Assuming acme/regx.c has been correct for the past
two decades, this commit should be correct too.
2021-01-05 23:38:09 -05:00
Russ Cox
0a513e6560 sam: rm dregs 2021-01-05 23:37:04 -05:00
Russ Cox
7f6458b045 stats: add threadmaybackground 2021-01-05 23:37:04 -05:00
Russ Cox
1f098efb73 all: a few more #define tricks for AIX
This should make the AIX build finally work.

Fixes #400.
2020-08-15 20:46:23 -04:00
Dan Cross
fa325e9b42 Trivial changes: whitespace and modes.
Remote whitespace at the ends of lines.
Remove blank lines from the ends of files.
Change modes on source files so that they
are not executable.

Signed-off-by: Dan Cross <cross@gajendra.net>
2020-01-10 14:54:30 +00:00
Russ Cox
a1ead676e6 sam: report close error 2019-12-19 15:00:58 -05:00
Xiao-Yong Jin
edfe3c016f sam: freetmpstr instead of free 2018-03-27 15:03:12 +02:00
Russ Cox
219cf22d68 acme, sam: handle >1GB files correctly
TBR=rsc
https://codereview.appspot.com/74060043
2014-03-13 18:46:28 -04:00
Russ Cox
0cfb376070 fix clang warnings reported by Tuncer Ayaz
R=rsc
http://codereview.appspot.com/6744054
2012-10-21 11:25:08 -04:00
Russ Cox
85504cda14 sam: add $% as an alias for $samfile
R=r
http://codereview.appspot.com/6488137
2012-09-17 14:53:11 -04:00
Russ Cox
860d327c8f sam: use ulong as type of dev consistently
Otherwise io.c:39 compares int != ulong,
causing spurious file modification warnings
when dev doesn't fit in an int.

R=r
http://codereview.appspot.com/1917045
2010-08-04 17:35:44 -07:00
Russ Cox
36d9b90c56 acme, sam: fix regexp code for bigger Runemax
R=r
http://codereview.appspot.com/1765042
2010-07-14 11:10:59 -07:00
Russ Cox
846cec9ebc sam: fix off-by-one in buffer merge.
exposed by UTFmax==4

R=rsc
http://codereview.appspot.com/165071
2009-12-06 17:27:08 -08:00
Russ Cox
0cadb4301d convert to 4-byte UTF-8 and 32-bit Rune
http://codereview.appspot.com/116075
2009-09-11 17:03:06 -04:00
Russ Cox
1412580357 sam: clean up checkerrs (Rob Pike) 2008-04-16 06:32:43 -07:00
Russ Cox
715d6f8e14 sam: allow more output from ! command (Rob Pike) 2008-04-15 19:15:17 -07:00
Russ Cox
3a9401ae90 sam: fix regexp match choice bug 2008-01-30 13:47:07 -05:00
Russ Cox
2deda14e42 sam: revert regexp fix 2007-12-07 17:33:03 -05:00
Russ Cox
608a09284e sam: regexp fix (see libregexp change) 2007-12-07 15:33:58 -05:00
Russ Cox
6d069877f0 sam: turn off DEBUG logging (oops) 2007-12-04 19:55:22 -05:00
rsc
c99ef336aa better fix 2007-06-09 05:17:47 +00:00
rsc
2f9d900118 day one bug in sam regexp code 2007-06-09 04:58:00 +00:00
rsc
5369e5ea0c change name 2007-01-12 16:32:11 +00:00
rsc
7103ceb031 Bug fix fix - remove debugging implementation of needoutflush. 2007-01-12 16:02:09 +00:00
rsc
78439d25f8 Fix 15-year-old sam protocol bug. 2007-01-12 15:57:34 +00:00
rsc
21c4c72798 Aviod seg fault when no file 2006-08-29 20:15:01 +00:00
rsc
c7c29d26b7 set $samfile during external commands 2006-08-24 18:37:55 +00:00
rsc
9bc519d686 fix dup file name bug 2006-06-26 05:49:18 +00:00
rsc
7f629d9d7b shut up gcc volatile 2006-05-06 19:54:50 +00:00
rsc
d9ed72433f darwin 2006-04-21 04:26:02 +00:00
rsc
2c0f3733ad 64-bit fixes 2006-04-20 20:49:00 +00:00
rsc
cbeb0b26e4 Use gcc -ansi -pedantic in 9c. Fix many non-C89-isms. 2006-04-01 19:24:03 +00:00
rsc
2387495b56 update usage 2006-03-20 04:02:36 +00:00
rsc
17157e4aa8 update lucida 2006-03-20 02:25:59 +00:00
rsc
2e32846495 warnings 2005-07-13 21:29:42 +00:00
rsc
2b6040818e use full prototypes 2005-05-07 22:42:14 +00:00
rsc
611d815b8b bug fix from plan 9 2005-03-18 21:52:19 +00:00
rsc
693892caf5 remove debugging print 2005-01-27 07:20:06 +00:00
rsc
17ab31aac6 add autoindent (-a) and chording.
clean up argument parsing.
2005-01-27 06:10:35 +00:00
rsc
c8b6342d3c Many small edits. 2005-01-13 04:49:19 +00:00
rsc
372e9667df Goodbye SHORTLIB 2005-01-04 22:10:29 +00:00
rsc
f7b74c1725 FreeBSD tweaks 2004-12-28 17:34:05 +00:00
rsc
22c7ebffda more little compile fixes 2004-12-28 01:45:05 +00:00
rsc
7e4a17cf33 use libplumb instead 2004-06-09 14:06:09 +00:00
rsc
8538a66037 allow
sam -r machine filelist...

from presotto
2004-05-14 18:25:49 +00:00
rsc
be36ff6885 add -W to specify window size.
various other little fixes.
2004-04-29 17:13:24 +00:00
rsc
1b135a7805 clean up when finished.
don't set PLAN9
don't set PLAN9
2004-04-19 23:04:36 +00:00
rsc
be22ae2d07 SunOS can rot in hell. 2004-03-26 01:59:35 +00:00