acme: fix off by one in editcmd, pointer comparison in getch, nextc
R=r http://codereview.appspot.com/868046
This commit is contained in:
parent
efe48aa670
commit
75a851e927
1 changed files with 3 additions and 3 deletions
|
|
@ -164,7 +164,7 @@ editcmd(Text *ct, Rune *r, uint n)
|
||||||
free(cmdstartp);
|
free(cmdstartp);
|
||||||
cmdstartp = runemalloc(n+2);
|
cmdstartp = runemalloc(n+2);
|
||||||
runemove(cmdstartp, r, n);
|
runemove(cmdstartp, r, n);
|
||||||
if(r[n] != '\n')
|
if(r[n-1] != '\n')
|
||||||
cmdstartp[n++] = '\n';
|
cmdstartp[n++] = '\n';
|
||||||
cmdstartp[n] = '\0';
|
cmdstartp[n] = '\0';
|
||||||
cmdendp = cmdstartp+n;
|
cmdendp = cmdstartp+n;
|
||||||
|
|
@ -195,7 +195,7 @@ editcmd(Text *ct, Rune *r, uint n)
|
||||||
int
|
int
|
||||||
getch(void)
|
getch(void)
|
||||||
{
|
{
|
||||||
if(*cmdp == *cmdendp)
|
if(cmdp == cmdendp)
|
||||||
return -1;
|
return -1;
|
||||||
return *cmdp++;
|
return *cmdp++;
|
||||||
}
|
}
|
||||||
|
|
@ -203,7 +203,7 @@ getch(void)
|
||||||
int
|
int
|
||||||
nextc(void)
|
nextc(void)
|
||||||
{
|
{
|
||||||
if(*cmdp == *cmdendp)
|
if(cmdp == cmdendp)
|
||||||
return -1;
|
return -1;
|
||||||
return *cmdp;
|
return *cmdp;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue