Simplified character input processing. - sam - An updated version of the sam text editor.
(HTM) git clone git://vernunftzentrum.de/sam.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit ab21252fbf883e2f6fd0f8293ea109839f37728c
(DIR) parent 9c1beacd363c68e2a85a9ebc94e28ace320958fa
(HTM) Author: Rob King <jking@deadpixi.com>
Date: Thu, 20 Oct 2016 16:44:38 -0500
Simplified character input processing.
Diffstat:
sam/cmd.c | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
---
(DIR) diff --git a/sam/cmd.c b/sam/cmd.c
@@ -86,12 +86,9 @@ resetcmd(void)
int
inputc(void)
{
- int n, nbuf;
- char buf[3] = {0};
wchar_t r = 0;
Again:
- nbuf = 0;
if(downloaded){
while(termoutp == terminp){
cmdupdate();
@@ -107,20 +104,14 @@ inputc(void)
r = *termoutp++;
if(termoutp == terminp)
terminp = termoutp = termline;
- }else{
- do{
- n = read(STDIN_FILENO, buf+nbuf, 1);
- if(n <= 0)
- return -1;
- nbuf += n;
- }while(!fullrune(buf, nbuf));
- if (mbtowc(&r, buf, strlen(buf)) < 0)
+ } else if (fscanf(stdin, "%lc", &r) != 1)
r = UNICODE_REPLACEMENT_CHAR;
- }
+
if(r == 0){
warn(Wnulls);
goto Again;
}
+
return r;
}