Giter Site home page Giter Site logo

sabotage-linux / netbsd-curses Goto Github PK

View Code? Open in Web Editor NEW
142.0 142.0 13.0 1.45 MB

libcurses and dependencies taken from netbsd and brought into a portable shape (at least to musl or glibc)

License: Other

Makefile 3.50% Shell 0.70% C 71.11% Brainfuck 0.28% Awk 0.12% Roff 23.88% Assembly 0.41%
c curses linux ncurses netbsd-curses portable

netbsd-curses's People

Contributors

0-wiz-0 avatar abhinav-upadhyay avatar jakllsch avatar jprjr avatar jsonn avatar krytarowski avatar martinhusemann avatar michaelforney avatar mrgtwentythree avatar msaitoh avatar nbuwe avatar rillig avatar rofl0r avatar rokuyama avatar rsmarples avatar sauclovian avatar snarkophilus avatar zoulasc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

netbsd-curses's Issues

TODO 3) get rid of terminfo cruft

the terminfo db is filled with a ton of junk; terminals that are unlikely to be ever encountered should be nuked from the list.

rather than starting to remove junk, the alternative is to do it the other way round:
start from zero and add the few terminals that are somewhat likely to be still in use in modern systems.

tic works differently than ncurses'.

investigating this issue here: martanne/dvtm#42 and reading the manpage of our tic and ncurses tic (as well as studying the behaviour with strace) it turned out that there's a fundamental difference between the two.

  • ncurses tic, when called with a terminfo description file, will create a compiled terminfo description and move that into the systems terminfo directory (usually /usr/share/terminfo ).
    from the perspective of a packager, this behaviour is annoying since it circumvents the usual DESTDIR staging mechanisms when building a package for future use on several systems.
    packagers most likely did override this by manually setting the TERMINFO environment variable to the staging dir.
  • netbsd-curses tic just creates a CDB file of the terminfo description input file with the extension ".cdb" in the current directory.
    it is not installed into a system directory.
    in order to use such a compiled terminfo cdb file, it must be named either $(PREFIX)/share/terminfo.cdb or $(HOME)/.terminfo.cdb.

unlike ncurses, the terminfo database is not a directory structure, that means you can not add a single terminfo entry by moving it into some structure. if you want to add compiled terminfo descriptions, the entire terminfo.cdb file must be re-generated in a single call from a single input file. this may be inconvenient in the current situation that there are a small number of packages that ship their own terminfo descriptions and expect the ncurses behaviour from tic. a solution might be to ship a tool that can join several .cdb files into one, or to change the code in netbsd-curses to iterate over all cdb files found in a specific directory, or to ship all terminfo descriptions of said small number of packages as part of netbsd-curses (this might become unpractical if one or more of those packages tend to change their descriptions regularly).

lack of mousehandling routines

when compiling htop against netbsd curses, the following errors need to patched out

