OpenSDE Packages Database (without history before r20070)
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

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../newt/newt-0.52.12-nostdin.patch
  5. # Copyright (C) 2011 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. From f16b3d1ac2edaceb64463f29a3e394a0102aa554 Mon Sep 17 00:00:00 2001
  17. From: Miroslav Lichvar <mlichvar@redhat.com>
  18. Date: Wed, 10 Nov 2010 17:57:11 +0100
  19. Subject: [PATCH 1/2] don't call exit in library
  20. The feof() detection of closed stdin doesn't work anyway.
  21. ---
  22. newt.c | 3 ---
  23. 1 files changed, 0 insertions(+), 3 deletions(-)
  24. diff --git a/newt.c b/newt.c
  25. index f3f49ff..4e37bc1 100644
  26. --- a/newt.c
  27. +++ b/newt.c
  28. @@ -565,10 +565,7 @@ int newtGetKey(void) {
  29. if (key == SLANG_GETKEY_ERROR) {
  30. /* Either garbage was read, or stdin disappeared
  31. * (the parent terminal was proably closed)
  32. - * if the latter, die.
  33. */
  34. - if (feof(stdin))
  35. - exit(1);
  36. if (needResize) {
  37. needResize = 0;
  38. return NEWT_KEY_RESIZE;
  39. --
  40. 1.7.3.2
  41. From b8b8a86f22d08216328dffb8d70b3ae67629a905 Mon Sep 17 00:00:00 2001
  42. From: Miroslav Lichvar <mlichvar@redhat.com>
  43. Date: Wed, 10 Nov 2010 18:10:46 +0100
  44. Subject: [PATCH 2/2] return NEWT_EXIT_ERROR from form when stdin disappears
  45. ---
  46. form.c | 9 ++++++++-
  47. newt.c | 15 ++++++++-------
  48. newt.h | 3 ++-
  49. 3 files changed, 18 insertions(+), 9 deletions(-)
  50. diff --git a/form.c b/form.c
  51. index 24542a0..5b421fb 100644
  52. --- a/form.c
  53. +++ b/form.c
  54. @@ -841,7 +841,8 @@ newtComponent newtRunForm(newtComponent co) {
  55. } else {
  56. return NULL;
  57. }
  58. - }
  59. + } else if (es.reason == NEWT_EXIT_ERROR)
  60. + return NULL;
  61. return es.u.co;
  62. }
  63. @@ -1072,6 +1073,12 @@ void newtFormRun(newtComponent co, struct newtExitStruct * es) {
  64. }
  65. }
  66. + if (key == NEWT_KEY_ERROR) {
  67. + es->u.watch = -1;
  68. + es->reason = NEWT_EXIT_ERROR;
  69. + done = 1;
  70. + }
  71. +
  72. if (!done) {
  73. ev.event = EV_KEYPRESS;
  74. ev.u.key = key;
  75. diff --git a/newt.c b/newt.c
  76. index 4e37bc1..ab41dd8 100644
  77. --- a/newt.c
  78. +++ b/newt.c
  79. @@ -555,29 +555,30 @@ static void kmap_trie_fallback(struct kmap_trie_entry *to,
  80. }
  81. int newtGetKey(void) {
  82. - int key;
  83. + int key, lastcode, errors = 0;
  84. unsigned char *chptr = keyreader_buf, *lastmatch;
  85. - int lastcode;
  86. struct kmap_trie_entry *curr = kmap_trie_root;
  87. do {
  88. key = getkey();
  89. if (key == SLANG_GETKEY_ERROR) {
  90. - /* Either garbage was read, or stdin disappeared
  91. - * (the parent terminal was proably closed)
  92. - */
  93. if (needResize) {
  94. needResize = 0;
  95. return NEWT_KEY_RESIZE;
  96. }
  97. - /* ignore other signals */
  98. + /* Ignore other signals, but assume that stdin disappeared (the
  99. + * parent terminal was proably closed) if the error persists.
  100. + */
  101. + if (errors++ > 10)
  102. + return NEWT_KEY_ERROR;
  103. +
  104. continue;
  105. }
  106. if (key == NEWT_KEY_SUSPEND && suspendCallback)
  107. suspendCallback(suspendCallbackData);
  108. - } while (key == NEWT_KEY_SUSPEND);
  109. + } while (key == NEWT_KEY_SUSPEND || key == SLANG_GETKEY_ERROR);
  110. /* Read more characters, matching against the trie as we go */
  111. lastcode = *chptr = key;
  112. diff --git a/newt.h b/newt.h
  113. index 3111a21..f71ce1e 100644
  114. --- a/newt.h
  115. +++ b/newt.h
  116. @@ -217,7 +217,7 @@ char * newtReflowText(char * text, int width, int flexDown, int flexUp,
  117. struct newtExitStruct {
  118. enum { NEWT_EXIT_HOTKEY, NEWT_EXIT_COMPONENT, NEWT_EXIT_FDREADY,
  119. - NEWT_EXIT_TIMER } reason;
  120. + NEWT_EXIT_TIMER, NEWT_EXIT_ERROR } reason;
  121. union {
  122. int watch;
  123. int key;
  124. @@ -307,6 +307,7 @@ void newtComponentDestroy(newtComponent co);
  125. /* not really a key, but newtGetKey returns it */
  126. #define NEWT_KEY_RESIZE NEWT_KEY_EXTRA_BASE + 113
  127. +#define NEWT_KEY_ERROR NEWT_KEY_EXTRA_BASE + 114
  128. #define NEWT_ANCHOR_LEFT (1 << 0)
  129. #define NEWT_ANCHOR_RIGHT (1 << 1)
  130. --
  131. 1.7.3.2