1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-11-12 23:56:51 -05:00

Centralize customization in defines.h instead of Makefile + estruct.h.

This commit is contained in:
Renaud 2021-08-18 16:54:35 +08:00
parent d99b7fcbac
commit e6921a8ed1
24 changed files with 119 additions and 240 deletions

View File

@ -13,11 +13,6 @@ else
endif
export E Q
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
# for windows based target, insure we strip the variant part
# CYGWIN_NT-6.1, CYGWIN_NT-6.1-WOW, CYGWIN_NT-6.1-WOW64, MSYS_NT-10.0-19042
uname_S := $(shell sh -c 'echo $(uname_S) | sed s/_.*$$//')
PROGRAM=ue
CC=gcc
@ -25,18 +20,7 @@ WARNINGS=-pedantic -Wall -Wextra -Wstrict-prototypes -Wno-unused-parameter
CFLAGS=-O2 $(WARNINGS)
LDFLAGS=-s
LIBS=-lcurses
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
DEFINES=-DPROGRAM=$(PROGRAM) -D_GNU_SOURCE # -DNDEBUG
BINDIR=/usr/bin
LIBDIR=/usr/lib

View File

@ -1,8 +1,9 @@
/* buffer.c -- implements buffer.h */
#include "buffer.h"
/* Buffer management. Some of the functions are internal, and some are actually attached to
user keys. Like everyone else, they set hints for the display system.
/* Buffer management. Some of the functions are internal, and some are
actually attached to user keys. Like everyone else, they set hints for
the display system.
modified by Petri Kutvonen
*/
@ -11,7 +12,6 @@
#include <string.h>
#include "defines.h"
#include "estruct.h"
#include "file.h"
#include "input.h"
#include "mlout.h"

View File

@ -1,17 +1,64 @@
/* defines.h -- */
/* defines.h -- customization based on gcc predefined macroes */
#ifndef __DEFINES_H__
#define __DEFINES_H__
/* Must define one of
USG | BSD
*/
#define USG 1
#define PKCODE 1
#define SCROLLCODE 1 /* scrolling code P.K. */
#define ENVFUNC 1
#if __unix__
# define UNIX 1
# if __NetBSD__
# define BSD 1
# define POSIX 1
# elsif __linux__
# define USG 1
# define SVR4 1 /* locks */
# define POSIX 1
# else /* __CYGWIN__ */
# define USG 1
//# define POSIX 1
# endif
#else
# error Missing gcc predefined __unix__
#endif
#define NSTRING 128 /* # of bytes, string buffers */
#define TERMCAP 1 /* UNIX */
#define XONXOFF 1 /* UNIX */
#define VISMAC 0 /* update display during keyboard macros */
#define MSDOS 0
#define IBMPC MSDOS
#define COLOR MSDOS
#define MEMMAP IBMPC
#define FILOCK (SVR4 | BSD)
#define ENVFUNC 1 /* only two types so far (USG | BSD) */
#define PKCODE 1 /* include P.K. extensions, define always */
#define SCROLLCODE 1 /* scrolling code P.K. */
/* Dynamic RAM tracking and reporting redefinitions */
#define RAMSIZE 0 /* dynamic RAM memory usage tracking */
#if RAMSIZE
# define RAMSHOW 1 /* auto dynamic RAM reporting */
# include <stdlib.h>
void *allocate( size_t size) ;
void release( void *ptr) ;
# define malloc allocate
# define free release
#endif
/* end of defines.h */
/* De-allocate memory always on exit (if the operating system or main
program can not
*/
#define CLEAN 0 /* de-alloc memory on exit */
#if CLEAN
# define exit(a) cexit(a)
void cexit( int status) ;
#endif
#endif
/* end of predefs.h */

View File

