diff --git a/Makefile b/Makefile index 14ee038..8c506de 100644 --- a/Makefile +++ b/Makefile @@ -25,15 +25,15 @@ WARNINGS=-pedantic -Wall -Wextra -Wstrict-prototypes -Wno-unused-parameter CFLAGS=-O2 $(WARNINGS) LDFLAGS=-s LIBS=-lcurses -DEFINES=-DAUTOCONF -DPROGRAM=$(PROGRAM) # -DNDEBUG -ifeq ($(uname_S),Linux) - DEFINES += -DPOSIX -DUSG -else ifeq ($(uname_S),CYGWIN) - DEFINES += -DCYGWIN -DSYSV -else ifeq ($(uname_S),MSYS) - DEFINES += -DCYGWIN -DSYSV -else ifeq ($(uname_S),NetBSD) - DEFINES += -DPOSIX -DBSD=1 +DEFINES=-DAUTOCONF -DPROGRAM=$(PROGRAM) -D_GNU_SOURCE # -DNDEBUG +ifeq ($(uname_S),Linux) # __unix__ __linux__ + DEFINES += -DUSG -DPOSIX +else ifeq ($(uname_S),CYGWIN) # __unix__ __CYGWIN__ + DEFINES += -DSYSV # -DPOSIX +else ifeq ($(uname_S),MSYS) # __unix__ __CYGWIN__ __MSYS__ + DEFINES += -DSYSV # -DPOSIX +else ifeq ($(uname_S),NetBSD) # __unix__ __NetBSD__ + DEFINES += -DBSD=1 -DPOSIX else $(error $(uname_S) needs configuration) endif diff --git a/posix.c b/posix.c index 29b1a37..75c80a2 100644 --- a/posix.c +++ b/posix.c @@ -1,18 +1,16 @@ /* posix.c -- posix implementation of termio.h */ -#ifdef POSIX - #include "termio.h" -/* posix.c - * - * The functions in this file negotiate with the operating system for - * characters, and write characters in a barely buffered fashion on the - * display. All operating systems. - * - * modified by Petri Kutvonen - * - * based on termio.c, with all the old cruft removed, and - * fixed for termios rather than the old termio.. Linus Torvalds +#ifdef POSIX + +/* The functions in this file negotiate with the operating system for + characters, and write characters in a barely buffered fashion on the + display. All operating systems. + + modified by Petri Kutvonen + + based on termio.c, with all the old cruft removed, and + fixed for termios rather than the old termio.. Linus Torvalds */ #include @@ -38,7 +36,7 @@ int ttcol = HUGE ; /* Column location of HW cursor */ #define XCASE 0000004 #endif -#ifdef CYGWIN +#ifdef __CYGWIN__ /* gcc predefined (see cpp -dM) */ #define XCASE 0 #define ECHOPRT 0 #define PENDIN 0 @@ -247,8 +245,6 @@ int typahead(void) return x; } -#else -typedef void _pedantic_empty_translation_unit ; -#endif /* not POSIX */ +#endif /* end of posix.c */ diff --git a/termio.c b/termio.c index f17265e..e306cf2 100644 --- a/termio.c +++ b/termio.c @@ -1,15 +1,13 @@ /* termio.c -- implements termio.h */ -#if !defined( POSIX) - #include "termio.h" -/* TERMIO.C - * - * The functions in this file negotiate with the operating system for - * characters, and write characters in a barely buffered fashion on the display. - * All operating systems. - * - * modified by Petri Kutvonen +#ifndef POSIX + +/* The functions in this file negotiate with the operating system for + characters, and write characters in a barely buffered fashion on the + display. All operating systems. + + modified by Petri Kutvonen */ #include @@ -258,14 +256,12 @@ int typahead( void) return kbdqp; #endif -#if !UNIX +# if !UNIX return FALSE; -#endif +# endif } -#endif +# endif -#else -typedef void _pedantic_empty_translation_unit ; #endif /* not POSIX */ /* end of termio.c */ diff --git a/utf8.c b/utf8.c index 0531fba..d7cfcd7 100644 --- a/utf8.c +++ b/utf8.c @@ -1,16 +1,13 @@ /* utf8.c -- implements utf8.h, conversion between unicode and UTF-8 */ #include "utf8.h" -#define _XOPEN_SOURCE /* wcwidth in wchar.h */ - #include -#include +#include /* either _XOPEN_SOURCE or _GNU_SOURCE */ /* Display width of UTF-8 character */ int _utf8_width( unicode_t c) { -#if CYGWIN - assert( sizeof( wchar_t) == 2) ; /* wcwidth only supports UTF-16 */ +#if __SIZEOF_WCHAR_T__ == 2 /* wcwidth only supports UTF-16 */ return (c < 0x10000) ? wcwidth( (wchar_t) c) : -1 ; #else return wcwidth( (wchar_t) c) ;