diff options
author | Russ Cox <rsc@swtch.com> | 2010-07-14 11:08:42 -0700 |
---|---|---|
committer | Russ Cox <rsc@swtch.com> | 2010-07-14 11:08:42 -0700 |
commit | 75a851e927dd7f8e562b0fd35490783b44966c9f (patch) | |
tree | 4db960d7708fa67d8659168e67a90c11625afd92 /src/cmd/acme | |
parent | efe48aa6703ce0ede31ce96792ace707c2b5c3b3 (diff) | |
download | plan9port-75a851e927dd7f8e562b0fd35490783b44966c9f.tar.gz plan9port-75a851e927dd7f8e562b0fd35490783b44966c9f.tar.bz2 plan9port-75a851e927dd7f8e562b0fd35490783b44966c9f.zip |
acme: fix off by one in editcmd, pointer comparison in getch, nextc
R=r
http://codereview.appspot.com/868046
Diffstat (limited to 'src/cmd/acme')
-rw-r--r-- | src/cmd/acme/edit.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/cmd/acme/edit.c b/src/cmd/acme/edit.c index f1a7d67f..4495bf69 100644 --- a/src/cmd/acme/edit.c +++ b/src/cmd/acme/edit.c @@ -164,7 +164,7 @@ editcmd(Text *ct, Rune *r, uint n) free(cmdstartp); cmdstartp = runemalloc(n+2); runemove(cmdstartp, r, n); - if(r[n] != '\n') + if(r[n-1] != '\n') cmdstartp[n++] = '\n'; cmdstartp[n] = '\0'; cmdendp = cmdstartp+n; @@ -195,7 +195,7 @@ editcmd(Text *ct, Rune *r, uint n) int getch(void) { - if(*cmdp == *cmdendp) + if(cmdp == cmdendp) return -1; return *cmdp++; } @@ -203,7 +203,7 @@ getch(void) int nextc(void) { - if(*cmdp == *cmdendp) + if(cmdp == cmdendp) return -1; return *cmdp; } |