From 036cb0ce95580efa03dff169bb3dba457a48cfdc Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 13 Jan 2010 12:05:22 +0000 Subject: Joakim Rosqvist: 27591 as modified in 27594: KEYBOARD_HACK variable --- Src/input.c | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) (limited to 'Src/input.c') diff --git a/Src/input.c b/Src/input.c index 80f8ec8d5..248d2ae71 100644 --- a/Src/input.c +++ b/Src/input.c @@ -291,20 +291,32 @@ inputline(void) zputs(ingetcline, stderr); fflush(stderr); } - if (*ingetcline && ingetcline[strlen(ingetcline) - 1] == '\n' && - interact && isset(SUNKEYBOARDHACK) && isset(SHINSTDIN) && - SHTTY != -1 && *ingetcline && ingetcline[1] && - ingetcline[strlen(ingetcline) - 2] == '`') { - /* Junk an unmatched "`" at the end of the line. */ - int ct; - char *ptr; - - for (ct = 0, ptr = ingetcline; *ptr; ptr++) - if (*ptr == '`') - ct++; - if (ct & 1) { - ptr[-2] = '\n'; - ptr[-1] = '\0'; + if (keyboardhackchar && *ingetcline && + ingetcline[strlen(ingetcline) - 1] == '\n' && + interact && isset(SHINSTDIN) && + SHTTY != -1 && ingetcline[1]) + { + char *stripptr = ingetcline + strlen(ingetcline) - 2; + if (*stripptr == keyboardhackchar) { + /* Junk an unwanted character at the end of the line. + (key too close to return key) */ + int ct = 1; /* force odd */ + char *ptr; + + if (keyboardhackchar == '\'' || keyboardhackchar == '"' || + keyboardhackchar == '`') { + /* + * for the chars above, also require an odd count before + * junking + */ + for (ct = 0, ptr = ingetcline; *ptr; ptr++) + if (*ptr == keyboardhackchar) + ct++; + } + if (ct & 1) { + stripptr[0] = '\n'; + stripptr[1] = '\0'; + } } } isfirstch = 1; -- cgit 1.4.1