diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/GridText.c | 10 | ||||
-rw-r--r-- | src/HTAlert.c | 35 | ||||
-rw-r--r-- | src/HTAlert.h | 4 | ||||
-rw-r--r-- | src/HTInit.c | 6 | ||||
-rw-r--r-- | src/LYBookmark.c | 10 | ||||
-rw-r--r-- | src/LYCookie.c | 12 | ||||
-rw-r--r-- | src/LYCurses.c | 2 | ||||
-rw-r--r-- | src/LYExtern.c | 6 | ||||
-rw-r--r-- | src/LYGetFile.c | 4 | ||||
-rw-r--r-- | src/LYGlobalDefs.h | 2 | ||||
-rw-r--r-- | src/LYHistory.c | 2 | ||||
-rw-r--r-- | src/LYJump.c | 2 | ||||
-rw-r--r-- | src/LYKeymap.c | 4 | ||||
-rw-r--r-- | src/LYLocal.c | 2 | ||||
-rw-r--r-- | src/LYMail.c | 168 | ||||
-rw-r--r-- | src/LYMain.c | 20 | ||||
-rw-r--r-- | src/LYMainLoop.c | 65 | ||||
-rw-r--r-- | src/LYNews.c | 6 | ||||
-rw-r--r-- | src/LYOptions.c | 35 | ||||
-rw-r--r-- | src/LYPrint.c | 6 | ||||
-rw-r--r-- | src/LYReadCFG.c | 71 | ||||
-rw-r--r-- | src/LYShowInfo.c | 17 | ||||
-rw-r--r-- | src/LYStrings.c | 8 | ||||
-rw-r--r-- | src/LYUpload.c | 21 | ||||
-rw-r--r-- | src/LYUtils.c | 123 | ||||
-rw-r--r-- | src/LYexit.c | 3 | ||||
-rw-r--r-- | src/LYrcFile.c | 226 | ||||
-rw-r--r-- | src/chrtrans/makefile.dos | 2 |
28 files changed, 429 insertions, 443 deletions
diff --git a/src/GridText.c b/src/GridText.c index a8687293..b88bf97d 100644 --- a/src/GridText.c +++ b/src/GridText.c @@ -4379,7 +4379,7 @@ check_WrapSource: #ifndef CONV_JISX0201KANA_JISX0208KANA else if ((HTCJK == JAPANESE) && IS_SJIS_X0201KANA((unsigned char)(ch)) && (kanji_code == EUC)) { - line->data[line->size++] = 0x8e; + line->data[line->size++] = (unsigned char) 0x8e; line->data[line->size++] = ch; } #endif @@ -6957,7 +6957,7 @@ PUBLIC void HText_pageDisplay ARGS2( #ifdef DISP_PARTIAL if (display_partial && debug_display_partial) - sleep(MessageSecs); + LYSleepMsg(); #endif is_www_index = HTAnchor_isIndex(HTMainAnchor); @@ -10358,7 +10358,7 @@ PUBLIC int HText_SubmitForm ARGS4( _user_message( CANNOT_TRANSCODE_FORM, target_csname ? target_csname : "UNKNOWN"); - sleep(AlertSecs); + LYSleepAlert(); } } } @@ -10490,7 +10490,7 @@ PUBLIC int HText_SubmitForm ARGS4( _user_message( CANNOT_TRANSCODE_FORM, target_csname ? target_csname : "UNKNOWN"); - sleep(AlertSecs); + LYSleepAlert(); } out_cs = form_ptr->value_cs; } else { @@ -10592,7 +10592,7 @@ PUBLIC int HText_SubmitForm ARGS4( _user_message( CANNOT_TRANSCODE_FORM, target_csname ? target_csname : "UNKNOWN"); - sleep(AlertSecs); + LYSleepAlert(); } } if (Boundary) { diff --git a/src/HTAlert.c b/src/HTAlert.c index 6596f411..a2415b1c 100644 --- a/src/HTAlert.c +++ b/src/HTAlert.c @@ -35,7 +35,7 @@ PUBLIC void HTAlert ARGS1( _user_message(ALERT_FORMAT, Msg); LYstore_message2(ALERT_FORMAT, Msg); - sleep(AlertSecs); + LYSleepAlert(); } PUBLIC void HTAlwaysAlert ARGS2( @@ -51,14 +51,14 @@ PUBLIC void HTAlwaysAlert ARGS2( extra_prefix, Msg); fflush(stdout); LYstore_message2(ALERT_FORMAT, Msg); - sleep(AlertSecs); + LYSleepAlert(); } else { fprintf(((TRACE) ? stdout : stderr), ALERT_FORMAT, (Msg == 0) ? "" : Msg); fflush(stdout); LYstore_message2(ALERT_FORMAT, Msg); - sleep(AlertSecs); + LYSleepAlert(); fprintf(((TRACE) ? stdout : stderr), "\n"); } CTRACE((tfp, "\nAlert!: %s\n\n", Msg)); @@ -90,7 +90,7 @@ PUBLIC void HTUserMsg ARGS1( if (Msg && *Msg) { CTRACE((tfp, "User message: %s\n", Msg)); LYstore_message(Msg); - sleep(MessageSecs); + LYSleepMsg(); } } @@ -104,7 +104,7 @@ PUBLIC void HTUserMsg2 ARGS2( CTRACE((tfp, Msg2, Arg)); CTRACE((tfp, "\n")); LYstore_message2(Msg2, Arg); - sleep(MessageSecs); + LYSleepMsg(); } } @@ -219,7 +219,7 @@ PUBLIC void HTReadProgress ARGS2( static long bytes_last; double transfer_rate; - char line[80]; + char line[MAX_LINE]; struct timeb tb; char *units = "bytes"; @@ -1100,6 +1100,29 @@ PUBLIC int HTConfirmPostRedirect ARGS2( return (result); } +#define okToSleep() (!crawl && !traversal && LYCursesON) + +/* + * Sleep for the given message class's time. + */ +PUBLIC void LYSleepAlert NOARGS +{ + if (okToSleep()) + sleep(AlertSecs); +} + +PUBLIC void LYSleepInfo NOARGS +{ + if (okToSleep()) + sleep(InfoSecs); +} + +PUBLIC void LYSleepMsg NOARGS +{ + if (okToSleep()) + sleep(MessageSecs); +} + /* * LYstrerror emulates the ANSI strerror() function. */ diff --git a/src/HTAlert.h b/src/HTAlert.h index 04f07bdd..563405de 100644 --- a/src/HTAlert.h +++ b/src/HTAlert.h @@ -151,6 +151,10 @@ extern int HTConfirmPostRedirect PARAMS(( int server_status)); +extern void LYSleepAlert NOPARAMS; +extern void LYSleepInfo NOPARAMS; +extern void LYSleepMsg NOPARAMS; + #ifdef HAVE_STRERROR #define LYStrerror strerror #else diff --git a/src/HTInit.c b/src/HTInit.c index 743c8ace..b3890286 100644 --- a/src/HTInit.c +++ b/src/HTInit.c @@ -1159,11 +1159,9 @@ PRIVATE int HTLoadExtensionsConfigFile ARGS1( while(line[0]) { HTGetWord(word, line, ' ', '\t'); if (word[0] && (word[0] != ' ')) { - char *ext = (char *)malloc(sizeof(char) * (strlen(word)+1+1)); - if (!ext) - outofmem(__FILE__, "HTLoadExtensionsConfigFile"); + char *ext = NULL; - sprintf(ext, ".%s", word); + HTSprintf0(&ext, ".%s", word); LYLowerCase(ext); CTRACE((tfp, "SETTING SUFFIX '%s' to '%s'.\n", ext, ct)); diff --git a/src/LYBookmark.c b/src/LYBookmark.c index f3caae8a..848d4cc8 100644 --- a/src/LYBookmark.c +++ b/src/LYBookmark.c @@ -146,7 +146,7 @@ PRIVATE char * convert_mosaic_bookmark_file ARGS1( LYRemoveTemp(newfile); if ((nfp = LYOpenTemp(newfile, HTML_SUFFIX, "w")) == NULL) { LYMBM_statusline(NO_TEMP_FOR_HOTLIST); - sleep(AlertSecs); + LYSleepAlert(); return (""); } @@ -298,7 +298,7 @@ PUBLIC void save_bookmark_link ARGS2( LYgetstr(string_buffer, VISIBLE, sizeof(string_buffer), NORECALL); if (*string_buffer == '\0') { LYMBM_statusline(CANCELLED); - sleep(MessageSecs); + LYSleepMsg(); FREE(bookmark_URL); return; } @@ -354,7 +354,7 @@ PUBLIC void save_bookmark_link ARGS2( BookmarkPage, filename_buffer)); if ((fp = fopen(filename_buffer, (first_time ? "w" : "a+"))) == NULL) { LYMBM_statusline(BOOKMARK_OPEN_FAILED); - sleep(AlertSecs); + LYSleepAlert(); FREE(Title); FREE(bookmark_URL); return; @@ -452,7 +452,7 @@ Note: if you edit this file manually\n\ FREE(Address); FREE(bookmark_URL); LYMBM_statusline(OPERATION_DONE); - sleep(MessageSecs); + LYSleepMsg(); } /* @@ -611,7 +611,7 @@ PUBLIC void remove_bookmark_link ARGS2( LYRemoveTemp(newfile); return; } - sleep(AlertSecs); /* give a chance to see error from cp - kw */ + LYSleepAlert(); /* give a chance to see error from cp - kw */ HTUserMsg(BOOKTEMP_COPY_FAIL); keep_tempfile = TRUE; } diff --git a/src/LYCookie.c b/src/LYCookie.c index cdae410a..c0f6845a 100644 --- a/src/LYCookie.c +++ b/src/LYCookie.c @@ -2315,7 +2315,7 @@ PRIVATE int LYHandleCookies ARGS4 ( */ if (HTList_isEmpty(domain_list)) { HTProgress(COOKIE_JAR_IS_EMPTY); - sleep(MessageSecs); + LYSleepMsg(); HTNoDataOK = 1; return(HT_NO_DATA); } @@ -2402,7 +2402,7 @@ PRIVATE int LYHandleCookies ARGS4 ( } else { HTProgress(COOKIE_EATEN); } - sleep(MessageSecs); + LYSleepMsg(); HTNoDataOK = 1; break; } @@ -2460,7 +2460,7 @@ PRIVATE int LYHandleCookies ARGS4 ( HTList_removeObject(domain_list, de); FREE(de); HTProgress(DOMAIN_EATEN); - sleep(MessageSecs); + LYSleepMsg(); break; } Delete_all_cookies_in_domain: @@ -2481,7 +2481,7 @@ Delete_all_cookies_in_domain: cl = next; } HTProgress(DOMAIN_COOKIES_EATEN); - sleep(MessageSecs); + LYSleepMsg(); /* * If a default accept/reject * choice is set, we're done. - FM @@ -2500,7 +2500,7 @@ Delete_all_cookies_in_domain: HTList_removeObject(domain_list, de); FREE(de); HTProgress(DOMAIN_EATEN); - sleep(MessageSecs); + LYSleepMsg(); } break; @@ -2543,7 +2543,7 @@ Delete_all_cookies_in_domain: * atexit may be called multiple times. - kw */ HTProgress(ALL_COOKIES_EATEN); - sleep(MessageSecs); + LYSleepMsg(); } FREE(domain); FREE(lynxID); diff --git a/src/LYCurses.c b/src/LYCurses.c index 0897642d..dce797f9 100644 --- a/src/LYCurses.c +++ b/src/LYCurses.c @@ -1201,7 +1201,7 @@ PUBLIC BOOLEAN setup ARGS1( (void) putenv(term_putenv); printf("\n%s %s\n", gettext("TERMINAL TYPE IS SET TO"), getenv("TERM")); - sleep(MESSAGESECS); + LYSleepMsg(); } start_curses(); diff --git a/src/LYExtern.c b/src/LYExtern.c index e3d84275..cc7a41ea 100644 --- a/src/LYExtern.c +++ b/src/LYExtern.c @@ -254,11 +254,11 @@ void run_external ARGS1(char *, c) char e_buff[PATH_MAX], *p; p = c + 17; + *e_buff = 0; if (strchr(p, ':') == NULL) { - sprintf(e_buff, "%s/%s", windows_drive, p); - } else { - strcpy(e_buff, p); + sprintf(e_buff, "%.3s/", windows_drive); } + strncat(e_buff, p, sizeof(e_buff) - strlen(e_buff) - 1); p = strrchr(e_buff, '.'); if (p) { p = strchr(p, '#'); diff --git a/src/LYGetFile.c b/src/LYGetFile.c index 4525dcbf..bb70c2e6 100644 --- a/src/LYGetFile.c +++ b/src/LYGetFile.c @@ -903,7 +903,7 @@ Try_Redirected_URL: if (LYCursesON) { _user_message(WWW_ILLEGAL_URL_MESSAGE, use_this_url_instead); - sleep(AlertSecs); + LYSleepAlert(); } else { fprintf(stderr, WWW_ILLEGAL_URL_MESSAGE, @@ -931,7 +931,7 @@ Try_Redirected_URL: CTRACE_SLEEP(MessageSecs); _user_message(WWW_USING_MESSAGE, use_this_url_instead); - sleep(InfoSecs); + LYSleepInfo(); CTRACE((tfp, "\n")); StrAllocCopy(doc->address, use_this_url_instead); diff --git a/src/LYGlobalDefs.h b/src/LYGlobalDefs.h index 14cdc76d..c394e812 100644 --- a/src/LYGlobalDefs.h +++ b/src/LYGlobalDefs.h @@ -464,7 +464,7 @@ extern BOOLEAN FileInitAlreadyDone; /* LYMain.c */ extern BOOLEAN focus_window; extern BOOLEAN system_is_NT; -extern char windows_drive[]; +extern char windows_drive[4]; extern int lynx_timeout; #endif /* _WINDOWS */ diff --git a/src/LYHistory.c b/src/LYHistory.c index ba3c1a26..c8b70d00 100644 --- a/src/LYHistory.c +++ b/src/LYHistory.c @@ -29,7 +29,7 @@ #include <HTCJK.h> PUBLIC HTList * Visited_Links = NULL; /* List of safe popped docs. */ -PUBLIC int Visited_Links_As = VISITED_LINKS_AS_TREE; +PUBLIC int Visited_Links_As = VISITED_LINKS_AS_LATEST | VISITED_LINKS_REVERSE; PRIVATE VisitedLink *PrevVisitedLink = NULL; /* NULL on auxillary */ PRIVATE VisitedLink *PrevActiveVisitedLink = NULL; /* Last non-auxillary */ PRIVATE VisitedLink Latest_first; diff --git a/src/LYJump.c b/src/LYJump.c index 0267cc6f..3da3b870 100644 --- a/src/LYJump.c +++ b/src/LYJump.c @@ -354,7 +354,7 @@ check_recall: jtp->nel, sizeof(JumpDatum), LYCompare); if (!found) { user_message("Unknown target '%s'", buf); - sleep(AlertSecs); + LYSleepAlert(); } StrAllocCopy(jtp->shortcut, bp); diff --git a/src/LYKeymap.c b/src/LYKeymap.c index dbde16f1..75914bd5 100644 --- a/src/LYKeymap.c +++ b/src/LYKeymap.c @@ -845,7 +845,7 @@ PRIVATE char *pretty ARGS1 (int, c) sprintf(buf, "^%c", c|0100); else if (c >= 0400 && (c - 0400) < (int) TABLESIZE(funckey) && funckey[c-0400]) - sprintf(buf, "%s", funckey[c-0400]); + sprintf(buf, "%.*s", (int)(sizeof(buf) - 1), funckey[c-0400]); else if (c >= 0400) sprintf(buf, "key-%#x", c); else @@ -879,7 +879,7 @@ PRIVATE char *pretty_html ARGS1 (int, c) sprintf(buf, "^%c", c|0100); else if (c >= 0400 && (c - 0400) < (int) TABLESIZE(funckey) && funckey[c-0400]) - sprintf(buf, "%s", funckey[c-0400]); + sprintf(buf, "%.*s", (int)(sizeof(buf) - 1), funckey[c-0400]); else if (c >= 0400) sprintf(buf, "%#x", c); else diff --git a/src/LYLocal.c b/src/LYLocal.c index bc6d8557..60244df9 100644 --- a/src/LYLocal.c +++ b/src/LYLocal.c @@ -2410,7 +2410,7 @@ PRIVATE int LYExecv ARGS3( * Screen may have message from the failed execv'd command. * Give user time to look at it before screen refresh. */ - sleep(AlertSecs); + LYSleepAlert(); } start_curses(); if (tmpbuf != 0) { diff --git a/src/LYMail.c b/src/LYMail.c index 3544ba46..00cf7eff 100644 --- a/src/LYMail.c +++ b/src/LYMail.c @@ -1,13 +1,3 @@ -/* - * This file checked for sprintf() buffer overruns on 1998/05/06 by Bela - * Lubkin <filbo@armory.com>. Please don't introduce any new ones... - * - * See comments marked "- BL" for two still-possible overruns in the VMS - * code. - * - * Not yet checked for any other sort of buffer overrun. - */ - #include <HTUtils.h> #include <HTParse.h> #include <LYGlobalDefs.h> @@ -69,7 +59,7 @@ PRIVATE char *blat_cmd( char *mail_addr) { FILE *fp; - static char b_cmd[512]; + static char *b_cmd; #ifdef __CYGWIN__ char dosname[LY_MAXPATH]; #endif @@ -98,9 +88,9 @@ PRIVATE char *blat_cmd( #ifdef __CYGWIN__ cygwin_conv_to_full_win32_path(bl_cmd_file, dosname); - sprintf(b_cmd, "%s \"@%s\"", mail_cmd, dosname); + HTSprintf0(&b_cmd, "%s \"@%s\"", mail_cmd, dosname); #else - sprintf(b_cmd, "%s @%s", mail_cmd, bl_cmd_file); + HTSprintf0(&b_cmd, "%s @%s", mail_cmd, bl_cmd_file); #endif return b_cmd; @@ -139,6 +129,7 @@ PUBLIC void mailform ARGS4( CONST char *, mailto_content, CONST char *, mailto_type) { + static char *cmd; FILE *fd; char *address = NULL; char *ccaddr = NULL; @@ -147,7 +138,7 @@ PUBLIC void mailform ARGS4( char self[80]; char subject[80]; char *searchpart = NULL; - char cmd[512]; + char buf[512]; char *cp0 = NULL, *cp1 = NULL; int ch, len, i; #ifdef VMS @@ -413,7 +404,7 @@ PUBLIC void mailform ARGS4( } #if CAN_PIPE_TO_MAILER - sprintf(cmd, "%s %s", system_mail, system_mail_flags); + HTSprintf0(&cmd, "%s %s", system_mail, system_mail_flags); if ((fd = popen(cmd, "w")) == NULL) { HTAlert(FORM_MAILTO_FAILED); FREE(address); @@ -502,9 +493,9 @@ PUBLIC void mailform ARGS4( i = 0; len = strlen(mailto_content); while (len > 78) { - strncpy(cmd, &mailto_content[i], 78); - cmd[78] = '\0'; - fprintf(fd, "%s\n", cmd); + strncpy(buf, &mailto_content[i], 78); + buf[78] = '\0'; + fprintf(fd, "%s\n", buf); i += 78; len = strlen(&mailto_content[i]); } @@ -514,9 +505,9 @@ PUBLIC void mailform ARGS4( i = 0; len = strlen(mailto_content); while (len > 78) { - strncpy(cmd, &mailto_content[i], 78); - cmd[78] = '\0'; - fprintf(fd, "%s\n", cmd); + strncpy(buf, &mailto_content[i], 78); + buf[78] = '\0'; + fprintf(fd, "%s\n", buf); i += 78; len = strlen(&mailto_content[i]); } @@ -525,7 +516,7 @@ PUBLIC void mailform ARGS4( #if CAN_PIPE_TO_MAILER pclose(fd); - sleep(MessageSecs); + LYSleepMsg(); #endif /* UNIX */ #if defined(VMS) || defined(DOSPATH) || defined(SH_EX) LYCloseTempFP(fd); @@ -546,7 +537,7 @@ PUBLIC void mailform ARGS4( /* * Now set up the command. - FM */ - sprintf(cmd, + HTSprintf0(&cmd, "%s %s %s,%s ", system_mail, system_mail_flags, @@ -558,10 +549,8 @@ PUBLIC void mailform ARGS4( * command, and ignore any keywords to minimize risk * of them making the line too long or having problem * characters. - FM - * - * Possibly still a problem if user supplies long subject. - BL */ - sprintf(cmd, + HTSprintf0(&cmd, "%s %s%s/subject=\"%s\" %s ", system_mail, system_mail_flags, @@ -587,16 +576,12 @@ PUBLIC void mailform ARGS4( * 4 letters is arbitrarily the smallest possible mail * address, at least for lynx. That way extra spaces * won't confuse the mailer and give a blank address. - * - * ignore addresses so long that they would overflow the - * temporary buffer (i.e., about 500 chars). - BL */ - if (strlen(address_ptr1) > 3 && - strlen(address_ptr1) + strlen(mail_adrs) < sizeof(cmd)) { + if (strlen(address_ptr1) > 3) { if (!first) { StrAllocCat(command, ","); } - sprintf(cmd, mail_adrs, address_ptr1); + HTSprintf0(&cmd, mail_adrs, address_ptr1); StrAllocCat(command, cmd); first = FALSE; } @@ -620,18 +605,13 @@ PUBLIC void mailform ARGS4( * 4 letters is arbitrarily the smallest possible mail * address, at least for lynx. That way extra spaces * won't confuse the mailer and give a blank address. - * - * ignore addresses so long that they would overflow the - * temporary buffer (i.e., about 500 chars). - BL */ - if (strlen(address_ptr1) > 3 && - strlen(address_ptr1) + strlen(mail_adrs) < sizeof(cmd)) { + if (strlen(address_ptr1) > 3) { StrAllocCat(command, ","); - sprintf(cmd, mail_adrs, address_ptr1); + HTSprintf(&command, mail_adrs, address_ptr1); if (isPMDF) { - strcat(cmd, "/CC"); + StrAllocCat(command, "/CC"); } - StrAllocCat(command, cmd); } address_ptr1 = address_ptr2; } while (address_ptr1 != NULL); @@ -641,7 +621,7 @@ PUBLIC void mailform ARGS4( printf("%s\n\n$ %s\n\n%s", SENDING_FORM_CONTENT, command, PLEASE_WAIT); LYSystem(command); /* Mail (VMS) */ FREE(command); - sleep(AlertSecs); + LYSleepAlert(); start_curses(); LYRemoveTemp(my_tmpfile); LYRemoveTemp(hdrfile); @@ -673,7 +653,7 @@ PUBLIC void mailform ARGS4( printf("%s\n\n$ %s\n\n%s", SENDING_FORM_CONTENT, command, PLEASE_WAIT); LYSystem(command); /* Mail sending form content (DOS/Windows) */ FREE(command); - sleep(MessageSecs); + LYSleepMsg(); start_curses(); LYRemoveTemp(my_tmpfile); @@ -938,9 +918,6 @@ PUBLIC void mailmsg ARGS4( * 4 letters is arbitrarily the smallest possible mail * address, at least for lynx. That way extra spaces * won't confuse the mailer and give a blank address. - * - * ignore addresses so long that they would overflow the - * temporary buffer (i.e., about 500 chars). - BL */ if (!first) { StrAllocCat(command, ","); @@ -961,7 +938,7 @@ PUBLIC void mailmsg ARGS4( #else /* DOSPATH */ #if USE_BLAT_MAILER if (mail_is_blat) - strcpy(cmd, + StrAllocCopy(cmd, blat_cmd( system_mail, my_tmpfile, @@ -973,13 +950,11 @@ PUBLIC void mailmsg ARGS4( ); else #endif - sprintf(cmd, "%s -t \"%s\" -F %s", system_mail, address, my_tmpfile); + HTSprintf0(&cmd, "%s -t \"%s\" -F %s", system_mail, address, my_tmpfile); LYSystem(cmd); /* Mail (DOS/Windows) */ + FREE(cmd); -#if 0 /* Not SH_EX */ - FREE(command); -#endif LYRemoveTemp(my_tmpfile); #if USE_BLAT_MAILER if (mail_is_blat) @@ -1028,10 +1003,10 @@ PUBLIC void reply_by_mail ARGS4( char *temp = NULL; int i, len; int c = 0; /* user input */ - char my_tmpfile[LY_MAXPATH], cmd[512]; + char my_tmpfile[LY_MAXPATH]; + char *command = NULL; #if !CAN_PIPE_TO_MAILER char tmpfile2[LY_MAXPATH]; - char *command = NULL; #endif #ifndef NO_ANONYMOUS_EMAIL static char *personal_name = NULL; @@ -1249,30 +1224,22 @@ PUBLIC void reply_by_mail ARGS4( i = 0; len = strlen(cp0); while (len > 78) { - strncpy(cmd, (char *)&cp0[i], 78); - cmd[78] = '\0'; - strcat(cmd, "\n"); - StrAllocCat(body, cmd); + HTSprintf(&body, "%.78s\n", &cp0[i]); i += 78; - len = strlen((char *)&cp0[i]); + len = strlen(&cp0[i]); } - sprintf(cmd, "%s\n", (char *)&cp0[i]); - StrAllocCat(body, cmd); + HTSprintf(&body, "%s\n", &cp0[i]); cp0 = (cp + 1); } i = 0; len = strlen(cp0); while (len > 78) { - strncpy(cmd, (char *)&cp0[i], 78); - cmd[78] = '\0'; - strcat(cmd, "\n"); - StrAllocCat(body, cmd); + HTSprintf(&body, "%.78s\n", &cp0[i]); i += 78; - len = strlen((char *)&cp0[i]); + len = strlen(&cp0[i]); } if (len) { - sprintf(cmd, "%s\n", (char *)&cp0[i]); - StrAllocCat(body, cmd); + HTSprintf(&body, "%s\n", &cp0[i]); } FREE(temp); } @@ -1403,9 +1370,8 @@ PUBLIC void reply_by_mail ARGS4( if (!LYHaveCJKCharacterSet && strncasecomp(LYCharSet_UC[current_char_set].MIMEname, "x-", 2) != 0) { - sprintf(buf,"Content-Type: text/plain; charset=%s\n", + HTSprintf(&header, "Content-Type: text/plain; charset=%s\n", LYCharSet_UC[current_char_set].MIMEname); - StrAllocCat(header, buf); } StrAllocCat(header, "Content-Transfer-Encoding: 8bit\n"); } @@ -1421,8 +1387,7 @@ PUBLIC void reply_by_mail ARGS4( StrAllocCat(header, address); } StrAllocCat(header, "\n"); - sprintf(buf, "X-Mailer: Lynx, Version %s\n", LYNX_VERSION); - StrAllocCat(header, buf); + HTSprintf(&header, "X-Mailer: Lynx, Version %s\n", LYNX_VERSION); if (refid && *refid) { StrAllocCat(header, "In-Reply-To: <"); @@ -1548,8 +1513,10 @@ PUBLIC void reply_by_mail ARGS4( addstr("From: "); #endif /* VMS */ /* Add the personal mail address if there is one. */ - sprintf(user_input, "%s", (personal_mail_address ? - personal_mail_address : "")); + sprintf(user_input, "%.*s", (int)(sizeof(user_input) - 1), + (personal_mail_address + ? personal_mail_address + : "")); if (LYgetstr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0 || term_letter) { addstr("\n"); @@ -1626,8 +1593,10 @@ PUBLIC void reply_by_mail ARGS4( /* * Add the mail address if there is one. */ - sprintf(user_input, "%s", (personal_mail_address ? - personal_mail_address : "")); + sprintf(user_input, "%.*s", (int) (sizeof(user_input) - 1), + (personal_mail_address + ? personal_mail_address + : "")); if (LYgetstr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0 || term_letter) { addstr("\n"); @@ -1684,8 +1653,7 @@ PUBLIC void reply_by_mail ARGS4( /* * Terminate the header. */ - sprintf(buf, "\n"); - StrAllocCat(header, buf); + StrAllocCat(header, "\n"); CTRACE((tfp,"**header==\n%s",header)); #endif /* !VMS */ @@ -1732,15 +1700,17 @@ PUBLIC void reply_by_mail ARGS4( if (strstr(editor, "pico")) { editor_arg = " -t"; /* No prompt for filename to use */ } - sprintf(user_input, "%s%s %s", editor, editor_arg, my_tmpfile); + command = 0; + HTSprintf0(&command, "%s%s %s", editor, editor_arg, my_tmpfile); _statusline(SPAWNING_EDITOR_FOR_MAIL); stop_curses(); - if (LYSystem(user_input)) { /* Spawn Editor */ + if (LYSystem(command)) { /* Spawn Editor */ start_curses(); HTAlert(ERROR_SPAWNING_EDITOR); } else { start_curses(); } + FREE(command); } else if (body) { /* @@ -1760,7 +1730,7 @@ PUBLIC void reply_by_mail ARGS4( addstr("\n"); if (term_letter || c == 7 || c == 3) { addstr(CANCELLED); - sleep(InfoSecs); + LYSleepInfo(); LYCloseTempFP(fd); /* Close the tmpfile. */ scrollok(stdscr, FALSE); /* Stop scrolling. */ goto cleanup; @@ -1879,8 +1849,7 @@ PUBLIC void reply_by_mail ARGS4( /* * Now set up the command. - FM */ - sprintf(cmd, - "%s %s %s,%s ", + HTSprintf0(&command, "%s %s %s,%s ", system_mail, system_mail_flags, hdrfile, @@ -1891,18 +1860,14 @@ PUBLIC void reply_by_mail ARGS4( * command, and ignore any keywords to minimize risk * of them making the line too long or having problem * characters. - FM - * - * Possibly still a problem if user supplies long subject. - BL */ - sprintf(cmd, - "%s %s%s/subject=\"%s\" %s ", + HTSprintf0(&command, "%s %s%s/subject=\"%s\" %s ", system_mail, system_mail_flags, (strncasecomp(system_mail, "MAIL", 4) ? "" : "/noself"), subject, my_tmpfile); } - StrAllocCopy(command, cmd); /* * Now add all the people in the address field. - FM @@ -1920,17 +1885,12 @@ PUBLIC void reply_by_mail ARGS4( * 4 letters is arbitrarily the smallest possible mail * address, at least for lynx. That way extra spaces * won't confuse the mailer and give a blank address. - * - * ignore addresses so long that they would overflow the - * temporary buffer (i.e., about 500 chars). - BL */ - if (strlen(address_ptr1) > 3 && - strlen(address_ptr1) + strlen(mail_adrs) < sizeof(cmd)) { + if (strlen(address_ptr1) > 3) { if (!first) { StrAllocCat(command, ","); } - sprintf(cmd, mail_adrs, address_ptr1); - StrAllocCat(command, cmd); + HTSprintf(command, mail_adrs, address_ptr1); first = FALSE; } address_ptr1 = address_ptr2; @@ -1953,18 +1913,13 @@ PUBLIC void reply_by_mail ARGS4( * 4 letters is arbitrarily the smallest possible mail * address, at least for lynx. That way extra spaces * won't confuse the mailer and give a blank address. - * - * ignore addresses so long that they would overflow the - * temporary buffer (i.e., about 500 chars). - BL */ - if (strlen(address_ptr1) > 3 && - strlen(address_ptr1) + strlen(mail_adrs) < sizeof(cmd)) { + if (strlen(address_ptr1) > 3) { StrAllocCat(command, ","); - sprintf(cmd, mail_adrs, address_ptr1); + HTSprintf(&command, mail_adrs, address_ptr1); if (isPMDF) { - strcat(cmd, "/CC"); + StrAllocCat(command, "/CC"); } - StrAllocCat(command, cmd); } address_ptr1 = address_ptr2; } while (address_ptr1 != NULL); @@ -1974,7 +1929,7 @@ PUBLIC void reply_by_mail ARGS4( printf("%s\n\n$ %s\n\n%s", SENDING_COMMENT, command, PLEASE_WAIT); LYSystem(command); /* SENDING COMMENT (VMS) */ FREE(command); - sleep(AlertSecs); + LYSleepAlert(); start_curses(); #else /* Unix/DOS/Windows */ /* @@ -1983,12 +1938,13 @@ PUBLIC void reply_by_mail ARGS4( _statusline(SENDING_YOUR_MSG); #if CAN_PIPE_TO_MAILER signal(SIGINT, SIG_IGN); - sprintf(cmd, "%s %s", system_mail, system_mail_flags); - CTRACE((tfp, "%s\n", cmd)); - fp = popen(cmd, "w"); + HTSprintf0(&command, "%s %s", system_mail, system_mail_flags); + CTRACE((tfp, "%s\n", command)); + fp = popen(command, "w"); if (fp == NULL) { HTInfoMsg(COMMENT_REQUEST_CANCELLED); } + FREE(command); #else if ((fp = LYOpenTemp(tmpfile2, ".txt", "w")) == NULL) { HTAlert(MAILTO_URL_TEMPOPEN_FAILED); @@ -2042,7 +1998,7 @@ PUBLIC void reply_by_mail ARGS4( printf("%s\n\n$ %s\n\n%s", SENDING_COMMENT, command, PLEASE_WAIT); LYSystem(command); /* SENDING COMMENT (DOS/Windows/Unix) */ FREE(command); - sleep(MessageSecs); + LYSleepMsg(); start_curses(); LYRemoveTemp(tmpfile2); /* Delete the tmpfile. */ #if USE_BLAT_MAILER diff --git a/src/LYMain.c b/src/LYMain.c index 1313b2dd..dcaa028f 100644 --- a/src/LYMain.c +++ b/src/LYMain.c @@ -1343,16 +1343,12 @@ PUBLIC int main ARGS2( #ifdef JUMPFILE StrAllocCopy(jumpfile, JUMPFILE); { - temp = (char *)malloc(strlen(jumpfile) + 10); - if (!temp) { - outofmem(__FILE__, "main"); - } else { - sprintf(temp, "JUMPFILE:%s", jumpfile); - if (!LYJumpInit(temp)) { - CTRACE((tfp, "Failed to register %s\n", temp)); - } - FREE(temp); + temp = NULL; + HTSprintf0(&temp, "JUMPFILE:%s", jumpfile); + if (!LYJumpInit(temp)) { + CTRACE((tfp, "Failed to register %s\n", temp)); } + FREE(temp); } #endif /* JUMPFILE */ @@ -3743,10 +3739,10 @@ in double-quotes (\"-\") on VMS)", NULL); switch (p->type & ARG_TYPE_MASK) { case TOGGLE_ARG: case SET_ARG: - sprintf(temp, "%s", *(q->set_value) ? "on" : "off"); + strcpy(temp, *(q->set_value) ? "on" : "off"); break; case UNSET_ARG: - sprintf(temp, "%s", *(q->set_value) ? "off" : "on"); + strcpy(temp, *(q->set_value) ? "off" : "on"); break; case INT_ARG: sprintf(temp, "%d", *(q->int_value)); @@ -3995,7 +3991,7 @@ PRIVATE void FatalProblem ARGS1( * Deal with curses, if on, and clean up. - FM */ if (LYOutOfMemory && LYCursesON) { - sleep(AlertSecs); + LYSleepAlert(); } cleanup_sig(0); #ifndef __linux__ diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c index b3f0f624..dd02bd80 100644 --- a/src/LYMainLoop.c +++ b/src/LYMainLoop.c @@ -1842,7 +1842,7 @@ PRIVATE void handle_LYK_DIRED_MENU ARGS3( int, real_c GCC_UNUSED) { #ifdef VMS - char *cp, *temp; + char *cp, *temp = 0; /* * Check if the CSwing Directory/File Manager is available. @@ -1888,10 +1888,7 @@ PRIVATE void handle_LYK_DIRED_MENU ARGS3( if (HTStat(cp, &stat_info) == -1) { CTRACE((tfp, "mainloop: Can't stat %s\n", cp)); FREE(cp); - temp = (char *)calloc(1, (strlen(LYCSwingPath) + 4)); - if (temp == NULL) - outofmem(__FILE__, "mainloop"); - sprintf(temp, "%s []", LYCSwingPath); + HTSprintf0(&temp, "%s []", LYCSwingPath); *refresh_screen = TRUE; /* redisplay */ } else { char *VMSdir = NULL; @@ -1919,13 +1916,7 @@ PRIVATE void handle_LYK_DIRED_MENU ARGS3( cp == NULL; } } - temp = (char *)calloc(1, - (strlen(LYCSwingPath) + - strlen(VMSdir) + - 2)); - if (temp == NULL) - outofmem(__FILE__, "mainloop"); - sprintf(temp, "%s %s", LYCSwingPath, VMSdir); + HTSprintf0(&temp, "%s %s", LYCSwingPath, VMSdir); FREE(VMSdir); /* * Uncache the current document in case we @@ -1950,10 +1941,7 @@ PRIVATE void handle_LYK_DIRED_MENU ARGS3( * an argument and don't uncache the current * document. - FM */ - temp = (char *)calloc(1, (strlen(LYCSwingPath) + 4)); - if (temp == NULL) - outofmem(__FILE__, "mainloop"); - sprintf(temp, "%s []", LYCSwingPath); + HTSprintf0(&temp, "%s []", LYCSwingPath); *refresh_screen = TRUE; /* redisplay */ } stop_curses(); @@ -4511,7 +4499,7 @@ PRIVATE void handle_LYK_TOOLBAR ARGS4( int, real_c) { char *cp; - char *toolbar; + char *toolbar = NULL; if (!HText_hasToolbar(HTMainText)) { if (*old_c != real_c) { @@ -4522,12 +4510,8 @@ PRIVATE void handle_LYK_TOOLBAR ARGS4( *old_c = real_c; if ((cp = strchr(curdoc.address, '#')) != NULL) *cp = '\0'; - toolbar = (char *)malloc(strlen(curdoc.address) + - strlen(LYToolbarName) + 2); - if (!toolbar) - outofmem(__FILE__, "mainloop"); - sprintf(toolbar, "%s#%s", curdoc.address, LYToolbarName); + HTSprintf0(&toolbar, "%s#%s", curdoc.address, LYToolbarName); if (cp) *cp = '#'; StrAllocCopy(newdoc.address, toolbar); @@ -4760,7 +4744,7 @@ PRIVATE void handle_LYK_VIEW_BOOKMARK ARGS3( if (*old_c != real_c) { *old_c = real_c; LYMBM_statusline(BOOKMARKS_NOT_OPEN); - sleep(AlertSecs); + LYSleepAlert(); if (LYMultiBookmarks == TRUE) { *refresh_screen = TRUE; } @@ -5705,17 +5689,15 @@ try_again: * if so, reload if with the relevant * bookmark elements set. - FM */ - if ((cp = (char *)calloc(1, - (strlen((char *)&temp[len]) + 2))) == NULL) - outofmem(__FILE__, "mainloop"); + cp = NULL; if (temp[len] == '/') { - if (strchr((char *)&temp[(len + 1)], '/')) { - sprintf(cp, ".%s", (char *)&temp[len]); + if (strchr(&temp[(len + 1)], '/')) { + HTSprintf0(&cp, ".%s", &temp[len]); } else { - strcpy(cp, (char *)&temp[(len + 1)]); + StrAllocCopy(cp, &temp[(len + 1)]); } } else { - strcpy(cp, (char *)&temp[len]); + StrAllocCopy(cp, &temp[len]); } #ifdef VMS #define CompareBookmark(a,b) strcasecomp(a, b) @@ -5855,7 +5837,7 @@ try_again: if (TRACE) { if (!LYTraceLogFP || trace_mode_flag) { - sleep(AlertSecs); /* allow me to look at the results */ + LYSleepAlert(); /* allow me to look at the results */ } } @@ -6088,7 +6070,7 @@ try_again: if (TRACE) { refresh_screen = TRUE; if (!LYTraceLogFP || trace_mode_flag) { - sleep(AlertSecs); + LYSleepAlert(); } } } @@ -7607,18 +7589,25 @@ PRIVATE void status_link ARGS3( #define MAX_STATUS (LYcols - 2) #define MIN_STATUS 0 char format[MAX_LINE]; - int prefix; + int prefix = 0; int length; *format = 0; - if (show_more) - sprintf(format, "%s ", gettext("-more-")); - if (show_indx) - sprintf(format + strlen(format), "%s ", gettext("-index-")); + if (show_more) { + sprintf(format, "%.*s ", + (int)(sizeof(format) - 1), + gettext("-more-")); + prefix = strlen(format); + } + if (show_indx) { + sprintf(format + prefix, "%.*s ", + (int)(sizeof(format) - prefix - 1), + gettext("-index-")); + } prefix = strlen(format); length = strlen(curlink_name); - if (prefix > MAX_STATUS) { + if (prefix > MAX_STATUS || prefix >= MAX_LINE - 1) { _user_message("%s", format); /* no room for url */ } else { sprintf(format + prefix, "%%.%ds", MAX_STATUS - prefix); diff --git a/src/LYNews.c b/src/LYNews.c index 910f8a9b..a58a5146 100644 --- a/src/LYNews.c +++ b/src/LYNews.c @@ -103,6 +103,7 @@ PUBLIC char *LYNewsPost ARGS2( BOOLEAN, followup) { char user_input[1024]; + char *command = NULL; char CJKinput[1024]; char *cp = NULL; CONST char *kp = NULL; @@ -377,15 +378,16 @@ PUBLIC char *LYNewsPost ARGS2( if (strstr(editor, "pico")) { editor_arg = " -t"; /* No prompt for filename to use */ } - sprintf(user_input,"%s%s %s", editor, editor_arg, my_tempfile); + HTSprintf0(&command, "%s%s %s", editor, editor_arg, my_tempfile); _statusline(SPAWNING_EDITOR_FOR_NEWS); stop_curses(); - if (LYSystem(user_input)) { + if (LYSystem(command)) { start_curses(); HTAlert(ERROR_SPAWNING_EDITOR); } else { start_curses(); } + FREE(command); nonempty = message_has_content(my_tempfile, &nonspaces); diff --git a/src/LYOptions.c b/src/LYOptions.c index c97dac50..9126fa56 100644 --- a/src/LYOptions.c +++ b/src/LYOptions.c @@ -2111,7 +2111,7 @@ draw_bookmark_list: } else if (!LYPathOffHomeOK(MBM_tmp_line, sizeof(MBM_tmp_line))) { LYMBM_statusline(USE_PATH_OFF_HOME); - sleep(AlertSecs); + LYSleepAlert(); } else { StrAllocCopy(MBM_A_subbookmark[a], MBM_tmp_line); if (a == 0) { @@ -2181,6 +2181,12 @@ PRIVATE int get_popup_choice_number ARGS1( return(atoi(temp)); } +#define FormatChoiceNum(dst, choice, value) \ + sprintf(dst, "%s%d: %.500s", \ + ((num_choices > 8 && choice < 9) ? \ + " " : ""), \ + (choice + 1), value) + /* * This function offers the choices for values of an * option via a popup window which functions like @@ -2412,10 +2418,7 @@ redraw: */ for (i = 0; i <= num_choices; i++) { if (i >= window_offset && i - window_offset < length) { - sprintf(Cnum, "%s%d: ", - ((num_choices > 8 && i < 9) ? - " " : ""), - (i + 1)); + FormatChoiceNum(Cnum, i, ""); #ifdef USE_SLANG SLsmg_gotorc(top + ((i + 1) - window_offset), (lx - 1 + 2)); addstr(Cnum); @@ -2448,10 +2451,7 @@ redraw: * Unreverse cur choice. */ if (Cptr != NULL) { - sprintf(Cnum, "%s%d: ", - ((num_choices > 8 && i < 9) ? - " " : ""), - (i + 1)); + FormatChoiceNum(Cnum, i, ""); #ifdef USE_SLANG SLsmg_gotorc((top + ((i + 1) - window_offset)), (lx - 1 + 2)); addstr(Cnum); @@ -2464,10 +2464,7 @@ redraw: } Cptr = choices; i = cur_choice; - sprintf(Cnum, "%s%d: ", - ((num_choices > 8 && i < 9) ? - " " : ""), - (i + 1)); + FormatChoiceNum(Cnum, i, ""); #ifdef USE_SLANG SLsmg_gotorc((top + ((i + 1) - window_offset)), (lx - 1 + 2)); addstr(Cnum); @@ -3048,11 +3045,7 @@ check_recall: * Start search at the next choice. - FM */ for (j = 1; Cptr[i+j] != NULL; j++) { - sprintf(buffer, "%s%d: %s", - ((num_choices > 8 && (j + i) < 9) ? - " " : ""), - (i + j + 1), - Cptr[i+j]); + FormatChoiceNum(buffer, (i + j), Cptr[i+j]); if (case_sensitive) { if (strstr(buffer, prev_target_buffer) != NULL) break; @@ -3090,11 +3083,7 @@ check_recall: * Search from the beginning to the current choice. - FM */ for (j = 0; j < cur_choice; j++) { - sprintf(buffer, "%s%d: %s", - ((num_choices > 8 && j < 9) ? - " " : ""), - (j + 1), - Cptr[j]); + FormatChoiceNum(buffer, (j + 1), Cptr[j]); if (case_sensitive) { if (strstr(buffer, prev_target_buffer) != NULL) break; diff --git a/src/LYPrint.c b/src/LYPrint.c index 640386cd..4ae19b31 100644 --- a/src/LYPrint.c +++ b/src/LYPrint.c @@ -655,7 +655,7 @@ PRIVATE void send_file_to_mail ARGS3( SetOutputMode( O_TEXT ); printf(MAILING_FILE); LYSystem(buffer); - sleep(AlertSecs); + LYSleepAlert(); start_curses(); SetOutputMode( O_BINARY ); @@ -781,7 +781,7 @@ PRIVATE void send_file_to_mail ARGS3( SetOutputMode(O_TEXT); printf("%s\n\n$ %s\n\n%s", gettext("Sending"), buffer, PLEASE_WAIT); LYSystem(buffer); - sleep(MessageSecs); + LYSleepMsg(); start_curses(); SetOutputMode( O_BINARY ); @@ -964,7 +964,7 @@ check_again: fflush(stdout); #endif SetOutputMode( O_BINARY ); - sleep(MessageSecs); + LYSleepMsg(); start_curses(); done: /* send_file_to_printer() */ diff --git a/src/LYReadCFG.c b/src/LYReadCFG.c index bfaa0de1..c1360af2 100644 --- a/src/LYReadCFG.c +++ b/src/LYReadCFG.c @@ -520,6 +520,25 @@ typedef struct } Config_Type; +typedef struct +{ + CONST char *name; + int value; +} +Config_Enum; + +static int config_enum ARGS2( + Config_Enum *, table, + CONST char *, name) +{ + while (table->name != 0) { + if (!strcasecomp(table->name, name)) + break; + table++; + } + return table->value; +} + static int assume_charset_fun ARGS1( char *, value) { @@ -631,14 +650,15 @@ static int numbers_as_arrows_fun ARGS1( static int default_user_mode_fun ARGS1( char *, value) { - if (!strncasecomp(value, "NOVICE", 6)) - user_mode = NOVICE_MODE; - else if (!strncasecomp(value, "INTER", 5)) - user_mode = INTERMEDIATE_MODE; - else if (!strncasecomp(value, "ADVANCE", 7)) - user_mode = ADVANCED_MODE; + static Config_Enum table[] = { + { "NOVICE", NOVICE_MODE }, + { "INTER", INTERMEDIATE_MODE }, + { "ADVANCE", ADVANCED_MODE }, + { NULL, NOVICE_MODE } + }; + user_mode = config_enum(table, value); - return 0; + return 0; } #ifdef DIRED_SUPPORT @@ -897,12 +917,13 @@ static int referer_with_query_fun ARGS1( static int source_cache_fun ARGS1( char *, value) { - if (!strncasecomp(value, "FILE", 4)) - LYCacheSource = SOURCE_CACHE_FILE; - else if (!strncasecomp(value, "MEM", 3)) - LYCacheSource = SOURCE_CACHE_MEMORY; - else if (!strncasecomp(value, "NONE", 4)) - LYCacheSource = SOURCE_CACHE_NONE; + static Config_Enum table[] = { + { "FILE", SOURCE_CACHE_FILE }, + { "MEM", SOURCE_CACHE_MEMORY }, + { "NONE", SOURCE_CACHE_NONE }, + { NULL, SOURCE_CACHE_NONE }, + }; + LYCacheSource = config_enum(table, value); return 0; } @@ -978,7 +999,7 @@ static int suffix_fun ARGS1( sq, value)); q = -1.0; } else { - q = df; + q = (float) df; } } HTSetSuffix5(value, mime_type, encoding, description, q); @@ -1211,16 +1232,10 @@ static int parse_html_src_spec ARGS3( return 0; } -typedef struct string_int_pair_ -{ - char* str; - int val; -} string_int_pair; - PRIVATE int psrcspec_fun ARGS1(char*,s) { char* e; - static string_int_pair lexemnames[] = + static Config_Enum lexemnames[] = { { "comm", HTL_comm }, { "tag", HTL_tag }, @@ -1236,8 +1251,7 @@ PRIVATE int psrcspec_fun ARGS1(char*,s) { "sgmlspecial", HTL_sgmlspecial }, { NULL, -1 } }; - string_int_pair* cur = lexemnames; - BOOL found = FALSE; + int found; e = strchr(s,':'); if (!e) { @@ -1245,16 +1259,11 @@ PRIVATE int psrcspec_fun ARGS1(char*,s) return 0; } *e = '\0'; - while (cur->str) { - if ((found = !strcasecomp(s, cur->str)) != 0) - break; - ++cur; - } - if (!found) { + if ((found = config_enum(lexemnames, s)) < 0) { CTRACE((tfp,"bad format of PRETTYSRC_SPEC setting value, ignored %s:%s\n",s,e+1)); return 0; } - parse_html_src_spec(cur->val, e+1, s); + parse_html_src_spec(found, e+1, s); return 0; } @@ -1525,9 +1534,9 @@ static Config_Type Config_Table [] = PARSE_SET("use_mouse", CONF_BOOL, &LYUseMouse), #endif PARSE_SET("use_select_popups", CONF_BOOL, &LYSelectPopups), + PARSE_FUN("viewer", CONF_FUN, viewer_fun), PARSE_SET("verbose_images", CONF_BOOL, &verbose_img), PARSE_SET("vi_keys_always_on", CONF_BOOL, &vi_keys), - PARSE_FUN("viewer", CONF_FUN, viewer_fun), PARSE_ENV("wais_proxy", CONF_ENV, 0 ), PARSE_STR("xloadimage_command", CONF_STR, &XLoadImageCommand), diff --git a/src/LYShowInfo.c b/src/LYShowInfo.c index 0be89fcd..f00e1557 100644 --- a/src/LYShowInfo.c +++ b/src/LYShowInfo.c @@ -44,7 +44,6 @@ PUBLIC int showinfo ARGS4( #endif #ifdef DIRED_SUPPORT - char temp[LY_MAXPATH]; struct stat dir_info; #endif /* DIRED_SUPPORT */ @@ -93,21 +92,18 @@ PUBLIC int showinfo ARGS4( #ifdef DIRED_SUPPORT if (lynx_edit_mode && nlinks > 0) { - char *s; + char *temp; fprintf(fp0, "<pre>\n"); fprintf(fp0, "\n%s\n\n", gettext("Directory that you are currently viewing")); - s = HTfullURL_toFile(doc->address); - strcpy(temp, s); - FREE(s); - + temp = HTfullURL_toFile(doc->address); fprintf(fp0, " <em>%4s</em> %s\n", gettext("Name:"), temp); + FREE(temp); + fprintf(fp0, " <em>%4s</em> %s\n", gettext("URL:"), doc->address); - s = HTfullURL_toFile(links[doc->link].lname); - strcpy(temp, s); - FREE(s); + temp = HTfullURL_toFile(links[doc->link].lname); if (lstat(temp, &dir_info) == -1) { CTRACE((tfp, "lstat(%s) failed, errno=%d\n", temp, errno)); @@ -138,7 +134,7 @@ PUBLIC int showinfo ARGS4( if ((buf_size = readlink(temp, buf, sizeof(buf)-1)) != -1) { buf[buf_size] = '\0'; } else { - strcpy(buf, gettext("Unable to follow link")); + sprintf(buf, "%.1024s", gettext("Unable to follow link")); } fprintf(fp0, " <em>%s</em> %s\n", gettext("Points to file:"), buf); } @@ -225,6 +221,7 @@ PUBLIC int showinfo ARGS4( } fprintf(fp0, "%s\n", (char *)&modes[2]); /* Skip leading ', ' */ } + FREE(temp); fprintf(fp0,"</pre>\n"); } else { #endif /* DIRED_SUPPORT */ diff --git a/src/LYStrings.c b/src/LYStrings.c index 0e4244f5..f02cff44 100644 --- a/src/LYStrings.c +++ b/src/LYStrings.c @@ -2085,9 +2085,9 @@ re_read: if (MOUSE_Y_POS > (LYlines - V_CMD_AREA)) { /* Screen BOTTOM */ if (MOUSE_X_POS < left) { - c = LTARROW; p = "<-"; + c = LTARROW; p = "<-"; } else if (MOUSE_X_POS < HIST_CMD_2) { - c = RTARROW; p = "->"; + c = RTARROW; p = "->"; } else if (MOUSE_X_POS > right) { c = 'z'; p = "Cancel"; } else { @@ -2096,9 +2096,9 @@ re_read: } else if (MOUSE_Y_POS < V_CMD_AREA) { /* Screen TOP */ if (MOUSE_X_POS < left) { - c = LTARROW; p = "<-"; + c = LTARROW; p = "<-"; } else if (MOUSE_X_POS < HIST_CMD_2) { - c = RTARROW; p = "->"; + c = RTARROW; p = "->"; } else if (MOUSE_X_POS > right) { c = 'z'; p = "Cancel"; } else { diff --git a/src/LYUpload.c b/src/LYUpload.c index 672a7b06..104d2087 100644 --- a/src/LYUpload.c +++ b/src/LYUpload.c @@ -46,7 +46,7 @@ PUBLIC int LYUpload ARGS1( int count; char *the_upload = 0; char tmpbuf[LY_MAXPATH]; - char buffer[LY_MAXPATH]; + char *filename = NULL; lynx_html_item_type *upload_command = 0; FILE *fp; char *the_command = 0; @@ -107,16 +107,16 @@ retry: HTAlert(gettext("Illegal redirection using \"~\" found! Request ignored.")); goto cancelled; } - sprintf(buffer, "%s/%s", directory, tmpbuf); + HTSprintf0(&filename, "%s/%s", directory, tmpbuf); #if HAVE_POPEN - if (LYIsPipeCommand(buffer)) { + if (LYIsPipeCommand(filename)) { HTAlert(CANNOT_WRITE_TO_FILE); _statusline(NEW_FILENAME_PROMPT); goto retry; } #endif - switch (LYValidateOutput(buffer)) { + switch (LYValidateOutput(filename)) { case 'Y': break; case 'N': @@ -128,18 +128,18 @@ retry: /* * See if we can write to it. */ - CTRACE((tfp, "LYUpload: filename is %s", buffer)); + CTRACE((tfp, "LYUpload: filename is %s", filename)); - if ((fp = fopen(buffer, "w")) != NULL) { + if ((fp = fopen(filename, "w")) != NULL) { fclose(fp); - remove(buffer); + remove(filename); } else { HTAlert(CANNOT_WRITE_TO_FILE); _statusline(NEW_FILENAME_PROMPT); goto retry; } - HTAddParam(&the_upload, upload_command->command, 1, buffer); + HTAddParam(&the_upload, upload_command->command, 1, filename); HTEndParam(&the_upload, upload_command->command, 1); } else { /* No substitution, no changes */ StrAllocCopy(the_upload, upload_command->command); @@ -158,9 +158,10 @@ retry: FREE(the_command); FREE(the_upload); #ifdef UNIX - chmod(buffer, HIDE_CHMOD); + if (filename != 0) + chmod(filename, HIDE_CHMOD); #endif /* UNIX */ - /* don't remove(file); */ + FREE(filename); return 1; diff --git a/src/LYUtils.c b/src/LYUtils.c index 31572b19..43e4292b 100644 --- a/src/LYUtils.c +++ b/src/LYUtils.c @@ -167,6 +167,15 @@ PRIVATE LY_TEMP *FindTempfileByFP ARGS1(FILE *, fp) } /* + * Get an environment variable, rejecting empty strings + */ +PRIVATE char *getenv_text ARGS1(char *, name) +{ + char *result = getenv(name); + return (result != 0 && *result != 0) ? result : 0; +} + +/* * Highlight (or unhighlight) a given link. */ PUBLIC void highlight ARGS3( @@ -2476,6 +2485,9 @@ PUBLIC int HTCheckForInterrupt NOARGS PUBLIC BOOLEAN LYisAbsPath ARGS1( char *, path) { +#ifdef VMS + return TRUE; +#else BOOLEAN result; #ifdef DOSPATH result = (BOOL) (LYIsPathSep(path[0]) @@ -2486,6 +2498,7 @@ PUBLIC BOOLEAN LYisAbsPath ARGS1( result = (LYIsPathSep(path[0])); #endif /* DOSPATH */ return result; +#endif } /* @@ -3128,7 +3141,7 @@ PUBLIC BOOLEAN LYCanDoHEAD ARGS1( if (acc_method && *acc_method) { char *proxy; StrAllocCat(acc_method, "_proxy"); - proxy = (char *)getenv(acc_method); + proxy = getenv(acc_method); if (proxy && (!strncmp(proxy, "http:", 5) || !strncmp(proxy, "lynxcgi:", 8)) && !override_proxy(temp0)) { @@ -3465,7 +3478,7 @@ PUBLIC void HTAddSugFilename ARGS1( PUBLIC void change_sug_filename ARGS1( char *, fname) { - char *temp, *cp, *cp1, *end; + char *temp = 0, *cp, *cp1, *end; #ifdef VMS char *dot; int j, k; @@ -3484,30 +3497,26 @@ PUBLIC void change_sug_filename ARGS1( /* * Rename any temporary files. */ - temp = (char *)calloc(1, (strlen(lynx_temp_space) + 60)); - if (temp == NULL) - outofmem(__FILE__, "change_sug_filename"); cp = wwwName(lynx_temp_space); #ifdef FNAMES_8_3 if (LYIsHtmlSep(*cp)) { - sprintf(temp, "file://localhost%s%04x", cp, GETPID()); + HTSprintf0(&temp, "file://localhost%s%04x", cp, GETPID()); } else { - sprintf(temp, "file://localhost/%s%04x", cp, GETPID()); + HTSprintf0(&temp, "file://localhost/%s%04x", cp, GETPID()); } #else if (LYIsHtmlSep(*cp)) { - sprintf(temp, "file://localhost%s%d", cp, (int)getpid()); + HTSprintf0(&temp, "file://localhost%s%d", cp, (int)getpid()); } else { - sprintf(temp, "file://localhost/%s%d", cp, (int)getpid()); + HTSprintf0(&temp, "file://localhost/%s%d", cp, (int)getpid()); } #endif if (!strncmp(fname, temp, strlen(temp))) { cp = strrchr(fname, '.'); if (strlen(cp) > (strlen(temp) - 4)) cp = NULL; - strcpy(temp, (cp ? cp : "")); - strcpy(fname, "temp"); - strcat(fname, temp); + StrAllocCopy(temp, (cp ? cp : "")); + sprintf(fname, "temp%.*s", LY_MAXPATH - 10, temp); } FREE(temp); @@ -4726,7 +4735,7 @@ have_VMS_URL: sprintf(buff, "'%s' not exist, Goto LynxHome '%s'.", q, p); _statusline(buff); - sleep(AlertSecs); + LYSleepAlert(); FREE(temp); StrAllocCat(*AllocatedString, p); goto Retry; @@ -5462,36 +5471,21 @@ PUBLIC CONST char * Home_Dir NOARGS char *cp = NULL; if (homedir == NULL) { - if ((cp = getenv("HOME")) == NULL || *cp == '\0' -#ifdef UNIX - || !(LYIsPathSep(*cp) -# ifdef __EMX__ - || (*cp && cp[1] == ':' && LYIsPathSep(cp[2])) -# endif - ) -#endif /* UNIX */ - ) { + if ((cp = getenv_text("HOME")) == NULL + || !LYisAbsPath(cp)) { #if defined (DOSPATH) || defined (__EMX__) /* BAD! WSB */ - if ((cp = getenv("TEMP")) == NULL || *cp == '\0') { - if ((cp = getenv("TMP")) == NULL || *cp == '\0') { - StrAllocCopy(HomeDir, "C:\\"); - } else { - StrAllocCopy(HomeDir, cp); - } - } else { - StrAllocCopy(HomeDir, cp); + if ((cp = getenv_text("TEMP")) == NULL + && (cp = getenv_text("TMP")) == NULL) { + cp = "C:\\"; } + StrAllocCopy(HomeDir, cp); #else #ifdef VMS - if ((cp = getenv("SYS$LOGIN")) == NULL || *cp == '\0') { - if ((cp = getenv("SYS$SCRATCH")) == NULL || *cp == '\0') { - StrAllocCopy(HomeDir, "sys$scratch:"); - } else { - StrAllocCopy(HomeDir, cp); - } - } else { - StrAllocCopy(HomeDir, cp); + if ((cp = getenv_text("SYS$LOGIN")) == NULL + && (cp = getenv_text("SYS$SCRATCH")) == NULL) { + cp = "sys$scratch:"; } + StrAllocCopy(HomeDir, cp); #else #if HAVE_UTMP /* @@ -5516,6 +5510,14 @@ PUBLIC CONST char * Home_Dir NOARGS #endif /* VMS */ #endif /* DOSPATH */ } else { +#if defined(_WINDOWS) || defined(DOSPATH) + char *hp = getenv_text("HOMEDRIVE"); + if (hp != 0 + && (LYIsPathSep(*cp) || !LYisAbsPath(cp))) { + StrAllocCopy(HomeDir, hp); + StrAllocCat(HomeDir, cp); + } else +#endif StrAllocCopy(HomeDir, cp); } homedir = (CONST char *)HomeDir; @@ -5817,11 +5819,8 @@ PUBLIC void LYAddPathToHome ARGS3( * SHELL syntax and append subdirectory path, * then convert that to VMS syntax. - FM */ - char *temp = (char *)calloc(1, - (strlen(home) + strlen(file) + 10)); - if (temp == NULL) - outofmem(__FILE__, "LYAddPathToHome"); - sprintf(temp, "%s%s", HTVMS_wwwName(home), (file + 1)); + char *temp = NULL; + HTSprintf0(&temp, "%s%s", HTVMS_wwwName(home), (file + 1)); sprintf(fbuffer, "%.*s", (fbuffer_size - 1), HTVMS_name("", temp)); FREE(temp); @@ -7031,12 +7030,17 @@ PUBLIC BOOLEAN LYValidateFilename ARGS2( #endif /* __EMX__*/ cp = NULL; + *result = 0; if (cp) { LYTrimPathSep(cp); - sprintf(result, "%s/%s", cp, HTSYS_name(given)); - } else { - strcpy(result, HTSYS_name(given)); + if (strlen(cp) >= LY_MAXPATH - 2) + return FALSE; + sprintf(result, "%s/", cp); } + cp = HTSYS_name(given); + if (strlen(result) + strlen(cp) >= LY_MAXPATH - 1) + return FALSE; + strcat(result, cp); #endif /* VMS */ return TRUE; } @@ -7426,7 +7430,7 @@ PUBLIC int LYSystem ARGS1( if (strchr(p, '\\') == NULL) { /* for Windows Application */ cygwin_conv_to_full_win32_path(p, win32_name); - sprintf(new_command, "%s \"%s\"", new_cmd, win32_name); + sprintf(new_command, "%.*s \"%.*s\"", LY_MAXPATH, new_cmd, LY_MAXPATH, win32_name); } else { /* for DOS like editor */ q = win32_name; @@ -7439,7 +7443,7 @@ PUBLIC int LYSystem ARGS1( q++, p++; } *q = '\0'; - sprintf(new_command, "%s %s", new_cmd, win32_name); + sprintf(new_command, "%.*s %.*s", LY_MAXPATH, new_cmd, LY_MAXPATH, win32_name); } command = new_command; } @@ -7502,7 +7506,7 @@ PUBLIC int Cygwin_Shell NOARGS /* Init a startup structure */ GetStartupInfo(&startUpInfo); - shell = getenv("COMSPEC"); + shell = getenv_text("COMSPEC"); /* Create the child process, specifying inherited handles. Pass the value of the @@ -7531,10 +7535,10 @@ PUBLIC char *LYSysShell NOARGS char *shell = 0; #ifdef DOSPATH #ifdef WIN_EX - shell = getenv("SHELL"); + shell = getenv_text("SHELL"); if (shell) { if (access(shell, 0) != 0) - shell = getenv("COMSPEC"); + shell = getenv_text("COMSPEC"); } if (shell == NULL) { if (system_is_NT) @@ -7543,9 +7547,9 @@ PUBLIC char *LYSysShell NOARGS shell = "command.com"; } #else - shell = getenv("SHELL"); + shell = getenv_text("SHELL"); if (shell == NULL) { - shell = getenv("COMSPEC"); + shell = getenv_text("COMSPEC"); } if (shell == NULL) { shell = "command.com"; @@ -7553,10 +7557,10 @@ PUBLIC char *LYSysShell NOARGS #endif /* WIN_EX */ #else #ifdef __EMX__ - if (getenv("SHELL") != NULL) { - shell = getenv("SHELL"); + if (getenv_text("SHELL") != NULL) { + shell = getenv_text("SHELL"); } else { - shell = (getenv("COMSPEC") == NULL) ? "cmd.exe" : getenv("COMSPEC"); + shell = (getenv_text("COMSPEC") == NULL) ? "cmd.exe" : getenv_text("COMSPEC"); } #else #ifdef VMS @@ -7581,7 +7585,7 @@ PUBLIC char *LYSysShell NOARGS PUBLIC char *LYgetXDisplay NOARGS { char *cp; - if ((cp = getenv(DISPLAY)) == NULL || *cp == '\0') + if ((cp = getenv_text(DISPLAY)) == NULL) cp = 0; return cp; } @@ -7599,11 +7603,8 @@ PUBLIC void LYsetXDisplay ARGS1( Define_VMSLogical(DISPLAY, new_display); #else static char *display_putenv_command; - display_putenv_command = malloc(strlen(new_display) + 12); - if (!display_putenv_command) - outofmem(__FILE__, "LYsetXDisplay"); - sprintf(display_putenv_command, "DISPLAY=%s", new_display); + HTSprintf0(&display_putenv_command, "DISPLAY=%s", new_display); putenv(display_putenv_command); #endif /* VMS */ if ((new_display = LYgetXDisplay()) != 0) { diff --git a/src/LYexit.c b/src/LYexit.c index 9d4fd0f2..02ad6fa6 100644 --- a/src/LYexit.c +++ b/src/LYexit.c @@ -3,6 +3,7 @@ */ #include <HTUtils.h> #include <LYexit.h> +#include <HTAlert.h> #ifndef VMS #include <LYGlobalDefs.h> #include <LYUtils.h> @@ -124,7 +125,7 @@ PUBLIC void LYexit ARGS1( * Deal with curses, if on, and clean up. - FM */ if (LYCursesON) { - sleep(AlertSecs); + LYSleepAlert(); } cleanup_sig(0); #ifndef __linux__ diff --git a/src/LYrcFile.c b/src/LYrcFile.c index d03f49d0..de97c538 100644 --- a/src/LYrcFile.c +++ b/src/LYrcFile.c @@ -17,10 +17,60 @@ #define FNAME_LYNXRC ".lynxrc" #endif /* FNAMES_8_3 */ +typedef struct +{ + CONST char *name; + int value; +} +Config_Enum; + #define FIND_KEYWORD(cp, keyword) \ ((cp = LYstrstr(line_buffer, keyword)) != NULL && \ (cp - line_buffer) < number_sign) +#define putBool(value) ((value) ? "on" : "off") + +#ifdef DIRED_SUPPORT +static Config_Enum dir_list_style_tbl[] = { + { "FILES_FIRST", FILES_FIRST }, + { "DIRECTORIES_FIRST", 0 }, + { "MIXED_STYLE", MIXED_STYLE }, + { NULL, -1 }, +}; +#endif + +static Config_Enum file_sort_tbl[] = { + { "BY_FILENAME", FILE_BY_NAME }, + { "BY_TYPE", FILE_BY_TYPE }, + { "BY_SIZE", FILE_BY_SIZE }, + { "BY_DATE", FILE_BY_DATE }, + { NULL, -1 }, +}; + +static Config_Enum keypad_mode_tbl[] = { + { "LINKS_AND_FIELDS_ARE_NUMBERED", LINKS_AND_FIELDS_ARE_NUMBERED }, + { "LINKS_AND_FORM_FIELDS_ARE_NUMBERED", LINKS_AND_FIELDS_ARE_NUMBERED }, + { "LINKS_ARE_NUMBERED", LINKS_ARE_NUMBERED }, + { "NUMBERS_AS_ARROWS", NUMBERS_AS_ARROWS }, + { NULL, -1 } +}; + +static Config_Enum user_mode_tbl[] = { + { "ADVANCED", ADVANCED_MODE }, + { "INTERMEDIATE", INTERMEDIATE_MODE }, + { "NOVICE", NOVICE_MODE }, + { NULL, -1 } +}; + +static Config_Enum visited_links_tbl[] = { + { "FIRST_REVERSED", VISITED_LINKS_AS_FIRST_V | VISITED_LINKS_REVERSE }, + { "FIRST", VISITED_LINKS_AS_FIRST_V }, + { "TREE", VISITED_LINKS_AS_TREE }, + { "LAST_REVERSED", VISITED_LINKS_AS_LATEST | VISITED_LINKS_REVERSE }, + { "LAST", VISITED_LINKS_AS_LATEST }, + { NULL, -1 } +}; + PRIVATE char *SkipEquals ARGS1(char *, src) { char *tmp; @@ -29,6 +79,41 @@ PRIVATE char *SkipEquals ARGS1(char *, src) return LYSkipBlanks(src); } +PRIVATE BOOL getBool ARGS1(char *, src) +{ + src = SkipEquals(src); + return (!strncasecomp(src, "on", 2) || !strncasecomp(src, "true", 4)); +} + +PRIVATE CONST char *putEnum ARGS2( + Config_Enum *, table, + int, value) +{ + while (table->name != 0) { + if (table->value == value) { + return table->name; + } + table++; + } + return "?"; +} + +PRIVATE BOOL getEnum ARGS3( + Config_Enum *, table, + char *, src, + int *, value) +{ + src = SkipEquals(src); + while (table->name != 0) { + if (!strncasecomp(table->name, src, strlen(table->name))) { + *value = table->value; + return TRUE; + } + table++; + } + return FALSE; +} + /* Read and process user options. * If the passed-in fp is NULL, open the regular user defaults file * for reading, otherwise use fp which has to be a file open for @@ -195,15 +280,7 @@ PUBLIC void read_rc ARGS1(FILE *, fp) */ } else if (FIND_KEYWORD(cp, "file_sorting_method")) { - cp = SkipEquals(cp); - if (!strncasecomp(cp, "BY_FILENAME", 11)) - HTfileSortMethod = FILE_BY_NAME; - else if (!strncasecomp(cp, "BY_TYPE", 7)) - HTfileSortMethod = FILE_BY_TYPE; - else if (!strncasecomp(cp, "BY_SIZE", 7)) - HTfileSortMethod = FILE_BY_SIZE; - else if (!strncasecomp(cp, "BY_DATE", 7)) - HTfileSortMethod = FILE_BY_DATE; + getEnum(file_sort_tbl, cp, &HTfileSortMethod); /* * Personal mail address. @@ -218,11 +295,7 @@ PUBLIC void read_rc ARGS1(FILE *, fp) */ } else if (FIND_KEYWORD(cp, "case_sensitive_searching")) { - cp = SkipEquals(cp); - if (!strncasecomp(cp, "on", 2)) - case_sensitive = TRUE; - else - case_sensitive = FALSE; + case_sensitive = getBool(cp); /* * Character set. @@ -260,33 +333,21 @@ PUBLIC void read_rc ARGS1(FILE *, fp) */ } else if (FIND_KEYWORD(cp, "vi_keys")) { - cp = SkipEquals(cp); - if (!strncasecomp(cp, "on", 2)) - vi_keys = TRUE; - else - vi_keys = FALSE; + vi_keys = getBool(cp); /* * EMACS keys. */ } else if (FIND_KEYWORD(cp, "emacs_keys")) { - cp = SkipEquals(cp); - if (!strncasecomp(cp, "on", 2)) - emacs_keys = TRUE; - else - emacs_keys=FALSE; + emacs_keys = getBool(cp); /* * Show dot files. */ } else if (FIND_KEYWORD(cp, "show_dotfiles")) { - cp = SkipEquals(cp); - if (!strncasecomp(cp, "on", 2)) - show_dotfiles = TRUE; - else - show_dotfiles = FALSE; + show_dotfiles = getBool(cp); /* * Show color. @@ -335,13 +396,8 @@ PUBLIC void read_rc ARGS1(FILE *, fp) */ } else if (FIND_KEYWORD(cp, "keypad_mode")) { - cp = SkipEquals(cp); - if (LYstrstr(cp, "LINKS_ARE_NUMBERED")) - keypad_mode = LINKS_ARE_NUMBERED; - else if (LYstrstr(cp, "LINKS_AND_FORM_FIELDS_ARE_NUMBERED")) - keypad_mode = LINKS_AND_FIELDS_ARE_NUMBERED; - else - keypad_mode = NUMBERS_AS_ARROWS; + if (!getEnum(keypad_mode_tbl, cp, &keypad_mode)) + keypad_mode = DEFAULT_KEYPAD_MODE; /* * Keyboard layout. @@ -381,27 +437,15 @@ PUBLIC void read_rc ARGS1(FILE *, fp) */ } else if (FIND_KEYWORD(cp, "dir_list_style")) { - cp = SkipEquals(cp); - if (LYstrstr(cp, "FILES_FIRST") != NULL) { - dir_list_style = FILES_FIRST; - } else if (LYstrstr(cp,"DIRECTORIES_FIRST") != NULL) { - dir_list_style = 0; - } else { + if (!getEnum(dir_list_style_tbl, cp, &dir_list_style)) dir_list_style = MIXED_STYLE; - } #endif /* DIRED_SUPPORT */ /* * Accept cookies from all domains? */ } else if (FIND_KEYWORD(cp, "accept_all_cookies")) { - cp = SkipEquals(cp); - if (LYstrstr(cp,"TRUE") != NULL) { - LYAcceptAllCookies = TRUE; - } else { - LYAcceptAllCookies = FALSE; - } - + LYAcceptAllCookies = getBool(cp); /* * Accept all cookies from certain domains? @@ -464,14 +508,8 @@ PUBLIC void read_rc ARGS1(FILE *, fp) */ } else if (FIND_KEYWORD(cp, "user_mode")) { - cp = SkipEquals(cp); - if (LYstrstr(cp, "ADVANCED") != NULL) { - user_mode = ADVANCED_MODE; - } else if (LYstrstr(cp,"INTERMEDIATE") != NULL) { - user_mode = INTERMEDIATE_MODE; - } else { + if (!getEnum(user_mode_tbl, cp, &user_mode)) user_mode = NOVICE_MODE; - } #ifdef NOTUSED #ifdef DISP_PARTIAL @@ -492,29 +530,21 @@ PUBLIC void read_rc ARGS1(FILE *, fp) */ } else if (FIND_KEYWORD(cp, "run_all_execution_links")) { - cp = SkipEquals(cp); - if (!strncasecomp(cp, "on", 2)) - local_exec = TRUE; - else - local_exec = FALSE; + local_exec = getBool(cp); /* * Local execution mode - only links in local files. */ } else if (FIND_KEYWORD(cp, "run_execution_links_on_local_files")) { - cp = SkipEquals(cp); - if (!strncasecomp(cp, "on", 2)) - local_exec_on_local_files = TRUE; - else - local_exec_on_local_files=FALSE; + local_exec_on_local_files = getBool(cp); #endif /* ENABLE_OPTS_CHANGE_EXEC */ } else if (FIND_KEYWORD(cp, "verbose_images")) { - cp = SkipEquals(cp); - if (!strncasecomp(cp, "on", 2)) - verbose_img = 1; - else if (!strncasecomp(cp, "off", 3)) - verbose_img = 0; + verbose_img = getBool(cp); + + } else if (FIND_KEYWORD(cp, "visited_links")) { + if (!getEnum(visited_links_tbl, cp, &Visited_Links_As)) + Visited_Links_As = DEFAULT_VISITED_LINKS; } /* end of if */ @@ -661,12 +691,7 @@ file lists such as FTP directories. The options are:\n\ BY_DATE -- sorts on the date of the file\n\ ")); fprintf(fp, "file_sorting_method=%s\n\n", - (HTfileSortMethod == FILE_BY_NAME ? "BY_FILENAME" - : - (HTfileSortMethod == FILE_BY_SIZE ? "BY_SIZE" - : - (HTfileSortMethod == FILE_BY_TYPE ? "BY_TYPE" - : "BY_DATE")))); + putEnum(file_sort_tbl, HTfileSortMethod)); /* * Personal mail address. @@ -691,8 +716,7 @@ If case_sensitive_searching is \"on\" then when the user invokes a search\n\ using the 's' or '/' keys, the search performed will be case sensitive\n\ instead of case INsensitive. The default is usually \"off\".\n\ ")); - fprintf(fp, "case_sensitive_searching=%s\n\n", - (case_sensitive ? "on" : "off")); + fprintf(fp, "case_sensitive_searching=%s\n\n", putBool(case_sensitive)); /* * Character set. @@ -779,7 +803,7 @@ will be enabled. These keys are only lower case.\n\ Capital 'H', 'J' and 'K will still activate help, jump shortcuts,\n\ and the keymap display, respectively.\n\ ")); - fprintf(fp, "vi_keys=%s\n\n", (vi_keys ? "on" : "off")); + fprintf(fp, "vi_keys=%s\n\n", putBool(vi_keys)); /* * EMACS keys. @@ -790,7 +814,7 @@ If emacs_keys is to \"on\" then the normal EMACS movement keys:\n\ ^B = left ^F = right\n\ will be enabled.\n\ ")); - fprintf(fp, "emacs_keys=%s\n\n", (emacs_keys ? "on" : "off")); + fprintf(fp, "emacs_keys=%s\n\n", putBool(emacs_keys)); /* * Show dot files. @@ -802,7 +826,7 @@ honored only if enabled via userdefs.h and/or lynx.cfg, and not\n\ restricted via a command line switch. If display of hidden files\n\ is disabled, creation of such files via Lynx also is disabled.\n\ ")); - fprintf(fp, "show_dotfiles=%s\n\n", (show_dotfiles ? "on" : "off")); + fprintf(fp, "show_dotfiles=%s\n\n", putBool(show_dotfiles)); /* * Select popups. @@ -816,7 +840,7 @@ of checkboxes for the OPTIONs. A value of \"on\" will set popup menus\n\ as the default while a value of \"off\" will set use of radio boxes.\n\ The default can be overridden via the -popup command line toggle.\n\ ")); - fprintf(fp, "select_popups=%s\n\n", (LYSelectPopups ? "on" : "off")); + fprintf(fp, "select_popups=%s\n\n", putBool(LYSelectPopups)); /* * Show cursor. @@ -832,7 +856,7 @@ or color. A value of \"on\" will set positioning to the left as the\n\ default while a value of \"off\" will set 'hiding' of the cursor.\n\ The default can be overridden via the -show_cursor command line toggle.\n\ ")); - fprintf(fp, "show_cursor=%s\n\n", (LYShowCursor ? "on" : "off")); + fprintf(fp, "show_cursor=%s\n\n", putBool(LYShowCursor)); /* * Keypad mode. @@ -864,10 +888,7 @@ NOTE: Some fixed format documents may look disfigured when\n\ \"LINKS_ARE_NUMBERED\" or \"LINKS_AND_FORM_FIELDS_ARE_NUMBERED\" are\n\ enabled.\n\ ")); - fprintf(fp, "keypad_mode=%s\n\n", - ((keypad_mode == NUMBERS_AS_ARROWS) ? "NUMBERS_AS_ARROWS" : - ((keypad_mode == LINKS_ARE_NUMBERED) ? "LINKS_ARE_NUMBERED" : - "LINKS_AND_FORM_FIELDS_ARE_NUMBERED"))); + fprintf(fp, "keypad_mode=%s\n\n", putEnum(keypad_mode_tbl, keypad_mode)); #ifdef NOTUSED #ifdef DISP_PARTIAL @@ -924,10 +945,7 @@ files and directories together. \"FILES_FIRST\" lists files first and\n\ \"DIRECTORIES_FIRST\" lists directories first.\n\ ")); fprintf(fp, "dir_list_style=%s\n\n", - (dir_list_style==FILES_FIRST ? "FILES_FIRST" - : - (dir_list_style==MIXED_STYLE ? "MIXED_STYLE" - : "DIRECTORIES_FIRST"))); + putEnum(dir_list_style_tbl, dir_list_style)); #endif /* DIRED_SUPPORT */ /* @@ -942,9 +960,7 @@ Use \"ADVANCED\" to see the URL of the currently selected link at the\n\ bottom of the screen.\n\ ")); fprintf(fp, "user_mode=%s\n\n", - (user_mode == NOVICE_MODE ? "NOVICE" : - (user_mode == ADVANCED_MODE ? - "ADVANCED" : "INTERMEDIATE"))); + putEnum(user_mode_tbl, user_mode)); /* * Cookie options @@ -955,8 +971,7 @@ accept all cookies if desired. The default is \"FALSE\" which will\n\ prompt for each cookie. Set accept_all_cookies to \"TRUE\" to accept\n\ all cookies.\n\ ")); - fprintf(fp, "accept_all_cookies=%s\n\n", - (LYAcceptAllCookies == FALSE ? "FALSE" : "TRUE")); + fprintf(fp, "accept_all_cookies=%s\n\n", putBool(LYAcceptAllCookies)); write_list(fp, gettext("\ cookie_accept_domains and cookie_reject_domains are comma-delimited\n\ @@ -1022,8 +1037,7 @@ WARNING - This is potentially VERY dangerous. Since you may view\n\ or compromise security. This should only be set to \"on\" if\n\ you are viewing trusted source information.\n\ ")); - fprintf(fp, "run_all_execution_links=%s\n\n", - (local_exec ? "on" : "off")); + fprintf(fp, "run_all_execution_links=%s\n\n", putBool(local_exec)); /* * Local execution mode - only links in local files. @@ -1043,7 +1057,7 @@ WARNING - This is potentially dangerous. Since you may view\n\ you are viewing trusted source information.\n\ ")); fprintf(fp, "run_execution_links_on_local_files=%s\n\n", - (local_exec_on_local_files ? "on" : "off")); + putBool(local_exec_on_local_files)); #endif /* defined(EXEC_LINKS) || defined(EXEC_SCRIPTS) */ write_list(fp, gettext("\ @@ -1051,8 +1065,14 @@ If verbose_images is \"on\", lynx will print the name of the image\n\ source file in place of [INLINE], [LINK] or [IMAGE]\n\ See also VERBOSE_IMAGES in lynx.cfg\n\ ")); - fprintf(fp, "verbose_images=%s\n\n", - verbose_img ? "on" : "off"); + fprintf(fp, "verbose_images=%s\n\n", putBool(verbose_img)); + + write_list(fp, gettext("\ +The visited_links setting controls how Lynx organizes the information\n\ +in the Visited Links Page.\n\ +")); + fprintf(fp, "visited_links=%s\n\n", + putEnum(visited_links_tbl, Visited_Links_As)); /* * Close the RC file. diff --git a/src/chrtrans/makefile.dos b/src/chrtrans/makefile.dos index 369246ac..3ba32967 100644 --- a/src/chrtrans/makefile.dos +++ b/src/chrtrans/makefile.dos @@ -12,7 +12,7 @@ CFLAGS = $(MCFLAGS) CC = gcc -MCFLAGS = -O3 -DDOSPATH -DNO_TTYTYP \ +MCFLAGS = -O1 -DDOSPATH -DNO_TTYTYP \ -I. \ -I../../WWW/Library/Implementation \ -I../../djgpp/watt32/inc \ |