From 128354e657d14d8ec3fe2192e24dd4a1af0ebd13 Mon Sep 17 00:00:00 2001 From: "U-Renaud-PC\\Renaud" Date: Tue, 30 Apr 2013 15:24:03 +0800 Subject: [PATCH 001/193] Adapatation to Cygwin32 --- Makefile | 3 +++ tcap.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 76a8122..e4abdd4 100644 --- a/Makefile +++ b/Makefile @@ -48,6 +48,9 @@ endif ifeq ($(uname_S),Darwin) DEFINES=-DAUTOCONF -DPOSIX -DSYSV -D_DARWIN_C_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE -D_XOPEN_SOURCE=600 endif +ifeq ($(uname_S),CYGWIN_NT-6.1-WOW64) + DEFINES=-DAUTOCONF +endif #DEFINES=-DAUTOCONF #LIBS=-ltermcap # BSD LIBS=-lcurses # SYSV diff --git a/tcap.c b/tcap.c index fa71fa6..42a3069 100644 --- a/tcap.c +++ b/tcap.c @@ -13,9 +13,9 @@ #define USE_BROKEN_OPTIMIZATION 0 #define termdef 1 /* Don't define "term" external. */ -#include +#include #include -#include +#include #include "estruct.h" #include "edef.h" From 68a79430e621ee0fc19e9c36783f25586b1ca11e Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 30 Apr 2013 17:24:46 +0800 Subject: [PATCH 002/193] cleanup usage and wrapper --- usage.c | 29 +++++++++++++++++------------ usage.h | 2 +- wrapper.c | 33 ++++++++++++++++++++------------- wrapper.h | 6 ++++-- 4 files changed, 42 insertions(+), 28 deletions(-) mode change 100644 => 100755 wrapper.h diff --git a/usage.c b/usage.c index 0ae18ce..3edb798 100644 --- a/usage.c +++ b/usage.c @@ -1,22 +1,27 @@ +/* usage.c -- implements usage.h */ + +/* TODO: align exit return code */ + #include "usage.h" #include #include #include -static void report(const char* prefix, const char *err, va_list params) -{ - char msg[4096]; - vsnprintf(msg, sizeof(msg), err, params); - fprintf(stderr, "%s%s\n", prefix, msg); +static void report( const char *prefix, const char *err, va_list params) { + char msg[ 4096] ; + + vsnprintf( msg, sizeof msg, err, params) ; + fprintf( stderr, "%s%s\n", prefix, msg) ; } -void die(const char* err, ...) -{ - va_list params; +void die( const char *err, ...) { + va_list params ; - va_start(params, err); - report("fatal: ", err, params); - va_end(params); - exit(128); + va_start( params, err) ; + report( "fatal: ", err, params) ; + va_end( params) ; + exit( 128) ; } + +/* end of usage.c */ diff --git a/usage.h b/usage.h index bb6b40e..c57b48a 100644 --- a/usage.h +++ b/usage.h @@ -1,6 +1,6 @@ #ifndef USAGE_H_ #define USAGE_H_ -extern void die(const char* err, ...); +void die( const char *err, ...) ; #endif /* USAGE_H_ */ diff --git a/wrapper.c b/wrapper.c index a3301e2..deedf08 100644 --- a/wrapper.c +++ b/wrapper.c @@ -1,22 +1,29 @@ +/* wrapper.c -- implements wrapper.h */ + +#include "wrapper.h" + #include "usage.h" #include +#include /* Function copyright: git */ -int xmkstemp(char *template) -{ - int fd; +void xmkstemp( char *template) { + int fd ; - fd = mkstemp(template); - if (fd < 0) - die("Unable to create temporary file"); - return fd; + fd = mkstemp( template) ; + if( fd < 0) + die( "Unable to create temporary file") ; + + close( fd) ; } -void *xmalloc(size_t size) -{ - void *ret = malloc(size); - if (!ret) - die("Out of memory"); - return ret; +void *xmalloc( size_t size) { + void *ret = malloc( size) ; + if( !ret) + die( "Out of memory") ; + + return ret ; } + +/* end of wrapper.c */ diff --git a/wrapper.h b/wrapper.h old mode 100644 new mode 100755 index 25f5bc0..1f81c10 --- a/wrapper.h +++ b/wrapper.h @@ -1,8 +1,10 @@ #ifndef WRAPPER_H_ #define WRAPPER_H_ -extern int xmkstemp(char *template); +#include -extern void *xmalloc(size_t size); +void xmkstemp( char *template) ; + +void *xmalloc( size_t size) ; #endif /* WRAPPER_H_ */ From f3ce8236afb4d40957e520861a5be6b0574070e3 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 1 May 2013 08:17:45 +0800 Subject: [PATCH 003/193] update file dependencies: usage, wrapper, version --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index e4abdd4..4449ed1 100644 --- a/Makefile +++ b/Makefile @@ -154,11 +154,14 @@ search.o: search.c estruct.h edef.h spawn.o: spawn.c estruct.h edef.h tcap.o: tcap.c estruct.h edef.h termio.o: termio.c estruct.h edef.h +usage.o: usage.c usage.h utf8.o: utf8.c utf8.h +version.o: version.c version.h vmsvt.o: vmsvt.c estruct.h edef.h vt52.o: vt52.c estruct.h edef.h window.o: window.c estruct.h edef.h word.o: word.c estruct.h edef.h +wrapper.o: wrapper.c wrapper.h usage.h # DEPENDENCIES MUST END AT END OF FILE # IF YOU PUT STUFF HERE IT WILL GO AWAY From c96175928811d11fc7f7fec6f5a94b7ddb8f1242 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 1 May 2013 09:21:16 +0800 Subject: [PATCH 004/193] rework version and help printing em --help now returns EXIT_SUCCESS --- Makefile | 6 +++--- main.c | 40 ++++++++++++++++++++++++---------------- version.c | 15 ++++++++++----- version.h | 11 ++++++----- 4 files changed, 43 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index 4449ed1..7882e0a 100644 --- a/Makefile +++ b/Makefile @@ -135,8 +135,8 @@ basic.o: basic.c estruct.h edef.h bind.o: bind.c estruct.h edef.h epath.h buffer.o: buffer.c estruct.h edef.h crypt.o: crypt.c estruct.h edef.h -display.o: display.c estruct.h edef.h utf8.h -eval.o: eval.c estruct.h edef.h evar.h +display.o: display.c estruct.h edef.h utf8.h version.h +eval.o: eval.c estruct.h edef.h evar.h version.h exec.o: exec.c estruct.h edef.h file.o: file.c estruct.h edef.h fileio.o: fileio.c estruct.h edef.h @@ -145,7 +145,7 @@ input.o: input.c estruct.h edef.h isearch.o: isearch.c estruct.h edef.h line.o: line.c estruct.h edef.h lock.o: lock.c estruct.h edef.h -main.o: main.c estruct.h efunc.h edef.h ebind.h +main.o: main.c estruct.h efunc.h edef.h ebind.h version.h pklock.o: pklock.c estruct.h posix.o: posix.c estruct.h utf8.h random.o: random.c estruct.h edef.h diff --git a/main.c b/main.c index 08f2f19..6db7e75 100644 --- a/main.c +++ b/main.c @@ -49,6 +49,10 @@ * * 4.0 Petri Kutvonen, 1-Sep-91 * + * This modified version is now called uEmacs/rf. + * + * 4.1 Renaud Fivet, 1-May-13 + * */ #include @@ -88,17 +92,19 @@ extern void sizesignal(int); #endif #endif -void usage(int status) -{ - printf("Usage: %s filename\n", PROGRAM_NAME); - printf(" or: %s [options]\n\n", PROGRAM_NAME); - fputs(" + start at the end of file\n", stdout); - fputs(" + start at line \n", stdout); - fputs(" -g[G] go to line \n", stdout); - fputs(" --help display this help and exit\n", stdout); - fputs(" --version output version information and exit\n", stdout); +static void version( void) { + printf( "%s version %s\n", PROGRAM_NAME_LONG, VERSION) ; +} - exit(status); + +static void usage( void) { + printf( "Usage: %s filename\n", PROGRAM_NAME) ; + printf( " or: %s [options]\n\n", PROGRAM_NAME) ; + fputs( " + start at the end of file\n", stdout) ; + fputs( " + start at line \n", stdout) ; + fputs( " -g[G] go to line \n", stdout) ; + fputs( " --help display this help and exit\n", stdout) ; + fputs( " --version output version information and exit\n", stdout) ; } int main(int argc, char **argv) @@ -139,13 +145,15 @@ int main(int argc, char **argv) signal(SIGWINCH, sizesignal); #endif #endif - if (argc == 2) { - if (strcmp(argv[1], "--help") == 0) { - usage(EXIT_FAILURE); + if( argc == 2) { + if( strcmp( argv[ 1], "--help") == 0) { + usage() ; + exit( EXIT_SUCCESS) ; } - if (strcmp(argv[1], "--version") == 0) { - version(); - exit(EXIT_SUCCESS); + + if( strcmp( argv[ 1], "--version") == 0) { + version() ; + exit( EXIT_SUCCESS) ; } } diff --git a/version.c b/version.c index d974764..9afc0ea 100644 --- a/version.c +++ b/version.c @@ -1,7 +1,12 @@ -#include +/* version.c -- inplements version.h */ + #include "version.h" -void version(void) -{ - printf("%s version %s\n", PROGRAM_NAME_LONG, VERSION); -} +#include + +char *pname_s = "em" ; +char *pnamel_s = "uEmacs/rf" ; + +char *version_s = "4.1.0" ; + +/* end of version.c */ diff --git a/version.h b/version.h index 1647462..13800e3 100644 --- a/version.h +++ b/version.h @@ -1,12 +1,13 @@ #ifndef VERSION_H_ #define VERSION_H_ -#define PROGRAM_NAME "em" -#define PROGRAM_NAME_LONG "uEmacs/Pk" +#define PROGRAM_NAME pname_s +#define PROGRAM_NAME_LONG pnamel_s -#define VERSION "4.0.15" +#define VERSION version_s -/* Print the version string. */ -void version(void); +extern char *pname_s ; +extern char *pnamel_s ; +extern char *version_s ; #endif /* VERSION_H_ */ From 02823cb59df421fc5719efe5dd78bbf01a5ce817 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 1 May 2013 09:29:54 +0800 Subject: [PATCH 005/193] remove unnecessary include --- version.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/version.c b/version.c index 9afc0ea..5b75c86 100644 --- a/version.c +++ b/version.c @@ -2,8 +2,6 @@ #include "version.h" -#include - char *pname_s = "em" ; char *pnamel_s = "uEmacs/rf" ; From a1124441f7d62996771acb19fc0d0d2f70018c70 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 1 May 2013 10:06:08 +0800 Subject: [PATCH 006/193] fix compilation warning --- search.c | 4 ++++ termio.c | 15 ++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/search.c b/search.c index 32877ab..6502f9b 100644 --- a/search.c +++ b/search.c @@ -739,6 +739,10 @@ static int replaces(int kind, int f, int n) struct line *lastline; /* position of last replace and */ int lastoff; /* offset (for 'u' query option) */ +/* rfi */ + lastline = NULL ; + lastoff = 0 ; + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ return rdonly(); /* we are in read only mode */ diff --git a/termio.c b/termio.c index 9a8d760..ac6d583 100644 --- a/termio.c +++ b/termio.c @@ -14,6 +14,10 @@ #include "estruct.h" #include "edef.h" +/* rfi */ +#include +#include + #if VMS #include #include @@ -269,8 +273,7 @@ void ttclose(void) * On CPM terminal I/O unbuffered, so we just write the byte out. Ditto on * MS-DOS (use the very very raw console output routine). */ -void ttputc(c) -{ +void ttputc( int c) { #if VMS if (nobuf >= NOBUF) ttflush(); @@ -290,8 +293,7 @@ void ttputc(c) * Flush terminal buffer. Does real work where the terminal output is buffered * up. A no-operation on systems where byte at a time terminal I/O is done. */ -int ttflush(void) -{ +void ttflush( void) { #if VMS int status; int iosb[2]; @@ -339,8 +341,7 @@ int ttflush(void) * at all. More complex in VMS that almost anyplace else, which figures. Very * simple on CPM, because the system can do exactly what you want. */ -ttgetc() -{ +int ttgetc( void) { #if VMS int status; int iosb[2]; @@ -412,7 +413,7 @@ ttgetc() keyboard buffer */ -typahead() +int typahead( void) { #if MSDOS & (MSC | TURBO) if (kbhit() != 0) From 4b53c4887beb4f78ef4ddb7dc13084b0f932f068 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 1 May 2013 11:46:06 +0800 Subject: [PATCH 007/193] add ncurses directory for Cygwin --- tcap.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tcap.c b/tcap.c index 42a3069..1c6b4d4 100644 --- a/tcap.c +++ b/tcap.c @@ -13,9 +13,15 @@ #define USE_BROKEN_OPTIMIZATION 0 #define termdef 1 /* Don't define "term" external. */ +#ifdef CYGWIN #include -#include #include +#else +#include +#include +#endif + +#include #include "estruct.h" #include "edef.h" From 052f7ff956c1f0edf3494ec0c252cbef63fbc9c9 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 1 May 2013 12:21:08 +0800 Subject: [PATCH 008/193] don't compile ansi, ibmpc, vmsvt, vt52 --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 7882e0a..a02acd6 100644 --- a/Makefile +++ b/Makefile @@ -16,16 +16,16 @@ uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') PROGRAM=em -SRC=ansi.c basic.c bind.c buffer.c crypt.c display.c eval.c exec.c \ - file.c fileio.c ibmpc.c input.c isearch.c line.c lock.c main.c \ +SRC=basic.c bind.c buffer.c crypt.c display.c eval.c exec.c \ + file.c fileio.c input.c isearch.c line.c lock.c main.c \ pklock.c posix.c random.c region.c search.c spawn.c tcap.c \ - termio.c vmsvt.c vt52.c window.c word.c names.c globals.c version.c \ + termio.c window.c word.c names.c globals.c version.c \ usage.c wrapper.c utf8.c -OBJ=ansi.o basic.o bind.o buffer.o crypt.o display.o eval.o exec.o \ - file.o fileio.o ibmpc.o input.o isearch.o line.o lock.o main.o \ +OBJ=basic.o bind.o buffer.o crypt.o display.o eval.o exec.o \ + file.o fileio.o input.o isearch.o line.o lock.o main.o \ pklock.o posix.o random.o region.o search.o spawn.o tcap.o \ - termio.o vmsvt.o vt52.o window.o word.o names.o globals.o version.o \ + termio.o window.o word.o names.o globals.o version.o \ usage.o wrapper.o utf8.o HDR=ebind.h edef.h efunc.h epath.h estruct.h evar.h util.h version.h From 45a6523572daff1311774ad40d364d16286ff0aa Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 1 May 2013 13:03:04 +0800 Subject: [PATCH 009/193] use posix (termios) with Cygwin) --- Makefile | 6 +++--- posix.c | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index a02acd6..46faee4 100644 --- a/Makefile +++ b/Makefile @@ -19,13 +19,13 @@ PROGRAM=em SRC=basic.c bind.c buffer.c crypt.c display.c eval.c exec.c \ file.c fileio.c input.c isearch.c line.c lock.c main.c \ pklock.c posix.c random.c region.c search.c spawn.c tcap.c \ - termio.c window.c word.c names.c globals.c version.c \ + window.c word.c names.c globals.c version.c \ usage.c wrapper.c utf8.c OBJ=basic.o bind.o buffer.o crypt.o display.o eval.o exec.o \ file.o fileio.o input.o isearch.o line.o lock.o main.o \ pklock.o posix.o random.o region.o search.o spawn.o tcap.o \ - termio.o window.o word.o names.o globals.o version.o \ + window.o word.o names.o globals.o version.o \ usage.o wrapper.o utf8.o HDR=ebind.h edef.h efunc.h epath.h estruct.h evar.h util.h version.h @@ -49,7 +49,7 @@ ifeq ($(uname_S),Darwin) DEFINES=-DAUTOCONF -DPOSIX -DSYSV -D_DARWIN_C_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE -D_XOPEN_SOURCE=600 endif ifeq ($(uname_S),CYGWIN_NT-6.1-WOW64) - DEFINES=-DAUTOCONF + DEFINES=-DAUTOCONF -DCYGWIN -DPOSIX endif #DEFINES=-DAUTOCONF #LIBS=-ltermcap # BSD diff --git a/posix.c b/posix.c index 97edd9f..c25dbf2 100644 --- a/posix.c +++ b/posix.c @@ -31,6 +31,12 @@ #define XCASE 0000004 #endif +#ifdef CYGWIN +#define XCASE 0 +#define ECHOPRT 0 +#define PENDIN 0 +#endif + static int kbdflgs; /* saved keyboard fd flags */ static int kbdpoll; /* in O_NDELAY mode */ From 646fbbc4f6e4fa3df62a5a6e7e00b40c0e13d8e9 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 1 May 2013 14:00:16 +0800 Subject: [PATCH 010/193] remove need for usage --- Makefile | 6 +++--- wrapper.c | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 46faee4..2bedba6 100644 --- a/Makefile +++ b/Makefile @@ -20,13 +20,13 @@ SRC=basic.c bind.c buffer.c crypt.c display.c eval.c exec.c \ file.c fileio.c input.c isearch.c line.c lock.c main.c \ pklock.c posix.c random.c region.c search.c spawn.c tcap.c \ window.c word.c names.c globals.c version.c \ - usage.c wrapper.c utf8.c + wrapper.c utf8.c OBJ=basic.o bind.o buffer.o crypt.o display.o eval.o exec.o \ file.o fileio.o input.o isearch.o line.o lock.o main.o \ pklock.o posix.o random.o region.o search.o spawn.o tcap.o \ window.o word.o names.o globals.o version.o \ - usage.o wrapper.o utf8.o + wrapper.o utf8.o HDR=ebind.h edef.h efunc.h epath.h estruct.h evar.h util.h version.h @@ -161,7 +161,7 @@ vmsvt.o: vmsvt.c estruct.h edef.h vt52.o: vt52.c estruct.h edef.h window.o: window.c estruct.h edef.h word.o: word.c estruct.h edef.h -wrapper.o: wrapper.c wrapper.h usage.h +wrapper.o: wrapper.c wrapper.h # DEPENDENCIES MUST END AT END OF FILE # IF YOU PUT STUFF HERE IT WILL GO AWAY diff --git a/wrapper.c b/wrapper.c index deedf08..c838a49 100644 --- a/wrapper.c +++ b/wrapper.c @@ -2,11 +2,15 @@ #include "wrapper.h" -#include "usage.h" - +#include #include #include +static void die( const char *err) { + fprintf( stderr, "fatal: %s\n", err) ; + exit( EXIT_FAILURE) ; +} + /* Function copyright: git */ void xmkstemp( char *template) { int fd ; From 2e2d68469750de1b017a72aa008c54781aecb904 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 1 May 2013 19:13:08 +0800 Subject: [PATCH 011/193] enable ^S in posix --- posix.c | 1 + 1 file changed, 1 insertion(+) diff --git a/posix.c b/posix.c index c25dbf2..0a723b8 100644 --- a/posix.c +++ b/posix.c @@ -64,6 +64,7 @@ void ttopen(void) /* raw CR/NL etc input handling, but keep ISTRIP if we're on a 7-bit line */ ntermios.c_iflag &= ~(IGNBRK | BRKINT | IGNPAR | PARMRK + | IXON | IXOFF | IXANY | INPCK | INLCR | IGNCR | ICRNL); /* raw CR/NR etc output handling */ From 8ef70b86fb6f7b4aba8ba3fe9b9ef487560c808a Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Thu, 2 May 2013 19:11:13 +0800 Subject: [PATCH 012/193] revert CYGWIN to termio for compatibility with console window --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 2bedba6..80170fb 100644 --- a/Makefile +++ b/Makefile @@ -19,13 +19,13 @@ PROGRAM=em SRC=basic.c bind.c buffer.c crypt.c display.c eval.c exec.c \ file.c fileio.c input.c isearch.c line.c lock.c main.c \ pklock.c posix.c random.c region.c search.c spawn.c tcap.c \ - window.c word.c names.c globals.c version.c \ + termio.c window.c word.c names.c globals.c version.c \ wrapper.c utf8.c OBJ=basic.o bind.o buffer.o crypt.o display.o eval.o exec.o \ file.o fileio.o input.o isearch.o line.o lock.o main.o \ pklock.o posix.o random.o region.o search.o spawn.o tcap.o \ - window.o word.o names.o globals.o version.o \ + termio.o window.o word.o names.o globals.o version.o \ wrapper.o utf8.o HDR=ebind.h edef.h efunc.h epath.h estruct.h evar.h util.h version.h @@ -49,7 +49,7 @@ ifeq ($(uname_S),Darwin) DEFINES=-DAUTOCONF -DPOSIX -DSYSV -D_DARWIN_C_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE -D_XOPEN_SOURCE=600 endif ifeq ($(uname_S),CYGWIN_NT-6.1-WOW64) - DEFINES=-DAUTOCONF -DCYGWIN -DPOSIX + DEFINES=-DAUTOCONF -DCYGWIN endif #DEFINES=-DAUTOCONF #LIBS=-ltermcap # BSD From 34615aae056006b631ffb468a1e780ed699082c1 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 14 May 2013 17:06:38 +0800 Subject: [PATCH 013/193] first step for constant version strings. --- version.c | 4 ++-- version.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/version.c b/version.c index 5b75c86..6ed57fa 100644 --- a/version.c +++ b/version.c @@ -2,8 +2,8 @@ #include "version.h" -char *pname_s = "em" ; -char *pnamel_s = "uEmacs/rf" ; +const char *pname_s = "em" ; +char *pnamel_s = "uEMACS" ; char *version_s = "4.1.0" ; diff --git a/version.h b/version.h index 13800e3..8b29000 100644 --- a/version.h +++ b/version.h @@ -6,7 +6,7 @@ #define VERSION version_s -extern char *pname_s ; +extern const char *pname_s ; extern char *pnamel_s ; extern char *version_s ; From 9f909644e981d6e9688f66eb630c9786c039b157 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 17 May 2013 09:21:59 +0800 Subject: [PATCH 014/193] rename program from 'em' to 'ue'. --- Makefile | 8 ++++---- version.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 80170fb..3d9922d 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ export E Q uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') -PROGRAM=em +PROGRAM=ue SRC=basic.c bind.c buffer.c crypt.c display.c eval.c exec.c \ file.c fileio.c input.c isearch.c line.c lock.c main.c \ @@ -76,10 +76,10 @@ clean: install: $(PROGRAM) strip $(PROGRAM) - cp em ${BINDIR} + cp $(PROGRAM) ${BINDIR} cp emacs.hlp ${LIBDIR} cp emacs.rc ${LIBDIR}/.emacsrc - chmod 755 ${BINDIR}/em + chmod 755 ${BINDIR}/$(PROGRAM) chmod 644 ${LIBDIR}/emacs.hlp ${LIBDIR}/.emacsrc lint: ${SRC} @@ -89,7 +89,7 @@ lint: ${SRC} errs: @rm -f makeout - make em >makeout + make $(PROGRAM) >makeout tags: ${SRC} @rm -f tags diff --git a/version.c b/version.c index 6ed57fa..45170b8 100644 --- a/version.c +++ b/version.c @@ -2,7 +2,7 @@ #include "version.h" -const char *pname_s = "em" ; +const char *pname_s = "ue" ; char *pnamel_s = "uEMACS" ; char *version_s = "4.1.0" ; From 86afdef45ecca68a6f4da6195cfd1e81677a80b8 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 17 May 2013 10:34:01 +0800 Subject: [PATCH 015/193] refactor handling of version and program name strings. --- Makefile | 5 ++--- display.c | 7 +------ main.c | 17 +++++++++-------- version.c | 10 ---------- version.h | 10 +++------- 5 files changed, 15 insertions(+), 34 deletions(-) delete mode 100644 version.c diff --git a/Makefile b/Makefile index 3d9922d..339e207 100644 --- a/Makefile +++ b/Makefile @@ -19,13 +19,13 @@ PROGRAM=ue SRC=basic.c bind.c buffer.c crypt.c display.c eval.c exec.c \ file.c fileio.c input.c isearch.c line.c lock.c main.c \ pklock.c posix.c random.c region.c search.c spawn.c tcap.c \ - termio.c window.c word.c names.c globals.c version.c \ + termio.c window.c word.c names.c globals.c \ wrapper.c utf8.c OBJ=basic.o bind.o buffer.o crypt.o display.o eval.o exec.o \ file.o fileio.o input.o isearch.o line.o lock.o main.o \ pklock.o posix.o random.o region.o search.o spawn.o tcap.o \ - termio.o window.o word.o names.o globals.o version.o \ + termio.o window.o word.o names.o globals.o \ wrapper.o utf8.o HDR=ebind.h edef.h efunc.h epath.h estruct.h evar.h util.h version.h @@ -156,7 +156,6 @@ tcap.o: tcap.c estruct.h edef.h termio.o: termio.c estruct.h edef.h usage.o: usage.c usage.h utf8.o: utf8.c utf8.h -version.o: version.c version.h vmsvt.o: vmsvt.c estruct.h edef.h vt52.o: vt52.c estruct.h edef.h window.o: window.c estruct.h edef.h diff --git a/display.c b/display.c index d6d3dba..e0fdc26 100644 --- a/display.c +++ b/display.c @@ -1121,12 +1121,7 @@ static void modeline(struct window *wp) n = 2; - strcpy(tline, " "); - strcat(tline, PROGRAM_NAME_LONG); - strcat(tline, " "); - strcat(tline, VERSION); - strcat(tline, ": "); - cp = &tline[0]; + cp = " " PROGRAM_NAME_LONG " " VERSION ": " ; while ((c = *cp++) != 0) { vtputc(c); ++n; diff --git a/main.c b/main.c index 6db7e75..ba2c22b 100644 --- a/main.c +++ b/main.c @@ -93,20 +93,21 @@ extern void sizesignal(int); #endif static void version( void) { - printf( "%s version %s\n", PROGRAM_NAME_LONG, VERSION) ; + fputs( PROGRAM_NAME_LONG " version " VERSION "\n", stdout) ; } static void usage( void) { - printf( "Usage: %s filename\n", PROGRAM_NAME) ; - printf( " or: %s [options]\n\n", PROGRAM_NAME) ; - fputs( " + start at the end of file\n", stdout) ; - fputs( " + start at line \n", stdout) ; - fputs( " -g[G] go to line \n", stdout) ; - fputs( " --help display this help and exit\n", stdout) ; - fputs( " --version output version information and exit\n", stdout) ; + fputs( "Usage: " PROGRAM_NAME " filename\n" + " or: " PROGRAM_NAME " [options]\n\n" + " + start at the end of file\n" + " + start at line \n" + " -g[G] go to line \n" + " --help display this help and exit\n" + " --version output version information and exit\n", stdout) ; } + int main(int argc, char **argv) { int c = -1; /* command character */ diff --git a/version.c b/version.c deleted file mode 100644 index 45170b8..0000000 --- a/version.c +++ /dev/null @@ -1,10 +0,0 @@ -/* version.c -- inplements version.h */ - -#include "version.h" - -const char *pname_s = "ue" ; -char *pnamel_s = "uEMACS" ; - -char *version_s = "4.1.0" ; - -/* end of version.c */ diff --git a/version.h b/version.h index 8b29000..dc1d6d4 100644 --- a/version.h +++ b/version.h @@ -1,13 +1,9 @@ #ifndef VERSION_H_ #define VERSION_H_ -#define PROGRAM_NAME pname_s -#define PROGRAM_NAME_LONG pnamel_s +#define PROGRAM_NAME "ue" +#define PROGRAM_NAME_LONG "uEMACS" -#define VERSION version_s - -extern const char *pname_s ; -extern char *pnamel_s ; -extern char *version_s ; +#define VERSION "4.1.1" #endif /* VERSION_H_ */ From c9a59faf42e251b45dc7cafae66fca9d338889a0 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 17 May 2013 10:42:12 +0800 Subject: [PATCH 016/193] usage obsolete as refactored into wrapper. --- Makefile | 1 - usage.c | 27 --------------------------- 2 files changed, 28 deletions(-) delete mode 100644 usage.c diff --git a/Makefile b/Makefile index 339e207..cf360c1 100644 --- a/Makefile +++ b/Makefile @@ -154,7 +154,6 @@ search.o: search.c estruct.h edef.h spawn.o: spawn.c estruct.h edef.h tcap.o: tcap.c estruct.h edef.h termio.o: termio.c estruct.h edef.h -usage.o: usage.c usage.h utf8.o: utf8.c utf8.h vmsvt.o: vmsvt.c estruct.h edef.h vt52.o: vt52.c estruct.h edef.h diff --git a/usage.c b/usage.c deleted file mode 100644 index 3edb798..0000000 --- a/usage.c +++ /dev/null @@ -1,27 +0,0 @@ -/* usage.c -- implements usage.h */ - -/* TODO: align exit return code */ - -#include "usage.h" - -#include -#include -#include - -static void report( const char *prefix, const char *err, va_list params) { - char msg[ 4096] ; - - vsnprintf( msg, sizeof msg, err, params) ; - fprintf( stderr, "%s%s\n", prefix, msg) ; -} - -void die( const char *err, ...) { - va_list params ; - - va_start( params, err) ; - report( "fatal: ", err, params) ; - va_end( params) ; - exit( 128) ; -} - -/* end of usage.c */ From 13f4a7cefde4579fa0473d463d0d594eec688ce1 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 17 May 2013 10:49:55 +0800 Subject: [PATCH 017/193] usage has been removed. should have been part of commit #776bd25 --- usage.h | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 usage.h diff --git a/usage.h b/usage.h deleted file mode 100644 index c57b48a..0000000 --- a/usage.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef USAGE_H_ -#define USAGE_H_ - -void die( const char *err, ...) ; - -#endif /* USAGE_H_ */ From 4958b7d2afe1764ecd0833de6e1104d4e376fd45 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 17 May 2013 16:54:02 +0800 Subject: [PATCH 018/193] use constant strings for pathnames. --- bind.c | 9 +++++---- efunc.h | 4 ++-- epath.h | 2 +- fileio.c | 2 +- spawn.c | 4 ++-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/bind.c b/bind.c index eb28c1f..f94db43 100644 --- a/bind.c +++ b/bind.c @@ -474,7 +474,7 @@ int startup(char *sfname) * char *fname; base file name to search for * int hflag; Look in the HOME environment variable first? */ -char *flook(char *fname, int hflag) +char *flook( const char *fname, int hflag) { char *home; /* path to home directory */ char *path; /* environmental PATH variable */ @@ -502,9 +502,10 @@ char *flook(char *fname, int hflag) #endif /* always try the current directory first */ - if (ffropen(fname) == FIOSUC) { - ffclose(); - return fname; + strcpy( fspec, fname) ; + if( ffropen( fspec) == FIOSUC) { + ffclose() ; + return fspec ; } #if ENVFUNC /* get the PATH variable */ diff --git a/efunc.h b/efunc.h index 6d0ffbc..e24bbba 100644 --- a/efunc.h +++ b/efunc.h @@ -180,7 +180,7 @@ extern int buildlist(int type, char *mstring); extern int strinc(char *source, char *sub); extern unsigned int getckey(int mflag); extern int startup(char *sfname); -extern char *flook(char *fname, int hflag); +char *flook( const char *fname, int hflag) ; extern void cmdstr(int c, char *seq); extern fn_t getbind(int c); extern char *getfname(fn_t); @@ -221,7 +221,7 @@ extern int filename(int f, int n); extern int ifile(char *fname); /* fileio.c */ -extern int ffropen(char *fn); +int ffropen( const char *fn) ; extern int ffwopen(char *fn); extern int ffclose(void); extern int ffputline(char *buf, int nbuf); diff --git a/epath.h b/epath.h index 1e85aaa..ff5b9cc 100644 --- a/epath.h +++ b/epath.h @@ -9,7 +9,7 @@ #define EPATH_H_ /* possible names and paths of help files under different OSs */ -static char *pathname[] = +static const char *pathname[] = #if MSDOS { "emacs.rc", diff --git a/fileio.c b/fileio.c index bab566e..eeadc05 100644 --- a/fileio.c +++ b/fileio.c @@ -17,7 +17,7 @@ static int eofflag; /* end-of-file flag */ /* * Open a file for reading. */ -int ffropen(char *fn) +int ffropen( const char *fn) { if ((ffp = fopen(fn, "r")) == NULL) return FIOFNF; diff --git a/spawn.c b/spawn.c index 4a7b1e5..e0d4471 100644 --- a/spawn.c +++ b/spawn.c @@ -1,4 +1,4 @@ -/* spaw.c +/* spawn.c * * Various operating system access commands. * @@ -571,7 +571,7 @@ int execprog(char *cmd) char *fcb1; /* 4 byte pointer to FCB at PSP+5Ch */ char *fcb2; /* 4 byte pointer to FCB at PSP+6Ch */ } pblock; - char *flook(); + char *flook( const char *fname, int hflag) ; /* parse the command name from the command line */ sp = prog; From 886402ccad0819ab4e75b649cf1e799830a62d84 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 17 May 2013 17:08:46 +0800 Subject: [PATCH 019/193] update file dependencies towards util. --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index cf360c1..71ac13e 100644 --- a/Makefile +++ b/Makefile @@ -132,11 +132,11 @@ depend: ${SRC} ansi.o: ansi.c estruct.h edef.h basic.o: basic.c estruct.h edef.h -bind.o: bind.c estruct.h edef.h epath.h +bind.o: bind.c estruct.h edef.h epath.h util.h buffer.o: buffer.c estruct.h edef.h crypt.o: crypt.c estruct.h edef.h display.o: display.c estruct.h edef.h utf8.h version.h -eval.o: eval.c estruct.h edef.h evar.h version.h +eval.o: eval.c estruct.h edef.h evar.h version.h util.h exec.o: exec.c estruct.h edef.h file.o: file.c estruct.h edef.h fileio.o: fileio.c estruct.h edef.h From e86bdad4fc20e8da787fae657da6625777ab0a90 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 17 May 2013 21:17:16 +0800 Subject: [PATCH 020/193] refactor epath into bind and util into eval. --- Makefile | 6 +++--- bind.c | 38 +++++++++++++++++++++++++++++++++++--- epath.h | 43 ------------------------------------------- eval.c | 3 ++- util.h | 6 ------ 5 files changed, 40 insertions(+), 56 deletions(-) delete mode 100644 epath.h delete mode 100644 util.h diff --git a/Makefile b/Makefile index 71ac13e..f13e1ee 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ OBJ=basic.o bind.o buffer.o crypt.o display.o eval.o exec.o \ termio.o window.o word.o names.o globals.o \ wrapper.o utf8.o -HDR=ebind.h edef.h efunc.h epath.h estruct.h evar.h util.h version.h +HDR=ebind.h edef.h efunc.h estruct.h evar.h version.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -132,11 +132,11 @@ depend: ${SRC} ansi.o: ansi.c estruct.h edef.h basic.o: basic.c estruct.h edef.h -bind.o: bind.c estruct.h edef.h epath.h util.h +bind.o: bind.c estruct.h edef.h buffer.o: buffer.c estruct.h edef.h crypt.o: crypt.c estruct.h edef.h display.o: display.c estruct.h edef.h utf8.h version.h -eval.o: eval.c estruct.h edef.h evar.h version.h util.h +eval.o: eval.c estruct.h edef.h evar.h version.h exec.o: exec.c estruct.h edef.h file.o: file.c estruct.h edef.h fileio.o: fileio.c estruct.h edef.h diff --git a/bind.c b/bind.c index f94db43..ba97b10 100644 --- a/bind.c +++ b/bind.c @@ -12,9 +12,41 @@ #include "estruct.h" #include "edef.h" #include "efunc.h" -#include "epath.h" #include "line.h" -#include "util.h" + + +/* possible names and paths of help files under different OSs */ +static const char *pathname[] = { +#if MSDOS + "emacs.rc", + "emacs.hlp", + "\\sys\\public\\", + "\\usr\\bin\\", + "\\bin\\", + "\\", + "" +#endif + +#if V7 | BSD | USG + ".emacsrc", + "emacs.hlp", +#if PKCODE + "/usr/global/lib/", "/usr/local/bin/", "/usr/local/lib/", +#endif + "/usr/local/", "/usr/lib/", "" +#endif + +#if VMS +{ + "emacs.rc", "emacs.hlp", "", +#if PKCODE + "sys$login:", "emacs_dir:", +#endif + "sys$sysdevice:[vmstools]" +#endif +}; + +#define PATHNAME_SIZE (sizeof pathname / sizeof pathname[ 0]) int help(int f, int n) { /* give me some help!!!! @@ -536,7 +568,7 @@ char *flook( const char *fname, int hflag) #endif /* look it up via the old table method */ - for (i = 2; i < ARRAY_SIZE(pathname); i++) { + for( i = 2; i < PATHNAME_SIZE ; i++) { strcpy(fspec, pathname[i]); strcat(fspec, fname); diff --git a/epath.h b/epath.h deleted file mode 100644 index ff5b9cc..0000000 --- a/epath.h +++ /dev/null @@ -1,43 +0,0 @@ -/* EPATH.H - * - * This file contains certain info needed to locate the - * initialization (etc) files on a system dependent basis - * - * modified by Petri Kutvonen - */ -#ifndef EPATH_H_ -#define EPATH_H_ - -/* possible names and paths of help files under different OSs */ -static const char *pathname[] = -#if MSDOS -{ - "emacs.rc", - "emacs.hlp", - "\\sys\\public\\", - "\\usr\\bin\\", - "\\bin\\", - "\\", - "" -}; -#endif - -#if V7 | BSD | USG -{ - ".emacsrc", "emacs.hlp", -#if PKCODE - "/usr/global/lib/", "/usr/local/bin/", "/usr/local/lib/", -#endif -"/usr/local/", "/usr/lib/", ""}; -#endif - -#if VMS -{ - "emacs.rc", "emacs.hlp", "", -#if PKCODE - "sys$login:", "emacs_dir:", -#endif -"sys$sysdevice:[vmstools]"}; -#endif - -#endif /* EPATH_H_ */ diff --git a/eval.c b/eval.c index fd4993b..27d2a63 100644 --- a/eval.c +++ b/eval.c @@ -13,11 +13,12 @@ #include "efunc.h" #include "evar.h" #include "line.h" -#include "util.h" #include "version.h" #define MAXVARS 255 +#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) + /* User variables */ static struct user_variable uv[MAXVARS + 1]; diff --git a/util.h b/util.h deleted file mode 100644 index 49f3649..0000000 --- a/util.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef UTIL_H_ -#define UTIL_H_ - -#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) - -#endif /* UTIL_H_ */ From d9bb0ea26228105171b65f373d2c9c8dfcc9ff12 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 17 May 2013 21:50:01 +0800 Subject: [PATCH 021/193] refactor epath into eval. --- Makefile | 4 +- eval.c | 197 ++++++++++++++++++++++++++++++++++++++++++++++++++- evar.h | 209 ------------------------------------------------------- 3 files changed, 198 insertions(+), 212 deletions(-) delete mode 100644 evar.h diff --git a/Makefile b/Makefile index f13e1ee..4939168 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ OBJ=basic.o bind.o buffer.o crypt.o display.o eval.o exec.o \ termio.o window.o word.o names.o globals.o \ wrapper.o utf8.o -HDR=ebind.h edef.h efunc.h estruct.h evar.h version.h +HDR=ebind.h edef.h efunc.h estruct.h version.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -136,7 +136,7 @@ bind.o: bind.c estruct.h edef.h buffer.o: buffer.c estruct.h edef.h crypt.o: crypt.c estruct.h edef.h display.o: display.c estruct.h edef.h utf8.h version.h -eval.o: eval.c estruct.h edef.h evar.h version.h +eval.o: eval.c estruct.h edef.h version.h exec.o: exec.c estruct.h edef.h file.o: file.c estruct.h edef.h fileio.o: fileio.c estruct.h edef.h diff --git a/eval.c b/eval.c index 27d2a63..c554db3 100644 --- a/eval.c +++ b/eval.c @@ -11,7 +11,6 @@ #include "estruct.h" #include "edef.h" #include "efunc.h" -#include "evar.h" #include "line.h" #include "version.h" @@ -19,6 +18,202 @@ #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) +/* Max #chars in a var name. */ +#define NVSIZE 10 + +/* Structure to hold user variables and their definitions. */ +struct user_variable { + char u_name[NVSIZE + 1]; /* name of user variable */ + char *u_value; /* value (string) */ +}; + +/* List of recognized environment variables. */ + +static const char *envars[] = { + "fillcol", /* current fill column */ + "pagelen", /* number of lines used by editor */ + "curcol", /* current column pos of cursor */ + "curline", /* current line in file */ + "ram", /* ram in use by malloc */ + "flicker", /* flicker supression */ + "curwidth", /* current screen width */ + "cbufname", /* current buffer name */ + "cfname", /* current file name */ + "sres", /* current screen resolution */ + "debug", /* macro debugging */ + "status", /* returns the status of the last command */ + "palette", /* current palette string */ + "asave", /* # of chars between auto-saves */ + "acount", /* # of chars until next auto-save */ + "lastkey", /* last keyboard char struck */ + "curchar", /* current character under the cursor */ + "discmd", /* display commands on command line */ + "version", /* current version number */ + "progname", /* returns current prog name - "MicroEMACS" */ + "seed", /* current random number seed */ + "disinp", /* display command line input characters */ + "wline", /* # of lines in current window */ + "cwline", /* current screen line in window */ + "target", /* target for line moves */ + "search", /* search pattern */ + "replace", /* replacement pattern */ + "match", /* last matched magic pattern */ + "kill", /* kill buffer (read only) */ + "cmode", /* mode of current buffer */ + "gmode", /* global modes */ + "tpause", /* length to pause for paren matching */ + "pending", /* type ahead pending flag */ + "lwidth", /* width of current line */ + "line", /* text of current line */ + "gflags", /* global internal emacs flags */ + "rval", /* child process return value */ + "tab", /* tab 4 or 8 */ + "overlap", + "jump", +#if SCROLLCODE + "scroll", /* scroll enabled */ +#endif +}; + +/* And its preprocesor definitions. */ + +#define EVFILLCOL 0 +#define EVPAGELEN 1 +#define EVCURCOL 2 +#define EVCURLINE 3 +#define EVRAM 4 +#define EVFLICKER 5 +#define EVCURWIDTH 6 +#define EVCBUFNAME 7 +#define EVCFNAME 8 +#define EVSRES 9 +#define EVDEBUG 10 +#define EVSTATUS 11 +#define EVPALETTE 12 +#define EVASAVE 13 +#define EVACOUNT 14 +#define EVLASTKEY 15 +#define EVCURCHAR 16 +#define EVDISCMD 17 +#define EVVERSION 18 +#define EVPROGNAME 19 +#define EVSEED 20 +#define EVDISINP 21 +#define EVWLINE 22 +#define EVCWLINE 23 +#define EVTARGET 24 +#define EVSEARCH 25 +#define EVREPLACE 26 +#define EVMATCH 27 +#define EVKILL 28 +#define EVCMODE 29 +#define EVGMODE 30 +#define EVTPAUSE 31 +#define EVPENDING 32 +#define EVLWIDTH 33 +#define EVLINE 34 +#define EVGFLAGS 35 +#define EVRVAL 36 +#define EVTAB 37 +#define EVOVERLAP 38 +#define EVSCROLLCOUNT 39 +#define EVSCROLL 40 + +enum function_type { + NILNAMIC = 0, + MONAMIC, + DYNAMIC, + TRINAMIC, +}; + +/* List of recognized user functions. */ +static struct { + const char f_name[ 4] ; + const enum function_type f_type ; +} funcs[] = { + { "add", DYNAMIC }, /* add two numbers together */ + { "sub", DYNAMIC }, /* subtraction */ + { "tim", DYNAMIC }, /* multiplication */ + { "div", DYNAMIC }, /* division */ + { "mod", DYNAMIC }, /* mod */ + { "neg", MONAMIC }, /* negate */ + { "cat", DYNAMIC }, /* concatinate string */ + { "lef", DYNAMIC }, /* left string(string, len) */ + { "rig", DYNAMIC }, /* right string(string, pos) */ + { "mid", TRINAMIC }, /* mid string(string, pos, len) */ + { "not", MONAMIC }, /* logical not */ + { "equ", DYNAMIC }, /* logical equality check */ + { "les", DYNAMIC }, /* logical less than */ + { "gre", DYNAMIC }, /* logical greater than */ + { "seq", DYNAMIC }, /* string logical equality check */ + { "sle", DYNAMIC }, /* string logical less than */ + { "sgr", DYNAMIC }, /* string logical greater than */ + { "ind", MONAMIC }, /* evaluate indirect value */ + { "and", DYNAMIC }, /* logical and */ + { "or", DYNAMIC }, /* logical or */ + { "len", MONAMIC }, /* string length */ + { "upp", MONAMIC }, /* uppercase string */ + { "low", MONAMIC }, /* lower case string */ + { "tru", MONAMIC }, /* Truth of the universe logical test */ + { "asc", MONAMIC }, /* char to integer conversion */ + { "chr", MONAMIC }, /* integer to char conversion */ + { "gtk", NILNAMIC }, /* get 1 charater */ + { "rnd", MONAMIC }, /* get a random number */ + { "abs", MONAMIC }, /* absolute value of a number */ + { "sin", DYNAMIC }, /* find the index of one string in another */ + { "env", MONAMIC }, /* retrieve a system environment var */ + { "bin", MONAMIC }, /* loopup what function name is bound to a key */ + { "exi", MONAMIC }, /* check if a file exists */ + { "fin", MONAMIC }, /* look for a file on the path... */ + { "ban", DYNAMIC }, /* bitwise and 9-10-87 jwm */ + { "bor", DYNAMIC }, /* bitwise or 9-10-87 jwm */ + { "bxo", DYNAMIC }, /* bitwise xor 9-10-87 jwm */ + { "bno", MONAMIC }, /* bitwise not */ + { "xla", TRINAMIC }, /* XLATE character string translation */ +}; + +/* And its preprocesor definitions. */ + +#define UFADD 0 +#define UFSUB 1 +#define UFTIMES 2 +#define UFDIV 3 +#define UFMOD 4 +#define UFNEG 5 +#define UFCAT 6 +#define UFLEFT 7 +#define UFRIGHT 8 +#define UFMID 9 +#define UFNOT 10 +#define UFEQUAL 11 +#define UFLESS 12 +#define UFGREATER 13 +#define UFSEQUAL 14 +#define UFSLESS 15 +#define UFSGREAT 16 +#define UFIND 17 +#define UFAND 18 +#define UFOR 19 +#define UFLENGTH 20 +#define UFUPPER 21 +#define UFLOWER 22 +#define UFTRUTH 23 +#define UFASCII 24 +#define UFCHR 25 +#define UFGTKEY 26 +#define UFRND 27 +#define UFABS 28 +#define UFSINDEX 29 +#define UFENV 30 +#define UFBIND 31 +#define UFEXIST 32 +#define UFFIND 33 +#define UFBAND 34 +#define UFBOR 35 +#define UFBXOR 36 +#define UFBNOT 37 +#define UFXLATE 38 + /* User variables */ static struct user_variable uv[MAXVARS + 1]; diff --git a/evar.h b/evar.h deleted file mode 100644 index 6e7cb6b..0000000 --- a/evar.h +++ /dev/null @@ -1,209 +0,0 @@ -/* EVAR.H - * - * Environment and user variable definitions - * - * written 1986 by Daniel Lawrence - * modified by Petri Kutvonen - */ -#ifndef EVAR_H_ -#define EVAR_H_ - -/* Max #chars in a var name. */ -#define NVSIZE 10 - -/* Structure to hold user variables and their definitions. */ -struct user_variable { - char u_name[NVSIZE + 1]; /* name of user variable */ - char *u_value; /* value (string) */ -}; - -/* List of recognized environment variables. */ - -static char *envars[] = { - "fillcol", /* current fill column */ - "pagelen", /* number of lines used by editor */ - "curcol", /* current column pos of cursor */ - "curline", /* current line in file */ - "ram", /* ram in use by malloc */ - "flicker", /* flicker supression */ - "curwidth", /* current screen width */ - "cbufname", /* current buffer name */ - "cfname", /* current file name */ - "sres", /* current screen resolution */ - "debug", /* macro debugging */ - "status", /* returns the status of the last command */ - "palette", /* current palette string */ - "asave", /* # of chars between auto-saves */ - "acount", /* # of chars until next auto-save */ - "lastkey", /* last keyboard char struck */ - "curchar", /* current character under the cursor */ - "discmd", /* display commands on command line */ - "version", /* current version number */ - "progname", /* returns current prog name - "MicroEMACS" */ - "seed", /* current random number seed */ - "disinp", /* display command line input characters */ - "wline", /* # of lines in current window */ - "cwline", /* current screen line in window */ - "target", /* target for line moves */ - "search", /* search pattern */ - "replace", /* replacement pattern */ - "match", /* last matched magic pattern */ - "kill", /* kill buffer (read only) */ - "cmode", /* mode of current buffer */ - "gmode", /* global modes */ - "tpause", /* length to pause for paren matching */ - "pending", /* type ahead pending flag */ - "lwidth", /* width of current line */ - "line", /* text of current line */ - "gflags", /* global internal emacs flags */ - "rval", /* child process return value */ - "tab", /* tab 4 or 8 */ - "overlap", - "jump", -#if SCROLLCODE - "scroll", /* scroll enabled */ -#endif -}; - -/* And its preprocesor definitions. */ - -#define EVFILLCOL 0 -#define EVPAGELEN 1 -#define EVCURCOL 2 -#define EVCURLINE 3 -#define EVRAM 4 -#define EVFLICKER 5 -#define EVCURWIDTH 6 -#define EVCBUFNAME 7 -#define EVCFNAME 8 -#define EVSRES 9 -#define EVDEBUG 10 -#define EVSTATUS 11 -#define EVPALETTE 12 -#define EVASAVE 13 -#define EVACOUNT 14 -#define EVLASTKEY 15 -#define EVCURCHAR 16 -#define EVDISCMD 17 -#define EVVERSION 18 -#define EVPROGNAME 19 -#define EVSEED 20 -#define EVDISINP 21 -#define EVWLINE 22 -#define EVCWLINE 23 -#define EVTARGET 24 -#define EVSEARCH 25 -#define EVREPLACE 26 -#define EVMATCH 27 -#define EVKILL 28 -#define EVCMODE 29 -#define EVGMODE 30 -#define EVTPAUSE 31 -#define EVPENDING 32 -#define EVLWIDTH 33 -#define EVLINE 34 -#define EVGFLAGS 35 -#define EVRVAL 36 -#define EVTAB 37 -#define EVOVERLAP 38 -#define EVSCROLLCOUNT 39 -#define EVSCROLL 40 - -enum function_type { - NILNAMIC = 0, - MONAMIC, - DYNAMIC, - TRINAMIC, -}; - -/* List of recognized user functions. */ -struct user_function { - char *f_name; - enum function_type f_type; -}; - -static struct user_function funcs[] = { - { "add", DYNAMIC }, /* add two numbers together */ - { "sub", DYNAMIC }, /* subtraction */ - { "tim", DYNAMIC }, /* multiplication */ - { "div", DYNAMIC }, /* division */ - { "mod", DYNAMIC }, /* mod */ - { "neg", MONAMIC }, /* negate */ - { "cat", DYNAMIC }, /* concatinate string */ - { "lef", DYNAMIC }, /* left string(string, len) */ - { "rig", DYNAMIC }, /* right string(string, pos) */ - { "mid", TRINAMIC }, /* mid string(string, pos, len) */ - { "not", MONAMIC }, /* logical not */ - { "equ", DYNAMIC }, /* logical equality check */ - { "les", DYNAMIC }, /* logical less than */ - { "gre", DYNAMIC }, /* logical greater than */ - { "seq", DYNAMIC }, /* string logical equality check */ - { "sle", DYNAMIC }, /* string logical less than */ - { "sgr", DYNAMIC }, /* string logical greater than */ - { "ind", MONAMIC }, /* evaluate indirect value */ - { "and", DYNAMIC }, /* logical and */ - { "or", DYNAMIC }, /* logical or */ - { "len", MONAMIC }, /* string length */ - { "upp", MONAMIC }, /* uppercase string */ - { "low", MONAMIC }, /* lower case string */ - { "tru", MONAMIC }, /* Truth of the universe logical test */ - { "asc", MONAMIC }, /* char to integer conversion */ - { "chr", MONAMIC }, /* integer to char conversion */ - { "gtk", NILNAMIC }, /* get 1 charater */ - { "rnd", MONAMIC }, /* get a random number */ - { "abs", MONAMIC }, /* absolute value of a number */ - { "sin", DYNAMIC }, /* find the index of one string in another */ - { "env", MONAMIC }, /* retrieve a system environment var */ - { "bin", MONAMIC }, /* loopup what function name is bound to a key */ - { "exi", MONAMIC }, /* check if a file exists */ - { "fin", MONAMIC }, /* look for a file on the path... */ - { "ban", DYNAMIC }, /* bitwise and 9-10-87 jwm */ - { "bor", DYNAMIC }, /* bitwise or 9-10-87 jwm */ - { "bxo", DYNAMIC }, /* bitwise xor 9-10-87 jwm */ - { "bno", MONAMIC }, /* bitwise not */ - { "xla", TRINAMIC }, /* XLATE character string translation */ -}; - -/* And its preprocesor definitions. */ - -#define UFADD 0 -#define UFSUB 1 -#define UFTIMES 2 -#define UFDIV 3 -#define UFMOD 4 -#define UFNEG 5 -#define UFCAT 6 -#define UFLEFT 7 -#define UFRIGHT 8 -#define UFMID 9 -#define UFNOT 10 -#define UFEQUAL 11 -#define UFLESS 12 -#define UFGREATER 13 -#define UFSEQUAL 14 -#define UFSLESS 15 -#define UFSGREAT 16 -#define UFIND 17 -#define UFAND 18 -#define UFOR 19 -#define UFLENGTH 20 -#define UFUPPER 21 -#define UFLOWER 22 -#define UFTRUTH 23 -#define UFASCII 24 -#define UFCHR 25 -#define UFGTKEY 26 -#define UFRND 27 -#define UFABS 28 -#define UFSINDEX 29 -#define UFENV 30 -#define UFBIND 31 -#define UFEXIST 32 -#define UFFIND 33 -#define UFBAND 34 -#define UFBOR 35 -#define UFBXOR 36 -#define UFBNOT 37 -#define UFXLATE 38 - -#endif /* EVAR_H_ */ From a65f7ca38c694689a41ac7cdb7fefdbf2f787dc1 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 17 May 2013 22:58:27 +0800 Subject: [PATCH 022/193] read files in text mode. review fileio prototypes. --- Makefile | 4 ++-- efunc.h | 7 +------ fileio.c | 14 +++++++++----- fileio.h | 11 +++++++++++ 4 files changed, 23 insertions(+), 13 deletions(-) create mode 100644 fileio.h diff --git a/Makefile b/Makefile index 4939168..7524ad2 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ OBJ=basic.o bind.o buffer.o crypt.o display.o eval.o exec.o \ termio.o window.o word.o names.o globals.o \ wrapper.o utf8.o -HDR=ebind.h edef.h efunc.h estruct.h version.h +HDR=ebind.h edef.h efunc.h estruct.h fileio.h version.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -139,7 +139,7 @@ display.o: display.c estruct.h edef.h utf8.h version.h eval.o: eval.c estruct.h edef.h version.h exec.o: exec.c estruct.h edef.h file.o: file.c estruct.h edef.h -fileio.o: fileio.c estruct.h edef.h +fileio.o: fileio.c fileio.h estruct.h edef.h ibmpc.o: ibmpc.c estruct.h edef.h input.o: input.c estruct.h edef.h isearch.o: isearch.c estruct.h edef.h diff --git a/efunc.h b/efunc.h index e24bbba..e5cdace 100644 --- a/efunc.h +++ b/efunc.h @@ -221,12 +221,7 @@ extern int filename(int f, int n); extern int ifile(char *fname); /* fileio.c */ -int ffropen( const char *fn) ; -extern int ffwopen(char *fn); -extern int ffclose(void); -extern int ffputline(char *buf, int nbuf); -extern int ffgetline(void); -extern int fexist(char *fname); +#include "fileio.h" /* exec.c */ extern int namedcmd(int f, int n); diff --git a/fileio.c b/fileio.c index eeadc05..0211c5f 100644 --- a/fileio.c +++ b/fileio.c @@ -1,3 +1,7 @@ +/* fileio.c -- implements fileio.h */ + +#include "fileio.h" + /* FILEIO.C * * The routines in this file read and write ASCII files from the disk. All of @@ -6,9 +10,9 @@ * modified by Petri Kutvonen */ -#include +#include #include "estruct.h" -#include "edef.h" +#include "edef.h" #include "efunc.h" static FILE *ffp; /* File pointer, all functions. */ @@ -19,7 +23,7 @@ static int eofflag; /* end-of-file flag */ */ int ffropen( const char *fn) { - if ((ffp = fopen(fn, "r")) == NULL) + if ((ffp = fopen(fn, "rt")) == NULL) return FIOFNF; eofflag = FALSE; return FIOSUC; @@ -29,7 +33,7 @@ int ffropen( const char *fn) * Open a file for writing. Return TRUE if all is well, and FALSE on error * (cannot create). */ -int ffwopen(char *fn) +int ffwopen( const char *fn) { #if VMS int fd; @@ -205,7 +209,7 @@ int ffgetline(void) * * char *fname; file to check for existance */ -int fexist(char *fname) +int fexist( const char *fname) { FILE *fp; diff --git a/fileio.h b/fileio.h new file mode 100644 index 0000000..d27008e --- /dev/null +++ b/fileio.h @@ -0,0 +1,11 @@ +#ifndef _FILEIO_H_ +#define _FILEIO_H_ + +int fexist( const char *fname) ; +int ffclose( void) ; +int ffgetline( void) ; +int ffputline( char *buf, int nbuf) ; +int ffropen( const char *fn) ; +int ffwopen( const char *fn) ; + +#endif From fa56e5dfff1ad50bd4f031be9cbb3f149d27ffa5 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sat, 18 May 2013 11:42:16 +0800 Subject: [PATCH 023/193] remove fileio from efunc, update dependencies. --- Makefile | 6 +++--- bind.c | 1 + efunc.h | 3 --- eval.c | 1 + file.c | 1 + 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 7524ad2..91e68da 100644 --- a/Makefile +++ b/Makefile @@ -132,13 +132,13 @@ depend: ${SRC} ansi.o: ansi.c estruct.h edef.h basic.o: basic.c estruct.h edef.h -bind.o: bind.c estruct.h edef.h +bind.o: bind.c estruct.h edef.h fileio.h buffer.o: buffer.c estruct.h edef.h crypt.o: crypt.c estruct.h edef.h display.o: display.c estruct.h edef.h utf8.h version.h -eval.o: eval.c estruct.h edef.h version.h +eval.o: eval.c estruct.h edef.h version.h fileio.h exec.o: exec.c estruct.h edef.h -file.o: file.c estruct.h edef.h +file.o: file.c estruct.h edef.h fileio.h fileio.o: fileio.c fileio.h estruct.h edef.h ibmpc.o: ibmpc.c estruct.h edef.h input.o: input.c estruct.h edef.h diff --git a/bind.c b/bind.c index ba97b10..26b7ce6 100644 --- a/bind.c +++ b/bind.c @@ -12,6 +12,7 @@ #include "estruct.h" #include "edef.h" #include "efunc.h" +#include "fileio.h" #include "line.h" diff --git a/efunc.h b/efunc.h index e5cdace..27a1785 100644 --- a/efunc.h +++ b/efunc.h @@ -220,9 +220,6 @@ extern int writeout(char *fn); extern int filename(int f, int n); extern int ifile(char *fname); -/* fileio.c */ -#include "fileio.h" - /* exec.c */ extern int namedcmd(int f, int n); extern int execcmd(int f, int n); diff --git a/eval.c b/eval.c index c554db3..41a94c3 100644 --- a/eval.c +++ b/eval.c @@ -11,6 +11,7 @@ #include "estruct.h" #include "edef.h" #include "efunc.h" +#include "fileio.h" #include "line.h" #include "version.h" diff --git a/file.c b/file.c index 1feb97a..42d5a2a 100644 --- a/file.c +++ b/file.c @@ -13,6 +13,7 @@ #include "estruct.h" #include "edef.h" #include "efunc.h" +#include "fileio.h" #include "line.h" #if defined(PKCODE) From f6780cb71b6df9c3a63f21ed0265a40ac0c7344c Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sat, 18 May 2013 12:20:01 +0800 Subject: [PATCH 024/193] remove crypt from efunc, update dependencies. --- Makefile | 11 ++++++----- crypt.c | 6 +++++- crypt.h | 7 +++++++ ebind.h | 1 + efunc.h | 4 ---- file.c | 1 + fileio.c | 1 + main.c | 1 + names.c | 1 + 9 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 crypt.h diff --git a/Makefile b/Makefile index 91e68da..2838e08 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ OBJ=basic.o bind.o buffer.o crypt.o display.o eval.o exec.o \ termio.o window.o word.o names.o globals.o \ wrapper.o utf8.o -HDR=ebind.h edef.h efunc.h estruct.h fileio.h version.h +HDR=crypt.h ebind.h edef.h efunc.h estruct.h fileio.h version.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -134,18 +134,19 @@ ansi.o: ansi.c estruct.h edef.h basic.o: basic.c estruct.h edef.h bind.o: bind.c estruct.h edef.h fileio.h buffer.o: buffer.c estruct.h edef.h -crypt.o: crypt.c estruct.h edef.h +crypt.o: crypt.c crypt.h estruct.h edef.h display.o: display.c estruct.h edef.h utf8.h version.h eval.o: eval.c estruct.h edef.h version.h fileio.h exec.o: exec.c estruct.h edef.h -file.o: file.c estruct.h edef.h fileio.h -fileio.o: fileio.c fileio.h estruct.h edef.h +file.o: file.c crypt.h estruct.h edef.h fileio.h +fileio.o: fileio.c fileio.h crypt.h estruct.h edef.h ibmpc.o: ibmpc.c estruct.h edef.h input.o: input.c estruct.h edef.h isearch.o: isearch.c estruct.h edef.h line.o: line.c estruct.h edef.h lock.o: lock.c estruct.h edef.h -main.o: main.c estruct.h efunc.h edef.h ebind.h version.h +main.o: main.c estruct.h crypt.h efunc.h edef.h ebind.h version.h +names.o: names.c estruct.h crypt.h edef.h efunc.h line.h pklock.o: pklock.c estruct.h posix.o: posix.c estruct.h utf8.h random.o: random.c estruct.h edef.h diff --git a/crypt.c b/crypt.c index 5f11ff5..c2b1c6a 100644 --- a/crypt.c +++ b/crypt.c @@ -1,3 +1,7 @@ +/* crypt.c -- implements crypt.h */ + +#include "crypt.h" + /* CRYPT.C * * Encryption routines @@ -8,7 +12,7 @@ #include #include "estruct.h" #include "edef.h" -#include "efunc.h" +#include "efunc.h" #if CRYPT diff --git a/crypt.h b/crypt.h new file mode 100644 index 0000000..18951c2 --- /dev/null +++ b/crypt.h @@ -0,0 +1,7 @@ +#ifndef _CRYPT_H_ +#define _CRYPT_H_ + +int set_encryption_key( int f, int n) ; +void myencrypt( char *bptr, unsigned len) ; + +#endif diff --git a/ebind.h b/ebind.h index f245246..85c3870 100644 --- a/ebind.h +++ b/ebind.h @@ -8,6 +8,7 @@ #ifndef EBIND_H_ #define EBIND_H_ +#include "crypt.h" #include "line.h" /* diff --git a/efunc.h b/efunc.h index 27a1785..4e0a8ab 100644 --- a/efunc.h +++ b/efunc.h @@ -340,10 +340,6 @@ extern int ernd(void); extern int sindex(char *source, char *pattern); extern char *xlat(char *source, char *lookup, char *trans); -/* crypt.c */ -extern int set_encryption_key(int f, int n); -extern void myencrypt(char *bptr, unsigned len); - /* lock.c */ extern int lockchk(char *fname); extern int lockrel(void); diff --git a/file.c b/file.c index 42d5a2a..c6423bc 100644 --- a/file.c +++ b/file.c @@ -10,6 +10,7 @@ #include #include +#include "crypt.h" #include "estruct.h" #include "edef.h" #include "efunc.h" diff --git a/fileio.c b/fileio.c index 0211c5f..5453edf 100644 --- a/fileio.c +++ b/fileio.c @@ -11,6 +11,7 @@ */ #include +#include "crypt.h" #include "estruct.h" #include "edef.h" #include "efunc.h" diff --git a/main.c b/main.c index ba2c22b..fd3f939 100644 --- a/main.c +++ b/main.c @@ -60,6 +60,7 @@ /* Make global definitions not external. */ #define maindef +#include "crypt.h" #include "estruct.h" /* Global structures and defines. */ #include "edef.h" /* Global definitions. */ #include "efunc.h" /* Function declarations and name table. */ diff --git a/names.c b/names.c index 4ee6228..d2962d9 100644 --- a/names.c +++ b/names.c @@ -5,6 +5,7 @@ * function. */ +#include "crypt.h" #include "estruct.h" #include "edef.h" #include "efunc.h" From 86d5b10fa9c71186fdbca09a8cf9f176c4025e81 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sat, 18 May 2013 13:40:11 +0800 Subject: [PATCH 025/193] fileio depends on display instead of efunc. --- Makefile | 6 +++--- display.c | 4 ++++ display.h | 23 +++++++++++++++++++++++ efunc.h | 19 +------------------ fileio.c | 8 ++++---- 5 files changed, 35 insertions(+), 25 deletions(-) create mode 100644 display.h diff --git a/Makefile b/Makefile index 2838e08..f1b580b 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ OBJ=basic.o bind.o buffer.o crypt.o display.o eval.o exec.o \ termio.o window.o word.o names.o globals.o \ wrapper.o utf8.o -HDR=crypt.h ebind.h edef.h efunc.h estruct.h fileio.h version.h +HDR=crypt.h display.h ebind.h edef.h efunc.h estruct.h fileio.h version.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -135,11 +135,11 @@ basic.o: basic.c estruct.h edef.h bind.o: bind.c estruct.h edef.h fileio.h buffer.o: buffer.c estruct.h edef.h crypt.o: crypt.c crypt.h estruct.h edef.h -display.o: display.c estruct.h edef.h utf8.h version.h +display.o: display.c display.h estruct.h edef.h utf8.h version.h eval.o: eval.c estruct.h edef.h version.h fileio.h exec.o: exec.c estruct.h edef.h file.o: file.c crypt.h estruct.h edef.h fileio.h -fileio.o: fileio.c fileio.h crypt.h estruct.h edef.h +fileio.o: fileio.c fileio.h crypt.h display.h estruct.h edef.h ibmpc.o: ibmpc.c estruct.h edef.h input.o: input.c estruct.h edef.h isearch.o: isearch.c estruct.h edef.h diff --git a/display.c b/display.c index e0fdc26..2f09f65 100644 --- a/display.c +++ b/display.c @@ -1,3 +1,7 @@ +/* display.c -- implements display.h */ + +#include "display.h" + /* display.c * * The functions in this file handle redisplay. There are two halves, the diff --git a/display.h b/display.h new file mode 100644 index 0000000..74e2785 --- /dev/null +++ b/display.h @@ -0,0 +1,23 @@ +#ifndef _DISPLAY_H_ +#define _DISPLAY_H_ + +void vtinit( void) ; +void vtfree( void) ; +void vttidy( void) ; +void vtmove( int row, int col) ; +int upscreen( int f, int n) ; +int update( int force) ; +void updpos( void) ; +void upddex( void) ; +void updgar( void) ; +int updupd( int force) ; +void upmode( void) ; +void movecursor( int row, int col) ; +void mlerase( void) ; +void mlwrite( const char *fmt, ...) ; +void mlforce( char *s) ; +void mlputs( char *s) ; +void getscreensize( int *widthp, int *heightp) ; +void sizesignal( int signr) ; + +#endif diff --git a/efunc.h b/efunc.h index 4e0a8ab..6ce5364 100644 --- a/efunc.h +++ b/efunc.h @@ -120,24 +120,7 @@ extern int unarg(int f, int n); extern int cexit(int status); /* display.c */ -extern void vtinit(void); -extern void vtfree(void); -extern void vttidy(void); -extern void vtmove(int row, int col); -extern int upscreen(int f, int n); -extern int update(int force); -extern void updpos(void); -extern void upddex(void); -extern void updgar(void); -extern int updupd(int force); -extern void upmode(void); -extern void movecursor(int row, int col); -extern void mlerase(void); -extern void mlwrite(const char *fmt, ...); -extern void mlforce(char *s); -extern void mlputs(char *s); -extern void getscreensize(int *widthp, int *heightp); -extern void sizesignal(int signr); +#include "display.h" /* region.c */ extern int killregion(int f, int n); diff --git a/fileio.c b/fileio.c index 5453edf..6fcb3f3 100644 --- a/fileio.c +++ b/fileio.c @@ -10,11 +10,11 @@ * modified by Petri Kutvonen */ -#include +#include #include "crypt.h" -#include "estruct.h" -#include "edef.h" -#include "efunc.h" +#include "display.h" +#include "estruct.h" +#include "edef.h" static FILE *ffp; /* File pointer, all functions. */ static int eofflag; /* end-of-file flag */ From 08a3aa81e1ef2a2f8d0612017380bf77995ce4e0 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sat, 18 May 2013 14:21:28 +0800 Subject: [PATCH 026/193] crypt depends on display and input instead of efunc. --- Makefile | 7 ++++--- crypt.c | 9 +++++---- edef.h | 2 ++ efunc.h | 13 +------------ estruct.h | 5 +++++ input.c | 4 ++++ input.h | 19 +++++++++++++++++++ 7 files changed, 40 insertions(+), 19 deletions(-) create mode 100644 input.h diff --git a/Makefile b/Makefile index f1b580b..eb64892 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,8 @@ OBJ=basic.o bind.o buffer.o crypt.o display.o eval.o exec.o \ termio.o window.o word.o names.o globals.o \ wrapper.o utf8.o -HDR=crypt.h display.h ebind.h edef.h efunc.h estruct.h fileio.h version.h +HDR=crypt.h display.h ebind.h edef.h efunc.h estruct.h fileio.h input.h \ + version.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -134,14 +135,14 @@ ansi.o: ansi.c estruct.h edef.h basic.o: basic.c estruct.h edef.h bind.o: bind.c estruct.h edef.h fileio.h buffer.o: buffer.c estruct.h edef.h -crypt.o: crypt.c crypt.h estruct.h edef.h +crypt.o: crypt.c crypt.h display.h estruct.h edef.h input.h display.o: display.c display.h estruct.h edef.h utf8.h version.h eval.o: eval.c estruct.h edef.h version.h fileio.h exec.o: exec.c estruct.h edef.h file.o: file.c crypt.h estruct.h edef.h fileio.h fileio.o: fileio.c fileio.h crypt.h display.h estruct.h edef.h ibmpc.o: ibmpc.c estruct.h edef.h -input.o: input.c estruct.h edef.h +input.o: input.c input.h estruct.h edef.h isearch.o: isearch.c estruct.h edef.h line.o: line.c estruct.h edef.h lock.o: lock.c estruct.h edef.h diff --git a/crypt.c b/crypt.c index c2b1c6a..7b735cb 100644 --- a/crypt.c +++ b/crypt.c @@ -9,10 +9,11 @@ * written by Dana Hoggatt and Daniel Lawrence */ -#include -#include "estruct.h" -#include "edef.h" -#include "efunc.h" +#include +#include "display.h" +#include "estruct.h" +#include "edef.h" +#include "input.h" #if CRYPT diff --git a/edef.h b/edef.h index b70c9cd..b61b9f0 100644 --- a/edef.h +++ b/edef.h @@ -10,6 +10,8 @@ #ifndef EDEF_H_ #define EDEF_H_ +#include "estruct.h" + #include #include diff --git a/efunc.h b/efunc.h index 6ce5364..6a11c9e 100644 --- a/efunc.h +++ b/efunc.h @@ -138,18 +138,7 @@ extern int ttgetc(void); extern int typahead(void); /* input.c */ -extern int mlyesno(char *prompt); -extern int mlreply(char *prompt, char *buf, int nbuf); -extern int mlreplyt(char *prompt, char *buf, int nbuf, int eolchar); -extern int ectoc(int c); -extern int ctoec(int c); -extern fn_t getname(void); -extern int tgetc(void); -extern int get1key(void); -extern int getcmd(void); -extern int getstring(char *prompt, char *buf, int nbuf, int eolchar); -extern void outstring(char *s); -extern void ostring(char *s); +#include "input.h" /* bind.c */ extern int help(int f, int n); diff --git a/estruct.h b/estruct.h index 3c382ce..af27316 100644 --- a/estruct.h +++ b/estruct.h @@ -1,3 +1,6 @@ +#ifndef _ESTRUCT_H_ +#define _ESTRUCT_H_ + /* ESTRUCT.H * * Structure and preprocessor defines @@ -678,3 +681,5 @@ struct magic_replacement { }; #endif /* MAGIC */ + +#endif diff --git a/input.c b/input.c index 28d6ada..cd1f88c 100644 --- a/input.c +++ b/input.c @@ -1,3 +1,7 @@ +/* input.c -- implements input.h */ + +#include "input.h" + /* input.c * * Various input routines diff --git a/input.h b/input.h new file mode 100644 index 0000000..a1da651 --- /dev/null +++ b/input.h @@ -0,0 +1,19 @@ +#ifndef _INPUT_H_ +#define _INPUT_H_ + +#include "edef.h" + +int mlyesno( char *prompt) ; +int mlreply( char *prompt, char *buf, int nbuf) ; +int mlreplyt( char *prompt, char *buf, int nbuf, int eolchar) ; +int ectoc( int c) ; +int ctoec( int c) ; +fn_t getname( void) ; +int tgetc( void) ; +int get1key( void) ; +int getcmd( void) ; +int getstring( char *prompt, char *buf, int nbuf, int eolchar) ; +void outstring( char *s) ; +void ostring( char *s) ; + +#endif From 0e9fc236f9520e8bfa755f11de5e2ef15a1103c2 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sat, 18 May 2013 14:43:13 +0800 Subject: [PATCH 027/193] display depends on window instead of efunc. --- Makefile | 6 +++--- display.c | 2 +- efunc.h | 23 +---------------------- window.c | 4 ++++ window.h | 28 ++++++++++++++++++++++++++++ 5 files changed, 37 insertions(+), 26 deletions(-) create mode 100644 window.h diff --git a/Makefile b/Makefile index eb64892..0f0ed63 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ OBJ=basic.o bind.o buffer.o crypt.o display.o eval.o exec.o \ wrapper.o utf8.o HDR=crypt.h display.h ebind.h edef.h efunc.h estruct.h fileio.h input.h \ - version.h + version.h window.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -136,7 +136,7 @@ basic.o: basic.c estruct.h edef.h bind.o: bind.c estruct.h edef.h fileio.h buffer.o: buffer.c estruct.h edef.h crypt.o: crypt.c crypt.h display.h estruct.h edef.h input.h -display.o: display.c display.h estruct.h edef.h utf8.h version.h +display.o: display.c display.h estruct.h edef.h utf8.h version.h window.h eval.o: eval.c estruct.h edef.h version.h fileio.h exec.o: exec.c estruct.h edef.h file.o: file.c crypt.h estruct.h edef.h fileio.h @@ -159,7 +159,7 @@ termio.o: termio.c estruct.h edef.h utf8.o: utf8.c utf8.h vmsvt.o: vmsvt.c estruct.h edef.h vt52.o: vt52.c estruct.h edef.h -window.o: window.c estruct.h edef.h +window.o: window.c window.h estruct.h edef.h word.o: word.c estruct.h edef.h wrapper.o: wrapper.c wrapper.h diff --git a/display.c b/display.c index 2f09f65..1ac864c 100644 --- a/display.c +++ b/display.c @@ -19,11 +19,11 @@ #include "estruct.h" #include "edef.h" -#include "efunc.h" #include "line.h" #include "version.h" #include "wrapper.h" #include "utf8.h" +#include "window.h" struct video { int v_flag; /* Flags */ diff --git a/efunc.h b/efunc.h index 6a11c9e..3f9e841 100644 --- a/efunc.h +++ b/efunc.h @@ -27,28 +27,7 @@ extern int killpara(int f, int n); extern int wordcount(int f, int n); /* window.c */ -extern int reposition(int f, int n); -extern int redraw(int f, int n); -extern int nextwind(int f, int n); -extern int prevwind(int f, int n); -extern int mvdnwind(int f, int n); -extern int mvupwind(int f, int n); -extern int onlywind(int f, int n); -extern int delwind(int f, int n); -extern int splitwind(int f, int n); -extern int enlargewind(int f, int n); -extern int shrinkwind(int f, int n); -extern int resize(int f, int n); -extern int scrnextup(int f, int n); -extern int scrnextdw(int f, int n); -extern int savewnd(int f, int n); -extern int restwnd(int f, int n); -extern int newsize(int f, int n); -extern int newwidth(int f, int n); -extern int getwpos(void); -extern void cknewwindow(void); -extern struct window *wpopup(void); /* Pop up window creation. */ - +#include "window.h" /* basic.c */ extern int gotobol(int f, int n); diff --git a/window.c b/window.c index 86da9a8..27743e8 100644 --- a/window.c +++ b/window.c @@ -1,3 +1,7 @@ +/* window.c -- inplements window.h */ + +#include "window.h" + /* window.c * * Window management. Some of the functions are internal, and some are diff --git a/window.h b/window.h new file mode 100644 index 0000000..5e0417c --- /dev/null +++ b/window.h @@ -0,0 +1,28 @@ +#ifndef _WINDOW_H_ +#define _WINDOW_H_ + +#include "estruct.h" + +int reposition( int f, int n); +int redraw( int f, int n) ; +int nextwind( int f, int n) ; +int prevwind( int f, int n) ; +int mvdnwind( int f, int n) ; +int mvupwind( int f, int n) ; +int onlywind( int f, int n) ; +int delwind( int f, int n) ; +int splitwind( int f, int n) ; +int enlargewind( int f, int n) ; +int shrinkwind( int f, int n) ; +int resize( int f, int n) ; +int scrnextup( int f, int n) ; +int scrnextdw( int f, int n) ; +int savewnd( int f, int n) ; +int restwnd( int f, int n) ; +int newsize( int f, int n) ; +int newwidth( int f, int n) ; +int getwpos( void) ; +void cknewwindow( void) ; +struct window *wpopup( void) ; /* Pop up window creation. */ + +#endif From 4bba6e741741b703dc9c2c271906feca5a7ba0ad Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sun, 19 May 2013 08:13:48 +0800 Subject: [PATCH 028/193] refactor main and basic out of efunc. --- Makefile | 10 +++++----- basic.c | 4 ++++ basic.h | 20 ++++++++++++++++++++ efunc.h | 32 ++------------------------------ main.c | 3 +++ main.h | 20 ++++++++++++++++++++ window.c | 4 +++- 7 files changed, 57 insertions(+), 36 deletions(-) create mode 100644 basic.h create mode 100644 main.h diff --git a/Makefile b/Makefile index 0f0ed63..d81523c 100644 --- a/Makefile +++ b/Makefile @@ -28,8 +28,8 @@ OBJ=basic.o bind.o buffer.o crypt.o display.o eval.o exec.o \ termio.o window.o word.o names.o globals.o \ wrapper.o utf8.o -HDR=crypt.h display.h ebind.h edef.h efunc.h estruct.h fileio.h input.h \ - version.h window.h +HDR=basic.h crypt.h display.h ebind.h edef.h efunc.h estruct.h fileio.h \ + input.h line.h main.h version.h window.h wrapper.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -132,7 +132,7 @@ depend: ${SRC} # DO NOT DELETE THIS LINE -- make depend uses it ansi.o: ansi.c estruct.h edef.h -basic.o: basic.c estruct.h edef.h +basic.o: basic.c basic.h estruct.h edef.h bind.o: bind.c estruct.h edef.h fileio.h buffer.o: buffer.c estruct.h edef.h crypt.o: crypt.c crypt.h display.h estruct.h edef.h input.h @@ -146,7 +146,7 @@ input.o: input.c input.h estruct.h edef.h isearch.o: isearch.c estruct.h edef.h line.o: line.c estruct.h edef.h lock.o: lock.c estruct.h edef.h -main.o: main.c estruct.h crypt.h efunc.h edef.h ebind.h version.h +main.o: main.c main.h estruct.h crypt.h efunc.h edef.h ebind.h version.h names.o: names.c estruct.h crypt.h edef.h efunc.h line.h pklock.o: pklock.c estruct.h posix.o: posix.c estruct.h utf8.h @@ -159,7 +159,7 @@ termio.o: termio.c estruct.h edef.h utf8.o: utf8.c utf8.h vmsvt.o: vmsvt.c estruct.h edef.h vt52.o: vt52.c estruct.h edef.h -window.o: window.c window.h estruct.h edef.h +window.o: window.c window.h estruct.h edef.h basic.h display.h main.h line.h wrapper.h word.o: word.c estruct.h edef.h wrapper.o: wrapper.c wrapper.h diff --git a/basic.c b/basic.c index 5071047..edfb6eb 100644 --- a/basic.c +++ b/basic.c @@ -1,3 +1,7 @@ +/* basic.c -- implements basic.h */ + +#include "basic.h" + /* basic.c * * The routines in this file move the cursor around on the screen. They diff --git a/basic.h b/basic.h new file mode 100644 index 0000000..cea1767 --- /dev/null +++ b/basic.h @@ -0,0 +1,20 @@ +#ifndef _BASIC_H_ +#define _BASIC_H_ + +int gotobol( int f, int n) ; +int backchar( int f, int n) ; +int gotoeol( int f, int n) ; +int forwchar( int f, int n) ; +int gotoline( int f, int n) ; +int gotobob( int f, int n) ; +int gotoeob( int f, int n) ; +int forwline( int f, int n) ; +int backline( int f, int n) ; +int gotobop( int f, int n) ; +int gotoeop( int f, int n) ; +int forwpage( int f, int n) ; +int backpage( int f, int n) ; +int setmark( int f, int n) ; +int swapmark( int f, int n) ; + +#endif diff --git a/efunc.h b/efunc.h index 3f9e841..a2b98d6 100644 --- a/efunc.h +++ b/efunc.h @@ -30,21 +30,7 @@ extern int wordcount(int f, int n); #include "window.h" /* basic.c */ -extern int gotobol(int f, int n); -extern int backchar(int f, int n); -extern int gotoeol(int f, int n); -extern int forwchar(int f, int n); -extern int gotoline(int f, int n); -extern int gotobob(int f, int n); -extern int gotoeob(int f, int n); -extern int forwline(int f, int n); -extern int backline(int f, int n); -extern int gotobop(int f, int n); -extern int gotoeop(int f, int n); -extern int forwpage(int f, int n); -extern int backpage(int f, int n); -extern int setmark(int f, int n); -extern int swapmark(int f, int n); +#include "basic.h" /* random.c */ extern int tabsize; /* Tab size (0: use real tabs). */ @@ -82,21 +68,7 @@ extern int istring(int f, int n); extern int ovstring(int f, int n); /* main.c */ -extern void edinit(char *bname); -extern int execute(int c, int f, int n); -extern int quickexit(int f, int n); -extern int quit(int f, int n); -extern int ctlxlp(int f, int n); -extern int ctlxrp(int f, int n); -extern int ctlxe(int f, int n); -extern int ctrlg(int f, int n); -extern int rdonly(void); -extern int resterr(void); -extern int nullproc(int f, int n); -extern int metafn(int f, int n); -extern int cex(int f, int n); -extern int unarg(int f, int n); -extern int cexit(int status); +#include "main.h" /* display.c */ #include "display.h" diff --git a/main.c b/main.c index fd3f939..776ba7e 100644 --- a/main.c +++ b/main.c @@ -1,3 +1,6 @@ +/* main.c -- implements main.h */ +#include "main.h" + /* * main.c diff --git a/main.h b/main.h new file mode 100644 index 0000000..76758e1 --- /dev/null +++ b/main.h @@ -0,0 +1,20 @@ +#ifndef _MAIN_H_ +#define _MAIN_H_ + +void edinit( char *bname) ; +int execute( int c, int f, int n) ; +int quickexit( int f, int n) ; +int quit( int f, int n) ; +int ctlxlp( int f, int n) ; +int ctlxrp( int f, int n) ; +int ctlxe( int f, int n) ; +int ctrlg( int f, int n) ; +int rdonly( void) ; +int resterr( void) ; +int nullproc( int f, int n) ; +int metafn( int f, int n) ; +int cex( int f, int n) ; +int unarg( int f, int n) ; +int cexit( int status) ; + +#endif diff --git a/window.c b/window.c index 27743e8..bd70e44 100644 --- a/window.c +++ b/window.c @@ -11,10 +11,12 @@ #include +#include "basic.h" +#include "display.h" #include "estruct.h" #include "edef.h" -#include "efunc.h" #include "line.h" +#include "main.h" #include "wrapper.h" /* From 93f2a6d691e4f9c019fcfb27693c5ea399ef2ac9 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sun, 19 May 2013 08:43:30 +0800 Subject: [PATCH 029/193] clean up line dependencies. --- estruct.h | 4 ++++ line.h | 36 ++++++++++++++++++------------------ utf8.h | 7 ++++--- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/estruct.h b/estruct.h index af27316..74acaca 100644 --- a/estruct.h +++ b/estruct.h @@ -11,6 +11,10 @@ * modified by Petri Kutvonen */ + +#include "line.h" + + #define MAXCOL 500 #define MAXROW 500 diff --git a/line.h b/line.h index 7b07a3b..2294b14 100644 --- a/line.h +++ b/line.h @@ -25,23 +25,23 @@ struct line { #define lputc(lp, n, c) ((lp)->l_text[(n)]=(c)) #define llength(lp) ((lp)->l_used) -extern void lfree(struct line *lp); -extern void lchange(int flag); -extern int insspace(int f, int n); -extern int linstr(char *instr); -extern int linsert(int n, int c); -extern int lowrite(int c); -extern int lover(char *ostr); -extern int lnewline(void); -extern int ldelete(long n, int kflag); -extern int ldelchar(long n, int kflag); -extern int lgetchar(unicode_t *); -extern char *getctext(void); -extern int putctext(char *iline); -extern int ldelnewline(void); -extern void kdelete(void); -extern int kinsert(int c); -extern int yank(int f, int n); -extern struct line *lalloc(int); /* Allocate a line. */ +void lfree( struct line *lp) ; +void lchange( int flag) ; +int insspace( int f, int n) ; +int linstr( char *instr) ; +int linsert( int n, int c) ; +int lowrite( int c) ; +int lover( char *ostr) ; +int lnewline( void) ; +int ldelete( long n, int kflag) ; +int ldelchar( long n, int kflag) ; +int lgetchar( unicode_t *) ; +char *getctext( void) ; +int putctext( char *iline) ; +int ldelnewline( void) ; +void kdelete( void) ; +int kinsert( int c) ; +int yank( int f, int n) ; +struct line *lalloc( int) ; /* Allocate a line. */ #endif /* LINE_H_ */ diff --git a/utf8.h b/utf8.h index c317a6a..1a6f274 100644 --- a/utf8.h +++ b/utf8.h @@ -3,10 +3,11 @@ typedef unsigned int unicode_t; -unsigned utf8_to_unicode(char *line, unsigned index, unsigned len, unicode_t *res); -unsigned unicode_to_utf8(unsigned int c, char *utf8); +unsigned utf8_to_unicode( char *line, unsigned index, unsigned len, + unicode_t *res) ; +unsigned unicode_to_utf8( unsigned int c, char *utf8) ; -static inline int is_beginning_utf8(unsigned char c) +static inline int is_beginning_utf8( unsigned char c) { return (c & 0xc0) != 0x80; } From 73c372fc7fc067ae8c9eaa8336d65b57fc2a8ec1 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sun, 19 May 2013 17:36:24 +0800 Subject: [PATCH 030/193] add file header. --- Makefile | 4 +- efunc.h | 24 +- file.c | 839 ++++++++++++++++++++++++++++--------------------------- file.h | 18 ++ 4 files changed, 449 insertions(+), 436 deletions(-) create mode 100644 file.h diff --git a/Makefile b/Makefile index d81523c..8fe91f0 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ OBJ=basic.o bind.o buffer.o crypt.o display.o eval.o exec.o \ termio.o window.o word.o names.o globals.o \ wrapper.o utf8.o -HDR=basic.h crypt.h display.h ebind.h edef.h efunc.h estruct.h fileio.h \ +HDR=basic.h crypt.h display.h ebind.h edef.h efunc.h estruct.h file.h fileio.h \ input.h line.h main.h version.h window.h wrapper.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -139,7 +139,7 @@ crypt.o: crypt.c crypt.h display.h estruct.h edef.h input.h display.o: display.c display.h estruct.h edef.h utf8.h version.h window.h eval.o: eval.c estruct.h edef.h version.h fileio.h exec.o: exec.c estruct.h edef.h -file.o: file.c crypt.h estruct.h edef.h fileio.h +file.o: file.c file.h crypt.h estruct.h edef.h fileio.h fileio.o: fileio.c fileio.h crypt.h display.h estruct.h edef.h ibmpc.o: ibmpc.c estruct.h edef.h input.o: input.c input.h estruct.h edef.h diff --git a/efunc.h b/efunc.h index a2b98d6..7a68499 100644 --- a/efunc.h +++ b/efunc.h @@ -1,12 +1,12 @@ -/* efunc.h +/* efunc.h * - * Function declarations and names. + * Function declarations and names. * - * This file list all the C code functions used and the names to use - * to bind keys to them. To add functions, declare it here in both the + * This file list all the C code functions used and the names to use + * to bind keys to them. To add functions, declare it here in both the * extern function list and the name binding table. * - * modified by Petri Kutvonen + * modified by Petri Kutvonen */ /* External function declarations. */ @@ -129,19 +129,7 @@ extern int unmark(int f, int n); extern struct buffer *bfind(char *bname, int cflag, int bflag); /* file.c */ -extern int fileread(int f, int n); -extern int insfile(int f, int n); -extern int filefind(int f, int n); -extern int viewfile(int f, int n); -extern int getfile(char *fname, int lockfl); -extern int readin(char *fname, int lockfl); -extern void makename(char *bname, char *fname); -extern void unqname(char *name); -extern int filewrite(int f, int n); -extern int filesave(int f, int n); -extern int writeout(char *fn); -extern int filename(int f, int n); -extern int ifile(char *fname); +#include "file.h" /* exec.c */ extern int namedcmd(int f, int n); diff --git a/file.c b/file.c index c6423bc..463b0ca 100644 --- a/file.c +++ b/file.c @@ -1,25 +1,32 @@ -/* file.c +/* file.c -- implements file.h */ + +#include "file.h" + +/* file.c * - * The routines in this file handle the reading, writing - * and lookup of disk files. All of details about the - * reading and writing of the disk are in "fileio.c". + * The routines in this file handle the reading, writing + * and lookup of disk files. All of details about the + * reading and writing of the disk are in "fileio.c". * - * modified by Petri Kutvonen + * modified by Petri Kutvonen */ #include #include #include "crypt.h" +#include "display.h" #include "estruct.h" #include "edef.h" #include "efunc.h" #include "fileio.h" +#include "input.h" #include "line.h" +#include "main.h" #if defined(PKCODE) /* Max number of lines from one file. */ -#define MAXNLINE 10000000 +#define MAXNLINE 10000000 #endif /* @@ -31,14 +38,14 @@ */ int fileread(int f, int n) { - int s; - char fname[NFILEN]; + int s; + char fname[NFILEN]; - if (restflag) /* don't allow this command if restricted */ - return resterr(); - if ((s = mlreply("Read file: ", fname, NFILEN)) != TRUE) - return s; - return readin(fname, TRUE); + if (restflag) /* don't allow this command if restricted */ + return resterr(); + if ((s = mlreply("Read file: ", fname, NFILEN)) != TRUE) + return s; + return readin(fname, TRUE); } /* @@ -50,18 +57,18 @@ int fileread(int f, int n) */ int insfile(int f, int n) { - int s; - char fname[NFILEN]; + int s; + char fname[NFILEN]; - if (restflag) /* don't allow this command if restricted */ - return resterr(); - if (curbp->b_mode & MDVIEW) /* don't allow this command if */ - return rdonly(); /* we are in read only mode */ - if ((s = mlreply("Insert file: ", fname, NFILEN)) != TRUE) - return s; - if ((s = ifile(fname)) != TRUE) - return s; - return reposition(TRUE, -1); + if (restflag) /* don't allow this command if restricted */ + return resterr(); + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return rdonly(); /* we are in read only mode */ + if ((s = mlreply("Insert file: ", fname, NFILEN)) != TRUE) + return s; + if ((s = ifile(fname)) != TRUE) + return s; + return reposition(TRUE, -1); } /* @@ -75,132 +82,132 @@ int insfile(int f, int n) */ int filefind(int f, int n) { - char fname[NFILEN]; /* file user wishes to find */ - int s; /* status return */ + char fname[NFILEN]; /* file user wishes to find */ + int s; /* status return */ - if (restflag) /* don't allow this command if restricted */ - return resterr(); - if ((s = mlreply("Find file: ", fname, NFILEN)) != TRUE) - return s; - return getfile(fname, TRUE); + if (restflag) /* don't allow this command if restricted */ + return resterr(); + if ((s = mlreply("Find file: ", fname, NFILEN)) != TRUE) + return s; + return getfile(fname, TRUE); } int viewfile(int f, int n) -{ /* visit a file in VIEW mode */ - char fname[NFILEN]; /* file user wishes to find */ - int s; /* status return */ - struct window *wp; /* scan for windows that need updating */ +{ /* visit a file in VIEW mode */ + char fname[NFILEN]; /* file user wishes to find */ + int s; /* status return */ + struct window *wp; /* scan for windows that need updating */ - if (restflag) /* don't allow this command if restricted */ - return resterr(); - if ((s = mlreply("View file: ", fname, NFILEN)) != TRUE) - return s; - s = getfile(fname, FALSE); - if (s) { /* if we succeed, put it in view mode */ - curwp->w_bufp->b_mode |= MDVIEW; + if (restflag) /* don't allow this command if restricted */ + return resterr(); + if ((s = mlreply("View file: ", fname, NFILEN)) != TRUE) + return s; + s = getfile(fname, FALSE); + if (s) { /* if we succeed, put it in view mode */ + curwp->w_bufp->b_mode |= MDVIEW; - /* scan through and update mode lines of all windows */ - wp = wheadp; - while (wp != NULL) { - wp->w_flag |= WFMODE; - wp = wp->w_wndp; - } - } - return s; + /* scan through and update mode lines of all windows */ + wp = wheadp; + while (wp != NULL) { + wp->w_flag |= WFMODE; + wp = wp->w_wndp; + } + } + return s; } -#if CRYPT +#if CRYPT static int resetkey(void) -{ /* reset the encryption key if needed */ - int s; /* return status */ +{ /* reset the encryption key if needed */ + int s; /* return status */ - /* turn off the encryption flag */ - cryptflag = FALSE; + /* turn off the encryption flag */ + cryptflag = FALSE; - /* if we are in crypt mode */ - if (curbp->b_mode & MDCRYPT) { - if (curbp->b_key[0] == 0) { - s = set_encryption_key(FALSE, 0); - if (s != TRUE) - return s; - } + /* if we are in crypt mode */ + if (curbp->b_mode & MDCRYPT) { + if (curbp->b_key[0] == 0) { + s = set_encryption_key(FALSE, 0); + if (s != TRUE) + return s; + } - /* let others know... */ - cryptflag = TRUE; + /* let others know... */ + cryptflag = TRUE; - /* and set up the key to be used! */ - /* de-encrypt it */ - myencrypt((char *) NULL, 0); - myencrypt(curbp->b_key, strlen(curbp->b_key)); + /* and set up the key to be used! */ + /* de-encrypt it */ + myencrypt((char *) NULL, 0); + myencrypt(curbp->b_key, strlen(curbp->b_key)); - /* re-encrypt it...seeding it to start */ - myencrypt((char *) NULL, 0); - myencrypt(curbp->b_key, strlen(curbp->b_key)); - } + /* re-encrypt it...seeding it to start */ + myencrypt((char *) NULL, 0); + myencrypt(curbp->b_key, strlen(curbp->b_key)); + } - return TRUE; + return TRUE; } #endif /* * getfile() * - * char fname[]; file name to find - * int lockfl; check the file for locks? + * char fname[]; file name to find + * int lockfl; check the file for locks? */ int getfile(char *fname, int lockfl) { - struct buffer *bp; - struct line *lp; - int i; - int s; - char bname[NBUFN]; /* buffer name to put file */ + struct buffer *bp; + struct line *lp; + int i; + int s; + char bname[NBUFN]; /* buffer name to put file */ -#if MSDOS - mklower(fname); /* msdos isn't case sensitive */ +#if MSDOS + mklower(fname); /* msdos isn't case sensitive */ #endif - for (bp = bheadp; bp != NULL; bp = bp->b_bufp) { - if ((bp->b_flag & BFINVS) == 0 - && strcmp(bp->b_fname, fname) == 0) { - swbuffer(bp); - lp = curwp->w_dotp; - i = curwp->w_ntrows / 2; - while (i-- && lback(lp) != curbp->b_linep) - lp = lback(lp); - curwp->w_linep = lp; - curwp->w_flag |= WFMODE | WFHARD; - cknewwindow(); - mlwrite("(Old buffer)"); - return TRUE; - } - } - makename(bname, fname); /* New buffer name. */ - while ((bp = bfind(bname, FALSE, 0)) != NULL) { - /* old buffer name conflict code */ - s = mlreply("Buffer name: ", bname, NBUFN); - if (s == ABORT) /* ^G to just quit */ - return s; - if (s == FALSE) { /* CR to clobber it */ - makename(bname, fname); - break; - } - } - if (bp == NULL && (bp = bfind(bname, TRUE, 0)) == NULL) { - mlwrite("Cannot create buffer"); - return FALSE; - } - if (--curbp->b_nwnd == 0) { /* Undisplay. */ - curbp->b_dotp = curwp->w_dotp; - curbp->b_doto = curwp->w_doto; - curbp->b_markp = curwp->w_markp; - curbp->b_marko = curwp->w_marko; - } - curbp = bp; /* Switch to it. */ - curwp->w_bufp = bp; - curbp->b_nwnd++; - s = readin(fname, lockfl); /* Read it in. */ - cknewwindow(); - return s; + for (bp = bheadp; bp != NULL; bp = bp->b_bufp) { + if ((bp->b_flag & BFINVS) == 0 + && strcmp(bp->b_fname, fname) == 0) { + swbuffer(bp); + lp = curwp->w_dotp; + i = curwp->w_ntrows / 2; + while (i-- && lback(lp) != curbp->b_linep) + lp = lback(lp); + curwp->w_linep = lp; + curwp->w_flag |= WFMODE | WFHARD; + cknewwindow(); + mlwrite("(Old buffer)"); + return TRUE; + } + } + makename(bname, fname); /* New buffer name. */ + while ((bp = bfind(bname, FALSE, 0)) != NULL) { + /* old buffer name conflict code */ + s = mlreply("Buffer name: ", bname, NBUFN); + if (s == ABORT) /* ^G to just quit */ + return s; + if (s == FALSE) { /* CR to clobber it */ + makename(bname, fname); + break; + } + } + if (bp == NULL && (bp = bfind(bname, TRUE, 0)) == NULL) { + mlwrite("Cannot create buffer"); + return FALSE; + } + if (--curbp->b_nwnd == 0) { /* Undisplay. */ + curbp->b_dotp = curwp->w_dotp; + curbp->b_doto = curwp->w_doto; + curbp->b_markp = curwp->w_markp; + curbp->b_marko = curwp->w_marko; + } + curbp = bp; /* Switch to it. */ + curwp->w_bufp = bp; + curbp->b_nwnd++; + s = readin(fname, lockfl); /* Read it in. */ + cknewwindow(); + return s; } /* @@ -211,110 +218,110 @@ int getfile(char *fname, int lockfl) * The command bound to M-FNR is called after the buffer is set up * and before it is read. * - * char fname[]; name of file to read - * int lockfl; check for file locks? + * char fname[]; name of file to read + * int lockfl; check for file locks? */ int readin(char *fname, int lockfl) { - struct line *lp1; - struct line *lp2; - int i; - struct window *wp; - struct buffer *bp; - int s; - int nbytes; - int nline; - char mesg[NSTRING]; + struct line *lp1; + struct line *lp2; + int i; + struct window *wp; + struct buffer *bp; + int s; + int nbytes; + int nline; + char mesg[NSTRING]; -#if (FILOCK && BSD) || SVR4 - if (lockfl && lockchk(fname) == ABORT) +#if (FILOCK && BSD) || SVR4 + if (lockfl && lockchk(fname) == ABORT) #if PKCODE - { - s = FIOFNF; - bp = curbp; - strcpy(bp->b_fname, ""); - goto out; - } + { + s = FIOFNF; + bp = curbp; + strcpy(bp->b_fname, ""); + goto out; + } #else - return ABORT; + return ABORT; #endif #endif -#if CRYPT - s = resetkey(); - if (s != TRUE) - return s; +#if CRYPT + s = resetkey(); + if (s != TRUE) + return s; #endif - bp = curbp; /* Cheap. */ - if ((s = bclear(bp)) != TRUE) /* Might be old. */ - return s; - bp->b_flag &= ~(BFINVS | BFCHG); - strcpy(bp->b_fname, fname); + bp = curbp; /* Cheap. */ + if ((s = bclear(bp)) != TRUE) /* Might be old. */ + return s; + bp->b_flag &= ~(BFINVS | BFCHG); + strcpy(bp->b_fname, fname); - /* let a user macro get hold of things...if he wants */ - execute(META | SPEC | 'R', FALSE, 1); + /* let a user macro get hold of things...if he wants */ + execute(META | SPEC | 'R', FALSE, 1); - if ((s = ffropen(fname)) == FIOERR) /* Hard file open. */ - goto out; + if ((s = ffropen(fname)) == FIOERR) /* Hard file open. */ + goto out; - if (s == FIOFNF) { /* File not found. */ - mlwrite("(New file)"); - goto out; - } + if (s == FIOFNF) { /* File not found. */ + mlwrite("(New file)"); + goto out; + } - /* read the file in */ - mlwrite("(Reading file)"); - nline = 0; - while ((s = ffgetline()) == FIOSUC) { - nbytes = strlen(fline); - if ((lp1 = lalloc(nbytes)) == NULL) { - s = FIOMEM; /* Keep message on the */ - break; /* display. */ - } -#if PKCODE - if (nline > MAXNLINE) { - s = FIOMEM; - break; - } + /* read the file in */ + mlwrite("(Reading file)"); + nline = 0; + while ((s = ffgetline()) == FIOSUC) { + nbytes = strlen(fline); + if ((lp1 = lalloc(nbytes)) == NULL) { + s = FIOMEM; /* Keep message on the */ + break; /* display. */ + } +#if PKCODE + if (nline > MAXNLINE) { + s = FIOMEM; + break; + } #endif - lp2 = lback(curbp->b_linep); - lp2->l_fp = lp1; - lp1->l_fp = curbp->b_linep; - lp1->l_bp = lp2; - curbp->b_linep->l_bp = lp1; - for (i = 0; i < nbytes; ++i) - lputc(lp1, i, fline[i]); - ++nline; - } - ffclose(); /* Ignore errors. */ - strcpy(mesg, "("); - if (s == FIOERR) { - strcat(mesg, "I/O ERROR, "); - curbp->b_flag |= BFTRUNC; - } - if (s == FIOMEM) { - strcat(mesg, "OUT OF MEMORY, "); - curbp->b_flag |= BFTRUNC; - } - sprintf(&mesg[strlen(mesg)], "Read %d line", nline); - if (nline != 1) - strcat(mesg, "s"); - strcat(mesg, ")"); - mlwrite(mesg); + lp2 = lback(curbp->b_linep); + lp2->l_fp = lp1; + lp1->l_fp = curbp->b_linep; + lp1->l_bp = lp2; + curbp->b_linep->l_bp = lp1; + for (i = 0; i < nbytes; ++i) + lputc(lp1, i, fline[i]); + ++nline; + } + ffclose(); /* Ignore errors. */ + strcpy(mesg, "("); + if (s == FIOERR) { + strcat(mesg, "I/O ERROR, "); + curbp->b_flag |= BFTRUNC; + } + if (s == FIOMEM) { + strcat(mesg, "OUT OF MEMORY, "); + curbp->b_flag |= BFTRUNC; + } + sprintf(&mesg[strlen(mesg)], "Read %d line", nline); + if (nline != 1) + strcat(mesg, "s"); + strcat(mesg, ")"); + mlwrite(mesg); out: - for (wp = wheadp; wp != NULL; wp = wp->w_wndp) { - if (wp->w_bufp == curbp) { - wp->w_linep = lforw(curbp->b_linep); - wp->w_dotp = lforw(curbp->b_linep); - wp->w_doto = 0; - wp->w_markp = NULL; - wp->w_marko = 0; - wp->w_flag |= WFMODE | WFHARD; - } - } - if (s == FIOERR || s == FIOFNF) /* False if error. */ - return FALSE; - return TRUE; + for (wp = wheadp; wp != NULL; wp = wp->w_wndp) { + if (wp->w_bufp == curbp) { + wp->w_linep = lforw(curbp->b_linep); + wp->w_dotp = lforw(curbp->b_linep); + wp->w_doto = 0; + wp->w_markp = NULL; + wp->w_marko = 0; + wp->w_flag |= WFMODE | WFHARD; + } + } + if (s == FIOERR || s == FIOFNF) /* False if error. */ + return FALSE; + return TRUE; } /* @@ -326,59 +333,59 @@ int readin(char *fname, int lockfl) */ void makename(char *bname, char *fname) { - char *cp1; - char *cp2; + char *cp1; + char *cp2; - cp1 = &fname[0]; - while (*cp1 != 0) - ++cp1; + cp1 = &fname[0]; + while (*cp1 != 0) + ++cp1; #if VMS -#if PKCODE - while (cp1 != &fname[0] && cp1[-1] != ':' && cp1[-1] != ']' - && cp1[-1] != '>') +#if PKCODE + while (cp1 != &fname[0] && cp1[-1] != ':' && cp1[-1] != ']' + && cp1[-1] != '>') #else - while (cp1 != &fname[0] && cp1[-1] != ':' && cp1[-1] != ']') + while (cp1 != &fname[0] && cp1[-1] != ':' && cp1[-1] != ']') #endif - --cp1; + --cp1; #endif #if MSDOS - while (cp1 != &fname[0] && cp1[-1] != ':' && cp1[-1] != '\\' - && cp1[-1] != '/') - --cp1; + while (cp1 != &fname[0] && cp1[-1] != ':' && cp1[-1] != '\\' + && cp1[-1] != '/') + --cp1; #endif #if V7 | USG | BSD - while (cp1 != &fname[0] && cp1[-1] != '/') - --cp1; + while (cp1 != &fname[0] && cp1[-1] != '/') + --cp1; #endif - cp2 = &bname[0]; - while (cp2 != &bname[NBUFN - 1] && *cp1 != 0 && *cp1 != ';') - *cp2++ = *cp1++; - *cp2 = 0; + cp2 = &bname[0]; + while (cp2 != &bname[NBUFN - 1] && *cp1 != 0 && *cp1 != ';') + *cp2++ = *cp1++; + *cp2 = 0; } /* * make sure a buffer name is unique * - * char *name; name to check on + * char *name; name to check on */ void unqname(char *name) { - char *sp; + char *sp; - /* check to see if it is in the buffer list */ - while (bfind(name, 0, FALSE) != NULL) { + /* check to see if it is in the buffer list */ + while (bfind(name, 0, FALSE) != NULL) { - /* go to the end of the name */ - sp = name; - while (*sp) - ++sp; - if (sp == name || (*(sp - 1) < '0' || *(sp - 1) > '8')) { - *sp++ = '0'; - *sp = 0; - } else - *(--sp) += 1; - } + /* go to the end of the name */ + sp = name; + while (*sp) + ++sp; + if (sp == name || (*(sp - 1) < '0' || *(sp - 1) > '8')) { + *sp++ = '0'; + *sp = 0; + } else + *(--sp) += 1; + } } /* @@ -392,25 +399,25 @@ void unqname(char *name) */ int filewrite(int f, int n) { - struct window *wp; - int s; - char fname[NFILEN]; + struct window *wp; + int s; + char fname[NFILEN]; - if (restflag) /* don't allow this command if restricted */ - return resterr(); - if ((s = mlreply("Write file: ", fname, NFILEN)) != TRUE) - return s; - if ((s = writeout(fname)) == TRUE) { - strcpy(curbp->b_fname, fname); - curbp->b_flag &= ~BFCHG; - wp = wheadp; /* Update mode lines. */ - while (wp != NULL) { - if (wp->w_bufp == curbp) - wp->w_flag |= WFMODE; - wp = wp->w_wndp; - } - } - return s; + if (restflag) /* don't allow this command if restricted */ + return resterr(); + if ((s = mlreply("Write file: ", fname, NFILEN)) != TRUE) + return s; + if ((s = writeout(fname)) == TRUE) { + strcpy(curbp->b_fname, fname); + curbp->b_flag &= ~BFCHG; + wp = wheadp; /* Update mode lines. */ + while (wp != NULL) { + if (wp->w_bufp == curbp) + wp->w_flag |= WFMODE; + wp = wp->w_wndp; + } + } + return s; } /* @@ -423,36 +430,36 @@ int filewrite(int f, int n) */ int filesave(int f, int n) { - struct window *wp; - int s; + struct window *wp; + int s; - if (curbp->b_mode & MDVIEW) /* don't allow this command if */ - return rdonly(); /* we are in read only mode */ - if ((curbp->b_flag & BFCHG) == 0) /* Return, no changes. */ - return TRUE; - if (curbp->b_fname[0] == 0) { /* Must have a name. */ - mlwrite("No file name"); - return FALSE; - } + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return rdonly(); /* we are in read only mode */ + if ((curbp->b_flag & BFCHG) == 0) /* Return, no changes. */ + return TRUE; + if (curbp->b_fname[0] == 0) { /* Must have a name. */ + mlwrite("No file name"); + return FALSE; + } - /* complain about truncated files */ - if ((curbp->b_flag & BFTRUNC) != 0) { - if (mlyesno("Truncated file ... write it out") == FALSE) { - mlwrite("(Aborted)"); - return FALSE; - } - } + /* complain about truncated files */ + if ((curbp->b_flag & BFTRUNC) != 0) { + if (mlyesno("Truncated file ... write it out") == FALSE) { + mlwrite("(Aborted)"); + return FALSE; + } + } - if ((s = writeout(curbp->b_fname)) == TRUE) { - curbp->b_flag &= ~BFCHG; - wp = wheadp; /* Update mode lines. */ - while (wp != NULL) { - if (wp->w_bufp == curbp) - wp->w_flag |= WFMODE; - wp = wp->w_wndp; - } - } - return s; + if ((s = writeout(curbp->b_fname)) == TRUE) { + curbp->b_flag &= ~BFCHG; + wp = wheadp; /* Update mode lines. */ + while (wp != NULL) { + if (wp->w_bufp == curbp) + wp->w_flag |= WFMODE; + wp = wp->w_wndp; + } + } + return s; } /* @@ -465,41 +472,41 @@ int filesave(int f, int n) */ int writeout(char *fn) { - int s; - struct line *lp; - int nline; + int s; + struct line *lp; + int nline; -#if CRYPT - s = resetkey(); - if (s != TRUE) - return s; +#if CRYPT + s = resetkey(); + if (s != TRUE) + return s; #endif - if ((s = ffwopen(fn)) != FIOSUC) { /* Open writes message. */ - return FALSE; - } - mlwrite("(Writing...)"); /* tell us were writing */ - lp = lforw(curbp->b_linep); /* First line. */ - nline = 0; /* Number of lines. */ - while (lp != curbp->b_linep) { - if ((s = ffputline(&lp->l_text[0], llength(lp))) != FIOSUC) - break; - ++nline; - lp = lforw(lp); - } - if (s == FIOSUC) { /* No write error. */ - s = ffclose(); - if (s == FIOSUC) { /* No close error. */ - if (nline == 1) - mlwrite("(Wrote 1 line)"); - else - mlwrite("(Wrote %d lines)", nline); - } - } else /* Ignore close error */ - ffclose(); /* if a write error. */ - if (s != FIOSUC) /* Some sort of error. */ - return FALSE; - return TRUE; + if ((s = ffwopen(fn)) != FIOSUC) { /* Open writes message. */ + return FALSE; + } + mlwrite("(Writing...)"); /* tell us were writing */ + lp = lforw(curbp->b_linep); /* First line. */ + nline = 0; /* Number of lines. */ + while (lp != curbp->b_linep) { + if ((s = ffputline(&lp->l_text[0], llength(lp))) != FIOSUC) + break; + ++nline; + lp = lforw(lp); + } + if (s == FIOSUC) { /* No write error. */ + s = ffclose(); + if (s == FIOSUC) { /* No close error. */ + if (nline == 1) + mlwrite("(Wrote 1 line)"); + else + mlwrite("(Wrote %d lines)", nline); + } + } else /* Ignore close error */ + ffclose(); /* if a write error. */ + if (s != FIOSUC) /* Some sort of error. */ + return FALSE; + return TRUE; } /* @@ -513,26 +520,26 @@ int writeout(char *fn) */ int filename(int f, int n) { - struct window *wp; - int s; - char fname[NFILEN]; + struct window *wp; + int s; + char fname[NFILEN]; - if (restflag) /* don't allow this command if restricted */ - return resterr(); - if ((s = mlreply("Name: ", fname, NFILEN)) == ABORT) - return s; - if (s == FALSE) - strcpy(curbp->b_fname, ""); - else - strcpy(curbp->b_fname, fname); - wp = wheadp; /* Update mode lines. */ - while (wp != NULL) { - if (wp->w_bufp == curbp) - wp->w_flag |= WFMODE; - wp = wp->w_wndp; - } - curbp->b_mode &= ~MDVIEW; /* no longer read only mode */ - return TRUE; + if (restflag) /* don't allow this command if restricted */ + return resterr(); + if ((s = mlreply("Name: ", fname, NFILEN)) == ABORT) + return s; + if (s == FALSE) + strcpy(curbp->b_fname, ""); + else + strcpy(curbp->b_fname, fname); + wp = wheadp; /* Update mode lines. */ + while (wp != NULL) { + if (wp->w_bufp == curbp) + wp->w_flag |= WFMODE; + wp = wp->w_wndp; + } + curbp->b_mode &= ~MDVIEW; /* no longer read only mode */ + return TRUE; } /* @@ -542,89 +549,89 @@ int filename(int f, int n) */ int ifile(char *fname) { - struct line *lp0; - struct line *lp1; - struct line *lp2; - int i; - struct buffer *bp; - int s; - int nbytes; - int nline; - char mesg[NSTRING]; + struct line *lp0; + struct line *lp1; + struct line *lp2; + int i; + struct buffer *bp; + int s; + int nbytes; + int nline; + char mesg[NSTRING]; - bp = curbp; /* Cheap. */ - bp->b_flag |= BFCHG; /* we have changed */ - bp->b_flag &= ~BFINVS; /* and are not temporary */ - if ((s = ffropen(fname)) == FIOERR) /* Hard file open. */ - goto out; - if (s == FIOFNF) { /* File not found. */ - mlwrite("(No such file)"); - return FALSE; - } - mlwrite("(Inserting file)"); + bp = curbp; /* Cheap. */ + bp->b_flag |= BFCHG; /* we have changed */ + bp->b_flag &= ~BFINVS; /* and are not temporary */ + if ((s = ffropen(fname)) == FIOERR) /* Hard file open. */ + goto out; + if (s == FIOFNF) { /* File not found. */ + mlwrite("(No such file)"); + return FALSE; + } + mlwrite("(Inserting file)"); -#if CRYPT - s = resetkey(); - if (s != TRUE) - return s; +#if CRYPT + s = resetkey(); + if (s != TRUE) + return s; #endif - /* back up a line and save the mark here */ - curwp->w_dotp = lback(curwp->w_dotp); - curwp->w_doto = 0; - curwp->w_markp = curwp->w_dotp; - curwp->w_marko = 0; + /* back up a line and save the mark here */ + curwp->w_dotp = lback(curwp->w_dotp); + curwp->w_doto = 0; + curwp->w_markp = curwp->w_dotp; + curwp->w_marko = 0; - nline = 0; - while ((s = ffgetline()) == FIOSUC) { - nbytes = strlen(fline); - if ((lp1 = lalloc(nbytes)) == NULL) { - s = FIOMEM; /* Keep message on the */ - break; /* display. */ - } - lp0 = curwp->w_dotp; /* line previous to insert */ - lp2 = lp0->l_fp; /* line after insert */ + nline = 0; + while ((s = ffgetline()) == FIOSUC) { + nbytes = strlen(fline); + if ((lp1 = lalloc(nbytes)) == NULL) { + s = FIOMEM; /* Keep message on the */ + break; /* display. */ + } + lp0 = curwp->w_dotp; /* line previous to insert */ + lp2 = lp0->l_fp; /* line after insert */ - /* re-link new line between lp0 and lp2 */ - lp2->l_bp = lp1; - lp0->l_fp = lp1; - lp1->l_bp = lp0; - lp1->l_fp = lp2; + /* re-link new line between lp0 and lp2 */ + lp2->l_bp = lp1; + lp0->l_fp = lp1; + lp1->l_bp = lp0; + lp1->l_fp = lp2; - /* and advance and write out the current line */ - curwp->w_dotp = lp1; - for (i = 0; i < nbytes; ++i) - lputc(lp1, i, fline[i]); - ++nline; - } - ffclose(); /* Ignore errors. */ - curwp->w_markp = lforw(curwp->w_markp); - strcpy(mesg, "("); - if (s == FIOERR) { - strcat(mesg, "I/O ERROR, "); - curbp->b_flag |= BFTRUNC; - } - if (s == FIOMEM) { - strcat(mesg, "OUT OF MEMORY, "); - curbp->b_flag |= BFTRUNC; - } - sprintf(&mesg[strlen(mesg)], "Inserted %d line", nline); - if (nline > 1) - strcat(mesg, "s"); - strcat(mesg, ")"); - mlwrite(mesg); + /* and advance and write out the current line */ + curwp->w_dotp = lp1; + for (i = 0; i < nbytes; ++i) + lputc(lp1, i, fline[i]); + ++nline; + } + ffclose(); /* Ignore errors. */ + curwp->w_markp = lforw(curwp->w_markp); + strcpy(mesg, "("); + if (s == FIOERR) { + strcat(mesg, "I/O ERROR, "); + curbp->b_flag |= BFTRUNC; + } + if (s == FIOMEM) { + strcat(mesg, "OUT OF MEMORY, "); + curbp->b_flag |= BFTRUNC; + } + sprintf(&mesg[strlen(mesg)], "Inserted %d line", nline); + if (nline > 1) + strcat(mesg, "s"); + strcat(mesg, ")"); + mlwrite(mesg); out: - /* advance to the next line and mark the window for changes */ - curwp->w_dotp = lforw(curwp->w_dotp); - curwp->w_flag |= WFHARD | WFMODE; + /* advance to the next line and mark the window for changes */ + curwp->w_dotp = lforw(curwp->w_dotp); + curwp->w_flag |= WFHARD | WFMODE; - /* copy window parameters back to the buffer structure */ - curbp->b_dotp = curwp->w_dotp; - curbp->b_doto = curwp->w_doto; - curbp->b_markp = curwp->w_markp; - curbp->b_marko = curwp->w_marko; + /* copy window parameters back to the buffer structure */ + curbp->b_dotp = curwp->w_dotp; + curbp->b_doto = curwp->w_doto; + curbp->b_markp = curwp->w_markp; + curbp->b_marko = curwp->w_marko; - if (s == FIOERR) /* False if error. */ - return FALSE; - return TRUE; + if (s == FIOERR) /* False if error. */ + return FALSE; + return TRUE; } diff --git a/file.h b/file.h new file mode 100644 index 0000000..886ce52 --- /dev/null +++ b/file.h @@ -0,0 +1,18 @@ +#ifndef _FILE_H_ +#define _FILE_H_ + +int fileread( int f, int n) ; +int insfile( int f, int n) ; +int filefind( int f, int n) ; +int viewfile( int f, int n) ; +int getfile( char *fname, int lockfl) ; +int readin( char *fname, int lockfl) ; +void makename( char *bname, char *fname) ; +void unqname( char *name) ; +int filewrite( int f, int n) ; +int filesave( int f, int n) ; +int writeout( char *fn) ; +int filename( int f, int n) ; +int ifile( char *fname) ; + +#endif From 9c311a1ba865843e9a4055d8734ce75c003b28fe Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Mon, 20 May 2013 13:16:08 +0800 Subject: [PATCH 031/193] split efunc into corresponding headers. --- Makefile | 34 +++++---- bind.c | 3 + bind.h | 25 ++++++ buffer.c | 3 + buffer.h | 22 ++++++ efunc.h | 225 +++++------------------------------------------------- eval.c | 2 + eval.h | 26 +++++++ exec.c | 3 + exec.h | 62 +++++++++++++++ isearch.c | 2 + isearch.h | 11 +++ lock.c | 2 + lock.h | 6 ++ pklock.c | 2 + pklock.h | 3 + posix.c | 3 + posix.h | 11 +++ random.c | 3 + random.h | 39 ++++++++++ region.c | 3 + region.h | 12 +++ search.c | 3 + search.h | 23 ++++++ spawn.c | 3 + spawn.h | 11 +++ word.c | 3 + word.h | 18 +++++ 28 files changed, 340 insertions(+), 223 deletions(-) create mode 100644 bind.h create mode 100644 buffer.h create mode 100644 eval.h create mode 100644 exec.h create mode 100644 isearch.h create mode 100644 lock.h create mode 100644 pklock.h create mode 100644 posix.h create mode 100644 random.h create mode 100644 region.h create mode 100644 search.h create mode 100644 spawn.h create mode 100644 word.h diff --git a/Makefile b/Makefile index 8fe91f0..96bd554 100644 --- a/Makefile +++ b/Makefile @@ -28,8 +28,10 @@ OBJ=basic.o bind.o buffer.o crypt.o display.o eval.o exec.o \ termio.o window.o word.o names.o globals.o \ wrapper.o utf8.o -HDR=basic.h crypt.h display.h ebind.h edef.h efunc.h estruct.h file.h fileio.h \ - input.h line.h main.h version.h window.h wrapper.h +HDR=basic.h bind.h buffer.h crypt.h display.h ebind.h edef.h efunc.h \ + estruct.h eval.h exec.h file.h fileio.h input.h isearch.h line.h \ + lock.h main.h pklock.h posix.h random.h region.h search.h spawn.h \ + utf8.h version.h window.h word.h wrapper.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -133,34 +135,34 @@ depend: ${SRC} ansi.o: ansi.c estruct.h edef.h basic.o: basic.c basic.h estruct.h edef.h -bind.o: bind.c estruct.h edef.h fileio.h -buffer.o: buffer.c estruct.h edef.h +bind.o: bind.c bind.h estruct.h edef.h fileio.h +buffer.o: buffer.c buffer.h estruct.h edef.h crypt.o: crypt.c crypt.h display.h estruct.h edef.h input.h display.o: display.c display.h estruct.h edef.h utf8.h version.h window.h -eval.o: eval.c estruct.h edef.h version.h fileio.h -exec.o: exec.c estruct.h edef.h +eval.o: eval.c eval.h estruct.h edef.h version.h fileio.h +exec.o: exec.c exec.h estruct.h edef.h file.o: file.c file.h crypt.h estruct.h edef.h fileio.h fileio.o: fileio.c fileio.h crypt.h display.h estruct.h edef.h ibmpc.o: ibmpc.c estruct.h edef.h input.o: input.c input.h estruct.h edef.h -isearch.o: isearch.c estruct.h edef.h -line.o: line.c estruct.h edef.h -lock.o: lock.c estruct.h edef.h +isearch.o: isearch.c isearch.h estruct.h edef.h +line.o: line.c line.h estruct.h edef.h +lock.o: lock.c lock.h estruct.h edef.h main.o: main.c main.h estruct.h crypt.h efunc.h edef.h ebind.h version.h names.o: names.c estruct.h crypt.h edef.h efunc.h line.h -pklock.o: pklock.c estruct.h -posix.o: posix.c estruct.h utf8.h -random.o: random.c estruct.h edef.h -region.o: region.c estruct.h edef.h -search.o: search.c estruct.h edef.h -spawn.o: spawn.c estruct.h edef.h +pklock.o: pklock.c pklock.h estruct.h +posix.o: posix.c posix.h estruct.h utf8.h +random.o: random.c random.h estruct.h edef.h +region.o: region.c region.h estruct.h edef.h +search.o: search.c search.h estruct.h edef.h +spawn.o: spawn.c spawn.h estruct.h edef.h tcap.o: tcap.c estruct.h edef.h termio.o: termio.c estruct.h edef.h utf8.o: utf8.c utf8.h vmsvt.o: vmsvt.c estruct.h edef.h vt52.o: vt52.c estruct.h edef.h window.o: window.c window.h estruct.h edef.h basic.h display.h main.h line.h wrapper.h -word.o: word.c estruct.h edef.h +word.o: word.c word.h estruct.h edef.h wrapper.o: wrapper.c wrapper.h # DEPENDENCIES MUST END AT END OF FILE diff --git a/bind.c b/bind.c index 26b7ce6..6b59eb3 100644 --- a/bind.c +++ b/bind.c @@ -1,3 +1,6 @@ +/* bind.c -- implements bind.h */ +#include "bind.h" + /* bind.c * * This file is for functions having to do with key bindings, diff --git a/bind.h b/bind.h new file mode 100644 index 0000000..ae7de26 --- /dev/null +++ b/bind.h @@ -0,0 +1,25 @@ +#ifndef _BIND_H_ +#define _BIND_H_ + +#include "edef.h" + +int help( int f, int n) ; +int deskey( int f, int n) ; +int bindtokey( int f, int n) ; +int unbindkey( int f, int n) ; +int unbindchar( int c) ; +int desbind( int f, int n) ; +int apro( int f, int n) ; +int buildlist( int type, char *mstring) ; +int strinc( char *source, char *sub) ; +unsigned int getckey( int mflag) ; +int startup( char *sfname) ; +char *flook( const char *fname, int hflag) ; +void cmdstr( int c, char *seq) ; +fn_t getbind( int c) ; +char *getfname( fn_t) ; +fn_t fncmatch( char *) ; +unsigned int stock( char *keyname) ; +char *transbind( char *skey) ; + +#endif diff --git a/buffer.c b/buffer.c index 9aaf530..a66587b 100644 --- a/buffer.c +++ b/buffer.c @@ -1,3 +1,6 @@ +/* buffer.c -- implements buffer.h */ +#include "buffer.h" + /* buffer.c * * Buffer management. diff --git a/buffer.h b/buffer.h new file mode 100644 index 0000000..3768346 --- /dev/null +++ b/buffer.h @@ -0,0 +1,22 @@ +#ifndef _BUFFER_H_ +#define _BUFFER_H_ + +#include "estruct.h" + +int usebuffer( int f, int n) ; +int nextbuffer( int f, int n) ; +int swbuffer( struct buffer *bp) ; +int killbuffer( int f, int n) ; +int zotbuf( struct buffer *bp) ; +int namebuffer( int f, int n) ; +int listbuffers( int f, int n) ; +int makelist( int iflag) ; +void ltoa( char *buf, int width, long num) ; +int addline( char *text) ; +int anycb( void) ; +int bclear( struct buffer *bp) ; +int unmark( int f, int n) ; +/* Lookup a buffer by name. */ +struct buffer *bfind( char *bname, int cflag, int bflag) ; + +#endif diff --git a/efunc.h b/efunc.h index 7a68499..55e09c0 100644 --- a/efunc.h +++ b/efunc.h @@ -1,3 +1,6 @@ +#ifndef _EFUNC_H_ +#define _EFUNC_H_ + /* efunc.h * * Function declarations and names. @@ -12,19 +15,7 @@ /* External function declarations. */ /* word.c */ -extern int wrapword(int f, int n); -extern int backword(int f, int n); -extern int forwword(int f, int n); -extern int upperword(int f, int n); -extern int lowerword(int f, int n); -extern int capword(int f, int n); -extern int delfword(int f, int n); -extern int delbword(int f, int n); -extern int inword(void); -extern int fillpara(int f, int n); -extern int justpara(int f, int n); -extern int killpara(int f, int n); -extern int wordcount(int f, int n); +#include "word.h" /* window.c */ #include "window.h" @@ -33,39 +24,7 @@ extern int wordcount(int f, int n); #include "basic.h" /* random.c */ -extern int tabsize; /* Tab size (0: use real tabs). */ -extern int setfillcol(int f, int n); -extern int showcpos(int f, int n); -extern int getcline(void); -extern int getccol(int bflg); -extern int setccol(int pos); -extern int twiddle(int f, int n); -extern int quote(int f, int n); -extern int insert_tab(int f, int n); -extern int detab(int f, int n); -extern int entab(int f, int n); -extern int trim(int f, int n); -extern int openline(int f, int n); -extern int insert_newline(int f, int n); -extern int cinsert(void); -extern int insbrace(int n, int c); -extern int inspound(void); -extern int deblank(int f, int n); -extern int indent(int f, int n); -extern int forwdel(int f, int n); -extern int backdel(int f, int n); -extern int killtext(int f, int n); -extern int setemode(int f, int n); -extern int delmode(int f, int n); -extern int setgmode(int f, int n); -extern int delgmode(int f, int n); -extern int adjustmode(int kind, int global); -extern int clrmes(int f, int n); -extern int writemsg(int f, int n); -extern int getfence(int f, int n); -extern int fmatch(int ch); -extern int istring(int f, int n); -extern int ovstring(int f, int n); +#include "random.h" /* main.c */ #include "main.h" @@ -74,190 +33,42 @@ extern int ovstring(int f, int n); #include "display.h" /* region.c */ -extern int killregion(int f, int n); -extern int copyregion(int f, int n); -extern int lowerregion(int f, int n); -extern int upperregion(int f, int n); -extern int getregion(struct region *rp); +#include "region.h" /* posix.c */ -extern void ttopen(void); -extern void ttclose(void); -extern int ttputc(int c); -extern void ttflush(void); -extern int ttgetc(void); -extern int typahead(void); +#include "posix.h" /* input.c */ #include "input.h" /* bind.c */ -extern int help(int f, int n); -extern int deskey(int f, int n); -extern int bindtokey(int f, int n); -extern int unbindkey(int f, int n); -extern int unbindchar(int c); -extern int desbind(int f, int n); -extern int apro(int f, int n); -extern int buildlist(int type, char *mstring); -extern int strinc(char *source, char *sub); -extern unsigned int getckey(int mflag); -extern int startup(char *sfname); -char *flook( const char *fname, int hflag) ; -extern void cmdstr(int c, char *seq); -extern fn_t getbind(int c); -extern char *getfname(fn_t); -extern fn_t fncmatch(char *); -extern unsigned int stock(char *keyname); -extern char *transbind(char *skey); +#include "bind.h" /* buffer.c */ -extern int usebuffer(int f, int n); -extern int nextbuffer(int f, int n); -extern int swbuffer(struct buffer *bp); -extern int killbuffer(int f, int n); -extern int zotbuf(struct buffer *bp); -extern int namebuffer(int f, int n); -extern int listbuffers(int f, int n); -extern int makelist(int iflag); -extern void ltoa(char *buf, int width, long num); -extern int addline(char *text); -extern int anycb(void); -extern int bclear(struct buffer *bp); -extern int unmark(int f, int n); -/* Lookup a buffer by name. */ -extern struct buffer *bfind(char *bname, int cflag, int bflag); +#include "buffer.h" /* file.c */ #include "file.h" /* exec.c */ -extern int namedcmd(int f, int n); -extern int execcmd(int f, int n); -extern int docmd(char *cline); -extern char *token(char *src, char *tok, int size); -extern int macarg(char *tok); -extern int nextarg(char *prompt, char *buffer, int size, int terminator); -extern int storemac(int f, int n); -extern int storeproc(int f, int n); -extern int execproc(int f, int n); -extern int execbuf(int f, int n); -extern int dobuf(struct buffer *bp); -extern void freewhile(struct while_block *wp); -extern int execfile(int f, int n); -extern int dofile(char *fname); -extern int cbuf(int f, int n, int bufnum); -extern int cbuf1(int f, int n); -extern int cbuf2(int f, int n); -extern int cbuf3(int f, int n); -extern int cbuf4(int f, int n); -extern int cbuf5(int f, int n); -extern int cbuf6(int f, int n); -extern int cbuf7(int f, int n); -extern int cbuf8(int f, int n); -extern int cbuf9(int f, int n); -extern int cbuf10(int f, int n); -extern int cbuf11(int f, int n); -extern int cbuf12(int f, int n); -extern int cbuf13(int f, int n); -extern int cbuf14(int f, int n); -extern int cbuf15(int f, int n); -extern int cbuf16(int f, int n); -extern int cbuf17(int f, int n); -extern int cbuf18(int f, int n); -extern int cbuf19(int f, int n); -extern int cbuf20(int f, int n); -extern int cbuf21(int f, int n); -extern int cbuf22(int f, int n); -extern int cbuf23(int f, int n); -extern int cbuf24(int f, int n); -extern int cbuf25(int f, int n); -extern int cbuf26(int f, int n); -extern int cbuf27(int f, int n); -extern int cbuf28(int f, int n); -extern int cbuf29(int f, int n); -extern int cbuf30(int f, int n); -extern int cbuf31(int f, int n); -extern int cbuf32(int f, int n); -extern int cbuf33(int f, int n); -extern int cbuf34(int f, int n); -extern int cbuf35(int f, int n); -extern int cbuf36(int f, int n); -extern int cbuf37(int f, int n); -extern int cbuf38(int f, int n); -extern int cbuf39(int f, int n); -extern int cbuf40(int f, int n); +#include "exec.h" /* spawn.c */ -extern int spawncli(int f, int n); -extern int bktoshell(int f, int n); -extern void rtfrmshell(void); -extern int spawn(int f, int n); -extern int execprg(int f, int n); -extern int pipecmd(int f, int n); -extern int filter_buffer(int f, int n); -extern int sys(char *cmd); -extern int shellprog(char *cmd); -extern int execprog(char *cmd); +#include "spawn.h" /* search.c */ -extern int forwsearch(int f, int n); -extern int forwhunt(int f, int n); -extern int backsearch(int f, int n); -extern int backhunt(int f, int n); -extern int mcscanner(struct magic *mcpatrn, int direct, int beg_or_end); -extern int scanner(const char *patrn, int direct, int beg_or_end); -extern int eq(unsigned char bc, unsigned char pc); -extern void savematch(void); -extern void rvstrcpy(char *rvstr, char *str); -extern int sreplace(int f, int n); -extern int qreplace(int f, int n); -extern int delins(int dlength, char *instr, int use_meta); -extern int expandp(char *srcstr, char *deststr, int maxlength); -extern int boundry(struct line *curline, int curoff, int dir); -extern void mcclear(void); -extern void rmcclear(void); +#include "search.h" /* isearch.c */ -extern int risearch(int f, int n); -extern int fisearch(int f, int n); -extern int isearch(int f, int n); -extern int checknext(char chr, char *patrn, int dir); -extern int scanmore(char *patrn, int dir); -extern int match_pat(char *patrn); -extern int promptpattern(char *prompt); -extern int get_char(void); -extern int uneat(void); -extern void reeat(int c); +#include "isearch.h" /* eval.c */ -extern void varinit(void); -extern char *gtfun(char *fname); -extern char *gtusr(char *vname); -extern char *gtenv(char *vname); -extern char *getkill(void); -extern int setvar(int f, int n); -extern void findvar(char *var, struct variable_description *vd, int size); -extern int svar(struct variable_description *var, char *value); -extern char *itoa(int i); -extern int gettyp(char *token); -extern char *getval(char *token); -extern int stol(char *val); -extern char *ltos(int val); -extern char *mkupper(char *str); -extern char *mklower(char *str); -extern int abs(int x); -extern int ernd(void); -extern int sindex(char *source, char *pattern); -extern char *xlat(char *source, char *lookup, char *trans); +#include "eval.h" /* lock.c */ -extern int lockchk(char *fname); -extern int lockrel(void); -extern int lock(char *fname); -extern int unlock(char *fname); -extern void lckerror(char *errstr); +#include "lock.h" /* pklock.c */ -extern char *dolock(char *fname); -extern char *undolock(char *fname); +#include "pklock.h" + +#endif diff --git a/eval.c b/eval.c index 41a94c3..2e39c28 100644 --- a/eval.c +++ b/eval.c @@ -1,3 +1,5 @@ +#include "eval.h" + /* eval.c * * Expression evaluation functions diff --git a/eval.h b/eval.h new file mode 100644 index 0000000..cc44b37 --- /dev/null +++ b/eval.h @@ -0,0 +1,26 @@ +#ifndef _EVAL_H_ +#define _EVAL_H_ + +#include "estruct.h" + +void varinit( void) ; +char *gtfun( char *fname) ; +char *gtusr( char *vname) ; +char *gtenv( char *vname) ; +char *getkill( void) ; +int setvar( int f, int n) ; +void findvar( char *var, struct variable_description *vd, int size) ; +int svar( struct variable_description *var, char *value) ; +char *itoa( int i) ; +int gettyp( char *token) ; +char *getval( char *token) ; +int stol( char *val) ; +char *ltos( int val) ; +char *mkupper( char *str) ; +char *mklower( char *str) ; +int abs( int x) ; +int ernd( void) ; +int sindex( char *source, char *pattern) ; +char *xlat( char *source, char *lookup, char *trans) ; + +#endif diff --git a/exec.c b/exec.c index 2937966..6ac8919 100644 --- a/exec.c +++ b/exec.c @@ -1,3 +1,6 @@ +/* exec.c -- implements exec.h */ +#include "exec.h" + /* exec.c * * This file is for functions dealing with execution of diff --git a/exec.h b/exec.h new file mode 100644 index 0000000..e0b8082 --- /dev/null +++ b/exec.h @@ -0,0 +1,62 @@ +#ifndef _EXEC_H_ +#define _EXEC_H_ + +#include "estruct.h" + +int namedcmd( int f, int n) ; +int execcmd( int f, int n) ; +int docmd( char *cline) ; +char *token( char *src, char *tok, int size) ; +int macarg( char *tok) ; +int nextarg( char *prompt, char *buffer, int size, int terminator) ; +int storemac( int f, int n) ; +int storeproc( int f, int n) ; +int execproc( int f, int n) ; +int execbuf( int f, int n) ; +int dobuf( struct buffer *bp) ; +void freewhile( struct while_block *wp) ; +int execfile( int f, int n) ; +int dofile( char *fname) ; +int cbuf( int f, int n, int bufnum) ; +int cbuf1( int f, int n) ; +int cbuf2( int f, int n) ; +int cbuf3( int f, int n) ; +int cbuf4( int f, int n) ; +int cbuf5( int f, int n) ; +int cbuf6( int f, int n) ; +int cbuf7( int f, int n) ; +int cbuf8( int f, int n) ; +int cbuf9( int f, int n) ; +int cbuf10( int f, int n) ; +int cbuf11( int f, int n) ; +int cbuf12( int f, int n) ; +int cbuf13( int f, int n) ; +int cbuf14( int f, int n) ; +int cbuf15( int f, int n) ; +int cbuf16( int f, int n) ; +int cbuf17( int f, int n) ; +int cbuf18( int f, int n) ; +int cbuf19( int f, int n) ; +int cbuf20( int f, int n) ; +int cbuf21( int f, int n) ; +int cbuf22( int f, int n) ; +int cbuf23( int f, int n) ; +int cbuf24( int f, int n) ; +int cbuf25( int f, int n) ; +int cbuf26( int f, int n) ; +int cbuf27( int f, int n) ; +int cbuf28( int f, int n) ; +int cbuf29( int f, int n) ; +int cbuf30( int f, int n) ; +int cbuf31( int f, int n) ; +int cbuf32( int f, int n) ; +int cbuf33( int f, int n) ; +int cbuf34( int f, int n) ; +int cbuf35( int f, int n) ; +int cbuf36( int f, int n) ; +int cbuf37( int f, int n) ; +int cbuf38( int f, int n) ; +int cbuf39( int f, int n) ; +int cbuf40( int f, int n) ; + +#endif diff --git a/isearch.c b/isearch.c index dcc408b..0fbe9e6 100644 --- a/isearch.c +++ b/isearch.c @@ -1,3 +1,5 @@ +#include "isearch.h" + /* isearch.c * * The functions in this file implement commands that perform incremental diff --git a/isearch.h b/isearch.h new file mode 100644 index 0000000..86e0b13 --- /dev/null +++ b/isearch.h @@ -0,0 +1,11 @@ +int risearch( int f, int n) ; +int fisearch( int f, int n) ; +int isearch( int f, int n) ; +int checknext( char chr, char *patrn, int dir) ; +int scanmore( char *patrn, int dir) ; +int match_pat( char *patrn) ; +int promptpattern( char *prompt) ; +int get_char( void) ; +int uneat( void) ; +void reeat( int c) ; + diff --git a/lock.c b/lock.c index dce53a7..753f9ef 100644 --- a/lock.c +++ b/lock.c @@ -1,3 +1,5 @@ +#include "lock.h" + /* LOCK.C * * File locking command routines diff --git a/lock.h b/lock.h new file mode 100644 index 0000000..b1f9d75 --- /dev/null +++ b/lock.h @@ -0,0 +1,6 @@ +int lockchk( char *fname) ; +int lockrel( void) ; +int lock( char *fname) ; +int unlock( char *fname) ; +void lckerror( char *errstr) ; + diff --git a/pklock.c b/pklock.c index dc30b76..51cdd28 100644 --- a/pklock.c +++ b/pklock.c @@ -1,3 +1,5 @@ +#include "pklock.h" + /* PKLOCK.C * * locking routines as modified by Petri Kutvonen diff --git a/pklock.h b/pklock.h new file mode 100644 index 0000000..fd91c1c --- /dev/null +++ b/pklock.h @@ -0,0 +1,3 @@ +char *dolock( char *fname) ; +char *undolock( char *fname) ; + diff --git a/posix.c b/posix.c index 0a723b8..8412333 100644 --- a/posix.c +++ b/posix.c @@ -1,3 +1,6 @@ +/* posix.c -- implements posix.h */ +#include "posix.h" + /* posix.c * * The functions in this file negotiate with the operating system for diff --git a/posix.h b/posix.h new file mode 100644 index 0000000..fd4c891 --- /dev/null +++ b/posix.h @@ -0,0 +1,11 @@ +#ifndef _POSIX_H_ +#define _POSIX_H_ + +void ttopen( void) ; +void ttclose( void) ; +int ttputc( int c) ; +void ttflush( void) ; +int ttgetc( void) ; +int typahead( void) ; + +#endif diff --git a/random.c b/random.c index 455661d..5a2321e 100644 --- a/random.c +++ b/random.c @@ -1,3 +1,6 @@ +/* random.c -- implements random.h */ +#include "random.h" + /* random.c * * This file contains the command processing functions for a number of diff --git a/random.h b/random.h new file mode 100644 index 0000000..db30655 --- /dev/null +++ b/random.h @@ -0,0 +1,39 @@ +#ifndef _RANDOM_H_ +#define _RANDOM_H_ + +extern int tabsize ; /* Tab size (0: use real tabs). */ + +int setfillcol( int f, int n) ; +int showcpos( int f, int n) ; +int getcline( void) ; +int getccol( int bflg) ; +int setccol( int pos) ; +int twiddle( int f, int n) ; +int quote( int f, int n) ; +int insert_tab( int f, int n) ; +int detab( int f, int n) ; +int entab( int f, int n) ; +int trim( int f, int n) ; +int openline( int f, int n) ; +int insert_newline( int f, int n) ; +int cinsert( void) ; +int insbrace( int n, int c) ; +int inspound( void) ; +int deblank( int f, int n) ; +int indent( int f, int n) ; +int forwdel( int f, int n) ; +int backdel( int f, int n) ; +int killtext( int f, int n) ; +int setemode( int f, int n) ; +int delmode( int f, int n) ; +int setgmode( int f, int n) ; +int delgmode( int f, int n) ; +int adjustmode( int kind, int global) ; +int clrmes( int f, int n) ; +int writemsg( int f, int n) ; +int getfence( int f, int n) ; +int fmatch( int ch) ; +int istring( int f, int n) ; +int ovstring( int f, int n) ; + +#endif diff --git a/region.c b/region.c index 5190f86..c523ae9 100644 --- a/region.c +++ b/region.c @@ -1,3 +1,6 @@ +/* region.c -- implements region.h */ +#include "region.h" + /* region.c * * The routines in this file deal with the region, that magic space diff --git a/region.h b/region.h new file mode 100644 index 0000000..bd98247 --- /dev/null +++ b/region.h @@ -0,0 +1,12 @@ +#ifndef _REGION_H_ +#define _REGION_H_ + +#include "estruct.h" + +int killregion( int f, int n) ; +int copyregion( int f, int n) ; +int lowerregion( int f, int n) ; +int upperregion( int f, int n) ; +int getregion( struct region *rp) ; + +#endif diff --git a/search.c b/search.c index 6502f9b..91621b3 100644 --- a/search.c +++ b/search.c @@ -1,3 +1,6 @@ +/* search.c -- implements search.h */ +#include "search.h" + /* search.c * * The functions in this file implement commands that search in the forward diff --git a/search.h b/search.h new file mode 100644 index 0000000..040a437 --- /dev/null +++ b/search.h @@ -0,0 +1,23 @@ +#ifndef _SEARCH_H_ +#define _SEARCH_H_ + +#include "estruct.h" + +int forwsearch( int f, int n) ; +int forwhunt( int f, int n) ; +int backsearch( int f, int n) ; +int backhunt( int f, int n) ; +int mcscanner( struct magic *mcpatrn, int direct, int beg_or_end) ; +int scanner( const char *patrn, int direct, int beg_or_end) ; +int eq( unsigned char bc, unsigned char pc) ; +void savematch( void) ; +void rvstrcpy( char *rvstr, char *str) ; +int sreplace( int f, int n) ; +int qreplace( int f, int n) ; +int delins( int dlength, char *instr, int use_meta) ; +int expandp( char *srcstr, char *deststr, int maxlength) ; +int boundry( struct line *curline, int curoff, int dir) ; +void mcclear( void) ; +void rmcclear( void) ; + +#endif diff --git a/spawn.c b/spawn.c index e0d4471..29a9129 100644 --- a/spawn.c +++ b/spawn.c @@ -1,3 +1,6 @@ +/* spawn.c -- implements spawn.h */ +#include "spawn.h" + /* spawn.c * * Various operating system access commands. diff --git a/spawn.h b/spawn.h new file mode 100644 index 0000000..3ce690d --- /dev/null +++ b/spawn.h @@ -0,0 +1,11 @@ +int spawncli( int f, int n) ; +int bktoshell( int f, int n) ; +void rtfrmshell( void) ; +int spawn( int f, int n) ; +int execprg( int f, int n) ; +int pipecmd( int f, int n) ; +int filter_buffer( int f, int n) ; +int sys( char *cmd) ; +int shellprog( char *cmd) ; +int execprog( char *cmd) ; + diff --git a/word.c b/word.c index 83cfe9b..fdd952b 100644 --- a/word.c +++ b/word.c @@ -1,3 +1,6 @@ +/* word.c -- implements word.h */ +#include "word.h" + /* word.c * * The routines in this file implement commands that work word or a diff --git a/word.h b/word.h new file mode 100644 index 0000000..2d0316d --- /dev/null +++ b/word.h @@ -0,0 +1,18 @@ +#ifndef _WORD_H_ +#define _WORD_H_ + +int wrapword( int f, int n) ; +int backword( int f, int n) ; +int forwword( int f, int n) ; +int upperword( int f, int n) ; +int lowerword( int f, int n) ; +int capword( int f, int n) ; +int delfword( int f, int n) ; +int delbword( int f, int n) ; +int inword( void) ; +int fillpara( int f, int n) ; +int justpara( int f, int n) ; +int killpara( int f, int n) ; +int wordcount( int f, int n) ; + +#endif From 548973517bf07f293a1faa3dccd3c3fa6110a6b4 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Mon, 20 May 2013 15:16:19 +0800 Subject: [PATCH 032/193] termio and posix implement same prototypes. --- Makefile | 8 ++++---- efunc.h | 2 +- posix.c | 4 ++-- termio.c | 4 +++- posix.h => termio.h | 4 ++-- 5 files changed, 12 insertions(+), 10 deletions(-) rename posix.h => termio.h (78%) diff --git a/Makefile b/Makefile index 96bd554..7a80b1f 100644 --- a/Makefile +++ b/Makefile @@ -30,8 +30,8 @@ OBJ=basic.o bind.o buffer.o crypt.o display.o eval.o exec.o \ HDR=basic.h bind.h buffer.h crypt.h display.h ebind.h edef.h efunc.h \ estruct.h eval.h exec.h file.h fileio.h input.h isearch.h line.h \ - lock.h main.h pklock.h posix.h random.h region.h search.h spawn.h \ - utf8.h version.h window.h word.h wrapper.h + lock.h main.h pklock.h random.h region.h search.h spawn.h \ + termio.h utf8.h version.h window.h word.h wrapper.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -151,13 +151,13 @@ lock.o: lock.c lock.h estruct.h edef.h main.o: main.c main.h estruct.h crypt.h efunc.h edef.h ebind.h version.h names.o: names.c estruct.h crypt.h edef.h efunc.h line.h pklock.o: pklock.c pklock.h estruct.h -posix.o: posix.c posix.h estruct.h utf8.h +posix.o: posix.c termio.h estruct.h utf8.h random.o: random.c random.h estruct.h edef.h region.o: region.c region.h estruct.h edef.h search.o: search.c search.h estruct.h edef.h spawn.o: spawn.c spawn.h estruct.h edef.h tcap.o: tcap.c estruct.h edef.h -termio.o: termio.c estruct.h edef.h +termio.o: termio.c termio.h estruct.h edef.h utf8.o: utf8.c utf8.h vmsvt.o: vmsvt.c estruct.h edef.h vt52.o: vt52.c estruct.h edef.h diff --git a/efunc.h b/efunc.h index 55e09c0..3a76de5 100644 --- a/efunc.h +++ b/efunc.h @@ -36,7 +36,7 @@ #include "region.h" /* posix.c */ -#include "posix.h" +#include "termio.h" /* input.c */ #include "input.h" diff --git a/posix.c b/posix.c index 8412333..d014315 100644 --- a/posix.c +++ b/posix.c @@ -1,5 +1,5 @@ -/* posix.c -- implements posix.h */ -#include "posix.h" +/* posix.c -- implements termio.h */ +#include "termio.h" /* posix.c * diff --git a/termio.c b/termio.c index ac6d583..b262609 100644 --- a/termio.c +++ b/termio.c @@ -1,3 +1,4 @@ +#include "termio.h" /* TERMIO.C * @@ -273,7 +274,7 @@ void ttclose(void) * On CPM terminal I/O unbuffered, so we just write the byte out. Ditto on * MS-DOS (use the very very raw console output routine). */ -void ttputc( int c) { +int ttputc( int c) { #if VMS if (nobuf >= NOBUF) ttflush(); @@ -287,6 +288,7 @@ void ttputc( int c) { #if V7 | USG | BSD fputc(c, stdout); #endif + return 0 ; } /* diff --git a/posix.h b/termio.h similarity index 78% rename from posix.h rename to termio.h index fd4c891..5f41f92 100644 --- a/posix.h +++ b/termio.h @@ -1,5 +1,5 @@ -#ifndef _POSIX_H_ -#define _POSIX_H_ +#ifndef _TERMIO_H_ +#define _TERMIO_H_ void ttopen( void) ; void ttclose( void) ; From 255cab18b3d44938617aeef40ae45bb98c06a16c Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sat, 25 May 2013 11:57:27 +0800 Subject: [PATCH 033/193] lock only for BSD or SVR4 --- efunc.h | 4 ++++ lock.h | 8 ++++++++ pklock.h | 8 ++++++++ 3 files changed, 20 insertions(+) diff --git a/efunc.h b/efunc.h index 3a76de5..661c473 100644 --- a/efunc.h +++ b/efunc.h @@ -65,10 +65,14 @@ /* eval.c */ #include "eval.h" +#if BSD | SVR4 /* lock.c */ #include "lock.h" +#if (FILOCK && BSD) || SVR4 /* pklock.c */ #include "pklock.h" +#endif +#endif #endif diff --git a/lock.h b/lock.h index b1f9d75..1183a10 100644 --- a/lock.h +++ b/lock.h @@ -1,6 +1,14 @@ +#ifndef _LOCK_H_ +#define _LOCK_H_ + +#if BSD | SVR4 + int lockchk( char *fname) ; int lockrel( void) ; int lock( char *fname) ; int unlock( char *fname) ; void lckerror( char *errstr) ; +#endif + +#endif diff --git a/pklock.h b/pklock.h index fd91c1c..a75ac02 100644 --- a/pklock.h +++ b/pklock.h @@ -1,3 +1,11 @@ +#ifndef _PKLOCK_H_ +#define _PKLOCK_H_ + +#if (FILOCK && BSD) || SVR4 + char *dolock( char *fname) ; char *undolock( char *fname) ; +#endif + +#endif From ba277c5573f771a64024e359bb0a14fd99332fc8 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sat, 25 May 2013 12:28:17 +0800 Subject: [PATCH 034/193] remove file from efunc. --- bind.c | 1 + buffer.c | 1 + ebind.h | 1 + efunc.h | 3 --- exec.c | 1 + names.c | 1 + spawn.c | 1 + 7 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bind.c b/bind.c index 6b59eb3..51805f9 100644 --- a/bind.c +++ b/bind.c @@ -15,6 +15,7 @@ #include "estruct.h" #include "edef.h" #include "efunc.h" +#include "file.h" #include "fileio.h" #include "line.h" diff --git a/buffer.c b/buffer.c index a66587b..fdb751f 100644 --- a/buffer.c +++ b/buffer.c @@ -17,6 +17,7 @@ #include "estruct.h" #include "edef.h" #include "efunc.h" +#include "file.h" #include "line.h" /* diff --git a/ebind.h b/ebind.h index 85c3870..8bbc5ce 100644 --- a/ebind.h +++ b/ebind.h @@ -9,6 +9,7 @@ #define EBIND_H_ #include "crypt.h" +#include "file.h" #include "line.h" /* diff --git a/efunc.h b/efunc.h index 661c473..5e5fec8 100644 --- a/efunc.h +++ b/efunc.h @@ -47,9 +47,6 @@ /* buffer.c */ #include "buffer.h" -/* file.c */ -#include "file.h" - /* exec.c */ #include "exec.h" diff --git a/exec.c b/exec.c index 6ac8919..b612e82 100644 --- a/exec.c +++ b/exec.c @@ -15,6 +15,7 @@ #include "estruct.h" #include "edef.h" #include "efunc.h" +#include "file.h" #include "line.h" /* diff --git a/names.c b/names.c index d2962d9..0b6931b 100644 --- a/names.c +++ b/names.c @@ -9,6 +9,7 @@ #include "estruct.h" #include "edef.h" #include "efunc.h" +#include "file.h" #include "line.h" struct name_bind names[] = { diff --git a/spawn.c b/spawn.c index 29a9129..13018f5 100644 --- a/spawn.c +++ b/spawn.c @@ -14,6 +14,7 @@ #include "estruct.h" #include "edef.h" #include "efunc.h" +#include "file.h" #if VMS #define EFN 0 /* Event flag. */ From 7ede4aa6d88a435bc0502387a501213d58160d63 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sat, 25 May 2013 12:37:03 +0800 Subject: [PATCH 035/193] remove exec from efunc. --- bind.c | 1 + ebind.h | 1 + efunc.h | 3 --- eval.c | 1 + input.c | 1 + names.c | 1 + 6 files changed, 5 insertions(+), 3 deletions(-) diff --git a/bind.c b/bind.c index 51805f9..8313f1d 100644 --- a/bind.c +++ b/bind.c @@ -15,6 +15,7 @@ #include "estruct.h" #include "edef.h" #include "efunc.h" +#include "exec.h" #include "file.h" #include "fileio.h" #include "line.h" diff --git a/ebind.h b/ebind.h index 8bbc5ce..74570f0 100644 --- a/ebind.h +++ b/ebind.h @@ -9,6 +9,7 @@ #define EBIND_H_ #include "crypt.h" +#include "exec.h" #include "file.h" #include "line.h" diff --git a/efunc.h b/efunc.h index 5e5fec8..acdb627 100644 --- a/efunc.h +++ b/efunc.h @@ -47,9 +47,6 @@ /* buffer.c */ #include "buffer.h" -/* exec.c */ -#include "exec.h" - /* spawn.c */ #include "spawn.h" diff --git a/eval.c b/eval.c index 2e39c28..13e98a9 100644 --- a/eval.c +++ b/eval.c @@ -13,6 +13,7 @@ #include "estruct.h" #include "edef.h" #include "efunc.h" +#include "exec.h" #include "fileio.h" #include "line.h" #include "version.h" diff --git a/input.c b/input.c index cd1f88c..198a8f1 100644 --- a/input.c +++ b/input.c @@ -16,6 +16,7 @@ #include "estruct.h" #include "edef.h" #include "efunc.h" +#include "exec.h" #include "wrapper.h" #if PKCODE diff --git a/names.c b/names.c index 0b6931b..f8b36ca 100644 --- a/names.c +++ b/names.c @@ -5,6 +5,7 @@ * function. */ +#include "exec.h" #include "crypt.h" #include "estruct.h" #include "edef.h" From 4ab2e37ecbf74f3bfab6751fbdd75f34efdff48a Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sat, 25 May 2013 12:40:35 +0800 Subject: [PATCH 036/193] remove spawn from efunc. --- ebind.h | 1 + efunc.h | 3 --- names.c | 1 + 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ebind.h b/ebind.h index 74570f0..906fc99 100644 --- a/ebind.h +++ b/ebind.h @@ -12,6 +12,7 @@ #include "exec.h" #include "file.h" #include "line.h" +#include "spawn.h" /* * Command table. diff --git a/efunc.h b/efunc.h index acdb627..922e5e9 100644 --- a/efunc.h +++ b/efunc.h @@ -47,9 +47,6 @@ /* buffer.c */ #include "buffer.h" -/* spawn.c */ -#include "spawn.h" - /* search.c */ #include "search.h" diff --git a/names.c b/names.c index f8b36ca..4f00aec 100644 --- a/names.c +++ b/names.c @@ -12,6 +12,7 @@ #include "efunc.h" #include "file.h" #include "line.h" +#include "spawn.h" struct name_bind names[] = { {"abort-command", ctrlg}, From 1428d9e2aabf6c67152a4297cf74ad5f5af52c87 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 28 May 2013 12:22:31 +0800 Subject: [PATCH 037/193] Remove search from efunc. --- ebind.h | 1 + efunc.h | 3 --- eval.c | 1 + isearch.c | 1 + names.c | 1 + random.c | 1 + 6 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ebind.h b/ebind.h index 906fc99..2eab1b6 100644 --- a/ebind.h +++ b/ebind.h @@ -12,6 +12,7 @@ #include "exec.h" #include "file.h" #include "line.h" +#include "search.h" #include "spawn.h" /* diff --git a/efunc.h b/efunc.h index 922e5e9..4b7ef22 100644 --- a/efunc.h +++ b/efunc.h @@ -47,9 +47,6 @@ /* buffer.c */ #include "buffer.h" -/* search.c */ -#include "search.h" - /* isearch.c */ #include "isearch.h" diff --git a/eval.c b/eval.c index 13e98a9..d80513a 100644 --- a/eval.c +++ b/eval.c @@ -16,6 +16,7 @@ #include "exec.h" #include "fileio.h" #include "line.h" +#include "search.h" #include "version.h" #define MAXVARS 255 diff --git a/isearch.c b/isearch.c index 0fbe9e6..97375f7 100644 --- a/isearch.c +++ b/isearch.c @@ -30,6 +30,7 @@ #include "edef.h" #include "efunc.h" #include "line.h" +#include "search.h" #if ISRCH diff --git a/names.c b/names.c index 4f00aec..94e82b5 100644 --- a/names.c +++ b/names.c @@ -12,6 +12,7 @@ #include "efunc.h" #include "file.h" #include "line.h" +#include "search.h" #include "spawn.h" struct name_bind names[] = { diff --git a/random.c b/random.c index 5a2321e..a2c8357 100644 --- a/random.c +++ b/random.c @@ -15,6 +15,7 @@ #include "edef.h" #include "efunc.h" #include "line.h" +#include "search.h" int tabsize; /* Tab size (0: use real tabs) */ From 886adf1b69ef8a2a6c13fcef66d359f036b50dac Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 28 May 2013 12:25:59 +0800 Subject: [PATCH 038/193] Remove isearch from efunc. --- ebind.h | 1 + efunc.h | 3 --- names.c | 1 + 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ebind.h b/ebind.h index 2eab1b6..e650970 100644 --- a/ebind.h +++ b/ebind.h @@ -11,6 +11,7 @@ #include "crypt.h" #include "exec.h" #include "file.h" +#include "isearch.h" #include "line.h" #include "search.h" #include "spawn.h" diff --git a/efunc.h b/efunc.h index 4b7ef22..d32cd27 100644 --- a/efunc.h +++ b/efunc.h @@ -47,9 +47,6 @@ /* buffer.c */ #include "buffer.h" -/* isearch.c */ -#include "isearch.h" - /* eval.c */ #include "eval.h" diff --git a/names.c b/names.c index 94e82b5..e2bcffd 100644 --- a/names.c +++ b/names.c @@ -11,6 +11,7 @@ #include "edef.h" #include "efunc.h" #include "file.h" +#include "isearch.h" #include "line.h" #include "search.h" #include "spawn.h" From f1a0771bfcb6502f58e7fe2ffa9e146fba4c7298 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 28 May 2013 12:37:04 +0800 Subject: [PATCH 039/193] Remove random from efunc. --- basic.c | 1 + ebind.h | 1 + efunc.h | 3 --- eval.c | 1 + line.c | 1 + names.c | 1 + word.c | 1 + 7 files changed, 6 insertions(+), 3 deletions(-) diff --git a/basic.c b/basic.c index edfb6eb..69d0c92 100644 --- a/basic.c +++ b/basic.c @@ -19,6 +19,7 @@ #include "edef.h" #include "efunc.h" #include "line.h" +#include "random.h" #include "utf8.h" /* diff --git a/ebind.h b/ebind.h index e650970..f527d8f 100644 --- a/ebind.h +++ b/ebind.h @@ -13,6 +13,7 @@ #include "file.h" #include "isearch.h" #include "line.h" +#include "random.h" #include "search.h" #include "spawn.h" diff --git a/efunc.h b/efunc.h index d32cd27..129857a 100644 --- a/efunc.h +++ b/efunc.h @@ -23,9 +23,6 @@ /* basic.c */ #include "basic.h" -/* random.c */ -#include "random.h" - /* main.c */ #include "main.h" diff --git a/eval.c b/eval.c index d80513a..d90e25a 100644 --- a/eval.c +++ b/eval.c @@ -16,6 +16,7 @@ #include "exec.h" #include "fileio.h" #include "line.h" +#include "random.h" #include "search.h" #include "version.h" diff --git a/line.c b/line.c index 172c9cd..b7a8151 100644 --- a/line.c +++ b/line.c @@ -20,6 +20,7 @@ #include "estruct.h" #include "edef.h" #include "efunc.h" +#include "random.h" #include "utf8.h" #define BLOCK_SIZE 16 /* Line block chunk size. */ diff --git a/names.c b/names.c index e2bcffd..f8a498a 100644 --- a/names.c +++ b/names.c @@ -13,6 +13,7 @@ #include "file.h" #include "isearch.h" #include "line.h" +#include "random.h" #include "search.h" #include "spawn.h" diff --git a/word.c b/word.c index fdd952b..e333ccd 100644 --- a/word.c +++ b/word.c @@ -16,6 +16,7 @@ #include "edef.h" #include "efunc.h" #include "line.h" +#include "random.h" /* Word wrap on n-spaces. Back-over whatever precedes the point on the current * line and stop on the first word-break or the beginning of the line. If we From 4f075262229adf95c35b89ada0232a3a1ef66f18 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 28 May 2013 12:42:06 +0800 Subject: [PATCH 040/193] Remove word from efunc. --- basic.c | 1 + ebind.h | 1 + efunc.h | 3 --- names.c | 1 + 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/basic.c b/basic.c index 69d0c92..2447355 100644 --- a/basic.c +++ b/basic.c @@ -21,6 +21,7 @@ #include "line.h" #include "random.h" #include "utf8.h" +#include "word.h" /* * This routine, given a pointer to a struct line, and the current cursor goal diff --git a/ebind.h b/ebind.h index f527d8f..5c3af81 100644 --- a/ebind.h +++ b/ebind.h @@ -16,6 +16,7 @@ #include "random.h" #include "search.h" #include "spawn.h" +#include "word.h" /* * Command table. diff --git a/efunc.h b/efunc.h index 129857a..9b79dfb 100644 --- a/efunc.h +++ b/efunc.h @@ -14,9 +14,6 @@ /* External function declarations. */ -/* word.c */ -#include "word.h" - /* window.c */ #include "window.h" diff --git a/names.c b/names.c index f8a498a..3c35bad 100644 --- a/names.c +++ b/names.c @@ -16,6 +16,7 @@ #include "random.h" #include "search.h" #include "spawn.h" +#include "word.h" struct name_bind names[] = { {"abort-command", ctrlg}, From dce5f2239cba39ed8b54a594e8a07b9f81660999 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 28 May 2013 12:47:48 +0800 Subject: [PATCH 041/193] Remove window from efunc. --- bind.c | 1 + buffer.c | 1 + ebind.h | 1 + efunc.h | 3 --- eval.c | 1 + file.c | 1 + names.c | 1 + spawn.c | 1 + 8 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bind.c b/bind.c index 8313f1d..580362c 100644 --- a/bind.c +++ b/bind.c @@ -19,6 +19,7 @@ #include "file.h" #include "fileio.h" #include "line.h" +#include "window.h" /* possible names and paths of help files under different OSs */ diff --git a/buffer.c b/buffer.c index fdb751f..7fe79e7 100644 --- a/buffer.c +++ b/buffer.c @@ -19,6 +19,7 @@ #include "efunc.h" #include "file.h" #include "line.h" +#include "window.h" /* * Attach a buffer to a window. The diff --git a/ebind.h b/ebind.h index 5c3af81..4ee5fa9 100644 --- a/ebind.h +++ b/ebind.h @@ -16,6 +16,7 @@ #include "random.h" #include "search.h" #include "spawn.h" +#include "window.h" #include "word.h" /* diff --git a/efunc.h b/efunc.h index 9b79dfb..1c20d8a 100644 --- a/efunc.h +++ b/efunc.h @@ -14,9 +14,6 @@ /* External function declarations. */ -/* window.c */ -#include "window.h" - /* basic.c */ #include "basic.h" diff --git a/eval.c b/eval.c index d90e25a..d757a50 100644 --- a/eval.c +++ b/eval.c @@ -19,6 +19,7 @@ #include "random.h" #include "search.h" #include "version.h" +#include "window.h" #define MAXVARS 255 diff --git a/file.c b/file.c index 463b0ca..463ab58 100644 --- a/file.c +++ b/file.c @@ -23,6 +23,7 @@ #include "input.h" #include "line.h" #include "main.h" +#include "window.h" #if defined(PKCODE) /* Max number of lines from one file. */ diff --git a/names.c b/names.c index 3c35bad..11c8155 100644 --- a/names.c +++ b/names.c @@ -16,6 +16,7 @@ #include "random.h" #include "search.h" #include "spawn.h" +#include "window.h" #include "word.h" struct name_bind names[] = { diff --git a/spawn.c b/spawn.c index 13018f5..185e46d 100644 --- a/spawn.c +++ b/spawn.c @@ -15,6 +15,7 @@ #include "edef.h" #include "efunc.h" #include "file.h" +#include "window.h" #if VMS #define EFN 0 /* Event flag. */ From 0b093b8228176b6335316ccb731cef7c5a49a890 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 28 May 2013 12:59:40 +0800 Subject: [PATCH 042/193] Remove main from efunc. --- bind.c | 1 + efunc.h | 3 --- input.c | 1 + line.c | 1 + names.c | 1 + random.c | 1 + region.c | 1 + search.c | 1 + spawn.c | 1 + word.c | 1 + 10 files changed, 9 insertions(+), 3 deletions(-) diff --git a/bind.c b/bind.c index 580362c..289b404 100644 --- a/bind.c +++ b/bind.c @@ -19,6 +19,7 @@ #include "file.h" #include "fileio.h" #include "line.h" +#include "main.h" #include "window.h" diff --git a/efunc.h b/efunc.h index 1c20d8a..7d6ba93 100644 --- a/efunc.h +++ b/efunc.h @@ -17,9 +17,6 @@ /* basic.c */ #include "basic.h" -/* main.c */ -#include "main.h" - /* display.c */ #include "display.h" diff --git a/input.c b/input.c index 198a8f1..b3f6a19 100644 --- a/input.c +++ b/input.c @@ -17,6 +17,7 @@ #include "edef.h" #include "efunc.h" #include "exec.h" +#include "main.h" #include "wrapper.h" #if PKCODE diff --git a/line.c b/line.c index b7a8151..926e56d 100644 --- a/line.c +++ b/line.c @@ -20,6 +20,7 @@ #include "estruct.h" #include "edef.h" #include "efunc.h" +#include "main.h" #include "random.h" #include "utf8.h" diff --git a/names.c b/names.c index 11c8155..94aab57 100644 --- a/names.c +++ b/names.c @@ -13,6 +13,7 @@ #include "file.h" #include "isearch.h" #include "line.h" +#include "main.h" #include "random.h" #include "search.h" #include "spawn.h" diff --git a/random.c b/random.c index a2c8357..638bb27 100644 --- a/random.c +++ b/random.c @@ -15,6 +15,7 @@ #include "edef.h" #include "efunc.h" #include "line.h" +#include "main.h" #include "search.h" int tabsize; /* Tab size (0: use real tabs) */ diff --git a/region.c b/region.c index c523ae9..cea8d5c 100644 --- a/region.c +++ b/region.c @@ -16,6 +16,7 @@ #include "edef.h" #include "efunc.h" #include "line.h" +#include "main.h" /* * Kill the region. Ask "getregion" diff --git a/search.c b/search.c index 91621b3..25e3628 100644 --- a/search.c +++ b/search.c @@ -66,6 +66,7 @@ #include "edef.h" #include "efunc.h" #include "line.h" +#include "main.h" #if defined(MAGIC) /* diff --git a/spawn.c b/spawn.c index 185e46d..4bc53fd 100644 --- a/spawn.c +++ b/spawn.c @@ -15,6 +15,7 @@ #include "edef.h" #include "efunc.h" #include "file.h" +#include "main.h" #include "window.h" #if VMS diff --git a/word.c b/word.c index e333ccd..d957563 100644 --- a/word.c +++ b/word.c @@ -16,6 +16,7 @@ #include "edef.h" #include "efunc.h" #include "line.h" +#include "main.h" #include "random.h" /* Word wrap on n-spaces. Back-over whatever precedes the point on the current From b971f265fc42e942371e392528d9610f63ae9e53 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 28 May 2013 13:04:39 +0800 Subject: [PATCH 043/193] Remove bind from efunc. --- ebind.h | 1 + efunc.h | 3 --- eval.c | 1 + exec.c | 1 + input.c | 1 + names.c | 1 + 6 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ebind.h b/ebind.h index 4ee5fa9..5014e42 100644 --- a/ebind.h +++ b/ebind.h @@ -8,6 +8,7 @@ #ifndef EBIND_H_ #define EBIND_H_ +#include "bind.h" #include "crypt.h" #include "exec.h" #include "file.h" diff --git a/efunc.h b/efunc.h index 7d6ba93..d9fe775 100644 --- a/efunc.h +++ b/efunc.h @@ -29,9 +29,6 @@ /* input.c */ #include "input.h" -/* bind.c */ -#include "bind.h" - /* buffer.c */ #include "buffer.h" diff --git a/eval.c b/eval.c index d757a50..a36fbc4 100644 --- a/eval.c +++ b/eval.c @@ -10,6 +10,7 @@ #include +#include "bind.h" #include "estruct.h" #include "edef.h" #include "efunc.h" diff --git a/exec.c b/exec.c index b612e82..460ccf2 100644 --- a/exec.c +++ b/exec.c @@ -12,6 +12,7 @@ #include +#include "bind.h" #include "estruct.h" #include "edef.h" #include "efunc.h" diff --git a/input.c b/input.c index b3f6a19..f35ac3b 100644 --- a/input.c +++ b/input.c @@ -13,6 +13,7 @@ #include #include +#include "bind.h" #include "estruct.h" #include "edef.h" #include "efunc.h" diff --git a/names.c b/names.c index 94aab57..71db22c 100644 --- a/names.c +++ b/names.c @@ -5,6 +5,7 @@ * function. */ +#include "bind.h" #include "exec.h" #include "crypt.h" #include "estruct.h" From 7816f9650801ea5a599b1e8ec9e386e5256fc126 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 28 May 2013 13:18:47 +0800 Subject: [PATCH 044/193] Remove region from efunc. --- ebind.h | 1 + efunc.h | 3 --- names.c | 1 + word.c | 1 + 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ebind.h b/ebind.h index 5014e42..3b17491 100644 --- a/ebind.h +++ b/ebind.h @@ -15,6 +15,7 @@ #include "isearch.h" #include "line.h" #include "random.h" +#include "region.h" #include "search.h" #include "spawn.h" #include "window.h" diff --git a/efunc.h b/efunc.h index d9fe775..a95753a 100644 --- a/efunc.h +++ b/efunc.h @@ -20,9 +20,6 @@ /* display.c */ #include "display.h" -/* region.c */ -#include "region.h" - /* posix.c */ #include "termio.h" diff --git a/names.c b/names.c index 71db22c..769d02f 100644 --- a/names.c +++ b/names.c @@ -15,6 +15,7 @@ #include "isearch.h" #include "line.h" #include "main.h" +#include "region.h" #include "random.h" #include "search.h" #include "spawn.h" diff --git a/word.c b/word.c index d957563..51742f7 100644 --- a/word.c +++ b/word.c @@ -18,6 +18,7 @@ #include "line.h" #include "main.h" #include "random.h" +#include "region.h" /* Word wrap on n-spaces. Back-over whatever precedes the point on the current * line and stop on the first word-break or the beginning of the line. If we From a61307aa59cb70c7432f2786caf7cb6165102711 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 28 May 2013 13:25:14 +0800 Subject: [PATCH 045/193] Remove buffer from efunc. --- bind.c | 1 + ebind.h | 1 + efunc.h | 3 --- eval.c | 1 + exec.c | 1 + file.c | 1 + names.c | 1 + spawn.c | 1 + 8 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bind.c b/bind.c index 289b404..0755d6f 100644 --- a/bind.c +++ b/bind.c @@ -12,6 +12,7 @@ #include +#include "buffer.h" #include "estruct.h" #include "edef.h" #include "efunc.h" diff --git a/ebind.h b/ebind.h index 3b17491..8b5d02a 100644 --- a/ebind.h +++ b/ebind.h @@ -9,6 +9,7 @@ #define EBIND_H_ #include "bind.h" +#include "buffer.h" #include "crypt.h" #include "exec.h" #include "file.h" diff --git a/efunc.h b/efunc.h index a95753a..1247fa5 100644 --- a/efunc.h +++ b/efunc.h @@ -26,9 +26,6 @@ /* input.c */ #include "input.h" -/* buffer.c */ -#include "buffer.h" - /* eval.c */ #include "eval.h" diff --git a/eval.c b/eval.c index a36fbc4..4724f1d 100644 --- a/eval.c +++ b/eval.c @@ -10,6 +10,7 @@ #include +#include "buffer.h" #include "bind.h" #include "estruct.h" #include "edef.h" diff --git a/exec.c b/exec.c index 460ccf2..e9cf890 100644 --- a/exec.c +++ b/exec.c @@ -12,6 +12,7 @@ #include +#include "buffer.h" #include "bind.h" #include "estruct.h" #include "edef.h" diff --git a/file.c b/file.c index 463ab58..a7fa9c0 100644 --- a/file.c +++ b/file.c @@ -14,6 +14,7 @@ #include #include +#include "buffer.h" #include "crypt.h" #include "display.h" #include "estruct.h" diff --git a/names.c b/names.c index 769d02f..45b3c54 100644 --- a/names.c +++ b/names.c @@ -5,6 +5,7 @@ * function. */ +#include "buffer.h" #include "bind.h" #include "exec.h" #include "crypt.h" diff --git a/spawn.c b/spawn.c index 4bc53fd..20ba51b 100644 --- a/spawn.c +++ b/spawn.c @@ -11,6 +11,7 @@ #include #include +#include "buffer.h" #include "estruct.h" #include "edef.h" #include "efunc.h" From 77c9fd09ade7e2d8af47f8c5d935689feb896d9f Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 28 May 2013 13:35:09 +0800 Subject: [PATCH 046/193] Remove eval from efunc. --- ebind.h | 1 + efunc.h | 3 --- exec.c | 1 + names.c | 1 + 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ebind.h b/ebind.h index 8b5d02a..240f8b4 100644 --- a/ebind.h +++ b/ebind.h @@ -11,6 +11,7 @@ #include "bind.h" #include "buffer.h" #include "crypt.h" +#include "eval.h" #include "exec.h" #include "file.h" #include "isearch.h" diff --git a/efunc.h b/efunc.h index 1247fa5..db59459 100644 --- a/efunc.h +++ b/efunc.h @@ -26,9 +26,6 @@ /* input.c */ #include "input.h" -/* eval.c */ -#include "eval.h" - #if BSD | SVR4 /* lock.c */ #include "lock.h" diff --git a/exec.c b/exec.c index e9cf890..2420f62 100644 --- a/exec.c +++ b/exec.c @@ -17,6 +17,7 @@ #include "estruct.h" #include "edef.h" #include "efunc.h" +#include "eval.h" #include "file.h" #include "line.h" diff --git a/names.c b/names.c index 45b3c54..721dd8d 100644 --- a/names.c +++ b/names.c @@ -7,6 +7,7 @@ #include "buffer.h" #include "bind.h" +#include "eval.h" #include "exec.h" #include "crypt.h" #include "estruct.h" From 539f327271bfd2e8e4ce94a74bb32d0863c58043 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 28 May 2013 14:46:44 +0800 Subject: [PATCH 047/193] Remove input from efunc. --- basic.c | 1 + bind.c | 1 + buffer.c | 1 + efunc.h | 3 --- eval.c | 1 + exec.c | 1 + isearch.c | 1 + main.c | 1 + random.c | 1 + search.c | 1 + spawn.c | 1 + 11 files changed, 10 insertions(+), 3 deletions(-) diff --git a/basic.c b/basic.c index 2447355..52894c8 100644 --- a/basic.c +++ b/basic.c @@ -18,6 +18,7 @@ #include "estruct.h" #include "edef.h" #include "efunc.h" +#include "input.h" #include "line.h" #include "random.h" #include "utf8.h" diff --git a/bind.c b/bind.c index 0755d6f..eaabf6d 100644 --- a/bind.c +++ b/bind.c @@ -19,6 +19,7 @@ #include "exec.h" #include "file.h" #include "fileio.h" +#include "input.h" #include "line.h" #include "main.h" #include "window.h" diff --git a/buffer.c b/buffer.c index 7fe79e7..395e1cd 100644 --- a/buffer.c +++ b/buffer.c @@ -18,6 +18,7 @@ #include "edef.h" #include "efunc.h" #include "file.h" +#include "input.h" #include "line.h" #include "window.h" diff --git a/efunc.h b/efunc.h index db59459..d015ed1 100644 --- a/efunc.h +++ b/efunc.h @@ -23,9 +23,6 @@ /* posix.c */ #include "termio.h" -/* input.c */ -#include "input.h" - #if BSD | SVR4 /* lock.c */ #include "lock.h" diff --git a/eval.c b/eval.c index 4724f1d..bc1bcc0 100644 --- a/eval.c +++ b/eval.c @@ -17,6 +17,7 @@ #include "efunc.h" #include "exec.h" #include "fileio.h" +#include "input.h" #include "line.h" #include "random.h" #include "search.h" diff --git a/exec.c b/exec.c index 2420f62..0cd7347 100644 --- a/exec.c +++ b/exec.c @@ -19,6 +19,7 @@ #include "efunc.h" #include "eval.h" #include "file.h" +#include "input.h" #include "line.h" /* diff --git a/isearch.c b/isearch.c index 97375f7..f7634e6 100644 --- a/isearch.c +++ b/isearch.c @@ -29,6 +29,7 @@ #include "estruct.h" #include "edef.h" #include "efunc.h" +#include "input.h" #include "line.h" #include "search.h" diff --git a/main.c b/main.c index 776ba7e..5b8ee6a 100644 --- a/main.c +++ b/main.c @@ -68,6 +68,7 @@ #include "edef.h" /* Global definitions. */ #include "efunc.h" /* Function declarations and name table. */ #include "ebind.h" /* Default key bindings. */ +#include "input.h" #include "version.h" /* For MSDOS, increase the default stack space. */ diff --git a/random.c b/random.c index 638bb27..6a186bc 100644 --- a/random.c +++ b/random.c @@ -14,6 +14,7 @@ #include "estruct.h" #include "edef.h" #include "efunc.h" +#include "input.h" #include "line.h" #include "main.h" #include "search.h" diff --git a/search.c b/search.c index 25e3628..464b3e4 100644 --- a/search.c +++ b/search.c @@ -65,6 +65,7 @@ #include "estruct.h" #include "edef.h" #include "efunc.h" +#include "input.h" #include "line.h" #include "main.h" diff --git a/spawn.c b/spawn.c index 20ba51b..499a18d 100644 --- a/spawn.c +++ b/spawn.c @@ -16,6 +16,7 @@ #include "edef.h" #include "efunc.h" #include "file.h" +#include "input.h" #include "main.h" #include "window.h" From 9c2c4b763587c5cbef42be2d03c1ad55c75cc1b6 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 28 May 2013 14:57:03 +0800 Subject: [PATCH 048/193] Remove display from efunc. --- basic.c | 1 + bind.c | 1 + buffer.c | 1 + efunc.h | 3 --- eval.c | 1 + exec.c | 1 + input.c | 1 + isearch.c | 1 + line.c | 1 + main.c | 1 + names.c | 1 + random.c | 1 + region.c | 1 + search.c | 1 + spawn.c | 1 + tcap.c | 1 + word.c | 1 + 17 files changed, 16 insertions(+), 3 deletions(-) diff --git a/basic.c b/basic.c index 52894c8..469a817 100644 --- a/basic.c +++ b/basic.c @@ -15,6 +15,7 @@ #include +#include "display.h" #include "estruct.h" #include "edef.h" #include "efunc.h" diff --git a/bind.c b/bind.c index eaabf6d..8c97fed 100644 --- a/bind.c +++ b/bind.c @@ -13,6 +13,7 @@ #include #include "buffer.h" +#include "display.h" #include "estruct.h" #include "edef.h" #include "efunc.h" diff --git a/buffer.c b/buffer.c index 395e1cd..81e95a2 100644 --- a/buffer.c +++ b/buffer.c @@ -14,6 +14,7 @@ #include +#include "display.h" #include "estruct.h" #include "edef.h" #include "efunc.h" diff --git a/efunc.h b/efunc.h index d015ed1..2955a72 100644 --- a/efunc.h +++ b/efunc.h @@ -17,9 +17,6 @@ /* basic.c */ #include "basic.h" -/* display.c */ -#include "display.h" - /* posix.c */ #include "termio.h" diff --git a/eval.c b/eval.c index bc1bcc0..dec4e31 100644 --- a/eval.c +++ b/eval.c @@ -12,6 +12,7 @@ #include "buffer.h" #include "bind.h" +#include "display.h" #include "estruct.h" #include "edef.h" #include "efunc.h" diff --git a/exec.c b/exec.c index 0cd7347..3acc4f7 100644 --- a/exec.c +++ b/exec.c @@ -14,6 +14,7 @@ #include "buffer.h" #include "bind.h" +#include "display.h" #include "estruct.h" #include "edef.h" #include "efunc.h" diff --git a/input.c b/input.c index f35ac3b..277e749 100644 --- a/input.c +++ b/input.c @@ -14,6 +14,7 @@ #include #include "bind.h" +#include "display.h" #include "estruct.h" #include "edef.h" #include "efunc.h" diff --git a/isearch.c b/isearch.c index f7634e6..9ae9ed9 100644 --- a/isearch.c +++ b/isearch.c @@ -26,6 +26,7 @@ #include +#include "display.h" #include "estruct.h" #include "edef.h" #include "efunc.h" diff --git a/line.c b/line.c index 926e56d..0edd906 100644 --- a/line.c +++ b/line.c @@ -17,6 +17,7 @@ #include +#include "display.h" #include "estruct.h" #include "edef.h" #include "efunc.h" diff --git a/main.c b/main.c index 5b8ee6a..0cddbb1 100644 --- a/main.c +++ b/main.c @@ -64,6 +64,7 @@ #define maindef #include "crypt.h" +#include "display.h" #include "estruct.h" /* Global structures and defines. */ #include "edef.h" /* Global definitions. */ #include "efunc.h" /* Function declarations and name table. */ diff --git a/names.c b/names.c index 721dd8d..6fe8692 100644 --- a/names.c +++ b/names.c @@ -7,6 +7,7 @@ #include "buffer.h" #include "bind.h" +#include "display.h" #include "eval.h" #include "exec.h" #include "crypt.h" diff --git a/random.c b/random.c index 6a186bc..2751f81 100644 --- a/random.c +++ b/random.c @@ -11,6 +11,7 @@ #include +#include "display.h" #include "estruct.h" #include "edef.h" #include "efunc.h" diff --git a/region.c b/region.c index cea8d5c..008fdee 100644 --- a/region.c +++ b/region.c @@ -12,6 +12,7 @@ #include +#include "display.h" #include "estruct.h" #include "edef.h" #include "efunc.h" diff --git a/search.c b/search.c index 464b3e4..4bd316e 100644 --- a/search.c +++ b/search.c @@ -62,6 +62,7 @@ #include +#include "display.h" #include "estruct.h" #include "edef.h" #include "efunc.h" diff --git a/spawn.c b/spawn.c index 499a18d..6a69288 100644 --- a/spawn.c +++ b/spawn.c @@ -12,6 +12,7 @@ #include #include "buffer.h" +#include "display.h" #include "estruct.h" #include "edef.h" #include "efunc.h" diff --git a/tcap.c b/tcap.c index 1c6b4d4..5f55e95 100644 --- a/tcap.c +++ b/tcap.c @@ -23,6 +23,7 @@ #include +#include "display.h" #include "estruct.h" #include "edef.h" #include "efunc.h" diff --git a/word.c b/word.c index 51742f7..b3cc28b 100644 --- a/word.c +++ b/word.c @@ -12,6 +12,7 @@ #include +#include "display.h" #include "estruct.h" #include "edef.h" #include "efunc.h" From 4e24edf71595afd515ad8495d55be67d4eca410b Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 28 May 2013 15:10:16 +0800 Subject: [PATCH 049/193] Remove basic from efunc. --- ebind.h | 1 + efunc.h | 3 --- eval.c | 3 ++- isearch.c | 1 + line.c | 1 + names.c | 3 ++- random.c | 1 + search.c | 1 + word.c | 1 + 9 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ebind.h b/ebind.h index 240f8b4..e27a586 100644 --- a/ebind.h +++ b/ebind.h @@ -8,6 +8,7 @@ #ifndef EBIND_H_ #define EBIND_H_ +#include "basic.h" #include "bind.h" #include "buffer.h" #include "crypt.h" diff --git a/efunc.h b/efunc.h index 2955a72..45c905a 100644 --- a/efunc.h +++ b/efunc.h @@ -14,9 +14,6 @@ /* External function declarations. */ -/* basic.c */ -#include "basic.h" - /* posix.c */ #include "termio.h" diff --git a/eval.c b/eval.c index dec4e31..06ccb5e 100644 --- a/eval.c +++ b/eval.c @@ -10,8 +10,9 @@ #include -#include "buffer.h" +#include "basic.h" #include "bind.h" +#include "buffer.h" #include "display.h" #include "estruct.h" #include "edef.h" diff --git a/isearch.c b/isearch.c index 9ae9ed9..413ba9f 100644 --- a/isearch.c +++ b/isearch.c @@ -26,6 +26,7 @@ #include +#include "basic.h" #include "display.h" #include "estruct.h" #include "edef.h" diff --git a/line.c b/line.c index 0edd906..0ba021f 100644 --- a/line.c +++ b/line.c @@ -17,6 +17,7 @@ #include +#include "basic.h" #include "display.h" #include "estruct.h" #include "edef.h" diff --git a/names.c b/names.c index 6fe8692..33933c9 100644 --- a/names.c +++ b/names.c @@ -5,8 +5,9 @@ * function. */ -#include "buffer.h" +#include "basic.h" #include "bind.h" +#include "buffer.h" #include "display.h" #include "eval.h" #include "exec.h" diff --git a/random.c b/random.c index 2751f81..0684837 100644 --- a/random.c +++ b/random.c @@ -11,6 +11,7 @@ #include +#include "basic.h" #include "display.h" #include "estruct.h" #include "edef.h" diff --git a/search.c b/search.c index 4bd316e..0f6d336 100644 --- a/search.c +++ b/search.c @@ -62,6 +62,7 @@ #include +#include "basic.h" #include "display.h" #include "estruct.h" #include "edef.h" diff --git a/word.c b/word.c index b3cc28b..8267e91 100644 --- a/word.c +++ b/word.c @@ -12,6 +12,7 @@ #include +#include "basic.h" #include "display.h" #include "estruct.h" #include "edef.h" From e1cb42e0aafdeab022926f9b967522bff1a97015 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 28 May 2013 15:17:15 +0800 Subject: [PATCH 050/193] Remove termio from efunc. --- efunc.h | 3 --- eval.c | 1 + main.c | 1 + tcap.c | 1 + 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/efunc.h b/efunc.h index 45c905a..12badbf 100644 --- a/efunc.h +++ b/efunc.h @@ -14,9 +14,6 @@ /* External function declarations. */ -/* posix.c */ -#include "termio.h" - #if BSD | SVR4 /* lock.c */ #include "lock.h" diff --git a/eval.c b/eval.c index 06ccb5e..523fe7b 100644 --- a/eval.c +++ b/eval.c @@ -23,6 +23,7 @@ #include "line.h" #include "random.h" #include "search.h" +#include "termio.h" #include "version.h" #include "window.h" diff --git a/main.c b/main.c index 0cddbb1..33dc44c 100644 --- a/main.c +++ b/main.c @@ -70,6 +70,7 @@ #include "efunc.h" /* Function declarations and name table. */ #include "ebind.h" /* Default key bindings. */ #include "input.h" +#include "termio.h" #include "version.h" /* For MSDOS, increase the default stack space. */ diff --git a/tcap.c b/tcap.c index 5f55e95..a9883ae 100644 --- a/tcap.c +++ b/tcap.c @@ -27,6 +27,7 @@ #include "estruct.h" #include "edef.h" #include "efunc.h" +#include "termio.h" #if TERMCAP From 04264b4d2703223902952bdd03c7b5cde385debb Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 28 May 2013 17:21:40 +0800 Subject: [PATCH 051/193] Start clean up of lock/pklock dependencies. --- display.c | 1 + efunc.h | 5 ----- lock.c | 7 +++++++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/display.c b/display.c index 1ac864c..164527f 100644 --- a/display.c +++ b/display.c @@ -20,6 +20,7 @@ #include "estruct.h" #include "edef.h" #include "line.h" +#include "termio.h" #include "version.h" #include "wrapper.h" #include "utf8.h" diff --git a/efunc.h b/efunc.h index 12badbf..f47bfd4 100644 --- a/efunc.h +++ b/efunc.h @@ -17,11 +17,6 @@ #if BSD | SVR4 /* lock.c */ #include "lock.h" - -#if (FILOCK && BSD) || SVR4 -/* pklock.c */ -#include "pklock.h" -#endif #endif #endif diff --git a/lock.c b/lock.c index 753f9ef..438731b 100644 --- a/lock.c +++ b/lock.c @@ -8,9 +8,16 @@ */ #include + +#include "display.h" #include "estruct.h" #include "edef.h" #include "efunc.h" +#include "input.h" + +#if (FILOCK && BSD) || SVR4 +#include "pklock.h" +#endif #if BSD | SVR4 #include From b321dce49ece894d74ac8d685f4e278da6799884 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 28 May 2013 17:40:01 +0800 Subject: [PATCH 052/193] Remove efunc as dependencies. --- Makefile | 4 ++-- basic.c | 1 - bind.c | 1 - buffer.c | 1 - eval.c | 1 - exec.c | 1 - file.c | 1 - input.c | 1 - isearch.c | 1 - line.c | 1 - lock.c | 1 - main.c | 1 - names.c | 1 - pklock.c | 1 - posix.c | 1 - random.c | 1 - region.c | 1 - search.c | 1 - spawn.c | 1 - tcap.c | 1 - word.c | 1 - 21 files changed, 2 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index 7a80b1f..015c91b 100644 --- a/Makefile +++ b/Makefile @@ -148,8 +148,8 @@ input.o: input.c input.h estruct.h edef.h isearch.o: isearch.c isearch.h estruct.h edef.h line.o: line.c line.h estruct.h edef.h lock.o: lock.c lock.h estruct.h edef.h -main.o: main.c main.h estruct.h crypt.h efunc.h edef.h ebind.h version.h -names.o: names.c estruct.h crypt.h edef.h efunc.h line.h +main.o: main.c main.h estruct.h crypt.h edef.h ebind.h version.h +names.o: names.c estruct.h crypt.h edef.h line.h pklock.o: pklock.c pklock.h estruct.h posix.o: posix.c termio.h estruct.h utf8.h random.o: random.c random.h estruct.h edef.h diff --git a/basic.c b/basic.c index 469a817..3705fd7 100644 --- a/basic.c +++ b/basic.c @@ -18,7 +18,6 @@ #include "display.h" #include "estruct.h" #include "edef.h" -#include "efunc.h" #include "input.h" #include "line.h" #include "random.h" diff --git a/bind.c b/bind.c index 8c97fed..285bd39 100644 --- a/bind.c +++ b/bind.c @@ -16,7 +16,6 @@ #include "display.h" #include "estruct.h" #include "edef.h" -#include "efunc.h" #include "exec.h" #include "file.h" #include "fileio.h" diff --git a/buffer.c b/buffer.c index 81e95a2..77b7bc2 100644 --- a/buffer.c +++ b/buffer.c @@ -17,7 +17,6 @@ #include "display.h" #include "estruct.h" #include "edef.h" -#include "efunc.h" #include "file.h" #include "input.h" #include "line.h" diff --git a/eval.c b/eval.c index 523fe7b..d809351 100644 --- a/eval.c +++ b/eval.c @@ -16,7 +16,6 @@ #include "display.h" #include "estruct.h" #include "edef.h" -#include "efunc.h" #include "exec.h" #include "fileio.h" #include "input.h" diff --git a/exec.c b/exec.c index 3acc4f7..e761206 100644 --- a/exec.c +++ b/exec.c @@ -17,7 +17,6 @@ #include "display.h" #include "estruct.h" #include "edef.h" -#include "efunc.h" #include "eval.h" #include "file.h" #include "input.h" diff --git a/file.c b/file.c index a7fa9c0..082df7e 100644 --- a/file.c +++ b/file.c @@ -19,7 +19,6 @@ #include "display.h" #include "estruct.h" #include "edef.h" -#include "efunc.h" #include "fileio.h" #include "input.h" #include "line.h" diff --git a/input.c b/input.c index 277e749..f817a8e 100644 --- a/input.c +++ b/input.c @@ -17,7 +17,6 @@ #include "display.h" #include "estruct.h" #include "edef.h" -#include "efunc.h" #include "exec.h" #include "main.h" #include "wrapper.h" diff --git a/isearch.c b/isearch.c index 413ba9f..7648ac2 100644 --- a/isearch.c +++ b/isearch.c @@ -30,7 +30,6 @@ #include "display.h" #include "estruct.h" #include "edef.h" -#include "efunc.h" #include "input.h" #include "line.h" #include "search.h" diff --git a/line.c b/line.c index 0ba021f..05cd944 100644 --- a/line.c +++ b/line.c @@ -21,7 +21,6 @@ #include "display.h" #include "estruct.h" #include "edef.h" -#include "efunc.h" #include "main.h" #include "random.h" #include "utf8.h" diff --git a/lock.c b/lock.c index 438731b..15d41f4 100644 --- a/lock.c +++ b/lock.c @@ -12,7 +12,6 @@ #include "display.h" #include "estruct.h" #include "edef.h" -#include "efunc.h" #include "input.h" #if (FILOCK && BSD) || SVR4 diff --git a/main.c b/main.c index 33dc44c..0bb70bf 100644 --- a/main.c +++ b/main.c @@ -67,7 +67,6 @@ #include "display.h" #include "estruct.h" /* Global structures and defines. */ #include "edef.h" /* Global definitions. */ -#include "efunc.h" /* Function declarations and name table. */ #include "ebind.h" /* Default key bindings. */ #include "input.h" #include "termio.h" diff --git a/names.c b/names.c index 33933c9..3a8629d 100644 --- a/names.c +++ b/names.c @@ -14,7 +14,6 @@ #include "crypt.h" #include "estruct.h" #include "edef.h" -#include "efunc.h" #include "file.h" #include "isearch.h" #include "line.h" diff --git a/pklock.c b/pklock.c index 51cdd28..976a3d2 100644 --- a/pklock.c +++ b/pklock.c @@ -7,7 +7,6 @@ #include "estruct.h" #include "edef.h" -#include "efunc.h" #if (FILOCK && BSD) || SVR4 #include diff --git a/posix.c b/posix.c index d014315..00b19be 100644 --- a/posix.c +++ b/posix.c @@ -24,7 +24,6 @@ #include "estruct.h" #include "edef.h" -#include "efunc.h" #include "utf8.h" /* Since Mac OS X's termios.h doesn't have the following 2 macros, define them. diff --git a/random.c b/random.c index 0684837..7ba83c1 100644 --- a/random.c +++ b/random.c @@ -15,7 +15,6 @@ #include "display.h" #include "estruct.h" #include "edef.h" -#include "efunc.h" #include "input.h" #include "line.h" #include "main.h" diff --git a/region.c b/region.c index 008fdee..68a4bc0 100644 --- a/region.c +++ b/region.c @@ -15,7 +15,6 @@ #include "display.h" #include "estruct.h" #include "edef.h" -#include "efunc.h" #include "line.h" #include "main.h" diff --git a/search.c b/search.c index 0f6d336..3651964 100644 --- a/search.c +++ b/search.c @@ -66,7 +66,6 @@ #include "display.h" #include "estruct.h" #include "edef.h" -#include "efunc.h" #include "input.h" #include "line.h" #include "main.h" diff --git a/spawn.c b/spawn.c index 6a69288..fc502b8 100644 --- a/spawn.c +++ b/spawn.c @@ -15,7 +15,6 @@ #include "display.h" #include "estruct.h" #include "edef.h" -#include "efunc.h" #include "file.h" #include "input.h" #include "main.h" diff --git a/tcap.c b/tcap.c index a9883ae..57e73a5 100644 --- a/tcap.c +++ b/tcap.c @@ -26,7 +26,6 @@ #include "display.h" #include "estruct.h" #include "edef.h" -#include "efunc.h" #include "termio.h" #if TERMCAP diff --git a/word.c b/word.c index 8267e91..a8ec144 100644 --- a/word.c +++ b/word.c @@ -16,7 +16,6 @@ #include "display.h" #include "estruct.h" #include "edef.h" -#include "efunc.h" #include "line.h" #include "main.h" #include "random.h" From 72f91dd131c7f287a7ca91c023609f710b2e40f4 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Thu, 30 May 2013 14:36:11 +0800 Subject: [PATCH 053/193] Reduce isearch exposed API. --- isearch.c | 27 +++++++++++++++++++-------- isearch.h | 9 --------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/isearch.c b/isearch.c index 7648ac2..39d2d70 100644 --- a/isearch.c +++ b/isearch.c @@ -34,6 +34,17 @@ #include "line.h" #include "search.h" + +static int isearch( int f, int n) ; +static int checknext( char chr, char *patrn, int dir) ; +static int scanmore( char *patrn, int dir) ; +static int match_pat( char *patrn) ; +static int promptpattern( char *prompt) ; +static int get_char( void) ; +static int uneat( void) ; +static void reeat( int c) ; + + #if ISRCH static int echo_char(int c, int col); @@ -143,7 +154,7 @@ int fisearch(int f, int n) * exists (or until the search is aborted). */ -int isearch(int f, int n) +static int isearch(int f, int n) { int status; /* Search status */ int col; /* prompt column */ @@ -283,7 +294,7 @@ int isearch(int f, int n) * char *patrn; The entire search string (incl chr) * int dir; Search direction */ -int checknext(char chr, char *patrn, int dir) /* Check next character in search string */ +static int checknext(char chr, char *patrn, int dir) /* Check next character in search string */ { struct line *curline; /* current line during scan */ int curoff; /* position within current line */ @@ -327,7 +338,7 @@ int checknext(char chr, char *patrn, int dir) /* Check next character in search * char *patrn; string to scan for * int dir; direction to search */ -int scanmore(char *patrn, int dir) /* search forward or back for a pattern */ +static int scanmore(char *patrn, int dir) /* search forward or back for a pattern */ { int sts; /* search status */ @@ -356,7 +367,7 @@ int scanmore(char *patrn, int dir) /* search forward or back for a pattern * * char *patrn; String to match to buffer */ -int match_pat(char *patrn) /* See if the pattern string matches string at "." */ +static int match_pat(char *patrn) /* See if the pattern string matches string at "." */ { int i; /* Generic loop index/offset */ int buffchar; /* character at current position */ @@ -388,7 +399,7 @@ int match_pat(char *patrn) /* See if the pattern string matches string at "." /* * Routine to prompt for I-Search string. */ -int promptpattern(char *prompt) +static int promptpattern(char *prompt) { char tpat[NPAT + 20]; @@ -455,7 +466,7 @@ static int echo_char(int c, int col) * Otherwise, we must be re-executing the command string, so just return the * next character. */ -int get_char(void) +static int get_char(void) { int c; /* A place to get a character */ @@ -486,7 +497,7 @@ int get_char(void) /* Come here on the next term.t_getchar call: */ -int uneat(void) +static int uneat(void) { int c; @@ -496,7 +507,7 @@ int uneat(void) return c; /* and return the last char */ } -void reeat(int c) +static void reeat(int c) { if (eaten_char != -1) /* If we've already been here */ return /*(NULL) */ ; /* Don't do it again */ diff --git a/isearch.h b/isearch.h index 86e0b13..a0ff176 100644 --- a/isearch.h +++ b/isearch.h @@ -1,11 +1,2 @@ int risearch( int f, int n) ; int fisearch( int f, int n) ; -int isearch( int f, int n) ; -int checknext( char chr, char *patrn, int dir) ; -int scanmore( char *patrn, int dir) ; -int match_pat( char *patrn) ; -int promptpattern( char *prompt) ; -int get_char( void) ; -int uneat( void) ; -void reeat( int c) ; - From 2ed4446758e3d9d4fb9ccc8d7677b29c24876123 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Thu, 30 May 2013 15:05:19 +0800 Subject: [PATCH 054/193] ebind as a module instead of include in main. --- Makefile | 8 ++++---- ebind.h => ebind.c | 9 +++------ main.c | 9 ++++++++- 3 files changed, 15 insertions(+), 11 deletions(-) rename ebind.h => ebind.c (98%) diff --git a/Makefile b/Makefile index 015c91b..79f64b4 100644 --- a/Makefile +++ b/Makefile @@ -16,19 +16,19 @@ uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') PROGRAM=ue -SRC=basic.c bind.c buffer.c crypt.c display.c eval.c exec.c \ +SRC=basic.c bind.c buffer.c crypt.c display.c ebind.c eval.c exec.c \ file.c fileio.c input.c isearch.c line.c lock.c main.c \ pklock.c posix.c random.c region.c search.c spawn.c tcap.c \ termio.c window.c word.c names.c globals.c \ wrapper.c utf8.c -OBJ=basic.o bind.o buffer.o crypt.o display.o eval.o exec.o \ +OBJ=basic.o bind.o buffer.o crypt.o display.o ebind.o eval.o exec.o \ file.o fileio.o input.o isearch.o line.o lock.o main.o \ pklock.o posix.o random.o region.o search.o spawn.o tcap.o \ termio.o window.o word.o names.o globals.o \ wrapper.o utf8.o -HDR=basic.h bind.h buffer.h crypt.h display.h ebind.h edef.h efunc.h \ +HDR=basic.h bind.h buffer.h crypt.h display.h edef.h efunc.h \ estruct.h eval.h exec.h file.h fileio.h input.h isearch.h line.h \ lock.h main.h pklock.h random.h region.h search.h spawn.h \ termio.h utf8.h version.h window.h word.h wrapper.h @@ -148,7 +148,7 @@ input.o: input.c input.h estruct.h edef.h isearch.o: isearch.c isearch.h estruct.h edef.h line.o: line.c line.h estruct.h edef.h lock.o: lock.c lock.h estruct.h edef.h -main.o: main.c main.h estruct.h crypt.h edef.h ebind.h version.h +main.o: main.c main.h estruct.h crypt.h edef.h version.h names.o: names.c estruct.h crypt.h edef.h line.h pklock.o: pklock.c pklock.h estruct.h posix.o: posix.c termio.h estruct.h utf8.h diff --git a/ebind.h b/ebind.c similarity index 98% rename from ebind.h rename to ebind.c index e27a586..deb3559 100644 --- a/ebind.h +++ b/ebind.c @@ -1,22 +1,21 @@ -/* ebind.h +/* ebind.c * * Initial default key to function bindings * * Modified by Petri Kutvonen */ -#ifndef EBIND_H_ -#define EBIND_H_ - #include "basic.h" #include "bind.h" #include "buffer.h" #include "crypt.h" +#include "estruct.h" #include "eval.h" #include "exec.h" #include "file.h" #include "isearch.h" #include "line.h" +#include "main.h" #include "random.h" #include "region.h" #include "search.h" @@ -435,5 +434,3 @@ struct key_tab keytab[NBINDS] = { {0, NULL} }; - -#endif /* EBIND_H_ */ diff --git a/main.c b/main.c index 0bb70bf..7525747 100644 --- a/main.c +++ b/main.c @@ -67,11 +67,18 @@ #include "display.h" #include "estruct.h" /* Global structures and defines. */ #include "edef.h" /* Global definitions. */ -#include "ebind.h" /* Default key bindings. */ #include "input.h" #include "termio.h" #include "version.h" +#include "basic.h" +#include "bind.h" +#include "buffer.h" +#include "eval.h" +#include "file.h" +#include "random.h" +#include "search.h" + /* For MSDOS, increase the default stack space. */ #if MSDOS & TURBO #if PKCODE From c4a5c31d42bbcc5a16505ff54506bedf04c832d6 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 31 May 2013 13:04:52 +0800 Subject: [PATCH 055/193] clarify ebind dependencies (only needed by bind). --- bind.c | 1 + ebind.c | 3 +++ ebind.h | 8 ++++++++ edef.h | 1 - estruct.h | 6 ------ 5 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 ebind.h diff --git a/bind.c b/bind.c index 285bd39..4db42ce 100644 --- a/bind.c +++ b/bind.c @@ -14,6 +14,7 @@ #include "buffer.h" #include "display.h" +#include "ebind.h" #include "estruct.h" #include "edef.h" #include "exec.h" diff --git a/ebind.c b/ebind.c index deb3559..560b36d 100644 --- a/ebind.c +++ b/ebind.c @@ -1,3 +1,6 @@ +/* ebind.c -- implements ebind.h */ +#include "ebind.h" + /* ebind.c * * Initial default key to function bindings diff --git a/ebind.h b/ebind.h new file mode 100644 index 0000000..af8ed2c --- /dev/null +++ b/ebind.h @@ -0,0 +1,8 @@ +/* Structure for the table of initial key bindings. */ +struct key_tab { + int k_code; /* Key code */ + int (*k_fp)(int, int); /* Routine to handle it */ +}; + +extern struct key_tab keytab[]; /* key bind to functions table */ + diff --git a/edef.h b/edef.h index b61b9f0..052ed90 100644 --- a/edef.h +++ b/edef.h @@ -33,7 +33,6 @@ extern int flickcode; /* do flicker supression? */ extern char *modename[]; /* text names of modes */ extern char *mode2name[]; /* text names of modes */ extern char modecode[]; /* letters to represent modes */ -extern struct key_tab keytab[]; /* key bind to functions table */ extern struct name_bind names[];/* name to function table */ extern int gmode; /* global editor mode */ extern int gflags; /* global control flag */ diff --git a/estruct.h b/estruct.h index 74acaca..0f34e72 100644 --- a/estruct.h +++ b/estruct.h @@ -561,12 +561,6 @@ struct terminal { #define TTbacg (*term.t_setback) #endif -/* Structure for the table of initial key bindings. */ -struct key_tab { - int k_code; /* Key code */ - int (*k_fp)(int, int); /* Routine to handle it */ -}; - /* Structure for the name binding table. */ struct name_bind { char *n_name; /* name of function key */ From cae7222493bb38180bf7ef42a22003e61225f64e Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 31 May 2013 13:18:10 +0800 Subject: [PATCH 056/193] Clarify names interface (only used in bind and input). --- bind.c | 1 + edef.h | 1 - estruct.h | 6 ------ input.c | 1 + names.c | 7 ++++--- names.h | 8 ++++++++ 6 files changed, 14 insertions(+), 10 deletions(-) create mode 100644 names.h diff --git a/bind.c b/bind.c index 4db42ce..534132b 100644 --- a/bind.c +++ b/bind.c @@ -23,6 +23,7 @@ #include "input.h" #include "line.h" #include "main.h" +#include "names.h" #include "window.h" diff --git a/edef.h b/edef.h index 052ed90..a70f71c 100644 --- a/edef.h +++ b/edef.h @@ -33,7 +33,6 @@ extern int flickcode; /* do flicker supression? */ extern char *modename[]; /* text names of modes */ extern char *mode2name[]; /* text names of modes */ extern char modecode[]; /* letters to represent modes */ -extern struct name_bind names[];/* name to function table */ extern int gmode; /* global editor mode */ extern int gflags; /* global control flag */ extern int gfcolor; /* global forgrnd color (white) */ diff --git a/estruct.h b/estruct.h index 0f34e72..dd7a83d 100644 --- a/estruct.h +++ b/estruct.h @@ -561,12 +561,6 @@ struct terminal { #define TTbacg (*term.t_setback) #endif -/* Structure for the name binding table. */ -struct name_bind { - char *n_name; /* name of function key */ - int (*n_func)(int, int); /* function name is bound to */ -}; - /* The editor holds deleted text chunks in the struct kill buffer. The * kill buffer is logically a stream of ascii characters, however * due to its unpredicatable size, it gets implemented as a linked diff --git a/input.c b/input.c index f817a8e..43291c4 100644 --- a/input.c +++ b/input.c @@ -19,6 +19,7 @@ #include "edef.h" #include "exec.h" #include "main.h" +#include "names.h" #include "wrapper.h" #if PKCODE diff --git a/names.c b/names.c index 3a8629d..17c9cf3 100644 --- a/names.c +++ b/names.c @@ -1,7 +1,10 @@ +/* names.c -- implements names.h */ +#include "names.h" + /* Name to function binding table. * * This table gives the names of all the bindable functions - * end their C function address. These are used for the bind-to-key + * and their C function address. These are used for the bind-to-key * function. */ @@ -12,8 +15,6 @@ #include "eval.h" #include "exec.h" #include "crypt.h" -#include "estruct.h" -#include "edef.h" #include "file.h" #include "isearch.h" #include "line.h" diff --git a/names.h b/names.h new file mode 100644 index 0000000..700b304 --- /dev/null +++ b/names.h @@ -0,0 +1,8 @@ +/* Structure for the name binding table. */ +struct name_bind { + char *n_name; /* name of function key */ + int (*n_func)(int, int); /* function name is bound to */ +}; + +extern struct name_bind names[];/* name to function table */ + From f210ed610b417d04c733b1c4227b69d0bdfeeda8 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 31 May 2013 14:27:49 +0800 Subject: [PATCH 057/193] cleanup bind & ebind dependencies to estruct & edef. --- Makefile | 9 +++++---- bind.c | 2 -- ebind.c | 1 - input.c | 2 -- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 79f64b4..1aad22b 100644 --- a/Makefile +++ b/Makefile @@ -28,9 +28,9 @@ OBJ=basic.o bind.o buffer.o crypt.o display.o ebind.o eval.o exec.o \ termio.o window.o word.o names.o globals.o \ wrapper.o utf8.o -HDR=basic.h bind.h buffer.h crypt.h display.h edef.h efunc.h \ +HDR=basic.h bind.h buffer.h crypt.h display.h ebind.h edef.h efunc.h \ estruct.h eval.h exec.h file.h fileio.h input.h isearch.h line.h \ - lock.h main.h pklock.h random.h region.h search.h spawn.h \ + lock.h main.h names.h pklock.h random.h region.h search.h spawn.h \ termio.h utf8.h version.h window.h word.h wrapper.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -135,10 +135,11 @@ depend: ${SRC} ansi.o: ansi.c estruct.h edef.h basic.o: basic.c basic.h estruct.h edef.h -bind.o: bind.c bind.h estruct.h edef.h fileio.h +bind.o: bind.c bind.h ebind.h fileio.h names.h buffer.o: buffer.c buffer.h estruct.h edef.h crypt.o: crypt.c crypt.h display.h estruct.h edef.h input.h display.o: display.c display.h estruct.h edef.h utf8.h version.h window.h +ebind.c: ebind.h eval.o: eval.c eval.h estruct.h edef.h version.h fileio.h exec.o: exec.c exec.h estruct.h edef.h file.o: file.c file.h crypt.h estruct.h edef.h fileio.h @@ -149,7 +150,7 @@ isearch.o: isearch.c isearch.h estruct.h edef.h line.o: line.c line.h estruct.h edef.h lock.o: lock.c lock.h estruct.h edef.h main.o: main.c main.h estruct.h crypt.h edef.h version.h -names.o: names.c estruct.h crypt.h edef.h line.h +names.o: names.c names.h crypt.h line.h pklock.o: pklock.c pklock.h estruct.h posix.o: posix.c termio.h estruct.h utf8.h random.o: random.c random.h estruct.h edef.h diff --git a/bind.c b/bind.c index 534132b..075f582 100644 --- a/bind.c +++ b/bind.c @@ -15,8 +15,6 @@ #include "buffer.h" #include "display.h" #include "ebind.h" -#include "estruct.h" -#include "edef.h" #include "exec.h" #include "file.h" #include "fileio.h" diff --git a/ebind.c b/ebind.c index 560b36d..2f2b33b 100644 --- a/ebind.c +++ b/ebind.c @@ -12,7 +12,6 @@ #include "bind.h" #include "buffer.h" #include "crypt.h" -#include "estruct.h" #include "eval.h" #include "exec.h" #include "file.h" diff --git a/input.c b/input.c index 43291c4..c0cd844 100644 --- a/input.c +++ b/input.c @@ -15,8 +15,6 @@ #include "bind.h" #include "display.h" -#include "estruct.h" -#include "edef.h" #include "exec.h" #include "main.h" #include "names.h" From 4348e9f757d55d0e9f0dbe3ea675ac7f2079a24e Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sat, 1 Jun 2013 11:18:29 +0800 Subject: [PATCH 058/193] restrict edinit visibility in main. --- main.c | 4 +++- main.h | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 7525747..4f9e636 100644 --- a/main.c +++ b/main.c @@ -105,6 +105,8 @@ extern void sizesignal(int); #endif #endif +static void edinit( char *bname) ; + static void version( void) { fputs( PROGRAM_NAME_LONG " version " VERSION "\n", stdout) ; } @@ -454,7 +456,7 @@ int main(int argc, char **argv) * as an argument, because the main routine may have been told to read in a * file by default, and we want the buffer name to be right. */ -void edinit(char *bname) +static void edinit(char *bname) { struct buffer *bp; struct window *wp; diff --git a/main.h b/main.h index 76758e1..db60001 100644 --- a/main.h +++ b/main.h @@ -1,7 +1,6 @@ #ifndef _MAIN_H_ #define _MAIN_H_ -void edinit( char *bname) ; int execute( int c, int f, int n) ; int quickexit( int f, int n) ; int quit( int f, int n) ; From 586026a867629865f1e0b43f7cbcdf8a106ecefd Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sat, 1 Jun 2013 11:39:15 +0800 Subject: [PATCH 059/193] make depend based on cc -MM. update Makefile by doing make depend. --- Makefile | 102 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 63 insertions(+), 39 deletions(-) diff --git a/Makefile b/Makefile index 1aad22b..8b475b5 100644 --- a/Makefile +++ b/Makefile @@ -28,9 +28,9 @@ OBJ=basic.o bind.o buffer.o crypt.o display.o ebind.o eval.o exec.o \ termio.o window.o word.o names.o globals.o \ wrapper.o utf8.o -HDR=basic.h bind.h buffer.h crypt.h display.h ebind.h edef.h efunc.h \ +HDR=basic.h bind.h buffer.h crypt.h display.h edef.h efunc.h \ estruct.h eval.h exec.h file.h fileio.h input.h isearch.h line.h \ - lock.h main.h names.h pklock.h random.h region.h search.h spawn.h \ + lock.h main.h pklock.h random.h region.h search.h spawn.h \ termio.h utf8.h version.h window.h word.h wrapper.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -110,12 +110,7 @@ source: depend: ${SRC} @for i in ${SRC}; do\ - cc ${DEFINES} -M $$i | sed -e 's, \./, ,' | grep -v '/usr/include' | \ - awk '{ if ($$1 != prev) { if (rec != "") print rec; \ - rec = $$0; prev = $$1; } \ - else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \ - else rec = rec " " $$2 } } \ - END { print rec }'; done >makedep + cc ${DEFINES} -MM $$i ; done >makedep @echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep @echo '$$r ./makedep' >>eddep @echo 'w' >>eddep @@ -127,44 +122,73 @@ depend: ${SRC} @echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >>makefile @echo '# see make depend above' >>makefile +# @for i in ${SRC}; do\ +# cc ${DEFINES} -M $$i | sed -e 's, \./, ,' | grep -v '/usr/include' | \ +# awk '{ if ($$1 != prev) { if (rec != "") print rec; \ +# rec = $$0; prev = $$1; } \ +# else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \ +# else rec = rec " " $$2 } } \ +# END { print rec }'; done >makedep + .c.o: $(E) " CC " $@ $(Q) ${CC} ${CFLAGS} ${DEFINES} -c $*.c # DO NOT DELETE THIS LINE -- make depend uses it -ansi.o: ansi.c estruct.h edef.h -basic.o: basic.c basic.h estruct.h edef.h -bind.o: bind.c bind.h ebind.h fileio.h names.h -buffer.o: buffer.c buffer.h estruct.h edef.h -crypt.o: crypt.c crypt.h display.h estruct.h edef.h input.h -display.o: display.c display.h estruct.h edef.h utf8.h version.h window.h -ebind.c: ebind.h -eval.o: eval.c eval.h estruct.h edef.h version.h fileio.h -exec.o: exec.c exec.h estruct.h edef.h -file.o: file.c file.h crypt.h estruct.h edef.h fileio.h -fileio.o: fileio.c fileio.h crypt.h display.h estruct.h edef.h -ibmpc.o: ibmpc.c estruct.h edef.h -input.o: input.c input.h estruct.h edef.h -isearch.o: isearch.c isearch.h estruct.h edef.h -line.o: line.c line.h estruct.h edef.h -lock.o: lock.c lock.h estruct.h edef.h -main.o: main.c main.h estruct.h crypt.h edef.h version.h -names.o: names.c names.h crypt.h line.h -pklock.o: pklock.c pklock.h estruct.h -posix.o: posix.c termio.h estruct.h utf8.h -random.o: random.c random.h estruct.h edef.h -region.o: region.c region.h estruct.h edef.h -search.o: search.c search.h estruct.h edef.h -spawn.o: spawn.c spawn.h estruct.h edef.h -tcap.o: tcap.c estruct.h edef.h -termio.o: termio.c termio.h estruct.h edef.h -utf8.o: utf8.c utf8.h -vmsvt.o: vmsvt.c estruct.h edef.h -vt52.o: vt52.c estruct.h edef.h -window.o: window.c window.h estruct.h edef.h basic.h display.h main.h line.h wrapper.h -word.o: word.c word.h estruct.h edef.h +basic.o: basic.c basic.h display.h estruct.h line.h utf8.h edef.h input.h \ + random.h word.h +bind.o: bind.c bind.h edef.h estruct.h line.h utf8.h buffer.h display.h \ + ebind.h exec.h file.h fileio.h input.h main.h names.h window.h +buffer.o: buffer.c buffer.h estruct.h line.h utf8.h display.h edef.h \ + file.h input.h window.h +crypt.o: crypt.c crypt.h display.h estruct.h line.h utf8.h edef.h input.h +display.o: display.c display.h estruct.h line.h utf8.h edef.h termio.h \ + version.h wrapper.h window.h +ebind.o: ebind.c ebind.h basic.h bind.h edef.h estruct.h line.h utf8.h \ + buffer.h crypt.h eval.h exec.h file.h isearch.h main.h random.h \ + region.h search.h spawn.h window.h word.h +eval.o: eval.c eval.h estruct.h line.h utf8.h basic.h bind.h edef.h \ + buffer.h display.h exec.h fileio.h input.h random.h search.h termio.h \ + version.h window.h +exec.o: exec.c exec.h estruct.h line.h utf8.h buffer.h bind.h edef.h \ + display.h eval.h file.h input.h +file.o: file.c file.h buffer.h estruct.h line.h utf8.h crypt.h display.h \ + edef.h fileio.h input.h main.h window.h +fileio.o: fileio.c fileio.h crypt.h display.h estruct.h line.h utf8.h \ + edef.h +input.o: input.c input.h edef.h estruct.h line.h utf8.h bind.h display.h \ + exec.h main.h names.h wrapper.h +isearch.o: isearch.c isearch.h basic.h display.h estruct.h line.h utf8.h \ + edef.h input.h search.h +line.o: line.c line.h utf8.h basic.h display.h estruct.h edef.h main.h \ + random.h +lock.o: lock.c lock.h display.h estruct.h line.h utf8.h edef.h input.h +main.o: main.c main.h crypt.h display.h estruct.h line.h utf8.h edef.h \ + input.h termio.h version.h basic.h bind.h buffer.h eval.h file.h \ + random.h search.h +pklock.o: pklock.c pklock.h estruct.h line.h utf8.h edef.h +posix.o: posix.c termio.h +random.o: random.c random.h basic.h display.h estruct.h line.h utf8.h \ + edef.h input.h main.h search.h +region.o: region.c region.h estruct.h line.h utf8.h display.h edef.h \ + main.h +search.o: search.c search.h estruct.h line.h utf8.h basic.h display.h \ + edef.h input.h main.h +spawn.o: spawn.c spawn.h buffer.h estruct.h line.h utf8.h display.h \ + edef.h file.h input.h main.h window.h +tcap.o: tcap.c display.h estruct.h line.h utf8.h edef.h termio.h +termio.o: termio.c termio.h estruct.h line.h utf8.h edef.h +window.o: window.c window.h estruct.h line.h utf8.h basic.h display.h \ + edef.h main.h wrapper.h +word.o: word.c word.h basic.h display.h estruct.h line.h utf8.h edef.h \ + main.h random.h region.h +names.o: names.c names.h basic.h bind.h edef.h estruct.h line.h utf8.h \ + buffer.h display.h eval.h exec.h crypt.h file.h isearch.h main.h \ + region.h random.h search.h spawn.h window.h word.h +globals.o: globals.c estruct.h line.h utf8.h edef.h wrapper.o: wrapper.c wrapper.h +utf8.o: utf8.c utf8.h # DEPENDENCIES MUST END AT END OF FILE # IF YOU PUT STUFF HERE IT WILL GO AWAY From 88fbe6bdff434a44861e2ddf376e075b4264c905 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sat, 1 Jun 2013 11:58:54 +0800 Subject: [PATCH 060/193] make source functional again. Update Makefile by running make source then make depend. --- Makefile | 41 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index 8b475b5..c404208 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,10 @@ -# makefile for emacs, updated Sun Apr 28 17:59:07 EET DST 1996 +# makefile for emacs, updated Sat, Jun 01, 2013 11:49:18 AM + +SRC=ansi.c basic.c bind.c buffer.c crypt.c display.c ebind.c eval.c exec.c file.c fileio.c globals.c ibmpc.c input.c isearch.c line.c lock.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c +OBJ=ansi.o basic.o bind.o buffer.o crypt.o display.o ebind.o eval.o exec.o file.o fileio.o globals.o ibmpc.o input.o isearch.o line.o lock.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o +HDR=basic.h bind.h buffer.h crypt.h display.h ebind.h edef.h efunc.h estruct.h eval.h exec.h file.h fileio.h input.h isearch.h line.h lock.h main.h names.h pklock.h random.h region.h search.h spawn.h termio.h utf8.h version.h window.h word.h wrapper.h + +# DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them # Make the build silent by default V = @@ -16,25 +22,6 @@ uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') PROGRAM=ue -SRC=basic.c bind.c buffer.c crypt.c display.c ebind.c eval.c exec.c \ - file.c fileio.c input.c isearch.c line.c lock.c main.c \ - pklock.c posix.c random.c region.c search.c spawn.c tcap.c \ - termio.c window.c word.c names.c globals.c \ - wrapper.c utf8.c - -OBJ=basic.o bind.o buffer.o crypt.o display.o ebind.o eval.o exec.o \ - file.o fileio.o input.o isearch.o line.o lock.o main.o \ - pklock.o posix.o random.o region.o search.o spawn.o tcap.o \ - termio.o window.o word.o names.o globals.o \ - wrapper.o utf8.o - -HDR=basic.h bind.h buffer.h crypt.h display.h edef.h efunc.h \ - estruct.h eval.h exec.h file.h fileio.h input.h isearch.h line.h \ - lock.h main.h pklock.h random.h region.h search.h spawn.h \ - termio.h utf8.h version.h window.h word.h wrapper.h - -# DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them - CC=gcc WARNINGS=-Wall -Wstrict-prototypes CFLAGS=-O2 $(WARNINGS) @@ -136,6 +123,7 @@ depend: ${SRC} # DO NOT DELETE THIS LINE -- make depend uses it +ansi.o: ansi.c estruct.h line.h utf8.h edef.h basic.o: basic.c basic.h display.h estruct.h line.h utf8.h edef.h input.h \ random.h word.h bind.o: bind.c bind.h edef.h estruct.h line.h utf8.h buffer.h display.h \ @@ -157,6 +145,8 @@ file.o: file.c file.h buffer.h estruct.h line.h utf8.h crypt.h display.h \ edef.h fileio.h input.h main.h window.h fileio.o: fileio.c fileio.h crypt.h display.h estruct.h line.h utf8.h \ edef.h +globals.o: globals.c estruct.h line.h utf8.h edef.h +ibmpc.o: ibmpc.c estruct.h line.h utf8.h edef.h input.o: input.c input.h edef.h estruct.h line.h utf8.h bind.h display.h \ exec.h main.h names.h wrapper.h isearch.o: isearch.c isearch.h basic.h display.h estruct.h line.h utf8.h \ @@ -167,6 +157,9 @@ lock.o: lock.c lock.h display.h estruct.h line.h utf8.h edef.h input.h main.o: main.c main.h crypt.h display.h estruct.h line.h utf8.h edef.h \ input.h termio.h version.h basic.h bind.h buffer.h eval.h file.h \ random.h search.h +names.o: names.c names.h basic.h bind.h edef.h estruct.h line.h utf8.h \ + buffer.h display.h eval.h exec.h crypt.h file.h isearch.h main.h \ + region.h random.h search.h spawn.h window.h word.h pklock.o: pklock.c pklock.h estruct.h line.h utf8.h edef.h posix.o: posix.c termio.h random.o: random.c random.h basic.h display.h estruct.h line.h utf8.h \ @@ -179,16 +172,14 @@ spawn.o: spawn.c spawn.h buffer.h estruct.h line.h utf8.h display.h \ edef.h file.h input.h main.h window.h tcap.o: tcap.c display.h estruct.h line.h utf8.h edef.h termio.h termio.o: termio.c termio.h estruct.h line.h utf8.h edef.h +utf8.o: utf8.c utf8.h +vmsvt.o: vmsvt.c estruct.h line.h utf8.h edef.h +vt52.o: vt52.c estruct.h line.h utf8.h edef.h window.o: window.c window.h estruct.h line.h utf8.h basic.h display.h \ edef.h main.h wrapper.h word.o: word.c word.h basic.h display.h estruct.h line.h utf8.h edef.h \ main.h random.h region.h -names.o: names.c names.h basic.h bind.h edef.h estruct.h line.h utf8.h \ - buffer.h display.h eval.h exec.h crypt.h file.h isearch.h main.h \ - region.h random.h search.h spawn.h window.h word.h -globals.o: globals.c estruct.h line.h utf8.h edef.h wrapper.o: wrapper.c wrapper.h -utf8.o: utf8.c utf8.h # DEPENDENCIES MUST END AT END OF FILE # IF YOU PUT STUFF HERE IT WILL GO AWAY From de787262d32b2c6c71b88ec9e2352e503d43193e Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sat, 1 Jun 2013 13:42:09 +0800 Subject: [PATCH 061/193] rebuild on linux and fix lock dependencies. --- Makefile | 57 ++++++++++++++++++++++++++++---------------------------- file.c | 1 + lock.c | 2 ++ lock.h | 3 ++- main.c | 1 + 5 files changed, 35 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index c404208..2b072b1 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# makefile for emacs, updated Sat, Jun 01, 2013 11:49:18 AM +# makefile for emacs, updated Sat Jun 1 12:46:04 CST 2013 SRC=ansi.c basic.c bind.c buffer.c crypt.c display.c ebind.c eval.c exec.c file.c fileio.c globals.c ibmpc.c input.c isearch.c line.c lock.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c OBJ=ansi.o basic.o bind.o buffer.o crypt.o display.o ebind.o eval.o exec.o file.o fileio.o globals.o ibmpc.o input.o isearch.o line.o lock.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o @@ -125,60 +125,61 @@ depend: ${SRC} ansi.o: ansi.c estruct.h line.h utf8.h edef.h basic.o: basic.c basic.h display.h estruct.h line.h utf8.h edef.h input.h \ - random.h word.h + random.h word.h bind.o: bind.c bind.h edef.h estruct.h line.h utf8.h buffer.h display.h \ - ebind.h exec.h file.h fileio.h input.h main.h names.h window.h + ebind.h exec.h file.h fileio.h input.h main.h names.h window.h buffer.o: buffer.c buffer.h estruct.h line.h utf8.h display.h edef.h \ - file.h input.h window.h + file.h input.h window.h crypt.o: crypt.c crypt.h display.h estruct.h line.h utf8.h edef.h input.h display.o: display.c display.h estruct.h line.h utf8.h edef.h termio.h \ - version.h wrapper.h window.h + version.h wrapper.h window.h ebind.o: ebind.c ebind.h basic.h bind.h edef.h estruct.h line.h utf8.h \ - buffer.h crypt.h eval.h exec.h file.h isearch.h main.h random.h \ - region.h search.h spawn.h window.h word.h + buffer.h crypt.h eval.h exec.h file.h isearch.h main.h random.h region.h \ + search.h spawn.h window.h word.h eval.o: eval.c eval.h estruct.h line.h utf8.h basic.h bind.h edef.h \ - buffer.h display.h exec.h fileio.h input.h random.h search.h termio.h \ - version.h window.h + buffer.h display.h exec.h fileio.h input.h random.h search.h termio.h \ + version.h window.h exec.o: exec.c exec.h estruct.h line.h utf8.h buffer.h bind.h edef.h \ - display.h eval.h file.h input.h + display.h eval.h file.h input.h file.o: file.c file.h buffer.h estruct.h line.h utf8.h crypt.h display.h \ - edef.h fileio.h input.h main.h window.h + edef.h fileio.h input.h lock.h main.h window.h fileio.o: fileio.c fileio.h crypt.h display.h estruct.h line.h utf8.h \ - edef.h + edef.h globals.o: globals.c estruct.h line.h utf8.h edef.h ibmpc.o: ibmpc.c estruct.h line.h utf8.h edef.h input.o: input.c input.h edef.h estruct.h line.h utf8.h bind.h display.h \ - exec.h main.h names.h wrapper.h + exec.h main.h names.h wrapper.h isearch.o: isearch.c isearch.h basic.h display.h estruct.h line.h utf8.h \ - edef.h input.h search.h + edef.h input.h search.h line.o: line.c line.h utf8.h basic.h display.h estruct.h edef.h main.h \ - random.h -lock.o: lock.c lock.h display.h estruct.h line.h utf8.h edef.h input.h + random.h +lock.o: lock.c lock.h estruct.h line.h utf8.h display.h edef.h input.h \ + pklock.h main.o: main.c main.h crypt.h display.h estruct.h line.h utf8.h edef.h \ - input.h termio.h version.h basic.h bind.h buffer.h eval.h file.h \ - random.h search.h + input.h termio.h version.h basic.h bind.h buffer.h eval.h file.h lock.h \ + random.h search.h names.o: names.c names.h basic.h bind.h edef.h estruct.h line.h utf8.h \ - buffer.h display.h eval.h exec.h crypt.h file.h isearch.h main.h \ - region.h random.h search.h spawn.h window.h word.h + buffer.h display.h eval.h exec.h crypt.h file.h isearch.h main.h \ + region.h random.h search.h spawn.h window.h word.h pklock.o: pklock.c pklock.h estruct.h line.h utf8.h edef.h -posix.o: posix.c termio.h +posix.o: posix.c termio.h estruct.h line.h utf8.h edef.h random.o: random.c random.h basic.h display.h estruct.h line.h utf8.h \ - edef.h input.h main.h search.h + edef.h input.h main.h search.h region.o: region.c region.h estruct.h line.h utf8.h display.h edef.h \ - main.h + main.h search.o: search.c search.h estruct.h line.h utf8.h basic.h display.h \ - edef.h input.h main.h + edef.h input.h main.h spawn.o: spawn.c spawn.h buffer.h estruct.h line.h utf8.h display.h \ - edef.h file.h input.h main.h window.h + edef.h file.h input.h main.h window.h tcap.o: tcap.c display.h estruct.h line.h utf8.h edef.h termio.h -termio.o: termio.c termio.h estruct.h line.h utf8.h edef.h +termio.o: termio.c termio.h utf8.o: utf8.c utf8.h vmsvt.o: vmsvt.c estruct.h line.h utf8.h edef.h vt52.o: vt52.c estruct.h line.h utf8.h edef.h window.o: window.c window.h estruct.h line.h utf8.h basic.h display.h \ - edef.h main.h wrapper.h + edef.h main.h wrapper.h word.o: word.c word.h basic.h display.h estruct.h line.h utf8.h edef.h \ - main.h random.h region.h + main.h random.h region.h wrapper.o: wrapper.c wrapper.h # DEPENDENCIES MUST END AT END OF FILE diff --git a/file.c b/file.c index 082df7e..37b2153 100644 --- a/file.c +++ b/file.c @@ -22,6 +22,7 @@ #include "fileio.h" #include "input.h" #include "line.h" +#include "lock.h" #include "main.h" #include "window.h" diff --git a/lock.c b/lock.c index 15d41f4..326d577 100644 --- a/lock.c +++ b/lock.c @@ -24,6 +24,8 @@ static char *lname[NLOCKS]; /* names of all locked files */ static int numlocks; /* # of current locks active */ +static void lckerror(char *errstr) ; + /* * lockchk: * check a file for locking and add it to the list diff --git a/lock.h b/lock.h index 1183a10..a5a24d0 100644 --- a/lock.h +++ b/lock.h @@ -1,13 +1,14 @@ #ifndef _LOCK_H_ #define _LOCK_H_ +#include "estruct.h" + #if BSD | SVR4 int lockchk( char *fname) ; int lockrel( void) ; int lock( char *fname) ; int unlock( char *fname) ; -void lckerror( char *errstr) ; #endif diff --git a/main.c b/main.c index 4f9e636..f09c64f 100644 --- a/main.c +++ b/main.c @@ -76,6 +76,7 @@ #include "buffer.h" #include "eval.h" #include "file.h" +#include "lock.h" #include "random.h" #include "search.h" From a96f1b5f854ac6ee5178d37b355a11065c444e19 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Mon, 3 Jun 2013 16:29:33 +0800 Subject: [PATCH 062/193] Move rdonly and reterr from main to display to avoid dependencies to main. --- Makefile | 59 ++++++++++++++++++++++++++----------------------------- display.c | 19 ++++++++++++++++++ display.h | 3 +++ line.c | 1 - main.c | 18 ----------------- main.h | 2 -- region.c | 1 - search.c | 1 - spawn.c | 1 - word.c | 1 - 10 files changed, 50 insertions(+), 56 deletions(-) diff --git a/Makefile b/Makefile index 2b072b1..f175715 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# makefile for emacs, updated Sat Jun 1 12:46:04 CST 2013 +# makefile for emacs, updated Mon, Jun 03, 2013 12:05:22 PM SRC=ansi.c basic.c bind.c buffer.c crypt.c display.c ebind.c eval.c exec.c file.c fileio.c globals.c ibmpc.c input.c isearch.c line.c lock.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c OBJ=ansi.o basic.o bind.o buffer.o crypt.o display.o ebind.o eval.o exec.o file.o fileio.o globals.o ibmpc.o input.o isearch.o line.o lock.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o @@ -125,61 +125,58 @@ depend: ${SRC} ansi.o: ansi.c estruct.h line.h utf8.h edef.h basic.o: basic.c basic.h display.h estruct.h line.h utf8.h edef.h input.h \ - random.h word.h + random.h word.h bind.o: bind.c bind.h edef.h estruct.h line.h utf8.h buffer.h display.h \ - ebind.h exec.h file.h fileio.h input.h main.h names.h window.h + ebind.h exec.h file.h fileio.h input.h main.h names.h window.h buffer.o: buffer.c buffer.h estruct.h line.h utf8.h display.h edef.h \ - file.h input.h window.h + file.h input.h window.h crypt.o: crypt.c crypt.h display.h estruct.h line.h utf8.h edef.h input.h display.o: display.c display.h estruct.h line.h utf8.h edef.h termio.h \ - version.h wrapper.h window.h + version.h wrapper.h window.h ebind.o: ebind.c ebind.h basic.h bind.h edef.h estruct.h line.h utf8.h \ - buffer.h crypt.h eval.h exec.h file.h isearch.h main.h random.h region.h \ - search.h spawn.h window.h word.h + buffer.h crypt.h eval.h exec.h file.h isearch.h main.h random.h \ + region.h search.h spawn.h window.h word.h eval.o: eval.c eval.h estruct.h line.h utf8.h basic.h bind.h edef.h \ - buffer.h display.h exec.h fileio.h input.h random.h search.h termio.h \ - version.h window.h + buffer.h display.h exec.h fileio.h input.h random.h search.h termio.h \ + version.h window.h exec.o: exec.c exec.h estruct.h line.h utf8.h buffer.h bind.h edef.h \ - display.h eval.h file.h input.h + display.h eval.h file.h input.h file.o: file.c file.h buffer.h estruct.h line.h utf8.h crypt.h display.h \ - edef.h fileio.h input.h lock.h main.h window.h + edef.h fileio.h input.h lock.h main.h window.h fileio.o: fileio.c fileio.h crypt.h display.h estruct.h line.h utf8.h \ - edef.h + edef.h globals.o: globals.c estruct.h line.h utf8.h edef.h ibmpc.o: ibmpc.c estruct.h line.h utf8.h edef.h input.o: input.c input.h edef.h estruct.h line.h utf8.h bind.h display.h \ - exec.h main.h names.h wrapper.h + exec.h main.h names.h wrapper.h isearch.o: isearch.c isearch.h basic.h display.h estruct.h line.h utf8.h \ - edef.h input.h search.h -line.o: line.c line.h utf8.h basic.h display.h estruct.h edef.h main.h \ - random.h -lock.o: lock.c lock.h estruct.h line.h utf8.h display.h edef.h input.h \ - pklock.h + edef.h input.h search.h +line.o: line.c line.h utf8.h basic.h display.h estruct.h edef.h random.h +lock.o: lock.c lock.h estruct.h line.h utf8.h display.h edef.h input.h main.o: main.c main.h crypt.h display.h estruct.h line.h utf8.h edef.h \ - input.h termio.h version.h basic.h bind.h buffer.h eval.h file.h lock.h \ - random.h search.h + input.h termio.h version.h basic.h bind.h buffer.h eval.h file.h lock.h \ + random.h search.h names.o: names.c names.h basic.h bind.h edef.h estruct.h line.h utf8.h \ - buffer.h display.h eval.h exec.h crypt.h file.h isearch.h main.h \ - region.h random.h search.h spawn.h window.h word.h + buffer.h display.h eval.h exec.h crypt.h file.h isearch.h main.h \ + region.h random.h search.h spawn.h window.h word.h pklock.o: pklock.c pklock.h estruct.h line.h utf8.h edef.h -posix.o: posix.c termio.h estruct.h line.h utf8.h edef.h +posix.o: posix.c termio.h random.o: random.c random.h basic.h display.h estruct.h line.h utf8.h \ - edef.h input.h main.h search.h -region.o: region.c region.h estruct.h line.h utf8.h display.h edef.h \ - main.h + edef.h input.h main.h search.h +region.o: region.c region.h estruct.h line.h utf8.h display.h edef.h search.o: search.c search.h estruct.h line.h utf8.h basic.h display.h \ - edef.h input.h main.h + edef.h input.h spawn.o: spawn.c spawn.h buffer.h estruct.h line.h utf8.h display.h \ - edef.h file.h input.h main.h window.h + edef.h file.h input.h window.h tcap.o: tcap.c display.h estruct.h line.h utf8.h edef.h termio.h -termio.o: termio.c termio.h +termio.o: termio.c termio.h estruct.h line.h utf8.h edef.h utf8.o: utf8.c utf8.h vmsvt.o: vmsvt.c estruct.h line.h utf8.h edef.h vt52.o: vt52.c estruct.h line.h utf8.h edef.h window.o: window.c window.h estruct.h line.h utf8.h basic.h display.h \ - edef.h main.h wrapper.h + edef.h main.h wrapper.h word.o: word.c word.h basic.h display.h estruct.h line.h utf8.h edef.h \ - main.h random.h region.h + random.h region.h wrapper.o: wrapper.c wrapper.h # DEPENDENCIES MUST END AT END OF FILE diff --git a/display.c b/display.c index 164527f..22345ae 100644 --- a/display.c +++ b/display.c @@ -1550,3 +1550,22 @@ static int newscreensize(int h, int w) } #endif + +/* + * tell the user that this command is illegal while we are in + * VIEW (read-only) mode + */ +int rdonly(void) +{ + TTbeep(); + mlwrite("(Key illegal in VIEW mode)"); + return FALSE; +} + +int resterr(void) +{ + TTbeep(); + mlwrite("(That command is RESTRICTED)"); + return FALSE; +} + diff --git a/display.h b/display.h index 74e2785..1bf987a 100644 --- a/display.h +++ b/display.h @@ -20,4 +20,7 @@ void mlputs( char *s) ; void getscreensize( int *widthp, int *heightp) ; void sizesignal( int signr) ; +int rdonly( void) ; +int resterr( void) ; + #endif diff --git a/line.c b/line.c index 05cd944..071c83c 100644 --- a/line.c +++ b/line.c @@ -21,7 +21,6 @@ #include "display.h" #include "estruct.h" #include "edef.h" -#include "main.h" #include "random.h" #include "utf8.h" diff --git a/main.c b/main.c index f09c64f..04224a6 100644 --- a/main.c +++ b/main.c @@ -720,24 +720,6 @@ int ctrlg(int f, int n) return ABORT; } -/* - * tell the user that this command is illegal while we are in - * VIEW (read-only) mode - */ -int rdonly(void) -{ - TTbeep(); - mlwrite("(Key illegal in VIEW mode)"); - return FALSE; -} - -int resterr(void) -{ - TTbeep(); - mlwrite("(That command is RESTRICTED)"); - return FALSE; -} - /* user function that does NOTHING */ int nullproc(int f, int n) { diff --git a/main.h b/main.h index db60001..fb2150c 100644 --- a/main.h +++ b/main.h @@ -8,8 +8,6 @@ int ctlxlp( int f, int n) ; int ctlxrp( int f, int n) ; int ctlxe( int f, int n) ; int ctrlg( int f, int n) ; -int rdonly( void) ; -int resterr( void) ; int nullproc( int f, int n) ; int metafn( int f, int n) ; int cex( int f, int n) ; diff --git a/region.c b/region.c index 68a4bc0..b2e4ec7 100644 --- a/region.c +++ b/region.c @@ -16,7 +16,6 @@ #include "estruct.h" #include "edef.h" #include "line.h" -#include "main.h" /* * Kill the region. Ask "getregion" diff --git a/search.c b/search.c index 3651964..9275829 100644 --- a/search.c +++ b/search.c @@ -68,7 +68,6 @@ #include "edef.h" #include "input.h" #include "line.h" -#include "main.h" #if defined(MAGIC) /* diff --git a/spawn.c b/spawn.c index fc502b8..ef9318c 100644 --- a/spawn.c +++ b/spawn.c @@ -17,7 +17,6 @@ #include "edef.h" #include "file.h" #include "input.h" -#include "main.h" #include "window.h" #if VMS diff --git a/word.c b/word.c index a8ec144..74aa0ac 100644 --- a/word.c +++ b/word.c @@ -17,7 +17,6 @@ #include "estruct.h" #include "edef.h" #include "line.h" -#include "main.h" #include "random.h" #include "region.h" From 48db208aac924dea73c865383d36a2fb3fc61ab0 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 4 Jun 2013 11:52:28 +0800 Subject: [PATCH 063/193] extract execute from main to avoid dependencies of file, random and window to main. --- Makefile | 20 +++++++----- execute.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ execute.h | 2 ++ file.c | 2 +- main.c | 93 +--------------------------------------------------- main.h | 1 - random.c | 2 +- window.c | 2 +- 8 files changed, 115 insertions(+), 105 deletions(-) create mode 100644 execute.c create mode 100644 execute.h diff --git a/Makefile b/Makefile index f175715..135d0d9 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ -# makefile for emacs, updated Mon, Jun 03, 2013 12:05:22 PM +# makefile for emacs, updated Tue, Jun 04, 2013 11:39:09 AM -SRC=ansi.c basic.c bind.c buffer.c crypt.c display.c ebind.c eval.c exec.c file.c fileio.c globals.c ibmpc.c input.c isearch.c line.c lock.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c -OBJ=ansi.o basic.o bind.o buffer.o crypt.o display.o ebind.o eval.o exec.o file.o fileio.o globals.o ibmpc.o input.o isearch.o line.o lock.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o -HDR=basic.h bind.h buffer.h crypt.h display.h ebind.h edef.h efunc.h estruct.h eval.h exec.h file.h fileio.h input.h isearch.h line.h lock.h main.h names.h pklock.h random.h region.h search.h spawn.h termio.h utf8.h version.h window.h word.h wrapper.h +SRC=ansi.c basic.c bind.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c globals.c ibmpc.c input.c isearch.c line.c lock.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c +OBJ=ansi.o basic.o bind.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o globals.o ibmpc.o input.o isearch.o line.o lock.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o +HDR=basic.h bind.h buffer.h crypt.h display.h ebind.h edef.h efunc.h estruct.h eval.h exec.h execute.h file.h fileio.h input.h isearch.h line.h lock.h main.h names.h pklock.h random.h region.h search.h spawn.h termio.h utf8.h version.h window.h word.h wrapper.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -141,8 +141,10 @@ eval.o: eval.c eval.h estruct.h line.h utf8.h basic.h bind.h edef.h \ version.h window.h exec.o: exec.c exec.h estruct.h line.h utf8.h buffer.h bind.h edef.h \ display.h eval.h file.h input.h +execute.o: execute.c edef.h estruct.h line.h utf8.h bind.h random.h \ + display.h file.h file.o: file.c file.h buffer.h estruct.h line.h utf8.h crypt.h display.h \ - edef.h fileio.h input.h lock.h main.h window.h + edef.h execute.h fileio.h input.h lock.h window.h fileio.o: fileio.c fileio.h crypt.h display.h estruct.h line.h utf8.h \ edef.h globals.o: globals.c estruct.h line.h utf8.h edef.h @@ -154,15 +156,15 @@ isearch.o: isearch.c isearch.h basic.h display.h estruct.h line.h utf8.h \ line.o: line.c line.h utf8.h basic.h display.h estruct.h edef.h random.h lock.o: lock.c lock.h estruct.h line.h utf8.h display.h edef.h input.h main.o: main.c main.h crypt.h display.h estruct.h line.h utf8.h edef.h \ - input.h termio.h version.h basic.h bind.h buffer.h eval.h file.h lock.h \ - random.h search.h + input.h termio.h version.h basic.h bind.h buffer.h eval.h execute.h \ + file.h lock.h random.h search.h names.o: names.c names.h basic.h bind.h edef.h estruct.h line.h utf8.h \ buffer.h display.h eval.h exec.h crypt.h file.h isearch.h main.h \ region.h random.h search.h spawn.h window.h word.h pklock.o: pklock.c pklock.h estruct.h line.h utf8.h edef.h posix.o: posix.c termio.h random.o: random.c random.h basic.h display.h estruct.h line.h utf8.h \ - edef.h input.h main.h search.h + edef.h execute.h input.h search.h region.o: region.c region.h estruct.h line.h utf8.h display.h edef.h search.o: search.c search.h estruct.h line.h utf8.h basic.h display.h \ edef.h input.h @@ -174,7 +176,7 @@ utf8.o: utf8.c utf8.h vmsvt.o: vmsvt.c estruct.h line.h utf8.h edef.h vt52.o: vt52.c estruct.h line.h utf8.h edef.h window.o: window.c window.h estruct.h line.h utf8.h basic.h display.h \ - edef.h main.h wrapper.h + edef.h execute.h wrapper.h word.o: word.c word.h basic.h display.h estruct.h line.h utf8.h edef.h \ random.h region.h wrapper.o: wrapper.c wrapper.h diff --git a/execute.c b/execute.c new file mode 100644 index 0000000..7de8667 --- /dev/null +++ b/execute.c @@ -0,0 +1,98 @@ +#include "edef.h" +#include "bind.h" +#include "random.h" +#include "display.h" +#include "file.h" + +/* + * This is the general command execution routine. It handles the fake binding + * of all the keys to "self-insert". It also clears out the "thisflag" word, + * and arranges to move it to the "lastflag", so that the next command can + * look at it. Return the status of command. + */ +int execute(int c, int f, int n) +{ + int status; + fn_t execfunc; + + /* if the keystroke is a bound function...do it */ + execfunc = getbind(c); + if (execfunc != NULL) { + thisflag = 0; + status = (*execfunc) (f, n); + lastflag = thisflag; + return status; + } + + /* + * If a space was typed, fill column is defined, the argument is non- + * negative, wrap mode is enabled, and we are now past fill column, + * and we are not read-only, perform word wrap. + */ + if (c == ' ' && (curwp->w_bufp->b_mode & MDWRAP) && fillcol > 0 && + n >= 0 && getccol(FALSE) > fillcol && + (curwp->w_bufp->b_mode & MDVIEW) == FALSE) + execute(META | SPEC | 'W', FALSE, 1); + +#if PKCODE + if ((c >= 0x20 && c <= 0x7E) /* Self inserting. */ +#if IBMPC + || (c >= 0x80 && c <= 0xFE)) { +#else +#if VMS || BSD || USG /* 8BIT P.K. */ + || (c >= 0xA0 && c <= 0x10FFFF)) { +#else + ) { +#endif +#endif +#else + if ((c >= 0x20 && c <= 0xFF)) { /* Self inserting. */ +#endif + if (n <= 0) { /* Fenceposts. */ + lastflag = 0; + return n < 0 ? FALSE : TRUE; + } + thisflag = 0; /* For the future. */ + + /* if we are in overwrite mode, not at eol, + and next char is not a tab or we are at a tab stop, + delete a char forword */ + if (curwp->w_bufp->b_mode & MDOVER && + curwp->w_doto < curwp->w_dotp->l_used && + (lgetc(curwp->w_dotp, curwp->w_doto) != '\t' || + (curwp->w_doto) % 8 == 7)) + ldelchar(1, FALSE); + + /* do the appropriate insertion */ + if (c == '}' && (curbp->b_mode & MDCMOD) != 0) + status = insbrace(n, c); + else if (c == '#' && (curbp->b_mode & MDCMOD) != 0) + status = inspound(); + else + status = linsert(n, c); + +#if CFENCE + /* check for CMODE fence matching */ + if ((c == '}' || c == ')' || c == ']') && + (curbp->b_mode & MDCMOD) != 0) + fmatch(c); +#endif + + /* check auto-save mode */ + if (curbp->b_mode & MDASAVE) + if (--gacount == 0) { + /* and save the file if needed */ + upscreen(FALSE, 0); + filesave(FALSE, 0); + gacount = gasave; + } + + lastflag = thisflag; + return status; + } + TTbeep(); + mlwrite("(Key not bound)"); /* complain */ + lastflag = 0; /* Fake last flags. */ + return FALSE; +} + diff --git a/execute.h b/execute.h new file mode 100644 index 0000000..4cb6224 --- /dev/null +++ b/execute.h @@ -0,0 +1,2 @@ +int execute( int c, int f, int n) ; + diff --git a/file.c b/file.c index 37b2153..109df0f 100644 --- a/file.c +++ b/file.c @@ -19,11 +19,11 @@ #include "display.h" #include "estruct.h" #include "edef.h" +#include "execute.h" #include "fileio.h" #include "input.h" #include "line.h" #include "lock.h" -#include "main.h" #include "window.h" #if defined(PKCODE) diff --git a/main.c b/main.c index 04224a6..e142220 100644 --- a/main.c +++ b/main.c @@ -75,6 +75,7 @@ #include "bind.h" #include "buffer.h" #include "eval.h" +#include "execute.h" #include "file.h" #include "lock.h" #include "random.h" @@ -489,98 +490,6 @@ static void edinit(char *bname) wp->w_flag = WFMODE | WFHARD; /* Full. */ } -/* - * This is the general command execution routine. It handles the fake binding - * of all the keys to "self-insert". It also clears out the "thisflag" word, - * and arranges to move it to the "lastflag", so that the next command can - * look at it. Return the status of command. - */ -int execute(int c, int f, int n) -{ - int status; - fn_t execfunc; - - /* if the keystroke is a bound function...do it */ - execfunc = getbind(c); - if (execfunc != NULL) { - thisflag = 0; - status = (*execfunc) (f, n); - lastflag = thisflag; - return status; - } - - /* - * If a space was typed, fill column is defined, the argument is non- - * negative, wrap mode is enabled, and we are now past fill column, - * and we are not read-only, perform word wrap. - */ - if (c == ' ' && (curwp->w_bufp->b_mode & MDWRAP) && fillcol > 0 && - n >= 0 && getccol(FALSE) > fillcol && - (curwp->w_bufp->b_mode & MDVIEW) == FALSE) - execute(META | SPEC | 'W', FALSE, 1); - -#if PKCODE - if ((c >= 0x20 && c <= 0x7E) /* Self inserting. */ -#if IBMPC - || (c >= 0x80 && c <= 0xFE)) { -#else -#if VMS || BSD || USG /* 8BIT P.K. */ - || (c >= 0xA0 && c <= 0x10FFFF)) { -#else - ) { -#endif -#endif -#else - if ((c >= 0x20 && c <= 0xFF)) { /* Self inserting. */ -#endif - if (n <= 0) { /* Fenceposts. */ - lastflag = 0; - return n < 0 ? FALSE : TRUE; - } - thisflag = 0; /* For the future. */ - - /* if we are in overwrite mode, not at eol, - and next char is not a tab or we are at a tab stop, - delete a char forword */ - if (curwp->w_bufp->b_mode & MDOVER && - curwp->w_doto < curwp->w_dotp->l_used && - (lgetc(curwp->w_dotp, curwp->w_doto) != '\t' || - (curwp->w_doto) % 8 == 7)) - ldelchar(1, FALSE); - - /* do the appropriate insertion */ - if (c == '}' && (curbp->b_mode & MDCMOD) != 0) - status = insbrace(n, c); - else if (c == '#' && (curbp->b_mode & MDCMOD) != 0) - status = inspound(); - else - status = linsert(n, c); - -#if CFENCE - /* check for CMODE fence matching */ - if ((c == '}' || c == ')' || c == ']') && - (curbp->b_mode & MDCMOD) != 0) - fmatch(c); -#endif - - /* check auto-save mode */ - if (curbp->b_mode & MDASAVE) - if (--gacount == 0) { - /* and save the file if needed */ - upscreen(FALSE, 0); - filesave(FALSE, 0); - gacount = gasave; - } - - lastflag = thisflag; - return status; - } - TTbeep(); - mlwrite("(Key not bound)"); /* complain */ - lastflag = 0; /* Fake last flags. */ - return FALSE; -} - /* * Fancy quit command, as implemented by Norm. If the any buffer has * changed do a write on that buffer and exit emacs, otherwise simply exit. diff --git a/main.h b/main.h index fb2150c..d35d539 100644 --- a/main.h +++ b/main.h @@ -1,7 +1,6 @@ #ifndef _MAIN_H_ #define _MAIN_H_ -int execute( int c, int f, int n) ; int quickexit( int f, int n) ; int quit( int f, int n) ; int ctlxlp( int f, int n) ; diff --git a/random.c b/random.c index 7ba83c1..06e8160 100644 --- a/random.c +++ b/random.c @@ -15,9 +15,9 @@ #include "display.h" #include "estruct.h" #include "edef.h" +#include "execute.h" #include "input.h" #include "line.h" -#include "main.h" #include "search.h" int tabsize; /* Tab size (0: use real tabs) */ diff --git a/window.c b/window.c index bd70e44..2dbc0cf 100644 --- a/window.c +++ b/window.c @@ -15,8 +15,8 @@ #include "display.h" #include "estruct.h" #include "edef.h" +#include "execute.h" #include "line.h" -#include "main.h" #include "wrapper.h" /* From c96138add58a368c82202775a274921b640675fa Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 5 Jun 2013 11:48:40 +0800 Subject: [PATCH 064/193] remove left dependencies to main: bindable functions. --- Makefile | 25 ++++---- bind.c | 2 +- bindable.c | 174 +++++++++++++++++++++++++++++++++++++++++++++++++++ bindable.h | 11 ++++ ebind.c | 2 +- input.c | 2 +- main.c | 179 +++-------------------------------------------------- main.h | 12 +--- names.c | 2 +- 9 files changed, 211 insertions(+), 198 deletions(-) create mode 100644 bindable.c create mode 100644 bindable.h diff --git a/Makefile b/Makefile index 135d0d9..9791d54 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ -# makefile for emacs, updated Tue, Jun 04, 2013 11:39:09 AM +# makefile for emacs, updated Wed, Jun 05, 2013 11:36:19 AM -SRC=ansi.c basic.c bind.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c globals.c ibmpc.c input.c isearch.c line.c lock.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c -OBJ=ansi.o basic.o bind.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o globals.o ibmpc.o input.o isearch.o line.o lock.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o -HDR=basic.h bind.h buffer.h crypt.h display.h ebind.h edef.h efunc.h estruct.h eval.h exec.h execute.h file.h fileio.h input.h isearch.h line.h lock.h main.h names.h pklock.h random.h region.h search.h spawn.h termio.h utf8.h version.h window.h word.h wrapper.h +SRC=ansi.c basic.c bind.c bindable.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c globals.c ibmpc.c input.c isearch.c line.c lock.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c +OBJ=ansi.o basic.o bind.o bindable.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o globals.o ibmpc.o input.o isearch.o line.o lock.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o +HDR=basic.h bind.h bindable.h buffer.h crypt.h display.h ebind.h edef.h efunc.h estruct.h eval.h exec.h execute.h file.h fileio.h input.h isearch.h line.h lock.h main.h names.h pklock.h random.h region.h search.h spawn.h termio.h utf8.h version.h window.h word.h wrapper.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -126,15 +126,16 @@ depend: ${SRC} ansi.o: ansi.c estruct.h line.h utf8.h edef.h basic.o: basic.c basic.h display.h estruct.h line.h utf8.h edef.h input.h \ random.h word.h -bind.o: bind.c bind.h edef.h estruct.h line.h utf8.h buffer.h display.h \ - ebind.h exec.h file.h fileio.h input.h main.h names.h window.h +bind.o: bind.c bind.h edef.h estruct.h line.h utf8.h bindable.h buffer.h \ + display.h ebind.h exec.h file.h fileio.h input.h names.h window.h +bindable.o: bindable.c bindable.h buffer.o: buffer.c buffer.h estruct.h line.h utf8.h display.h edef.h \ file.h input.h window.h crypt.o: crypt.c crypt.h display.h estruct.h line.h utf8.h edef.h input.h display.o: display.c display.h estruct.h line.h utf8.h edef.h termio.h \ version.h wrapper.h window.h ebind.o: ebind.c ebind.h basic.h bind.h edef.h estruct.h line.h utf8.h \ - buffer.h crypt.h eval.h exec.h file.h isearch.h main.h random.h \ + bindable.h buffer.h crypt.h eval.h exec.h file.h isearch.h random.h \ region.h search.h spawn.h window.h word.h eval.o: eval.c eval.h estruct.h line.h utf8.h basic.h bind.h edef.h \ buffer.h display.h exec.h fileio.h input.h random.h search.h termio.h \ @@ -149,17 +150,17 @@ fileio.o: fileio.c fileio.h crypt.h display.h estruct.h line.h utf8.h \ edef.h globals.o: globals.c estruct.h line.h utf8.h edef.h ibmpc.o: ibmpc.c estruct.h line.h utf8.h edef.h -input.o: input.c input.h edef.h estruct.h line.h utf8.h bind.h display.h \ - exec.h main.h names.h wrapper.h +input.o: input.c input.h edef.h estruct.h line.h utf8.h bind.h bindable.h \ + display.h exec.h names.h wrapper.h isearch.o: isearch.c isearch.h basic.h display.h estruct.h line.h utf8.h \ edef.h input.h search.h line.o: line.c line.h utf8.h basic.h display.h estruct.h edef.h random.h lock.o: lock.c lock.h estruct.h line.h utf8.h display.h edef.h input.h main.o: main.c main.h crypt.h display.h estruct.h line.h utf8.h edef.h \ - input.h termio.h version.h basic.h bind.h buffer.h eval.h execute.h \ - file.h lock.h random.h search.h + input.h termio.h version.h basic.h bind.h bindable.h buffer.h eval.h \ + execute.h file.h lock.h random.h search.h names.o: names.c names.h basic.h bind.h edef.h estruct.h line.h utf8.h \ - buffer.h display.h eval.h exec.h crypt.h file.h isearch.h main.h \ + bindable.h buffer.h display.h eval.h exec.h crypt.h file.h isearch.h \ region.h random.h search.h spawn.h window.h word.h pklock.o: pklock.c pklock.h estruct.h line.h utf8.h edef.h posix.o: posix.c termio.h diff --git a/bind.c b/bind.c index 075f582..62f20b5 100644 --- a/bind.c +++ b/bind.c @@ -12,6 +12,7 @@ #include +#include "bindable.h" #include "buffer.h" #include "display.h" #include "ebind.h" @@ -20,7 +21,6 @@ #include "fileio.h" #include "input.h" #include "line.h" -#include "main.h" #include "names.h" #include "window.h" diff --git a/bindable.c b/bindable.c new file mode 100644 index 0000000..2dd341a --- /dev/null +++ b/bindable.c @@ -0,0 +1,174 @@ +/* bindable.h -- implements bindable.c */ +#include "bindable.h" + +#include "buffer.h" +#include "display.h" +#include "edef.h" +#include "file.h" +#include "input.h" + +#if VMS +#include +#define GOOD (SS$_NORMAL) +#endif + +#ifndef GOOD +#define GOOD 0 +#endif + +/* + * Fancy quit command, as implemented by Norm. If the any buffer has + * changed do a write on that buffer and exit emacs, otherwise simply exit. + */ +int quickexit(int f, int n) +{ + struct buffer *bp; /* scanning pointer to buffers */ + struct buffer *oldcb; /* original current buffer */ + int status; + + oldcb = curbp; /* save in case we fail */ + + bp = bheadp; + while (bp != NULL) { + if ((bp->b_flag & BFCHG) != 0 /* Changed. */ + && (bp->b_flag & BFTRUNC) == 0 /* Not truncated P.K. */ + && (bp->b_flag & BFINVS) == 0) { /* Real. */ + curbp = bp; /* make that buffer cur */ + mlwrite("(Saving %s)", bp->b_fname); +#if PKCODE +#else + mlwrite("\n"); +#endif + if ((status = filesave(f, n)) != TRUE) { + curbp = oldcb; /* restore curbp */ + return status; + } + } + bp = bp->b_bufp; /* on to the next buffer */ + } + quit(f, n); /* conditionally quit */ + return TRUE; +} + +/* + * Quit command. If an argument, always quit. Otherwise confirm if a buffer + * has been changed and not written out. Normally bound to "C-X C-C". + */ +int quit(int f, int n) +{ + int s; + + if (f != FALSE /* Argument forces it. */ + || anycb() == FALSE /* All buffers clean. */ + /* User says it's OK. */ + || (s = + mlyesno("Modified buffers exist. Leave anyway")) == TRUE) { +#if (FILOCK && BSD) || SVR4 + if (lockrel() != TRUE) { + TTputc('\n'); + TTputc('\r'); + TTclose(); + TTkclose(); + exit(1); + } +#endif + vttidy(); + if (f) + exit(n); + else + exit(GOOD); + } + mlwrite(""); + return s; +} + +/* + * Begin a keyboard macro. + * Error if not at the top level in keyboard processing. Set up variables and + * return. + */ +int ctlxlp(int f, int n) +{ + if (kbdmode != STOP) { + mlwrite("%%Macro already active"); + return FALSE; + } + mlwrite("(Start macro)"); + kbdptr = &kbdm[0]; + kbdend = kbdptr; + kbdmode = RECORD; + return TRUE; +} + +/* + * End keyboard macro. Check for the same limit conditions as the above + * routine. Set up the variables and return to the caller. + */ +int ctlxrp(int f, int n) +{ + if (kbdmode == STOP) { + mlwrite("%%Macro not active"); + return FALSE; + } + if (kbdmode == RECORD) { + mlwrite("(End macro)"); + kbdmode = STOP; + } + return TRUE; +} + +/* + * Execute a macro. + * The command argument is the number of times to loop. Quit as soon as a + * command gets an error. Return TRUE if all ok, else FALSE. + */ +int ctlxe(int f, int n) +{ + if (kbdmode != STOP) { + mlwrite("%%Macro already active"); + return FALSE; + } + if (n <= 0) + return TRUE; + kbdrep = n; /* remember how many times to execute */ + kbdmode = PLAY; /* start us in play mode */ + kbdptr = &kbdm[0]; /* at the beginning */ + return TRUE; +} + +/* + * Abort. + * Beep the beeper. Kill off any keyboard macro, etc., that is in progress. + * Sometimes called as a routine, to do general aborting of stuff. + */ +int ctrlg(int f, int n) +{ + TTbeep(); + kbdmode = STOP; + mlwrite("(Aborted)"); + return ABORT; +} + +/* user function that does NOTHING */ +int nullproc(int f, int n) +{ + return TRUE; +} + +/* dummy function for binding to meta prefix */ +int metafn(int f, int n) +{ + return TRUE; +} + +/* dummy function for binding to control-x prefix */ +int cex(int f, int n) +{ + return TRUE; +} + +/* dummy function for binding to universal-argument */ +int unarg(int f, int n) +{ + return TRUE; +} diff --git a/bindable.h b/bindable.h new file mode 100644 index 0000000..8e10ac6 --- /dev/null +++ b/bindable.h @@ -0,0 +1,11 @@ +/* functions that can be bound to keys or procedure names */ +int quickexit( int f, int n) ; +int quit( int f, int n) ; +int ctlxlp( int f, int n) ; +int ctlxrp( int f, int n) ; +int ctlxe( int f, int n) ; +int ctrlg( int f, int n) ; +int nullproc( int f, int n) ; +int metafn( int f, int n) ; +int cex( int f, int n) ; +int unarg( int f, int n) ; diff --git a/ebind.c b/ebind.c index 2f2b33b..2f9e9ad 100644 --- a/ebind.c +++ b/ebind.c @@ -10,6 +10,7 @@ #include "basic.h" #include "bind.h" +#include "bindable.h" #include "buffer.h" #include "crypt.h" #include "eval.h" @@ -17,7 +18,6 @@ #include "file.h" #include "isearch.h" #include "line.h" -#include "main.h" #include "random.h" #include "region.h" #include "search.h" diff --git a/input.c b/input.c index c0cd844..1bd797d 100644 --- a/input.c +++ b/input.c @@ -14,9 +14,9 @@ #include #include "bind.h" +#include "bindable.h" #include "display.h" #include "exec.h" -#include "main.h" #include "names.h" #include "wrapper.h" diff --git a/main.c b/main.c index e142220..352a0b1 100644 --- a/main.c +++ b/main.c @@ -73,6 +73,7 @@ #include "basic.h" #include "bind.h" +#include "bindable.h" #include "buffer.h" #include "eval.h" #include "execute.h" @@ -90,21 +91,18 @@ extern unsigned _stklen = 32766; #endif #endif -#if VMS -#include -#define GOOD (SS$_NORMAL) -#endif - -#ifndef GOOD -#define GOOD 0 -#endif - #if UNIX #include static void emergencyexit(int); #ifdef SIGWINCH extern void sizesignal(int); #endif + +static void emergencyexit(int signr) +{ + quickexit(FALSE, 0); + quit(TRUE, 0); +} #endif static void edinit( char *bname) ; @@ -490,169 +488,6 @@ static void edinit(char *bname) wp->w_flag = WFMODE | WFHARD; /* Full. */ } -/* - * Fancy quit command, as implemented by Norm. If the any buffer has - * changed do a write on that buffer and exit emacs, otherwise simply exit. - */ -int quickexit(int f, int n) -{ - struct buffer *bp; /* scanning pointer to buffers */ - struct buffer *oldcb; /* original current buffer */ - int status; - - oldcb = curbp; /* save in case we fail */ - - bp = bheadp; - while (bp != NULL) { - if ((bp->b_flag & BFCHG) != 0 /* Changed. */ - && (bp->b_flag & BFTRUNC) == 0 /* Not truncated P.K. */ - && (bp->b_flag & BFINVS) == 0) { /* Real. */ - curbp = bp; /* make that buffer cur */ - mlwrite("(Saving %s)", bp->b_fname); -#if PKCODE -#else - mlwrite("\n"); -#endif - if ((status = filesave(f, n)) != TRUE) { - curbp = oldcb; /* restore curbp */ - return status; - } - } - bp = bp->b_bufp; /* on to the next buffer */ - } - quit(f, n); /* conditionally quit */ - return TRUE; -} - -static void emergencyexit(int signr) -{ - quickexit(FALSE, 0); - quit(TRUE, 0); -} - -/* - * Quit command. If an argument, always quit. Otherwise confirm if a buffer - * has been changed and not written out. Normally bound to "C-X C-C". - */ -int quit(int f, int n) -{ - int s; - - if (f != FALSE /* Argument forces it. */ - || anycb() == FALSE /* All buffers clean. */ - /* User says it's OK. */ - || (s = - mlyesno("Modified buffers exist. Leave anyway")) == TRUE) { -#if (FILOCK && BSD) || SVR4 - if (lockrel() != TRUE) { - TTputc('\n'); - TTputc('\r'); - TTclose(); - TTkclose(); - exit(1); - } -#endif - vttidy(); - if (f) - exit(n); - else - exit(GOOD); - } - mlwrite(""); - return s; -} - -/* - * Begin a keyboard macro. - * Error if not at the top level in keyboard processing. Set up variables and - * return. - */ -int ctlxlp(int f, int n) -{ - if (kbdmode != STOP) { - mlwrite("%%Macro already active"); - return FALSE; - } - mlwrite("(Start macro)"); - kbdptr = &kbdm[0]; - kbdend = kbdptr; - kbdmode = RECORD; - return TRUE; -} - -/* - * End keyboard macro. Check for the same limit conditions as the above - * routine. Set up the variables and return to the caller. - */ -int ctlxrp(int f, int n) -{ - if (kbdmode == STOP) { - mlwrite("%%Macro not active"); - return FALSE; - } - if (kbdmode == RECORD) { - mlwrite("(End macro)"); - kbdmode = STOP; - } - return TRUE; -} - -/* - * Execute a macro. - * The command argument is the number of times to loop. Quit as soon as a - * command gets an error. Return TRUE if all ok, else FALSE. - */ -int ctlxe(int f, int n) -{ - if (kbdmode != STOP) { - mlwrite("%%Macro already active"); - return FALSE; - } - if (n <= 0) - return TRUE; - kbdrep = n; /* remember how many times to execute */ - kbdmode = PLAY; /* start us in play mode */ - kbdptr = &kbdm[0]; /* at the beginning */ - return TRUE; -} - -/* - * Abort. - * Beep the beeper. Kill off any keyboard macro, etc., that is in progress. - * Sometimes called as a routine, to do general aborting of stuff. - */ -int ctrlg(int f, int n) -{ - TTbeep(); - kbdmode = STOP; - mlwrite("(Aborted)"); - return ABORT; -} - -/* user function that does NOTHING */ -int nullproc(int f, int n) -{ - return TRUE; -} - -/* dummy function for binding to meta prefix */ -int metafn(int f, int n) -{ - return TRUE; -} - -/* dummy function for binding to control-x prefix */ -int cex(int f, int n) -{ - return TRUE; -} - -/* dummy function for binding to universal-argument */ -int unarg(int f, int n) -{ - return TRUE; -} - /***** Compiler specific Library functions ****/ #if RAMSIZE diff --git a/main.h b/main.h index d35d539..34c2f3b 100644 --- a/main.h +++ b/main.h @@ -1,16 +1,8 @@ #ifndef _MAIN_H_ #define _MAIN_H_ -int quickexit( int f, int n) ; -int quit( int f, int n) ; -int ctlxlp( int f, int n) ; -int ctlxrp( int f, int n) ; -int ctlxe( int f, int n) ; -int ctrlg( int f, int n) ; -int nullproc( int f, int n) ; -int metafn( int f, int n) ; -int cex( int f, int n) ; -int unarg( int f, int n) ; +#if CLEAN int cexit( int status) ; +#endif #endif diff --git a/names.c b/names.c index 17c9cf3..82dfa0b 100644 --- a/names.c +++ b/names.c @@ -10,6 +10,7 @@ #include "basic.h" #include "bind.h" +#include "bindable.h" #include "buffer.h" #include "display.h" #include "eval.h" @@ -18,7 +19,6 @@ #include "file.h" #include "isearch.h" #include "line.h" -#include "main.h" #include "region.h" #include "random.h" #include "search.h" From e2fcb90996c592a51979e95133a0652d13bdb1fd Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Thu, 6 Jun 2013 09:28:34 +0800 Subject: [PATCH 065/193] clean macroes in main and remove main.h (no more dependencies to main). --- estruct.h | 2 ++ main.c | 22 +++++++--------------- main.h | 8 -------- 3 files changed, 9 insertions(+), 23 deletions(-) delete mode 100644 main.h diff --git a/estruct.h b/estruct.h index dd7a83d..9863a1e 100644 --- a/estruct.h +++ b/estruct.h @@ -403,6 +403,8 @@ #if CLEAN #define exit(a) cexit(a) + +int cexit( int status) ; #endif /* diff --git a/main.c b/main.c index 352a0b1..5b1758c 100644 --- a/main.c +++ b/main.c @@ -1,6 +1,3 @@ -/* main.c -- implements main.h */ -#include "main.h" - /* * main.c @@ -60,27 +57,23 @@ #include -/* Make global definitions not external. */ -#define maindef - -#include "crypt.h" -#include "display.h" -#include "estruct.h" /* Global structures and defines. */ -#include "edef.h" /* Global definitions. */ -#include "input.h" -#include "termio.h" -#include "version.h" - #include "basic.h" #include "bind.h" #include "bindable.h" #include "buffer.h" +#include "crypt.h" +#include "display.h" +#include "edef.h" /* Global definitions. */ +#include "estruct.h" /* Global structures and defines. */ #include "eval.h" #include "execute.h" #include "file.h" +#include "input.h" #include "lock.h" #include "random.h" #include "search.h" +#include "termio.h" +#include "version.h" /* For MSDOS, increase the default stack space. */ #if MSDOS & TURBO @@ -93,7 +86,6 @@ extern unsigned _stklen = 32766; #if UNIX #include -static void emergencyexit(int); #ifdef SIGWINCH extern void sizesignal(int); #endif diff --git a/main.h b/main.h deleted file mode 100644 index 34c2f3b..0000000 --- a/main.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _MAIN_H_ -#define _MAIN_H_ - -#if CLEAN -int cexit( int status) ; -#endif - -#endif From 9da83ebffb3dd8792e00734e5c3c5e1b0ceb0960 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Thu, 6 Jun 2013 09:37:27 +0800 Subject: [PATCH 066/193] rerun make source and make depend as there is no more dependencies to main. --- Makefile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 9791d54..4f27d2c 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ -# makefile for emacs, updated Wed, Jun 05, 2013 11:36:19 AM +# makefile for emacs, updated Thu, Jun 06, 2013 9:29:56 AM SRC=ansi.c basic.c bind.c bindable.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c globals.c ibmpc.c input.c isearch.c line.c lock.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c OBJ=ansi.o basic.o bind.o bindable.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o globals.o ibmpc.o input.o isearch.o line.o lock.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o -HDR=basic.h bind.h bindable.h buffer.h crypt.h display.h ebind.h edef.h efunc.h estruct.h eval.h exec.h execute.h file.h fileio.h input.h isearch.h line.h lock.h main.h names.h pklock.h random.h region.h search.h spawn.h termio.h utf8.h version.h window.h word.h wrapper.h +HDR=basic.h bind.h bindable.h buffer.h crypt.h display.h ebind.h edef.h efunc.h estruct.h eval.h exec.h execute.h file.h fileio.h input.h isearch.h line.h lock.h names.h pklock.h random.h region.h search.h spawn.h termio.h utf8.h version.h window.h word.h wrapper.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -128,7 +128,8 @@ basic.o: basic.c basic.h display.h estruct.h line.h utf8.h edef.h input.h \ random.h word.h bind.o: bind.c bind.h edef.h estruct.h line.h utf8.h bindable.h buffer.h \ display.h ebind.h exec.h file.h fileio.h input.h names.h window.h -bindable.o: bindable.c bindable.h +bindable.o: bindable.c bindable.h buffer.h estruct.h line.h utf8.h \ + display.h edef.h file.h input.h buffer.o: buffer.c buffer.h estruct.h line.h utf8.h display.h edef.h \ file.h input.h window.h crypt.o: crypt.c crypt.h display.h estruct.h line.h utf8.h edef.h input.h @@ -156,9 +157,9 @@ isearch.o: isearch.c isearch.h basic.h display.h estruct.h line.h utf8.h \ edef.h input.h search.h line.o: line.c line.h utf8.h basic.h display.h estruct.h edef.h random.h lock.o: lock.c lock.h estruct.h line.h utf8.h display.h edef.h input.h -main.o: main.c main.h crypt.h display.h estruct.h line.h utf8.h edef.h \ - input.h termio.h version.h basic.h bind.h bindable.h buffer.h eval.h \ - execute.h file.h lock.h random.h search.h +main.o: main.c basic.h bind.h edef.h estruct.h line.h utf8.h bindable.h \ + buffer.h crypt.h display.h eval.h execute.h file.h input.h lock.h \ + random.h search.h termio.h version.h names.o: names.c names.h basic.h bind.h edef.h estruct.h line.h utf8.h \ bindable.h buffer.h display.h eval.h exec.h crypt.h file.h isearch.h \ region.h random.h search.h spawn.h window.h word.h From 5ee997b69513ad4a148bd2f0a88699b4fc022aae Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Thu, 6 Jun 2013 12:08:23 +0800 Subject: [PATCH 067/193] reduce visibility of directive name variable (dname[]). --- edef.h | 2 -- exec.c | 10 ++++++++++ globals.c | 10 ---------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/edef.h b/edef.h index a70f71c..a8df99c 100644 --- a/edef.h +++ b/edef.h @@ -115,8 +115,6 @@ extern char *patmatch; extern struct line *matchline; extern int matchoff; -extern char *dname[]; /* Directive name table. */ - #if DEBUGM /* Vars needed for macro debugging output. */ extern char outline[]; /* Global string to hold debug line text. */ diff --git a/exec.c b/exec.c index e761206..d0cf737 100644 --- a/exec.c +++ b/exec.c @@ -22,6 +22,16 @@ #include "input.h" #include "line.h" +/* directive name table: + This holds the names of all the directives.... */ + +static const char *dname[] = { + "if", "else", "endif", + "goto", "return", "endm", + "while", "endwhile", "break", + "force" +}; + /* * Execute a named command even if it is not bound. */ diff --git a/globals.c b/globals.c index c2d4c37..c9f684a 100644 --- a/globals.c +++ b/globals.c @@ -119,16 +119,6 @@ char *patmatch = NULL; struct line *matchline = NULL; int matchoff = 0; -/* directive name table: - This holds the names of all the directives.... */ - -char *dname[] = { - "if", "else", "endif", - "goto", "return", "endm", - "while", "endwhile", "break", - "force" -}; - #if DEBUGM /* vars needed for macro debugging output */ char outline[NSTRING]; /* global string to hold debug line text */ From 70dab2c8d815ddda0b230f1ce896014c4af6e5a6 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Thu, 6 Jun 2013 13:08:32 +0800 Subject: [PATCH 068/193] review visibility of functions defined by line. --- line.c | 6 ++++-- line.h | 2 -- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/line.c b/line.c index 071c83c..04b0079 100644 --- a/line.c +++ b/line.c @@ -26,6 +26,8 @@ #define BLOCK_SIZE 16 /* Line block chunk size. */ +static int ldelnewline( void) ; + /* * This routine allocates a block of memory large enough to hold a struct line * containing "used" characters. The block is always rounded up a bit. Return @@ -265,7 +267,7 @@ int linsert(int n, int c) * * int c; character to overwrite on current position */ -int lowrite(int c) +static int lowrite(int c) { if (curwp->w_doto < curwp->w_dotp->l_used && (lgetc(curwp->w_dotp, curwp->w_doto) != '\t' || @@ -515,7 +517,7 @@ int putctext(char *iline) * about in memory. Return FALSE on error and TRUE if all looks ok. Called by * "ldelete" only. */ -int ldelnewline(void) +static int ldelnewline(void) { char *cp1; char *cp2; diff --git a/line.h b/line.h index 2294b14..d649ee7 100644 --- a/line.h +++ b/line.h @@ -30,7 +30,6 @@ void lchange( int flag) ; int insspace( int f, int n) ; int linstr( char *instr) ; int linsert( int n, int c) ; -int lowrite( int c) ; int lover( char *ostr) ; int lnewline( void) ; int ldelete( long n, int kflag) ; @@ -38,7 +37,6 @@ int ldelchar( long n, int kflag) ; int lgetchar( unicode_t *) ; char *getctext( void) ; int putctext( char *iline) ; -int ldelnewline( void) ; void kdelete( void) ; int kinsert( int c) ; int yank( int f, int n) ; From 102618586f8b7209f3a9d1bc12ce56f72b427da6 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Thu, 6 Jun 2013 16:14:15 +0800 Subject: [PATCH 069/193] termio support of unicode. --- termio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/termio.c b/termio.c index b262609..cc02ec6 100644 --- a/termio.c +++ b/termio.c @@ -286,7 +286,11 @@ int ttputc( int c) { #endif #if V7 | USG | BSD - fputc(c, stdout); + char utf8[6]; + int bytes; + + bytes = unicode_to_utf8(c, utf8); + fwrite(utf8, 1, bytes, stdout); #endif return 0 ; } From 006f89258e4232194e042f790d9ef7307a105f22 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 7 Jun 2013 14:00:56 +0800 Subject: [PATCH 070/193] update usage with all supported options. --- main.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/main.c b/main.c index 5b1758c..d8e6aba 100644 --- a/main.c +++ b/main.c @@ -105,13 +105,20 @@ static void version( void) { static void usage( void) { - fputs( "Usage: " PROGRAM_NAME " filename\n" - " or: " PROGRAM_NAME " [options]\n\n" - " + start at the end of file\n" - " + start at line \n" - " -g[G] go to line \n" - " --help display this help and exit\n" - " --version output version information and exit\n", stdout) ; + fputs( "Usage: " PROGRAM_NAME " [OPTION].. [FILE]..\n\n" + " + start at the end of file\n" + " + start at line \n" + " --help display this help and exit\n" + " --version output version information and exit\n" + " -a|A process error file\n" + " -e|E edit file\n" + " -g|G go to line \n" + " -k|K use code key\n" + " -n|N accept null chars\n" + " -r|R restrictive use\n" + " -s|S search string\n" + " -v|V view file\n" + , stdout) ; } From a2804f6ca5a3f3699483bc47388577f34a182993 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sat, 8 Jun 2013 10:23:23 +0800 Subject: [PATCH 071/193] Align program name between Makefile and version.h --- Makefile | 2 +- version.h | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 4f27d2c..4ea27dd 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ ifeq ($(uname_S),Darwin) DEFINES=-DAUTOCONF -DPOSIX -DSYSV -D_DARWIN_C_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE -D_XOPEN_SOURCE=600 endif ifeq ($(uname_S),CYGWIN_NT-6.1-WOW64) - DEFINES=-DAUTOCONF -DCYGWIN + DEFINES=-DAUTOCONF -DCYGWIN -DPROGRAM=$(PROGRAM) endif #DEFINES=-DAUTOCONF #LIBS=-ltermcap # BSD diff --git a/version.h b/version.h index dc1d6d4..57fc82c 100644 --- a/version.h +++ b/version.h @@ -1,7 +1,14 @@ #ifndef VERSION_H_ #define VERSION_H_ -#define PROGRAM_NAME "ue" +#ifdef PROGRAM +# define _QUOTE( s) #s +# define QUOTE( s) _QUOTE( s) +# define PROGRAM_NAME QUOTE(PROGRAM) +#else +# define PROGRAM_NAME "em" +#endif + #define PROGRAM_NAME_LONG "uEMACS" #define VERSION "4.1.1" From 319957e8e0b415fa23cfcdf2f0d765c1f048dc20 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sat, 8 Jun 2013 10:23:55 +0800 Subject: [PATCH 072/193] Add @cmdfile to usage. --- main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/main.c b/main.c index d8e6aba..b363967 100644 --- a/main.c +++ b/main.c @@ -110,6 +110,7 @@ static void usage( void) { " + start at line \n" " --help display this help and exit\n" " --version output version information and exit\n" + " @cmdfile execute command file\n" " -a|A process error file\n" " -e|E edit file\n" " -g|G go to line \n" From 30b1b06acb69f00213ffff3ef076187753f22081 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sat, 8 Jun 2013 17:32:48 +0800 Subject: [PATCH 073/193] Handle all types of eol when reading files. --- file.c | 21 +++++ fileio.c | 275 +++++++++++++++++++++++++++++-------------------------- fileio.h | 7 ++ 3 files changed, 172 insertions(+), 131 deletions(-) diff --git a/file.c b/file.c index 109df0f..1c6ede3 100644 --- a/file.c +++ b/file.c @@ -231,6 +231,7 @@ int readin(char *fname, int lockfl) struct window *wp; struct buffer *bp; int s; + int eoltype ; int nbytes; int nline; char mesg[NSTRING]; @@ -294,6 +295,7 @@ int readin(char *fname, int lockfl) lputc(lp1, i, fline[i]); ++nline; } + eoltype = ftype ; ffclose(); /* Ignore errors. */ strcpy(mesg, "("); if (s == FIOERR) { @@ -307,6 +309,25 @@ int readin(char *fname, int lockfl) sprintf(&mesg[strlen(mesg)], "Read %d line", nline); if (nline != 1) strcat(mesg, "s"); + + strcat( mesg, ", eol = ") ; + switch( eoltype) { + case FTYPE_DOS: + strcat( mesg, "DOS") ; + break ; + case FTYPE_UNIX: + strcat( mesg, "UNIX") ; + break ; + case FTYPE_MAC: + strcat( mesg, "MAC") ; + break ; + case FTYPE_NONE: + strcat( mesg, "NONE") ; + break ; + default: + strcat( mesg, "MIXED") ; + } + strcat(mesg, ")"); mlwrite(mesg); diff --git a/fileio.c b/fileio.c index 6fcb3f3..f67889d 100644 --- a/fileio.c +++ b/fileio.c @@ -2,12 +2,12 @@ #include "fileio.h" -/* FILEIO.C +/* FILEIO.C * * The routines in this file read and write ASCII files from the disk. All of * the knowledge about files are here. * - * modified by Petri Kutvonen + * modified by Petri Kutvonen */ #include @@ -16,18 +16,21 @@ #include "estruct.h" #include "edef.h" -static FILE *ffp; /* File pointer, all functions. */ -static int eofflag; /* end-of-file flag */ +static FILE *ffp; /* File pointer, all functions. */ +static int eofflag; /* end-of-file flag */ + +int ftype ; /* * Open a file for reading. */ int ffropen( const char *fn) { - if ((ffp = fopen(fn, "rt")) == NULL) - return FIOFNF; - eofflag = FALSE; - return FIOSUC; + if ((ffp = fopen(fn, "r")) == NULL) + return FIOFNF; + eofflag = FALSE; + ftype = FTYPE_NONE ; + return FIOSUC; } /* @@ -37,17 +40,17 @@ int ffropen( const char *fn) int ffwopen( const char *fn) { #if VMS - int fd; + int fd; - if ((fd = creat(fn, 0666, "rfm=var", "rat=cr")) < 0 - || (ffp = fdopen(fd, "w")) == NULL) { + if ((fd = creat(fn, 0666, "rfm=var", "rat=cr")) < 0 + || (ffp = fdopen(fd, "w")) == NULL) { #else - if ((ffp = fopen(fn, "w")) == NULL) { + if ((ffp = fopen(fn, "w")) == NULL) { #endif - mlwrite("Cannot open file for writing"); - return FIOERR; - } - return FIOSUC; + mlwrite("Cannot open file for writing"); + return FIOERR; + } + return FIOSUC; } /* @@ -55,26 +58,27 @@ int ffwopen( const char *fn) */ int ffclose(void) { - /* free this since we do not need it anymore */ - if (fline) { - free(fline); - fline = NULL; - } - eofflag = FALSE; + /* free this since we do not need it anymore */ + if (fline) { + free(fline); + fline = NULL; + } + eofflag = FALSE; + ftype = FTYPE_NONE ; -#if MSDOS & CTRLZ - fputc(26, ffp); /* add a ^Z at the end of the file */ +#if MSDOS & CTRLZ + fputc(26, ffp); /* add a ^Z at the end of the file */ #endif #if V7 | USG | BSD | (MSDOS & (MSC | TURBO)) - if (fclose(ffp) != FALSE) { - mlwrite("Error closing file"); - return FIOERR; - } - return FIOSUC; + if (fclose(ffp) != FALSE) { + mlwrite("Error closing file"); + return FIOERR; + } + return FIOSUC; #else - fclose(ffp); - return FIOSUC; + fclose(ffp); + return FIOSUC; #endif } @@ -85,32 +89,33 @@ int ffclose(void) */ int ffputline(char *buf, int nbuf) { - int i; -#if CRYPT - char c; /* character to translate */ + int i; +#if CRYPT + char c; /* character to translate */ - if (cryptflag) { - for (i = 0; i < nbuf; ++i) { - c = buf[i] & 0xff; - myencrypt(&c, 1); - fputc(c, ffp); - } - } else - for (i = 0; i < nbuf; ++i) - fputc(buf[i] & 0xFF, ffp); + if (cryptflag) { + for (i = 0; i < nbuf; ++i) { + c = buf[i] & 0xff; + myencrypt(&c, 1); + fputc(c, ffp); + } + } else + for (i = 0; i < nbuf; ++i) + fputc(buf[i] & 0xFF, ffp); #else - for (i = 0; i < nbuf; ++i) - fputc(buf[i] & 0xFF, ffp); + for (i = 0; i < nbuf; ++i) + fputc(buf[i] & 0xFF, ffp); #endif - fputc('\n', ffp); + fputc( '\r', ffp) ; + fputc('\n', ffp); - if (ferror(ffp)) { - mlwrite("Write I/O error"); - return FIOERR; - } + if (ferror(ffp)) { + mlwrite("Write I/O error"); + return FIOERR; + } - return FIOSUC; + return FIOSUC; } /* @@ -121,107 +126,115 @@ int ffputline(char *buf, int nbuf) */ int ffgetline(void) { - int c; /* current character read */ - int i; /* current index into fline */ - char *tmpline; /* temp storage for expanding line */ + int c; /* current character read */ + int i; /* current index into fline */ + char *tmpline; /* temp storage for expanding line */ - /* if we are at the end...return it */ - if (eofflag) - return FIOEOF; + /* if we are at the end...return it */ + if (eofflag) + return FIOEOF; - /* dump fline if it ended up too big */ - if (flen > NSTRING) { - free(fline); - fline = NULL; - } + /* dump fline if it ended up too big */ + if (flen > NSTRING) { + free(fline); + fline = NULL; + } - /* if we don't have an fline, allocate one */ - if (fline == NULL) - if ((fline = malloc(flen = NSTRING)) == NULL) - return FIOMEM; + /* if we don't have an fline, allocate one */ + if (fline == NULL) + if ((fline = malloc(flen = NSTRING)) == NULL) + return FIOMEM; - /* read the line in */ -#if PKCODE - if (!nullflag) { - if (fgets(fline, NSTRING, ffp) == (char *) NULL) { /* EOF ? */ - i = 0; - c = EOF; - } else { - i = strlen(fline); - c = 0; - if (i > 0) { - c = fline[i - 1]; - i--; - } - } - } else { - i = 0; - c = fgetc(ffp); - } - while (c != EOF && c != '\n') { + /* read the line in */ +#if 0 /* PKCODE */ + if (!nullflag) { + if (fgets(fline, NSTRING, ffp) == (char *) NULL) { /* EOF ? */ + i = 0; + c = EOF; + } else { + i = strlen(fline); + c = 0; + if (i > 0) { + c = fline[i - 1]; + i--; + } + } + } else { + i = 0; + c = fgetc(ffp); + } + while (c != EOF && c != '\n') { #else - i = 0; - while ((c = fgetc(ffp)) != EOF && c != '\n') { + i = 0; + while ((c = fgetc(ffp)) != EOF && c != '\r' && c != '\n') { #endif -#if PKCODE - if (c) { +#if 0 /* PKCODE */ + if (c) { #endif - fline[i++] = c; - /* if it's longer, get more room */ - if (i >= flen) { - if ((tmpline = - malloc(flen + NSTRING)) == NULL) - return FIOMEM; - strncpy(tmpline, fline, flen); - flen += NSTRING; - free(fline); - fline = tmpline; - } -#if PKCODE - } - c = fgetc(ffp); + fline[i++] = c; + /* if it's longer, get more room */ + if (i >= flen) { + if ((tmpline = + malloc(flen + NSTRING)) == NULL) + return FIOMEM; + strncpy(tmpline, fline, flen); + flen += NSTRING; + free(fline); + fline = tmpline; + } +#if 0 /* PKCODE */ + } + c = fgetc(ffp); #endif - } + } - /* test for any errors that may have occured */ - if (c == EOF) { - if (ferror(ffp)) { - mlwrite("File read error"); - return FIOERR; - } + /* test for any errors that may have occured */ + if (c == EOF) { + if (ferror(ffp)) { + mlwrite("File read error"); + return FIOERR; + } - if (i != 0) - eofflag = TRUE; - else - return FIOEOF; - } + if (i != 0) + eofflag = TRUE; + else + return FIOEOF; + } else if( c == '\r') { + c = fgetc( ffp) ; + if( c != '\n') { + ftype |= FTYPE_MAC ; + ungetc( c, ffp) ; + } else + ftype |= FTYPE_DOS ; + } else /* c == '\n' */ + ftype |= FTYPE_UNIX ; - /* terminate and decrypt the string */ - fline[i] = 0; -#if CRYPT - if (cryptflag) - myencrypt(fline, strlen(fline)); + /* terminate and decrypt the string */ + fline[i] = 0; +#if CRYPT + if (cryptflag) + myencrypt(fline, strlen(fline)); #endif - return FIOSUC; + return FIOSUC; } /* * does exist on disk? * - * char *fname; file to check for existance + * char *fname; file to check for existance */ int fexist( const char *fname) { - FILE *fp; + FILE *fp; - /* try to open the file for reading */ - fp = fopen(fname, "r"); + /* try to open the file for reading */ + fp = fopen(fname, "r"); - /* if it fails, just return false! */ - if (fp == NULL) - return FALSE; + /* if it fails, just return false! */ + if (fp == NULL) + return FALSE; - /* otherwise, close it and report true */ - fclose(fp); - return TRUE; + /* otherwise, close it and report true */ + fclose(fp); + return TRUE; } diff --git a/fileio.h b/fileio.h index d27008e..d722d47 100644 --- a/fileio.h +++ b/fileio.h @@ -1,6 +1,13 @@ #ifndef _FILEIO_H_ #define _FILEIO_H_ +#define FTYPE_NONE 0 +#define FTYPE_UNIX 1 +#define FTYPE_DOS 2 +#define FTYPE_MAC 4 + +extern int ftype ; + int fexist( const char *fname) ; int ffclose( void) ; int ffgetline( void) ; From a3f310201361cd6e633725c1b55b0dd40f0cd2d0 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sun, 9 Jun 2013 11:21:35 +0800 Subject: [PATCH 074/193] DOS mode added to preserve eol termination. --- edef.h | 6 +++--- estruct.h | 4 +++- file.c | 6 +++++- fileio.c | 6 ++++-- fileio.h | 2 +- globals.c | 10 +++++----- 6 files changed, 21 insertions(+), 13 deletions(-) diff --git a/edef.h b/edef.h index a8df99c..a33271d 100644 --- a/edef.h +++ b/edef.h @@ -30,9 +30,9 @@ extern int execlevel; /* execution IF level */ extern int eolexist; /* does clear to EOL exist? */ extern int revexist; /* does reverse video exist? */ extern int flickcode; /* do flicker supression? */ -extern char *modename[]; /* text names of modes */ -extern char *mode2name[]; /* text names of modes */ -extern char modecode[]; /* letters to represent modes */ +extern const char *modename[]; /* text names of modes */ +extern const char *mode2name[]; /* text names of modes */ +extern const char modecode[]; /* letters to represent modes */ extern int gmode; /* global editor mode */ extern int gflags; /* global control flag */ extern int gfcolor; /* global forgrnd color (white) */ diff --git a/estruct.h b/estruct.h index 9863a1e..97247e2 100644 --- a/estruct.h +++ b/estruct.h @@ -481,7 +481,7 @@ struct buffer { #define BFTRUNC 0x04 /* buffer was truncated when read */ /* mode flags */ -#define NUMMODES 10 /* # of defined modes */ +#define NUMMODES 11 /* # of defined modes */ #define MDWRAP 0x0001 /* word wrap */ #define MDCMOD 0x0002 /* C indentation and fence match */ @@ -492,6 +492,8 @@ struct buffer { #define MDMAGIC 0x0040 /* regular expresions in search */ #define MDCRYPT 0x0080 /* encrytion mode active */ #define MDASAVE 0x0100 /* auto-save mode */ +#define MDUTF8 0x0200 /* utf8 mode */ +#define MDDOS 0x0400 /* CRLF eol mode */ /* * The starting position of a region, and the size of the region in diff --git a/file.c b/file.c index 1c6ede3..1715c5e 100644 --- a/file.c +++ b/file.c @@ -296,6 +296,9 @@ int readin(char *fname, int lockfl) ++nline; } eoltype = ftype ; + if( ftype == FTYPE_DOS) + curbp->b_mode |= MDDOS ; + ffclose(); /* Ignore errors. */ strcpy(mesg, "("); if (s == FIOERR) { @@ -512,7 +515,8 @@ int writeout(char *fn) lp = lforw(curbp->b_linep); /* First line. */ nline = 0; /* Number of lines. */ while (lp != curbp->b_linep) { - if ((s = ffputline(&lp->l_text[0], llength(lp))) != FIOSUC) + s = ffputline( &lp->l_text[0], llength(lp), curbp->b_mode & MDDOS) ; + if( s != FIOSUC) break; ++nline; lp = lforw(lp); diff --git a/fileio.c b/fileio.c index f67889d..0ec25b9 100644 --- a/fileio.c +++ b/fileio.c @@ -87,7 +87,7 @@ int ffclose(void) * and the "nbuf" is its length, less the free newline. Return the status. * Check only at the newline. */ -int ffputline(char *buf, int nbuf) +int ffputline( char *buf, int nbuf, int dosflag) { int i; #if CRYPT @@ -107,7 +107,9 @@ int ffputline(char *buf, int nbuf) fputc(buf[i] & 0xFF, ffp); #endif - fputc( '\r', ffp) ; + if( dosflag) + fputc( '\r', ffp) ; + fputc('\n', ffp); if (ferror(ffp)) { diff --git a/fileio.h b/fileio.h index d722d47..70ade7b 100644 --- a/fileio.h +++ b/fileio.h @@ -11,7 +11,7 @@ extern int ftype ; int fexist( const char *fname) ; int ffclose( void) ; int ffgetline( void) ; -int ffputline( char *buf, int nbuf) ; +int ffputline( char *buf, int nbuf, int dosflag) ; int ffropen( const char *fn) ; int ffwopen( const char *fn) ; diff --git a/globals.c b/globals.c index c9f684a..e96b22f 100644 --- a/globals.c +++ b/globals.c @@ -11,15 +11,15 @@ int execlevel = 0; /* execution IF level */ int eolexist = TRUE; /* does clear to EOL exist */ int revexist = FALSE; /* does reverse video exist? */ int flickcode = FALSE; /* do flicker supression? */ -char *modename[] = { /* name of modes */ +const char *modename[] = { /* name of modes */ "WRAP", "CMODE", "SPELL", "EXACT", "VIEW", "OVER", - "MAGIC", "CRYPT", "ASAVE", "UTF-8" + "MAGIC", "CRYPT", "ASAVE", "UTF-8", "DOS" }; -char *mode2name[] = { /* name of modes */ +const char *mode2name[] = { /* name of modes */ "Wrap", "Cmode", "Spell", "Exact", "View", "Over", - "Magic", "Crypt", "Asave", "utf-8" + "Magic", "Crypt", "Asave", "utf-8", "Dos" }; -char modecode[] = "WCSEVOMYAU"; /* letters to represent modes */ +const char modecode[] = "WCSEVOMYAUD"; /* letters to represent modes */ int gmode = 0; /* global editor mode */ int gflags = GFREAD; /* global control flag */ #if PKCODE & IBMPC From b57c1adc2064438de2bb2d6db5a98d60bb60e1bd Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sun, 9 Jun 2013 16:16:02 +0800 Subject: [PATCH 075/193] Move FIO return code into fileio.h, where they belong. --- estruct.h | 7 ------- fileio.h | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/estruct.h b/estruct.h index 97247e2..0ae1a7e 100644 --- a/estruct.h +++ b/estruct.h @@ -289,13 +289,6 @@ #define FORWARD 0 /* forward direction */ #define REVERSE 1 /* backwards direction */ -#define FIOSUC 0 /* File I/O, success. */ -#define FIOFNF 1 /* File I/O, file not found. */ -#define FIOEOF 2 /* File I/O, end of file. */ -#define FIOERR 3 /* File I/O, error. */ -#define FIOMEM 4 /* File I/O, out of memory */ -#define FIOFUN 5 /* File I/O, eod of file/bad line */ - #define CFCPCN 0x0001 /* Last command was C-P, C-N */ #define CFKILL 0x0002 /* Last command was a kill */ diff --git a/fileio.h b/fileio.h index 70ade7b..df607c3 100644 --- a/fileio.h +++ b/fileio.h @@ -1,6 +1,13 @@ #ifndef _FILEIO_H_ #define _FILEIO_H_ +#define FIOSUC 0 /* File I/O, success. */ +#define FIOFNF 1 /* File I/O, file not found. */ +#define FIOEOF 2 /* File I/O, end of file. */ +#define FIOERR 3 /* File I/O, error. */ +#define FIOMEM 4 /* File I/O, out of memory */ +#define FIOFUN 5 /* File I/O, eod of file/bad line */ + #define FTYPE_NONE 0 #define FTYPE_UNIX 1 #define FTYPE_DOS 2 From 4bf4c48056f52a518537be6f86a3e2948aac2cc3 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sun, 9 Jun 2013 17:31:28 +0800 Subject: [PATCH 076/193] Review interface of fileio. --- edef.h | 2 -- estruct.h | 8 ++++++++ fileio.c | 16 +++++++++------- fileio.h | 31 +++++++++++++++++++------------ globals.c | 2 -- 5 files changed, 36 insertions(+), 23 deletions(-) diff --git a/edef.h b/edef.h index a33271d..55b23c7 100644 --- a/edef.h +++ b/edef.h @@ -81,8 +81,6 @@ extern char falsem[]; /* false litereal */ extern int cmdstatus; /* last command status */ extern char palstr[]; /* palette string */ extern int saveflag; /* Flags, saved with the $target var */ -extern char *fline; /* dynamic return line */ -extern int flen; /* current length of fline */ extern int rval; /* return value of a subprocess */ #if PKCODE extern int nullflag; diff --git a/estruct.h b/estruct.h index 0ae1a7e..c71056b 100644 --- a/estruct.h +++ b/estruct.h @@ -256,10 +256,18 @@ #undef TRUE #endif +#if 0 #define FALSE 0 /* False, no, bad, etc. */ #define TRUE 1 /* True, yes, good, etc. */ #define ABORT 2 /* Death, ^G, abort, etc. */ #define FAILED 3 /* not-quite fatal false return */ +#endif +typedef enum { + FALSE, + TRUE +} boolean ; + +#define ABORT 2 #define STOP 0 /* keyboard macro not in use */ #define PLAY 1 /* playing */ diff --git a/fileio.c b/fileio.c index 0ec25b9..84ebbbf 100644 --- a/fileio.c +++ b/fileio.c @@ -17,14 +17,16 @@ #include "edef.h" static FILE *ffp; /* File pointer, all functions. */ -static int eofflag; /* end-of-file flag */ +static boolean eofflag ; /* end-of-file flag */ +char *fline = NULL; /* dynamic return line */ +int flen = 0; /* current length of fline */ int ftype ; /* * Open a file for reading. */ -int ffropen( const char *fn) +fio_code ffropen( const char *fn) { if ((ffp = fopen(fn, "r")) == NULL) return FIOFNF; @@ -37,7 +39,7 @@ int ffropen( const char *fn) * Open a file for writing. Return TRUE if all is well, and FALSE on error * (cannot create). */ -int ffwopen( const char *fn) +fio_code ffwopen( const char *fn) { #if VMS int fd; @@ -56,7 +58,7 @@ int ffwopen( const char *fn) /* * Close a file. Should look at the status in all systems. */ -int ffclose(void) +fio_code ffclose(void) { /* free this since we do not need it anymore */ if (fline) { @@ -87,7 +89,7 @@ int ffclose(void) * and the "nbuf" is its length, less the free newline. Return the status. * Check only at the newline. */ -int ffputline( char *buf, int nbuf, int dosflag) +fio_code ffputline( char *buf, int nbuf, int dosflag) { int i; #if CRYPT @@ -126,7 +128,7 @@ int ffputline( char *buf, int nbuf, int dosflag) * at the end of the file that don't have a newline present. Check for I/O * errors too. Return status. */ -int ffgetline(void) +fio_code ffgetline(void) { int c; /* current character read */ int i; /* current index into fline */ @@ -225,7 +227,7 @@ int ffgetline(void) * * char *fname; file to check for existance */ -int fexist( const char *fname) +boolean fexist( const char *fname) { FILE *fp; diff --git a/fileio.h b/fileio.h index df607c3..73e2ff1 100644 --- a/fileio.h +++ b/fileio.h @@ -1,25 +1,32 @@ #ifndef _FILEIO_H_ #define _FILEIO_H_ -#define FIOSUC 0 /* File I/O, success. */ -#define FIOFNF 1 /* File I/O, file not found. */ -#define FIOEOF 2 /* File I/O, end of file. */ -#define FIOERR 3 /* File I/O, error. */ -#define FIOMEM 4 /* File I/O, out of memory */ -#define FIOFUN 5 /* File I/O, eod of file/bad line */ +#include "estruct.h" + +typedef enum { + FIOSUC, /* File I/O, success. */ + FIOFNF, /* File I/O, file not found. */ + FIOEOF, /* File I/O, end of file. */ + FIOERR, /* File I/O, error. */ + FIOMEM, /* File I/O, out of memory */ + FIOFUN /* File I/O, eod of file/bad line */ +} fio_code ; #define FTYPE_NONE 0 #define FTYPE_UNIX 1 #define FTYPE_DOS 2 #define FTYPE_MAC 4 +/* FTYPE_MIXED [ 3, 5, 6, 7] */ +extern char *fline ; /* dynamic return line */ +extern int flen ; /* current length of fline */ extern int ftype ; -int fexist( const char *fname) ; -int ffclose( void) ; -int ffgetline( void) ; -int ffputline( char *buf, int nbuf, int dosflag) ; -int ffropen( const char *fn) ; -int ffwopen( const char *fn) ; +boolean fexist( const char *fname) ; +fio_code ffclose( void) ; +fio_code ffgetline( void) ; +fio_code ffputline( char *buf, int nbuf, int dosflag) ; +fio_code ffropen( const char *fn) ; +fio_code ffwopen( const char *fn) ; #endif diff --git a/globals.c b/globals.c index e96b22f..927acd1 100644 --- a/globals.c +++ b/globals.c @@ -78,8 +78,6 @@ char falsem[] = "FALSE"; /* false litereal */ int cmdstatus = TRUE; /* last command status */ char palstr[49] = ""; /* palette string */ int saveflag = 0; /* Flags, saved with the $target var */ -char *fline = NULL; /* dynamic return line */ -int flen = 0; /* current length of fline */ int rval = 0; /* return value of a subprocess */ #if PKCODE int nullflag = FALSE; /* accept null characters */ From 45c67abc59b1047069b403f32ee1e330e486fead Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Mon, 10 Jun 2013 12:09:39 +0800 Subject: [PATCH 077/193] Rewrite ffputline to perform write at once when not encrypted. --- fileio.c | 43 ++++++++++++++++++++----------------------- fileio.h | 2 +- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/fileio.c b/fileio.c index 84ebbbf..5df09b7 100644 --- a/fileio.c +++ b/fileio.c @@ -89,37 +89,34 @@ fio_code ffclose(void) * and the "nbuf" is its length, less the free newline. Return the status. * Check only at the newline. */ -fio_code ffputline( char *buf, int nbuf, int dosflag) -{ - int i; +fio_code ffputline( unsigned char *buf, int nbuf, int dosflag) { #if CRYPT - char c; /* character to translate */ + if( cryptflag) { + int i ; - if (cryptflag) { - for (i = 0; i < nbuf; ++i) { - c = buf[i] & 0xff; - myencrypt(&c, 1); - fputc(c, ffp); - } - } else - for (i = 0; i < nbuf; ++i) - fputc(buf[i] & 0xFF, ffp); -#else - for (i = 0; i < nbuf; ++i) - fputc(buf[i] & 0xFF, ffp); + for( i = 0 ; i < nbuf ; i++) { + unsigned char c ; + + c = buf[ i] ; + myencrypt( &c, 1) ; + fputc( c, ffp) ; + } + } else #endif - if( dosflag) - fputc( '\r', ffp) ; + fwrite( buf, 1, nbuf, ffp) ; + + if( dosflag) + fputc( '\r', ffp) ; - fputc('\n', ffp); + fputc( '\n', ffp) ; - if (ferror(ffp)) { - mlwrite("Write I/O error"); - return FIOERR; + if( ferror( ffp)) { + mlwrite( "Write I/O error") ; + return FIOERR ; } - return FIOSUC; + return FIOSUC ; } /* diff --git a/fileio.h b/fileio.h index 73e2ff1..c5824f1 100644 --- a/fileio.h +++ b/fileio.h @@ -25,7 +25,7 @@ extern int ftype ; boolean fexist( const char *fname) ; fio_code ffclose( void) ; fio_code ffgetline( void) ; -fio_code ffputline( char *buf, int nbuf, int dosflag) ; +fio_code ffputline( unsigned char *buf, int nbuf, int dosflag) ; fio_code ffropen( const char *fn) ; fio_code ffwopen( const char *fn) ; From 787189d50c0efbbf2195ac9e3f8850d45a0123ad Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Mon, 10 Jun 2013 13:30:06 +0800 Subject: [PATCH 078/193] Insure consistency when building with CRYPT on or off. clarify fileio dependencies t crypt. --- crypt.c | 5 +---- edef.h | 1 - estruct.h | 2 ++ file.c | 4 ++-- fileio.c | 30 ++++++++++++++++++++---------- fileio.h | 10 +++++++--- globals.c | 20 +++++++++++++++++--- main.c | 2 ++ 8 files changed, 51 insertions(+), 23 deletions(-) diff --git a/crypt.c b/crypt.c index 7b735cb..70b2fb5 100644 --- a/crypt.c +++ b/crypt.c @@ -221,8 +221,5 @@ static int mod95(int val) val += 95; return val; } -#else -static void myennocrypt(void) -{ -} + #endif diff --git a/edef.h b/edef.h index 55b23c7..9365f4f 100644 --- a/edef.h +++ b/edef.h @@ -65,7 +65,6 @@ extern struct kill *kbufp; /* current kill buffer chunk pointer */ extern struct kill *kbufh; /* kill buffer header pointer */ extern int kused; /* # of bytes used in KB */ extern struct window *swindow; /* saved window pointer */ -extern int cryptflag; /* currently encrypting? */ extern int *kbdptr; /* current position in keyboard buf */ extern int *kbdend; /* ptr to end of the keyboard */ extern int kbdmode; /* current keyboard macro mode */ diff --git a/estruct.h b/estruct.h index c71056b..82f4f5d 100644 --- a/estruct.h +++ b/estruct.h @@ -491,7 +491,9 @@ struct buffer { #define MDVIEW 0x0010 /* read-only buffer */ #define MDOVER 0x0020 /* overwrite mode */ #define MDMAGIC 0x0040 /* regular expresions in search */ +#if CRYPT #define MDCRYPT 0x0080 /* encrytion mode active */ +#endif #define MDASAVE 0x0100 /* auto-save mode */ #define MDUTF8 0x0200 /* utf8 mode */ #define MDDOS 0x0400 /* CRLF eol mode */ diff --git a/file.c b/file.c index 1715c5e..8c8d02c 100644 --- a/file.c +++ b/file.c @@ -124,7 +124,7 @@ static int resetkey(void) int s; /* return status */ /* turn off the encryption flag */ - cryptflag = FALSE; + is_crypted = FALSE; /* if we are in crypt mode */ if (curbp->b_mode & MDCRYPT) { @@ -135,7 +135,7 @@ static int resetkey(void) } /* let others know... */ - cryptflag = TRUE; + is_crypted = TRUE; /* and set up the key to be used! */ /* de-encrypt it */ diff --git a/fileio.c b/fileio.c index 5df09b7..7d9f835 100644 --- a/fileio.c +++ b/fileio.c @@ -11,17 +11,27 @@ */ #include -#include "crypt.h" -#include "display.h" +#include +#include + #include "estruct.h" -#include "edef.h" +#include "display.h" -static FILE *ffp; /* File pointer, all functions. */ -static boolean eofflag ; /* end-of-file flag */ -char *fline = NULL; /* dynamic return line */ -int flen = 0; /* current length of fline */ -int ftype ; +#if CRYPT +#include "crypt.h" + +boolean is_crypted ; /* currently encrypting? */ +#endif + +char *fline = NULL ; /* dynamic return line */ +int flen = 0 ; /* current length of fline */ +int ftype ; + + +static FILE *ffp ; /* File pointer, all functions. */ +static boolean eofflag ; /* end-of-file flag */ + /* * Open a file for reading. @@ -91,7 +101,7 @@ fio_code ffclose(void) */ fio_code ffputline( unsigned char *buf, int nbuf, int dosflag) { #if CRYPT - if( cryptflag) { + if( is_crypted) { int i ; for( i = 0 ; i < nbuf ; i++) { @@ -213,7 +223,7 @@ fio_code ffgetline(void) /* terminate and decrypt the string */ fline[i] = 0; #if CRYPT - if (cryptflag) + if( is_crypted) myencrypt(fline, strlen(fline)); #endif return FIOSUC; diff --git a/fileio.h b/fileio.h index c5824f1..fd2e482 100644 --- a/fileio.h +++ b/fileio.h @@ -18,9 +18,13 @@ typedef enum { #define FTYPE_MAC 4 /* FTYPE_MIXED [ 3, 5, 6, 7] */ -extern char *fline ; /* dynamic return line */ -extern int flen ; /* current length of fline */ -extern int ftype ; +#if CRYPT +extern boolean is_crypted ; /* currently encrypting? */ +#endif + +extern char *fline ; /* dynamic return line */ +extern int flen ; /* current length of fline */ +extern int ftype ; boolean fexist( const char *fname) ; fio_code ffclose( void) ; diff --git a/globals.c b/globals.c index 927acd1..3fd13b1 100644 --- a/globals.c +++ b/globals.c @@ -13,13 +13,28 @@ int revexist = FALSE; /* does reverse video exist? */ int flickcode = FALSE; /* do flicker supression? */ const char *modename[] = { /* name of modes */ "WRAP", "CMODE", "SPELL", "EXACT", "VIEW", "OVER", - "MAGIC", "CRYPT", "ASAVE", "UTF-8", "DOS" + "MAGIC", +#if CRYPT + "CRYPT", +#else + "", +#endif + "ASAVE", "UTF-8", "DOS" }; + const char *mode2name[] = { /* name of modes */ "Wrap", "Cmode", "Spell", "Exact", "View", "Over", - "Magic", "Crypt", "Asave", "utf-8", "Dos" + "Magic", +#if CRYPT + "Crypt", +#else + "", +#endif + "Asave", "utf-8", "Dos" }; + const char modecode[] = "WCSEVOMYAUD"; /* letters to represent modes */ + int gmode = 0; /* global editor mode */ int gflags = GFREAD; /* global control flag */ #if PKCODE & IBMPC @@ -62,7 +77,6 @@ struct kill *kbufp = NULL; /* current kill buffer chunk pointer */ struct kill *kbufh = NULL; /* kill buffer header pointer */ int kused = KBLOCK; /* # of bytes used in kill buffer */ struct window *swindow = NULL; /* saved window pointer */ -int cryptflag = FALSE; /* currently encrypting? */ int *kbdptr; /* current position in keyboard buf */ int *kbdend = &kbdm[0]; /* ptr to end of the keyboard */ int kbdmode = STOP; /* current keyboard macro mode */ diff --git a/main.c b/main.c index b363967..99cfb76 100644 --- a/main.c +++ b/main.c @@ -114,7 +114,9 @@ static void usage( void) { " -a|A process error file\n" " -e|E edit file\n" " -g|G go to line \n" +#if CRYPT " -k|K use code key\n" +#endif " -n|N accept null chars\n" " -r|R restrictive use\n" " -s|S search string\n" From 45527243a064c1aafaceb8c4c6fa7dcbd383b449 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Mon, 10 Jun 2013 14:39:19 +0800 Subject: [PATCH 079/193] Avoid strlen & strncpy in reading lines from file. --- file.c | 4 ++-- fileio.c | 59 ++++++++++++++++++-------------------------------------- fileio.h | 3 ++- 3 files changed, 23 insertions(+), 43 deletions(-) diff --git a/file.c b/file.c index 8c8d02c..1d63cbe 100644 --- a/file.c +++ b/file.c @@ -275,7 +275,7 @@ int readin(char *fname, int lockfl) mlwrite("(Reading file)"); nline = 0; while ((s = ffgetline()) == FIOSUC) { - nbytes = strlen(fline); + nbytes = fpayload ; if ((lp1 = lalloc(nbytes)) == NULL) { s = FIOMEM; /* Keep message on the */ break; /* display. */ @@ -610,7 +610,7 @@ int ifile(char *fname) nline = 0; while ((s = ffgetline()) == FIOSUC) { - nbytes = strlen(fline); + nbytes = fpayload ; if ((lp1 = lalloc(nbytes)) == NULL) { s = FIOMEM; /* Keep message on the */ break; /* display. */ diff --git a/fileio.c b/fileio.c index 7d9f835..1401076 100644 --- a/fileio.c +++ b/fileio.c @@ -25,8 +25,9 @@ boolean is_crypted ; /* currently encrypting? */ #endif char *fline = NULL ; /* dynamic return line */ -int flen = 0 ; /* current length of fline */ +int flen = 0 ; /* current allocated length of fline */ int ftype ; +int fpayload ; /* actual length of fline content */ static FILE *ffp ; /* File pointer, all functions. */ @@ -139,7 +140,6 @@ fio_code ffgetline(void) { int c; /* current character read */ int i; /* current index into fline */ - char *tmpline; /* temp storage for expanding line */ /* if we are at the end...return it */ if (eofflag) @@ -157,48 +157,27 @@ fio_code ffgetline(void) return FIOMEM; /* read the line in */ -#if 0 /* PKCODE */ - if (!nullflag) { - if (fgets(fline, NSTRING, ffp) == (char *) NULL) { /* EOF ? */ - i = 0; - c = EOF; - } else { - i = strlen(fline); - c = 0; - if (i > 0) { - c = fline[i - 1]; - i--; - } - } - } else { - i = 0; - c = fgetc(ffp); - } - while (c != EOF && c != '\n') { -#else i = 0; while ((c = fgetc(ffp)) != EOF && c != '\r' && c != '\n') { -#endif -#if 0 /* PKCODE */ - if (c) { -#endif - fline[i++] = c; - /* if it's longer, get more room */ - if (i >= flen) { - if ((tmpline = - malloc(flen + NSTRING)) == NULL) - return FIOMEM; - strncpy(tmpline, fline, flen); - flen += NSTRING; - free(fline); - fline = tmpline; - } -#if 0 /* PKCODE */ + fline[i++] = c; + /* if it's longer, get more room */ + if (i >= flen) { + char *tmpline; /* temp storage for expanding line */ + + fpayload = i ; + tmpline = malloc(flen + NSTRING) ; + if( tmpline == NULL) + return FIOMEM ; + + memcpy( tmpline, fline, flen) ; + flen += NSTRING; + free(fline); + fline = tmpline; } - c = fgetc(ffp); -#endif } + fpayload = i ; + /* test for any errors that may have occured */ if (c == EOF) { if (ferror(ffp)) { @@ -224,7 +203,7 @@ fio_code ffgetline(void) fline[i] = 0; #if CRYPT if( is_crypted) - myencrypt(fline, strlen(fline)); + myencrypt( fline, fpayload); #endif return FIOSUC; } diff --git a/fileio.h b/fileio.h index fd2e482..704ab96 100644 --- a/fileio.h +++ b/fileio.h @@ -23,8 +23,9 @@ extern boolean is_crypted ; /* currently encrypting? */ #endif extern char *fline ; /* dynamic return line */ -extern int flen ; /* current length of fline */ +extern int flen ; /* current allocated length of fline */ extern int ftype ; +extern int fpayload ; /* actual length of fline content */ boolean fexist( const char *fname) ; fio_code ffclose( void) ; From b6c7a2cc80f2a9b00a2e00a57a7fe3b014898fea Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Mon, 10 Jun 2013 15:00:15 +0800 Subject: [PATCH 080/193] Remove default of disallowing null and option to allow it. Allow null is default and no option. --- edef.h | 1 - globals.c | 1 - main.c | 7 ------- 3 files changed, 9 deletions(-) diff --git a/edef.h b/edef.h index 9365f4f..feddb9a 100644 --- a/edef.h +++ b/edef.h @@ -82,7 +82,6 @@ extern char palstr[]; /* palette string */ extern int saveflag; /* Flags, saved with the $target var */ extern int rval; /* return value of a subprocess */ #if PKCODE -extern int nullflag; extern int justflag; /* justify, don't fill */ #endif extern int overlap; /* line overlap in forw/back page */ diff --git a/globals.c b/globals.c index 3fd13b1..0b35876 100644 --- a/globals.c +++ b/globals.c @@ -94,7 +94,6 @@ char palstr[49] = ""; /* palette string */ int saveflag = 0; /* Flags, saved with the $target var */ int rval = 0; /* return value of a subprocess */ #if PKCODE -int nullflag = FALSE; /* accept null characters */ int justflag = FALSE; /* justify, don't fill */ #endif int overlap = 0; /* line overlap in forw/back page */ diff --git a/main.c b/main.c index 99cfb76..cedd4dc 100644 --- a/main.c +++ b/main.c @@ -117,7 +117,6 @@ static void usage( void) { #if CRYPT " -k|K use code key\n" #endif - " -n|N accept null chars\n" " -r|R restrictive use\n" " -s|S search string\n" " -v|V view file\n" @@ -221,12 +220,6 @@ int main(int argc, char **argv) cryptflag = TRUE; strcpy(ekey, &argv[carg][2]); break; -#endif -#if PKCODE - case 'n': /* -n accept null chars */ - case 'N': - nullflag = TRUE; - break; #endif case 'r': /* -r restrictive use */ case 'R': From a3b5257bfe98fa67d3ebab75be1444bd27f60e18 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Mon, 10 Jun 2013 15:54:28 +0800 Subject: [PATCH 081/193] Use memcpy to fill in line structure when reading and inserting files. --- file.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/file.c b/file.c index 1d63cbe..fc3a9a3 100644 --- a/file.c +++ b/file.c @@ -227,7 +227,6 @@ int readin(char *fname, int lockfl) { struct line *lp1; struct line *lp2; - int i; struct window *wp; struct buffer *bp; int s; @@ -276,23 +275,22 @@ int readin(char *fname, int lockfl) nline = 0; while ((s = ffgetline()) == FIOSUC) { nbytes = fpayload ; - if ((lp1 = lalloc(nbytes)) == NULL) { - s = FIOMEM; /* Keep message on the */ - break; /* display. */ - } #if PKCODE if (nline > MAXNLINE) { s = FIOMEM; break; } #endif + if ((lp1 = lalloc(nbytes)) == NULL) { + s = FIOMEM; /* Keep message on the */ + break; /* display. */ + } lp2 = lback(curbp->b_linep); lp2->l_fp = lp1; lp1->l_fp = curbp->b_linep; lp1->l_bp = lp2; curbp->b_linep->l_bp = lp1; - for (i = 0; i < nbytes; ++i) - lputc(lp1, i, fline[i]); + memcpy( lp1->l_text, fline, nbytes) ; ++nline; } eoltype = ftype ; @@ -579,7 +577,6 @@ int ifile(char *fname) struct line *lp0; struct line *lp1; struct line *lp2; - int i; struct buffer *bp; int s; int nbytes; @@ -626,8 +623,7 @@ int ifile(char *fname) /* and advance and write out the current line */ curwp->w_dotp = lp1; - for (i = 0; i < nbytes; ++i) - lputc(lp1, i, fline[i]); + memcpy( lp1->l_text, fline, nbytes) ; ++nline; } ffclose(); /* Ignore errors. */ From fb395c3f01bad1a597af37758818a43d2f76e85f Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Mon, 10 Jun 2013 17:03:32 +0800 Subject: [PATCH 082/193] Cleanup encryption key setting by moving core to file. --- crypt.c | 39 ++------------------------------------- crypt.h | 5 ++++- ebind.c | 1 - file.c | 41 +++++++++++++++++++++++++++++++++++++---- file.h | 5 +++++ main.c | 6 ++---- names.c | 1 - 7 files changed, 50 insertions(+), 48 deletions(-) diff --git a/crypt.c b/crypt.c index 70b2fb5..3384410 100644 --- a/crypt.c +++ b/crypt.c @@ -9,47 +9,12 @@ * written by Dana Hoggatt and Daniel Lawrence */ -#include -#include "display.h" -#include "estruct.h" -#include "edef.h" -#include "input.h" - #if CRYPT +#include + static int mod95(int); -/* - * reset encryption key of current buffer - * - * int f; default flag - * int n; numeric argument - */ -int set_encryption_key(int f, int n) -{ - int status; /* return status */ - int odisinp; /* original vlaue of disinp */ - char key[NPAT]; /* new encryption string */ - - /* turn command input echo off */ - odisinp = disinp; - disinp = FALSE; - - /* get the string to use as an encrytion string */ - status = mlreply("Encryption String: ", key, NPAT - 1); - disinp = odisinp; - if (status != TRUE) - return status; - - /* and encrypt it */ - myencrypt((char *) NULL, 0); - myencrypt(key, strlen(key)); - - /* and save it off */ - strcpy(curbp->b_key, key); - mlwrite(" "); /* clear it off the bottom line */ - return TRUE; -} /********** * diff --git a/crypt.h b/crypt.h index 18951c2..7cfbaca 100644 --- a/crypt.h +++ b/crypt.h @@ -1,7 +1,10 @@ #ifndef _CRYPT_H_ #define _CRYPT_H_ -int set_encryption_key( int f, int n) ; +#include "estruct.h" + +#if CRYPT void myencrypt( char *bptr, unsigned len) ; +#endif #endif diff --git a/ebind.c b/ebind.c index 2f9e9ad..c43ab92 100644 --- a/ebind.c +++ b/ebind.c @@ -12,7 +12,6 @@ #include "bind.h" #include "bindable.h" #include "buffer.h" -#include "crypt.h" #include "eval.h" #include "exec.h" #include "file.h" diff --git a/file.c b/file.c index fc3a9a3..4312fc2 100644 --- a/file.c +++ b/file.c @@ -119,6 +119,41 @@ int viewfile(int f, int n) } #if CRYPT +void cryptbufferkey( struct buffer *bp) { + myencrypt( (char *) NULL, 0) ; + myencrypt( bp->b_key, strlen( bp->b_key)) ; +} + +/* + * reset encryption key of current buffer + * + * int f; default flag + * int n; numeric argument + */ +int set_encryption_key(int f, int n) +{ + int status; /* return status */ + int odisinp; /* original vlaue of disinp */ + char key[NPAT]; /* new encryption string */ + + /* turn command input echo off */ + odisinp = disinp; + disinp = FALSE; + + /* get the string to use as an encrytion string */ + status = mlreply("Encryption String: ", key, NPAT - 1); + disinp = odisinp; + if (status != TRUE) + return status; + + /* save it off and encrypt it*/ + strcpy(curbp->b_key, key); + cryptbufferkey( curbp) ; + + mlwrite(" "); /* clear it off the bottom line */ + return TRUE; +} + static int resetkey(void) { /* reset the encryption key if needed */ int s; /* return status */ @@ -139,12 +174,10 @@ static int resetkey(void) /* and set up the key to be used! */ /* de-encrypt it */ - myencrypt((char *) NULL, 0); - myencrypt(curbp->b_key, strlen(curbp->b_key)); + cryptbufferkey( curbp) ; /* re-encrypt it...seeding it to start */ - myencrypt((char *) NULL, 0); - myencrypt(curbp->b_key, strlen(curbp->b_key)); + cryptbufferkey( curbp) ; } return TRUE; diff --git a/file.h b/file.h index 886ce52..f2f1d55 100644 --- a/file.h +++ b/file.h @@ -1,6 +1,11 @@ #ifndef _FILE_H_ #define _FILE_H_ +#if CRYPT +void cryptbufferkey( struct buffer *bp) ; +int set_encryption_key( int f, int n) ; +#endif + int fileread( int f, int n) ; int insfile( int f, int n) ; int filefind( int f, int n) ; diff --git a/main.c b/main.c index cedd4dc..e6bd8eb 100644 --- a/main.c +++ b/main.c @@ -61,7 +61,6 @@ #include "bind.h" #include "bindable.h" #include "buffer.h" -#include "crypt.h" #include "display.h" #include "edef.h" /* Global definitions. */ #include "estruct.h" /* Global structures and defines. */ @@ -269,9 +268,8 @@ int main(int argc, char **argv) #if CRYPT if (cryptflag) { bp->b_mode |= MDCRYPT; - myencrypt((char *) NULL, 0); - myencrypt(ekey, strlen(ekey)); - strncpy(bp->b_key, ekey, NPAT); + strncpy( bp->b_key, ekey, NPAT) ; + cryptbufferkey( bp) ; } #endif } diff --git a/names.c b/names.c index 82dfa0b..e451240 100644 --- a/names.c +++ b/names.c @@ -15,7 +15,6 @@ #include "display.h" #include "eval.h" #include "exec.h" -#include "crypt.h" #include "file.h" #include "isearch.h" #include "line.h" From 5bbc6104ae8fa6be7d56d3f9f63b61161e6b68a5 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Mon, 10 Jun 2013 18:14:09 +0800 Subject: [PATCH 083/193] Move flook and fexist to flook tosimplify dependency graph. --- bind.c | 121 ++-------------------------------------------- bind.h | 2 - eval.c | 2 +- exec.c | 1 + fileio.c | 21 -------- fileio.h | 1 - flook.c | 144 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ flook.h | 9 ++++ 8 files changed, 158 insertions(+), 143 deletions(-) create mode 100644 flook.c create mode 100644 flook.h diff --git a/bind.c b/bind.c index 62f20b5..d5bd86f 100644 --- a/bind.c +++ b/bind.c @@ -18,45 +18,14 @@ #include "ebind.h" #include "exec.h" #include "file.h" -#include "fileio.h" +#include "flook.h" #include "input.h" #include "line.h" #include "names.h" #include "window.h" -/* possible names and paths of help files under different OSs */ -static const char *pathname[] = { -#if MSDOS - "emacs.rc", - "emacs.hlp", - "\\sys\\public\\", - "\\usr\\bin\\", - "\\bin\\", - "\\", - "" -#endif - -#if V7 | BSD | USG - ".emacsrc", - "emacs.hlp", -#if PKCODE - "/usr/global/lib/", "/usr/local/bin/", "/usr/local/lib/", -#endif - "/usr/local/", "/usr/lib/", "" -#endif - -#if VMS -{ - "emacs.rc", "emacs.hlp", "", -#if PKCODE - "sys$login:", "emacs_dir:", -#endif - "sys$sysdevice:[vmstools]" -#endif -}; - -#define PATHNAME_SIZE (sizeof pathname / sizeof pathname[ 0]) +static char *getfname( fn_t) ; int help(int f, int n) { /* give me some help!!!! @@ -508,90 +477,6 @@ int startup(char *sfname) return dofile(fname); } -/* - * Look up the existance of a file along the normal or PATH - * environment variable. Look first in the HOME directory if - * asked and possible - * - * char *fname; base file name to search for - * int hflag; Look in the HOME environment variable first? - */ -char *flook( const char *fname, int hflag) -{ - char *home; /* path to home directory */ - char *path; /* environmental PATH variable */ - char *sp; /* pointer into path spec */ - int i; /* index */ - static char fspec[NSTRING]; /* full path spec to search */ - -#if ENVFUNC - - if (hflag) { - home = getenv("HOME"); - if (home != NULL) { - /* build home dir file spec */ - strcpy(fspec, home); - strcat(fspec, "/"); - strcat(fspec, fname); - - /* and try it out */ - if (ffropen(fspec) == FIOSUC) { - ffclose(); - return fspec; - } - } - } -#endif - - /* always try the current directory first */ - strcpy( fspec, fname) ; - if( ffropen( fspec) == FIOSUC) { - ffclose() ; - return fspec ; - } -#if ENVFUNC - /* get the PATH variable */ - path = getenv("PATH"); - if (path != NULL) - while (*path) { - - /* build next possible file spec */ - sp = fspec; - while (*path && (*path != PATHCHR)) - *sp++ = *path++; - - /* add a terminating dir separator if we need it */ - if (sp != fspec) - *sp++ = '/'; - *sp = 0; - strcat(fspec, fname); - - /* and try it out */ - if (ffropen(fspec) == FIOSUC) { - ffclose(); - return fspec; - } - - if (*path == PATHCHR) - ++path; - } -#endif - - /* look it up via the old table method */ - for( i = 2; i < PATHNAME_SIZE ; i++) { - strcpy(fspec, pathname[i]); - strcat(fspec, fname); - - /* and try it out */ - if (ffropen(fspec) == FIOSUC) { - ffclose(); - return fspec; - } - } - - return NULL; /* no such luck */ -} - /* * change a key command to a string we can print out * @@ -659,7 +544,7 @@ int (*getbind(int c))(int, int) * This function takes a ptr to function and gets the name * associated with it. */ -char *getfname(fn_t func) +static char *getfname(fn_t func) { struct name_bind *nptr; /* pointer into the name binding table */ diff --git a/bind.h b/bind.h index ae7de26..a5efd9f 100644 --- a/bind.h +++ b/bind.h @@ -14,10 +14,8 @@ int buildlist( int type, char *mstring) ; int strinc( char *source, char *sub) ; unsigned int getckey( int mflag) ; int startup( char *sfname) ; -char *flook( const char *fname, int hflag) ; void cmdstr( int c, char *seq) ; fn_t getbind( int c) ; -char *getfname( fn_t) ; fn_t fncmatch( char *) ; unsigned int stock( char *keyname) ; char *transbind( char *skey) ; diff --git a/eval.c b/eval.c index d809351..2beff5a 100644 --- a/eval.c +++ b/eval.c @@ -17,7 +17,7 @@ #include "estruct.h" #include "edef.h" #include "exec.h" -#include "fileio.h" +#include "flook.h" #include "input.h" #include "line.h" #include "random.h" diff --git a/exec.c b/exec.c index d0cf737..a437523 100644 --- a/exec.c +++ b/exec.c @@ -19,6 +19,7 @@ #include "edef.h" #include "eval.h" #include "file.h" +#include "flook.h" #include "input.h" #include "line.h" diff --git a/fileio.c b/fileio.c index 1401076..7ae3508 100644 --- a/fileio.c +++ b/fileio.c @@ -207,24 +207,3 @@ fio_code ffgetline(void) #endif return FIOSUC; } - -/* - * does exist on disk? - * - * char *fname; file to check for existance - */ -boolean fexist( const char *fname) -{ - FILE *fp; - - /* try to open the file for reading */ - fp = fopen(fname, "r"); - - /* if it fails, just return false! */ - if (fp == NULL) - return FALSE; - - /* otherwise, close it and report true */ - fclose(fp); - return TRUE; -} diff --git a/fileio.h b/fileio.h index 704ab96..c6cb436 100644 --- a/fileio.h +++ b/fileio.h @@ -27,7 +27,6 @@ extern int flen ; /* current allocated length of fline */ extern int ftype ; extern int fpayload ; /* actual length of fline content */ -boolean fexist( const char *fname) ; fio_code ffclose( void) ; fio_code ffgetline( void) ; fio_code ffputline( unsigned char *buf, int nbuf, int dosflag) ; diff --git a/flook.c b/flook.c new file mode 100644 index 0000000..0524816 --- /dev/null +++ b/flook.c @@ -0,0 +1,144 @@ +/* flook.c -- implements flook.h */ +#include "flook.h" + + +#include +#include +#include + + +#include "fileio.h" + + +/* possible names and paths of help files under different OSs */ +const char *pathname[] = { +#if MSDOS + "emacs.rc", + "emacs.hlp", + "\\sys\\public\\", + "\\usr\\bin\\", + "\\bin\\", + "\\", + "" +#endif + +#if V7 | BSD | USG + ".emacsrc", + "emacs.hlp", +#if PKCODE + "/usr/global/lib/", "/usr/local/bin/", "/usr/local/lib/", +#endif + "/usr/local/", "/usr/lib/", "" +#endif + +#if VMS +{ + "emacs.rc", "emacs.hlp", "", +#if PKCODE + "sys$login:", "emacs_dir:", +#endif + "sys$sysdevice:[vmstools]" +#endif +}; + +#define PATHNAME_SIZE (sizeof pathname / sizeof pathname[ 0]) + + +/* + * does exist on disk? + * + * char *fname; file to check for existance + */ +boolean fexist( const char *fname) +{ + FILE *fp; + + /* try to open the file for reading */ + fp = fopen(fname, "r"); + + /* if it fails, just return false! */ + if (fp == NULL) + return FALSE; + + /* otherwise, close it and report true */ + fclose(fp); + return TRUE; +} + +/* + * Look up the existance of a file along the normal or PATH + * environment variable. Look first in the HOME directory if + * asked and possible + * + * char *fname; base file name to search for + * int hflag; Look in the HOME environment variable first? + */ +char *flook( const char *fname, int hflag) +{ + char *home; /* path to home directory */ + char *path; /* environmental PATH variable */ + char *sp; /* pointer into path spec */ + int i; /* index */ + static char fspec[NSTRING]; /* full path spec to search */ + +#if ENVFUNC + + if (hflag) { + home = getenv("HOME"); + if (home != NULL) { + /* build home dir file spec */ + strcpy(fspec, home); + strcat(fspec, "/"); + strcat(fspec, fname); + + /* and try it out */ + if( fexist( fspec)) + return fspec ; + } + } +#endif + + /* always try the current directory first */ + strcpy( fspec, fname) ; + if( fexist( fspec)) + return fspec ; + +#if ENVFUNC + /* get the PATH variable */ + path = getenv("PATH"); + if (path != NULL) + while (*path) { + + /* build next possible file spec */ + sp = fspec; + while (*path && (*path != PATHCHR)) + *sp++ = *path++; + + /* add a terminating dir separator if we need it */ + if (sp != fspec) + *sp++ = '/'; + *sp = 0; + strcat(fspec, fname); + + /* and try it out */ + if( fexist( fspec)) + return fspec ; + + if (*path == PATHCHR) + ++path; + } +#endif + + /* look it up via the old table method */ + for( i = 2; i < PATHNAME_SIZE ; i++) { + strcpy(fspec, pathname[i]); + strcat(fspec, fname); + + /* and try it out */ + if( fexist( fspec)) + return fspec ; + } + + return NULL; /* no such luck */ +} + diff --git a/flook.h b/flook.h new file mode 100644 index 0000000..3779644 --- /dev/null +++ b/flook.h @@ -0,0 +1,9 @@ +#include "estruct.h" + + +extern const char *pathname[] ; + + +boolean fexist( const char *fname) ; +char *flook( const char *fname, int hflag) ; + From d6058046fa3df7052db4310b69f3048d7c57a4e7 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Mon, 10 Jun 2013 18:15:32 +0800 Subject: [PATCH 084/193] Rerun make source and make depend. --- Makefile | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 4ea27dd..b04e40f 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ -# makefile for emacs, updated Thu, Jun 06, 2013 9:29:56 AM +# makefile for emacs, updated Mon, Jun 10, 2013 5:55:29 PM -SRC=ansi.c basic.c bind.c bindable.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c globals.c ibmpc.c input.c isearch.c line.c lock.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c -OBJ=ansi.o basic.o bind.o bindable.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o globals.o ibmpc.o input.o isearch.o line.o lock.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o -HDR=basic.h bind.h bindable.h buffer.h crypt.h display.h ebind.h edef.h efunc.h estruct.h eval.h exec.h execute.h file.h fileio.h input.h isearch.h line.h lock.h names.h pklock.h random.h region.h search.h spawn.h termio.h utf8.h version.h window.h word.h wrapper.h +SRC=ansi.c basic.c bind.c bindable.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c globals.c ibmpc.c input.c isearch.c line.c lock.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c +OBJ=ansi.o basic.o bind.o bindable.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o globals.o ibmpc.o input.o isearch.o line.o lock.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o +HDR=basic.h bind.h bindable.h buffer.h crypt.h display.h ebind.h edef.h efunc.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h names.h pklock.h random.h region.h search.h spawn.h termio.h utf8.h version.h window.h word.h wrapper.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -127,28 +127,28 @@ ansi.o: ansi.c estruct.h line.h utf8.h edef.h basic.o: basic.c basic.h display.h estruct.h line.h utf8.h edef.h input.h \ random.h word.h bind.o: bind.c bind.h edef.h estruct.h line.h utf8.h bindable.h buffer.h \ - display.h ebind.h exec.h file.h fileio.h input.h names.h window.h + display.h ebind.h exec.h file.h flook.h input.h names.h window.h bindable.o: bindable.c bindable.h buffer.h estruct.h line.h utf8.h \ display.h edef.h file.h input.h buffer.o: buffer.c buffer.h estruct.h line.h utf8.h display.h edef.h \ file.h input.h window.h -crypt.o: crypt.c crypt.h display.h estruct.h line.h utf8.h edef.h input.h +crypt.o: crypt.c crypt.h estruct.h line.h utf8.h display.o: display.c display.h estruct.h line.h utf8.h edef.h termio.h \ version.h wrapper.h window.h ebind.o: ebind.c ebind.h basic.h bind.h edef.h estruct.h line.h utf8.h \ - bindable.h buffer.h crypt.h eval.h exec.h file.h isearch.h random.h \ - region.h search.h spawn.h window.h word.h + bindable.h buffer.h eval.h exec.h file.h isearch.h random.h region.h \ + search.h spawn.h window.h word.h eval.o: eval.c eval.h estruct.h line.h utf8.h basic.h bind.h edef.h \ - buffer.h display.h exec.h fileio.h input.h random.h search.h termio.h \ + buffer.h display.h exec.h flook.h input.h random.h search.h termio.h \ version.h window.h exec.o: exec.c exec.h estruct.h line.h utf8.h buffer.h bind.h edef.h \ - display.h eval.h file.h input.h + display.h eval.h file.h flook.h input.h execute.o: execute.c edef.h estruct.h line.h utf8.h bind.h random.h \ display.h file.h file.o: file.c file.h buffer.h estruct.h line.h utf8.h crypt.h display.h \ edef.h execute.h fileio.h input.h lock.h window.h -fileio.o: fileio.c fileio.h crypt.h display.h estruct.h line.h utf8.h \ - edef.h +fileio.o: fileio.c fileio.h estruct.h line.h utf8.h display.h crypt.h +flook.o: flook.c flook.h estruct.h line.h utf8.h fileio.h globals.o: globals.c estruct.h line.h utf8.h edef.h ibmpc.o: ibmpc.c estruct.h line.h utf8.h edef.h input.o: input.c input.h edef.h estruct.h line.h utf8.h bind.h bindable.h \ @@ -158,11 +158,11 @@ isearch.o: isearch.c isearch.h basic.h display.h estruct.h line.h utf8.h \ line.o: line.c line.h utf8.h basic.h display.h estruct.h edef.h random.h lock.o: lock.c lock.h estruct.h line.h utf8.h display.h edef.h input.h main.o: main.c basic.h bind.h edef.h estruct.h line.h utf8.h bindable.h \ - buffer.h crypt.h display.h eval.h execute.h file.h input.h lock.h \ - random.h search.h termio.h version.h + buffer.h display.h eval.h execute.h file.h input.h lock.h random.h \ + search.h termio.h version.h names.o: names.c names.h basic.h bind.h edef.h estruct.h line.h utf8.h \ - bindable.h buffer.h display.h eval.h exec.h crypt.h file.h isearch.h \ - region.h random.h search.h spawn.h window.h word.h + bindable.h buffer.h display.h eval.h exec.h file.h isearch.h region.h \ + random.h search.h spawn.h window.h word.h pklock.o: pklock.c pklock.h estruct.h line.h utf8.h edef.h posix.o: posix.c termio.h random.o: random.c random.h basic.h display.h estruct.h line.h utf8.h \ From 0071ce8f5b14dc4a802179f9d445307c7d0da932 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 11 Jun 2013 09:51:29 +0800 Subject: [PATCH 085/193] Rebuild on Linux, rollback prototype of ffputline. --- Makefile | 63 ++++++++++++++++++++++++++++---------------------------- fileio.c | 4 ++-- fileio.h | 2 +- 3 files changed, 35 insertions(+), 34 deletions(-) diff --git a/Makefile b/Makefile index b04e40f..c2d1a19 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ -# makefile for emacs, updated Mon, Jun 10, 2013 5:55:29 PM +# makefile for emacs, updated Tue Jun 11 09:36:56 CST 2013 -SRC=ansi.c basic.c bind.c bindable.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c globals.c ibmpc.c input.c isearch.c line.c lock.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c -OBJ=ansi.o basic.o bind.o bindable.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o globals.o ibmpc.o input.o isearch.o line.o lock.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o -HDR=basic.h bind.h bindable.h buffer.h crypt.h display.h ebind.h edef.h efunc.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h names.h pklock.h random.h region.h search.h spawn.h termio.h utf8.h version.h window.h word.h wrapper.h +SRC=ansi.c basic.c bindable.c bind.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c globals.c ibmpc.c input.c isearch.c line.c lock.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c +OBJ=ansi.o basic.o bindable.o bind.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o globals.o ibmpc.o input.o isearch.o line.o lock.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o +HDR=basic.h bindable.h bind.h buffer.h crypt.h display.h ebind.h edef.h efunc.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h names.h pklock.h random.h region.h search.h spawn.h termio.h utf8.h version.h window.h word.h wrapper.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -125,62 +125,63 @@ depend: ${SRC} ansi.o: ansi.c estruct.h line.h utf8.h edef.h basic.o: basic.c basic.h display.h estruct.h line.h utf8.h edef.h input.h \ - random.h word.h -bind.o: bind.c bind.h edef.h estruct.h line.h utf8.h bindable.h buffer.h \ - display.h ebind.h exec.h file.h flook.h input.h names.h window.h + random.h word.h bindable.o: bindable.c bindable.h buffer.h estruct.h line.h utf8.h \ - display.h edef.h file.h input.h + display.h edef.h file.h input.h +bind.o: bind.c bind.h edef.h estruct.h line.h utf8.h bindable.h buffer.h \ + display.h ebind.h exec.h file.h flook.h input.h names.h window.h buffer.o: buffer.c buffer.h estruct.h line.h utf8.h display.h edef.h \ - file.h input.h window.h + file.h input.h window.h crypt.o: crypt.c crypt.h estruct.h line.h utf8.h display.o: display.c display.h estruct.h line.h utf8.h edef.h termio.h \ - version.h wrapper.h window.h + version.h wrapper.h window.h ebind.o: ebind.c ebind.h basic.h bind.h edef.h estruct.h line.h utf8.h \ - bindable.h buffer.h eval.h exec.h file.h isearch.h random.h region.h \ - search.h spawn.h window.h word.h + bindable.h buffer.h eval.h exec.h file.h isearch.h random.h region.h \ + search.h spawn.h window.h word.h eval.o: eval.c eval.h estruct.h line.h utf8.h basic.h bind.h edef.h \ - buffer.h display.h exec.h flook.h input.h random.h search.h termio.h \ - version.h window.h + buffer.h display.h exec.h flook.h input.h random.h search.h termio.h \ + version.h window.h exec.o: exec.c exec.h estruct.h line.h utf8.h buffer.h bind.h edef.h \ - display.h eval.h file.h flook.h input.h + display.h eval.h file.h flook.h input.h execute.o: execute.c edef.h estruct.h line.h utf8.h bind.h random.h \ - display.h file.h + display.h file.h file.o: file.c file.h buffer.h estruct.h line.h utf8.h crypt.h display.h \ - edef.h execute.h fileio.h input.h lock.h window.h + edef.h execute.h fileio.h input.h lock.h window.h fileio.o: fileio.c fileio.h estruct.h line.h utf8.h display.h crypt.h flook.o: flook.c flook.h estruct.h line.h utf8.h fileio.h globals.o: globals.c estruct.h line.h utf8.h edef.h ibmpc.o: ibmpc.c estruct.h line.h utf8.h edef.h input.o: input.c input.h edef.h estruct.h line.h utf8.h bind.h bindable.h \ - display.h exec.h names.h wrapper.h + display.h exec.h names.h wrapper.h isearch.o: isearch.c isearch.h basic.h display.h estruct.h line.h utf8.h \ - edef.h input.h search.h + edef.h input.h search.h line.o: line.c line.h utf8.h basic.h display.h estruct.h edef.h random.h -lock.o: lock.c lock.h estruct.h line.h utf8.h display.h edef.h input.h +lock.o: lock.c lock.h estruct.h line.h utf8.h display.h edef.h input.h \ + pklock.h main.o: main.c basic.h bind.h edef.h estruct.h line.h utf8.h bindable.h \ - buffer.h display.h eval.h execute.h file.h input.h lock.h random.h \ - search.h termio.h version.h + buffer.h display.h eval.h execute.h file.h input.h lock.h random.h \ + search.h termio.h version.h names.o: names.c names.h basic.h bind.h edef.h estruct.h line.h utf8.h \ - bindable.h buffer.h display.h eval.h exec.h file.h isearch.h region.h \ - random.h search.h spawn.h window.h word.h + bindable.h buffer.h display.h eval.h exec.h file.h isearch.h region.h \ + random.h search.h spawn.h window.h word.h pklock.o: pklock.c pklock.h estruct.h line.h utf8.h edef.h -posix.o: posix.c termio.h +posix.o: posix.c termio.h estruct.h line.h utf8.h edef.h random.o: random.c random.h basic.h display.h estruct.h line.h utf8.h \ - edef.h execute.h input.h search.h + edef.h execute.h input.h search.h region.o: region.c region.h estruct.h line.h utf8.h display.h edef.h search.o: search.c search.h estruct.h line.h utf8.h basic.h display.h \ - edef.h input.h + edef.h input.h spawn.o: spawn.c spawn.h buffer.h estruct.h line.h utf8.h display.h \ - edef.h file.h input.h window.h + edef.h file.h input.h window.h tcap.o: tcap.c display.h estruct.h line.h utf8.h edef.h termio.h -termio.o: termio.c termio.h estruct.h line.h utf8.h edef.h +termio.o: termio.c termio.h utf8.o: utf8.c utf8.h vmsvt.o: vmsvt.c estruct.h line.h utf8.h edef.h vt52.o: vt52.c estruct.h line.h utf8.h edef.h window.o: window.c window.h estruct.h line.h utf8.h basic.h display.h \ - edef.h execute.h wrapper.h + edef.h execute.h wrapper.h word.o: word.c word.h basic.h display.h estruct.h line.h utf8.h edef.h \ - random.h region.h + random.h region.h wrapper.o: wrapper.c wrapper.h # DEPENDENCIES MUST END AT END OF FILE diff --git a/fileio.c b/fileio.c index 7ae3508..4d17a45 100644 --- a/fileio.c +++ b/fileio.c @@ -100,13 +100,13 @@ fio_code ffclose(void) * and the "nbuf" is its length, less the free newline. Return the status. * Check only at the newline. */ -fio_code ffputline( unsigned char *buf, int nbuf, int dosflag) { +fio_code ffputline( char *buf, int nbuf, int dosflag) { #if CRYPT if( is_crypted) { int i ; for( i = 0 ; i < nbuf ; i++) { - unsigned char c ; + char c ; c = buf[ i] ; myencrypt( &c, 1) ; diff --git a/fileio.h b/fileio.h index c6cb436..0d47f47 100644 --- a/fileio.h +++ b/fileio.h @@ -29,7 +29,7 @@ extern int fpayload ; /* actual length of fline content */ fio_code ffclose( void) ; fio_code ffgetline( void) ; -fio_code ffputline( unsigned char *buf, int nbuf, int dosflag) ; +fio_code ffputline( char *buf, int nbuf, int dosflag) ; fio_code ffropen( const char *fn) ; fio_code ffwopen( const char *fn) ; From 423c45f2ccc5cb3e3d7840b0f76147115d4df84b Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 11 Jun 2013 11:53:08 +0800 Subject: [PATCH 086/193] Move mlwrite calls from fileio to file to avoid dependencies of fileio towards display. --- Makefile | 65 ++++++++++++++++++++++++++++---------------------------- file.c | 13 ++++++++++-- fileio.c | 23 +++++++------------- 3 files changed, 51 insertions(+), 50 deletions(-) diff --git a/Makefile b/Makefile index c2d1a19..58377ae 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ -# makefile for emacs, updated Tue Jun 11 09:36:56 CST 2013 +# makefile for emacs, updated Tue, Jun 11, 2013 11:00:52 AM -SRC=ansi.c basic.c bindable.c bind.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c globals.c ibmpc.c input.c isearch.c line.c lock.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c -OBJ=ansi.o basic.o bindable.o bind.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o globals.o ibmpc.o input.o isearch.o line.o lock.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o -HDR=basic.h bindable.h bind.h buffer.h crypt.h display.h ebind.h edef.h efunc.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h names.h pklock.h random.h region.h search.h spawn.h termio.h utf8.h version.h window.h word.h wrapper.h +SRC=ansi.c basic.c bind.c bindable.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c globals.c ibmpc.c input.c isearch.c line.c lock.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c +OBJ=ansi.o basic.o bind.o bindable.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o globals.o ibmpc.o input.o isearch.o line.o lock.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o +HDR=basic.h bind.h bindable.h buffer.h crypt.h display.h ebind.h edef.h efunc.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h names.h pklock.h random.h region.h search.h spawn.h termio.h utf8.h version.h window.h word.h wrapper.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -125,63 +125,62 @@ depend: ${SRC} ansi.o: ansi.c estruct.h line.h utf8.h edef.h basic.o: basic.c basic.h display.h estruct.h line.h utf8.h edef.h input.h \ - random.h word.h -bindable.o: bindable.c bindable.h buffer.h estruct.h line.h utf8.h \ - display.h edef.h file.h input.h + random.h word.h bind.o: bind.c bind.h edef.h estruct.h line.h utf8.h bindable.h buffer.h \ - display.h ebind.h exec.h file.h flook.h input.h names.h window.h + display.h ebind.h exec.h file.h flook.h input.h names.h window.h +bindable.o: bindable.c bindable.h buffer.h estruct.h line.h utf8.h \ + display.h edef.h file.h input.h buffer.o: buffer.c buffer.h estruct.h line.h utf8.h display.h edef.h \ - file.h input.h window.h + file.h input.h window.h crypt.o: crypt.c crypt.h estruct.h line.h utf8.h display.o: display.c display.h estruct.h line.h utf8.h edef.h termio.h \ - version.h wrapper.h window.h + version.h wrapper.h window.h ebind.o: ebind.c ebind.h basic.h bind.h edef.h estruct.h line.h utf8.h \ - bindable.h buffer.h eval.h exec.h file.h isearch.h random.h region.h \ - search.h spawn.h window.h word.h + bindable.h buffer.h eval.h exec.h file.h isearch.h random.h region.h \ + search.h spawn.h window.h word.h eval.o: eval.c eval.h estruct.h line.h utf8.h basic.h bind.h edef.h \ - buffer.h display.h exec.h flook.h input.h random.h search.h termio.h \ - version.h window.h + buffer.h display.h exec.h flook.h input.h random.h search.h termio.h \ + version.h window.h exec.o: exec.c exec.h estruct.h line.h utf8.h buffer.h bind.h edef.h \ - display.h eval.h file.h flook.h input.h + display.h eval.h file.h flook.h input.h execute.o: execute.c edef.h estruct.h line.h utf8.h bind.h random.h \ - display.h file.h + display.h file.h file.o: file.c file.h buffer.h estruct.h line.h utf8.h crypt.h display.h \ - edef.h execute.h fileio.h input.h lock.h window.h -fileio.o: fileio.c fileio.h estruct.h line.h utf8.h display.h crypt.h + edef.h execute.h fileio.h input.h lock.h window.h +fileio.o: fileio.c fileio.h estruct.h line.h utf8.h crypt.h flook.o: flook.c flook.h estruct.h line.h utf8.h fileio.h globals.o: globals.c estruct.h line.h utf8.h edef.h ibmpc.o: ibmpc.c estruct.h line.h utf8.h edef.h input.o: input.c input.h edef.h estruct.h line.h utf8.h bind.h bindable.h \ - display.h exec.h names.h wrapper.h + display.h exec.h names.h wrapper.h isearch.o: isearch.c isearch.h basic.h display.h estruct.h line.h utf8.h \ - edef.h input.h search.h + edef.h input.h search.h line.o: line.c line.h utf8.h basic.h display.h estruct.h edef.h random.h -lock.o: lock.c lock.h estruct.h line.h utf8.h display.h edef.h input.h \ - pklock.h +lock.o: lock.c lock.h estruct.h line.h utf8.h display.h edef.h input.h main.o: main.c basic.h bind.h edef.h estruct.h line.h utf8.h bindable.h \ - buffer.h display.h eval.h execute.h file.h input.h lock.h random.h \ - search.h termio.h version.h + buffer.h display.h eval.h execute.h file.h input.h lock.h random.h \ + search.h termio.h version.h names.o: names.c names.h basic.h bind.h edef.h estruct.h line.h utf8.h \ - bindable.h buffer.h display.h eval.h exec.h file.h isearch.h region.h \ - random.h search.h spawn.h window.h word.h + bindable.h buffer.h display.h eval.h exec.h file.h isearch.h region.h \ + random.h search.h spawn.h window.h word.h pklock.o: pklock.c pklock.h estruct.h line.h utf8.h edef.h -posix.o: posix.c termio.h estruct.h line.h utf8.h edef.h +posix.o: posix.c termio.h random.o: random.c random.h basic.h display.h estruct.h line.h utf8.h \ - edef.h execute.h input.h search.h + edef.h execute.h input.h search.h region.o: region.c region.h estruct.h line.h utf8.h display.h edef.h search.o: search.c search.h estruct.h line.h utf8.h basic.h display.h \ - edef.h input.h + edef.h input.h spawn.o: spawn.c spawn.h buffer.h estruct.h line.h utf8.h display.h \ - edef.h file.h input.h window.h + edef.h file.h input.h window.h tcap.o: tcap.c display.h estruct.h line.h utf8.h edef.h termio.h -termio.o: termio.c termio.h +termio.o: termio.c termio.h estruct.h line.h utf8.h edef.h utf8.o: utf8.c utf8.h vmsvt.o: vmsvt.c estruct.h line.h utf8.h edef.h vt52.o: vt52.c estruct.h line.h utf8.h edef.h window.o: window.c window.h estruct.h line.h utf8.h basic.h display.h \ - edef.h execute.h wrapper.h + edef.h execute.h wrapper.h word.o: word.c word.h basic.h display.h estruct.h line.h utf8.h edef.h \ - random.h region.h + random.h region.h wrapper.o: wrapper.c wrapper.h # DEPENDENCIES MUST END AT END OF FILE diff --git a/file.c b/file.c index 4312fc2..1257d57 100644 --- a/file.c +++ b/file.c @@ -326,6 +326,10 @@ int readin(char *fname, int lockfl) memcpy( lp1->l_text, fline, nbytes) ; ++nline; } + + if( s == FIOERR) + mlwrite( "File read error") ; + eoltype = ftype ; if( ftype == FTYPE_DOS) curbp->b_mode |= MDDOS ; @@ -540,6 +544,7 @@ int writeout(char *fn) #endif if ((s = ffwopen(fn)) != FIOSUC) { /* Open writes message. */ + mlwrite( "Cannot open file for writing") ; return FALSE; } mlwrite("(Writing...)"); /* tell us were writing */ @@ -547,8 +552,11 @@ int writeout(char *fn) nline = 0; /* Number of lines. */ while (lp != curbp->b_linep) { s = ffputline( &lp->l_text[0], llength(lp), curbp->b_mode & MDDOS) ; - if( s != FIOSUC) + if( s != FIOSUC) { + mlwrite( "Write I/O error") ; break; + } + ++nline; lp = lforw(lp); } @@ -559,7 +567,8 @@ int writeout(char *fn) mlwrite("(Wrote 1 line)"); else mlwrite("(Wrote %d lines)", nline); - } + } else + mlwrite( "Error closing file") ; } else /* Ignore close error */ ffclose(); /* if a write error. */ if (s != FIOSUC) /* Some sort of error. */ diff --git a/fileio.c b/fileio.c index 4d17a45..2bcdf4d 100644 --- a/fileio.c +++ b/fileio.c @@ -15,7 +15,6 @@ #include #include "estruct.h" -#include "display.h" #if CRYPT @@ -56,13 +55,12 @@ fio_code ffwopen( const char *fn) int fd; if ((fd = creat(fn, 0666, "rfm=var", "rat=cr")) < 0 - || (ffp = fdopen(fd, "w")) == NULL) { + || (ffp = fdopen(fd, "w")) == NULL) #else - if ((ffp = fopen(fn, "w")) == NULL) { + if ((ffp = fopen(fn, "w")) == NULL) #endif - mlwrite("Cannot open file for writing"); return FIOERR; - } + return FIOSUC; } @@ -84,10 +82,9 @@ fio_code ffclose(void) #endif #if V7 | USG | BSD | (MSDOS & (MSC | TURBO)) - if (fclose(ffp) != FALSE) { - mlwrite("Error closing file"); + if (fclose(ffp) != FALSE) return FIOERR; - } + return FIOSUC; #else fclose(ffp); @@ -122,10 +119,8 @@ fio_code ffputline( char *buf, int nbuf, int dosflag) { fputc( '\n', ffp) ; - if( ferror( ffp)) { - mlwrite( "Write I/O error") ; + if( ferror( ffp)) return FIOERR ; - } return FIOSUC ; } @@ -180,10 +175,8 @@ fio_code ffgetline(void) /* test for any errors that may have occured */ if (c == EOF) { - if (ferror(ffp)) { - mlwrite("File read error"); - return FIOERR; - } + if( ferror( ffp)) + return FIOERR ; if (i != 0) eofflag = TRUE; From c7d2d30ab3c1b723673f75fbe9e118d954625f78 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 12 Jun 2013 10:41:28 +0800 Subject: [PATCH 087/193] Force buffer in view mode when reading mixed eol file. --- file.c | 56 ++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/file.c b/file.c index 1257d57..f8af380 100644 --- a/file.c +++ b/file.c @@ -31,6 +31,22 @@ #define MAXNLINE 10000000 #endif +typedef enum { + EOL_NONE, + EOL_UNIX, + EOL_DOS, + EOL_MAC, + EOL_MIXED +} eoltype ; + +static const char *eolname[] = { + "NONE", + "UNIX", + "DOS", + "MAC", + "MIXED" +} ; + /* * Read a file into the current * buffer. This is really easy; all you do it @@ -263,7 +279,7 @@ int readin(char *fname, int lockfl) struct window *wp; struct buffer *bp; int s; - int eoltype ; + eoltype found_eol ; int nbytes; int nline; char mesg[NSTRING]; @@ -330,9 +346,25 @@ int readin(char *fname, int lockfl) if( s == FIOERR) mlwrite( "File read error") ; - eoltype = ftype ; - if( ftype == FTYPE_DOS) + switch( ftype) { + case FTYPE_DOS: + found_eol = EOL_DOS ; curbp->b_mode |= MDDOS ; + break ; + case FTYPE_UNIX: + found_eol = EOL_UNIX ; + break ; + case FTYPE_MAC: + found_eol = EOL_MAC ; + break ; + case FTYPE_NONE: + found_eol = EOL_NONE ; + break ; + default: + found_eol = EOL_MIXED ; + curbp->b_mode |= MDVIEW ; /* add view mode as we have lost + ** information */ + } ffclose(); /* Ignore errors. */ strcpy(mesg, "("); @@ -349,23 +381,7 @@ int readin(char *fname, int lockfl) strcat(mesg, "s"); strcat( mesg, ", eol = ") ; - switch( eoltype) { - case FTYPE_DOS: - strcat( mesg, "DOS") ; - break ; - case FTYPE_UNIX: - strcat( mesg, "UNIX") ; - break ; - case FTYPE_MAC: - strcat( mesg, "MAC") ; - break ; - case FTYPE_NONE: - strcat( mesg, "NONE") ; - break ; - default: - strcat( mesg, "MIXED") ; - } - + strcat( mesg, eolname[ found_eol]) ; strcat(mesg, ")"); mlwrite(mesg); From 4cba352689f2880d62e68e26f5a9f05ccb50984d Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 12 Jun 2013 13:57:30 +0800 Subject: [PATCH 088/193] cleanup PKCODE variant in file --- file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/file.c b/file.c index f8af380..fe37bae 100644 --- a/file.c +++ b/file.c @@ -26,7 +26,7 @@ #include "lock.h" #include "window.h" -#if defined(PKCODE) +#if PKCODE /* Max number of lines from one file. */ #define MAXNLINE 10000000 #endif From 47c67446b0a5697b9d54cf8d491f6e88d729e495 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 12 Jun 2013 14:27:09 +0800 Subject: [PATCH 089/193] review naming and lookup of rc and hlp files. --- bind.c | 6 +++--- buffer.c | 2 +- buffer.h | 2 +- flook.h | 3 +++ 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bind.c b/bind.c index d5bd86f..a717fa5 100644 --- a/bind.c +++ b/bind.c @@ -36,10 +36,10 @@ int help(int f, int n) char *fname = NULL; /* ptr to file returned by flook() */ /* first check if we are already here */ - bp = bfind("emacs.hlp", FALSE, BFINVS); + bp = bfind( hlpfname, FALSE, BFINVS); if (bp == NULL) { - fname = flook(pathname[1], FALSE); + fname = flook( hlpfname, FALSE); if (fname == NULL) { mlwrite("(Help file is not online)"); return FALSE; @@ -467,7 +467,7 @@ int startup(char *sfname) if (*sfname != 0) fname = flook(sfname, TRUE); else - fname = flook(pathname[0], TRUE); + fname = flook( rcfname, TRUE); /* if it isn't around, don't sweat it */ if (fname == NULL) diff --git a/buffer.c b/buffer.c index 77b7bc2..ace29f0 100644 --- a/buffer.c +++ b/buffer.c @@ -451,7 +451,7 @@ int anycb(void) * and the "cflag" is TRUE, create it. The "bflag" is * the settings for the flags in in buffer. */ -struct buffer *bfind(char *bname, int cflag, int bflag) +struct buffer *bfind( const char *bname, int cflag, int bflag) { struct buffer *bp; struct buffer *sb; /* buffer to insert after */ diff --git a/buffer.h b/buffer.h index 3768346..04ce0b4 100644 --- a/buffer.h +++ b/buffer.h @@ -17,6 +17,6 @@ int anycb( void) ; int bclear( struct buffer *bp) ; int unmark( int f, int n) ; /* Lookup a buffer by name. */ -struct buffer *bfind( char *bname, int cflag, int bflag) ; +struct buffer *bfind( const char *bname, int cflag, int bflag) ; #endif diff --git a/flook.h b/flook.h index 3779644..8466659 100644 --- a/flook.h +++ b/flook.h @@ -1,6 +1,9 @@ #include "estruct.h" +#define rcfname pathname[ 0] +#define hlpfname pathname[ 1] + extern const char *pathname[] ; From 008852ada3fe037793118ff938f23c806f9e98f5 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Thu, 13 Jun 2013 19:16:46 +0800 Subject: [PATCH 090/193] Review buffer public interface. --- buffer.c | 12 +++++++++--- buffer.h | 3 --- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/buffer.c b/buffer.c index ace29f0..acddc03 100644 --- a/buffer.c +++ b/buffer.c @@ -22,6 +22,12 @@ #include "line.h" #include "window.h" + +static int makelist( int iflag) ; +static int addline( char *text) ; +static void ltoa( char *buf, int width, long num) ; + + /* * Attach a buffer to a window. The * values of dot and mark come from the buffer @@ -273,7 +279,7 @@ int listbuffers(int f, int n) * int iflag; list hidden buffer flag */ #define MAXLINE MAXCOL -int makelist(int iflag) +static int makelist( int iflag) { char *cp1; char *cp2; @@ -381,7 +387,7 @@ int makelist(int iflag) return TRUE; /* All done */ } -void ltoa(char *buf, int width, long num) +static void ltoa(char *buf, int width, long num) { buf[width] = 0; /* End of string. */ while (num >= 10) { /* Conditional digits. */ @@ -400,7 +406,7 @@ void ltoa(char *buf, int width, long num) * on the end. Return TRUE if it worked and * FALSE if you ran out of room. */ -int addline(char *text) +static int addline( char *text) { struct line *lp; int i; diff --git a/buffer.h b/buffer.h index 04ce0b4..2118c44 100644 --- a/buffer.h +++ b/buffer.h @@ -10,9 +10,6 @@ int killbuffer( int f, int n) ; int zotbuf( struct buffer *bp) ; int namebuffer( int f, int n) ; int listbuffers( int f, int n) ; -int makelist( int iflag) ; -void ltoa( char *buf, int width, long num) ; -int addline( char *text) ; int anycb( void) ; int bclear( struct buffer *bp) ; int unmark( int f, int n) ; From 287c55cbac4e55b8087ab47e813021bafe258483 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 14 Jun 2013 09:12:31 +0800 Subject: [PATCH 091/193] Insure consistency when REVSTA is off (no reverse status bar). --- display.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/display.c b/display.c index 22345ae..2fc1eb8 100644 --- a/display.c +++ b/display.c @@ -952,8 +952,10 @@ static int updateline(int row, struct video *vp1, struct video *vp2) unicode_t *cp4; unicode_t *cp5; int nbflag; /* non-blanks to the right flag? */ - int rev; /* reverse video flag */ - int req; /* reverse video request flag */ +#if REVSTA + int rev; /* reverse video flag */ +#endif + int req = FALSE ; /* reverse video request flag */ /* set up pointers to virtual and physical lines */ @@ -1098,7 +1100,7 @@ static void modeline(struct window *wp) #endif vtmove(n, 0); /* Seek to right line. */ if (wp == curwp) /* mark the current buffer */ -#if PKCODE +#if PKCODE && REVSTA lchar = '-'; #else lchar = '='; From 4f9598b5da79424e94daa8d852c336b76eb218d7 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 14 Jun 2013 11:53:59 +0800 Subject: [PATCH 092/193] review line dependencies. --- Makefile | 2 +- basic.c | 63 ---------------------------------------- basic.h | 2 -- eval.c | 25 ++++++++++++++++ line.c | 88 ++++++++++++++++++++++++++++++++++++++++---------------- line.h | 4 ++- 6 files changed, 92 insertions(+), 92 deletions(-) diff --git a/Makefile b/Makefile index 58377ae..b1f3f6f 100644 --- a/Makefile +++ b/Makefile @@ -155,7 +155,7 @@ input.o: input.c input.h edef.h estruct.h line.h utf8.h bind.h bindable.h \ display.h exec.h names.h wrapper.h isearch.o: isearch.c isearch.h basic.h display.h estruct.h line.h utf8.h \ edef.h input.h search.h -line.o: line.c line.h utf8.h basic.h display.h estruct.h edef.h random.h +line.o: line.c line.h utf8.h display.h estruct.h edef.h lock.o: lock.c lock.h estruct.h line.h utf8.h display.h edef.h input.h main.o: main.c basic.h bind.h edef.h estruct.h line.h utf8.h bindable.h \ buffer.h display.h eval.h execute.h file.h input.h lock.h random.h \ diff --git a/basic.c b/basic.c index 3705fd7..73bc4c7 100644 --- a/basic.c +++ b/basic.c @@ -69,38 +69,6 @@ int gotobol(int f, int n) return TRUE; } -/* - * Move the cursor backwards by "n" characters. If "n" is less than zero call - * "forwchar" to actually do the move. Otherwise compute the new cursor - * location. Error if you try and move out of the buffer. Set the flag if the - * line pointer for dot changes. - */ -int backchar(int f, int n) -{ - struct line *lp; - - if (n < 0) - return forwchar(f, -n); - while (n--) { - if (curwp->w_doto == 0) { - if ((lp = lback(curwp->w_dotp)) == curbp->b_linep) - return FALSE; - curwp->w_dotp = lp; - curwp->w_doto = llength(lp); - curwp->w_flag |= WFMOVE; - } else { - do { - unsigned char c; - curwp->w_doto--; - c = lgetc(curwp->w_dotp, curwp->w_doto); - if (is_beginning_utf8(c)) - break; - } while (curwp->w_doto); - } - } - return TRUE; -} - /* * Move the cursor to the end of the current line. Trivial. No errors. */ @@ -110,37 +78,6 @@ int gotoeol(int f, int n) return TRUE; } -/* - * Move the cursor forwards by "n" characters. If "n" is less than zero call - * "backchar" to actually do the move. Otherwise compute the new cursor - * location, and move ".". Error if you try and move off the end of the - * buffer. Set the flag if the line pointer for dot changes. - */ -int forwchar(int f, int n) -{ - if (n < 0) - return backchar(f, -n); - while (n--) { - int len = llength(curwp->w_dotp); - if (curwp->w_doto == len) { - if (curwp->w_dotp == curbp->b_linep) - return FALSE; - curwp->w_dotp = lforw(curwp->w_dotp); - curwp->w_doto = 0; - curwp->w_flag |= WFMOVE; - } else { - do { - unsigned char c; - curwp->w_doto++; - c = lgetc(curwp->w_dotp, curwp->w_doto); - if (is_beginning_utf8(c)) - break; - } while (curwp->w_doto < len); - } - } - return TRUE; -} - /* * Move to a particular line. * diff --git a/basic.h b/basic.h index cea1767..8ebbeea 100644 --- a/basic.h +++ b/basic.h @@ -2,9 +2,7 @@ #define _BASIC_H_ int gotobol( int f, int n) ; -int backchar( int f, int n) ; int gotoeol( int f, int n) ; -int forwchar( int f, int n) ; int gotoline( int f, int n) ; int gotobob( int f, int n) ; int gotoeob( int f, int n) ; diff --git a/eval.c b/eval.c index 2beff5a..5aee669 100644 --- a/eval.c +++ b/eval.c @@ -229,6 +229,31 @@ static struct { /* User variables */ static struct user_variable uv[MAXVARS + 1]; + +/* + * putctext: + * replace the current line with the passed in text + * + * char *iline; contents of new line + */ +static int putctext( char *iline) +{ + int status; + + /* delete the current line */ + curwp->w_doto = 0; /* starting at the beginning of the line */ + if ((status = killtext(TRUE, 1)) != TRUE) + return status; + + /* insert the new line */ + if ((status = linstr(iline)) != TRUE) + return status; + status = lnewline(); + backline(TRUE, 1); + return status; +} + + /* Initialize the user variable list. */ void varinit(void) { diff --git a/line.c b/line.c index 04b0079..556f6f4 100644 --- a/line.c +++ b/line.c @@ -17,17 +17,78 @@ #include -#include "basic.h" #include "display.h" #include "estruct.h" #include "edef.h" -#include "random.h" #include "utf8.h" #define BLOCK_SIZE 16 /* Line block chunk size. */ static int ldelnewline( void) ; +/* + * Move the cursor backwards by "n" characters. If "n" is less than zero call + * "forwchar" to actually do the move. Otherwise compute the new cursor + * location. Error if you try and move out of the buffer. Set the flag if the + * line pointer for dot changes. + */ +int backchar(int f, int n) +{ + struct line *lp; + + if (n < 0) + return forwchar(f, -n); + while (n--) { + if (curwp->w_doto == 0) { + if ((lp = lback(curwp->w_dotp)) == curbp->b_linep) + return FALSE; + curwp->w_dotp = lp; + curwp->w_doto = llength(lp); + curwp->w_flag |= WFMOVE; + } else { + do { + unsigned char c; + curwp->w_doto--; + c = lgetc(curwp->w_dotp, curwp->w_doto); + if (is_beginning_utf8(c)) + break; + } while (curwp->w_doto); + } + } + return TRUE; +} + +/* + * Move the cursor forwards by "n" characters. If "n" is less than zero call + * "backchar" to actually do the move. Otherwise compute the new cursor + * location, and move ".". Error if you try and move off the end of the + * buffer. Set the flag if the line pointer for dot changes. + */ +int forwchar(int f, int n) +{ + if (n < 0) + return backchar(f, -n); + while (n--) { + int len = llength(curwp->w_dotp); + if (curwp->w_doto == len) { + if (curwp->w_dotp == curbp->b_linep) + return FALSE; + curwp->w_dotp = lforw(curwp->w_dotp); + curwp->w_doto = 0; + curwp->w_flag |= WFMOVE; + } else { + do { + unsigned char c; + curwp->w_doto++; + c = lgetc(curwp->w_dotp, curwp->w_doto); + if (is_beginning_utf8(c)) + break; + } while (curwp->w_doto < len); + } + } + return TRUE; +} + /* * This routine allocates a block of memory large enough to hold a struct line * containing "used" characters. The block is always rounded up a bit. Return @@ -485,29 +546,6 @@ char *getctext(void) return rline; } -/* - * putctext: - * replace the current line with the passed in text - * - * char *iline; contents of new line - */ -int putctext(char *iline) -{ - int status; - - /* delete the current line */ - curwp->w_doto = 0; /* starting at the beginning of the line */ - if ((status = killtext(TRUE, 1)) != TRUE) - return status; - - /* insert the new line */ - if ((status = linstr(iline)) != TRUE) - return status; - status = lnewline(); - backline(TRUE, 1); - return status; -} - /* * Delete a newline. Join the current line with the next line. If the next line * is the magic header line always return TRUE; merging the last line with the diff --git a/line.h b/line.h index d649ee7..248adb3 100644 --- a/line.h +++ b/line.h @@ -25,6 +25,9 @@ struct line { #define lputc(lp, n, c) ((lp)->l_text[(n)]=(c)) #define llength(lp) ((lp)->l_used) +int backchar( int f, int n) ; +int forwchar( int f, int n) ; + void lfree( struct line *lp) ; void lchange( int flag) ; int insspace( int f, int n) ; @@ -36,7 +39,6 @@ int ldelete( long n, int kflag) ; int ldelchar( long n, int kflag) ; int lgetchar( unicode_t *) ; char *getctext( void) ; -int putctext( char *iline) ; void kdelete( void) ; int kinsert( int c) ; int yank( int f, int n) ; From 03bd7dd90238465144457c372762c46c62576f01 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 14 Jun 2013 17:35:35 +0800 Subject: [PATCH 093/193] Make line independant of display by introducing instanciable logwrite. --- Makefile | 15 ++++++++------- line.c | 10 +++++----- log.c | 6 ++++++ log.h | 2 ++ main.c | 2 ++ 5 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 log.c create mode 100644 log.h diff --git a/Makefile b/Makefile index b1f3f6f..21a0dd2 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ -# makefile for emacs, updated Tue, Jun 11, 2013 11:00:52 AM +# makefile for emacs, updated Fri, Jun 14, 2013 5:12:57 PM -SRC=ansi.c basic.c bind.c bindable.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c globals.c ibmpc.c input.c isearch.c line.c lock.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c -OBJ=ansi.o basic.o bind.o bindable.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o globals.o ibmpc.o input.o isearch.o line.o lock.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o -HDR=basic.h bind.h bindable.h buffer.h crypt.h display.h ebind.h edef.h efunc.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h names.h pklock.h random.h region.h search.h spawn.h termio.h utf8.h version.h window.h word.h wrapper.h +SRC=ansi.c basic.c bind.c bindable.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c globals.c ibmpc.c input.c isearch.c line.c lock.c log.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c +OBJ=ansi.o basic.o bind.o bindable.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o globals.o ibmpc.o input.o isearch.o line.o lock.o log.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o +HDR=basic.h bind.h bindable.h buffer.h crypt.h display.h ebind.h edef.h efunc.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h log.h names.h pklock.h random.h region.h search.h spawn.h termio.h utf8.h version.h window.h word.h wrapper.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -155,11 +155,12 @@ input.o: input.c input.h edef.h estruct.h line.h utf8.h bind.h bindable.h \ display.h exec.h names.h wrapper.h isearch.o: isearch.c isearch.h basic.h display.h estruct.h line.h utf8.h \ edef.h input.h search.h -line.o: line.c line.h utf8.h display.h estruct.h edef.h +line.o: line.c line.h utf8.h display.h estruct.h edef.h log.h lock.o: lock.c lock.h estruct.h line.h utf8.h display.h edef.h input.h +log.o: log.c log.h main.o: main.c basic.h bind.h edef.h estruct.h line.h utf8.h bindable.h \ - buffer.h display.h eval.h execute.h file.h input.h lock.h random.h \ - search.h termio.h version.h + buffer.h display.h eval.h execute.h file.h input.h lock.h log.h \ + random.h search.h termio.h version.h names.o: names.c names.h basic.h bind.h edef.h estruct.h line.h utf8.h \ bindable.h buffer.h display.h eval.h exec.h file.h isearch.h region.h \ random.h search.h spawn.h window.h word.h diff --git a/line.c b/line.c index 556f6f4..4ec2c0b 100644 --- a/line.c +++ b/line.c @@ -20,6 +20,7 @@ #include "display.h" #include "estruct.h" #include "edef.h" +#include "log.h" #include "utf8.h" #define BLOCK_SIZE 16 /* Line block chunk size. */ @@ -104,7 +105,7 @@ struct line *lalloc(int used) if (size == 0) /* Assume that is an empty. */ size = BLOCK_SIZE; /* Line is for type-in. */ if ((lp = (struct line *)malloc(sizeof(struct line) + size)) == NULL) { - mlwrite("(OUT OF MEMORY)"); + logwrite( "(OUT OF MEMORY)") ; return NULL; } lp->l_size = size; @@ -209,7 +210,7 @@ int linstr(char *instr) /* Insertion error? */ if (status != TRUE) { - mlwrite("%%Out of memory while inserting"); + logwrite( "%%Out of memory while inserting") ; break; } instr++; @@ -244,7 +245,7 @@ static int linsert_byte(int n, int c) lp1 = curwp->w_dotp; /* Current line */ if (lp1 == curbp->b_linep) { /* At the end: special */ if (curwp->w_doto != 0) { - mlwrite("bug: linsert"); + logwrite( "bug: linsert") ; return FALSE; } if ((lp2 = lalloc(n)) == NULL) /* Allocate new line */ @@ -352,8 +353,7 @@ int lover(char *ostr) /* Insertion error? */ if (status != TRUE) { - mlwrite - ("%%Out of memory while overwriting"); + logwrite( "%%Out of memory while overwriting") ; break; } ostr++; diff --git a/log.c b/log.c new file mode 100644 index 0000000..f918e37 --- /dev/null +++ b/log.c @@ -0,0 +1,6 @@ +#include "log.h" + +void logdump( const char *buf, ...) { +} + +void (*logwrite)( const char *, ...) = logdump ; diff --git a/log.h b/log.h new file mode 100644 index 0000000..eab0e46 --- /dev/null +++ b/log.h @@ -0,0 +1,2 @@ +extern void (*logwrite)( const char *, ...) ; + diff --git a/main.c b/main.c index e6bd8eb..743f9a8 100644 --- a/main.c +++ b/main.c @@ -69,6 +69,7 @@ #include "file.h" #include "input.h" #include "lock.h" +#include "log.h" #include "random.h" #include "search.h" #include "termio.h" @@ -175,6 +176,7 @@ int main(int argc, char **argv) /* Initialize the editor. */ vtinit(); /* Display */ + logwrite = mlwrite ; edinit("main"); /* Buffers, windows */ varinit(); /* user variables */ From 15012326db8c632666f419c360a93ad4b6385dc7 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sat, 14 Sep 2013 13:54:23 +0800 Subject: [PATCH 094/193] Compile under Cygwin64. --- Makefile | 51 +++++++++++++++++++++++++++------------------------ display.c | 3 ++- estruct.h | 2 +- flook.c | 7 ++++--- input.c | 2 +- 5 files changed, 35 insertions(+), 30 deletions(-) diff --git a/Makefile b/Makefile index 21a0dd2..7c13391 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# makefile for emacs, updated Fri, Jun 14, 2013 5:12:57 PM +# makefile for emacs, updated Sat, Sep 14, 2013 12:02:10 PM SRC=ansi.c basic.c bind.c bindable.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c globals.c ibmpc.c input.c isearch.c line.c lock.c log.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c OBJ=ansi.o basic.o bind.o bindable.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o globals.o ibmpc.o input.o isearch.o line.o lock.o log.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o @@ -41,6 +41,9 @@ endif ifeq ($(uname_S),CYGWIN_NT-6.1-WOW64) DEFINES=-DAUTOCONF -DCYGWIN -DPROGRAM=$(PROGRAM) endif +ifeq ($(uname_S),CYGWIN_NT-6.1) + DEFINES=-DAUTOCONF -DCYGWIN -DPROGRAM=$(PROGRAM) +endif #DEFINES=-DAUTOCONF #LIBS=-ltermcap # BSD LIBS=-lcurses # SYSV @@ -125,63 +128,63 @@ depend: ${SRC} ansi.o: ansi.c estruct.h line.h utf8.h edef.h basic.o: basic.c basic.h display.h estruct.h line.h utf8.h edef.h input.h \ - random.h word.h + random.h word.h bind.o: bind.c bind.h edef.h estruct.h line.h utf8.h bindable.h buffer.h \ - display.h ebind.h exec.h file.h flook.h input.h names.h window.h + display.h ebind.h exec.h file.h flook.h input.h names.h window.h bindable.o: bindable.c bindable.h buffer.h estruct.h line.h utf8.h \ - display.h edef.h file.h input.h + display.h edef.h file.h input.h buffer.o: buffer.c buffer.h estruct.h line.h utf8.h display.h edef.h \ - file.h input.h window.h + file.h input.h window.h crypt.o: crypt.c crypt.h estruct.h line.h utf8.h display.o: display.c display.h estruct.h line.h utf8.h edef.h termio.h \ - version.h wrapper.h window.h + version.h wrapper.h window.h ebind.o: ebind.c ebind.h basic.h bind.h edef.h estruct.h line.h utf8.h \ - bindable.h buffer.h eval.h exec.h file.h isearch.h random.h region.h \ - search.h spawn.h window.h word.h + bindable.h buffer.h eval.h exec.h file.h isearch.h random.h region.h \ + search.h spawn.h window.h word.h eval.o: eval.c eval.h estruct.h line.h utf8.h basic.h bind.h edef.h \ - buffer.h display.h exec.h flook.h input.h random.h search.h termio.h \ - version.h window.h + buffer.h display.h exec.h flook.h input.h random.h search.h termio.h \ + version.h window.h exec.o: exec.c exec.h estruct.h line.h utf8.h buffer.h bind.h edef.h \ - display.h eval.h file.h flook.h input.h + display.h eval.h file.h flook.h input.h execute.o: execute.c edef.h estruct.h line.h utf8.h bind.h random.h \ - display.h file.h + display.h file.h file.o: file.c file.h buffer.h estruct.h line.h utf8.h crypt.h display.h \ - edef.h execute.h fileio.h input.h lock.h window.h + edef.h execute.h fileio.h input.h lock.h window.h fileio.o: fileio.c fileio.h estruct.h line.h utf8.h crypt.h flook.o: flook.c flook.h estruct.h line.h utf8.h fileio.h globals.o: globals.c estruct.h line.h utf8.h edef.h ibmpc.o: ibmpc.c estruct.h line.h utf8.h edef.h input.o: input.c input.h edef.h estruct.h line.h utf8.h bind.h bindable.h \ - display.h exec.h names.h wrapper.h + display.h exec.h names.h wrapper.h isearch.o: isearch.c isearch.h basic.h display.h estruct.h line.h utf8.h \ - edef.h input.h search.h + edef.h input.h search.h line.o: line.c line.h utf8.h display.h estruct.h edef.h log.h lock.o: lock.c lock.h estruct.h line.h utf8.h display.h edef.h input.h log.o: log.c log.h main.o: main.c basic.h bind.h edef.h estruct.h line.h utf8.h bindable.h \ - buffer.h display.h eval.h execute.h file.h input.h lock.h log.h \ - random.h search.h termio.h version.h + buffer.h display.h eval.h execute.h file.h input.h lock.h log.h random.h \ + search.h termio.h version.h names.o: names.c names.h basic.h bind.h edef.h estruct.h line.h utf8.h \ - bindable.h buffer.h display.h eval.h exec.h file.h isearch.h region.h \ - random.h search.h spawn.h window.h word.h + bindable.h buffer.h display.h eval.h exec.h file.h isearch.h region.h \ + random.h search.h spawn.h window.h word.h pklock.o: pklock.c pklock.h estruct.h line.h utf8.h edef.h posix.o: posix.c termio.h random.o: random.c random.h basic.h display.h estruct.h line.h utf8.h \ - edef.h execute.h input.h search.h + edef.h execute.h input.h search.h region.o: region.c region.h estruct.h line.h utf8.h display.h edef.h search.o: search.c search.h estruct.h line.h utf8.h basic.h display.h \ - edef.h input.h + edef.h input.h spawn.o: spawn.c spawn.h buffer.h estruct.h line.h utf8.h display.h \ - edef.h file.h input.h window.h + edef.h file.h input.h window.h tcap.o: tcap.c display.h estruct.h line.h utf8.h edef.h termio.h termio.o: termio.c termio.h estruct.h line.h utf8.h edef.h utf8.o: utf8.c utf8.h vmsvt.o: vmsvt.c estruct.h line.h utf8.h edef.h vt52.o: vt52.c estruct.h line.h utf8.h edef.h window.o: window.c window.h estruct.h line.h utf8.h basic.h display.h \ - edef.h execute.h wrapper.h + edef.h execute.h wrapper.h word.o: word.c word.h basic.h display.h estruct.h line.h utf8.h edef.h \ - random.h region.h + random.h region.h wrapper.o: wrapper.c wrapper.h # DEPENDENCIES MUST END AT END OF FILE diff --git a/display.c b/display.c index 2fc1eb8..274db40 100644 --- a/display.c +++ b/display.c @@ -56,6 +56,8 @@ static int displaying = TRUE; #include /* for window size changes */ int chg_width, chg_height; + +static int newscreensize(int h, int w); #endif static int reframe(struct window *wp); @@ -71,7 +73,6 @@ static void modeline(struct window *wp); static void mlputi(int i, int r); static void mlputli(long l, int r); static void mlputf(int s); -static int newscreensize(int h, int w); #if RAINBOW static void putline(int row, int col, char *buf); diff --git a/estruct.h b/estruct.h index 82f4f5d..e443557 100644 --- a/estruct.h +++ b/estruct.h @@ -54,7 +54,7 @@ #undef BSD #endif -#if defined(SYSV) || defined(u3b2) || defined(_AIX) || (defined(i386) && defined(unix)) || defined(__hpux) +#if defined(SYSV) || defined(u3b2) || defined(_AIX) || (defined(i386) && defined(unix)) || defined(__hpux) || defined( CYGWIN) #define USG 1 /* System V UNIX */ #else #define USG 0 diff --git a/flook.c b/flook.c index 0524816..cde4fb5 100644 --- a/flook.c +++ b/flook.c @@ -75,15 +75,15 @@ boolean fexist( const char *fname) */ char *flook( const char *fname, int hflag) { - char *home; /* path to home directory */ - char *path; /* environmental PATH variable */ - char *sp; /* pointer into path spec */ int i; /* index */ static char fspec[NSTRING]; /* full path spec to search */ #if ENVFUNC + char *path; /* environmental PATH variable */ if (hflag) { + char *home; /* path to home directory */ + home = getenv("HOME"); if (home != NULL) { /* build home dir file spec */ @@ -108,6 +108,7 @@ char *flook( const char *fname, int hflag) path = getenv("PATH"); if (path != NULL) while (*path) { + char *sp; /* pointer into path spec */ /* build next possible file spec */ sp = fspec; diff --git a/input.c b/input.c index 1bd797d..8979157 100644 --- a/input.c +++ b/input.c @@ -345,9 +345,9 @@ int getcmd(void) #if VT220 proc_metac: -#endif if (c == 128+27) /* CSI */ goto handle_CSI; +#endif /* process META prefix */ if (c == (CONTROL | '[')) { c = get1key(); From e83feafda194767a6f744ed778cad5e01ebd3f4a Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sat, 14 Sep 2013 21:31:42 +0800 Subject: [PATCH 095/193] Minimize Cygwin64 changes & use __unix__ instead of CYGWIN. --- display.c | 3 +-- estruct.h | 2 +- flook.c | 7 +++---- input.c | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/display.c b/display.c index 274db40..2fc1eb8 100644 --- a/display.c +++ b/display.c @@ -56,8 +56,6 @@ static int displaying = TRUE; #include /* for window size changes */ int chg_width, chg_height; - -static int newscreensize(int h, int w); #endif static int reframe(struct window *wp); @@ -73,6 +71,7 @@ static void modeline(struct window *wp); static void mlputi(int i, int r); static void mlputli(long l, int r); static void mlputf(int s); +static int newscreensize(int h, int w); #if RAINBOW static void putline(int row, int col, char *buf); diff --git a/estruct.h b/estruct.h index e443557..120b871 100644 --- a/estruct.h +++ b/estruct.h @@ -54,7 +54,7 @@ #undef BSD #endif -#if defined(SYSV) || defined(u3b2) || defined(_AIX) || (defined(i386) && defined(unix)) || defined(__hpux) || defined( CYGWIN) +#if defined(SYSV) || defined(u3b2) || defined(_AIX) || (defined(i386) && defined(unix)) || defined(__hpux) || defined( __unix__) #define USG 1 /* System V UNIX */ #else #define USG 0 diff --git a/flook.c b/flook.c index cde4fb5..0524816 100644 --- a/flook.c +++ b/flook.c @@ -75,15 +75,15 @@ boolean fexist( const char *fname) */ char *flook( const char *fname, int hflag) { + char *home; /* path to home directory */ + char *path; /* environmental PATH variable */ + char *sp; /* pointer into path spec */ int i; /* index */ static char fspec[NSTRING]; /* full path spec to search */ #if ENVFUNC - char *path; /* environmental PATH variable */ if (hflag) { - char *home; /* path to home directory */ - home = getenv("HOME"); if (home != NULL) { /* build home dir file spec */ @@ -108,7 +108,6 @@ char *flook( const char *fname, int hflag) path = getenv("PATH"); if (path != NULL) while (*path) { - char *sp; /* pointer into path spec */ /* build next possible file spec */ sp = fspec; diff --git a/input.c b/input.c index 8979157..1bd797d 100644 --- a/input.c +++ b/input.c @@ -345,9 +345,9 @@ int getcmd(void) #if VT220 proc_metac: +#endif if (c == 128+27) /* CSI */ goto handle_CSI; -#endif /* process META prefix */ if (c == (CONTROL | '[')) { c = get1key(); From 451b12319a0bc16ef0bb0f08eb82c84fc3178964 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sat, 14 Sep 2013 22:01:16 +0800 Subject: [PATCH 096/193] Add assert to guard logic of static function activation. --- line.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/line.c b/line.c index 4ec2c0b..b3f7a77 100644 --- a/line.c +++ b/line.c @@ -15,6 +15,7 @@ #include "line.h" +#include #include #include "display.h" @@ -239,8 +240,11 @@ static int linsert_byte(int n, int c) int i; struct window *wp; + assert( (curbp->b_mode & MDVIEW) == 0) ; +#if 0 if (curbp->b_mode & MDVIEW) /* don't allow this command if */ return rdonly(); /* we are in read only mode */ +#endif lchange(WFEDIT); lp1 = curwp->w_dotp; /* Current line */ if (lp1 == curbp->b_linep) { /* At the end: special */ @@ -309,8 +313,13 @@ static int linsert_byte(int n, int c) int linsert(int n, int c) { char utf8[6]; - int bytes = unicode_to_utf8(c, utf8), i; + int bytes, i ; + assert( n > 0) ; + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return rdonly(); /* we are in read only mode */ + + bytes = unicode_to_utf8(c, utf8) ; if (bytes == 1) return linsert_byte(n, (unsigned char) utf8[0]); for (i = 0; i < n; i++) { @@ -564,8 +573,11 @@ static int ldelnewline(void) struct line *lp3; struct window *wp; + assert( (curbp->b_mode & MDVIEW) == 0) ; +#if 0 if (curbp->b_mode & MDVIEW) /* don't allow this command if */ return rdonly(); /* we are in read only mode */ +#endif lp1 = curwp->w_dotp; lp2 = lp1->l_fp; if (lp2 == curbp->b_linep) { /* At the buffer end. */ From 245c4a04775d5001ffcb6373406c4d1ecb7f4d80 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 18 Sep 2013 10:56:11 +0800 Subject: [PATCH 097/193] Remove dependencies from line to display: Move rdonly from display to loc and create instantiable function logger( retcode, beep, string). --- Makefile | 4 ++-- display.c | 11 ----------- line.c | 49 +++++++++++++++++++++++-------------------------- log.c | 26 +++++++++++++++++++++++++- log.h | 5 ++++- main.c | 9 +++++++++ 6 files changed, 63 insertions(+), 41 deletions(-) diff --git a/Makefile b/Makefile index 7c13391..c7ca249 100644 --- a/Makefile +++ b/Makefile @@ -158,9 +158,9 @@ input.o: input.c input.h edef.h estruct.h line.h utf8.h bind.h bindable.h \ display.h exec.h names.h wrapper.h isearch.o: isearch.c isearch.h basic.h display.h estruct.h line.h utf8.h \ edef.h input.h search.h -line.o: line.c line.h utf8.h display.h estruct.h edef.h log.h +line.o: line.c line.h utf8.h estruct.h edef.h log.h lock.o: lock.c lock.h estruct.h line.h utf8.h display.h edef.h input.h -log.o: log.c log.h +log.o: log.c log.h estruct.h line.h utf8.h main.o: main.c basic.h bind.h edef.h estruct.h line.h utf8.h bindable.h \ buffer.h display.h eval.h execute.h file.h input.h lock.h log.h random.h \ search.h termio.h version.h diff --git a/display.c b/display.c index 2fc1eb8..c754521 100644 --- a/display.c +++ b/display.c @@ -1553,17 +1553,6 @@ static int newscreensize(int h, int w) #endif -/* - * tell the user that this command is illegal while we are in - * VIEW (read-only) mode - */ -int rdonly(void) -{ - TTbeep(); - mlwrite("(Key illegal in VIEW mode)"); - return FALSE; -} - int resterr(void) { TTbeep(); diff --git a/line.c b/line.c index b3f7a77..366a9ed 100644 --- a/line.c +++ b/line.c @@ -18,7 +18,6 @@ #include #include -#include "display.h" #include "estruct.h" #include "edef.h" #include "log.h" @@ -199,24 +198,23 @@ int insspace(int f, int n) * linstr -- Insert a string at the current point */ -int linstr(char *instr) -{ - int status = TRUE; - char tmpc; +int linstr( char *instr) { + int status = TRUE ; - if (instr != NULL) - while ((tmpc = *instr) && status == TRUE) { + if( instr != NULL) { + char tmpc ; + + while( (tmpc = *instr++)) { status = - (tmpc == '\n' ? lnewline() : linsert(1, tmpc)); + (tmpc == '\n' ? lnewline() : linsert( 1, tmpc)) ; /* Insertion error? */ - if (status != TRUE) { - logwrite( "%%Out of memory while inserting") ; - break; - } - instr++; + if( status != TRUE) + return logger( status, FALSE, "%%Out of memory while inserting") ; } - return status; + } + + return status ; } /* @@ -350,24 +348,23 @@ static int lowrite(int c) /* * lover -- Overwrite a string at the current point */ -int lover(char *ostr) -{ - int status = TRUE; - char tmpc; +int lover( char *ostr) { + int status = TRUE ; - if (ostr != NULL) - while ((tmpc = *ostr) && status == TRUE) { + if (ostr != NULL) { + char tmpc ; + + while( (tmpc = *ostr++)) { status = (tmpc == '\n' ? lnewline() : lowrite(tmpc)); /* Insertion error? */ - if (status != TRUE) { - logwrite( "%%Out of memory while overwriting") ; - break; - } - ostr++; + if( status != TRUE) + return logger( status, FALSE, "%%Out of memory while overwriting") ; } - return status; + } + + return status ; } /* diff --git a/log.c b/log.c index f918e37..e33ef09 100644 --- a/log.c +++ b/log.c @@ -1,6 +1,30 @@ #include "log.h" -void logdump( const char *buf, ...) { +#include "estruct.h" + + +static void logdump( const char *buf, ...) { } void (*logwrite)( const char *, ...) = logdump ; + +static int logit( int retcode, int beep_f, const char *buf, ...) { + return retcode ; +} + +int (*logger)( int, int, const char *, ...) = logit ; + +/* + * tell the user that this command is illegal while we are in + * VIEW (read-only) mode + */ +int rdonly(void) +{ +/* TTbeep(); + mlwrite("(Key illegal in VIEW mode)"); + return FALSE; +*/ + return logger( FALSE, TRUE, "(Key illegal in VIEW mode)"); +} + + diff --git a/log.h b/log.h index eab0e46..8e74887 100644 --- a/log.h +++ b/log.h @@ -1,2 +1,5 @@ -extern void (*logwrite)( const char *, ...) ; +int rdonly( void) ; + +extern void (*logwrite)( const char *, ...) ; +extern int (*logger)( int, int, const char *, ...) ; diff --git a/main.c b/main.c index 743f9a8..20aa84c 100644 --- a/main.c +++ b/main.c @@ -124,6 +124,14 @@ static void usage( void) { } +static int mllog( int retcode, int beep_f, const char *buf, ...) { + if( beep_f) + TTbeep() ; + + mlwrite( buf) ; + return retcode ; +} + int main(int argc, char **argv) { int c = -1; /* command character */ @@ -177,6 +185,7 @@ int main(int argc, char **argv) /* Initialize the editor. */ vtinit(); /* Display */ logwrite = mlwrite ; + logger = mllog ; edinit("main"); /* Buffers, windows */ varinit(); /* user variables */ From 45ea35f2a73d40a1080ce7a1464bc4cd443c427d Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 18 Sep 2013 14:25:39 +0800 Subject: [PATCH 098/193] Move dependencies from display to log. --- Makefile | 14 +++++++------- display.c | 8 -------- display.h | 3 --- file.c | 38 +++++++++++++++++++------------------- log.c | 11 +++++++++++ log.h | 1 + random.c | 1 + region.c | 8 ++++---- search.c | 1 + spawn.c | 1 + word.c | 10 +++++----- 11 files changed, 50 insertions(+), 46 deletions(-) diff --git a/Makefile b/Makefile index c7ca249..724ee05 100644 --- a/Makefile +++ b/Makefile @@ -148,8 +148,8 @@ exec.o: exec.c exec.h estruct.h line.h utf8.h buffer.h bind.h edef.h \ display.h eval.h file.h flook.h input.h execute.o: execute.c edef.h estruct.h line.h utf8.h bind.h random.h \ display.h file.h -file.o: file.c file.h buffer.h estruct.h line.h utf8.h crypt.h display.h \ - edef.h execute.h fileio.h input.h lock.h window.h +file.o: file.c file.h buffer.h estruct.h line.h utf8.h crypt.h edef.h \ + execute.h fileio.h input.h lock.h log.h window.h fileio.o: fileio.c fileio.h estruct.h line.h utf8.h crypt.h flook.o: flook.c flook.h estruct.h line.h utf8.h fileio.h globals.o: globals.c estruct.h line.h utf8.h edef.h @@ -170,12 +170,12 @@ names.o: names.c names.h basic.h bind.h edef.h estruct.h line.h utf8.h \ pklock.o: pklock.c pklock.h estruct.h line.h utf8.h edef.h posix.o: posix.c termio.h random.o: random.c random.h basic.h display.h estruct.h line.h utf8.h \ - edef.h execute.h input.h search.h -region.o: region.c region.h estruct.h line.h utf8.h display.h edef.h + edef.h execute.h input.h log.h search.h +region.o: region.c region.h estruct.h line.h utf8.h edef.h log.h search.o: search.c search.h estruct.h line.h utf8.h basic.h display.h \ - edef.h input.h + edef.h input.h log.h spawn.o: spawn.c spawn.h buffer.h estruct.h line.h utf8.h display.h \ - edef.h file.h input.h window.h + edef.h file.h input.h log.h window.h tcap.o: tcap.c display.h estruct.h line.h utf8.h edef.h termio.h termio.o: termio.c termio.h estruct.h line.h utf8.h edef.h utf8.o: utf8.c utf8.h @@ -183,7 +183,7 @@ vmsvt.o: vmsvt.c estruct.h line.h utf8.h edef.h vt52.o: vt52.c estruct.h line.h utf8.h edef.h window.o: window.c window.h estruct.h line.h utf8.h basic.h display.h \ edef.h execute.h wrapper.h -word.o: word.c word.h basic.h display.h estruct.h line.h utf8.h edef.h \ +word.o: word.c word.h basic.h estruct.h line.h utf8.h edef.h log.h \ random.h region.h wrapper.o: wrapper.c wrapper.h diff --git a/display.c b/display.c index c754521..a27709a 100644 --- a/display.c +++ b/display.c @@ -1552,11 +1552,3 @@ static int newscreensize(int h, int w) } #endif - -int resterr(void) -{ - TTbeep(); - mlwrite("(That command is RESTRICTED)"); - return FALSE; -} - diff --git a/display.h b/display.h index 1bf987a..74e2785 100644 --- a/display.h +++ b/display.h @@ -20,7 +20,4 @@ void mlputs( char *s) ; void getscreensize( int *widthp, int *heightp) ; void sizesignal( int signr) ; -int rdonly( void) ; -int resterr( void) ; - #endif diff --git a/file.c b/file.c index fe37bae..40f8990 100644 --- a/file.c +++ b/file.c @@ -16,7 +16,6 @@ #include "buffer.h" #include "crypt.h" -#include "display.h" #include "estruct.h" #include "edef.h" #include "execute.h" @@ -24,6 +23,7 @@ #include "input.h" #include "line.h" #include "lock.h" +#include "log.h" #include "window.h" #if PKCODE @@ -166,7 +166,7 @@ int set_encryption_key(int f, int n) strcpy(curbp->b_key, key); cryptbufferkey( curbp) ; - mlwrite(" "); /* clear it off the bottom line */ + logwrite(" "); /* clear it off the bottom line */ return TRUE; } @@ -228,7 +228,7 @@ int getfile(char *fname, int lockfl) curwp->w_linep = lp; curwp->w_flag |= WFMODE | WFHARD; cknewwindow(); - mlwrite("(Old buffer)"); + logwrite("(Old buffer)"); return TRUE; } } @@ -244,7 +244,7 @@ int getfile(char *fname, int lockfl) } } if (bp == NULL && (bp = bfind(bname, TRUE, 0)) == NULL) { - mlwrite("Cannot create buffer"); + logwrite("Cannot create buffer"); return FALSE; } if (--curbp->b_nwnd == 0) { /* Undisplay. */ @@ -315,12 +315,12 @@ int readin(char *fname, int lockfl) goto out; if (s == FIOFNF) { /* File not found. */ - mlwrite("(New file)"); + logwrite("(New file)"); goto out; } /* read the file in */ - mlwrite("(Reading file)"); + logwrite("(Reading file)"); nline = 0; while ((s = ffgetline()) == FIOSUC) { nbytes = fpayload ; @@ -344,7 +344,7 @@ int readin(char *fname, int lockfl) } if( s == FIOERR) - mlwrite( "File read error") ; + logwrite( "File read error") ; switch( ftype) { case FTYPE_DOS: @@ -383,7 +383,7 @@ int readin(char *fname, int lockfl) strcat( mesg, ", eol = ") ; strcat( mesg, eolname[ found_eol]) ; strcat(mesg, ")"); - mlwrite(mesg); + logwrite(mesg); out: for (wp = wheadp; wp != NULL; wp = wp->w_wndp) { @@ -515,14 +515,14 @@ int filesave(int f, int n) if ((curbp->b_flag & BFCHG) == 0) /* Return, no changes. */ return TRUE; if (curbp->b_fname[0] == 0) { /* Must have a name. */ - mlwrite("No file name"); + logwrite("No file name"); return FALSE; } /* complain about truncated files */ if ((curbp->b_flag & BFTRUNC) != 0) { if (mlyesno("Truncated file ... write it out") == FALSE) { - mlwrite("(Aborted)"); + logwrite("(Aborted)"); return FALSE; } } @@ -560,16 +560,16 @@ int writeout(char *fn) #endif if ((s = ffwopen(fn)) != FIOSUC) { /* Open writes message. */ - mlwrite( "Cannot open file for writing") ; + logwrite( "Cannot open file for writing") ; return FALSE; } - mlwrite("(Writing...)"); /* tell us were writing */ + logwrite("(Writing...)"); /* tell us were writing */ lp = lforw(curbp->b_linep); /* First line. */ nline = 0; /* Number of lines. */ while (lp != curbp->b_linep) { s = ffputline( &lp->l_text[0], llength(lp), curbp->b_mode & MDDOS) ; if( s != FIOSUC) { - mlwrite( "Write I/O error") ; + logwrite( "Write I/O error") ; break; } @@ -580,11 +580,11 @@ int writeout(char *fn) s = ffclose(); if (s == FIOSUC) { /* No close error. */ if (nline == 1) - mlwrite("(Wrote 1 line)"); + logwrite("(Wrote 1 line)"); else - mlwrite("(Wrote %d lines)", nline); + logwrite("(Wrote %d lines)", nline); } else - mlwrite( "Error closing file") ; + logwrite( "Error closing file") ; } else /* Ignore close error */ ffclose(); /* if a write error. */ if (s != FIOSUC) /* Some sort of error. */ @@ -647,10 +647,10 @@ int ifile(char *fname) if ((s = ffropen(fname)) == FIOERR) /* Hard file open. */ goto out; if (s == FIOFNF) { /* File not found. */ - mlwrite("(No such file)"); + logwrite("(No such file)"); return FALSE; } - mlwrite("(Inserting file)"); + logwrite("(Inserting file)"); #if CRYPT s = resetkey(); @@ -699,7 +699,7 @@ int ifile(char *fname) if (nline > 1) strcat(mesg, "s"); strcat(mesg, ")"); - mlwrite(mesg); + logwrite(mesg); out: /* advance to the next line and mark the window for changes */ diff --git a/log.c b/log.c index e33ef09..98963a2 100644 --- a/log.c +++ b/log.c @@ -28,3 +28,14 @@ int rdonly(void) } + +int resterr(void) +{ +/* TTbeep(); + mlwrite("(That command is RESTRICTED)"); + return FALSE; +*/ + return logger( FALSE, TRUE, "(That command is RESTRICTED)"); +} + + diff --git a/log.h b/log.h index 8e74887..66c8beb 100644 --- a/log.h +++ b/log.h @@ -1,4 +1,5 @@ int rdonly( void) ; +int resterr( void) ; extern void (*logwrite)( const char *, ...) ; extern int (*logger)( int, int, const char *, ...) ; diff --git a/random.c b/random.c index 06e8160..dfbab69 100644 --- a/random.c +++ b/random.c @@ -18,6 +18,7 @@ #include "execute.h" #include "input.h" #include "line.h" +#include "log.h" #include "search.h" int tabsize; /* Tab size (0: use real tabs) */ diff --git a/region.c b/region.c index b2e4ec7..19e77f1 100644 --- a/region.c +++ b/region.c @@ -12,10 +12,10 @@ #include -#include "display.h" #include "estruct.h" #include "edef.h" #include "line.h" +#include "log.h" /* * Kill the region. Ask "getregion" @@ -72,7 +72,7 @@ int copyregion(int f, int n) ++loffs; } } - mlwrite("(region copied)"); + logwrite("(region copied)"); return TRUE; } @@ -169,7 +169,7 @@ int getregion(struct region *rp) long bsize; if (curwp->w_markp == NULL) { - mlwrite("No mark set in this window"); + logwrite("No mark set in this window"); return FALSE; } if (curwp->w_dotp == curwp->w_markp) { @@ -211,6 +211,6 @@ int getregion(struct region *rp) } } } - mlwrite("Bug: lost mark"); + logwrite("Bug: lost mark"); return FALSE; } diff --git a/search.c b/search.c index 9275829..372a067 100644 --- a/search.c +++ b/search.c @@ -68,6 +68,7 @@ #include "edef.h" #include "input.h" #include "line.h" +#include "log.h" #if defined(MAGIC) /* diff --git a/spawn.c b/spawn.c index ef9318c..3f61036 100644 --- a/spawn.c +++ b/spawn.c @@ -17,6 +17,7 @@ #include "edef.h" #include "file.h" #include "input.h" +#include "log.h" #include "window.h" #if VMS diff --git a/word.c b/word.c index 74aa0ac..da3b456 100644 --- a/word.c +++ b/word.c @@ -13,10 +13,10 @@ #include #include "basic.h" -#include "display.h" #include "estruct.h" #include "edef.h" #include "line.h" +#include "log.h" #include "random.h" #include "region.h" @@ -419,7 +419,7 @@ int fillpara(int f, int n) if (curbp->b_mode & MDVIEW) /* don't allow this command if */ return rdonly(); /* we are in read only mode */ if (fillcol == 0) { /* no fill column set */ - mlwrite("No fill column set"); + logwrite("No fill column set"); return FALSE; } #if PKCODE @@ -518,14 +518,14 @@ int justpara(int f, int n) if (curbp->b_mode & MDVIEW) /* don't allow this command if */ return rdonly(); /* we are in read only mode */ if (fillcol == 0) { /* no fill column set */ - mlwrite("No fill column set"); + logwrite("No fill column set"); return FALSE; } justflag = TRUE; leftmarg = curwp->w_doto; if (leftmarg + 10 > fillcol) { leftmarg = 0; - mlwrite("Column too narrow"); + logwrite("Column too narrow"); return FALSE; } @@ -710,7 +710,7 @@ int wordcount(int f, int n) else avgch = 0; - mlwrite("Words %D Chars %D Lines %d Avg chars/word %f", + logwrite("Words %D Chars %D Lines %d Avg chars/word %f", nwords, nchars, nlines + 1, avgch); return TRUE; } From c3bffda340e9b2e9ea95aea03cba3eb10139d1e5 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Thu, 19 Sep 2013 12:18:38 +0800 Subject: [PATCH 099/193] Extract retcode from estruct.h. Clean up log dependencies. --- Makefile | 112 ++++++++++++++++++++++++++++-------------------------- estruct.h | 20 +--------- log.c | 2 +- 3 files changed, 60 insertions(+), 74 deletions(-) diff --git a/Makefile b/Makefile index 724ee05..a6bcbe3 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ -# makefile for emacs, updated Sat, Sep 14, 2013 12:02:10 PM +# makefile for emacs, updated Thu, Sep 19, 2013 12:14:27 PM SRC=ansi.c basic.c bind.c bindable.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c globals.c ibmpc.c input.c isearch.c line.c lock.c log.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c OBJ=ansi.o basic.o bind.o bindable.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o globals.o ibmpc.o input.o isearch.o line.o lock.o log.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o -HDR=basic.h bind.h bindable.h buffer.h crypt.h display.h ebind.h edef.h efunc.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h log.h names.h pklock.h random.h region.h search.h spawn.h termio.h utf8.h version.h window.h word.h wrapper.h +HDR=basic.h bind.h bindable.h buffer.h crypt.h display.h ebind.h edef.h efunc.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h log.h names.h pklock.h random.h region.h retcode.h search.h spawn.h termio.h utf8.h version.h window.h word.h wrapper.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -126,65 +126,69 @@ depend: ${SRC} # DO NOT DELETE THIS LINE -- make depend uses it -ansi.o: ansi.c estruct.h line.h utf8.h edef.h -basic.o: basic.c basic.h display.h estruct.h line.h utf8.h edef.h input.h \ - random.h word.h -bind.o: bind.c bind.h edef.h estruct.h line.h utf8.h bindable.h buffer.h \ - display.h ebind.h exec.h file.h flook.h input.h names.h window.h +ansi.o: ansi.c estruct.h line.h utf8.h retcode.h edef.h +basic.o: basic.c basic.h display.h estruct.h line.h utf8.h retcode.h \ + edef.h input.h random.h word.h +bind.o: bind.c bind.h edef.h estruct.h line.h utf8.h retcode.h bindable.h \ + buffer.h display.h ebind.h exec.h file.h flook.h input.h names.h \ + window.h bindable.o: bindable.c bindable.h buffer.h estruct.h line.h utf8.h \ - display.h edef.h file.h input.h -buffer.o: buffer.c buffer.h estruct.h line.h utf8.h display.h edef.h \ - file.h input.h window.h -crypt.o: crypt.c crypt.h estruct.h line.h utf8.h -display.o: display.c display.h estruct.h line.h utf8.h edef.h termio.h \ - version.h wrapper.h window.h + retcode.h display.h edef.h file.h input.h +buffer.o: buffer.c buffer.h estruct.h line.h utf8.h retcode.h display.h \ + edef.h file.h input.h window.h +crypt.o: crypt.c crypt.h estruct.h line.h utf8.h retcode.h +display.o: display.c display.h estruct.h line.h utf8.h retcode.h edef.h \ + termio.h version.h wrapper.h window.h ebind.o: ebind.c ebind.h basic.h bind.h edef.h estruct.h line.h utf8.h \ - bindable.h buffer.h eval.h exec.h file.h isearch.h random.h region.h \ - search.h spawn.h window.h word.h -eval.o: eval.c eval.h estruct.h line.h utf8.h basic.h bind.h edef.h \ - buffer.h display.h exec.h flook.h input.h random.h search.h termio.h \ - version.h window.h -exec.o: exec.c exec.h estruct.h line.h utf8.h buffer.h bind.h edef.h \ - display.h eval.h file.h flook.h input.h -execute.o: execute.c edef.h estruct.h line.h utf8.h bind.h random.h \ - display.h file.h -file.o: file.c file.h buffer.h estruct.h line.h utf8.h crypt.h edef.h \ - execute.h fileio.h input.h lock.h log.h window.h -fileio.o: fileio.c fileio.h estruct.h line.h utf8.h crypt.h -flook.o: flook.c flook.h estruct.h line.h utf8.h fileio.h -globals.o: globals.c estruct.h line.h utf8.h edef.h -ibmpc.o: ibmpc.c estruct.h line.h utf8.h edef.h -input.o: input.c input.h edef.h estruct.h line.h utf8.h bind.h bindable.h \ - display.h exec.h names.h wrapper.h + retcode.h bindable.h buffer.h eval.h exec.h file.h isearch.h random.h \ + region.h search.h spawn.h window.h word.h +eval.o: eval.c eval.h estruct.h line.h utf8.h retcode.h basic.h bind.h \ + edef.h buffer.h display.h exec.h flook.h input.h random.h search.h \ + termio.h version.h window.h +exec.o: exec.c exec.h estruct.h line.h utf8.h retcode.h buffer.h bind.h \ + edef.h display.h eval.h file.h flook.h input.h +execute.o: execute.c edef.h estruct.h line.h utf8.h retcode.h bind.h \ + random.h display.h file.h +file.o: file.c file.h buffer.h estruct.h line.h utf8.h retcode.h crypt.h \ + edef.h execute.h fileio.h input.h lock.h log.h window.h +fileio.o: fileio.c fileio.h estruct.h line.h utf8.h retcode.h crypt.h +flook.o: flook.c flook.h estruct.h line.h utf8.h retcode.h fileio.h +globals.o: globals.c estruct.h line.h utf8.h retcode.h edef.h +ibmpc.o: ibmpc.c estruct.h line.h utf8.h retcode.h edef.h +input.o: input.c input.h edef.h estruct.h line.h utf8.h retcode.h bind.h \ + bindable.h display.h exec.h names.h wrapper.h isearch.o: isearch.c isearch.h basic.h display.h estruct.h line.h utf8.h \ - edef.h input.h search.h -line.o: line.c line.h utf8.h estruct.h edef.h log.h -lock.o: lock.c lock.h estruct.h line.h utf8.h display.h edef.h input.h -log.o: log.c log.h estruct.h line.h utf8.h -main.o: main.c basic.h bind.h edef.h estruct.h line.h utf8.h bindable.h \ - buffer.h display.h eval.h execute.h file.h input.h lock.h log.h random.h \ - search.h termio.h version.h + retcode.h edef.h input.h search.h +line.o: line.c line.h utf8.h estruct.h retcode.h edef.h log.h +lock.o: lock.c lock.h estruct.h line.h utf8.h retcode.h display.h edef.h \ + input.h +log.o: log.c log.h retcode.h +main.o: main.c basic.h bind.h edef.h estruct.h line.h utf8.h retcode.h \ + bindable.h buffer.h display.h eval.h execute.h file.h input.h lock.h \ + log.h random.h search.h termio.h version.h names.o: names.c names.h basic.h bind.h edef.h estruct.h line.h utf8.h \ - bindable.h buffer.h display.h eval.h exec.h file.h isearch.h region.h \ - random.h search.h spawn.h window.h word.h -pklock.o: pklock.c pklock.h estruct.h line.h utf8.h edef.h + retcode.h bindable.h buffer.h display.h eval.h exec.h file.h isearch.h \ + region.h random.h search.h spawn.h window.h word.h +pklock.o: pklock.c pklock.h estruct.h line.h utf8.h retcode.h edef.h posix.o: posix.c termio.h random.o: random.c random.h basic.h display.h estruct.h line.h utf8.h \ - edef.h execute.h input.h log.h search.h -region.o: region.c region.h estruct.h line.h utf8.h edef.h log.h -search.o: search.c search.h estruct.h line.h utf8.h basic.h display.h \ - edef.h input.h log.h -spawn.o: spawn.c spawn.h buffer.h estruct.h line.h utf8.h display.h \ - edef.h file.h input.h log.h window.h -tcap.o: tcap.c display.h estruct.h line.h utf8.h edef.h termio.h -termio.o: termio.c termio.h estruct.h line.h utf8.h edef.h + retcode.h edef.h execute.h input.h log.h search.h +region.o: region.c region.h estruct.h line.h utf8.h retcode.h edef.h \ + log.h +search.o: search.c search.h estruct.h line.h utf8.h retcode.h basic.h \ + display.h edef.h input.h log.h +spawn.o: spawn.c spawn.h buffer.h estruct.h line.h utf8.h retcode.h \ + display.h edef.h file.h input.h log.h window.h +tcap.o: tcap.c display.h estruct.h line.h utf8.h retcode.h edef.h \ + termio.h +termio.o: termio.c termio.h estruct.h line.h utf8.h retcode.h edef.h utf8.o: utf8.c utf8.h -vmsvt.o: vmsvt.c estruct.h line.h utf8.h edef.h -vt52.o: vt52.c estruct.h line.h utf8.h edef.h -window.o: window.c window.h estruct.h line.h utf8.h basic.h display.h \ - edef.h execute.h wrapper.h -word.o: word.c word.h basic.h estruct.h line.h utf8.h edef.h log.h \ - random.h region.h +vmsvt.o: vmsvt.c estruct.h line.h utf8.h retcode.h edef.h +vt52.o: vt52.c estruct.h line.h utf8.h retcode.h edef.h +window.o: window.c window.h estruct.h line.h utf8.h retcode.h basic.h \ + display.h edef.h execute.h wrapper.h +word.o: word.c word.h basic.h estruct.h line.h utf8.h retcode.h edef.h \ + log.h random.h region.h wrapper.o: wrapper.c wrapper.h # DEPENDENCIES MUST END AT END OF FILE diff --git a/estruct.h b/estruct.h index 120b871..6787442 100644 --- a/estruct.h +++ b/estruct.h @@ -249,25 +249,7 @@ #define CTLX 0x40000000 /* ^X flag, or'ed in */ #define SPEC 0x80000000 /* special key (function keys) */ -#ifdef FALSE -#undef FALSE -#endif -#ifdef TRUE -#undef TRUE -#endif - -#if 0 -#define FALSE 0 /* False, no, bad, etc. */ -#define TRUE 1 /* True, yes, good, etc. */ -#define ABORT 2 /* Death, ^G, abort, etc. */ -#define FAILED 3 /* not-quite fatal false return */ -#endif -typedef enum { - FALSE, - TRUE -} boolean ; - -#define ABORT 2 +#include "retcode.h" #define STOP 0 /* keyboard macro not in use */ #define PLAY 1 /* playing */ diff --git a/log.c b/log.c index 98963a2..dce6d7a 100644 --- a/log.c +++ b/log.c @@ -1,6 +1,6 @@ #include "log.h" -#include "estruct.h" +#include "retcode.h" static void logdump( const char *buf, ...) { From d266ec4b2a69283c3dd16c318e0f3eeeaa3ab392 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Thu, 19 Sep 2013 13:28:34 +0800 Subject: [PATCH 100/193] Remove estruct dependencies in headers of fileio and flook. --- Makefile | 4 ++-- fileio.h | 2 +- flook.c | 1 + flook.h | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index a6bcbe3..e508990 100644 --- a/Makefile +++ b/Makefile @@ -151,8 +151,8 @@ execute.o: execute.c edef.h estruct.h line.h utf8.h retcode.h bind.h \ random.h display.h file.h file.o: file.c file.h buffer.h estruct.h line.h utf8.h retcode.h crypt.h \ edef.h execute.h fileio.h input.h lock.h log.h window.h -fileio.o: fileio.c fileio.h estruct.h line.h utf8.h retcode.h crypt.h -flook.o: flook.c flook.h estruct.h line.h utf8.h retcode.h fileio.h +fileio.o: fileio.c fileio.h retcode.h estruct.h line.h utf8.h crypt.h +flook.o: flook.c flook.h retcode.h estruct.h line.h utf8.h fileio.h globals.o: globals.c estruct.h line.h utf8.h retcode.h edef.h ibmpc.o: ibmpc.c estruct.h line.h utf8.h retcode.h edef.h input.o: input.c input.h edef.h estruct.h line.h utf8.h retcode.h bind.h \ diff --git a/fileio.h b/fileio.h index 0d47f47..be60bdf 100644 --- a/fileio.h +++ b/fileio.h @@ -1,7 +1,7 @@ #ifndef _FILEIO_H_ #define _FILEIO_H_ -#include "estruct.h" +#include "retcode.h" typedef enum { FIOSUC, /* File I/O, success. */ diff --git a/flook.c b/flook.c index 0524816..5f7875f 100644 --- a/flook.c +++ b/flook.c @@ -7,6 +7,7 @@ #include +#include "estruct.h" #include "fileio.h" diff --git a/flook.h b/flook.h index 8466659..cfcd1cd 100644 --- a/flook.h +++ b/flook.h @@ -1,4 +1,4 @@ -#include "estruct.h" +#include "retcode.h" #define rcfname pathname[ 0] From 669b7396d4511573586c48bc855a4384669a896c Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Thu, 19 Sep 2013 13:50:27 +0800 Subject: [PATCH 101/193] Insure flook compile without warning when ENVFUN is 0. --- flook.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/flook.c b/flook.c index 5f7875f..403f9fd 100644 --- a/flook.c +++ b/flook.c @@ -76,15 +76,15 @@ boolean fexist( const char *fname) */ char *flook( const char *fname, int hflag) { - char *home; /* path to home directory */ - char *path; /* environmental PATH variable */ - char *sp; /* pointer into path spec */ int i; /* index */ static char fspec[NSTRING]; /* full path spec to search */ #if ENVFUNC + char *path; /* environmental PATH variable */ if (hflag) { + char *home; /* path to home directory */ + home = getenv("HOME"); if (home != NULL) { /* build home dir file spec */ @@ -109,6 +109,7 @@ char *flook( const char *fname, int hflag) path = getenv("PATH"); if (path != NULL) while (*path) { + char *sp; /* pointer into path spec */ /* build next possible file spec */ sp = fspec; From 226c63b63adb80e4ef137186d3b6886fff6ca16f Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Thu, 19 Sep 2013 13:55:06 +0800 Subject: [PATCH 102/193] Add retcode.h missing from commit d17334e3ae. --- retcode.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 retcode.h diff --git a/retcode.h b/retcode.h new file mode 100644 index 0000000..947244a --- /dev/null +++ b/retcode.h @@ -0,0 +1,25 @@ +#ifndef __RETCODE_H__ +#define __RETCODE_H__ + +#ifdef FALSE +#undef FALSE +#endif +#ifdef TRUE +#undef TRUE +#endif + +#if 0 +#define FALSE 0 /* False, no, bad, etc. */ +#define TRUE 1 /* True, yes, good, etc. */ +#define ABORT 2 /* Death, ^G, abort, etc. */ +#define FAILED 3 /* not-quite fatal false return */ +#endif + +typedef enum { + FALSE, + TRUE +} boolean ; + +#define ABORT 2 + +#endif From 34e2041d8ef1f5f780d785447ac8ed8ca448792f Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Thu, 19 Sep 2013 14:13:07 +0800 Subject: [PATCH 103/193] Include flook header in spawn instead of redeclaring function. --- Makefile | 2 +- flook.c | 4 ++-- flook.h | 2 +- spawn.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index e508990..4ac9244 100644 --- a/Makefile +++ b/Makefile @@ -178,7 +178,7 @@ region.o: region.c region.h estruct.h line.h utf8.h retcode.h edef.h \ search.o: search.c search.h estruct.h line.h utf8.h retcode.h basic.h \ display.h edef.h input.h log.h spawn.o: spawn.c spawn.h buffer.h estruct.h line.h utf8.h retcode.h \ - display.h edef.h file.h input.h log.h window.h + display.h edef.h file.h flook.h input.h log.h window.h tcap.o: tcap.c display.h estruct.h line.h utf8.h retcode.h edef.h \ termio.h termio.o: termio.c termio.h estruct.h line.h utf8.h retcode.h edef.h diff --git a/flook.c b/flook.c index 403f9fd..cb2b844 100644 --- a/flook.c +++ b/flook.c @@ -72,9 +72,9 @@ boolean fexist( const char *fname) * asked and possible * * char *fname; base file name to search for - * int hflag; Look in the HOME environment variable first? + * boolean hflag; Look in the HOME environment variable first? */ -char *flook( const char *fname, int hflag) +char *flook( const char *fname, boolean hflag) { int i; /* index */ static char fspec[NSTRING]; /* full path spec to search */ diff --git a/flook.h b/flook.h index cfcd1cd..e56358c 100644 --- a/flook.h +++ b/flook.h @@ -8,5 +8,5 @@ extern const char *pathname[] ; boolean fexist( const char *fname) ; -char *flook( const char *fname, int hflag) ; +char *flook( const char *fname, boolean hflag) ; diff --git a/spawn.c b/spawn.c index 3f61036..6342b63 100644 --- a/spawn.c +++ b/spawn.c @@ -16,6 +16,7 @@ #include "estruct.h" #include "edef.h" #include "file.h" +#include "flook.h" #include "input.h" #include "log.h" #include "window.h" @@ -579,7 +580,6 @@ int execprog(char *cmd) char *fcb1; /* 4 byte pointer to FCB at PSP+5Ch */ char *fcb2; /* 4 byte pointer to FCB at PSP+6Ch */ } pblock; - char *flook( const char *fname, int hflag) ; /* parse the command name from the command line */ sp = prog; From fb6d6bd595a38dc63deba40cae57e74920ec9dbc Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Thu, 19 Sep 2013 14:58:20 +0800 Subject: [PATCH 104/193] Insure CRYPT is defined before header inclusion. --- Makefile | 6 +++--- crypt.c | 2 ++ crypt.h | 6 +++--- file.c | 1 + file.h | 4 +++- fileio.c | 1 + fileio.h | 4 +++- 7 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 4ac9244..74e7b68 100644 --- a/Makefile +++ b/Makefile @@ -136,7 +136,7 @@ bindable.o: bindable.c bindable.h buffer.h estruct.h line.h utf8.h \ retcode.h display.h edef.h file.h input.h buffer.o: buffer.c buffer.h estruct.h line.h utf8.h retcode.h display.h \ edef.h file.h input.h window.h -crypt.o: crypt.c crypt.h estruct.h line.h utf8.h retcode.h +crypt.o: crypt.c estruct.h line.h utf8.h retcode.h crypt.h display.o: display.c display.h estruct.h line.h utf8.h retcode.h edef.h \ termio.h version.h wrapper.h window.h ebind.o: ebind.c ebind.h basic.h bind.h edef.h estruct.h line.h utf8.h \ @@ -149,9 +149,9 @@ exec.o: exec.c exec.h estruct.h line.h utf8.h retcode.h buffer.h bind.h \ edef.h display.h eval.h file.h flook.h input.h execute.o: execute.c edef.h estruct.h line.h utf8.h retcode.h bind.h \ random.h display.h file.h -file.o: file.c file.h buffer.h estruct.h line.h utf8.h retcode.h crypt.h \ +file.o: file.c estruct.h line.h utf8.h retcode.h file.h buffer.h crypt.h \ edef.h execute.h fileio.h input.h lock.h log.h window.h -fileio.o: fileio.c fileio.h retcode.h estruct.h line.h utf8.h crypt.h +fileio.o: fileio.c estruct.h line.h utf8.h retcode.h fileio.h crypt.h flook.o: flook.c flook.h retcode.h estruct.h line.h utf8.h fileio.h globals.o: globals.c estruct.h line.h utf8.h retcode.h edef.h ibmpc.o: ibmpc.c estruct.h line.h utf8.h retcode.h edef.h diff --git a/crypt.c b/crypt.c index 3384410..bd98014 100644 --- a/crypt.c +++ b/crypt.c @@ -1,5 +1,7 @@ /* crypt.c -- implements crypt.h */ +#include "estruct.h" + #include "crypt.h" /* CRYPT.C diff --git a/crypt.h b/crypt.h index 7cfbaca..dd7bea3 100644 --- a/crypt.h +++ b/crypt.h @@ -1,9 +1,9 @@ #ifndef _CRYPT_H_ #define _CRYPT_H_ -#include "estruct.h" - -#if CRYPT +#ifndef CRYPT +#error CRYPT should be defined +#elif CRYPT void myencrypt( char *bptr, unsigned len) ; #endif diff --git a/file.c b/file.c index 40f8990..371e2b6 100644 --- a/file.c +++ b/file.c @@ -1,5 +1,6 @@ /* file.c -- implements file.h */ +#include "estruct.h" #include "file.h" /* file.c diff --git a/file.h b/file.h index f2f1d55..f8ada9c 100644 --- a/file.h +++ b/file.h @@ -1,7 +1,9 @@ #ifndef _FILE_H_ #define _FILE_H_ -#if CRYPT +#ifndef CRYPT +#error CRYPT should be defined. +#elif CRYPT void cryptbufferkey( struct buffer *bp) ; int set_encryption_key( int f, int n) ; #endif diff --git a/fileio.c b/fileio.c index 2bcdf4d..5327070 100644 --- a/fileio.c +++ b/fileio.c @@ -1,5 +1,6 @@ /* fileio.c -- implements fileio.h */ +#include "estruct.h" #include "fileio.h" /* FILEIO.C diff --git a/fileio.h b/fileio.h index be60bdf..3afb4dc 100644 --- a/fileio.h +++ b/fileio.h @@ -18,7 +18,9 @@ typedef enum { #define FTYPE_MAC 4 /* FTYPE_MIXED [ 3, 5, 6, 7] */ -#if CRYPT +#ifndef CRYPT +#error CRYPT should be defined. +#elif CRYPT extern boolean is_crypted ; /* currently encrypting? */ #endif From 0aea939e21a6d8f90760bb75e466ec7da4c988d9 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Thu, 19 Sep 2013 15:33:56 +0800 Subject: [PATCH 105/193] Review prototypes of function with filenames and lock flag. --- file.c | 16 ++++++++-------- file.h | 12 +++++++----- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/file.c b/file.c index 371e2b6..007972e 100644 --- a/file.c +++ b/file.c @@ -205,9 +205,9 @@ static int resetkey(void) * getfile() * * char fname[]; file name to find - * int lockfl; check the file for locks? + * boolean lockfl; check the file for locks? */ -int getfile(char *fname, int lockfl) +int getfile( const char *fname, boolean lockfl) { struct buffer *bp; struct line *lp; @@ -271,9 +271,9 @@ int getfile(char *fname, int lockfl) * and before it is read. * * char fname[]; name of file to read - * int lockfl; check for file locks? + * boolean lockfl; check for file locks? */ -int readin(char *fname, int lockfl) +int readin(const char *fname, boolean lockfl) { struct line *lp1; struct line *lp2; @@ -409,9 +409,9 @@ int readin(char *fname, int lockfl) * I suppose that this information could be put in * a better place than a line of code. */ -void makename(char *bname, char *fname) +void makename(char *bname, const char *fname) { - char *cp1; + const char *cp1; char *cp2; cp1 = &fname[0]; @@ -548,7 +548,7 @@ int filesave(int f, int n) * a macro for this. Most of the grief is error * checking of some sort. */ -int writeout(char *fn) +int writeout( const char *fn) { int s; struct line *lp; @@ -631,7 +631,7 @@ int filename(int f, int n) * buffer, Called by insert file command. Return the final * status of the read. */ -int ifile(char *fname) +int ifile( const char *fname) { struct line *lp0; struct line *lp1; diff --git a/file.h b/file.h index f8ada9c..42f4e18 100644 --- a/file.h +++ b/file.h @@ -1,6 +1,8 @@ #ifndef _FILE_H_ #define _FILE_H_ +#include "retcode.h" + #ifndef CRYPT #error CRYPT should be defined. #elif CRYPT @@ -12,14 +14,14 @@ int fileread( int f, int n) ; int insfile( int f, int n) ; int filefind( int f, int n) ; int viewfile( int f, int n) ; -int getfile( char *fname, int lockfl) ; -int readin( char *fname, int lockfl) ; -void makename( char *bname, char *fname) ; +int getfile( const char *fname, boolean lockfl) ; +int readin( const char *fname, boolean lockfl) ; +void makename( char *bname, const char *fname) ; void unqname( char *name) ; int filewrite( int f, int n) ; int filesave( int f, int n) ; -int writeout( char *fn) ; +int writeout( const char *fn) ; int filename( int f, int n) ; -int ifile( char *fname) ; +int ifile( const char *fname) ; #endif From f5c715debd496e1f096306f664106ae610fb7d72 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Thu, 19 Sep 2013 16:10:29 +0800 Subject: [PATCH 106/193] Review prototypes of prompting functions. --- exec.c | 4 ++-- exec.h | 2 +- input.c | 10 +++++----- input.h | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/exec.c b/exec.c index a437523..f9a4995 100644 --- a/exec.c +++ b/exec.c @@ -241,12 +241,12 @@ int macarg(char *tok) * nextarg: * get the next argument * - * char *prompt; prompt to use if we must be interactive + * const char *prompt; prompt to use if we must be interactive * char *buffer; buffer to put token into * int size; size of the buffer * int terminator; terminating char to be used on interactive fetch */ -int nextarg(char *prompt, char *buffer, int size, int terminator) +int nextarg(const char *prompt, char *buffer, int size, int terminator) { /* if we are interactive, go get it! */ if (clexec == FALSE) diff --git a/exec.h b/exec.h index e0b8082..27f6b11 100644 --- a/exec.h +++ b/exec.h @@ -8,7 +8,7 @@ int execcmd( int f, int n) ; int docmd( char *cline) ; char *token( char *src, char *tok, int size) ; int macarg( char *tok) ; -int nextarg( char *prompt, char *buffer, int size, int terminator) ; +int nextarg( const char *prompt, char *buffer, int size, int terminator) ; int storemac( int f, int n) ; int storeproc( int f, int n) ; int execproc( int f, int n) ; diff --git a/input.c b/input.c index 1bd797d..0cc3b72 100644 --- a/input.c +++ b/input.c @@ -37,7 +37,7 @@ * ABORT. The ABORT status is returned if the user bumps out of the question * with a ^G. Used any time a confirmation is required. */ -int mlyesno(char *prompt) +int mlyesno( const char *prompt) { char c; /* input character */ char buf[NPAT]; /* prompt to user */ @@ -70,12 +70,12 @@ int mlyesno(char *prompt) * return. Handle erase, kill, and abort keys. */ -int mlreply(char *prompt, char *buf, int nbuf) +int mlreply( const char *prompt, char *buf, int nbuf) { return nextarg(prompt, buf, nbuf, ctoec('\n')); } -int mlreplyt(char *prompt, char *buf, int nbuf, int eolchar) +int mlreplyt(const char *prompt, char *buf, int nbuf, int eolchar) { return nextarg(prompt, buf, nbuf, eolchar); } @@ -444,11 +444,11 @@ handle_CSI: to specify the proper terminator. If the terminator is not a return ('\n') it will echo as "" */ -int getstring(char *prompt, char *buf, int nbuf, int eolchar) +int getstring( const char *prompt, char *buf, int nbuf, int eolchar) { int cpos; /* current character position in string */ int c; - int quotef; /* are we quoting the next char? */ + boolean quotef ; /* are we quoting the next char? */ #if COMPLC int ffile, ocpos, nskip = 0, didtry = 0; #if MSDOS diff --git a/input.h b/input.h index a1da651..99ee8db 100644 --- a/input.h +++ b/input.h @@ -3,16 +3,16 @@ #include "edef.h" -int mlyesno( char *prompt) ; -int mlreply( char *prompt, char *buf, int nbuf) ; -int mlreplyt( char *prompt, char *buf, int nbuf, int eolchar) ; +int mlyesno( const char *prompt) ; +int mlreply( const char *prompt, char *buf, int nbuf) ; +int mlreplyt( const char *prompt, char *buf, int nbuf, int eolchar) ; int ectoc( int c) ; int ctoec( int c) ; fn_t getname( void) ; int tgetc( void) ; int get1key( void) ; int getcmd( void) ; -int getstring( char *prompt, char *buf, int nbuf, int eolchar) ; +int getstring( const char *prompt, char *buf, int nbuf, int eolchar) ; void outstring( char *s) ; void ostring( char *s) ; From 32a5631bde2e28699a21d9920dce3f8ae585fc00 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Thu, 19 Sep 2013 16:32:20 +0800 Subject: [PATCH 107/193] Review return type of log functions. --- log.c | 8 ++++---- log.h | 8 +++++--- main.c | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/log.c b/log.c index dce6d7a..debf1b4 100644 --- a/log.c +++ b/log.c @@ -8,17 +8,17 @@ static void logdump( const char *buf, ...) { void (*logwrite)( const char *, ...) = logdump ; -static int logit( int retcode, int beep_f, const char *buf, ...) { +static boolean logit( boolean retcode, boolean beep_f, const char *buf, ...) { return retcode ; } -int (*logger)( int, int, const char *, ...) = logit ; +boolean (*logger)( boolean, boolean, const char *, ...) = logit ; /* * tell the user that this command is illegal while we are in * VIEW (read-only) mode */ -int rdonly(void) +boolean rdonly(void) { /* TTbeep(); mlwrite("(Key illegal in VIEW mode)"); @@ -29,7 +29,7 @@ int rdonly(void) -int resterr(void) +boolean resterr(void) { /* TTbeep(); mlwrite("(That command is RESTRICTED)"); diff --git a/log.h b/log.h index 66c8beb..4441fad 100644 --- a/log.h +++ b/log.h @@ -1,6 +1,8 @@ -int rdonly( void) ; -int resterr( void) ; +#include "retcode.h" + +boolean rdonly( void) ; +boolean resterr( void) ; extern void (*logwrite)( const char *, ...) ; -extern int (*logger)( int, int, const char *, ...) ; +extern boolean (*logger)( boolean, boolean, const char *, ...) ; diff --git a/main.c b/main.c index 20aa84c..abe7f05 100644 --- a/main.c +++ b/main.c @@ -124,7 +124,7 @@ static void usage( void) { } -static int mllog( int retcode, int beep_f, const char *buf, ...) { +static boolean mllog( boolean retcode, boolean beep_f, const char *buf, ...) { if( beep_f) TTbeep() ; From ab432a67813d83e421ab179040e10884e6994b30 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 20 Sep 2013 11:44:18 +0800 Subject: [PATCH 108/193] Clean up dependecies on estruct by introducing defines.h. --- Makefile | 12 ++++++------ crypt.c | 2 +- estruct.h | 6 ------ fileio.c | 9 ++------- flook.c | 8 +++++++- line.c | 2 -- 6 files changed, 16 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index 74e7b68..416fdef 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ -# makefile for emacs, updated Thu, Sep 19, 2013 12:14:27 PM +# makefile for emacs, updated Fri, Sep 20, 2013 10:43:27 AM SRC=ansi.c basic.c bind.c bindable.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c globals.c ibmpc.c input.c isearch.c line.c lock.c log.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c OBJ=ansi.o basic.o bind.o bindable.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o globals.o ibmpc.o input.o isearch.o line.o lock.o log.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o -HDR=basic.h bind.h bindable.h buffer.h crypt.h display.h ebind.h edef.h efunc.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h log.h names.h pklock.h random.h region.h retcode.h search.h spawn.h termio.h utf8.h version.h window.h word.h wrapper.h +HDR=basic.h bind.h bindable.h buffer.h crypt.h defines.h display.h ebind.h edef.h efunc.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h log.h names.h pklock.h random.h region.h retcode.h search.h spawn.h termio.h utf8.h version.h window.h word.h wrapper.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -136,7 +136,7 @@ bindable.o: bindable.c bindable.h buffer.h estruct.h line.h utf8.h \ retcode.h display.h edef.h file.h input.h buffer.o: buffer.c buffer.h estruct.h line.h utf8.h retcode.h display.h \ edef.h file.h input.h window.h -crypt.o: crypt.c estruct.h line.h utf8.h retcode.h crypt.h +crypt.o: crypt.c defines.h crypt.h display.o: display.c display.h estruct.h line.h utf8.h retcode.h edef.h \ termio.h version.h wrapper.h window.h ebind.o: ebind.c ebind.h basic.h bind.h edef.h estruct.h line.h utf8.h \ @@ -151,15 +151,15 @@ execute.o: execute.c edef.h estruct.h line.h utf8.h retcode.h bind.h \ random.h display.h file.h file.o: file.c estruct.h line.h utf8.h retcode.h file.h buffer.h crypt.h \ edef.h execute.h fileio.h input.h lock.h log.h window.h -fileio.o: fileio.c estruct.h line.h utf8.h retcode.h fileio.h crypt.h -flook.o: flook.c flook.h retcode.h estruct.h line.h utf8.h fileio.h +fileio.o: fileio.c defines.h fileio.h retcode.h crypt.h +flook.o: flook.c flook.h retcode.h defines.h fileio.h globals.o: globals.c estruct.h line.h utf8.h retcode.h edef.h ibmpc.o: ibmpc.c estruct.h line.h utf8.h retcode.h edef.h input.o: input.c input.h edef.h estruct.h line.h utf8.h retcode.h bind.h \ bindable.h display.h exec.h names.h wrapper.h isearch.o: isearch.c isearch.h basic.h display.h estruct.h line.h utf8.h \ retcode.h edef.h input.h search.h -line.o: line.c line.h utf8.h estruct.h retcode.h edef.h log.h +line.o: line.c line.h utf8.h edef.h estruct.h retcode.h log.h lock.o: lock.c lock.h estruct.h line.h utf8.h retcode.h display.h edef.h \ input.h log.o: log.c log.h retcode.h diff --git a/crypt.c b/crypt.c index bd98014..27d78b7 100644 --- a/crypt.c +++ b/crypt.c @@ -1,6 +1,6 @@ /* crypt.c -- implements crypt.h */ -#include "estruct.h" +#include "defines.h" #include "crypt.h" diff --git a/estruct.h b/estruct.h index 6787442..fd8700a 100644 --- a/estruct.h +++ b/estruct.h @@ -285,12 +285,6 @@ #define BELL 0x07 /* a bell character */ #define TAB 0x09 /* a tab character */ -#if V7 | USG | BSD -#define PATHCHR ':' -#else -#define PATHCHR ';' -#endif - #define INTWIDTH sizeof(int) * 3 /* Macro argument token types */ diff --git a/fileio.c b/fileio.c index 5327070..2f0fd4e 100644 --- a/fileio.c +++ b/fileio.c @@ -1,6 +1,6 @@ /* fileio.c -- implements fileio.h */ -#include "estruct.h" +#include "defines.h" #include "fileio.h" /* FILEIO.C @@ -15,9 +15,6 @@ #include #include -#include "estruct.h" - - #if CRYPT #include "crypt.h" @@ -85,12 +82,10 @@ fio_code ffclose(void) #if V7 | USG | BSD | (MSDOS & (MSC | TURBO)) if (fclose(ffp) != FALSE) return FIOERR; - - return FIOSUC; #else fclose(ffp); - return FIOSUC; #endif + return FIOSUC; } /* diff --git a/flook.c b/flook.c index cb2b844..2971edb 100644 --- a/flook.c +++ b/flook.c @@ -7,7 +7,7 @@ #include -#include "estruct.h" +#include "defines.h" #include "fileio.h" @@ -105,6 +105,12 @@ char *flook( const char *fname, boolean hflag) return fspec ; #if ENVFUNC +#if V7 | USG | BSD +#define PATHCHR ':' +#else +#define PATHCHR ';' +#endif + /* get the PATH variable */ path = getenv("PATH"); if (path != NULL) diff --git a/line.c b/line.c index 366a9ed..ab50369 100644 --- a/line.c +++ b/line.c @@ -18,10 +18,8 @@ #include #include -#include "estruct.h" #include "edef.h" #include "log.h" -#include "utf8.h" #define BLOCK_SIZE 16 /* Line block chunk size. */ From 39e23cb169e94a6c93e3c35b2e6d299a74ea9569 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 20 Sep 2013 11:47:47 +0800 Subject: [PATCH 109/193] Defines.h missing in previous commit. --- defines.h | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 defines.h diff --git a/defines.h b/defines.h new file mode 100644 index 0000000..73e7919 --- /dev/null +++ b/defines.h @@ -0,0 +1,8 @@ +#define USG 1 + +#define CRYPT 1 /* file encryption enabled? */ + +#define NSTRING 128 /* # of bytes, string buffers */ + +#define PKCODE 1 +#define ENVFUNC 1 From 87cd40ce6a597d7d31487ed35f6836c1f6a17b8e Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 20 Sep 2013 18:10:30 +0800 Subject: [PATCH 110/193] Extract struct buffer and struct window from estruct.h. --- basic.c | 2 ++ bindable.c | 1 + buffer.c | 4 +-- buffer.h | 58 ++++++++++++++++++++++++++++++++- crypt.c | 2 -- crypt.h | 6 ++-- defines.h | 6 ++-- display.c | 1 + edef.h | 13 +++++++- estruct.h | 94 +++--------------------------------------------------- exec.c | 1 + exec.h | 1 + execute.c | 1 + file.c | 2 +- file.h | 7 ++-- fileio.c | 5 ++- fileio.h | 8 ++--- globals.c | 7 ++-- isearch.c | 3 +- line.c | 2 ++ log.c | 3 -- main.c | 1 + random.c | 2 ++ region.c | 2 ++ search.c | 2 ++ spawn.c | 2 ++ window.c | 3 +- window.h | 42 +++++++++++++++++++++++- word.c | 2 ++ 29 files changed, 163 insertions(+), 120 deletions(-) diff --git a/basic.c b/basic.c index 73bc4c7..dd8f2a7 100644 --- a/basic.c +++ b/basic.c @@ -15,6 +15,7 @@ #include +#include "buffer.h" #include "display.h" #include "estruct.h" #include "edef.h" @@ -22,6 +23,7 @@ #include "line.h" #include "random.h" #include "utf8.h" +#include "window.h" #include "word.h" /* diff --git a/bindable.c b/bindable.c index 2dd341a..b23f431 100644 --- a/bindable.c +++ b/bindable.c @@ -1,6 +1,7 @@ /* bindable.h -- implements bindable.c */ #include "bindable.h" +#include "defines.h" #include "buffer.h" #include "display.h" #include "edef.h" diff --git a/buffer.c b/buffer.c index acddc03..495fa93 100644 --- a/buffer.c +++ b/buffer.c @@ -14,12 +14,12 @@ #include +#include "defines.h" #include "display.h" -#include "estruct.h" +/* #include "estruct.h" */ #include "edef.h" #include "file.h" #include "input.h" -#include "line.h" #include "window.h" diff --git a/buffer.h b/buffer.h index 2118c44..6eb70e3 100644 --- a/buffer.h +++ b/buffer.h @@ -1,7 +1,63 @@ #ifndef _BUFFER_H_ #define _BUFFER_H_ -#include "estruct.h" +#include "crypt.h" +#include "line.h" + +#define NFILEN 80 /* # of bytes, file name */ +#define NBUFN 16 /* # of bytes, buffer name */ +#define NPAT 128 /* # of bytes, pattern */ + +/* + * Text is kept in buffers. A buffer header, described below, exists for every + * buffer in the system. The buffers are kept in a big list, so that commands + * that search for a buffer by name can find the buffer header. There is a + * safe store for the dot and mark in the header, but this is only valid if + * the buffer is not being displayed (that is, if "b_nwnd" is 0). The text for + * the buffer is kept in a circularly linked list of lines, with a pointer to + * the header line in "b_linep". + * Buffers may be "Inactive" which means the files associated with them + * have not been read in yet. These get read in at "use buffer" time. + */ +struct buffer { + struct buffer *b_bufp; /* Link to next struct buffer */ + struct line *b_dotp; /* Link to "." struct line structure */ + struct line *b_markp; /* The same as the above two, */ + struct line *b_linep; /* Link to the header struct line */ + int b_doto; /* Offset of "." in above struct line */ + int b_marko; /* but for the "mark" */ + int b_mode; /* editor mode of this buffer */ + char b_active; /* window activated flag */ + char b_nwnd; /* Count of windows on buffer */ + char b_flag; /* Flags */ + char b_fname[NFILEN]; /* File name */ + char b_bname[NBUFN]; /* Buffer name */ +#if CRYPT + char b_key[NPAT]; /* current encrypted key */ +#endif +}; + +#define BFINVS 0x01 /* Internal invisable buffer */ +#define BFCHG 0x02 /* Changed since last write */ +#define BFTRUNC 0x04 /* buffer was truncated when read */ + +/* mode flags */ +#define NUMMODES 11 /* # of defined modes */ + +#define MDWRAP 0x0001 /* word wrap */ +#define MDCMOD 0x0002 /* C indentation and fence match */ +#define MDSPELL 0x0004 /* spell error parcing */ +#define MDEXACT 0x0008 /* Exact matching for searches */ +#define MDVIEW 0x0010 /* read-only buffer */ +#define MDOVER 0x0020 /* overwrite mode */ +#define MDMAGIC 0x0040 /* regular expresions in search */ +#if CRYPT +#define MDCRYPT 0x0080 /* encrytion mode active */ +#endif +#define MDASAVE 0x0100 /* auto-save mode */ +#define MDUTF8 0x0200 /* utf8 mode */ +#define MDDOS 0x0400 /* CRLF eol mode */ + int usebuffer( int f, int n) ; int nextbuffer( int f, int n) ; diff --git a/crypt.c b/crypt.c index 27d78b7..3384410 100644 --- a/crypt.c +++ b/crypt.c @@ -1,7 +1,5 @@ /* crypt.c -- implements crypt.h */ -#include "defines.h" - #include "crypt.h" /* CRYPT.C diff --git a/crypt.h b/crypt.h index dd7bea3..e0ea3e9 100644 --- a/crypt.h +++ b/crypt.h @@ -1,9 +1,9 @@ #ifndef _CRYPT_H_ #define _CRYPT_H_ -#ifndef CRYPT -#error CRYPT should be defined -#elif CRYPT +#define CRYPT 1 /* file encryption enabled? */ + +#if CRYPT void myencrypt( char *bptr, unsigned len) ; #endif diff --git a/defines.h b/defines.h index 73e7919..0c99915 100644 --- a/defines.h +++ b/defines.h @@ -1,8 +1,10 @@ +/* Must define one of + VMS | V7 | USG | BSD | MSDOS +*/ #define USG 1 -#define CRYPT 1 /* file encryption enabled? */ - #define NSTRING 128 /* # of bytes, string buffers */ #define PKCODE 1 +#define SCROLLCODE 1 /* scrolling code P.K. */ #define ENVFUNC 1 diff --git a/display.c b/display.c index a27709a..d318504 100644 --- a/display.c +++ b/display.c @@ -17,6 +17,7 @@ #include #include +#include "buffer.h" #include "estruct.h" #include "edef.h" #include "line.h" diff --git a/edef.h b/edef.h index feddb9a..da2323a 100644 --- a/edef.h +++ b/edef.h @@ -10,6 +10,7 @@ #ifndef EDEF_H_ #define EDEF_H_ +#include "buffer.h" #include "estruct.h" #include @@ -67,7 +68,17 @@ extern int kused; /* # of bytes used in KB */ extern struct window *swindow; /* saved window pointer */ extern int *kbdptr; /* current position in keyboard buf */ extern int *kbdend; /* ptr to end of the keyboard */ -extern int kbdmode; /* current keyboard macro mode */ + +#if 0 +#define STOP 0 /* keyboard macro not in use */ +#define PLAY 1 /* playing */ +#define RECORD 2 /* recording */ +#endif + +typedef enum { + STOP, PLAY, RECORD +} kbdstate ; +extern kbdstate kbdmode ; /* current keyboard macro mode */ extern int kbdrep; /* number of repetitions */ extern int restflag; /* restricted use? */ extern int lastkey; /* last keystoke */ diff --git a/estruct.h b/estruct.h index fd8700a..87e71e1 100644 --- a/estruct.h +++ b/estruct.h @@ -158,7 +158,9 @@ #define ISRCH 1 /* Incremental searches like ITS EMACS */ #define WORDPRO 1 /* Advanced word processing features */ #define APROP 1 /* Add code for Apropos command */ +#if 0 #define CRYPT 1 /* file encryption enabled? */ +#endif #define MAGIC 1 /* include regular expression matching? */ #define AEDIT 1 /* advanced editing options: en/detabbing */ #define PROC 1 /* named procedures */ @@ -251,9 +253,11 @@ #include "retcode.h" +#if 0 #define STOP 0 /* keyboard macro not in use */ #define PLAY 1 /* playing */ #define RECORD 2 /* recording */ +#endif /* Directive definitions */ @@ -384,96 +388,6 @@ int cexit( int status) ; #endif -/* - * There is a window structure allocated for every active display window. The - * windows are kept in a big list, in top to bottom screen order, with the - * listhead at "wheadp". Each window contains its own values of dot and mark. - * The flag field contains some bits that are set by commands to guide - * redisplay. Although this is a bit of a compromise in terms of decoupling, - * the full blown redisplay is just too expensive to run for every input - * character. - */ -struct window { - struct window *w_wndp; /* Next window */ - struct buffer *w_bufp; /* Buffer displayed in window */ - struct line *w_linep; /* Top line in the window */ - struct line *w_dotp; /* Line containing "." */ - struct line *w_markp; /* Line containing "mark" */ - int w_doto; /* Byte offset for "." */ - int w_marko; /* Byte offset for "mark" */ - char w_toprow; /* Origin 0 top row of window */ - char w_ntrows; /* # of rows of text in window */ - char w_force; /* If NZ, forcing row. */ - char w_flag; /* Flags. */ -#if COLOR - char w_fcolor; /* current forground color */ - char w_bcolor; /* current background color */ -#endif -}; - -#define WFFORCE 0x01 /* Window needs forced reframe */ -#define WFMOVE 0x02 /* Movement from line to line */ -#define WFEDIT 0x04 /* Editing within a line */ -#define WFHARD 0x08 /* Better to a full display */ -#define WFMODE 0x10 /* Update mode line. */ -#define WFCOLR 0x20 /* Needs a color change */ - -#if SCROLLCODE -#define WFKILLS 0x40 /* something was deleted */ -#define WFINS 0x80 /* something was inserted */ -#endif - - -/* - * Text is kept in buffers. A buffer header, described below, exists for every - * buffer in the system. The buffers are kept in a big list, so that commands - * that search for a buffer by name can find the buffer header. There is a - * safe store for the dot and mark in the header, but this is only valid if - * the buffer is not being displayed (that is, if "b_nwnd" is 0). The text for - * the buffer is kept in a circularly linked list of lines, with a pointer to - * the header line in "b_linep". - * Buffers may be "Inactive" which means the files associated with them - * have not been read in yet. These get read in at "use buffer" time. - */ -struct buffer { - struct buffer *b_bufp; /* Link to next struct buffer */ - struct line *b_dotp; /* Link to "." struct line structure */ - struct line *b_markp; /* The same as the above two, */ - struct line *b_linep; /* Link to the header struct line */ - int b_doto; /* Offset of "." in above struct line */ - int b_marko; /* but for the "mark" */ - int b_mode; /* editor mode of this buffer */ - char b_active; /* window activated flag */ - char b_nwnd; /* Count of windows on buffer */ - char b_flag; /* Flags */ - char b_fname[NFILEN]; /* File name */ - char b_bname[NBUFN]; /* Buffer name */ -#if CRYPT - char b_key[NPAT]; /* current encrypted key */ -#endif -}; - -#define BFINVS 0x01 /* Internal invisable buffer */ -#define BFCHG 0x02 /* Changed since last write */ -#define BFTRUNC 0x04 /* buffer was truncated when read */ - -/* mode flags */ -#define NUMMODES 11 /* # of defined modes */ - -#define MDWRAP 0x0001 /* word wrap */ -#define MDCMOD 0x0002 /* C indentation and fence match */ -#define MDSPELL 0x0004 /* spell error parcing */ -#define MDEXACT 0x0008 /* Exact matching for searches */ -#define MDVIEW 0x0010 /* read-only buffer */ -#define MDOVER 0x0020 /* overwrite mode */ -#define MDMAGIC 0x0040 /* regular expresions in search */ -#if CRYPT -#define MDCRYPT 0x0080 /* encrytion mode active */ -#endif -#define MDASAVE 0x0100 /* auto-save mode */ -#define MDUTF8 0x0200 /* utf8 mode */ -#define MDDOS 0x0400 /* CRLF eol mode */ - /* * The starting position of a region, and the size of the region in * characters, is kept in a region structure. Used by the region commands. diff --git a/exec.c b/exec.c index f9a4995..2a6fa25 100644 --- a/exec.c +++ b/exec.c @@ -22,6 +22,7 @@ #include "flook.h" #include "input.h" #include "line.h" +#include "window.h" /* directive name table: This holds the names of all the directives.... */ diff --git a/exec.h b/exec.h index 27f6b11..e0604c7 100644 --- a/exec.h +++ b/exec.h @@ -1,6 +1,7 @@ #ifndef _EXEC_H_ #define _EXEC_H_ +#include "buffer.h" #include "estruct.h" int namedcmd( int f, int n) ; diff --git a/execute.c b/execute.c index 7de8667..184893b 100644 --- a/execute.c +++ b/execute.c @@ -3,6 +3,7 @@ #include "random.h" #include "display.h" #include "file.h" +#include "window.h" /* * This is the general command execution routine. It handles the fake binding diff --git a/file.c b/file.c index 007972e..30a32c5 100644 --- a/file.c +++ b/file.c @@ -1,6 +1,5 @@ /* file.c -- implements file.h */ -#include "estruct.h" #include "file.h" /* file.c @@ -17,6 +16,7 @@ #include "buffer.h" #include "crypt.h" +#include "defines.h" #include "estruct.h" #include "edef.h" #include "execute.h" diff --git a/file.h b/file.h index 42f4e18..d60e264 100644 --- a/file.h +++ b/file.h @@ -1,11 +1,12 @@ #ifndef _FILE_H_ #define _FILE_H_ +#include "crypt.h" #include "retcode.h" -#ifndef CRYPT -#error CRYPT should be defined. -#elif CRYPT +#if CRYPT +#include "buffer.h" + void cryptbufferkey( struct buffer *bp) ; int set_encryption_key( int f, int n) ; #endif diff --git a/fileio.c b/fileio.c index 2f0fd4e..070ca49 100644 --- a/fileio.c +++ b/fileio.c @@ -1,6 +1,5 @@ /* fileio.c -- implements fileio.h */ -#include "defines.h" #include "fileio.h" /* FILEIO.C @@ -15,9 +14,9 @@ #include #include -#if CRYPT -#include "crypt.h" +#include "defines.h" +#if CRYPT boolean is_crypted ; /* currently encrypting? */ #endif diff --git a/fileio.h b/fileio.h index 3afb4dc..3ee7ff2 100644 --- a/fileio.h +++ b/fileio.h @@ -1,7 +1,7 @@ #ifndef _FILEIO_H_ #define _FILEIO_H_ -#include "retcode.h" +#include "crypt.h" typedef enum { FIOSUC, /* File I/O, success. */ @@ -18,9 +18,9 @@ typedef enum { #define FTYPE_MAC 4 /* FTYPE_MIXED [ 3, 5, 6, 7] */ -#ifndef CRYPT -#error CRYPT should be defined. -#elif CRYPT +#if CRYPT +#include "retcode.h" + extern boolean is_crypted ; /* currently encrypting? */ #endif diff --git a/globals.c b/globals.c index 0b35876..40ba064 100644 --- a/globals.c +++ b/globals.c @@ -1,4 +1,7 @@ -#include "estruct.h" +#include "crypt.h" +#include "defines.h" + +/* #include "estruct.h" */ #include "edef.h" /* initialized global definitions */ @@ -79,7 +82,7 @@ int kused = KBLOCK; /* # of bytes used in kill buffer */ struct window *swindow = NULL; /* saved window pointer */ int *kbdptr; /* current position in keyboard buf */ int *kbdend = &kbdm[0]; /* ptr to end of the keyboard */ -int kbdmode = STOP; /* current keyboard macro mode */ +kbdstate kbdmode = STOP; /* current keyboard macro mode */ int kbdrep = 0; /* number of repetitions */ int restflag = FALSE; /* restricted use? */ int lastkey = 0; /* last keystoke */ diff --git a/isearch.c b/isearch.c index 39d2d70..2b07baf 100644 --- a/isearch.c +++ b/isearch.c @@ -27,13 +27,14 @@ #include #include "basic.h" +#include "buffer.h" #include "display.h" #include "estruct.h" #include "edef.h" #include "input.h" #include "line.h" #include "search.h" - +#include "window.h" static int isearch( int f, int n) ; static int checknext( char chr, char *patrn, int dir) ; diff --git a/line.c b/line.c index ab50369..11cf6d5 100644 --- a/line.c +++ b/line.c @@ -18,8 +18,10 @@ #include #include +#include "buffer.h" #include "edef.h" #include "log.h" +#include "window.h" #define BLOCK_SIZE 16 /* Line block chunk size. */ diff --git a/log.c b/log.c index debf1b4..49d0189 100644 --- a/log.c +++ b/log.c @@ -1,8 +1,5 @@ #include "log.h" -#include "retcode.h" - - static void logdump( const char *buf, ...) { } diff --git a/main.c b/main.c index abe7f05..840ecfb 100644 --- a/main.c +++ b/main.c @@ -74,6 +74,7 @@ #include "search.h" #include "termio.h" #include "version.h" +#include "window.h" /* For MSDOS, increase the default stack space. */ #if MSDOS & TURBO diff --git a/random.c b/random.c index dfbab69..2bcbcc1 100644 --- a/random.c +++ b/random.c @@ -12,6 +12,7 @@ #include #include "basic.h" +#include "buffer.h" #include "display.h" #include "estruct.h" #include "edef.h" @@ -20,6 +21,7 @@ #include "line.h" #include "log.h" #include "search.h" +#include "window.h" int tabsize; /* Tab size (0: use real tabs) */ diff --git a/region.c b/region.c index 19e77f1..3a390b1 100644 --- a/region.c +++ b/region.c @@ -12,10 +12,12 @@ #include +#include "buffer.h" #include "estruct.h" #include "edef.h" #include "line.h" #include "log.h" +#include "window.h" /* * Kill the region. Ask "getregion" diff --git a/search.c b/search.c index 372a067..c242f1f 100644 --- a/search.c +++ b/search.c @@ -63,12 +63,14 @@ #include #include "basic.h" +#include "buffer.h" #include "display.h" #include "estruct.h" #include "edef.h" #include "input.h" #include "line.h" #include "log.h" +#include "window.h" #if defined(MAGIC) /* diff --git a/spawn.c b/spawn.c index 6342b63..abe9cce 100644 --- a/spawn.c +++ b/spawn.c @@ -11,6 +11,8 @@ #include #include +#include "defines.h" + #include "buffer.h" #include "display.h" #include "estruct.h" diff --git a/window.c b/window.c index 2dbc0cf..f9cf8bf 100644 --- a/window.c +++ b/window.c @@ -12,8 +12,9 @@ #include #include "basic.h" +#include "buffer.h" #include "display.h" -#include "estruct.h" +/* #include "estruct.h" */ #include "edef.h" #include "execute.h" #include "line.h" diff --git a/window.h b/window.h index 5e0417c..60d17b2 100644 --- a/window.h +++ b/window.h @@ -1,7 +1,47 @@ #ifndef _WINDOW_H_ #define _WINDOW_H_ -#include "estruct.h" +#include "defines.h" /* COLOR, SCROLLCODE */ +#include "buffer.h" /* buffer, line */ + +/* + * There is a window structure allocated for every active display window. The + * windows are kept in a big list, in top to bottom screen order, with the + * listhead at "wheadp". Each window contains its own values of dot and mark. + * The flag field contains some bits that are set by commands to guide + * redisplay. Although this is a bit of a compromise in terms of decoupling, + * the full blown redisplay is just too expensive to run for every input + * character. + */ +struct window { + struct window *w_wndp; /* Next window */ + struct buffer *w_bufp; /* Buffer displayed in window */ + struct line *w_linep; /* Top line in the window */ + struct line *w_dotp; /* Line containing "." */ + struct line *w_markp; /* Line containing "mark" */ + int w_doto; /* Byte offset for "." */ + int w_marko; /* Byte offset for "mark" */ + char w_toprow; /* Origin 0 top row of window */ + char w_ntrows; /* # of rows of text in window */ + char w_force; /* If NZ, forcing row. */ + char w_flag; /* Flags. */ +#if COLOR + char w_fcolor; /* current forground color */ + char w_bcolor; /* current background color */ +#endif +}; + +#define WFFORCE 0x01 /* Window needs forced reframe */ +#define WFMOVE 0x02 /* Movement from line to line */ +#define WFEDIT 0x04 /* Editing within a line */ +#define WFHARD 0x08 /* Better to a full display */ +#define WFMODE 0x10 /* Update mode line. */ +#define WFCOLR 0x20 /* Needs a color change */ + +#if SCROLLCODE +#define WFKILLS 0x40 /* something was deleted */ +#define WFINS 0x80 /* something was inserted */ +#endif int reposition( int f, int n); int redraw( int f, int n) ; diff --git a/word.c b/word.c index da3b456..8420912 100644 --- a/word.c +++ b/word.c @@ -13,12 +13,14 @@ #include #include "basic.h" +#include "buffer.h" #include "estruct.h" #include "edef.h" #include "line.h" #include "log.h" #include "random.h" #include "region.h" +#include "window.h" /* Word wrap on n-spaces. Back-over whatever precedes the point on the current * line and stop on the first word-break or the beginning of the line. If we From 947c4e7ef41734c883178b8ba1cce5dc6bff3b5d Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 20 Sep 2013 18:12:19 +0800 Subject: [PATCH 111/193] Make depend missing in previous commit. --- Makefile | 122 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 65 insertions(+), 57 deletions(-) diff --git a/Makefile b/Makefile index 416fdef..fedbf1d 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# makefile for emacs, updated Fri, Sep 20, 2013 10:43:27 AM +# makefile for emacs, updated Fri, Sep 20, 2013 3:09:46 PM SRC=ansi.c basic.c bind.c bindable.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c globals.c ibmpc.c input.c isearch.c line.c lock.c log.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c OBJ=ansi.o basic.o bind.o bindable.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o globals.o ibmpc.o input.o isearch.o line.o lock.o log.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o @@ -126,69 +126,77 @@ depend: ${SRC} # DO NOT DELETE THIS LINE -- make depend uses it -ansi.o: ansi.c estruct.h line.h utf8.h retcode.h edef.h -basic.o: basic.c basic.h display.h estruct.h line.h utf8.h retcode.h \ - edef.h input.h random.h word.h -bind.o: bind.c bind.h edef.h estruct.h line.h utf8.h retcode.h bindable.h \ - buffer.h display.h ebind.h exec.h file.h flook.h input.h names.h \ - window.h -bindable.o: bindable.c bindable.h buffer.h estruct.h line.h utf8.h \ - retcode.h display.h edef.h file.h input.h -buffer.o: buffer.c buffer.h estruct.h line.h utf8.h retcode.h display.h \ - edef.h file.h input.h window.h -crypt.o: crypt.c defines.h crypt.h -display.o: display.c display.h estruct.h line.h utf8.h retcode.h edef.h \ - termio.h version.h wrapper.h window.h -ebind.o: ebind.c ebind.h basic.h bind.h edef.h estruct.h line.h utf8.h \ - retcode.h bindable.h buffer.h eval.h exec.h file.h isearch.h random.h \ - region.h search.h spawn.h window.h word.h +ansi.o: ansi.c estruct.h line.h utf8.h retcode.h edef.h buffer.h crypt.h +basic.o: basic.c basic.h buffer.h crypt.h line.h utf8.h display.h \ + estruct.h retcode.h edef.h input.h random.h window.h defines.h word.h +bind.o: bind.c bind.h edef.h buffer.h crypt.h line.h utf8.h estruct.h \ + retcode.h bindable.h display.h ebind.h exec.h file.h flook.h input.h \ + names.h window.h defines.h +bindable.o: bindable.c bindable.h defines.h buffer.h crypt.h line.h \ + utf8.h display.h edef.h estruct.h retcode.h file.h input.h +buffer.o: buffer.c buffer.h crypt.h line.h utf8.h defines.h display.h \ + edef.h estruct.h retcode.h file.h input.h window.h +crypt.o: crypt.c crypt.h +display.o: display.c display.h buffer.h crypt.h line.h utf8.h estruct.h \ + retcode.h edef.h termio.h version.h wrapper.h window.h defines.h +ebind.o: ebind.c ebind.h basic.h bind.h edef.h buffer.h crypt.h line.h \ + utf8.h estruct.h retcode.h bindable.h eval.h exec.h file.h isearch.h \ + random.h region.h search.h spawn.h window.h defines.h word.h eval.o: eval.c eval.h estruct.h line.h utf8.h retcode.h basic.h bind.h \ - edef.h buffer.h display.h exec.h flook.h input.h random.h search.h \ - termio.h version.h window.h -exec.o: exec.c exec.h estruct.h line.h utf8.h retcode.h buffer.h bind.h \ - edef.h display.h eval.h file.h flook.h input.h -execute.o: execute.c edef.h estruct.h line.h utf8.h retcode.h bind.h \ - random.h display.h file.h -file.o: file.c estruct.h line.h utf8.h retcode.h file.h buffer.h crypt.h \ - edef.h execute.h fileio.h input.h lock.h log.h window.h -fileio.o: fileio.c defines.h fileio.h retcode.h crypt.h -flook.o: flook.c flook.h retcode.h defines.h fileio.h -globals.o: globals.c estruct.h line.h utf8.h retcode.h edef.h -ibmpc.o: ibmpc.c estruct.h line.h utf8.h retcode.h edef.h -input.o: input.c input.h edef.h estruct.h line.h utf8.h retcode.h bind.h \ - bindable.h display.h exec.h names.h wrapper.h -isearch.o: isearch.c isearch.h basic.h display.h estruct.h line.h utf8.h \ - retcode.h edef.h input.h search.h -line.o: line.c line.h utf8.h edef.h estruct.h retcode.h log.h + edef.h buffer.h crypt.h display.h exec.h flook.h input.h random.h \ + search.h termio.h version.h window.h defines.h +exec.o: exec.c exec.h buffer.h crypt.h line.h utf8.h estruct.h retcode.h \ + bind.h edef.h display.h eval.h file.h flook.h input.h window.h defines.h +execute.o: execute.c edef.h buffer.h crypt.h line.h utf8.h estruct.h \ + retcode.h bind.h random.h display.h file.h window.h defines.h +file.o: file.c file.h crypt.h retcode.h buffer.h line.h utf8.h defines.h \ + estruct.h edef.h execute.h fileio.h input.h lock.h log.h window.h +fileio.o: fileio.c fileio.h crypt.h retcode.h defines.h +flook.o: flook.c flook.h retcode.h defines.h fileio.h crypt.h +globals.o: globals.c crypt.h defines.h edef.h buffer.h line.h utf8.h \ + estruct.h retcode.h +ibmpc.o: ibmpc.c estruct.h line.h utf8.h retcode.h edef.h buffer.h \ + crypt.h +input.o: input.c input.h edef.h buffer.h crypt.h line.h utf8.h estruct.h \ + retcode.h bind.h bindable.h display.h exec.h names.h wrapper.h +isearch.o: isearch.c isearch.h basic.h buffer.h crypt.h line.h utf8.h \ + display.h estruct.h retcode.h edef.h input.h search.h window.h defines.h +line.o: line.c line.h utf8.h buffer.h crypt.h edef.h estruct.h retcode.h \ + log.h window.h defines.h lock.o: lock.c lock.h estruct.h line.h utf8.h retcode.h display.h edef.h \ - input.h + buffer.h crypt.h input.h log.o: log.c log.h retcode.h -main.o: main.c basic.h bind.h edef.h estruct.h line.h utf8.h retcode.h \ - bindable.h buffer.h display.h eval.h execute.h file.h input.h lock.h \ - log.h random.h search.h termio.h version.h -names.o: names.c names.h basic.h bind.h edef.h estruct.h line.h utf8.h \ - retcode.h bindable.h buffer.h display.h eval.h exec.h file.h isearch.h \ - region.h random.h search.h spawn.h window.h word.h -pklock.o: pklock.c pklock.h estruct.h line.h utf8.h retcode.h edef.h +main.o: main.c basic.h bind.h edef.h buffer.h crypt.h line.h utf8.h \ + estruct.h retcode.h bindable.h display.h eval.h execute.h file.h input.h \ + lock.h log.h random.h search.h termio.h version.h window.h defines.h +names.o: names.c names.h basic.h bind.h edef.h buffer.h crypt.h line.h \ + utf8.h estruct.h retcode.h bindable.h display.h eval.h exec.h file.h \ + isearch.h region.h random.h search.h spawn.h window.h defines.h word.h +pklock.o: pklock.c pklock.h estruct.h line.h utf8.h retcode.h edef.h \ + buffer.h crypt.h posix.o: posix.c termio.h -random.o: random.c random.h basic.h display.h estruct.h line.h utf8.h \ - retcode.h edef.h execute.h input.h log.h search.h -region.o: region.c region.h estruct.h line.h utf8.h retcode.h edef.h \ - log.h +random.o: random.c random.h basic.h buffer.h crypt.h line.h utf8.h \ + display.h estruct.h retcode.h edef.h execute.h input.h log.h search.h \ + window.h defines.h +region.o: region.c region.h estruct.h line.h utf8.h retcode.h buffer.h \ + crypt.h edef.h log.h window.h defines.h search.o: search.c search.h estruct.h line.h utf8.h retcode.h basic.h \ - display.h edef.h input.h log.h -spawn.o: spawn.c spawn.h buffer.h estruct.h line.h utf8.h retcode.h \ - display.h edef.h file.h flook.h input.h log.h window.h + buffer.h crypt.h display.h edef.h input.h log.h window.h defines.h +spawn.o: spawn.c spawn.h defines.h buffer.h crypt.h line.h utf8.h \ + display.h estruct.h retcode.h edef.h file.h flook.h input.h log.h \ + window.h tcap.o: tcap.c display.h estruct.h line.h utf8.h retcode.h edef.h \ - termio.h -termio.o: termio.c termio.h estruct.h line.h utf8.h retcode.h edef.h + buffer.h crypt.h termio.h +termio.o: termio.c termio.h estruct.h line.h utf8.h retcode.h edef.h \ + buffer.h crypt.h utf8.o: utf8.c utf8.h -vmsvt.o: vmsvt.c estruct.h line.h utf8.h retcode.h edef.h -vt52.o: vt52.c estruct.h line.h utf8.h retcode.h edef.h -window.o: window.c window.h estruct.h line.h utf8.h retcode.h basic.h \ - display.h edef.h execute.h wrapper.h -word.o: word.c word.h basic.h estruct.h line.h utf8.h retcode.h edef.h \ - log.h random.h region.h +vmsvt.o: vmsvt.c estruct.h line.h utf8.h retcode.h edef.h buffer.h \ + crypt.h +vt52.o: vt52.c estruct.h line.h utf8.h retcode.h edef.h buffer.h crypt.h +window.o: window.c window.h defines.h buffer.h crypt.h line.h utf8.h \ + basic.h display.h edef.h estruct.h retcode.h execute.h wrapper.h +word.o: word.c word.h basic.h buffer.h crypt.h line.h utf8.h estruct.h \ + retcode.h edef.h log.h random.h region.h window.h defines.h wrapper.o: wrapper.c wrapper.h # DEPENDENCIES MUST END AT END OF FILE From 263834b7d9f8c3d998834a0b85fa53b646c62a53 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sat, 21 Sep 2013 10:24:45 +0800 Subject: [PATCH 112/193] Recompile on linux; Clean up lock prototypes. --- Makefile | 42 +++++++++++++++++++++--------------------- bindable.c | 1 + lock.c | 12 ++++++------ lock.h | 6 +++--- pklock.c | 4 ++-- pklock.h | 4 ++-- 6 files changed, 35 insertions(+), 34 deletions(-) diff --git a/Makefile b/Makefile index fedbf1d..324a490 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# makefile for emacs, updated Fri, Sep 20, 2013 3:09:46 PM +# Makefile for emacs, updated Fri, Sep 20, 2013 3:09:46 PM SRC=ansi.c basic.c bind.c bindable.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c globals.c ibmpc.c input.c isearch.c line.c lock.c log.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c OBJ=ansi.o basic.o bind.o bindable.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o globals.o ibmpc.o input.o isearch.o line.o lock.o log.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o @@ -65,7 +65,7 @@ sparse: clean: $(E) " CLEAN" - $(Q) rm -f $(PROGRAM) core lintout makeout tags makefile.bak *.o + $(Q) rm -f $(PROGRAM) core lintout makeout tags Makefile.bak *.o install: $(PROGRAM) strip $(PROGRAM) @@ -89,14 +89,14 @@ tags: ${SRC} ctags ${SRC} source: - @mv makefile makefile.bak - @echo "# makefile for emacs, updated `date`" >makefile - @echo '' >>makefile - @echo SRC=`ls *.c` >>makefile - @echo OBJ=`ls *.c | sed s/c$$/o/` >>makefile - @echo HDR=`ls *.h` >>makefile - @echo '' >>makefile - @sed -n -e '/^# DO NOT ADD OR MODIFY/,$$p' >makefile + @mv Makefile Makefile.bak + @echo "# Makefile for emacs, updated `date`" >Makefile + @echo '' >>Makefile + @echo SRC=`ls *.c` >>Makefile + @echo OBJ=`ls *.c | sed s/c$$/o/` >>Makefile + @echo HDR=`ls *.h` >>Makefile + @echo '' >>Makefile + @sed -n -e '/^# DO NOT ADD OR MODIFY/,$$p' >Makefile depend: ${SRC} @for i in ${SRC}; do\ @@ -104,13 +104,13 @@ depend: ${SRC} @echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep @echo '$$r ./makedep' >>eddep @echo 'w' >>eddep - @cp makefile makefile.bak - @ed - makefile >makefile - @echo '# DEPENDENCIES MUST END AT END OF FILE' >>makefile - @echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >>makefile - @echo '# see make depend above' >>makefile + @echo '' >>Makefile + @echo '# DEPENDENCIES MUST END AT END OF FILE' >>Makefile + @echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >>Makefile + @echo '# see make depend above' >>Makefile # @for i in ${SRC}; do\ # cc ${DEFINES} -M $$i | sed -e 's, \./, ,' | grep -v '/usr/include' | \ @@ -133,7 +133,7 @@ bind.o: bind.c bind.h edef.h buffer.h crypt.h line.h utf8.h estruct.h \ retcode.h bindable.h display.h ebind.h exec.h file.h flook.h input.h \ names.h window.h defines.h bindable.o: bindable.c bindable.h defines.h buffer.h crypt.h line.h \ - utf8.h display.h edef.h estruct.h retcode.h file.h input.h + utf8.h display.h edef.h estruct.h retcode.h file.h input.h lock.h buffer.o: buffer.c buffer.h crypt.h line.h utf8.h defines.h display.h \ edef.h estruct.h retcode.h file.h input.h window.h crypt.o: crypt.c crypt.h @@ -164,7 +164,7 @@ isearch.o: isearch.c isearch.h basic.h buffer.h crypt.h line.h utf8.h \ line.o: line.c line.h utf8.h buffer.h crypt.h edef.h estruct.h retcode.h \ log.h window.h defines.h lock.o: lock.c lock.h estruct.h line.h utf8.h retcode.h display.h edef.h \ - buffer.h crypt.h input.h + buffer.h crypt.h input.h pklock.h log.o: log.c log.h retcode.h main.o: main.c basic.h bind.h edef.h buffer.h crypt.h line.h utf8.h \ estruct.h retcode.h bindable.h display.h eval.h execute.h file.h input.h \ @@ -174,7 +174,8 @@ names.o: names.c names.h basic.h bind.h edef.h buffer.h crypt.h line.h \ isearch.h region.h random.h search.h spawn.h window.h defines.h word.h pklock.o: pklock.c pklock.h estruct.h line.h utf8.h retcode.h edef.h \ buffer.h crypt.h -posix.o: posix.c termio.h +posix.o: posix.c termio.h estruct.h line.h utf8.h retcode.h edef.h \ + buffer.h crypt.h random.o: random.c random.h basic.h buffer.h crypt.h line.h utf8.h \ display.h estruct.h retcode.h edef.h execute.h input.h log.h search.h \ window.h defines.h @@ -187,8 +188,7 @@ spawn.o: spawn.c spawn.h defines.h buffer.h crypt.h line.h utf8.h \ window.h tcap.o: tcap.c display.h estruct.h line.h utf8.h retcode.h edef.h \ buffer.h crypt.h termio.h -termio.o: termio.c termio.h estruct.h line.h utf8.h retcode.h edef.h \ - buffer.h crypt.h +termio.o: termio.c termio.h utf8.o: utf8.c utf8.h vmsvt.o: vmsvt.c estruct.h line.h utf8.h retcode.h edef.h buffer.h \ crypt.h diff --git a/bindable.c b/bindable.c index b23f431..8ae843c 100644 --- a/bindable.c +++ b/bindable.c @@ -7,6 +7,7 @@ #include "edef.h" #include "file.h" #include "input.h" +#include "lock.h" #if VMS #include diff --git a/lock.c b/lock.c index 326d577..1f2f516 100644 --- a/lock.c +++ b/lock.c @@ -30,9 +30,9 @@ static void lckerror(char *errstr) ; * lockchk: * check a file for locking and add it to the list * - * char *fname; file to check for a lock + * const char *fname; file to check for a lock */ -int lockchk(char *fname) +int lockchk( const char *fname) { int i; /* loop indexes */ int status; /* return status */ @@ -98,9 +98,9 @@ int lockrel(void) * FALSE = file was locked and overridden * ABORT = file was locked, abort command * - * char *fname; file name to lock + * const char *fname; file name to lock */ -int lock(char *fname) +int lock( const char *fname) { char *locker; /* lock error message */ int status; /* return status */ @@ -133,9 +133,9 @@ int lock(char *fname) * Unlock a file * this only warns the user if it fails * - * char *fname; file to unlock + * const char *fname; file to unlock */ -int unlock(char *fname) +int unlock( const char *fname) { char *locker; /* undolock return string */ diff --git a/lock.h b/lock.h index a5a24d0..b0e7ace 100644 --- a/lock.h +++ b/lock.h @@ -5,10 +5,10 @@ #if BSD | SVR4 -int lockchk( char *fname) ; +int lockchk( const char *fname) ; int lockrel( void) ; -int lock( char *fname) ; -int unlock( char *fname) ; +int lock( const char *fname) ; +int unlock( const char *fname) ; #endif diff --git a/pklock.c b/pklock.c index 976a3d2..a403d76 100644 --- a/pklock.c +++ b/pklock.c @@ -42,7 +42,7 @@ int gethostname(char *name, int namelen) * if other error, returns "LOCK ERROR: explanation" * *********************/ -char *dolock(char *fname) +char *dolock( const char *fname) { int fd, n; static char lname[MAXLOCK], locker[MAXNAME + 1]; @@ -103,7 +103,7 @@ char *dolock(char *fname) * *********************/ -char *undolock(char *fname) +char *undolock( const char *fname) { static char lname[MAXLOCK]; diff --git a/pklock.h b/pklock.h index a75ac02..7b62237 100644 --- a/pklock.h +++ b/pklock.h @@ -3,8 +3,8 @@ #if (FILOCK && BSD) || SVR4 -char *dolock( char *fname) ; -char *undolock( char *fname) ; +char *dolock( const char *fname) ; +char *undolock( const char *fname) ; #endif From 63feade29946595258ee59df5129bc01b2cd53b9 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sat, 21 Sep 2013 11:43:48 +0800 Subject: [PATCH 113/193] make depend on Cygwin64. --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 324a490..d6125ae 100644 --- a/Makefile +++ b/Makefile @@ -164,7 +164,7 @@ isearch.o: isearch.c isearch.h basic.h buffer.h crypt.h line.h utf8.h \ line.o: line.c line.h utf8.h buffer.h crypt.h edef.h estruct.h retcode.h \ log.h window.h defines.h lock.o: lock.c lock.h estruct.h line.h utf8.h retcode.h display.h edef.h \ - buffer.h crypt.h input.h pklock.h + buffer.h crypt.h input.h log.o: log.c log.h retcode.h main.o: main.c basic.h bind.h edef.h buffer.h crypt.h line.h utf8.h \ estruct.h retcode.h bindable.h display.h eval.h execute.h file.h input.h \ @@ -174,8 +174,7 @@ names.o: names.c names.h basic.h bind.h edef.h buffer.h crypt.h line.h \ isearch.h region.h random.h search.h spawn.h window.h defines.h word.h pklock.o: pklock.c pklock.h estruct.h line.h utf8.h retcode.h edef.h \ buffer.h crypt.h -posix.o: posix.c termio.h estruct.h line.h utf8.h retcode.h edef.h \ - buffer.h crypt.h +posix.o: posix.c termio.h random.o: random.c random.h basic.h buffer.h crypt.h line.h utf8.h \ display.h estruct.h retcode.h edef.h execute.h input.h log.h search.h \ window.h defines.h @@ -188,7 +187,8 @@ spawn.o: spawn.c spawn.h defines.h buffer.h crypt.h line.h utf8.h \ window.h tcap.o: tcap.c display.h estruct.h line.h utf8.h retcode.h edef.h \ buffer.h crypt.h termio.h -termio.o: termio.c termio.h +termio.o: termio.c termio.h estruct.h line.h utf8.h retcode.h edef.h \ + buffer.h crypt.h utf8.o: utf8.c utf8.h vmsvt.o: vmsvt.c estruct.h line.h utf8.h retcode.h edef.h buffer.h \ crypt.h From 7b079662e471c8f25c2823692776b42b6ad1c3cb Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Mon, 23 Sep 2013 17:45:02 +0800 Subject: [PATCH 114/193] Remove line.h from estruct.h. --- Makefile | 42 +++++++++++++++++++++--------------------- estruct.h | 3 --- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index d6125ae..67df64a 100644 --- a/Makefile +++ b/Makefile @@ -126,7 +126,7 @@ depend: ${SRC} # DO NOT DELETE THIS LINE -- make depend uses it -ansi.o: ansi.c estruct.h line.h utf8.h retcode.h edef.h buffer.h crypt.h +ansi.o: ansi.c estruct.h retcode.h edef.h buffer.h crypt.h line.h utf8.h basic.o: basic.c basic.h buffer.h crypt.h line.h utf8.h display.h \ estruct.h retcode.h edef.h input.h random.h window.h defines.h word.h bind.o: bind.c bind.h edef.h buffer.h crypt.h line.h utf8.h estruct.h \ @@ -142,9 +142,9 @@ display.o: display.c display.h buffer.h crypt.h line.h utf8.h estruct.h \ ebind.o: ebind.c ebind.h basic.h bind.h edef.h buffer.h crypt.h line.h \ utf8.h estruct.h retcode.h bindable.h eval.h exec.h file.h isearch.h \ random.h region.h search.h spawn.h window.h defines.h word.h -eval.o: eval.c eval.h estruct.h line.h utf8.h retcode.h basic.h bind.h \ - edef.h buffer.h crypt.h display.h exec.h flook.h input.h random.h \ - search.h termio.h version.h window.h defines.h +eval.o: eval.c eval.h estruct.h retcode.h basic.h bind.h edef.h buffer.h \ + crypt.h line.h utf8.h display.h exec.h flook.h input.h random.h search.h \ + termio.h version.h window.h defines.h exec.o: exec.c exec.h buffer.h crypt.h line.h utf8.h estruct.h retcode.h \ bind.h edef.h display.h eval.h file.h flook.h input.h window.h defines.h execute.o: execute.c edef.h buffer.h crypt.h line.h utf8.h estruct.h \ @@ -155,16 +155,16 @@ fileio.o: fileio.c fileio.h crypt.h retcode.h defines.h flook.o: flook.c flook.h retcode.h defines.h fileio.h crypt.h globals.o: globals.c crypt.h defines.h edef.h buffer.h line.h utf8.h \ estruct.h retcode.h -ibmpc.o: ibmpc.c estruct.h line.h utf8.h retcode.h edef.h buffer.h \ - crypt.h +ibmpc.o: ibmpc.c estruct.h retcode.h edef.h buffer.h crypt.h line.h \ + utf8.h input.o: input.c input.h edef.h buffer.h crypt.h line.h utf8.h estruct.h \ retcode.h bind.h bindable.h display.h exec.h names.h wrapper.h isearch.o: isearch.c isearch.h basic.h buffer.h crypt.h line.h utf8.h \ display.h estruct.h retcode.h edef.h input.h search.h window.h defines.h line.o: line.c line.h utf8.h buffer.h crypt.h edef.h estruct.h retcode.h \ log.h window.h defines.h -lock.o: lock.c lock.h estruct.h line.h utf8.h retcode.h display.h edef.h \ - buffer.h crypt.h input.h +lock.o: lock.c lock.h estruct.h retcode.h display.h edef.h buffer.h \ + crypt.h line.h utf8.h input.h log.o: log.c log.h retcode.h main.o: main.c basic.h bind.h edef.h buffer.h crypt.h line.h utf8.h \ estruct.h retcode.h bindable.h display.h eval.h execute.h file.h input.h \ @@ -172,27 +172,27 @@ main.o: main.c basic.h bind.h edef.h buffer.h crypt.h line.h utf8.h \ names.o: names.c names.h basic.h bind.h edef.h buffer.h crypt.h line.h \ utf8.h estruct.h retcode.h bindable.h display.h eval.h exec.h file.h \ isearch.h region.h random.h search.h spawn.h window.h defines.h word.h -pklock.o: pklock.c pklock.h estruct.h line.h utf8.h retcode.h edef.h \ - buffer.h crypt.h +pklock.o: pklock.c pklock.h estruct.h retcode.h edef.h buffer.h crypt.h \ + line.h utf8.h posix.o: posix.c termio.h random.o: random.c random.h basic.h buffer.h crypt.h line.h utf8.h \ display.h estruct.h retcode.h edef.h execute.h input.h log.h search.h \ window.h defines.h -region.o: region.c region.h estruct.h line.h utf8.h retcode.h buffer.h \ - crypt.h edef.h log.h window.h defines.h -search.o: search.c search.h estruct.h line.h utf8.h retcode.h basic.h \ - buffer.h crypt.h display.h edef.h input.h log.h window.h defines.h +region.o: region.c region.h estruct.h retcode.h buffer.h crypt.h line.h \ + utf8.h edef.h log.h window.h defines.h +search.o: search.c search.h estruct.h retcode.h basic.h buffer.h crypt.h \ + line.h utf8.h display.h edef.h input.h log.h window.h defines.h spawn.o: spawn.c spawn.h defines.h buffer.h crypt.h line.h utf8.h \ display.h estruct.h retcode.h edef.h file.h flook.h input.h log.h \ window.h -tcap.o: tcap.c display.h estruct.h line.h utf8.h retcode.h edef.h \ - buffer.h crypt.h termio.h -termio.o: termio.c termio.h estruct.h line.h utf8.h retcode.h edef.h \ - buffer.h crypt.h +tcap.o: tcap.c display.h estruct.h retcode.h edef.h buffer.h crypt.h \ + line.h utf8.h termio.h +termio.o: termio.c termio.h estruct.h retcode.h edef.h buffer.h crypt.h \ + line.h utf8.h utf8.o: utf8.c utf8.h -vmsvt.o: vmsvt.c estruct.h line.h utf8.h retcode.h edef.h buffer.h \ - crypt.h -vt52.o: vt52.c estruct.h line.h utf8.h retcode.h edef.h buffer.h crypt.h +vmsvt.o: vmsvt.c estruct.h retcode.h edef.h buffer.h crypt.h line.h \ + utf8.h +vt52.o: vt52.c estruct.h retcode.h edef.h buffer.h crypt.h line.h utf8.h window.o: window.c window.h defines.h buffer.h crypt.h line.h utf8.h \ basic.h display.h edef.h estruct.h retcode.h execute.h wrapper.h word.o: word.c word.h basic.h buffer.h crypt.h line.h utf8.h estruct.h \ diff --git a/estruct.h b/estruct.h index 87e71e1..4b0fb78 100644 --- a/estruct.h +++ b/estruct.h @@ -12,9 +12,6 @@ */ -#include "line.h" - - #define MAXCOL 500 #define MAXROW 500 From 870989f9486010fe9b16b83d6577c61dfde2d476 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Mon, 23 Sep 2013 18:58:31 +0800 Subject: [PATCH 115/193] Move struct region from estruct.t to regiom.h. --- Makefile | 4 ++-- estruct.h | 10 ---------- region.h | 12 +++++++++++- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 67df64a..0a84df7 100644 --- a/Makefile +++ b/Makefile @@ -178,8 +178,8 @@ posix.o: posix.c termio.h random.o: random.c random.h basic.h buffer.h crypt.h line.h utf8.h \ display.h estruct.h retcode.h edef.h execute.h input.h log.h search.h \ window.h defines.h -region.o: region.c region.h estruct.h retcode.h buffer.h crypt.h line.h \ - utf8.h edef.h log.h window.h defines.h +region.o: region.c region.h line.h utf8.h buffer.h crypt.h estruct.h \ + retcode.h edef.h log.h window.h defines.h search.o: search.c search.h estruct.h retcode.h basic.h buffer.h crypt.h \ line.h utf8.h display.h edef.h input.h log.h window.h defines.h spawn.o: spawn.c spawn.h defines.h buffer.h crypt.h line.h utf8.h \ diff --git a/estruct.h b/estruct.h index 4b0fb78..ad22d3e 100644 --- a/estruct.h +++ b/estruct.h @@ -385,16 +385,6 @@ int cexit( int status) ; #endif -/* - * The starting position of a region, and the size of the region in - * characters, is kept in a region structure. Used by the region commands. - */ -struct region { - struct line *r_linep; /* Origin struct line address. */ - int r_offset; /* Origin struct line offset. */ - long r_size; /* Length in characters. */ -}; - /* * The editor communicates with the display using a high level interface. A * "TERM" structure holds useful variables, and indirect pointers to routines diff --git a/region.h b/region.h index bd98247..1e46e7f 100644 --- a/region.h +++ b/region.h @@ -1,7 +1,17 @@ #ifndef _REGION_H_ #define _REGION_H_ -#include "estruct.h" +#include "line.h" + +/* + * The starting position of a region, and the size of the region in + * characters, is kept in a region structure. Used by the region commands. + */ +struct region { + struct line *r_linep; /* Origin struct line address. */ + int r_offset; /* Origin struct line offset. */ + long r_size; /* Length in characters. */ +}; int killregion( int f, int n) ; int copyregion( int f, int n) ; From f99fe6fe5402a309a5f0c94fe116a7e00a13d7b8 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Mon, 23 Sep 2013 19:31:29 +0800 Subject: [PATCH 116/193] Move magic related definitions from estruct.h to search.c. Review search.h accordingly. --- Makefile | 4 ++-- estruct.h | 56 +----------------------------------------------------- search.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- search.h | 8 ++++++-- 4 files changed, 64 insertions(+), 61 deletions(-) diff --git a/Makefile b/Makefile index 0a84df7..14ad258 100644 --- a/Makefile +++ b/Makefile @@ -180,8 +180,8 @@ random.o: random.c random.h basic.h buffer.h crypt.h line.h utf8.h \ window.h defines.h region.o: region.c region.h line.h utf8.h buffer.h crypt.h estruct.h \ retcode.h edef.h log.h window.h defines.h -search.o: search.c search.h estruct.h retcode.h basic.h buffer.h crypt.h \ - line.h utf8.h display.h edef.h input.h log.h window.h defines.h +search.o: search.c search.h line.h utf8.h basic.h buffer.h crypt.h \ + display.h edef.h estruct.h retcode.h input.h log.h window.h defines.h spawn.o: spawn.c spawn.h defines.h buffer.h crypt.h line.h utf8.h \ display.h estruct.h retcode.h edef.h file.h flook.h input.h log.h \ window.h diff --git a/estruct.h b/estruct.h index ad22d3e..744eceb 100644 --- a/estruct.h +++ b/estruct.h @@ -157,8 +157,8 @@ #define APROP 1 /* Add code for Apropos command */ #if 0 #define CRYPT 1 /* file encryption enabled? */ -#endif #define MAGIC 1 /* include regular expression matching? */ +#endif #define AEDIT 1 /* advanced editing options: en/detabbing */ #define PROC 1 /* named procedures */ #define CLEAN 0 /* de-alloc memory on exit */ @@ -503,59 +503,5 @@ struct while_block { #endif -#if defined(MAGIC) -/* - * Defines for the metacharacters in the regular expression - * search routines. - */ -#define MCNIL 0 /* Like the '\0' for strings. */ -#define LITCHAR 1 /* Literal character, or string. */ -#define ANY 2 -#define CCL 3 -#define NCCL 4 -#define BOL 5 -#define EOL 6 -#define DITTO 7 -#define CLOSURE 256 /* An or-able value. */ -#define MASKCL (CLOSURE - 1) - -#define MC_ANY '.' /* 'Any' character (except newline). */ -#define MC_CCL '[' /* Character class. */ -#define MC_NCCL '^' /* Negate character class. */ -#define MC_RCCL '-' /* Range in character class. */ -#define MC_ECCL ']' /* End of character class. */ -#define MC_BOL '^' /* Beginning of line. */ -#define MC_EOL '$' /* End of line. */ -#define MC_CLOSURE '*' /* Closure - does not extend past newline. */ -#define MC_DITTO '&' /* Use matched string in replacement. */ -#define MC_ESC '\\' /* Escape - suppress meta-meaning. */ - -#define BIT(n) (1 << (n)) /* An integer with one bit set. */ -#define CHCASE(c) ((c) ^ DIFCASE) /* Toggle the case of a letter. */ - -/* HICHAR - 1 is the largest character we will deal with. - * HIBYTE represents the number of bytes in the bitmap. - */ -#define HICHAR 256 -#define HIBYTE HICHAR >> 3 - -/* Typedefs that define the meta-character structure for MAGIC mode searching - * (struct magic), and the meta-character structure for MAGIC mode replacement - * (struct magic_replacement). - */ -struct magic { - short int mc_type; - union { - int lchar; - char *cclmap; - } u; -}; - -struct magic_replacement { - short int mc_type; - char *rstr; -}; - -#endif /* MAGIC */ #endif diff --git a/search.c b/search.c index c242f1f..ea6f718 100644 --- a/search.c +++ b/search.c @@ -65,7 +65,6 @@ #include "basic.h" #include "buffer.h" #include "display.h" -#include "estruct.h" #include "edef.h" #include "input.h" #include "line.h" @@ -73,6 +72,58 @@ #include "window.h" #if defined(MAGIC) +/* + * Defines for the metacharacters in the regular expression + * search routines. + */ +#define MCNIL 0 /* Like the '\0' for strings. */ +#define LITCHAR 1 /* Literal character, or string. */ +#define ANY 2 +#define CCL 3 +#define NCCL 4 +#define BOL 5 +#define EOL 6 +#define DITTO 7 +#define CLOSURE 256 /* An or-able value. */ +#define MASKCL (CLOSURE - 1) + +#define MC_ANY '.' /* 'Any' character (except newline). */ +#define MC_CCL '[' /* Character class. */ +#define MC_NCCL '^' /* Negate character class. */ +#define MC_RCCL '-' /* Range in character class. */ +#define MC_ECCL ']' /* End of character class. */ +#define MC_BOL '^' /* Beginning of line. */ +#define MC_EOL '$' /* End of line. */ +#define MC_CLOSURE '*' /* Closure - does not extend past newline. */ +#define MC_DITTO '&' /* Use matched string in replacement. */ +#define MC_ESC '\\' /* Escape - suppress meta-meaning. */ + +#define BIT(n) (1 << (n)) /* An integer with one bit set. */ +#define CHCASE(c) ((c) ^ DIFCASE) /* Toggle the case of a letter. */ + +/* HICHAR - 1 is the largest character we will deal with. + * HIBYTE represents the number of bytes in the bitmap. + */ +#define HICHAR 256 +#define HIBYTE HICHAR >> 3 + +/* Typedefs that define the meta-character structure for MAGIC mode searching + * (struct magic), and the meta-character structure for MAGIC mode replacement + * (struct magic_replacement). + */ +struct magic { + short int mc_type; + union { + int lchar; + char *cclmap; + } u; +}; + +struct magic_replacement { + short int mc_type; + char *rstr; +}; + /* * The variables magical and rmagical determine if there * were actual metacharacters in the search and replace strings - @@ -84,6 +135,8 @@ static short int rmagical; static struct magic mcpat[NPAT]; /* The magic pattern. */ static struct magic tapcm[NPAT]; /* The reversed magic patterni. */ static struct magic_replacement rmcpat[NPAT]; /* The replacement magic array. */ + +static int mcscanner( struct magic *mcpatrn, int direct, int beg_or_end) ; #endif static int amatch(struct magic *mcptr, int direct, struct line **pcwline, int *pcwoff); @@ -309,7 +362,7 @@ int backhunt(int f, int n) * int direct; which way to go. * int beg_or_end; put point at beginning or end of pattern. */ -int mcscanner(struct magic *mcpatrn, int direct, int beg_or_end) +static int mcscanner(struct magic *mcpatrn, int direct, int beg_or_end) { struct line *curline; /* current line during scan */ int curoff; /* position within current line */ diff --git a/search.h b/search.h index 040a437..83ae0b7 100644 --- a/search.h +++ b/search.h @@ -1,13 +1,14 @@ #ifndef _SEARCH_H_ #define _SEARCH_H_ -#include "estruct.h" +#define MAGIC 1 + +#include "line.h" int forwsearch( int f, int n) ; int forwhunt( int f, int n) ; int backsearch( int f, int n) ; int backhunt( int f, int n) ; -int mcscanner( struct magic *mcpatrn, int direct, int beg_or_end) ; int scanner( const char *patrn, int direct, int beg_or_end) ; int eq( unsigned char bc, unsigned char pc) ; void savematch( void) ; @@ -17,7 +18,10 @@ int qreplace( int f, int n) ; int delins( int dlength, char *instr, int use_meta) ; int expandp( char *srcstr, char *deststr, int maxlength) ; int boundry( struct line *curline, int curoff, int dir) ; + +#if MAGIC void mcclear( void) ; void rmcclear( void) ; +#endif #endif From 33713eb3bf52f81b915a982131a54df2d3d088c5 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Mon, 23 Sep 2013 20:28:31 +0800 Subject: [PATCH 117/193] Add lost comment in search.h (improve on previous commit). --- search.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/search.h b/search.h index 83ae0b7..fb6afee 100644 --- a/search.h +++ b/search.h @@ -1,7 +1,7 @@ #ifndef _SEARCH_H_ #define _SEARCH_H_ -#define MAGIC 1 +#define MAGIC 1 /* include regular expression matching? */ #include "line.h" From 01d108d56dfe7a4d71161ee4927226df47ca5b65 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Mon, 23 Sep 2013 20:29:49 +0800 Subject: [PATCH 118/193] Move struct while and related defines from estruct to exec. Review exec.h. --- Makefile | 5 +++-- estruct.h | 38 ++------------------------------------ exec.c | 37 +++++++++++++++++++++++++++++++++++-- exec.h | 12 ++++++------ 4 files changed, 46 insertions(+), 46 deletions(-) diff --git a/Makefile b/Makefile index 14ad258..d5ada54 100644 --- a/Makefile +++ b/Makefile @@ -145,8 +145,9 @@ ebind.o: ebind.c ebind.h basic.h bind.h edef.h buffer.h crypt.h line.h \ eval.o: eval.c eval.h estruct.h retcode.h basic.h bind.h edef.h buffer.h \ crypt.h line.h utf8.h display.h exec.h flook.h input.h random.h search.h \ termio.h version.h window.h defines.h -exec.o: exec.c exec.h buffer.h crypt.h line.h utf8.h estruct.h retcode.h \ - bind.h edef.h display.h eval.h file.h flook.h input.h window.h defines.h +exec.o: exec.c exec.h buffer.h crypt.h line.h utf8.h bind.h edef.h \ + estruct.h retcode.h display.h eval.h file.h flook.h input.h window.h \ + defines.h execute.o: execute.c edef.h buffer.h crypt.h line.h utf8.h estruct.h \ retcode.h bind.h random.h display.h file.h window.h defines.h file.o: file.c file.h crypt.h retcode.h buffer.h line.h utf8.h defines.h \ diff --git a/estruct.h b/estruct.h index 744eceb..94d0cf1 100644 --- a/estruct.h +++ b/estruct.h @@ -160,7 +160,9 @@ #define MAGIC 1 /* include regular expression matching? */ #endif #define AEDIT 1 /* advanced editing options: en/detabbing */ +#if 0 #define PROC 1 /* named procedures */ +#endif #define CLEAN 0 /* de-alloc memory on exit */ #define ASCII 1 /* always using ASCII char sequences for now */ @@ -250,27 +252,6 @@ #include "retcode.h" -#if 0 -#define STOP 0 /* keyboard macro not in use */ -#define PLAY 1 /* playing */ -#define RECORD 2 /* recording */ -#endif - -/* Directive definitions */ - -#define DIF 0 -#define DELSE 1 -#define DENDIF 2 -#define DGOTO 3 -#define DRETURN 4 -#define DENDM 5 -#define DWHILE 6 -#define DENDWHILE 7 -#define DBREAK 8 -#define DFORCE 9 - -#define NUMDIRS 10 - /* * PTBEG, PTEND, FORWARD, and REVERSE are all toggle-able values for * the scan routines. @@ -465,21 +446,6 @@ struct variable_description { int v_num; /* Ordinal pointer to variable in list. */ }; -/* The !WHILE directive in the execution language needs to - * stack references to pending whiles. These are stored linked - * to each currently open procedure via a linked list of - * the following structure. -*/ -struct while_block { - struct line *w_begin; /* ptr to !while statement */ - struct line *w_end; /* ptr to the !endwhile statement */ - int w_type; /* block type */ - struct while_block *w_next; /* next while */ -}; - -#define BTWHILE 1 -#define BTBREAK 2 - /* * Incremental search defines. */ diff --git a/exec.c b/exec.c index 2a6fa25..58ce976 100644 --- a/exec.c +++ b/exec.c @@ -24,6 +24,36 @@ #include "line.h" #include "window.h" +/* Directive definitions */ + +#define DIF 0 +#define DELSE 1 +#define DENDIF 2 +#define DGOTO 3 +#define DRETURN 4 +#define DENDM 5 +#define DWHILE 6 +#define DENDWHILE 7 +#define DBREAK 8 +#define DFORCE 9 + +#define NUMDIRS 10 + +/* The !WHILE directive in the execution language needs to + * stack references to pending whiles. These are stored linked + * to each currently open procedure via a linked list of + * the following structure. +*/ +struct while_block { + struct line *w_begin; /* ptr to !while statement */ + struct line *w_end; /* ptr to the !endwhile statement */ + int w_type; /* block type */ + struct while_block *w_next; /* next while */ +}; + +#define BTWHILE 1 +#define BTBREAK 2 + /* directive name table: This holds the names of all the directives.... */ @@ -34,6 +64,9 @@ static const char *dname[] = { "force" }; +static int dobuf( struct buffer *bp) ; +static void freewhile( struct while_block *wp) ; + /* * Execute a named command even if it is not bound. */ @@ -436,7 +469,7 @@ int execbuf(int f, int n) * * struct buffer *bp; buffer to execute */ -int dobuf(struct buffer *bp) +static int dobuf(struct buffer *bp) { int status; /* status return */ struct line *lp; /* pointer to line to execute */ @@ -853,7 +886,7 @@ int dobuf(struct buffer *bp) * * struct while_block *wp; head of structure to free */ -void freewhile(struct while_block *wp) +static void freewhile(struct while_block *wp) { if (wp == NULL) return; diff --git a/exec.h b/exec.h index e0604c7..56939b4 100644 --- a/exec.h +++ b/exec.h @@ -1,8 +1,12 @@ #ifndef _EXEC_H_ #define _EXEC_H_ -#include "buffer.h" -#include "estruct.h" +#define PROC 1 /* named procedures */ + +#if PROC +int storeproc( int f, int n) ; +int execproc( int f, int n) ; +#endif int namedcmd( int f, int n) ; int execcmd( int f, int n) ; @@ -11,11 +15,7 @@ char *token( char *src, char *tok, int size) ; int macarg( char *tok) ; int nextarg( const char *prompt, char *buffer, int size, int terminator) ; int storemac( int f, int n) ; -int storeproc( int f, int n) ; -int execproc( int f, int n) ; int execbuf( int f, int n) ; -int dobuf( struct buffer *bp) ; -void freewhile( struct while_block *wp) ; int execfile( int f, int n) ; int dofile( char *fname) ; int cbuf( int f, int n, int bufnum) ; From 58642eb97fa8a6403530f8e8bc3ba991c67fde6b Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Mon, 23 Sep 2013 20:55:59 +0800 Subject: [PATCH 119/193] Move variable related definition from estruct to eval, and ISRCH related ones to isearch. --- Makefile | 6 +++--- estruct.h | 35 ++--------------------------------- eval.c | 16 ++++++++++++++-- eval.h | 4 ---- isearch.c | 24 ++++++++++++++++++++++++ isearch.h | 9 +++++++++ 6 files changed, 52 insertions(+), 42 deletions(-) diff --git a/Makefile b/Makefile index d5ada54..4860935 100644 --- a/Makefile +++ b/Makefile @@ -142,9 +142,9 @@ display.o: display.c display.h buffer.h crypt.h line.h utf8.h estruct.h \ ebind.o: ebind.c ebind.h basic.h bind.h edef.h buffer.h crypt.h line.h \ utf8.h estruct.h retcode.h bindable.h eval.h exec.h file.h isearch.h \ random.h region.h search.h spawn.h window.h defines.h word.h -eval.o: eval.c eval.h estruct.h retcode.h basic.h bind.h edef.h buffer.h \ - crypt.h line.h utf8.h display.h exec.h flook.h input.h random.h search.h \ - termio.h version.h window.h defines.h +eval.o: eval.c eval.h basic.h bind.h edef.h buffer.h crypt.h line.h \ + utf8.h estruct.h retcode.h display.h exec.h flook.h input.h random.h \ + search.h termio.h version.h window.h defines.h exec.o: exec.c exec.h buffer.h crypt.h line.h utf8.h bind.h edef.h \ estruct.h retcode.h display.h eval.h file.h flook.h input.h window.h \ defines.h diff --git a/estruct.h b/estruct.h index 94d0cf1..f2e656b 100644 --- a/estruct.h +++ b/estruct.h @@ -152,7 +152,9 @@ #endif /* Autoconf. */ +#if 0 #define ISRCH 1 /* Incremental searches like ITS EMACS */ +#endif #define WORDPRO 1 /* Advanced word processing features */ #define APROP 1 /* Add code for Apropos command */ #if 0 @@ -437,37 +439,4 @@ struct kill { char d_chunk[KBLOCK]; /* Deleted text. */ }; -/* When emacs' command interpetor needs to get a variable's name, - * rather than it's value, it is passed back as a variable description - * structure. The v_num field is a index into the appropriate variable table. - */ -struct variable_description { - int v_type; /* Type of variable. */ - int v_num; /* Ordinal pointer to variable in list. */ -}; - -/* - * Incremental search defines. - */ -#if ISRCH - -#define CMDBUFLEN 256 /* Length of our command buffer */ - -#define IS_ABORT 0x07 /* Abort the isearch */ -#define IS_BACKSP 0x08 /* Delete previous char */ -#define IS_TAB 0x09 /* Tab character (allowed search char) */ -#define IS_NEWLINE 0x0D /* New line from keyboard (Carriage return) */ -#define IS_QUOTE 0x11 /* Quote next character */ -#define IS_REVERSE 0x12 /* Search backward */ -#define IS_FORWARD 0x13 /* Search forward */ -#define IS_VMSQUOTE 0x16 /* VMS quote character */ -#define IS_VMSFORW 0x18 /* Search forward for VMS */ -#define IS_QUIT 0x1B /* Exit the search */ -#define IS_RUBOUT 0x7F /* Delete previous character */ - -/* IS_QUIT is no longer used, the variable metac is used instead */ - -#endif - - #endif diff --git a/eval.c b/eval.c index 5aee669..0f4b90e 100644 --- a/eval.c +++ b/eval.c @@ -1,3 +1,4 @@ +/* eval.c -- implements eval.h */ #include "eval.h" /* eval.c @@ -229,6 +230,17 @@ static struct { /* User variables */ static struct user_variable uv[MAXVARS + 1]; +/* When emacs' command interpetor needs to get a variable's name, + * rather than it's value, it is passed back as a variable description + * structure. The v_num field is a index into the appropriate variable table. + */ +struct variable_description { + int v_type; /* Type of variable. */ + int v_num; /* Ordinal pointer to variable in list. */ +}; + +static void findvar( char *var, struct variable_description *vd, int size) ; +static int svar( struct variable_description *var, char *value) ; /* * putctext: @@ -688,7 +700,7 @@ int setvar(int f, int n) * @vd: structure to hold type and pointer. * @size: size of variable array. */ -void findvar(char *var, struct variable_description *vd, int size) +static void findvar(char *var, struct variable_description *vd, int size) { int vnum; /* subscript in variable arrays */ int vtype; /* type to return */ @@ -746,7 +758,7 @@ fvar: * @var: variable to set. * @value: value to set to. */ -int svar(struct variable_description *var, char *value) +static int svar(struct variable_description *var, char *value) { int vnum; /* ordinal number of var refrenced */ int vtype; /* type of variable to set */ diff --git a/eval.h b/eval.h index cc44b37..655123a 100644 --- a/eval.h +++ b/eval.h @@ -1,16 +1,12 @@ #ifndef _EVAL_H_ #define _EVAL_H_ -#include "estruct.h" - void varinit( void) ; char *gtfun( char *fname) ; char *gtusr( char *vname) ; char *gtenv( char *vname) ; char *getkill( void) ; int setvar( int f, int n) ; -void findvar( char *var, struct variable_description *vd, int size) ; -int svar( struct variable_description *var, char *value) ; char *itoa( int i) ; int gettyp( char *token) ; char *getval( char *token) ; diff --git a/isearch.c b/isearch.c index 2b07baf..0425aaf 100644 --- a/isearch.c +++ b/isearch.c @@ -36,6 +36,30 @@ #include "search.h" #include "window.h" +/* + * Incremental search defines. + */ +#if ISRCH + +#define CMDBUFLEN 256 /* Length of our command buffer */ + +#define IS_ABORT 0x07 /* Abort the isearch */ +#define IS_BACKSP 0x08 /* Delete previous char */ +#define IS_TAB 0x09 /* Tab character (allowed search char) */ +#define IS_NEWLINE 0x0D /* New line from keyboard (Carriage return) */ +#define IS_QUOTE 0x11 /* Quote next character */ +#define IS_REVERSE 0x12 /* Search backward */ +#define IS_FORWARD 0x13 /* Search forward */ +#define IS_VMSQUOTE 0x16 /* VMS quote character */ +#define IS_VMSFORW 0x18 /* Search forward for VMS */ +#define IS_QUIT 0x1B /* Exit the search */ +#define IS_RUBOUT 0x7F /* Delete previous character */ + +/* IS_QUIT is no longer used, the variable metac is used instead */ + +#endif + + static int isearch( int f, int n) ; static int checknext( char chr, char *patrn, int dir) ; static int scanmore( char *patrn, int dir) ; diff --git a/isearch.h b/isearch.h index a0ff176..871ae9c 100644 --- a/isearch.h +++ b/isearch.h @@ -1,2 +1,11 @@ +#ifndef __ISEARCH_H__ +#define __ISEARCH_H__ + +#define ISRCH 1 /* Incremental searches like ITS EMACS */ + +#if ISRCH int risearch( int f, int n) ; int fisearch( int f, int n) ; +#endif + +#endif From 1de3e139bbf8187546c690742645a6063e9f5412 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Mon, 23 Sep 2013 21:30:31 +0800 Subject: [PATCH 120/193] Move APROP and Token type out of estruct. --- bind.h | 9 +++++++-- estruct.h | 16 +--------------- eval.h | 17 ++++++++++++++++- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/bind.h b/bind.h index a5efd9f..0314903 100644 --- a/bind.h +++ b/bind.h @@ -3,15 +3,20 @@ #include "edef.h" +#define APROP 1 /* Add code for Apropos command */ + +#if APROP +int apro( int f, int n) ; +int strinc( char *source, char *sub) ; +#endif + int help( int f, int n) ; int deskey( int f, int n) ; int bindtokey( int f, int n) ; int unbindkey( int f, int n) ; int unbindchar( int c) ; int desbind( int f, int n) ; -int apro( int f, int n) ; int buildlist( int type, char *mstring) ; -int strinc( char *source, char *sub) ; unsigned int getckey( int mflag) ; int startup( char *sfname) ; void cmdstr( int c, char *seq) ; diff --git a/estruct.h b/estruct.h index f2e656b..a725ff5 100644 --- a/estruct.h +++ b/estruct.h @@ -156,8 +156,8 @@ #define ISRCH 1 /* Incremental searches like ITS EMACS */ #endif #define WORDPRO 1 /* Advanced word processing features */ -#define APROP 1 /* Add code for Apropos command */ #if 0 +#define APROP 1 /* Add code for Apropos command */ #define CRYPT 1 /* file encryption enabled? */ #define MAGIC 1 /* include regular expression matching? */ #endif @@ -271,20 +271,6 @@ #define INTWIDTH sizeof(int) * 3 -/* Macro argument token types */ - -#define TKNUL 0 /* end-of-string */ -#define TKARG 1 /* interactive argument */ -#define TKBUF 2 /* buffer argument */ -#define TKVAR 3 /* user variables */ -#define TKENV 4 /* environment variables */ -#define TKFUN 5 /* function.... */ -#define TKDIR 6 /* directive */ -#define TKLBL 7 /* line label */ -#define TKLIT 8 /* numeric literal */ -#define TKSTR 9 /* quoted string literal */ -#define TKCMD 10 /* command name */ - /* Internal defined functions */ #define nextab(a) (a & ~tabmask) + (tabmask+1) diff --git a/eval.h b/eval.h index 655123a..29cec28 100644 --- a/eval.h +++ b/eval.h @@ -1,6 +1,22 @@ #ifndef _EVAL_H_ #define _EVAL_H_ +/* Macro argument token types */ + +#define TKNUL 0 /* end-of-string */ +#define TKARG 1 /* interactive argument */ +#define TKBUF 2 /* buffer argument */ +#define TKVAR 3 /* user variables */ +#define TKENV 4 /* environment variables */ +#define TKFUN 5 /* function.... */ +#define TKDIR 6 /* directive */ +#define TKLBL 7 /* line label */ +#define TKLIT 8 /* numeric literal */ +#define TKSTR 9 /* quoted string literal */ +#define TKCMD 10 /* command name */ + +int gettyp( char *token) ; + void varinit( void) ; char *gtfun( char *fname) ; char *gtusr( char *vname) ; @@ -8,7 +24,6 @@ char *gtenv( char *vname) ; char *getkill( void) ; int setvar( int f, int n) ; char *itoa( int i) ; -int gettyp( char *token) ; char *getval( char *token) ; int stol( char *val) ; char *ltos( int val) ; From 9ec9176c81eefafd9ae3e9bc47c026e59a765556 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 25 Sep 2013 13:23:52 +0800 Subject: [PATCH 121/193] Centralize kill buffer code in line.c --- edef.h | 4 +--- estruct.h | 12 ------------ eval.c | 26 -------------------------- eval.h | 1 - globals.c | 4 +--- line.c | 42 ++++++++++++++++++++++++++++++++++++++++++ line.h | 2 ++ 7 files changed, 46 insertions(+), 45 deletions(-) diff --git a/edef.h b/edef.h index da2323a..26d8909 100644 --- a/edef.h +++ b/edef.h @@ -62,9 +62,7 @@ extern int abortc; /* current abort command char */ extern int quotec; /* quote char during mlreply() */ extern int tabmask; extern char *cname[]; /* names of colors */ -extern struct kill *kbufp; /* current kill buffer chunk pointer */ -extern struct kill *kbufh; /* kill buffer header pointer */ -extern int kused; /* # of bytes used in KB */ + extern struct window *swindow; /* saved window pointer */ extern int *kbdptr; /* current position in keyboard buf */ extern int *kbdend; /* ptr to end of the keyboard */ diff --git a/estruct.h b/estruct.h index a725ff5..2bcd834 100644 --- a/estruct.h +++ b/estruct.h @@ -245,7 +245,6 @@ #define HUGE 1000 /* Huge number */ #define NLOCKS 100 /* max # of file locks active */ #define NCOLORS 8 /* number of supported colors */ -#define KBLOCK 250 /* sizeof kill buffer chunks */ #define CONTROL 0x10000000 /* Control flag, or'ed in */ #define META 0x20000000 /* Meta flag, or'ed in */ @@ -414,15 +413,4 @@ struct terminal { #define TTbacg (*term.t_setback) #endif -/* The editor holds deleted text chunks in the struct kill buffer. The - * kill buffer is logically a stream of ascii characters, however - * due to its unpredicatable size, it gets implemented as a linked - * list of chunks. (The d_ prefix is for "deleted" text, as k_ - * was taken up by the keycode structure). - */ -struct kill { - struct kill *d_next; /* Link to next chunk, NULL if last. */ - char d_chunk[KBLOCK]; /* Deleted text. */ -}; - #endif diff --git a/eval.c b/eval.c index 0f4b90e..b0165fb 100644 --- a/eval.c +++ b/eval.c @@ -438,8 +438,6 @@ char *gtusr(char *vname) return errorm; } -extern char *getkill(void); - /* * gtenv() * @@ -569,30 +567,6 @@ char *gtenv(char *vname) exit(-12); /* again, we should never get here */ } -/* - * return some of the contents of the kill buffer - */ -char *getkill(void) -{ - int size; /* max number of chars to return */ - static char value[NSTRING]; /* temp buffer for value */ - - if (kbufh == NULL) - /* no kill buffer....just a null string */ - value[0] = 0; - else { - /* copy in the contents... */ - if (kused < NSTRING) - size = kused; - else - size = NSTRING - 1; - strncpy(value, kbufh->d_chunk, size); - } - - /* and return the constructed value */ - return value; -} - /* * set a variable * diff --git a/eval.h b/eval.h index 29cec28..d2a7364 100644 --- a/eval.h +++ b/eval.h @@ -21,7 +21,6 @@ void varinit( void) ; char *gtfun( char *fname) ; char *gtusr( char *vname) ; char *gtenv( char *vname) ; -char *getkill( void) ; int setvar( int f, int n) ; char *itoa( int i) ; char *getval( char *token) ; diff --git a/globals.c b/globals.c index 40ba064..f082ab7 100644 --- a/globals.c +++ b/globals.c @@ -76,9 +76,7 @@ char *cname[] = { /* names of colors */ , "HIGH" #endif }; -struct kill *kbufp = NULL; /* current kill buffer chunk pointer */ -struct kill *kbufh = NULL; /* kill buffer header pointer */ -int kused = KBLOCK; /* # of bytes used in kill buffer */ + struct window *swindow = NULL; /* saved window pointer */ int *kbdptr; /* current position in keyboard buf */ int *kbdend = &kbdm[0]; /* ptr to end of the keyboard */ diff --git a/line.c b/line.c index 11cf6d5..252688b 100644 --- a/line.c +++ b/line.c @@ -27,6 +27,48 @@ static int ldelnewline( void) ; +/* The editor holds deleted text chunks in the struct kill buffer. The + * kill buffer is logically a stream of ascii characters, however + * due to its unpredicatable size, it gets implemented as a linked + * list of chunks. (The d_ prefix is for "deleted" text, as k_ + * was taken up by the keycode structure). + */ + +#define KBLOCK 250 /* sizeof kill buffer chunks */ + +struct kill { + struct kill *d_next; /* Link to next chunk, NULL if last. */ + char d_chunk[KBLOCK]; /* Deleted text. */ +}; + +static struct kill *kbufp = NULL ; /* current kill buffer chunk pointer */ +static struct kill *kbufh = NULL ; /* kill buffer header pointer */ +static int kused = KBLOCK ; /* # of bytes used in kill buffer */ + +/* + * return some of the contents of the kill buffer + */ +char *getkill( void) +{ + int size; /* max number of chars to return */ + static char value[NSTRING]; /* temp buffer for value */ + + if (kbufh == NULL) + /* no kill buffer....just a null string */ + value[0] = 0; + else { + /* copy in the contents... */ + if (kused < NSTRING) + size = kused; + else + size = NSTRING - 1; + strncpy(value, kbufh->d_chunk, size); + } + + /* and return the constructed value */ + return value; +} + /* * Move the cursor backwards by "n" characters. If "n" is less than zero call * "forwchar" to actually do the move. Otherwise compute the new cursor diff --git a/line.h b/line.h index 248adb3..cdcc55e 100644 --- a/line.h +++ b/line.h @@ -25,6 +25,8 @@ struct line { #define lputc(lp, n, c) ((lp)->l_text[(n)]=(c)) #define llength(lp) ((lp)->l_used) +char *getkill( void) ; + int backchar( int f, int n) ; int forwchar( int f, int n) ; From 1f7826d3a80d6e42a702be286bf6f06df4458934 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 25 Sep 2013 15:09:09 +0800 Subject: [PATCH 122/193] Move paragraph related function from basic.c to word.c. --- Makefile | 2 +- basic.c | 101 ---------------------------------------------------- basic.h | 2 -- estruct.h | 2 -- word.c | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++- word.h | 7 +++- 6 files changed, 110 insertions(+), 108 deletions(-) diff --git a/Makefile b/Makefile index 4860935..5f7c659 100644 --- a/Makefile +++ b/Makefile @@ -128,7 +128,7 @@ depend: ${SRC} ansi.o: ansi.c estruct.h retcode.h edef.h buffer.h crypt.h line.h utf8.h basic.o: basic.c basic.h buffer.h crypt.h line.h utf8.h display.h \ - estruct.h retcode.h edef.h input.h random.h window.h defines.h word.h + estruct.h retcode.h edef.h input.h random.h window.h defines.h bind.o: bind.c bind.h edef.h buffer.h crypt.h line.h utf8.h estruct.h \ retcode.h bindable.h display.h ebind.h exec.h file.h flook.h input.h \ names.h window.h defines.h diff --git a/basic.c b/basic.c index dd8f2a7..bb97d9d 100644 --- a/basic.c +++ b/basic.c @@ -24,7 +24,6 @@ #include "random.h" #include "utf8.h" #include "window.h" -#include "word.h" /* * This routine, given a pointer to a struct line, and the current cursor goal @@ -215,106 +214,6 @@ int backline(int f, int n) return TRUE; } -#if WORDPRO -/* - * go back to the beginning of the current paragraph - * here we look for a or or - * combination to delimit the beginning of a paragraph - * - * int f, n; default Flag & Numeric argument - */ -int gotobop(int f, int n) -{ - int suc; /* success of last backchar */ - - if (n < 0) /* the other way... */ - return gotoeop(f, -n); - - while (n-- > 0) { /* for each one asked for */ - - /* first scan back until we are in a word */ - suc = backchar(FALSE, 1); - while (!inword() && suc) - suc = backchar(FALSE, 1); - curwp->w_doto = 0; /* and go to the B-O-Line */ - - /* and scan back until we hit a or - or a */ - while (lback(curwp->w_dotp) != curbp->b_linep) - if (llength(curwp->w_dotp) != 0 && -#if PKCODE - ((justflag == TRUE) || -#endif - (lgetc(curwp->w_dotp, curwp->w_doto) != TAB && - lgetc(curwp->w_dotp, curwp->w_doto) != ' ')) -#if PKCODE - ) -#endif - curwp->w_dotp = lback(curwp->w_dotp); - else - break; - - /* and then forward until we are in a word */ - suc = forwchar(FALSE, 1); - while (suc && !inword()) - suc = forwchar(FALSE, 1); - } - curwp->w_flag |= WFMOVE; /* force screen update */ - return TRUE; -} - -/* - * Go forword to the end of the current paragraph - * here we look for a or or - * combination to delimit the beginning of a paragraph - * - * int f, n; default Flag & Numeric argument - */ -int gotoeop(int f, int n) -{ - int suc; /* success of last backchar */ - - if (n < 0) /* the other way... */ - return gotobop(f, -n); - - while (n-- > 0) { /* for each one asked for */ - /* first scan forward until we are in a word */ - suc = forwchar(FALSE, 1); - while (!inword() && suc) - suc = forwchar(FALSE, 1); - curwp->w_doto = 0; /* and go to the B-O-Line */ - if (suc) /* of next line if not at EOF */ - curwp->w_dotp = lforw(curwp->w_dotp); - - /* and scan forword until we hit a or - or a */ - while (curwp->w_dotp != curbp->b_linep) { - if (llength(curwp->w_dotp) != 0 && -#if PKCODE - ((justflag == TRUE) || -#endif - (lgetc(curwp->w_dotp, curwp->w_doto) != TAB && - lgetc(curwp->w_dotp, curwp->w_doto) != ' ')) -#if PKCODE - ) -#endif - curwp->w_dotp = lforw(curwp->w_dotp); - else - break; - } - - /* and then backward until we are in a word */ - suc = backchar(FALSE, 1); - while (suc && !inword()) { - suc = backchar(FALSE, 1); - } - curwp->w_doto = llength(curwp->w_dotp); /* and to the EOL */ - } - curwp->w_flag |= WFMOVE; /* force screen update */ - return TRUE; -} -#endif - /* * Scroll forward by a specified number of lines, or by a full page if no * argument. Bound to "C-V". The "2" in the arithmetic on the window size is diff --git a/basic.h b/basic.h index 8ebbeea..1b0f6ee 100644 --- a/basic.h +++ b/basic.h @@ -8,8 +8,6 @@ int gotobob( int f, int n) ; int gotoeob( int f, int n) ; int forwline( int f, int n) ; int backline( int f, int n) ; -int gotobop( int f, int n) ; -int gotoeop( int f, int n) ; int forwpage( int f, int n) ; int backpage( int f, int n) ; int setmark( int f, int n) ; diff --git a/estruct.h b/estruct.h index 2bcd834..d74a405 100644 --- a/estruct.h +++ b/estruct.h @@ -154,9 +154,7 @@ #if 0 #define ISRCH 1 /* Incremental searches like ITS EMACS */ -#endif #define WORDPRO 1 /* Advanced word processing features */ -#if 0 #define APROP 1 /* Add code for Apropos command */ #define CRYPT 1 /* file encryption enabled? */ #define MAGIC 1 /* include regular expression matching? */ diff --git a/word.c b/word.c index 8420912..72edea4 100644 --- a/word.c +++ b/word.c @@ -22,6 +22,8 @@ #include "region.h" #include "window.h" +static int inword( void) ; + /* Word wrap on n-spaces. Back-over whatever precedes the point on the current * line and stop on the first word-break or the beginning of the line. If we * reach the beginning of the line, jump back to the end of the word and start @@ -378,7 +380,7 @@ int delbword(int f, int n) * Return TRUE if the character at dot is a character that is considered to be * part of a word. The word character list is hard coded. Should be setable. */ -int inword(void) +static int inword(void) { int c; @@ -717,3 +719,103 @@ int wordcount(int f, int n) return TRUE; } #endif + +#if WORDPRO +/* + * go back to the beginning of the current paragraph + * here we look for a or or + * combination to delimit the beginning of a paragraph + * + * int f, n; default Flag & Numeric argument + */ +int gotobop(int f, int n) +{ + int suc; /* success of last backchar */ + + if (n < 0) /* the other way... */ + return gotoeop(f, -n); + + while (n-- > 0) { /* for each one asked for */ + + /* first scan back until we are in a word */ + suc = backchar(FALSE, 1); + while (!inword() && suc) + suc = backchar(FALSE, 1); + curwp->w_doto = 0; /* and go to the B-O-Line */ + + /* and scan back until we hit a or + or a */ + while (lback(curwp->w_dotp) != curbp->b_linep) + if (llength(curwp->w_dotp) != 0 && +#if PKCODE + ((justflag == TRUE) || +#endif + (lgetc(curwp->w_dotp, curwp->w_doto) != TAB && + lgetc(curwp->w_dotp, curwp->w_doto) != ' ')) +#if PKCODE + ) +#endif + curwp->w_dotp = lback(curwp->w_dotp); + else + break; + + /* and then forward until we are in a word */ + suc = forwchar(FALSE, 1); + while (suc && !inword()) + suc = forwchar(FALSE, 1); + } + curwp->w_flag |= WFMOVE; /* force screen update */ + return TRUE; +} + +/* + * Go forword to the end of the current paragraph + * here we look for a or or + * combination to delimit the beginning of a paragraph + * + * int f, n; default Flag & Numeric argument + */ +int gotoeop(int f, int n) +{ + int suc; /* success of last backchar */ + + if (n < 0) /* the other way... */ + return gotobop(f, -n); + + while (n-- > 0) { /* for each one asked for */ + /* first scan forward until we are in a word */ + suc = forwchar(FALSE, 1); + while (!inword() && suc) + suc = forwchar(FALSE, 1); + curwp->w_doto = 0; /* and go to the B-O-Line */ + if (suc) /* of next line if not at EOF */ + curwp->w_dotp = lforw(curwp->w_dotp); + + /* and scan forword until we hit a or + or a */ + while (curwp->w_dotp != curbp->b_linep) { + if (llength(curwp->w_dotp) != 0 && +#if PKCODE + ((justflag == TRUE) || +#endif + (lgetc(curwp->w_dotp, curwp->w_doto) != TAB && + lgetc(curwp->w_dotp, curwp->w_doto) != ' ')) +#if PKCODE + ) +#endif + curwp->w_dotp = lforw(curwp->w_dotp); + else + break; + } + + /* and then backward until we are in a word */ + suc = backchar(FALSE, 1); + while (suc && !inword()) { + suc = backchar(FALSE, 1); + } + curwp->w_doto = llength(curwp->w_dotp); /* and to the EOL */ + } + curwp->w_flag |= WFMOVE; /* force screen update */ + return TRUE; +} +#endif diff --git a/word.h b/word.h index 2d0316d..e89d095 100644 --- a/word.h +++ b/word.h @@ -1,6 +1,8 @@ #ifndef _WORD_H_ #define _WORD_H_ +#define WORDPRO 1 + int wrapword( int f, int n) ; int backword( int f, int n) ; int forwword( int f, int n) ; @@ -9,10 +11,13 @@ int lowerword( int f, int n) ; int capword( int f, int n) ; int delfword( int f, int n) ; int delbword( int f, int n) ; -int inword( void) ; +#if WORDPRO +int gotobop( int f, int n) ; +int gotoeop( int f, int n) ; int fillpara( int f, int n) ; int justpara( int f, int n) ; int killpara( int f, int n) ; int wordcount( int f, int n) ; +#endif #endif From e97f2346078f0d723eeb836f11a77ec82b9c78eb Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 25 Sep 2013 15:37:07 +0800 Subject: [PATCH 123/193] AEDIT code activation moved from estruct to random.h. --- estruct.h | 2 -- random.h | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/estruct.h b/estruct.h index d74a405..a5e6a22 100644 --- a/estruct.h +++ b/estruct.h @@ -158,9 +158,7 @@ #define APROP 1 /* Add code for Apropos command */ #define CRYPT 1 /* file encryption enabled? */ #define MAGIC 1 /* include regular expression matching? */ -#endif #define AEDIT 1 /* advanced editing options: en/detabbing */ -#if 0 #define PROC 1 /* named procedures */ #endif #define CLEAN 0 /* de-alloc memory on exit */ diff --git a/random.h b/random.h index db30655..fe7e4df 100644 --- a/random.h +++ b/random.h @@ -1,6 +1,8 @@ #ifndef _RANDOM_H_ #define _RANDOM_H_ +#define AEDIT 1 + extern int tabsize ; /* Tab size (0: use real tabs). */ int setfillcol( int f, int n) ; @@ -11,9 +13,11 @@ int setccol( int pos) ; int twiddle( int f, int n) ; int quote( int f, int n) ; int insert_tab( int f, int n) ; +#if AEDIT int detab( int f, int n) ; int entab( int f, int n) ; int trim( int f, int n) ; +#endif int openline( int f, int n) ; int insert_newline( int f, int n) ; int cinsert( void) ; From 9780b4ce16f1b59636a732fbfef38ecdbf57d8b6 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 25 Sep 2013 21:45:05 +0800 Subject: [PATCH 124/193] Extract Struct terminal from estruct to terminal.h implemented by tcap. --- Makefile | 39 +++++++++++++++++------------ basic.c | 1 + bindable.c | 1 + display.c | 1 + edef.h | 5 ---- estruct.h | 60 -------------------------------------------- eval.c | 1 + execute.c | 1 + globals.c | 2 -- input.c | 1 + isearch.c | 1 + main.c | 1 + random.c | 1 + search.c | 1 + spawn.c | 1 + tcap.c | 5 ++-- terminal.h | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ termio.c | 12 ++++++--- termio.h | 3 +++ window.c | 1 + 20 files changed, 123 insertions(+), 88 deletions(-) create mode 100644 terminal.h diff --git a/Makefile b/Makefile index 5f7c659..ef6b11f 100644 --- a/Makefile +++ b/Makefile @@ -128,28 +128,31 @@ depend: ${SRC} ansi.o: ansi.c estruct.h retcode.h edef.h buffer.h crypt.h line.h utf8.h basic.o: basic.c basic.h buffer.h crypt.h line.h utf8.h display.h \ - estruct.h retcode.h edef.h input.h random.h window.h defines.h + estruct.h retcode.h edef.h input.h random.h terminal.h defines.h \ + window.h bind.o: bind.c bind.h edef.h buffer.h crypt.h line.h utf8.h estruct.h \ retcode.h bindable.h display.h ebind.h exec.h file.h flook.h input.h \ names.h window.h defines.h bindable.o: bindable.c bindable.h defines.h buffer.h crypt.h line.h \ - utf8.h display.h edef.h estruct.h retcode.h file.h input.h lock.h + utf8.h display.h edef.h estruct.h retcode.h file.h input.h lock.h \ + terminal.h buffer.o: buffer.c buffer.h crypt.h line.h utf8.h defines.h display.h \ edef.h estruct.h retcode.h file.h input.h window.h crypt.o: crypt.c crypt.h display.o: display.c display.h buffer.h crypt.h line.h utf8.h estruct.h \ - retcode.h edef.h termio.h version.h wrapper.h window.h defines.h + retcode.h edef.h termio.h terminal.h defines.h version.h wrapper.h \ + window.h ebind.o: ebind.c ebind.h basic.h bind.h edef.h buffer.h crypt.h line.h \ utf8.h estruct.h retcode.h bindable.h eval.h exec.h file.h isearch.h \ random.h region.h search.h spawn.h window.h defines.h word.h eval.o: eval.c eval.h basic.h bind.h edef.h buffer.h crypt.h line.h \ utf8.h estruct.h retcode.h display.h exec.h flook.h input.h random.h \ - search.h termio.h version.h window.h defines.h + search.h terminal.h defines.h termio.h version.h window.h exec.o: exec.c exec.h buffer.h crypt.h line.h utf8.h bind.h edef.h \ estruct.h retcode.h display.h eval.h file.h flook.h input.h window.h \ defines.h execute.o: execute.c edef.h buffer.h crypt.h line.h utf8.h estruct.h \ - retcode.h bind.h random.h display.h file.h window.h defines.h + retcode.h bind.h random.h display.h file.h terminal.h defines.h window.h file.o: file.c file.h crypt.h retcode.h buffer.h line.h utf8.h defines.h \ estruct.h edef.h execute.h fileio.h input.h lock.h log.h window.h fileio.o: fileio.c fileio.h crypt.h retcode.h defines.h @@ -159,9 +162,11 @@ globals.o: globals.c crypt.h defines.h edef.h buffer.h line.h utf8.h \ ibmpc.o: ibmpc.c estruct.h retcode.h edef.h buffer.h crypt.h line.h \ utf8.h input.o: input.c input.h edef.h buffer.h crypt.h line.h utf8.h estruct.h \ - retcode.h bind.h bindable.h display.h exec.h names.h wrapper.h + retcode.h bind.h bindable.h display.h exec.h names.h terminal.h \ + defines.h wrapper.h isearch.o: isearch.c isearch.h basic.h buffer.h crypt.h line.h utf8.h \ - display.h estruct.h retcode.h edef.h input.h search.h window.h defines.h + display.h estruct.h retcode.h edef.h input.h search.h terminal.h \ + defines.h window.h line.o: line.c line.h utf8.h buffer.h crypt.h edef.h estruct.h retcode.h \ log.h window.h defines.h lock.o: lock.c lock.h estruct.h retcode.h display.h edef.h buffer.h \ @@ -169,7 +174,8 @@ lock.o: lock.c lock.h estruct.h retcode.h display.h edef.h buffer.h \ log.o: log.c log.h retcode.h main.o: main.c basic.h bind.h edef.h buffer.h crypt.h line.h utf8.h \ estruct.h retcode.h bindable.h display.h eval.h execute.h file.h input.h \ - lock.h log.h random.h search.h termio.h version.h window.h defines.h + lock.h log.h random.h search.h terminal.h defines.h termio.h version.h \ + window.h names.o: names.c names.h basic.h bind.h edef.h buffer.h crypt.h line.h \ utf8.h estruct.h retcode.h bindable.h display.h eval.h exec.h file.h \ isearch.h region.h random.h search.h spawn.h window.h defines.h word.h @@ -178,24 +184,25 @@ pklock.o: pklock.c pklock.h estruct.h retcode.h edef.h buffer.h crypt.h \ posix.o: posix.c termio.h random.o: random.c random.h basic.h buffer.h crypt.h line.h utf8.h \ display.h estruct.h retcode.h edef.h execute.h input.h log.h search.h \ - window.h defines.h + terminal.h defines.h window.h region.o: region.c region.h line.h utf8.h buffer.h crypt.h estruct.h \ retcode.h edef.h log.h window.h defines.h search.o: search.c search.h line.h utf8.h basic.h buffer.h crypt.h \ - display.h edef.h estruct.h retcode.h input.h log.h window.h defines.h + display.h edef.h estruct.h retcode.h input.h log.h terminal.h defines.h \ + window.h spawn.o: spawn.c spawn.h defines.h buffer.h crypt.h line.h utf8.h \ display.h estruct.h retcode.h edef.h file.h flook.h input.h log.h \ - window.h -tcap.o: tcap.c display.h estruct.h retcode.h edef.h buffer.h crypt.h \ - line.h utf8.h termio.h -termio.o: termio.c termio.h estruct.h retcode.h edef.h buffer.h crypt.h \ - line.h utf8.h + terminal.h window.h +tcap.o: tcap.c terminal.h defines.h display.h estruct.h retcode.h edef.h \ + buffer.h crypt.h line.h utf8.h termio.h +termio.o: termio.c termio.h estruct.h retcode.h utf8.h utf8.o: utf8.c utf8.h vmsvt.o: vmsvt.c estruct.h retcode.h edef.h buffer.h crypt.h line.h \ utf8.h vt52.o: vt52.c estruct.h retcode.h edef.h buffer.h crypt.h line.h utf8.h window.o: window.c window.h defines.h buffer.h crypt.h line.h utf8.h \ - basic.h display.h edef.h estruct.h retcode.h execute.h wrapper.h + basic.h display.h edef.h estruct.h retcode.h execute.h terminal.h \ + wrapper.h word.o: word.c word.h basic.h buffer.h crypt.h line.h utf8.h estruct.h \ retcode.h edef.h log.h random.h region.h window.h defines.h wrapper.o: wrapper.c wrapper.h diff --git a/basic.c b/basic.c index bb97d9d..0b5a1af 100644 --- a/basic.c +++ b/basic.c @@ -22,6 +22,7 @@ #include "input.h" #include "line.h" #include "random.h" +#include "terminal.h" #include "utf8.h" #include "window.h" diff --git a/bindable.c b/bindable.c index 8ae843c..ffd9116 100644 --- a/bindable.c +++ b/bindable.c @@ -8,6 +8,7 @@ #include "file.h" #include "input.h" #include "lock.h" +#include "terminal.h" #if VMS #include diff --git a/display.c b/display.c index d318504..6255287 100644 --- a/display.c +++ b/display.c @@ -22,6 +22,7 @@ #include "edef.h" #include "line.h" #include "termio.h" +#include "terminal.h" #include "version.h" #include "wrapper.h" #include "utf8.h" diff --git a/edef.h b/edef.h index 26d8909..a8d2160 100644 --- a/edef.h +++ b/edef.h @@ -49,8 +49,6 @@ extern int disinp; /* display input characters */ extern struct buffer *bstore; /* buffer to store macro text to */ extern int vtrow; /* Row location of SW cursor */ extern int vtcol; /* Column location of SW cursor */ -extern int ttrow; /* Row location of HW cursor */ -extern int ttcol; /* Column location of HW cursor */ extern int lbound; /* leftmost column of current line being displayed */ extern int taboff; /* tab offset for display */ @@ -125,7 +123,4 @@ extern int matchoff; extern char outline[]; /* Global string to hold debug line text. */ #endif -/* Terminal table defined only in term.c */ -extern struct terminal term; - #endif /* EDEF_H_ */ diff --git a/estruct.h b/estruct.h index a5e6a22..023e149 100644 --- a/estruct.h +++ b/estruct.h @@ -349,64 +349,4 @@ int cexit( int status) ; #endif -/* - * The editor communicates with the display using a high level interface. A - * "TERM" structure holds useful variables, and indirect pointers to routines - * that do useful operations. The low level get and put routines are here too. - * This lets a terminal, in addition to having non standard commands, have - * funny get and put character code too. The calls might get changed to - * "termp->t_field" style in the future, to make it possible to run more than - * one terminal type. - */ -struct terminal { - short t_mrow; /* max number of rows allowable */ - short t_nrow; /* current number of rows used */ - short t_mcol; /* max Number of columns. */ - short t_ncol; /* current Number of columns. */ - short t_margin; /* min margin for extended lines */ - short t_scrsiz; /* size of scroll region " */ - int t_pause; /* # times thru update to pause */ - void (*t_open)(void); /* Open terminal at the start. */ - void (*t_close)(void); /* Close terminal at end. */ - void (*t_kopen)(void); /* Open keyboard */ - void (*t_kclose)(void); /* close keyboard */ - int (*t_getchar)(void); /* Get character from keyboard. */ - int (*t_putchar)(int); /* Put character to display. */ - void (*t_flush) (void); /* Flush output buffers. */ - void (*t_move)(int, int);/* Move the cursor, origin 0. */ - void (*t_eeol)(void); /* Erase to end of line. */ - void (*t_eeop)(void); /* Erase to end of page. */ - void (*t_beep)(void); /* Beep. */ - void (*t_rev)(int); /* set reverse video state */ - int (*t_rez)(char *); /* change screen resolution */ -#if COLOR - int (*t_setfor) (); /* set forground color */ - int (*t_setback) (); /* set background color */ -#endif -#if SCROLLCODE - void (*t_scroll)(int, int,int); /* scroll a region of the screen */ -#endif -}; - -/* TEMPORARY macros for terminal I/O (to be placed in a machine - dependant place later) */ - -#define TTopen (*term.t_open) -#define TTclose (*term.t_close) -#define TTkopen (*term.t_kopen) -#define TTkclose (*term.t_kclose) -#define TTgetc (*term.t_getchar) -#define TTputc (*term.t_putchar) -#define TTflush (*term.t_flush) -#define TTmove (*term.t_move) -#define TTeeol (*term.t_eeol) -#define TTeeop (*term.t_eeop) -#define TTbeep (*term.t_beep) -#define TTrev (*term.t_rev) -#define TTrez (*term.t_rez) -#if COLOR -#define TTforg (*term.t_setfor) -#define TTbacg (*term.t_setback) -#endif - #endif diff --git a/eval.c b/eval.c index b0165fb..6848eca 100644 --- a/eval.c +++ b/eval.c @@ -23,6 +23,7 @@ #include "line.h" #include "random.h" #include "search.h" +#include "terminal.h" #include "termio.h" #include "version.h" #include "window.h" diff --git a/execute.c b/execute.c index 184893b..0afd8a3 100644 --- a/execute.c +++ b/execute.c @@ -3,6 +3,7 @@ #include "random.h" #include "display.h" #include "file.h" +#include "terminal.h" #include "window.h" /* diff --git a/globals.c b/globals.c index f082ab7..f51bdbd 100644 --- a/globals.c +++ b/globals.c @@ -57,8 +57,6 @@ int disinp = TRUE; /* display input characters */ struct buffer *bstore = NULL; /* buffer to store macro text to */ int vtrow = 0; /* Row location of SW cursor */ int vtcol = 0; /* Column location of SW cursor */ -int ttrow = HUGE; /* Row location of HW cursor */ -int ttcol = HUGE; /* Column location of HW cursor */ int lbound = 0; /* leftmost column of current line being displayed */ int taboff = 0; /* tab offset for display */ diff --git a/input.c b/input.c index 0cc3b72..5cd4685 100644 --- a/input.c +++ b/input.c @@ -18,6 +18,7 @@ #include "display.h" #include "exec.h" #include "names.h" +#include "terminal.h" #include "wrapper.h" #if PKCODE diff --git a/isearch.c b/isearch.c index 0425aaf..461b044 100644 --- a/isearch.c +++ b/isearch.c @@ -34,6 +34,7 @@ #include "input.h" #include "line.h" #include "search.h" +#include "terminal.h" #include "window.h" /* diff --git a/main.c b/main.c index 840ecfb..6a71426 100644 --- a/main.c +++ b/main.c @@ -72,6 +72,7 @@ #include "log.h" #include "random.h" #include "search.h" +#include "terminal.h" #include "termio.h" #include "version.h" #include "window.h" diff --git a/random.c b/random.c index 2bcbcc1..c5dd248 100644 --- a/random.c +++ b/random.c @@ -21,6 +21,7 @@ #include "line.h" #include "log.h" #include "search.h" +#include "terminal.h" #include "window.h" int tabsize; /* Tab size (0: use real tabs) */ diff --git a/search.c b/search.c index ea6f718..c7deea9 100644 --- a/search.c +++ b/search.c @@ -69,6 +69,7 @@ #include "input.h" #include "line.h" #include "log.h" +#include "terminal.h" #include "window.h" #if defined(MAGIC) diff --git a/spawn.c b/spawn.c index abe9cce..422fe62 100644 --- a/spawn.c +++ b/spawn.c @@ -21,6 +21,7 @@ #include "flook.h" #include "input.h" #include "log.h" +#include "terminal.h" #include "window.h" #if VMS diff --git a/tcap.c b/tcap.c index 57e73a5..45e3d4d 100644 --- a/tcap.c +++ b/tcap.c @@ -1,3 +1,6 @@ +/* tcap.c -- implements terminal.h */ +#include "terminal.h" + /* tcap.c * * Unix V7 SysV and BS4 Termcap video driver @@ -21,8 +24,6 @@ #include #endif -#include - #include "display.h" #include "estruct.h" #include "edef.h" diff --git a/terminal.h b/terminal.h new file mode 100644 index 0000000..2e4701f --- /dev/null +++ b/terminal.h @@ -0,0 +1,73 @@ +#ifndef __TERMINAL_H__ +#define __TERMINAL_H__ + + +#include "defines.h" /* COLOR, SCROLLCODE */ + +/* + * The editor communicates with the display using a high level interface. A + * "TERM" structure holds useful variables, and indirect pointers to routines + * that do useful operations. The low level get and put routines are here too. + * This lets a terminal, in addition to having non standard commands, have + * funny get and put character code too. The calls might get changed to + * "termp->t_field" style in the future, to make it possible to run more than + * one terminal type. + */ +struct terminal { + short t_mrow; /* max number of rows allowable */ + short t_nrow; /* current number of rows used */ + short t_mcol; /* max Number of columns. */ + short t_ncol; /* current Number of columns. */ + short t_margin; /* min margin for extended lines */ + short t_scrsiz; /* size of scroll region " */ + int t_pause; /* # times thru update to pause */ + void (*t_open)(void); /* Open terminal at the start. */ + void (*t_close)(void); /* Close terminal at end. */ + void (*t_kopen)(void); /* Open keyboard */ + void (*t_kclose)(void); /* close keyboard */ + int (*t_getchar)(void); /* Get character from keyboard. */ + int (*t_putchar)(int); /* Put character to display. */ + void (*t_flush) (void); /* Flush output buffers. */ + void (*t_move)(int, int);/* Move the cursor, origin 0. */ + void (*t_eeol)(void); /* Erase to end of line. */ + void (*t_eeop)(void); /* Erase to end of page. */ + void (*t_beep)(void); /* Beep. */ + void (*t_rev)(int); /* set reverse video state */ + int (*t_rez)(char *); /* change screen resolution */ +#if COLOR + int (*t_setfor) (); /* set forground color */ + int (*t_setback) (); /* set background color */ +#endif +#if SCROLLCODE + void (*t_scroll)(int, int,int); /* scroll a region of the screen */ +#endif +}; + +/* TEMPORARY macros for terminal I/O (to be placed in a machine + dependant place later) */ + +#define TTopen (*term.t_open) +#define TTclose (*term.t_close) +#define TTkopen (*term.t_kopen) +#define TTkclose (*term.t_kclose) +#define TTgetc (*term.t_getchar) +#define TTputc (*term.t_putchar) +#define TTflush (*term.t_flush) +#define TTmove (*term.t_move) +#define TTeeol (*term.t_eeol) +#define TTeeop (*term.t_eeop) +#define TTbeep (*term.t_beep) +#define TTrev (*term.t_rev) +#define TTrez (*term.t_rez) +#if COLOR +#define TTforg (*term.t_setfor) +#define TTbacg (*term.t_setback) +#endif + +/* Terminal table defined only in term.c */ +extern struct terminal term ; + +extern int ttrow ; /* Row location of HW cursor */ +extern int ttcol ; /* Column location of HW cursor */ + +#endif diff --git a/termio.c b/termio.c index cc02ec6..43d78fa 100644 --- a/termio.c +++ b/termio.c @@ -11,14 +11,20 @@ #ifndef POSIX -#include -#include "estruct.h" -#include "edef.h" +#include +#include + +#include "estruct.h" +#include "utf8.h" + /* rfi */ #include #include +int ttrow = HUGE ; /* Row location of HW cursor */ +int ttcol = HUGE ; /* Column location of HW cursor */ + #if VMS #include #include diff --git a/termio.h b/termio.h index 5f41f92..5b057aa 100644 --- a/termio.h +++ b/termio.h @@ -1,6 +1,9 @@ #ifndef _TERMIO_H_ #define _TERMIO_H_ +extern int ttrow ; /* Row location of HW cursor */ +extern int ttcol ; /* Column location of HW cursor */ + void ttopen( void) ; void ttclose( void) ; int ttputc( int c) ; diff --git a/window.c b/window.c index f9cf8bf..f31ee5a 100644 --- a/window.c +++ b/window.c @@ -18,6 +18,7 @@ #include "edef.h" #include "execute.h" #include "line.h" +#include "terminal.h" #include "wrapper.h" /* From 015771e7a5c1ed39382d87af4c4f411f5f4d181a Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Thu, 26 Sep 2013 19:16:28 +0800 Subject: [PATCH 125/193] Move search and flag related defines out of estruct. --- edef.h | 6 ++++++ estruct.h | 12 ------------ search.h | 12 +++++++++++- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/edef.h b/edef.h index a8d2160..7a024b7 100644 --- a/edef.h +++ b/edef.h @@ -98,8 +98,14 @@ extern int scrollcount; /* number of lines to scroll */ extern int currow; /* Cursor row */ extern int curcol; /* Cursor column */ + + +#define CFCPCN 0x0001 /* Last command was C-P, C-N */ +#define CFKILL 0x0002 /* Last command was a kill */ + extern int thisflag; /* Flags, this command */ extern int lastflag; /* Flags, last command */ + extern int curgoal; /* Goal for C-P, C-N */ extern struct window *curwp; /* Current window */ extern struct buffer *curbp; /* Current buffer */ diff --git a/estruct.h b/estruct.h index 023e149..54f9a2a 100644 --- a/estruct.h +++ b/estruct.h @@ -249,18 +249,6 @@ #include "retcode.h" -/* - * PTBEG, PTEND, FORWARD, and REVERSE are all toggle-able values for - * the scan routines. - */ -#define PTBEG 0 /* Leave the point at the beginning on search */ -#define PTEND 1 /* Leave the point at the end on search */ -#define FORWARD 0 /* forward direction */ -#define REVERSE 1 /* backwards direction */ - -#define CFCPCN 0x0001 /* Last command was C-P, C-N */ -#define CFKILL 0x0002 /* Last command was a kill */ - #define BELL 0x07 /* a bell character */ #define TAB 0x09 /* a tab character */ diff --git a/search.h b/search.h index fb6afee..6f16445 100644 --- a/search.h +++ b/search.h @@ -5,11 +5,21 @@ #include "line.h" +/* + * PTBEG, PTEND, FORWARD, and REVERSE are all toggle-able values for + * the scan routines. + */ +#define PTBEG 0 /* Leave the point at the beginning on search */ +#define PTEND 1 /* Leave the point at the end on search */ +#define FORWARD 0 /* forward direction */ +#define REVERSE 1 /* backwards direction */ + +int scanner( const char *patrn, int direct, int beg_or_end) ; + int forwsearch( int f, int n) ; int forwhunt( int f, int n) ; int backsearch( int f, int n) ; int backhunt( int f, int n) ; -int scanner( const char *patrn, int direct, int beg_or_end) ; int eq( unsigned char bc, unsigned char pc) ; void savematch( void) ; void rvstrcpy( char *rvstr, char *str) ; From 4e7a07405d73d458ed059ee01245893e56ae2d6a Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Thu, 26 Sep 2013 20:06:36 +0800 Subject: [PATCH 126/193] Review scope of some global variables. --- edef.h | 12 +++++------- exec.c | 4 ++++ globals.c | 6 +++--- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/edef.h b/edef.h index 7a024b7..1dd5fc6 100644 --- a/edef.h +++ b/edef.h @@ -25,9 +25,10 @@ extern int fillcol; /* Fill column */ extern int kbdm[]; /* Holds kayboard macro data */ extern char pat[]; /* Search pattern */ extern char rpat[]; /* Replacement pattern */ -extern char *execstr; /* pointer to string to execute */ -extern char golabel[]; /* current line to go to */ -extern int execlevel; /* execution IF level */ +extern char tap[]; /* Reversed pattern array. */ +extern char *execstr; /* pointer to string to execute */ + + extern int eolexist; /* does clear to EOL exist? */ extern int revexist; /* does reverse video exist? */ extern int flickcode; /* do flicker supression? */ @@ -46,7 +47,7 @@ extern int clexec; /* command line execution flag */ extern int mstore; /* storing text to macro flag */ extern int discmd; /* display command flag */ extern int disinp; /* display input characters */ -extern struct buffer *bstore; /* buffer to store macro text to */ + extern int vtrow; /* Row location of SW cursor */ extern int vtcol; /* Column location of SW cursor */ extern int lbound; /* leftmost column of current line @@ -114,9 +115,6 @@ extern struct buffer *bheadp; /* Head of list of buffers */ extern struct buffer *blistp; /* Buffer for C-X C-B */ extern char sres[NBUFN]; /* Current screen resolution. */ -extern char pat[]; /* Search pattern. */ -extern char tap[]; /* Reversed pattern array. */ -extern char rpat[]; /* Replacement pattern. */ extern unsigned int matchlen; extern unsigned int mlenold; diff --git a/exec.c b/exec.c index 58ce976..ddda97c 100644 --- a/exec.c +++ b/exec.c @@ -64,6 +64,10 @@ static const char *dname[] = { "force" }; +static char golabel[ NPAT] = "" ; /* current line to go to */ +static int execlevel = 0 ; /* execution IF level */ +static struct buffer *bstore = NULL ; /* buffer to store macro text to */ + static int dobuf( struct buffer *bp) ; static void freewhile( struct while_block *wp) ; diff --git a/globals.c b/globals.c index f51bdbd..0c613b3 100644 --- a/globals.c +++ b/globals.c @@ -9,8 +9,8 @@ int fillcol = 72; /* Current fill column */ int kbdm[NKBDM]; /* Macro */ char *execstr = NULL; /* pointer to string to execute */ -char golabel[NPAT] = ""; /* current line to go to */ -int execlevel = 0; /* execution IF level */ + + int eolexist = TRUE; /* does clear to EOL exist */ int revexist = FALSE; /* does reverse video exist? */ int flickcode = FALSE; /* do flicker supression? */ @@ -54,7 +54,7 @@ int clexec = FALSE; /* command line execution flag */ int mstore = FALSE; /* storing text to macro flag */ int discmd = TRUE; /* display command flag */ int disinp = TRUE; /* display input characters */ -struct buffer *bstore = NULL; /* buffer to store macro text to */ + int vtrow = 0; /* Row location of SW cursor */ int vtcol = 0; /* Column location of SW cursor */ int lbound = 0; /* leftmost column of current line From 6f81579213615debc840e7e74e63acc79597de69 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 27 Sep 2013 14:16:29 +0800 Subject: [PATCH 127/193] Move global variable to private scope. --- edef.h | 2 +- globals.c | 2 +- window.c | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/edef.h b/edef.h index 1dd5fc6..770b1d9 100644 --- a/edef.h +++ b/edef.h @@ -62,7 +62,7 @@ extern int quotec; /* quote char during mlreply() */ extern int tabmask; extern char *cname[]; /* names of colors */ -extern struct window *swindow; /* saved window pointer */ + extern int *kbdptr; /* current position in keyboard buf */ extern int *kbdend; /* ptr to end of the keyboard */ diff --git a/globals.c b/globals.c index 0c613b3..e3d45e2 100644 --- a/globals.c +++ b/globals.c @@ -75,7 +75,7 @@ char *cname[] = { /* names of colors */ #endif }; -struct window *swindow = NULL; /* saved window pointer */ + int *kbdptr; /* current position in keyboard buf */ int *kbdend = &kbdm[0]; /* ptr to end of the keyboard */ kbdstate kbdmode = STOP; /* current keyboard macro mode */ diff --git a/window.c b/window.c index f31ee5a..288bb9e 100644 --- a/window.c +++ b/window.c @@ -21,6 +21,10 @@ #include "terminal.h" #include "wrapper.h" + +static struct window *swindow = NULL ; /* saved window pointer */ + + /* * Reposition dot in the current window to line "n". If the argument is * positive, it is that line. If it is negative it is that line from the From e2035f0d9261d2570a559c3e6b58065a9c2df432 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 27 Sep 2013 14:29:26 +0800 Subject: [PATCH 128/193] Move global variables to public input scope. --- edef.h | 4 ---- estruct.h | 1 - globals.c | 3 --- input.c | 5 +++++ input.h | 4 ++++ 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/edef.h b/edef.h index 770b1d9..f3a4927 100644 --- a/edef.h +++ b/edef.h @@ -22,7 +22,6 @@ typedef int (*fn_t)(int, int); /* Initialized global external declarations. */ extern int fillcol; /* Fill column */ -extern int kbdm[]; /* Holds kayboard macro data */ extern char pat[]; /* Search pattern */ extern char rpat[]; /* Replacement pattern */ extern char tap[]; /* Reversed pattern array. */ @@ -63,9 +62,6 @@ extern int tabmask; extern char *cname[]; /* names of colors */ -extern int *kbdptr; /* current position in keyboard buf */ -extern int *kbdend; /* ptr to end of the keyboard */ - #if 0 #define STOP 0 /* keyboard macro not in use */ #define PLAY 1 /* playing */ diff --git a/estruct.h b/estruct.h index 54f9a2a..dd5b69a 100644 --- a/estruct.h +++ b/estruct.h @@ -236,7 +236,6 @@ #define NBUFN 16 /* # of bytes, buffer name */ #define NLINE 256 /* # of bytes, input line */ #define NSTRING 128 /* # of bytes, string buffers */ -#define NKBDM 256 /* # of strokes, keyboard macro */ #define NPAT 128 /* # of bytes, pattern */ #define HUGE 1000 /* Huge number */ #define NLOCKS 100 /* max # of file locks active */ diff --git a/globals.c b/globals.c index e3d45e2..e90ad7f 100644 --- a/globals.c +++ b/globals.c @@ -7,7 +7,6 @@ /* initialized global definitions */ int fillcol = 72; /* Current fill column */ -int kbdm[NKBDM]; /* Macro */ char *execstr = NULL; /* pointer to string to execute */ @@ -76,8 +75,6 @@ char *cname[] = { /* names of colors */ }; -int *kbdptr; /* current position in keyboard buf */ -int *kbdend = &kbdm[0]; /* ptr to end of the keyboard */ kbdstate kbdmode = STOP; /* current keyboard macro mode */ int kbdrep = 0; /* number of repetitions */ int restflag = FALSE; /* restricted use? */ diff --git a/input.c b/input.c index 5cd4685..9201586 100644 --- a/input.c +++ b/input.c @@ -33,6 +33,11 @@ #define COMPLC 0 #endif +#define NKBDM 256 /* # of strokes, keyboard macro */ +int kbdm[ NKBDM] ; /* Macro */ +int *kbdptr ; /* current position in keyboard buf */ +int *kbdend = &kbdm[0] ; /* ptr to end of the keyboard */ + /* * Ask a yes or no question in the message line. Return either TRUE, FALSE, or * ABORT. The ABORT status is returned if the user bumps out of the question diff --git a/input.h b/input.h index 99ee8db..da12bba 100644 --- a/input.h +++ b/input.h @@ -3,6 +3,10 @@ #include "edef.h" +extern int kbdm[] ; /* Holds kayboard macro data */ +extern int *kbdptr ; /* current position in keyboard buf */ +extern int *kbdend ; /* ptr to end of the keyboard */ + int mlyesno( const char *prompt) ; int mlreply( const char *prompt, char *buf, int nbuf) ; int mlreplyt( const char *prompt, char *buf, int nbuf, int eolchar) ; From 62e887547b4e247a6b1dd5b4d3ae4330b2d44e85 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 27 Sep 2013 14:53:04 +0800 Subject: [PATCH 129/193] Move global search pattern variables to public search scope. --- edef.h | 5 ----- globals.c | 12 ------------ search.c | 14 ++++++++++++++ search.h | 3 +++ 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/edef.h b/edef.h index f3a4927..6743275 100644 --- a/edef.h +++ b/edef.h @@ -112,11 +112,6 @@ extern struct buffer *blistp; /* Buffer for C-X C-B */ extern char sres[NBUFN]; /* Current screen resolution. */ -extern unsigned int matchlen; -extern unsigned int mlenold; -extern char *patmatch; -extern struct line *matchline; -extern int matchoff; #if DEBUGM /* Vars needed for macro debugging output. */ diff --git a/globals.c b/globals.c index e90ad7f..a06968e 100644 --- a/globals.c +++ b/globals.c @@ -113,18 +113,6 @@ char pat[NPAT]; /* Search pattern */ char tap[NPAT]; /* Reversed pattern array. */ char rpat[NPAT]; /* replacement pattern */ -/* The variable matchlen holds the length of the matched - * string - used by the replace functions. - * The variable patmatch holds the string that satisfies - * the search command. - * The variables matchline and matchoff hold the line and - * offset position of the *start* of match. - */ -unsigned int matchlen = 0; -unsigned int mlenold = 0; -char *patmatch = NULL; -struct line *matchline = NULL; -int matchoff = 0; #if DEBUGM /* vars needed for macro debugging output */ diff --git a/search.c b/search.c index c7deea9..0deccae 100644 --- a/search.c +++ b/search.c @@ -72,6 +72,20 @@ #include "terminal.h" #include "window.h" +/* The variable matchlen holds the length of the matched + * string - used by the replace functions. + * The variable patmatch holds the string that satisfies + * the search command. + * The variables matchline and matchoff hold the line and + * offset position of the *start* of match. + */ +unsigned int matchlen = 0 ; +static unsigned int mlenold = 0 ; +char *patmatch = NULL ; +static struct line *matchline = NULL; +static int matchoff = 0; + + #if defined(MAGIC) /* * Defines for the metacharacters in the regular expression diff --git a/search.h b/search.h index 6f16445..1bf2d1e 100644 --- a/search.h +++ b/search.h @@ -5,6 +5,9 @@ #include "line.h" +extern unsigned int matchlen ; +extern char *patmatch ; + /* * PTBEG, PTEND, FORWARD, and REVERSE are all toggle-able values for * the scan routines. From 422bfa0288245484f763aca67a851af570cb417e Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sat, 28 Sep 2013 09:40:42 +0800 Subject: [PATCH 130/193] Recompile on Linux. --- Makefile | 21 +++++++++++---------- posix.c | 3 +++ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index ef6b11f..16f33b6 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ -# Makefile for emacs, updated Fri, Sep 20, 2013 3:09:46 PM +# Makefile for emacs, updated Sat Sep 28 09:31:49 CST 2013 -SRC=ansi.c basic.c bind.c bindable.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c globals.c ibmpc.c input.c isearch.c line.c lock.c log.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c -OBJ=ansi.o basic.o bind.o bindable.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o globals.o ibmpc.o input.o isearch.o line.o lock.o log.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o -HDR=basic.h bind.h bindable.h buffer.h crypt.h defines.h display.h ebind.h edef.h efunc.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h log.h names.h pklock.h random.h region.h retcode.h search.h spawn.h termio.h utf8.h version.h window.h word.h wrapper.h +SRC=ansi.c basic.c bindable.c bind.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c globals.c ibmpc.c input.c isearch.c line.c lock.c log.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c +OBJ=ansi.o basic.o bindable.o bind.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o globals.o ibmpc.o input.o isearch.o line.o lock.o log.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o +HDR=basic.h bindable.h bind.h buffer.h crypt.h defines.h display.h ebind.h edef.h efunc.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h log.h names.h pklock.h random.h region.h retcode.h search.h spawn.h terminal.h termio.h utf8.h version.h window.h word.h wrapper.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -130,12 +130,12 @@ ansi.o: ansi.c estruct.h retcode.h edef.h buffer.h crypt.h line.h utf8.h basic.o: basic.c basic.h buffer.h crypt.h line.h utf8.h display.h \ estruct.h retcode.h edef.h input.h random.h terminal.h defines.h \ window.h -bind.o: bind.c bind.h edef.h buffer.h crypt.h line.h utf8.h estruct.h \ - retcode.h bindable.h display.h ebind.h exec.h file.h flook.h input.h \ - names.h window.h defines.h bindable.o: bindable.c bindable.h defines.h buffer.h crypt.h line.h \ utf8.h display.h edef.h estruct.h retcode.h file.h input.h lock.h \ terminal.h +bind.o: bind.c bind.h edef.h buffer.h crypt.h line.h utf8.h estruct.h \ + retcode.h bindable.h display.h ebind.h exec.h file.h flook.h input.h \ + names.h window.h defines.h buffer.o: buffer.c buffer.h crypt.h line.h utf8.h defines.h display.h \ edef.h estruct.h retcode.h file.h input.h window.h crypt.o: crypt.c crypt.h @@ -170,7 +170,7 @@ isearch.o: isearch.c isearch.h basic.h buffer.h crypt.h line.h utf8.h \ line.o: line.c line.h utf8.h buffer.h crypt.h edef.h estruct.h retcode.h \ log.h window.h defines.h lock.o: lock.c lock.h estruct.h retcode.h display.h edef.h buffer.h \ - crypt.h line.h utf8.h input.h + crypt.h line.h utf8.h input.h pklock.h log.o: log.c log.h retcode.h main.o: main.c basic.h bind.h edef.h buffer.h crypt.h line.h utf8.h \ estruct.h retcode.h bindable.h display.h eval.h execute.h file.h input.h \ @@ -181,7 +181,8 @@ names.o: names.c names.h basic.h bind.h edef.h buffer.h crypt.h line.h \ isearch.h region.h random.h search.h spawn.h window.h defines.h word.h pklock.o: pklock.c pklock.h estruct.h retcode.h edef.h buffer.h crypt.h \ line.h utf8.h -posix.o: posix.c termio.h +posix.o: posix.c termio.h estruct.h retcode.h edef.h buffer.h crypt.h \ + line.h utf8.h random.o: random.c random.h basic.h buffer.h crypt.h line.h utf8.h \ display.h estruct.h retcode.h edef.h execute.h input.h log.h search.h \ terminal.h defines.h window.h @@ -195,7 +196,7 @@ spawn.o: spawn.c spawn.h defines.h buffer.h crypt.h line.h utf8.h \ terminal.h window.h tcap.o: tcap.c terminal.h defines.h display.h estruct.h retcode.h edef.h \ buffer.h crypt.h line.h utf8.h termio.h -termio.o: termio.c termio.h estruct.h retcode.h utf8.h +termio.o: termio.c termio.h utf8.o: utf8.c utf8.h vmsvt.o: vmsvt.c estruct.h retcode.h edef.h buffer.h crypt.h line.h \ utf8.h diff --git a/posix.c b/posix.c index 00b19be..062f776 100644 --- a/posix.c +++ b/posix.c @@ -26,6 +26,9 @@ #include "edef.h" #include "utf8.h" +int ttrow = HUGE ; /* Row location of HW cursor */ +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)) From 097de3bcdfe7606b5f8ab4bb82962d8c22eb38cf Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sun, 29 Sep 2013 12:47:26 +0800 Subject: [PATCH 131/193] Recompile under Cygwin64. Move color names as private to random. --- Makefile | 7 +++---- edef.h | 1 - globals.c | 7 ------- random.c | 8 ++++++++ 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 16f33b6..25c9dbb 100644 --- a/Makefile +++ b/Makefile @@ -170,7 +170,7 @@ isearch.o: isearch.c isearch.h basic.h buffer.h crypt.h line.h utf8.h \ line.o: line.c line.h utf8.h buffer.h crypt.h edef.h estruct.h retcode.h \ log.h window.h defines.h lock.o: lock.c lock.h estruct.h retcode.h display.h edef.h buffer.h \ - crypt.h line.h utf8.h input.h pklock.h + crypt.h line.h utf8.h input.h log.o: log.c log.h retcode.h main.o: main.c basic.h bind.h edef.h buffer.h crypt.h line.h utf8.h \ estruct.h retcode.h bindable.h display.h eval.h execute.h file.h input.h \ @@ -181,8 +181,7 @@ names.o: names.c names.h basic.h bind.h edef.h buffer.h crypt.h line.h \ isearch.h region.h random.h search.h spawn.h window.h defines.h word.h pklock.o: pklock.c pklock.h estruct.h retcode.h edef.h buffer.h crypt.h \ line.h utf8.h -posix.o: posix.c termio.h estruct.h retcode.h edef.h buffer.h crypt.h \ - line.h utf8.h +posix.o: posix.c termio.h random.o: random.c random.h basic.h buffer.h crypt.h line.h utf8.h \ display.h estruct.h retcode.h edef.h execute.h input.h log.h search.h \ terminal.h defines.h window.h @@ -196,7 +195,7 @@ spawn.o: spawn.c spawn.h defines.h buffer.h crypt.h line.h utf8.h \ terminal.h window.h tcap.o: tcap.c terminal.h defines.h display.h estruct.h retcode.h edef.h \ buffer.h crypt.h line.h utf8.h termio.h -termio.o: termio.c termio.h +termio.o: termio.c termio.h estruct.h retcode.h utf8.h utf8.o: utf8.c utf8.h vmsvt.o: vmsvt.c estruct.h retcode.h edef.h buffer.h crypt.h line.h \ utf8.h diff --git a/edef.h b/edef.h index 6743275..f8a1ac4 100644 --- a/edef.h +++ b/edef.h @@ -59,7 +59,6 @@ extern int abortc; /* current abort command char */ extern int quotec; /* quote char during mlreply() */ extern int tabmask; -extern char *cname[]; /* names of colors */ #if 0 diff --git a/globals.c b/globals.c index a06968e..fe94fe3 100644 --- a/globals.c +++ b/globals.c @@ -66,13 +66,6 @@ int abortc = CONTROL | 'G'; /* current abort command char */ int quotec = 0x11; /* quote char during mlreply() */ int tabmask = 0x07; /* tabulator mask */ -char *cname[] = { /* names of colors */ - "BLACK", "RED", "GREEN", "YELLOW", "BLUE", - "MAGENTA", "CYAN", "WHITE" -#if PKCODE & IBMPC - , "HIGH" -#endif -}; kbdstate kbdmode = STOP; /* current keyboard macro mode */ diff --git a/random.c b/random.c index c5dd248..bee1088 100644 --- a/random.c +++ b/random.c @@ -24,6 +24,14 @@ #include "terminal.h" #include "window.h" +static const char *cname[] = { /* names of colors */ + "BLACK", "RED", "GREEN", "YELLOW", "BLUE", + "MAGENTA", "CYAN", "WHITE" +#if PKCODE & IBMPC + , "HIGH" +#endif +} ; + int tabsize; /* Tab size (0: use real tabs) */ /* From 2a34d732c56ae0c71c5d4cf40554452f92c4ea94 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sun, 29 Sep 2013 13:26:48 +0800 Subject: [PATCH 132/193] Move global variables to module scope, public of search and private of word. --- edef.h | 6 ------ globals.c | 6 ------ search.c | 4 ++++ search.h | 4 ++++ word.c | 4 ++++ 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/edef.h b/edef.h index f8a1ac4..792f61e 100644 --- a/edef.h +++ b/edef.h @@ -22,9 +22,6 @@ typedef int (*fn_t)(int, int); /* Initialized global external declarations. */ extern int fillcol; /* Fill column */ -extern char pat[]; /* Search pattern */ -extern char rpat[]; /* Replacement pattern */ -extern char tap[]; /* Reversed pattern array. */ extern char *execstr; /* pointer to string to execute */ @@ -84,9 +81,6 @@ extern int cmdstatus; /* last command status */ extern char palstr[]; /* palette string */ extern int saveflag; /* Flags, saved with the $target var */ extern int rval; /* return value of a subprocess */ -#if PKCODE -extern int justflag; /* justify, don't fill */ -#endif extern int overlap; /* line overlap in forw/back page */ extern int scrollcount; /* number of lines to scroll */ diff --git a/globals.c b/globals.c index fe94fe3..76e67fa 100644 --- a/globals.c +++ b/globals.c @@ -82,9 +82,6 @@ int cmdstatus = TRUE; /* last command status */ char palstr[49] = ""; /* palette string */ int saveflag = 0; /* Flags, saved with the $target var */ int rval = 0; /* return value of a subprocess */ -#if PKCODE -int justflag = FALSE; /* justify, don't fill */ -#endif int overlap = 0; /* line overlap in forw/back page */ int scrollcount = 1; /* number of lines to scroll */ @@ -102,9 +99,6 @@ struct buffer *bheadp; /* Head of list of buffers */ struct buffer *blistp; /* Buffer for C-X C-B */ char sres[NBUFN]; /* current screen resolution */ -char pat[NPAT]; /* Search pattern */ -char tap[NPAT]; /* Reversed pattern array. */ -char rpat[NPAT]; /* replacement pattern */ #if DEBUGM diff --git a/search.c b/search.c index 0deccae..897519a 100644 --- a/search.c +++ b/search.c @@ -85,6 +85,10 @@ char *patmatch = NULL ; static struct line *matchline = NULL; static int matchoff = 0; +char pat[ NPAT] ; /* Search pattern */ +char tap[ NPAT] ; /* Reversed pattern array. */ +char rpat[ NPAT] ; /* replacement pattern */ + #if defined(MAGIC) /* diff --git a/search.h b/search.h index 1bf2d1e..b354b50 100644 --- a/search.h +++ b/search.h @@ -8,6 +8,10 @@ extern unsigned int matchlen ; extern char *patmatch ; +extern char pat[] ; /* Search pattern */ +extern char tap[] ; /* Reversed pattern array. */ +extern char rpat[] ; /* replacement pattern */ + /* * PTBEG, PTEND, FORWARD, and REVERSE are all toggle-able values for * the scan routines. diff --git a/word.c b/word.c index 72edea4..3a3b0e8 100644 --- a/word.c +++ b/word.c @@ -22,6 +22,10 @@ #include "region.h" #include "window.h" +#if PKCODE +static int justflag = FALSE ; /* justify, don't fill */ +#endif + static int inword( void) ; /* Word wrap on n-spaces. Back-over whatever precedes the point on the current From d0a5516da63238efd535c81307e3eea12149360c Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sun, 29 Sep 2013 14:07:53 +0800 Subject: [PATCH 133/193] Move global string literal to eval. --- edef.h | 5 ----- eval.c | 17 +++++++++++++++-- eval.h | 1 - globals.c | 5 ----- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/edef.h b/edef.h index 792f61e..07f45bc 100644 --- a/edef.h +++ b/edef.h @@ -71,14 +71,9 @@ extern kbdstate kbdmode ; /* current keyboard macro mode */ extern int kbdrep; /* number of repetitions */ extern int restflag; /* restricted use? */ extern int lastkey; /* last keystoke */ -extern int seed; /* random number seed */ extern long envram; /* # of bytes current in use by malloc */ extern int macbug; /* macro debuging flag */ -extern char errorm[]; /* error literal */ -extern char truem[]; /* true literal */ -extern char falsem[]; /* false litereal */ extern int cmdstatus; /* last command status */ -extern char palstr[]; /* palette string */ extern int saveflag; /* Flags, saved with the $target var */ extern int rval; /* return value of a subprocess */ extern int overlap; /* line overlap in forw/back page */ diff --git a/eval.c b/eval.c index 6848eca..89b6ef8 100644 --- a/eval.c +++ b/eval.c @@ -41,6 +41,12 @@ struct user_variable { char *u_value; /* value (string) */ }; +static char errorm[] = "ERROR" ; /* error literal */ + +static int seed = 0 ; /* random number seed */ + +static char *ltos( int val) ; + /* List of recognized environment variables. */ static const char *envars[] = { @@ -494,8 +500,12 @@ char *gtenv(char *vname) return ltos(macbug); case EVSTATUS: return ltos(cmdstatus); - case EVPALETTE: + case EVPALETTE: { + static char palstr[ 49] = "" ; /* palette string */ + return palstr; + } + case EVASAVE: return itoa(gasave); case EVACOUNT: @@ -1089,8 +1099,11 @@ int stol(char *val) * * int val; value to translate */ -char *ltos(int val) +static char *ltos( int val) { + static char truem[] = "TRUE" ; /* true literal */ + static char falsem[] = "FALSE" ; /* false literal */ + if (val) return truem; else diff --git a/eval.h b/eval.h index d2a7364..85dd60e 100644 --- a/eval.h +++ b/eval.h @@ -25,7 +25,6 @@ int setvar( int f, int n) ; char *itoa( int i) ; char *getval( char *token) ; int stol( char *val) ; -char *ltos( int val) ; char *mkupper( char *str) ; char *mklower( char *str) ; int abs( int x) ; diff --git a/globals.c b/globals.c index 76e67fa..852e2f8 100644 --- a/globals.c +++ b/globals.c @@ -72,14 +72,9 @@ kbdstate kbdmode = STOP; /* current keyboard macro mode */ int kbdrep = 0; /* number of repetitions */ int restflag = FALSE; /* restricted use? */ int lastkey = 0; /* last keystoke */ -int seed = 0; /* random number seed */ long envram = 0l; /* # of bytes current in use by malloc */ int macbug = FALSE; /* macro debuging flag */ -char errorm[] = "ERROR"; /* error literal */ -char truem[] = "TRUE"; /* true literal */ -char falsem[] = "FALSE"; /* false litereal */ int cmdstatus = TRUE; /* last command status */ -char palstr[49] = ""; /* palette string */ int saveflag = 0; /* Flags, saved with the $target var */ int rval = 0; /* return value of a subprocess */ int overlap = 0; /* line overlap in forw/back page */ From 897c50013ee9cc04b16e0dbf36039c15d24b2d27 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sun, 29 Sep 2013 16:56:13 +0800 Subject: [PATCH 134/193] Fix crash when "insert-string $HOME", missing length check when copying environment variables. --- exec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exec.c b/exec.c index ddda97c..44a2e9f 100644 --- a/exec.c +++ b/exec.c @@ -294,7 +294,8 @@ int nextarg(const char *prompt, char *buffer, int size, int terminator) execstr = token(execstr, buffer, size); /* evaluate it */ - strcpy(buffer, getval(buffer)); + strncpy( buffer, getval( buffer), size - 1) ; + buffer[ size - 1] = '\0' ; return TRUE; } From 63e2f82211ae234275e07118cc6f1ad92f3e032a Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sun, 29 Sep 2013 21:58:54 +0800 Subject: [PATCH 135/193] Move global variable to module scope (display, exec, input). --- display.c | 9 +++++++++ display.h | 2 ++ edef.h | 12 ------------ exec.c | 1 + globals.c | 10 ---------- input.c | 2 ++ 6 files changed, 14 insertions(+), 22 deletions(-) diff --git a/display.c b/display.c index 6255287..0542849 100644 --- a/display.c +++ b/display.c @@ -60,6 +60,15 @@ static int displaying = TRUE; int chg_width, chg_height; #endif +static int currow ; /* Cursor row */ +static int curcol ; /* Cursor column */ +static int vtrow = 0 ; /* Row location of SW cursor */ +static int vtcol = 0 ; /* Column location of SW cursor */ +static int lbound = 0 ; /* leftmost column of current line being displayed */ +static int taboff = 0 ; /* tab offset for display */ + +int mpresf = FALSE ; /* TRUE if message in last line */ + static int reframe(struct window *wp); static void updone(struct window *wp); static void updall(struct window *wp); diff --git a/display.h b/display.h index 74e2785..b5ecbd4 100644 --- a/display.h +++ b/display.h @@ -1,6 +1,8 @@ #ifndef _DISPLAY_H_ #define _DISPLAY_H_ +extern int mpresf ; /* Stuff in message line */ + void vtinit( void) ; void vtfree( void) ; void vttidy( void) ; diff --git a/edef.h b/edef.h index 07f45bc..10f2b08 100644 --- a/edef.h +++ b/edef.h @@ -38,23 +38,15 @@ extern int gbcolor; /* global backgrnd color (black) */ extern int gasave; /* global ASAVE size */ extern int gacount; /* count until next ASAVE */ extern int sgarbf; /* State of screen unknown */ -extern int mpresf; /* Stuff in message line */ extern int clexec; /* command line execution flag */ -extern int mstore; /* storing text to macro flag */ extern int discmd; /* display command flag */ extern int disinp; /* display input characters */ -extern int vtrow; /* Row location of SW cursor */ -extern int vtcol; /* Column location of SW cursor */ -extern int lbound; /* leftmost column of current line - being displayed */ -extern int taboff; /* tab offset for display */ extern int metac; /* current meta character */ extern int ctlxc; /* current control X prefix char */ extern int reptc; /* current universal repeat char */ extern int abortc; /* current abort command char */ -extern int quotec; /* quote char during mlreply() */ extern int tabmask; @@ -81,10 +73,6 @@ extern int scrollcount; /* number of lines to scroll */ /* Uninitialized global external declarations. */ -extern int currow; /* Cursor row */ -extern int curcol; /* Cursor column */ - - #define CFCPCN 0x0001 /* Last command was C-P, C-N */ #define CFKILL 0x0002 /* Last command was a kill */ diff --git a/exec.c b/exec.c index 44a2e9f..bc78ac0 100644 --- a/exec.c +++ b/exec.c @@ -67,6 +67,7 @@ static const char *dname[] = { static char golabel[ NPAT] = "" ; /* current line to go to */ static int execlevel = 0 ; /* execution IF level */ static struct buffer *bstore = NULL ; /* buffer to store macro text to */ +static int mstore = FALSE ; /* storing text to macro flag */ static int dobuf( struct buffer *bp) ; static void freewhile( struct while_block *wp) ; diff --git a/globals.c b/globals.c index 852e2f8..19ac809 100644 --- a/globals.c +++ b/globals.c @@ -48,23 +48,15 @@ int gbcolor = 0; /* global backgrnd color (black) */ int gasave = 256; /* global ASAVE size */ int gacount = 256; /* count until next ASAVE */ int sgarbf = TRUE; /* TRUE if screen is garbage */ -int mpresf = FALSE; /* TRUE if message in last line */ int clexec = FALSE; /* command line execution flag */ -int mstore = FALSE; /* storing text to macro flag */ int discmd = TRUE; /* display command flag */ int disinp = TRUE; /* display input characters */ -int vtrow = 0; /* Row location of SW cursor */ -int vtcol = 0; /* Column location of SW cursor */ -int lbound = 0; /* leftmost column of current line - being displayed */ -int taboff = 0; /* tab offset for display */ int metac = CONTROL | '['; /* current meta character */ int ctlxc = CONTROL | 'X'; /* current control X prefix char */ int reptc = CONTROL | 'U'; /* current universal repeat char */ int abortc = CONTROL | 'G'; /* current abort command char */ -int quotec = 0x11; /* quote char during mlreply() */ int tabmask = 0x07; /* tabulator mask */ @@ -82,8 +74,6 @@ int scrollcount = 1; /* number of lines to scroll */ /* uninitialized global definitions */ -int currow; /* Cursor row */ -int curcol; /* Cursor column */ int thisflag; /* Flags, this command */ int lastflag; /* Flags, last command */ int curgoal; /* Goal for C-P, C-N */ diff --git a/input.c b/input.c index 9201586..16c17db 100644 --- a/input.c +++ b/input.c @@ -38,6 +38,8 @@ int kbdm[ NKBDM] ; /* Macro */ int *kbdptr ; /* current position in keyboard buf */ int *kbdend = &kbdm[0] ; /* ptr to end of the keyboard */ +static const int quotec = 0x11 ; /* quote char during mlreply() */ + /* * Ask a yes or no question in the message line. Return either TRUE, FALSE, or * ABORT. The ABORT status is returned if the user bumps out of the question From 526c1e3baa124411c73640451da0b5e5fc3d93e6 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Mon, 30 Sep 2013 23:05:29 +0800 Subject: [PATCH 136/193] Review global literals for mode names and color names. --- buffer.c | 19 ++++++++++++++++--- buffer.h | 3 +++ display.c | 2 +- edef.h | 3 --- estruct.h | 1 - globals.c | 24 ------------------------ random.c | 32 ++++++++------------------------ 7 files changed, 28 insertions(+), 56 deletions(-) diff --git a/buffer.c b/buffer.c index 495fa93..8cffbaa 100644 --- a/buffer.c +++ b/buffer.c @@ -23,6 +23,20 @@ #include "window.h" +const char *modename[] = { /* name of modes */ + "Wrap", "Cmode", "Spell", "Exact", "View", "Over", + "Magic", +#if CRYPT + "Crypt", +#else + "", +#endif + "Asave", "Utf-8", "Dos" +} ; + +static const char modecode[] = "WCSEVOMYAUD" ; /* letters to represent modes */ + + static int makelist( int iflag) ; static int addline( char *text) ; static void ltoa( char *buf, int width, long num) ; @@ -296,9 +310,8 @@ static int makelist( int iflag) if ((s = bclear(blistp)) != TRUE) /* Blow old text away */ return s; strcpy(blistp->b_fname, ""); - if (addline("ACT MODES Size Buffer File") == FALSE - || addline("--- ----- ---- ------ ----") == - FALSE) + if( addline("ACT MODES Size Buffer File") == FALSE + || addline("--- ----- ---- ------ ----") == FALSE) return FALSE; bp = bheadp; /* For all buffers */ diff --git a/buffer.h b/buffer.h index 6eb70e3..41b2e4f 100644 --- a/buffer.h +++ b/buffer.h @@ -59,6 +59,9 @@ struct buffer { #define MDDOS 0x0400 /* CRLF eol mode */ +extern const char *modename[] ; /* text names of modes */ + + int usebuffer( int f, int n) ; int nextbuffer( int f, int n) ; int swbuffer( struct buffer *bp) ; diff --git a/display.c b/display.c index 0542849..9400a8b 100644 --- a/display.c +++ b/display.c @@ -1165,7 +1165,7 @@ static void modeline(struct window *wp) if (firstm != TRUE) strcat(tline, " "); firstm = FALSE; - strcat(tline, mode2name[i]); + strcat( tline, modename[ i]) ; } strcat(tline, ") "); diff --git a/edef.h b/edef.h index 10f2b08..821e456 100644 --- a/edef.h +++ b/edef.h @@ -28,9 +28,6 @@ extern char *execstr; /* pointer to string to execute */ extern int eolexist; /* does clear to EOL exist? */ extern int revexist; /* does reverse video exist? */ extern int flickcode; /* do flicker supression? */ -extern const char *modename[]; /* text names of modes */ -extern const char *mode2name[]; /* text names of modes */ -extern const char modecode[]; /* letters to represent modes */ extern int gmode; /* global editor mode */ extern int gflags; /* global control flag */ extern int gfcolor; /* global forgrnd color (white) */ diff --git a/estruct.h b/estruct.h index dd5b69a..60ff1b0 100644 --- a/estruct.h +++ b/estruct.h @@ -239,7 +239,6 @@ #define NPAT 128 /* # of bytes, pattern */ #define HUGE 1000 /* Huge number */ #define NLOCKS 100 /* max # of file locks active */ -#define NCOLORS 8 /* number of supported colors */ #define CONTROL 0x10000000 /* Control flag, or'ed in */ #define META 0x20000000 /* Meta flag, or'ed in */ diff --git a/globals.c b/globals.c index 19ac809..ee81dfe 100644 --- a/globals.c +++ b/globals.c @@ -13,30 +13,6 @@ char *execstr = NULL; /* pointer to string to execute */ int eolexist = TRUE; /* does clear to EOL exist */ int revexist = FALSE; /* does reverse video exist? */ int flickcode = FALSE; /* do flicker supression? */ -const char *modename[] = { /* name of modes */ - "WRAP", "CMODE", "SPELL", "EXACT", "VIEW", "OVER", - "MAGIC", -#if CRYPT - "CRYPT", -#else - "", -#endif - "ASAVE", "UTF-8", "DOS" -}; - -const char *mode2name[] = { /* name of modes */ - "Wrap", "Cmode", "Spell", "Exact", "View", "Over", - "Magic", -#if CRYPT - "Crypt", -#else - "", -#endif - "Asave", "utf-8", "Dos" -}; - -const char modecode[] = "WCSEVOMYAUD"; /* letters to represent modes */ - int gmode = 0; /* global editor mode */ int gflags = GFREAD; /* global control flag */ #if PKCODE & IBMPC diff --git a/random.c b/random.c index bee1088..be90bd0 100644 --- a/random.c +++ b/random.c @@ -24,7 +24,8 @@ #include "terminal.h" #include "window.h" -static const char *cname[] = { /* names of colors */ + +static const char *cname[] = { /* names of colors */ "BLACK", "RED", "GREEN", "YELLOW", "BLUE", "MAGENTA", "CYAN", "WHITE" #if PKCODE & IBMPC @@ -32,6 +33,9 @@ static const char *cname[] = { /* names of colors */ #endif } ; +#define NCOLORS (sizeof cname / sizeof( *cname)) /* # of supported colors */ + + int tabsize; /* Tab size (0: use real tabs) */ /* @@ -917,12 +921,8 @@ int delgmode(int f, int n) */ int adjustmode(int kind, int global) { - char *scan; /* scanning pointer to convert prompt */ int i; /* loop index */ int status; /* error return on input */ -#if COLOR - int uflag; /* was modename uppercase? */ -#endif char prompt[50]; /* string to prompt user with */ char cbuf[NPAT]; /* buffer to recieve mode name into */ @@ -943,28 +943,12 @@ int adjustmode(int kind, int global) if (status != TRUE) return status; - /* make it uppercase */ - - scan = cbuf; -#if COLOR - uflag = (*scan >= 'A' && *scan <= 'Z'); -#endif - while (*scan != 0) { - if (*scan >= 'a' && *scan <= 'z') - *scan = *scan - 32; - scan++; - } - /* test it first against the colors we know */ -#if PKCODE & IBMPC - for (i = 0; i <= NCOLORS; i++) { -#else for (i = 0; i < NCOLORS; i++) { -#endif - if (strcmp(cbuf, cname[i]) == 0) { + if( stricmp( cbuf, cname[ i]) == 0) { /* finding the match, we set the color */ #if COLOR - if (uflag) { + if( *cbuf >= 'A' && *cbuf <= 'Z') { if (global) gfcolor = i; #if PKCODE == 0 @@ -990,7 +974,7 @@ int adjustmode(int kind, int global) /* test it against the modes we know */ for (i = 0; i < NUMMODES; i++) { - if (strcmp(cbuf, modename[i]) == 0) { + if( stricmp( cbuf, modename[ i]) == 0) { /* finding a match, we process it */ if (kind == TRUE) if (global) From b07c1c0acd440f88f331e08fde9677b8a04c1012 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 1 Oct 2013 18:27:57 +0800 Subject: [PATCH 137/193] Recompile with CRYPT turned off. --- fileio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fileio.c b/fileio.c index 070ca49..8148e54 100644 --- a/fileio.c +++ b/fileio.c @@ -15,6 +15,7 @@ #include #include "defines.h" +#include "retcode.h" #if CRYPT boolean is_crypted ; /* currently encrypting? */ From 1d5cbe67a4ff6dd3b0f309be2ea20503f78dc8e7 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 1 Oct 2013 19:40:26 +0800 Subject: [PATCH 138/193] Move global color variable with color names in random. --- globals.c | 6 ------ random.c | 2 ++ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/globals.c b/globals.c index ee81dfe..e9d2f4a 100644 --- a/globals.c +++ b/globals.c @@ -15,12 +15,6 @@ int revexist = FALSE; /* does reverse video exist? */ int flickcode = FALSE; /* do flicker supression? */ int gmode = 0; /* global editor mode */ int gflags = GFREAD; /* global control flag */ -#if PKCODE & IBMPC -int gfcolor = 8; /* global forgrnd color (white) */ -#else -int gfcolor = 7; /* global forgrnd color (white) */ -#endif -int gbcolor = 0; /* global backgrnd color (black) */ int gasave = 256; /* global ASAVE size */ int gacount = 256; /* count until next ASAVE */ int sgarbf = TRUE; /* TRUE if screen is garbage */ diff --git a/random.c b/random.c index be90bd0..6f74d9b 100644 --- a/random.c +++ b/random.c @@ -35,6 +35,8 @@ static const char *cname[] = { /* names of colors */ #define NCOLORS (sizeof cname / sizeof( *cname)) /* # of supported colors */ +int gfcolor = NCOLORS - 1 ; /* global forgrnd color (white) */ +int gbcolor = 0 ; /* global backgrnd color (black) */ int tabsize; /* Tab size (0: use real tabs) */ From a3be4fea81dd599214adfe20f262bded9c62cafb Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 2 Oct 2013 09:22:40 +0800 Subject: [PATCH 139/193] Recompile on Linux; Replace stricmp by strcasecmp. --- Makefile | 7 ++++--- random.c | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 25c9dbb..16f33b6 100644 --- a/Makefile +++ b/Makefile @@ -170,7 +170,7 @@ isearch.o: isearch.c isearch.h basic.h buffer.h crypt.h line.h utf8.h \ line.o: line.c line.h utf8.h buffer.h crypt.h edef.h estruct.h retcode.h \ log.h window.h defines.h lock.o: lock.c lock.h estruct.h retcode.h display.h edef.h buffer.h \ - crypt.h line.h utf8.h input.h + crypt.h line.h utf8.h input.h pklock.h log.o: log.c log.h retcode.h main.o: main.c basic.h bind.h edef.h buffer.h crypt.h line.h utf8.h \ estruct.h retcode.h bindable.h display.h eval.h execute.h file.h input.h \ @@ -181,7 +181,8 @@ names.o: names.c names.h basic.h bind.h edef.h buffer.h crypt.h line.h \ isearch.h region.h random.h search.h spawn.h window.h defines.h word.h pklock.o: pklock.c pklock.h estruct.h retcode.h edef.h buffer.h crypt.h \ line.h utf8.h -posix.o: posix.c termio.h +posix.o: posix.c termio.h estruct.h retcode.h edef.h buffer.h crypt.h \ + line.h utf8.h random.o: random.c random.h basic.h buffer.h crypt.h line.h utf8.h \ display.h estruct.h retcode.h edef.h execute.h input.h log.h search.h \ terminal.h defines.h window.h @@ -195,7 +196,7 @@ spawn.o: spawn.c spawn.h defines.h buffer.h crypt.h line.h utf8.h \ terminal.h window.h tcap.o: tcap.c terminal.h defines.h display.h estruct.h retcode.h edef.h \ buffer.h crypt.h line.h utf8.h termio.h -termio.o: termio.c termio.h estruct.h retcode.h utf8.h +termio.o: termio.c termio.h utf8.o: utf8.c utf8.h vmsvt.o: vmsvt.c estruct.h retcode.h edef.h buffer.h crypt.h line.h \ utf8.h diff --git a/random.c b/random.c index 6f74d9b..66ee779 100644 --- a/random.c +++ b/random.c @@ -947,7 +947,7 @@ int adjustmode(int kind, int global) /* test it first against the colors we know */ for (i = 0; i < NCOLORS; i++) { - if( stricmp( cbuf, cname[ i]) == 0) { + if( strcasecmp( cbuf, cname[ i]) == 0) { /* finding the match, we set the color */ #if COLOR if( *cbuf >= 'A' && *cbuf <= 'Z') { @@ -976,7 +976,7 @@ int adjustmode(int kind, int global) /* test it against the modes we know */ for (i = 0; i < NUMMODES; i++) { - if( stricmp( cbuf, modename[ i]) == 0) { + if( strcasecmp( cbuf, modename[ i]) == 0) { /* finding a match, we process it */ if (kind == TRUE) if (global) From df349fa061c899adc7b31a9eb70d4607405d6cb0 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 8 Oct 2013 10:20:01 +0800 Subject: [PATCH 140/193] Recompile under CYGWIN64. Move DEBUGM code to eval and exec. --- Makefile | 7 +++---- edef.h | 5 ----- estruct.h | 1 - eval.c | 13 +++++++++---- eval.h | 10 ++++++++++ exec.c | 9 ++++----- globals.c | 6 ------ 7 files changed, 26 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index 16f33b6..25c9dbb 100644 --- a/Makefile +++ b/Makefile @@ -170,7 +170,7 @@ isearch.o: isearch.c isearch.h basic.h buffer.h crypt.h line.h utf8.h \ line.o: line.c line.h utf8.h buffer.h crypt.h edef.h estruct.h retcode.h \ log.h window.h defines.h lock.o: lock.c lock.h estruct.h retcode.h display.h edef.h buffer.h \ - crypt.h line.h utf8.h input.h pklock.h + crypt.h line.h utf8.h input.h log.o: log.c log.h retcode.h main.o: main.c basic.h bind.h edef.h buffer.h crypt.h line.h utf8.h \ estruct.h retcode.h bindable.h display.h eval.h execute.h file.h input.h \ @@ -181,8 +181,7 @@ names.o: names.c names.h basic.h bind.h edef.h buffer.h crypt.h line.h \ isearch.h region.h random.h search.h spawn.h window.h defines.h word.h pklock.o: pklock.c pklock.h estruct.h retcode.h edef.h buffer.h crypt.h \ line.h utf8.h -posix.o: posix.c termio.h estruct.h retcode.h edef.h buffer.h crypt.h \ - line.h utf8.h +posix.o: posix.c termio.h random.o: random.c random.h basic.h buffer.h crypt.h line.h utf8.h \ display.h estruct.h retcode.h edef.h execute.h input.h log.h search.h \ terminal.h defines.h window.h @@ -196,7 +195,7 @@ spawn.o: spawn.c spawn.h defines.h buffer.h crypt.h line.h utf8.h \ terminal.h window.h tcap.o: tcap.c terminal.h defines.h display.h estruct.h retcode.h edef.h \ buffer.h crypt.h line.h utf8.h termio.h -termio.o: termio.c termio.h +termio.o: termio.c termio.h estruct.h retcode.h utf8.h utf8.o: utf8.c utf8.h vmsvt.o: vmsvt.c estruct.h retcode.h edef.h buffer.h crypt.h line.h \ utf8.h diff --git a/edef.h b/edef.h index 821e456..093e803 100644 --- a/edef.h +++ b/edef.h @@ -86,9 +86,4 @@ extern struct buffer *blistp; /* Buffer for C-X C-B */ extern char sres[NBUFN]; /* Current screen resolution. */ -#if DEBUGM -/* Vars needed for macro debugging output. */ -extern char outline[]; /* Global string to hold debug line text. */ -#endif - #endif /* EDEF_H_ */ diff --git a/estruct.h b/estruct.h index 60ff1b0..d756b32 100644 --- a/estruct.h +++ b/estruct.h @@ -129,7 +129,6 @@ #define CLRMSG 0 /* space clears the message line with no insert */ #define CFENCE 1 /* fench matching in CMODE */ #define TYPEAH 1 /* type ahead causes update to be skipped */ -#define DEBUGM 1 /* $debug triggers macro debugging */ #define VISMAC 0 /* update display during keyboard macros */ #define CTRLZ 0 /* add a ^Z at end of files under MSDOS only */ #define ADDCR 0 /* ajout d'un CR en fin de chaque ligne (ST520) */ diff --git a/eval.c b/eval.c index 89b6ef8..f11220d 100644 --- a/eval.c +++ b/eval.c @@ -32,6 +32,11 @@ #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) +#if DEBUGM +/* vars needed for macro debugging output */ +char outline[ NSTRING] ; /* global string to hold debug line text */ +#endif + /* Max #chars in a var name. */ #define NVSIZE 10 @@ -587,10 +592,6 @@ char *gtenv(char *vname) int setvar(int f, int n) { int status; /* status return */ -#if DEBUGM - char *sp; /* temp string pointer */ - char *ep; /* ptr to end of outline */ -#endif struct variable_description vd; /* variable num/type */ char var[NVSIZE + 1]; /* name of variable to fetch */ char value[NSTRING]; /* value to set variable to */ @@ -631,6 +632,8 @@ int setvar(int f, int n) that effect here. */ if (macbug) { + char *sp ; /* temp string pointer */ + strcpy(outline, "((("); /* assignment status */ @@ -649,6 +652,8 @@ int setvar(int f, int n) sp = outline; while (*sp) if (*sp++ == '%') { + char *ep ; /* ptr to end of outline */ + /* advance to the end */ ep = --sp; while (*ep++); diff --git a/eval.h b/eval.h index 85dd60e..378c72a 100644 --- a/eval.h +++ b/eval.h @@ -1,6 +1,16 @@ #ifndef _EVAL_H_ #define _EVAL_H_ + +#define DEBUGM 1 /* $debug triggers macro debugging */ + + +#if DEBUGM +/* Vars needed for macro debugging output. */ +extern char outline[] ; /* Global string to hold debug line text. */ +#endif + + /* Macro argument token types */ #define TKNUL 0 /* end-of-string */ diff --git a/exec.c b/exec.c index bc78ac0..77cc2f0 100644 --- a/exec.c +++ b/exec.c @@ -495,11 +495,6 @@ static int dobuf(struct buffer *bp) char *eline; /* text of line to execute */ char tkn[NSTRING]; /* buffer to evaluate an expresion in */ -#if DEBUGM - char *sp; /* temp for building debug string */ - char *ep; /* ptr to end of outline */ -#endif - /* clear IF level flags/while ptr */ execlevel = 0; whlist = NULL; @@ -616,6 +611,8 @@ static int dobuf(struct buffer *bp) ^G will abort the command */ if (macbug) { + char *sp ; /* temp for building debug string */ + strcpy(outline, "<<<"); /* debug macro name */ @@ -634,6 +631,8 @@ static int dobuf(struct buffer *bp) sp = outline; while (*sp) if (*sp++ == '%') { + char *ep ; /* ptr to end of outline */ + /* advance to the end */ ep = --sp; while (*ep++); diff --git a/globals.c b/globals.c index e9d2f4a..627d58b 100644 --- a/globals.c +++ b/globals.c @@ -54,9 +54,3 @@ struct buffer *bheadp; /* Head of list of buffers */ struct buffer *blistp; /* Buffer for C-X C-B */ char sres[NBUFN]; /* current screen resolution */ - - -#if DEBUGM -/* vars needed for macro debugging output */ -char outline[NSTRING]; /* global string to hold debug line text */ -#endif From 4da4c2f4dea8e97c63131073da8b44800f8d640e Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 8 Oct 2013 10:27:25 +0800 Subject: [PATCH 141/193] Avoid warning when turning DEBUGM off. --- exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exec.c b/exec.c index 77cc2f0..ad81f9b 100644 --- a/exec.c +++ b/exec.c @@ -485,7 +485,6 @@ static int dobuf(struct buffer *bp) int dirnum; /* directive index */ int linlen; /* length of line to execute */ int i; /* index */ - int c; /* temp character */ int force; /* force TRUE result? */ struct window *wp; /* ptr to windows to scan */ struct while_block *whlist; /* ptr to !WHILE list */ @@ -612,6 +611,7 @@ static int dobuf(struct buffer *bp) if (macbug) { char *sp ; /* temp for building debug string */ + int c ; /* temp character */ strcpy(outline, "<<<"); From 31b1cc84fbe6361b2bb8ebd24c2f77fbecd9bca6 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 8 Oct 2013 15:53:27 +0800 Subject: [PATCH 142/193] Move gflags to eval. --- edef.h | 1 - estruct.h | 4 ---- eval.c | 2 ++ eval.h | 6 ++++++ globals.c | 1 - 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/edef.h b/edef.h index 093e803..713185f 100644 --- a/edef.h +++ b/edef.h @@ -29,7 +29,6 @@ extern int eolexist; /* does clear to EOL exist? */ extern int revexist; /* does reverse video exist? */ extern int flickcode; /* do flicker supression? */ extern int gmode; /* global editor mode */ -extern int gflags; /* global control flag */ extern int gfcolor; /* global forgrnd color (white) */ extern int gbcolor; /* global backgrnd color (black) */ extern int gasave; /* global ASAVE size */ diff --git a/estruct.h b/estruct.h index d756b32..dccfcd2 100644 --- a/estruct.h +++ b/estruct.h @@ -224,10 +224,6 @@ #define ENVFUNC 0 #endif -/* Emacs global flag bit definitions (for gflags). */ - -#define GFREAD 1 - /* Internal constants. */ #define NBINDS 256 /* max # of bound keys */ diff --git a/eval.c b/eval.c index f11220d..1e02c05 100644 --- a/eval.c +++ b/eval.c @@ -37,6 +37,8 @@ char outline[ NSTRING] ; /* global string to hold debug line text */ #endif +int gflags = GFREAD ; /* global control flag */ + /* Max #chars in a var name. */ #define NVSIZE 10 diff --git a/eval.h b/eval.h index 378c72a..13a72d5 100644 --- a/eval.h +++ b/eval.h @@ -11,6 +11,12 @@ extern char outline[] ; /* Global string to hold debug line text. */ #endif +/* Emacs global flag bit definitions (for gflags). */ + +#define GFREAD 1 + +extern int gflags ; /* global control flag */ + /* Macro argument token types */ #define TKNUL 0 /* end-of-string */ diff --git a/globals.c b/globals.c index 627d58b..589bef7 100644 --- a/globals.c +++ b/globals.c @@ -14,7 +14,6 @@ int eolexist = TRUE; /* does clear to EOL exist */ int revexist = FALSE; /* does reverse video exist? */ int flickcode = FALSE; /* do flicker supression? */ int gmode = 0; /* global editor mode */ -int gflags = GFREAD; /* global control flag */ int gasave = 256; /* global ASAVE size */ int gacount = 256; /* count until next ASAVE */ int sgarbf = TRUE; /* TRUE if screen is garbage */ From a0279731569e5aaaee2f4b97b2774b3df525c4f2 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 8 Oct 2013 16:24:11 +0800 Subject: [PATCH 143/193] Move macbug, cmdstatus and saveflag to eval. --- edef.h | 3 --- eval.c | 5 +++++ eval.h | 2 ++ globals.c | 3 --- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/edef.h b/edef.h index 713185f..bf32c69 100644 --- a/edef.h +++ b/edef.h @@ -60,9 +60,6 @@ extern int kbdrep; /* number of repetitions */ extern int restflag; /* restricted use? */ extern int lastkey; /* last keystoke */ extern long envram; /* # of bytes current in use by malloc */ -extern int macbug; /* macro debuging flag */ -extern int cmdstatus; /* last command status */ -extern int saveflag; /* Flags, saved with the $target var */ extern int rval; /* return value of a subprocess */ extern int overlap; /* line overlap in forw/back page */ extern int scrollcount; /* number of lines to scroll */ diff --git a/eval.c b/eval.c index 1e02c05..46a7642 100644 --- a/eval.c +++ b/eval.c @@ -38,6 +38,11 @@ char outline[ NSTRING] ; /* global string to hold debug line text */ #endif int gflags = GFREAD ; /* global control flag */ +int macbug = FALSE ; /* macro debuging flag */ +int cmdstatus = TRUE ; /* last command status */ + +static int saveflag = 0 ; /* Flags, saved with the $target var */ + /* Max #chars in a var name. */ #define NVSIZE 10 diff --git a/eval.h b/eval.h index 13a72d5..85fe51f 100644 --- a/eval.h +++ b/eval.h @@ -16,6 +16,8 @@ extern char outline[] ; /* Global string to hold debug line text. */ #define GFREAD 1 extern int gflags ; /* global control flag */ +extern int macbug ; /* macro debuging flag */ +extern int cmdstatus ; /* last command status */ /* Macro argument token types */ diff --git a/globals.c b/globals.c index 589bef7..afad3bc 100644 --- a/globals.c +++ b/globals.c @@ -34,9 +34,6 @@ int kbdrep = 0; /* number of repetitions */ int restflag = FALSE; /* restricted use? */ int lastkey = 0; /* last keystoke */ long envram = 0l; /* # of bytes current in use by malloc */ -int macbug = FALSE; /* macro debuging flag */ -int cmdstatus = TRUE; /* last command status */ -int saveflag = 0; /* Flags, saved with the $target var */ int rval = 0; /* return value of a subprocess */ int overlap = 0; /* line overlap in forw/back page */ int scrollcount = 1; /* number of lines to scroll */ From 0a998c1cf936f11221bf14d79da0de5b12be7889 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 8 Oct 2013 16:39:15 +0800 Subject: [PATCH 144/193] Move gasave and gacount to execute. --- Makefile | 9 +++++---- edef.h | 2 -- eval.c | 1 + execute.c | 6 ++++++ execute.h | 3 +++ globals.c | 2 -- 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 25c9dbb..9ec8584 100644 --- a/Makefile +++ b/Makefile @@ -146,13 +146,14 @@ ebind.o: ebind.c ebind.h basic.h bind.h edef.h buffer.h crypt.h line.h \ utf8.h estruct.h retcode.h bindable.h eval.h exec.h file.h isearch.h \ random.h region.h search.h spawn.h window.h defines.h word.h eval.o: eval.c eval.h basic.h bind.h edef.h buffer.h crypt.h line.h \ - utf8.h estruct.h retcode.h display.h exec.h flook.h input.h random.h \ - search.h terminal.h defines.h termio.h version.h window.h + utf8.h estruct.h retcode.h display.h exec.h execute.h flook.h input.h \ + random.h search.h terminal.h defines.h termio.h version.h window.h exec.o: exec.c exec.h buffer.h crypt.h line.h utf8.h bind.h edef.h \ estruct.h retcode.h display.h eval.h file.h flook.h input.h window.h \ defines.h -execute.o: execute.c edef.h buffer.h crypt.h line.h utf8.h estruct.h \ - retcode.h bind.h random.h display.h file.h terminal.h defines.h window.h +execute.o: execute.c execute.h edef.h buffer.h crypt.h line.h utf8.h \ + estruct.h retcode.h bind.h random.h display.h file.h terminal.h \ + defines.h window.h file.o: file.c file.h crypt.h retcode.h buffer.h line.h utf8.h defines.h \ estruct.h edef.h execute.h fileio.h input.h lock.h log.h window.h fileio.o: fileio.c fileio.h crypt.h retcode.h defines.h diff --git a/edef.h b/edef.h index bf32c69..10cc895 100644 --- a/edef.h +++ b/edef.h @@ -31,8 +31,6 @@ extern int flickcode; /* do flicker supression? */ extern int gmode; /* global editor mode */ extern int gfcolor; /* global forgrnd color (white) */ extern int gbcolor; /* global backgrnd color (black) */ -extern int gasave; /* global ASAVE size */ -extern int gacount; /* count until next ASAVE */ extern int sgarbf; /* State of screen unknown */ extern int clexec; /* command line execution flag */ extern int discmd; /* display command flag */ diff --git a/eval.c b/eval.c index 46a7642..fcb2d2e 100644 --- a/eval.c +++ b/eval.c @@ -18,6 +18,7 @@ #include "estruct.h" #include "edef.h" #include "exec.h" +#include "execute.h" #include "flook.h" #include "input.h" #include "line.h" diff --git a/execute.c b/execute.c index 0afd8a3..708a723 100644 --- a/execute.c +++ b/execute.c @@ -1,3 +1,6 @@ +/* execute.c -- implements execute.h */ +#include "execute.h" + #include "edef.h" #include "bind.h" #include "random.h" @@ -6,6 +9,9 @@ #include "terminal.h" #include "window.h" +int gasave = 256 ; /* global ASAVE size */ +int gacount = 256 ; /* count until next ASAVE */ + /* * This is the general command execution routine. It handles the fake binding * of all the keys to "self-insert". It also clears out the "thisflag" word, diff --git a/execute.h b/execute.h index 4cb6224..a172652 100644 --- a/execute.h +++ b/execute.h @@ -1,2 +1,5 @@ +extern int gasave ; /* global ASAVE size */ +extern int gacount ; /* count until next ASAVE */ + int execute( int c, int f, int n) ; diff --git a/globals.c b/globals.c index afad3bc..c54cdb6 100644 --- a/globals.c +++ b/globals.c @@ -14,8 +14,6 @@ int eolexist = TRUE; /* does clear to EOL exist */ int revexist = FALSE; /* does reverse video exist? */ int flickcode = FALSE; /* do flicker supression? */ int gmode = 0; /* global editor mode */ -int gasave = 256; /* global ASAVE size */ -int gacount = 256; /* count until next ASAVE */ int sgarbf = TRUE; /* TRUE if screen is garbage */ int clexec = FALSE; /* command line execution flag */ int discmd = TRUE; /* display command flag */ From 83e10e36d5859b961d628163fd0a932fba1d360b Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 8 Oct 2013 16:56:47 +0800 Subject: [PATCH 145/193] Move execstr from globals to exec. --- edef.h | 1 - exec.c | 4 ++++ exec.h | 4 ++++ globals.c | 1 - 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/edef.h b/edef.h index 10cc895..0615594 100644 --- a/edef.h +++ b/edef.h @@ -22,7 +22,6 @@ typedef int (*fn_t)(int, int); /* Initialized global external declarations. */ extern int fillcol; /* Fill column */ -extern char *execstr; /* pointer to string to execute */ extern int eolexist; /* does clear to EOL exist? */ diff --git a/exec.c b/exec.c index ad81f9b..662a2a6 100644 --- a/exec.c +++ b/exec.c @@ -24,6 +24,10 @@ #include "line.h" #include "window.h" + +char *execstr = NULL ; /* pointer to string to execute */ + + /* Directive definitions */ #define DIF 0 diff --git a/exec.h b/exec.h index 56939b4..cd0fb8a 100644 --- a/exec.h +++ b/exec.h @@ -8,6 +8,10 @@ int storeproc( int f, int n) ; int execproc( int f, int n) ; #endif + +extern char *execstr ; /* pointer to string to execute */ + + int namedcmd( int f, int n) ; int execcmd( int f, int n) ; int docmd( char *cline) ; diff --git a/globals.c b/globals.c index c54cdb6..1823192 100644 --- a/globals.c +++ b/globals.c @@ -7,7 +7,6 @@ /* initialized global definitions */ int fillcol = 72; /* Current fill column */ -char *execstr = NULL; /* pointer to string to execute */ int eolexist = TRUE; /* does clear to EOL exist */ From 83a0cc9d67b542f492417e02e2c787febe9436fd Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 8 Oct 2013 17:16:27 +0800 Subject: [PATCH 146/193] Move global buffer pointers and gmode to buffer. --- buffer.c | 6 ++++++ buffer.h | 5 +++++ edef.h | 4 ---- globals.c | 4 ---- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/buffer.c b/buffer.c index 8cffbaa..8a752df 100644 --- a/buffer.c +++ b/buffer.c @@ -23,6 +23,10 @@ #include "window.h" +struct buffer *curbp ; /* Current buffer */ +struct buffer *bheadp ; /* Head of list of buffers */ +struct buffer *blistp ; /* Buffer for C-X C-B */ + const char *modename[] = { /* name of modes */ "Wrap", "Cmode", "Spell", "Exact", "View", "Over", "Magic", @@ -34,6 +38,8 @@ const char *modename[] = { /* name of modes */ "Asave", "Utf-8", "Dos" } ; +int gmode = 0 ; /* global editor mode */ + static const char modecode[] = "WCSEVOMYAUD" ; /* letters to represent modes */ diff --git a/buffer.h b/buffer.h index 41b2e4f..2b69eb8 100644 --- a/buffer.h +++ b/buffer.h @@ -37,6 +37,10 @@ struct buffer { #endif }; +extern struct buffer *curbp ; /* Current buffer */ +extern struct buffer *bheadp ; /* Head of list of buffers */ +extern struct buffer *blistp ; /* Buffer for C-X C-B */ + #define BFINVS 0x01 /* Internal invisable buffer */ #define BFCHG 0x02 /* Changed since last write */ #define BFTRUNC 0x04 /* buffer was truncated when read */ @@ -60,6 +64,7 @@ struct buffer { extern const char *modename[] ; /* text names of modes */ +extern int gmode ; /* global editor mode */ int usebuffer( int f, int n) ; diff --git a/edef.h b/edef.h index 0615594..6f1274a 100644 --- a/edef.h +++ b/edef.h @@ -27,7 +27,6 @@ extern int fillcol; /* Fill column */ extern int eolexist; /* does clear to EOL exist? */ extern int revexist; /* does reverse video exist? */ extern int flickcode; /* do flicker supression? */ -extern int gmode; /* global editor mode */ extern int gfcolor; /* global forgrnd color (white) */ extern int gbcolor; /* global backgrnd color (black) */ extern int sgarbf; /* State of screen unknown */ @@ -71,10 +70,7 @@ extern int lastflag; /* Flags, last command */ extern int curgoal; /* Goal for C-P, C-N */ extern struct window *curwp; /* Current window */ -extern struct buffer *curbp; /* Current buffer */ extern struct window *wheadp; /* Head of list of windows */ -extern struct buffer *bheadp; /* Head of list of buffers */ -extern struct buffer *blistp; /* Buffer for C-X C-B */ extern char sres[NBUFN]; /* Current screen resolution. */ diff --git a/globals.c b/globals.c index 1823192..28eaef7 100644 --- a/globals.c +++ b/globals.c @@ -12,7 +12,6 @@ int fillcol = 72; /* Current fill column */ int eolexist = TRUE; /* does clear to EOL exist */ int revexist = FALSE; /* does reverse video exist? */ int flickcode = FALSE; /* do flicker supression? */ -int gmode = 0; /* global editor mode */ int sgarbf = TRUE; /* TRUE if screen is garbage */ int clexec = FALSE; /* command line execution flag */ int discmd = TRUE; /* display command flag */ @@ -41,9 +40,6 @@ int thisflag; /* Flags, this command */ int lastflag; /* Flags, last command */ int curgoal; /* Goal for C-P, C-N */ struct window *curwp; /* Current window */ -struct buffer *curbp; /* Current buffer */ struct window *wheadp; /* Head of list of windows */ -struct buffer *bheadp; /* Head of list of buffers */ -struct buffer *blistp; /* Buffer for C-X C-B */ char sres[NBUFN]; /* current screen resolution */ From d6e3df6ff37ed79d0b947d85873115dc01232b81 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 8 Oct 2013 17:41:49 +0800 Subject: [PATCH 147/193] Move global window pointers to window and global keyboard variables to input. --- Makefile | 6 +++--- display.c | 1 + edef.h | 14 -------------- globals.c | 5 ----- input.c | 4 ++++ input.h | 6 ++++++ window.c | 3 +++ window.h | 3 +++ 8 files changed, 20 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index 9ec8584..2fd24a3 100644 --- a/Makefile +++ b/Makefile @@ -140,8 +140,8 @@ buffer.o: buffer.c buffer.h crypt.h line.h utf8.h defines.h display.h \ edef.h estruct.h retcode.h file.h input.h window.h crypt.o: crypt.c crypt.h display.o: display.c display.h buffer.h crypt.h line.h utf8.h estruct.h \ - retcode.h edef.h termio.h terminal.h defines.h version.h wrapper.h \ - window.h + retcode.h edef.h input.h termio.h terminal.h defines.h version.h \ + wrapper.h window.h ebind.o: ebind.c ebind.h basic.h bind.h edef.h buffer.h crypt.h line.h \ utf8.h estruct.h retcode.h bindable.h eval.h exec.h file.h isearch.h \ random.h region.h search.h spawn.h window.h defines.h word.h @@ -202,7 +202,7 @@ vmsvt.o: vmsvt.c estruct.h retcode.h edef.h buffer.h crypt.h line.h \ utf8.h vt52.o: vt52.c estruct.h retcode.h edef.h buffer.h crypt.h line.h utf8.h window.o: window.c window.h defines.h buffer.h crypt.h line.h utf8.h \ - basic.h display.h edef.h estruct.h retcode.h execute.h terminal.h \ + basic.h display.h estruct.h retcode.h edef.h execute.h terminal.h \ wrapper.h word.o: word.c word.h basic.h buffer.h crypt.h line.h utf8.h estruct.h \ retcode.h edef.h log.h random.h region.h window.h defines.h diff --git a/display.c b/display.c index 9400a8b..604acfc 100644 --- a/display.c +++ b/display.c @@ -20,6 +20,7 @@ #include "buffer.h" #include "estruct.h" #include "edef.h" +#include "input.h" #include "line.h" #include "termio.h" #include "terminal.h" diff --git a/edef.h b/edef.h index 6f1274a..66c6a9d 100644 --- a/edef.h +++ b/edef.h @@ -42,19 +42,7 @@ extern int abortc; /* current abort command char */ extern int tabmask; -#if 0 -#define STOP 0 /* keyboard macro not in use */ -#define PLAY 1 /* playing */ -#define RECORD 2 /* recording */ -#endif - -typedef enum { - STOP, PLAY, RECORD -} kbdstate ; -extern kbdstate kbdmode ; /* current keyboard macro mode */ -extern int kbdrep; /* number of repetitions */ extern int restflag; /* restricted use? */ -extern int lastkey; /* last keystoke */ extern long envram; /* # of bytes current in use by malloc */ extern int rval; /* return value of a subprocess */ extern int overlap; /* line overlap in forw/back page */ @@ -69,8 +57,6 @@ extern int thisflag; /* Flags, this command */ extern int lastflag; /* Flags, last command */ extern int curgoal; /* Goal for C-P, C-N */ -extern struct window *curwp; /* Current window */ -extern struct window *wheadp; /* Head of list of windows */ extern char sres[NBUFN]; /* Current screen resolution. */ diff --git a/globals.c b/globals.c index 28eaef7..384aa55 100644 --- a/globals.c +++ b/globals.c @@ -25,10 +25,7 @@ int abortc = CONTROL | 'G'; /* current abort command char */ int tabmask = 0x07; /* tabulator mask */ -kbdstate kbdmode = STOP; /* current keyboard macro mode */ -int kbdrep = 0; /* number of repetitions */ int restflag = FALSE; /* restricted use? */ -int lastkey = 0; /* last keystoke */ long envram = 0l; /* # of bytes current in use by malloc */ int rval = 0; /* return value of a subprocess */ int overlap = 0; /* line overlap in forw/back page */ @@ -39,7 +36,5 @@ int scrollcount = 1; /* number of lines to scroll */ int thisflag; /* Flags, this command */ int lastflag; /* Flags, last command */ int curgoal; /* Goal for C-P, C-N */ -struct window *curwp; /* Current window */ -struct window *wheadp; /* Head of list of windows */ char sres[NBUFN]; /* current screen resolution */ diff --git a/input.c b/input.c index 16c17db..c40a5fd 100644 --- a/input.c +++ b/input.c @@ -38,6 +38,10 @@ int kbdm[ NKBDM] ; /* Macro */ int *kbdptr ; /* current position in keyboard buf */ int *kbdend = &kbdm[0] ; /* ptr to end of the keyboard */ +kbdstate kbdmode = STOP ; /* current keyboard macro mode */ +int lastkey = 0 ; /* last keystoke */ +int kbdrep = 0 ; /* number of repetitions */ + static const int quotec = 0x11 ; /* quote char during mlreply() */ /* diff --git a/input.h b/input.h index da12bba..1fc1aa9 100644 --- a/input.h +++ b/input.h @@ -3,6 +3,12 @@ #include "edef.h" +typedef enum { + STOP, PLAY, RECORD +} kbdstate ; +extern kbdstate kbdmode ; /* current keyboard macro mode */ +extern int lastkey ; /* last keystoke */ +extern int kbdrep ; /* number of repetitions */ extern int kbdm[] ; /* Holds kayboard macro data */ extern int *kbdptr ; /* current position in keyboard buf */ extern int *kbdend ; /* ptr to end of the keyboard */ diff --git a/window.c b/window.c index 288bb9e..dab5f8f 100644 --- a/window.c +++ b/window.c @@ -22,6 +22,9 @@ #include "wrapper.h" +struct window *curwp ; /* Current window */ +struct window *wheadp ; /* Head of list of windows */ + static struct window *swindow = NULL ; /* saved window pointer */ diff --git a/window.h b/window.h index 60d17b2..669d8e1 100644 --- a/window.h +++ b/window.h @@ -31,6 +31,9 @@ struct window { #endif }; +extern struct window *curwp ; /* Current window */ +extern struct window *wheadp ; /* Head of list of windows */ + #define WFFORCE 0x01 /* Window needs forced reframe */ #define WFMOVE 0x02 /* Movement from line to line */ #define WFEDIT 0x04 /* Editing within a line */ From bdeba62fcb7c350eb3b0e5d42d7d363e842a1deb Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 8 Oct 2013 18:01:15 +0800 Subject: [PATCH 148/193] Move fn_t type definition to bind.h. Review globals.c imports. --- Makefile | 32 ++++++++++++++++---------------- bind.h | 3 +++ edef.h | 3 --- globals.c | 1 - input.h | 3 ++- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 2fd24a3..f7fa3a6 100644 --- a/Makefile +++ b/Makefile @@ -128,19 +128,19 @@ depend: ${SRC} ansi.o: ansi.c estruct.h retcode.h edef.h buffer.h crypt.h line.h utf8.h basic.o: basic.c basic.h buffer.h crypt.h line.h utf8.h display.h \ - estruct.h retcode.h edef.h input.h random.h terminal.h defines.h \ + estruct.h retcode.h edef.h input.h bind.h random.h terminal.h defines.h \ window.h bindable.o: bindable.c bindable.h defines.h buffer.h crypt.h line.h \ - utf8.h display.h edef.h estruct.h retcode.h file.h input.h lock.h \ + utf8.h display.h edef.h estruct.h retcode.h file.h input.h bind.h lock.h \ terminal.h bind.o: bind.c bind.h edef.h buffer.h crypt.h line.h utf8.h estruct.h \ retcode.h bindable.h display.h ebind.h exec.h file.h flook.h input.h \ names.h window.h defines.h buffer.o: buffer.c buffer.h crypt.h line.h utf8.h defines.h display.h \ - edef.h estruct.h retcode.h file.h input.h window.h + edef.h estruct.h retcode.h file.h input.h bind.h window.h crypt.o: crypt.c crypt.h display.o: display.c display.h buffer.h crypt.h line.h utf8.h estruct.h \ - retcode.h edef.h input.h termio.h terminal.h defines.h version.h \ + retcode.h edef.h input.h bind.h termio.h terminal.h defines.h version.h \ wrapper.h window.h ebind.o: ebind.c ebind.h basic.h bind.h edef.h buffer.h crypt.h line.h \ utf8.h estruct.h retcode.h bindable.h eval.h exec.h file.h isearch.h \ @@ -155,23 +155,23 @@ execute.o: execute.c execute.h edef.h buffer.h crypt.h line.h utf8.h \ estruct.h retcode.h bind.h random.h display.h file.h terminal.h \ defines.h window.h file.o: file.c file.h crypt.h retcode.h buffer.h line.h utf8.h defines.h \ - estruct.h edef.h execute.h fileio.h input.h lock.h log.h window.h + estruct.h edef.h execute.h fileio.h input.h bind.h lock.h log.h window.h fileio.o: fileio.c fileio.h crypt.h retcode.h defines.h flook.o: flook.c flook.h retcode.h defines.h fileio.h crypt.h -globals.o: globals.c crypt.h defines.h edef.h buffer.h line.h utf8.h \ +globals.o: globals.c defines.h edef.h buffer.h crypt.h line.h utf8.h \ estruct.h retcode.h ibmpc.o: ibmpc.c estruct.h retcode.h edef.h buffer.h crypt.h line.h \ utf8.h -input.o: input.c input.h edef.h buffer.h crypt.h line.h utf8.h estruct.h \ - retcode.h bind.h bindable.h display.h exec.h names.h terminal.h \ +input.o: input.c input.h bind.h edef.h buffer.h crypt.h line.h utf8.h \ + estruct.h retcode.h bindable.h display.h exec.h names.h terminal.h \ defines.h wrapper.h isearch.o: isearch.c isearch.h basic.h buffer.h crypt.h line.h utf8.h \ - display.h estruct.h retcode.h edef.h input.h search.h terminal.h \ + display.h estruct.h retcode.h edef.h input.h bind.h search.h terminal.h \ defines.h window.h line.o: line.c line.h utf8.h buffer.h crypt.h edef.h estruct.h retcode.h \ log.h window.h defines.h lock.o: lock.c lock.h estruct.h retcode.h display.h edef.h buffer.h \ - crypt.h line.h utf8.h input.h + crypt.h line.h utf8.h input.h bind.h log.o: log.c log.h retcode.h main.o: main.c basic.h bind.h edef.h buffer.h crypt.h line.h utf8.h \ estruct.h retcode.h bindable.h display.h eval.h execute.h file.h input.h \ @@ -184,15 +184,15 @@ pklock.o: pklock.c pklock.h estruct.h retcode.h edef.h buffer.h crypt.h \ line.h utf8.h posix.o: posix.c termio.h random.o: random.c random.h basic.h buffer.h crypt.h line.h utf8.h \ - display.h estruct.h retcode.h edef.h execute.h input.h log.h search.h \ - terminal.h defines.h window.h + display.h estruct.h retcode.h edef.h execute.h input.h bind.h log.h \ + search.h terminal.h defines.h window.h region.o: region.c region.h line.h utf8.h buffer.h crypt.h estruct.h \ retcode.h edef.h log.h window.h defines.h search.o: search.c search.h line.h utf8.h basic.h buffer.h crypt.h \ - display.h edef.h estruct.h retcode.h input.h log.h terminal.h defines.h \ - window.h + display.h edef.h estruct.h retcode.h input.h bind.h log.h terminal.h \ + defines.h window.h spawn.o: spawn.c spawn.h defines.h buffer.h crypt.h line.h utf8.h \ - display.h estruct.h retcode.h edef.h file.h flook.h input.h log.h \ + display.h estruct.h retcode.h edef.h file.h flook.h input.h bind.h log.h \ terminal.h window.h tcap.o: tcap.c terminal.h defines.h display.h estruct.h retcode.h edef.h \ buffer.h crypt.h line.h utf8.h termio.h @@ -202,7 +202,7 @@ vmsvt.o: vmsvt.c estruct.h retcode.h edef.h buffer.h crypt.h line.h \ utf8.h vt52.o: vt52.c estruct.h retcode.h edef.h buffer.h crypt.h line.h utf8.h window.o: window.c window.h defines.h buffer.h crypt.h line.h utf8.h \ - basic.h display.h estruct.h retcode.h edef.h execute.h terminal.h \ + basic.h display.h edef.h estruct.h retcode.h execute.h terminal.h \ wrapper.h word.o: word.c word.h basic.h buffer.h crypt.h line.h utf8.h estruct.h \ retcode.h edef.h log.h random.h region.h window.h defines.h diff --git a/bind.h b/bind.h index 0314903..d8e1f4b 100644 --- a/bind.h +++ b/bind.h @@ -10,6 +10,9 @@ int apro( int f, int n) ; int strinc( char *source, char *sub) ; #endif +/* Some global fuction declarations. */ +typedef int (*fn_t)(int, int); + int help( int f, int n) ; int deskey( int f, int n) ; int bindtokey( int f, int n) ; diff --git a/edef.h b/edef.h index 66c6a9d..cb969f2 100644 --- a/edef.h +++ b/edef.h @@ -16,9 +16,6 @@ #include #include -/* Some global fuction declarations. */ -typedef int (*fn_t)(int, int); - /* Initialized global external declarations. */ extern int fillcol; /* Fill column */ diff --git a/globals.c b/globals.c index 384aa55..66274f6 100644 --- a/globals.c +++ b/globals.c @@ -1,4 +1,3 @@ -#include "crypt.h" #include "defines.h" /* #include "estruct.h" */ diff --git a/input.h b/input.h index 1fc1aa9..1dd1970 100644 --- a/input.h +++ b/input.h @@ -1,7 +1,8 @@ #ifndef _INPUT_H_ #define _INPUT_H_ -#include "edef.h" +#include "bind.h" + typedef enum { STOP, PLAY, RECORD From dc3e8984ab02766940410fc751a90c831171a902 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 9 Oct 2013 09:43:15 +0800 Subject: [PATCH 149/193] Move standard includes of stdlib and string from edef.h. --- basic.c | 1 + bind.c | 1 + bindable.c | 3 +++ buffer.c | 4 +++- display.c | 1 + ebind.c | 3 +++ edef.h | 3 --- eval.c | 2 ++ exec.c | 2 ++ execute.c | 2 ++ file.c | 1 + input.c | 1 + isearch.c | 1 + line.c | 2 ++ main.c | 2 ++ names.c | 2 ++ random.c | 1 + search.c | 2 ++ spawn.c | 2 ++ tcap.c | 3 +++ 20 files changed, 35 insertions(+), 4 deletions(-) diff --git a/basic.c b/basic.c index 0b5a1af..edbe6c2 100644 --- a/basic.c +++ b/basic.c @@ -14,6 +14,7 @@ */ #include +#include #include "buffer.h" #include "display.h" diff --git a/bind.c b/bind.c index a717fa5..bc373ca 100644 --- a/bind.c +++ b/bind.c @@ -11,6 +11,7 @@ */ #include +#include #include "bindable.h" #include "buffer.h" diff --git a/bindable.c b/bindable.c index ffd9116..10fa26c 100644 --- a/bindable.c +++ b/bindable.c @@ -1,6 +1,9 @@ /* bindable.h -- implements bindable.c */ #include "bindable.h" +#include + + #include "defines.h" #include "buffer.h" #include "display.h" diff --git a/buffer.c b/buffer.c index 8a752df..9712d12 100644 --- a/buffer.c +++ b/buffer.c @@ -12,7 +12,9 @@ * modified by Petri Kutvonen */ -#include +#include +#include +#include #include "defines.h" #include "display.h" diff --git a/display.c b/display.c index 604acfc..7296a8c 100644 --- a/display.c +++ b/display.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include "buffer.h" diff --git a/ebind.c b/ebind.c index c43ab92..98c1719 100644 --- a/ebind.c +++ b/ebind.c @@ -8,6 +8,9 @@ * Modified by Petri Kutvonen */ +#include + + #include "basic.h" #include "bind.h" #include "bindable.h" diff --git a/edef.h b/edef.h index cb969f2..57fdada 100644 --- a/edef.h +++ b/edef.h @@ -13,9 +13,6 @@ #include "buffer.h" #include "estruct.h" -#include -#include - /* Initialized global external declarations. */ extern int fillcol; /* Fill column */ diff --git a/eval.c b/eval.c index fcb2d2e..0bd9efa 100644 --- a/eval.c +++ b/eval.c @@ -10,6 +10,8 @@ */ #include +#include +#include #include "basic.h" #include "bind.h" diff --git a/exec.c b/exec.c index 662a2a6..734c246 100644 --- a/exec.c +++ b/exec.c @@ -11,6 +11,8 @@ */ #include +#include +#include #include "buffer.h" #include "bind.h" diff --git a/execute.c b/execute.c index 708a723..73ba632 100644 --- a/execute.c +++ b/execute.c @@ -1,6 +1,8 @@ /* execute.c -- implements execute.h */ #include "execute.h" +#include + #include "edef.h" #include "bind.h" #include "random.h" diff --git a/file.c b/file.c index 30a32c5..92a2301 100644 --- a/file.c +++ b/file.c @@ -12,6 +12,7 @@ */ #include +#include #include #include "buffer.h" diff --git a/input.c b/input.c index c40a5fd..37ed89a 100644 --- a/input.c +++ b/input.c @@ -11,6 +11,7 @@ */ #include +#include #include #include "bind.h" diff --git a/isearch.c b/isearch.c index 461b044..77d6ef4 100644 --- a/isearch.c +++ b/isearch.c @@ -25,6 +25,7 @@ */ #include +#include #include "basic.h" #include "buffer.h" diff --git a/line.c b/line.c index 252688b..2c60c2e 100644 --- a/line.c +++ b/line.c @@ -17,6 +17,8 @@ #include #include +#include +#include #include "buffer.h" #include "edef.h" diff --git a/main.c b/main.c index 6a71426..e0b29ad 100644 --- a/main.c +++ b/main.c @@ -56,6 +56,8 @@ */ #include +#include +#include #include "basic.h" #include "bind.h" diff --git a/names.c b/names.c index e451240..8736721 100644 --- a/names.c +++ b/names.c @@ -8,6 +8,8 @@ * function. */ +#include + #include "basic.h" #include "bind.h" #include "bindable.h" diff --git a/random.c b/random.c index 66ee779..3e445a3 100644 --- a/random.c +++ b/random.c @@ -10,6 +10,7 @@ */ #include +#include #include "basic.h" #include "buffer.h" diff --git a/search.c b/search.c index 897519a..4e46b50 100644 --- a/search.c +++ b/search.c @@ -61,6 +61,8 @@ */ #include +#include +#include #include "basic.h" #include "buffer.h" diff --git a/spawn.c b/spawn.c index 422fe62..b872801 100644 --- a/spawn.c +++ b/spawn.c @@ -9,6 +9,8 @@ */ #include +#include +#include #include #include "defines.h" diff --git a/tcap.c b/tcap.c index 45e3d4d..59310de 100644 --- a/tcap.c +++ b/tcap.c @@ -8,6 +8,9 @@ * modified by Petri Kutvonen */ +#include +#include + /* * Defining this to 1 breaks tcapopen() - it doesn't check if the * sceen size has changed. From 7573dcd2260c79138c24ab89dcebecd7a7aa9851 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 9 Oct 2013 10:48:00 +0800 Subject: [PATCH 150/193] Move edef.h out of bind.h and buffer.h out of edef.h. --- Makefile | 58 ++- bind.c | 839 +++++++++++++++++++++---------------------- bind.h | 2 - ebind.c | 795 ++++++++++++++++++++-------------------- edef.h | 1 - input.c | 1057 +++++++++++++++++++++++++++--------------------------- 6 files changed, 1373 insertions(+), 1379 deletions(-) diff --git a/Makefile b/Makefile index f7fa3a6..fa62477 100644 --- a/Makefile +++ b/Makefile @@ -126,15 +126,15 @@ depend: ${SRC} # DO NOT DELETE THIS LINE -- make depend uses it -ansi.o: ansi.c estruct.h retcode.h edef.h buffer.h crypt.h line.h utf8.h +ansi.o: ansi.c estruct.h retcode.h edef.h basic.o: basic.c basic.h buffer.h crypt.h line.h utf8.h display.h \ estruct.h retcode.h edef.h input.h bind.h random.h terminal.h defines.h \ window.h bindable.o: bindable.c bindable.h defines.h buffer.h crypt.h line.h \ utf8.h display.h edef.h estruct.h retcode.h file.h input.h bind.h lock.h \ terminal.h -bind.o: bind.c bind.h edef.h buffer.h crypt.h line.h utf8.h estruct.h \ - retcode.h bindable.h display.h ebind.h exec.h file.h flook.h input.h \ +bind.o: bind.c bind.h edef.h estruct.h retcode.h bindable.h buffer.h \ + crypt.h line.h utf8.h display.h ebind.h exec.h file.h flook.h input.h \ names.h window.h defines.h buffer.o: buffer.c buffer.h crypt.h line.h utf8.h defines.h display.h \ edef.h estruct.h retcode.h file.h input.h bind.h window.h @@ -142,46 +142,41 @@ crypt.o: crypt.c crypt.h display.o: display.c display.h buffer.h crypt.h line.h utf8.h estruct.h \ retcode.h edef.h input.h bind.h termio.h terminal.h defines.h version.h \ wrapper.h window.h -ebind.o: ebind.c ebind.h basic.h bind.h edef.h buffer.h crypt.h line.h \ - utf8.h estruct.h retcode.h bindable.h eval.h exec.h file.h isearch.h \ +ebind.o: ebind.c ebind.h basic.h bind.h edef.h estruct.h retcode.h \ + bindable.h buffer.h crypt.h line.h utf8.h eval.h exec.h file.h isearch.h \ random.h region.h search.h spawn.h window.h defines.h word.h -eval.o: eval.c eval.h basic.h bind.h edef.h buffer.h crypt.h line.h \ - utf8.h estruct.h retcode.h display.h exec.h execute.h flook.h input.h \ +eval.o: eval.c eval.h basic.h bind.h buffer.h crypt.h line.h utf8.h \ + display.h estruct.h retcode.h edef.h exec.h execute.h flook.h input.h \ random.h search.h terminal.h defines.h termio.h version.h window.h -exec.o: exec.c exec.h buffer.h crypt.h line.h utf8.h bind.h edef.h \ - estruct.h retcode.h display.h eval.h file.h flook.h input.h window.h \ +exec.o: exec.c exec.h buffer.h crypt.h line.h utf8.h bind.h display.h \ + estruct.h retcode.h edef.h eval.h file.h flook.h input.h window.h \ defines.h -execute.o: execute.c execute.h edef.h buffer.h crypt.h line.h utf8.h \ - estruct.h retcode.h bind.h random.h display.h file.h terminal.h \ - defines.h window.h +execute.o: execute.c execute.h edef.h estruct.h retcode.h bind.h random.h \ + display.h file.h crypt.h buffer.h line.h utf8.h terminal.h defines.h \ + window.h file.o: file.c file.h crypt.h retcode.h buffer.h line.h utf8.h defines.h \ estruct.h edef.h execute.h fileio.h input.h bind.h lock.h log.h window.h fileio.o: fileio.c fileio.h crypt.h retcode.h defines.h flook.o: flook.c flook.h retcode.h defines.h fileio.h crypt.h -globals.o: globals.c defines.h edef.h buffer.h crypt.h line.h utf8.h \ - estruct.h retcode.h -ibmpc.o: ibmpc.c estruct.h retcode.h edef.h buffer.h crypt.h line.h \ - utf8.h -input.o: input.c input.h bind.h edef.h buffer.h crypt.h line.h utf8.h \ - estruct.h retcode.h bindable.h display.h exec.h names.h terminal.h \ - defines.h wrapper.h +globals.o: globals.c defines.h edef.h estruct.h retcode.h +ibmpc.o: ibmpc.c estruct.h retcode.h edef.h +input.o: input.c input.h bind.h edef.h estruct.h retcode.h bindable.h \ + display.h exec.h names.h terminal.h defines.h wrapper.h isearch.o: isearch.c isearch.h basic.h buffer.h crypt.h line.h utf8.h \ display.h estruct.h retcode.h edef.h input.h bind.h search.h terminal.h \ defines.h window.h line.o: line.c line.h utf8.h buffer.h crypt.h edef.h estruct.h retcode.h \ log.h window.h defines.h -lock.o: lock.c lock.h estruct.h retcode.h display.h edef.h buffer.h \ - crypt.h line.h utf8.h input.h bind.h +lock.o: lock.c lock.h estruct.h retcode.h display.h edef.h input.h bind.h log.o: log.c log.h retcode.h -main.o: main.c basic.h bind.h edef.h buffer.h crypt.h line.h utf8.h \ - estruct.h retcode.h bindable.h display.h eval.h execute.h file.h input.h \ +main.o: main.c basic.h bind.h bindable.h buffer.h crypt.h line.h utf8.h \ + display.h edef.h estruct.h retcode.h eval.h execute.h file.h input.h \ lock.h log.h random.h search.h terminal.h defines.h termio.h version.h \ window.h -names.o: names.c names.h basic.h bind.h edef.h buffer.h crypt.h line.h \ - utf8.h estruct.h retcode.h bindable.h display.h eval.h exec.h file.h \ - isearch.h region.h random.h search.h spawn.h window.h defines.h word.h -pklock.o: pklock.c pklock.h estruct.h retcode.h edef.h buffer.h crypt.h \ - line.h utf8.h +names.o: names.c names.h basic.h bind.h bindable.h buffer.h crypt.h \ + line.h utf8.h display.h eval.h exec.h file.h retcode.h isearch.h \ + region.h random.h search.h spawn.h window.h defines.h word.h +pklock.o: pklock.c pklock.h estruct.h retcode.h edef.h posix.o: posix.c termio.h random.o: random.c random.h basic.h buffer.h crypt.h line.h utf8.h \ display.h estruct.h retcode.h edef.h execute.h input.h bind.h log.h \ @@ -195,12 +190,11 @@ spawn.o: spawn.c spawn.h defines.h buffer.h crypt.h line.h utf8.h \ display.h estruct.h retcode.h edef.h file.h flook.h input.h bind.h log.h \ terminal.h window.h tcap.o: tcap.c terminal.h defines.h display.h estruct.h retcode.h edef.h \ - buffer.h crypt.h line.h utf8.h termio.h + termio.h termio.o: termio.c termio.h estruct.h retcode.h utf8.h utf8.o: utf8.c utf8.h -vmsvt.o: vmsvt.c estruct.h retcode.h edef.h buffer.h crypt.h line.h \ - utf8.h -vt52.o: vt52.c estruct.h retcode.h edef.h buffer.h crypt.h line.h utf8.h +vmsvt.o: vmsvt.c estruct.h retcode.h edef.h +vt52.o: vt52.c estruct.h retcode.h edef.h window.o: window.c window.h defines.h buffer.h crypt.h line.h utf8.h \ basic.h display.h edef.h estruct.h retcode.h execute.h terminal.h \ wrapper.h diff --git a/bind.c b/bind.c index bc373ca..b88b51c 100644 --- a/bind.c +++ b/bind.c @@ -1,18 +1,19 @@ /* bind.c -- implements bind.h */ #include "bind.h" -/* bind.c +/* bind.c * - * This file is for functions having to do with key bindings, - * descriptions, help commands and startup file. + * This file is for functions having to do with key bindings, + * descriptions, help commands and startup file. * - * Written 11-feb-86 by Daniel Lawrence - * Modified by Petri Kutvonen + * Written 11-feb-86 by Daniel Lawrence + * Modified by Petri Kutvonen */ #include #include +#include "edef.h" #include "bindable.h" #include "buffer.h" #include "display.h" @@ -29,232 +30,232 @@ static char *getfname( fn_t) ; int help(int f, int n) -{ /* give me some help!!!! - bring up a fake buffer and read the help file - into it with view mode */ - struct window *wp; /* scaning pointer to windows */ - struct buffer *bp; /* buffer pointer to help */ - char *fname = NULL; /* ptr to file returned by flook() */ +{ /* give me some help!!!! + bring up a fake buffer and read the help file + into it with view mode */ + struct window *wp; /* scaning pointer to windows */ + struct buffer *bp; /* buffer pointer to help */ + char *fname = NULL; /* ptr to file returned by flook() */ - /* first check if we are already here */ - bp = bfind( hlpfname, FALSE, BFINVS); + /* first check if we are already here */ + bp = bfind( hlpfname, FALSE, BFINVS); - if (bp == NULL) { - fname = flook( hlpfname, FALSE); - if (fname == NULL) { - mlwrite("(Help file is not online)"); - return FALSE; - } - } + if (bp == NULL) { + fname = flook( hlpfname, FALSE); + if (fname == NULL) { + mlwrite("(Help file is not online)"); + return FALSE; + } + } - /* split the current window to make room for the help stuff */ - if (splitwind(FALSE, 1) == FALSE) - return FALSE; + /* split the current window to make room for the help stuff */ + if (splitwind(FALSE, 1) == FALSE) + return FALSE; - if (bp == NULL) { - /* and read the stuff in */ - if (getfile(fname, FALSE) == FALSE) - return FALSE; - } else - swbuffer(bp); + if (bp == NULL) { + /* and read the stuff in */ + if (getfile(fname, FALSE) == FALSE) + return FALSE; + } else + swbuffer(bp); - /* make this window in VIEW mode, update all mode lines */ - curwp->w_bufp->b_mode |= MDVIEW; - curwp->w_bufp->b_flag |= BFINVS; - wp = wheadp; - while (wp != NULL) { - wp->w_flag |= WFMODE; - wp = wp->w_wndp; - } - return TRUE; + /* make this window in VIEW mode, update all mode lines */ + curwp->w_bufp->b_mode |= MDVIEW; + curwp->w_bufp->b_flag |= BFINVS; + wp = wheadp; + while (wp != NULL) { + wp->w_flag |= WFMODE; + wp = wp->w_wndp; + } + return TRUE; } int deskey(int f, int n) -{ /* describe the command for a certain key */ - int c; /* key to describe */ - char *ptr; /* string pointer to scan output strings */ - char outseq[NSTRING]; /* output buffer for command sequence */ +{ /* describe the command for a certain key */ + int c; /* key to describe */ + char *ptr; /* string pointer to scan output strings */ + char outseq[NSTRING]; /* output buffer for command sequence */ - /* prompt the user to type us a key to describe */ - mlwrite(": describe-key "); + /* prompt the user to type us a key to describe */ + mlwrite(": describe-key "); - /* get the command sequence to describe - change it to something we can print as well */ - cmdstr(c = getckey(FALSE), &outseq[0]); + /* get the command sequence to describe + change it to something we can print as well */ + cmdstr(c = getckey(FALSE), &outseq[0]); - /* and dump it out */ - ostring(outseq); - ostring(" "); + /* and dump it out */ + ostring(outseq); + ostring(" "); - /* find the right ->function */ - if ((ptr = getfname(getbind(c))) == NULL) - ptr = "Not Bound"; + /* find the right ->function */ + if ((ptr = getfname(getbind(c))) == NULL) + ptr = "Not Bound"; - /* output the command sequence */ - ostring(ptr); - return TRUE; + /* output the command sequence */ + ostring(ptr); + return TRUE; } /* * bindtokey: - * add a new key to the key binding table + * add a new key to the key binding table * - * int f, n; command arguments [IGNORED] + * int f, n; command arguments [IGNORED] */ int bindtokey(int f, int n) { - unsigned int c; /* command key to bind */ - fn_t kfunc; /* ptr to the requested function to bind to */ - struct key_tab *ktp; /* pointer into the command table */ - int found; /* matched command flag */ - char outseq[80]; /* output buffer for keystroke sequence */ + unsigned int c; /* command key to bind */ + fn_t kfunc; /* ptr to the requested function to bind to */ + struct key_tab *ktp; /* pointer into the command table */ + int found; /* matched command flag */ + char outseq[80]; /* output buffer for keystroke sequence */ - /* prompt the user to type in a key to bind */ - mlwrite(": bind-to-key "); + /* prompt the user to type in a key to bind */ + mlwrite(": bind-to-key "); - /* get the function name to bind it to */ - kfunc = getname(); - if (kfunc == NULL) { - mlwrite("(No such function)"); - return FALSE; - } - ostring(" "); + /* get the function name to bind it to */ + kfunc = getname(); + if (kfunc == NULL) { + mlwrite("(No such function)"); + return FALSE; + } + ostring(" "); - /* get the command sequence to bind */ - c = getckey((kfunc == metafn) || (kfunc == cex) || - (kfunc == unarg) || (kfunc == ctrlg)); + /* get the command sequence to bind */ + c = getckey((kfunc == metafn) || (kfunc == cex) || + (kfunc == unarg) || (kfunc == ctrlg)); - /* change it to something we can print as well */ - cmdstr(c, &outseq[0]); + /* change it to something we can print as well */ + cmdstr(c, &outseq[0]); - /* and dump it out */ - ostring(outseq); + /* and dump it out */ + ostring(outseq); - /* if the function is a prefix key */ - if (kfunc == metafn || kfunc == cex || - kfunc == unarg || kfunc == ctrlg) { + /* if the function is a prefix key */ + if (kfunc == metafn || kfunc == cex || + kfunc == unarg || kfunc == ctrlg) { - /* search for an existing binding for the prefix key */ - ktp = &keytab[0]; - found = FALSE; - while (ktp->k_fp != NULL) { - if (ktp->k_fp == kfunc) - unbindchar(ktp->k_code); - ++ktp; - } + /* search for an existing binding for the prefix key */ + ktp = &keytab[0]; + found = FALSE; + while (ktp->k_fp != NULL) { + if (ktp->k_fp == kfunc) + unbindchar(ktp->k_code); + ++ktp; + } - /* reset the appropriate global prefix variable */ - if (kfunc == metafn) - metac = c; - if (kfunc == cex) - ctlxc = c; - if (kfunc == unarg) - reptc = c; - if (kfunc == ctrlg) - abortc = c; - } + /* reset the appropriate global prefix variable */ + if (kfunc == metafn) + metac = c; + if (kfunc == cex) + ctlxc = c; + if (kfunc == unarg) + reptc = c; + if (kfunc == ctrlg) + abortc = c; + } - /* search the table to see if it exists */ - ktp = &keytab[0]; - found = FALSE; - while (ktp->k_fp != NULL) { - if (ktp->k_code == c) { - found = TRUE; - break; - } - ++ktp; - } + /* search the table to see if it exists */ + ktp = &keytab[0]; + found = FALSE; + while (ktp->k_fp != NULL) { + if (ktp->k_code == c) { + found = TRUE; + break; + } + ++ktp; + } - if (found) { /* it exists, just change it then */ - ktp->k_fp = kfunc; - } else { /* otherwise we need to add it to the end */ - /* if we run out of binding room, bitch */ - if (ktp >= &keytab[NBINDS]) { - mlwrite("Binding table FULL!"); - return FALSE; - } + if (found) { /* it exists, just change it then */ + ktp->k_fp = kfunc; + } else { /* otherwise we need to add it to the end */ + /* if we run out of binding room, bitch */ + if (ktp >= &keytab[NBINDS]) { + mlwrite("Binding table FULL!"); + return FALSE; + } - ktp->k_code = c; /* add keycode */ - ktp->k_fp = kfunc; /* and the function pointer */ - ++ktp; /* and make sure the next is null */ - ktp->k_code = 0; - ktp->k_fp = NULL; - } - return TRUE; + ktp->k_code = c; /* add keycode */ + ktp->k_fp = kfunc; /* and the function pointer */ + ++ktp; /* and make sure the next is null */ + ktp->k_code = 0; + ktp->k_fp = NULL; + } + return TRUE; } /* * unbindkey: - * delete a key from the key binding table + * delete a key from the key binding table * - * int f, n; command arguments [IGNORED] + * int f, n; command arguments [IGNORED] */ int unbindkey(int f, int n) { - int c; /* command key to unbind */ - char outseq[80]; /* output buffer for keystroke sequence */ + int c; /* command key to unbind */ + char outseq[80]; /* output buffer for keystroke sequence */ - /* prompt the user to type in a key to unbind */ - mlwrite(": unbind-key "); + /* prompt the user to type in a key to unbind */ + mlwrite(": unbind-key "); - /* get the command sequence to unbind */ - c = getckey(FALSE); /* get a command sequence */ + /* get the command sequence to unbind */ + c = getckey(FALSE); /* get a command sequence */ - /* change it to something we can print as well */ - cmdstr(c, &outseq[0]); + /* change it to something we can print as well */ + cmdstr(c, &outseq[0]); - /* and dump it out */ - ostring(outseq); + /* and dump it out */ + ostring(outseq); - /* if it isn't bound, bitch */ - if (unbindchar(c) == FALSE) { - mlwrite("(Key not bound)"); - return FALSE; - } - return TRUE; + /* if it isn't bound, bitch */ + if (unbindchar(c) == FALSE) { + mlwrite("(Key not bound)"); + return FALSE; + } + return TRUE; } /* * unbindchar() * - * int c; command key to unbind + * int c; command key to unbind */ int unbindchar(int c) { - struct key_tab *ktp; /* pointer into the command table */ - struct key_tab *sktp; /* saved pointer into the command table */ - int found; /* matched command flag */ + struct key_tab *ktp; /* pointer into the command table */ + struct key_tab *sktp; /* saved pointer into the command table */ + int found; /* matched command flag */ - /* search the table to see if the key exists */ - ktp = &keytab[0]; - found = FALSE; - while (ktp->k_fp != NULL) { - if (ktp->k_code == c) { - found = TRUE; - break; - } - ++ktp; - } + /* search the table to see if the key exists */ + ktp = &keytab[0]; + found = FALSE; + while (ktp->k_fp != NULL) { + if (ktp->k_code == c) { + found = TRUE; + break; + } + ++ktp; + } - /* if it isn't bound, bitch */ - if (!found) - return FALSE; + /* if it isn't bound, bitch */ + if (!found) + return FALSE; - /* save the pointer and scan to the end of the table */ - sktp = ktp; - while (ktp->k_fp != NULL) - ++ktp; - --ktp; /* backup to the last legit entry */ + /* save the pointer and scan to the end of the table */ + sktp = ktp; + while (ktp->k_fp != NULL) + ++ktp; + --ktp; /* backup to the last legit entry */ - /* copy the last entry to the current one */ - sktp->k_code = ktp->k_code; - sktp->k_fp = ktp->k_fp; + /* copy the last entry to the current one */ + sktp->k_code = ktp->k_code; + sktp->k_fp = ktp->k_fp; - /* null out the last one */ - ktp->k_code = 0; - ktp->k_fp = NULL; - return TRUE; + /* null out the last one */ + ktp->k_code = 0; + ktp->k_fp = NULL; + return TRUE; } /* describe bindings @@ -262,386 +263,386 @@ int unbindchar(int c) * into it with view mode */ int desbind(int f, int n) -#if APROP +#if APROP { - buildlist(TRUE, ""); - return TRUE; + buildlist(TRUE, ""); + return TRUE; } int apro(int f, int n) -{ /* Apropos (List functions that match a substring) */ - char mstring[NSTRING]; /* string to match cmd names to */ - int status; /* status return */ +{ /* Apropos (List functions that match a substring) */ + char mstring[NSTRING]; /* string to match cmd names to */ + int status; /* status return */ - status = mlreply("Apropos string: ", mstring, NSTRING - 1); - if (status != TRUE) - return status; + status = mlreply("Apropos string: ", mstring, NSTRING - 1); + if (status != TRUE) + return status; - return buildlist(FALSE, mstring); + return buildlist(FALSE, mstring); } /* * build a binding list (limited or full) * - * int type; true = full list, false = partial list - * char *mstring; match string if a partial list + * int type; true = full list, false = partial list + * char *mstring; match string if a partial list */ int buildlist(int type, char *mstring) #endif { - struct window *wp; /* scanning pointer to windows */ - struct key_tab *ktp; /* pointer into the command table */ - struct name_bind *nptr; /* pointer into the name binding table */ - struct buffer *bp; /* buffer to put binding list into */ - int cpos; /* current position to use in outseq */ - char outseq[80]; /* output buffer for keystroke sequence */ + struct window *wp; /* scanning pointer to windows */ + struct key_tab *ktp; /* pointer into the command table */ + struct name_bind *nptr; /* pointer into the name binding table */ + struct buffer *bp; /* buffer to put binding list into */ + int cpos; /* current position to use in outseq */ + char outseq[80]; /* output buffer for keystroke sequence */ - /* split the current window to make room for the binding list */ - if (splitwind(FALSE, 1) == FALSE) - return FALSE; + /* split the current window to make room for the binding list */ + if (splitwind(FALSE, 1) == FALSE) + return FALSE; - /* and get a buffer for it */ - bp = bfind("*Binding list*", TRUE, 0); - if (bp == NULL || bclear(bp) == FALSE) { - mlwrite("Can not display binding list"); - return FALSE; - } + /* and get a buffer for it */ + bp = bfind("*Binding list*", TRUE, 0); + if (bp == NULL || bclear(bp) == FALSE) { + mlwrite("Can not display binding list"); + return FALSE; + } - /* let us know this is in progress */ - mlwrite("(Building binding list)"); + /* let us know this is in progress */ + mlwrite("(Building binding list)"); - /* disconect the current buffer */ - if (--curbp->b_nwnd == 0) { /* Last use. */ - curbp->b_dotp = curwp->w_dotp; - curbp->b_doto = curwp->w_doto; - curbp->b_markp = curwp->w_markp; - curbp->b_marko = curwp->w_marko; - } + /* disconect the current buffer */ + if (--curbp->b_nwnd == 0) { /* Last use. */ + curbp->b_dotp = curwp->w_dotp; + curbp->b_doto = curwp->w_doto; + curbp->b_markp = curwp->w_markp; + curbp->b_marko = curwp->w_marko; + } - /* connect the current window to this buffer */ - curbp = bp; /* make this buffer current in current window */ - bp->b_mode = 0; /* no modes active in binding list */ - bp->b_nwnd++; /* mark us as more in use */ - wp = curwp; - wp->w_bufp = bp; - wp->w_linep = bp->b_linep; - wp->w_flag = WFHARD | WFFORCE; - wp->w_dotp = bp->b_dotp; - wp->w_doto = bp->b_doto; - wp->w_markp = NULL; - wp->w_marko = 0; + /* connect the current window to this buffer */ + curbp = bp; /* make this buffer current in current window */ + bp->b_mode = 0; /* no modes active in binding list */ + bp->b_nwnd++; /* mark us as more in use */ + wp = curwp; + wp->w_bufp = bp; + wp->w_linep = bp->b_linep; + wp->w_flag = WFHARD | WFFORCE; + wp->w_dotp = bp->b_dotp; + wp->w_doto = bp->b_doto; + wp->w_markp = NULL; + wp->w_marko = 0; - /* build the contents of this window, inserting it line by line */ - nptr = &names[0]; - while (nptr->n_func != NULL) { + /* build the contents of this window, inserting it line by line */ + nptr = &names[0]; + while (nptr->n_func != NULL) { - /* add in the command name */ - strcpy(outseq, nptr->n_name); - cpos = strlen(outseq); + /* add in the command name */ + strcpy(outseq, nptr->n_name); + cpos = strlen(outseq); -#if APROP - /* if we are executing an apropos command..... */ - if (type == FALSE && - /* and current string doesn't include the search string */ - strinc(outseq, mstring) == FALSE) - goto fail; +#if APROP + /* if we are executing an apropos command..... */ + if (type == FALSE && + /* and current string doesn't include the search string */ + strinc(outseq, mstring) == FALSE) + goto fail; #endif - /* search down any keys bound to this */ - ktp = &keytab[0]; - while (ktp->k_fp != NULL) { - if (ktp->k_fp == nptr->n_func) { - /* padd out some spaces */ - while (cpos < 28) - outseq[cpos++] = ' '; + /* search down any keys bound to this */ + ktp = &keytab[0]; + while (ktp->k_fp != NULL) { + if (ktp->k_fp == nptr->n_func) { + /* padd out some spaces */ + while (cpos < 28) + outseq[cpos++] = ' '; - /* add in the command sequence */ - cmdstr(ktp->k_code, &outseq[cpos]); - strcat(outseq, "\n"); + /* add in the command sequence */ + cmdstr(ktp->k_code, &outseq[cpos]); + strcat(outseq, "\n"); - /* and add it as a line into the buffer */ - if (linstr(outseq) != TRUE) - return FALSE; + /* and add it as a line into the buffer */ + if (linstr(outseq) != TRUE) + return FALSE; - cpos = 0; /* and clear the line */ - } - ++ktp; - } + cpos = 0; /* and clear the line */ + } + ++ktp; + } - /* if no key was bound, we need to dump it anyway */ - if (cpos > 0) { - outseq[cpos++] = '\n'; - outseq[cpos] = 0; - if (linstr(outseq) != TRUE) - return FALSE; - } + /* if no key was bound, we need to dump it anyway */ + if (cpos > 0) { + outseq[cpos++] = '\n'; + outseq[cpos] = 0; + if (linstr(outseq) != TRUE) + return FALSE; + } - fail: /* and on to the next name */ - ++nptr; - } + fail: /* and on to the next name */ + ++nptr; + } - curwp->w_bufp->b_mode |= MDVIEW; /* put this buffer view mode */ - curbp->b_flag &= ~BFCHG; /* don't flag this as a change */ - wp->w_dotp = lforw(bp->b_linep); /* back to the beginning */ - wp->w_doto = 0; - wp = wheadp; /* and update ALL mode lines */ - while (wp != NULL) { - wp->w_flag |= WFMODE; - wp = wp->w_wndp; - } - mlwrite(""); /* clear the mode line */ - return TRUE; + curwp->w_bufp->b_mode |= MDVIEW; /* put this buffer view mode */ + curbp->b_flag &= ~BFCHG; /* don't flag this as a change */ + wp->w_dotp = lforw(bp->b_linep); /* back to the beginning */ + wp->w_doto = 0; + wp = wheadp; /* and update ALL mode lines */ + while (wp != NULL) { + wp->w_flag |= WFMODE; + wp = wp->w_wndp; + } + mlwrite(""); /* clear the mode line */ + return TRUE; } -#if APROP +#if APROP /* * does source include sub? * - * char *source; string to search in - * char *sub; substring to look for + * char *source; string to search in + * char *sub; substring to look for */ int strinc(char *source, char *sub) { - char *sp; /* ptr into source */ - char *nxtsp; /* next ptr into source */ - char *tp; /* ptr into substring */ + char *sp; /* ptr into source */ + char *nxtsp; /* next ptr into source */ + char *tp; /* ptr into substring */ - /* for each character in the source string */ - sp = source; - while (*sp) { - tp = sub; - nxtsp = sp; + /* for each character in the source string */ + sp = source; + while (*sp) { + tp = sub; + nxtsp = sp; - /* is the substring here? */ - while (*tp) { - if (*nxtsp++ != *tp) - break; - else - tp++; - } + /* is the substring here? */ + while (*tp) { + if (*nxtsp++ != *tp) + break; + else + tp++; + } - /* yes, return a success */ - if (*tp == 0) - return TRUE; + /* yes, return a success */ + if (*tp == 0) + return TRUE; - /* no, onward */ - sp++; - } - return FALSE; + /* no, onward */ + sp++; + } + return FALSE; } #endif /* * get a command key sequence from the keyboard * - * int mflag; going for a meta sequence? + * int mflag; going for a meta sequence? */ unsigned int getckey(int mflag) { - unsigned int c; /* character fetched */ - char tok[NSTRING]; /* command incoming */ + unsigned int c; /* character fetched */ + char tok[NSTRING]; /* command incoming */ - /* check to see if we are executing a command line */ - if (clexec) { - macarg(tok); /* get the next token */ - return stock(tok); - } + /* check to see if we are executing a command line */ + if (clexec) { + macarg(tok); /* get the next token */ + return stock(tok); + } - /* or the normal way */ - if (mflag) - c = get1key(); - else - c = getcmd(); - return c; + /* or the normal way */ + if (mflag) + c = get1key(); + else + c = getcmd(); + return c; } /* * execute the startup file * - * char *sfname; name of startup file (null if default) + * char *sfname; name of startup file (null if default) */ int startup(char *sfname) { - char *fname; /* resulting file name to execute */ + char *fname; /* resulting file name to execute */ - /* look up the startup file */ - if (*sfname != 0) - fname = flook(sfname, TRUE); - else - fname = flook( rcfname, TRUE); + /* look up the startup file */ + if (*sfname != 0) + fname = flook(sfname, TRUE); + else + fname = flook( rcfname, TRUE); - /* if it isn't around, don't sweat it */ - if (fname == NULL) - return TRUE; + /* if it isn't around, don't sweat it */ + if (fname == NULL) + return TRUE; - /* otherwise, execute the sucker */ - return dofile(fname); + /* otherwise, execute the sucker */ + return dofile(fname); } /* * change a key command to a string we can print out * - * int c; sequence to translate - * char *seq; destination string for sequence + * int c; sequence to translate + * char *seq; destination string for sequence */ void cmdstr(int c, char *seq) { - char *ptr; /* pointer into current position in sequence */ + char *ptr; /* pointer into current position in sequence */ - ptr = seq; + ptr = seq; - /* apply meta sequence if needed */ - if (c & META) { - *ptr++ = 'M'; - *ptr++ = '-'; - } + /* apply meta sequence if needed */ + if (c & META) { + *ptr++ = 'M'; + *ptr++ = '-'; + } - /* apply ^X sequence if needed */ - if (c & CTLX) { - *ptr++ = '^'; - *ptr++ = 'X'; - } + /* apply ^X sequence if needed */ + if (c & CTLX) { + *ptr++ = '^'; + *ptr++ = 'X'; + } - /* apply SPEC sequence if needed */ - if (c & SPEC) { - *ptr++ = 'F'; - *ptr++ = 'N'; - } + /* apply SPEC sequence if needed */ + if (c & SPEC) { + *ptr++ = 'F'; + *ptr++ = 'N'; + } - /* apply control sequence if needed */ - if (c & CONTROL) { - *ptr++ = '^'; - } + /* apply control sequence if needed */ + if (c & CONTROL) { + *ptr++ = '^'; + } - /* and output the final sequence */ + /* and output the final sequence */ - *ptr++ = c & 255; /* strip the prefixes */ + *ptr++ = c & 255; /* strip the prefixes */ - *ptr = 0; /* terminate the string */ + *ptr = 0; /* terminate the string */ } /* * This function looks a key binding up in the binding table * - * int c; key to find what is bound to it + * int c; key to find what is bound to it */ int (*getbind(int c))(int, int) { - struct key_tab *ktp; + struct key_tab *ktp; - ktp = &keytab[0]; /* Look in key table. */ - while (ktp->k_fp != NULL) { - if (ktp->k_code == c) - return ktp->k_fp; - ++ktp; - } + ktp = &keytab[0]; /* Look in key table. */ + while (ktp->k_fp != NULL) { + if (ktp->k_code == c) + return ktp->k_fp; + ++ktp; + } - /* no such binding */ - return NULL; + /* no such binding */ + return NULL; } /* * getfname: - * This function takes a ptr to function and gets the name - * associated with it. + * This function takes a ptr to function and gets the name + * associated with it. */ static char *getfname(fn_t func) { - struct name_bind *nptr; /* pointer into the name binding table */ + struct name_bind *nptr; /* pointer into the name binding table */ - /* skim through the table, looking for a match */ - nptr = &names[0]; - while (nptr->n_func != NULL) { - if (nptr->n_func == func) - return nptr->n_name; - ++nptr; - } - return NULL; + /* skim through the table, looking for a match */ + nptr = &names[0]; + while (nptr->n_func != NULL) { + if (nptr->n_func == func) + return nptr->n_name; + ++nptr; + } + return NULL; } /* * match fname to a function in the names table * and return any match or NULL if none * - * char *fname; name to attempt to match + * char *fname; name to attempt to match */ int (*fncmatch(char *fname)) (int, int) { - struct name_bind *ffp; /* pointer to entry in name binding table */ + struct name_bind *ffp; /* pointer to entry in name binding table */ - /* scan through the table, returning any match */ - ffp = &names[0]; - while (ffp->n_func != NULL) { - if (strcmp(fname, ffp->n_name) == 0) - return ffp->n_func; - ++ffp; - } - return NULL; + /* scan through the table, returning any match */ + ffp = &names[0]; + while (ffp->n_func != NULL) { + if (strcmp(fname, ffp->n_name) == 0) + return ffp->n_func; + ++ffp; + } + return NULL; } /* * stock: - * String key name TO Command Key + * String key name TO Command Key * - * char *keyname; name of key to translate to Command key form + * char *keyname; name of key to translate to Command key form */ unsigned int stock(char *keyname) { - unsigned int c; /* key sequence to return */ + unsigned int c; /* key sequence to return */ - /* parse it up */ - c = 0; + /* parse it up */ + c = 0; - /* first, the META prefix */ - if (*keyname == 'M' && *(keyname + 1) == '-') { - c = META; - keyname += 2; - } + /* first, the META prefix */ + if (*keyname == 'M' && *(keyname + 1) == '-') { + c = META; + keyname += 2; + } - /* next the function prefix */ - if (*keyname == 'F' && *(keyname + 1) == 'N') { - c |= SPEC; - keyname += 2; - } + /* next the function prefix */ + if (*keyname == 'F' && *(keyname + 1) == 'N') { + c |= SPEC; + keyname += 2; + } - /* control-x as well... (but not with FN) */ - if (*keyname == '^' && *(keyname + 1) == 'X' && !(c & SPEC)) { - c |= CTLX; - keyname += 2; - } + /* control-x as well... (but not with FN) */ + if (*keyname == '^' && *(keyname + 1) == 'X' && !(c & SPEC)) { + c |= CTLX; + keyname += 2; + } - /* a control char? */ - if (*keyname == '^' && *(keyname + 1) != 0) { - c |= CONTROL; - ++keyname; - } - if (*keyname < 32) { - c |= CONTROL; - *keyname += 'A'; - } + /* a control char? */ + if (*keyname == '^' && *(keyname + 1) != 0) { + c |= CONTROL; + ++keyname; + } + if (*keyname < 32) { + c |= CONTROL; + *keyname += 'A'; + } - /* make sure we are not lower case (not with function keys) */ - if (*keyname >= 'a' && *keyname <= 'z' && !(c & SPEC)) - *keyname -= 32; + /* make sure we are not lower case (not with function keys) */ + if (*keyname >= 'a' && *keyname <= 'z' && !(c & SPEC)) + *keyname -= 32; - /* the final sequence... */ - c |= *keyname; - return c; + /* the final sequence... */ + c |= *keyname; + return c; } /* * string key name to binding name.... * - * char *skey; name of keey to get binding for + * char *skey; name of keey to get binding for */ char *transbind(char *skey) { - char *bindname; + char *bindname; - bindname = getfname(getbind(stock(skey))); - if (bindname == NULL) - bindname = "ERROR"; + bindname = getfname(getbind(stock(skey))); + if (bindname == NULL) + bindname = "ERROR"; - return bindname; + return bindname; } diff --git a/bind.h b/bind.h index d8e1f4b..3e4c569 100644 --- a/bind.h +++ b/bind.h @@ -1,8 +1,6 @@ #ifndef _BIND_H_ #define _BIND_H_ -#include "edef.h" - #define APROP 1 /* Add code for Apropos command */ #if APROP diff --git a/ebind.c b/ebind.c index 98c1719..7af8614 100644 --- a/ebind.c +++ b/ebind.c @@ -1,11 +1,11 @@ /* ebind.c -- implements ebind.h */ #include "ebind.h" -/* ebind.c +/* ebind.c * - * Initial default key to function bindings + * Initial default key to function bindings * - * Modified by Petri Kutvonen + * Modified by Petri Kutvonen */ #include @@ -13,6 +13,7 @@ #include "basic.h" #include "bind.h" +#include "edef.h" #include "bindable.h" #include "buffer.h" #include "eval.h" @@ -34,407 +35,407 @@ * control-X commands. */ struct key_tab keytab[NBINDS] = { - {CONTROL | 'A', gotobol} - , - {CONTROL | 'B', backchar} - , - {CONTROL | 'C', insspace} - , - {CONTROL | 'D', forwdel} - , - {CONTROL | 'E', gotoeol} - , - {CONTROL | 'F', forwchar} - , - {CONTROL | 'G', ctrlg} - , - {CONTROL | 'H', backdel} - , - {CONTROL | 'I', insert_tab} - , - {CONTROL | 'J', indent} - , - {CONTROL | 'K', killtext} - , - {CONTROL | 'L', redraw} - , - {CONTROL | 'M', insert_newline} - , - {CONTROL | 'N', forwline} - , - {CONTROL | 'O', openline} - , - {CONTROL | 'P', backline} - , - {CONTROL | 'Q', quote} - , - {CONTROL | 'R', backsearch} - , - {CONTROL | 'S', forwsearch} - , - {CONTROL | 'T', twiddle} - , - {CONTROL | 'U', unarg} - , - {CONTROL | 'V', forwpage} - , - {CONTROL | 'W', killregion} - , - {CONTROL | 'X', cex} - , - {CONTROL | 'Y', yank} - , - {CONTROL | 'Z', backpage} - , - {CONTROL | ']', metafn} - , - {CTLX | CONTROL | 'B', listbuffers} - , - {CTLX | CONTROL | 'C', quit} - , /* Hard quit. */ -#if PKCODE & AEDIT - {CTLX | CONTROL | 'A', detab} - , + {CONTROL | 'A', gotobol} + , + {CONTROL | 'B', backchar} + , + {CONTROL | 'C', insspace} + , + {CONTROL | 'D', forwdel} + , + {CONTROL | 'E', gotoeol} + , + {CONTROL | 'F', forwchar} + , + {CONTROL | 'G', ctrlg} + , + {CONTROL | 'H', backdel} + , + {CONTROL | 'I', insert_tab} + , + {CONTROL | 'J', indent} + , + {CONTROL | 'K', killtext} + , + {CONTROL | 'L', redraw} + , + {CONTROL | 'M', insert_newline} + , + {CONTROL | 'N', forwline} + , + {CONTROL | 'O', openline} + , + {CONTROL | 'P', backline} + , + {CONTROL | 'Q', quote} + , + {CONTROL | 'R', backsearch} + , + {CONTROL | 'S', forwsearch} + , + {CONTROL | 'T', twiddle} + , + {CONTROL | 'U', unarg} + , + {CONTROL | 'V', forwpage} + , + {CONTROL | 'W', killregion} + , + {CONTROL | 'X', cex} + , + {CONTROL | 'Y', yank} + , + {CONTROL | 'Z', backpage} + , + {CONTROL | ']', metafn} + , + {CTLX | CONTROL | 'B', listbuffers} + , + {CTLX | CONTROL | 'C', quit} + , /* Hard quit. */ +#if PKCODE & AEDIT + {CTLX | CONTROL | 'A', detab} + , #endif -#if PKCODE - {CTLX | CONTROL | 'D', filesave} - , /* alternative */ -#else -#if AEDIT - {CTLX | CONTROL | 'D', detab} - , -#endif -#endif -#if AEDIT - {CTLX | CONTROL | 'E', entab} - , -#endif - {CTLX | CONTROL | 'F', filefind} - , - {CTLX | CONTROL | 'I', insfile} - , - {CTLX | CONTROL | 'L', lowerregion} - , - {CTLX | CONTROL | 'M', delmode} - , - {CTLX | CONTROL | 'N', mvdnwind} - , - {CTLX | CONTROL | 'O', deblank} - , - {CTLX | CONTROL | 'P', mvupwind} - , - {CTLX | CONTROL | 'R', fileread} - , - {CTLX | CONTROL | 'S', filesave} - , -#if AEDIT - {CTLX | CONTROL | 'T', trim} - , -#endif - {CTLX | CONTROL | 'U', upperregion} - , - {CTLX | CONTROL | 'V', viewfile} - , - {CTLX | CONTROL | 'W', filewrite} - , - {CTLX | CONTROL | 'X', swapmark} - , - {CTLX | CONTROL | 'Z', shrinkwind} - , - {CTLX | '?', deskey} - , - {CTLX | '!', spawn} - , - {CTLX | '@', pipecmd} - , - {CTLX | '#', filter_buffer} - , - {CTLX | '$', execprg} - , - {CTLX | '=', showcpos} - , - {CTLX | '(', ctlxlp} - , - {CTLX | ')', ctlxrp} - , - {CTLX | '^', enlargewind} - , - {CTLX | '0', delwind} - , - {CTLX | '1', onlywind} - , - {CTLX | '2', splitwind} - , - {CTLX | 'A', setvar} - , - {CTLX | 'B', usebuffer} - , - {CTLX | 'C', spawncli} - , -#if BSD | __hpux | SVR4 - {CTLX | 'D', bktoshell} - , -#endif - {CTLX | 'E', ctlxe} - , - {CTLX | 'F', setfillcol} - , - {CTLX | 'K', killbuffer} - , - {CTLX | 'M', setemode} - , - {CTLX | 'N', filename} - , - {CTLX | 'O', nextwind} - , - {CTLX | 'P', prevwind} - , -#if PKCODE - {CTLX | 'Q', quote} - , /* alternative */ -#endif -#if ISRCH - {CTLX | 'R', risearch} - , - {CTLX | 'S', fisearch} - , -#endif - {CTLX | 'W', resize} - , - {CTLX | 'X', nextbuffer} - , - {CTLX | 'Z', enlargewind} - , -#if WORDPRO - {META | CONTROL | 'C', wordcount} - , -#endif -#if PKCODE - {META | CONTROL | 'D', newsize} - , -#endif -#if PROC - {META | CONTROL | 'E', execproc} - , -#endif -#if CFENCE - {META | CONTROL | 'F', getfence} - , -#endif - {META | CONTROL | 'H', delbword} - , - {META | CONTROL | 'K', unbindkey} - , - {META | CONTROL | 'L', reposition} - , - {META | CONTROL | 'M', delgmode} - , - {META | CONTROL | 'N', namebuffer} - , - {META | CONTROL | 'R', qreplace} - , - {META | CONTROL | 'S', newsize} - , - {META | CONTROL | 'T', newwidth} - , - {META | CONTROL | 'V', scrnextdw} - , -#if WORDPRO - {META | CONTROL | 'W', killpara} - , -#endif - {META | CONTROL | 'Z', scrnextup} - , - {META | ' ', setmark} - , - {META | '?', help} - , - {META | '!', reposition} - , - {META | '.', setmark} - , - {META | '>', gotoeob} - , - {META | '<', gotobob} - , - {META | '~', unmark} - , -#if APROP - {META | 'A', apro} - , -#endif - {META | 'B', backword} - , - {META | 'C', capword} - , - {META | 'D', delfword} - , -#if CRYPT - {META | 'E', set_encryption_key} - , -#endif - {META | 'F', forwword} - , - {META | 'G', gotoline} - , -#if PKCODE -#if WORDPRO - {META | 'J', justpara} - , -#endif -#endif - {META | 'K', bindtokey} - , - {META | 'L', lowerword} - , - {META | 'M', setgmode} - , -#if WORDPRO - {META | 'N', gotoeop} - , - {META | 'P', gotobop} - , - {META | 'Q', fillpara} - , -#endif - {META | 'R', sreplace} - , -#if PKCODE - {META | 'S', forwsearch} - , /* alternative P.K. */ -#else -#if BSD - {META | 'S', bktoshell} - , -#endif -#endif - {META | 'U', upperword} - , - {META | 'V', backpage} - , - {META | 'W', copyregion} - , - {META | 'X', namedcmd} - , - {META | 'Z', quickexit} - , - {META | 0x7F, delbword} - , - -#if MSDOS - {SPEC | CONTROL | '_', forwhunt} - , - {SPEC | CONTROL | 'S', backhunt} - , - {SPEC | 71, gotobol} - , - {SPEC | 72, backline} - , - {SPEC | 73, backpage} - , - {SPEC | 75, backchar} - , - {SPEC | 77, forwchar} - , - {SPEC | 79, gotoeol} - , - {SPEC | 80, forwline} - , - {SPEC | 81, forwpage} - , - {SPEC | 82, insspace} - , - {SPEC | 83, forwdel} - , - {SPEC | 115, backword} - , - {SPEC | 116, forwword} - , -#if WORDPRO - {SPEC | 132, gotobop} - , - {SPEC | 118, gotoeop} - , -#endif - {SPEC | 84, cbuf1} - , - {SPEC | 85, cbuf2} - , - {SPEC | 86, cbuf3} - , - {SPEC | 87, cbuf4} - , - {SPEC | 88, cbuf5} - , - {SPEC | 89, cbuf6} - , - {SPEC | 90, cbuf7} - , - {SPEC | 91, cbuf8} - , - {SPEC | 92, cbuf9} - , - {SPEC | 93, cbuf10} - , #if PKCODE - {SPEC | 117, gotoeob} - , - {SPEC | 119, gotobob} - , - {SPEC | 141, gotobop} - , - {SPEC | 145, gotoeop} - , - {SPEC | 146, yank} - , - {SPEC | 147, killregion} - , + {CTLX | CONTROL | 'D', filesave} + , /* alternative */ +#else +#if AEDIT + {CTLX | CONTROL | 'D', detab} + , +#endif +#endif +#if AEDIT + {CTLX | CONTROL | 'E', entab} + , +#endif + {CTLX | CONTROL | 'F', filefind} + , + {CTLX | CONTROL | 'I', insfile} + , + {CTLX | CONTROL | 'L', lowerregion} + , + {CTLX | CONTROL | 'M', delmode} + , + {CTLX | CONTROL | 'N', mvdnwind} + , + {CTLX | CONTROL | 'O', deblank} + , + {CTLX | CONTROL | 'P', mvupwind} + , + {CTLX | CONTROL | 'R', fileread} + , + {CTLX | CONTROL | 'S', filesave} + , +#if AEDIT + {CTLX | CONTROL | 'T', trim} + , +#endif + {CTLX | CONTROL | 'U', upperregion} + , + {CTLX | CONTROL | 'V', viewfile} + , + {CTLX | CONTROL | 'W', filewrite} + , + {CTLX | CONTROL | 'X', swapmark} + , + {CTLX | CONTROL | 'Z', shrinkwind} + , + {CTLX | '?', deskey} + , + {CTLX | '!', spawn} + , + {CTLX | '@', pipecmd} + , + {CTLX | '#', filter_buffer} + , + {CTLX | '$', execprg} + , + {CTLX | '=', showcpos} + , + {CTLX | '(', ctlxlp} + , + {CTLX | ')', ctlxrp} + , + {CTLX | '^', enlargewind} + , + {CTLX | '0', delwind} + , + {CTLX | '1', onlywind} + , + {CTLX | '2', splitwind} + , + {CTLX | 'A', setvar} + , + {CTLX | 'B', usebuffer} + , + {CTLX | 'C', spawncli} + , +#if BSD | __hpux | SVR4 + {CTLX | 'D', bktoshell} + , +#endif + {CTLX | 'E', ctlxe} + , + {CTLX | 'F', setfillcol} + , + {CTLX | 'K', killbuffer} + , + {CTLX | 'M', setemode} + , + {CTLX | 'N', filename} + , + {CTLX | 'O', nextwind} + , + {CTLX | 'P', prevwind} + , +#if PKCODE + {CTLX | 'Q', quote} + , /* alternative */ +#endif +#if ISRCH + {CTLX | 'R', risearch} + , + {CTLX | 'S', fisearch} + , +#endif + {CTLX | 'W', resize} + , + {CTLX | 'X', nextbuffer} + , + {CTLX | 'Z', enlargewind} + , +#if WORDPRO + {META | CONTROL | 'C', wordcount} + , +#endif +#if PKCODE + {META | CONTROL | 'D', newsize} + , +#endif +#if PROC + {META | CONTROL | 'E', execproc} + , +#endif +#if CFENCE + {META | CONTROL | 'F', getfence} + , +#endif + {META | CONTROL | 'H', delbword} + , + {META | CONTROL | 'K', unbindkey} + , + {META | CONTROL | 'L', reposition} + , + {META | CONTROL | 'M', delgmode} + , + {META | CONTROL | 'N', namebuffer} + , + {META | CONTROL | 'R', qreplace} + , + {META | CONTROL | 'S', newsize} + , + {META | CONTROL | 'T', newwidth} + , + {META | CONTROL | 'V', scrnextdw} + , +#if WORDPRO + {META | CONTROL | 'W', killpara} + , +#endif + {META | CONTROL | 'Z', scrnextup} + , + {META | ' ', setmark} + , + {META | '?', help} + , + {META | '!', reposition} + , + {META | '.', setmark} + , + {META | '>', gotoeob} + , + {META | '<', gotobob} + , + {META | '~', unmark} + , +#if APROP + {META | 'A', apro} + , +#endif + {META | 'B', backword} + , + {META | 'C', capword} + , + {META | 'D', delfword} + , +#if CRYPT + {META | 'E', set_encryption_key} + , +#endif + {META | 'F', forwword} + , + {META | 'G', gotoline} + , +#if PKCODE +#if WORDPRO + {META | 'J', justpara} + , +#endif +#endif + {META | 'K', bindtokey} + , + {META | 'L', lowerword} + , + {META | 'M', setgmode} + , +#if WORDPRO + {META | 'N', gotoeop} + , + {META | 'P', gotobop} + , + {META | 'Q', fillpara} + , +#endif + {META | 'R', sreplace} + , +#if PKCODE + {META | 'S', forwsearch} + , /* alternative P.K. */ +#else +#if BSD + {META | 'S', bktoshell} + , +#endif +#endif + {META | 'U', upperword} + , + {META | 'V', backpage} + , + {META | 'W', copyregion} + , + {META | 'X', namedcmd} + , + {META | 'Z', quickexit} + , + {META | 0x7F, delbword} + , + +#if MSDOS + {SPEC | CONTROL | '_', forwhunt} + , + {SPEC | CONTROL | 'S', backhunt} + , + {SPEC | 71, gotobol} + , + {SPEC | 72, backline} + , + {SPEC | 73, backpage} + , + {SPEC | 75, backchar} + , + {SPEC | 77, forwchar} + , + {SPEC | 79, gotoeol} + , + {SPEC | 80, forwline} + , + {SPEC | 81, forwpage} + , + {SPEC | 82, insspace} + , + {SPEC | 83, forwdel} + , + {SPEC | 115, backword} + , + {SPEC | 116, forwword} + , +#if WORDPRO + {SPEC | 132, gotobop} + , + {SPEC | 118, gotoeop} + , +#endif + {SPEC | 84, cbuf1} + , + {SPEC | 85, cbuf2} + , + {SPEC | 86, cbuf3} + , + {SPEC | 87, cbuf4} + , + {SPEC | 88, cbuf5} + , + {SPEC | 89, cbuf6} + , + {SPEC | 90, cbuf7} + , + {SPEC | 91, cbuf8} + , + {SPEC | 92, cbuf9} + , + {SPEC | 93, cbuf10} + , +#if PKCODE + {SPEC | 117, gotoeob} + , + {SPEC | 119, gotobob} + , + {SPEC | 141, gotobop} + , + {SPEC | 145, gotoeop} + , + {SPEC | 146, yank} + , + {SPEC | 147, killregion} + , #endif #endif -#if VT220 - {SPEC | '1', fisearch} - , /* VT220 keys */ - {SPEC | '2', yank} - , - {SPEC | '3', killregion} - , - {SPEC | '4', setmark} - , - {SPEC | '5', backpage} - , - {SPEC | '6', forwpage} - , - {SPEC | 'A', backline} - , - {SPEC | 'B', forwline} - , - {SPEC | 'C', forwchar} - , - {SPEC | 'D', backchar} - , - {SPEC | 'c', metafn} - , - {SPEC | 'd', backchar} - , - {SPEC | 'e', forwline} - , - {SPEC | 'f', gotobob} - , - {SPEC | 'h', help} - , - {SPEC | 'i', cex} - , +#if VT220 + {SPEC | '1', fisearch} + , /* VT220 keys */ + {SPEC | '2', yank} + , + {SPEC | '3', killregion} + , + {SPEC | '4', setmark} + , + {SPEC | '5', backpage} + , + {SPEC | '6', forwpage} + , + {SPEC | 'A', backline} + , + {SPEC | 'B', forwline} + , + {SPEC | 'C', forwchar} + , + {SPEC | 'D', backchar} + , + {SPEC | 'c', metafn} + , + {SPEC | 'd', backchar} + , + {SPEC | 'e', forwline} + , + {SPEC | 'f', gotobob} + , + {SPEC | 'h', help} + , + {SPEC | 'i', cex} + , #endif - {0x7F, backdel} - , + {0x7F, backdel} + , - /* special internal bindings */ - { SPEC | META | 'W', wrapword }, /* called on word wrap */ - { SPEC | META | 'C', nullproc }, /* every command input */ - { SPEC | META | 'R', nullproc }, /* on file read */ - { SPEC | META | 'X', nullproc }, /* on window change P.K. */ + /* special internal bindings */ + { SPEC | META | 'W', wrapword }, /* called on word wrap */ + { SPEC | META | 'C', nullproc }, /* every command input */ + { SPEC | META | 'R', nullproc }, /* on file read */ + { SPEC | META | 'X', nullproc }, /* on window change P.K. */ - {0, NULL} + {0, NULL} }; diff --git a/edef.h b/edef.h index 57fdada..251a11e 100644 --- a/edef.h +++ b/edef.h @@ -10,7 +10,6 @@ #ifndef EDEF_H_ #define EDEF_H_ -#include "buffer.h" #include "estruct.h" /* Initialized global external declarations. */ diff --git a/input.c b/input.c index 37ed89a..ae68c28 100644 --- a/input.c +++ b/input.c @@ -2,12 +2,12 @@ #include "input.h" -/* input.c +/* input.c * - * Various input routines + * Various input routines * - * written by Daniel Lawrence 5/9/86 - * modified by Petri Kutvonen + * written by Daniel Lawrence 5/9/86 + * modified by Petri Kutvonen */ #include @@ -15,6 +15,7 @@ #include #include "bind.h" +#include "edef.h" #include "bindable.h" #include "display.h" #include "exec.h" @@ -22,28 +23,28 @@ #include "terminal.h" #include "wrapper.h" -#if PKCODE +#if PKCODE #if MSDOS && TURBO -#include +#include #endif #endif -#if PKCODE && (UNIX || (MSDOS && TURBO)) -#define COMPLC 1 +#if PKCODE && (UNIX || (MSDOS && TURBO)) +#define COMPLC 1 #else -#define COMPLC 0 +#define COMPLC 0 #endif -#define NKBDM 256 /* # of strokes, keyboard macro */ -int kbdm[ NKBDM] ; /* Macro */ -int *kbdptr ; /* current position in keyboard buf */ -int *kbdend = &kbdm[0] ; /* ptr to end of the keyboard */ +#define NKBDM 256 /* # of strokes, keyboard macro */ +int kbdm[ NKBDM] ; /* Macro */ +int *kbdptr ; /* current position in keyboard buf */ +int *kbdend = &kbdm[0] ; /* ptr to end of the keyboard */ -kbdstate kbdmode = STOP ; /* current keyboard macro mode */ -int lastkey = 0 ; /* last keystoke */ -int kbdrep = 0 ; /* number of repetitions */ +kbdstate kbdmode = STOP ; /* current keyboard macro mode */ +int lastkey = 0 ; /* last keystoke */ +int kbdrep = 0 ; /* number of repetitions */ -static const int quotec = 0x11 ; /* quote char during mlreply() */ +static const int quotec = 0x11 ; /* quote char during mlreply() */ /* * Ask a yes or no question in the message line. Return either TRUE, FALSE, or @@ -52,27 +53,27 @@ static const int quotec = 0x11 ; /* quote char during mlreply() */ */ int mlyesno( const char *prompt) { - char c; /* input character */ - char buf[NPAT]; /* prompt to user */ + char c; /* input character */ + char buf[NPAT]; /* prompt to user */ - for (;;) { - /* build and prompt the user */ - strcpy(buf, prompt); - strcat(buf, " (y/n)? "); - mlwrite(buf); + for (;;) { + /* build and prompt the user */ + strcpy(buf, prompt); + strcat(buf, " (y/n)? "); + mlwrite(buf); - /* get the responce */ - c = tgetc(); + /* get the responce */ + c = tgetc(); - if (c == ectoc(abortc)) /* Bail out! */ - return ABORT; + if (c == ectoc(abortc)) /* Bail out! */ + return ABORT; - if (c == 'y' || c == 'Y') - return TRUE; + if (c == 'y' || c == 'Y') + return TRUE; - if (c == 'n' || c == 'N') - return FALSE; - } + if (c == 'n' || c == 'N') + return FALSE; + } } /* @@ -85,38 +86,38 @@ int mlyesno( const char *prompt) int mlreply( const char *prompt, char *buf, int nbuf) { - return nextarg(prompt, buf, nbuf, ctoec('\n')); + return nextarg(prompt, buf, nbuf, ctoec('\n')); } int mlreplyt(const char *prompt, char *buf, int nbuf, int eolchar) { - return nextarg(prompt, buf, nbuf, eolchar); + return nextarg(prompt, buf, nbuf, eolchar); } /* * ectoc: - * expanded character to character - * collapse the CONTROL and SPEC flags back into an ascii code + * expanded character to character + * collapse the CONTROL and SPEC flags back into an ascii code */ int ectoc(int c) { - if (c & CONTROL) - c = c & ~(CONTROL | 0x40); - if (c & SPEC) - c = c & 255; - return c; + if (c & CONTROL) + c = c & ~(CONTROL | 0x40); + if (c & SPEC) + c = c & 255; + return c; } /* * ctoec: - * character to extended character - * pull out the CONTROL and SPEC prefixes (if possible) + * character to extended character + * pull out the CONTROL and SPEC prefixes (if possible) */ int ctoec(int c) { - if (c >= 0x00 && c <= 0x1F) - c = CONTROL | (c + '@'); - return c; + if (c >= 0x00 && c <= 0x1F) + c = CONTROL | (c + '@'); + return c; } /* @@ -126,615 +127,615 @@ int ctoec(int c) */ fn_t getname(void) { - int cpos; /* current column on screen output */ - int c; - char *sp; /* pointer to string for output */ - struct name_bind *ffp; /* first ptr to entry in name binding table */ - struct name_bind *cffp; /* current ptr to entry in name binding table */ - struct name_bind *lffp; /* last ptr to entry in name binding table */ - char buf[NSTRING]; /* buffer to hold tentative command name */ + int cpos; /* current column on screen output */ + int c; + char *sp; /* pointer to string for output */ + struct name_bind *ffp; /* first ptr to entry in name binding table */ + struct name_bind *cffp; /* current ptr to entry in name binding table */ + struct name_bind *lffp; /* last ptr to entry in name binding table */ + char buf[NSTRING]; /* buffer to hold tentative command name */ - /* starting at the beginning of the string buffer */ - cpos = 0; + /* starting at the beginning of the string buffer */ + cpos = 0; - /* if we are executing a command line get the next arg and match it */ - if (clexec) { - if (macarg(buf) != TRUE) - return NULL; - return fncmatch(&buf[0]); - } + /* if we are executing a command line get the next arg and match it */ + if (clexec) { + if (macarg(buf) != TRUE) + return NULL; + return fncmatch(&buf[0]); + } - /* build a name string from the keyboard */ - while (TRUE) { - c = tgetc(); + /* build a name string from the keyboard */ + while (TRUE) { + c = tgetc(); - /* if we are at the end, just match it */ - if (c == 0x0d) { - buf[cpos] = 0; + /* if we are at the end, just match it */ + if (c == 0x0d) { + buf[cpos] = 0; - /* and match it off */ - return fncmatch(&buf[0]); + /* and match it off */ + return fncmatch(&buf[0]); - } else if (c == ectoc(abortc)) { /* Bell, abort */ - ctrlg(FALSE, 0); - TTflush(); - return NULL; + } else if (c == ectoc(abortc)) { /* Bell, abort */ + ctrlg(FALSE, 0); + TTflush(); + return NULL; - } else if (c == 0x7F || c == 0x08) { /* rubout/erase */ - if (cpos != 0) { - TTputc('\b'); - TTputc(' '); - TTputc('\b'); - --ttcol; - --cpos; - TTflush(); - } + } else if (c == 0x7F || c == 0x08) { /* rubout/erase */ + if (cpos != 0) { + TTputc('\b'); + TTputc(' '); + TTputc('\b'); + --ttcol; + --cpos; + TTflush(); + } - } else if (c == 0x15) { /* C-U, kill */ - while (cpos != 0) { - TTputc('\b'); - TTputc(' '); - TTputc('\b'); - --cpos; - --ttcol; - } + } else if (c == 0x15) { /* C-U, kill */ + while (cpos != 0) { + TTputc('\b'); + TTputc(' '); + TTputc('\b'); + --cpos; + --ttcol; + } - TTflush(); + TTflush(); - } else if (c == ' ' || c == 0x1b || c == 0x09) { + } else if (c == ' ' || c == 0x1b || c == 0x09) { /* <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */ - /* attempt a completion */ - buf[cpos] = 0; /* terminate it for us */ - ffp = &names[0]; /* scan for matches */ - while (ffp->n_func != NULL) { - if (strncmp(buf, ffp->n_name, strlen(buf)) - == 0) { - /* a possible match! More than one? */ - if ((ffp + 1)->n_func == NULL || - (strncmp - (buf, (ffp + 1)->n_name, - strlen(buf)) != 0)) { - /* no...we match, print it */ - sp = ffp->n_name + cpos; - while (*sp) - TTputc(*sp++); - TTflush(); - return ffp->n_func; - } else { + /* attempt a completion */ + buf[cpos] = 0; /* terminate it for us */ + ffp = &names[0]; /* scan for matches */ + while (ffp->n_func != NULL) { + if (strncmp(buf, ffp->n_name, strlen(buf)) + == 0) { + /* a possible match! More than one? */ + if ((ffp + 1)->n_func == NULL || + (strncmp + (buf, (ffp + 1)->n_name, + strlen(buf)) != 0)) { + /* no...we match, print it */ + sp = ffp->n_name + cpos; + while (*sp) + TTputc(*sp++); + TTflush(); + return ffp->n_func; + } else { /* << << << << << << << << << << << << << << << << << */ - /* try for a partial match against the list */ + /* try for a partial match against the list */ - /* first scan down until we no longer match the current input */ - lffp = (ffp + 1); - while ((lffp + - 1)->n_func != - NULL) { - if (strncmp - (buf, - (lffp + - 1)->n_name, - strlen(buf)) - != 0) - break; - ++lffp; - } + /* first scan down until we no longer match the current input */ + lffp = (ffp + 1); + while ((lffp + + 1)->n_func != + NULL) { + if (strncmp + (buf, + (lffp + + 1)->n_name, + strlen(buf)) + != 0) + break; + ++lffp; + } - /* and now, attempt to partial complete the string, char at a time */ - while (TRUE) { - /* add the next char in */ - buf[cpos] = - ffp-> - n_name[cpos]; + /* and now, attempt to partial complete the string, char at a time */ + while (TRUE) { + /* add the next char in */ + buf[cpos] = + ffp-> + n_name[cpos]; - /* scan through the candidates */ - cffp = ffp + 1; - while (cffp <= - lffp) { - if (cffp-> - n_name - [cpos] - != - buf - [cpos]) - goto onward; - ++cffp; - } + /* scan through the candidates */ + cffp = ffp + 1; + while (cffp <= + lffp) { + if (cffp-> + n_name + [cpos] + != + buf + [cpos]) + goto onward; + ++cffp; + } - /* add the character */ - TTputc(buf - [cpos++]); - } + /* add the character */ + TTputc(buf + [cpos++]); + } /* << << << << << << << << << << << << << << << << << */ - } - } - ++ffp; - } + } + } + ++ffp; + } - /* no match.....beep and onward */ - TTbeep(); - onward:; - TTflush(); + /* no match.....beep and onward */ + TTbeep(); + onward:; + TTflush(); /* <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */ - } else { - if (cpos < NSTRING - 1 && c > ' ') { - buf[cpos++] = c; - TTputc(c); - } + } else { + if (cpos < NSTRING - 1 && c > ' ') { + buf[cpos++] = c; + TTputc(c); + } - ++ttcol; - TTflush(); - } - } + ++ttcol; + TTflush(); + } + } } -/* tgetc: Get a key from the terminal driver, resolve any keyboard - macro action */ +/* tgetc: Get a key from the terminal driver, resolve any keyboard + macro action */ int tgetc(void) { - int c; /* fetched character */ + int c; /* fetched character */ - /* if we are playing a keyboard macro back, */ - if (kbdmode == PLAY) { + /* if we are playing a keyboard macro back, */ + if (kbdmode == PLAY) { - /* if there is some left... */ - if (kbdptr < kbdend) - return (int) *kbdptr++; + /* if there is some left... */ + if (kbdptr < kbdend) + return (int) *kbdptr++; - /* at the end of last repitition? */ - if (--kbdrep < 1) { - kbdmode = STOP; -#if VISMAC == 0 - /* force a screen update after all is done */ - update(FALSE); + /* at the end of last repitition? */ + if (--kbdrep < 1) { + kbdmode = STOP; +#if VISMAC == 0 + /* force a screen update after all is done */ + update(FALSE); #endif - } else { + } else { - /* reset the macro to the begining for the next rep */ - kbdptr = &kbdm[0]; - return (int) *kbdptr++; - } - } + /* reset the macro to the begining for the next rep */ + kbdptr = &kbdm[0]; + return (int) *kbdptr++; + } + } - /* fetch a character from the terminal driver */ - c = TTgetc(); + /* fetch a character from the terminal driver */ + c = TTgetc(); - /* record it for $lastkey */ - lastkey = c; + /* record it for $lastkey */ + lastkey = c; - /* save it if we need to */ - if (kbdmode == RECORD) { - *kbdptr++ = c; - kbdend = kbdptr; + /* save it if we need to */ + if (kbdmode == RECORD) { + *kbdptr++ = c; + kbdend = kbdptr; - /* don't overrun the buffer */ - if (kbdptr == &kbdm[NKBDM - 1]) { - kbdmode = STOP; - TTbeep(); - } - } + /* don't overrun the buffer */ + if (kbdptr == &kbdm[NKBDM - 1]) { + kbdmode = STOP; + TTbeep(); + } + } - /* and finally give the char back */ - return c; + /* and finally give the char back */ + return c; } -/* GET1KEY: Get one keystroke. The only prefixs legal here - are the SPEC and CONTROL prefixes. - */ +/* GET1KEY: Get one keystroke. The only prefixs legal here + are the SPEC and CONTROL prefixes. + */ int get1key(void) { - int c; + int c; - /* get a keystroke */ - c = tgetc(); + /* get a keystroke */ + c = tgetc(); -#if MSDOS - if (c == 0) { /* Apply SPEC prefix */ - c = tgetc(); - if (c >= 0x00 && c <= 0x1F) /* control key? */ - c = CONTROL | (c + '@'); - return SPEC | c; - } +#if MSDOS + if (c == 0) { /* Apply SPEC prefix */ + c = tgetc(); + if (c >= 0x00 && c <= 0x1F) /* control key? */ + c = CONTROL | (c + '@'); + return SPEC | c; + } #endif - if (c >= 0x00 && c <= 0x1F) /* C0 control -> C- */ - c = CONTROL | (c + '@'); - return c; + if (c >= 0x00 && c <= 0x1F) /* C0 control -> C- */ + c = CONTROL | (c + '@'); + return c; } -/* GETCMD: Get a command from the keyboard. Process all applicable - prefix keys - */ +/* GETCMD: Get a command from the keyboard. Process all applicable + prefix keys + */ int getcmd(void) { - int c; /* fetched keystroke */ + int c; /* fetched keystroke */ #if VT220 - int d; /* second character P.K. */ - int cmask = 0; + int d; /* second character P.K. */ + int cmask = 0; #endif - /* get initial character */ - c = get1key(); + /* get initial character */ + c = get1key(); #if VT220 proc_metac: #endif - if (c == 128+27) /* CSI */ - goto handle_CSI; - /* process META prefix */ - if (c == (CONTROL | '[')) { - c = get1key(); + if (c == 128+27) /* CSI */ + goto handle_CSI; + /* process META prefix */ + if (c == (CONTROL | '[')) { + c = get1key(); #if VT220 - if (c == '[' || c == 'O') { /* CSI P.K. */ + if (c == '[' || c == 'O') { /* CSI P.K. */ handle_CSI: - c = get1key(); - if (c >= 'A' && c <= 'D') - return SPEC | c | cmask; - if (c >= 'E' && c <= 'z' && c != 'i' && c != 'c') - return SPEC | c | cmask; - d = get1key(); - if (d == '~') /* ESC [ n ~ P.K. */ - return SPEC | c | cmask; - switch (c) { /* ESC [ n n ~ P.K. */ - case '1': - c = d + 32; - break; - case '2': - c = d + 48; - break; - case '3': - c = d + 64; - break; - default: - c = '?'; - break; - } - if (d != '~') /* eat tilde P.K. */ - get1key(); - if (c == 'i') { /* DO key P.K. */ - c = ctlxc; - goto proc_ctlxc; - } else if (c == 'c') /* ESC key P.K. */ - c = get1key(); - else - return SPEC | c | cmask; - } + c = get1key(); + if (c >= 'A' && c <= 'D') + return SPEC | c | cmask; + if (c >= 'E' && c <= 'z' && c != 'i' && c != 'c') + return SPEC | c | cmask; + d = get1key(); + if (d == '~') /* ESC [ n ~ P.K. */ + return SPEC | c | cmask; + switch (c) { /* ESC [ n n ~ P.K. */ + case '1': + c = d + 32; + break; + case '2': + c = d + 48; + break; + case '3': + c = d + 64; + break; + default: + c = '?'; + break; + } + if (d != '~') /* eat tilde P.K. */ + get1key(); + if (c == 'i') { /* DO key P.K. */ + c = ctlxc; + goto proc_ctlxc; + } else if (c == 'c') /* ESC key P.K. */ + c = get1key(); + else + return SPEC | c | cmask; + } #endif #if VT220 - if (c == (CONTROL | '[')) { - cmask = META; - goto proc_metac; - } + if (c == (CONTROL | '[')) { + cmask = META; + goto proc_metac; + } #endif - if (islower(c)) /* Force to upper */ - c ^= DIFCASE; - if (c >= 0x00 && c <= 0x1F) /* control key */ - c = CONTROL | (c + '@'); - return META | c; - } -#if PKCODE - else if (c == metac) { - c = get1key(); + if (islower(c)) /* Force to upper */ + c ^= DIFCASE; + if (c >= 0x00 && c <= 0x1F) /* control key */ + c = CONTROL | (c + '@'); + return META | c; + } +#if PKCODE + else if (c == metac) { + c = get1key(); #if VT220 - if (c == (CONTROL | '[')) { - cmask = META; - goto proc_metac; - } + if (c == (CONTROL | '[')) { + cmask = META; + goto proc_metac; + } #endif - if (islower(c)) /* Force to upper */ - c ^= DIFCASE; - if (c >= 0x00 && c <= 0x1F) /* control key */ - c = CONTROL | (c + '@'); - return META | c; - } + if (islower(c)) /* Force to upper */ + c ^= DIFCASE; + if (c >= 0x00 && c <= 0x1F) /* control key */ + c = CONTROL | (c + '@'); + return META | c; + } #endif -#if VT220 +#if VT220 proc_ctlxc: #endif - /* process CTLX prefix */ - if (c == ctlxc) { - c = get1key(); + /* process CTLX prefix */ + if (c == ctlxc) { + c = get1key(); #if VT220 - if (c == (CONTROL | '[')) { - cmask = CTLX; - goto proc_metac; - } + if (c == (CONTROL | '[')) { + cmask = CTLX; + goto proc_metac; + } #endif - if (c >= 'a' && c <= 'z') /* Force to upper */ - c -= 0x20; - if (c >= 0x00 && c <= 0x1F) /* control key */ - c = CONTROL | (c + '@'); - return CTLX | c; - } + if (c >= 'a' && c <= 'z') /* Force to upper */ + c -= 0x20; + if (c >= 0x00 && c <= 0x1F) /* control key */ + c = CONTROL | (c + '@'); + return CTLX | c; + } - /* otherwise, just return it */ - return c; + /* otherwise, just return it */ + return c; } -/* A more generalized prompt/reply function allowing the caller - to specify the proper terminator. If the terminator is not - a return ('\n') it will echo as "" - */ +/* A more generalized prompt/reply function allowing the caller + to specify the proper terminator. If the terminator is not + a return ('\n') it will echo as "" + */ int getstring( const char *prompt, char *buf, int nbuf, int eolchar) { - int cpos; /* current character position in string */ - int c; - boolean quotef ; /* are we quoting the next char? */ -#if COMPLC - int ffile, ocpos, nskip = 0, didtry = 0; + int cpos; /* current character position in string */ + int c; + boolean quotef ; /* are we quoting the next char? */ +#if COMPLC + int ffile, ocpos, nskip = 0, didtry = 0; #if MSDOS - struct ffblk ffblk; - char *fcp; + struct ffblk ffblk; + char *fcp; #endif -#if UNIX - static char tmp[] = "/tmp/meXXXXXX"; - FILE *tmpf = NULL; +#if UNIX + static char tmp[] = "/tmp/meXXXXXX"; + FILE *tmpf = NULL; #endif - ffile = (strcmp(prompt, "Find file: ") == 0 - || strcmp(prompt, "View file: ") == 0 - || strcmp(prompt, "Insert file: ") == 0 - || strcmp(prompt, "Write file: ") == 0 - || strcmp(prompt, "Read file: ") == 0 - || strcmp(prompt, "File to execute: ") == 0); + ffile = (strcmp(prompt, "Find file: ") == 0 + || strcmp(prompt, "View file: ") == 0 + || strcmp(prompt, "Insert file: ") == 0 + || strcmp(prompt, "Write file: ") == 0 + || strcmp(prompt, "Read file: ") == 0 + || strcmp(prompt, "File to execute: ") == 0); #endif - cpos = 0; - quotef = FALSE; + cpos = 0; + quotef = FALSE; - /* prompt the user for the input string */ - mlwrite(prompt); + /* prompt the user for the input string */ + mlwrite(prompt); - for (;;) { -#if COMPLC - if (!didtry) - nskip = -1; - didtry = 0; + for (;;) { +#if COMPLC + if (!didtry) + nskip = -1; + didtry = 0; #endif - /* get a character from the user */ - c = get1key(); + /* get a character from the user */ + c = get1key(); - /* If it is a , change it to a */ -#if PKCODE - if (c == (CONTROL | 0x4d) && !quotef) + /* If it is a , change it to a */ +#if PKCODE + if (c == (CONTROL | 0x4d) && !quotef) #else - if (c == (CONTROL | 0x4d)) + if (c == (CONTROL | 0x4d)) #endif - c = CONTROL | 0x40 | '\n'; + c = CONTROL | 0x40 | '\n'; - /* if they hit the line terminate, wrap it up */ - if (c == eolchar && quotef == FALSE) { - buf[cpos++] = 0; + /* if they hit the line terminate, wrap it up */ + if (c == eolchar && quotef == FALSE) { + buf[cpos++] = 0; - /* clear the message line */ - mlwrite(""); - TTflush(); + /* clear the message line */ + mlwrite(""); + TTflush(); - /* if we default the buffer, return FALSE */ - if (buf[0] == 0) - return FALSE; + /* if we default the buffer, return FALSE */ + if (buf[0] == 0) + return FALSE; - return TRUE; - } + return TRUE; + } - /* change from command form back to character form */ - c = ectoc(c); + /* change from command form back to character form */ + c = ectoc(c); - if (c == ectoc(abortc) && quotef == FALSE) { - /* Abort the input? */ - ctrlg(FALSE, 0); - TTflush(); - return ABORT; - } else if ((c == 0x7F || c == 0x08) && quotef == FALSE) { - /* rubout/erase */ - if (cpos != 0) { - outstring("\b \b"); - --ttcol; + if (c == ectoc(abortc) && quotef == FALSE) { + /* Abort the input? */ + ctrlg(FALSE, 0); + TTflush(); + return ABORT; + } else if ((c == 0x7F || c == 0x08) && quotef == FALSE) { + /* rubout/erase */ + if (cpos != 0) { + outstring("\b \b"); + --ttcol; - if (buf[--cpos] < 0x20) { - outstring("\b \b"); - --ttcol; - } - if (buf[cpos] == '\n') { - outstring("\b\b \b\b"); - ttcol -= 2; - } + if (buf[--cpos] < 0x20) { + outstring("\b \b"); + --ttcol; + } + if (buf[cpos] == '\n') { + outstring("\b\b \b\b"); + ttcol -= 2; + } - TTflush(); - } + TTflush(); + } - } else if (c == 0x15 && quotef == FALSE) { - /* C-U, kill */ - while (cpos != 0) { - outstring("\b \b"); - --ttcol; + } else if (c == 0x15 && quotef == FALSE) { + /* C-U, kill */ + while (cpos != 0) { + outstring("\b \b"); + --ttcol; - if (buf[--cpos] < 0x20) { - outstring("\b \b"); - --ttcol; - } - if (buf[cpos] == '\n') { - outstring("\b\b \b\b"); - ttcol -= 2; - } - } - TTflush(); + if (buf[--cpos] < 0x20) { + outstring("\b \b"); + --ttcol; + } + if (buf[cpos] == '\n') { + outstring("\b\b \b\b"); + ttcol -= 2; + } + } + TTflush(); -#if COMPLC - } else if ((c == 0x09 || c == ' ') && quotef == FALSE - && ffile) { - /* TAB, complete file name */ - char ffbuf[255]; -#if MSDOS - char sffbuf[128]; - int lsav = -1; +#if COMPLC + } else if ((c == 0x09 || c == ' ') && quotef == FALSE + && ffile) { + /* TAB, complete file name */ + char ffbuf[255]; +#if MSDOS + char sffbuf[128]; + int lsav = -1; #endif - int n, iswild = 0; + int n, iswild = 0; - didtry = 1; - ocpos = cpos; - while (cpos != 0) { - outstring("\b \b"); - --ttcol; + didtry = 1; + ocpos = cpos; + while (cpos != 0) { + outstring("\b \b"); + --ttcol; - if (buf[--cpos] < 0x20) { - outstring("\b \b"); - --ttcol; - } - if (buf[cpos] == '\n') { - outstring("\b\b \b\b"); - ttcol -= 2; - } - if (buf[cpos] == '*' || buf[cpos] == '?') - iswild = 1; -#if MSDOS - if (lsav < 0 && (buf[cpos] == '\\' || - buf[cpos] == '/' || - buf[cpos] == ':' - && cpos == 1)) - lsav = cpos; + if (buf[--cpos] < 0x20) { + outstring("\b \b"); + --ttcol; + } + if (buf[cpos] == '\n') { + outstring("\b\b \b\b"); + ttcol -= 2; + } + if (buf[cpos] == '*' || buf[cpos] == '?') + iswild = 1; +#if MSDOS + if (lsav < 0 && (buf[cpos] == '\\' || + buf[cpos] == '/' || + buf[cpos] == ':' + && cpos == 1)) + lsav = cpos; #endif - } - TTflush(); - if (nskip < 0) { - buf[ocpos] = 0; -#if UNIX - if (tmpf != NULL) - fclose(tmpf); - strcpy(tmp, "/tmp/meXXXXXX"); - strcpy(ffbuf, "echo "); - strcat(ffbuf, buf); - if (!iswild) - strcat(ffbuf, "*"); - strcat(ffbuf, " >"); - xmkstemp(tmp); - strcat(ffbuf, tmp); - strcat(ffbuf, " 2>&1"); - system(ffbuf); - tmpf = fopen(tmp, "r"); + } + TTflush(); + if (nskip < 0) { + buf[ocpos] = 0; +#if UNIX + if (tmpf != NULL) + fclose(tmpf); + strcpy(tmp, "/tmp/meXXXXXX"); + strcpy(ffbuf, "echo "); + strcat(ffbuf, buf); + if (!iswild) + strcat(ffbuf, "*"); + strcat(ffbuf, " >"); + xmkstemp(tmp); + strcat(ffbuf, tmp); + strcat(ffbuf, " 2>&1"); + system(ffbuf); + tmpf = fopen(tmp, "r"); #endif -#if MSDOS - strcpy(sffbuf, buf); - if (!iswild) - strcat(sffbuf, "*.*"); +#if MSDOS + strcpy(sffbuf, buf); + if (!iswild) + strcat(sffbuf, "*.*"); #endif - nskip = 0; - } -#if UNIX - c = ' '; - for (n = nskip; n > 0; n--) - while ((c = getc(tmpf)) != EOF - && c != ' '); + nskip = 0; + } +#if UNIX + c = ' '; + for (n = nskip; n > 0; n--) + while ((c = getc(tmpf)) != EOF + && c != ' '); #endif -#if MSDOS - if (nskip == 0) { - strcpy(ffbuf, sffbuf); - c = findfirst(ffbuf, &ffblk, - FA_DIREC) ? '*' : ' '; - } else if (nskip > 0) - c = findnext(&ffblk) ? 0 : ' '; +#if MSDOS + if (nskip == 0) { + strcpy(ffbuf, sffbuf); + c = findfirst(ffbuf, &ffblk, + FA_DIREC) ? '*' : ' '; + } else if (nskip > 0) + c = findnext(&ffblk) ? 0 : ' '; #endif - nskip++; + nskip++; - if (c != ' ') { - TTbeep(); - nskip = 0; - } -#if UNIX - while ((c = getc(tmpf)) != EOF && c != '\n' - && c != ' ' && c != '*') + if (c != ' ') { + TTbeep(); + nskip = 0; + } +#if UNIX + while ((c = getc(tmpf)) != EOF && c != '\n' + && c != ' ' && c != '*') #endif -#if MSDOS - if (c == '*') - fcp = sffbuf; - else { - strncpy(buf, sffbuf, lsav + 1); - cpos = lsav + 1; - fcp = ffblk.ff_name; - } - while (c != 0 && (c = *fcp++) != 0 && c != '*') +#if MSDOS + if (c == '*') + fcp = sffbuf; + else { + strncpy(buf, sffbuf, lsav + 1); + cpos = lsav + 1; + fcp = ffblk.ff_name; + } + while (c != 0 && (c = *fcp++) != 0 && c != '*') #endif - { - if (cpos < nbuf - 1) - buf[cpos++] = c; - } -#if UNIX - if (c == '*') - TTbeep(); + { + if (cpos < nbuf - 1) + buf[cpos++] = c; + } +#if UNIX + if (c == '*') + TTbeep(); #endif - for (n = 0; n < cpos; n++) { - c = buf[n]; - if ((c < ' ') && (c != '\n')) { - outstring("^"); - ++ttcol; - c ^= 0x40; - } + for (n = 0; n < cpos; n++) { + c = buf[n]; + if ((c < ' ') && (c != '\n')) { + outstring("^"); + ++ttcol; + c ^= 0x40; + } - if (c != '\n') { - if (disinp) - TTputc(c); - } else { /* put out for */ - outstring(""); - ttcol += 3; - } - ++ttcol; - } - TTflush(); -#if UNIX - rewind(tmpf); - unlink(tmp); + if (c != '\n') { + if (disinp) + TTputc(c); + } else { /* put out for */ + outstring(""); + ttcol += 3; + } + ++ttcol; + } + TTflush(); +#if UNIX + rewind(tmpf); + unlink(tmp); #endif #endif - } else if ((c == quotec || c == 0x16) && quotef == FALSE) { - quotef = TRUE; - } else { - quotef = FALSE; - if (cpos < nbuf - 1) { - buf[cpos++] = c; + } else if ((c == quotec || c == 0x16) && quotef == FALSE) { + quotef = TRUE; + } else { + quotef = FALSE; + if (cpos < nbuf - 1) { + buf[cpos++] = c; - if ((c < ' ') && (c != '\n')) { - outstring("^"); - ++ttcol; - c ^= 0x40; - } + if ((c < ' ') && (c != '\n')) { + outstring("^"); + ++ttcol; + c ^= 0x40; + } - if (c != '\n') { - if (disinp) - TTputc(c); - } else { /* put out for */ - outstring(""); - ttcol += 3; - } - ++ttcol; - TTflush(); - } - } - } + if (c != '\n') { + if (disinp) + TTputc(c); + } else { /* put out for */ + outstring(""); + ttcol += 3; + } + ++ttcol; + TTflush(); + } + } + } } /* * output a string of characters * - * char *s; string to output + * char *s; string to output */ void outstring(char *s) { - if (disinp) - while (*s) - TTputc(*s++); + if (disinp) + while (*s) + TTputc(*s++); } /* * output a string of output characters * - * char *s; string to output + * char *s; string to output */ void ostring(char *s) { - if (discmd) - while (*s) - TTputc(*s++); + if (discmd) + while (*s) + TTputc(*s++); } From cfd92b066c11fccae143a81ff6c26eee2b282ee3 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 9 Oct 2013 13:15:38 +0800 Subject: [PATCH 151/193] Introduce globals.h to prepare rmoval of edef.h. --- Makefile | 103 ++++++++++++++++++++++++++++-------------------------- defines.h | 6 ++++ edef.h | 43 +---------------------- globals.c | 7 ++-- globals.h | 48 +++++++++++++++++++++++++ 5 files changed, 112 insertions(+), 95 deletions(-) create mode 100644 globals.h diff --git a/Makefile b/Makefile index fa62477..c279864 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ -# Makefile for emacs, updated Sat Sep 28 09:31:49 CST 2013 +# Makefile for emacs, updated Wed, Oct 09, 2013 1:11:02 PM -SRC=ansi.c basic.c bindable.c bind.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c globals.c ibmpc.c input.c isearch.c line.c lock.c log.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c -OBJ=ansi.o basic.o bindable.o bind.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o globals.o ibmpc.o input.o isearch.o line.o lock.o log.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o -HDR=basic.h bindable.h bind.h buffer.h crypt.h defines.h display.h ebind.h edef.h efunc.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h log.h names.h pklock.h random.h region.h retcode.h search.h spawn.h terminal.h termio.h utf8.h version.h window.h word.h wrapper.h +SRC=ansi.c basic.c bind.c bindable.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c globals.c ibmpc.c input.c isearch.c line.c lock.c log.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c +OBJ=ansi.o basic.o bind.o bindable.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o globals.o ibmpc.o input.o isearch.o line.o lock.o log.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o +HDR=basic.h bind.h bindable.h buffer.h crypt.h defines.h display.h ebind.h edef.h efunc.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h globals.h input.h isearch.h line.h lock.h log.h names.h pklock.h random.h region.h retcode.h search.h spawn.h terminal.h termio.h utf8.h version.h window.h word.h wrapper.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -126,80 +126,83 @@ depend: ${SRC} # DO NOT DELETE THIS LINE -- make depend uses it -ansi.o: ansi.c estruct.h retcode.h edef.h +ansi.o: ansi.c estruct.h retcode.h edef.h globals.h basic.o: basic.c basic.h buffer.h crypt.h line.h utf8.h display.h \ - estruct.h retcode.h edef.h input.h bind.h random.h terminal.h defines.h \ - window.h + estruct.h retcode.h edef.h globals.h input.h bind.h random.h terminal.h \ + defines.h window.h +bind.o: bind.c bind.h edef.h estruct.h retcode.h globals.h bindable.h \ + buffer.h crypt.h line.h utf8.h display.h ebind.h exec.h file.h flook.h \ + input.h names.h window.h defines.h bindable.o: bindable.c bindable.h defines.h buffer.h crypt.h line.h \ - utf8.h display.h edef.h estruct.h retcode.h file.h input.h bind.h lock.h \ - terminal.h -bind.o: bind.c bind.h edef.h estruct.h retcode.h bindable.h buffer.h \ - crypt.h line.h utf8.h display.h ebind.h exec.h file.h flook.h input.h \ - names.h window.h defines.h + utf8.h display.h edef.h estruct.h retcode.h globals.h file.h input.h \ + bind.h lock.h terminal.h buffer.o: buffer.c buffer.h crypt.h line.h utf8.h defines.h display.h \ - edef.h estruct.h retcode.h file.h input.h bind.h window.h + edef.h estruct.h retcode.h globals.h file.h input.h bind.h window.h crypt.o: crypt.c crypt.h display.o: display.c display.h buffer.h crypt.h line.h utf8.h estruct.h \ - retcode.h edef.h input.h bind.h termio.h terminal.h defines.h version.h \ - wrapper.h window.h + retcode.h edef.h globals.h input.h bind.h termio.h terminal.h defines.h \ + version.h wrapper.h window.h ebind.o: ebind.c ebind.h basic.h bind.h edef.h estruct.h retcode.h \ - bindable.h buffer.h crypt.h line.h utf8.h eval.h exec.h file.h isearch.h \ - random.h region.h search.h spawn.h window.h defines.h word.h + globals.h bindable.h buffer.h crypt.h line.h utf8.h eval.h exec.h file.h \ + isearch.h random.h region.h search.h spawn.h window.h defines.h word.h eval.o: eval.c eval.h basic.h bind.h buffer.h crypt.h line.h utf8.h \ - display.h estruct.h retcode.h edef.h exec.h execute.h flook.h input.h \ - random.h search.h terminal.h defines.h termio.h version.h window.h -exec.o: exec.c exec.h buffer.h crypt.h line.h utf8.h bind.h display.h \ - estruct.h retcode.h edef.h eval.h file.h flook.h input.h window.h \ - defines.h -execute.o: execute.c execute.h edef.h estruct.h retcode.h bind.h random.h \ - display.h file.h crypt.h buffer.h line.h utf8.h terminal.h defines.h \ + display.h estruct.h retcode.h edef.h globals.h exec.h execute.h flook.h \ + input.h random.h search.h terminal.h defines.h termio.h version.h \ window.h +exec.o: exec.c exec.h buffer.h crypt.h line.h utf8.h bind.h display.h \ + estruct.h retcode.h edef.h globals.h eval.h file.h flook.h input.h \ + window.h defines.h +execute.o: execute.c execute.h edef.h estruct.h retcode.h globals.h \ + bind.h random.h display.h file.h crypt.h buffer.h line.h utf8.h \ + terminal.h defines.h window.h file.o: file.c file.h crypt.h retcode.h buffer.h line.h utf8.h defines.h \ - estruct.h edef.h execute.h fileio.h input.h bind.h lock.h log.h window.h + estruct.h edef.h globals.h execute.h fileio.h input.h bind.h lock.h \ + log.h window.h fileio.o: fileio.c fileio.h crypt.h retcode.h defines.h flook.o: flook.c flook.h retcode.h defines.h fileio.h crypt.h -globals.o: globals.c defines.h edef.h estruct.h retcode.h -ibmpc.o: ibmpc.c estruct.h retcode.h edef.h -input.o: input.c input.h bind.h edef.h estruct.h retcode.h bindable.h \ - display.h exec.h names.h terminal.h defines.h wrapper.h +globals.o: globals.c globals.h defines.h retcode.h +ibmpc.o: ibmpc.c estruct.h retcode.h edef.h globals.h +input.o: input.c input.h bind.h edef.h estruct.h retcode.h globals.h \ + bindable.h display.h exec.h names.h terminal.h defines.h wrapper.h isearch.o: isearch.c isearch.h basic.h buffer.h crypt.h line.h utf8.h \ - display.h estruct.h retcode.h edef.h input.h bind.h search.h terminal.h \ - defines.h window.h + display.h estruct.h retcode.h edef.h globals.h input.h bind.h search.h \ + terminal.h defines.h window.h line.o: line.c line.h utf8.h buffer.h crypt.h edef.h estruct.h retcode.h \ - log.h window.h defines.h -lock.o: lock.c lock.h estruct.h retcode.h display.h edef.h input.h bind.h + globals.h log.h window.h defines.h +lock.o: lock.c lock.h estruct.h retcode.h display.h edef.h globals.h \ + input.h bind.h log.o: log.c log.h retcode.h main.o: main.c basic.h bind.h bindable.h buffer.h crypt.h line.h utf8.h \ - display.h edef.h estruct.h retcode.h eval.h execute.h file.h input.h \ - lock.h log.h random.h search.h terminal.h defines.h termio.h version.h \ - window.h + display.h edef.h estruct.h retcode.h globals.h eval.h execute.h file.h \ + input.h lock.h log.h random.h search.h terminal.h defines.h termio.h \ + version.h window.h names.o: names.c names.h basic.h bind.h bindable.h buffer.h crypt.h \ line.h utf8.h display.h eval.h exec.h file.h retcode.h isearch.h \ region.h random.h search.h spawn.h window.h defines.h word.h -pklock.o: pklock.c pklock.h estruct.h retcode.h edef.h +pklock.o: pklock.c pklock.h estruct.h retcode.h edef.h globals.h posix.o: posix.c termio.h random.o: random.c random.h basic.h buffer.h crypt.h line.h utf8.h \ - display.h estruct.h retcode.h edef.h execute.h input.h bind.h log.h \ - search.h terminal.h defines.h window.h + display.h estruct.h retcode.h edef.h globals.h execute.h input.h bind.h \ + log.h search.h terminal.h defines.h window.h region.o: region.c region.h line.h utf8.h buffer.h crypt.h estruct.h \ - retcode.h edef.h log.h window.h defines.h + retcode.h edef.h globals.h log.h window.h defines.h search.o: search.c search.h line.h utf8.h basic.h buffer.h crypt.h \ - display.h edef.h estruct.h retcode.h input.h bind.h log.h terminal.h \ - defines.h window.h + display.h edef.h estruct.h retcode.h globals.h input.h bind.h log.h \ + terminal.h defines.h window.h spawn.o: spawn.c spawn.h defines.h buffer.h crypt.h line.h utf8.h \ - display.h estruct.h retcode.h edef.h file.h flook.h input.h bind.h log.h \ - terminal.h window.h + display.h estruct.h retcode.h edef.h globals.h file.h flook.h input.h \ + bind.h log.h terminal.h window.h tcap.o: tcap.c terminal.h defines.h display.h estruct.h retcode.h edef.h \ - termio.h + globals.h termio.h termio.o: termio.c termio.h estruct.h retcode.h utf8.h utf8.o: utf8.c utf8.h -vmsvt.o: vmsvt.c estruct.h retcode.h edef.h -vt52.o: vt52.c estruct.h retcode.h edef.h +vmsvt.o: vmsvt.c estruct.h retcode.h edef.h globals.h +vt52.o: vt52.c estruct.h retcode.h edef.h globals.h window.o: window.c window.h defines.h buffer.h crypt.h line.h utf8.h \ - basic.h display.h edef.h estruct.h retcode.h execute.h terminal.h \ - wrapper.h + basic.h display.h edef.h estruct.h retcode.h globals.h execute.h \ + terminal.h wrapper.h word.o: word.c word.h basic.h buffer.h crypt.h line.h utf8.h estruct.h \ - retcode.h edef.h log.h random.h region.h window.h defines.h + retcode.h edef.h globals.h log.h random.h region.h window.h defines.h wrapper.o: wrapper.c wrapper.h # DEPENDENCIES MUST END AT END OF FILE diff --git a/defines.h b/defines.h index 0c99915..2e59365 100644 --- a/defines.h +++ b/defines.h @@ -3,8 +3,14 @@ */ #define USG 1 +#define NBUFN 16 /* # of bytes, buffer name */ #define NSTRING 128 /* # of bytes, string buffers */ #define PKCODE 1 #define SCROLLCODE 1 /* scrolling code P.K. */ #define ENVFUNC 1 + +#define CONTROL 0x10000000 /* Control flag, or'ed in */ +#define META 0x20000000 /* Meta flag, or'ed in */ +#define CTLX 0x40000000 /* ^X flag, or'ed in */ +#define SPEC 0x80000000 /* special key (function keys) */ diff --git a/edef.h b/edef.h index 251a11e..617e0e1 100644 --- a/edef.h +++ b/edef.h @@ -11,47 +11,6 @@ #define EDEF_H_ #include "estruct.h" - -/* Initialized global external declarations. */ - -extern int fillcol; /* Fill column */ - - -extern int eolexist; /* does clear to EOL exist? */ -extern int revexist; /* does reverse video exist? */ -extern int flickcode; /* do flicker supression? */ -extern int gfcolor; /* global forgrnd color (white) */ -extern int gbcolor; /* global backgrnd color (black) */ -extern int sgarbf; /* State of screen unknown */ -extern int clexec; /* command line execution flag */ -extern int discmd; /* display command flag */ -extern int disinp; /* display input characters */ - -extern int metac; /* current meta character */ -extern int ctlxc; /* current control X prefix char */ -extern int reptc; /* current universal repeat char */ -extern int abortc; /* current abort command char */ - -extern int tabmask; - - -extern int restflag; /* restricted use? */ -extern long envram; /* # of bytes current in use by malloc */ -extern int rval; /* return value of a subprocess */ -extern int overlap; /* line overlap in forw/back page */ -extern int scrollcount; /* number of lines to scroll */ - -/* Uninitialized global external declarations. */ - -#define CFCPCN 0x0001 /* Last command was C-P, C-N */ -#define CFKILL 0x0002 /* Last command was a kill */ - -extern int thisflag; /* Flags, this command */ -extern int lastflag; /* Flags, last command */ - -extern int curgoal; /* Goal for C-P, C-N */ - -extern char sres[NBUFN]; /* Current screen resolution. */ - +#include "globals.h" #endif /* EDEF_H_ */ diff --git a/globals.c b/globals.c index 66274f6..429a3b5 100644 --- a/globals.c +++ b/globals.c @@ -1,7 +1,8 @@ -#include "defines.h" +/* globals.c -- implements global.h */ +#include "globals.h" -/* #include "estruct.h" */ -#include "edef.h" +#include "defines.h" +#include "retcode.h" /* initialized global definitions */ diff --git a/globals.h b/globals.h new file mode 100644 index 0000000..a11b16d --- /dev/null +++ b/globals.h @@ -0,0 +1,48 @@ +/* globals.h -- Global variable definitions */ + +#ifndef __GLOBALS_H__ +#define __GLOBALS_H__ + +/* Initialized global external declarations. */ + +extern int fillcol; /* Fill column */ + + +extern int eolexist; /* does clear to EOL exist? */ +extern int revexist; /* does reverse video exist? */ +extern int flickcode; /* do flicker supression? */ +extern int gfcolor; /* global forgrnd color (white) */ +extern int gbcolor; /* global backgrnd color (black) */ +extern int sgarbf; /* State of screen unknown */ +extern int clexec; /* command line execution flag */ +extern int discmd; /* display command flag */ +extern int disinp; /* display input characters */ + +extern int metac; /* current meta character */ +extern int ctlxc; /* current control X prefix char */ +extern int reptc; /* current universal repeat char */ +extern int abortc; /* current abort command char */ + +extern int tabmask; + + +extern int restflag; /* restricted use? */ +extern long envram; /* # of bytes current in use by malloc */ +extern int rval; /* return value of a subprocess */ +extern int overlap; /* line overlap in forw/back page */ +extern int scrollcount; /* number of lines to scroll */ + +/* Uninitialized global external declarations. */ + +#define CFCPCN 0x0001 /* Last command was C-P, C-N */ +#define CFKILL 0x0002 /* Last command was a kill */ + +extern int thisflag; /* Flags, this command */ +extern int lastflag; /* Flags, last command */ + +extern int curgoal; /* Goal for C-P, C-N */ + +extern char sres[] ; /* Current screen resolution. */ + + +#endif From 80256bdd6d29eeb6e9042550cc984ceddef73c90 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 9 Oct 2013 13:43:32 +0800 Subject: [PATCH 152/193] Remove edef.h, obsoleted by globals.h. --- Makefile | 95 +++++++++++++++++++++++++++--------------------------- ansi.c | 2 +- basic.c | 2 +- bind.c | 3 +- bindable.c | 3 +- buffer.c | 4 +-- display.c | 2 +- ebind.c | 3 +- edef.h | 16 --------- eval.c | 2 +- exec.c | 2 +- execute.c | 3 +- file.c | 2 +- ibmpc.c | 2 +- input.c | 3 +- isearch.c | 2 +- line.c | 3 +- lock.c | 2 +- main.c | 4 +-- pklock.c | 2 +- posix.c | 2 +- random.c | 2 +- region.c | 2 +- search.c | 3 +- spawn.c | 2 +- tcap.c | 2 +- vmsvt.c | 2 +- vt52.c | 2 +- window.c | 4 +-- word.c | 2 +- 30 files changed, 85 insertions(+), 95 deletions(-) delete mode 100644 edef.h diff --git a/Makefile b/Makefile index c279864..1314f83 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ -# Makefile for emacs, updated Wed, Oct 09, 2013 1:11:02 PM +# Makefile for emacs, updated Wed, Oct 09, 2013 1:41:31 PM SRC=ansi.c basic.c bind.c bindable.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c globals.c ibmpc.c input.c isearch.c line.c lock.c log.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c OBJ=ansi.o basic.o bind.o bindable.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o globals.o ibmpc.o input.o isearch.o line.o lock.o log.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o -HDR=basic.h bind.h bindable.h buffer.h crypt.h defines.h display.h ebind.h edef.h efunc.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h globals.h input.h isearch.h line.h lock.h log.h names.h pklock.h random.h region.h retcode.h search.h spawn.h terminal.h termio.h utf8.h version.h window.h word.h wrapper.h +HDR=basic.h bind.h bindable.h buffer.h crypt.h defines.h display.h ebind.h efunc.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h globals.h input.h isearch.h line.h lock.h log.h names.h pklock.h random.h region.h retcode.h search.h spawn.h terminal.h termio.h utf8.h version.h window.h word.h wrapper.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -126,83 +126,82 @@ depend: ${SRC} # DO NOT DELETE THIS LINE -- make depend uses it -ansi.o: ansi.c estruct.h retcode.h edef.h globals.h +ansi.o: ansi.c estruct.h retcode.h globals.h basic.o: basic.c basic.h buffer.h crypt.h line.h utf8.h display.h \ - estruct.h retcode.h edef.h globals.h input.h bind.h random.h terminal.h \ + estruct.h retcode.h globals.h input.h bind.h random.h terminal.h \ defines.h window.h -bind.o: bind.c bind.h edef.h estruct.h retcode.h globals.h bindable.h \ - buffer.h crypt.h line.h utf8.h display.h ebind.h exec.h file.h flook.h \ - input.h names.h window.h defines.h +bind.o: bind.c bind.h estruct.h retcode.h globals.h bindable.h buffer.h \ + crypt.h line.h utf8.h display.h ebind.h exec.h file.h flook.h input.h \ + names.h window.h defines.h bindable.o: bindable.c bindable.h defines.h buffer.h crypt.h line.h \ - utf8.h display.h edef.h estruct.h retcode.h globals.h file.h input.h \ - bind.h lock.h terminal.h + utf8.h display.h estruct.h retcode.h globals.h file.h input.h bind.h \ + lock.h terminal.h buffer.o: buffer.c buffer.h crypt.h line.h utf8.h defines.h display.h \ - edef.h estruct.h retcode.h globals.h file.h input.h bind.h window.h + estruct.h retcode.h globals.h file.h input.h bind.h window.h crypt.o: crypt.c crypt.h display.o: display.c display.h buffer.h crypt.h line.h utf8.h estruct.h \ - retcode.h edef.h globals.h input.h bind.h termio.h terminal.h defines.h \ + retcode.h globals.h input.h bind.h termio.h terminal.h defines.h \ version.h wrapper.h window.h -ebind.o: ebind.c ebind.h basic.h bind.h edef.h estruct.h retcode.h \ - globals.h bindable.h buffer.h crypt.h line.h utf8.h eval.h exec.h file.h \ - isearch.h random.h region.h search.h spawn.h window.h defines.h word.h +ebind.o: ebind.c ebind.h basic.h bind.h estruct.h retcode.h globals.h \ + bindable.h buffer.h crypt.h line.h utf8.h eval.h exec.h file.h isearch.h \ + random.h region.h search.h spawn.h window.h defines.h word.h eval.o: eval.c eval.h basic.h bind.h buffer.h crypt.h line.h utf8.h \ - display.h estruct.h retcode.h edef.h globals.h exec.h execute.h flook.h \ - input.h random.h search.h terminal.h defines.h termio.h version.h \ - window.h + display.h estruct.h retcode.h globals.h exec.h execute.h flook.h input.h \ + random.h search.h terminal.h defines.h termio.h version.h window.h exec.o: exec.c exec.h buffer.h crypt.h line.h utf8.h bind.h display.h \ - estruct.h retcode.h edef.h globals.h eval.h file.h flook.h input.h \ - window.h defines.h -execute.o: execute.c execute.h edef.h estruct.h retcode.h globals.h \ - bind.h random.h display.h file.h crypt.h buffer.h line.h utf8.h \ - terminal.h defines.h window.h + estruct.h retcode.h globals.h eval.h file.h flook.h input.h window.h \ + defines.h +execute.o: execute.c execute.h estruct.h retcode.h globals.h bind.h \ + random.h display.h file.h crypt.h buffer.h line.h utf8.h terminal.h \ + defines.h window.h file.o: file.c file.h crypt.h retcode.h buffer.h line.h utf8.h defines.h \ - estruct.h edef.h globals.h execute.h fileio.h input.h bind.h lock.h \ - log.h window.h + estruct.h globals.h execute.h fileio.h input.h bind.h lock.h log.h \ + window.h fileio.o: fileio.c fileio.h crypt.h retcode.h defines.h flook.o: flook.c flook.h retcode.h defines.h fileio.h crypt.h globals.o: globals.c globals.h defines.h retcode.h -ibmpc.o: ibmpc.c estruct.h retcode.h edef.h globals.h -input.o: input.c input.h bind.h edef.h estruct.h retcode.h globals.h \ - bindable.h display.h exec.h names.h terminal.h defines.h wrapper.h +ibmpc.o: ibmpc.c estruct.h retcode.h globals.h +input.o: input.c input.h bind.h estruct.h retcode.h globals.h bindable.h \ + display.h exec.h names.h terminal.h defines.h wrapper.h isearch.o: isearch.c isearch.h basic.h buffer.h crypt.h line.h utf8.h \ - display.h estruct.h retcode.h edef.h globals.h input.h bind.h search.h \ + display.h estruct.h retcode.h globals.h input.h bind.h search.h \ terminal.h defines.h window.h -line.o: line.c line.h utf8.h buffer.h crypt.h edef.h estruct.h retcode.h \ +line.o: line.c line.h utf8.h buffer.h crypt.h estruct.h retcode.h \ globals.h log.h window.h defines.h -lock.o: lock.c lock.h estruct.h retcode.h display.h edef.h globals.h \ - input.h bind.h +lock.o: lock.c lock.h estruct.h retcode.h display.h globals.h input.h \ + bind.h log.o: log.c log.h retcode.h main.o: main.c basic.h bind.h bindable.h buffer.h crypt.h line.h utf8.h \ - display.h edef.h estruct.h retcode.h globals.h eval.h execute.h file.h \ - input.h lock.h log.h random.h search.h terminal.h defines.h termio.h \ - version.h window.h + display.h estruct.h retcode.h globals.h eval.h execute.h file.h input.h \ + lock.h log.h random.h search.h terminal.h defines.h termio.h version.h \ + window.h names.o: names.c names.h basic.h bind.h bindable.h buffer.h crypt.h \ line.h utf8.h display.h eval.h exec.h file.h retcode.h isearch.h \ region.h random.h search.h spawn.h window.h defines.h word.h -pklock.o: pklock.c pklock.h estruct.h retcode.h edef.h globals.h +pklock.o: pklock.c pklock.h estruct.h retcode.h globals.h posix.o: posix.c termio.h random.o: random.c random.h basic.h buffer.h crypt.h line.h utf8.h \ - display.h estruct.h retcode.h edef.h globals.h execute.h input.h bind.h \ - log.h search.h terminal.h defines.h window.h + display.h estruct.h retcode.h globals.h execute.h input.h bind.h log.h \ + search.h terminal.h defines.h window.h region.o: region.c region.h line.h utf8.h buffer.h crypt.h estruct.h \ - retcode.h edef.h globals.h log.h window.h defines.h + retcode.h globals.h log.h window.h defines.h search.o: search.c search.h line.h utf8.h basic.h buffer.h crypt.h \ - display.h edef.h estruct.h retcode.h globals.h input.h bind.h log.h \ - terminal.h defines.h window.h + display.h estruct.h retcode.h globals.h input.h bind.h log.h terminal.h \ + defines.h window.h spawn.o: spawn.c spawn.h defines.h buffer.h crypt.h line.h utf8.h \ - display.h estruct.h retcode.h edef.h globals.h file.h flook.h input.h \ - bind.h log.h terminal.h window.h -tcap.o: tcap.c terminal.h defines.h display.h estruct.h retcode.h edef.h \ + display.h estruct.h retcode.h globals.h file.h flook.h input.h bind.h \ + log.h terminal.h window.h +tcap.o: tcap.c terminal.h defines.h display.h estruct.h retcode.h \ globals.h termio.h termio.o: termio.c termio.h estruct.h retcode.h utf8.h utf8.o: utf8.c utf8.h -vmsvt.o: vmsvt.c estruct.h retcode.h edef.h globals.h -vt52.o: vt52.c estruct.h retcode.h edef.h globals.h +vmsvt.o: vmsvt.c estruct.h retcode.h globals.h +vt52.o: vt52.c estruct.h retcode.h globals.h window.o: window.c window.h defines.h buffer.h crypt.h line.h utf8.h \ - basic.h display.h edef.h estruct.h retcode.h globals.h execute.h \ - terminal.h wrapper.h + basic.h display.h estruct.h retcode.h globals.h execute.h terminal.h \ + wrapper.h word.o: word.c word.h basic.h buffer.h crypt.h line.h utf8.h estruct.h \ - retcode.h edef.h globals.h log.h random.h region.h window.h defines.h + retcode.h globals.h log.h random.h region.h window.h defines.h wrapper.o: wrapper.c wrapper.h # DEPENDENCIES MUST END AT END OF FILE diff --git a/ansi.c b/ansi.c index a60eb64..041db06 100644 --- a/ansi.c +++ b/ansi.c @@ -11,7 +11,7 @@ #include #include "estruct.h" -#include "edef.h" +#include "globals.h" #if ANSI diff --git a/basic.c b/basic.c index edbe6c2..a88fff8 100644 --- a/basic.c +++ b/basic.c @@ -19,7 +19,7 @@ #include "buffer.h" #include "display.h" #include "estruct.h" -#include "edef.h" +#include "globals.h" #include "input.h" #include "line.h" #include "random.h" diff --git a/bind.c b/bind.c index b88b51c..782fd0f 100644 --- a/bind.c +++ b/bind.c @@ -13,7 +13,8 @@ #include #include -#include "edef.h" +#include "estruct.h" +#include "globals.h" #include "bindable.h" #include "buffer.h" #include "display.h" diff --git a/bindable.c b/bindable.c index 10fa26c..82d879e 100644 --- a/bindable.c +++ b/bindable.c @@ -7,7 +7,8 @@ #include "defines.h" #include "buffer.h" #include "display.h" -#include "edef.h" +#include "estruct.h" +#include "globals.h" #include "file.h" #include "input.h" #include "lock.h" diff --git a/buffer.c b/buffer.c index 9712d12..68fff57 100644 --- a/buffer.c +++ b/buffer.c @@ -18,8 +18,8 @@ #include "defines.h" #include "display.h" -/* #include "estruct.h" */ -#include "edef.h" +#include "estruct.h" +#include "globals.h" #include "file.h" #include "input.h" #include "window.h" diff --git a/display.c b/display.c index 7296a8c..a1994cc 100644 --- a/display.c +++ b/display.c @@ -20,7 +20,7 @@ #include "buffer.h" #include "estruct.h" -#include "edef.h" +#include "globals.h" #include "input.h" #include "line.h" #include "termio.h" diff --git a/ebind.c b/ebind.c index 7af8614..ce2bfd1 100644 --- a/ebind.c +++ b/ebind.c @@ -13,7 +13,8 @@ #include "basic.h" #include "bind.h" -#include "edef.h" +#include "estruct.h" +#include "globals.h" #include "bindable.h" #include "buffer.h" #include "eval.h" diff --git a/edef.h b/edef.h deleted file mode 100644 index 617e0e1..0000000 --- a/edef.h +++ /dev/null @@ -1,16 +0,0 @@ -/* edef.h - * - * Global variable definitions - * - * written by Dave G. Conroy - * modified by Steve Wilhite, George Jones - * greatly modified by Daniel Lawrence - * modified by Petri Kutvonen - */ -#ifndef EDEF_H_ -#define EDEF_H_ - -#include "estruct.h" -#include "globals.h" - -#endif /* EDEF_H_ */ diff --git a/eval.c b/eval.c index 0bd9efa..6b19832 100644 --- a/eval.c +++ b/eval.c @@ -18,7 +18,7 @@ #include "buffer.h" #include "display.h" #include "estruct.h" -#include "edef.h" +#include "globals.h" #include "exec.h" #include "execute.h" #include "flook.h" diff --git a/exec.c b/exec.c index 734c246..46dcbc7 100644 --- a/exec.c +++ b/exec.c @@ -18,7 +18,7 @@ #include "bind.h" #include "display.h" #include "estruct.h" -#include "edef.h" +#include "globals.h" #include "eval.h" #include "file.h" #include "flook.h" diff --git a/execute.c b/execute.c index 73ba632..c367b33 100644 --- a/execute.c +++ b/execute.c @@ -3,7 +3,8 @@ #include -#include "edef.h" +#include "estruct.h" +#include "globals.h" #include "bind.h" #include "random.h" #include "display.h" diff --git a/file.c b/file.c index 92a2301..d011ad9 100644 --- a/file.c +++ b/file.c @@ -19,7 +19,7 @@ #include "crypt.h" #include "defines.h" #include "estruct.h" -#include "edef.h" +#include "globals.h" #include "execute.h" #include "fileio.h" #include "input.h" diff --git a/ibmpc.c b/ibmpc.c index 577017d..217aa31 100644 --- a/ibmpc.c +++ b/ibmpc.c @@ -12,7 +12,7 @@ #include #include "estruct.h" -#include "edef.h" +#include "globals.h" #if IBMPC #if PKCODE diff --git a/input.c b/input.c index ae68c28..12e7b44 100644 --- a/input.c +++ b/input.c @@ -15,7 +15,8 @@ #include #include "bind.h" -#include "edef.h" +#include "estruct.h" +#include "globals.h" #include "bindable.h" #include "display.h" #include "exec.h" diff --git a/isearch.c b/isearch.c index 77d6ef4..74a7147 100644 --- a/isearch.c +++ b/isearch.c @@ -31,7 +31,7 @@ #include "buffer.h" #include "display.h" #include "estruct.h" -#include "edef.h" +#include "globals.h" #include "input.h" #include "line.h" #include "search.h" diff --git a/line.c b/line.c index 2c60c2e..3c07aec 100644 --- a/line.c +++ b/line.c @@ -21,7 +21,8 @@ #include #include "buffer.h" -#include "edef.h" +#include "estruct.h" +#include "globals.h" #include "log.h" #include "window.h" diff --git a/lock.c b/lock.c index 1f2f516..ac380ae 100644 --- a/lock.c +++ b/lock.c @@ -11,7 +11,7 @@ #include "display.h" #include "estruct.h" -#include "edef.h" +#include "globals.h" #include "input.h" #if (FILOCK && BSD) || SVR4 diff --git a/main.c b/main.c index e0b29ad..76af13a 100644 --- a/main.c +++ b/main.c @@ -64,8 +64,8 @@ #include "bindable.h" #include "buffer.h" #include "display.h" -#include "edef.h" /* Global definitions. */ -#include "estruct.h" /* Global structures and defines. */ +#include "estruct.h" /* Global structures and defines. */ +#include "globals.h" /* Global definitions. */ #include "eval.h" #include "execute.h" #include "file.h" diff --git a/pklock.c b/pklock.c index a403d76..8acf550 100644 --- a/pklock.c +++ b/pklock.c @@ -6,7 +6,7 @@ */ #include "estruct.h" -#include "edef.h" +#include "globals.h" #if (FILOCK && BSD) || SVR4 #include diff --git a/posix.c b/posix.c index 062f776..c6103ca 100644 --- a/posix.c +++ b/posix.c @@ -23,7 +23,7 @@ #include #include "estruct.h" -#include "edef.h" +#include "globals.h" #include "utf8.h" int ttrow = HUGE ; /* Row location of HW cursor */ diff --git a/random.c b/random.c index 3e445a3..0196ebf 100644 --- a/random.c +++ b/random.c @@ -16,7 +16,7 @@ #include "buffer.h" #include "display.h" #include "estruct.h" -#include "edef.h" +#include "globals.h" #include "execute.h" #include "input.h" #include "line.h" diff --git a/region.c b/region.c index 3a390b1..86a72ce 100644 --- a/region.c +++ b/region.c @@ -14,7 +14,7 @@ #include "buffer.h" #include "estruct.h" -#include "edef.h" +#include "globals.h" #include "line.h" #include "log.h" #include "window.h" diff --git a/search.c b/search.c index 4e46b50..7ef94b8 100644 --- a/search.c +++ b/search.c @@ -67,7 +67,8 @@ #include "basic.h" #include "buffer.h" #include "display.h" -#include "edef.h" +#include "estruct.h" +#include "globals.h" #include "input.h" #include "line.h" #include "log.h" diff --git a/spawn.c b/spawn.c index b872801..654354f 100644 --- a/spawn.c +++ b/spawn.c @@ -18,7 +18,7 @@ #include "buffer.h" #include "display.h" #include "estruct.h" -#include "edef.h" +#include "globals.h" #include "file.h" #include "flook.h" #include "input.h" diff --git a/tcap.c b/tcap.c index 59310de..9176c20 100644 --- a/tcap.c +++ b/tcap.c @@ -29,7 +29,7 @@ #include "display.h" #include "estruct.h" -#include "edef.h" +#include "globals.h" #include "termio.h" #if TERMCAP diff --git a/vmsvt.c b/vmsvt.c index b04dab0..ce599ae 100644 --- a/vmsvt.c +++ b/vmsvt.c @@ -11,7 +11,7 @@ #include /* Standard I/O package */ #include "estruct.h" /* Emacs' structures */ -#include "edef.h" /* Emacs' definitions */ +#include "globals.h" /* Emacs' definitions */ #if VMSVT diff --git a/vt52.c b/vt52.c index bec7267..4c13af0 100644 --- a/vt52.c +++ b/vt52.c @@ -15,7 +15,7 @@ #include #include "estruct.h" -#include "edef.h" +#include "globals.h" #if VT52 diff --git a/window.c b/window.c index dab5f8f..5ec64ff 100644 --- a/window.c +++ b/window.c @@ -14,8 +14,8 @@ #include "basic.h" #include "buffer.h" #include "display.h" -/* #include "estruct.h" */ -#include "edef.h" +#include "estruct.h" +#include "globals.h" #include "execute.h" #include "line.h" #include "terminal.h" diff --git a/word.c b/word.c index 3a3b0e8..21e3560 100644 --- a/word.c +++ b/word.c @@ -15,7 +15,7 @@ #include "basic.h" #include "buffer.h" #include "estruct.h" -#include "edef.h" +#include "globals.h" #include "line.h" #include "log.h" #include "random.h" From 886283859428b0f63339e5894be7212ce620f566 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 9 Oct 2013 14:03:56 +0800 Subject: [PATCH 153/193] Restflag moved from globals to file. --- file.c | 2 ++ file.h | 2 ++ globals.c | 1 - globals.h | 1 - 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/file.c b/file.c index d011ad9..5587889 100644 --- a/file.c +++ b/file.c @@ -49,6 +49,8 @@ static const char *eolname[] = { "MIXED" } ; +boolean restflag = FALSE ; /* restricted use? */ + /* * Read a file into the current * buffer. This is really easy; all you do it diff --git a/file.h b/file.h index d60e264..ab3ca71 100644 --- a/file.h +++ b/file.h @@ -11,6 +11,8 @@ void cryptbufferkey( struct buffer *bp) ; int set_encryption_key( int f, int n) ; #endif +extern boolean restflag ; /* restricted use? */ + int fileread( int f, int n) ; int insfile( int f, int n) ; int filefind( int f, int n) ; diff --git a/globals.c b/globals.c index 429a3b5..612ddd8 100644 --- a/globals.c +++ b/globals.c @@ -25,7 +25,6 @@ int abortc = CONTROL | 'G'; /* current abort command char */ int tabmask = 0x07; /* tabulator mask */ -int restflag = FALSE; /* restricted use? */ long envram = 0l; /* # of bytes current in use by malloc */ int rval = 0; /* return value of a subprocess */ int overlap = 0; /* line overlap in forw/back page */ diff --git a/globals.h b/globals.h index a11b16d..eadf57b 100644 --- a/globals.h +++ b/globals.h @@ -26,7 +26,6 @@ extern int abortc; /* current abort command char */ extern int tabmask; -extern int restflag; /* restricted use? */ extern long envram; /* # of bytes current in use by malloc */ extern int rval; /* return value of a subprocess */ extern int overlap; /* line overlap in forw/back page */ From 0f6ff70764fa0f7c1b0d3e2712b9ceb634643c6a Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 9 Oct 2013 14:38:55 +0800 Subject: [PATCH 154/193] Move variables from globals to corresponding modules. --- basic.c | 4 ++++ basic.h | 2 ++ display.c | 1 + display.h | 1 + eval.c | 3 +++ eval.h | 2 ++ globals.c | 5 ----- globals.h | 6 ------ tcap.c | 2 ++ terminal.h | 2 ++ 10 files changed, 17 insertions(+), 11 deletions(-) diff --git a/basic.c b/basic.c index a88fff8..96b6715 100644 --- a/basic.c +++ b/basic.c @@ -27,6 +27,10 @@ #include "utf8.h" #include "window.h" + +int overlap = 0 ; /* line overlap in forw/back page */ + + /* * This routine, given a pointer to a struct line, and the current cursor goal * column, return the best choice for the offset. The offset is returned. diff --git a/basic.h b/basic.h index 1b0f6ee..27ba4d4 100644 --- a/basic.h +++ b/basic.h @@ -1,6 +1,8 @@ #ifndef _BASIC_H_ #define _BASIC_H_ +extern int overlap ; /* line overlap in forw/back page */ + int gotobol( int f, int n) ; int gotoeol( int f, int n) ; int gotoline( int f, int n) ; diff --git a/display.c b/display.c index a1994cc..68cc8b1 100644 --- a/display.c +++ b/display.c @@ -70,6 +70,7 @@ static int lbound = 0 ; /* leftmost column of current line being displayed */ static int taboff = 0 ; /* tab offset for display */ int mpresf = FALSE ; /* TRUE if message in last line */ +int scrollcount = 1 ; /* number of lines to scroll */ static int reframe(struct window *wp); static void updone(struct window *wp); diff --git a/display.h b/display.h index b5ecbd4..8892a8f 100644 --- a/display.h +++ b/display.h @@ -2,6 +2,7 @@ #define _DISPLAY_H_ extern int mpresf ; /* Stuff in message line */ +extern int scrollcount ; /* number of lines to scroll */ void vtinit( void) ; void vtfree( void) ; diff --git a/eval.c b/eval.c index 6b19832..05f9c0a 100644 --- a/eval.c +++ b/eval.c @@ -47,6 +47,9 @@ int cmdstatus = TRUE ; /* last command status */ static int saveflag = 0 ; /* Flags, saved with the $target var */ +long envram = 0l ; /* # of bytes current in use by malloc */ + + /* Max #chars in a var name. */ #define NVSIZE 10 diff --git a/eval.h b/eval.h index 85fe51f..3b1d9ea 100644 --- a/eval.h +++ b/eval.h @@ -19,6 +19,8 @@ extern int gflags ; /* global control flag */ extern int macbug ; /* macro debuging flag */ extern int cmdstatus ; /* last command status */ +extern long envram ; /* # of bytes current in use by malloc */ + /* Macro argument token types */ #define TKNUL 0 /* end-of-string */ diff --git a/globals.c b/globals.c index 612ddd8..51787d0 100644 --- a/globals.c +++ b/globals.c @@ -25,15 +25,10 @@ int abortc = CONTROL | 'G'; /* current abort command char */ int tabmask = 0x07; /* tabulator mask */ -long envram = 0l; /* # of bytes current in use by malloc */ int rval = 0; /* return value of a subprocess */ -int overlap = 0; /* line overlap in forw/back page */ -int scrollcount = 1; /* number of lines to scroll */ /* uninitialized global definitions */ int thisflag; /* Flags, this command */ int lastflag; /* Flags, last command */ int curgoal; /* Goal for C-P, C-N */ - -char sres[NBUFN]; /* current screen resolution */ diff --git a/globals.h b/globals.h index eadf57b..16229d7 100644 --- a/globals.h +++ b/globals.h @@ -26,10 +26,7 @@ extern int abortc; /* current abort command char */ extern int tabmask; -extern long envram; /* # of bytes current in use by malloc */ extern int rval; /* return value of a subprocess */ -extern int overlap; /* line overlap in forw/back page */ -extern int scrollcount; /* number of lines to scroll */ /* Uninitialized global external declarations. */ @@ -41,7 +38,4 @@ extern int lastflag; /* Flags, last command */ extern int curgoal; /* Goal for C-P, C-N */ -extern char sres[] ; /* Current screen resolution. */ - - #endif diff --git a/tcap.c b/tcap.c index 9176c20..b10bbc1 100644 --- a/tcap.c +++ b/tcap.c @@ -34,6 +34,8 @@ #if TERMCAP +char sres[ NBUFN] ; /* current screen resolution */ + #if UNIX #include #endif diff --git a/terminal.h b/terminal.h index 2e4701f..d979b6b 100644 --- a/terminal.h +++ b/terminal.h @@ -70,4 +70,6 @@ extern struct terminal term ; extern int ttrow ; /* Row location of HW cursor */ extern int ttcol ; /* Column location of HW cursor */ +extern char sres[] ; /* Current screen resolution. */ + #endif From f166293e7365cae699922af6da902bae05368881 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 9 Oct 2013 14:56:43 +0800 Subject: [PATCH 155/193] Clean up extern's in C files. --- display.h | 3 +++ main.c | 11 +++++------ search.c | 1 - 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/display.h b/display.h index 8892a8f..e3b9b13 100644 --- a/display.h +++ b/display.h @@ -21,6 +21,9 @@ void mlwrite( const char *fmt, ...) ; void mlforce( char *s) ; void mlputs( char *s) ; void getscreensize( int *widthp, int *heightp) ; + +#ifdef SIGWINCH void sizesignal( int signr) ; +#endif #endif diff --git a/main.c b/main.c index 76af13a..994eb7b 100644 --- a/main.c +++ b/main.c @@ -59,12 +59,16 @@ #include #include +#include "estruct.h" /* Global structures and defines. */ +#if UNIX +#include +#endif + #include "basic.h" #include "bind.h" #include "bindable.h" #include "buffer.h" #include "display.h" -#include "estruct.h" /* Global structures and defines. */ #include "globals.h" /* Global definitions. */ #include "eval.h" #include "execute.h" @@ -89,11 +93,6 @@ extern unsigned _stklen = 32766; #endif #if UNIX -#include -#ifdef SIGWINCH -extern void sizesignal(int); -#endif - static void emergencyexit(int signr) { quickexit(FALSE, 0); diff --git a/search.c b/search.c index 7ef94b8..1b9cc7a 100644 --- a/search.c +++ b/search.c @@ -1471,7 +1471,6 @@ static int mceq(int bc, struct magic *mt) return result; } -extern char *clearbits(void); /* * cclmake -- create the bitmap for the character class. From 867f0d9d6023cbbf06b2cae27f572837f5e3c2e3 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 9 Oct 2013 16:11:43 +0800 Subject: [PATCH 156/193] Display related global flags moved to terminal/tcap. --- globals.c | 4 +--- globals.h | 2 -- tcap.c | 3 +++ terminal.h | 4 ++++ 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/globals.c b/globals.c index 51787d0..a899891 100644 --- a/globals.c +++ b/globals.c @@ -1,4 +1,4 @@ -/* globals.c -- implements global.h */ +/* globals.c -- implements globals.h */ #include "globals.h" #include "defines.h" @@ -9,8 +9,6 @@ int fillcol = 72; /* Current fill column */ -int eolexist = TRUE; /* does clear to EOL exist */ -int revexist = FALSE; /* does reverse video exist? */ int flickcode = FALSE; /* do flicker supression? */ int sgarbf = TRUE; /* TRUE if screen is garbage */ int clexec = FALSE; /* command line execution flag */ diff --git a/globals.h b/globals.h index 16229d7..3af7f50 100644 --- a/globals.h +++ b/globals.h @@ -8,8 +8,6 @@ extern int fillcol; /* Fill column */ -extern int eolexist; /* does clear to EOL exist? */ -extern int revexist; /* does reverse video exist? */ extern int flickcode; /* do flicker supression? */ extern int gfcolor; /* global forgrnd color (white) */ extern int gbcolor; /* global backgrnd color (black) */ diff --git a/tcap.c b/tcap.c index b10bbc1..d08c4fd 100644 --- a/tcap.c +++ b/tcap.c @@ -34,6 +34,9 @@ #if TERMCAP +boolean eolexist = TRUE ; /* does clear to EOL exist */ +boolean revexist = FALSE ; /* does reverse video exist? */ + char sres[ NBUFN] ; /* current screen resolution */ #if UNIX diff --git a/terminal.h b/terminal.h index d979b6b..2a8956d 100644 --- a/terminal.h +++ b/terminal.h @@ -3,6 +3,7 @@ #include "defines.h" /* COLOR, SCROLLCODE */ +#include "retcode.h" /* * The editor communicates with the display using a high level interface. A @@ -70,6 +71,9 @@ extern struct terminal term ; extern int ttrow ; /* Row location of HW cursor */ extern int ttcol ; /* Column location of HW cursor */ +extern boolean eolexist ; /* does clear to EOL exist? */ +extern boolean revexist ; /* does reverse video exist? */ + extern char sres[] ; /* Current screen resolution. */ #endif From f03b7c97e3cc4cfd02e5703b987f72af2cb4abd4 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 9 Oct 2013 16:58:33 +0800 Subject: [PATCH 157/193] Move globals variables to related modules. --- display.c | 1 + display.h | 3 +++ eval.c | 1 + eval.h | 2 +- globals.c | 4 ---- globals.h | 6 ------ input.c | 2 ++ input.h | 3 ++- tcap.c | 1 + terminal.h | 1 + 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/display.c b/display.c index 68cc8b1..415b0c3 100644 --- a/display.c +++ b/display.c @@ -71,6 +71,7 @@ static int taboff = 0 ; /* tab offset for display */ int mpresf = FALSE ; /* TRUE if message in last line */ int scrollcount = 1 ; /* number of lines to scroll */ +int discmd = TRUE ; /* display command flag */ static int reframe(struct window *wp); static void updone(struct window *wp); diff --git a/display.h b/display.h index e3b9b13..84ab229 100644 --- a/display.h +++ b/display.h @@ -3,6 +3,9 @@ extern int mpresf ; /* Stuff in message line */ extern int scrollcount ; /* number of lines to scroll */ +extern int discmd ; /* display command flag */ +extern int gfcolor ; /* global forgrnd color (white) */ +extern int gbcolor ; /* global backgrnd color (black) */ void vtinit( void) ; void vtfree( void) ; diff --git a/eval.c b/eval.c index 05f9c0a..6ef6f0b 100644 --- a/eval.c +++ b/eval.c @@ -43,6 +43,7 @@ char outline[ NSTRING] ; /* global string to hold debug line text */ int gflags = GFREAD ; /* global control flag */ int macbug = FALSE ; /* macro debuging flag */ int cmdstatus = TRUE ; /* last command status */ +int flickcode = FALSE ; /* do flicker supression? */ static int saveflag = 0 ; /* Flags, saved with the $target var */ diff --git a/eval.h b/eval.h index 3b1d9ea..2b72134 100644 --- a/eval.h +++ b/eval.h @@ -18,7 +18,7 @@ extern char outline[] ; /* Global string to hold debug line text. */ extern int gflags ; /* global control flag */ extern int macbug ; /* macro debuging flag */ extern int cmdstatus ; /* last command status */ - +extern int flickcode ; /* do flicker supression? */ extern long envram ; /* # of bytes current in use by malloc */ /* Macro argument token types */ diff --git a/globals.c b/globals.c index a899891..3f57941 100644 --- a/globals.c +++ b/globals.c @@ -9,11 +9,7 @@ int fillcol = 72; /* Current fill column */ -int flickcode = FALSE; /* do flicker supression? */ -int sgarbf = TRUE; /* TRUE if screen is garbage */ int clexec = FALSE; /* command line execution flag */ -int discmd = TRUE; /* display command flag */ -int disinp = TRUE; /* display input characters */ int metac = CONTROL | '['; /* current meta character */ int ctlxc = CONTROL | 'X'; /* current control X prefix char */ diff --git a/globals.h b/globals.h index 3af7f50..f6be871 100644 --- a/globals.h +++ b/globals.h @@ -8,13 +8,7 @@ extern int fillcol; /* Fill column */ -extern int flickcode; /* do flicker supression? */ -extern int gfcolor; /* global forgrnd color (white) */ -extern int gbcolor; /* global backgrnd color (black) */ -extern int sgarbf; /* State of screen unknown */ extern int clexec; /* command line execution flag */ -extern int discmd; /* display command flag */ -extern int disinp; /* display input characters */ extern int metac; /* current meta character */ extern int ctlxc; /* current control X prefix char */ diff --git a/input.c b/input.c index 12e7b44..9672b92 100644 --- a/input.c +++ b/input.c @@ -45,6 +45,8 @@ kbdstate kbdmode = STOP ; /* current keyboard macro mode */ int lastkey = 0 ; /* last keystoke */ int kbdrep = 0 ; /* number of repetitions */ +int disinp = TRUE ; /* display input characters */ + static const int quotec = 0x11 ; /* quote char during mlreply() */ /* diff --git a/input.h b/input.h index 1dd1970..6c30dd3 100644 --- a/input.h +++ b/input.h @@ -12,7 +12,8 @@ extern int lastkey ; /* last keystoke */ extern int kbdrep ; /* number of repetitions */ extern int kbdm[] ; /* Holds kayboard macro data */ extern int *kbdptr ; /* current position in keyboard buf */ -extern int *kbdend ; /* ptr to end of the keyboard */ +extern int *kbdend ; /* ptr to end of the keyboard */ +extern int disinp ; /* display input characters */ int mlyesno( const char *prompt) ; int mlreply( const char *prompt, char *buf, int nbuf) ; diff --git a/tcap.c b/tcap.c index d08c4fd..1fe3621 100644 --- a/tcap.c +++ b/tcap.c @@ -36,6 +36,7 @@ boolean eolexist = TRUE ; /* does clear to EOL exist */ boolean revexist = FALSE ; /* does reverse video exist? */ +boolean sgarbf = TRUE ; /* TRUE if screen is garbage */ char sres[ NBUFN] ; /* current screen resolution */ diff --git a/terminal.h b/terminal.h index 2a8956d..1fe04ed 100644 --- a/terminal.h +++ b/terminal.h @@ -73,6 +73,7 @@ extern int ttcol ; /* Column location of HW cursor */ extern boolean eolexist ; /* does clear to EOL exist? */ extern boolean revexist ; /* does reverse video exist? */ +extern boolean sgarbf ; /* State of screen unknown */ extern char sres[] ; /* Current screen resolution. */ From 0fdefdba7c17e53a114c16019e788e658d459637 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Thu, 10 Oct 2013 09:55:03 +0800 Subject: [PATCH 158/193] Move clexec from globals to exec. --- Makefile | 24 ++++++++++++------------ exec.c | 6 ++++-- exec.h | 5 +++++ globals.c | 3 --- globals.h | 3 --- isearch.c | 1 + spawn.c | 2 +- 7 files changed, 23 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 1314f83..6dd2970 100644 --- a/Makefile +++ b/Makefile @@ -148,8 +148,8 @@ ebind.o: ebind.c ebind.h basic.h bind.h estruct.h retcode.h globals.h \ eval.o: eval.c eval.h basic.h bind.h buffer.h crypt.h line.h utf8.h \ display.h estruct.h retcode.h globals.h exec.h execute.h flook.h input.h \ random.h search.h terminal.h defines.h termio.h version.h window.h -exec.o: exec.c exec.h buffer.h crypt.h line.h utf8.h bind.h display.h \ - estruct.h retcode.h globals.h eval.h file.h flook.h input.h window.h \ +exec.o: exec.c exec.h retcode.h buffer.h crypt.h line.h utf8.h bind.h \ + display.h estruct.h globals.h eval.h file.h flook.h input.h window.h \ defines.h execute.o: execute.c execute.h estruct.h retcode.h globals.h bind.h \ random.h display.h file.h crypt.h buffer.h line.h utf8.h terminal.h \ @@ -159,24 +159,24 @@ file.o: file.c file.h crypt.h retcode.h buffer.h line.h utf8.h defines.h \ window.h fileio.o: fileio.c fileio.h crypt.h retcode.h defines.h flook.o: flook.c flook.h retcode.h defines.h fileio.h crypt.h -globals.o: globals.c globals.h defines.h retcode.h +globals.o: globals.c globals.h defines.h ibmpc.o: ibmpc.c estruct.h retcode.h globals.h input.o: input.c input.h bind.h estruct.h retcode.h globals.h bindable.h \ display.h exec.h names.h terminal.h defines.h wrapper.h isearch.o: isearch.c isearch.h basic.h buffer.h crypt.h line.h utf8.h \ - display.h estruct.h retcode.h globals.h input.h bind.h search.h \ + display.h estruct.h retcode.h globals.h exec.h input.h bind.h search.h \ terminal.h defines.h window.h line.o: line.c line.h utf8.h buffer.h crypt.h estruct.h retcode.h \ globals.h log.h window.h defines.h lock.o: lock.c lock.h estruct.h retcode.h display.h globals.h input.h \ bind.h log.o: log.c log.h retcode.h -main.o: main.c basic.h bind.h bindable.h buffer.h crypt.h line.h utf8.h \ - display.h estruct.h retcode.h globals.h eval.h execute.h file.h input.h \ - lock.h log.h random.h search.h terminal.h defines.h termio.h version.h \ - window.h +main.o: main.c estruct.h retcode.h basic.h bind.h bindable.h buffer.h \ + crypt.h line.h utf8.h display.h globals.h eval.h execute.h file.h \ + input.h lock.h log.h random.h search.h terminal.h defines.h termio.h \ + version.h window.h names.o: names.c names.h basic.h bind.h bindable.h buffer.h crypt.h \ - line.h utf8.h display.h eval.h exec.h file.h retcode.h isearch.h \ + line.h utf8.h display.h eval.h exec.h retcode.h file.h isearch.h \ region.h random.h search.h spawn.h window.h defines.h word.h pklock.o: pklock.c pklock.h estruct.h retcode.h globals.h posix.o: posix.c termio.h @@ -189,9 +189,9 @@ search.o: search.c search.h line.h utf8.h basic.h buffer.h crypt.h \ display.h estruct.h retcode.h globals.h input.h bind.h log.h terminal.h \ defines.h window.h spawn.o: spawn.c spawn.h defines.h buffer.h crypt.h line.h utf8.h \ - display.h estruct.h retcode.h globals.h file.h flook.h input.h bind.h \ - log.h terminal.h window.h -tcap.o: tcap.c terminal.h defines.h display.h estruct.h retcode.h \ + display.h estruct.h retcode.h exec.h file.h flook.h input.h bind.h log.h \ + terminal.h window.h +tcap.o: tcap.c terminal.h defines.h retcode.h display.h estruct.h \ globals.h termio.h termio.o: termio.c termio.h estruct.h retcode.h utf8.h utf8.o: utf8.c utf8.h diff --git a/exec.c b/exec.c index 46dcbc7..cfad97e 100644 --- a/exec.c +++ b/exec.c @@ -28,6 +28,8 @@ char *execstr = NULL ; /* pointer to string to execute */ +boolean clexec = FALSE ; /* command line execution flag */ + /* Directive definitions */ @@ -138,7 +140,7 @@ int docmd(char *cline) int n; /* numeric repeat value */ fn_t fnc; /* function to execute */ int status; /* return status of function */ - int oldcle; /* old contents of clexec flag */ + boolean oldcle ; /* old contents of clexec flag */ char *oldestr; /* original exec string */ char tkn[NSTRING]; /* next token off of command line */ @@ -272,7 +274,7 @@ char *token(char *src, char *tok, int size) */ int macarg(char *tok) { - int savcle; /* buffer to store original clexec */ + boolean savcle ; /* buffer to store original clexec */ int status; savcle = clexec; /* save execution mode */ diff --git a/exec.h b/exec.h index cd0fb8a..b82c6b9 100644 --- a/exec.h +++ b/exec.h @@ -1,6 +1,9 @@ #ifndef _EXEC_H_ #define _EXEC_H_ +#include "retcode.h" + + #define PROC 1 /* named procedures */ #if PROC @@ -10,6 +13,8 @@ int execproc( int f, int n) ; extern char *execstr ; /* pointer to string to execute */ +extern boolean clexec ; /* command line execution flag */ + int namedcmd( int f, int n) ; diff --git a/globals.c b/globals.c index 3f57941..4de1ca5 100644 --- a/globals.c +++ b/globals.c @@ -2,15 +2,12 @@ #include "globals.h" #include "defines.h" -#include "retcode.h" /* initialized global definitions */ int fillcol = 72; /* Current fill column */ -int clexec = FALSE; /* command line execution flag */ - int metac = CONTROL | '['; /* current meta character */ int ctlxc = CONTROL | 'X'; /* current control X prefix char */ int reptc = CONTROL | 'U'; /* current universal repeat char */ diff --git a/globals.h b/globals.h index f6be871..99cb63b 100644 --- a/globals.h +++ b/globals.h @@ -7,9 +7,6 @@ extern int fillcol; /* Fill column */ - -extern int clexec; /* command line execution flag */ - extern int metac; /* current meta character */ extern int ctlxc; /* current control X prefix char */ extern int reptc; /* current universal repeat char */ diff --git a/isearch.c b/isearch.c index 74a7147..c100963 100644 --- a/isearch.c +++ b/isearch.c @@ -32,6 +32,7 @@ #include "display.h" #include "estruct.h" #include "globals.h" +#include "exec.h" #include "input.h" #include "line.h" #include "search.h" diff --git a/spawn.c b/spawn.c index 654354f..2a55bff 100644 --- a/spawn.c +++ b/spawn.c @@ -18,7 +18,7 @@ #include "buffer.h" #include "display.h" #include "estruct.h" -#include "globals.h" +#include "exec.h" #include "file.h" #include "flook.h" #include "input.h" From 96ca2e8580ff741135651ba7b3e0e4cace8ffb5d Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Thu, 10 Oct 2013 11:13:49 +0800 Subject: [PATCH 159/193] Move global fillcol to random. --- globals.c | 3 --- globals.h | 2 -- random.c | 8 +++++--- random.h | 4 +++- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/globals.c b/globals.c index 4de1ca5..73c61b4 100644 --- a/globals.c +++ b/globals.c @@ -5,9 +5,6 @@ /* initialized global definitions */ -int fillcol = 72; /* Current fill column */ - - int metac = CONTROL | '['; /* current meta character */ int ctlxc = CONTROL | 'X'; /* current control X prefix char */ int reptc = CONTROL | 'U'; /* current universal repeat char */ diff --git a/globals.h b/globals.h index 99cb63b..e2e10b4 100644 --- a/globals.h +++ b/globals.h @@ -5,8 +5,6 @@ /* Initialized global external declarations. */ -extern int fillcol; /* Fill column */ - extern int metac; /* current meta character */ extern int ctlxc; /* current control X prefix char */ extern int reptc; /* current universal repeat char */ diff --git a/random.c b/random.c index 0196ebf..14d0275 100644 --- a/random.c +++ b/random.c @@ -36,10 +36,12 @@ static const char *cname[] = { /* names of colors */ #define NCOLORS (sizeof cname / sizeof( *cname)) /* # of supported colors */ -int gfcolor = NCOLORS - 1 ; /* global forgrnd color (white) */ -int gbcolor = 0 ; /* global backgrnd color (black) */ +int gfcolor = NCOLORS - 1 ; /* global forgrnd color (white) */ +int gbcolor = 0 ; /* global backgrnd color (black) */ + +int tabsize ; /* Tab size (0: use real tabs) */ +int fillcol = 72 ; /* Current fill column */ -int tabsize; /* Tab size (0: use real tabs) */ /* * Set fill column to n. diff --git a/random.h b/random.h index fe7e4df..c9bed3c 100644 --- a/random.h +++ b/random.h @@ -3,7 +3,9 @@ #define AEDIT 1 -extern int tabsize ; /* Tab size (0: use real tabs). */ +extern int tabsize ; /* Tab size (0: use real tabs). */ +extern int fillcol ; /* Fill column */ + int setfillcol( int f, int n) ; int showcpos( int f, int n) ; From bd14ff374f5019cf53d24cc1634a37c7ca33ab4f Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Thu, 10 Oct 2013 11:42:33 +0800 Subject: [PATCH 160/193] Move globals rval and tabmask to eval and line. --- estruct.h | 1 - eval.c | 4 +++- eval.h | 1 + globals.c | 5 ----- globals.h | 5 ----- line.c | 3 +++ line.h | 3 +++ 7 files changed, 10 insertions(+), 12 deletions(-) diff --git a/estruct.h b/estruct.h index dccfcd2..eecc1d8 100644 --- a/estruct.h +++ b/estruct.h @@ -249,7 +249,6 @@ /* Internal defined functions */ -#define nextab(a) (a & ~tabmask) + (tabmask+1) #ifdef abs #undef abs #endif diff --git a/eval.c b/eval.c index 6ef6f0b..58aac09 100644 --- a/eval.c +++ b/eval.c @@ -40,10 +40,12 @@ char outline[ NSTRING] ; /* global string to hold debug line text */ #endif -int gflags = GFREAD ; /* global control flag */ +int gflags = GFREAD ; /* global control flag */ int macbug = FALSE ; /* macro debuging flag */ int cmdstatus = TRUE ; /* last command status */ int flickcode = FALSE ; /* do flicker supression? */ +int rval = 0 ; /* return value of a subprocess */ + static int saveflag = 0 ; /* Flags, saved with the $target var */ diff --git a/eval.h b/eval.h index 2b72134..fd674eb 100644 --- a/eval.h +++ b/eval.h @@ -19,6 +19,7 @@ extern int gflags ; /* global control flag */ extern int macbug ; /* macro debuging flag */ extern int cmdstatus ; /* last command status */ extern int flickcode ; /* do flicker supression? */ +extern int rval ; /* return value of a subprocess */ extern long envram ; /* # of bytes current in use by malloc */ /* Macro argument token types */ diff --git a/globals.c b/globals.c index 73c61b4..ec7903b 100644 --- a/globals.c +++ b/globals.c @@ -10,11 +10,6 @@ int ctlxc = CONTROL | 'X'; /* current control X prefix char */ int reptc = CONTROL | 'U'; /* current universal repeat char */ int abortc = CONTROL | 'G'; /* current abort command char */ -int tabmask = 0x07; /* tabulator mask */ - - -int rval = 0; /* return value of a subprocess */ - /* uninitialized global definitions */ int thisflag; /* Flags, this command */ diff --git a/globals.h b/globals.h index e2e10b4..63b717c 100644 --- a/globals.h +++ b/globals.h @@ -10,11 +10,6 @@ extern int ctlxc; /* current control X prefix char */ extern int reptc; /* current universal repeat char */ extern int abortc; /* current abort command char */ -extern int tabmask; - - -extern int rval; /* return value of a subprocess */ - /* Uninitialized global external declarations. */ #define CFCPCN 0x0001 /* Last command was C-P, C-N */ diff --git a/line.c b/line.c index 3c07aec..25e7d5d 100644 --- a/line.c +++ b/line.c @@ -26,6 +26,9 @@ #include "log.h" #include "window.h" + +int tabmask = 0x07 ; /* tabulator mask */ + #define BLOCK_SIZE 16 /* Line block chunk size. */ static int ldelnewline( void) ; diff --git a/line.h b/line.h index cdcc55e..2080899 100644 --- a/line.h +++ b/line.h @@ -25,6 +25,9 @@ struct line { #define lputc(lp, n, c) ((lp)->l_text[(n)]=(c)) #define llength(lp) ((lp)->l_used) +#define nextab(a) (a & ~tabmask) + (tabmask+1) +extern int tabmask ; + char *getkill( void) ; int backchar( int f, int n) ; From ceac004e303d886a691a06bdaa32a72ecc627cd6 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Thu, 10 Oct 2013 11:49:04 +0800 Subject: [PATCH 161/193] Move global curgoal to basic. --- basic.c | 3 ++- basic.h | 4 +++- globals.c | 1 - globals.h | 2 -- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/basic.c b/basic.c index 96b6715..096b04b 100644 --- a/basic.c +++ b/basic.c @@ -28,7 +28,8 @@ #include "window.h" -int overlap = 0 ; /* line overlap in forw/back page */ +int overlap = 0 ; /* line overlap in forw/back page */ +int curgoal ; /* Goal for C-P, C-N */ /* diff --git a/basic.h b/basic.h index 27ba4d4..20631db 100644 --- a/basic.h +++ b/basic.h @@ -1,7 +1,9 @@ #ifndef _BASIC_H_ #define _BASIC_H_ -extern int overlap ; /* line overlap in forw/back page */ +extern int overlap ; /* line overlap in forw/back page */ +extern int curgoal ; /* Goal for C-P, C-N */ + int gotobol( int f, int n) ; int gotoeol( int f, int n) ; diff --git a/globals.c b/globals.c index ec7903b..6e2ab1e 100644 --- a/globals.c +++ b/globals.c @@ -14,4 +14,3 @@ int abortc = CONTROL | 'G'; /* current abort command char */ int thisflag; /* Flags, this command */ int lastflag; /* Flags, last command */ -int curgoal; /* Goal for C-P, C-N */ diff --git a/globals.h b/globals.h index 63b717c..cc5ac42 100644 --- a/globals.h +++ b/globals.h @@ -18,6 +18,4 @@ extern int abortc; /* current abort command char */ extern int thisflag; /* Flags, this command */ extern int lastflag; /* Flags, last command */ -extern int curgoal; /* Goal for C-P, C-N */ - #endif From 2fe2d9c153e6f120d609989f3d92bb8539951821 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Thu, 10 Oct 2013 12:33:13 +0800 Subject: [PATCH 162/193] Finish move of globals into input and random. Remove globals. --- Makefile | 97 ++++++++++++++++++++++++++---------------------------- ansi.c | 2 +- basic.c | 1 - bind.c | 1 - bindable.c | 1 - buffer.c | 1 - display.c | 1 - ebind.c | 1 - eval.c | 1 - exec.c | 2 +- execute.c | 1 - file.c | 1 - globals.c | 16 --------- globals.h | 21 ------------ ibmpc.c | 1 - input.c | 8 +++-- input.h | 5 +++ isearch.c | 1 - line.c | 1 - lock.c | 1 - main.c | 1 - pklock.c | 1 - posix.c | 1 - random.c | 6 +++- random.h | 8 +++++ region.c | 2 +- search.c | 1 - tcap.c | 1 - vmsvt.c | 1 - vt52.c | 1 - window.c | 1 - word.c | 1 - 32 files changed, 73 insertions(+), 116 deletions(-) delete mode 100644 globals.c delete mode 100644 globals.h diff --git a/Makefile b/Makefile index 6dd2970..910f67c 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ -# Makefile for emacs, updated Wed, Oct 09, 2013 1:41:31 PM +# Makefile for emacs, updated Thu, Oct 10, 2013 12:28:18 PM -SRC=ansi.c basic.c bind.c bindable.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c globals.c ibmpc.c input.c isearch.c line.c lock.c log.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c -OBJ=ansi.o basic.o bind.o bindable.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o globals.o ibmpc.o input.o isearch.o line.o lock.o log.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o -HDR=basic.h bind.h bindable.h buffer.h crypt.h defines.h display.h ebind.h efunc.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h globals.h input.h isearch.h line.h lock.h log.h names.h pklock.h random.h region.h retcode.h search.h spawn.h terminal.h termio.h utf8.h version.h window.h word.h wrapper.h +SRC=ansi.c basic.c bind.c bindable.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c ibmpc.c input.c isearch.c line.c lock.c log.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c +OBJ=ansi.o basic.o bind.o bindable.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o ibmpc.o input.o isearch.o line.o lock.o log.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o +HDR=basic.h bind.h bindable.h buffer.h crypt.h defines.h display.h ebind.h efunc.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h log.h names.h pklock.h random.h region.h retcode.h search.h spawn.h terminal.h termio.h utf8.h version.h window.h word.h wrapper.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -126,82 +126,77 @@ depend: ${SRC} # DO NOT DELETE THIS LINE -- make depend uses it -ansi.o: ansi.c estruct.h retcode.h globals.h +ansi.o: ansi.c estruct.h retcode.h basic.o: basic.c basic.h buffer.h crypt.h line.h utf8.h display.h \ - estruct.h retcode.h globals.h input.h bind.h random.h terminal.h \ - defines.h window.h -bind.o: bind.c bind.h estruct.h retcode.h globals.h bindable.h buffer.h \ - crypt.h line.h utf8.h display.h ebind.h exec.h file.h flook.h input.h \ - names.h window.h defines.h + estruct.h retcode.h input.h bind.h random.h terminal.h defines.h \ + window.h +bind.o: bind.c bind.h estruct.h retcode.h bindable.h buffer.h crypt.h \ + line.h utf8.h display.h ebind.h exec.h file.h flook.h input.h names.h \ + window.h defines.h bindable.o: bindable.c bindable.h defines.h buffer.h crypt.h line.h \ - utf8.h display.h estruct.h retcode.h globals.h file.h input.h bind.h \ - lock.h terminal.h + utf8.h display.h estruct.h retcode.h file.h input.h bind.h lock.h \ + terminal.h buffer.o: buffer.c buffer.h crypt.h line.h utf8.h defines.h display.h \ - estruct.h retcode.h globals.h file.h input.h bind.h window.h + estruct.h retcode.h file.h input.h bind.h window.h crypt.o: crypt.c crypt.h display.o: display.c display.h buffer.h crypt.h line.h utf8.h estruct.h \ - retcode.h globals.h input.h bind.h termio.h terminal.h defines.h \ - version.h wrapper.h window.h -ebind.o: ebind.c ebind.h basic.h bind.h estruct.h retcode.h globals.h \ - bindable.h buffer.h crypt.h line.h utf8.h eval.h exec.h file.h isearch.h \ - random.h region.h search.h spawn.h window.h defines.h word.h + retcode.h input.h bind.h termio.h terminal.h defines.h version.h \ + wrapper.h window.h +ebind.o: ebind.c ebind.h basic.h bind.h estruct.h retcode.h bindable.h \ + buffer.h crypt.h line.h utf8.h eval.h exec.h file.h isearch.h random.h \ + region.h search.h spawn.h window.h defines.h word.h eval.o: eval.c eval.h basic.h bind.h buffer.h crypt.h line.h utf8.h \ - display.h estruct.h retcode.h globals.h exec.h execute.h flook.h input.h \ - random.h search.h terminal.h defines.h termio.h version.h window.h + display.h estruct.h retcode.h exec.h execute.h flook.h input.h random.h \ + search.h terminal.h defines.h termio.h version.h window.h exec.o: exec.c exec.h retcode.h buffer.h crypt.h line.h utf8.h bind.h \ - display.h estruct.h globals.h eval.h file.h flook.h input.h window.h \ + display.h estruct.h eval.h file.h flook.h input.h random.h window.h \ defines.h -execute.o: execute.c execute.h estruct.h retcode.h globals.h bind.h \ - random.h display.h file.h crypt.h buffer.h line.h utf8.h terminal.h \ - defines.h window.h -file.o: file.c file.h crypt.h retcode.h buffer.h line.h utf8.h defines.h \ - estruct.h globals.h execute.h fileio.h input.h bind.h lock.h log.h \ +execute.o: execute.c execute.h estruct.h retcode.h bind.h random.h \ + display.h file.h crypt.h buffer.h line.h utf8.h terminal.h defines.h \ window.h +file.o: file.c file.h crypt.h retcode.h buffer.h line.h utf8.h defines.h \ + estruct.h execute.h fileio.h input.h bind.h lock.h log.h window.h fileio.o: fileio.c fileio.h crypt.h retcode.h defines.h flook.o: flook.c flook.h retcode.h defines.h fileio.h crypt.h -globals.o: globals.c globals.h defines.h -ibmpc.o: ibmpc.c estruct.h retcode.h globals.h -input.o: input.c input.h bind.h estruct.h retcode.h globals.h bindable.h \ - display.h exec.h names.h terminal.h defines.h wrapper.h +ibmpc.o: ibmpc.c estruct.h retcode.h +input.o: input.c input.h bind.h estruct.h retcode.h bindable.h display.h \ + exec.h names.h terminal.h defines.h wrapper.h isearch.o: isearch.c isearch.h basic.h buffer.h crypt.h line.h utf8.h \ - display.h estruct.h retcode.h globals.h exec.h input.h bind.h search.h \ - terminal.h defines.h window.h -line.o: line.c line.h utf8.h buffer.h crypt.h estruct.h retcode.h \ - globals.h log.h window.h defines.h -lock.o: lock.c lock.h estruct.h retcode.h display.h globals.h input.h \ - bind.h + display.h estruct.h retcode.h exec.h input.h bind.h search.h terminal.h \ + defines.h window.h +line.o: line.c line.h utf8.h buffer.h crypt.h estruct.h retcode.h log.h \ + window.h defines.h +lock.o: lock.c lock.h estruct.h retcode.h display.h input.h bind.h log.o: log.c log.h retcode.h main.o: main.c estruct.h retcode.h basic.h bind.h bindable.h buffer.h \ - crypt.h line.h utf8.h display.h globals.h eval.h execute.h file.h \ - input.h lock.h log.h random.h search.h terminal.h defines.h termio.h \ - version.h window.h + crypt.h line.h utf8.h display.h eval.h execute.h file.h input.h lock.h \ + log.h random.h search.h terminal.h defines.h termio.h version.h window.h names.o: names.c names.h basic.h bind.h bindable.h buffer.h crypt.h \ line.h utf8.h display.h eval.h exec.h retcode.h file.h isearch.h \ region.h random.h search.h spawn.h window.h defines.h word.h -pklock.o: pklock.c pklock.h estruct.h retcode.h globals.h +pklock.o: pklock.c pklock.h estruct.h retcode.h posix.o: posix.c termio.h random.o: random.c random.h basic.h buffer.h crypt.h line.h utf8.h \ - display.h estruct.h retcode.h globals.h execute.h input.h bind.h log.h \ - search.h terminal.h defines.h window.h + display.h estruct.h retcode.h execute.h input.h bind.h log.h search.h \ + terminal.h defines.h window.h region.o: region.c region.h line.h utf8.h buffer.h crypt.h estruct.h \ - retcode.h globals.h log.h window.h defines.h + retcode.h log.h random.h window.h defines.h search.o: search.c search.h line.h utf8.h basic.h buffer.h crypt.h \ - display.h estruct.h retcode.h globals.h input.h bind.h log.h terminal.h \ - defines.h window.h + display.h estruct.h retcode.h input.h bind.h log.h terminal.h defines.h \ + window.h spawn.o: spawn.c spawn.h defines.h buffer.h crypt.h line.h utf8.h \ display.h estruct.h retcode.h exec.h file.h flook.h input.h bind.h log.h \ terminal.h window.h tcap.o: tcap.c terminal.h defines.h retcode.h display.h estruct.h \ - globals.h termio.h + termio.h termio.o: termio.c termio.h estruct.h retcode.h utf8.h utf8.o: utf8.c utf8.h -vmsvt.o: vmsvt.c estruct.h retcode.h globals.h -vt52.o: vt52.c estruct.h retcode.h globals.h +vmsvt.o: vmsvt.c estruct.h retcode.h +vt52.o: vt52.c estruct.h retcode.h window.o: window.c window.h defines.h buffer.h crypt.h line.h utf8.h \ - basic.h display.h estruct.h retcode.h globals.h execute.h terminal.h \ - wrapper.h + basic.h display.h estruct.h retcode.h execute.h terminal.h wrapper.h word.o: word.c word.h basic.h buffer.h crypt.h line.h utf8.h estruct.h \ - retcode.h globals.h log.h random.h region.h window.h defines.h + retcode.h log.h random.h region.h window.h defines.h wrapper.o: wrapper.c wrapper.h # DEPENDENCIES MUST END AT END OF FILE diff --git a/ansi.c b/ansi.c index 041db06..425d96c 100644 --- a/ansi.c +++ b/ansi.c @@ -11,7 +11,7 @@ #include #include "estruct.h" -#include "globals.h" + #if ANSI diff --git a/basic.c b/basic.c index 096b04b..459bbc4 100644 --- a/basic.c +++ b/basic.c @@ -19,7 +19,6 @@ #include "buffer.h" #include "display.h" #include "estruct.h" -#include "globals.h" #include "input.h" #include "line.h" #include "random.h" diff --git a/bind.c b/bind.c index 782fd0f..53747b0 100644 --- a/bind.c +++ b/bind.c @@ -14,7 +14,6 @@ #include #include "estruct.h" -#include "globals.h" #include "bindable.h" #include "buffer.h" #include "display.h" diff --git a/bindable.c b/bindable.c index 82d879e..ac69788 100644 --- a/bindable.c +++ b/bindable.c @@ -8,7 +8,6 @@ #include "buffer.h" #include "display.h" #include "estruct.h" -#include "globals.h" #include "file.h" #include "input.h" #include "lock.h" diff --git a/buffer.c b/buffer.c index 68fff57..df4d39f 100644 --- a/buffer.c +++ b/buffer.c @@ -19,7 +19,6 @@ #include "defines.h" #include "display.h" #include "estruct.h" -#include "globals.h" #include "file.h" #include "input.h" #include "window.h" diff --git a/display.c b/display.c index 415b0c3..c6b1ae9 100644 --- a/display.c +++ b/display.c @@ -20,7 +20,6 @@ #include "buffer.h" #include "estruct.h" -#include "globals.h" #include "input.h" #include "line.h" #include "termio.h" diff --git a/ebind.c b/ebind.c index ce2bfd1..56d9125 100644 --- a/ebind.c +++ b/ebind.c @@ -14,7 +14,6 @@ #include "basic.h" #include "bind.h" #include "estruct.h" -#include "globals.h" #include "bindable.h" #include "buffer.h" #include "eval.h" diff --git a/eval.c b/eval.c index 58aac09..176da31 100644 --- a/eval.c +++ b/eval.c @@ -18,7 +18,6 @@ #include "buffer.h" #include "display.h" #include "estruct.h" -#include "globals.h" #include "exec.h" #include "execute.h" #include "flook.h" diff --git a/exec.c b/exec.c index cfad97e..8406617 100644 --- a/exec.c +++ b/exec.c @@ -18,12 +18,12 @@ #include "bind.h" #include "display.h" #include "estruct.h" -#include "globals.h" #include "eval.h" #include "file.h" #include "flook.h" #include "input.h" #include "line.h" +#include "random.h" #include "window.h" diff --git a/execute.c b/execute.c index c367b33..78333da 100644 --- a/execute.c +++ b/execute.c @@ -4,7 +4,6 @@ #include #include "estruct.h" -#include "globals.h" #include "bind.h" #include "random.h" #include "display.h" diff --git a/file.c b/file.c index 5587889..bd69bdd 100644 --- a/file.c +++ b/file.c @@ -19,7 +19,6 @@ #include "crypt.h" #include "defines.h" #include "estruct.h" -#include "globals.h" #include "execute.h" #include "fileio.h" #include "input.h" diff --git a/globals.c b/globals.c deleted file mode 100644 index 6e2ab1e..0000000 --- a/globals.c +++ /dev/null @@ -1,16 +0,0 @@ -/* globals.c -- implements globals.h */ -#include "globals.h" - -#include "defines.h" - -/* initialized global definitions */ - -int metac = CONTROL | '['; /* current meta character */ -int ctlxc = CONTROL | 'X'; /* current control X prefix char */ -int reptc = CONTROL | 'U'; /* current universal repeat char */ -int abortc = CONTROL | 'G'; /* current abort command char */ - -/* uninitialized global definitions */ - -int thisflag; /* Flags, this command */ -int lastflag; /* Flags, last command */ diff --git a/globals.h b/globals.h deleted file mode 100644 index cc5ac42..0000000 --- a/globals.h +++ /dev/null @@ -1,21 +0,0 @@ -/* globals.h -- Global variable definitions */ - -#ifndef __GLOBALS_H__ -#define __GLOBALS_H__ - -/* Initialized global external declarations. */ - -extern int metac; /* current meta character */ -extern int ctlxc; /* current control X prefix char */ -extern int reptc; /* current universal repeat char */ -extern int abortc; /* current abort command char */ - -/* Uninitialized global external declarations. */ - -#define CFCPCN 0x0001 /* Last command was C-P, C-N */ -#define CFKILL 0x0002 /* Last command was a kill */ - -extern int thisflag; /* Flags, this command */ -extern int lastflag; /* Flags, last command */ - -#endif diff --git a/ibmpc.c b/ibmpc.c index 217aa31..7cdd3bc 100644 --- a/ibmpc.c +++ b/ibmpc.c @@ -12,7 +12,6 @@ #include #include "estruct.h" -#include "globals.h" #if IBMPC #if PKCODE diff --git a/input.c b/input.c index 9672b92..bb98cc8 100644 --- a/input.c +++ b/input.c @@ -16,7 +16,6 @@ #include "bind.h" #include "estruct.h" -#include "globals.h" #include "bindable.h" #include "display.h" #include "exec.h" @@ -47,7 +46,12 @@ int kbdrep = 0 ; /* number of repetitions */ int disinp = TRUE ; /* display input characters */ -static const int quotec = 0x11 ; /* quote char during mlreply() */ +int metac = CONTROL | '[' ; /* current meta character */ +int ctlxc = CONTROL | 'X' ; /* current control X prefix char */ +int reptc = CONTROL | 'U' ; /* current universal repeat char */ +int abortc = CONTROL | 'G' ; /* current abort command char */ + +static const int quotec = 0x11 ; /* quote char during mlreply() */ /* * Ask a yes or no question in the message line. Return either TRUE, FALSE, or diff --git a/input.h b/input.h index 6c30dd3..98befd1 100644 --- a/input.h +++ b/input.h @@ -14,6 +14,11 @@ extern int kbdm[] ; /* Holds kayboard macro data */ extern int *kbdptr ; /* current position in keyboard buf */ extern int *kbdend ; /* ptr to end of the keyboard */ extern int disinp ; /* display input characters */ +extern int metac; /* current meta character */ +extern int ctlxc; /* current control X prefix char */ +extern int reptc; /* current universal repeat char */ +extern int abortc; /* current abort command char */ + int mlyesno( const char *prompt) ; int mlreply( const char *prompt, char *buf, int nbuf) ; diff --git a/isearch.c b/isearch.c index c100963..e14988f 100644 --- a/isearch.c +++ b/isearch.c @@ -31,7 +31,6 @@ #include "buffer.h" #include "display.h" #include "estruct.h" -#include "globals.h" #include "exec.h" #include "input.h" #include "line.h" diff --git a/line.c b/line.c index 25e7d5d..02eb65d 100644 --- a/line.c +++ b/line.c @@ -22,7 +22,6 @@ #include "buffer.h" #include "estruct.h" -#include "globals.h" #include "log.h" #include "window.h" diff --git a/lock.c b/lock.c index ac380ae..ee8d12b 100644 --- a/lock.c +++ b/lock.c @@ -11,7 +11,6 @@ #include "display.h" #include "estruct.h" -#include "globals.h" #include "input.h" #if (FILOCK && BSD) || SVR4 diff --git a/main.c b/main.c index 994eb7b..07778be 100644 --- a/main.c +++ b/main.c @@ -69,7 +69,6 @@ #include "bindable.h" #include "buffer.h" #include "display.h" -#include "globals.h" /* Global definitions. */ #include "eval.h" #include "execute.h" #include "file.h" diff --git a/pklock.c b/pklock.c index 8acf550..a727882 100644 --- a/pklock.c +++ b/pklock.c @@ -6,7 +6,6 @@ */ #include "estruct.h" -#include "globals.h" #if (FILOCK && BSD) || SVR4 #include diff --git a/posix.c b/posix.c index c6103ca..37a8f21 100644 --- a/posix.c +++ b/posix.c @@ -23,7 +23,6 @@ #include #include "estruct.h" -#include "globals.h" #include "utf8.h" int ttrow = HUGE ; /* Row location of HW cursor */ diff --git a/random.c b/random.c index 14d0275..1792c3a 100644 --- a/random.c +++ b/random.c @@ -16,7 +16,6 @@ #include "buffer.h" #include "display.h" #include "estruct.h" -#include "globals.h" #include "execute.h" #include "input.h" #include "line.h" @@ -42,6 +41,11 @@ int gbcolor = 0 ; /* global backgrnd color (black) */ int tabsize ; /* Tab size (0: use real tabs) */ int fillcol = 72 ; /* Current fill column */ +/* uninitialized global definitions */ + +int thisflag ; /* Flags, this command */ +int lastflag ; /* Flags, last command */ + /* * Set fill column to n. diff --git a/random.h b/random.h index c9bed3c..da646ca 100644 --- a/random.h +++ b/random.h @@ -7,6 +7,14 @@ extern int tabsize ; /* Tab size (0: use real tabs). */ extern int fillcol ; /* Fill column */ +/* Uninitialized global external declarations. */ + +#define CFCPCN 0x0001 /* Last command was C-P, C-N */ +#define CFKILL 0x0002 /* Last command was a kill */ + +extern int thisflag ; /* Flags, this command */ +extern int lastflag ; /* Flags, last command */ + int setfillcol( int f, int n) ; int showcpos( int f, int n) ; int getcline( void) ; diff --git a/region.c b/region.c index 86a72ce..8e70093 100644 --- a/region.c +++ b/region.c @@ -14,9 +14,9 @@ #include "buffer.h" #include "estruct.h" -#include "globals.h" #include "line.h" #include "log.h" +#include "random.h" #include "window.h" /* diff --git a/search.c b/search.c index 1b9cc7a..c32e56b 100644 --- a/search.c +++ b/search.c @@ -68,7 +68,6 @@ #include "buffer.h" #include "display.h" #include "estruct.h" -#include "globals.h" #include "input.h" #include "line.h" #include "log.h" diff --git a/tcap.c b/tcap.c index 1fe3621..9100fd6 100644 --- a/tcap.c +++ b/tcap.c @@ -29,7 +29,6 @@ #include "display.h" #include "estruct.h" -#include "globals.h" #include "termio.h" #if TERMCAP diff --git a/vmsvt.c b/vmsvt.c index ce599ae..b02bd1b 100644 --- a/vmsvt.c +++ b/vmsvt.c @@ -11,7 +11,6 @@ #include /* Standard I/O package */ #include "estruct.h" /* Emacs' structures */ -#include "globals.h" /* Emacs' definitions */ #if VMSVT diff --git a/vt52.c b/vt52.c index 4c13af0..c11149b 100644 --- a/vt52.c +++ b/vt52.c @@ -15,7 +15,6 @@ #include #include "estruct.h" -#include "globals.h" #if VT52 diff --git a/window.c b/window.c index 5ec64ff..f78ccd7 100644 --- a/window.c +++ b/window.c @@ -15,7 +15,6 @@ #include "buffer.h" #include "display.h" #include "estruct.h" -#include "globals.h" #include "execute.h" #include "line.h" #include "terminal.h" diff --git a/word.c b/word.c index 21e3560..76be9ea 100644 --- a/word.c +++ b/word.c @@ -15,7 +15,6 @@ #include "basic.h" #include "buffer.h" #include "estruct.h" -#include "globals.h" #include "line.h" #include "log.h" #include "random.h" From 5ecb1a288c0abe9f03b3c7b2a1fa38bb9d48430d Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Thu, 10 Oct 2013 13:47:09 +0800 Subject: [PATCH 163/193] Remove includes of estruct.h from all headers. --- Makefile | 8 ++++---- efunc.h | 22 ---------------------- lock.c | 6 ++++-- lock.h | 5 +++-- pklock.c | 4 ++-- pklock.h | 4 ++++ 6 files changed, 17 insertions(+), 32 deletions(-) delete mode 100644 efunc.h diff --git a/Makefile b/Makefile index 910f67c..b61ac87 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ -# Makefile for emacs, updated Thu, Oct 10, 2013 12:28:18 PM +# Makefile for emacs, updated Thu, Oct 10, 2013 1:03:16 PM SRC=ansi.c basic.c bind.c bindable.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c ibmpc.c input.c isearch.c line.c lock.c log.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c OBJ=ansi.o basic.o bind.o bindable.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o ibmpc.o input.o isearch.o line.o lock.o log.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o -HDR=basic.h bind.h bindable.h buffer.h crypt.h defines.h display.h ebind.h efunc.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h log.h names.h pklock.h random.h region.h retcode.h search.h spawn.h terminal.h termio.h utf8.h version.h window.h word.h wrapper.h +HDR=basic.h bind.h bindable.h buffer.h crypt.h defines.h display.h ebind.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h log.h names.h pklock.h random.h region.h retcode.h search.h spawn.h terminal.h termio.h utf8.h version.h window.h word.h wrapper.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -166,7 +166,7 @@ isearch.o: isearch.c isearch.h basic.h buffer.h crypt.h line.h utf8.h \ defines.h window.h line.o: line.c line.h utf8.h buffer.h crypt.h estruct.h retcode.h log.h \ window.h defines.h -lock.o: lock.c lock.h estruct.h retcode.h display.h input.h bind.h +lock.o: lock.c lock.h estruct.h retcode.h log.o: log.c log.h retcode.h main.o: main.c estruct.h retcode.h basic.h bind.h bindable.h buffer.h \ crypt.h line.h utf8.h display.h eval.h execute.h file.h input.h lock.h \ @@ -174,7 +174,7 @@ main.o: main.c estruct.h retcode.h basic.h bind.h bindable.h buffer.h \ names.o: names.c names.h basic.h bind.h bindable.h buffer.h crypt.h \ line.h utf8.h display.h eval.h exec.h retcode.h file.h isearch.h \ region.h random.h search.h spawn.h window.h defines.h word.h -pklock.o: pklock.c pklock.h estruct.h retcode.h +pklock.o: pklock.c estruct.h retcode.h pklock.h posix.o: posix.c termio.h random.o: random.c random.h basic.h buffer.h crypt.h line.h utf8.h \ display.h estruct.h retcode.h execute.h input.h bind.h log.h search.h \ diff --git a/efunc.h b/efunc.h deleted file mode 100644 index f47bfd4..0000000 --- a/efunc.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef _EFUNC_H_ -#define _EFUNC_H_ - -/* efunc.h - * - * Function declarations and names. - * - * This file list all the C code functions used and the names to use - * to bind keys to them. To add functions, declare it here in both the - * extern function list and the name binding table. - * - * modified by Petri Kutvonen - */ - -/* External function declarations. */ - -#if BSD | SVR4 -/* lock.c */ -#include "lock.h" -#endif - -#endif diff --git a/lock.c b/lock.c index ee8d12b..a39c51a 100644 --- a/lock.c +++ b/lock.c @@ -1,3 +1,4 @@ +#include "estruct.h" #include "lock.h" /* LOCK.C @@ -7,17 +8,18 @@ * written by Daniel Lawrence */ +#if BSD | SVR4 #include +#include +#include #include "display.h" -#include "estruct.h" #include "input.h" #if (FILOCK && BSD) || SVR4 #include "pklock.h" #endif -#if BSD | SVR4 #include static char *lname[NLOCKS]; /* names of all locked files */ diff --git a/lock.h b/lock.h index b0e7ace..aa04d75 100644 --- a/lock.h +++ b/lock.h @@ -1,7 +1,9 @@ #ifndef _LOCK_H_ #define _LOCK_H_ -#include "estruct.h" +#ifndef _ESTRUCT_H_ +#error uEmacs compilation settings needs to be done! +#endif #if BSD | SVR4 @@ -11,5 +13,4 @@ int lock( const char *fname) ; int unlock( const char *fname) ; #endif - #endif diff --git a/pklock.c b/pklock.c index a727882..4ce1b34 100644 --- a/pklock.c +++ b/pklock.c @@ -1,3 +1,5 @@ +/* pklock.c -- implements pklock.h */ +#include "estruct.h" #include "pklock.h" /* PKLOCK.C @@ -5,8 +7,6 @@ * locking routines as modified by Petri Kutvonen */ -#include "estruct.h" - #if (FILOCK && BSD) || SVR4 #include #include diff --git a/pklock.h b/pklock.h index 7b62237..7cba16c 100644 --- a/pklock.h +++ b/pklock.h @@ -1,6 +1,10 @@ #ifndef _PKLOCK_H_ #define _PKLOCK_H_ +#ifndef _ESTRUCT_H_ +#error uEmacs compilation settings needs to be done! +#endif + #if (FILOCK && BSD) || SVR4 char *dolock( const char *fname) ; From ba2dc0e5f865810573d027016350c454bed80ca1 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Thu, 10 Oct 2013 17:46:13 +0800 Subject: [PATCH 164/193] Assign 'common' functionality to Del, Home and End keys. --- ebind.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ebind.c b/ebind.c index 56d9125..90b9cc4 100644 --- a/ebind.c +++ b/ebind.c @@ -394,13 +394,13 @@ struct key_tab keytab[NBINDS] = { #endif #if VT220 - {SPEC | '1', fisearch} + {SPEC | '1', gotobob /* fisearch */} , /* VT220 keys */ {SPEC | '2', yank} , - {SPEC | '3', killregion} + {SPEC | '3', forwdel /* killregion */} , - {SPEC | '4', setmark} + {SPEC | '4', gotoeob /* setmark */} , {SPEC | '5', backpage} , From 94d21c96f32f20f853de35282f3bf3cb18fdee00 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 11 Oct 2013 11:20:06 +0800 Subject: [PATCH 165/193] Move globals defines out of estruct.h. --- Makefile | 59 +++++++++++++++++++++++++++--------------------------- defines.h | 4 +++- ebind.h | 9 +++++---- estruct.h | 14 ------------- eval.c | 2 ++ line.h | 2 ++ lock.c | 7 ++++--- search.h | 2 ++ tcap.c | 3 ++- terminal.h | 1 + termio.c | 1 + word.c | 2 ++ 12 files changed, 53 insertions(+), 53 deletions(-) diff --git a/Makefile b/Makefile index b61ac87..3ee359f 100644 --- a/Makefile +++ b/Makefile @@ -126,77 +126,76 @@ depend: ${SRC} # DO NOT DELETE THIS LINE -- make depend uses it -ansi.o: ansi.c estruct.h retcode.h +ansi.o: ansi.c estruct.h basic.o: basic.c basic.h buffer.h crypt.h line.h utf8.h display.h \ - estruct.h retcode.h input.h bind.h random.h terminal.h defines.h \ + estruct.h input.h bind.h random.h terminal.h defines.h retcode.h \ window.h -bind.o: bind.c bind.h estruct.h retcode.h bindable.h buffer.h crypt.h \ - line.h utf8.h display.h ebind.h exec.h file.h flook.h input.h names.h \ +bind.o: bind.c bind.h estruct.h bindable.h buffer.h crypt.h line.h utf8.h \ + display.h ebind.h exec.h retcode.h file.h flook.h input.h names.h \ window.h defines.h bindable.o: bindable.c bindable.h defines.h buffer.h crypt.h line.h \ - utf8.h display.h estruct.h retcode.h file.h input.h bind.h lock.h \ + utf8.h display.h estruct.h file.h retcode.h input.h bind.h lock.h \ terminal.h buffer.o: buffer.c buffer.h crypt.h line.h utf8.h defines.h display.h \ - estruct.h retcode.h file.h input.h bind.h window.h + estruct.h file.h retcode.h input.h bind.h window.h crypt.o: crypt.c crypt.h display.o: display.c display.h buffer.h crypt.h line.h utf8.h estruct.h \ - retcode.h input.h bind.h termio.h terminal.h defines.h version.h \ + input.h bind.h termio.h terminal.h defines.h retcode.h version.h \ wrapper.h window.h -ebind.o: ebind.c ebind.h basic.h bind.h estruct.h retcode.h bindable.h \ - buffer.h crypt.h line.h utf8.h eval.h exec.h file.h isearch.h random.h \ +ebind.o: ebind.c ebind.h basic.h bind.h estruct.h bindable.h buffer.h \ + crypt.h line.h utf8.h eval.h exec.h retcode.h file.h isearch.h random.h \ region.h search.h spawn.h window.h defines.h word.h eval.o: eval.c eval.h basic.h bind.h buffer.h crypt.h line.h utf8.h \ - display.h estruct.h retcode.h exec.h execute.h flook.h input.h random.h \ + display.h estruct.h exec.h retcode.h execute.h flook.h input.h random.h \ search.h terminal.h defines.h termio.h version.h window.h exec.o: exec.c exec.h retcode.h buffer.h crypt.h line.h utf8.h bind.h \ display.h estruct.h eval.h file.h flook.h input.h random.h window.h \ defines.h -execute.o: execute.c execute.h estruct.h retcode.h bind.h random.h \ - display.h file.h crypt.h buffer.h line.h utf8.h terminal.h defines.h \ - window.h +execute.o: execute.c execute.h estruct.h bind.h random.h display.h file.h \ + crypt.h retcode.h buffer.h line.h utf8.h terminal.h defines.h window.h file.o: file.c file.h crypt.h retcode.h buffer.h line.h utf8.h defines.h \ estruct.h execute.h fileio.h input.h bind.h lock.h log.h window.h fileio.o: fileio.c fileio.h crypt.h retcode.h defines.h flook.o: flook.c flook.h retcode.h defines.h fileio.h crypt.h -ibmpc.o: ibmpc.c estruct.h retcode.h -input.o: input.c input.h bind.h estruct.h retcode.h bindable.h display.h \ - exec.h names.h terminal.h defines.h wrapper.h +ibmpc.o: ibmpc.c estruct.h +input.o: input.c input.h bind.h estruct.h bindable.h display.h exec.h \ + retcode.h names.h terminal.h defines.h wrapper.h isearch.o: isearch.c isearch.h basic.h buffer.h crypt.h line.h utf8.h \ - display.h estruct.h retcode.h exec.h input.h bind.h search.h terminal.h \ + display.h estruct.h exec.h retcode.h input.h bind.h search.h terminal.h \ defines.h window.h -line.o: line.c line.h utf8.h buffer.h crypt.h estruct.h retcode.h log.h \ +line.o: line.c line.h utf8.h buffer.h crypt.h estruct.h log.h retcode.h \ window.h defines.h -lock.o: lock.c lock.h estruct.h retcode.h +lock.o: lock.c estruct.h lock.h log.o: log.c log.h retcode.h -main.o: main.c estruct.h retcode.h basic.h bind.h bindable.h buffer.h \ - crypt.h line.h utf8.h display.h eval.h execute.h file.h input.h lock.h \ +main.o: main.c estruct.h basic.h bind.h bindable.h buffer.h crypt.h \ + line.h utf8.h display.h eval.h execute.h file.h retcode.h input.h lock.h \ log.h random.h search.h terminal.h defines.h termio.h version.h window.h names.o: names.c names.h basic.h bind.h bindable.h buffer.h crypt.h \ line.h utf8.h display.h eval.h exec.h retcode.h file.h isearch.h \ region.h random.h search.h spawn.h window.h defines.h word.h -pklock.o: pklock.c estruct.h retcode.h pklock.h +pklock.o: pklock.c estruct.h pklock.h posix.o: posix.c termio.h random.o: random.c random.h basic.h buffer.h crypt.h line.h utf8.h \ - display.h estruct.h retcode.h execute.h input.h bind.h log.h search.h \ + display.h estruct.h execute.h input.h bind.h log.h retcode.h search.h \ terminal.h defines.h window.h region.o: region.c region.h line.h utf8.h buffer.h crypt.h estruct.h \ - retcode.h log.h random.h window.h defines.h + log.h retcode.h random.h window.h defines.h search.o: search.c search.h line.h utf8.h basic.h buffer.h crypt.h \ - display.h estruct.h retcode.h input.h bind.h log.h terminal.h defines.h \ + display.h estruct.h input.h bind.h log.h retcode.h terminal.h defines.h \ window.h spawn.o: spawn.c spawn.h defines.h buffer.h crypt.h line.h utf8.h \ - display.h estruct.h retcode.h exec.h file.h flook.h input.h bind.h log.h \ + display.h estruct.h exec.h retcode.h file.h flook.h input.h bind.h log.h \ terminal.h window.h tcap.o: tcap.c terminal.h defines.h retcode.h display.h estruct.h \ termio.h termio.o: termio.c termio.h estruct.h retcode.h utf8.h utf8.o: utf8.c utf8.h -vmsvt.o: vmsvt.c estruct.h retcode.h -vt52.o: vt52.c estruct.h retcode.h +vmsvt.o: vmsvt.c estruct.h +vt52.o: vt52.c estruct.h window.o: window.c window.h defines.h buffer.h crypt.h line.h utf8.h \ - basic.h display.h estruct.h retcode.h execute.h terminal.h wrapper.h + basic.h display.h estruct.h execute.h terminal.h retcode.h wrapper.h word.o: word.c word.h basic.h buffer.h crypt.h line.h utf8.h estruct.h \ - retcode.h log.h random.h region.h window.h defines.h + log.h retcode.h random.h region.h window.h defines.h wrapper.o: wrapper.c wrapper.h # DEPENDENCIES MUST END AT END OF FILE diff --git a/defines.h b/defines.h index 2e59365..1ed7467 100644 --- a/defines.h +++ b/defines.h @@ -3,7 +3,6 @@ */ #define USG 1 -#define NBUFN 16 /* # of bytes, buffer name */ #define NSTRING 128 /* # of bytes, string buffers */ #define PKCODE 1 @@ -14,3 +13,6 @@ #define META 0x20000000 /* Meta flag, or'ed in */ #define CTLX 0x40000000 /* ^X flag, or'ed in */ #define SPEC 0x80000000 /* special key (function keys) */ + +#define MAXCOL 500 +#define MAXROW 500 diff --git a/ebind.h b/ebind.h index af8ed2c..4f129df 100644 --- a/ebind.h +++ b/ebind.h @@ -1,8 +1,9 @@ /* Structure for the table of initial key bindings. */ struct key_tab { - int k_code; /* Key code */ - int (*k_fp)(int, int); /* Routine to handle it */ -}; + int k_code ; /* Key code */ + int (*k_fp)( int, int) ; /* Routine to handle it */ +} ; -extern struct key_tab keytab[]; /* key bind to functions table */ +#define NBINDS 256 /* max # of bound keys */ +extern struct key_tab keytab[ NBINDS] ; /* key bind to functions table */ diff --git a/estruct.h b/estruct.h index eecc1d8..0bcde5f 100644 --- a/estruct.h +++ b/estruct.h @@ -12,9 +12,6 @@ */ -#define MAXCOL 500 -#define MAXROW 500 - #ifdef MSDOS #undef MSDOS #endif @@ -226,27 +223,16 @@ /* Internal constants. */ -#define NBINDS 256 /* max # of bound keys */ #define NFILEN 80 /* # of bytes, file name */ -#define NBUFN 16 /* # of bytes, buffer name */ -#define NLINE 256 /* # of bytes, input line */ #define NSTRING 128 /* # of bytes, string buffers */ #define NPAT 128 /* # of bytes, pattern */ #define HUGE 1000 /* Huge number */ -#define NLOCKS 100 /* max # of file locks active */ #define CONTROL 0x10000000 /* Control flag, or'ed in */ #define META 0x20000000 /* Meta flag, or'ed in */ #define CTLX 0x40000000 /* ^X flag, or'ed in */ #define SPEC 0x80000000 /* special key (function keys) */ -#include "retcode.h" - -#define BELL 0x07 /* a bell character */ -#define TAB 0x09 /* a tab character */ - -#define INTWIDTH sizeof(int) * 3 - /* Internal defined functions */ #ifdef abs diff --git a/eval.c b/eval.c index 176da31..b72a38e 100644 --- a/eval.c +++ b/eval.c @@ -937,6 +937,8 @@ static int svar(struct variable_description *var, char *value) */ char *itoa(int i) { + #define INTWIDTH sizeof( int) * 3 + int digit; /* current digit being used */ char *sp; /* pointer into result */ int sign; /* sign of resulting number */ diff --git a/line.h b/line.h index 2080899..634a18a 100644 --- a/line.h +++ b/line.h @@ -3,6 +3,8 @@ #include "utf8.h" +#define NLINE 256 /* # of bytes, input line */ + /* * All text is kept in circularly linked lists of "struct line" structures. These * begin at the header line (which is the blank line beyond the end of the diff --git a/lock.c b/lock.c index a39c51a..f912f52 100644 --- a/lock.c +++ b/lock.c @@ -22,8 +22,9 @@ #include -static char *lname[NLOCKS]; /* names of all locked files */ -static int numlocks; /* # of current locks active */ +#define NLOCKS 100 /* max # of file locks active */ +static char *lname[ NLOCKS] ; /* names of all locked files */ +static int numlocks ; /* # of current locks active */ static void lckerror(char *errstr) ; @@ -45,7 +46,7 @@ int lockchk( const char *fname) return TRUE; /* if we have a full locking table, bitch and leave */ - if (numlocks == NLOCKS) { + if( numlocks >= NLOCKS) { mlwrite("LOCK ERROR: Lock table full"); return ABORT; } diff --git a/search.h b/search.h index b354b50..9b53f32 100644 --- a/search.h +++ b/search.h @@ -5,6 +5,8 @@ #include "line.h" +#define BELL 0x07 /* a bell character */ + extern unsigned int matchlen ; extern char *patmatch ; diff --git a/tcap.c b/tcap.c index 9100fd6..ffa0c00 100644 --- a/tcap.c +++ b/tcap.c @@ -37,7 +37,8 @@ boolean eolexist = TRUE ; /* does clear to EOL exist */ boolean revexist = FALSE ; /* does reverse video exist? */ boolean sgarbf = TRUE ; /* TRUE if screen is garbage */ -char sres[ NBUFN] ; /* current screen resolution */ +char sres[ 16] ; /* current screen resolution */ + /* NORMAL, CGA, EGA, VGA */ #if UNIX #include diff --git a/terminal.h b/terminal.h index 1fe04ed..df4e9e8 100644 --- a/terminal.h +++ b/terminal.h @@ -76,5 +76,6 @@ extern boolean revexist ; /* does reverse video exist? */ extern boolean sgarbf ; /* State of screen unknown */ extern char sres[] ; /* Current screen resolution. */ + /* NORMAL, CGA, EGA, VGA */ #endif diff --git a/termio.c b/termio.c index 43d78fa..92fbc95 100644 --- a/termio.c +++ b/termio.c @@ -15,6 +15,7 @@ #include #include "estruct.h" +#include "retcode.h" #include "utf8.h" diff --git a/word.c b/word.c index 76be9ea..b29f060 100644 --- a/word.c +++ b/word.c @@ -21,6 +21,8 @@ #include "region.h" #include "window.h" +#define TAB 0x09 /* a tab character */ + #if PKCODE static int justflag = FALSE ; /* justify, don't fill */ #endif From c4becabbc2c5550e342ae8fb3464582155bc3c76 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 11 Oct 2013 12:37:31 +0800 Subject: [PATCH 166/193] Move globals defines from globals.c. --- estruct.h | 2 -- file.h | 2 ++ termio.h | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/estruct.h b/estruct.h index 0bcde5f..72aa1f9 100644 --- a/estruct.h +++ b/estruct.h @@ -223,10 +223,8 @@ /* Internal constants. */ -#define NFILEN 80 /* # of bytes, file name */ #define NSTRING 128 /* # of bytes, string buffers */ #define NPAT 128 /* # of bytes, pattern */ -#define HUGE 1000 /* Huge number */ #define CONTROL 0x10000000 /* Control flag, or'ed in */ #define META 0x20000000 /* Meta flag, or'ed in */ diff --git a/file.h b/file.h index ab3ca71..0d0330b 100644 --- a/file.h +++ b/file.h @@ -11,6 +11,8 @@ void cryptbufferkey( struct buffer *bp) ; int set_encryption_key( int f, int n) ; #endif +#define NFILEN 80 /* # of bytes, file name */ + extern boolean restflag ; /* restricted use? */ int fileread( int f, int n) ; diff --git a/termio.h b/termio.h index 5b057aa..79f9ca5 100644 --- a/termio.h +++ b/termio.h @@ -1,7 +1,9 @@ #ifndef _TERMIO_H_ #define _TERMIO_H_ -extern int ttrow ; /* Row location of HW cursor */ +#define HUGE 1000 /* Huge number (for row/col) */ + +extern int ttrow ; /* Row location of HW cursor */ extern int ttcol ; /* Column location of HW cursor */ void ttopen( void) ; From da813d2efcf1e756ecb5fd1cb3205e1a3579309c Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 11 Oct 2013 14:09:29 +0800 Subject: [PATCH 167/193] Partial move configuration options out of estruct.h. --- basic.c | 2 ++ defines.h | 5 +++-- display.c | 2 ++ estruct.h | 29 ----------------------------- fileio.c | 5 +++++ main.c | 4 ++++ random.c | 2 ++ termio.h | 2 ++ 8 files changed, 20 insertions(+), 31 deletions(-) diff --git a/basic.c b/basic.c index 459bbc4..90f492b 100644 --- a/basic.c +++ b/basic.c @@ -2,6 +2,8 @@ #include "basic.h" +#define CVMVAS 1 /* arguments to page forward/back in pages */ + /* basic.c * * The routines in this file move the cursor around on the screen. They diff --git a/defines.h b/defines.h index 1ed7467..f84bd94 100644 --- a/defines.h +++ b/defines.h @@ -3,12 +3,13 @@ */ #define USG 1 -#define NSTRING 128 /* # of bytes, string buffers */ - #define PKCODE 1 #define SCROLLCODE 1 /* scrolling code P.K. */ #define ENVFUNC 1 +#define NSTRING 128 /* # of bytes, string buffers */ +#define NPAT 128 /* # of bytes, pattern */ + #define CONTROL 0x10000000 /* Control flag, or'ed in */ #define META 0x20000000 /* Meta flag, or'ed in */ #define CTLX 0x40000000 /* ^X flag, or'ed in */ diff --git a/display.c b/display.c index c6b1ae9..09bbb92 100644 --- a/display.c +++ b/display.c @@ -2,6 +2,8 @@ #include "display.h" +#define REVSTA 1 /* Status line appears in reverse video */ + /* display.c * * The functions in this file handle redisplay. There are two halves, the diff --git a/estruct.h b/estruct.h index 72aa1f9..6133e28 100644 --- a/estruct.h +++ b/estruct.h @@ -18,9 +18,6 @@ #ifdef EGA #undef EGA #endif -#ifdef CTRLZ -#undef CTRLZ -#endif /* Machine/OS definitions. */ @@ -122,15 +119,8 @@ /* Configuration options */ -#define CVMVAS 1 /* arguments to page forward/back in pages */ -#define CLRMSG 0 /* space clears the message line with no insert */ #define CFENCE 1 /* fench matching in CMODE */ -#define TYPEAH 1 /* type ahead causes update to be skipped */ #define VISMAC 0 /* update display during keyboard macros */ -#define CTRLZ 0 /* add a ^Z at end of files under MSDOS only */ -#define ADDCR 0 /* ajout d'un CR en fin de chaque ligne (ST520) */ -#define NBRACE 1 /* new style brace matching command */ -#define REVSTA 1 /* Status line appears in reverse video */ #ifndef AUTOCONF @@ -148,15 +138,6 @@ #endif /* Autoconf. */ -#if 0 -#define ISRCH 1 /* Incremental searches like ITS EMACS */ -#define WORDPRO 1 /* Advanced word processing features */ -#define APROP 1 /* Add code for Apropos command */ -#define CRYPT 1 /* file encryption enabled? */ -#define MAGIC 1 /* include regular expression matching? */ -#define AEDIT 1 /* advanced editing options: en/detabbing */ -#define PROC 1 /* named procedures */ -#endif #define CLEAN 0 /* de-alloc memory on exit */ #define ASCII 1 /* always using ASCII char sequences for now */ @@ -221,16 +202,6 @@ #define ENVFUNC 0 #endif -/* Internal constants. */ - -#define NSTRING 128 /* # of bytes, string buffers */ -#define NPAT 128 /* # of bytes, pattern */ - -#define CONTROL 0x10000000 /* Control flag, or'ed in */ -#define META 0x20000000 /* Meta flag, or'ed in */ -#define CTLX 0x40000000 /* ^X flag, or'ed in */ -#define SPEC 0x80000000 /* special key (function keys) */ - /* Internal defined functions */ #ifdef abs diff --git a/fileio.c b/fileio.c index 8148e54..18812c3 100644 --- a/fileio.c +++ b/fileio.c @@ -2,6 +2,11 @@ #include "fileio.h" +#ifdef CTRLZ +#undef CTRLZ +#endif +#define CTRLZ 0 /* add a ^Z at end of files under MSDOS only */ + /* FILEIO.C * * The routines in this file read and write ASCII files from the disk. All of diff --git a/main.c b/main.c index 07778be..c2f8ff5 100644 --- a/main.c +++ b/main.c @@ -1,3 +1,7 @@ +/* main.c -- */ + +#define CLRMSG 0 /* space clears the message line with no insert */ + /* * main.c diff --git a/random.c b/random.c index 1792c3a..79c1a32 100644 --- a/random.c +++ b/random.c @@ -1,6 +1,8 @@ /* random.c -- implements random.h */ #include "random.h" +#define NBRACE 1 /* new style brace matching command */ + /* random.c * * This file contains the command processing functions for a number of diff --git a/termio.h b/termio.h index 79f9ca5..5a3382c 100644 --- a/termio.h +++ b/termio.h @@ -1,6 +1,8 @@ #ifndef _TERMIO_H_ #define _TERMIO_H_ +#define TYPEAH 1 /* type ahead causes update to be skipped */ + #define HUGE 1000 /* Huge number (for row/col) */ extern int ttrow ; /* Row location of HW cursor */ From 81c98138de57513437da0d8c2b11b1f4c6b75fef Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 11 Oct 2013 15:36:36 +0800 Subject: [PATCH 168/193] Clean compile with RAMSIZE and RAMSHOW activated. --- estruct.h | 7 ++++++- main.c | 15 ++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/estruct.h b/estruct.h index 6133e28..22acf9d 100644 --- a/estruct.h +++ b/estruct.h @@ -87,7 +87,9 @@ /* Debugging options */ #define RAMSIZE 0 /* dynamic RAM memory usage tracking */ -#define RAMSHOW 0 /* auto dynamic RAM reporting */ +#if RAMSIZE +#define RAMSHOW 1 /* auto dynamic RAM reporting */ +#endif #ifndef AUTOCONF @@ -270,6 +272,9 @@ /* Dynamic RAM tracking and reporting redefinitions */ #if RAMSIZE +#include +void *allocate( size_t size) ; +void release( void *ptr) ; #define malloc allocate #define free release #endif diff --git a/main.c b/main.c index c2f8ff5..5f23a86 100644 --- a/main.c +++ b/main.c @@ -510,16 +510,19 @@ static void edinit(char *bname) end of the bottom mode line and is updated whenever it is changed. */ +static void dspram( void) ; + #undef malloc #undef free - +#if 0 char *allocate(nbytes) /* allocate nbytes and track */ unsigned nbytes; /* # of bytes to allocate */ - +#endif +void *allocate( size_t nbytes) { char *mp; /* ptr returned from malloc */ - char *malloc(); +/* char *malloc(); */ mp = malloc(nbytes); if (mp) { @@ -532,10 +535,12 @@ unsigned nbytes; /* # of bytes to allocate */ return mp; } +#if 0 release(mp) /* release malloced memory and track */ char *mp; /* chunk of RAM to release */ - +#endif +void release( void *mp) { unsigned *lp; /* ptr to the long containing the block size */ @@ -551,7 +556,7 @@ char *mp; /* chunk of RAM to release */ } #if RAMSHOW -dspram() +static void dspram( void) { /* display the amount of RAM currently malloced */ char mbuf[20]; char *sp; From 2669f218b733b488f2555b68411c4960a1eef46f Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sun, 13 Oct 2013 09:54:05 +0800 Subject: [PATCH 169/193] Recompile on Linux --- Makefile | 6 +++--- lock.c | 2 ++ posix.c | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 3ee359f..bdb199e 100644 --- a/Makefile +++ b/Makefile @@ -165,7 +165,7 @@ isearch.o: isearch.c isearch.h basic.h buffer.h crypt.h line.h utf8.h \ defines.h window.h line.o: line.c line.h utf8.h buffer.h crypt.h estruct.h log.h retcode.h \ window.h defines.h -lock.o: lock.c estruct.h lock.h +lock.o: lock.c estruct.h lock.h display.h input.h bind.h pklock.h log.o: log.c log.h retcode.h main.o: main.c estruct.h basic.h bind.h bindable.h buffer.h crypt.h \ line.h utf8.h display.h eval.h execute.h file.h retcode.h input.h lock.h \ @@ -174,7 +174,7 @@ names.o: names.c names.h basic.h bind.h bindable.h buffer.h crypt.h \ line.h utf8.h display.h eval.h exec.h retcode.h file.h isearch.h \ region.h random.h search.h spawn.h window.h defines.h word.h pklock.o: pklock.c estruct.h pklock.h -posix.o: posix.c termio.h +posix.o: posix.c termio.h estruct.h utf8.h random.o: random.c random.h basic.h buffer.h crypt.h line.h utf8.h \ display.h estruct.h execute.h input.h bind.h log.h retcode.h search.h \ terminal.h defines.h window.h @@ -188,7 +188,7 @@ spawn.o: spawn.c spawn.h defines.h buffer.h crypt.h line.h utf8.h \ terminal.h window.h tcap.o: tcap.c terminal.h defines.h retcode.h display.h estruct.h \ termio.h -termio.o: termio.c termio.h estruct.h retcode.h utf8.h +termio.o: termio.c termio.h utf8.o: utf8.c utf8.h vmsvt.o: vmsvt.c estruct.h vt52.o: vt52.c estruct.h diff --git a/lock.c b/lock.c index f912f52..d012ce3 100644 --- a/lock.c +++ b/lock.c @@ -13,8 +13,10 @@ #include #include +#include "defines.h" #include "display.h" #include "input.h" +#include "retcode.h" #if (FILOCK && BSD) || SVR4 #include "pklock.h" diff --git a/posix.c b/posix.c index 37a8f21..e12ff55 100644 --- a/posix.c +++ b/posix.c @@ -23,6 +23,7 @@ #include #include "estruct.h" +#include "retcode.h" #include "utf8.h" int ttrow = HUGE ; /* Row location of HW cursor */ From 5e87236c02f72c09070c2cd9038ba6250fd11a60 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sun, 13 Oct 2013 10:15:52 +0800 Subject: [PATCH 170/193] Review header dependencies --- Makefile | 5 +++-- posix.c | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index bdb199e..1fcc747 100644 --- a/Makefile +++ b/Makefile @@ -165,7 +165,8 @@ isearch.o: isearch.c isearch.h basic.h buffer.h crypt.h line.h utf8.h \ defines.h window.h line.o: line.c line.h utf8.h buffer.h crypt.h estruct.h log.h retcode.h \ window.h defines.h -lock.o: lock.c estruct.h lock.h display.h input.h bind.h pklock.h +lock.o: lock.c estruct.h lock.h defines.h display.h input.h bind.h \ + retcode.h pklock.h log.o: log.c log.h retcode.h main.o: main.c estruct.h basic.h bind.h bindable.h buffer.h crypt.h \ line.h utf8.h display.h eval.h execute.h file.h retcode.h input.h lock.h \ @@ -174,7 +175,7 @@ names.o: names.c names.h basic.h bind.h bindable.h buffer.h crypt.h \ line.h utf8.h display.h eval.h exec.h retcode.h file.h isearch.h \ region.h random.h search.h spawn.h window.h defines.h word.h pklock.o: pklock.c estruct.h pklock.h -posix.o: posix.c termio.h estruct.h utf8.h +posix.o: posix.c termio.h estruct.h retcode.h utf8.h random.o: random.c random.h basic.h buffer.h crypt.h line.h utf8.h \ display.h estruct.h execute.h input.h bind.h log.h retcode.h search.h \ terminal.h defines.h window.h diff --git a/posix.c b/posix.c index e12ff55..b1a1ae4 100644 --- a/posix.c +++ b/posix.c @@ -19,6 +19,8 @@ #include #include #include +#include +#include #include #include From 6455b200c3ff3e681eba1a044f7df90a898724dd Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 20 Nov 2013 16:45:41 +0800 Subject: [PATCH 171/193] Recompile on CYGWIN64. --- Makefile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 1fcc747..3ee359f 100644 --- a/Makefile +++ b/Makefile @@ -165,8 +165,7 @@ isearch.o: isearch.c isearch.h basic.h buffer.h crypt.h line.h utf8.h \ defines.h window.h line.o: line.c line.h utf8.h buffer.h crypt.h estruct.h log.h retcode.h \ window.h defines.h -lock.o: lock.c estruct.h lock.h defines.h display.h input.h bind.h \ - retcode.h pklock.h +lock.o: lock.c estruct.h lock.h log.o: log.c log.h retcode.h main.o: main.c estruct.h basic.h bind.h bindable.h buffer.h crypt.h \ line.h utf8.h display.h eval.h execute.h file.h retcode.h input.h lock.h \ @@ -175,7 +174,7 @@ names.o: names.c names.h basic.h bind.h bindable.h buffer.h crypt.h \ line.h utf8.h display.h eval.h exec.h retcode.h file.h isearch.h \ region.h random.h search.h spawn.h window.h defines.h word.h pklock.o: pklock.c estruct.h pklock.h -posix.o: posix.c termio.h estruct.h retcode.h utf8.h +posix.o: posix.c termio.h random.o: random.c random.h basic.h buffer.h crypt.h line.h utf8.h \ display.h estruct.h execute.h input.h bind.h log.h retcode.h search.h \ terminal.h defines.h window.h @@ -189,7 +188,7 @@ spawn.o: spawn.c spawn.h defines.h buffer.h crypt.h line.h utf8.h \ terminal.h window.h tcap.o: tcap.c terminal.h defines.h retcode.h display.h estruct.h \ termio.h -termio.o: termio.c termio.h +termio.o: termio.c termio.h estruct.h retcode.h utf8.h utf8.o: utf8.c utf8.h vmsvt.o: vmsvt.c estruct.h vt52.o: vt52.c estruct.h From e9142541a91c413a8e2e438bd05d711e52f3a9cd Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 20 Nov 2013 17:11:15 +0800 Subject: [PATCH 172/193] Review visibility of tabsize variable and nextab() macro. --- line.h | 1 - random.c | 4 +++- random.h | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/line.h b/line.h index 634a18a..a01730b 100644 --- a/line.h +++ b/line.h @@ -27,7 +27,6 @@ struct line { #define lputc(lp, n, c) ((lp)->l_text[(n)]=(c)) #define llength(lp) ((lp)->l_used) -#define nextab(a) (a & ~tabmask) + (tabmask+1) extern int tabmask ; char *getkill( void) ; diff --git a/random.c b/random.c index 79c1a32..da10dce 100644 --- a/random.c +++ b/random.c @@ -40,7 +40,7 @@ static const char *cname[] = { /* names of colors */ int gfcolor = NCOLORS - 1 ; /* global forgrnd color (white) */ int gbcolor = 0 ; /* global backgrnd color (black) */ -int tabsize ; /* Tab size (0: use real tabs) */ +static int tabsize ; /* Tab size (0: use real tabs) */ int fillcol = 72 ; /* Current fill column */ /* uninitialized global definitions */ @@ -345,6 +345,8 @@ int detab(int f, int n) */ int entab(int f, int n) { +#define nextab(a) (a & ~tabmask) + (tabmask+1) + int inc; /* increment to next line [sgn(n)] */ int fspace; /* pointer to first space if in a run */ int ccol; /* current cursor column */ diff --git a/random.h b/random.h index da646ca..749a62c 100644 --- a/random.h +++ b/random.h @@ -3,7 +3,6 @@ #define AEDIT 1 -extern int tabsize ; /* Tab size (0: use real tabs). */ extern int fillcol ; /* Fill column */ From 7b398855e77354b03f5950b2f79513c71f3ca270 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 27 May 2014 17:28:57 +0800 Subject: [PATCH 173/193] Remove buffer overflow by limiting argument size of encryption key and filenames. --- main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 5f23a86..63eb40c 100644 --- a/main.c +++ b/main.c @@ -234,7 +234,8 @@ int main(int argc, char **argv) case 'k': /* -k for code key */ case 'K': cryptflag = TRUE; - strcpy(ekey, &argv[carg][2]); + strncpy( ekey, &argv[ carg][ 2], sizeof ekey - 1) ; /* max encryption pattern limited to NPAT - 1 */ + ekey[ sizeof ekey - 1] = 0 ; break; #endif case 'r': /* -r restrictive use */ @@ -272,7 +273,8 @@ int main(int argc, char **argv) /* set this to inactive */ bp = bfind(bname, TRUE, 0); - strcpy(bp->b_fname, argv[carg]); + strncpy( bp->b_fname, argv[ carg], NFILEN - 1) ; /* max filename length limited to NFILEN - 1 (79) */ + bp->b_fname[ NFILEN - 1] = 0 ; bp->b_active = FALSE; if (firstfile) { firstbp = bp; From ccbd7d709908eef7aa6d8cc57ceb297660bcc4f3 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 28 May 2014 17:48:47 +0800 Subject: [PATCH 174/193] Remove buffer overflow by limiting argument size of search pattern. --- main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 63eb40c..812ce14 100644 --- a/main.c +++ b/main.c @@ -245,7 +245,8 @@ int main(int argc, char **argv) case 's': /* -s for initial search string */ case 'S': searchflag = TRUE; - strncpy(pat, &argv[carg][2], NPAT); + strncpy( pat, &argv[ carg][ 2], NPAT - 1) ; + pat[ NPAT -1] = 0 ; break; case 'v': /* -v for View File */ case 'V': From 5a0b64f9521828b331ecec9a08d168740fe46776 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Thu, 29 May 2014 14:50:39 +0800 Subject: [PATCH 175/193] Add test script to check and size limit on string variables and filenames. --- tststr.cmd | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tststr.cmd diff --git a/tststr.cmd b/tststr.cmd new file mode 100644 index 0000000..988a4b0 --- /dev/null +++ b/tststr.cmd @@ -0,0 +1,37 @@ +; Insert long environment variables [will be truncated to NSTRING - 1 (127)] +insert-string $PATH +newline +; Insert string with escaped characters +insert-string "hello, world~n" +newline +; Insert long quoted string [will be truncated to NSTRING - 2 (126)] +insert-string "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" +next-line +; Insert long tokens [will be truncated to NSTRING - 1 (127)] +insert-string 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 +next-line +insert-string _________1_________2_________3_________4_________5_________6_________7_________8_________9_________0_________1_________2_________3 +next-line +; Create and insert string variable until size exceed string limit [will be truncated to NSTRING - 1 (127) +set %nam 123 +set %expect &len %nam +!while &equ &len %nam %expect + insert-string %nam + newline + set %nam &cat %nam %nam + set %expect &tim %expect 2 +!endwhile +insert-string %nam +newline +insert-string &cat "Actual: " &len %nam +newline +insert-string &cat "Expected: " %expect +newline +; Use the variable as filename [will be truncated to NFILEN - 1 (79)] +write-file %nam +insert-string &cat "Filename: " $cfname +newline +insert-string "Filename length: " +insert-string &len $cfname +save-file +beginning-of-file From 494210424c9d6e7789052db390186939682c11ef Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 30 May 2014 15:27:56 +0800 Subject: [PATCH 176/193] Introduce fname_t type and remove need of NFILEN filename length constant. --- buffer.h | 5 +++-- file.c | 24 ++++++++++++------------ file.h | 2 -- main.c | 4 ++-- spawn.c | 2 +- 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/buffer.h b/buffer.h index 2b69eb8..3109de8 100644 --- a/buffer.h +++ b/buffer.h @@ -4,10 +4,11 @@ #include "crypt.h" #include "line.h" -#define NFILEN 80 /* # of bytes, file name */ #define NBUFN 16 /* # of bytes, buffer name */ #define NPAT 128 /* # of bytes, pattern */ +typedef char fname_t[ 80] ; + /* * Text is kept in buffers. A buffer header, described below, exists for every * buffer in the system. The buffers are kept in a big list, so that commands @@ -30,7 +31,7 @@ struct buffer { char b_active; /* window activated flag */ char b_nwnd; /* Count of windows on buffer */ char b_flag; /* Flags */ - char b_fname[NFILEN]; /* File name */ + fname_t b_fname ; /* File name */ char b_bname[NBUFN]; /* Buffer name */ #if CRYPT char b_key[NPAT]; /* current encrypted key */ diff --git a/file.c b/file.c index bd69bdd..1caa65c 100644 --- a/file.c +++ b/file.c @@ -60,11 +60,11 @@ boolean restflag = FALSE ; /* restricted use? */ int fileread(int f, int n) { int s; - char fname[NFILEN]; + fname_t fname ; if (restflag) /* don't allow this command if restricted */ return resterr(); - if ((s = mlreply("Read file: ", fname, NFILEN)) != TRUE) + if ((s = mlreply("Read file: ", fname, sizeof fname)) != TRUE) return s; return readin(fname, TRUE); } @@ -79,13 +79,13 @@ int fileread(int f, int n) int insfile(int f, int n) { int s; - char fname[NFILEN]; + fname_t fname ; if (restflag) /* don't allow this command if restricted */ return resterr(); if (curbp->b_mode & MDVIEW) /* don't allow this command if */ return rdonly(); /* we are in read only mode */ - if ((s = mlreply("Insert file: ", fname, NFILEN)) != TRUE) + if ((s = mlreply("Insert file: ", fname, sizeof fname)) != TRUE) return s; if ((s = ifile(fname)) != TRUE) return s; @@ -103,25 +103,25 @@ int insfile(int f, int n) */ int filefind(int f, int n) { - char fname[NFILEN]; /* file user wishes to find */ + fname_t fname ; /* file user wishes to find */ int s; /* status return */ if (restflag) /* don't allow this command if restricted */ return resterr(); - if ((s = mlreply("Find file: ", fname, NFILEN)) != TRUE) + if ((s = mlreply("Find file: ", fname, sizeof fname)) != TRUE) return s; return getfile(fname, TRUE); } int viewfile(int f, int n) { /* visit a file in VIEW mode */ - char fname[NFILEN]; /* file user wishes to find */ + fname_t fname ; /* file user wishes to find */ int s; /* status return */ struct window *wp; /* scan for windows that need updating */ if (restflag) /* don't allow this command if restricted */ return resterr(); - if ((s = mlreply("View file: ", fname, NFILEN)) != TRUE) + if ((s = mlreply("View file: ", fname, sizeof fname)) != TRUE) return s; s = getfile(fname, FALSE); if (s) { /* if we succeed, put it in view mode */ @@ -481,11 +481,11 @@ int filewrite(int f, int n) { struct window *wp; int s; - char fname[NFILEN]; + fname_t fname ; if (restflag) /* don't allow this command if restricted */ return resterr(); - if ((s = mlreply("Write file: ", fname, NFILEN)) != TRUE) + if ((s = mlreply("Write file: ", fname, sizeof fname)) != TRUE) return s; if ((s = writeout(fname)) == TRUE) { strcpy(curbp->b_fname, fname); @@ -608,11 +608,11 @@ int filename(int f, int n) { struct window *wp; int s; - char fname[NFILEN]; + fname_t fname ; if (restflag) /* don't allow this command if restricted */ return resterr(); - if ((s = mlreply("Name: ", fname, NFILEN)) == ABORT) + if ((s = mlreply("Name: ", fname, sizeof fname)) == ABORT) return s; if (s == FALSE) strcpy(curbp->b_fname, ""); diff --git a/file.h b/file.h index 0d0330b..ab3ca71 100644 --- a/file.h +++ b/file.h @@ -11,8 +11,6 @@ void cryptbufferkey( struct buffer *bp) ; int set_encryption_key( int f, int n) ; #endif -#define NFILEN 80 /* # of bytes, file name */ - extern boolean restflag ; /* restricted use? */ int fileread( int f, int n) ; diff --git a/main.c b/main.c index 812ce14..8c864c3 100644 --- a/main.c +++ b/main.c @@ -274,8 +274,8 @@ int main(int argc, char **argv) /* set this to inactive */ bp = bfind(bname, TRUE, 0); - strncpy( bp->b_fname, argv[ carg], NFILEN - 1) ; /* max filename length limited to NFILEN - 1 (79) */ - bp->b_fname[ NFILEN - 1] = 0 ; + strncpy( bp->b_fname, argv[ carg], sizeof bp->b_fname - 1) ; /* max filename length limited to NFILEN - 1 (79) */ + bp->b_fname[ sizeof bp->b_fname - 1] = 0 ; bp->b_active = FALSE; if (firstfile) { firstbp = bp; diff --git a/spawn.c b/spawn.c index 2a55bff..0c50ab9 100644 --- a/spawn.c +++ b/spawn.c @@ -401,7 +401,7 @@ int filter_buffer(int f, int n) int s; /* return status from CLI */ struct buffer *bp; /* pointer to buffer to zot */ char line[NLINE]; /* command line send to shell */ - char tmpnam[NFILEN]; /* place to store real file name */ + fname_t tmpnam ; /* place to store real file name */ static char bname1[] = "fltinp"; static char filnam1[] = "fltinp"; From fc79c8e013f93dcaefa8953e5aa35b86aabf6d96 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 30 May 2014 18:08:58 +0800 Subject: [PATCH 177/193] Introduce bname_t type and reduce need of NBUFN buffer name length constant. --- buffer.c | 12 ++++++------ buffer.h | 7 ++++--- exec.c | 12 ++++++------ file.c | 4 ++-- main.c | 2 +- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/buffer.c b/buffer.c index df4d39f..d0e2c57 100644 --- a/buffer.c +++ b/buffer.c @@ -59,9 +59,9 @@ int usebuffer(int f, int n) { struct buffer *bp; int s; - char bufn[NBUFN]; + bname_t bufn ; - if ((s = mlreply("Use buffer: ", bufn, NBUFN)) != TRUE) + if ((s = mlreply("Use buffer: ", bufn, sizeof bufn)) != TRUE) return s; if ((bp = bfind(bufn, TRUE, 0)) == NULL) return FALSE; @@ -168,9 +168,9 @@ int killbuffer(int f, int n) { struct buffer *bp; int s; - char bufn[NBUFN]; + bname_t bufn ; - if ((s = mlreply("Kill buffer: ", bufn, NBUFN)) != TRUE) + if ((s = mlreply("Kill buffer: ", bufn, sizeof bufn)) != TRUE) return s; if ((bp = bfind(bufn, FALSE, 0)) == NULL) /* Easy if unknown. */ return TRUE; @@ -218,10 +218,10 @@ int zotbuf(struct buffer *bp) int namebuffer(int f, int n) { struct buffer *bp; /* pointer to scan through all buffers */ - char bufn[NBUFN]; /* buffer to hold buffer name */ + bname_t bufn ; /* buffer to hold buffer name */ /* prompt for and get the new buffer name */ - ask:if (mlreply("Change buffer name to: ", bufn, NBUFN) != + ask:if (mlreply("Change buffer name to: ", bufn, sizeof bufn) != TRUE) return FALSE; diff --git a/buffer.h b/buffer.h index 3109de8..84de9d1 100644 --- a/buffer.h +++ b/buffer.h @@ -4,10 +4,11 @@ #include "crypt.h" #include "line.h" -#define NBUFN 16 /* # of bytes, buffer name */ #define NPAT 128 /* # of bytes, pattern */ -typedef char fname_t[ 80] ; +typedef char fname_t[ 80] ; /* file name */ +typedef char bname_t[ 16] ; /* buffer name */ +#define NBUFN sizeof( bname_t) /* * Text is kept in buffers. A buffer header, described below, exists for every @@ -32,7 +33,7 @@ struct buffer { char b_nwnd; /* Count of windows on buffer */ char b_flag; /* Flags */ fname_t b_fname ; /* File name */ - char b_bname[NBUFN]; /* Buffer name */ + bname_t b_bname ; /* Buffer name */ #if CRYPT char b_key[NPAT]; /* current encrypted key */ #endif diff --git a/exec.c b/exec.c index 8406617..a6130e2 100644 --- a/exec.c +++ b/exec.c @@ -319,7 +319,7 @@ int nextarg(const char *prompt, char *buffer, int size, int terminator) int storemac(int f, int n) { struct buffer *bp; /* pointer to macro buffer */ - char bname[NBUFN]; /* name of buffer to use */ + bname_t bname ; /* name of buffer to use */ /* must have a numeric argument to this function */ if (f == FALSE) { @@ -366,7 +366,7 @@ int storeproc(int f, int n) { struct buffer *bp; /* pointer to macro buffer */ int status; /* return status */ - char bname[NBUFN]; /* name of buffer to use */ + bname_t bname ; /* name of buffer to use */ /* a numeric argument means its a numbered macro */ if (f == TRUE) @@ -374,7 +374,7 @@ int storeproc(int f, int n) /* get the name of the procedure */ if ((status = - mlreply("Procedure name: ", &bname[1], NBUFN - 2)) != TRUE) + mlreply("Procedure name: ", &bname[1], sizeof bname - 2)) != TRUE) return status; /* construct the macro buffer name */ @@ -441,10 +441,10 @@ int execbuf(int f, int n) { struct buffer *bp; /* ptr to buffer to execute */ int status; /* status return */ - char bufn[NSTRING]; /* name of buffer to execute */ + bname_t bufn ; /* name of buffer to execute */ /* find out what buffer the user wants to execute */ - if ((status = mlreply("Execute buffer: ", bufn, NBUFN)) != TRUE) + if ((status = mlreply("Execute buffer: ", bufn, sizeof bufn)) != TRUE) return status; /* find the pointer to that buffer */ @@ -952,7 +952,7 @@ int dofile(char *fname) struct buffer *bp; /* buffer to place file to exeute */ struct buffer *cb; /* temp to hold current buf while we read */ int status; /* results of various calls */ - char bname[NBUFN]; /* name of buffer */ + bname_t bname ; /* name of buffer */ makename(bname, fname); /* derive the name of the buffer */ unqname(bname); /* make sure we don't stomp things */ diff --git a/file.c b/file.c index 1caa65c..21fc668 100644 --- a/file.c +++ b/file.c @@ -215,7 +215,7 @@ int getfile( const char *fname, boolean lockfl) struct line *lp; int i; int s; - char bname[NBUFN]; /* buffer name to put file */ + bname_t bname ; /* buffer name to put file */ #if MSDOS mklower(fname); /* msdos isn't case sensitive */ @@ -238,7 +238,7 @@ int getfile( const char *fname, boolean lockfl) makename(bname, fname); /* New buffer name. */ while ((bp = bfind(bname, FALSE, 0)) != NULL) { /* old buffer name conflict code */ - s = mlreply("Buffer name: ", bname, NBUFN); + s = mlreply("Buffer name: ", bname, sizeof bname); if (s == ABORT) /* ^G to just quit */ return s; if (s == FALSE) { /* CR to clobber it */ diff --git a/main.c b/main.c index 8c864c3..78b91b5 100644 --- a/main.c +++ b/main.c @@ -156,7 +156,7 @@ int main(int argc, char **argv) int searchflag; /* Do we need to search at start? */ int saveflag; /* temp store for lastflag */ int errflag; /* C error processing? */ - char bname[NBUFN]; /* buffer name of file to read */ + bname_t bname ; /* buffer name of file to read */ #if CRYPT int cryptflag; /* encrypting on the way in? */ char ekey[NPAT]; /* startup encryption key */ From 3847f03f04f3cc8d669389f55dc60fcd67b1c4e6 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sat, 31 May 2014 09:36:25 +0800 Subject: [PATCH 178/193] Explicit use of buffer name type in buffer name creation. --- file.c | 4 ++-- file.h | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/file.c b/file.c index 21fc668..25c8466 100644 --- a/file.c +++ b/file.c @@ -411,7 +411,7 @@ int readin(const char *fname, boolean lockfl) * I suppose that this information could be put in * a better place than a line of code. */ -void makename(char *bname, const char *fname) +void makename( bname_t bname, const char *fname) { const char *cp1; char *cp2; @@ -439,7 +439,7 @@ void makename(char *bname, const char *fname) --cp1; #endif cp2 = &bname[0]; - while (cp2 != &bname[NBUFN - 1] && *cp1 != 0 && *cp1 != ';') + while( cp2 != &bname[ sizeof( bname_t) - 1] && *cp1 != 0 && *cp1 != ';') *cp2++ = *cp1++; *cp2 = 0; } diff --git a/file.h b/file.h index ab3ca71..53417ad 100644 --- a/file.h +++ b/file.h @@ -1,12 +1,11 @@ #ifndef _FILE_H_ #define _FILE_H_ +#include "buffer.h" #include "crypt.h" #include "retcode.h" #if CRYPT -#include "buffer.h" - void cryptbufferkey( struct buffer *bp) ; int set_encryption_key( int f, int n) ; #endif @@ -19,7 +18,7 @@ int filefind( int f, int n) ; int viewfile( int f, int n) ; int getfile( const char *fname, boolean lockfl) ; int readin( const char *fname, boolean lockfl) ; -void makename( char *bname, const char *fname) ; +void makename( bname_t bname, const char *fname) ; void unqname( char *name) ; int filewrite( int f, int n) ; int filesave( int f, int n) ; From 0c423e4e04e7027249a41f39e099cb0e1c78b168 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sat, 31 May 2014 10:02:39 +0800 Subject: [PATCH 179/193] Adjust columns according to buffer name size in list-buffers. --- buffer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/buffer.c b/buffer.c index d0e2c57..600eec3 100644 --- a/buffer.c +++ b/buffer.c @@ -317,8 +317,8 @@ static int makelist( int iflag) if ((s = bclear(blistp)) != TRUE) /* Blow old text away */ return s; strcpy(blistp->b_fname, ""); - if( addline("ACT MODES Size Buffer File") == FALSE - || addline("--- ----- ---- ------ ----") == FALSE) + if( addline("ACT MODES Size Buffer File") == FALSE + || addline("--- ----- ---- ------ ----") == FALSE) return FALSE; bp = bheadp; /* For all buffers */ @@ -392,7 +392,7 @@ static int makelist( int iflag) *cp1++ = c; cp2 = &bp->b_fname[0]; /* File name */ if (*cp2 != 0) { - while (cp1 < &line[3 + 1 + 5 + 1 + 6 + 4 + NBUFN]) + while( cp1 < &line[ 3 + 1 + NUMMODES + 1 + 6 + 1 + NBUFN + 1]) *cp1++ = ' '; while ((c = *cp2++) != 0) { if (cp1 < &line[MAXLINE - 1]) From e2ae45e187599e8784420003e8619cc7f112a1c9 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sat, 31 May 2014 12:09:33 +0800 Subject: [PATCH 180/193] Insure list-buffer can report buffer size up to 99 999 999. --- buffer.c | 16 ++++++++++------ count.cmd | 9 +++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 count.cmd diff --git a/buffer.c b/buffer.c index 600eec3..6548f51 100644 --- a/buffer.c +++ b/buffer.c @@ -310,7 +310,7 @@ static int makelist( int iflag) int s; int i; long nbytes; /* # of bytes in current buffer */ - char b[7 + 1]; + char b[ 8 + 1] ; char line[MAXLINE]; blistp->b_flag &= ~BFCHG; /* Don't complain! */ @@ -375,24 +375,28 @@ static int makelist( int iflag) else *cp1++ = '.'; } - *cp1++ = ' '; /* Gap. */ + + /* No gap as buffer size if left padded with space */ + + /* Buffer size */ nbytes = 0L; /* Count bytes in buf. */ lp = lforw(bp->b_linep); while (lp != bp->b_linep) { nbytes += (long) llength(lp) + 1L; lp = lforw(lp); } - ltoa(b, 7, nbytes); /* 6 digit buffer size. */ + ltoa( b, sizeof b, nbytes) ; /* 8 digits string buffer size. */ cp2 = &b[0]; while ((c = *cp2++) != 0) *cp1++ = c; + *cp1++ = ' '; /* Gap. */ cp2 = &bp->b_bname[0]; /* Buffer name */ while ((c = *cp2++) != 0) *cp1++ = c; cp2 = &bp->b_fname[0]; /* File name */ if (*cp2 != 0) { - while( cp1 < &line[ 3 + 1 + NUMMODES + 1 + 6 + 1 + NBUFN + 1]) + while( cp1 < &line[ 3 + 1 + NUMMODES + 8 + 1 + (NBUFN-1) + 1]) *cp1++ = ' '; while ((c = *cp2++) != 0) { if (cp1 < &line[MAXLINE - 1]) @@ -409,13 +413,13 @@ static int makelist( int iflag) static void ltoa(char *buf, int width, long num) { - buf[width] = 0; /* End of string. */ + buf[ --width] = 0 ; /* End of string. */ while (num >= 10) { /* Conditional digits. */ buf[--width] = (int) (num % 10L) + '0'; num /= 10L; } buf[--width] = (int) num + '0'; /* Always 1 digit. */ - while (width != 0) /* Pad with blanks. */ + while( width > 0) /* Pad with blanks. */ buf[--width] = ' '; } diff --git a/count.cmd b/count.cmd new file mode 100644 index 0000000..69223cf --- /dev/null +++ b/count.cmd @@ -0,0 +1,9 @@ +; count.cmd -- create a buffer with digit from 1 to n +set %i 1 +!while &less %i 2000000 + insert-string %i + newline + set %i &add %i 1 +!endwhile +write-file count.txt +exit-emacs From fa6edaa28285db061807e809185b922185ba57b9 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Mon, 2 Jun 2014 14:22:05 +0800 Subject: [PATCH 181/193] Introduce ekey_t encryption key type and remove need for NKEY length constant. --- buffer.h | 12 +++++++----- file.c | 4 ++-- main.c | 6 +++--- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/buffer.h b/buffer.h index 84de9d1..878df4f 100644 --- a/buffer.h +++ b/buffer.h @@ -4,12 +4,14 @@ #include "crypt.h" #include "line.h" -#define NPAT 128 /* # of bytes, pattern */ - -typedef char fname_t[ 80] ; /* file name */ -typedef char bname_t[ 16] ; /* buffer name */ +typedef char fname_t[ 80] ; /* file name type */ +typedef char bname_t[ 16] ; /* buffer name type */ #define NBUFN sizeof( bname_t) +#if CRYPT +typedef char ekey_t[ 128] ; /* encryption key type */ +#endif + /* * Text is kept in buffers. A buffer header, described below, exists for every * buffer in the system. The buffers are kept in a big list, so that commands @@ -35,7 +37,7 @@ struct buffer { fname_t b_fname ; /* File name */ bname_t b_bname ; /* Buffer name */ #if CRYPT - char b_key[NPAT]; /* current encrypted key */ + ekey_t b_key ; /* current encrypted key */ #endif }; diff --git a/file.c b/file.c index 25c8466..9594553 100644 --- a/file.c +++ b/file.c @@ -153,14 +153,14 @@ int set_encryption_key(int f, int n) { int status; /* return status */ int odisinp; /* original vlaue of disinp */ - char key[NPAT]; /* new encryption string */ + ekey_t key ; /* new encryption string */ /* turn command input echo off */ odisinp = disinp; disinp = FALSE; /* get the string to use as an encrytion string */ - status = mlreply("Encryption String: ", key, NPAT - 1); + status = mlreply("Encryption String: ", key, sizeof key - 1); disinp = odisinp; if (status != TRUE) return status; diff --git a/main.c b/main.c index 78b91b5..6c0ee7b 100644 --- a/main.c +++ b/main.c @@ -159,7 +159,7 @@ int main(int argc, char **argv) bname_t bname ; /* buffer name of file to read */ #if CRYPT int cryptflag; /* encrypting on the way in? */ - char ekey[NPAT]; /* startup encryption key */ + ekey_t ekey ; /* startup encryption key */ #endif int newc; @@ -234,7 +234,7 @@ int main(int argc, char **argv) case 'k': /* -k for code key */ case 'K': cryptflag = TRUE; - strncpy( ekey, &argv[ carg][ 2], sizeof ekey - 1) ; /* max encryption pattern limited to NPAT - 1 */ + strncpy( ekey, &argv[ carg][ 2], sizeof ekey - 1) ; ekey[ sizeof ekey - 1] = 0 ; break; #endif @@ -288,7 +288,7 @@ int main(int argc, char **argv) #if CRYPT if (cryptflag) { bp->b_mode |= MDCRYPT; - strncpy( bp->b_key, ekey, NPAT) ; + strncpy( bp->b_key, ekey, sizeof ekey) ; cryptbufferkey( bp) ; } #endif From 3197080cb12560069e34600b6765faacb5990927 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Mon, 2 Jun 2014 15:16:18 +0800 Subject: [PATCH 182/193] Introduce spat_t as search pattern type and reduce need for NPAT as pattern length constant. --- defines.h | 1 - exec.c | 4 ++-- input.c | 4 ++-- isearch.c | 9 +++++---- main.c | 4 ++-- random.c | 18 +++++++++--------- search.c | 8 ++++---- search.h | 9 ++++++--- 8 files changed, 30 insertions(+), 27 deletions(-) diff --git a/defines.h b/defines.h index f84bd94..b710333 100644 --- a/defines.h +++ b/defines.h @@ -8,7 +8,6 @@ #define ENVFUNC 1 #define NSTRING 128 /* # of bytes, string buffers */ -#define NPAT 128 /* # of bytes, pattern */ #define CONTROL 0x10000000 /* Control flag, or'ed in */ #define META 0x20000000 /* Meta flag, or'ed in */ diff --git a/exec.c b/exec.c index a6130e2..e32d895 100644 --- a/exec.c +++ b/exec.c @@ -72,7 +72,7 @@ static const char *dname[] = { "force" }; -static char golabel[ NPAT] = "" ; /* current line to go to */ +static char golabel[ NSTRING] = "" ; /* current line to go to */ static int execlevel = 0 ; /* execution IF level */ static struct buffer *bstore = NULL ; /* buffer to store macro text to */ static int mstore = FALSE ; /* storing text to macro flag */ @@ -798,7 +798,7 @@ static int dobuf(struct buffer *bp) /* grab label to jump to */ eline = - token(eline, golabel, NPAT); + token( eline, golabel, sizeof golabel) ; linlen = strlen(golabel); glp = hlp->l_fp; while (glp != hlp) { diff --git a/input.c b/input.c index bb98cc8..e599cde 100644 --- a/input.c +++ b/input.c @@ -61,7 +61,7 @@ static const int quotec = 0x11 ; /* quote char during mlreply() */ int mlyesno( const char *prompt) { char c; /* input character */ - char buf[NPAT]; /* prompt to user */ + char buf[ NSTRING] ; /* prompt to user */ for (;;) { /* build and prompt the user */ @@ -69,7 +69,7 @@ int mlyesno( const char *prompt) strcat(buf, " (y/n)? "); mlwrite(buf); - /* get the responce */ + /* get the response */ c = tgetc(); if (c == ectoc(abortc)) /* Bail out! */ diff --git a/isearch.c b/isearch.c index e14988f..258d8ce 100644 --- a/isearch.c +++ b/isearch.c @@ -188,7 +188,7 @@ static int isearch(int f, int n) int cpos; /* character number in search string */ int c; /* current input character */ int expc; /* function expanded input char */ - char pat_save[NPAT]; /* Saved copy of the old pattern str */ + spat_t pat_save ; /* Saved copy of the old pattern str */ struct line *curline; /* Current line on entry */ int curoff; /* Current offset on entry */ int init_direction; /* The initial search direction */ @@ -198,7 +198,7 @@ static int isearch(int f, int n) cmd_reexecute = -1; /* We're not re-executing (yet?) */ cmd_offset = 0; /* Start at the beginning of the buff */ cmd_buff[0] = '\0'; /* Init the command buffer */ - strncpy(pat_save, pat, NPAT); /* Save the old pattern string */ + strncpy( pat_save, pat, sizeof pat_save) ; /* Save the old pattern string */ curline = curwp->w_dotp; /* Save the current line pointer */ curoff = curwp->w_doto; /* Save the current offset */ init_direction = n; /* Save the initial search direction */ @@ -276,7 +276,7 @@ static int isearch(int f, int n) curwp->w_dotp = curline; /* Reset the line pointer */ curwp->w_doto = curoff; /* and the offset */ n = init_direction; /* Reset the search direction */ - strncpy(pat, pat_save, NPAT); /* Restore the old search str */ + strncpy( pat, pat_save, sizeof pat) ; /* Restore the old search str */ cmd_reexecute = 0; /* Start the whole mess over */ goto start_over; /* Let it take care of itself */ @@ -292,7 +292,8 @@ static int isearch(int f, int n) /* I guess we got something to search for, so search for it */ pat[cpos++] = c; /* put the char in the buffer */ - if (cpos >= NPAT) { /* too many chars in string? *//* Yup. Complain about it */ + if (cpos >= sizeof pat) { /* too many chars in string? */ + /* Yup. Complain about it */ mlwrite("? Search string too long"); return TRUE; /* Return an error */ } diff --git a/main.c b/main.c index 6c0ee7b..d7b8f37 100644 --- a/main.c +++ b/main.c @@ -245,8 +245,8 @@ int main(int argc, char **argv) case 's': /* -s for initial search string */ case 'S': searchflag = TRUE; - strncpy( pat, &argv[ carg][ 2], NPAT - 1) ; - pat[ NPAT -1] = 0 ; + strncpy( pat, &argv[ carg][ 2], sizeof pat - 1) ; + pat[ sizeof pat -1] = 0 ; break; case 'v': /* -v for View File */ case 'V': diff --git a/random.c b/random.c index da10dce..55827af 100644 --- a/random.c +++ b/random.c @@ -937,7 +937,7 @@ int adjustmode(int kind, int global) int i; /* loop index */ int status; /* error return on input */ char prompt[50]; /* string to prompt user with */ - char cbuf[NPAT]; /* buffer to recieve mode name into */ + char cbuf[ NSTRING] ; /* buffer to recieve mode name into */ /* build the proper prompt string */ if (global) @@ -952,7 +952,7 @@ int adjustmode(int kind, int global) /* prompt the user and get an answer */ - status = mlreply(prompt, cbuf, NPAT - 1); + status = mlreply( prompt, cbuf, sizeof cbuf - 1) ; if (status != TRUE) return status; @@ -1033,11 +1033,11 @@ int writemsg(int f, int n) char *sp; /* pointer into buf to expand %s */ char *np; /* ptr into nbuf */ int status; - char buf[NPAT]; /* buffer to recieve message into */ - char nbuf[NPAT * 2]; /* buffer to expand string into */ + char buf[ NSTRING] ; /* buffer to recieve message into */ + char nbuf[ NSTRING * 2] ; /* buffer to expand string into */ if ((status = - mlreply("Message to write: ", buf, NPAT - 1)) != TRUE) + mlreply("Message to write: ", buf, sizeof buf - 1)) != TRUE) return status; /* expand all '%' to "%%" so mlwrite won't expect arguments */ @@ -1231,11 +1231,11 @@ int fmatch(int ch) int istring(int f, int n) { int status; /* status return code */ - char tstring[NPAT + 1]; /* string to add */ + char tstring[ NSTRING + 1] ; /* string to add */ /* ask for string to insert */ status = - mlreplyt("String to insert: ", tstring, NPAT, metac); + mlreplyt("String to insert: ", tstring, NSTRING, metac) ; if (status != TRUE) return status; @@ -1259,11 +1259,11 @@ int istring(int f, int n) int ovstring(int f, int n) { int status; /* status return code */ - char tstring[NPAT + 1]; /* string to add */ + char tstring[ NSTRING + 1] ; /* string to add */ /* ask for string to insert */ status = - mlreplyt("String to overwrite: ", tstring, NPAT, metac); + mlreplyt( "String to overwrite: ", tstring, NSTRING, metac) ; if (status != TRUE) return status; diff --git a/search.c b/search.c index c32e56b..db2971a 100644 --- a/search.c +++ b/search.c @@ -87,9 +87,9 @@ char *patmatch = NULL ; static struct line *matchline = NULL; static int matchoff = 0; -char pat[ NPAT] ; /* Search pattern */ -char tap[ NPAT] ; /* Reversed pattern array. */ -char rpat[ NPAT] ; /* replacement pattern */ +spat_t pat ; /* Search pattern */ +spat_t tap ; /* Reversed pattern array. */ +spat_t rpat ; /* replacement pattern */ #if defined(MAGIC) @@ -815,7 +815,7 @@ static int replaces(int kind, int f, int n) int nlflag; /* last char of search string a ? */ int nlrepl; /* was a replace done on the last line? */ char c; /* input char for query */ - char tpat[NPAT]; /* temporary to hold search pattern */ + spat_t tpat ; /* temporary to hold search pattern */ struct line *origline; /* original "." position */ int origoff; /* and offset (for . query option) */ struct line *lastline; /* position of last replace and */ diff --git a/search.h b/search.h index 9b53f32..568d553 100644 --- a/search.h +++ b/search.h @@ -7,12 +7,15 @@ #define BELL 0x07 /* a bell character */ +typedef char spat_t[ 128] ; /* search pattern type */ +#define NPAT sizeof( spat_t) /* # of bytes, pattern */ + extern unsigned int matchlen ; extern char *patmatch ; -extern char pat[] ; /* Search pattern */ -extern char tap[] ; /* Reversed pattern array. */ -extern char rpat[] ; /* replacement pattern */ +extern spat_t pat ; /* Search pattern */ +extern spat_t tap ; /* Reversed pattern array. */ +extern spat_t rpat ; /* replacement pattern */ /* * PTBEG, PTEND, FORWARD, and REVERSE are all toggle-able values for From a560025c0cbf9d99d1c8746e19d2ae7203e14e57 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 3 Jun 2014 15:45:41 +0800 Subject: [PATCH 183/193] Fix $kill to cover at most first 127 characters of kill buffer. Was only first N % 250 (ex 25 out of 275). --- line.c | 2 +- tststr.cmd | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/line.c b/line.c index 02eb65d..e0fa6ed 100644 --- a/line.c +++ b/line.c @@ -63,7 +63,7 @@ char *getkill( void) value[0] = 0; else { /* copy in the contents... */ - if (kused < NSTRING) + if( kbufh == kbufp && kused < NSTRING) size = kused; else size = NSTRING - 1; diff --git a/tststr.cmd b/tststr.cmd index 988a4b0..9f524b1 100644 --- a/tststr.cmd +++ b/tststr.cmd @@ -33,5 +33,18 @@ insert-string &cat "Filename: " $cfname newline insert-string "Filename length: " insert-string &len $cfname +end-of-file +; Create a line longer than 1 kill block (250), 2 * 127 + 21 = 255 +insert-string 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 +insert-string 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 +insert-string "#12345678901234567890" +; kill and yank +beginning-of-line +kill-to-end-of-line +yank +newline +; insert kill variable (up to 127 characters), was 25 before fix +insert-string $kill save-file beginning-of-file + From 79b57c96d1978c58d4b9df11d41d8035bd105a56 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 4 Jun 2014 11:32:50 +0800 Subject: [PATCH 184/193] insert-string can insert strings up to 512 characters. --- random.c | 4 ++-- tststr.cmd | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/random.c b/random.c index 55827af..ba87dca 100644 --- a/random.c +++ b/random.c @@ -1231,11 +1231,11 @@ int fmatch(int ch) int istring(int f, int n) { int status; /* status return code */ - char tstring[ NSTRING + 1] ; /* string to add */ + char tstring[ 512] ; /* string to add */ /* ask for string to insert */ status = - mlreplyt("String to insert: ", tstring, NSTRING, metac) ; + mlreplyt("String to insert: ", tstring, sizeof tstring - 1, metac) ; if (status != TRUE) return status; diff --git a/tststr.cmd b/tststr.cmd index 9f524b1..9089987 100644 --- a/tststr.cmd +++ b/tststr.cmd @@ -1,6 +1,13 @@ ; Insert long environment variables [will be truncated to NSTRING - 1 (127)] +insert-string &env PATH +newline insert-string $PATH newline +set %mypath $PATH +insert-string %mypath +newline +insert-string &cat "Length of $PATH: " &len $PATH +newline ; Insert string with escaped characters insert-string "hello, world~n" newline @@ -41,8 +48,9 @@ insert-string "#12345678901234567890" ; kill and yank beginning-of-line kill-to-end-of-line +kill-to-end-of-line +yank yank -newline ; insert kill variable (up to 127 characters), was 25 before fix insert-string $kill save-file From cc06049046d8395f3ac70fd38fbbafcba2f9d4da Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 4 Jun 2014 13:51:33 +0800 Subject: [PATCH 185/193] $kill returns full copy of kill buffer. --- line.c | 45 +++++++++++++++++++++++++++++++++------------ tststr.cmd | 13 ++++++++++++- 2 files changed, 45 insertions(+), 13 deletions(-) diff --git a/line.c b/line.c index e0fa6ed..9bfcc83 100644 --- a/line.c +++ b/line.c @@ -49,26 +49,38 @@ struct kill { static struct kill *kbufp = NULL ; /* current kill buffer chunk pointer */ static struct kill *kbufh = NULL ; /* kill buffer header pointer */ static int kused = KBLOCK ; /* # of bytes used in kill buffer */ +static int klen ; /* length of kill buffer content */ +static char *value = NULL ; /* temp buffer for value */ /* * return some of the contents of the kill buffer */ -char *getkill( void) -{ - int size; /* max number of chars to return */ - static char value[NSTRING]; /* temp buffer for value */ +char *getkill( void) { + struct kill *kp ; + char *cp ; if (kbufh == NULL) /* no kill buffer....just a null string */ - value[0] = 0; - else { - /* copy in the contents... */ - if( kbufh == kbufp && kused < NSTRING) - size = kused; + return "" ; + + if( value != NULL) + free( value) ; + + value = (char *) malloc( klen + 1) ; + cp = value ; + for( kp = kbufh ; kp != NULL ; kp = kp->d_next) { + int size ; + + if( kp->d_next != NULL) + size = KBLOCK ; else - size = NSTRING - 1; - strncpy(value, kbufh->d_chunk, size); + size = kused ; + + memcpy( cp, kp->d_chunk, size) ; + cp += size ; } + + *cp = 0 ; /* and return the constructed value */ return value; @@ -712,6 +724,11 @@ void kdelete(void) /* and reset all the kill buffer pointers */ kbufh = kbufp = NULL; kused = KBLOCK; + klen = 0 ; + if( value != NULL) { + free( value) ; + value = NULL ; + } } } @@ -729,8 +746,11 @@ int kinsert(int c) if (kused >= KBLOCK) { if ((nchunk = (struct kill *)malloc(sizeof(struct kill))) == NULL) return FALSE; - if (kbufh == NULL) /* set head ptr if first time */ + if( kbufh == NULL) { /* set head ptr if first time */ kbufh = nchunk; + klen = 0 ; + } + if (kbufp != NULL) /* point the current to this new one */ kbufp->d_next = nchunk; kbufp = nchunk; @@ -740,6 +760,7 @@ int kinsert(int c) /* and now insert the character */ kbufp->d_chunk[kused++] = c; + klen += 1 ; return TRUE; } diff --git a/tststr.cmd b/tststr.cmd index 9089987..1463032 100644 --- a/tststr.cmd +++ b/tststr.cmd @@ -3,6 +3,8 @@ insert-string &env PATH newline insert-string $PATH newline +insert-string &cat $PATH $PATH +newline set %mypath $PATH insert-string %mypath newline @@ -11,6 +13,12 @@ newline ; Insert string with escaped characters insert-string "hello, world~n" newline +; Insert 512 long token [will be truncated to sizeof istring buffer - 2 (510)] +insert-string 0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF +newline +; Insert 512 long quoted string [will be truncated to sizeof istring buffer - 3 (509)] +insert-string "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" +newline ; Insert long quoted string [will be truncated to NSTRING - 2 (126)] insert-string "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" next-line @@ -55,4 +63,7 @@ yank insert-string $kill save-file beginning-of-file - +set-mark +end-of-file +copy-region +insert-string $kill From 45981e8793461b227d777a94aeacc4394b585055 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 6 Jun 2014 15:09:08 +0800 Subject: [PATCH 186/193] Limit the scope of docmd. --- exec.c | 5 +++-- exec.h | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/exec.c b/exec.c index e32d895..5e07a33 100644 --- a/exec.c +++ b/exec.c @@ -101,6 +101,8 @@ int namedcmd(int f, int n) return kfunc(f, n); } +static int docmd( char *cline) ; + /* * execcmd: * Execute a command line command to be typed in @@ -134,8 +136,7 @@ int execcmd(int f, int n) * * char *cline; command line to execute */ -int docmd(char *cline) -{ +static int docmd( char *cline) { int f; /* default argument flag */ int n; /* numeric repeat value */ fn_t fnc; /* function to execute */ diff --git a/exec.h b/exec.h index b82c6b9..7ac4b1c 100644 --- a/exec.h +++ b/exec.h @@ -19,7 +19,6 @@ extern boolean clexec ; /* command line execution flag */ int namedcmd( int f, int n) ; int execcmd( int f, int n) ; -int docmd( char *cline) ; char *token( char *src, char *tok, int size) ; int macarg( char *tok) ; int nextarg( const char *prompt, char *buffer, int size, int terminator) ; From 3be85dec655b614bd38a15ef91117ee5c50d15d7 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 18 Jun 2014 14:59:40 +0800 Subject: [PATCH 187/193] Recompile under MinGW32 with base framework for implementing kbd/screen (mingw32 + wscreen). --- Makefile | 22 ++- buffer.c | 6 +- display.c | 2 + estruct.h | 11 ++ eval.c | 84 ++++----- eval.h | 2 +- exec.c | 2 +- main.c | 2 + spawn.c | 2 +- tcap.c | 2 + termio.c | 540 +++++++++++++++++++++++++++--------------------------- wrapper.c | 6 + 12 files changed, 356 insertions(+), 325 deletions(-) diff --git a/Makefile b/Makefile index 3ee359f..599ce46 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ -# Makefile for emacs, updated Thu, Oct 10, 2013 1:03:16 PM +# Makefile for emacs, updated Wed, Jun 18, 2014 2:24:32 PM -SRC=ansi.c basic.c bind.c bindable.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c ibmpc.c input.c isearch.c line.c lock.c log.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c -OBJ=ansi.o basic.o bind.o bindable.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o ibmpc.o input.o isearch.o line.o lock.o log.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o -HDR=basic.h bind.h bindable.h buffer.h crypt.h defines.h display.h ebind.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h log.h names.h pklock.h random.h region.h retcode.h search.h spawn.h terminal.h termio.h utf8.h version.h window.h word.h wrapper.h +SRC=ansi.c basic.c bind.c bindable.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c ibmpc.c input.c isearch.c line.c lock.c log.c main.c mingw32.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c wscreen.c +OBJ=ansi.o basic.o bind.o bindable.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o ibmpc.o input.o isearch.o line.o lock.o log.o main.o mingw32.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o wscreen.o +HDR=basic.h bind.h bindable.h buffer.h crypt.h defines.h display.h ebind.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h log.h names.h pklock.h random.h region.h retcode.h search.h spawn.h terminal.h termio.h utf8.h version.h window.h word.h wrapper.h wscreen.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -40,13 +40,19 @@ ifeq ($(uname_S),Darwin) endif ifeq ($(uname_S),CYGWIN_NT-6.1-WOW64) DEFINES=-DAUTOCONF -DCYGWIN -DPROGRAM=$(PROGRAM) + LIBS=-lcurses # SYSV endif ifeq ($(uname_S),CYGWIN_NT-6.1) DEFINES=-DAUTOCONF -DCYGWIN -DPROGRAM=$(PROGRAM) + LIBS=-lcurses # SYSV +endif +ifeq ($(uname_S),MINGW32_NT-6.1) + DEFINES=-DAUTOCONF -DSYSV -DMINGW32 -DPROGRAM=$(PROGRAM) + LIBS= endif #DEFINES=-DAUTOCONF #LIBS=-ltermcap # BSD -LIBS=-lcurses # SYSV +#LIBS=-lcurses # SYSV #LIBS=-ltermlib #LIBS=-L/usr/lib/termcap -ltermcap LFLAGS=-hbx @@ -152,8 +158,8 @@ exec.o: exec.c exec.h retcode.h buffer.h crypt.h line.h utf8.h bind.h \ display.h estruct.h eval.h file.h flook.h input.h random.h window.h \ defines.h execute.o: execute.c execute.h estruct.h bind.h random.h display.h file.h \ - crypt.h retcode.h buffer.h line.h utf8.h terminal.h defines.h window.h -file.o: file.c file.h crypt.h retcode.h buffer.h line.h utf8.h defines.h \ + buffer.h crypt.h line.h utf8.h retcode.h terminal.h defines.h window.h +file.o: file.c file.h buffer.h crypt.h line.h utf8.h retcode.h defines.h \ estruct.h execute.h fileio.h input.h bind.h lock.h log.h window.h fileio.o: fileio.c fileio.h crypt.h retcode.h defines.h flook.o: flook.c flook.h retcode.h defines.h fileio.h crypt.h @@ -170,6 +176,7 @@ log.o: log.c log.h retcode.h main.o: main.c estruct.h basic.h bind.h bindable.h buffer.h crypt.h \ line.h utf8.h display.h eval.h execute.h file.h retcode.h input.h lock.h \ log.h random.h search.h terminal.h defines.h termio.h version.h window.h +mingw32.o: mingw32.c names.o: names.c names.h basic.h bind.h bindable.h buffer.h crypt.h \ line.h utf8.h display.h eval.h exec.h retcode.h file.h isearch.h \ region.h random.h search.h spawn.h window.h defines.h word.h @@ -197,6 +204,7 @@ window.o: window.c window.h defines.h buffer.h crypt.h line.h utf8.h \ word.o: word.c word.h basic.h buffer.h crypt.h line.h utf8.h estruct.h \ log.h retcode.h random.h region.h window.h defines.h wrapper.o: wrapper.c wrapper.h +wscreen.o: wscreen.c wscreen.h # DEPENDENCIES MUST END AT END OF FILE # IF YOU PUT STUFF HERE IT WILL GO AWAY diff --git a/buffer.c b/buffer.c index 6548f51..625e1b7 100644 --- a/buffer.c +++ b/buffer.c @@ -46,7 +46,7 @@ static const char modecode[] = "WCSEVOMYAUD" ; /* letters to represent modes */ static int makelist( int iflag) ; static int addline( char *text) ; -static void ltoa( char *buf, int width, long num) ; +static void l_to_a( char *buf, int width, long num) ; /* @@ -385,7 +385,7 @@ static int makelist( int iflag) nbytes += (long) llength(lp) + 1L; lp = lforw(lp); } - ltoa( b, sizeof b, nbytes) ; /* 8 digits string buffer size. */ + l_to_a( b, sizeof b, nbytes) ; /* 8 digits string buffer size. */ cp2 = &b[0]; while ((c = *cp2++) != 0) *cp1++ = c; @@ -411,7 +411,7 @@ static int makelist( int iflag) return TRUE; /* All done */ } -static void ltoa(char *buf, int width, long num) +static void l_to_a(char *buf, int width, long num) { buf[ --width] = 0 ; /* End of string. */ while (num >= 10) { /* Conditional digits. */ diff --git a/display.c b/display.c index 09bbb92..404a03d 100644 --- a/display.c +++ b/display.c @@ -87,7 +87,9 @@ static void modeline(struct window *wp); static void mlputi(int i, int r); static void mlputli(long l, int r); static void mlputf(int s); +#if SIGWINCH static int newscreensize(int h, int w); +#endif #if RAINBOW static void putline(int row, int col, char *buf); diff --git a/estruct.h b/estruct.h index 22acf9d..cb2e2d4 100644 --- a/estruct.h +++ b/estruct.h @@ -106,6 +106,17 @@ #define TERMCAP 0 /* Use TERMCAP */ #define IBMPC 1 /* IBM-PC CGA/MONO/EGA driver */ +#elif defined( MINGW32) + +#define VT220 (UNIX | VMS) +#define VT100 0 + +#define ANSI 0 +#define VMSVT 0 +#define VT52 0 +#define TERMCAP 0 +#define IBMPC 0 + #else #define VT220 (UNIX | VMS) diff --git a/eval.c b/eval.c index b72a38e..18d4f0d 100644 --- a/eval.c +++ b/eval.c @@ -348,17 +348,17 @@ char *gtfun(char *fname) /* and now evaluate it! */ switch (fnum) { case UFADD: - return itoa(atoi(arg1) + atoi(arg2)); + return i_to_a(atoi(arg1) + atoi(arg2)); case UFSUB: - return itoa(atoi(arg1) - atoi(arg2)); + return i_to_a(atoi(arg1) - atoi(arg2)); case UFTIMES: - return itoa(atoi(arg1) * atoi(arg2)); + return i_to_a(atoi(arg1) * atoi(arg2)); case UFDIV: - return itoa(atoi(arg1) / atoi(arg2)); + return i_to_a(atoi(arg1) / atoi(arg2)); case UFMOD: - return itoa(atoi(arg1) % atoi(arg2)); + return i_to_a(atoi(arg1) % atoi(arg2)); case UFNEG: - return itoa(-atoi(arg1)); + return i_to_a(-atoi(arg1)); case UFCAT: strcpy(result, arg1); return strcat(result, arg2); @@ -391,7 +391,7 @@ char *gtfun(char *fname) case UFOR: return ltos(stol(arg1) || stol(arg2)); case UFLENGTH: - return itoa(strlen(arg1)); + return i_to_a(strlen(arg1)); case UFUPPER: return mkupper(arg1); case UFLOWER: @@ -399,7 +399,7 @@ char *gtfun(char *fname) case UFTRUTH: return ltos(atoi(arg1) == 42); case UFASCII: - return itoa((int) arg1[0]); + return i_to_a((int) arg1[0]); case UFCHR: result[0] = atoi(arg1); result[1] = 0; @@ -409,11 +409,11 @@ char *gtfun(char *fname) result[1] = 0; return result; case UFRND: - return itoa((ernd() % abs(atoi(arg1))) + 1); + return i_to_a((ernd() % abs(atoi(arg1))) + 1); case UFABS: - return itoa(abs(atoi(arg1))); + return i_to_a(abs(atoi(arg1))); case UFSINDEX: - return itoa(sindex(arg1, arg2)); + return i_to_a(sindex(arg1, arg2)); case UFENV: #if ENVFUNC tsp = getenv(arg1); @@ -429,13 +429,13 @@ char *gtfun(char *fname) tsp = flook(arg1, TRUE); return tsp == NULL ? "" : tsp; case UFBAND: - return itoa(atoi(arg1) & atoi(arg2)); + return i_to_a(atoi(arg1) & atoi(arg2)); case UFBOR: - return itoa(atoi(arg1) | atoi(arg2)); + return i_to_a(atoi(arg1) | atoi(arg2)); case UFBXOR: - return itoa(atoi(arg1) ^ atoi(arg2)); + return i_to_a(atoi(arg1) ^ atoi(arg2)); case UFBNOT: - return itoa(~atoi(arg1)); + return i_to_a(~atoi(arg1)); case UFXLATE: return xlat(arg1, arg2, arg3); } @@ -497,19 +497,19 @@ char *gtenv(char *vname) /* otherwise, fetch the appropriate value */ switch (vnum) { case EVFILLCOL: - return itoa(fillcol); + return i_to_a(fillcol); case EVPAGELEN: - return itoa(term.t_nrow + 1); + return i_to_a(term.t_nrow + 1); case EVCURCOL: - return itoa(getccol(FALSE)); + return i_to_a(getccol(FALSE)); case EVCURLINE: - return itoa(getcline()); + return i_to_a(getcline()); case EVRAM: - return itoa((int) (envram / 1024l)); + return i_to_a((int) (envram / 1024l)); case EVFLICKER: return ltos(flickcode); case EVCURWIDTH: - return itoa(term.t_ncol); + return i_to_a(term.t_ncol); case EVCBUFNAME: return curbp->b_bname; case EVCFNAME: @@ -527,15 +527,15 @@ char *gtenv(char *vname) } case EVASAVE: - return itoa(gasave); + return i_to_a(gasave); case EVACOUNT: - return itoa(gacount); + return i_to_a(gacount); case EVLASTKEY: - return itoa(lastkey); + return i_to_a(lastkey); case EVCURCHAR: return (curwp->w_dotp->l_used == - curwp->w_doto ? itoa('\n') : - itoa(lgetc(curwp->w_dotp, curwp->w_doto))); + curwp->w_doto ? i_to_a('\n') : + i_to_a(lgetc(curwp->w_dotp, curwp->w_doto))); case EVDISCMD: return ltos(discmd); case EVVERSION: @@ -543,16 +543,16 @@ char *gtenv(char *vname) case EVPROGNAME: return PROGRAM_NAME_LONG; case EVSEED: - return itoa(seed); + return i_to_a(seed); case EVDISINP: return ltos(disinp); case EVWLINE: - return itoa(curwp->w_ntrows); + return i_to_a(curwp->w_ntrows); case EVCWLINE: - return itoa(getwpos()); + return i_to_a(getwpos()); case EVTARGET: saveflag = lastflag; - return itoa(curgoal); + return i_to_a(curgoal); case EVSEARCH: return pat; case EVREPLACE: @@ -562,11 +562,11 @@ char *gtenv(char *vname) case EVKILL: return getkill(); case EVCMODE: - return itoa(curbp->b_mode); + return i_to_a(curbp->b_mode); case EVGMODE: - return itoa(gmode); + return i_to_a(gmode); case EVTPAUSE: - return itoa(term.t_pause); + return i_to_a(term.t_pause); case EVPENDING: #if TYPEAH return ltos(typahead()); @@ -574,19 +574,19 @@ char *gtenv(char *vname) return falsem; #endif case EVLWIDTH: - return itoa(llength(curwp->w_dotp)); + return i_to_a(llength(curwp->w_dotp)); case EVLINE: return getctext(); case EVGFLAGS: - return itoa(gflags); + return i_to_a(gflags); case EVRVAL: - return itoa(rval); + return i_to_a(rval); case EVTAB: - return itoa(tabmask + 1); + return i_to_a(tabmask + 1); case EVOVERLAP: - return itoa(overlap); + return i_to_a(overlap); case EVSCROLLCOUNT: - return itoa(scrollcount); + return i_to_a(scrollcount); #if SCROLLCODE case EVSCROLL: return ltos(term.t_scroll != NULL); @@ -632,7 +632,7 @@ int setvar(int f, int n) /* get the value for that variable */ if (f == TRUE) - strcpy(value, itoa(n)); + strcpy(value, i_to_a(n)); else { status = mlreply("Value: ", &value[0], NSTRING); if (status != TRUE) @@ -929,13 +929,13 @@ static int svar(struct variable_description *var, char *value) } /* - * itoa: + * i_to_a: * integer to ascii string.......... This is too * inconsistant to use the system's * * int i; integer to translate to a string */ -char *itoa(int i) +char *i_to_a(int i) { #define INTWIDTH sizeof( int) * 3 diff --git a/eval.h b/eval.h index fd674eb..84a5b58 100644 --- a/eval.h +++ b/eval.h @@ -43,7 +43,7 @@ char *gtfun( char *fname) ; char *gtusr( char *vname) ; char *gtenv( char *vname) ; int setvar( int f, int n) ; -char *itoa( int i) ; +char *i_to_a( int i) ; char *getval( char *token) ; int stol( char *val) ; char *mkupper( char *str) ; diff --git a/exec.c b/exec.c index 5e07a33..d37ffcd 100644 --- a/exec.c +++ b/exec.c @@ -629,7 +629,7 @@ static int dobuf(struct buffer *bp) strcat(outline, ":"); /* debug if levels */ - strcat(outline, itoa(execlevel)); + strcat(outline, i_to_a(execlevel)); strcat(outline, ":"); /* and lastly the line */ diff --git a/main.c b/main.c index d7b8f37..f576afd 100644 --- a/main.c +++ b/main.c @@ -296,7 +296,9 @@ int main(int argc, char **argv) } #if UNIX +#ifdef SIGHUP signal(SIGHUP, emergencyexit); +#endif signal(SIGTERM, emergencyexit); #endif diff --git a/spawn.c b/spawn.c index 0c50ab9..c7f4bad 100644 --- a/spawn.c +++ b/spawn.c @@ -102,7 +102,7 @@ int spawncli(int f, int n) system("exec /bin/sh"); #endif sgarbf = TRUE; - sleep(2); + usleep( 2000000L) ; TTopen(); TTkopen(); #ifdef SIGWINCH diff --git a/tcap.c b/tcap.c index ffa0c00..5b045fa 100644 --- a/tcap.c +++ b/tcap.c @@ -19,6 +19,7 @@ #define USE_BROKEN_OPTIMIZATION 0 #define termdef 1 /* Don't define "term" external. */ +#ifndef MINGW32 #ifdef CYGWIN #include #include @@ -26,6 +27,7 @@ #include #include #endif +#endif #include "display.h" #include "estruct.h" diff --git a/termio.c b/termio.c index 92fbc95..abb2620 100644 --- a/termio.c +++ b/termio.c @@ -1,15 +1,15 @@ #include "termio.h" -/* TERMIO.C +/* 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 + * modified by Petri Kutvonen */ -#ifndef POSIX +#if !defined( POSIX) && !defined( MINGW32) #include #include @@ -23,8 +23,8 @@ #include #include -int ttrow = HUGE ; /* Row location of HW cursor */ -int ttcol = HUGE ; /* Column location of HW cursor */ +int ttrow = HUGE ; /* Row location of HW cursor */ +int ttcol = HUGE ; /* Column location of HW cursor */ #if VMS #include @@ -32,76 +32,76 @@ int ttcol = HUGE ; /* Column location of HW cursor */ #include #include #include -#include +#include -#define NIBUF 128 /* Input buffer size */ -#define NOBUF 1024 /* MM says bug buffers win! */ -#define EFN 0 /* Event flag */ +#define NIBUF 128 /* Input buffer size */ +#define NOBUF 1024 /* MM says bug buffers win! */ +#define EFN 0 /* Event flag */ -char obuf[NOBUF]; /* Output buffer */ -int nobuf; /* # of bytes in above */ -char ibuf[NIBUF]; /* Input buffer */ -int nibuf; /* # of bytes in above */ -int ibufi; /* Read index */ -int oldmode[3]; /* Old TTY mode bits */ -int newmode[3]; /* New TTY mode bits */ -short iochan; /* TTY I/O channel */ +char obuf[NOBUF]; /* Output buffer */ +int nobuf; /* # of bytes in above */ +char ibuf[NIBUF]; /* Input buffer */ +int nibuf; /* # of bytes in above */ +int ibufi; /* Read index */ +int oldmode[3]; /* Old TTY mode bits */ +int newmode[3]; /* New TTY mode bits */ +short iochan; /* TTY I/O channel */ #endif #if MSDOS & (MSC | TURBO) -union REGS rg; /* cpu register for use of DOS calls */ -int nxtchar = -1; /* character held from type ahead */ +union REGS rg; /* cpu register for use of DOS calls */ +int nxtchar = -1; /* character held from type ahead */ #endif -#if USG /* System V */ -#include -#include -#include -int kbdflgs; /* saved keyboard fd flags */ -int kbdpoll; /* in O_NDELAY mode */ -int kbdqp; /* there is a char in kbdq */ -char kbdq; /* char we've already read */ -struct termio otermio; /* original terminal characteristics */ -struct termio ntermio; /* charactoristics to use inside */ -#if XONXOFF -#define XXMASK 0016000 +#if USG /* System V */ +#include +#include +#include +int kbdflgs; /* saved keyboard fd flags */ +int kbdpoll; /* in O_NDELAY mode */ +int kbdqp; /* there is a char in kbdq */ +char kbdq; /* char we've already read */ +struct termio otermio; /* original terminal characteristics */ +struct termio ntermio; /* charactoristics to use inside */ +#if XONXOFF +#define XXMASK 0016000 #endif #endif -#if V7 | BSD -#include /* for stty/gtty functions */ -#include -struct sgttyb ostate; /* saved tty state */ -struct sgttyb nstate; /* values for editor mode */ -struct tchars otchars; /* Saved terminal special character set */ -#if XONXOFF +#if V7 | BSD +#include /* for stty/gtty functions */ +#include +struct sgttyb ostate; /* saved tty state */ +struct sgttyb nstate; /* values for editor mode */ +struct tchars otchars; /* Saved terminal special character set */ +#if XONXOFF struct tchars ntchars = { 0xff, 0xff, 0x11, 0x13, 0xff, 0xff }; - /* A lot of nothing and XON/XOFF */ + /* A lot of nothing and XON/XOFF */ #else struct tchars ntchars = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; - /* A lot of nothing */ + /* A lot of nothing */ #endif -#if BSD & PKCODE -struct ltchars oltchars; /* Saved terminal local special character set */ +#if BSD & PKCODE +struct ltchars oltchars; /* Saved terminal local special character set */ struct ltchars nltchars = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; - /* A lot of nothing */ + /* A lot of nothing */ #endif #if BSD -#include /* to get at the typeahead */ -extern int rtfrmshell(); /* return from suspended shell */ -#define TBUFSIZ 128 -char tobuf[TBUFSIZ]; /* terminal output buffer */ +#include /* to get at the typeahead */ +extern int rtfrmshell(); /* return from suspended shell */ +#define TBUFSIZ 128 +char tobuf[TBUFSIZ]; /* terminal output buffer */ #endif #endif -#if __hpux | SVR4 -extern int rtfrmshell(); /* return from suspended shell */ +#if __hpux | SVR4 +extern int rtfrmshell(); /* return from suspended shell */ #define TBUFSIZ 128 -char tobuf[TBUFSIZ]; /* terminal output buffer */ +char tobuf[TBUFSIZ]; /* terminal output buffer */ #endif /* @@ -112,121 +112,121 @@ char tobuf[TBUFSIZ]; /* terminal output buffer */ void ttopen(void) { #if VMS - struct dsc$descriptor idsc; - struct dsc$descriptor odsc; - char oname[40]; - int iosb[2]; - int status; + struct dsc$descriptor idsc; + struct dsc$descriptor odsc; + char oname[40]; + int iosb[2]; + int status; - odsc.dsc$a_pointer = "TT"; - odsc.dsc$w_length = strlen(odsc.dsc$a_pointer); - odsc.dsc$b_dtype = DSC$K_DTYPE_T; - odsc.dsc$b_class = DSC$K_CLASS_S; - idsc.dsc$b_dtype = DSC$K_DTYPE_T; - idsc.dsc$b_class = DSC$K_CLASS_S; - do { - idsc.dsc$a_pointer = odsc.dsc$a_pointer; - idsc.dsc$w_length = odsc.dsc$w_length; - odsc.dsc$a_pointer = &oname[0]; - odsc.dsc$w_length = sizeof(oname); - status = LIB$SYS_TRNLOG(&idsc, &odsc.dsc$w_length, &odsc); - if (status != SS$_NORMAL && status != SS$_NOTRAN) - exit(status); - if (oname[0] == 0x1B) { - odsc.dsc$a_pointer += 4; - odsc.dsc$w_length -= 4; - } - } while (status == SS$_NORMAL); - status = SYS$ASSIGN(&odsc, &iochan, 0, 0); - if (status != SS$_NORMAL) - exit(status); - status = SYS$QIOW(EFN, iochan, IO$_SENSEMODE, iosb, 0, 0, - oldmode, sizeof(oldmode), 0, 0, 0, 0); - if (status != SS$_NORMAL || (iosb[0] & 0xFFFF) != SS$_NORMAL) - exit(status); - newmode[0] = oldmode[0]; - newmode[1] = oldmode[1] | TT$M_NOECHO; -#if XONXOFF + odsc.dsc$a_pointer = "TT"; + odsc.dsc$w_length = strlen(odsc.dsc$a_pointer); + odsc.dsc$b_dtype = DSC$K_DTYPE_T; + odsc.dsc$b_class = DSC$K_CLASS_S; + idsc.dsc$b_dtype = DSC$K_DTYPE_T; + idsc.dsc$b_class = DSC$K_CLASS_S; + do { + idsc.dsc$a_pointer = odsc.dsc$a_pointer; + idsc.dsc$w_length = odsc.dsc$w_length; + odsc.dsc$a_pointer = &oname[0]; + odsc.dsc$w_length = sizeof(oname); + status = LIB$SYS_TRNLOG(&idsc, &odsc.dsc$w_length, &odsc); + if (status != SS$_NORMAL && status != SS$_NOTRAN) + exit(status); + if (oname[0] == 0x1B) { + odsc.dsc$a_pointer += 4; + odsc.dsc$w_length -= 4; + } + } while (status == SS$_NORMAL); + status = SYS$ASSIGN(&odsc, &iochan, 0, 0); + if (status != SS$_NORMAL) + exit(status); + status = SYS$QIOW(EFN, iochan, IO$_SENSEMODE, iosb, 0, 0, + oldmode, sizeof(oldmode), 0, 0, 0, 0); + if (status != SS$_NORMAL || (iosb[0] & 0xFFFF) != SS$_NORMAL) + exit(status); + newmode[0] = oldmode[0]; + newmode[1] = oldmode[1] | TT$M_NOECHO; +#if XONXOFF #else - newmode[1] &= ~(TT$M_TTSYNC | TT$M_HOSTSYNC); + newmode[1] &= ~(TT$M_TTSYNC | TT$M_HOSTSYNC); #endif - newmode[2] = oldmode[2] | TT2$M_PASTHRU; - status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0, - newmode, sizeof(newmode), 0, 0, 0, 0); - if (status != SS$_NORMAL || (iosb[0] & 0xFFFF) != SS$_NORMAL) - exit(status); - term.t_nrow = (newmode[1] >> 24) - 1; - term.t_ncol = newmode[0] >> 16; + newmode[2] = oldmode[2] | TT2$M_PASTHRU; + status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0, + newmode, sizeof(newmode), 0, 0, 0, 0); + if (status != SS$_NORMAL || (iosb[0] & 0xFFFF) != SS$_NORMAL) + exit(status); + term.t_nrow = (newmode[1] >> 24) - 1; + term.t_ncol = newmode[0] >> 16; #endif #if MSDOS & (TURBO | (PKCODE & MSC)) - /* kill the CONTROL-break interupt */ - rg.h.ah = 0x33; /* control-break check dos call */ - rg.h.al = 1; /* set the current state */ - rg.h.dl = 0; /* set it OFF */ - intdos(&rg, &rg); /* go for it! */ + /* kill the CONTROL-break interupt */ + rg.h.ah = 0x33; /* control-break check dos call */ + rg.h.al = 1; /* set the current state */ + rg.h.dl = 0; /* set it OFF */ + intdos(&rg, &rg); /* go for it! */ #endif -#if USG - ioctl(0, TCGETA, &otermio); /* save old settings */ - ntermio.c_iflag = 0; /* setup new settings */ -#if XONXOFF - ntermio.c_iflag = otermio.c_iflag & XXMASK; /* save XON/XOFF P.K. */ +#if USG + ioctl(0, TCGETA, &otermio); /* save old settings */ + ntermio.c_iflag = 0; /* setup new settings */ +#if XONXOFF + ntermio.c_iflag = otermio.c_iflag & XXMASK; /* save XON/XOFF P.K. */ #endif - ntermio.c_oflag = 0; - ntermio.c_cflag = otermio.c_cflag; - ntermio.c_lflag = 0; - ntermio.c_line = otermio.c_line; - ntermio.c_cc[VMIN] = 1; - ntermio.c_cc[VTIME] = 0; -#if PKCODE - ioctl(0, TCSETAW, &ntermio); /* and activate them */ + ntermio.c_oflag = 0; + ntermio.c_cflag = otermio.c_cflag; + ntermio.c_lflag = 0; + ntermio.c_line = otermio.c_line; + ntermio.c_cc[VMIN] = 1; + ntermio.c_cc[VTIME] = 0; +#if PKCODE + ioctl(0, TCSETAW, &ntermio); /* and activate them */ #else - ioctl(0, TCSETA, &ntermio); /* and activate them */ + ioctl(0, TCSETA, &ntermio); /* and activate them */ #endif - kbdflgs = fcntl(0, F_GETFL, 0); - kbdpoll = FALSE; + kbdflgs = fcntl(0, F_GETFL, 0); + kbdpoll = FALSE; #endif #if V7 | BSD - gtty(0, &ostate); /* save old state */ - gtty(0, &nstate); /* get base of new state */ -#if XONXOFF - nstate.sg_flags |= (CBREAK | TANDEM); + gtty(0, &ostate); /* save old state */ + gtty(0, &nstate); /* get base of new state */ +#if XONXOFF + nstate.sg_flags |= (CBREAK | TANDEM); #else - nstate.sg_flags |= RAW; + nstate.sg_flags |= RAW; #endif - nstate.sg_flags &= ~(ECHO | CRMOD); /* no echo for now... */ - stty(0, &nstate); /* set mode */ - ioctl(0, TIOCGETC, &otchars); /* Save old characters */ - ioctl(0, TIOCSETC, &ntchars); /* Place new character into K */ -#if BSD & PKCODE - ioctl(0, TIOCGLTC, &oltchars); /* Save old local characters */ - ioctl(0, TIOCSLTC, &nltchars); /* New local characters */ + nstate.sg_flags &= ~(ECHO | CRMOD); /* no echo for now... */ + stty(0, &nstate); /* set mode */ + ioctl(0, TIOCGETC, &otchars); /* Save old characters */ + ioctl(0, TIOCSETC, &ntchars); /* Place new character into K */ +#if BSD & PKCODE + ioctl(0, TIOCGLTC, &oltchars); /* Save old local characters */ + ioctl(0, TIOCSLTC, &nltchars); /* New local characters */ #endif -#if BSD - /* provide a smaller terminal output buffer so that - the type ahead detection works better (more often) */ - setbuffer(stdout, &tobuf[0], TBUFSIZ); - signal(SIGTSTP, SIG_DFL); /* set signals so that we can */ - signal(SIGCONT, rtfrmshell); /* suspend & restart emacs */ +#if BSD + /* provide a smaller terminal output buffer so that + the type ahead detection works better (more often) */ + setbuffer(stdout, &tobuf[0], TBUFSIZ); + signal(SIGTSTP, SIG_DFL); /* set signals so that we can */ + signal(SIGCONT, rtfrmshell); /* suspend & restart emacs */ #endif #endif -#if __hpux | SVR4 - /* provide a smaller terminal output buffer so that - the type ahead detection works better (more often) */ - setvbuf(stdout, &tobuf[0], _IOFBF, TBUFSIZ); - signal(SIGTSTP, SIG_DFL); /* set signals so that we can */ - signal(SIGCONT, rtfrmshell); /* suspend & restart emacs */ - TTflush(); -#endif /* __hpux */ +#if __hpux | SVR4 + /* provide a smaller terminal output buffer so that + the type ahead detection works better (more often) */ + setvbuf(stdout, &tobuf[0], _IOFBF, TBUFSIZ); + signal(SIGTSTP, SIG_DFL); /* set signals so that we can */ + signal(SIGCONT, rtfrmshell); /* suspend & restart emacs */ + TTflush(); +#endif /* __hpux */ - /* on all screens we are not sure of the initial position - of the cursor */ - ttrow = 999; - ttcol = 999; + /* on all screens we are not sure of the initial position + of the cursor */ + ttrow = 999; + ttcol = 999; } /* @@ -237,40 +237,40 @@ void ttopen(void) void ttclose(void) { #if VMS - int status; - int iosb[1]; + int status; + int iosb[1]; - ttflush(); - status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0, - oldmode, sizeof(oldmode), 0, 0, 0, 0); - if (status != SS$_NORMAL || (iosb[0] & 0xFFFF) != SS$_NORMAL) - exit(status); - status = SYS$DASSGN(iochan); - if (status != SS$_NORMAL) - exit(status); + ttflush(); + status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0, + oldmode, sizeof(oldmode), 0, 0, 0, 0); + if (status != SS$_NORMAL || (iosb[0] & 0xFFFF) != SS$_NORMAL) + exit(status); + status = SYS$DASSGN(iochan); + if (status != SS$_NORMAL) + exit(status); #endif #if MSDOS & (TURBO | (PKCODE & MSC)) - /* restore the CONTROL-break interupt */ - rg.h.ah = 0x33; /* control-break check dos call */ - rg.h.al = 1; /* set the current state */ - rg.h.dl = 1; /* set it ON */ - intdos(&rg, &rg); /* go for it! */ + /* restore the CONTROL-break interupt */ + rg.h.ah = 0x33; /* control-break check dos call */ + rg.h.al = 1; /* set the current state */ + rg.h.dl = 1; /* set it ON */ + intdos(&rg, &rg); /* go for it! */ #endif -#if USG -#if PKCODE - ioctl(0, TCSETAW, &otermio); /* restore terminal settings */ +#if USG +#if PKCODE + ioctl(0, TCSETAW, &otermio); /* restore terminal settings */ #else - ioctl(0, TCSETA, &otermio); /* restore terminal settings */ + ioctl(0, TCSETA, &otermio); /* restore terminal settings */ #endif - fcntl(0, F_SETFL, kbdflgs); + fcntl(0, F_SETFL, kbdflgs); #endif #if V7 | BSD - stty(0, &ostate); - ioctl(0, TIOCSETC, &otchars); /* Place old character into K */ -#if BSD & PKCODE - ioctl(0, TIOCSLTC, &oltchars); /* Place old local character into K */ + stty(0, &ostate); + ioctl(0, TIOCSETC, &otchars); /* Place old character into K */ +#if BSD & PKCODE + ioctl(0, TIOCSLTC, &oltchars); /* Place old local character into K */ #endif #endif } @@ -283,23 +283,23 @@ void ttclose(void) */ int ttputc( int c) { #if VMS - if (nobuf >= NOBUF) - ttflush(); - obuf[nobuf++] = c; + if (nobuf >= NOBUF) + ttflush(); + obuf[nobuf++] = c; #endif -#if MSDOS & ~IBMPC - bdos(6, c, 0); +#if MSDOS & ~IBMPC + bdos(6, c, 0); #endif #if V7 | USG | BSD - char utf8[6]; - int bytes; + char utf8[6]; + int bytes; - bytes = unicode_to_utf8(c, utf8); - fwrite(utf8, 1, bytes, stdout); + bytes = unicode_to_utf8(c, utf8); + fwrite(utf8, 1, bytes, stdout); #endif - return 0 ; + return 0 ; } /* @@ -308,19 +308,19 @@ int ttputc( int c) { */ void ttflush( void) { #if VMS - int status; - int iosb[2]; + int status; + int iosb[2]; - status = SS$_NORMAL; - if (nobuf != 0) { - status = - SYS$QIOW(EFN, iochan, IO$_WRITELBLK | IO$M_NOFORMAT, - iosb, 0, 0, obuf, nobuf, 0, 0, 0, 0); - if (status == SS$_NORMAL) - status = iosb[0] & 0xFFFF; - nobuf = 0; - } - return status; + status = SS$_NORMAL; + if (nobuf != 0) { + status = + SYS$QIOW(EFN, iochan, IO$_WRITELBLK | IO$M_NOFORMAT, + iosb, 0, 0, obuf, nobuf, 0, 0, 0, 0); + if (status == SS$_NORMAL) + status = iosb[0] & 0xFFFF; + nobuf = 0; + } + return status; #endif #if MSDOS @@ -339,13 +339,13 @@ void ttflush( void) { #include - int status; + int status; - status = fflush(stdout); + status = fflush(stdout); - if (status != 0 && errno != EAGAIN) { - exit(errno); - } + if (status != 0 && errno != EAGAIN) { + exit(errno); + } #endif } @@ -356,111 +356,111 @@ void ttflush( void) { */ int ttgetc( void) { #if VMS - int status; - int iosb[2]; - int term[2]; + int status; + int iosb[2]; + int term[2]; - while (ibufi >= nibuf) { - ibufi = 0; - term[0] = 0; - term[1] = 0; - status = SYS$QIOW(EFN, iochan, IO$_READLBLK | IO$M_TIMED, - iosb, 0, 0, ibuf, NIBUF, 0, term, 0, 0); - if (status != SS$_NORMAL) - exit(status); - status = iosb[0] & 0xFFFF; - if (status != SS$_NORMAL && status != SS$_TIMEOUT && - status != SS$_DATAOVERUN) - exit(status); - nibuf = (iosb[0] >> 16) + (iosb[1] >> 16); - if (nibuf == 0) { - status = SYS$QIOW(EFN, iochan, IO$_READLBLK, - iosb, 0, 0, ibuf, 1, 0, term, 0, - 0); - if (status != SS$_NORMAL - || (status = (iosb[0] & 0xFFFF)) != SS$_NORMAL) - if (status != SS$_DATAOVERUN) - exit(status); - nibuf = (iosb[0] >> 16) + (iosb[1] >> 16); - } - } - return ibuf[ibufi++] & 0xFF; /* Allow multinational */ + while (ibufi >= nibuf) { + ibufi = 0; + term[0] = 0; + term[1] = 0; + status = SYS$QIOW(EFN, iochan, IO$_READLBLK | IO$M_TIMED, + iosb, 0, 0, ibuf, NIBUF, 0, term, 0, 0); + if (status != SS$_NORMAL) + exit(status); + status = iosb[0] & 0xFFFF; + if (status != SS$_NORMAL && status != SS$_TIMEOUT && + status != SS$_DATAOVERUN) + exit(status); + nibuf = (iosb[0] >> 16) + (iosb[1] >> 16); + if (nibuf == 0) { + status = SYS$QIOW(EFN, iochan, IO$_READLBLK, + iosb, 0, 0, ibuf, 1, 0, term, 0, + 0); + if (status != SS$_NORMAL + || (status = (iosb[0] & 0xFFFF)) != SS$_NORMAL) + if (status != SS$_DATAOVERUN) + exit(status); + nibuf = (iosb[0] >> 16) + (iosb[1] >> 16); + } + } + return ibuf[ibufi++] & 0xFF; /* Allow multinational */ #endif -#if MSDOS & (MSC | TURBO) - int c; /* character read */ +#if MSDOS & (MSC | TURBO) + int c; /* character read */ - /* if a char already is ready, return it */ - if (nxtchar >= 0) { - c = nxtchar; - nxtchar = -1; - return c; - } + /* if a char already is ready, return it */ + if (nxtchar >= 0) { + c = nxtchar; + nxtchar = -1; + return c; + } - /* call the dos to get a char */ - rg.h.ah = 7; /* dos Direct Console Input call */ - intdos(&rg, &rg); - c = rg.h.al; /* grab the char */ - return c & 255; + /* call the dos to get a char */ + rg.h.ah = 7; /* dos Direct Console Input call */ + intdos(&rg, &rg); + c = rg.h.al; /* grab the char */ + return c & 255; #endif #if V7 | BSD - return 255 & fgetc(stdin); /* 8BIT P.K. */ + return 255 & fgetc(stdin); /* 8BIT P.K. */ #endif -#if USG - if (kbdqp) - kbdqp = FALSE; - else { - if (kbdpoll && fcntl(0, F_SETFL, kbdflgs) < 0) - return FALSE; - kbdpoll = FALSE; - while (read(0, &kbdq, 1) != 1); - } - return kbdq & 255; +#if USG + if (kbdqp) + kbdqp = FALSE; + else { + if (kbdpoll && fcntl(0, F_SETFL, kbdflgs) < 0) + return FALSE; + kbdpoll = FALSE; + while (read(0, &kbdq, 1) != 1); + } + return kbdq & 255; #endif } -#if TYPEAH -/* typahead: Check to see if any characters are already in the - keyboard buffer +#if TYPEAH +/* typahead: Check to see if any characters are already in the + keyboard buffer */ int typahead( void) { -#if MSDOS & (MSC | TURBO) - if (kbhit() != 0) - return TRUE; - else - return FALSE; +#if MSDOS & (MSC | TURBO) + if (kbhit() != 0) + return TRUE; + else + return FALSE; #endif -#if BSD - int x; /* holds # of pending chars */ +#if BSD + int x; /* holds # of pending chars */ - return (ioctl(0, FIONREAD, &x) < 0) ? 0 : x; + return (ioctl(0, FIONREAD, &x) < 0) ? 0 : x; #endif -#if PKCODE & VMS - return ibufi < nibuf; +#if PKCODE & VMS + return ibufi < nibuf; #endif -#if USG - if (!kbdqp) { - if (!kbdpoll && fcntl(0, F_SETFL, kbdflgs | O_NDELAY) < 0) - return FALSE; -#if PKCODE - kbdpoll = 1; +#if USG + if (!kbdqp) { + if (!kbdpoll && fcntl(0, F_SETFL, kbdflgs | O_NDELAY) < 0) + return FALSE; +#if PKCODE + kbdpoll = 1; #endif - kbdqp = (1 == read(0, &kbdq, 1)); - } - return kbdqp; + kbdqp = (1 == read(0, &kbdq, 1)); + } + return kbdqp; #endif #if !UNIX & !VMS & !MSDOS - return FALSE; + return FALSE; #endif } #endif -#endif /* not POSIX */ +#endif /* not POSIX */ diff --git a/wrapper.c b/wrapper.c index c838a49..43a63a2 100644 --- a/wrapper.c +++ b/wrapper.c @@ -6,6 +6,12 @@ #include #include +#ifdef MINGW32 +int mkstemp( char *template) { + return -1 ; +} +#endif + static void die( const char *err) { fprintf( stderr, "fatal: %s\n", err) ; exit( EXIT_FAILURE) ; From 1911a389b4b8aeb9f42313033c0e2a45a9bcd890 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sat, 15 Nov 2014 11:12:59 +0800 Subject: [PATCH 188/193] Regenerate Makefile with Cygwin64 (make source ; make depend) as mingw32 and wscreen not commited. --- Makefile | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 599ce46..90bc9cd 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ -# Makefile for emacs, updated Wed, Jun 18, 2014 2:24:32 PM +# Makefile for emacs, updated Sat, Nov 15, 2014 11:09:11 AM -SRC=ansi.c basic.c bind.c bindable.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c ibmpc.c input.c isearch.c line.c lock.c log.c main.c mingw32.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c wscreen.c -OBJ=ansi.o basic.o bind.o bindable.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o ibmpc.o input.o isearch.o line.o lock.o log.o main.o mingw32.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o wscreen.o -HDR=basic.h bind.h bindable.h buffer.h crypt.h defines.h display.h ebind.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h log.h names.h pklock.h random.h region.h retcode.h search.h spawn.h terminal.h termio.h utf8.h version.h window.h word.h wrapper.h wscreen.h +SRC=ansi.c basic.c bind.c bindable.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c ibmpc.c input.c isearch.c line.c lock.c log.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c +OBJ=ansi.o basic.o bind.o bindable.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o ibmpc.o input.o isearch.o line.o lock.o log.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o +HDR=basic.h bind.h bindable.h buffer.h crypt.h defines.h display.h ebind.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h log.h names.h pklock.h random.h region.h retcode.h search.h spawn.h terminal.h termio.h utf8.h version.h window.h word.h wrapper.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -176,7 +176,6 @@ log.o: log.c log.h retcode.h main.o: main.c estruct.h basic.h bind.h bindable.h buffer.h crypt.h \ line.h utf8.h display.h eval.h execute.h file.h retcode.h input.h lock.h \ log.h random.h search.h terminal.h defines.h termio.h version.h window.h -mingw32.o: mingw32.c names.o: names.c names.h basic.h bind.h bindable.h buffer.h crypt.h \ line.h utf8.h display.h eval.h exec.h retcode.h file.h isearch.h \ region.h random.h search.h spawn.h window.h defines.h word.h @@ -204,7 +203,6 @@ window.o: window.c window.h defines.h buffer.h crypt.h line.h utf8.h \ word.o: word.c word.h basic.h buffer.h crypt.h line.h utf8.h estruct.h \ log.h retcode.h random.h region.h window.h defines.h wrapper.o: wrapper.c wrapper.h -wscreen.o: wscreen.c wscreen.h # DEPENDENCIES MUST END AT END OF FILE # IF YOU PUT STUFF HERE IT WILL GO AWAY From cc4841b2e1dfc0e79fab94e618dce491fd53cd8b Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Mon, 17 Nov 2014 13:09:13 +0800 Subject: [PATCH 189/193] Add mingw32 and wscreen for initial MingGW32 support. --- Makefile | 10 +-- mingw32.c | 191 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ wscreen.c | 117 +++++++++++++++++++++++++++++++++ wscreen.h | 14 ++++ 4 files changed, 328 insertions(+), 4 deletions(-) create mode 100644 mingw32.c create mode 100644 wscreen.c create mode 100644 wscreen.h diff --git a/Makefile b/Makefile index 90bc9cd..e2a8caa 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ -# Makefile for emacs, updated Sat, Nov 15, 2014 11:09:11 AM +# Makefile for emacs, updated Mon, Nov 17, 2014 1:05:02 PM -SRC=ansi.c basic.c bind.c bindable.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c ibmpc.c input.c isearch.c line.c lock.c log.c main.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c -OBJ=ansi.o basic.o bind.o bindable.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o ibmpc.o input.o isearch.o line.o lock.o log.o main.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o -HDR=basic.h bind.h bindable.h buffer.h crypt.h defines.h display.h ebind.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h log.h names.h pklock.h random.h region.h retcode.h search.h spawn.h terminal.h termio.h utf8.h version.h window.h word.h wrapper.h +SRC=ansi.c basic.c bind.c bindable.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c ibmpc.c input.c isearch.c line.c lock.c log.c main.c mingw32.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c wscreen.c +OBJ=ansi.o basic.o bind.o bindable.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o ibmpc.o input.o isearch.o line.o lock.o log.o main.o mingw32.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o wscreen.o +HDR=basic.h bind.h bindable.h buffer.h crypt.h defines.h display.h ebind.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h log.h names.h pklock.h random.h region.h retcode.h search.h spawn.h terminal.h termio.h utf8.h version.h window.h word.h wrapper.h wscreen.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -176,6 +176,7 @@ log.o: log.c log.h retcode.h main.o: main.c estruct.h basic.h bind.h bindable.h buffer.h crypt.h \ line.h utf8.h display.h eval.h execute.h file.h retcode.h input.h lock.h \ log.h random.h search.h terminal.h defines.h termio.h version.h window.h +mingw32.o: mingw32.c names.o: names.c names.h basic.h bind.h bindable.h buffer.h crypt.h \ line.h utf8.h display.h eval.h exec.h retcode.h file.h isearch.h \ region.h random.h search.h spawn.h window.h defines.h word.h @@ -203,6 +204,7 @@ window.o: window.c window.h defines.h buffer.h crypt.h line.h utf8.h \ word.o: word.c word.h basic.h buffer.h crypt.h line.h utf8.h estruct.h \ log.h retcode.h random.h region.h window.h defines.h wrapper.o: wrapper.c wrapper.h +wscreen.o: wscreen.c wscreen.h # DEPENDENCIES MUST END AT END OF FILE # IF YOU PUT STUFF HERE IT WILL GO AWAY diff --git a/mingw32.c b/mingw32.c new file mode 100644 index 0000000..029f67e --- /dev/null +++ b/mingw32.c @@ -0,0 +1,191 @@ +#ifdef MINGW32 +#include "termio.h" +#include "terminal.h" + +#include +#include +#include +#include +#include + +#include "utf8.h" +#include "wscreen.h" + +static void vv( void) {} +static void vi( int i) {} +static int is( char *s) { return *s ; } + +static void ttmove( int l, int c) ; + +#define MARGIN 8 +#define SCRSIZ 64 +#define NPAUSE 10 /* # times thru update to pause. */ + +struct terminal term = { + 24, /* These four values are set dynamically at open time. */ + 24, + 80, + 80, + MARGIN, + SCRSIZ, + NPAUSE, + ttopen, +#if PKCODE + ttclose, +#else + ttclose, +#endif + vv, /* ttkopen, */ + vv, /* ttkclose, */ + ttgetc, + ttputc, + ttflush, + ttmove, + vv, /* tteeol, */ + vv, /* tteeop, */ + vv, /* ttbeep, */ + vi, /* ttrev, */ + is /* ttcres */ +#if COLOR + , iv, /* ttfcol, */ + iv /* ttbcol */ +#endif +#if SCROLLCODE + , NULL /* set dynamically at open time */ +#endif +} ; + + +int ttrow ; /* Row location of HW cursor */ +int ttcol ; /* Column location of HW cursor */ + +boolean eolexist = TRUE ; /* does clear to EOL exist? */ +boolean revexist = FALSE ; /* does reverse video exist? */ +boolean sgarbf = TRUE ; /* State of screen unknown */ + +char sres[ 16] ; /* Current screen resolution. */ + /* NORMAL, CGA, EGA, VGA */ + +void ttopen( void) { + winit() ; + wcls() ; + term.t_mrow = term.t_nrow = wbottom() - wtop() ; + term.t_mcol = term.t_ncol = wright() - wleft() + 1 ; + wtitle( "uEMACS") ; +} + +void ttclose( void) { +} + +int ttputc( int c) { + char utf8[ 6] ; + int bytes ; + + bytes = unicode_to_utf8( c, utf8) ; + fwrite( utf8, 1, bytes, stdout); + return 0 ; +} + +void ttflush( void) { + int status ; + + status = fflush( stdout); + while( status < 0 && errno == EAGAIN) { + _sleep( 1) ; + status = fflush( stdout) ; + } + + if( status < 0) + exit( 15) ; +} + +int ttgetc( void) { + static char buffer[ 32] ; + static int pending ; + unicode_t c ; + int count, bytes = 1, expected ; + + count = pending ; + if( !count) { + count = read( 0, buffer, sizeof( buffer)) ; + if( count <= 0) + return 0 ; + + pending = count ; + } + + c = (unsigned char) buffer[ 0] ; + if( c >= 32 && c < 128) + goto done ; + + /* + * Lazy. We don't bother calculating the exact + * expected length. We want at least two characters + * for the special character case (ESC+[) and for + * the normal short UTF8 sequence that starts with + * the 110xxxxx pattern. + * + * But if we have any of the other patterns, just + * try to get more characters. At worst, that will + * just result in a barely perceptible 0.1 second + * delay for some *very* unusual utf8 character + * input. + */ + expected = 2 ; + if( (c & 0xe0) == 0xe0) + expected = 6 ; + + /* Special character - try to fill buffer */ + if( count < expected) { + int n; +#if 0 + ntermios.c_cc[VMIN] = 0; + ntermios.c_cc[VTIME] = 1; /* A .1 second lag */ + tcsetattr(0, TCSANOW, &ntermios); +#endif + n = read(0, buffer + count, sizeof(buffer) - count); + + /* Undo timeout */ +#if 0 + ntermios.c_cc[VMIN] = 1; + ntermios.c_cc[VTIME] = 0; + tcsetattr(0, TCSANOW, &ntermios); +#endif + if (n > 0) + pending += n; + } + + if( pending > 1) { + unsigned char second = buffer[1]; + + /* Turn ESC+'[' into CSI */ + if (c == 27 && second == '[') { + bytes = 2; + c = 128+27; + goto done; + } + } + + bytes = utf8_to_unicode( buffer, 0, pending, &c) ; + +done: + pending -= bytes ; + memmove( buffer, buffer+bytes, pending) ; + return c ; +} + +int typahead( void) { + int x ; /* holds # of pending chars */ + +#ifdef FIONREAD + if( ioctl( 0, FIONREAD, &x) < 0) +#endif + x = 0 ; + return x ; +} + +static void ttmove( int l, int c) { + wgoxy( c, l) ; +} + +#endif diff --git a/wscreen.c b/wscreen.c new file mode 100644 index 0000000..45460d1 --- /dev/null +++ b/wscreen.c @@ -0,0 +1,117 @@ +/* wscreen.c -- windows screen console */ +#include "wscreen.h" + +#ifdef MINGW32 + +#include +#include +#include + +/* Standard error macro for reporting API errors */ +#define PERR(bSuccess, api){if(!(bSuccess)) printf("%s:Error %d from %s \ + on line %d\n", __FILE__, GetLastError(), api, __LINE__);} + +static void cls( HANDLE hConsole ) +{ + COORD coordScreen = { 0, 0 }; /* here's where we'll home the + cursor */ + BOOL bSuccess; + DWORD cCharsWritten; + CONSOLE_SCREEN_BUFFER_INFO csbi; /* to get buffer info */ + DWORD dwConSize; /* number of character cells in + the current buffer */ + + /* get the number of character cells in the current buffer */ + + bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi ); + PERR( bSuccess, "GetConsoleScreenBufferInfo" ); + dwConSize = csbi.dwSize.X * csbi.dwSize.Y; + + /* fill the entire screen with blanks */ + + bSuccess = FillConsoleOutputCharacter( hConsole, (TCHAR) ' ', + dwConSize, coordScreen, &cCharsWritten ); + PERR( bSuccess, "FillConsoleOutputCharacter" ); + + /* get the current text attribute */ + + bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi ); + PERR( bSuccess, "ConsoleScreenBufferInfo" ); + + /* now set the buffer's attributes accordingly */ + + bSuccess = FillConsoleOutputAttribute( hConsole, csbi.wAttributes, + dwConSize, coordScreen, &cCharsWritten ); + PERR( bSuccess, "FillConsoleOutputAttribute" ); + + /* put the cursor at (0, 0) */ + + bSuccess = SetConsoleCursorPosition( hConsole, coordScreen ); + PERR( bSuccess, "SetConsoleCursorPosition" ); + return; +} + +void wcls( void) { + cls( GetStdHandle( STD_OUTPUT_HANDLE)) ; +} + +static struct { + int width ; + int height ; + int curTop, curBot, curRight, curLeft ; +} Screen ; + +void winit( void) { + CONSOLE_SCREEN_BUFFER_INFO csbInfo ; + + wcls() ; + if( GetConsoleScreenBufferInfo( + GetStdHandle( STD_OUTPUT_HANDLE), &csbInfo)) { + Screen.width = csbInfo.dwSize.X ; + Screen.height = csbInfo.dwSize.Y ; + Screen.curLeft = csbInfo.srWindow.Left ; + Screen.curTop = csbInfo.srWindow.Top ; + Screen.curRight = csbInfo.srWindow.Right ; + Screen.curBot = csbInfo.srWindow.Bottom ; + } +} + +int wwidth( void) { + return Screen.width ; +} + +int wheight( void) { + return Screen.height ; +} + +int wleft( void) { + return Screen.curLeft ; +} + +int wtop( void) { + return Screen.curTop ; +} + +int wright( void) { + return Screen.curRight ; +} + +int wbottom( void) { + return Screen.curBot ; +} + +void wgoxy( int x, int y) { + COORD coord ; + + coord.X = x ; + coord.Y = y ; + SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE), coord ); +} + +void wtitle( const char *title) { + SetConsoleTitle( title) ; +} + +#endif + +/* end of wscreen.c */ diff --git a/wscreen.h b/wscreen.h new file mode 100644 index 0000000..65080f4 --- /dev/null +++ b/wscreen.h @@ -0,0 +1,14 @@ +/* wscreen.h -- character screen drawing */ + +void winit( void) ; +void wcls( void) ; +void wgoxy( int x, int y) ; +void wtitle( const char *title) ; +int wwidth( void) ; +int wheight( void) ; +int wleft( void) ; +int wright( void) ; +int wtop( void) ; +int wbottom( void) ; + +/* end of wscreen.h */ From 4c8493a888948cc88e58deec74b644bea4f3146f Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sat, 20 Dec 2014 16:58:06 +0800 Subject: [PATCH 190/193] Create empty readme.md for documenting changes. --- readme.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 readme.md diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..e69de29 From b5405fa6b86ce2020ce8cd56564fdc3c9985efe8 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Mon, 22 Dec 2014 21:24:47 +0800 Subject: [PATCH 191/193] curses.h now comes in standard include directory on Cygwin. --- tcap.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tcap.c b/tcap.c index 5b045fa..911d866 100644 --- a/tcap.c +++ b/tcap.c @@ -20,14 +20,9 @@ #define termdef 1 /* Don't define "term" external. */ #ifndef MINGW32 -#ifdef CYGWIN -#include -#include -#else #include #include #endif -#endif #include "display.h" #include "estruct.h" From 5b5325dbe7a7680d49fc8e38a6e727fbf9a865e5 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 23 Dec 2014 07:32:57 +0800 Subject: [PATCH 192/193] Revert "Create empty readme.md for documenting changes." This reverts commit 4c8493a888948cc88e58deec74b644bea4f3146f. --- readme.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 readme.md diff --git a/readme.md b/readme.md deleted file mode 100644 index e69de29..0000000 From ce0f6b9678890cb5a47e2d74d0073685e3e7c73f Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sat, 20 Dec 2014 09:07:05 +0000 Subject: [PATCH 193/193] README.md edited online with Bitbucket --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..a923e7f --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +# README # + +Cigue is ue on Cygwin, based on uEmacs/PK from kernel.org. + +### What is this repository for? ### + +* Quick summary +* Version +* [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo) + +### How do I get set up? ### + +* Summary of set up +* Configuration +* Dependencies +* Database configuration +* How to run tests +* Deployment instructions + +### Contribution guidelines ### + +* Writing tests +* Code review +* Other guidelines + +### Who do I talk to? ### + +* Repo owner or admin +* Other community or team contact \ No newline at end of file