aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>1998-09-13 14:41:19 -0400
committerThomas E. Dickey <dickey@invisible-island.net>1998-09-13 14:41:19 -0400
commit02f2851492143446abaaa33cc9536fade7b51124 (patch)
tree613e06824c47ca1592dd53eab57ed1ddb1409404 /src
parent5816641fc3a761e00d154c4dea9551a0027a7c63 (diff)
downloadlynx-snapshots-02f2851492143446abaaa33cc9536fade7b51124.tar.gz
snapshot of project "lynx", label v2-8-1dev_26
Diffstat (limited to 'src')
-rw-r--r--src/AttrList.h2
-rw-r--r--src/GridText.c30
-rw-r--r--src/HTInit.c21
-rw-r--r--src/HTML.c61
-rw-r--r--src/LYCharSets.c248
-rw-r--r--src/LYCharSets.h5
-rw-r--r--src/LYCharUtils.c104
-rw-r--r--src/LYCookie.c49
-rw-r--r--src/LYCurses.c4
-rw-r--r--src/LYCurses.h15
-rw-r--r--src/LYForms.c2
-rw-r--r--src/LYGlobalDefs.h5
-rw-r--r--src/LYKeymap.c2
-rw-r--r--src/LYMail.c2
-rw-r--r--src/LYMain.c130
-rw-r--r--src/LYMainLoop.c7
-rw-r--r--src/LYOptions.c52
-rw-r--r--src/LYPrint.c18
-rw-r--r--src/LYPrint.h4
-rw-r--r--src/LYReadCFG.c20
-rw-r--r--src/LYShowInfo.c46
-rw-r--r--src/LYStrings.c674
-rw-r--r--src/LYStrings.h4
-rw-r--r--src/LYUtils.c50
-rw-r--r--src/LYUtils.h3
-rw-r--r--src/LYrcFile.c33
-rw-r--r--src/UCAux.c23
-rw-r--r--src/UCdomap.c47
28 files changed, 979 insertions, 682 deletions
diff --git a/src/AttrList.h b/src/AttrList.h
index cacb02e4..b58456ff 100644
--- a/src/AttrList.h
+++ b/src/AttrList.h
@@ -56,7 +56,7 @@ typedef struct _linkedlist {
} linked_list;
#endif
-#define HText_characterStyle if(TRACE)fprintf(stderr,"HTC called from %s/%d\n",__FILE__,__LINE__);_internal_HTC
+#define HText_characterStyle CTRACE(tfp,"HTC called from %s/%d\n",__FILE__,__LINE__);_internal_HTC
#undef HText_characterStyle
#define HText_characterStyle _internal_HTC
diff --git a/src/GridText.c b/src/GridText.c
index 5d7d2e0f..be443759 100644
--- a/src/GridText.c
+++ b/src/GridText.c
@@ -3200,7 +3200,6 @@ PRIVATE void remove_special_attr_chars ARGS1(
PUBLIC void HText_endAppend ARGS1(
HText *, text)
{
- int cur_line, cur_char, cur_shift;
HTLine *line_ptr;
if (!text)
@@ -3227,9 +3226,6 @@ PUBLIC void HText_endAppend ARGS1(
* Get the first line.
*/
line_ptr = text->last_line->next;
- cur_char = line_ptr->size;
- cur_line = 0;
- cur_shift = 0;
/*
* Remove the blank lines at the end of document.
@@ -3256,9 +3252,10 @@ PUBLIC void HText_endAppend ARGS1(
* Fix up the anchor structure values and
* create the hightext strings. - FM
*/
- HText_trimHightext(HTMainText, FALSE);
+ HText_trimHightext(text, FALSE);
}
+
/*
** This function gets the hightext from the text by finding the char
** position, and brings the anchors in line with the text by adding the text
@@ -4071,15 +4068,19 @@ PUBLIC void HText_pageDisplay ARGS2(
CTRACE(tfp, "GridText: HText_pageDisplay at line %d started\n", line_num);
#ifdef DISP_PARTIAL
- if (display_partial && !debug_display_partial)
+ if (display_partial && detected_forms_input_partial) {
/*
** Garbage is reported from forms input fields in incremental mode.
** So we start HText_trimHightext() to forget this side effect.
** This function was split-out from HText_endAppend().
** It may not be the best solution but it works. - LP
** (TRUE = to disable annoying repeated trace messages)
+ **
+ ** Side effect is reported from multiply call of HText_trimHightext.
*/
HText_trimHightext(HTMainText, TRUE);
+ }
+ detected_forms_input_partial = FALSE;
#endif
display_page(HTMainText, line_num-1, target);
@@ -6343,6 +6344,11 @@ PUBLIC int HText_beginInput ARGS3(
CTRACE(tfp,"Entering HText_beginInput\n");
+#ifdef DISP_PARTIAL
+ if (display_partial)
+ detected_forms_input_partial = TRUE; /* trimHightext temp fix */
+#endif
+
if (a == NULL || f == NULL)
outofmem(__FILE__, "HText_beginInput");
@@ -7043,16 +7049,10 @@ PUBLIC void HText_SubmitForm ARGS4(
HTMainText->node_anchor->charset &&
*HTMainText->node_anchor->charset) {
target_cs = UCGetLYhndl_byMIME(HTMainText->node_anchor->charset);
- if (target_cs >= 0) {
- target_csname = HTMainText->node_anchor->charset;
- } else {
- target_cs = UCLYhndl_for_unspec;
- if (target_cs >= 0)
- target_csname = LYCharSet_UC[target_cs].MIMEname;
+ if (target_cs < 0) {
+ target_cs = UCLYhndl_for_unspec; /* always >= 0 */
}
- }
- if (target_cs < 0) {
- target_cs = UCLYhndl_for_unspec;
+ target_csname = LYCharSet_UC[target_cs].MIMEname;
}
/*
diff --git a/src/HTInit.c b/src/HTInit.c
index aac98355..9e6eccf1 100644
--- a/src/HTInit.c
+++ b/src/HTInit.c
@@ -160,13 +160,8 @@ PUBLIC void HTFormatInit NOARGS
/* These should override everything else. */
HTLoadTypesConfigFile(personal_type_map);
} else {
- char buffer[256];
-#ifdef VMS
- sprintf(buffer, "sys$login:%s", personal_type_map);
-#else
- sprintf(buffer, "%s/%s", (Home_Dir() ? Home_Dir() : ""),
- personal_type_map);
-#endif
+ char buffer[LY_MAXPATH];
+ LYAddPathToHome(buffer, sizeof(buffer), personal_type_map);
HTLoadTypesConfigFile(buffer);
}
@@ -227,7 +222,6 @@ PRIVATE int ExitWithError PARAMS((char *txt));
PRIVATE int PassesTest PARAMS((struct MailcapEntry *mc));
#define LINE_BUF_SIZE 2048
-#define TMPFILE_NAME_SIZE 256
PRIVATE char *GetCommand ARGS2(
char *, s,
@@ -482,7 +476,7 @@ PRIVATE int PassesTest ARGS1(
struct MailcapEntry *, mc)
{
int result;
- char *cmd, TmpFileName[TMPFILE_NAME_SIZE];
+ char *cmd, TmpFileName[LY_MAXPATH];
/*
* Make sure we have a command
@@ -852,13 +846,8 @@ PUBLIC void HTFileInit NOARGS
/* These should override everything else. */
HTLoadExtensionsConfigFile(personal_extension_map);
} else {
- char buffer[256];
-#ifdef VMS
- sprintf(buffer, "sys$login:%s", personal_extension_map);
-#else
- sprintf(buffer, "%s/%s", (Home_Dir() ? Home_Dir() : ""),
- personal_extension_map);
-#endif /* VMS */
+ char buffer[LY_MAXPATH];
+ LYAddPathToHome(buffer, sizeof(buffer), personal_extension_map);
/* These should override everything else. */
HTLoadExtensionsConfigFile(buffer);
}
diff --git a/src/HTML.c b/src/HTML.c
index ac10f00e..c54761d6 100644
--- a/src/HTML.c
+++ b/src/HTML.c
@@ -113,8 +113,9 @@ PRIVATE void change_paragraph_style PARAMS((HTStructured * me,
#define VERBOSE_IMG(value,src_type,string) \
((verbose_img) ? (newtitle = MakeNewTitle(value,src_type)): string)
-PRIVATE char * MakeNewTitle PARAMS((CONST char ** value, int src_type));
-PRIVATE char * MakeNewImageValue PARAMS((CONST char ** value));
+PRIVATE char* MakeNewTitle PARAMS((CONST char ** value, int src_type));
+PRIVATE char* MakeNewImageValue PARAMS((CONST char ** value));
+PRIVATE char* MakeNewMapValue PARAMS((const char ** value, const char* mapstr));
/* Set an internal flag that the next call to a stack-affecting method
** is only internal and the stack manipulation should be skipped. - kw
@@ -636,7 +637,7 @@ PRIVATE void HTML_start_element ARGS6(
char *I_value = NULL;
char *I_name = NULL;
char *temp = NULL;
- int dest_char_set = -1;
+ int dest_char_set = UCLYhndl_for_unrec;
HTParentAnchor *dest = NULL; /* An anchor's destination */
BOOL dest_ismap = FALSE; /* Is dest an image map script? */
BOOL UseBASE = TRUE; /* Resoved vs. BASE if present? */
@@ -1096,12 +1097,13 @@ PRIVATE void HTML_start_element ARGS6(
dest_char_set = UCGetLYhndl_byMIME(value[HTML_LINK_CHARSET]);
if (dest_char_set < 0)
dest_char_set = UCLYhndl_for_unrec;
+ if (dest_char_set < 0) /* recover if not defined :-( */
+ dest_char_set = UCLYhndl_for_unspec; /* always >= 0 */
}
- if (dest && dest_char_set >= 0)
+ if (dest)
HTAnchor_setUCInfoStage(dest, dest_char_set,
UCT_STAGE_PARSER,
UCT_SETBY_LINK);
- dest_char_set = -1;
}
UPDATE_STYLE;
if (!HText_hasToolbar(me->text) &&
@@ -2532,6 +2534,8 @@ PRIVATE void HTML_start_element ARGS6(
dest_char_set = UCGetLYhndl_byMIME(temp);
if (dest_char_set < 0) {
dest_char_set = UCLYhndl_for_unrec;
+ if (dest_char_set < 0) /* recover if not defined :-( */
+ dest_char_set = UCLYhndl_for_unspec; /* always >= 0 */
}
}
if (title != NULL || dest_ismap == TRUE || dest_char_set >= 0) {
@@ -2543,7 +2547,7 @@ PRIVATE void HTML_start_element ARGS6(
HTAnchor_setTitle(dest, title);
if (dest && dest_ismap)
dest->isISMAPScript = TRUE;
- if (dest && dest_char_set >= 0) {
+ if (dest) {
/*
** Load the anchor's chartrans structures.
** This should be done more intelligently
@@ -2560,7 +2564,6 @@ PRIVATE void HTML_start_element ARGS6(
FREE(temp);
dest = NULL;
dest_ismap = FALSE;
- dest_char_set = -1;
FREE(title);
}
me->CurrentANum = HText_beginAnchor(me->text,
@@ -2732,11 +2735,11 @@ PRIVATE void HTML_start_element ARGS6(
LYTrimTail(alt_string);
if (*alt_string == '\0') {
if (map_href) {
- StrAllocCopy(alt_string, (title ?
- title : "[USEMAP]"));
+ StrAllocCopy(alt_string, (title ? title :
+ MakeNewMapValue(value,"USEMAP")));
} else if (dest_ismap) {
- StrAllocCopy(alt_string, (title ?
- title : "[ISMAP]"));
+ StrAllocCopy(alt_string, (title ? title :
+ MakeNewMapValue(value,"ISMAP")));
} else if (me->inA == TRUE && dest) {
StrAllocCopy(alt_string, (title ?
@@ -2755,13 +2758,13 @@ PRIVATE void HTML_start_element ARGS6(
}
} else if (map_href) {
- StrAllocCopy(alt_string, (title ?
- title : "[USEMAP]"));
+ StrAllocCopy(alt_string, (title ? title :
+ MakeNewMapValue(value,"USEMAP")));
} else if ((dest_ismap == TRUE) ||
(me->inA && present && present[HTML_IMG_ISMAP])) {
- StrAllocCopy(alt_string, (title ?
- title : "[ISMAP]"));
+ StrAllocCopy(alt_string, (title ? title :
+ MakeNewMapValue(value,"ISMAP")));
} else if (me->inA == TRUE && dest) {
StrAllocCopy(alt_string, (title ?
@@ -2780,7 +2783,7 @@ PRIVATE void HTML_start_element ARGS6(
title : ""));
}
if (*alt_string == '\0' && map_href) {
- StrAllocCopy(alt_string, "[USEMAP]");
+ StrAllocCopy(alt_string, MakeNewMapValue(value,"USEMAP"));
}
CTRACE(tfp, "HTML IMG: USEMAP=%d ISMAP=%d ANCHOR=%d PARA=%d\n",
@@ -2842,7 +2845,7 @@ PRIVATE void HTML_start_element ARGS6(
if (dest_ismap) {
HTML_put_character(me, ' ');
me->in_word = NO;
- HTML_put_string(me, "[ISMAP]");
+ HTML_put_string(me, MakeNewMapValue(value,"ISMAP"));
} else if (dest) {
HTML_put_character(me, ' ');
me->in_word = NO;
@@ -3010,7 +3013,7 @@ PRIVATE void HTML_start_element ARGS6(
if (dest_ismap) {
HTML_put_character(me, ' ');/* space char may be ignored */
me->in_word = NO;
- HTML_put_string(me, "[ISMAP]");
+ HTML_put_string(me, MakeNewMapValue(value,"ISMAP"));
} else if (dest) {
HTML_put_character(me, ' ');/* space char may be ignored */
me->in_word = NO;
@@ -7447,7 +7450,6 @@ PUBLIC int HTLoadError ARGS3(
return -number;
}
-
PRIVATE char * MakeNewTitle ARGS2(CONST char **, value, int, src_type)
{
char *ptr;
@@ -7463,6 +7465,7 @@ PRIVATE char * MakeNewTitle ARGS2(CONST char **, value, int, src_type)
StrAllocCat(newtitle, "]");
return newtitle;
}
+
PRIVATE char * MakeNewImageValue ARGS1(CONST char **, value)
{
char *ptr;
@@ -7478,3 +7481,23 @@ PRIVATE char * MakeNewImageValue ARGS1(CONST char **, value)
StrAllocCat(newtitle, "]-Submit");
return newtitle;
}
+
+PRIVATE char * MakeNewMapValue ARGS2(const char **, value, const char*, mapstr)
+{
+ char *ptr;
+ char *newtitle = NULL;
+
+ StrAllocCopy(newtitle, "[");
+ StrAllocCat(newtitle,mapstr); /* ISMAP or USEMAP */
+ if ( verbose_img ) {
+ StrAllocCat(newtitle,":");
+ ptr = strrchr(value[HTML_IMG_SRC], '/');
+ if (!ptr) {
+ StrAllocCat(newtitle, value[HTML_IMG_SRC]);
+ } else {
+ StrAllocCat(newtitle, ptr + 1);
+ }
+ }
+ StrAllocCat(newtitle, "]");
+ return newtitle;
+}
diff --git a/src/LYCharSets.c b/src/LYCharSets.c
index 415d1584..5858b4e1 100644
--- a/src/LYCharSets.c
+++ b/src/LYCharSets.c
@@ -25,7 +25,11 @@ PUBLIC BOOLEAN LYHaveCJKCharacterSet = FALSE;
PUBLIC BOOLEAN DisplayCharsetMatchLocale = TRUE;
extern void UCInit NOARGS;
extern int UCInitialized;
-PUBLIC int LYNumCharsets = 0; /* Will be initialized later by UC_Register. */
+PUBLIC int LYNumCharsets = 0; /* Will be initialized later by UC_Register. */
+PUBLIC int current_char_set = -1; /* will be intitialized later in LYMain.c */
+PUBLIC CONST char** p_entity_values = NULL; /* Pointer, for HTML_put_entity()*/
+ /* obsolete and probably not used(???) */
+ /* will be initialized in HTMLUseCharacterSet */
/*
* INSTRUCTIONS for adding new character sets which do not have
@@ -451,15 +455,6 @@ PUBLIC int LYlowest_eightbit[MAXCHARSETS]={
128 /* Transparent (???) */
};
-/*
- * The default character set.
- * --------------------------
- * Use lynx.cfg and/or user
- * 'o'ptions (.lynxrc) to
- * set a different default.
- */
-PUBLIC CONST char** p_entity_values = ISO_Latin1; /* Pointer to translation */
-PUBLIC int current_char_set = 0; /* Index for translation */
/*
* Function to set the handling of selected character sets
@@ -467,12 +462,9 @@ PUBLIC int current_char_set = 0; /* Index for translation */
*/
PUBLIC void HTMLSetCharacterHandling ARGS1(int,i)
{
- int chndl = -2;
- if (LYCharSet_UC[i].enc != UCT_ENC_CJK) {
- chndl = UCGetLYhndl_byMIME("iso-8859-1");
+ int chndl = safeUCGetLYhndl_byMIME(UCAssume_MIMEcharset);
- if (UCAssume_MIMEcharset)
- chndl = UCGetLYhndl_byMIME(UCAssume_MIMEcharset);
+ if (LYCharSet_UC[i].enc != UCT_ENC_CJK) {
HTCJK = NOCJK;
kanji_code = NOKANJI;
@@ -480,7 +472,7 @@ PUBLIC void HTMLSetCharacterHandling ARGS1(int,i)
((LYCharSet_UC[i].codepoints & UCT_CP_SUPERSETOF_LAT1) ||
(LYCharSet_UC[i].like8859 & UCT_R_HIGH8BIT));
- if (i == (chndl < 0 ? 0 : chndl)) {
+ if (i == chndl) {
LYRawMode = LYUseDefaultRawMode ? TRUE : FALSE;
} else {
LYRawMode = LYUseDefaultRawMode ? FALSE : TRUE;
@@ -498,76 +490,72 @@ PUBLIC void HTMLSetCharacterHandling ARGS1(int,i)
HTPassHighCtrlNum = FALSE;
- } else if (!strncmp(LYchar_set_names[i], "Chinese", 7)) {
- HTCJK = LYUseDefaultRawMode ? CHINESE : NOCJK;
- LYRawMode = (HTCJK != NOCJK) ? TRUE : FALSE;
- kanji_code = EUC;
- HTPassEightBitRaw = FALSE;
- HTPassEightBitNum = FALSE;
- HTPassHighCtrlRaw = (HTCJK != NOCJK) ? TRUE : FALSE;
- HTPassHighCtrlNum = FALSE;
-
- } else if (!strncmp(LYchar_set_names[i], "Japanese (EUC-JP)", 17)) {
- HTCJK = LYUseDefaultRawMode ? JAPANESE : NOCJK;
- LYRawMode = (HTCJK != NOCJK) ? TRUE : FALSE;
- kanji_code = EUC;
- HTPassEightBitRaw = FALSE;
- HTPassEightBitNum = FALSE;
- HTPassHighCtrlRaw = (HTCJK != NOCJK) ? TRUE : FALSE;
- HTPassHighCtrlNum = FALSE;
-
- } else if (!strncmp(LYchar_set_names[i], "Japanese (Shift_JIS)", 20)) {
- HTCJK = LYUseDefaultRawMode ? JAPANESE : NOCJK;
- LYRawMode = (HTCJK != NOCJK) ? TRUE : FALSE;
- kanji_code = SJIS;
- HTPassEightBitRaw = FALSE;
- HTPassEightBitNum = FALSE;
- HTPassHighCtrlRaw = (HTCJK != NOCJK) ? TRUE : FALSE;
- HTPassHighCtrlNum = FALSE;
-
- } else if (!strncmp(LYchar_set_names[i], "Korean", 6)) {
- HTCJK = LYUseDefaultRawMode ? KOREAN : NOCJK;
- LYRawMode = (HTCJK != NOCJK) ? TRUE : FALSE;
- kanji_code = EUC;
- HTPassEightBitRaw = FALSE;
- HTPassEightBitNum = FALSE;
- HTPassHighCtrlRaw = (HTCJK != NOCJK) ? TRUE : FALSE;
- HTPassHighCtrlNum = FALSE;
+ } else { /* CJK encoding: */
+ CONST char *mime = LYCharSet_UC[i].MIMEname;
- } else if (!strncmp(LYchar_set_names[i], "Taipei (Big5)", 13)) {
- HTCJK = LYUseDefaultRawMode ? TAIPEI : NOCJK;
- LYRawMode = (HTCJK != NOCJK) ? TRUE : FALSE;
- kanji_code = EUC;
- HTPassEightBitRaw = FALSE;
- HTPassEightBitNum = FALSE;
- HTPassHighCtrlRaw = (HTCJK != NOCJK) ? TRUE : FALSE;
- HTPassHighCtrlNum = FALSE;
+ if (!strcmp(mime, "euc-cn")) {
+ HTCJK = LYUseDefaultRawMode ? CHINESE : NOCJK;
+ LYRawMode = (HTCJK != NOCJK) ? TRUE : FALSE;
+ kanji_code = EUC;
+ HTPassEightBitRaw = FALSE;
+ HTPassEightBitNum = FALSE;
+ HTPassHighCtrlRaw = (HTCJK != NOCJK) ? TRUE : FALSE;
+ HTPassHighCtrlNum = FALSE;
+
+ } else if (!strcmp(mime, "euc-jp")) {
+ HTCJK = LYUseDefaultRawMode ? JAPANESE : NOCJK;
+ LYRawMode = (HTCJK != NOCJK) ? TRUE : FALSE;
+ kanji_code = EUC;
+ HTPassEightBitRaw = FALSE;
+ HTPassEightBitNum = FALSE;
+ HTPassHighCtrlRaw = (HTCJK != NOCJK) ? TRUE : FALSE;
+ HTPassHighCtrlNum = FALSE;
+
+ } else if (!strcmp(mime, "shift_jis")) {
+ HTCJK = LYUseDefaultRawMode ? JAPANESE : NOCJK;
+ LYRawMode = (HTCJK != NOCJK) ? TRUE : FALSE;
+ kanji_code = SJIS;
+ HTPassEightBitRaw = FALSE;
+ HTPassEightBitNum = FALSE;
+ HTPassHighCtrlRaw = (HTCJK != NOCJK) ? TRUE : FALSE;
+ HTPassHighCtrlNum = FALSE;
+
+ } else if (!strcmp(mime, "euc-kr")) {
+ HTCJK = LYUseDefaultRawMode ? KOREAN : NOCJK;
+ LYRawMode = (HTCJK != NOCJK) ? TRUE : FALSE;
+ kanji_code = EUC;
+ HTPassEightBitRaw = FALSE;
+ HTPassEightBitNum = FALSE;
+ HTPassHighCtrlRaw = (HTCJK != NOCJK) ? TRUE : FALSE;
+ HTPassHighCtrlNum = FALSE;
+
+ } else if (!strcmp(mime, "big5")) {
+ HTCJK = LYUseDefaultRawMode ? TAIPEI : NOCJK;
+ LYRawMode = (HTCJK != NOCJK) ? TRUE : FALSE;
+ kanji_code = EUC;
+ HTPassEightBitRaw = FALSE;
+ HTPassEightBitNum = FALSE;
+ HTPassHighCtrlRaw = (HTCJK != NOCJK) ? TRUE : FALSE;
+ HTPassHighCtrlNum = FALSE;
- } else {
- HTCJK = NOCJK;
- kanji_code = NOKANJI;
- HTPassEightBitRaw = LYUseDefaultRawMode ? FALSE : TRUE;
- LYRawMode = HTPassEightBitRaw;
- HTPassEightBitNum = FALSE;
- HTPassHighCtrlRaw = FALSE;
- HTPassHighCtrlNum = FALSE;
+ }
}
+ /*
+ * Comment for coding below:
+ * UCLYhndl_for_unspec is "current" state with LYRawMode,
+ * but UCAssume_MIMEcharset is independent from LYRawMode:
+ * holds the history and may be changed from 'O'ptions menu only. - LP
+ */
if (LYRawMode) {
- UCLYhndl_for_unspec = i;
+ UCLYhndl_for_unspec = i; /* UCAssume_MIMEcharset not changed! */
} else {
- if (chndl == -2) {
- chndl = UCGetLYhndl_byMIME("iso-8859-1");
-
- if (UCAssume_MIMEcharset)
- chndl = UCGetLYhndl_byMIME(UCAssume_MIMEcharset);
- }
- if (chndl != i && chndl >= 0 &&
+ if (chndl != i &&
(LYCharSet_UC[i].enc != UCT_ENC_CJK ||
LYCharSet_UC[chndl].enc != UCT_ENC_CJK)) {
- UCLYhndl_for_unspec = chndl;
+ UCLYhndl_for_unspec = chndl; /* fall to UCAssume_MIMEcharset */
} else {
- UCLYhndl_for_unspec = UCGetLYhndl_byMIME("iso-8859-1");
+ UCLYhndl_for_unspec = LATIN1; /* UCAssume_MIMEcharset not changed! */
}
}
@@ -588,21 +576,42 @@ PUBLIC void HTMLSetCharacterHandling ARGS1(int,i)
}
/*
- * Function to set the LYDefaultRawMode value
- * based on the selected character set. - FM
+ * Function to set HTCJK based on "in" and "out" charsets.
*/
-PUBLIC void HTMLSetRawModeDefault ARGS1(int,i)
+PUBLIC void Set_HTCJK ARGS2(
+ CONST char *, inMIMEname,
+ CONST char *, outMIMEname)
{
- if (!strncmp(LYchar_set_names[i], "Western (ISO-8859-1)", 20) ||
- !strncmp(LYchar_set_names[i], "Chinese", 7) ||
- !strncmp(LYchar_set_names[i], "Japanese (EUC-JP)", 17) ||
- !strncmp(LYchar_set_names[i], "Japanese (Shift_JIS)", 20) ||
- !strncmp(LYchar_set_names[i], "Korean", 6) ||
- !strncmp(LYchar_set_names[i], "Taipei (Big5)", 13)) {
- LYDefaultRawMode = TRUE;
+ if (LYRawMode) {
+ if ((!strcmp(inMIMEname, "euc-jp") ||
+ !strcmp(inMIMEname, "shift_jis")) &&
+ (!strcmp(outMIMEname, "euc-jp") ||
+ !strcmp(outMIMEname, "shift_jis"))) {
+ HTCJK = JAPANESE;
+ } else if (!strcmp(inMIMEname, "euc-cn") &&
+ !strcmp(outMIMEname, "euc-cn")) {
+ HTCJK = CHINESE;
+ } else if (!strcmp(inMIMEname, "big5") &&
+ !strcmp(outMIMEname, "big5")) {
+ HTCJK = TAIPEI;
+ } else if (!strcmp(inMIMEname, "euc-kr") &&
+ !strcmp(outMIMEname, "euc-kr")) {
+ HTCJK = KOREAN;
+ } else {
+ HTCJK = NOCJK;
+ }
} else {
- LYDefaultRawMode = FALSE;
+ HTCJK = NOCJK;
}
+}
+
+/*
+ * Function to set the LYDefaultRawMode value
+ * based on the selected character set. - FM
+ */
+PRIVATE void HTMLSetRawModeDefault ARGS1(int,i)
+{
+ LYDefaultRawMode = (LYCharSet_UC[i].enc == UCT_ENC_CJK);
return;
}
@@ -616,32 +625,15 @@ PUBLIC void HTMLSetUseDefaultRawMode ARGS2(
BOOLEAN, modeflag)
{
if (LYCharSet_UC[i].enc != UCT_ENC_CJK) {
- int chndl = UCGetLYhndl_byMIME("iso-8859-1");
- if (UCAssume_MIMEcharset)
- chndl = UCGetLYhndl_byMIME(UCAssume_MIMEcharset);
+ int chndl = safeUCGetLYhndl_byMIME(UCAssume_MIMEcharset);
if (i == chndl)
LYUseDefaultRawMode = modeflag;
else
LYUseDefaultRawMode = (!modeflag);
- } else if (!strncmp(LYchar_set_names[i], "Western (ISO-8859-1)", 20) ||
- !strncmp(LYchar_set_names[i], "Chinese", 7) ||
- !strncmp(LYchar_set_names[i], "Japanese (EUC-JP)", 17) ||
- !strncmp(LYchar_set_names[i], "Japanese (Shift_JIS)", 20) ||
- !strncmp(LYchar_set_names[i], "Korean", 6) ||
- !strncmp(LYchar_set_names[i], "Taipei (Big5)", 13)) {
- if (modeflag == TRUE) {
- LYUseDefaultRawMode = TRUE;
- } else {
- LYUseDefaultRawMode = FALSE;
- }
- } else {
- if (modeflag == FALSE) {
- LYUseDefaultRawMode = TRUE;
- } else {
- LYUseDefaultRawMode = FALSE;
- }
- }
+ } else /* CJK encoding: */
+ LYUseDefaultRawMode = modeflag;
+
return;
}
@@ -649,17 +641,9 @@ PUBLIC void HTMLSetUseDefaultRawMode ARGS2(
* Function to set the LYHaveCJKCharacterSet value
* based on the selected character set. - FM
*/
-PUBLIC void HTMLSetHaveCJKCharacterSet ARGS1(int,i)
+PRIVATE void HTMLSetHaveCJKCharacterSet ARGS1(int,i)
{
- if (!strncmp(LYchar_set_names[i], "Chinese", 7) ||
- !strncmp(LYchar_set_names[i], "Japanese (EUC-JP)", 17) ||
- !strncmp(LYchar_set_names[i], "Japanese (Shift_JIS)", 20) ||
- !strncmp(LYchar_set_names[i], "Korean", 6) ||
- !strncmp(LYchar_set_names[i], "Taipei (Big5)", 13)) {
- LYHaveCJKCharacterSet = TRUE;
- } else {
- LYHaveCJKCharacterSet = FALSE;
- }
+ LYHaveCJKCharacterSet = (LYCharSet_UC[i].enc == UCT_ENC_CJK);
return;
}
@@ -671,6 +655,8 @@ PUBLIC void HTMLSetHaveCJKCharacterSet ARGS1(int,i)
*/
PRIVATE void HTMLSetDisplayCharsetMatchLocale ARGS1(int,i)
{
+ BOOLEAN match;
+
if (LYHaveCJKCharacterSet) {
/*
** We have no intention to pass CJK via UCTransChar if that happened.
@@ -686,22 +672,23 @@ PRIVATE void HTMLSetDisplayCharsetMatchLocale ARGS1(int,i)
** rarely matches locale. (In fact, MS Windows codepoints locale are
** never seen on UNIX).
*/
- DisplayCharsetMatchLocale = FALSE;
+ match = FALSE;
} else {
- DisplayCharsetMatchLocale = TRUE; /* guess, but see below */
+ match = TRUE; /* guess, but see below */
#if !defined(LOCALE)
- DisplayCharsetMatchLocale = FALSE;
+ match = FALSE;
#else
if (UCForce8bitTOUPPER) {
/*
** Force disable locale (from lynx.cfg)
*/
- DisplayCharsetMatchLocale = FALSE;
+ match = FALSE;
}
#endif
}
+ DisplayCharsetMatchLocale = match;
return;
}
@@ -880,8 +867,9 @@ PUBLIC UCode_t HTMLGetEntityUCValue ARGS1(
* Function to select a character set and then set the
* character handling and LYHaveCJKCharacterSet flag. - FM
*/
-PUBLIC void HTMLUseCharacterSet ARGS1(int,i)
+PUBLIC void HTMLUseCharacterSet ARGS1(int, i)
{
+ HTMLSetRawModeDefault(i);
p_entity_values = LYCharSets[i];
HTMLSetCharacterHandling(i); /* set LYRawMode and CJK attributes */
HTMLSetHaveCJKCharacterSet(i);
@@ -897,17 +885,5 @@ PUBLIC int LYCharSetsDeclared NOPARAMS
{
UCInit();
- if (UCAssume_MIMEcharset && *UCAssume_MIMEcharset) {
- UCLYhndl_for_unspec = UCGetLYhndl_byMIME(UCAssume_MIMEcharset);
- } else {
- UCLYhndl_for_unspec = UCGetLYhndl_byMIME("iso-8859-1");
- }
- if (UCAssume_localMIMEcharset && *UCAssume_localMIMEcharset)
- UCLYhndl_HTFile_for_unspec =
- UCGetLYhndl_byMIME(UCAssume_localMIMEcharset);
- if (UCAssume_unrecMIMEcharset && *UCAssume_unrecMIMEcharset)
- UCLYhndl_for_unrec =
- UCGetLYhndl_byMIME(UCAssume_unrecMIMEcharset);
-
return UCInitialized;
}
diff --git a/src/LYCharSets.h b/src/LYCharSets.h
index 746f84c2..33c6ef76 100644
--- a/src/LYCharSets.h
+++ b/src/LYCharSets.h
@@ -9,7 +9,7 @@
#endif /* !UCMAP_H */
extern BOOLEAN LYHaveCJKCharacterSet;
-extern BOOLEAN DisplayCharsetMatchLocale;
+extern BOOLEAN DisplayCharsetMatchLocale;
/*
* LYchar_set_name[current_char_set] points to the currently active set.
@@ -31,11 +31,10 @@ extern int LYlowest_eightbit[];
extern int LYNumCharsets;
extern LYUCcharset LYCharSet_UC[];
extern void HTMLSetCharacterHandling PARAMS((int i));
-extern void HTMLSetRawModeDefault PARAMS((int i));
extern void HTMLSetUseDefaultRawMode PARAMS((int i, BOOLEAN modeflag));
-extern void HTMLSetHaveCJKCharacterSet PARAMS((int i));
extern void HTMLUseCharacterSet PARAMS((int i));
extern UCode_t HTMLGetEntityUCValue PARAMS((CONST char *name));
+extern void Set_HTCJK PARAMS((CONST char *inMIMEname, CONST char *outMIMEname));
extern CONST char * LYEntityNames[];
extern CONST char * HTMLGetEntityName PARAMS((UCode_t code));
diff --git a/src/LYCharUtils.c b/src/LYCharUtils.c
index cc53b72f..8dda30ef 100644
--- a/src/LYCharUtils.c
+++ b/src/LYCharUtils.c
@@ -2517,7 +2517,7 @@ PUBLIC void LYHandleMETA ARGS4(
HTStructured *, me,
CONST BOOL*, present,
CONST char **, value,
- char **, include)
+ char **, include GCC_UNUSED)
{
char *http_equiv = NULL, *name = NULL, *content = NULL;
char *href = NULL, *id_string = NULL, *temp = NULL;
@@ -2708,6 +2708,7 @@ PUBLIC void LYHandleMETA ARGS4(
} else if (!(me->node_anchor->charset && *me->node_anchor->charset) &&
!strcasecomp((http_equiv ? http_equiv : ""), "Content-Type")) {
LYUCcharset * p_in = NULL;
+ LYUCcharset * p_out = NULL;
LYUCFullyTranslateString(&content, me->tag_charset, me->tag_charset,
NO, NO, YES, st_other);
LYTrimHead(content);
@@ -2745,6 +2746,8 @@ PUBLIC void LYHandleMETA ARGS4(
* Got something but we don't recognize it.
*/
chndl = UCLYhndl_for_unrec;
+ if (chndl < 0) /* UCLYhndl_for_unrec not defined :-( */
+ chndl = UCLYhndl_for_unspec; /* always >= 0 */
if (UCCanTranslateFromTo(chndl, current_char_set)) {
chartrans_ok = YES;
HTAnchor_setUCInfoStage(me->node_anchor, chndl,
@@ -2753,13 +2756,12 @@ PUBLIC void LYHandleMETA ARGS4(
}
}
if (chartrans_ok) {
- LYUCcharset * p_out =
- HTAnchor_setUCInfoStage(me->node_anchor,
- current_char_set,
- UCT_STAGE_HTEXT,
- UCT_SETBY_DEFAULT);
p_in = HTAnchor_getUCInfoStage(me->node_anchor,
UCT_STAGE_PARSER);
+ p_out = HTAnchor_setUCInfoStage(me->node_anchor,
+ current_char_set,
+ UCT_STAGE_HTEXT,
+ UCT_SETBY_DEFAULT);
if (!p_out) {
/*
* Try again.
@@ -2791,37 +2793,30 @@ PUBLIC void LYHandleMETA ARGS4(
HTPassEightBitRaw = TRUE;
}
} else if (p_out->enc == UCT_ENC_CJK) {
- if (LYRawMode) {
- if ((!strcmp(p_in->MIMEname, "euc-jp") ||
- !strcmp(p_in->MIMEname, "shift_jis")) &&
- (!strcmp(p_out->MIMEname, "euc-jp") ||
- !strcmp(p_out->MIMEname, "shift_jis"))) {
- HTCJK = JAPANESE;
- } else if (!strcmp(p_in->MIMEname, "euc-cn") &&
- !strcmp(p_out->MIMEname, "euc-cn")) {
- HTCJK = CHINESE;
- } else if (!strcmp(p_in->MIMEname, "big5") &&
- !strcmp(p_out->MIMEname, "big5")) {
- HTCJK = TAIPEI;
- } else if (!strcmp(p_in->MIMEname, "euc-kr") &&
- !strcmp(p_out->MIMEname, "euc-kr")) {
- HTCJK = KOREAN;
- } else {
- HTCJK = NOCJK;
- }
- } else {
- HTCJK = NOCJK;
- }
+ Set_HTCJK(p_in->MIMEname, p_out->MIMEname);
}
LYGetChartransInfo(me);
- /*
- * Fall through to old behavior.
- */
- } else if (!strncmp(cp1, "us-ascii", 8) ||
- !strncmp(cp1, "iso-8859-1", 10)) {
- StrAllocCopy(me->node_anchor->charset, "iso-8859-1");
- HTCJK = NOCJK;
-
+ /*
+ ** Update the chartrans info homologously to
+ ** a Content-Type MIME header with a charset
+ ** parameter. - FM
+ */
+ if (me->UCLYhndl != chndl) {
+ HTAnchor_setUCInfoStage(me->node_anchor, chndl,
+ UCT_STAGE_MIME,
+ UCT_SETBY_STRUCTURED);
+ HTAnchor_setUCInfoStage(me->node_anchor, chndl,
+ UCT_STAGE_PARSER,
+ UCT_SETBY_STRUCTURED);
+ me->inUCLYhndl = HTAnchor_getUCLYhndl(me->node_anchor,
+ UCT_STAGE_PARSER);
+ me->inUCI = HTAnchor_getUCInfoStage(me->node_anchor,
+ UCT_STAGE_PARSER);
+ }
+ UCSetTransParams(&me->T,
+ me->inUCLYhndl, me->inUCI,
+ me->outUCLYhndl, me->outUCI);
+ } else {
/*
* Hope it's a match, for now. - FM
*/
@@ -2834,41 +2829,6 @@ PUBLIC void LYHandleMETA ARGS4(
HTPassEightBitRaw = TRUE;
HTAlert(me->node_anchor->charset);
- } else if (!strncmp(cp1, "euc-jp", 6) && HTCJK == JAPANESE) {
- StrAllocCopy(me->node_anchor->charset, "euc-jp");
-
- } else if (!strncmp(cp1, "shift_jis", 9) && HTCJK == JAPANESE) {
- StrAllocCopy(me->node_anchor->charset, "shift_jis");
-
- } else if (!strncmp(cp1, "iso-2022-jp", 11) &&
- HTCJK == JAPANESE) {
- StrAllocCopy(me->node_anchor->charset, "iso-2022-jp");
-
- } else if (!strncmp(cp1, "iso-2022-jp-2", 13) &&
- HTCJK == JAPANESE) {
- StrAllocCopy(me->node_anchor->charset, "iso-2022-jp-2");
-
- } else if (!strncmp(cp1, "euc-kr", 6) && HTCJK == KOREAN) {
- StrAllocCopy(me->node_anchor->charset, "euc-kr");
-
- } else if (!strncmp(cp1, "iso-2022-kr", 11) && HTCJK == KOREAN) {
- StrAllocCopy(me->node_anchor->charset, "iso-2022-kr");
-
- } else if ((!strncmp(cp1, "big5", 4) ||
- !strncmp(cp1, "cn-big5", 7)) &&
- HTCJK == TAIPEI) {
- StrAllocCopy(me->node_anchor->charset, "big5");
-
- } else if (!strncmp(cp1, "euc-cn", 6) && HTCJK == CHINESE) {
- StrAllocCopy(me->node_anchor->charset, "euc-cn");
-
- } else if ((!strncmp(cp1, "gb2312", 6) ||
- !strncmp(cp1, "cn-gb", 5)) &&
- HTCJK == CHINESE) {
- StrAllocCopy(me->node_anchor->charset, "gb2312");
-
- } else if (!strncmp(cp1, "iso-2022-cn", 11) && HTCJK == CHINESE) {
- StrAllocCopy(me->node_anchor->charset, "iso-2022-cn");
}
FREE(cp3);
@@ -3103,7 +3063,7 @@ PUBLIC void LYHandleP ARGS5(
HTStructured *, me,
CONST BOOL*, present,
CONST char **, value,
- char **, include,
+ char **, include GCC_UNUSED,
BOOL, start)
{
if (TRUE) {
@@ -3211,7 +3171,7 @@ PUBLIC void LYHandleSELECT ARGS5(
HTStructured *, me,
CONST BOOL*, present,
CONST char **, value,
- char **, include,
+ char **, include GCC_UNUSED,
BOOL, start)
{
int i;
diff --git a/src/LYCookie.c b/src/LYCookie.c
index c82dd592..e586cf04 100644
--- a/src/LYCookie.c
+++ b/src/LYCookie.c
@@ -1832,8 +1832,21 @@ PUBLIC void LYLoadCookies ARGS1 (
{
FILE *cookie_handle;
char buf[5000]; /* should be long enough for a cookie line */
- static char domain[256], path[256], name[256], value[4100];
+ static char domain[256], path[LY_MAXPATH], name[256], value[4100];
static char what[8], secure[8], expires_a[16];
+ static struct {
+ char *s;
+ size_t n;
+ } tok_values[] = {
+ { domain, sizeof(domain) },
+ { what, sizeof(what) },
+ { path, sizeof(path) },
+ { secure, sizeof(secure) },
+ { expires_a, sizeof(expires_a) },
+ { name, sizeof(name) },
+ { value, sizeof(value) },
+ { NULL, 0 }
+ };
time_t expires;
cookie_handle = fopen(cookie_file, "r+");
@@ -1843,13 +1856,17 @@ PUBLIC void LYLoadCookies ARGS1 (
while (!feof(cookie_handle)) {
cookie *moo;
int tok_loop;
- char *tok_values[] = {domain, what, path, secure, expires_a, name, value, NULL};
char *tok_out, *tok_ptr;
+ char *j;
- fgets(buf, 4999, cookie_handle); /* test return value */
+ j = fgets(buf, sizeof(buf)-1, cookie_handle);
+
+ if((j == NULL) || (buf[0] == '\0' || buf[0] == '\n')) {
+ continue;
+ }
/*
- * Tokenise the cookie line into it's component parts -
+ * Tokenise the cookie line into its component parts -
* this only works for Netscape style cookie files at the
* moment. It may be worth investigating an alternative
* format for Lynx because the Netscape format isn't all
@@ -1860,10 +1877,10 @@ PUBLIC void LYLoadCookies ARGS1 (
*/
tok_ptr = buf;
tok_out = LYstrsep(&tok_ptr, "\t");
- for (tok_loop = 0; tok_out && tok_values[tok_loop]; tok_loop++) {
+ for (tok_loop = 0; tok_out && tok_values[tok_loop].s; tok_loop++) {
CTRACE(tfp, ">%d:%p:%p:[%s]:%s\n",
- tok_loop, tok_values[tok_loop], tok_out, tok_out, buf);
- strcpy(tok_values[tok_loop], tok_out);
+ tok_loop, tok_values[tok_loop].s, tok_out, tok_out, buf);
+ LYstrncpy(tok_values[tok_loop].s, tok_out, tok_values[tok_loop].n);
/*
* It looks like strtok ignores a leading delimiter,
* which makes things a bit more interesting. Something
@@ -1873,7 +1890,7 @@ PUBLIC void LYLoadCookies ARGS1 (
tok_out = LYstrsep(&tok_ptr, "\t");
}
expires = atol(expires_a);
- fprintf(stderr, "COOKIE: expires %s\n", ctime(&expires));
+ CTRACE(tfp, "COOKIE: expires %s\n", ctime(&expires));
/*
* This fails when the path is blank
@@ -2438,7 +2455,8 @@ PUBLIC void cookie_add_acceptlist ARGS1(
domain_entry *de2 = NULL;
HTList *hl;
char **str = (char **)calloc(1, sizeof(acceptstr));
- char *strsmall = (char *)calloc(1, sizeof(acceptstr));
+ char *astr = NULL;
+ char *strsmall = NULL;
int isexisting = FALSE;
/* is this the first cookie we're handling? if so, initialize the
@@ -2451,7 +2469,9 @@ PUBLIC void cookie_add_acceptlist ARGS1(
total_cookies = 0;
}
- *str = acceptstr;
+ StrAllocCopy(astr, acceptstr);
+
+ *str = astr;
for(; (strsmall = LYstrsep(str, ","));) {
if(strsmall == NULL)
@@ -2490,6 +2510,7 @@ PUBLIC void cookie_add_acceptlist ARGS1(
FREE(str);
FREE(strsmall);
+ FREE(astr);
}
@@ -2505,7 +2526,8 @@ PUBLIC void cookie_add_rejectlist ARGS1(
domain_entry *de2 = NULL;
HTList *hl;
char **str = (char **)calloc(1, sizeof(rejectstr));
- char *strsmall = (char *)calloc(1, sizeof(rejectstr));
+ char *rstr = NULL;
+ char *strsmall = NULL;
int isexisting = FALSE;
/* is this the first cookie we're handling? if so, initialize the
@@ -2518,7 +2540,9 @@ PUBLIC void cookie_add_rejectlist ARGS1(
total_cookies = 0;
}
- *str = rejectstr;
+ StrAllocCopy(rstr, rejectstr);
+
+ *str = rstr;
for(; (strsmall = LYstrsep(str, ","));) {
if(strsmall == NULL)
@@ -2557,6 +2581,7 @@ PUBLIC void cookie_add_rejectlist ARGS1(
FREE(str);
FREE(strsmall);
+ FREE(rstr);
}
#ifdef GLOBALDEF_IS_MACRO
diff --git a/src/LYCurses.c b/src/LYCurses.c
index 4bbd8758..b6d149fa 100644
--- a/src/LYCurses.c
+++ b/src/LYCurses.c
@@ -762,6 +762,10 @@ PUBLIC void start_curses NOARGS
#if defined(SIGWINCH) && defined(NCURSES_VERSION)
size_change(0);
#endif /* SIGWINCH */
+#if defined(USE_KEYMAPS) && defined(NCURSES_VERSION)
+ if (-1 == lynx_initialize_keymaps ())
+ exit (-1);
+#endif
/*
* This is a workaround for a bug in SVr4 curses, observed on Solaris
diff --git a/src/LYCurses.h b/src/LYCurses.h
index 9df3b749..a0275449 100644
--- a/src/LYCurses.h
+++ b/src/LYCurses.h
@@ -99,6 +99,11 @@
extern void LYsubwindow PARAMS((WINDOW * param));
# endif /* NCURSES */
+#if defined(NCURSES_VERSION) && defined(HAVE_DEFINE_KEY)
+#include <term.h>
+#define USE_KEYMAPS 1
+#endif
+
#else
# if defined(VMS) && defined(__GNUC__)
# include <LYGCurses.h>
@@ -186,17 +191,19 @@ extern unsigned int Lynx_Color_Flags;
#endif
#ifdef USE_SLANG
+
#if !defined(VMS) && !defined(DJGPP)
#define USE_SLANG_MOUSE 1
-#endif /* USE_SLANG */
+#endif
-#if ((SLANG_VERSION >= 10000) && !defined(__DJGPP__))
-#define USE_SLANG_KEYMAPS 1
-#endif /* SLANG_VERSION >= 10000 */
+#if !defined(__DJGPP__)
+#define USE_KEYMAPS 1
+#endif
#define SL_LYNX_USE_COLOR 1
#define SL_LYNX_USE_BLINK 2
#define SL_LYNX_OVERRIDE_COLOR 4
+
#define start_bold() LYaddAttr(1)
#define start_reverse() LYaddAttr(2)
#define start_underline() LYaddAttr(4)
diff --git a/src/LYForms.c b/src/LYForms.c
index eb44fa14..ff64cb2d 100644
--- a/src/LYForms.c
+++ b/src/LYForms.c
@@ -804,8 +804,8 @@ redraw:
SLsmg_gotorc((LYlines - 1), (LYcols - 1));
SLsmg_refresh();
#else
- wstart_reverse(form_window);
wmove(form_window, ((i + 1) - window_offset), 2);
+ wstart_reverse(form_window);
paddstr(form_window, width, opt_ptr->name);
wstop_reverse(form_window);
/*
diff --git a/src/LYGlobalDefs.h b/src/LYGlobalDefs.h
index ebc78984..37550ce3 100644
--- a/src/LYGlobalDefs.h
+++ b/src/LYGlobalDefs.h
@@ -250,10 +250,13 @@ extern BOOLEAN enable_scrollback; /* Clear screen before displaying new page */
extern BOOLEAN keep_mime_headers; /* Include mime headers and *
* force source dump */
extern BOOLEAN no_url_redirection; /* Don't follow URL redirections */
+#ifdef DISP_PARTIAL
extern BOOLEAN display_partial; /* Display document during download */
extern int Newline_partial; /* -//- "current" newline position */
extern int NumOfLines_partial; /* -//- "current" number of lines */
extern BOOLEAN debug_display_partial; /* show with MessageSecs delay */
+extern BOOLEAN detected_forms_input_partial; /* trimHightext temp fix */
+#endif
extern char *form_post_data; /* User data for post form */
extern char *form_get_data; /* User data for get form */
extern char *http_error_file; /* Place HTTP status code in this file */
@@ -287,8 +290,6 @@ extern BOOLEAN LYRawMode;
extern BOOLEAN LYDefaultRawMode;
extern BOOLEAN LYUseDefaultRawMode;
extern char *UCAssume_MIMEcharset;
-extern char *UCAssume_localMIMEcharset;
-extern char *UCAssume_unrecMIMEcharset;
extern BOOLEAN UCSaveBookmarksInUnicode; /* in titles, chars >127 save as &#xUUUU */
extern BOOLEAN UCForce8bitTOUPPER; /* disable locale case-conversion for >127 */
extern BOOLEAN LYisConfiguredForX;
diff --git a/src/LYKeymap.c b/src/LYKeymap.c
index e5614d8a..17674b03 100644
--- a/src/LYKeymap.c
+++ b/src/LYKeymap.c
@@ -8,8 +8,6 @@
#include <LYLeaks.h>
-#define TABLESIZE(v) (sizeof(v)/sizeof(v[0]))
-
PRIVATE CONST DocAddress keymap_anchor = {"LYNXKEYMAP", NULL, NULL};
struct _HTStream
diff --git a/src/LYMail.c b/src/LYMail.c
index 3d1138f3..d61413d5 100644
--- a/src/LYMail.c
+++ b/src/LYMail.c
@@ -883,7 +883,9 @@ PUBLIC void reply_by_mail ARGS3(
#if defined(DOSPATH) || defined(VMS)
char *command = NULL;
#endif
+#ifndef NO_ANONYMOUS_EMAIL
static char *personal_name = NULL;
+#endif
char subject[80];
#ifdef VMS
char *address_ptr1 = NULL, *address_ptr2 = NULL;
diff --git a/src/LYMain.c b/src/LYMain.c
index 9d7f174a..3322b390 100644
--- a/src/LYMain.c
+++ b/src/LYMain.c
@@ -293,8 +293,6 @@ PUBLIC BOOLEAN LYRawMode;
PUBLIC BOOLEAN LYDefaultRawMode;
PUBLIC BOOLEAN LYUseDefaultRawMode = TRUE;
PUBLIC char *UCAssume_MIMEcharset = NULL;
-PUBLIC char *UCAssume_localMIMEcharset = NULL;
-PUBLIC char *UCAssume_unrecMIMEcharset = NULL;
PUBLIC BOOLEAN UCSaveBookmarksInUnicode = FALSE;
PUBLIC BOOLEAN UCForce8bitTOUPPER = FALSE; /* override locale for case-conversion? */
PUBLIC int LYlines = 24;
@@ -357,6 +355,7 @@ PUBLIC BOOLEAN LYQuitDefaultYes = QUIT_DEFAULT_YES;
#ifdef DISP_PARTIAL
PUBLIC BOOLEAN display_partial = TRUE; /* Display document during download */
PUBLIC BOOLEAN debug_display_partial = FALSE; /* Show with MessageSecs delay */
+PUBLIC BOOLEAN detected_forms_input_partial = FALSE; /* trimHightext temp fix */
#endif
/* These are declared in cutil.h for current freeWAIS libraries. - FM */
@@ -479,8 +478,6 @@ PRIVATE void free_lynx_globals NOARGS
FREE(lynx_lss_file);
#endif
FREE(UCAssume_MIMEcharset);
- FREE(UCAssume_unrecMIMEcharset);
- FREE(UCAssume_localMIMEcharset);
for (i = 0; i < nlinks; i++) {
FREE(links[i].lname);
}
@@ -754,19 +751,6 @@ PUBLIC int main ARGS2(
StrAllocCopy(URLDomainPrefixes, URL_DOMAIN_PREFIXES);
StrAllocCopy(URLDomainSuffixes, URL_DOMAIN_SUFFIXES);
StrAllocCopy(XLoadImageCommand, XLOADIMAGE_COMMAND);
- /*
- * Set up the compilation default character set. - FM
- */
- for (i = 0; LYchar_set_names[i]; i++) {
- if (!strncmp(CHARACTER_SET, LYchar_set_names[i],
- strlen(CHARACTER_SET))) {
- current_char_set=i;
- break;
- }
- }
- if (!LYchar_set_names[i])
- current_char_set = i = 0;
- HTMLSetRawModeDefault(i);
/*
* Disable news posting if the compilation-based
@@ -1032,12 +1016,8 @@ PUBLIC int main ARGS2(
/*
* Set up the TRACE log path, and logging if appropriate. - FM
*/
-#ifdef VMS
- StrAllocCopy(LYTraceLogPath, "sys$login:Lynx.trace");
-#else
- StrAllocCopy(LYTraceLogPath, (Home_Dir() ? Home_Dir() : ""));
- StrAllocCat(LYTraceLogPath, "/Lynx.trace");
-#endif /* VMS */
+ LYAddPathToHome(LYTraceLogPath = malloc(LY_MAXPATH), LY_MAXPATH, "Lynx.trace");
+
if (TRACE && LYUseTraceLog) {
#if defined(__DJGPP__) || defined(_WINDOWS)
_fmode = O_TEXT;
@@ -1147,10 +1127,11 @@ PUBLIC int main ARGS2(
}
fclose(fp);
-#if defined(USE_SLANG_KEYMAPS)
+#if defined(USE_KEYMAPS) && defined(USE_SLANG)
if (-1 == lynx_initialize_keymaps ())
exit (-1);
#endif
+
/*
* Make sure we have the character sets declared.
* This will initialize the CHARTRANS handling. - KW
@@ -1159,6 +1140,22 @@ PUBLIC int main ARGS2(
fprintf(stderr, "\nLynx character sets not declared.\n\n");
exit(-1);
}
+ /*
+ * (**) in Lynx, UCLYhndl_HTFile_for_unspec and UCLYhndl_for_unrec may be
+ * valid or not, but current_char_set and UCLYhndl_for_unspec SHOULD
+ * ALWAYS be a valid charset. Initialized here and may be changed later
+ * from lynx.cfg/command_line/options_menu. - LP (**)
+ */
+ /*
+ * Set up the compilation default character set. - FM
+ */
+ current_char_set = safeUCGetLYhndl_byMIME(CHARACTER_SET);
+ /*
+ * Set up HTTP default for unlabeled charset (iso-8859-1).
+ */
+ UCLYhndl_for_unspec = LATIN1;
+ StrAllocCopy(UCAssume_MIMEcharset,
+ LYCharSet_UC[UCLYhndl_for_unspec].MIMEname);
#if defined(USE_HASH)
/*
@@ -1199,7 +1196,7 @@ PUBLIC int main ARGS2(
* inform the user and exit.
*/
if ((fp = fopen(lynx_lss_file, "r")) == NULL) {
- fprintf(stderr, "\nLynxile file %s is not available.\n\n",
+ fprintf(stderr, "\nLynx file %s is not available.\n\n",
lynx_lss_file);
}
else
@@ -1502,15 +1499,7 @@ PUBLIC int main ARGS2(
* cookies file, probably. - RP
*/
if(LYCookieFile == NULL) {
-#ifdef VMS
- /* I really don't know if this is going to work on VMS. Someone
- * who knows needs to take a look. - BJP
- */
- StrAllocCopy(LYCookieFile, "sys$login:cookies");
-#else
- StrAllocCopy(LYCookieFile, Home_Dir());
- StrAllocCat(LYCookieFile, "/cookies");
-#endif /* VMS */
+ LYAddPathToHome(LYCookieFile = malloc(LY_MAXPATH), LY_MAXPATH, "cookies");
} else {
if ((cp = strchr(LYCookieFile, '~'))) {
temp = NULL;
@@ -1534,6 +1523,22 @@ PUBLIC int main ARGS2(
LYLoadCookies(LYCookieFile);
#endif
+#ifdef SIGTSTP
+ /*
+ * Block Control-Z suspending if requested. - FM
+ */
+ if (no_suspend)
+ (void) signal(SIGTSTP,SIG_IGN);
+#endif /* SIGTSTP */
+
+ /*
+ * Finish setting up for an INTERACTIVE session.
+ * Done here so that URL guessing in LYEnsureAbsoluteURL() can be
+ * interruptible (terminal is in raw mode, select() works). -BL
+ */
+ if (!dump_output_immediately) {
+ setup(terminal);
+ }
/*
* If startfile is a file URL and the host is defaulted,
* force in "//localhost", and if it's not an absolute URL,
@@ -1587,14 +1592,6 @@ PUBLIC int main ARGS2(
rlogin_ok = !no_outside_rlogin && rlogin_ok;
}
-#ifdef SIGTSTP
- /*
- * Block Control-Z suspending if requested. - FM
- */
- if (no_suspend)
- (void) signal(SIGTSTP,SIG_IGN);
-#endif /* SIGTSTP */
-
/*
* Check for a valid HEAD request. - FM
*/
@@ -1722,17 +1719,14 @@ PUBLIC int main ARGS2(
#endif /* SIGTSTP */
} else {
/*
- * Finish setting up and start an
- * INTERACTIVE session. - FM
+ * Start an INTERACTIVE session. - FM
*/
- if (setup(terminal)) {
- if (x_display != NULL && *x_display != '\0') {
- LYisConfiguredForX = TRUE;
- }
- ena_csi((LYlowest_eightbit[current_char_set] > 155));
- status = mainloop();
- cleanup();
+ if (x_display != NULL && *x_display != '\0') {
+ LYisConfiguredForX = TRUE;
}
+ ena_csi((LYlowest_eightbit[current_char_set] > 155));
+ status = mainloop();
+ cleanup();
}
exit(status);
@@ -1890,14 +1884,13 @@ static int assume_charset_fun ARGS3(
char **, argv GCC_UNUSED,
char *, next_arg)
{
- if (next_arg == 0) {
- UCLYhndl_for_unspec = UCGetLYhndl_byMIME("iso-8859-1");
- } else {
- LYLowerCase(next_arg);
- StrAllocCopy(UCAssume_MIMEcharset, next_arg);
- if (UCAssume_MIMEcharset && *UCAssume_MIMEcharset)
- UCLYhndl_for_unspec = UCGetLYhndl_byMIME(UCAssume_MIMEcharset);
- }
+ UCLYhndl_for_unspec = safeUCGetLYhndl_byMIME(next_arg);
+ StrAllocCopy(UCAssume_MIMEcharset,
+ LYCharSet_UC[UCLYhndl_for_unspec].MIMEname);
+/* this may be a memory for bogus typo -
+ StrAllocCopy(UCAssume_MIMEcharset, next_arg);
+ LYLowerCase(UCAssume_MIMEcharset); */
+
return 0;
}
@@ -1907,15 +1900,7 @@ static int assume_local_charset_fun ARGS3(
char **, argv GCC_UNUSED,
char *, next_arg)
{
- if (next_arg == 0) {
- UCLYhndl_HTFile_for_unspec = UCGetLYhndl_byMIME("iso-8859-1");
- } else {
- LYLowerCase(next_arg);
- StrAllocCopy(UCAssume_localMIMEcharset, next_arg);
- if (UCAssume_localMIMEcharset && *UCAssume_localMIMEcharset)
- UCLYhndl_HTFile_for_unspec =
- UCGetLYhndl_byMIME(UCAssume_localMIMEcharset);
- }
+ UCLYhndl_HTFile_for_unspec = safeUCGetLYhndl_byMIME(next_arg);
return 0;
}
@@ -1925,14 +1910,7 @@ static int assume_unrec_charset_fun ARGS3(
char **, argv GCC_UNUSED,
char *, next_arg)
{
- if (next_arg == 0) {
- UCLYhndl_for_unrec = UCGetLYhndl_byMIME("iso-8859-1");
- } else {
- LYLowerCase(next_arg);
- StrAllocCopy(UCAssume_unrecMIMEcharset, next_arg);
- if (UCAssume_unrecMIMEcharset && *UCAssume_unrecMIMEcharset)
- UCLYhndl_for_unrec = UCGetLYhndl_byMIME(UCAssume_unrecMIMEcharset);
- }
+ UCLYhndl_for_unrec = safeUCGetLYhndl_byMIME(next_arg);
return 0;
}
diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c
index a65bee19..bba831b3 100644
--- a/src/LYMainLoop.c
+++ b/src/LYMainLoop.c
@@ -4344,8 +4344,8 @@ check_goto_URL:
*/
if (strcmp((curdoc.title ? curdoc.title : ""),
SHOWINFO_TITLE)) {
- if (!showinfo(&curdoc, lines_in_file,
- &newdoc, owner_address))
+ if (showinfo(&curdoc, lines_in_file,
+ &newdoc, owner_address) < 0)
break;
StrAllocCopy(newdoc.title, SHOWINFO_TITLE);
FREE(newdoc.post_data);
@@ -4381,7 +4381,8 @@ check_goto_URL:
if (strcmp((curdoc.title ? curdoc.title : ""),
PRINT_OPTIONS_TITLE)) {
- if (print_options(&newdoc.address, lines_in_file) < 0)
+ if (print_options(&newdoc.address,
+ &curdoc.address, lines_in_file) < 0)
break;
StrAllocCopy(newdoc.title, PRINT_OPTIONS_TITLE);
FREE(newdoc.post_data);
diff --git a/src/LYOptions.c b/src/LYOptions.c
index 41017171..50643fb8 100644
--- a/src/LYOptions.c
+++ b/src/LYOptions.c
@@ -837,7 +837,6 @@ draw_options:
* character set if changed. - FM
*/
if (CurrentCharSet != current_char_set) {
- HTMLSetRawModeDefault(current_char_set);
LYUseDefaultRawMode = TRUE;
HTMLUseCharacterSet(current_char_set);
CurrentCharSet = current_char_set;
@@ -2237,7 +2236,7 @@ PRIVATE int popup_choice ARGS6(
if (!(form_window = newwin(bottom - top, (Lnum + width + 4),
top, (lx - 1))) &&
!(form_window = newwin(bottom - top, 0, top, 0))) {
- _statusline(POPUP_FAILED);
+ HTAlert(POPUP_FAILED);
return(orig_choice);
}
scrollok(form_window, TRUE);
@@ -2395,9 +2394,6 @@ redraw:
term_options = FALSE;
c = LYgetch();
if (term_options || c == 3 || c == 7) {
- /*
- * Control-C or Control-G
- */
cmd = LYK_QUIT;
} else {
cmd = keymap[c+1];
@@ -3115,9 +3111,10 @@ static char * cookies_string = "cookies";
static char * cookies_ignore_all_string = "ignore";
static char * cookies_up_to_user_string = "ask user";
static char * cookies_accept_all_string = "accept all";
-static char * display_string = "display";
+static char * x_display_string = "display";
static char * editor_string = "editor";
static char * emacs_keys_string = "emacs_keys";
+
#ifdef ALLOW_USERS_TO_CHANGE_EXEC_WITHIN_OPTIONS
#define EXEC_ALWAYS 2
#define EXEC_LOCAL 1
@@ -3131,6 +3128,7 @@ static OptValues exec_links_values[] = {
#endif
{ 0, 0, 0 }};
#endif /* ALLOW_USERS_TO_CHANGE_EXEC_WITHIN_OPTIONS */
+
static char * keypad_mode_string = "keypad_mode";
static OptValues keypad_mode_values[] = {
{ NUMBERS_AS_ARROWS, "Numbers act as arrows", "number_arrows" },
@@ -3415,8 +3413,8 @@ PUBLIC int postoptions ARGS1(
}
}
- /* Display: INPUT */
- if (!strcmp(data[i].tag, display_string)) {
+ /* X Display: INPUT */
+ if (!strcmp(data[i].tag, x_display_string)) {
LYsetXDisplay(data[i].value);
}
@@ -3487,9 +3485,14 @@ PUBLIC int postoptions ARGS1(
LYShowCursor = GetOptValues(bool_values, data[i].value);
}
- /* User Mode: Default: */
+ /* User Mode: SELECT */
if (!strcmp(data[i].tag, user_mode_string)) {
user_mode = GetOptValues(user_mode_values, data[i].value);
+ if (user_mode == NOVICE_MODE) {
+ display_lines = (LYlines - 4);
+ } else {
+ display_lines = LYlines-2;
+ }
}
/* Verbose Images: ON/OFF */
@@ -3611,7 +3614,6 @@ PUBLIC int postoptions ARGS1(
* Set the LYUseDefaultRawMode value and character
* handling if LYRawMode was changed. - FM
*/
- HTMLSetRawModeDefault(current_char_set);
LYUseDefaultRawMode = TRUE;
HTMLUseCharacterSet(current_char_set);
}
@@ -3651,6 +3653,16 @@ PUBLIC int postoptions ARGS1(
return(NULLFILE);
}
+PRIVATE char *NewSecureValue NOARGS
+{
+ FREE(secure_value);
+ if ((secure_value = malloc(80)) != 0) {
+ sprintf(secure_value, "%ld", (long)secure_value + (long)time(0));
+ return secure_value;
+ }
+ return "?";
+}
+
/*
* Okay, someone wants to change options. So, lets gen up a form for them
* and pass it around. Gor, this is ugly. Be a lot easier in Bourne with
@@ -3685,7 +3697,7 @@ PUBLIC int gen_options ARGS1(
StrAllocCopy(*newfile, any_filename);
LYforce_no_cache = TRUE;
- BeginInternalPage(fp0, OPTIONS_TITLE, OPTIONS_HELP);
+ BeginInternalPage(fp0, OPTIONS_TITLE, NULL); /* help link below */
/*
* I do C, not HTML. Feel free to pretty this up.
@@ -3696,10 +3708,8 @@ PUBLIC int gen_options ARGS1(
* (or was it CUTE?) telnet one shot password to allow ftp to self.
* to prevent spoofing.
*/
- FREE(secure_value);
- StrAllocCopy(secure_value, "FIXMEtest=the&encoding");
fprintf(fp0,"<input name=\"%s\" type=\"hidden\" value=\"%s\">\n",
- secure_string, secure_value);
+ secure_string, NewSecureValue());
/*
* visible text begins here
@@ -3740,11 +3750,7 @@ PUBLIC int gen_options ARGS1(
cookies_accept_all_string);
EndSelect(fp0);
- /* Display: Input */
- PutLabel(fp0, "Display");
- PutTextInput(fp0, display_string, NOTEMPTY(x_display), text_len, "");
-
- /* Editor: Input */
+ /* Editor: INPUT */
PutLabel(fp0, "Editor");
PutTextInput(fp0, editor_string, NOTEMPTY(editor), text_len,
DISABLED(no_editor || system_editor));
@@ -3848,7 +3854,7 @@ PUBLIC int gen_options ARGS1(
PutOptValues(fp0, LYShowCursor, bool_values);
EndSelect(fp0);
- /* User Mode: Default: */
+ /* User Mode: SELECT */
PutLabel(fp0, "User mode");
BeginSelect(fp0, user_mode_string);
PutOptValues(fp0, user_mode, user_mode_values);
@@ -3867,6 +3873,10 @@ PUBLIC int gen_options ARGS1(
EndSelect(fp0);
+ /* X Display: INPUT */
+ PutLabel(fp0, "X Display");
+ PutTextInput(fp0, x_display_string, NOTEMPTY(x_display), text_len, "");
+
/*
* Bookmark Options
*/
@@ -4003,7 +4013,7 @@ PUBLIC int gen_options ARGS1(
PutTextInput(fp0, preferred_doc_lang_string,
NOTEMPTY(language), cset_len+2, "");
- /* User Agent: INPUT */
+ /* User Agent: INPUT */
if (!no_useragent) {
PutLabel(fp0, "User-Agent header");
PutTextInput(fp0, user_agent_string,
diff --git a/src/LYPrint.c b/src/LYPrint.c
index 24c824ee..8b95de3a 100644
--- a/src/LYPrint.c
+++ b/src/LYPrint.c
@@ -1244,8 +1244,9 @@ PRIVATE int remove_quotes ARGS1(
* LYNXPRINT://MAIL_FILE/lines=# mail the file
* LYNXPRINT://PRINTER/lines=#/number=# print to printer number #
*/
-PUBLIC int print_options ARGS2(
+PUBLIC int print_options ARGS3(
char **, newfile,
+ char **, printed_url,
int, lines_in_file)
{
static char tempfile[256];
@@ -1256,7 +1257,6 @@ PUBLIC int print_options ARGS2(
FILE *fp0;
lynx_printer_item_type *cur_printer;
- pages = lines_in_file/66 + 1;
LYRemoveTemp(tempfile);
if ((fp0 = LYOpenTemp(tempfile, HTML_SUFFIX, "w")) == NULL) {
@@ -1271,13 +1271,17 @@ PUBLIC int print_options ARGS2(
BeginInternalPage(fp0, PRINT_OPTIONS_TITLE, PRINT_OPTIONS_HELP);
fprintf(fp0, "<pre>\n");
+
+ /* pages = lines_in_file/66 + 1; */
pages = (lines_in_file+65)/66;
sprintf(buffer, " \
-<em>You print the document:</em> %s\n \
- <em>Number of lines:</em> %d\n \
- <em>Number of pages:</em> %d page%s (approximately)\n",
- tempfile, lines_in_file, pages, (pages > 1 ? "s" : ""));
- fputs(buffer,fp0);
+<em>Document:</em> %s\n \
+<em>Number of lines:</em> %d\n \
+<em>Number of pages:</em> %d page%s (approximately)\n",
+ *printed_url,
+ lines_in_file,
+ pages, (pages > 1 ? "s" : ""));
+ fputs(buffer, fp0);
if (no_print || no_disk_save || child_lynx || no_mail)
fprintf(fp0, " <em>Some print functions have been disabled!</em>\n");
diff --git a/src/LYPrint.h b/src/LYPrint.h
index 5229e368..12efe47c 100644
--- a/src/LYPrint.h
+++ b/src/LYPrint.h
@@ -1,4 +1,3 @@
-
#ifndef LYPRINT_H
#define LYPRINT_H
@@ -7,7 +6,8 @@
#endif /* LYSTRUCTS_H */
extern int printfile PARAMS((document *newdoc));
-extern int print_options PARAMS((char **newfile, int lines_in_file));
+extern int print_options PARAMS((char **newfile,
+ char **printed_url, int lines_in_file));
#endif /* LYPRINT_H */
diff --git a/src/LYReadCFG.c b/src/LYReadCFG.c
index f68c0d94..bf422aa6 100644
--- a/src/LYReadCFG.c
+++ b/src/LYReadCFG.c
@@ -489,27 +489,27 @@ Config_Type;
static int assume_charset_fun ARGS1(
char *, value)
{
+ UCLYhndl_for_unspec = safeUCGetLYhndl_byMIME(value);
+ StrAllocCopy(UCAssume_MIMEcharset,
+ LYCharSet_UC[UCLYhndl_for_unspec].MIMEname);
+/* this may be a memory for bogus typo -
StrAllocCopy(UCAssume_MIMEcharset, value);
- LYLowerCase(UCAssume_MIMEcharset);
- UCLYhndl_for_unspec = UCGetLYhndl_byMIME(UCAssume_MIMEcharset);
+ LYLowerCase(UCAssume_MIMEcharset); */
+
return 0;
}
static int assume_local_charset_fun ARGS1(
char *, value)
{
- StrAllocCopy(UCAssume_localMIMEcharset, value);
- LYLowerCase(UCAssume_localMIMEcharset);
- UCLYhndl_HTFile_for_unspec = UCGetLYhndl_byMIME(UCAssume_localMIMEcharset);
+ UCLYhndl_HTFile_for_unspec = safeUCGetLYhndl_byMIME(value);
return 0;
}
static int assume_unrec_charset_fun ARGS1(
char *, value)
{
- StrAllocCopy(UCAssume_unrecMIMEcharset, value);
- LYLowerCase(UCAssume_unrecMIMEcharset);
- UCLYhndl_for_unrec = UCGetLYhndl_byMIME(UCAssume_unrecMIMEcharset);
+ UCLYhndl_for_unrec = safeUCGetLYhndl_byMIME(value);
return 0;
}
@@ -523,13 +523,11 @@ static int character_set_fun ARGS1(
for (i = 0; LYchar_set_names[i]; i++) { /* search by name, compatibility */
if (!strncmp(value, LYchar_set_names[i], len)) {
current_char_set = i;
- HTMLSetRawModeDefault(current_char_set);
return 0;
}
}
- current_char_set = UCGetLYhndl_byMIME(value); /* by MIME */
- HTMLSetRawModeDefault(current_char_set);
+ current_char_set = safeUCGetLYhndl_byMIME(value); /* by MIME */
return 0;
}
diff --git a/src/LYShowInfo.c b/src/LYShowInfo.c
index 7b88643c..9ab29041 100644
--- a/src/LYShowInfo.c
+++ b/src/LYShowInfo.c
@@ -21,6 +21,44 @@
#include <LYLocal.h>
#endif /* DIRED_SUPPORT */
+#ifdef HAVE_CONFIG_H
+#define HAVE_CFG_DEFS_H
+
+#define PutDefs(table, n) fprintf(fp0, "%-35s %s\n", table[n].name, table[n].value)
+
+PRIVATE char *lynx_compile_opts NOARGS
+{
+ static char tempfile[256];
+#include <cfg_defs.h>
+ unsigned n;
+ FILE *fp0;
+
+ if (strlen(tempfile) == 0) {
+ if ((fp0 = LYOpenTemp (tempfile, HTML_SUFFIX, "w")) == 0) {
+ HTAlert(CANNOT_OPEN_TEMP);
+ tempfile[0] = '\0';
+ return(0);
+ }
+ BeginInternalPage (fp0, CONFIG_DEF_TITLE, (char *)0);
+ fprintf(fp0, "<pre>\n");
+ fprintf(fp0, "\n<em>config.cache</em>\n");
+ for (n = 0; n < TABLESIZE(config_cache); n++) {
+ PutDefs(config_cache, n);
+ }
+ fprintf(fp0, "\n<em>lynx_cfg.h</em>\n");
+ for (n = 0; n < TABLESIZE(config_defines); n++) {
+ PutDefs(config_defines, n);
+ }
+ fprintf(fp0, "</pre>\n");
+ EndInternalPage(fp0);
+ LYCloseTempFP(fp0);
+ }
+ return tempfile;
+}
+#else
+#undef HAVE_CFG_DEFS_H
+#endif
+
/*
* Showinfo prints a page of info about the current file and the link
* that the cursor is on.
@@ -49,7 +87,7 @@ PUBLIC int showinfo ARGS4(
LYRemoveTemp(tempfile);
if ((fp0 = LYOpenTemp (tempfile, HTML_SUFFIX, "w")) == 0) {
HTAlert(CANNOT_OPEN_TEMP);
- return(0);
+ return(-1);
}
LYLocalFileToURL(info_url, tempfile);
@@ -76,12 +114,12 @@ PUBLIC int showinfo ARGS4(
fprintf(fp0, "<title>%s</title>\n</head>\n<body>\n",
SHOWINFO_TITLE);
-#ifdef LYNX_COMPILE_OPTS
+#ifdef HAVE_CFG_DEFS_H
fprintf(fp0, "<h1>%s %s (<a href=\"%s\">%s</a>) - <a href=\"%s\">compile time settings</a></h1>\n",
LYNX_NAME, LYNX_VERSION,
(LYNX_RELEASE ? LYNX_WWW_HOME : LYNX_WWW_DIST),
(LYNX_RELEASE ? "major release" : "development version"),
- LYNX_COMPILE_OPTS);
+ lynx_compile_opts());
#else
fprintf(fp0, "<h1>%s %s (<a href=\"%s\">%s</a>)</h1>\n",
LYNX_NAME, LYNX_VERSION,
@@ -354,5 +392,5 @@ PUBLIC int showinfo ARGS4(
FREE(Address);
FREE(Title);
- return(1);
+ return(0);
}
diff --git a/src/LYStrings.c b/src/LYStrings.c
index 7ee93c99..58fb3452 100644
--- a/src/LYStrings.c
+++ b/src/LYStrings.c
@@ -56,37 +56,47 @@ PUBLIC int get_mouse_link NOARGS
PRIVATE int set_clicked_link ARGS2(int,x,int,y)
{
- int i;
-
- /* Loop over the links and see if we can get a match */
- for(i=0; i < nlinks && mouse_link == -1; i++) {
- /* Check the first line of the link */
- if ( links[i].hightext != NULL &&
- links[i].ly == y &&
- (x - links[i].lx) < (int)strlen(links[i].hightext ) ) {
- mouse_link=i;
- }
- /* Check the second line */
- if (links[i].hightext2 != NULL &&
- 1+links[i].ly == y &&
- (x - links[i].hightext2_offset) < (int)strlen(links[i].hightext2) ) {
- mouse_link=i;
+ int left = 6;
+ int right = LYcols-6;
+ /* yes, I am assuming that my screen will be a certain width. */
+ int i;
+ int c = -1;
+
+ if (y == (LYlines-1)) {
+ if (x < left) c = LTARROW;
+ else if (x > right) c = '\b';
+ else c = PGDOWN;
+ } else if (y == 0) {
+ if (x < left) c = LTARROW;
+ else if (x > right) c = '\b';
+ else c = PGUP;
+ } else {
+ /* Loop over the links and see if we can get a match */
+ for (i = 0; i < nlinks; i++) {
+ /* Check the first line of the link */
+ if ( links[i].hightext != NULL &&
+ links[i].ly == y &&
+ (x - links[i].lx) < (int)strlen(links[i].hightext ) ) {
+ mouse_link = i;
+ break;
+ }
+ /* Check the second line */
+ if (links[i].hightext2 != NULL &&
+ 1+links[i].ly == y &&
+ (x - links[i].hightext2_offset) < (int)strlen(links[i].hightext2) ) {
+ mouse_link = i;
+ break;
+ }
+ }
+ /*
+ * If a link was hit, we must look for a key which will activate
+ * LYK_ACTIVATE We expect to find LYK_ACTIVATE (it's usually mapped to
+ * the Enter key).
+ */
+ if (mouse_link >= 0)
+ c = lookup_keymap(LYK_ACTIVATE);
}
- }
- /* If no link was found, just return a do-nothing code */
- if (mouse_link == -1) return -1;
-
- /* If a link was hit, we must look for a key which will activate LYK_ACTIVATE
- ** We expect to find LYK_ACTIVATE (it's usually mapped to the Enter key).
- **/
- if ((i = lookup_keymap(LYK_ACTIVATE)) >= 0)
- return i;
-
- /* Whoops! Nothing's defined as LYK_ACTIVATE!
- Well, who are we to argue with the user?
- Forget about the mouse click */
- mouse_link = -1;
- return -1;
+ return c;
}
@@ -100,7 +110,7 @@ PUBLIC char *LYstrncpy ARGS3(
int, n)
{
char *val;
- int len=strlen(src);
+ int len = strlen(src);
if (n < 0)
n = 0;
@@ -300,9 +310,7 @@ PRIVATE int sl_parse_mouse_event ARGS3(int *, x, int *, y, int *, button)
*y = SLang_getkey () - 33;
return 0;
}
-#endif
-#if defined(USE_SLANG_MOUSE)
PRIVATE int sl_read_mouse_event NOARGS
{
int mouse_x, mouse_y, button;
@@ -333,198 +341,439 @@ PUBLIC void ena_csi ARGS1(
csi_is_csi = flag;
}
-#if defined(USE_SLANG_KEYMAPS)
-static SLKeyMap_List_Type *Keymap_List;
+#if defined(USE_KEYMAPS)
+#ifdef USE_SLANG
+#define define_key(string, code) \
+ SLkm_define_keysym (string, code, Keymap_List)
+#define expand_substring(dst, first, last) \
+ SLexpand_escaped_string(dst, first, last)
+static SLKeyMap_List_Type *Keymap_List;
/* This value should be larger than anything in LYStrings.h */
#define MOUSE_KEYSYM 0x1000
+#endif
+
+
+#define SQUOTE '\''
+#define DQUOTE '"'
+#define ESCAPE '\\'
+#define LPAREN '('
+#define RPAREN ')'
+
+/*
+ * For ncurses, we use the predefined keysyms, since that lets us also reuse
+ * the CSI logic and other special cases for VMS, NCSA telnet, etc.
+ */
+#ifdef USE_SLANG
+#define DEFINE_KEY(string,lynx,curses) {string,lynx}
+#else
+#define DEFINE_KEY(string,lynx,curses) {string,curses}
+#endif
typedef struct
{
- char *name;
- int keysym;
+ char *string;
+ int value;
}
Keysym_String_List;
static Keysym_String_List Keysym_Strings [] =
{
- {"UPARROW", UPARROW},
- {"DNARROW", DNARROW},
- {"RTARROW", RTARROW},
- {"LTARROW", LTARROW},
- {"PGDOWN", PGDOWN},
- {"PGUP", PGUP},
- {"HOME", HOME},
- {"END", END_KEY},
- {"F1", F1},
- {"DO_KEY", DO_KEY},
- {"FIND_KEY", FIND_KEY},
- {"SELECT_KEY", SELECT_KEY},
- {"INSERT_KEY", INSERT_KEY},
- {"REMOVE_KEY", REMOVE_KEY},
- {"DO_NOTHING", DO_NOTHING},
- {NULL, -1}
+ DEFINE_KEY( "UPARROW", UPARROW, KEY_UP ),
+ DEFINE_KEY( "DNARROW", DNARROW, KEY_DOWN ),
+ DEFINE_KEY( "RTARROW", RTARROW, KEY_RIGHT ),
+ DEFINE_KEY( "LTARROW", LTARROW, KEY_LEFT ),
+ DEFINE_KEY( "PGDOWN", PGDOWN, KEY_NPAGE ),
+ DEFINE_KEY( "PGUP", PGUP, KEY_PPAGE ),
+ DEFINE_KEY( "HOME", HOME, KEY_HOME ),
+ DEFINE_KEY( "END", END_KEY, KEY_END ),
+ DEFINE_KEY( "F1", F1, KEY_F(1) ),
+ DEFINE_KEY( "DO_KEY", DO_KEY, KEY_F(16) ),
+ DEFINE_KEY( "FIND_KEY", FIND_KEY, KEY_FIND ),
+ DEFINE_KEY( "SELECT_KEY", SELECT_KEY, KEY_SELECT ),
+ DEFINE_KEY( "INSERT_KEY", INSERT_KEY, KEY_IC ),
+ DEFINE_KEY( "REMOVE_KEY", REMOVE_KEY, KEY_DC ),
+ DEFINE_KEY( "DO_NOTHING", DO_NOTHING, 0 ),
+ DEFINE_KEY( NULL, -1, ERR )
};
-PRIVATE int map_string_to_keysym (char *str, int *keysym)
+#ifdef NCURSES_VERSION
+/*
+ * Ncurses stores the termcap/terminfo names in arrays sorted to match the
+ * array of strings in the TERMTYPE struct.
+ */
+PRIVATE int lookup_tiname (char *name, NCURSES_CONST char *const *names)
{
- Keysym_String_List *k;
+ int code;
- k = Keysym_Strings;
- while (k->name != NULL)
- {
- if (0 == strcmp (k->name, str))
- {
- *keysym = k->keysym;
- return 0;
- }
- k++;
- }
- fprintf (stderr, "Keysym %s is unknown\n", str);
- *keysym = -1;
- return -1;
+ for (code = 0; names[code] != 0; code++)
+ if (!strcmp(names[code], name))
+ return code;
+ return -1;
}
-
-/* The second argument may either be a string or and integer */
-PRIVATE int setkey_cmd (int argc GCC_UNUSED, SLcmd_Cmd_Table_Type *table)
+PRIVATE char *expand_tiname (char *first, size_t len, char **result)
{
- char *keyseq;
- int keysym;
+ char name[BUFSIZ];
+ int code;
+
+ strncpy(name, first, len);
+ name[len] = '\0';
+ if ((code = lookup_tiname(name, strnames)) >= 0
+ || (code = lookup_tiname(name, strfnames)) >= 0) {
+ strcpy(*result, cur_term->type.Strings[code]);
+ (*result) += strlen(*result);
+ }
+ return first + len;
+}
- keyseq = table->string_args [1];
- switch (table->arg_type[2])
- {
- case SLANG_INT_TYPE:
- keysym = table->int_args[2];
+PRIVATE char *expand_tichar (char *first, char **result)
+{
+ int ch;
+ int limit = 0;
+ int radix = 0;
+ int value = 0;
+ char *name = 0;
+
+ switch (ch = *first++) {
+ case 'E': case 'e': value = 27; break;
+ case 'a': name = "bel"; break;
+ case 'b': value = '\b'; break;
+ case 'f': value = '\f'; break;
+ case 'n': value = '\n'; break;
+ case 'r': value = '\r'; break;
+ case 't': value = '\t'; break;
+ case 'v': value = '\v'; break;
+ case 'd': radix = 10; limit = 3; break;
+ case 'x': radix = 16; limit = 2; break;
+ default:
+ if (isdigit(ch)) {
+ radix = 8;
+ limit = 3;
+ first--;
+ } else {
+ value = *first;
+ }
break;
+ }
- case SLANG_STRING_TYPE:
- if (-1 == map_string_to_keysym (table->string_args[2], &keysym))
- return -1;
- break;
+ if (radix != 0) {
+ char *last;
+ int save = first[limit];
+ first[limit] = '\0';
+ value = strtol(first, &last, radix);
+ first[limit] = save;
+ first = last;
+ }
- default:
- return -1;
- }
+ if (name != 0) {
+ (void) expand_tiname(name, strlen(name), result);
+ } else {
+ **result = value;
+ (*result) += 1;
+ }
- return SLkm_define_keysym (keyseq, keysym, Keymap_List);
+ return first;
+}
+
+PRIVATE void expand_substring (char* dst, char* first, char* last)
+{
+ int ch;
+ while (first < last) {
+ switch (ch = *first++) {
+ case ESCAPE:
+ first = expand_tichar(first, &dst);
+ break;
+ case '^':
+ ch = *first++;
+ if (ch == LPAREN) {
+ char *s = strchr(first, RPAREN);
+ if (s == 0)
+ s = first + strlen(first);
+ first = expand_tiname(first, s-first, &dst);
+ } else if (ch == '?') { /* ASCII delete? */
+ *dst++ = 127;
+ } else if ((ch & 0x3f) < 0x20) { /* ASCII control char? */
+ *dst++ = (ch & 0x1f);
+ } else {
+ *dst++ = '^';
+ first--; /* not legal... */
+ }
+ break;
+ case 0: /* convert nulls for terminfo */
+ ch = 0200;
+ /* FALLTHRU */
+ default:
+ *dst++ = ch;
+ break;
+ }
+ }
+ *dst = '\0';
}
+#endif
-PRIVATE int unsetkey_cmd (int argc GCC_UNUSED, SLcmd_Cmd_Table_Type *table)
+PRIVATE void unescaped_char ARGS2(char*, parse, int*,keysym)
{
- SLang_undefine_key (table->string_args[1], Keymap_List);
- if (SLang_Error) return -1;
- return 0;
+ size_t len = strlen(parse);
+ char buf[BUFSIZ];
+
+ if (len >= 3) {
+ expand_substring(buf, parse + 1, parse + len - 1);
+ if (strlen(buf) == 1)
+ *keysym = *buf;
+ }
}
-static SLcmd_Cmd_Type Keymap_Cmd_Table [] =
+PRIVATE BOOLEAN unescape_string ARGS2(char*, src, char *, dst)
{
- {setkey_cmd, "setkey", "SG"},
- {unsetkey_cmd, "unsetkey", "S"},
- {NULL}
-};
+ BOOLEAN ok = FALSE;
+
+ if (*src == SQUOTE) {
+ int keysym;
+ unescaped_char(src, &keysym);
+ if (keysym >= 0) {
+ dst[0] = keysym;
+ dst[1] = '\0';
+ ok = TRUE;
+ }
+ } else if (*src == DQUOTE) {
+ expand_substring(dst, src + 1, src + strlen(src) - 1);
+ ok = TRUE;
+ }
+ return ok;
+}
-PRIVATE int read_keymap_file NOARGS
+PRIVATE int map_string_to_keysym ARGS2(char*, str, int*,keysym)
{
- char line[1024];
- FILE *fp;
- char file[1024];
- char *home;
- char *keymap_file;
- int ret;
- SLcmd_Cmd_Table_Type tbl;
- int linenum;
+ *keysym = -1;
+
+ if (*str == SQUOTE) {
+ unescaped_char(str, keysym);
+ } else if (isdigit(*str)) {
+ char *tmp;
+ long value = strtol(str, &tmp, 0);
+ if (!isalnum(*tmp))
+ *keysym = value;
+ } else {
+ Keysym_String_List *k;
-#ifdef VMS
- keymap_file = "lynx.keymaps";
- home = "SYS$LOGIN:";
-#else
-#ifdef FNAMES_8_3
- keymap_file = "/_lynxkey.map";
-#else
- keymap_file = "/.lynx-keymaps";
-#endif /* FNAMES_8_3 */
- home = getenv ("HOME");
- if (home == NULL) home = "";
-#endif
+ k = Keysym_Strings;
+ while (k->string != NULL) {
+ if (0 == strcmp (k->string, str)) {
+ *keysym = k->value;
+ break;
+ }
+ k++;
+ }
+ }
- sprintf (file, "%s%s", home, keymap_file);
+ return (*keysym);
+}
- if (NULL == (fp = fopen (file, "r")))
- return 0;
+/*
+ * Starting at a nonblank character, skip over a token, counting quoted and
+ * escaped characters.
+ */
+PRIVATE char *skip_keysym ARGS1(char *, parse)
+{
+ int quoted = 0;
+ int escaped = 0;
+
+ while (*parse) {
+ if (escaped) {
+ escaped = 0;
+ } else if (quoted) {
+ if (*parse == ESCAPE) {
+ escaped = 1;
+ } else if (*parse == quoted) {
+ quoted = 0;
+ }
+ } else if (*parse == ESCAPE) {
+ escaped = 1;
+ } else if (*parse == DQUOTE || *parse == SQUOTE) {
+ quoted = *parse;
+ } else if (isspace(*parse)) {
+ break;
+ }
+ parse++;
+ }
+ return (quoted || escaped) ? 0 : parse;
+}
- tbl.table = Keymap_Cmd_Table;
+/*
+ * The first token is the string to define, the second is the name (of the
+ * keysym) to define it to.
+ */
+PRIVATE int setkey_cmd (char *parse)
+{
+ char *s, *t;
+ int keysym;
+ char buf[BUFSIZ];
+
+ if ((s = skip_keysym(parse)) != 0) {
+ if (isspace(*s)) {
+ *s++ = '\0';
+ s = LYSkipBlanks(s);
+ if ((t = skip_keysym(s)) == 0)
+ return -1;
+ if (t != s)
+ *t = '\0';
+ if (map_string_to_keysym (s, &keysym) >= 0
+ && unescape_string(parse, buf)) {
+ return define_key(buf, keysym);
+ }
+ }
+ }
+ return -1;
+}
- linenum = 0;
- ret = 0;
- while (NULL != fgets (line, sizeof (line), fp))
- {
+PRIVATE int unsetkey_cmd (char *parse)
+{
+ char *s = skip_keysym(parse);
+ if (s != parse) {
+ *s = '\0';
+#ifdef NCURSES_VERSION
+ /*
+ * This won't work with Slang. Remove the definition for the given
+ * keysym.
+ */
+ {
+ int keysym;
+ if (map_string_to_keysym (parse, &keysym) >= 0)
+ define_key((char *)0, keysym);
+ }
+#endif
+#ifdef USE_SLANG
+ /* Slang implements this, for undefining the string which is associated
+ * with a keysym (the reverse of what we normally want, but may
+ * occasionally find useful).
+ */
+ SLang_undefine_key (parse, Keymap_List);
+ if (SLang_Error) return -1;
+#endif
+ }
+ return 0;
+}
+
+#ifdef FNAMES_8_3
+#define FNAME_LYNX_KEYMAPS "_lynxkey.map"
+#else
+#define FNAME_LYNX_KEYMAPS ".lynx-keymaps"
+#endif /* FNAMES_8_3 */
+
+PRIVATE int read_keymap_file NOARGS
+{
+ static struct {
+ CONST char *name;
+ int (*func) PARAMS((char *s));
+ } table[] = {
+ {"setkey", setkey_cmd },
+ {"unsetkey", unsetkey_cmd },
+ };
+
+ char line[1024];
+ FILE *fp;
+ char file[LY_MAXPATH];
+ int ret;
+ int linenum;
+ size_t n;
+
+ LYAddPathToHome(file, sizeof(file), FNAME_LYNX_KEYMAPS);
+
+ if ((fp = fopen (file, "r")) == 0)
+ return 0;
+
+ linenum = 0;
+ ret = 0;
+ while ((fgets (line, sizeof (line), fp) != 0) && (ret == 0))
+ {
char *s = LYSkipBlanks(line);
linenum++;
if ((*s == 0) || (*s == '#'))
- continue;
+ continue;
- if (-1 == SLcmd_execute_string (s, &tbl))
- {
- ret = -1;
- break;
- }
- }
+ for (n = 0; n < TABLESIZE(table); n++) {
+ size_t len = strlen(table[n].name);
+ if (strlen(s) > len
+ && !strncmp(s, table[n].name, len)) {
+ if ((*(table[n].func))(LYSkipBlanks(s+len)) < 0) {
+ ret = -1;
+ break;
+ }
+ }
+ }
+ }
- fclose (fp);
+ fclose (fp);
- if (ret == -1)
- fprintf (stderr, "Error processing line %d of %s\n", linenum, file);
+ if (ret == -1)
+ fprintf (stderr, "Error processing line %d of %s\n", linenum, file);
- return ret;
+ return ret;
+}
+
+PRIVATE void setup_vtXXX_keymap NOARGS
+{
+ static Keysym_String_List table[] = {
+ DEFINE_KEY( "\033[A", UPARROW, KEY_UP ),
+ DEFINE_KEY( "\033OA", UPARROW, KEY_UP ),
+ DEFINE_KEY( "\033[B", DNARROW, KEY_DOWN ),
+ DEFINE_KEY( "\033OB", DNARROW, KEY_DOWN ),
+ DEFINE_KEY( "\033[C", RTARROW, KEY_RIGHT ),
+ DEFINE_KEY( "\033OC", RTARROW, KEY_RIGHT ),
+ DEFINE_KEY( "\033[D", LTARROW, KEY_LEFT ),
+ DEFINE_KEY( "\033OD", LTARROW, KEY_LEFT ),
+ DEFINE_KEY( "\033[1~", FIND_KEY, KEY_FIND ),
+ DEFINE_KEY( "\033[2~", INSERT_KEY, KEY_IC ),
+ DEFINE_KEY( "\033[3~", REMOVE_KEY, KEY_DC ),
+ DEFINE_KEY( "\033[4~", SELECT_KEY, KEY_SELECT ),
+ DEFINE_KEY( "\033[5~", PGUP, KEY_PPAGE ),
+ DEFINE_KEY( "\033[6~", PGDOWN, KEY_NPAGE ),
+ DEFINE_KEY( "\033[8~", END_KEY, KEY_END ),
+ DEFINE_KEY( "\033[7~", HOME, KEY_HOME),
+ DEFINE_KEY( "\033[28~", F1, KEY_F(0) ),
+ DEFINE_KEY( "\033[29~", DO_KEY, KEY_F(6) ),
+ };
+ size_t n;
+ for (n = 0; n < TABLESIZE(table); n++)
+ define_key(table[n].string, table[n].value);
}
PUBLIC int lynx_initialize_keymaps NOARGS
{
- int i;
- char keybuf[2];
+#ifdef USE_SLANG
+ int i;
+ char keybuf[2];
- if (NULL == (Keymap_List = SLang_create_keymap ("Lynx", NULL)))
- return -1;
+ if (NULL == (Keymap_List = SLang_create_keymap ("Lynx", NULL)))
+ return -1;
- keybuf[1] = 0;
- for (i = 1; i < 256; i++)
- {
+ keybuf[1] = 0;
+ for (i = 1; i < 256; i++)
+ {
keybuf[0] = (char) i;
- SLkm_define_keysym (keybuf, i, Keymap_List);
- }
+ define_key (keybuf, i);
+ }
- SLkm_define_keysym ("\033[A", UPARROW, Keymap_List);
- SLkm_define_keysym ("\033OA", UPARROW, Keymap_List);
- SLkm_define_keysym ("\033[B", DNARROW, Keymap_List);
- SLkm_define_keysym ("\033OB", DNARROW, Keymap_List);
- SLkm_define_keysym ("\033[C", RTARROW, Keymap_List);
- SLkm_define_keysym ("\033OC", RTARROW, Keymap_List);
- SLkm_define_keysym ("\033[D", LTARROW, Keymap_List);
- SLkm_define_keysym ("\033OD", LTARROW, Keymap_List);
- SLkm_define_keysym ("\033[1~", FIND_KEY, Keymap_List);
- SLkm_define_keysym ("\033[2~", INSERT_KEY, Keymap_List);
- SLkm_define_keysym ("\033[3~", REMOVE_KEY, Keymap_List);
- SLkm_define_keysym ("\033[4~", SELECT_KEY, Keymap_List);
- SLkm_define_keysym ("\033[5~", PGUP, Keymap_List);
- SLkm_define_keysym ("\033[6~", PGDOWN, Keymap_List);
- SLkm_define_keysym ("\033[8~", END_KEY, Keymap_List);
- SLkm_define_keysym ("\033[7~", HOME, Keymap_List);
- SLkm_define_keysym ("\033[28~", F1, Keymap_List);
- SLkm_define_keysym ("\033[29~", DO_KEY, Keymap_List);
-
- SLkm_define_keysym ("\033[M", MOUSE_KEYSYM, Keymap_List);
-
- if (SLang_Error
- || (-1 == read_keymap_file ()))
- SLang_exit_error ("Unable to initialize keymaps");
-
- return 0;
+ setup_vtXXX_keymap();
+ define_key ("\033[M", MOUSE_KEYSYM);
+
+ if (SLang_Error
+ || (-1 == read_keymap_file ()))
+ SLang_exit_error ("Unable to initialize keymaps");
+ return 0;
+#else
+ setup_vtXXX_keymap();
+ return read_keymap_file();
+#endif
}
+#endif /* USE_KEYMAPS */
+
+#if defined(USE_KEYMAPS) && defined(USE_SLANG)
+
/* We cannot guarantee the type for 'GetChar', and should not use a cast. */
PRIVATE int myGetChar NOARGS
{
@@ -552,11 +801,14 @@ PUBLIC int LYgetch NOARGS
return keysym;
}
-#else
+
+#else /* !USE_KEYMAPS */
/*
* LYgetch() translates some escape sequences and may fake noecho.
*/
+#define found_CSI(first,second) ((second) == '[' || (first) == 155)
+
PUBLIC int LYgetch NOARGS
{
int a, b, c, d = -1;
@@ -583,7 +835,7 @@ re_read:
#endif /* IGNORE_CTRL_C */
return(7); /* use ^G to cancel whatever called us. */
}
- }
+ }
#endif /* !USE_SLANG || VMS */
#ifdef USE_GETCHAR
@@ -657,7 +909,7 @@ re_read:
case 'q': c = END_KEY; break; /* keypad on pc ncsa telnet */
case 'M':
#ifdef USE_SLANG_MOUSE
- if ((c == 27) && (b == '['))
+ if (found_CSI(c,b))
{
c = sl_read_mouse_event ();
}
@@ -701,11 +953,11 @@ re_read:
c = '0'; /* keypad 0 */
break;
case '1': /** VTxxx Find **/
- if ((b == '[' || c == 155) && (d=GetChar()) == '~')
+ if (found_CSI(c,b) && (d=GetChar()) == '~')
c = FIND_KEY;
break;
case '2':
- if (b == '[' || c == 155) {
+ if (found_CSI(c,b)) {
if ((d=GetChar())=='~') /** VTxxx Insert **/
c = INSERT_KEY;
else if ((d == '8' ||
@@ -721,23 +973,23 @@ re_read:
}
break;
case '3': /** VTxxx Delete **/
- if ((b == '[' || c == 155) && (d=GetChar()) == '~')
+ if (found_CSI(c,b) && (d=GetChar()) == '~')
c = REMOVE_KEY;
break;
case '4': /** VTxxx Select **/
- if ((b == '[' || c == 155) && (d=GetChar()) == '~')
+ if (found_CSI(c,b) && (d=GetChar()) == '~')
c = SELECT_KEY;
break;
case '5': /** VTxxx PrevScreen **/
- if ((b == '[' || c == 155) && (d=GetChar()) == '~')
+ if (found_CSI(c,b) && (d=GetChar()) == '~')
c = PGUP;
break;
case '6': /** VTxxx NextScreen **/
- if ((b == '[' || c == 155) && (d=GetChar()) == '~')
+ if (found_CSI(c,b) && (d=GetChar()) == '~')
c = PGDOWN;
break;
case '[': /** Linux F1-F5: ^[[[A etc. **/
- if (b == '[' || c == 155) {
+ if (found_CSI(c,b)) {
if ((d=GetChar()) == 'A')
c = F1;
break;
@@ -747,7 +999,7 @@ re_read:
CTRACE_SLEEP(MessageSecs);
break;
}
- if (isdigit(a) && (b == '[' || c == 155) && d != -1 && d != '~')
+ if (isdigit(a) && found_CSI(c,b) && d != -1 && d != '~')
d = GetChar();
}
#if HAVE_KEYPAD
@@ -852,43 +1104,31 @@ re_read:
#endif /* KEY_DC */
#ifdef NCURSES_MOUSE_VERSION
case KEY_MOUSE:
- {
+ {
#ifndef DOSPATH
- MEVENT event;
- int err;
-
- c = -1;
- mouse_link = -1;
- err=getmouse(&event);
- if (event.bstate & BUTTON1_CLICKED) {
- c = set_clicked_link(event.x, event.y);
- } else if (event.bstate & BUTTON3_CLICKED) {
- c = LYReverseKeymap (LYK_PREV_DOC);
- }
+ MEVENT event;
+ int err;
+
+ c = -1;
+ mouse_link = -1;
+ err = getmouse(&event);
+ if (event.bstate & BUTTON1_CLICKED) {
+ c = set_clicked_link(event.x, event.y);
+ } else if (event.bstate & BUTTON3_CLICKED) {
+ c = LYReverseKeymap (LYK_PREV_DOC);
+ }
#else /* pdcurses version */
- int left,right;
- /* yes, I am assuming that my screen will be a certain width. */
- left = 6;
- right = LYcols-6;
- c = -1;
- mouse_link = -1;
- request_mouse_pos();
- if (Mouse_status.button[0] & BUTTON_CLICKED) {
- if (Mouse_status.y == (LYlines-1)) {
- if (Mouse_status.x < left) c=LTARROW;
- else if (Mouse_status.x > right) c='\b';
- else c = PGDOWN;
- } else if (Mouse_status.y == 0) {
- if (Mouse_status.x < left) c=LTARROW;
- else if (Mouse_status.x > right) c='\b';
- else c = PGUP;
- } else {
- c = set_clicked_link(Mouse_status.x, Mouse_status.y);
+ c = -1;
+ mouse_link = -1;
+ request_mouse_pos();
+ if (BUTTON_STATUS(1) & BUTTON_CLICKED) {
+ c = set_clicked_link(MOUSE_X_POS, MOUSE_Y_POS);
+ } else if (BUTTON_STATUS(3) & BUTTON_CLICKED) {
+ c = LYReverseKeymap (LYK_PREV_DOC);
}
- }
#endif /* DOSPATH */
- }
- break;
+ }
+ break;
#endif /* NCURSES_MOUSE_VERSION */
}
}
@@ -931,7 +1171,7 @@ re_read:
}
}
#endif /* DGJPP_KEYHANDLER */
-#if defined(USE_SLANG) && defined(__DJGPP__) && !defined(DJGPP_KEYHANDLER) && !defined(USE_SLANG_KEYMAPS)
+#if defined(USE_SLANG) && defined(__DJGPP__) && !defined(DJGPP_KEYHANDLER) && !defined(USE_KEYMAPS)
else {
switch(c) {
case SL_KEY_DOWN: /* The four arrow keys ... */
@@ -964,7 +1204,7 @@ re_read:
break;
}
}
-#endif /* USE_SLANG && __DJGPP__ && !DJGPP_KEYHANDLER && !USE_SLANG_KEYMAPS */
+#endif /* USE_SLANG && __DJGPP__ && !DJGPP_KEYHANDLER && !USE_KEYMAPS */
#if (defined(__DJGPP__) || defined(_WINDOWS))
if (c > 659)
@@ -983,7 +1223,7 @@ re_read:
}
}
-#endif /* NOT USE_SLANG_KEYMAPS */
+#endif /* NOT USE_KEYMAPS */
/*
* Convert a null-terminated string to lowercase
diff --git a/src/LYStrings.h b/src/LYStrings.h
index ccd78dee..14cb46cf 100644
--- a/src/LYStrings.h
+++ b/src/LYStrings.h
@@ -144,7 +144,7 @@ typedef struct _EditFieldData {
#define LYE_AIX (LYE_LKCMD +1) /* Hex 97 */
-#if defined(USE_SLANG_KEYMAPS)
+#if defined(USE_KEYMAPS)
extern int lynx_initialize_keymaps NOPARAMS;
#endif
@@ -184,7 +184,7 @@ extern int current_lineedit;
extern char * LYLineeditNames[];
extern char * LYLineEditors[];
-/* Push a chacter through the linedit machinery */
+/* Push a character through the lineedit machinery */
#define EditBinding(c) (LYLineEditors[current_lineedit][c])
#define LYLineEdit(e,c,m) LYEdit1(e,c,EditBinding(c),m)
diff --git a/src/LYUtils.c b/src/LYUtils.c
index caebd6b0..bbf90ac1 100644
--- a/src/LYUtils.c
+++ b/src/LYUtils.c
@@ -1,4 +1,5 @@
#include <HTUtils.h>
+#include <HTTCP.h>
#include <HTParse.h>
#include <HTAccess.h>
#include <HTCJK.h>
@@ -4147,7 +4148,8 @@ PUBLIC BOOLEAN LYExpandHostForURL ARGS3(
char *Host = NULL, *HostColon = NULL, *host = NULL;
char *Path = NULL;
char *Fragment = NULL;
- struct hostent *phost;
+ int hoststat;
+ SockA sock;
BOOLEAN GotHost = FALSE;
BOOLEAN Startup = (helpfilepath == NULL);
@@ -4222,7 +4224,8 @@ PUBLIC BOOLEAN LYExpandHostForURL ARGS3(
fprintf(stdout, "Looking up '%s' first.\n", host);
}
#ifndef DJGPP
- if ((phost = gethostbyname(host)) != NULL)
+ sock.sin_port = htons(80);
+ if ((hoststat = HTParseInet(&sock, host)) == 0)
#else
if (resolve(host) != 0)
#endif /* DJGPP */
@@ -4243,7 +4246,11 @@ PUBLIC BOOLEAN LYExpandHostForURL ARGS3(
FREE(Str);
FREE(MsgStr);
return GotHost;
+#ifndef DJGPP
+ } else if (LYCursesON && ((hoststat == HT_INTERRUPTED) || HTCheckForInterrupt())) {
+#else /* DJGPP */
} else if (LYCursesON && HTCheckForInterrupt()) {
+#endif /* DJGPP */
/*
* Give the user chance to interrupt lookup cycles. - KW & FM
*/
@@ -4339,7 +4346,8 @@ PUBLIC BOOLEAN LYExpandHostForURL ARGS3(
fprintf(stdout, "Looking up '%s', guessing...\n", host);
}
#ifndef DJGPP
- GotHost = ((phost = gethostbyname(host)) != NULL);
+ sock.sin_port = htons(80);
+ GotHost = ((hoststat = HTParseInet(&sock, host)) == 0);
#else
GotHost = (resolve(host) != 0);
#endif /* DJGPP */
@@ -4350,7 +4358,12 @@ PUBLIC BOOLEAN LYExpandHostForURL ARGS3(
/*
* Give the user chance to interrupt lookup cycles. - KW
*/
- if (LYCursesON && HTCheckForInterrupt()) {
+#ifndef DJGPP
+ if (LYCursesON && ((hoststat == HT_INTERRUPTED) || HTCheckForInterrupt()))
+#else /* DJGPP */
+ if (LYCursesON && HTCheckForInterrupt())
+#endif /* DJGPP */
+ {
CTRACE(tfp, "LYExpandHostForURL: Interrupted while '%s' failed to resolve.\n",
host);
FREE(Str);
@@ -5827,6 +5840,26 @@ PUBLIC void LYLocalFileToURL ARGS2(
#endif /* DOSPATH */
}
+PUBLIC int LYOpenInternalPage ARGS2(
+ FILE *, fp0,
+ char **, newfile)
+{
+ static char tempfile[256];
+ static char local_address[256];
+
+ LYRemoveTemp(tempfile);
+ if ((fp0 = LYOpenTemp(tempfile, HTML_SUFFIX, "w")) == NULL) {
+ HTAlert(CANNOT_OPEN_TEMP);
+ return(-1);
+ }
+
+ LYLocalFileToURL(local_address, tempfile);
+ StrAllocCopy(*newfile, local_address);
+ LYforce_no_cache = TRUE; /* don't cache this doc */
+
+ return(0); /* OK */
+}
+
PUBLIC void BeginInternalPage ARGS3(
FILE *, fp0,
char*, Title,
@@ -5854,16 +5887,15 @@ PUBLIC void BeginInternalPage ARGS3(
if ((user_mode == NOVICE_MODE)
&& LYwouldPush(Title)
&& (HelpURL != 0)) {
- fprintf(fp0, "<h1>%s (%s), help on <a href=\"%s%s\">%s</a></h1>\n",
- LYNX_NAME, LYNX_VERSION,
- helpfilepath, HelpURL, Title);
+ fprintf(fp0, "<h1>%s (%s Version %s), <a href=\"%s%s\">help</a></h1>\n",
+ Title, LYNX_NAME, LYNX_VERSION,
+ helpfilepath, HelpURL);
} else {
- fprintf(fp0, "<h1>%s (%s Version %s)</h1>\n",
+ fprintf(fp0, "<h1>%s (%s Version %s)</h1>\n",
Title, LYNX_NAME, LYNX_VERSION);
}
}
-
PUBLIC void EndInternalPage ARGS1(
FILE *, fp0)
{
diff --git a/src/LYUtils.h b/src/LYUtils.h
index fee1718e..687007c1 100644
--- a/src/LYUtils.h
+++ b/src/LYUtils.h
@@ -13,6 +13,8 @@
#define LYIsHtmlSep(ch) ((ch) == '/')
+#define TABLESIZE(v) (sizeof(v)/sizeof(v[0]))
+
extern BOOLEAN LYAddSchemeForURL PARAMS((char **AllocatedString, char *default_scheme));
extern BOOLEAN LYCachedTemp PARAMS((char *result, char **cached));
extern BOOLEAN LYCanDoHEAD PARAMS((CONST char *address));
@@ -40,6 +42,7 @@ extern int LYSystem PARAMS((char *command));
extern int is_url PARAMS((char *filename));
extern int number2arrows PARAMS((int number));
extern time_t LYmktime PARAMS((char *string, BOOL absolute));
+extern int LYOpenInternalPage PARAMS((FILE *fp0, char **newfile));
extern void BeginInternalPage PARAMS((FILE *fp0, char *Title, char *HelpURL));
extern void EndInternalPage PARAMS((FILE *fp0));
extern void HTAddSugFilename PARAMS((char *fname));
diff --git a/src/LYrcFile.c b/src/LYrcFile.c
index c5326615..78639b05 100644
--- a/src/LYrcFile.c
+++ b/src/LYrcFile.c
@@ -10,10 +10,16 @@
#include <LYLeaks.h>
+#ifdef FNAMES_8_3
+#define FNAME_LYNXRC "lynx.rc"
+#else
+#define FNAME_LYNXRC ".lynxrc"
+#endif /* FNAMES_8_3 */
+
PUBLIC void read_rc NOPARAMS
{
char line_buffer[256];
- char rcfile[256];
+ char rcfile[LY_MAXPATH];
FILE *fp;
char *cp, *cp2;
int number_sign;
@@ -25,15 +31,7 @@ PUBLIC void read_rc NOPARAMS
/*
* Make an RC file name.
*/
-#ifdef DJGPP
- sprintf(rcfile, "%s/lynx.rc", Home_Dir());
-#else
-#ifdef VMS
- sprintf(rcfile, "sys$login:.lynxrc");
-#else
- sprintf(rcfile, "%s/.lynxrc", Home_Dir());
-#endif /* VMS */
-#endif /* DJGPP */
+ LYAddPathToHome(rcfile, sizeof(rcfile), FNAME_LYNXRC);
/*
* Open the RC file for reading.
@@ -251,7 +249,6 @@ PUBLIC void read_rc NOPARAMS
for (; LYchar_set_names[i]; i++) {
if (!strncmp(cp, LYchar_set_names[i], strlen(cp))) {
current_char_set=i;
- HTMLSetRawModeDefault(i);
break;
}
}
@@ -549,7 +546,7 @@ PUBLIC void read_rc NOPARAMS
PUBLIC int save_rc NOPARAMS
{
- char rcfile[256];
+ char rcfile[LY_MAXPATH];
FILE *fp;
int i;
int MBM_c;
@@ -557,15 +554,7 @@ PUBLIC int save_rc NOPARAMS
/*
* Make a name.
*/
-#ifdef DJGPP
- sprintf(rcfile, "%s/lynx.rc", Home_Dir());
-#else
-#ifdef VMS
- sprintf(rcfile, "sys$login:.lynxrc");
-#else
- sprintf(rcfile, "%s/.lynxrc", Home_Dir());
-#endif /* VMS */
-#endif /* DJGPP */
+ LYAddPathToHome(rcfile, sizeof(rcfile), FNAME_LYNXRC);
/*
* Open the file for write.
@@ -854,7 +843,7 @@ PUBLIC int save_rc NOPARAMS
* Lineedit mode.
*/
fprintf(fp, "\
-# linedit_mode specifies the key binding used for inputting strings in\n\
+# lineedit_mode specifies the key binding used for inputting strings in\n\
# prompts and forms. If lineedit_mode is set to \"Default Binding\" then\n\
# the following control characters are used for moving and deleting:\n\
#\n\
diff --git a/src/UCAux.c b/src/UCAux.c
index 01ea1593..6847b150 100644
--- a/src/UCAux.c
+++ b/src/UCAux.c
@@ -37,9 +37,9 @@ PUBLIC BOOL UCCanTranslateFromTo ARGS2(
return YES;
if (from < 0 || to < 0)
return NO;
- if (from == 0)
+ if (from == LATIN1)
return UCCanTranslateUniTo(to);
- if (to == 0 || LYCharSet_UC[to].enc == UCT_ENC_UTF8)
+ if (to == LATIN1 || LYCharSet_UC[to].enc == UCT_ENC_UTF8)
return UCCanUniTranslateFrom(from);
{
CONST char * fromname = LYCharSet_UC[from].MIMEname;
@@ -102,7 +102,7 @@ PUBLIC BOOL UCNeedNotTranslate ARGS2(
}
if (to < 0)
return NO; /* ??? */
- if (to == 0) {
+ if (to == LATIN1) {
if (LYCharSet_UC[from].codepoints & (UCT_CP_SUBSETOF_LAT1))
return YES;
}
@@ -113,7 +113,7 @@ PUBLIC BOOL UCNeedNotTranslate ARGS2(
if (LYCharSet_UC[to].enc == UCT_ENC_UTF8) {
return NO;
}
- if (from == 0) {
+ if (from == LATIN1) {
if (LYCharSet_UC[from].codepoints & (UCT_CP_SUPERSETOF_LAT1))
return YES;
}
@@ -121,14 +121,7 @@ PUBLIC BOOL UCNeedNotTranslate ARGS2(
if (HTCJK == NOCJK) /* Use that global flag, for now. */
return NO;
if (HTCJK == JAPANESE &&
- /*
- ** Always strip the "x-" from "x-euc-jp",
- ** or convert "x-shift-jis" to "shift_jis",
- ** before calling this function, and so
- ** don't check for them here. - FM
- */
(!strcmp(fromname, "euc-jp") ||
- !strncmp(fromname, "iso-2022-jp",11) ||
!strcmp(fromname, "shift_jis")))
return YES; /* ??? */
return NO; /* If not handled by (from == to) above. */
@@ -185,7 +178,7 @@ PUBLIC void UCSetTransParams ARGS5(
pT->trans_C0_to_uni = (p_in->enc == UCT_ENC_8BIT_C0 ||
p_out->enc == UCT_ENC_8BIT_C0);
} else {
- /*
+ /*
** Initialize local flags. - FM
*/
BOOL intm_ucs = FALSE;
@@ -222,7 +215,7 @@ PUBLIC void UCSetTransParams ARGS5(
** equivalent to them, i.e. if we have UCS without
** having to do a table translation.
*/
- intm_ucs = (cs_in == 0 || pT->decode_utf8 ||
+ intm_ucs = (cs_in == LATIN1 || pT->decode_utf8 ||
(p_in->codepoints &
(UCT_CP_SUBSETOF_LAT1|UCT_CP_SUBSETOF_UCS2)));
/*
@@ -277,7 +270,7 @@ PUBLIC void UCSetTransParams ARGS5(
*/
pT->use_raw_char_in = (!pT->output_utf8 &&
cs_in == cs_out &&
- !pT->trans_C0_to_uni);
+ !pT->trans_C0_to_uni);
/*
** This should be set TRUE when we expect to have
** done translation to Unicode or had the equivalent
@@ -412,7 +405,7 @@ PUBLIC BOOL UCConvertUniToUtf8 ARGS2(
if (code <= 0 || code > 0x7fffffffL) {
*ch = '\0';
- return NO;
+ return NO;
}
if (code < 0x800L) {
diff --git a/src/UCdomap.c b/src/UCdomap.c
index 0392457b..146538e0 100644
--- a/src/UCdomap.c
+++ b/src/UCdomap.c
@@ -23,6 +23,7 @@
#include <UCMap.h>
#include <UCDefs.h>
#include <LYCharSets.h>
+#include <LYStrings.h>
/*
* Include tables & parameters.
@@ -1274,7 +1275,7 @@ PUBLIC long int UCTransToUni ARGS2(
ch_iu = (unsigned char)ch_in;
#ifndef UC_NO_SHORTCUTS
- if (charset_in == 0)
+ if (charset_in == LATIN1)
return ch_iu;
if ((unsigned char)ch_in < 128 && (unsigned char)ch_in >= 32)
return ch_iu;
@@ -1502,27 +1503,34 @@ PUBLIC int UCGetRawUniMode_byLYhndl ARGS1(
}
/*
- * Currently the charset name has to match exactly -- not substring
- * matching as was done before (see HTMIME.c, HTML.c).
+ * Get Lynx internal charset handler from MIME name,
+ * return -1 if we got NULL or did not recognize value.
+ * According to RFC, MIME headers should match case-insensitively.
*/
PUBLIC int UCGetLYhndl_byMIME ARGS1(
- CONST char *, UC_MIMEcharset)
+ CONST char *, value)
{
int i;
int LYhndl = -1;
+ char *UC_MIMEcharset = NULL;
- if (!UC_MIMEcharset || !(*UC_MIMEcharset))
+ if (!value || !(*value)) {
+ CTRACE(tfp, "UCGetLYhndl_byMIME: NULL argument instead of MIME name.\n");
return -1;
+ }
+
+ StrAllocCopy(UC_MIMEcharset, value);
+ LYLowerCase(UC_MIMEcharset);
for (i = 0;
(i < MAXCHARSETS && i < LYNumCharsets &&
- LYchar_set_names[i] && LYhndl < 0); i++) {
+ LYchar_set_names[i]); i++) {
if (LYCharSet_UC[i].MIMEname &&
!strcmp(UC_MIMEcharset, LYCharSet_UC[i].MIMEname)) {
- LYhndl = i;
+ return i;
}
}
- if (LYhndl < 0) {
+ {
/*
* Not yet found, try synonyms. - FM
*/
@@ -1625,9 +1633,12 @@ PUBLIC int UCGetLYhndl_byMIME ARGS1(
}
if (!strcmp(UC_MIMEcharset, "koi-8")) { /* accentsoft bugosity */
return UCGetLYhndl_byMIME("koi8-r");
- }
+ }
}
- return LYhndl; /* returns -1 if no charset found by that MIME name */
+ /* no more synonyms if come here... */
+
+ CTRACE(tfp, "UCGetLYhndl_byMIME: unrecognized MIME name \"%s\"\n", value);
+ return -1; /* returns -1 if no charset found by that MIME name */
}
/*
@@ -2059,3 +2070,19 @@ PUBLIC void UCInit NOARGS
* check function UCGetLYhndl_byMIME in this file.
*/
}
+
+/*
+ * Safe variant of UCGetLYhndl_byMIME, with blind recovery from typo
+ * in user input: lynx.cfg, userdefs.h, switches from command line.
+ */
+PUBLIC int safeUCGetLYhndl_byMIME ARGS1 (CONST char *, value)
+{
+ int i = UCGetLYhndl_byMIME(value);
+
+ if (i == -1) { /* was user's typo or not yet recognized value */
+ i = LATIN1; /* error recovery? */
+ CTRACE(tfp, "safeUCGetLYhndl_byMIME: ISO-8859-1 assumed.\n");
+ }
+
+ return(i);
+}