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 */