From 45ea35f2a73d40a1080ce7a1464bc4cd443c427d Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 18 Sep 2013 14:25:39 +0800 Subject: [PATCH] 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; }