aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>1998-12-03 18:41:23 -0500
committerThomas E. Dickey <dickey@invisible-island.net>1998-12-03 18:41:23 -0500
commit0654c7025fbe241efddf0c3b9e58817f262aeda9 (patch)
tree763b5e6a40224fd71653797b3066bf276c81f308 /src
parente87f21b4ae754e738cbb577215a039a26e28ad52 (diff)
downloadlynx-snapshots-0654c7025fbe241efddf0c3b9e58817f262aeda9.tar.gz
snapshot of project "lynx", label v2-8-2dev_8
Diffstat (limited to 'src')
-rw-r--r--src/GridText.c272
-rw-r--r--src/GridText.h4
-rw-r--r--src/HTFWriter.c2
-rw-r--r--src/HTInit.c1
-rw-r--r--src/LYBookmark.c37
-rw-r--r--src/LYCgi.c64
-rw-r--r--src/LYCookie.c92
-rw-r--r--src/LYCookie.h2
-rw-r--r--src/LYCurses.c21
-rw-r--r--src/LYCurses.h7
-rw-r--r--src/LYEditmap.c4
-rw-r--r--src/LYForms.c53
-rw-r--r--src/LYGlobalDefs.h4
-rw-r--r--src/LYHistory.c2
-rw-r--r--src/LYLocal.c230
-rw-r--r--src/LYMail.c2
-rw-r--r--src/LYMain.c2
-rw-r--r--src/LYMainLoop.c2
-rw-r--r--src/LYMap.c6
-rw-r--r--src/LYOptions.c11
-rw-r--r--src/LYPrint.c8
-rw-r--r--src/LYStrings.c188
-rw-r--r--src/LYStrings.h15
-rw-r--r--src/LYStructs.h4
-rw-r--r--src/LYUtils.c15
-rw-r--r--src/UCdomap.c28
-rw-r--r--src/UCdomap.h8
-rw-r--r--src/chrtrans/makeuctb.c10
28 files changed, 758 insertions, 336 deletions
diff --git a/src/GridText.c b/src/GridText.c
index 500210f7..dea8155f 100644
--- a/src/GridText.c
+++ b/src/GridText.c
@@ -61,6 +61,17 @@ void LynxClearScreenCache NOARGS
for (j=0;j<CACHEW;j++)
cached_styles[i][j]=s_a;
}
+#endif
+#ifdef USE_COLOR_STYLE
+PRIVATE void LynxResetScreenCache NOARGS
+{
+ int i,j;
+
+ for (i=1; (i<CACHEH && i <= display_lines); i++) {
+ for (j=0;j<CACHEW;j++)
+ cached_styles[i][j]=0;
+ }
+}
#endif /* USE_COLOR_STYLE */
struct _HTStream { /* only know it as object */
@@ -183,6 +194,10 @@ struct _HText {
BOOL in_line_1; /* of paragraph */
BOOL stale; /* Must refresh */
BOOL page_has_target; /* has target on screen */
+#ifdef DISP_PARTIAL
+ int first_lineno_last_disp_partial;
+ int last_lineno_last_disp_partial;
+#endif
HTkcode kcode; /* Kanji code? */
enum grid_state { S_text, S_esc, S_dollar, S_paren,
@@ -539,6 +554,15 @@ PUBLIC HText * HText_new ARGS1(
*/
if (display_partial)
NumOfLines_partial = 0; /* enable HTDisplayPartial() */
+
+ /*
+ * These two fields should only be set to valid line numbers
+ * by calls of display_page during partial displaying. This
+ * is just so that the FIRST display_page AFTER that can avoid
+ * repainting the same lines on the screen. - kw
+ */
+ self->first_lineno_last_disp_partial =
+ self->last_lineno_last_disp_partial = -1;
#endif
CTRACE(tfp, "GridText: start HText_new\n");
@@ -589,7 +613,7 @@ PUBLIC void HText_free ARGS1(
}
}
if (l == self->last_line) { /* empty */
- l = NULL;
+ l = self->last_line = NULL;
break;
}
};
@@ -1053,6 +1077,9 @@ PRIVATE void display_page ARGS3(
HTAnchor *link_dest_intl = NULL;
static int last_nlinks = 0;
static int charset_last_displayed = -1;
+#ifdef DISP_PARTIAL
+ int last_disp_partial = -1;
+#endif
lynx_mode = NORMAL_LYNX_MODE;
@@ -1073,6 +1100,14 @@ PRIVATE void display_page ARGS3(
return;
}
+#ifdef DISP_PARTIAL
+ if (display_partial || recent_sizechange || text->stale) {
+ /* Reset them, will be set near end if all is okay. - kw */
+ text->first_lineno_last_disp_partial =
+ text->last_lineno_last_disp_partial = -1;
+ }
+#endif /* DISP_PARTIAL */
+
tmp[0] = tmp[1] = tmp[2] = '\0';
text->page_has_target = NO;
last_screen = text->Lines - (display_lines - 2);
@@ -1143,6 +1178,10 @@ PRIVATE void display_page ARGS3(
clear();
}
+#ifdef USE_COLOR_STYLE
+ LynxResetScreenCache();
+#endif
+
text->top_of_screen = line_number;
display_title(text); /* will move cursor to top of screen */
display_flag=TRUE;
@@ -1176,6 +1215,14 @@ PRIVATE void display_page ARGS3(
#else
assert(line != NULL);
#endif /* !VMS */
+
+#ifdef DISP_PARTIAL
+ if (!display_partial &&
+ line_number == text->first_lineno_last_disp_partial &&
+ i + line_number <= text->last_lineno_last_disp_partial)
+ move((i + 2), 0);
+ else
+#endif
display_line(line, text);
#if defined(FANCY_CURSES) || defined(USE_SLANG)
@@ -1357,6 +1404,15 @@ PRIVATE void display_page ARGS3(
}
break;
}
+#ifdef DISP_PARTIAL
+ if (display_partial) {
+ /*
+ * Remember as fully shown during last partial display,
+ * if it was not the last text line. - kw
+ */
+ last_disp_partial = i + line_number;
+ }
+#endif /* DISP_PARTIAL */
display_flag = TRUE;
line = line->next;
} /* end of "Verify and display each line." loop */
@@ -1550,6 +1606,18 @@ PRIVATE void display_page ARGS3(
addstr("\n Document is empty");
}
+#ifdef DISP_PARTIAL
+ if (display_partial && display_flag &&
+ last_disp_partial >= text->top_of_screen &&
+ !recent_sizechange) { /* really remember them if ok - kw */
+ text->first_lineno_last_disp_partial = text->top_of_screen;
+ text->last_lineno_last_disp_partial = last_disp_partial;
+ } else {
+ text->first_lineno_last_disp_partial =
+ text->last_lineno_last_disp_partial = -1;
+ }
+#endif /* DISP_PARTIAL */
+
if (HTCJK != NOCJK || text->T.output_utf8) {
/*
* For non-multibyte curses.
@@ -2748,8 +2816,12 @@ PUBLIC int HText_beginAnchor ARGS3(
if ((a->number > 0) &&
(keypad_mode == LINKS_ARE_NUMBERED ||
keypad_mode == LINKS_AND_FORM_FIELDS_ARE_NUMBERED)) {
+ char saved_lastchar = text->LastChar;
+ int saved_linenum = text->Lines;
sprintf(marker,"[%d]", a->number);
HText_appendText(text, marker);
+ if (saved_linenum && text->Lines && saved_lastchar != ' ')
+ text->LastChar = ']'; /* if marker not after space caused split */
a->start = text->chars + text->last_line->size;
a->line_num = text->Lines;
a->line_pos = text->last_line->size;
@@ -2818,6 +2890,7 @@ PUBLIC void HText_endAnchor ARGS2(
HTAnchor_followMainLink((HTAnchor *)a->anchor)))));
HTLine *last = text->last_line;
HTLine *prev = text->last_line->prev;
+ HTLine *start = last;
int CurBlankExtent = 0;
int BlankExtent = 0;
@@ -2877,7 +2950,13 @@ PUBLIC void HText_endAnchor ARGS2(
* immediately preceding line also has only
* white and special characters. - FM
*/
- while (i == 0 && a->extent > CurBlankExtent) {
+ while (i == 0 &&
+ (a->extent > CurBlankExtent ||
+ (a->extent == CurBlankExtent &&
+ prev != text->last_line &&
+ (prev->size == 0 ||
+ prev->data[prev->size - 1] == ']')))) {
+ start = prev;
j = prev->size - a->extent + CurBlankExtent;
if (j < 0) {
/*
@@ -2902,7 +2981,11 @@ PUBLIC void HText_endAnchor ARGS2(
j++;
}
if (i == 0) {
- if (a->extent > (CurBlankExtent + prev->size)) {
+ if (a->extent > (CurBlankExtent + prev->size) ||
+ (a->extent == CurBlankExtent + prev->size &&
+ prev->prev != text->last_line &&
+ (prev->prev->size == 0 ||
+ prev->prev->data[prev->prev->size - 1] == ']'))) {
/*
* This line has only white and special
* characters, so treat its entire extent
@@ -2931,6 +3014,11 @@ PUBLIC void HText_endAnchor ARGS2(
*/
a->show_anchor = NO;
+ CTRACE(tfp,
+ "HText_endAnchor: hidden (line,start,pos,ext,BlankExtent):(%d,%d,%d,%d,%d)",
+ a->line_num,a->start,a->line_pos,a->extent,
+ BlankExtent);
+
/*
* If links are numbered, then try to get rid of the
* numbered bracket and adjust the anchor count. - FM
@@ -2944,7 +3032,6 @@ PUBLIC void HText_endAnchor ARGS2(
* possibly caused by HTML errors. - kw
*/
if (remove_numbers_on_empty) {
- HTLine *start;
int NumSize = 0;
TextAnchor *anc;
@@ -2953,18 +3040,16 @@ PUBLIC void HText_endAnchor ARGS2(
* or to the beginning of the line on which the
* anchor start. - FM
*/
- if (prev == last->prev) {
+ if (start == last) {
/*
* The anchor starts on the last line. - FM
*/
- start = last;
j = (last->size - a->extent - 1);
} else {
/*
* The anchor starts on a previous line. - FM
*/
- start = prev;
- prev = prev->prev;
+ prev = start->prev;
j = (start->size - a->extent + CurBlankExtent - 1);
}
if (j < 0)
@@ -2997,6 +3082,12 @@ PUBLIC void HText_endAnchor ARGS2(
* on this line. - FM
*/
NumSize++;
+ if (start==last && (int)text->permissible_split > j) {
+ if ((int)text->permissible_split - NumSize < j)
+ text->permissible_split = j;
+ else
+ text->permissible_split -= NumSize;
+ }
k = j + NumSize;
while (k < start->size)
start->data[j++] = start->data[k++];
@@ -3004,7 +3095,10 @@ PUBLIC void HText_endAnchor ARGS2(
text->chars -= NumSize;
for (anc = a; anc; anc = anc->next) {
anc->start -= NumSize;
+ if (anc->line_num == a->line_num &&
+ anc->line_pos >= NumSize) {
anc->line_pos -= NumSize;
+ }
}
start->size = j;
start->data[j++] = '\0';
@@ -3034,7 +3128,7 @@ PUBLIC void HText_endAnchor ARGS2(
NumSize++;
l = (i - j);
while (i < prev->size)
- start->data[j++] = start->data[i++];
+ prev->data[j++] = prev->data[i++];
text->chars -= l;
for (anc = a; anc; anc = anc->next) {
anc->start -= l;
@@ -3042,7 +3136,13 @@ PUBLIC void HText_endAnchor ARGS2(
prev->size = j;
prev->data[j] = '\0';
while (j < i)
- start->data[j++] = '\0';
+ prev->data[j++] = '\0';
+ if (start == last && text->permissible_split > 0) {
+ if ((int)text->permissible_split < k)
+ text->permissible_split = 0;
+ else
+ text->permissible_split -= k;
+ }
j = 0;
i = k;
while (k < start->size)
@@ -3051,7 +3151,10 @@ PUBLIC void HText_endAnchor ARGS2(
text->chars -= i;
for (anc = a; anc; anc = anc->next) {
anc->start -= i;
- anc->line_pos -= i;
+ if (anc->line_num == a->line_num &&
+ anc->line_pos >= i) {
+ anc->line_pos -= i;
+ }
}
start->size = j;
start->data[j++] = '\0';
@@ -3078,7 +3181,7 @@ PUBLIC void HText_endAnchor ARGS2(
if (j < 0)
j = 0;
i = (j + 1);
- if ((j > 2) &&
+ if ((j >= 2) &&
(prev->data[j] == ']' &&
isdigit((unsigned char)prev->data[j - 1]))) {
j--;
@@ -3110,7 +3213,7 @@ PUBLIC void HText_endAnchor ARGS2(
prev->size = j;
prev->data[j++] = '\0';
while (j < k)
- start->data[j++] = '\0';
+ prev->data[j++] = '\0';
} else {
/*
* Shucks! We didn't find the
@@ -3140,6 +3243,12 @@ PUBLIC void HText_endAnchor ARGS2(
* as a link. - FM
*/
a->show_anchor = YES;
+ if (BlankExtent) {
+ CTRACE(tfp,
+ "HText_endAnchor: blanks (line,start,pos,ext,BlankExtent):(%d,%d,%d,%d,%d)",
+ a->line_num,a->start,a->line_pos,a->extent,
+ BlankExtent);
+ }
}
if (a->show_anchor == NO) {
/*
@@ -3165,6 +3274,13 @@ PUBLIC void HText_endAnchor ARGS2(
a->extent -= ((BlankExtent < a->extent) ?
BlankExtent : 0);
}
+ if (BlankExtent || a->extent <= 0 || a->number <= 0) {
+ CTRACE(tfp,
+ "->[%d](%d,%d,%d,%d,%d)\n",
+ a->number,
+ a->line_num,a->start,a->line_pos,a->extent,
+ BlankExtent);
+ }
} else {
/*
* It's a named anchor without an HREF, so it
@@ -3274,7 +3390,7 @@ PUBLIC void HText_endAppend ARGS1(
* Fix up the anchor structure values and
* create the hightext strings. - FM
*/
- HText_trimHightext(text, FALSE);
+ HText_trimHightext(text, TRUE);
}
@@ -3286,25 +3402,37 @@ PUBLIC void HText_endAppend ARGS1(
** `Forms input' fields cannot be displayed properly without this function
** to be invoked (detected in display_partial mode).
**
-** (BOOLEAN value allow us to disable annoying repeated trace messages
-** for display_partial mode).
+** If final is set, this is the final fixup; if not set, we don't have
+** to do everything because there should be another call later.
+**
+** BEFORE this function has treated a TextAnchor, its line_pos and
+** extent fields are counting bytes in the HTLine data, including
+** invisible special attribute chars and counting UTF-8 multibyte
+** characters as multiple bytes.
+** AFTER the adjustment, the anchor line_pos (and hightext2offset
+** if applicable) fields indicate x positions in terms of displayed
+** character cells, and the extent field apparently is unimportant;
+** the anchor text has been copied to the hightext (and possibly
+** hightext2) fields (which should be NULL up to this point), with
+** special attribute chars removed.
+** This needs to be done so that display_page finds the anchors in the
+** form it expects when it sets the links[] elements.
*/
PUBLIC void HText_trimHightext ARGS2(
HText *, text,
- BOOLEAN, disable_trace)
+ BOOLEAN, final)
{
int cur_line, cur_char, cur_shift;
TextAnchor *anchor_ptr;
+ TextAnchor *prev_a = NULL;
HTLine *line_ptr;
unsigned char ch;
if (!text)
return;
- CTRACE(tfp,"Gridtext: Entering HText_trimHightext\n");
-
- if (disable_trace)
- CTRACE(tfp,"HText_trimHightext: trace disabled in display_partial mode\n");
+ CTRACE(tfp,"Gridtext: Entering HText_trimHightext %s\n",
+ final ? "(final)" : "(partial)");
/*
* Get the first line.
@@ -3312,37 +3440,71 @@ PUBLIC void HText_trimHightext ARGS2(
line_ptr = text->last_line->next;
cur_char = line_ptr->size;
cur_line = 0;
- cur_shift = 0;
/*
* Fix up the anchor structure values and
* create the hightext strings. - FM
*/
for (anchor_ptr = text->first_anchor;
- anchor_ptr; anchor_ptr=anchor_ptr->next) {
+ anchor_ptr;
+ prev_a = anchor_ptr, anchor_ptr=anchor_ptr->next) {
re_parse:
/*
* Find the right line.
*/
- for (; anchor_ptr->start >= cur_char;
+ for (; anchor_ptr->start > cur_char;
line_ptr = line_ptr->next,
cur_char += line_ptr->size+1,
cur_line++) {
; /* null body */
}
+
+ if (!final) {
+ /*
+ * If this is not the final call, stop when we have reached
+ * the last line, or the very end of preceding line.
+ * The last line is probably still not finished. - kw
+ */
+ if (cur_line >= text->Lines)
+ break;
+ if (anchor_ptr->start >= text->chars - 1)
+ break;
+ /*
+ * Also skip this anchor if it looks like HText_endAnchor
+ * is not yet done with it. - kw
+ */
+ if (!anchor_ptr->extent && anchor_ptr->number &&
+ (anchor_ptr->link_type & HYPERTEXT_ANCHOR) &&
+ !anchor_ptr->show_anchor &&
+ anchor_ptr->number == text->last_anchor_number)
+ continue;
+ }
+
+ /*
+ * If hightext has already been set, then we must have already
+ * done the trimming & adjusting for this anchor, so avoid
+ * doing it a second time. - kw
+ */
+ if (anchor_ptr->hightext)
+ continue;
+
if (anchor_ptr->start == cur_char) {
anchor_ptr->line_pos = line_ptr->size;
} else {
anchor_ptr->line_pos = anchor_ptr->start -
(cur_char - line_ptr->size);
}
- if (anchor_ptr->line_pos < 0)
+ if (anchor_ptr->line_pos < 0) {
+ anchor_ptr->start -= anchor_ptr->line_pos;
anchor_ptr->line_pos = 0;
+ anchor_ptr->line_num = cur_line;
+ }
+ CTRACE(tfp,
+ "Gridtext: Anchor found on line:%d col:%d [%d] ext:%d\n",
+ cur_line, anchor_ptr->line_pos,
+ anchor_ptr->number, anchor_ptr->extent);
- if (!disable_trace)
- CTRACE(tfp, "Gridtext: Anchor found on line:%d col:%d\n",
- cur_line, anchor_ptr->line_pos);
-
+ cur_shift = 0;
/*
* Strip off any spaces or SpecialAttrChars at the beginning,
* if they exist, but only on HYPERTEXT_ANCHORS.
@@ -3360,22 +3522,29 @@ re_parse:
if (anchor_ptr->extent < 0) {
anchor_ptr->extent = 0;
}
+ anchor_ptr->start += cur_shift;
- if (!disable_trace)
CTRACE(tfp, "anchor text: '%s'\n",
line_ptr->data);
/*
* If the link begins with an end of line and we have more
* lines, then start the highlighting on the next line. - FM
+ * But if an empty anchor is at the end of line and empty,
+ * keep it where it is, unless the previous anchor in the list
+ * (if any) already starts later. - kw
*/
- if ((unsigned)anchor_ptr->line_pos >= strlen(line_ptr->data) &&
- cur_line < text->Lines) {
- anchor_ptr->start += (cur_shift + 1);
- cur_shift = 0;
- CTRACE(tfp, "found anchor at end of line\n");
- goto re_parse;
+ if ((unsigned)anchor_ptr->line_pos >= strlen(line_ptr->data)) {
+ if (cur_line < text->Lines &&
+ (anchor_ptr->extent ||
+ anchor_ptr->line_pos != (int)line_ptr->size ||
+ (prev_a && prev_a->start > anchor_ptr->start))) {
+ anchor_ptr->start++;
+ CTRACE(tfp, "found anchor at end of line\n");
+ goto re_parse;
+ } else {
+ CTRACE(tfp, "found anchor at end of line, leaving it there\n");
+ }
}
- cur_shift = 0;
/*
* Copy the link name into the data structure.
@@ -3395,6 +3564,13 @@ re_parse:
*/
if ((unsigned)anchor_ptr->extent > strlen(anchor_ptr->hightext)) {
HTLine *line_ptr2 = line_ptr->next;
+
+ if (!final) {
+ if (cur_line + 1 >= text->Lines) {
+ FREE(anchor_ptr->hightext); /* bail out */
+ break;
+ }
+ }
/*
* Double check that we have a line pointer,
* and if so, copy into hightext2.
@@ -3439,9 +3615,9 @@ re_parse:
anchor_ptr->line_pos += line_ptr->offset;
anchor_ptr->line_num = cur_line;
- if (!disable_trace)
- CTRACE(tfp, "GridText: add link on line %d col %d in HText_trimHightext\n",
- cur_line, anchor_ptr->line_pos);
+ CTRACE(tfp, "GridText: add link on line %d col %d [%d] %s\n",
+ cur_line, anchor_ptr->line_pos,
+ anchor_ptr->number, "in HText_trimHightext");
/*
* If this is the last anchor, we're done!
@@ -4101,11 +4277,11 @@ PUBLIC void HText_pageDisplay ARGS2(
** 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.
+ ** (FALSE = indicate that we are in partial mode)
+ ** Multiple calls of HText_trimHightext works without problem now.
*/
- HText_trimHightext(HTMainText, TRUE);
+ HText_trimHightext(HTMainText, FALSE);
}
detected_forms_input_partial = FALSE;
#endif
@@ -6216,6 +6392,14 @@ PUBLIC char * HText_setLastOptionValue ARGS7(
new_ptr->name = NULL;
new_ptr->cp_submit_value = NULL;
new_ptr->next = NULL;
+ /*
+ * Find first non-space again, convert_to_spaces above may have
+ * changed the string. - kw
+ */
+ cp = value;
+ while (isspace((unsigned char)*cp) ||
+ IsSpecialAttrChar((unsigned char)*cp))
+ cp++;
for (i = 0, j = 0; cp[i]; i++) {
if (cp[i] == HT_NON_BREAK_SPACE ||
cp[i] == HT_EM_SPACE) {
@@ -8019,6 +8203,8 @@ PRIVATE void free_all_texts NOARGS
*/
while (loaded_texts && !HTList_isEmpty(loaded_texts)) {
if ((cur = (HText *)HTList_removeLastObject(loaded_texts)) != NULL) {
+ if (cur->node_anchor && cur->node_anchor->underway)
+ cur->node_anchor->underway = FALSE;
HText_free(cur);
}
}
diff --git a/src/GridText.h b/src/GridText.h
index a99f66da..679e6fa6 100644
--- a/src/GridText.h
+++ b/src/GridText.h
@@ -23,7 +23,7 @@
#ifndef LY_SOFT_HYPHEN
#define LY_SOFT_HYPHEN ((char)7)
#endif /* !LY_SOFT_HYPHEN */
-#define LY_SOFT_NEWLINE ((char)8)
+#define LY_SOFT_NEWLINE ((char)8)
#define IsSpecialAttrChar(a) ((a > '\002') && (a <= '\010'))
@@ -202,7 +202,7 @@ extern int HText_beginInput PARAMS((
InputFieldData *I));
extern void HText_trimHightext PARAMS((
HText * text,
- BOOLEAN disable_trace));
+ BOOLEAN final));
extern void HText_SubmitForm PARAMS((
FormInfo * submit_item,
document * doc,
diff --git a/src/HTFWriter.c b/src/HTFWriter.c
index 8b1e8805..9e0b03b6 100644
--- a/src/HTFWriter.c
+++ b/src/HTFWriter.c
@@ -708,7 +708,7 @@ PUBLIC HTStream* HTSaveToFile ARGS3(
* Unix folks don't need to know this, but we'll show it to
* them, too. - FM
*/
- HTUserMsg2(gettext("Content-type: %s"), pres->rep->name);
+ HTUserMsg2(CONTENT_TYPE_MSG, pres->rep->name);
StrAllocCopy(WWW_Download_File,fnam);
diff --git a/src/HTInit.c b/src/HTInit.c
index 21a0dc4e..74403779 100644
--- a/src/HTInit.c
+++ b/src/HTInit.c
@@ -21,7 +21,6 @@
#include <HTWSRC.h>
#include <HTSaveToFile.h> /* LJM */
-#include <userdefs.h>
#include <LYStrings.h>
#include <LYUtils.h>
#include <LYGlobalDefs.h>
diff --git a/src/LYBookmark.c b/src/LYBookmark.c
index 7f103f11..a05fb6aa 100644
--- a/src/LYBookmark.c
+++ b/src/LYBookmark.c
@@ -144,11 +144,11 @@ PRIVATE char * convert_mosaic_bookmark_file ARGS1(
return (""); /* should always open */
fprintf(nfp,"<head>\n<title>%s</title>\n</head>\n",MOSAIC_BOOKMARK_TITLE);
- fprintf(nfp,gettext("\
+ fprintf(nfp, "%s\n\n<p>\n<ol>\n", gettext("\
This file is an HTML representation of the X Mosaic hotlist file.\n\
Outdated or invalid links may be removed by using the\n\
remove bookmark command, it is usually the 'R' key but may have\n\
- been remapped by you or your system administrator.\n\n<p>\n<ol>\n"));
+ been remapped by you or your system administrator."));
while (fgets(buf, sizeof(buf), fp) != NULL) {
if(line >= 0) {
@@ -740,7 +740,7 @@ draw_bookmark_choices:
addstr(MULTIBOOKMARKS_SHEAD);
}
- lynx_stop_h1_color ();
+ lynx_stop_h1_color ();
MBM_tmp_count = 0;
for (c = MBM_from; c <= MBM_to; c++) {
@@ -903,7 +903,7 @@ PRIVATE BOOLEAN havevisible ARGS1(CONST char *, Title)
unicode = UCTransToUni(*p, current_char_set);
if (unicode > 32 && unicode < 127)
return(TRUE);
- if (c <= 32 || (c >= 127 && c <= 160) || c == 0xad)
+ if (unicode <= 32 || unicode == 0xa0 || unicode == 0xad)
continue;
if (unicode >= 0x2000 && unicode < 0x200f)
continue;
@@ -955,7 +955,7 @@ PRIVATE char* title_convert8bit ARGS1(CONST char *, Title)
char *ncr = NULL;
char *buf = NULL;
int charset_in = current_char_set;
- int charset_out = -1;
+ int charset_out = UCGetLYhndl_byMIME("us-ascii");
for ( ; *p; p++) {
LYstrncpy(q, p, 1);
@@ -963,24 +963,21 @@ PRIVATE char* title_convert8bit ARGS1(CONST char *, Title)
StrAllocCat(comment, q);
StrAllocCat(ncr, q);
} else {
- int uck;
- long unicode;
- char replace_buf [10], replace_buf2 [10];
+ int uck;
+ long unicode;
+ char replace_buf [10], replace_buf2 [10];
- if (charset_out < 0)
- charset_out = UCGetLYhndl_byMIME("us-ascii");
+ uck = UCTransCharStr(replace_buf, sizeof(replace_buf), *q,
+ charset_in, charset_out, YES);
+ if (uck >0)
+ StrAllocCat(comment, replace_buf);
- uck = UCTransCharStr(replace_buf, sizeof(replace_buf), *q,
- charset_in, charset_out, YES);
- if (uck >0)
- StrAllocCat(comment, replace_buf);
+ unicode = UCTransToUni( *q, charset_in);
- unicode = UCTransToUni( *q, charset_in);
-
- StrAllocCat(ncr, "&#");
- sprintf(replace_buf2, "%ld", unicode);
- StrAllocCat(ncr, replace_buf2);
- StrAllocCat(ncr, ";");
+ StrAllocCat(ncr, "&#");
+ sprintf(replace_buf2, "%ld", unicode);
+ StrAllocCat(ncr, replace_buf2);
+ StrAllocCat(ncr, ";");
}
}
diff --git a/src/LYCgi.c b/src/LYCgi.c
index 3c27a113..7843ad58 100644
--- a/src/LYCgi.c
+++ b/src/LYCgi.c
@@ -21,7 +21,7 @@
**
** Should try and parse for a HTTP 1.1 header in case we are "calling" a
** nph- script.
-*/
+*/
#include <HTUtils.h>
#include <HTTP.h>
@@ -50,7 +50,7 @@
#include <sys/wait.h>
#endif
-struct _HTStream
+struct _HTStream
{
HTStreamClass * isa;
};
@@ -90,7 +90,7 @@ PRIVATE void add_environment_value ARGS1(
env[envc++] = env_value;
env[envc] = NULL; /* Make sure it is always properly terminated */
}
-
+
/*
* Add the value of an existing environment variable to those passed on to the
* lynxcgi script.
@@ -184,7 +184,7 @@ PRIVATE int LYLoadCGI ARGS4(
if (statrv < 0) {
/* Did not find PATH_INFO data */
- if (TRACE)
+ if (TRACE)
perror("LYNXCGI: stat() of pgm_buff failed");
} else {
/* Found PATH_INFO data. Strip it off of pgm and into path_info. */
@@ -229,7 +229,7 @@ PRIVATE int LYLoadCGI ARGS4(
status = -4;
return(status);
}
-
+
LYLocalFileToURL (&new_arg, orig_pgm);
CTRACE(tfp, "%s is not an executable file, passing the buck.\n", arg);
@@ -301,15 +301,15 @@ PRIVATE int LYLoadCGI ARGS4(
/* Show output as plain text */
format_in = WWW_PLAINTEXT;
} else {
-
+
/* Decode full HTTP response */
format_in = HTAtom_for("www/mime");
}
-
+
target = HTStreamStack(format_in,
format_out,
sink, anAnchor);
-
+
if (!target || target == NULL) {
sprintf(buf, CANNOT_CONVERT_I_TO_O,
HTAtom_name(format_in), HTAtom_name(format_out));
@@ -322,7 +322,7 @@ PRIVATE int LYLoadCGI ARGS4(
perror("LYNXCGI: pipe() failed");
}
status = -3;
-
+
} else if (pipe(fd2) < 0) {
HTAlert(CONNECT_SET_FAILED);
if (TRACE) {
@@ -331,30 +331,30 @@ PRIVATE int LYLoadCGI ARGS4(
close(fd1[0]);
close(fd1[1]);
status = -3;
-
- } else {
+
+ } else {
static BOOL first_time = TRUE; /* One time setup flag */
if (first_time) { /* Set up static environment variables */
first_time = FALSE; /* Only once */
-
+
add_environment_value("REMOTE_HOST=localhost");
add_environment_value("REMOTE_ADDR=127.0.0.1");
-
+
sprintf(user_agent, "HTTP_USER_AGENT=%s/%s libwww/%s",
LYNX_NAME, LYNX_VERSION, HTLibraryVersion);
add_environment_value(user_agent);
-
+
sprintf(server_software, "SERVER_SOFTWARE=%s/%s",
LYNX_NAME, LYNX_VERSION);
add_environment_value(server_software);
}
-
+
if ((pid = fork()) > 0) { /* The good, */
int chars, total_chars;
-
+
close(fd2[1]);
-
+
if (anAnchor->post_data) {
int written, remaining, total_written = 0;
close(fd1[0]);
@@ -363,7 +363,7 @@ PRIVATE int LYLoadCGI ARGS4(
CTRACE(tfp, "LYNXCGI: Doing post, content-type '%s'\n",
anAnchor->post_content_type);
CTRACE(tfp, "LYNXCGI: Writing:\n%s----------------------------------\n",
- anAnchor->post_data);
+ anAnchor->post_data);
remaining = strlen(anAnchor->post_data);
while ((written = write(fd1[1],
anAnchor->post_data + total_written,
@@ -395,11 +395,11 @@ PRIVATE int LYLoadCGI ARGS4(
}
close(fd1[1]);
}
-
+
HTReadProgress(total_chars = 0, 0);
while((chars = read(fd2[0], buf, sizeof(buf))) > 0) {
HTReadProgress(total_chars += chars, 0);
- CTRACE(tfp, "LYNXCGI: Rx: %.*s\n", chars, buf);
+ CTRACE(tfp, "LYNXCGI: Rx: %.*s\n", chars, buf);
(*target->isa->put_block)(target, buf, chars);
}
#if !HAVE_WAITPID
@@ -420,7 +420,7 @@ PRIVATE int LYLoadCGI ARGS4(
#endif /* !HAVE_WAITPID */
close(fd2[0]);
status = HT_LOADED;
-
+
} else if (pid == 0) { /* The Bad, */
char **argv = NULL;
char post_len[32];
@@ -474,7 +474,7 @@ PRIVATE int LYLoadCGI ARGS4(
}
}
- /*
+ /*
* Set up argument line, mainly for <index> scripts
*/
if (pgm_args != NULL) {
@@ -490,7 +490,7 @@ PRIVATE int LYLoadCGI ARGS4(
outofmem(__FILE__, "LYCgi");
}
cur_argv = argv + 1; /* For argv[0] */
- if (pgm_args != NULL) {
+ if (pgm_args != NULL) {
char *cr;
/* Data for a get/search form */
@@ -499,7 +499,7 @@ PRIVATE int LYLoadCGI ARGS4(
} else if (!anAnchor->isHEAD) {
add_environment_value("REQUEST_METHOD=GET");
}
-
+
cp = NULL;
StrAllocCopy(cp, "QUERY_STRING=");
StrAllocCat(cp, pgm_args);
@@ -514,7 +514,7 @@ PRIVATE int LYLoadCGI ARGS4(
if (*cp == '\0') {
*(cur_argv++) = HTUnEscape(cr);
break;
-
+
} else if (*cp == '+') {
*cp++ = '\0';
*(cur_argv++) = HTUnEscape(cr);
@@ -523,10 +523,10 @@ PRIVATE int LYLoadCGI ARGS4(
cp++;
}
}
- *cur_argv = NULL; /* Terminate argv */
+ *cur_argv = NULL; /* Terminate argv */
argv[0] = pgm;
- /* Begin WebSter Mods -jkt */
+ /* Begin WebSter Mods -jkt */
if (LYCgiDocumentRoot != NULL) {
/* Add DOCUMENT_ROOT to env */
cp = NULL;
@@ -559,7 +559,7 @@ PRIVATE int LYLoadCGI ARGS4(
if (TRACE) {
perror("LYNXCGI: execve failed");
}
-
+
} else { /* and the Ugly */
HTAlert(CONNECT_FAILED);
if (TRACE) {
@@ -585,13 +585,13 @@ PRIVATE int LYLoadCGI ARGS4(
HTStream *target;
char buf[256];
- target = HTStreamStack(WWW_HTML,
+ target = HTStreamStack(WWW_HTML,
format_out,
sink, anAnchor);
sprintf(buf, "<head>\n<title>%s</title>\n</head>\n<body>\n", gettext("Good Advice"));
(*target->isa->put_block)(target, buf, strlen(buf));
-
+
sprintf(buf, "<h1>%s</h1>\n", gettext("Good Advice"));
(*target->isa->put_block)(target, buf, strlen(buf));
@@ -605,8 +605,8 @@ PRIVATE int LYLoadCGI ARGS4(
sprintf(buf, ">%s</a>.\n", gettext("this link"));
(*target->isa->put_block)(target, buf, strlen(buf));
- sprintf(buf,
- gettext("<p>It provides <b>state of the art</b> CGI script support.\n"));
+ sprintf(buf, "<p>%s\n",
+ gettext("It provides state of the art CGI script support.\n"));
(*target->isa->put_block)(target, buf, strlen(buf));
sprintf(buf,"</body>\n");
diff --git a/src/LYCookie.c b/src/LYCookie.c
index 0ef68296..73d9049e 100644
--- a/src/LYCookie.c
+++ b/src/LYCookie.c
@@ -131,12 +131,10 @@ PRIVATE void MemAllocCopy ARGS3(
PRIVATE cookie * newCookie NOARGS
{
cookie *p = (cookie *)calloc(1, sizeof(cookie));
- char lynxID[64];
if (p == NULL)
outofmem(__FILE__, "newCookie");
- sprintf(lynxID, "%p", p);
- StrAllocCopy(p->lynxID, lynxID);
+ HTSprintf0(&(p->lynxID), "%p", p);
p->port = 80;
return p;
}
@@ -350,16 +348,9 @@ PRIVATE void store_cookie ARGS3(
*/
ptr = ((hostname + strlen(hostname)) - strlen(co->domain));
if (strchr(hostname, '.') < ptr) {
- char *msg = calloc(1,
- (strlen(co->domain) +
- strlen(hostname) +
- strlen(INVALID_COOKIE_DOMAIN_CONFIRMATION) +
- 1));
-
- if (msg == 0)
- outofmem(__FILE__, "store_cookie");
if (!LYAcceptAllCookies) {
- sprintf(msg,
+ char *msg = 0;
+ HTSprintf0(&msg,
INVALID_COOKIE_DOMAIN_CONFIRMATION,
co->domain,
hostname);
@@ -372,8 +363,8 @@ PRIVATE void store_cookie ARGS3(
FREE(msg);
return;
}
+ FREE(msg);
}
- FREE(msg);
}
}
}
@@ -624,9 +615,7 @@ PRIVATE char * scan_cookie_sublist ARGS6(
* the version number goes before the
* first cookie.
*/
- char version[16];
- sprintf(version, "$Version=\"%d\"; ", co->version);
- StrAllocCopy(header, version);
+ HTSprintf0(&header, "$Version=\"%d\"; ", co->version);
len += strlen(header);
}
} else {
@@ -1093,9 +1082,7 @@ PRIVATE void LYProcessSetCookies ARGS6(
* Don't process a repeat port. - FM
*/
if (cur_cookie->PortList == NULL) {
- char temp[256];
- sprintf(temp, "%d", port);
- StrAllocCopy(cur_cookie->PortList, temp);
+ HTSprintf0(&(cur_cookie->PortList), "%d", port);
length += strlen(cur_cookie->PortList);
}
known_attr = YES;
@@ -1579,9 +1566,7 @@ PRIVATE void LYProcessSetCookies ARGS6(
* Don't process a repeat port. - FM
*/
if (cur_cookie->PortList == NULL) {
- char temp[256];
- sprintf(temp, "%d", port);
- StrAllocCopy(cur_cookie->PortList, temp);
+ HTSprintf0(&(cur_cookie->PortList), "%d", port);
length += strlen(cur_cookie->PortList);
}
known_attr = YES;
@@ -2003,9 +1988,11 @@ PUBLIC void LYLoadCookies ARGS1 (
/* rjp - experimental persistent cookie support */
PUBLIC void LYStoreCookies ARGS1 (
- CONST char *, cookie_file)
+ char *, cookie_file)
{
- char buf[1024];
+#if 0
+ char *buf = NULL;
+#endif
HTList *dl, *cl;
domain_entry *de;
cookie *co;
@@ -2023,7 +2010,7 @@ PUBLIC void LYStoreCookies ARGS1 (
return;
}
- cookie_handle = fopen(cookie_file, "w+");
+ cookie_handle = LYNewTxtFile (cookie_file);
for (dl = domain_list; dl != NULL; dl = dl->next) {
de = dl->object;
if (de == NULL)
@@ -2032,20 +2019,23 @@ PUBLIC void LYStoreCookies ARGS1 (
*/
continue;
+#if 0
switch (de->bv) {
case (ACCEPT_ALWAYS):
- sprintf(buf, COOKIES_ALWAYS_ALLOWED);
+ HTSprintf0(&buf, COOKIES_ALWAYS_ALLOWED);
break;
case (REJECT_ALWAYS):
- sprintf(buf, COOKIES_NEVER_ALLOWED);
+ HTSprintf0(&buf, COOKIES_NEVER_ALLOWED);
break;
case (QUERY_USER):
- sprintf(buf, COOKIES_ALLOWED_VIA_PROMPT);
+ HTSprintf0(&buf, COOKIES_ALLOWED_VIA_PROMPT);
break;
case (FROM_FILE):
- sprintf(buf, gettext("(From Cookie Jar)"));
+ HTSprintf0(&buf, gettext("(From Cookie Jar)"));
break;
}
+ /* FIXME: buf unused */
+#endif
/*
* Show the domain's cookies. - FM
@@ -2097,7 +2087,7 @@ PRIVATE int LYHandleCookies ARGS4 (
{
HTFormat format_in = WWW_HTML;
HTStream *target = NULL;
- char buf[1024];
+ char *buf = NULL;
char *domain = NULL;
char *lynxID = NULL;
HTList *dl, *cl, *next;
@@ -2352,9 +2342,10 @@ Delete_all_cookies_in_domain:
format_out,
sink, anAnchor);
if (!target || target == NULL) {
- sprintf(buf, CANNOT_CONVERT_I_TO_O,
+ HTSprintf0(&buf, CANNOT_CONVERT_I_TO_O,
HTAtom_name(format_in), HTAtom_name(format_out));
HTAlert(buf);
+ FREE(buf);
return(HT_NOT_LOADED);
}
@@ -2362,21 +2353,21 @@ Delete_all_cookies_in_domain:
* Load HTML strings into buf and pass buf
* to the target for parsing and rendering. - FM
*/
- sprintf(buf, "<HEAD>\n<TITLE>%s</title>\n</HEAD>\n<BODY>\n",
+ HTSprintf0(&buf, "<HEAD>\n<TITLE>%s</title>\n</HEAD>\n<BODY>\n",
COOKIE_JAR_TITLE);
(*target->isa->put_block)(target, buf, strlen(buf));
- sprintf(buf, "<h1>%s (%s)%s<a href=\"%s%s\">%s</a></h1>\n",
+ HTSprintf0(&buf, "<h1>%s (%s)%s<a href=\"%s%s\">%s</a></h1>\n",
LYNX_NAME, LYNX_VERSION,
HELP_ON_SEGMENT,
helpfilepath, COOKIE_JAR_HELP, COOKIE_JAR_TITLE);
(*target->isa->put_block)(target, buf, strlen(buf));
- sprintf(buf, "<NOTE>%s\n", ACTIVATE_TO_GOBBLE);
+ HTSprintf0(&buf, "<NOTE>%s\n", ACTIVATE_TO_GOBBLE);
(*target->isa->put_block)(target, buf, strlen(buf));
- sprintf(buf, "%s</NOTE>\n", OR_CHANGE_ALLOW);
+ HTSprintf0(&buf, "%s</NOTE>\n", OR_CHANGE_ALLOW);
(*target->isa->put_block)(target, buf, strlen(buf));
- sprintf(buf, "<DL COMPACT>\n");
+ HTSprintf0(&buf, "<DL COMPACT>\n");
(*target->isa->put_block)(target, buf, strlen(buf));
for (dl = domain_list; dl != NULL; dl = dl->next) {
de = dl->object;
@@ -2389,25 +2380,25 @@ Delete_all_cookies_in_domain:
/*
* Show the domain link and 'allow' setting. - FM
*/
- sprintf(buf, "<DT>%s<DD><A HREF=\"LYNXCOOKIE://%s/\">Domain=%s</A>\n",
+ HTSprintf0(&buf, "<DT>%s<DD><A HREF=\"LYNXCOOKIE://%s/\">Domain=%s</A>\n",
de->domain, de->domain, de->domain);
(*target->isa->put_block)(target, buf, strlen(buf));
switch (de->bv) {
case (ACCEPT_ALWAYS):
- sprintf(buf, COOKIES_ALWAYS_ALLOWED);
+ HTSprintf0(&buf, COOKIES_ALWAYS_ALLOWED);
break;
case (REJECT_ALWAYS):
- sprintf(buf, COOKIES_NEVER_ALLOWED);
+ HTSprintf0(&buf, COOKIES_NEVER_ALLOWED);
break;
case (QUERY_USER):
- sprintf(buf, COOKIES_ALLOWED_VIA_PROMPT);
+ HTSprintf0(&buf, COOKIES_ALLOWED_VIA_PROMPT);
break;
case (FROM_FILE):
- sprintf(buf, COOKIES_READ_FROM_FILE);
+ HTSprintf0(&buf, COOKIES_READ_FROM_FILE);
break;
}
(*target->isa->put_block)(target, buf, strlen(buf));
- sprintf(buf, "\n");
+ HTSprintf0(&buf, "\n");
(*target->isa->put_block)(target, buf, strlen(buf));
/*
@@ -2435,7 +2426,7 @@ Delete_all_cookies_in_domain:
} else {
StrAllocCopy(value, NO_VALUE);
}
- sprintf(buf, "<DD><A HREF=\"LYNXCOOKIE://%s/%s\">%s=%s</A>\n",
+ HTSprintf0(&buf, "<DD><A HREF=\"LYNXCOOKIE://%s/%s\">%s=%s</A>\n",
de->domain, co->lynxID, name, value);
FREE(name);
FREE(value);
@@ -2450,7 +2441,7 @@ Delete_all_cookies_in_domain:
} else {
StrAllocCopy(path, "/");
}
- sprintf(buf, "<DD>Path=%s\n<DD>Port: %d Secure: %s Discard: %s\n",
+ HTSprintf0(&buf, "<DD>Path=%s\n<DD>Port: %d Secure: %s Discard: %s\n",
path, co->port,
((co->flags & COOKIE_FLAG_SECURE) ? "YES" : "NO"),
((co->flags & COOKIE_FLAG_DISCARD) ? "YES" : "NO"));
@@ -2461,7 +2452,7 @@ Delete_all_cookies_in_domain:
* Show the list of acceptable ports, if present. - FM
*/
if (co->PortList) {
- sprintf(buf, "<DD>PortList=\"%s\"\n", co->PortList);
+ HTSprintf0(&buf, "<DD>PortList=\"%s\"\n", co->PortList);
(*target->isa->put_block)(target, buf, strlen(buf));
}
@@ -2473,7 +2464,7 @@ Delete_all_cookies_in_domain:
LYEntify(&Address, FALSE);
StrAllocCopy(Title, co->commentURL);
LYEntify(&Title, TRUE);
- sprintf(buf,
+ HTSprintf0(&buf,
"<DD>CommentURL: <A href=\"%s\">%s</A>\n",
Address,
Title);
@@ -2488,7 +2479,7 @@ Delete_all_cookies_in_domain:
if (co->comment) {
StrAllocCopy(comment, co->comment);
LYEntify(&comment, TRUE);
- sprintf(buf, "<DD>Comment: %s\n", comment);
+ HTSprintf0(&buf, "<DD>Comment: %s\n", comment);
FREE(comment);
(*target->isa->put_block)(target, buf, strlen(buf));
}
@@ -2496,7 +2487,7 @@ Delete_all_cookies_in_domain:
/*
* Show the Maximum Gobble Date. - FM
*/
- sprintf(buf, "<DD><EM>%s</EM> %s%s",
+ HTSprintf0(&buf, "<DD><EM>%s</EM> %s%s",
gettext("Maximum Gobble Date:"),
((co->expires > 0 &&
!(co->flags & COOKIE_FLAG_DISCARD))
@@ -2508,10 +2499,10 @@ Delete_all_cookies_in_domain:
"" : "\n"));
(*target->isa->put_block)(target, buf, strlen(buf));
}
- sprintf(buf, "</DT>\n");
+ HTSprintf0(&buf, "</DT>\n");
(*target->isa->put_block)(target, buf, strlen(buf));
}
- sprintf(buf, "</DL>\n</BODY>\n");
+ HTSprintf0(&buf, "</DL>\n</BODY>\n");
(*target->isa->put_block)(target, buf, strlen(buf));
/*
@@ -2519,6 +2510,7 @@ Delete_all_cookies_in_domain:
* Cookie Jar Page, and report a successful load. - FM
*/
(*target->isa->_free)(target);
+ FREE(buf);
return(HT_LOADED);
}
diff --git a/src/LYCookie.h b/src/LYCookie.h
index f54518bf..62caa88a 100644
--- a/src/LYCookie.h
+++ b/src/LYCookie.h
@@ -14,7 +14,7 @@ extern char *LYCookie PARAMS((
int port,
BOOL secure));
extern void LYStoreCookies PARAMS((
- CONST char * cookie_file));
+ char * cookie_file));
extern void LYLoadCookies PARAMS((
char * cookie_file));
extern void cookie_add_acceptlist PARAMS((
diff --git a/src/LYCurses.c b/src/LYCurses.c
index 42b10477..b103d4de 100644
--- a/src/LYCurses.c
+++ b/src/LYCurses.c
@@ -754,6 +754,7 @@ PUBLIC void start_curses NOARGS
}
#if defined(SIGWINCH) && defined(NCURSES_VERSION)
size_change(0);
+ recent_sizechange = FALSE; /* prevent mainloop drawing 1st doc twice */
#endif /* SIGWINCH */
#if defined(USE_KEYMAPS) && defined(NCURSES_VERSION)
if (-1 == lynx_initialize_keymaps ())
@@ -873,10 +874,22 @@ PUBLIC void lynx_enable_mouse ARGS1(int,state)
}
#else
/* Inform ncurses that we're interested in knowing when mouse
- * button 1 is clicked */
- if (state)
- mousemask(BUTTON1_CLICKED | BUTTON3_CLICKED, NULL);
- else
+ * button 1 is clicked. We cannot just specify
+ * BUTTON1_CLICKED | BUTTON3_CLICKED, since ncurses will try hard
+ * to translate other events to single-clicks.
+ * Compensate for small value of maxclick in ncurses. */
+ if (state) {
+ static was = 0;
+
+ if (!was) {
+ int old = mouseinterval(-1);
+
+ was++;
+ if (old < 200) /* Default 166 */
+ mouseinterval(300);
+ }
+ mousemask(ALL_MOUSE_EVENTS, NULL);
+ } else
mousemask(0, NULL);
#endif /* __BORLANDC__ and __PDCURSES__ */
#endif /* NCURSES_MOUSE_VERSION */
diff --git a/src/LYCurses.h b/src/LYCurses.h
index 1a857341..eb63fea2 100644
--- a/src/LYCurses.h
+++ b/src/LYCurses.h
@@ -2,7 +2,6 @@
#define LYCURSES_H
#include <HTUtils.h>
-#include <userdefs.h>
/*
* The simple color scheme maps the 8 combinations of bold/underline/reverse
@@ -27,9 +26,6 @@
#if defined(UNIX) && !defined(unix)
#define unix
#endif /* UNIX && !unix */
-#ifdef va_start
-#undef va_start /* not used, undef to avoid warnings on some systems */
-#endif /* va_start */
#include <slang.h>
#else /* Using curses: */
@@ -218,6 +214,9 @@ extern unsigned int Lynx_Color_Flags;
/*
* Map some curses functions to slang functions.
*/
+#ifndef WINDOW
+#define WINDOW void
+#endif
#define stdscr NULL
#ifdef SLANG_MBCS_HACK
extern int PHYSICAL_SLtt_Screen_Cols;
diff --git a/src/LYEditmap.c b/src/LYEditmap.c
index 1a1dcebd..8ba0d65c 100644
--- a/src/LYEditmap.c
+++ b/src/LYEditmap.c
@@ -99,7 +99,7 @@ LYE_CHAR, LYE_CHAR, LYE_CHAR, LYE_CHAR,
LYE_CHAR, LYE_CHAR, LYE_CHAR, LYE_CHAR,
LYE_CHAR, LYE_CHAR, LYE_CHAR, LYE_CHAR,
-/* 100..10E function key definitions in LYStrings.h */
+/* 100..10F function key definitions in LYStrings.h */
LYE_NOP, LYE_NOP, LYE_FORW, LYE_BACK,
/* UPARROW DNARROW RTARROW LTARROW */
@@ -110,7 +110,7 @@ LYE_NOP, LYE_TAB, LYE_BOL, LYE_EOL,
/* F1 Do key Find key Select key */
LYE_NOP, LYE_DELP, LYE_NOP, LYE_NOP,
-/* Insert key Remove key DO_NOTHING ... */
+/* Insert key Remove key MOUSE_KEY DO_NOTHING */
};
/*
diff --git a/src/LYForms.c b/src/LYForms.c
index ff64cb2d..2de3e9e3 100644
--- a/src/LYForms.c
+++ b/src/LYForms.c
@@ -263,7 +263,7 @@ PRIVATE int form_getstr ARGS1(
int max_length;
int startcol, startline;
BOOL HaveMaxlength = FALSE;
- int action;
+ int action, repeat, non_first = 0;
#ifdef VMS
extern BOOLEAN HadVMSInterrupt; /* Flag from cleanup_sig() AST */
@@ -288,7 +288,7 @@ PRIVATE int form_getstr ARGS1(
form->maxlength < sizeof(MyEdit.buffer)) ?
form->maxlength :
(sizeof(MyEdit.buffer) - 1));
- if (strlen(form->value) > max_length) {
+ if (strlen(form->value) > (size_t)max_length) {
/*
* We can't fit the entire value into the editing buffer,
* so enter as much of the tail as fits. - FM
@@ -337,14 +337,38 @@ PRIVATE int form_getstr ARGS1(
*/
for (;;) {
again:
- ch = LYgetch();
+ repeat = -1;
+ get_mouse_link(); /* Reset mouse_link. */
+ /* Try to set position basing on the last mouse event */
+ if (!non_first++)
+ peek_mouse_levent();
+
+ ch = LYgetch_for(FOR_INPUT);
#ifdef VMS
if (HadVMSInterrupt) {
HadVMSInterrupt = FALSE;
ch = 7;
}
#endif /* VMS */
-
+# ifdef NCURSES_MOUSE_VERSION
+ if (ch == MOUSE_KEY) { /* Need to process ourselves */
+ MEVENT event;
+ int curx, cury;
+
+ getmouse(&event);
+ LYGetYX(cury, curx);
+ if (event.y == cury) {
+ repeat = event.x - curx;
+ if (repeat < 0) {
+ ch = LTARROW;
+ repeat = - repeat;
+ } else
+ ch = RTARROW;
+ }
+ }
+# endif /* defined NCURSES_MOUSE_VERSION */
+ if (peek_mouse_link() != -1)
+ break;
/*
* Filter out global navigation keys that should not be passed
* to line editor, and LYK_REFRESH.
@@ -393,7 +417,7 @@ again:
* else you can get trapped in a form without submit button!
*/
case LTARROW:
- if (MyEdit.pos == 0) {
+ if (MyEdit.pos == 0 && repeat == -1) {
int c = 'Y'; /* Go back immediately if no changes */
if (strcmp(MyEdit.buffer, value)) {
_statusline(PREV_DOC_QUERY);
@@ -416,7 +440,10 @@ again:
/*
* Make sure the statusline uses editmode help.
*/
- LYLineEdit(&MyEdit, ch, TRUE);
+ if (repeat < 0)
+ repeat = 1;
+ while (repeat--)
+ LYLineEdit(&MyEdit, ch, TRUE);
if (MyEdit.strlen >= max_length) {
HaveMaxlength = TRUE;
} else if (HaveMaxlength &&
@@ -824,11 +851,19 @@ redraw:
wrefresh(form_window);
#endif /* USE_SLANG */
- c = LYgetch();
- if (c == 3 || c == 7) /* Control-C or Control-G */
+ c = LYgetch_for(FOR_CHOICE);
+ if (c == 3 || c == 7) { /* Control-C or Control-G */
cmd = LYK_QUIT;
- else
+#ifndef USE_SLANG
+ } else if (c == MOUSE_KEY) {
+ if ((cmd = fancy_mouse(form_window, i + 1 + window_offset, &cur_selection)) < 0)
+ goto redraw;
+ if (cmd == LYK_ACTIVATE)
+ break;
+#endif
+ } else {
cmd = keymap[c+1];
+ }
#ifdef VMS
if (HadVMSInterrupt) {
HadVMSInterrupt = FALSE;
diff --git a/src/LYGlobalDefs.h b/src/LYGlobalDefs.h
index 663c968f..3028e143 100644
--- a/src/LYGlobalDefs.h
+++ b/src/LYGlobalDefs.h
@@ -3,10 +3,6 @@
#ifndef LYGLOBALDEFS_H
#define LYGLOBALDEFS_H
-#ifndef USERDEFS_H
-#include <userdefs.h>
-#endif /* USERDEFS_H */
-
#ifndef HTUTILS_H
#include <HTUtils.h>
#endif /* HTUTILS_H */
diff --git a/src/LYHistory.c b/src/LYHistory.c
index 6ba11db6..9c94786f 100644
--- a/src/LYHistory.c
+++ b/src/LYHistory.c
@@ -385,7 +385,7 @@ PUBLIC int showhistory ARGS1(
BeginInternalPage(fp0, HISTORY_PAGE_TITLE, HISTORY_PAGE_HELP);
fprintf(fp0, "<pre>\n");
- fprintf(fp0, gettext("<em>%s</em>\n"), gettext("You selected:"));
+ fprintf(fp0, "<em>%s</em>\n", gettext("You selected:"));
for (x = nhist-1; x >= 0; x--) {
/*
* The number of the document in the hist stack,
diff --git a/src/LYLocal.c b/src/LYLocal.c
index 6d12f738..37c63cb3 100644
--- a/src/LYLocal.c
+++ b/src/LYLocal.c
@@ -238,12 +238,12 @@ struct dired_menu {
PRIVATE BOOLEAN ok_stat ARGS2(char *, name, struct stat*, sb)
{
- char tmpbuf[LY_MAXPATH+80];
-
CTRACE(tfp, "testing ok_stat(%s)\n", name);
if (stat(name, sb) < 0) {
- sprintf(tmpbuf, gettext("Unable to get status of '%s'."), name);
+ char *tmpbuf = 0;
+ HTSprintf(&tmpbuf, gettext("Unable to get status of '%s'."), name);
HTAlert(tmpbuf);
+ FREE(tmpbuf);
return FALSE;
}
return TRUE;
@@ -252,12 +252,12 @@ PRIVATE BOOLEAN ok_stat ARGS2(char *, name, struct stat*, sb)
#ifdef HAVE_LSTAT
PRIVATE BOOLEAN ok_lstat ARGS2(char *, name, struct stat*, sb)
{
- char tmpbuf[LY_MAXPATH+80];
-
CTRACE(tfp, "testing ok_lstat(%s)\n", name);
if (lstat(name, sb) < 0) {
- sprintf(tmpbuf, gettext("Unable to get status of '%s'."), name);
+ char *tmpbuf = 0;
+ HTSprintf(&tmpbuf, gettext("Unable to get status of '%s'."), name);
HTAlert(tmpbuf);
+ FREE(tmpbuf);
return FALSE;
}
return TRUE;
@@ -297,8 +297,9 @@ PRIVATE BOOLEAN ok_localname ARGS2(char*, dst, char*, src)
PRIVATE BOOLEAN remove_tagged NOARGS
{
int c, ans;
- char *cp, *tp;
- char tmpbuf[1024];
+ BOOL will_clear = TRUE;
+ char *cp;
+ char *tmpbuf = NULL;
char *testpath = NULL;
struct stat dir_info;
int count;
@@ -316,33 +317,35 @@ PRIVATE BOOLEAN remove_tagged NOARGS
tag = tagged;
while (ans == 'Y' && (cp = (char *)HTList_nextObject(tag)) != NULL) {
if (is_url(cp) == FILE_URL_TYPE) { /* unnecessary check */
- tp = HTfullURL_toFile(cp);
- StrAllocCopy(testpath, tp);
- free(tp);
-
+ testpath = HTfullURL_toFile(cp);
LYTrimPathSep(testpath);
+ will_clear = TRUE;
/*
* Check the current status of the path to be deleted.
*/
if (!ok_stat(testpath, &dir_info)) {
- return count;
+ will_clear = FALSE;
+ break;
} else {
args[0] = "rm";
args[1] = "-rf";
args[2] = testpath;
args[3] = (char *) 0;
- sprintf(tmpbuf, gettext("remove %s"), testpath);
+ HTSprintf0(&tmpbuf, gettext("remove %s"), testpath);
if (LYExecv(RM_PATH, args, tmpbuf) <= 0) {
- FREE(testpath);
- return ((count == 0) ? -1 : count);
+ if (count == 0) count = -1;
+ will_clear = FALSE;
+ break;
}
++count;
}
}
}
FREE(testpath);
- clear_tags();
+ FREE(tmpbuf);
+ if (will_clear)
+ clear_tags();
return count;
}
@@ -485,18 +488,19 @@ PRIVATE BOOLEAN modify_tagged ARGS1(
while ((cp = (char *)HTList_nextObject(tag)) != NULL) {
cp = HTfullURL_toFile(cp);
StrAllocCopy(srcpath, cp);
- free(cp);
- sprintf(tmpbuf, gettext("move %s to %s"), srcpath, savepath);
+ HTSprintf0(&cp, gettext("move %s to %s"), srcpath, savepath);
args[0] = "mv";
args[1] = srcpath;
args[2] = savepath;
args[3] = (char *) 0;
- if (LYExecv(MV_PATH, args, tmpbuf) <= 0) {
+ if (LYExecv(MV_PATH, args, cp) <= 0) {
+ FREE(cp);
if (count == 0)
count = -1;
break;
}
+ FREE(cp);
++count;
}
FREE(srcpath);
@@ -567,19 +571,22 @@ PRIVATE BOOLEAN modify_name ARGS1(
* Make sure the destination does not already exist.
*/
if (stat(newpath, &dir_info) == -1) {
+ char *msg = 0;
if (errno != ENOENT) {
- sprintf(tmpbuf,
+ HTSprintf(&msg,
gettext("Unable to determine status of '%s'."), newpath);
- HTAlert(tmpbuf);
+ HTAlert(msg);
+ FREE(msg);
} else {
- sprintf(tmpbuf, gettext("move %s to %s"), savepath, newpath);
+ int code;
+ HTSprintf(&msg, gettext("move %s to %s"), savepath, newpath);
args[0] = "mv";
args[1] = savepath;
args[2] = newpath;
args[3] = (char *) 0;
- if (LYExecv(MV_PATH, args, tmpbuf) <= 0)
- return (-1);
- return 1;
+ code = (LYExecv(MV_PATH, args, msg) <= 0) ? -1 : 1;
+ FREE(msg);
+ return code;
}
} else if (S_ISDIR(dir_info.st_mode)) {
HTAlert(gettext("There is already a directory with that name! Request ignored."));
@@ -680,14 +687,16 @@ PRIVATE BOOLEAN modify_location ARGS1(
return 0;
}
if (dir_info.st_uid == owner) {
- sprintf(tmpbuf,gettext("move %s to %s"),savepath,newpath);
+ int code;
+ char *msg = 0;
+ HTSprintf(&msg,gettext("move %s to %s"),savepath,newpath);
args[0] = "mv";
args[1] = savepath;
args[2] = newpath;
args[3] = (char *) 0;
- if (LYExecv(MV_PATH, args, tmpbuf) <= 0)
- return (-1);
- return 1;
+ code = (LYExecv(MV_PATH, args, msg) <= 0) ? -1 : 1;
+ FREE(msg);
+ return code;
} else {
HTAlert(gettext("Destination has different owner! Request denied."));
return 0;
@@ -803,19 +812,22 @@ PRIVATE BOOLEAN create_file ARGS1(
* Make sure the target does not already exist
*/
if (stat(testpath, &dir_info) == -1) {
+ int code;
+ char *msg = 0;
if (errno != ENOENT) {
- sprintf(tmpbuf,
+ HTSprintf(&msg,
gettext("Unable to determine status of '%s'."), testpath);
- HTAlert(tmpbuf);
- return 0;
+ HTAlert(msg);
+ code = 0;
+ } else {
+ HTSprintf(&msg,gettext("create %s"),testpath);
+ args[0] = "touch";
+ args[1] = testpath;
+ args[2] = (char *) 0;
+ code = (LYExecv(TOUCH_PATH, args, msg) <= 0) ? -1 : 1;
}
- sprintf(tmpbuf,gettext("create %s"),testpath);
- args[0] = "touch";
- args[1] = testpath;
- args[2] = (char *) 0;
- if (LYExecv(TOUCH_PATH, args, tmpbuf) <= 0)
- return (-1);
- return 1;
+ FREE(msg);
+ return code;
} else if (S_ISDIR(dir_info.st_mode)) {
HTAlert(gettext("There is already a directory with that name! Request ignored."));
} else if (S_ISREG(dir_info.st_mode)) {
@@ -860,19 +872,22 @@ PRIVATE BOOLEAN create_directory ARGS1(
* Make sure the target does not already exist.
*/
if (stat(testpath, &dir_info) == -1) {
+ int code;
+ char *msg = 0;
if (errno != ENOENT) {
- sprintf(tmpbuf,
- gettext("Unable to determine status of '%s'."), testpath);
- HTAlert(tmpbuf);
- return 0;
+ HTSprintf(&msg,
+ gettext("Unable to determine status of '%s'."), testpath);
+ HTAlert(msg);
+ code = 0;
+ } else {
+ HTSprintf(&msg,"make directory %s",testpath);
+ args[0] = "mkdir";
+ args[1] = testpath;
+ args[2] = (char *) 0;
+ code = (LYExecv(MKDIR_PATH, args, msg) <= 0) ? -1 : 1;
}
- sprintf(tmpbuf,"make directory %s",testpath);
- args[0] = "mkdir";
- args[1] = testpath;
- args[2] = (char *) 0;
- if (LYExecv(MKDIR_PATH, args, tmpbuf) <= 0)
- return (-1);
- return 1;
+ FREE(msg);
+ return code;
} else if (S_ISDIR(dir_info.st_mode)) {
HTAlert(gettext("There is already a directory with that name! Request ignored."));
} else if (S_ISREG(dir_info.st_mode)) {
@@ -918,8 +933,9 @@ PRIVATE BOOLEAN remove_single ARGS1(
char *, testpath)
{
int c;
+ int code = 0;
char *cp;
- char tmpbuf[1024];
+ char *tmpbuf = 0;
struct stat dir_info;
char *args[5];
@@ -939,45 +955,45 @@ PRIVATE BOOLEAN remove_single ARGS1(
/*** This strlen stuff will probably screw up intl translations /jes ***/
/*** Course, it's probably broken for screen sizes other 80, too ***/
if (strlen(cp) < 37) {
- sprintf(tmpbuf,
- gettext("Remove '%s' and all of its contents (y or n): "), cp);
+ HTSprintf0(&tmpbuf,
+ gettext("Remove '%s' and all of its contents (y or n): "), cp);
} else {
- sprintf(tmpbuf,
- gettext("Remove directory and all of its contents (y or n): "));
+ HTSprintf0(&tmpbuf,
+ gettext("Remove directory and all of its contents (y or n): "));
}
} else if (S_ISREG(dir_info.st_mode)) {
if (strlen(cp) < 60) {
- sprintf(tmpbuf, gettext("Remove file '%s' (y or n): "), cp);
+ HTSprintf0(&tmpbuf, gettext("Remove file '%s' (y or n): "), cp);
} else {
- sprintf(tmpbuf, gettext("Remove file (y or n): "));
+ HTSprintf0(&tmpbuf, gettext("Remove file (y or n): "));
}
#ifdef S_IFLNK
} else if (S_ISLNK(dir_info.st_mode)) {
if (strlen(cp) < 50) {
- sprintf(tmpbuf, gettext("Remove symbolic link '%s' (y or n): "), cp);
+ HTSprintf0(&tmpbuf, gettext("Remove symbolic link '%s' (y or n): "), cp);
} else {
- sprintf(tmpbuf, gettext("Remove symbolic link (y or n): "));
+ HTSprintf0(&tmpbuf, gettext("Remove symbolic link (y or n): "));
}
#endif
} else {
- sprintf(tmpbuf, gettext("Unable to determine status of '%s'."), testpath);
+ HTSprintf0(&tmpbuf, gettext("Unable to determine status of '%s'."), testpath);
HTAlert(tmpbuf);
+ FREE(tmpbuf);
return 0;
}
_statusline(tmpbuf);
c = LYgetch();
if (TOUPPER(c) == 'Y') {
- sprintf(tmpbuf,"remove %s",testpath);
+ HTSprintf0(&tmpbuf,"remove %s",testpath);
args[0] = "rm";
args[1] = "-rf";
args[2] = testpath;
args[3] = (char *) 0;
- if (LYExecv(RM_PATH, args, tmpbuf) <= 0)
- return (-1);
- return 1;
+ code = (LYExecv(RM_PATH, args, tmpbuf) <= 0) ? -1 : 1;
}
- return 0;
+ FREE(tmpbuf);
+ return code;
}
/*
@@ -1056,7 +1072,7 @@ PRIVATE BOOLEAN permit_location ARGS3(
#else
static char tempfile[LY_MAXPATH] = "\0";
char *cp;
- char tmpbuf[LINESIZE];
+ char *tmpbuf = NULL;
char tmpdst[LY_MAXPATH];
struct stat dir_info;
@@ -1101,7 +1117,7 @@ PRIVATE BOOLEAN permit_location ARGS3(
fprintf(fp0, "<Html><Head>\n<Title>%s</Title>\n</Head>\n<Body>\n",
PERMIT_OPTIONS_TITLE);
- fprintf(fp0,gettext("<H1>%s%s</H1>\n"), PERMISSIONS_SEGMENT, user_filename);
+ fprintf(fp0,"<H1>%s%s</H1>\n", PERMISSIONS_SEGMENT, user_filename);
{ /*
* Prevent filenames which include '#' or '?' from messing it up.
*/
@@ -1160,8 +1176,8 @@ PRIVATE BOOLEAN permit_location ARGS3(
(dir_info.st_mode & S_IXOTH) ? "checked" : "",
S_ISDIR(dir_info.st_mode) ? "Search" : "Execute");
- fprintf(fp0, gettext(
-"<Br>\n<Li><Input Type=\"submit\" Value=\"Submit\"> %s %s %s.\n</Ol>\n</Form>\n"),
+ fprintf(fp0,
+"<Br>\n<Li><Input Type=\"submit\" Value=\"Submit\"> %s %s %s.\n</Ol>\n</Form>\n",
gettext("form to permit"),
S_ISDIR(dir_info.st_mode) ? "directory" : "file",
user_filename);
@@ -1275,15 +1291,17 @@ PRIVATE BOOLEAN permit_location ARGS3(
/*
* Call chmod().
*/
- sprintf(tmpbuf, "chmod %.4o %s", (unsigned int)new_mode, destpath);
+ HTSprintf(&tmpbuf, "chmod %.4o %s", (unsigned int)new_mode, destpath);
sprintf(amode, "%.4o", (unsigned int)new_mode);
args[0] = "chmod";
args[1] = amode;
args[2] = destpath;
args[3] = (char *) 0;
if (LYExecv(CHMOD_PATH, args, tmpbuf) <= 0) {
+ FREE(tmpbuf);
return (-1);
}
+ FREE(tmpbuf);
#endif /* UNIX */
LYforce_no_cache = TRUE; /* Force update of dired listing. */
return 1;
@@ -1353,14 +1371,17 @@ PUBLIC void showtags ARGS1(
* about not escaping parsing '#' "the URL way" built into HTParse, but that
* doesn't look like a clean way.)
*/
+#ifdef VMS
+ extern BOOLEAN HadVMSInterrupt;
+#endif /* VMS */
PUBLIC int local_dired ARGS1(
document *, doc)
{
char *line_url; /* will point to doc's address, which is a URL */
char *line = NULL; /* same as line_url, but HTUnEscaped, will be alloced */
char *cp, *tp, *bp;
- char tmpbuf[256];
- char buffer[512];
+ char *tmpbuf = NULL;
+ char *buffer = NULL;
line_url = doc->address;
CTRACE(tfp, "local_dired: called for <%s>.\n",
@@ -1437,16 +1458,15 @@ PUBLIC int local_dired ARGS1(
* Construct the appropriate system command taking care to
* escape all path references to avoid spoofing the shell.
*/
- *buffer = '\0';
if (!strncmp(line, "LYNXDIRED://DECOMPRESS", 22)) {
tp = quote_pathname(line + 22);
- sprintf(buffer,"%s %s", UNCOMPRESS_PATH, tp);
+ HTSprintf0(&buffer,"%s %s", UNCOMPRESS_PATH, tp);
FREE(tp);
#if defined(OK_UUDECODE) && !defined(ARCHIVE_ONLY)
} else if (!strncmp(line, "LYNXDIRED://UUDECODE", 20)) {
tp = quote_pathname(line + 20);
- sprintf(buffer,"%s %s", UUDECODE_PATH, tp);
+ HTSprintf0(&buffer,"%s %s", UUDECODE_PATH, tp);
HTAlert(gettext("Warning! UUDecoded file will exist in the directory you started Lynx."));
FREE(tp);
#endif /* OK_UUDECODE && !ARCHIVE_ONLY */
@@ -1458,8 +1478,8 @@ PUBLIC int local_dired ARGS1(
tp = quote_pathname(line+20);
*cp++ = '\0';
cp = quote_pathname(line + 20);
- sprintf(buffer, "%s -qdc %s | (cd %s; %s -xf -)",
- GZIP_PATH, tp, cp, TAR_PATH);
+ HTSprintf0(&buffer, "%s -qdc %s | (cd %s; %s -xf -)",
+ GZIP_PATH, tp, cp, TAR_PATH);
FREE(cp);
FREE(tp);
# endif /* OK_GZIP */
@@ -1468,8 +1488,8 @@ PUBLIC int local_dired ARGS1(
tp = quote_pathname(line + 19);
*cp++ = '\0';
cp = quote_pathname(line + 19);
- sprintf(buffer, "%s %s | (cd %s; %s -xf -)",
- ZCAT_PATH, tp, cp, TAR_PATH);
+ HTSprintf0(&buffer, "%s %s | (cd %s; %s -xf -)",
+ ZCAT_PATH, tp, cp, TAR_PATH);
FREE(cp);
FREE(tp);
@@ -1477,7 +1497,7 @@ PUBLIC int local_dired ARGS1(
tp = quote_pathname(line + 17);
*cp++ = '\0';
cp = quote_pathname(line + 17);
- sprintf(buffer, "cd %s; %s -xf %s", cp, TAR_PATH, tp);
+ HTSprintf0(&buffer, "cd %s; %s -xf %s", cp, TAR_PATH, tp);
FREE(cp);
FREE(tp);
# endif /* !ARCHIVE_ONLY */
@@ -1487,8 +1507,8 @@ PUBLIC int local_dired ARGS1(
*cp++ = '\0';
cp = quote_pathname(cp);
tp = quote_pathname(line + 18);
- sprintf(buffer, "(cd %s; %s -cf - %s) | %s -qc >%s/%s.tar.gz",
- tp, TAR_PATH, cp, GZIP_PATH, tp, cp);
+ HTSprintf0(&buffer, "(cd %s; %s -cf - %s) | %s -qc >%s/%s.tar.gz",
+ tp, TAR_PATH, cp, GZIP_PATH, tp, cp);
FREE(cp);
FREE(tp);
# endif /* OK_GZIP */
@@ -1497,8 +1517,8 @@ PUBLIC int local_dired ARGS1(
*cp++ = '\0';
cp = quote_pathname(cp);
tp = quote_pathname(line + 17);
- sprintf(buffer, "(cd %s; %s -cf - %s) | %s >%s/%s.tar.Z",
- tp, TAR_PATH, cp, COMPRESS_PATH, tp, cp);
+ HTSprintf0(&buffer, "(cd %s; %s -cf - %s) | %s >%s/%s.tar.Z",
+ tp, TAR_PATH, cp, COMPRESS_PATH, tp, cp);
FREE(cp);
FREE(tp);
@@ -1506,7 +1526,7 @@ PUBLIC int local_dired ARGS1(
*cp++ = '\0';
cp = quote_pathname(cp);
tp = quote_pathname(line + 15);
- sprintf(buffer, "(cd %s; %s -cf %s.tar %s)",
+ HTSprintf0(&buffer, "(cd %s; %s -cf %s.tar %s)",
tp, TAR_PATH, cp, cp);
FREE(cp);
FREE(tp);
@@ -1515,12 +1535,12 @@ PUBLIC int local_dired ARGS1(
#ifdef OK_GZIP
} else if (!strncmp(line, "LYNXDIRED://GZIP", 16)) {
tp = quote_pathname(line + 16);
- sprintf(buffer, "%s -q %s", GZIP_PATH, tp);
+ HTSprintf0(&buffer, "%s -q %s", GZIP_PATH, tp);
FREE(tp);
#ifndef ARCHIVE_ONLY
} else if (!strncmp(line, "LYNXDIRED://UNGZIP", 18)) {
tp = quote_pathname(line + 18);
- sprintf(buffer, "%s -d %s", GZIP_PATH, tp);
+ HTSprintf0(&buffer, "%s -d %s", GZIP_PATH, tp);
FREE(tp);
#endif /* !ARCHIVE_ONLY */
#endif /* OK_GZIP */
@@ -1531,7 +1551,7 @@ PUBLIC int local_dired ARGS1(
*cp++ = '\0';
bp = quote_pathname(cp);
cp = quote_pathname(line + 15);
- sprintf(buffer, "cd %s; %s -rq %s.zip %s", cp, ZIP_PATH, tp, bp);
+ HTSprintf0(&buffer, "cd %s; %s -rq %s.zip %s", cp, ZIP_PATH, tp, bp);
FREE(cp);
FREE(bp);
FREE(tp);
@@ -1540,7 +1560,7 @@ PUBLIC int local_dired ARGS1(
tp = quote_pathname(line + 17);
*cp = '\0';
cp = quote_pathname(line + 17);
- sprintf(buffer, "cd %s; %s -q %s", cp, UNZIP_PATH, tp);
+ HTSprintf0(&buffer, "cd %s; %s -q %s", cp, UNZIP_PATH, tp);
FREE(cp);
FREE(tp);
# endif /* !ARCHIVE_ONLY */
@@ -1548,23 +1568,22 @@ PUBLIC int local_dired ARGS1(
} else if (!strncmp(line, "LYNXDIRED://COMPRESS", 20)) {
tp = quote_pathname(line + 20);
- sprintf(buffer, "%s %s", COMPRESS_PATH, tp);
+ HTSprintf0(&buffer, "%s %s", COMPRESS_PATH, tp);
FREE(tp);
}
- if (strlen(buffer)) {
+ if (buffer != 0) {
if (strlen(buffer) < 60) {
- sprintf(tmpbuf, gettext("Executing %s "), buffer);
+ HTSprintf0(&tmpbuf, gettext("Executing %s "), buffer);
} else {
- sprintf(tmpbuf,
- gettext("Executing system command. This might take a while."));
+ HTSprintf0(&tmpbuf,
+ gettext("Executing system command. This might take a while."));
}
_statusline(tmpbuf);
stop_curses();
printf("%s\n", tmpbuf);
LYSystem(buffer);
#ifdef VMS
- extern BOOLEAN HadVMSInterrupt
HadVMSInterrupt = FALSE;
#endif /* VMS */
start_curses();
@@ -1572,6 +1591,8 @@ PUBLIC int local_dired ARGS1(
}
}
+ FREE(tmpbuf);
+ FREE(buffer);
FREE(line);
LYpop(doc);
return 0;
@@ -1777,7 +1798,7 @@ PUBLIC BOOLEAN local_install ARGS3(
char *, srcpath,
char **, newpath)
{
- char tmpbuf[512];
+ char *tmpbuf = NULL;
static char savepath[512]; /* This will be the link that
is to be installed. */
struct stat dir_info;
@@ -1819,7 +1840,7 @@ PUBLIC BOOLEAN local_install ARGS3(
src = n++;
args[n++] = destpath;
args[n] = (char *)0;
- sprintf(tmpbuf, "install %s", destpath);
+ HTSprintf(&tmpbuf, "install %s", destpath);
tag = tagged;
if (HTList_isEmpty(tagged)) {
@@ -1840,6 +1861,7 @@ PUBLIC BOOLEAN local_install ARGS3(
}
clear_tags();
}
+ FREE(tmpbuf);
HTInfoMsg(gettext("Installation complete"));
return count;
}
@@ -2030,7 +2052,7 @@ PRIVATE int LYExecv ARGS3(
return(0);
#else
int rc;
- char tmpbuf[512];
+ char *tmpbuf = 0;
pid_t pid;
#if HAVE_TYPE_UNIONWAIT
union wait wstatus;
@@ -2046,12 +2068,11 @@ PRIVATE int LYExecv ARGS3(
}
rc = 1; /* It will work */
- tmpbuf[0] = '\0'; /* empty buffer for alert messages */
stop_curses();
pid = fork(); /* fork and execute rm */
switch (pid) {
case -1:
- sprintf(tmpbuf, gettext("Unable to %s due to system error!"), msg);
+ HTSprintf(&tmpbuf, gettext("Unable to %s due to system error!"), msg);
rc = 0;
break; /* don't fall thru! - KW */
case 0: /* child */
@@ -2076,8 +2097,8 @@ PRIVATE int LYExecv ARGS3(
#endif /* !HAVE_WAITPID */
if (WEXITSTATUS(wstatus) != 0 ||
WTERMSIG(wstatus) > 0) { /* error return */
- sprintf(tmpbuf, gettext("Probable failure to %s due to system error!"),
- msg);
+ HTSprintf(&tmpbuf, gettext("Probable failure to %s due to system error!"),
+ msg);
rc = 0;
}
}
@@ -2090,8 +2111,9 @@ PRIVATE int LYExecv ARGS3(
sleep(AlertSecs);
}
start_curses();
- if (tmpbuf[0]) {
+ if (tmpbuf != 0) {
HTAlert(tmpbuf);
+ FREE(tmpbuf);
}
return(rc);
diff --git a/src/LYMail.c b/src/LYMail.c
index dd8a2141..73bf04bd 100644
--- a/src/LYMail.c
+++ b/src/LYMail.c
@@ -1420,7 +1420,7 @@ PUBLIC void reply_by_mail ARGS3(
*/
addstr(ENTER_SUBJECT_LINE);
addstr(CTRL_U_TO_ERASE);
- addstr(gettext("Subject: "));
+ addstr(SUBJECT_PROMPT);
/* Add the default subject. */
sprintf(user_input, "%.70s%.63s",
(subject[0] != '\0') ?
diff --git a/src/LYMain.c b/src/LYMain.c
index 7d8c8e75..12edc851 100644
--- a/src/LYMain.c
+++ b/src/LYMain.c
@@ -1294,7 +1294,7 @@ PUBLIC int main ARGS2(
* Set up default foreground and background colors.
*/
lynx_setup_colors();
-#endif /* USE_SLANG */
+#endif /* USE_COLOR_TABLE */
/*
* Set the compilation default signature file. - FM
diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c
index f9268079..9b601f3c 100644
--- a/src/LYMainLoop.c
+++ b/src/LYMainLoop.c
@@ -1058,6 +1058,8 @@ try_again:
start_curses();
clear();
refresh_screen = TRUE; /* to force a redraw */
+ if (HTMainText) /* to REALLY force it... - kw */
+ HText_setStale(HTMainText);
recent_sizechange = FALSE;
if (user_mode == NOVICE_MODE) {
display_lines = LYlines-4;
diff --git a/src/LYMap.c b/src/LYMap.c
index 68845bec..55b44121 100644
--- a/src/LYMap.c
+++ b/src/LYMap.c
@@ -193,7 +193,7 @@ PUBLIC BOOL LYAddImageMap ARGS3(
new = (old != NULL) ?
old : (LYImageMap *)calloc(1, sizeof(LYImageMap));
if (new == NULL) {
- perror(gettext("Out of memory in LYAddImageMap"));
+ outofmem(__FILE__, "LYAddImageMap");
return FALSE;
}
StrAllocCopy(new->address, address);
@@ -434,7 +434,7 @@ PRIVATE int LYLoadIMGmap ARGS4 (
if (anAnchor->post_data && !WWWDoc.safe &&
((underlying && underlying->document && !LYforce_no_cache) ||
HTConfirm(CONFIRM_POST_RESUBMISSION) != TRUE)) {
- HTAlert(gettext("Image map from POST response not available!"));
+ HTAlert(FAILED_MAP_POST_REQUEST);
return(HT_NOT_LOADED);
}
LYforce_no_cache = TRUE;
@@ -471,7 +471,7 @@ PRIVATE int LYLoadIMGmap ARGS4 (
if (anAnchor->post_data && !WWWDoc.safe &&
((underlying && underlying->document && !LYforce_no_cache) ||
HTConfirm(CONFIRM_POST_RESUBMISSION) != TRUE)) {
- HTAlert(gettext("Image map from POST response not available!"));
+ HTAlert(FAILED_MAP_POST_REQUEST);
return(HT_NOT_LOADED);
}
LYforce_no_cache = TRUE;
diff --git a/src/LYOptions.c b/src/LYOptions.c
index 073e38d6..848e4a25 100644
--- a/src/LYOptions.c
+++ b/src/LYOptions.c
@@ -2528,9 +2528,16 @@ redraw:
#endif /* USE_SLANG */
term_options = FALSE;
- c = LYgetch();
+ c = LYgetch_for(FOR_CHOICE);
if (term_options || c == 3 || c == 7) {
cmd = LYK_QUIT;
+#ifndef USE_SLANG
+ } else if (c == MOUSE_KEY) {
+ if ((cmd = fancy_mouse(form_window, i + 1 + window_offset, &cur_choice)) < 0)
+ goto redraw;
+ if (cmd == LYK_ACTIVATE)
+ break;
+#endif
} else {
cmd = keymap[c+1];
}
@@ -4154,7 +4161,7 @@ PUBLIC int gen_options ARGS1(
/*
* File Management Options
*/
- fprintf(fp0,"\n <em>%s</em>\n", gettext("File Management Options"));
+ fprintf(fp0,"\n <em>%s</em>\n", DIRED_MENU_TITLE);
/* FTP sort: SELECT */
PutLabel(fp0, gettext("FTP sort criteria"));
diff --git a/src/LYPrint.c b/src/LYPrint.c
index 1b0c7d4b..e7b3e27f 100644
--- a/src/LYPrint.c
+++ b/src/LYPrint.c
@@ -838,7 +838,7 @@ PUBLIC int printfile ARGS1(
sprintf(buffer, "%s -t \"%s\" -F %s", system_mail, user_response, tempfile);
LYCloseTempFP(outfile_fp); /* Close the tmpfile. */
stop_curses();
- printf("%s\n\n$ %s\n\n%s", gettext("Sending"), buffer, gettext("Please wait..."));
+ printf("%s\n\n$ %s\n\n%s", gettext("Sending"), buffer, PLEASE_WAIT);
LYSystem(buffer);
sleep(MessageSecs);
start_curses();
@@ -1320,8 +1320,10 @@ PUBLIC int print_options ARGS3(
if (no_print || no_disk_save || child_lynx || no_mail)
fprintf(fp0, " <em>%s</em>\n", gettext("Some print functions have been disabled!"));
- fprintf(fp0, "\n%s %s\n", gettext("options:"),
- (user_mode == NOVICE_MODE) ? gettext("Standard print") : gettext("Print"));
+ fprintf(fp0, "\n%s\n",
+ (user_mode == NOVICE_MODE)
+ ? gettext("Standard print options:")
+ : gettext("Print options:"));
if (child_lynx == FALSE && no_disk_save == FALSE && no_print == FALSE) {
fprintf(fp0,
diff --git a/src/LYStrings.c b/src/LYStrings.c
index 7505f20e..6f4ac249 100644
--- a/src/LYStrings.c
+++ b/src/LYStrings.c
@@ -1,6 +1,5 @@
#include <HTUtils.h>
#include <HTCJK.h>
-#include <LYCurses.h>
#include <LYUtils.h>
#include <LYStrings.h>
#include <LYGlobalDefs.h>
@@ -39,13 +38,123 @@ extern HTCJKlang HTCJK;
/* The number of the link selected w/ the mouse (-1 if none) */
static int mouse_link = -1;
+static int have_levent;
+
+#ifdef NCURSES_MOUSE_VERSION
+static MEVENT levent;
+#endif
+
+/* Return the value of mouse_link */
+PUBLIC int peek_mouse_levent NOARGS
+{
+#ifdef NCURSES_MOUSE_VERSION
+ if (have_levent) {
+ ungetmouse(&levent);
+ return 1;
+ }
+#endif
+ return 0;
+}
+
/* Return the value of mouse_link, erasing it */
PUBLIC int get_mouse_link NOARGS
{
- int t;
- t=mouse_link;
- mouse_link = -1;
- return t;
+ int t;
+ t = mouse_link;
+ mouse_link = -1;
+ if (t < 0)
+ t = -1; /* Backward compatibility. */
+ return t;
+}
+
+/* Return the value of mouse_link */
+PUBLIC int peek_mouse_link NOARGS
+{
+ return mouse_link;
+}
+
+PUBLIC int fancy_mouse ARGS3(
+ WINDOW *, win,
+ int, row,
+ int *, position)
+{
+ int cmd = LYK_DO_NOTHING;
+#ifdef NCURSES_MOUSE_VERSION
+#ifndef getbegx
+#define getbegx(win) ((win)->_begx)
+#endif
+#ifndef getbegy
+#define getbegy(win) ((win)->_begy)
+#endif
+ MEVENT event;
+
+ getmouse(&event);
+ if ((event.bstate & (BUTTON1_CLICKED
+ | BUTTON1_DOUBLE_CLICKED
+ | BUTTON1_TRIPLE_CLICKED))
+ && (event.x >= getbegx(win)
+ && (event.x < (getbegx(win) + getmaxx(win))))) {
+ int mypos = event.y - getbegy(win);
+ int delta = mypos - row;
+
+ if (mypos+1 == getmaxy(win)) {
+ /* At the decorative border: scroll forward */
+ if (event.bstate & BUTTON1_TRIPLE_CLICKED)
+ cmd = LYK_END;
+ else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
+ cmd = LYK_NEXT_PAGE;
+ else
+ cmd = LYK_NEXT_LINK;
+ } else if (mypos >= getmaxy(win)) {
+ if (event.bstate & (BUTTON1_DOUBLE_CLICKED
+ | BUTTON1_TRIPLE_CLICKED))
+ cmd = LYK_END;
+ else
+ cmd = LYK_NEXT_PAGE;
+ } else if (mypos == 0) {
+ /* At the decorative border: scroll back */
+ if (event.bstate & BUTTON1_TRIPLE_CLICKED)
+ cmd = LYK_HOME;
+ else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
+ cmd = LYK_PREV_PAGE;
+ else
+ cmd = LYK_PREV_LINK;
+ } else if (mypos < 0) {
+ if (event.bstate & (BUTTON1_DOUBLE_CLICKED
+ | BUTTON1_TRIPLE_CLICKED))
+ cmd = LYK_HOME;
+ else
+ cmd = LYK_PREV_PAGE;
+#ifdef KNOW_HOW_TO_TOGGLE
+ } else if (event.bstate & (BUTTON_CTRL)) {
+ cur_selection += delta;
+ cmd = LYX_TOGGLE;
+#endif
+ } else if (event.bstate & (BUTTON_ALT | BUTTON_SHIFT | BUTTON_CTRL)) {
+ /* Probably some unrelated activity, such as selecting some text.
+ * Select, but do nothing else.
+ */
+ *position += delta;
+ cmd = -1;
+ } else {
+ /* No scrolling or overflow checks necessary. */
+ *position += delta;
+#if 0
+ /* Immediate action looks reasonable since we have no help
+ * available for individual options. Moreover, one can position
+ * active element with shift-click-1. (;-)
+ */
+ if (!(event.bstate & (BUTTON1_DOUBLE_CLICKED
+ | BUTTON1_TRIPLE_CLICKED)))
+ goto redraw;
+#endif
+ cmd = LYK_ACTIVATE;
+ }
+ } else if (event.bstate & (BUTTON3_CLICKED | BUTTON3_DOUBLE_CLICKED | BUTTON3_TRIPLE_CLICKED)) {
+ cmd = LYK_QUIT;
+ }
+#endif
+ return cmd;
}
/* Given X and Y coordinates of a mouse event, set mouse_link to the
@@ -55,7 +164,7 @@ PUBLIC int get_mouse_link NOARGS
** link.
**/
-PRIVATE int set_clicked_link ARGS2(int,x,int,y)
+PRIVATE int set_clicked_link ARGS3(int,x,int,y,int,code)
{
int left = 6;
int right = LYcols-6;
@@ -64,21 +173,44 @@ PRIVATE int set_clicked_link ARGS2(int,x,int,y)
int c = -1;
if (y == (LYlines-1)) {
+ mouse_link = -2;
if (x < left) c = LTARROW;
else if (x > right) c = '\b';
else c = PGDOWN;
} else if (y == 0) {
+ mouse_link = -2;
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++) {
+ int len, lx = links[i].lx, is_text = 0;
+
+ if (links[i].type == WWW_FORM_LINK_TYPE
+ /* XXXX What else? */
+ && (links[i].form->type == F_TEXTAREA_TYPE
+ || links[i].form->type == F_TEXT_TYPE))
+ is_text = 1;
+
+ if (is_text)
+ len = links[i].form->size;
+ else
+ len = strlen(links[i].hightext );
+
/* 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;
+ links[i].ly == y && (x - lx) < len && (x >= lx)) {
+ int cury, curx;
+
+ if (code != FOR_INPUT
+ /* Do not pick up the current input field */
+ || !(LYGetYX(cury,curx),
+ (cury == y && (curx >= lx) && ((curx - lx) <= len)))) {
+ if (is_text)
+ have_levent = 1;
+ mouse_link = i;
+ }
break;
}
/* Check the second line */
@@ -324,7 +456,7 @@ PRIVATE int sl_read_mouse_event NOARGS
if (-1 != sl_parse_mouse_event (&mouse_x, &mouse_y, &button))
{
if (button == 0) /* left */
- return set_clicked_link (mouse_x, mouse_y);
+ return set_clicked_link (mouse_x, mouse_y, FOR_PANEL);
if (button == 2) /* right */
{
@@ -809,6 +941,12 @@ PUBLIC int LYgetch NOARGS
return keysym;
}
+PUBLIC int LYgetch_for ARGS1(
+ int, code)
+{
+ return LYgetch();
+}
+
#else /* !USE_KEYMAPS */
/*
@@ -818,8 +956,16 @@ PUBLIC int LYgetch NOARGS
PUBLIC int LYgetch NOARGS
{
+ return LYgetch_for(FOR_PANEL);
+}
+
+PUBLIC int LYgetch_for ARGS1(
+ int, code)
+{
int a, b, c, d = -1;
+ have_levent = 0;
+
#if defined(IGNORE_CTRL_C) || defined(USE_GETCHAR) || !defined(NCURSES)
re_read:
#endif /* IGNORE_CTRL_C || USE_GETCHAR */
@@ -1105,7 +1251,9 @@ re_read:
#endif /* KEY_DC */
#ifdef NCURSES_MOUSE_VERSION
case KEY_MOUSE:
- {
+ if (code == FOR_CHOICE) {
+ c = MOUSE_KEY; /* Will be processed by the caller */
+ } else {
#ifndef DOSPATH
MEVENT event;
int err;
@@ -1113,17 +1261,31 @@ re_read:
c = -1;
mouse_link = -1;
err = getmouse(&event);
+ levent = event; /* Allow setting pos in entry fields */
if (event.bstate & BUTTON1_CLICKED) {
- c = set_clicked_link(event.x, event.y);
+ c = set_clicked_link(event.x, event.y, code);
+ } else if (event.bstate & BUTTON1_DOUBLE_CLICKED) {
+ c = set_clicked_link(event.x, event.y, code);
+ if (c == PGDOWN)
+ c = END_KEY;
+ else if (c == PGUP)
+ c = HOME;
+ else if (c == LTARROW)
+ c = LYReverseKeymap(LYK_MAIN_MENU);
} else if (event.bstate & BUTTON3_CLICKED) {
c = LYReverseKeymap (LYK_PREV_DOC);
}
+ if (code == FOR_INPUT && mouse_link == -1) {
+ ungetmouse(&event); /* Caller will process this. */
+ getch(); /* ungetmouse puts KEY_MOUSE back */
+ c = MOUSE_KEY;
+ }
#else /* pdcurses version */
c = -1;
mouse_link = -1;
request_mouse_pos();
if (BUTTON_STATUS(1) & BUTTON_CLICKED) {
- c = set_clicked_link(MOUSE_X_POS, MOUSE_Y_POS);
+ c = set_clicked_link(MOUSE_X_POS, MOUSE_Y_POS, FOR_PANEL);
} else if (BUTTON_STATUS(3) & BUTTON_CLICKED) {
c = LYReverseKeymap (LYK_PREV_DOC);
}
diff --git a/src/LYStrings.h b/src/LYStrings.h
index 8f53178c..7bb6f95b 100644
--- a/src/LYStrings.h
+++ b/src/LYStrings.h
@@ -1,7 +1,7 @@
#ifndef LYSTRINGS_H
#define LYSTRINGS_H
-#include <HTUtils.h>
+#include <LYCurses.h>
/* UPPER8(ch1,ch2) is an extension of (TOUPPER(ch1) - TOUPPER(ch2)) */
extern int UPPER8 PARAMS((
@@ -9,12 +9,18 @@ extern int UPPER8 PARAMS((
int ch2));
extern int get_mouse_link NOPARAMS;
+extern int peek_mouse_link NOPARAMS;
+extern int peek_mouse_levent NOPARAMS;
+extern int fancy_mouse PARAMS((WINDOW *win, int row, int *position));
+
extern char * LYstrncpy PARAMS((
char * dst,
CONST char * src,
int n));
extern void ena_csi PARAMS((BOOLEAN flag));
extern int LYgetch NOPARAMS;
+extern int LYgetch_for PARAMS((
+ int code));
extern int LYgetstr PARAMS((
char * inputline,
int hidden,
@@ -84,7 +90,12 @@ extern char * SNACat PARAMS((
#define SELECT_KEY 267 /* 0x10B */
#define INSERT_KEY 268 /* 0x10C */
#define REMOVE_KEY 269 /* 0x10D */
-#define DO_NOTHING 270 /* 0x10E */
+#define MOUSE_KEY 270 /* 0x10E */
+#define DO_NOTHING 271 /* 0x10F */
+
+# define FOR_PANEL 0
+# define FOR_CHOICE 1
+# define FOR_INPUT 2
#define VISIBLE 0
#define HIDDEN 1
diff --git a/src/LYStructs.h b/src/LYStructs.h
index ff58cd87..78075f48 100644
--- a/src/LYStructs.h
+++ b/src/LYStructs.h
@@ -1,10 +1,6 @@
#ifndef LYSTRUCTS_H
#define LYSTRUCTS_H
-#ifndef USERDEFS_H
-#include <userdefs.h>
-#endif /* USERDEFS_H */
-
#ifndef HTANCHOR_H
#include <HTAnchor.h>
#endif /* HTANCHOR_H */
diff --git a/src/LYUtils.c b/src/LYUtils.c
index eb9ed2c5..554914b4 100644
--- a/src/LYUtils.c
+++ b/src/LYUtils.c
@@ -2837,7 +2837,7 @@ PUBLIC BOOLEAN inlocaldomain NOARGS
#endif /* LINUX */
} else {
- CTRACE(tfp,"Could not get ttyname or open UTMP file");
+ CTRACE(tfp,"Could not get ttyname or open UTMP file %s\n", UTMP_FILE);
}
return(FALSE);
@@ -5511,6 +5511,7 @@ PRIVATE BOOL IsOurFile ARGS1(char *, name)
PRIVATE FILE *OpenHiddenFile ARGS2(char *, name, char *, mode)
{
FILE *fp = 0;
+ struct stat data;
#if defined(O_CREAT) && defined(O_EXCL) /* we have fcntl.h or kindred? */
/*
@@ -5532,10 +5533,12 @@ PRIVATE FILE *OpenHiddenFile ARGS2(char *, name, char *, mode)
}
else
#endif
- if (*mode == 'a'
- && IsOurFile(name)
- && chmod(name, HIDE_CHMOD) == 0)
- fp = fopen(name, mode);
+ if (*mode == 'a') {
+ if (IsOurFile(name)
+ && chmod(name, HIDE_CHMOD) == 0)
+ fp = fopen(name, mode);
+ else if (lstat(name, &data) != 0)
+ fp = OpenHiddenFile(name, "w");
/*
* This is less stringent, but reasonably portable. For new files, the
* umask will suffice; however if the file already exists we'll change
@@ -5545,7 +5548,7 @@ PRIVATE FILE *OpenHiddenFile ARGS2(char *, name, char *, mode)
*
* This won't work properly if the user is root, since the chmod succeeds.
*/
- else if (*mode != 'a') {
+ } else if (*mode != 'a') {
int save = umask(HIDE_UMASK);
if (chmod(name, HIDE_CHMOD) == 0 || errno == ENOENT)
fp = fopen(name, mode);
diff --git a/src/UCdomap.c b/src/UCdomap.c
index 2ce2ac2c..2d49dc26 100644
--- a/src/UCdomap.c
+++ b/src/UCdomap.c
@@ -471,7 +471,7 @@ PRIVATE void UC_con_set_trans ARGS3(
int, update_flag)
{
int i, j;
- u16 *p;
+ CONST u16 *p;
u16 *ptrans;
if (!UC_valid_UC_charset(UC_charset_in_hndl)) {
@@ -533,7 +533,7 @@ PRIVATE char* **uni_pagedir_str[32] =
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
};
-PRIVATE u16 * UC_current_unitable = NULL;
+PRIVATE CONST u16 * UC_current_unitable = NULL;
PRIVATE struct unimapdesc_str *UC_current_unitable_str = NULL;
/*
@@ -558,8 +558,8 @@ static char* **unidefault_pagedir_str[32] =
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
};
-PRIVATE u16 * UC_default_unitable = NULL;
-PRIVATE struct unimapdesc_str *UC_default_unitable_str = NULL;
+PRIVATE CONST u16 * UC_default_unitable = 0;
+PRIVATE CONST struct unimapdesc_str *UC_default_unitable_str = 0;
PRIVATE int con_insert_unipair ARGS3(
u16, unicode,
@@ -745,7 +745,7 @@ PRIVATE int con_set_unimap ARGS2(
PRIVATE void con_set_default_unimap NOARGS
{
int i, j;
- u16 *p;
+ CONST u16 *p;
/*
* The default font is always 256 characters.
@@ -784,7 +784,7 @@ PRIVATE int UC_con_set_unimap ARGS2(
int, update_flag)
{
int i, j;
- u16 *p;
+ CONST u16 *p;
if (!UC_valid_UC_charset(UC_charset_out_hndl)) {
CTRACE(tfp, "UC_con_set_unimap: Invalid charset handle %d.\n",
@@ -1028,7 +1028,7 @@ PUBLIC int UCTransUniChar ARGS2(
int rc = 0;
int UChndl_out;
int isdefault, trydefault = 0;
- u16 * ut;
+ CONST u16 * ut;
if ((UChndl_out = LYCharSet_UC[charset_out].UChndl) < 0) {
if ((UChndl_out = default_UChndl) < 0)
@@ -1079,7 +1079,7 @@ PUBLIC int UCTransUniCharStr ARGS5(
int UChndl_out;
int isdefault, trydefault = 0;
struct unimapdesc_str * repl;
- u16 * ut;
+ CONST u16 * ut;
if (buflen < 2)
return -13;
@@ -1204,7 +1204,7 @@ PUBLIC int UCTransChar ARGS3(
int rc = -4;
int UChndl_in, UChndl_out;
int isdefault, trydefault = 0;
- u16 * ut;
+ CONST u16 * ut;
int upd = 0;
#ifndef UC_NO_SHORTCUTS
@@ -1311,7 +1311,7 @@ PUBLIC int UCReverseTransChar ARGS3(
int UChndl_in, UChndl_out;
int isdefault;
int i_ch = (unsigned char)ch_out;
- u16 * ut;
+ CONST u16 * ut;
#ifndef UC_NO_SHORTCUTS
if (charset_in == charset_out)
@@ -1377,7 +1377,7 @@ PUBLIC int UCTransCharStr ARGS6(
int UChndl_in, UChndl_out;
int isdefault, trydefault = 0;
struct unimapdesc_str * repl;
- u16 * ut;
+ CONST u16 * ut;
int upd = 0;
if (buflen < 2)
@@ -1690,7 +1690,7 @@ PRIVATE CONST char ** UC_setup_LYCharSets_repl ARGS2(
CONST char **ISO_Latin1 = LYCharSets[0];
CONST char **p;
char **prepl;
- u16 *pp;
+ CONST u16 *pp;
CONST char **tp;
CONST char *s7;
CONST char *s8;
@@ -1934,8 +1934,8 @@ PRIVATE int UC_Register_with_LYCharSets ARGS4(
PUBLIC void UC_Charset_Setup ARGS9(
CONST char *, UC_MIMEcharset,
CONST char *, UC_LYNXcharset,
- u8 *, unicount,
- u16 *, unitable,
+ CONST u8 *, unicount,
+ CONST u16 *, unitable,
int, nnuni,
struct unimapdesc_str, replacedesc,
int, lowest_eight,
diff --git a/src/UCdomap.h b/src/UCdomap.h
index 6805b712..16541353 100644
--- a/src/UCdomap.h
+++ b/src/UCdomap.h
@@ -24,8 +24,8 @@
extern void UC_Charset_Setup PARAMS((
CONST char * UC_MIMEcharset,
CONST char * UC_LYNXcharset,
- u8 * unicount,
- u16 * unitable,
+ CONST u8 * unicount,
+ CONST u16 * unitable,
int nnuni,
struct unimapdesc_str replacedesc,
int lowest_eight,
@@ -40,8 +40,8 @@ int UC_GNhandles[4] = {-1, -1, -1, -1};
struct UC_charset {
CONST char *MIMEname;
CONST char *LYNXname;
- u8* unicount;
- u16* unitable;
+ CONST u8* unicount;
+ CONST u16* unitable;
int num_uni;
struct unimapdesc_str replacedesc;
int uc_status;
diff --git a/src/chrtrans/makeuctb.c b/src/chrtrans/makeuctb.c
index b9d2c520..1207d3d1 100644
--- a/src/chrtrans/makeuctb.c
+++ b/src/chrtrans/makeuctb.c
@@ -694,7 +694,7 @@ PUBLIC int main ARGS2(
*\n\
*/\n\
\n\
-static u8 dfont_unicount%s[%d] = \n\
+static CONST u8 dfont_unicount%s[%d] = \n\
{\n\t", argv[0], argv[1], id_append, fontlen);
for (i = 0; i < fontlen; i++) {
@@ -720,10 +720,10 @@ static u8 dfont_unicount%s[%d] = \n\
}
if (nuni) {
- printf("\nstatic u16 dfont_unitable%s[%d] = \n{\n\t",
+ printf("\nstatic CONST u16 dfont_unitable%s[%d] = \n{\n\t",
id_append, nuni);
} else {
- printf("\nstatic u16 dfont_unitable%s[1]; /* dummy */\n", id_append);
+ printf("\nstatic CONST u16 dfont_unitable%s[1]; /* dummy */\n", id_append);
}
fp0 = 0;
@@ -766,11 +766,11 @@ static struct unipair_str repl_map%s[%d] = \n\
}
if (themap_str.entry_ct) {
printf("\n\
-static struct unimapdesc_str dfont_replacedesc%s = {%d,repl_map%s,",
+static CONST struct unimapdesc_str dfont_replacedesc%s = {%d,repl_map%s,",
id_append, themap_str.entry_ct, id_append);
} else {
printf("\n\
-static struct unimapdesc_str dfont_replacedesc%s = {0,NULL,",id_append);
+static CONST struct unimapdesc_str dfont_replacedesc%s = {0,NULL,",id_append);
}
printf("%d,%d};\n",
this_isDefaultMap ? 1 : 0,