@ -12,12 +12,13 @@
*/
#include <errno.h>
#include <locale.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include "buffer.h"
#include "estruct.h"
#include "defines.h"
#include "input.h"
#include "line.h"
#include "termio.h"
@ -50,16 +51,16 @@ static video_p *pscreen ; /* Physical screen. */
#endif
static int displaying = TRUE ;
#if UNIX
# include <signal.h>
#endif
#ifdef SIGWINCH
# include <sys/ioctl.h>
/* for window size changes */
int chg_width, chg_height ;
int chg_width, chg_height ;
static void sizesignal( int signr) ;
#endif
static int currow ; /* Cursor row */
static int curcol ; /* Cursor column */
static int vtrow = 0 ; /* Row location of SW cursor */
@ -105,6 +106,11 @@ static int newscreensize( int h, int w) ;
completely redrawn on the first call to "update".
*/
void vtinit( void) {
#ifdef SIGWINCH
signal( SIGWINCH, sizesignal) ;
#endif
setlocale( LC_CTYPE, "") ; /* expects $LANG like en_GB.UTF-8 */
TTopen() ; /* open the screen */
TTkopen() ; /* open the keyboard */
TTrev( FALSE) ;
@ -1404,7 +1410,7 @@ void getscreensize( int *widthp, int *heightp) {
}
#ifdef SIGWINCH
void sizesignal( int signr) {
static void sizesignal( int signr) {
int w, h ;
int old_errno = errno ;

View File

@ -4,7 +4,7 @@
#include <stdarg.h>
#include "estruct.h"
#include "defines.h" /* UNIX */
#include "names.h" /* BINDABLE() */
#include "utf8.h" /* unicode_t */
@ -40,8 +40,6 @@ void getscreensize( int *widthp, int *heightp) ;
# include <signal.h>
# ifdef SIGWINCH
extern int chg_width, chg_height ;
void sizesignal( int signr) ;
# endif
#endif

135
estruct.h
View File

@ -1,135 +0,0 @@
/* estruct.h -- */
#ifndef _ESTRUCT_H_
#define _ESTRUCT_H_
/* Structure and preprocessor defines
*
* written by Dave G. Conroy
* modified by Steve Wilhite, George Jones
* substantially modified by Daniel Lawrence
* modified by Petri Kutvonen
*/
#ifdef MSDOS
# undef MSDOS
#endif
/* Machine/OS definitions. */
#if defined(AUTOCONF) || defined(BSD) || defined(SYSV)
/* Make an intelligent guess about the target system. */
# if defined(BSD) || defined(sun) || defined(ultrix) || defined(__osf__)
# ifndef BSD
# define BSD 1 /* Berkeley UNIX */
# endif
# else
# define BSD 0
# endif
# if defined(SVR4) || defined(__linux__) /* ex. SunOS 5.3 */
# define SVR4 1
# define SYSV 1
# undef BSD
# endif
# if defined(SYSV) || defined(u3b2) || defined(_AIX) || (defined(i386) && defined(unix)) || defined( __unix__)
# define USG 1 /* System V UNIX */
# else
# define USG 0
# endif
#else
# define BSD 0 /* UNIX BSD 4.2 and ULTRIX */
# define USG 1 /* UNIX system V */
#endif /*autoconf || BSD || SYSV */
#define MSDOS 0 /* MS-DOS */
/* Compiler definitions */
#ifndef AUTOCONF
# define UNIX 1 /* a random UNIX compiler */
#else
# define UNIX (BSD | USG)
#endif /*autoconf */
/* Debugging options */
#define RAMSIZE 0 /* dynamic RAM memory usage tracking */
#if RAMSIZE
# define RAMSHOW 1 /* auto dynamic RAM reporting */
#endif
#ifndef AUTOCONF
/* Terminal Output definitions */
# define TERMCAP 0 /* Use TERMCAP */
# define IBMPC 1 /* IBM-PC CGA/MONO/EGA driver */
#else
# define TERMCAP UNIX
# define IBMPC MSDOS
#endif /* Autoconf. */
/* Configuration options */
#define VISMAC 0 /* update display during keyboard macros */
#ifndef AUTOCONF
# define COLOR 1 /* color commands and windows */
# define FILOCK 0 /* file locking under unix BSD 4.2 */
#else
# define COLOR MSDOS
# ifdef SVR4
# define FILOCK 1
# else
# define FILOCK BSD
# endif
#endif /* Autoconf. */
#define CLEAN 0 /* de-alloc memory on exit */
#ifndef AUTOCONF
# define XONXOFF 0 /* don't disable XON-XOFF flow control P.K. */
#else
# define XONXOFF UNIX
#endif /* Autoconf. */
#define PKCODE 1 /* include my extensions P.K., define always */
#define SCROLLCODE 1 /* scrolling code P.K. */
/* Define some ability flags. */
#if IBMPC
# define MEMMAP 1
#else
# define MEMMAP 0
#endif
#if USG | BSD
# define ENVFUNC 1
#else
# define ENVFUNC 0
#endif
/* Dynamic RAM tracking and reporting redefinitions */
#if RAMSIZE
# include <stdlib.h>
void *allocate( size_t size) ;
void release( void *ptr) ;
# define malloc allocate
# define free release
#endif
/* De-allocate memory always on exit (if the operating system or
main program can not
*/
#if CLEAN
# define exit(a) cexit(a)
void cexit( int status) ;
#endif
#endif
/* end of estruct.h */

2
eval.c
View File

@ -15,8 +15,8 @@
#include "basic.h"
#include "bind.h"
#include "buffer.h"
#include "defines.h"
#include "display.h"
#include "estruct.h"
#include "exec.h"
#include "execute.h"
#include "flook.h"

View File

@ -7,12 +7,12 @@
#include <stdlib.h>
#include <unistd.h>
#include "estruct.h"
#include "random.h"
#include "defines.h"
#include "display.h"
#include "file.h"
#include "input.h"
#include "mlout.h"
#include "random.h"
#include "search.h"
#include "terminal.h"
#include "window.h"

1
file.c
View File

@ -17,7 +17,6 @@
#include "buffer.h"
#include "defines.h"
#include "display.h"
#include "estruct.h"
#include "execute.h"
#include "fileio.h"
#include "input.h"

View File

@ -13,8 +13,8 @@
#include <unistd.h>
#include "bind.h"
#include "estruct.h"
#include "bindable.h"
#include "defines.h"
#include "display.h" /* rubout(), echos(), echoc(), update() */
#include "exec.h"
#include "isa.h"

View File

@ -27,8 +27,8 @@
#include "basic.h"
#include "buffer.h"
#include "defines.h"
#include "display.h"
#include "estruct.h"
#include "exec.h"
#include "input.h"
#include "line.h"

2
line.c
View File

@ -20,7 +20,7 @@
#include <string.h>
#include "buffer.h"
#include "estruct.h"
#include "defines.h"
#include "mlout.h"
#include "utf8.h"
#include "window.h"

2
lock.h
View File

@ -2,7 +2,7 @@
#ifndef _LOCK_H_
#define _LOCK_H_
#include "estruct.h"
#include "defines.h" /* BSD, SVR4 */
#if BSD | SVR4
int lockchk( const char *fname) ;

72
main.c
View File

@ -62,14 +62,13 @@
*
*/
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "estruct.h" /* Global structures and defines. */
#include "defines.h" /* OS specific customization */
#if UNIX
#include <signal.h>
# include <signal.h>
#endif
#include "basic.h"
@ -91,9 +90,8 @@
#include "window.h"
#if UNIX
static void emergencyexit(int signr)
{
quickexit(FALSE, 0);
static void emergencyexit( int signr) {
quickexit( FALSE, 0) ;
quit( TRUE, 0) ; /* If quickexit fails (to save changes), do a force quit */
}
#endif
@ -124,13 +122,12 @@ static void usage( void) {
}
int main(int argc, char **argv)
{
struct buffer *bp; /* temp buffer pointer */
int main( int argc, char *argv[]) {
buffer_p bp; /* temp buffer pointer */
int firstfile; /* first file flag */
int carg; /* current arg to scan */
int startflag; /* startup executed flag */
struct buffer *firstbp = NULL; /* ptr to first buffer in cmd line */
buffer_p firstbp = NULL; /* ptr to first buffer in cmd line */
int viewflag; /* are we starting in view mode? */
int gotoflag; /* do we need to goto a line at start? */
int gline = 0; /* if so, what line? */
@ -138,17 +135,10 @@ int main(int argc, char **argv)
int errflag; /* C error processing? */
bname_t bname ; /* buffer name of file to read */
setlocale( LC_CTYPE, "") ; /* expects $LANG like en_GB.UTF-8 */
#if PKCODE & BSD
sleep(1); /* Time for window manager. */
#endif
#if UNIX
#ifdef SIGWINCH
signal(SIGWINCH, sizesignal);
#endif
#endif
if( argc == 2) {
if( strcmp( argv[ 1], "--help") == 0) {
usage() ;
@ -325,7 +315,7 @@ int main(int argc, char **argv)
*/
static void edinit( char *bname) {
buffer_p bp;
struct window *wp;
window_p wp;
if( !init_bindings() /* initialize mapping of function to name and key */
|| NULL == (bp = bfind( bname, TRUE, 0)) /* First buffer */
@ -442,42 +432,36 @@ static void dspram( void)
#if CLEAN
/*
* cexit()
/* cexit()
*
* int status; return status of emacs
*/
void cexit( int status) {
struct buffer *bp; /* buffer list pointer */
struct window *wp; /* window list pointer */
struct window *tp; /* temporary window pointer */
/* first clean up the windows */
wp = wheadp;
while (wp) {
tp = wp->w_wndp;
free(wp);
wp = tp;
/* first clean up the windows */
window_p wp = wheadp ;
while( wp) {
window_p tp = wp->w_wndp ;
free( wp) ;
wp = tp ;
}
wheadp = NULL;
wheadp = NULL ;
/* then the buffers */
bp = bheadp;
while (bp) {
bp->b_nwnd = 0;
bp->b_flag = 0; /* don't say anything about a changed buffer! */
zotbuf(bp);
bp = bheadp;
/* then the buffers */
buffer_p bp ;
while( (bp = bheadp) != NULL) {
bp->b_nwnd = 0 ;
bp->b_flag = 0 ; /* don't say anything about a changed buffer! */
zotbuf( bp) ;
}
/* and the kill buffer */
kdelete();
/* and the kill buffer */
kdelete() ;
/* and the video buffers */
vtfree();
/* and the video buffers */
vtfree() ;
#undef exit
exit(status);
(exit)( status) ;
}
#endif

View File

@ -2,7 +2,7 @@
#ifndef _PKLOCK_H_
#define _PKLOCK_H_
#include "estruct.h"
#include "defines.h" /* FILOCK, BSD, SVR4 */
#if (FILOCK && BSD) || SVR4
char *dolock( const char *fname) ;

View File

@ -1,6 +1,7 @@
/* posix.c -- posix implementation of termio.h */
#include "termio.h"
#include "defines.h" /* POSIX */
#ifdef POSIX
/* The functions in this file negotiate with the operating system for
@ -22,7 +23,6 @@
#include <termios.h>
#include <unistd.h>
#include "estruct.h"
#include "retcode.h"
#include "utf8.h"

View File

@ -14,8 +14,8 @@
#include "basic.h"
#include "buffer.h"
#include "defines.h"
#include "display.h"
#include "estruct.h"
#include "execute.h"
#include "input.h"
#include "line.h"

View File

@ -12,7 +12,7 @@
#include <stddef.h>
#include "buffer.h"
#include "estruct.h"
#include "defines.h"
#include "line.h"
#include "mlout.h"
#include "random.h"

View File

@ -65,8 +65,8 @@
#include "basic.h"
#include "buffer.h"
#include "defines.h"
#include "display.h"
#include "estruct.h"
#include "input.h"
#include "isa.h"
#include "line.h"

View File

@ -12,11 +12,9 @@
#include <string.h>
#include <unistd.h>
#include "defines.h"
#include "buffer.h"
#include "defines.h"
#include "display.h"
#include "estruct.h"
#include "exec.h"
#include "file.h"
#include "flook.h"
@ -27,8 +25,6 @@
#if USG | BSD
#include <signal.h>
#ifdef SIGWINCH
#endif
#endif

2
tcap.c
View File

@ -20,8 +20,8 @@
#include <curses.h>
#include <term.h>
#include "defines.h"
#include "display.h"
#include "estruct.h"
#include "termio.h"
#if TERMCAP

View File

@ -1,6 +1,7 @@
/* termio.c -- implements termio.h */
#include "termio.h"
#include "defines.h" /* POSIX */
#ifndef POSIX
/* The functions in this file negotiate with the operating system for
@ -13,7 +14,6 @@
#include <stdio.h>
#include <stdlib.h>
#include "estruct.h"
#include "retcode.h"
#include "utf8.h"

View File

@ -9,8 +9,8 @@
#include "basic.h"
#include "buffer.h"
#include "defines.h"
#include "display.h" /* upmode() */
#include "estruct.h"
#include "execute.h"
#include "line.h"
#include "mlout.h"

2
word.c
View File

@ -14,7 +14,7 @@
#include "basic.h"
#include "buffer.h"
#include "estruct.h"
#include "defines.h"
#include "isa.h"
#include "line.h"
#include "mlout.h"