чување 6084e7a436ad49abe7bb1af5e1de49bdf11268d6
родитељ 90dea08528d8bfe9ea968a031d6827cc36a14a19
Аутор: Страхиња Радић <contact@strahinja.org>
Датум: Sun, 28 Aug 2022 22:34:12 +0200
Add tigetstr test program; update TODO
Signed-off-by: Страхиња Радић <contact@strahinja.org>
Diffstat:
| M | TODO | | | 8 | +++++++- |
| A | tigetstr-test.c | | | 58 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
измењених датотека: 2, додавања: 65(+), брисања: 1(-)
diff --git a/TODO b/TODO
@@ -22,7 +22,13 @@ TODO
- Create a debug version of netbsd-curses and debug that? With
now-added gdb
- The problem is in __UNCONST - the cast appears to strip the initial
- 2 bytes, rendering the pointer invalid
+ 2 bytes, rendering the pointer invalid - -fPIC related perhaps? -
+ Recompiled everything with -fPIC, still segfaults
+ - Mock test program tigetstr-test.c which initializes ncurses, then
+ calls the same tigetstr("tsl") runs fine. (??)
+ Compile it with
+ gcc -O0 -g -Wall tigetstr-test.c -o tigetstr-test \
+ -lncurses -lterminfo
[?] Try with S-nail (mailx) for now? all the dependencies above are then
not needed
diff --git a/tigetstr-test.c b/tigetstr-test.c
@@ -0,0 +1,58 @@
+#include <ncurses.h>
+#include <term.h>
+
+int
+main()
+{
+ char* s;
+ char buf[4096];
+
+ if (!initscr())
+ {
+ perror("initscr");
+ return 1;
+ }
+ cbreak();
+ noecho();
+ nonl();
+ s = tigetstr("tsl");
+ if (s)
+ {
+ if (s != (char*)-1)
+ {
+ char* ps = s;
+ char* pbuf = buf;
+ int len = 0;
+ const char* ver = curses_version();
+
+ if (!ver)
+ {
+ endwin();
+ printf("!ver\n");
+ return 1;
+ }
+ len = sprintf(pbuf, "%s\n", ver);
+ pbuf += len;
+
+ len = sprintf(pbuf, "tigetstr(\"tsl\")=[");
+ pbuf += len;
+ while (*ps)
+ {
+ len = sprintf(pbuf, "%X%s", *ps,
+ *(ps+1) ? " " : "");
+ pbuf += len;
+ ps++;
+ }
+ sprintf(pbuf, "]\n");
+ }
+ else
+ sprintf(buf, "tigetstr(\"tsl\")=(char*)-1\n");
+ }
+ else
+ sprintf(buf, "tigetstr(\"tsl\")=NULL\n");
+ addstr(buf);
+ refresh();
+ getchar();
+ endwin();
+ return 0;
+}