You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

148 lines
4.2 KiB

# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../newt/newt-0.52.12-nostdin.patch
# Copyright (C) 2011 The OpenSDE Project
#
# More information can be found in the files COPYING and README.
#
# This patch file is dual-licensed. It is available under the license the
# patched project is licensed under, as long as it is an OpenSource license
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
# of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
# --- SDE-COPYRIGHT-NOTE-END ---
From f16b3d1ac2edaceb64463f29a3e394a0102aa554 Mon Sep 17 00:00:00 2001
From: Miroslav Lichvar <mlichvar@redhat.com>
Date: Wed, 10 Nov 2010 17:57:11 +0100
Subject: [PATCH 1/2] don't call exit in library
The feof() detection of closed stdin doesn't work anyway.
---
newt.c | 3 ---
1 files changed, 0 insertions(+), 3 deletions(-)
diff --git a/newt.c b/newt.c
index f3f49ff..4e37bc1 100644
--- a/newt.c
+++ b/newt.c
@@ -565,10 +565,7 @@ int newtGetKey(void) {
if (key == SLANG_GETKEY_ERROR) {
/* Either garbage was read, or stdin disappeared
* (the parent terminal was proably closed)
- * if the latter, die.
*/
- if (feof(stdin))
- exit(1);
if (needResize) {
needResize = 0;
return NEWT_KEY_RESIZE;
--
1.7.3.2
From b8b8a86f22d08216328dffb8d70b3ae67629a905 Mon Sep 17 00:00:00 2001
From: Miroslav Lichvar <mlichvar@redhat.com>
Date: Wed, 10 Nov 2010 18:10:46 +0100
Subject: [PATCH 2/2] return NEWT_EXIT_ERROR from form when stdin disappears
---
form.c | 9 ++++++++-
newt.c | 15 ++++++++-------
newt.h | 3 ++-
3 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/form.c b/form.c
index 24542a0..5b421fb 100644
--- a/form.c
+++ b/form.c
@@ -841,7 +841,8 @@ newtComponent newtRunForm(newtComponent co) {
} else {
return NULL;
}
- }
+ } else if (es.reason == NEWT_EXIT_ERROR)
+ return NULL;
return es.u.co;
}
@@ -1072,6 +1073,12 @@ void newtFormRun(newtComponent co, struct newtExitStruct * es) {
}
}
+ if (key == NEWT_KEY_ERROR) {
+ es->u.watch = -1;
+ es->reason = NEWT_EXIT_ERROR;
+ done = 1;
+ }
+
if (!done) {
ev.event = EV_KEYPRESS;
ev.u.key = key;
diff --git a/newt.c b/newt.c
index 4e37bc1..ab41dd8 100644
--- a/newt.c
+++ b/newt.c
@@ -555,29 +555,30 @@ static void kmap_trie_fallback(struct kmap_trie_entry *to,
}
int newtGetKey(void) {
- int key;
+ int key, lastcode, errors = 0;
unsigned char *chptr = keyreader_buf, *lastmatch;
- int lastcode;
struct kmap_trie_entry *curr = kmap_trie_root;
do {
key = getkey();
if (key == SLANG_GETKEY_ERROR) {
- /* Either garbage was read, or stdin disappeared
- * (the parent terminal was proably closed)
- */
if (needResize) {
needResize = 0;
return NEWT_KEY_RESIZE;
}
- /* ignore other signals */
+ /* Ignore other signals, but assume that stdin disappeared (the
+ * parent terminal was proably closed) if the error persists.
+ */
+ if (errors++ > 10)
+ return NEWT_KEY_ERROR;
+
continue;
}
if (key == NEWT_KEY_SUSPEND && suspendCallback)
suspendCallback(suspendCallbackData);
- } while (key == NEWT_KEY_SUSPEND);
+ } while (key == NEWT_KEY_SUSPEND || key == SLANG_GETKEY_ERROR);
/* Read more characters, matching against the trie as we go */
lastcode = *chptr = key;
diff --git a/newt.h b/newt.h
index 3111a21..f71ce1e 100644
--- a/newt.h
+++ b/newt.h
@@ -217,7 +217,7 @@ char * newtReflowText(char * text, int width, int flexDown, int flexUp,
struct newtExitStruct {
enum { NEWT_EXIT_HOTKEY, NEWT_EXIT_COMPONENT, NEWT_EXIT_FDREADY,
- NEWT_EXIT_TIMER } reason;
+ NEWT_EXIT_TIMER, NEWT_EXIT_ERROR } reason;
union {
int watch;
int key;
@@ -307,6 +307,7 @@ void newtComponentDestroy(newtComponent co);
/* not really a key, but newtGetKey returns it */
#define NEWT_KEY_RESIZE NEWT_KEY_EXTRA_BASE + 113
+#define NEWT_KEY_ERROR NEWT_KEY_EXTRA_BASE + 114
#define NEWT_ANCHOR_LEFT (1 << 0)
#define NEWT_ANCHOR_RIGHT (1 << 1)
--
1.7.3.2