diff --git a/sys/unix/Makefile.doc b/sys/unix/Makefile.doc index 92473995b..2186b15d9 100644 --- a/sys/unix/Makefile.doc +++ b/sys/unix/Makefile.doc @@ -11,6 +11,8 @@ NHSROOT=.. MAKEDEFS = ../util/makedefs +#STRIPBS ?= ../util/stripbs + # Which version do we want to build? (XXX These are not used anywhere.) GUIDEBOOK = Guidebook # regular ASCII file #GUIDEBOOK = Guidebook.ps # PostScript file @@ -21,8 +23,9 @@ GUIDEBOOK = Guidebook # regular ASCII file # recognize the option. Sigh. # # col is unnecessary, but harmless, with groff. See grotty(1). -COLCMD = col -bx -#COLCMD = col -b +COLCMD ?= col -bx +#COLCMD ?= col -b +#COLCMD ?= $(STRIPBS) # The command to use to generate a PostScript file # PSCMD = ditroff | psdit @@ -59,8 +62,8 @@ ONEPAGE_PREFORMAT = cat Gbk-1pg-pfx.mn $(GUIDEBOOK_MN) Gbk-1pg-sfx.mn \ | $(NHGREP) | tbl tmac.n - # the basic guidebook -Guidebook : $(GUIDEBOOK_MN) tmac.n tmac.nh $(NEEDMAKEDEFS) - $(GUIDECMD) > Guidebook +Guidebook : $(GUIDEBOOK_MN) tmac.n tmac.nh $(NEEDMAKEDEFS) $(STRIPBS) + -$(GUIDECMD) > Guidebook # Fancier output for those with ditroff, psdit and a PostScript printer. # Could be converted to Guidebook.pdf if tool(s) for that are available. @@ -80,7 +83,10 @@ Guidebook.dvi : $(GUIDEBOOK_TEX) # (note: 'make makedefs', not 'make $(MAKEDEFS)') $(MAKEDEFS) : ../util/makedefs.c ../include/config.h ../src/mdlib.c \ ../util/mdgrep.h - ( cd ../util ; make makedefs ) + ( cd .. ; make makedefs ) + +../util/stripbx: ../util/stripbs.c + ( cd .. ; $(MAKE) stripbs ) GAME = nethack MANDIR ?= /usr/man/man6 diff --git a/sys/unix/Makefile.top b/sys/unix/Makefile.top index f3bb66d23..9323f42c8 100644 --- a/sys/unix/Makefile.top +++ b/sys/unix/Makefile.top @@ -416,6 +416,12 @@ fetch-docs: shift; \ done +makedefs: + ( cd util ; $(MAKE) makedefs ) + +stripbs: + ( cd util ; $(MAKE) stripbs ) + # 'make update' can be used to install a revised version after making # customizations or such. Unlike 'make install', it doesn't delete everything # from the target directory to have a clean start. diff --git a/sys/unix/Makefile.utl b/sys/unix/Makefile.utl index ebe974cc1..770213255 100644 --- a/sys/unix/Makefile.utl +++ b/sys/unix/Makefile.utl @@ -293,6 +293,11 @@ dlb: $(DLBOBJS) $(HACKLIB) dlb_main.o: dlb_main.c $(CONFIG_H) ../include/dlb.h $(CC) $(CFLAGS) $(CSTD) -c dlb_main.c -o $@ +stripbs: stripbs.o + $(CC) $(LFLAGS) -o stripbs stripbs.o + +stripbs.o: stripbs.c + $(CC) $(CFLAGS) -c stripbs.c # dependencies for tile utilities # diff --git a/sys/unix/hints/include/multiw-2.370 b/sys/unix/hints/include/multiw-2.370 index 938c958f3..05cd0dae5 100644 --- a/sys/unix/hints/include/multiw-2.370 +++ b/sys/unix/hints/include/multiw-2.370 @@ -194,6 +194,20 @@ CPLUSPLUS_NEEDED = 1 endif endif +ifeq "$(musl)" "1" +MUSL=1 +endif +ifeq "$(MUSL)" "1" +ifneq "$(NOCRASHREPORT)" "1" +NOCRASHREPORT=1 +endif +WINCFLAGS += -DMUSL_LIBC +# use this instead of col -bx +COLCMD = ../util/stripbs +else +WINCFLAGS += -DGNU_LIBC +endif + ifeq "$(NOCRASHREPORT)" "1" WINCFLAGS += -DNOCRASHREPORT endif diff --git a/util/.gitignore b/util/.gitignore index 6852dfc87..56d768999 100644 --- a/util/.gitignore +++ b/util/.gitignore @@ -11,6 +11,7 @@ lev_comp dlb dlb_main recover +stripbs tilemap tileedit tile2x11 diff --git a/util/stripbs.c b/util/stripbs.c new file mode 100644 index 000000000..4c7af7fed --- /dev/null +++ b/util/stripbs.c @@ -0,0 +1,42 @@ +/* NetHack 3.7 stripbs.c */ +/* Copyright (c) Michael Allison, 2025. */ +/* NetHack may be freely redistributed. See license for details. */ + +/* + * a simple filter to strip character-backspace-character + * from stdin and write the results to stdout. + */ + +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + int stop = 0, trouble = 0; + char buf[2]; + char *cp = &buf[0], *prev = &buf[1]; + + *prev = 0; + while (!stop) { + if ((fread(buf, 1, 1, stdin)) > 0) { + if (*cp == 8) { + *prev = 0; + } else { + if (*prev) + fputc(*prev, stdout); + *prev = *cp; + } + } else { + if (errno != EOF) + trouble = 1; + if (*prev) + fputc(*prev, stdout); + stop = 1; + } + } + fflush(stdout); + fclose(stdout); + return trouble ? EXIT_FAILURE : EXIT_SUCCESS; +}