Fix bug in input handling when not downloaded. - 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 352fe7ddbeafce2db71b014625565a59b15c53c0
(DIR) parent f256522620ca007b623e5029d0cb6db4215c0ce0
(HTM) Author: Rob King <jking@deadpixi.com>
Date: Wed, 4 Jan 2017 11:55:19 -0600
Fix bug in input handling when not downloaded.
Diffstat:
sam/cmd.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
---
(DIR) diff --git a/sam/cmd.c b/sam/cmd.c
@@ -1,4 +1,6 @@
/* Copyright (c) 1998 Lucent Technologies - All rights reserved. */
+#include <errno.h>
+
#include "sam.h"
#include "parse.h"
@@ -104,8 +106,13 @@ inputc(void)
r = *termoutp++;
if(termoutp == terminp)
terminp = termoutp = termline;
- } else if (fscanf(stdin, "%lc", &r) != 1)
+ } else{
+ int olderr = errno;
+ r = fgetwc(stdin);
+ if (r == WEOF && errno)
r = UNICODE_REPLACEMENT_CHAR;
+ errno = olderr;
+ }
if(r == 0){
warn(Wnulls);