CRT.c:210:4: warning: implicit declaration of function 'mousemask' [-Wimplicit-$
CRT.c:210:14: error: 'BUTTON1_CLICKED' undeclared (first use in this function)  
htop.c:590:10: error: unknown type name 'MEVENT'                                
htop.c:591:10: warning: implicit declaration of function 'getmouse' [-Wimplicit$
htop.c:593:23: error: request for member 'bstate' in something not a structure $
htop.c:593:33: error: 'BUTTON1_CLICKED' undeclared (first use in this function) 
htop.c:594:26: error: request for member 'y' in something not a structure or un$
htop.c:614:40: error: 'BUTTON4_CLICKED' undeclared (first use in this function) 

the patch is straightforward and it should be considered upstreaming it (configure check for getmouse, and conditional compilation via #ifdef HAVE_MOUSE or similar).
out of several tested packages, htop is the only one to make use of ncurses' unique mouse features.

Compile fails with glibc 2.27-8

Specifically, trying to compile on standard debian box with glibc C fails in three places:

  • libcurses/refresh.c uses wcwidth
  • libterminfo/term.c uses strlcpy
  • libcurses/tstp.c uses SIG_HOLD

strlcpy appears to be a BSD extension that glibc deliberately doesn't implement. The other two seem to be available under glibc (from a cursory web search) so may be missing headers.

Checked gcc 8.2 and clang 6.0 with glibc 2.27-8.

libmenu lacks some ncurses features

notably, alsa-utils 1.0.28 uses the function set_menu_spacing, which is unavailable.
defining it as a no-op macro fixes the build and does not make a functional difference
(there's only a visible difference in color mode as text strings are not padded in the bg color).

Build Error: Assumed value of MB_LEN_MAX wrong

Arch. netbsd-curses 0.0.4. Unable to complete the build process due to following error:

In file included from /usr/include/stdlib.h:925:0,
from libcurses/fileio.c:41:
/usr/include/bits/stdlib.h: In function ‘wctomb’:
/usr/include/bits/stdlib.h:90:3: error: #error "Assumed value of MB_LEN_MAX wrong"

error "Assumed value of MB_LEN_MAX wrong"

^~~~~
cc -D_FORTIFY_SOURCE=2 -I. -I./libterminfo -DHAVE_WCHAR -I./libcurses -march=amdfam16 -O2 -pipe -fstack-protector-all -fomit-frame-pointer -Werror-implicit-function-declaration -c -o libcurses/getch.o libcurses/getch.c
make: *** [GNUmakefile:399: libcurses/fileio.o] Error 1
make: *** Waiting for unfinished jobs....
==> ERROR: A failure occurred in build().
Aborting...

How to resolve?

Cannot seem to build static w/ specified lib && include paths

Attempting a static build. I have a static binutils, musl-libc, and gcc targeted to that libc.

My config.mak (aside, would be nice if build recognized config.mk as well ) looks like:

PREFIX = /home/[me]/repos/toolbox/ins
TARGET = x86_64-linux-musl
CFLAGS=-O2 -I. -I${PREFIX}/${TARGET}/include -I./libcurses -I${PREFIX}/include -nostdinc
LDFLAGS=-static -L${PREFIX}/lib -L${PREFIX}/${TARGET}/lib -nodefaultlibs
CC=${TARGET}-gcc

I then run "make all-static" but it doesn't seem to pull in the LDFLAGS and the build does not build nbperf statically:

file src/netbsd-curses/nbperf/nbperf
src/netbsd-curses/nbperf/nbperf: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), not stripped

It is just after the nbperf build that I get the error which is ( with nbperf's called build command for context )

x86_64-linux-musl-gcc  nbperf/nbperf.o nbperf/nbperf-bdz.o nbperf/nbperf-chm.o nbperf/nbperf-chm3.o nbperf/graph2.o nbperf/graph3.o nbperf/mi_vector_hash.o -o nbperf/nbperf
Generating terminfo hash
TERMINFODIR=./terminfo TOOL_AWK=awk TOOL_NBPERF=nbperf/nbperf TOOL_SED=sed TOOL_SORT=sort TOOL_TIC=tic/host_tic /bin/sh libterminfo/genhash libterminfo/term.h nbperf/nbperf > libterminfo/hash.c
libterminfo/genhash: nbperf/nbperf: /lib/ld-musl-x86_64.so.1: bad ELF interpreter: No such file or directory
make: *** [libterminfo/hash.c] Error 126

Any ideas what could be going on? Also apologies if this is in the wrong place; didn't see anywhere else in the readme to submit a build issue.

Thank you!

TODO 5) import infocmp tool

it seems there are some legitimate uses of the infocmp tool, and since ncurses ships it we should probably add it as well.

Cross-compiling issues

When cross-compiling netbsd-curses for aarch64 the following happens:

[...]
Generating terminfo hash
TERMINFODIR=./terminfo TOOL_AWK=awk TOOL_NBPERF=nbperf/nbperf TOOL_SED=sed TOOL_SORT=sort TOOL_TIC=tic/host_tic /bin/sh libterminfo/genhash libterminfo/term.h nbperf/nbperf > libterminfo/hash.c
libterminfo/genhash: 60: libterminfo/genhash: nbperf/nbperf: Exec format error
make[1]: *** [GNUmakefile:478: libterminfo/hash.c] Error 2
make[1]: Leaving directory '/mnt/build/tools/tools-src/curses/netbsd-curses-0.3.1'
make: *** [Makefile:8: all] Error 2

The "Exec format error" is obvious since nbperf was built for aarch64, and the host machine is x86_64.

make(1) is called with the following flags:

CC = cc
HOSTCC = /mnt/build/tools/aarch64/bin/clang
CFLAGS_HOST = -B/mnt/build/tools/aarch64/bin   # it contains ld, a symlink to ld.lld

Was something done incorrectly or incompletely?

midnight commander output in `linux` terminal is garbage

instead of drawing the line characters, some 'Ä'-like umlauts are displayed.
also when moving the cursor down, the line drawing is shifted one character to the side, i.e. to another column.
trying around with different other terminfo entries, i found that the bterm terminfo descriptions work almost 100% (apart from some black bricks painted in random locations when refreshing), so i diffed the output of infocmp for linux and bterm.
i then added the things linux had but bterm not, and the result is an almost perfect terminfo description:

footerm|foo console,
	acsc=aajjkkllmmqqttuuxx,
	am,
	bce,
	bel=^G,
	blink=\E[5m,
	bold=\E[1m,
	ccc,
	civis=\E[?25l,
	clear=\E[H\E[2J,
	cnorm=\E[?25h,
	colors#8,
	cols#80,
	cr=^M,
	csr=\E[%i%p1%d;%p2%dr,
	cub1=^H,
	cub=\E[%p1%dD,
	cud1=^J,
	cud=\E[%p1%dB,
	cuf1=\E[C,
	cuf=\E[%p1%dC,
	cup=\E[%i%p1%d;%p2%dH,
	cuu1=\E[A,
	cuu=\E[%p1%dA,
	cvvis=\E[?25h\E[?8c,
	dch1=\E[P,
	dch=\E[%p1%dP,
	dim=\E[2m,
	dl1=\E[M,
	dl=\E[%p1%dM,
	ech=\E[%p1%dX,
	ed=\E[J,
	el1=\E[1K,
	el=\E[K,
	eo,
	flash=\E[?5h\E[?5l$<200/>,
	home=\E[H,
	hpa=\E[%i%p1%dG,
	ht=^I,
	hts=\EH,
	ich1=\E[@,
	ich=\E[%p1%d@,
	il1=\E[L,
	il=\E[%p1%dL,
	ind=^J,
	initc=\E]P%p1%x%p2%{255}%*%{1000}%/%02x%p3%{255}%*%{1000}%/%02x%p4%{255}%*%{1000}%/%02x,
	it#8,
	kb2=\E[G,
	kbs=^?,
	kcbt=\E[Z,
	kcub1=\E[D,
	kcud1=\E[B,
	kcuf1=\E[C,
	kcuu1=\E[A,
	kdch1=\E[3~,
	kend=\E[4~,
	kf10=\E[21~,
	kf11=\E[23~,
	kf12=\E[24~,
	kf13=\E[25~,
	kf14=\E[26~,
	kf15=\E[28~,
	kf16=\E[29~,
	kf17=\E[31~,
	kf18=\E[32~,
	kf19=\E[33~,
	kf1=\E[[A,
	kf20=\E[34~,
	kf2=\E[[B,
	kf3=\E[[C,
	kf4=\E[[D,
	kf5=\E[[E,
	kf6=\E[17~,
	kf7=\E[18~,
	kf8=\E[19~,
	kf9=\E[20~,
	khome=\E[1~,
	kich1=\E[2~,
	kmous=\E[M,
	knp=\E[6~,
	kpp=\E[5~,
	kspd=^Z,
	lines#24,
	mir,
	msgr,
	ncv#18,
	nel=^M^J,
	oc=\E]R,
	op=\E[49m\E[39m,
	pairs#64,
	rc=\E8,
	rev=\E[7m,
	ri=\EM,
	rmacs=^O,
	rmam=\E[?7l,
	rmir=\E[4l,
	rmpch=\E[10m,
	rmso=\E[27m,
	rmul=\E[24m,
	rs1=\Ec\E]R,
	sc=\E7,
	setab=\E[4%p1%dm,
	setaf=\E[3%p1%dm,
	sgr0=\E[0m,
	sgr=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p5%t;2%;%?%p6%t;1%;%?%p9%t;11%;m,
	smacs=^N,
	smam=\E[?7h,
	smir=\E[4h,
	smpch=\E[11m,
	smso=\E[7m,
	smul=\E[4m,
	tbc=\E[3g,
	u6=\E[%i%d;%dR,
	u7=\E[6n,
	u8=\E[?6c,
	u9=\E[c,
	vpa=\E[%i%p1%dd,
	xenl,
	xon,

then i diffed that against the linux output and added the changed lines as comments:

linux99|linux99 console,
	acsc=+\020\,\021-\030.^Y0\333`\004a\261f\370g\361h\260i\316j\331k\277l\332m\300n\305o~p\304q\304r\304s_t\303u\264v\301w\302x\263y\363z\362{\343|\330}\234~\376,
#	acsc=aajjkkllmmqqttuuxx,
	am,
	bce,
	bel=^G,
	blink=\E[5m,
	bold=\E[1m,
	ccc,
	civis=\E[?25l\E[?1c,
	clear=\E[H\E[J,
	cnorm=\E[?25h\E[?0c,
#	civis=\E[?25l,
#	clear=\E[H\E[2J,
#	cnorm=\E[?25h,
	colors#8,
#	cols#80,
	cr=^M,
	csr=\E[%i%p1%d;%p2%dr,
	cub1=^H,
	cub=\E[%p1%dD,
	cud1=^J,
	cud=\E[%p1%dB,
	cuf1=\E[C,
	cuf=\E[%p1%dC,
	cup=\E[%i%p1%d;%p2%dH,
	cuu1=\E[A,
	cuu=\E[%p1%dA,
	cvvis=\E[?25h\E[?8c,
	dch1=\E[P,
	dch=\E[%p1%dP,
	dim=\E[2m,
	dl1=\E[M,
	dl=\E[%p1%dM,
	ech=\E[%p1%dX,
	ed=\E[J,
	el1=\E[1K,
	el=\E[K,
	eo,
	flash=\E[?5h\E[?5l$<200/>,
	home=\E[H,
	hpa=\E[%i%p1%dG,
	ht=^I,
	hts=\EH,
	ich1=\E[@,
	ich=\E[%p1%d@,
	il1=\E[L,
	il=\E[%p1%dL,
	ind=^J,
	initc=\E]P%p1%x%p2%{255}%*%{1000}%/%02x%p3%{255}%*%{1000}%/%02x%p4%{255}%*%{1000}%/%02x,
	it#8,
	kb2=\E[G,
	kbs=^?,
	kcbt=\E[Z,
	kcub1=\E[D,
	kcud1=\E[B,
	kcuf1=\E[C,
	kcuu1=\E[A,
	kdch1=\E[3~,
	kend=\E[4~,
	kf10=\E[21~,
	kf11=\E[23~,
	kf12=\E[24~,
	kf13=\E[25~,
	kf14=\E[26~,
	kf15=\E[28~,
	kf16=\E[29~,
	kf17=\E[31~,
	kf18=\E[32~,
	kf19=\E[33~,
	kf1=\E[[A,
	kf20=\E[34~,
	kf2=\E[[B,
	kf3=\E[[C,
	kf4=\E[[D,
	kf5=\E[[E,
	kf6=\E[17~,
	kf7=\E[18~,
	kf8=\E[19~,
	kf9=\E[20~,
	khome=\E[1~,
	kich1=\E[2~,
	kmous=\E[M,
	knp=\E[6~,
	kpp=\E[5~,
	kspd=^Z,
#	lines#24,
	mir,
	msgr,
	ncv#18,
	nel=^M^J,
	oc=\E]R,
	op=\E[39;49m,
#	op=\E[49m\E[39m,
	pairs#64,
	rc=\E8,
	rev=\E[7m,
	ri=\EM,
	rmacs=\E[10m,
#	rmacs=^O,
	rmam=\E[?7l,
	rmir=\E[4l,
	rmpch=\E[10m,
	rmso=\E[27m,
	rmul=\E[24m,
	rs1=\Ec\E]R,
	sc=\E7,
	setab=\E[4%p1%dm,
	setaf=\E[3%p1%dm,
	sgr0=\E[0;10m,
#	sgr0=\E[0m,
	sgr=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p5%t;2%;%?%p6%t;1%;%?%p9%t;11%;m,
	smacs=\E[11m,
#	smacs=^N,
	smam=\E[?7h,
	smir=\E[4h,
	smpch=\E[11m,
	smso=\E[7m,
	smul=\E[4m,
	tbc=\E[3g,
	u6=\E[%i%d;%dR,
	u7=\E[6n,
	u8=\E[?6c,
	u9=\E[c,
	vpa=\E[%i%p1%dd,
	xenl,
	xon,

by turning on and off the differing items i finally found that switching smacs and acsc, the problem appears to be fixed.
googling for smacs and rmacs found this debian bug report:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=515609
so this bug report basically says that the smacs and rmacs used by the ncurses terminfo db are buggy (correct would be what bterm uses), so that was fixed but later *reverted* because it broke midnight commander(linked with slang) for ppl using non-utf8 locales (interestingly in about the same way linux is currently broken for us *without* the fix).
there are some follow-ups to that bug that may be of interest as well:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=665959
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=823658

CANCELLED_STRING

Regarding:
libterminfo/term_private.h:75: #define CANCELLED_STRING (char *)(-1)

(char *)(-1) evaluates to 0xffffffffffff or 16^16.

If an application calls ti_getstr with a bad ID string, it returns 0xffffffffffff. Is this the intended behavior? How should an end user of this library handle this error?

Thanks

Add toe utility

toe - table of (terminfo) entries

With no options, toe lists all available terminal types by primary name
with descriptions. File arguments specify the directories to be
scanned; if no such arguments are given, your default terminfo direc‐
tory is scanned. If you also specify the -h option, a directory header
will be issued as each directory is entered.

ul (util-linux 2.29): undefined references

Workaround is to --disable-ul.

text-utils/ul-ul.o: In function `xsetmode':
ul.c:(.text+0x259): undefined reference to `tputs'
ul.c:(.text+0x276): undefined reference to `tputs'
text-utils/ul-ul.o: In function `outc':
ul.c:(.text+0x4f5): undefined reference to `tputs'
ul.c:(.text+0x535): undefined reference to `tputs'
text-utils/ul-ul.o: In function `flushln':
ul.c:(.text+0x6bb): undefined reference to `tputs'
text-utils/ul-ul.o:ul.c:(.text+0xbe7): more undefined references to `tputs' follow
text-utils/ul-ul.o: In function `main':
ul.c:(.text.startup+0x145): undefined reference to `setupterm'
ul.c:(.text.startup+0x17b): undefined reference to `setupterm'
ul.c:(.text.startup+0x187): undefined reference to `tigetstr'
ul.c:(.text.startup+0x19a): undefined reference to `tigetstr'
ul.c:(.text.startup+0x1ad): undefined reference to `tigetstr'
ul.c:(.text.startup+0x1ce): undefined reference to `tigetstr'
ul.c:(.text.startup+0x1e1): undefined reference to `tigetstr'
text-utils/ul-ul.o:ul.c:(.text.startup+0x1f4): more undefined references to `tigetstr' follow
text-utils/ul-ul.o: In function `main':
ul.c:(.text.startup+0x2d7): undefined reference to `tigetflag'
ul.c:(.text.startup+0x2f5): undefined reference to `tigetflag'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:6883: ul] Error 1
make[2]: *** Waiting for unfinished jobs....
ar: `u' modifier ignored since `D' is the default (see `U')
copying selected object files to avoid basename conflicts...
ar: `u' modifier ignored since `D' is the default (see `U')
make[2]: Leaving directory '/tmp/archives/util-linux/src/util-linux-2.29'
make[1]: *** [Makefile:11436: all-recursive] Error 1
make[1]: Leaving directory '/tmp/archives/util-linux/src/util-linux-2.29'
make: *** [Makefile:4767: all] Error 2
==> ERROR: A failure occurred in build().
    Aborting...

latest manpage additions missing.

i imported a number of upstream additions that mention related manpages, however they are not to be found in the git clone of the netbsd src tree i'm using. the following manpages were mentioned but are currently missing:

filter.0
filter.3

getsyx.0
is_keypad.0
is_leaveok.0
setsyx.0
getsyx.3
is_keypad.3
is_leaveok.3
setsyx.3

use_env.0
use_env.3

typeahead.0
typeahead.3

has_key.0
has_key.3

additionally this manpage curses_screen.3 was added to a Makefile, but not to the tree, so it was probably already there but forgotten to add.
we need to get these manpages from some other source, maybe directly from the CVS.

__scanflike error on musl

Hi. I'm building tabs from nbase using Clang, and got this error which seems to be related to this ncurses:

/usr/include/curses.h:721:43: error: expected function body after function declarator
int      mvscanw(int, int, const char *, ...) __scanflike(3, 4);
                                              ^
/usr/include/curses.h:731:54: error: expected function body after function declarator
int      mvwscanw(WINDOW *, int, int, const char *, ...) __scanflike(4, 5);
                                                         ^
/usr/include/curses.h:763:31: error: expected function body after function declarator
int      scanw(const char *, ...) __scanflike(1, 2);
                                  ^
/usr/include/curses.h:786:50: error: expected function body after function declarator
int      vw_scanw(WINDOW *, const char *, __va_list) __scanflike(2, 0);
                                                     ^
/usr/include/curses.h:788:49: error: expected function body after function declarator
int      vwscanw(WINDOW *, const char *, __va_list) __scanflike(2, 0);
                                                    ^
/usr/include/curses.h:831:42: error: expected function body after function declarator
int      wscanw(WINDOW *, const char *, ...) __scanflike(2, 3);

A quick grep shows that function was defined in form.h, but adding it didn't solve the problem. And at you said in #46, there's a lot of mismatches growing between NetBSD's version and this version, maybe it caused the problem.
What do I need to do make it work?

support for strfnames/strnames

libtermkey requires strfnames/strnames, which are not currently available in netbsd-curses. The patch was created thanks to the help of Michael Forney.

Best regards,
Daniel

diff -urN netbsd-curses.orig/libterminfo/names.awk netbsd-curses/libterminfo/names.awk
--- netbsd-curses.orig/libterminfo/names.awk	Thu Jan  1 00:00:00 1970
+++ netbsd-curses/libterminfo/names.awk	Mon Nov 26 15:26:54 2018
@@ -0,0 +1,21 @@
+/TICODE_[a-z]+,/ {
+	names[++numnames] = substr($1, 8, length($1) - 8)
+}
+
+/^#define t_[a-z]+(t)/ {
+	fnames[++numfnames] = substr($2, 3, length($2) - 5)
+}
+
+END {
+	print "\nconst char *const strnames[] = {"
+	for (i = 1; i <= numnames; ++i)
+		print("\t\"" names[i] "\",")
+	print "\t(void *)0"
+	print "};"
+
+	print "\nconst char *const strfnames[] = {"
+	for (i = 1; i <= numfnames; ++i)
+		print("\t\"" fnames[i] "\",")
+	print "\t(void *)0"
+	print "};"
+}
diff -urN netbsd-curses.orig/libterminfo/term.h netbsd-curses/libterminfo/term.h
--- netbsd-curses.orig/libterminfo/term.h	Mon Nov 26 15:17:58 2018
+++ netbsd-curses/libterminfo/term.h	Mon Nov 26 15:26:00 2018
@@ -1944,6 +1944,8 @@
 #endif
 
 extern TERMINAL *cur_term;
+extern const char *const strfnames[];
+extern const char *const strnames[];
 
 /* setup functions */
 int		setupterm(const char *, int, int *);
diff -urN netbsd-curses.orig/GNUmakefile netbsd-curses/GNUmakefile
--- netbsd-curses.orig/GNUmakefile	Mon Nov 26 16:06:47 2018
+++ netbsd-curses/GNUmakefile	Mon Nov 26 16:08:49 2018
@@ -67,6 +67,7 @@
 TI_SRCS+=libterminfo/compile.c libterminfo/hash.c
 TI_SRCS+=libterminfo/cdbr.c
 TI_SRCS+=libterminfo/mi_vector_hash.c
+TI_SRCS+=libterminfo/names.c
 # Build in termcap emulation
 TI_SRCS+=libterminfo/termcap.c
 TI_LIBA=libterminfo/libterminfo.a
@@ -74,6 +75,9 @@
 TI_OBJS=$(TI_SRCS:.c=.o)
 TI_LOBJS=$(TI_SRCS:.c=.lo)
 TI_MAN =$(sort $(wildcard libterminfo/*.3))
+
+libterminfo/names.c: libterminfo/term.h
+	cat $^ | awk -f libterminfo/names.awk > $@
 
 libterminfo/term.o: CPPFLAGS+=-DINSTALL_PREFIX=\"$(PREFIX)\"
 libterminfo/term.lo: CPPFLAGS+=-DINSTALL_PREFIX=\"$(PREFIX)\"
diff -urN netbsd-curses.orig/libterminfo/GNUmakefile netbsd-curses/libterminfo/GNUmakefile
--- netbsd-curses.orig/libterminfo/GNUmakefile	Mon Nov 26 15:17:58 2018
+++ netbsd-curses/libterminfo/GNUmakefile	Mon Nov 26 15:23:01 2018
@@ -12,6 +12,7 @@
 SRCS+=		compile.c hash.c
 SRCS+=		cdbr.c
 SRCS+=		mi_vector_hash.c
+SRCS+=		names.c
 
 INCS=		term.h
 INCSDIR=	/usr/include
@@ -99,6 +100,9 @@
 
 term.c: compiled_terms.c
 termcap.c: termcap_hash.c
+
+names.c: term.h
+	cat $^ | awk -f names.awk > $@
 
 libterminfo.a: $(OBJS)
 	ar cru $@ $^

bug in linux terminal with mc and nano

  • open a linux terminal
  • run midnight commander
  • in midnight commander, run nano inexistant_file
  • nano opens, close it with CTRL-X
    now you get a black screen with a blinking cursor.
    the cursor transformed from previously _ to [] style, i.e. it looks like an insert-mode cursor.
  • quit mc py pressing F10.
    the cursor still is [], and the terminal state is messed up. text you enter is not visible.
    need to type reset to get the terminal back into a usable state.

generate terminfo.5 manpage

# Generate our man pages
terminfo.5: genman terminfo.5.in term.h termcap_map.c
                @echo "Generating terminfo man pages"
                ${SCRIPT_ENV} ${HOST_SH} ${.ALLSRC} > ${.TARGET}

CLEANFILES+=    terminfo.5

man: terminfo.5 

Problems uninstalling

The makefile does not contain targets for uninstalling. This requires the user to figure out which files belong to netbsd-curses, and remove them manually.

TODO 2) urxvt terminfo entry uses non-portable tic features

when compiling the urxvt terminfo entry (at the very bottom) of the terminfo file, tic spits out a number of warnings, resulting from usage of non-standard descriptor format.
as a result the compiled terminfo misses some features, for example usage of HOME/END keys in urxvt is not possible.
this should be fixed by using "old-school" style descriptors for the entries tic warns about.

Provide a full generic static target

It could be a smart idea to provide a static-only target inside the GNUMakefile. The default install target can be easily modified with sed(1), but it does not seem to be a perenial solution (for maintainers for example).
I was thinking about something like this:

install-static: install-headers install-stalibs install-progs install-pcs

This is a random (harmless) example (having a all-static could work too). Dunno if it's enough clean for you. I can provide a tiny patch (which is a better) if you agree with the request.

Another question: do you plan to create a tag soon?

GPG Signature or Hash Verifications?

Being that the Curses library is so important, can you provide us with auth mechanisms to ensure the integrity of our downloads? Thank you for continuing development on netbsd-curses as it has replaced ncurses on several Arch boxes thus far. The only build issue I came across was with urxvt:

/usr/bin/tic ./etc/rxvt-unicode.terminfo
tic: rxvt-unicode: kDC5: unknown capability
tic: rxvt-unicode: kDC6: unknown capability
tic: rxvt-unicode: kDN: unknown capability
tic: rxvt-unicode: kDN5: unknown capability
tic: rxvt-unicode: kIC5: unknown capability
tic: rxvt-unicode: kIC6: unknown capability
tic: rxvt-unicode: kEND5: unknown capability
tic: rxvt-unicode: kEND6: unknown capability
tic: rxvt-unicode: kFND5: unknown capability
tic: rxvt-unicode: kFND6: unknown capability
tic: rxvt-unicode: kHOM5: unknown capability
tic: rxvt-unicode: kHOM6: unknown capability
tic: rxvt-unicode: kLFT5: unknown capability
tic: rxvt-unicode: kNXT5: unknown capability
tic: rxvt-unicode: kNXT6: unknown capability
tic: rxvt-unicode: kPRV5: unknown capability
tic: rxvt-unicode: kPRV6: unknown capability
tic: rxvt-unicode: kRIT5: unknown capability
tic: rxvt-unicode: kUP: unknown capability
tic: rxvt-unicode: kUP5: unknown capability

At minimum what needs to be done to replace ncurses on Arch is:

  1. Build ncurses out of bash (to allow pacman to function)
  2. Install netbsd-curses based on: http://pastebin.com/X85EA5A8
  3. Drop PGP and hash verifications for readline/pinentry/gpg
  4. Build readline/pinentry/gpg against netbsd-curses; install
  5. Build binutils against netbsd-curses and rebuild netbsd-curses; install

I'll continue testing as I go along. Again, thanks for porting this over :)

Error compiling with ncurses installed.

Platform is latest Arch Linux, GCC, GNU crap, etc.
Compiling with LDFLAGS=-static, PREFIX="".

It fails with

In file included from libterminfo/setupterm.c:41:0:
/usr/include/curses.h:879:32: error: conflicting types for tparam
 extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, ...); /*special*/

In file included from libterminfo/setupterm.c:41:0:
./libterminfo/term.h:1961:9: note: previous declaration of tparm was here
 char *  tparm(const char *, long, long, long, long, long, 

(Apologies if there is a typo here and there -- I had to type it out manually from a box that doesn't have internet access :( )

It seems to me as if GCC is selecting /usr/include/curses.h over ./curses/curses.h, but the compile options for that module start with -I./../curses, so that seems unlikely.

nnn with netbsd-curses

Hi,

We are trying out nnn with netbsd-curses and musl libc.

The performance results are just awesome!

Seeing the issue jarun/nnn#998 because of the following difference between ncursesw and netbsd-curses:

In a case where ncursesw sends KEY_RESIZE (key value 410) twice, netbsd-curses sends a KEY_RESIZE (key value 512) followed by a NULL (key value 0) character.

nnn uses the NULL key (^Space) for range selection leading into issues.

Can you please take a look why the NULL key is sent after the KEY_RESIZE?

Attached the debug logs from ncursesw and netbsd-curses. A diff would show the problem.

Please let us know if you need some more details.

nnndbg_ncurses.txt
nnndbg_netbsd.txt

Compile errors (with glibc)

  • glibc 2.23.90 (gad1b6d8)
  • gcc 5.3.0 | clang 3.7.1
  • gmake 4.1

Sorry if I'm being dumb here but there seems to be some issue on my system with
how includes or conditional macros are defined, as when attempting to build by
simply running make I get the following errors:

cc -I../libterminfo -I.. -I. -Werror-implicit-function-declaration    -c -o tic.o tic.c
In file included from /usr/include/sys/stat.h:36:0,
                 from tic.c:33:
/usr/include/time.h:75:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘typedef’
 typedef __time_t time_t;
 ^
/usr/include/time.h:76:1: error: unknown type name ‘__END_NAMESPACE_STD’
 __END_NAMESPACE_STD
 ^
In file included from tic.c:33:0:
/usr/include/sys/stat.h: In function ‘__USING_NAMESPACE_STD’:
/usr/include/sys/stat.h:43:17: error: storage class specified for parameter ‘dev_t’
 typedef __dev_t dev_t;
                 ^
/usr/include/sys/stat.h:48:17: error: storage class specified for parameter ‘gid_t’
 typedef __gid_t gid_t;
                 ^

This continues for roughly 3000 lines before ending with:

/usr/include/sys/stat.h:48:17: error: declaration for parameter ‘gid_t’ but no such parameter
 typedef __gid_t gid_t;
                 ^
/usr/include/sys/stat.h:43:17: error: declaration for parameter ‘dev_t’ but no such parameter
 typedef __dev_t dev_t;
                 ^
tic.c:627:1: error: expected ‘{’ at end of input
 }
 ^
GNUmakefile:27: recipe for target 'tic.o' failed
make: *** [tic.o] Error 1

I don't expect it to really build with glibc but these kinds of errors seem
like syntax rules are being broken and I'm not sure where.

Heavy namespace violations in curses.h

curses.h is full of identifiers in the __-prefixed namespace, many of which are things that could easily clash with system headers. I saw a report of it failing to build on OSX that looked like it might have been related, and while I didn't see cause for that particular failure it prompted me to notice all these violations. I don't think any of them are essential/public API.

Make a new release

Hi! I'm looking into packaging netbsd-curses for Void Linux, but we try to stick to proper releases from upstream instead of grabbing some git rev of a given package. Since this repo seems to have received many commits ever since the last 2019 release, I think a new release would be very helpful!

Let me know if you need help for testing anything.

0.2.1 Build Failure

libcurses/slk.c: In function '__slk_set':
libcurses/slk.c:488:10: error: implicit declaration of function 'wcwidth' [-Werror=implicit-function-declaration]
len += wcwidth(wc);

Last known successful build was 22acb33 so something between then and now may be the culprit.

wchar_t / unicode support broken? - initscr breaking putwc

Hi,

i've spent quite a bit of time trying to debug this issue and at this point i feel confident to say it might be a bug. If putwc is called with a valid codepoint (i've used 0xF6 for testing which should render as "ö") before initscr everything works as expected but anywhere after initscr non 7bit codepoints render as unknown characters (inverse color question marks) and as putwc is used by all functions printing wchar_t strings (for example waddwstr) this basically breaks unicode support. Locale settings (setlocale) don't seem to affect this at all (en_US.UTF-8, C or an invalid setting all result in the same behavior).

Trying to track down the cause i've come to the conclusion that it seems to be related to tputs/ti_puts calls (adding macros to curses_private.h turning those into noops keeps putwc functional but obviously otherwise breaks rendering badly). Sadly i wasn't able to pin this to a certain call as it seems at least multiple (or even all of them?) result in putwc breaking. Any kind of hint or pointer on to how to get this working would be greatly appreciated.

Testing was done on Devuan Ascii (a linux distribution pretty much identical to Debian 9.0 sans systemd). Curses version used is 0.3.2 release. I've also tried a handful of different terminal definitions which made no difference regarding putwc behavior (terminal used for most testing is sakura which is libvte based identifying as xterm-256color. Xterm (the application, not just the definition) gave the same results though.

libmenu userpointer uses char* rather than void*

this is a difference to the ncurses API and should be fixed.
void* makes sense, char* not.
seen compiling alsa-utils 1.0.28 against libcurses.

card_select.c: In function 'on_key_enter':                                      
card_select.c:52:23: warning: initialization from incompatible pointer type [en$
card_select.c: In function 'create_list_items':                                 
card_select.c:235:3: warning: passing argument 2 of 'set_item_userptr' from inc$
In file included from card_select.c:24:0:                                       
/usr/include/menu.h:207:5: note: expected 'char *' but argument is of type 'str$

Unable to build with gnu-efi (linker relocation fails)

Hello!

I am interested in creating a UEFI application utilizing netbsd-curses.
For this purpose, I attempted to build netbsd-curses against gnu-efi on a recent Debian GNU/Linux 11 testing/bullseye amd64 system. (gnu-efi is available as repository package)

However, after adjusting CFLAGS and LDFLAGS accordingly, I found myself unable to successfully link ANY shared library from netbsd-curses. All object files seem to compile flawlessly. I confirmed this by changing parts of the GNUmakefile and forcing some components off, etc.

All attempts to link terminate like this:

cc -I. -I./libterminfo -DHAVE_WCHAR -DINSTALL_PREFIX="/usr" -DINSTALL_PREFIX="/usr" -I./tic -I/usr/include/efi -I/usr/include/efi/x86_64 -I/usr/include/efi/protocol -fno-stack-protector -fPIC -fshort-wchar -mno-red-zone -Wall -DEFI_FUNCTION_WRAPPER -O2 -c -o tic/hash.o tic/hash.c
cc -nostdlib -znocombreloc -T /usr/lib/elf_x86_64_efi.lds -shared -Bsymbolic -L /usr/lib /usr/lib/crt0-efi-x86_64.o -lefi -lgnuefi tic/tic.o tic/cdbw.o tic/mi_vector_hash.o tic/compile.o tic/hash.o -o tic/tic
/usr/bin/ld: /usr/lib/crt0-efi-x86_64.o: warning: relocation against ImageBase' in read-only section '.text'
/usr/bin/ld: /usr/lib/crt0-efi-x86_64.o: relocation R_X86_64_PC32 against symbol 'ImageBase' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make: *** [GNUmakefile:457: tic/tic] Error 1

I build using the following command:

#!/bin/bash
EFIINCS="-I/usr/include/efi -I/usr/include/efi/x86_64 -I/usr/include/efi/protocol"
LIB="/usr/lib"
EFI_LDS="$LIB/elf_x86_64_efi.lds"
EFI_CRT_OBJS="$LIB/crt0-efi-x86_64.o"
LDFLAGS="-nostdlib -znocombreloc -T $EFI_LDS -shared -Bsymbolic -L $LIB $EFI_CRT_OBJS -lefi -lgnuefi"
CFLAGS="$EFIINCS -fno-stack-protector -fPIC -fshort-wchar -mno-red-zone -Wall -DEFI_FUNCTION_WRAPPER -O2"
make CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" PREFIX=/usr all-dynamic

From what I can see (I also attempted to force CFLAGS and LDFLAGS into every "CC" line the makefile), all files are built with -fpic. The gnu-efi crt0-efi-x86_64.o was also built with -fpic (to be sure, I also rebuilt it myself).

Do you have any idea what might be causing this issue?
If not, do you know an appropriate place where I could ask for help?

Thank you very much!
Cheers,

schreiberstein

dvtm: vt.c:(.text+0x134e): undefined reference to `forkpty'

Unable to build dvtm against netbsd-curses...

==> Starting build()...
cleaning
cleaning
dvtm build options:
CC dvtm.c
CC vt.c
CFLAGS = -march=native -O2 -pipe -fstack-protector-all -fomit-frame-pointer -std=c99 -I. -DVERSION="0.15" -DNDEBUG -D_FORTIFY_SOURCE=2 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_XOPEN_SOURCE_EXTENDED
LDFLAGS = -lcurses
CC = cc
vt.c: In function ‘vt_forkpty’:
vt.c:1636:4: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result]
chdir(cwd);
^~~~~~~~~~
CC -o dvtm
vt.o: In function vt_forkpty': vt.c:(.text+0x134e): undefined reference to forkpty'
collect2: error: ld returned 1 exit status
make: *** [Makefile:25: dvtm] Error 1
==> ERROR: A failure occurred in build().
Aborting...

Using the Sabotage build recipe as a guideline...

==> Starting build()...
cleaning
cleaning
dvtm build options:
CC dvtm.c
CC vt.c
CFLAGS = -march=native -O2 -pipe -fstack-protector-all -fomit-frame-pointer -std=c99 -I. -DVERSION="0.15" -DNDEBUG -D_FORTIFY_SOURCE=2 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_XOPEN_SOURCE_EXTENDED
LDFLAGS = -lncurses
CC = cc
vt.c: In function ‘vt_forkpty’:
vt.c:1636:4: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result]
chdir(cwd);
^~~~~~~~~~
CC -o dvtm
vt.o: In function vt_forkpty': vt.c:(.text+0x134e): undefined reference to forkpty'
collect2: error: ld returned 1 exit status
make: *** [Makefile:25: dvtm] Error 1
==> ERROR: A failure occurred in build().

With system LDFLAGS build failure...

==> Starting build()...
cleaning
cleaning
dvtm build options:
CC dvtm.c
CC vt.c
CFLAGS = -march=native -O2 -pipe -fstack-protector-all -fomit-frame-pointer -std=c99 -I. -DVERSION="0.15" -DNDEBUG -D_FORTIFY_SOURCE=2 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_XOPEN_SOURCE_EXTENDED
LDFLAGS = -Wl,-z,now -Wl,-O1,--sort-common,--as-needed,-z,relro -lcurses -lterminfo
CC = cc
vt.c: In function ‘vt_forkpty’:
vt.c:1636:4: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result]
chdir(cwd);
^~~~~~~~~~
CC -o dvtm
vt.o: In function vt_forkpty': vt.c:(.text+0x134e): undefined reference to forkpty'
collect2: error: ld returned 1 exit status
make: *** [Makefile:25: dvtm] Error 1
==> ERROR: A failure occurred in build().
Aborting...

TODO 1) manpages

  1. analyze the original Makefiles and see which manpages were symlinked to other names.
  2. create the symlinks in the source tree rather than logic hardcoded in the makefiles
  3. add an install-manpage target for each component that basically just install's $(COMPONENT_DIR)/*.[13]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.