aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/acme/addr.c
AgeCommit message (Collapse)AuthorFilesLines
2018-09-19acme: Apply each -/+ only once (#156)Martin Kühl1-3/+3
When plumbing an address like `3-`, Acme selects line 1, and similarly `3+` selects line 5. The same problem can be observed for character addresses (`#123+`) but _not_ for ones like `+`, `.+` or `/foo/+`: The problem only occurs when a number is followed by a direction (`-`/`+`). Following along with the example `3-` through `address` (in addr.c): We read `3` into `c` and match the `case` on line 239. The `while` loop on line 242ff reads additional digits into `c` and puts the first non-digit back by decrementing the index `q`. Then we find the range for line 3 on line 251 and continue. On the next iteration, we set `prevc` to the last `c`, but since that part read ahead _into `c`_, `c` is currently the _next_ character we will read, `-`, and now `prevc` is too. Then in the case block (line 210) the condition on line 211 holds and Acme believes that it has read two `-` in sequence and modifies the range to account for the “first” `-`. The “second” `-` gets applied after the loop is done, on line 292. So the general problem is: While reading numbers, Acme reads the next character after the number into `c`. It decrements the counter to ensure it will read it again on the next iteration, but it still uses it to update `prevc`. This change solves the problem by reading digits into `nc` instead. This variable is used to similar effect in the block for directions (line 212) and fills the role of “local `c` that we can safely use to read ahead” nicely.
2017-11-02acme: preserve window position and selection during GetRuss Cox1-0/+21
Before, executing Get in a file rewound the window offset and selection to the start of the file. After this CL, Get preserves the window offset and selection, where preserve is defined as "the same line number and rune offset within the line". So if the window started at line 10 before and the selection was line 13 chars 5-7, then that will still be true after Get, provided the new content is large enough. This should help the common situation of plumbing a compiler error, realizing the window is out of date, clicking Get, and then losing the positioning from the plumb operation.
2017-10-10acme: check file content before declaring file "modified since last read"Russ Cox1-0/+1
Bad remote file systems can change mtime unexpectedly, and then there is the problem that git rebase and similar operations like to change the files and then change them back, modifying the mtimes but not the content. Avoid spurious Put errors on both of those by checking file content. (False positive "modified since last read" make the real ones difficult to notice.)
2013-07-31acme: allow :6 in 5-line fileRuss Cox1-0/+2
R=rsc https://codereview.appspot.com/12162043
2011-07-10acme: fix out of order address crashRuss Cox1-1/+1
R=rsc http://codereview.appspot.com/4690042
2007-03-26make :1-1 work (Arvindh Tamilmani)rsc1-1/+2
2006-04-01Use gcc -ansi -pedantic in 9c. Fix many non-C89-isms.rsc1-2/+2
2005-01-27remove searching print; check fids in use; handle addr correctly againrsc1-1/+0
2004-10-22change md argument to number etc. (which acted only as a flag)rsc1-12/+14
to an actual flag. buffer underrun check in number add xdata file for exactly the addressed region save addr across opens
2004-03-26SunOS can rot in hell.rsc1-3/+3
2003-12-11More files related to user-level file servers.rsc1-0/+269
Also add acme!