Fix bug in input handling when not downloaded. - sam - An updated version of th… | |
git clone git://vernunftzentrum.de/sam.git | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit 352fe7ddbeafce2db71b014625565a59b15c53c0 | |
parent f256522620ca007b623e5029d0cb6db4215c0ce0 | |
Author: Rob King <[email protected]> | |
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(-) | |
--- | |
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); |