1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-12-17 23:06:25 -05:00

Merge NetBSD adaptation.

This commit is contained in:
Renaud 2020-06-16 14:09:44 +08:00
parent 8ac4a96a34
commit 4847d8c589
6 changed files with 26 additions and 11 deletions

View File

@ -26,7 +26,7 @@ uname_S := $(shell sh -c 'echo $(uname_S) | sed s/_.*$$//')
PROGRAM=ue
CC=gcc
WARNINGS=-pedantic -Wall -Wextra -Wstrict-prototypes -Wno-unused-parameter -Wimplicit-fallthrough=2
WARNINGS=-pedantic -Wall -Wextra -Wstrict-prototypes -Wno-unused-parameter
CFLAGS=-O2 $(WARNINGS)
#CC=c89 +O3 # HP
#CFLAGS= -D_HPUX_SOURCE -DSYSV
@ -51,6 +51,10 @@ ifeq ($(uname_S),MINGW32)
DEFINES=-DAUTOCONF -DPOSIX -DSYSV -DPROGRAM=$(PROGRAM) -IC:/MinGW/include/ncursesw
LIBS=
endif
ifeq ($(uname_S),NetBSD)
DEFINES=-DAUTOCONF -DPOSIX -DBSD=1 -DPROGRAM=$(PROGRAM)
LIBS=-lcurses
endif
#DEFINES=-DAUTOCONF
#LIBS=-ltermcap # BSD
#LIBS=-lcurses # SYSV
@ -130,7 +134,7 @@ depend: ${SRC}
$(Q) ${CC} ${CFLAGS} ${DEFINES} -c $*.c
# DO NOT DELETE THIS LINE -- make depend uses it
# Updated Mon Nov 25 12:50:00 CST 2019
# Updated Tue Jun 16 13:25:24 CST 2020
basic.o: basic.c basic.h retcode.h input.h bind.h mlout.h random.h \
terminal.h defines.h utf8.h window.h buffer.h line.h

4
lock.c
View File

@ -24,7 +24,11 @@
#include "pklock.h"
#endif
#if BSD
#include <errno.h>
#else
#include <sys/errno.h>
#endif
#define NLOCKS 100 /* max # of file locks active */
static char *lname[ NLOCKS] ; /* names of all locked files */

View File

@ -93,7 +93,11 @@ char *dolock( const char *fname)
** logname = getlogin() ;
** strcpy( locker, logname ? logname : cuserid( NULL)) ;
*/
#if BSD
strcpy( locker, getlogin()) ;
#else
strcpy( locker, cuserid( NULL)) ;
#endif
strcat(locker + strlen(locker), "@");
gethostname(locker + strlen(locker), 64);

View File

@ -33,7 +33,7 @@ int ttcol = HUGE ; /* Column location of HW cursor */
/* Since Mac OS X's termios.h doesn't have the following 2 macros, define them.
*/
#if defined(SYSV) && (defined(_DARWIN_C_SOURCE) || defined(_FREEBSD_C_SOURCE))
#if BSD || defined(SYSV) && (defined(_DARWIN_C_SOURCE) || defined(_FREEBSD_C_SOURCE))
#define OLCUC 0000002
#define XCASE 0000004
#endif

12
tcap.c
View File

@ -74,7 +74,7 @@ static void tcapscroll_delins(int from, int to, int linestoscroll);
#define TCAPSLEN 315
static char tcapbuf[TCAPSLEN];
static char *UP, PC, *CM, *CE, *CL, *SO, *SE;
static char *_UP, _PC, *CM, *CE, *CL, *SO, *SE;
#if PKCODE
static char *TI, *TE;
@ -167,14 +167,14 @@ static void tcapopen(void)
p = tcapbuf;
t = tgetstr("pc", &p);
if (t)
PC = *t;
_PC = *t;
else
PC = 0;
_PC = 0;
CL = tgetstr("cl", &p);
CM = tgetstr("cm", &p);
CE = tgetstr("ce", &p);
UP = tgetstr("up", &p);
_UP = tgetstr("up", &p);
SE = tgetstr("se", &p);
SO = tgetstr("so", &p);
if (SO != NULL)
@ -189,7 +189,7 @@ static void tcapopen(void)
TE = tgetstr("te", &p);
#endif
if (CL == NULL || CM == NULL || UP == NULL) {
if (CL == NULL || CM == NULL || _UP == NULL) {
fputs( "Incomplete termcap entry\n", stderr) ;
exit( EXIT_FAILURE) ;
}
@ -338,7 +338,7 @@ static void tcapscroll_delins(int from, int to, int howmanylines)
/* cs is set up just like cm, so we use tgoto... */
static void tcapscrollregion(int top, int bot)
{
ttputc(PC);
ttputc(_PC);
putpad(tgoto(CS, bot, top));
}

7
utf8.c
View File

@ -11,9 +11,12 @@
* Display width of UTF-8 character
*/
unsigned utf8_width( unicode_t c) {
#ifdef CYGWIN
assert( sizeof( wchar_t) == 2) ; /* wcwidth only handle UTF-16 */
#if CYGWIN
assert( sizeof( wchar_t) == 2) ; /* wcwidth only handles UTF-16 */
return (c < 0x10000) ? (unsigned) wcwidth( (wchar_t) c) : 2 ;
#elif BSD
assert( sizeof( wchar_t) == 4) ; /* wcwidth should handle UTF-32 */
return 1 ;
#else
return (unsigned) wcwidth( (wchar_t) c) ;
#endif