diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/HTAlert.c | 6 | ||||
-rw-r--r-- | src/LYClean.c | 12 | ||||
-rw-r--r-- | src/LYCurses.c | 3 | ||||
-rw-r--r-- | src/LYMain.c | 30 | ||||
-rw-r--r-- | src/LYStrings.c | 13 | ||||
-rw-r--r-- | src/LYStrings.h | 2 | ||||
-rw-r--r-- | src/LYUtils.c | 3 |
7 files changed, 55 insertions, 14 deletions
diff --git a/src/HTAlert.c b/src/HTAlert.c index 28ea7867..132a34a7 100644 --- a/src/HTAlert.c +++ b/src/HTAlert.c @@ -180,7 +180,7 @@ PUBLIC void HTReadProgress ARGS2( static double first, last, last_active; #else #if defined(HAVE_FTIME) && defined(HAVE_SYS_TIMEB_H) - static double now, first, last; + static double now, first, last, last_active; struct timeb tb; ftime(&tb); @@ -202,7 +202,7 @@ PUBLIC void HTReadProgress ARGS2( (now != first)) /* 1 sec delay for transfer_rate calculation without g-t-o-d */ { if (transfer_rate <= 0) /* the very first time */ - transfer_rate = (bytes) / (now - first); /* bytes/sec */ + transfer_rate = (long)((bytes) / (now - first)); /* bytes/sec */ total_last = total; /* @@ -225,7 +225,7 @@ PUBLIC void HTReadProgress ARGS2( if (bytes_last != bytes) last_active = now; bytes_last = bytes; - transfer_rate = bytes / (now - first); /* more accurate here */ + transfer_rate = (long)(bytes / (now - first)); /* more accurate here */ } if (total > 0) diff --git a/src/LYClean.c b/src/LYClean.c index 216b1618..89270923 100644 --- a/src/LYClean.c +++ b/src/LYClean.c @@ -26,12 +26,12 @@ PUBLIC void cleanup_sig ARGS1( #ifdef IGNORE_CTRL_C if (sig == SIGINT) { - /* - * Need to rearm the signal. - */ - signal(SIGINT, cleanup_sig); - sigint = TRUE; - return; + /* + * Need to rearm the signal. + */ + signal(SIGINT, cleanup_sig); + sigint = TRUE; + return; } #endif /* IGNORE_CTRL_C */ diff --git a/src/LYCurses.c b/src/LYCurses.c index de225c6f..7cddbc34 100644 --- a/src/LYCurses.c +++ b/src/LYCurses.c @@ -1258,6 +1258,9 @@ PUBLIC BOOLEAN setup ARGS1( } #endif /* HAVE_TTYTYPE */ + LYlines = LINES; + LYcols = COLS; + #if defined(PDCURSES_EXP) && defined(WIN_EX) && defined(CJK_EX) /* 1999/08/26 (Thu) 17:53:38 */ { extern int current_codepage; /* PDCurses lib. */ diff --git a/src/LYMain.c b/src/LYMain.c index a06c4bf3..11b2b916 100644 --- a/src/LYMain.c +++ b/src/LYMain.c @@ -810,6 +810,19 @@ PRIVATE BOOL GetStdin ARGS1( return FALSE; } +#ifdef WIN32 +PRIVATE BOOL cleanup_win32(DWORD fdwCtrlType) +{ + switch (fdwCtrlType) { + case CTRL_CLOSE_EVENT: + cleanup_sig(-1); + return TRUE; + default: + return FALSE; + } +} +#endif + /* * Wow! Someone wants to start up Lynx. */ @@ -1450,17 +1463,21 @@ PUBLIC int main ARGS2( } #undef TTY_DEVICE +#undef NUL_DEVICE #ifdef VMS #define TTY_DEVICE "tt:" +#define NUL_DEVICE "nl:" #endif #ifdef _WINDOWS #define TTY_DEVICE "con" +#define NUL_DEVICE "nul" #endif #ifndef TTY_DEVICE #define TTY_DEVICE "/dev/tty" +#define NUL_DEVICE "/dev/null" #endif #if defined (TTY_DEVICE) || defined(HAVE_TTYNAME) @@ -1476,9 +1493,9 @@ PUBLIC int main ARGS2( tty = ttyname(fileno(stderr)); # endif if (tty == NULL) - tty = TTY_DEVICE; + tty = isatty(fileno(stdin)) ? TTY_DEVICE : NUL_DEVICE; - CTRACE((tfp, "processing stdin startfile\n")); + CTRACE((tfp, "processing stdin startfile, tty=%s\n", tty)); if ((fp = LYOpenTemp (result, HTML_SUFFIX, "w")) != 0) { StrAllocCopy(startfile, result); while (GetStdin(&buf)) { @@ -1489,8 +1506,7 @@ PUBLIC int main ARGS2( LYCloseTempFP(fp); } CTRACE((tfp, "...done stdin startfile\n")); - if ((freopen(tty, "r", stdin)) == 0 - || !isatty(fileno(stdin))) { + if ((freopen(tty, "r", stdin)) == 0) { CTRACE((tfp, "cannot open a terminal (%s)\n", tty)); if (!dump_output_immediately) { fprintf(stderr, "cannot open a terminal (%s)\n", tty); @@ -1740,13 +1756,17 @@ PUBLIC int main ARGS2( #endif /* __DJGPP__ */ /* trap interrupts */ +#ifdef WIN32 + SetConsoleCtrlHandler((PHANDLER_ROUTINE) cleanup_win32, TRUE); +#endif if (!dump_output_immediately) #ifndef NOSIGHUP (void) signal(SIGHUP, cleanup_sig); #endif /* NOSIGHUP */ + (void) signal(SIGTERM, cleanup_sig); #ifdef SIGWINCH - LYExtSignal(SIGWINCH, size_change); + LYExtSignal(SIGWINCH, size_change); #endif /* SIGWINCH */ #ifndef VMS if (!TRACE && !dump_output_immediately && !stack_dump) { diff --git a/src/LYStrings.c b/src/LYStrings.c index 51625738..b6e1e387 100644 --- a/src/LYStrings.c +++ b/src/LYStrings.c @@ -4483,6 +4483,7 @@ PUBLIC int LYgetstr ARGS4( LYSetupEdit(&MyEdit, inputline, MaxStringSize, (LYcols-1)-x); MyEdit.hidden = hidden ; + CTRACE((tfp, "called LYgetstr\n")); for (;;) { again: #ifndef SUPPORT_MULTIBYTE_EDIT @@ -4522,6 +4523,7 @@ again: if (recall != NORECALL && (ch == UPARROW || ch == DNARROW)) { LYstrncpy(inputline, MyEdit.buffer, (int)bufsize); LYAddToCloset(MyEdit.buffer); + CTRACE((tfp, "LYgetstr(%s) recall\n", inputline)); return(ch); } ch |= CurModif; @@ -4626,6 +4628,7 @@ again: LYstrncpy(inputline, MyEdit.buffer, (int)bufsize); if (!hidden) LYAddToCloset(MyEdit.buffer); + CTRACE((tfp, "LYgetstr(%s) LYE_ENTER\n", inputline)); return(ch); #if defined(WIN_EX) @@ -4659,6 +4662,7 @@ again: * Control-C or Control-G aborts. */ inputline[0] = '\0'; + CTRACE((tfp, "LYgetstr LYE_ABORT\n")); return(-1); case LYE_LKCMD: @@ -5533,10 +5537,18 @@ PUBLIC void LYOpenCmdLogfile ARGS2( } } +PUBLIC BOOL LYHaveCmdScript NOARGS +{ + return cmd_script != 0; +} + PUBLIC void LYOpenCmdScript NOARGS { if (lynx_cmd_script != 0) { cmd_script = fopen(lynx_cmd_script, "r"); + CTRACE((tfp, "LYOpenCmdScript(%s) %s\n", + lynx_cmd_script, + cmd_script != 0 ? "SUCCESS" : "FAIL")); } } @@ -5567,6 +5579,7 @@ PUBLIC int LYReadCmdKey ARGS1( } else { ch = LYgetch_for(mode); } + CTRACE((tfp, "LYReadCmdKey(%d) ->%c (%#x)\n", mode, ch, ch)); LYWriteCmdKey(ch); return ch; } diff --git a/src/LYStrings.h b/src/LYStrings.h index 5df1d16d..82066819 100644 --- a/src/LYStrings.h +++ b/src/LYStrings.h @@ -94,12 +94,14 @@ extern char * SNACat PARAMS(( extern char *LYSafeGets PARAMS((char ** src, FILE * fp)); #ifdef EXP_CMD_LOGGING +extern BOOL LYHaveCmdScript NOPARAMS; extern int LYReadCmdKey PARAMS((int mode)); extern void LYCloseCmdLogfile NOPARAMS; extern void LYOpenCmdLogfile PARAMS((int argc, char **argv)); extern void LYOpenCmdScript NOPARAMS; extern void LYWriteCmdKey PARAMS((int ch)); #else +#define LYHaveCmdScript() FALSE #define LYReadCmdKey(mode) LYgetch_for(mode) #define LYCloseCmdLogfile() /* nothing */ #endif diff --git a/src/LYUtils.c b/src/LYUtils.c index 02cfcce3..1cd2a119 100644 --- a/src/LYUtils.c +++ b/src/LYUtils.c @@ -2246,6 +2246,9 @@ PRIVATE int DontCheck NOARGS if (dump_output_immediately) return(TRUE); + if (LYHaveCmdScript()) /* we may be running from a script */ + return(TRUE); + #ifdef MISC_EXP if (LYNoZapKey) return(TRUE); |