sacc

sacc(omys), simple console gopher client (mirror)
git clone https://git.parazyd.org/sacc
Log | Files | Refs | LICENSE

commit 3e0b5be80fdfac3c1ef3ed2e9df4bdbdea5e0091
parent 17c4223fc2c7163d3bfd5681a8d2467b54d0d4da
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sun, 25 Mar 2018 14:54:35 +0200

Fix and reverse feature detection of asprintf function

The new behaviour is to define NEED_ASPRINTF for platforms when the
asprintf is needed.

Diffstat:
MMakefile | 3++-
Mcommon.h | 4++--
Mconfig.mk | 3+++
Msacc.c | 4++--
4 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile @@ -32,7 +32,8 @@ uninstall: rm -f $(DESTDIR)$(PREFIX)/bin/$(BIN) # Stock FLAGS -SACCCFLAGS = -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700 -D_BSD_SOURCE $(CFLAGS) +SACCCFLAGS = -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700 -D_BSD_SOURCE -D_GNU_SOURCE \ + $(CFLAGS) .c.o: $(CC) $(SACCCFLAGS) -c $< diff --git a/common.h b/common.h @@ -22,9 +22,9 @@ struct dir { size_t curline; }; -#ifndef asprintf +#ifdef NEED_ASPRINTF int asprintf(char **s, const char *fmt, ...); -#endif /* asprintf */ +#endif /* NEED_ASPRINTF */ void die(const char *fmt, ...); size_t mbsprint(const char *s, size_t len); const char *typedisplay(char t); diff --git a/config.mk b/config.mk @@ -8,3 +8,6 @@ MANDIR = $(PREFIX)/share/man/man1 # ti (screen-oriented) UI=ti LIBS=-lcurses + +# Define NEED_ASPRINTF in your cflags is your system doesn't provide asprintf() +#CFLAGS = -DNEED_ASPRINTF diff --git a/sacc.c b/sacc.c @@ -40,7 +40,7 @@ die(const char *fmt, ...) exit(1); } -#ifndef asprintf +#ifdef NEED_ASPRINTF int asprintf(char **s, const char *fmt, ...) { @@ -60,7 +60,7 @@ asprintf(char **s, const char *fmt, ...) return n; } -#endif /* asprintf */ +#endif /* NEED_ASPRINTF */ /* print `len' columns of characters. */ size_t