From f7c3c4ca429260c4d056b1e032e05162e25554ca Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Thu, 4 Mar 1999 10:56:18 -0500 Subject: snapshot of project "lynx", label v2-8-2dev_18 --- src/GridText.c | 1173 ++++++++++++++++++++++++++++----------- src/GridText.h | 6 + src/HTFWriter.c | 1 - src/HTML.c | 56 +- src/LYBookmark.c | 8 +- src/LYCharSets.c | 86 +-- src/LYCookie.c | 11 +- src/LYEdit.c | 16 +- src/LYForms.c | 55 +- src/LYGetFile.c | 39 +- src/LYGlobalDefs.h | 1 - src/LYHistory.c | 3 + src/LYKeymap.c | 22 +- src/LYKeymap.h | 211 +++---- src/LYList.c | 5 + src/LYMain.c | 32 +- src/LYMainLoop.c | 188 ++++++- src/LYMainLoop.h | 4 + src/LYPrint.c | 145 ++++- src/LYPrint.h | 1 + src/LYReadCFG.c | 2 +- src/LYStrings.c | 2 +- src/LYUtils.c | 19 +- src/LYUtils.h | 9 + src/LYrcFile.c | 18 +- src/UCAuto.c | 1 - src/UCAux.c | 18 +- src/UCdomap.c | 43 +- src/UCdomap.h | 48 ++ src/chrtrans/MAKEW32.BAT | 2 +- src/chrtrans/build-chrtrans.com | 4 +- src/chrtrans/def7_uni.tbl | 5 +- src/chrtrans/makefile.dos | 4 +- src/chrtrans/makefile.in | 4 +- src/structdump.h | 20 + 35 files changed, 1643 insertions(+), 619 deletions(-) (limited to 'src') diff --git a/src/GridText.c b/src/GridText.c index 8ddc702e..9db4602c 100644 --- a/src/GridText.c +++ b/src/GridText.c @@ -36,6 +36,7 @@ #include /* LYUCTranslateBack... */ #include #include +#include #ifdef EXP_CHARTRANS_AUTOSWITCH #include #endif /* EXP_CHARTRANS_AUTOSWITCH */ @@ -3101,7 +3102,7 @@ PUBLIC void HText_endAnchor ARGS2( */ a->extent += (text->chars + last->size) - a->start - (text->Lines - a->line_num); - if (a->extent > last->size) { + if ((unsigned) a->extent > last->size) { /* * The anchor extends over more than one line, * so set up to check the entire last line. - FM @@ -3115,7 +3116,7 @@ PUBLIC void HText_endAnchor ARGS2( i = a->extent; } k = j = (last->size - i); - while (j < last->size) { + while ((unsigned) j < last->size) { if (!IsSpecialAttrChar(last->data[j]) && !isspace((unsigned char)last->data[j]) && last->data[j] != HT_NON_BREAK_SPACE && @@ -3125,7 +3126,7 @@ PUBLIC void HText_endAnchor ARGS2( j++; } if (i == 0) { - if (a->extent > last->size) { + if ((unsigned) a->extent > last->size) { /* * The anchor starts on a preceding line, and * the last line has only white and special @@ -3172,7 +3173,7 @@ PUBLIC void HText_endAnchor ARGS2( */ i = a->extent - CurBlankExtent; } - while (j < prev->size) { + while ((unsigned) j < prev->size) { if (!IsSpecialAttrChar(prev->data[j]) && !isspace((unsigned char)prev->data[j]) && prev->data[j] != HT_NON_BREAK_SPACE && @@ -3182,7 +3183,7 @@ PUBLIC void HText_endAnchor ARGS2( j++; } if (i == 0) { - if (a->extent > (CurBlankExtent + prev->size) || + if ((unsigned) a->extent > (CurBlankExtent + prev->size) || (a->extent == CurBlankExtent + (int)prev->size && k == 0 && prev->prev != text->last_line && @@ -3291,7 +3292,7 @@ PUBLIC void HText_endAnchor ARGS2( text->permissible_split -= NumSize; } k = j + NumSize; - while (k < start->size) + while ((unsigned) k < start->size) start->data[j++] = start->data[k++]; if (start != last) text->chars -= NumSize; @@ -3329,7 +3330,7 @@ PUBLIC void HText_endAnchor ARGS2( */ NumSize++; l = (i - j); - while (i < prev->size) + while ((unsigned) i < prev->size) prev->data[j++] = prev->data[i++]; text->chars -= l; for (anc = a; anc; anc = anc->next) { @@ -3347,7 +3348,7 @@ PUBLIC void HText_endAnchor ARGS2( } j = 0; i = k; - while (k < start->size) + while ((unsigned) k < start->size) start->data[j++] = start->data[k++]; if (start != last) text->chars -= i; @@ -3406,7 +3407,7 @@ PUBLIC void HText_endAnchor ARGS2( */ NumSize++; k = j + NumSize; - while (k < prev->size) + while ((unsigned) k < prev->size) prev->data[j++] = prev->data[k++]; text->chars -= NumSize; for (anc = a; anc; anc = anc->next) { @@ -3654,7 +3655,7 @@ 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++) { @@ -3947,6 +3948,73 @@ PUBLIC void HText_FormDescNumber ARGS2( } } +/* HTGetRelLinkNum returns the anchor number to which follow_link_number() + * is to jump (input was 123+ or 123- or 123+g or 123-g or 123 or 123g) + * num is the number specified + * rel is 0 or '+' or '-' + * cur is the current link + */ +PUBLIC int HTGetRelLinkNum ARGS3( + int, num, + int, rel, + int, cur) +{ + TextAnchor *a, *l = 0; + int scrtop = HText_getTopOfScreen()+1; + int curline = links[cur].anchor_line_num; + int curpos = links[cur].lx; + int on_screen = ( curline >= scrtop && curline < (scrtop + display_lines) ); + /* curanchor may or may not be the "current link", depending whether it's + * on the current screen + */ + int curanchor = links[cur].anchor_number; + + CTRACE(tfp, "HTGetRelLinkNum(%d,%d,%d) -- HTMainText=%p\n", + num, rel, cur, HTMainText); + CTRACE(tfp," scrtop=%d, curline=%d, curanchor=%d, display_lines=%d, %s\n", + scrtop, curline, curanchor, display_lines, + on_screen ? "on_screen" : "0"); + if (!HTMainText) return 0; + if ( rel==0 ) return num; + + /* if cur numbered link is on current page, use it */ + if ( on_screen && curanchor ) { + CTRACE(tfp,"curanchor=%d at line %d on screen\n",curanchor,curline); + if ( rel == '+' ) return curanchor + num; + else if ( rel == '-' ) return curanchor - num; + else return num; /* shouldn't happen */ + } + + /* no current link on screen, or current link is not numbered + * -- find previous closest numbered link + */ + for (a = HTMainText->first_anchor; a; a = a->next) { + CTRACE(tfp," a->line_num=%d, a->number=%d\n",a->line_num,a->number); + if ( a->line_num >= scrtop ) break; + if ( a->number == 0 ) continue; + l = a; + curanchor = l->number; + } + CTRACE(tfp," a=%p, l=%p, curanchor=%d\n",a,l,curanchor); + if ( on_screen ) { /* on screen but not a numbered link */ + for ( ; a; a = a->next ) { + if ( a->number ) { l = a; curanchor = l->number; } + if ( curline == a->line_num && curpos == a->line_pos ) break; + } + } + if ( rel == '+' ) { + return curanchor + num; + } else if ( rel == '-' ) { + if ( l ) + return curanchor + 1 - num; + else { + for ( ; a && a->number==0; a = a->next ) ; + return a ? a->number - num : 0; + } + } + else return num; /* shouldn't happen */ +} + /* * HTGetLinkInfo returns some link info based on the number. * @@ -4152,7 +4220,7 @@ PRIVATE BOOLEAN same_anchor_or_field ARGS5( #define same_anchor_as_link(i,a) (i >= 0 && a &&\ same_anchor_or_field(links[i].anchor_number,\ - (links[i].type == WWW_FORM_LINK_TYPE) ? links[i].form : NULL,\ + (links[i].type == WWW_FORM_LINK_TYPE) ? links[i].form : NULL,\ a->number,\ (a->link_type == INPUT_ANCHOR) ? a->input_field : NULL,\ ta_skip)) @@ -8959,6 +9027,104 @@ PUBLIC BOOL HText_AreDifferent ARGS2( } +/* + * Cleanup new lines coming into a TEXTAREA from an external editor, or a + * file, such that they are in a suitable format for TEXTAREA rendering, + * display, and manipulation. That means trimming off trailing whitespace + * from the line, expanding TABS into SPACES, and substituting a printable + * character for control chars, and the like. + * + * --KED 02/24/99 + */ +PRIVATE void cleanup_line_for_textarea ARGS2( + char *, line, + int, len) +{ + char tbuf[MAX_LINE]; + + char *cp; + char *p; + char *s; + int i; + int n; + + + /* + * Whack off trailing whitespace from the line. + */ + for (i = len, p = line + (len - 1); i != 0; p--, i--) { + if (isspace (*p)) + *p = '\0'; + else + break; + } + + if (strlen (line) != 0) { + /* + * Expand any tab's, since they won't render properly in a TEXTAREA. + * + * [Is that "by spec", or just a "lynxism"? As may be, it seems that + * such chars may cause other problems, too ... with cursor movement, + * submit'ing, etc. Probably needs looking into more deeply.] + */ + p = line; + s = tbuf; + + while (*p) { + if ((cp = strchr (p, '\t')) != 0) { + i = cp - p; + s = (strncpy (s, p, i)) + i; + n = TABSTOP - (i % TABSTOP); + s = (strncpy (s, SPACES, n)) + n; + p += (i + 1); + + } else { + + strcpy (s, p); + break; + } + } + + /* + * Replace control chars with something printable. Note that char + * substitution above 0x7f is dependent on the charset being used, + * and then only applies to the contiguous run of char values that + * are between 0x80, and the 1st real high-order-bit-set character, + * as specified by the charset. In general (ie, for many character + * sets), that usually means the so-called "C1 control chars" that + * range from 0x80 thru 0x9f. For EBCDIC machines, we only trim the + * (control) chars below a space (x'40'). + * + * The assumption in all this is that the charset used in the editor, + * is compatible with the charset specified in lynx. + * + * [At some point in time, when/if lynx ever supports multibyte chars + * internally (eg, UCS-2, UCS-4, UTF-16, etc), this kind of thing may + * well cause problems. But then, supporting such char sets will + * require massive changes in (most) all parts of the lynx code, so + * until then, we do the rational thing with char values that would + * otherwise foul the display, if left alone. If you're implementing + * multibyte character set support, consider yourself to have been + * warned.] + */ + for (p = line, s = tbuf; *s != '\0'; p++, s++) +#ifndef EBCDIC + *p = (((unsigned char)*s < (unsigned char)' ') || + ((unsigned char)*s == (unsigned char)'\177') || + (((unsigned char)*s > (unsigned char)'\177') && + ((unsigned char)*s < + (unsigned char)LYlowest_eightbit[current_char_set]))) + ? SPLAT : *s; +#else + *p = ((unsigned char)*s < (unsigned char)' ') ? SPLAT : *s; +#endif + *p = '\0'; + } + + return; +} + + /* * Re-render the text of a tagged ("[123]") HTLine (arg1), with the tag * number incremented by some value (arg5). The re-rendered string may @@ -8967,7 +9133,7 @@ PUBLIC BOOL HText_AreDifferent ARGS2( * of) a value which must match, in order for the tag to be incremented, * or (the address of) a 0-value, which will match any value, and cause * any valid tag to be incremented. Arg2 is a pointer to the first/only - * Anchor that exists on the line; we may need to adjust their position(s) + * anchor that exists on the line; we may need to adjust their position(s) * on the line. Arg3 when non-0 indicates the number of new digits that * were added to the 2nd line in a line crossing pair. * @@ -8977,7 +9143,9 @@ PUBLIC BOOL HText_AreDifferent ARGS2( * Untagged or improperly tagged lines are not altered. * * Returns the number of chars added to the original string's length, if - * any. KED 02/03/99 + * any. + * + * --KED 02/03/99 */ PRIVATE int increment_tagged_htline ARGS6( HTLine *, ht, @@ -9031,26 +9199,25 @@ PRIVATE int increment_tagged_htline ARGS6( if (st_anchor) st_anchor = st_anchor->next; } - /* * Walk thru the line looking for tags (ie, "[nnn]" strings). */ while (*p != '\0') { if (*p != '[') { - *s++ = *p++; - continue; + *s++ = *p++; + continue; } else { - *s++ = *p++; - t = p; - n = 0; + *s++ = *p++; + t = p; + n = 0; valid = TRUE; /* p = t = byte after '[' */ /* * Make sure there are only digits between "[" and "]". */ while (*t != ']') { - if (*t == '\0') { /* uhoh - we have a potential line crosser */ + if (*t == '\0') { /* uhoh - we have a potential line crosser */ valid = FALSE; plx = TRUE; break; @@ -9061,7 +9228,7 @@ PRIVATE int increment_tagged_htline ARGS6( } else { valid = FALSE; break; - } + } } /* @@ -9084,9 +9251,9 @@ PRIVATE int increment_tagged_htline ARGS6( */ if ((valid) && (n > 0)) { val = atoi (p); - if ((val == *old_val) || (*old_val == 0)) { /* 0 matches all */ + if ((val == *old_val) || (*old_val == 0)) { /* 0 matches all */ if (*old_val != 0) - (*old_val)++; + (*old_val)++; val += incr; sprintf (s, "%d", val); new_n = strlen (s); @@ -9116,15 +9283,15 @@ PRIVATE int increment_tagged_htline ARGS6( */ if (new_n -= n) { nxt_anchor = st_anchor; - while ((nxt_anchor) && - (nxt_anchor->line_num == a->line_num)) { + while ((nxt_anchor) && + (nxt_anchor->line_num == a->line_num)) { nxt_anchor->line_pos += new_n; nxt_anchor = nxt_anchor->next; } if (st_anchor) st_anchor = st_anchor->next; } } - } + } /* * Unfortunately, valid [tag] strings *can* be split across two @@ -9140,10 +9307,10 @@ PRIVATE int increment_tagged_htline ARGS6( if (plx) { strcpy (lx, p); /* <- 1st part of a possible lx'ing tag */ pre_n = strlen (p); /* count of 1st part chars in this line */ - strcat (lx, ht->next->data); /* tack on NEXT line */ + strcat (lx, ht->next->data); /* tack on NEXT line */ - t = lx; - n = 0; + t = lx; + n = 0; valid = TRUE; /* @@ -9191,8 +9358,8 @@ PRIVATE int increment_tagged_htline ARGS6( *lx_val = new_n - n; } } - break; /* had an lx'er, so we're done with this line */ - } + break; /* had an lx'er, so we're done with this line */ + } } } @@ -9207,6 +9374,283 @@ PRIVATE int increment_tagged_htline ARGS6( } +/* + * Creates a new anchor and associated struct's appropriate for a form + * TEXTAREA, and links them into the lists following the current anchor + * position (as specified by arg1). + * + * Exits with arg1 now pointing at the new TextAnchor, and arg2 pointing + * at the new, associated HTLine. + * + * --KED 02/13/99 + */ +PRIVATE void insert_new_textarea_anchor ARGS2( + TextAnchor **, curr_anchor, + HTLine **, exit_htline) +{ + TextAnchor *anchor = *curr_anchor; + HTLine *htline; + + TextAnchor *a = 0; + FormInfo *f = 0; + HTLine *l = 0; + + int curr_tag = 0; /* 0 ==> match any [tag] number */ + int lx = 0; /* 0 ==> no line crossing [tag]; it's a new line */ + int i; + + + /* + * Find line in the text that matches ending anchorline of + * the TEXTAREA. + * + * [Yes, Virginia ... we *do* have to go thru this for each + * anchor being added, since there is NOT a 1-to-1 mapping + * between anchors and htlines. I suppose we could create + * YAS (Yet Another Struct), but there are too many structs{} + * floating around in here, as it is. IMNSHO.] + */ + for (htline = HTMainText->last_line->next, i = 0; + anchor->line_num != i; i++) { + htline = htline->next; + if (htline == HTMainText->last_line) + break; + } + + /* + * Clone and initialize the struct's needed to add a new TEXTAREA + * anchor. + */ + if (((a = (TextAnchor *) calloc (1, sizeof(*a))) == 0) || + ((f = (FormInfo *) calloc (1, sizeof(*f))) == 0) || + ((l = (HTLine *) calloc (1, LINE_SIZE(MAX_LINE))) == 0)) + outofmem(__FILE__, "insert_new_textarea_anchor"); + + /* Init all the fields in the new TextAnchor. */ + /* [anything "special" needed based on ->show_anchor value ?] */ + a->next = anchor->next; + a->number = anchor->number; + a->start = anchor->start + anchor->input_field->size + 1; + a->line_pos = anchor->line_pos; + a->extent = anchor->extent; + a->line_num = anchor->line_num + 1; + StrAllocCopy (a->hightext, anchor->hightext); + StrAllocCopy (a->hightext2, anchor->hightext2); + a->hightext2offset = anchor->hightext2offset; + a->link_type = anchor->link_type; + a->input_field = f; + a->show_anchor = anchor->show_anchor; + a->inUnderline = anchor->inUnderline; + a->expansion_anch = TRUE; + a->anchor = NULL; + + /* Just the (seemingly) relevant fields in the new FormInfo. */ + /* [do we need to do anything "special" based on ->disabled] */ + StrAllocCopy (f->name, anchor->input_field->name); + f->number = anchor->input_field->number; + f->type = anchor->input_field->type; + StrAllocCopy (f->orig_value, ""); + f->size = anchor->input_field->size; + f->maxlength = anchor->input_field->maxlength; + f->no_cache = anchor->input_field->no_cache; + f->disabled = anchor->input_field->disabled; + + /* Init all the fields in the new HTLine (but see the #if). */ + l->next = htline->next; + l->prev = htline; + l->offset = htline->offset; + l->size = htline->size; + l->split_after = htline->split_after; + l->bullet = htline->bullet; + l->expansion_line = TRUE; +#if defined(USE_COLOR_STYLE) + /* dup styles[] if needed [no need in TEXTAREA (?); leave 0's] */ + l->numstyles = htline->numstyles; +#endif + strcpy (l->data, htline->data); + if (keypad_mode == LINKS_AND_FORM_FIELDS_ARE_NUMBERED) { + a->number++; + increment_tagged_htline (l, a, &lx, &curr_tag, 1, CHOP); + } + + /* + * If we're at the tail end of the TextAnchor or HTLine list(s), + * the new node becomes the last node. + */ + if (anchor == HTMainText->last_anchor) + HTMainText->last_anchor = a; + if (htline == HTMainText->last_line) + HTMainText->last_line = l; + + /* + * Link in the new TextAnchor and point the entry anchor arg at it; + * link in the new HTLine and point the entry htline arg at it, too. + */ + anchor->next = a; + *curr_anchor = a; + + htline->next->prev = l; + htline->next = l; + *exit_htline = l->next; + + return; +} + + +/* + * If new anchors were added to expand a TEXTAREA, we need to ripple the + * new line numbers [and char counts ?] thru the subsequent anchors. + * + * If form lines are getting [nnn] tagged, we need to update the displayed + * tag values to match (which means rerendering them ... sigh). + * + * Finally, we need to update various HTMainText and other counts, etc. + * + * [dunno if the char counts really *need* to be done, or if we're using + * the exactly proper values/algorithms ... seems to be OK though ...] + * + * --KED 02/13/99 + */ +PRIVATE void update_subsequent_anchors ARGS4( + int, n, + TextAnchor *, start_anchor, + HTLine *, start_htline, + int, start_tag) +{ + TextAnchor *anchor; + HTLine *htline = start_htline; + + int form_chars_added = (start_anchor->input_field->size + 1) * n; + int line_adj = 0; + int tag_adj = 0; + int lx = 0; + int hang = 0; /* for HANG detection of a nasty intermittent */ + int hang_detect = 100000; /* ditto */ + + + CTRACE(tfp, "GridText: adjusting struct's to add %d new line(s)\n", n); + + /* + * Update numeric fields of the rest of the anchors. + * + * [We bypass bumping ->number if it has a value of 0, which takes care + * of the ->input_field->type == F_HIDDEN_TYPE (as well as any other + * "hidden" anchors (if such things exist). Seems like the "right + * thing" to do. I think. + */ + anchor = start_anchor->next; /* begin updating with the NEXT anchor */ + while (anchor) { + if ((keypad_mode == LINKS_AND_FORM_FIELDS_ARE_NUMBERED) && + (anchor->number != 0)) + anchor->number += n; + anchor->line_num += n; + anchor->start += form_chars_added; + anchor = anchor->next; + } + + /* + * Update/rerender anchor [tags], if they are being numbered. + * + * [If a number tag (eg, "[177]") is itself broken across a line + * boundary, this fixup only partially works. While the tag + * numbering is done properly across the pair of lines, the + * horizontal positioning on *either* side of the split, can get + * out of sync by a char or two when it gets selected. See [com + * ments] in increment_tagged_htline() for some more detail. + * + * I suppose THE fix is to prevent such tag-breaking in the first + * place (dunno where yet, though). Ah well ... at least the tag + * numbers themselves are correct from top to bottom now. + * + * All that said, about the only time this will be a problem in + * *practice*, is when a page has near 1000 links or more (possibly + * after a TEXTAREA expansion), and has line crossing tag(s), and + * the tag numbers in a line crosser go from initially all 3 digit + * numbers, to some mix of 3 and 4 digits (or all 4 digits) as a + * result of the expansion process. Oh, you also need a "clump" of + * anchors all on the same lines. + * + * Yes, it *can* happen, but in real life, it probably won't be + * seen very much ...] + * + * [This may also be an artifact of bumping into the right hand + * screen edge (or RHS margin), since we don't even *think* about + * relocating an anchor to the following line, when [tag] digits + * expansion pushes things too far in that direction.] + */ + if (keypad_mode == LINKS_AND_FORM_FIELDS_ARE_NUMBERED) { + anchor = start_anchor->next; + while (htline != HTMainText->last_line->next) { + + while (anchor) { + if ((anchor->number - n) == start_tag) + break; + + /*** A HANG (infinite loop) *has* occurred here, with */ + /*** the values of anchor and anchor->next being the */ + /*** the same, OR with anchor->number "magically" and */ + /*** suddenly taking on an anchor-pointer-like value. */ + /*** */ + /*** The same code and same doc have both passed and */ + /*** failed at different times, which indicates some */ + /*** sort of content/html dependency, or some kind of */ + /*** a "race" condition, but I'll be damned if I can */ + /*** find it after tons of CTRACE's, printf()'s, gdb */ + /*** breakpoints and watchpoints, etc. */ + /*** */ + /*** I have added a hang detector (with error msg and */ + /*** beep) here, to break the loop and warn the user, */ + /*** until it can be isolated and fixed. */ + /*** */ + /*** [One UGLY intermittent .. gak ..! 02/22/99 KED] */ + + hang++; + if ((anchor == anchor->next) || (hang >= hang_detect)) + goto hang_detected; + + anchor = anchor->next; + } + + if (anchor) { + line_adj = increment_tagged_htline (htline, anchor, &lx, + &start_tag, n, NOCHOP); + htline->size += line_adj; + tag_adj += line_adj; + + } else { + + break; /* out of anchors ... we're done */ + } + + htline = htline->next; + } + } + +exit: + /* + * Fixup various global variables. + */ + nlinks += n; + HTMainText->Lines += n; + HTMainText->last_anchor_number += n; + HTMainText->chars += (form_chars_added + tag_adj); + + more = HText_canScrollDown(); + + CTRACE(tfp, "GridText: TextAnchor and HTLine struct's adjusted\n"); + + return; + +hang_detected: /* uglyness has happened; inform user and do the best we can */ + + printf ("\007"); /* beep the user */ + fflush (NULL); + HTAlert ("Hang Detect: TextAnchor struct corrupted - suggest aborting!"); + HTAlert ("Hang Detect: TextAnchor struct corrupted - suggest aborting!"); + goto exit; +} + + /* * Transfer the initial contents of a TEXTAREA to a temp file, invoke the * user's editor on that file, then transfer the contents of the resultant @@ -9220,9 +9664,10 @@ PRIVATE int increment_tagged_htline ARGS6( * --KED 02/01/99 */ PUBLIC int HText_ExtEditForm ARGS1( - struct link *, form_link) + struct link *, form_link) { struct stat stat_info; + size_t size; char *ed_temp; FILE *fp; @@ -9245,26 +9690,14 @@ PUBLIC int HText_ExtEditForm ARGS1( HTLine *htline = NULL; - TextAnchor *a = 0; - FormInfo *f = 0; - HTLine *l = 0; - char *ebuf; char *tbuf = NULL; char *line; char *lp; char *cp; - char *p; - char *s; - int curr_tag; - int line_adj = 0; - int tag_adj = 0; - int newlines = 0; + int match_tag = 0; + int newlines = 0; int len; - int i; - int n; - int lx; - size_t size; CTRACE(tfp, "GridText: entered HText_ExtEditForm()\n"); @@ -9320,7 +9753,7 @@ PUBLIC int HText_ExtEditForm ARGS1( } anchor_ptr = anchor_ptr->next; } - fclose (fp); + LYCloseTempFP (fp); CTRACE(tfp, "GridText: TEXTAREA name=|%s| dumped to tempfile\n", areaname); CTRACE(tfp, "GridText: invoking editor (%s) on tempfile\n", editor); @@ -9332,10 +9765,10 @@ PUBLIC int HText_ExtEditForm ARGS1( */ if (((entry_line - start_line) > 0) && editor_can_position()) #ifdef VMS - sprintf (ed_offset, "-%d", ((entry_line - start_line) + 1)); + sprintf (ed_offset, "-%d", ((entry_line - start_line) + 1)); HTSprintf0 (&tbuf, "%s %s %s", editor, ed_temp, ed_offset); #else - sprintf (ed_offset, "+%d", ((entry_line - start_line) + 1)); + sprintf (ed_offset, "+%d", ((entry_line - start_line) + 1)); HTSprintf0 (&tbuf, "%s %s %s", editor, ed_offset, ed_temp); #endif @@ -9347,9 +9780,9 @@ PUBLIC int HText_ExtEditForm ARGS1( */ HTSprintf0 (&tbuf, "%s~", ed_temp); if (stat (tbuf, &stat_info) == 0) - remove (tbuf); + remove (tbuf); #endif - FREE (tbuf); + FREE(tbuf); CTRACE(tfp, "GridText: returned from editor (%s)\n", editor); @@ -9379,13 +9812,10 @@ PUBLIC int HText_ExtEditForm ARGS1( /* * Copy each line from the temp file into the corresponding anchor - * struct, removing any trailing whitespace, expanding any embedded - * tab's, and substituting a printable char for any other embedded - * control chars. Add new lines to the TEXTAREA if needed. (Always - * leave the user with a blank line at the end of the TEXTAREA.) + * struct. Add new lines to the TEXTAREA if needed. (Always leave + * the user with a blank line at the end of the TEXTAREA.) */ - if (((line = (char *) malloc (MAX_LINE)) == 0) || - ((tbuf = (char *) malloc (MAX_LINE)) == 0)) + if ((line = (char *) malloc (MAX_LINE)) == 0) outofmem(__FILE__, "HText_ExtEditForm"); anchor_ptr = start_anchor; @@ -9403,184 +9833,24 @@ PUBLIC int HText_ExtEditForm ARGS1( strncpy (line, lp, len); *(line + len) = '\0'; - /* - * Whack off trailing whitespace from the line. - */ - for (i = len, p = line + (len - 1); i != 0; p--, i--) { - if (isspace (*p)) - *p = '\0'; - else - break; - } - - if (strlen (line) != 0) { - /* - * Expand any tab's, since they won't render properly in a - * TEXTAREA. - * - * [is that "by spec", or just a "lynxism" ? ... as may be, it - * seems they may cause other problems, too ... haven't really - * looked into that very deeply though] - */ - p = line; - s = tbuf; - - while (*p) { - if ((cp = strchr (p, '\t')) != 0) { - i = cp - p; - s = (strncpy (s, p, i)) + i; - n = TABSTOP - (i % TABSTOP); - s = (strncpy (s, SPACES, n)) + n; - p += (i + 1); - - } else { - - strcpy (s, p); - break; - } - } - - /* - * Replace control chars with something printable. Note that - * we leave any chars above 0x7f alone (ie, no translation is - * performed ... the assumption being that the charset used in - * the editor is compatible with the charset rendered by lynx). - * - * [At some point in time, when/if lynx ever supports multibyte - * characters internally (eg, UCS-2, UCS-4, UTF-16, etc), this - * kind of thing may well cause problems. But then, supporting - * such char sets will require massive changes in (most) all - * parts of the lynx code, so until then, we do the rational - * thing with chars that would otherwise foul the display, if - * left alone. If you're implementing multibyte character set - * support, consider yourself to have been warned.] - */ - for (p = line, s = tbuf; *s != '\0'; p++, s++) -#ifndef EBCDIC - *p = (((unsigned char)*s < ' ') || - ((unsigned char)*s == '\177')) ? SPLAT : *s; -#else - *p = ((unsigned char)*s < ' ') ? SPLAT : *s; -#endif - *p = '\0'; - } - + cleanup_line_for_textarea (line, len); /* * If there are more lines in the edit buffer than were in the - * original TEXTAREA, we need to add some new lines, continuing - * until the edit buffer is empty. - * - * [cloning structs could be moved to a seperate fn(), or three] + * original TEXTAREA, we need to add a new line/anchor, continuing + * on until the edit buffer is empty. */ if (line_cnt > orig_cnt) { - - /* - * Find line in the text that matches ending anchorline of - * the TEXTAREA. - * - * [Yes, Virginia ... we *do* have to go thru this for each - * anchor being added, since there is NOT a 1-to-1 mapping - * between anchors and htlines. I suppose we could create - * YAS (Yet Another Struct), but there are too many structs{} - * floating around in here, as it is. IMNSHO.] - */ - for (htline = HTMainText->last_line->next, i = 0; - end_anchor->line_num != i; i++) { - htline = htline->next; - if (htline == HTMainText->last_line) - break; - } - - /* - * Clone and initialize the structs needed to add a new - * TEXTAREA anchor. - */ - if (((a = (TextAnchor *) calloc (1, sizeof(*a))) == 0) || - ((f = (FormInfo *) calloc (1, sizeof(*f))) == 0) || - ((l = (HTLine *) calloc (1, LINE_SIZE(MAX_LINE))) == 0)) - outofmem(__FILE__, "HText_ExtEditForm"); - - /* Init all the fields in the new TextAnchor. */ - /* [anything "special" needed based on ->show_anchor value ?] */ - a->next = end_anchor->next; - a->number = end_anchor->number; - a->start = end_anchor->start + - end_anchor->input_field->size + 1; - a->line_pos = end_anchor->line_pos; - a->extent = end_anchor->extent; - a->line_num = end_anchor->line_num + 1; - StrAllocCopy (a->hightext, end_anchor->hightext); - StrAllocCopy (a->hightext2, end_anchor->hightext2); - a->hightext2offset = end_anchor->hightext2offset; - a->link_type = end_anchor->link_type; - a->input_field = f; - a->show_anchor = end_anchor->show_anchor; - a->inUnderline = end_anchor->inUnderline; - a->expansion_anch = TRUE; - a->anchor = NULL; - - /* Just the (seemingly) relevant fields in the new FormInfo. */ - /* [do we need to do anything "special" based on ->disabled] */ - StrAllocCopy (f->name, end_anchor->input_field->name); - f->number = end_anchor->input_field->number; - f->type = end_anchor->input_field->type; - StrAllocCopy (f->orig_value, ""); - f->size = end_anchor->input_field->size; - f->maxlength = end_anchor->input_field->maxlength; - f->no_cache = end_anchor->input_field->no_cache; - f->disabled = end_anchor->input_field->disabled; - - /* Init all the fields in the new HTLine (but see the #if). */ - l->next = htline->next; - l->prev = htline; - l->offset = htline->offset; - l->size = htline->size; - l->split_after = htline->split_after; - l->bullet = htline->bullet; - l->expansion_line = TRUE; -#if defined(USE_COLOR_STYLE) - /* dup styles[] if needed [no need in TEXTAREA (?); leave 0's] */ - l->numstyles = htline->numstyles; -#endif - strcpy (l->data, htline->data); - if (keypad_mode == LINKS_AND_FORM_FIELDS_ARE_NUMBERED) { - a->number++; - curr_tag = 0; /* 0 matches any [tag] number */ - lx = 0; - increment_tagged_htline (l, a, &lx, &curr_tag, 1, CHOP); - } - - /* - * If we're at the tail end of the TextAnchor or HTLine list(s), - * the new node becomes the last node. - */ - if (end_anchor == HTMainText->last_anchor) - HTMainText->last_anchor = a; - if (htline == HTMainText->last_line) - HTMainText->last_line = l; - - /* - * Link in the new TextAnchor and make it current; link in - * the new HTLine. - */ - end_anchor->next = a; - anchor_ptr = a; - - htline->next->prev = l; - htline->next = l; - htline = l->next; - + insert_new_textarea_anchor (&end_anchor, &htline); + anchor_ptr = end_anchor; /* make the new anchor current */ newlines++; } - /* * Finally copy the new line from the edit buffer into the anchor. */ StrAllocCopy(anchor_ptr->input_field->value, line); - /* * Keep track of 1st blank line in any trailing blank lines, for * later cursor repositioning. @@ -9600,7 +9870,7 @@ PUBLIC int HText_ExtEditForm ARGS1( anchor_ptr = anchor_ptr->next; if (anchor_ptr) - curr_tag = anchor_ptr->number; + match_tag = anchor_ptr->number; line_cnt++; } @@ -9608,118 +9878,403 @@ PUBLIC int HText_ExtEditForm ARGS1( CTRACE(tfp, "GridText: edited text inserted into lynx struct's\n"); /* - * If new anchors were added, we need to ripple the new line numbers - * (and char counts ?) thru the subsequent anchors. If form lines - * are getting tagged, we need to update the displayed tag values - * to match (which means re-rendering them ...sigh). Finally update - * the HText counts. + * If we've added any new lines/anchors, we need to adjust various + * things in all anchor-bearing lines following the last newly added + * line/anchor. The fun stuff starts here ... + */ + if (newlines > 0) + update_subsequent_anchors (newlines, end_anchor, htline, match_tag); + + /* + * Cleanup time. + */ + FREE(line); + FREE(ebuf); + LYRemoveTemp (ed_temp); + FREE(ed_temp); + + CTRACE(tfp, "GridText: exiting HText_ExtEditForm()\n"); + + /* + * Return the offset needed to move the cursor from its current + * (on entry) line number, to the 1st blank line of the trailing + * (group of) blank line(s), which is where we want to be. Let + * the caller deal with moving us there, however ... :-) ... + */ + return (exit_line - entry_line); +} + + +/* + * Expand the size of a TEXTAREA by a fixed number of lines (as specified + * by arg2). + * + * --KED 02/14/99 + */ +PUBLIC void HText_ExpandTextarea ARGS2( + struct link *, form_link, + int, newlines) +{ + TextAnchor *anchor_ptr; + TextAnchor *end_anchor = NULL; + BOOLEAN firstanchor = TRUE; + + FormInfo *form = form_link->form; + char *areaname = form->name; + int form_num = form->number; + + HTLine *htline = NULL; + + int match_tag = 0; + int i; + + + CTRACE(tfp, "GridText: entered HText_ExpandTextarea()\n"); + + if (newlines < 1) return; + + /* + * Begin at the beginning, to find the TEXTAREA, then on to find + * the last line (anchor) in it. * - * [dunno if the char counts really need to be done, or if we're using - * the exactly proper values ... seems to be OK though ...] + * [Finding the TEXTAREA we're actually *in* with these attributes + * isn't foolproof. The form_num isn't unique to a given TEXTAREA, + * and there *could* be TEXTAREA's with the same "name". If that + * should ever be true, we'll actually expand the *1st* TEXTAREA + * in the page that matches. We should probably assign a unique + * id to each TEXTAREA in a page, and match on that, to avoid this + * (potential) problem. + * + * Since the odds of "false matches" *actually* happening in real + * life seem rather small though, we'll hold off doing this, for a + * rainy day ...] */ - if (newlines > 0) { + anchor_ptr = HTMainText->first_anchor; + + while (anchor_ptr) { + + if ((anchor_ptr->link_type == INPUT_ANCHOR) && + (anchor_ptr->input_field->type == F_TEXTAREA_TYPE) && + (anchor_ptr->input_field->number == form_num) && + !strcmp (anchor_ptr->input_field->name, areaname)) { + + if (firstanchor) + firstanchor = FALSE; + + end_anchor = anchor_ptr; + + } else { - CTRACE(tfp, "GridText: adjusting struct's to add %d new lines\n", - newlines); + if (!firstanchor) + break; + } + anchor_ptr = anchor_ptr->next; + } - i = (end_anchor->input_field->size + 1) * newlines; + for (i = 1; i <= newlines; i++) { + insert_new_textarea_anchor (&end_anchor, &htline); /* - * [*may* need to bypass bumping ->number if ->input_field->type - * is of F_HIDDEN_TYPE ... need to investigate further] + * Make the new line blank. */ - while (anchor_ptr) { - if (keypad_mode == LINKS_AND_FORM_FIELDS_ARE_NUMBERED) - anchor_ptr->number += newlines; - anchor_ptr->line_num += newlines; - anchor_ptr->start += i; - anchor_ptr = anchor_ptr->next; - } - anchor_ptr = end_anchor; + StrAllocCopy(end_anchor->input_field->value, ""); /* - * If a number tag (eg, "[177]") is itself broken across a line - * boundary, this fixup only partially works. While the tag - * numbering is done properly across the pair of lines, the - * horizontal positioning on *either* side of the split, can get - * out of sync by a char or two when it gets selected. See [com - * ments] in increment_tagged_htline() for some more detail. - * - * I suppose THE fix is to prevent such tag-breaking in the first - * place (dunno where yet, though). Ah well ... at least the tag - * numbers are correct from top to bottom now. - * - * All that said, about the only time this will be a problem in - * *practice*, is when a page has near 1000 links or more (possibly - * after a TEXTAREA expansion), and has line crossing tag(s), and - * the tag numbers in a line crosser go from initially all 3 digit - * numbers, to some mix of 3 and 4 digits (or all 4 digits) as a - * result of the expansion process. Oh, and you need a "clump" of - * anchors all on the same lines. - * - * Yes, it *can* happen, but in real life, it probably won't be - * seen very much ... - * - * [This may also be an artifact of bumping into the right hand - * screen edge (or RHS margin), since we don't even *think* about - * relocating an anchor to the following line, when [tag] digits - * expansion pushes things too far in that direction.] + * And go add another line ... */ - if (keypad_mode == LINKS_AND_FORM_FIELDS_ARE_NUMBERED) { - lx = 0; - while (htline != HTMainText->last_line->next) { + if (end_anchor->next) + match_tag = end_anchor->next->number; + } - while (anchor_ptr) { - if ((anchor_ptr->number - newlines) == curr_tag) - break; - else - anchor_ptr = anchor_ptr->next; - } + CTRACE(tfp, "GridText: %d blank line(s) added to TEXTAREA name=|%s|\n", + newlines, areaname); - if (anchor_ptr) { - line_adj = increment_tagged_htline (htline, anchor_ptr, - &lx, &curr_tag, - newlines, NOCHOP); - htline->size += line_adj; - tag_adj += line_adj; + /* + * We need to adjust various things in all anchor bearing lines + * following the last newly added line/anchor. Fun stuff. + */ + update_subsequent_anchors (newlines, end_anchor, htline, match_tag); - } else { + CTRACE(tfp, "GridText: exiting HText_ExpandTextarea()\n"); - break; /* out of anchors ... we're done */ - } + return; +} - htline = htline->next; - } + +/* + * Insert the contents of a file into a TEXTAREA between the cursorline, + * and the line preceeding it. + * + * Returns the number of lines that the cursor should be moved so that it + * will end up on the 1st line in the TEXTAREA following the inserted file + * (if we decide to do that). + * + * --KED 02/21/99 + */ +PUBLIC int HText_InsertFile ARGS1( + struct link *, form_link) +{ + struct stat stat_info; + size_t size; + + FILE *fp; + char *fn; + + TextAnchor *anchor_ptr; + TextAnchor *prev_anchor = NULL; + TextAnchor *end_anchor = NULL; + BOOLEAN firstanchor = TRUE; + + FormInfo *form = form_link->form; + char *areaname = form->name; + int form_num = form->number; + + HTLine *htline = NULL; + + TextAnchor *a = 0; + FormInfo *f = 0; + HTLine *l = 0; + + char *fbuf; + char *line; + char *lp; + char *cp; + int entry_line = form_link->anchor_line_num; + int match_tag = 0; + int newlines = 0; + int len; + int i; + + + CTRACE(tfp, "GridText: entered HText_InsertFile()\n"); + + /* + * Get the filename of the insert file. + */ + if (!(fn = GetFileName())) { + HTInfoMsg (FILE_INSERT_CANCELLED); + CTRACE(tfp, "GridText: file insert cancelled - no filename provided\n"); + return (0); + } + + /* + * Read it into our buffer (abort on 0-length file). + */ + if ((stat (fn, &stat_info) < 0) || + ((size = stat_info.st_size) == 0)) { + HTInfoMsg (FILE_INSERT_0_LENGTH); + CTRACE(tfp, "GridText: file insert aborted - file=|%s|- was 0-length\n", + fn); + FREE(fn); + return (0); + + } else { + + if ((fbuf = (char *) calloc (size + 1, (sizeof(char)))) == NULL) + outofmem(__FILE__, "HText_InsertFile"); + + fp = fopen (fn, "r"); + size = fread (fbuf, 1, size, fp); + fclose (fp); + FREE(fn); + } + + + /* + * Begin at the beginning, to find the TEXTAREA we're in, then + * the current cursorline. + * + * [Finding the TEXTAREA we're actually *in* with these attributes + * isn't foolproof. The form_num isn't unique to a given TEXTAREA, + * and there *could* be TEXTAREA's with the same "name". If that + * should ever be true, we'll actually insert data into the *1st* + * TEXTAREA in the page that matches. We should probably assign + * a unique id to each TEXTAREA in a page, and match on that, to + * avoid this (potential) problem. + * + * Since the odds of "false matches" *actually* happening in real + * life seem rather small though, we'll hold off doing this, for a + * rainy day ...] + */ + anchor_ptr = HTMainText->first_anchor; + + while (anchor_ptr) { + + if ((anchor_ptr->link_type == INPUT_ANCHOR) && + (anchor_ptr->input_field->type == F_TEXTAREA_TYPE) && + (anchor_ptr->input_field->number == form_num) && + !strcmp (anchor_ptr->input_field->name, areaname)) { + + if (anchor_ptr->line_num == entry_line) + break; + } + prev_anchor = anchor_ptr; + anchor_ptr = anchor_ptr->next; + } + + + /* + * Clone a new TEXTAREA line/anchor using the cursorline anchor as + * a template, but link it in BEFORE the cursorline anchor/htline. + * + * [We can probably combine this with insert_new_textarea_anchor() + * along with a flag to indicate "insert before" as we do here, + * or the "normal" mode of operation (add after "current" anchor/ + * line). Beware of the differences ... some are a bit subtle to + * notice. + */ + for (htline = HTMainText->last_line->next, i = 0; + anchor_ptr->line_num != i; i++) { + htline = htline->next; + if (htline == HTMainText->last_line) + break; + } + + if (((a = (TextAnchor *) calloc (1, sizeof(*a))) == 0) || + ((f = (FormInfo *) calloc (1, sizeof(*f))) == 0) || + ((l = (HTLine *) calloc (1, LINE_SIZE(MAX_LINE))) == 0)) + outofmem(__FILE__, "HText_InsertFile"); + + /* Init all the fields in the new TextAnchor. */ + /* [anything "special" needed based on ->show_anchor value ?] */ + a->next = anchor_ptr; + a->number = anchor_ptr->number; + a->start = anchor_ptr->start; + a->line_pos = anchor_ptr->line_pos; + a->extent = anchor_ptr->extent; + a->line_num = anchor_ptr->line_num; + StrAllocCopy (a->hightext, anchor_ptr->hightext); + StrAllocCopy (a->hightext2, anchor_ptr->hightext2); + a->hightext2offset = anchor_ptr->hightext2offset; + a->link_type = anchor_ptr->link_type; + a->input_field = f; + a->show_anchor = anchor_ptr->show_anchor; + a->inUnderline = anchor_ptr->inUnderline; + a->expansion_anch = TRUE; + a->anchor = NULL; + + /* Just the (seemingly) relevant fields in the new FormInfo. */ + /* [do we need to do anything "special" based on ->disabled] */ + StrAllocCopy (f->name, anchor_ptr->input_field->name); + f->number = anchor_ptr->input_field->number; + f->type = anchor_ptr->input_field->type; + StrAllocCopy (f->orig_value, ""); + f->size = anchor_ptr->input_field->size; + f->maxlength = anchor_ptr->input_field->maxlength; + f->no_cache = anchor_ptr->input_field->no_cache; + f->disabled = anchor_ptr->input_field->disabled; + + /* Init all the fields in the new HTLine (but see the #if). */ + l->offset = htline->offset; + l->size = htline->size; + l->split_after = htline->split_after; + l->bullet = htline->bullet; + l->expansion_line = TRUE; +#if defined(USE_COLOR_STYLE) + /* dup styles[] if needed [no need in TEXTAREA (?); leave 0's] */ + l->numstyles = htline->numstyles; +#endif + strcpy (l->data, htline->data); + + /* + * If we're at the head of the TextAnchor list, the new node becomes + * the first node. + */ + if (anchor_ptr == HTMainText->first_anchor) + HTMainText->first_anchor = a; + + /* + * Link in the new TextAnchor, and corresponding HTLine. + */ + if (prev_anchor) + prev_anchor->next = a; + + htline = htline->prev; + l->next = htline->next; + l->prev = htline; + htline->next->prev = l; + htline->next = l; + + /* + * update_subsequent_anchors() expects htline to point to 1st potential + * line needing fixup; we need to do this just in case the inserted file + * was only a single line (yes, it's pathological ... ). + */ + htline = htline->next; /* ->new (current) htline, for 1st inserted line */ + htline = htline->next; /* ->1st potential (following) [tag] fixup htline */ + + anchor_ptr = a; + newlines++; + + + /* + * Copy each line from the insert file into the corresponding anchor + * struct. + * + * Begin with the new line/anchor we just added (above the cursorline). + */ + if ((line = (char *) malloc (MAX_LINE)) == 0) + outofmem(__FILE__, "HText_InsertFile"); + + match_tag = anchor_ptr->number; + + len = 0; + lp = fbuf; + + while (*lp) { + + if ((cp = strchr (lp, '\n')) != 0) + len = cp - lp; + else + len = strlen (lp); + + strncpy (line, lp, len); + *(line + len) = '\0'; + + cleanup_line_for_textarea (line, len); + + /* + * If not the first line from the insert file, we need to add + * a new line/anchor, continuing on until the buffer is empty. + */ + if (!firstanchor) { + insert_new_textarea_anchor (&end_anchor, &htline); + anchor_ptr = end_anchor; /* make the new anchor current */ + newlines++; } /* - * Fixup various global variables. + * Copy the new line from the buffer into the anchor. */ - nlinks += newlines; - HTMainText->Lines += newlines; - HTMainText->last_anchor_number += newlines; - HTMainText->chars += (i + tag_adj); + StrAllocCopy(anchor_ptr->input_field->value, line); - more = TRUE; + /* + * And do the next line of insert text, for the next anchor ... + */ + lp += len; + if (*lp) lp++; - CTRACE(tfp, "GridText: TextAnchor and HTLine struct's adjusted\n"); + firstanchor = FALSE; + end_anchor = anchor_ptr; + anchor_ptr = anchor_ptr->next; } - CTRACE(tfp, "GridText: struct's adjusted - exiting HText_ExtEditForm()\n"); + CTRACE(tfp, "GridText: file inserted into lynx struct's\n"); - FREE (line); - FREE (ebuf); - FREE (tbuf); - LYRemoveTemp (ed_temp); - FREE (ed_temp); + /* + * Now adjust various things in all anchor-bearing lines following the + * last newly added line/anchor. Some say this is the fun part ... + */ + update_subsequent_anchors (newlines, end_anchor, htline, match_tag); - CTRACE(tfp, "GridText: exiting HText_ExtEditForm()\n"); /* - * Return the offset needed to move the cursor from its current - * (on entry) line number, to the 1st blank line of the trailing - * (group of) blank line(s), which is where we want to be. Let - * the caller deal with moving us there, however ... :-) ... + * Cleanup time. */ - return (exit_line - entry_line); + FREE(line); + FREE(fbuf); + + CTRACE(tfp, "GridText: exiting HText_InsertFile()\n"); + + return (newlines); } diff --git a/src/GridText.h b/src/GridText.h index 16cca89c..15edf892 100644 --- a/src/GridText.h +++ b/src/GridText.h @@ -142,6 +142,7 @@ extern void print_wwwfile_to_fd PARAMS((FILE * fp, int is_reply)); extern BOOL HText_select PARAMS((HText *text)); extern BOOL HText_POSTReplyLoaded PARAMS((document *doc)); extern BOOL HTFindPoundSelector PARAMS((char *selector)); +extern int HTGetRelLinkNum PARAMS((int num, int rel, int cur)); extern int HTGetLinkInfo PARAMS(( int number, int want_go, @@ -264,5 +265,10 @@ extern BOOL HText_AreDifferent PARAMS(( extern int HText_ExtEditForm PARAMS(( struct link * form_link)); +extern void HText_ExpandTextarea PARAMS(( + struct link * form_link, + int newlines)); +extern int HText_InsertFile PARAMS(( + struct link * form_link)); #endif /* LYGRIDTEXT_H */ diff --git a/src/HTFWriter.c b/src/HTFWriter.c index de3c6019..4f33d01e 100644 --- a/src/HTFWriter.c +++ b/src/HTFWriter.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include diff --git a/src/HTML.c b/src/HTML.c index 567dd804..d3ad2038 100644 --- a/src/HTML.c +++ b/src/HTML.c @@ -656,6 +656,7 @@ PRIVATE void HTML_start_element ARGS6( char *alt_string = NULL; char *id_string = NULL; char *newtitle = NULL; + char **pdoctitle = NULL; char *href = NULL; char *map_href = NULL; char *title = NULL; @@ -1005,10 +1006,6 @@ PRIVATE void HTML_start_element ARGS6( !strcasecomp(value[HTML_LINK_REL], "Index") || !strcasecomp(value[HTML_LINK_REL], "Glossary") || !strcasecomp(value[HTML_LINK_REL], "Copyright") || - !strcasecomp(value[HTML_LINK_REL], "Up") || - !strcasecomp(value[HTML_LINK_REL], "Next") || - !strcasecomp(value[HTML_LINK_REL], "Previous") || - !strcasecomp(value[HTML_LINK_REL], "Prev") || !strcasecomp(value[HTML_LINK_REL], "Help") || !strcasecomp(value[HTML_LINK_REL], "Search") || !strcasecomp(value[HTML_LINK_REL], "Bookmark") || @@ -1016,29 +1013,51 @@ PRIVATE void HTML_start_element ARGS6( !strcasecomp(value[HTML_LINK_REL], "Top") || !strcasecomp(value[HTML_LINK_REL], "Origin") || !strcasecomp(value[HTML_LINK_REL], "Navigator") || - !strcasecomp(value[HTML_LINK_REL], "Child") || !strcasecomp(value[HTML_LINK_REL], "Disclaimer") || - !strcasecomp(value[HTML_LINK_REL], "Sibling") || - !strcasecomp(value[HTML_LINK_REL], "Parent") || !strcasecomp(value[HTML_LINK_REL], "Author") || !strcasecomp(value[HTML_LINK_REL], "Editor") || !strcasecomp(value[HTML_LINK_REL], "Publisher") || !strcasecomp(value[HTML_LINK_REL], "Trademark") || - !strcasecomp(value[HTML_LINK_REL], "Meta") || - !strcasecomp(value[HTML_LINK_REL], "URC") || !strcasecomp(value[HTML_LINK_REL], "Hotlist") || !strcasecomp(value[HTML_LINK_REL], "Begin") || !strcasecomp(value[HTML_LINK_REL], "First") || !strcasecomp(value[HTML_LINK_REL], "End") || !strcasecomp(value[HTML_LINK_REL], "Last") || + !strcasecomp(value[HTML_LINK_REL], "Documentation") || + !strcasecomp(value[HTML_LINK_REL], "Biblioentry") || + !strcasecomp(value[HTML_LINK_REL], "Bibliography") || + !strcasecomp(value[HTML_LINK_REL], "Alternate") || + !strcasecomp(value[HTML_LINK_REL], "Start") || + !strcasecomp(value[HTML_LINK_REL], "Section") || + !strcasecomp(value[HTML_LINK_REL], "Subsection") || + !strcasecomp(value[HTML_LINK_REL], "Appendix")) { + StrAllocCopy(title, value[HTML_LINK_REL]); + pdoctitle = &title; /* for setting HTAnchor's title */ + } else + if (!strcasecomp(value[HTML_LINK_REL], "Up") || + !strcasecomp(value[HTML_LINK_REL], "Next") || + !strcasecomp(value[HTML_LINK_REL], "Previous") || + !strcasecomp(value[HTML_LINK_REL], "Prev") || + !strcasecomp(value[HTML_LINK_REL], "Child") || + !strcasecomp(value[HTML_LINK_REL], "Sibling") || + !strcasecomp(value[HTML_LINK_REL], "Parent") || + !strcasecomp(value[HTML_LINK_REL], "Meta") || + !strcasecomp(value[HTML_LINK_REL], "URC") || !strcasecomp(value[HTML_LINK_REL], "Pointer") || !strcasecomp(value[HTML_LINK_REL], "Translation") || !strcasecomp(value[HTML_LINK_REL], "Definition") || - !strcasecomp(value[HTML_LINK_REL], "Chapter") || - !strcasecomp(value[HTML_LINK_REL], "Documentation") || - !strcasecomp(value[HTML_LINK_REL], "Biblioentry") || - !strcasecomp(value[HTML_LINK_REL], "Bibliography")) { + !strcasecomp(value[HTML_LINK_REL], "Chapter")) { StrAllocCopy(title, value[HTML_LINK_REL]); + /* not setting target HTAnchor's title, for these + link of highly relative character. Instead, + try to remember the REL attribute as a property + of the link (but not the destination), in the + (otherwise underused) link type in a special format; + the LIST page generation code may later use it. - kw */ + if (!intern_flag) { + StrAllocCopy(temp, "RelTitle: "); + StrAllocCat(temp, value[HTML_LINK_REL]); + } } else { CTRACE(tfp, "HTML: LINK with REL=\"%s\" ignored.\n", value[HTML_LINK_REL]); @@ -1064,6 +1083,7 @@ PRIVATE void HTML_start_element ARGS6( break; } StrAllocCopy(title, value[HTML_LINK_REL]); + pdoctitle = &title; } if (href) { /* @@ -1077,6 +1097,8 @@ PRIVATE void HTML_start_element ARGS6( TRANSLATE_AND_UNESCAPE_ENTITIES(&title, TRUE, FALSE); LYTrimHead(title); LYTrimTail(title); + pdoctitle = &title; + FREE(temp); /* forget about recording RelTitle - kw */ } if (!(title && *title)) { FREE(href); @@ -1103,12 +1125,14 @@ PRIVATE void HTML_start_element ARGS6( me->node_anchor, /* Parent */ NULL, /* Tag */ href, /* Addresss */ - INTERN_LT); /* Type */ + temp ? + (HTLinkType*)HTAtom_for(temp) : INTERN_LT); /* Type */ + FREE(temp); if ((dest = HTAnchor_parent( HTAnchor_followMainLink((HTAnchor*)me->CurrentA) )) != NULL) { - if (!HTAnchor_title(dest)) - HTAnchor_setTitle(dest, title); + if (pdoctitle && !HTAnchor_title(dest)) + HTAnchor_setTitle(dest, *pdoctitle); dest = NULL; if (present[HTML_LINK_CHARSET] && value[HTML_LINK_CHARSET] && *value[HTML_LINK_CHARSET] != '\0') { diff --git a/src/LYBookmark.c b/src/LYBookmark.c index 8c2b9932..fcad0b4d 100644 --- a/src/LYBookmark.c +++ b/src/LYBookmark.c @@ -89,7 +89,7 @@ PUBLIC char * get_bookmark_filename ARGS1( /* * Seek it in the home path. - FM */ - LYAddPathToHome(filename_buffer, + LYAddPathToHome(filename_buffer, sizeof(filename_buffer), BookmarkPage); CTRACE(tfp, "\nget_bookmark_filename: SEEKING %s\n AS %s\n\n", @@ -309,9 +309,9 @@ PUBLIC void save_bookmark_link ARGS2( /* * Seek it in the home path. - FM */ - LYAddPathToHome(filename_buffer, - sizeof(filename_buffer), - BookmarkPage); + LYAddPathToHome(filename_buffer, + sizeof(filename_buffer), + BookmarkPage); } CTRACE(tfp, "\nsave_bookmark_link: SEEKING %s\n AS %s\n\n", BookmarkPage, filename_buffer); diff --git a/src/LYCharSets.c b/src/LYCharSets.c index a309cb05..422cf121 100644 --- a/src/LYCharSets.c +++ b/src/LYCharSets.c @@ -32,17 +32,20 @@ PUBLIC CONST char** p_entity_values = NULL; /* Pointer, for HTML_put_entity()*/ /* will be initialized in HTMLUseCharacterSet */ /* + * New character sets now declared with UCInit() in UCdomap.c + * * INSTRUCTIONS for adding new character sets which do not have - * Unicode tables. + * Unicode tables now in UCdomap.h * - * Currently we only declare some charset's properties here - * (such as MIME names, etc.), it does not include real mapping. * - * [We hope you need not correct/add old-style mapping + * [We hope you need not correct/add old-style mapping below * as in ISO_LATIN1[] or SevenBitApproximations[] any more - * it works now via new chartrans mechanism, but kept for compatibility only: * we should cleanup the stuff, but this is not so easy...] * + * Currently we only declare some charset's properties here + * (such as MIME names, etc.), it does not include real mapping. + * * There is a place marked "Add your new character sets HERE" in this file. * Make up a character set and add it in the same * style as the ISO_LATIN1 set below, giving it a unique name. @@ -328,21 +331,7 @@ PUBLIC CONST char * SevenBitApproximations[] = { */ PUBLIC CONST char ** LYCharSets[MAXCHARSETS]={ ISO_Latin1, /* ISO Latin 1 */ - SevenBitApproximations, /* ISO 8859-15 (Latin 9)*/ - SevenBitApproximations, /* DosLatin1 (cp850) */ - SevenBitApproximations, /* WinLatin1 (cp1252) */ - SevenBitApproximations, /* DosLatinUS (cp437) */ - SevenBitApproximations, /* DEC Multinational */ - SevenBitApproximations, /* Macintosh (8 bit) */ - SevenBitApproximations, /* NeXT character set */ - SevenBitApproximations, /* Chinese */ - SevenBitApproximations, /* Japanese (EUC-JP) */ - SevenBitApproximations, /* Japanese (Shift_JIS) */ - SevenBitApproximations, /* Korean */ - SevenBitApproximations, /* Taipei (Big5) */ - SevenBitApproximations, /* Vietnamese (VISCII) */ SevenBitApproximations, /* 7 Bit Approximations */ - SevenBitApproximations, /* Transparent */ }; /* @@ -351,21 +340,7 @@ PUBLIC CONST char ** LYCharSets[MAXCHARSETS]={ */ PUBLIC CONST char * LYchar_set_names[MAXCHARSETS + 1]={ "Western (ISO-8859-1)", - "Western (ISO-8859-15)", - "Western (cp850)", - "Western (windows-1252)", - "IBM PC US codepage (cp437)", - "DEC Multinational", - "Macintosh (8 bit)", - "NeXT character set", - "Chinese", - "Japanese (EUC-JP)", - "Japanese (Shift_JIS)", - "Korean", - "Taipei (Big5)", - "Vietnamese (VISCII)", "7 bit approximations (US-ASCII)", - "Transparent", (char *) 0 }; @@ -393,42 +368,11 @@ PUBLIC LYUCcharset LYCharSet_UC[MAXCHARSETS]= /* * Placeholders for Unicode tables. - FM */ - {-1,"iso-8859-15", UCT_ENC_8BIT,0,0,0, UCT_R_8BIT,UCT_R_ASCII}, - {-1,"cp850", UCT_ENC_8BIT,0, - UCT_REP_SUPERSETOF_LAT1, - 0, UCT_R_8BIT,UCT_R_ASCII}, - {-1,"windows-1252", UCT_ENC_8BIT,0, - UCT_REP_SUPERSETOF_LAT1, - 0, UCT_R_8BIT,UCT_R_ASCII}, - {-1,"cp437", UCT_ENC_8BIT,0,0,0, UCT_R_8BIT,UCT_R_ASCII}, - {-1,"dec-mcs", UCT_ENC_8BIT,0,0,0, UCT_R_8BIT,UCT_R_ASCII}, - {-1,"macintosh", UCT_ENC_8BIT,0,0,0, UCT_R_8BIT,UCT_R_ASCII}, - {-1,"next", UCT_ENC_8BIT,0,0,0, UCT_R_8BIT,UCT_R_ASCII}, - - /* - * There is no strict correlation for the next five, since the transfer - * charset gets decoded into Display Char Set by the CJK code (separate - * from Unicode mechanism). For now we use the MIME name that describes - * what is output to the terminal. - KW - */ - {-1,"euc-cn", UCT_ENC_CJK,0,0,0, UCT_R_8BIT,UCT_R_ASCII}, - {-1,"euc-jp", UCT_ENC_CJK,0,0,0, UCT_R_8BIT,UCT_R_ASCII}, - {-1,"shift_jis", UCT_ENC_CJK,0,0,0, UCT_R_8BIT,UCT_R_ASCII}, - {-1,"euc-kr", UCT_ENC_CJK,0,0,0, UCT_R_8BIT,UCT_R_ASCII}, - {-1,"big5", UCT_ENC_CJK,0,0,0, UCT_R_8BIT,UCT_R_ASCII}, - - /* - * Placeholders for Unicode tables. - FM - */ - {-1,"viscii", UCT_ENC_8BIT_C0,0,0,0, UCT_R_8BIT,UCT_R_ASCII}, {-1,"us-ascii", UCT_ENC_7BIT,0, UCT_REP_SUBSETOF_LAT1, UCT_CP_SUBSETOF_LAT1, UCT_R_ASCII,UCT_R_ASCII}, - /* - * Placeholder for non-translation mode. - FM - */ - {-1,"x-transparent", UCT_ENC_8BIT,0,0,0, UCT_R_8BIT,UCT_R_ASCII} +/* {-1,"iso-8859-15", UCT_ENC_8BIT,0,0,0, UCT_R_8BIT,UCT_R_ASCII}, */ }; @@ -442,21 +386,7 @@ PUBLIC LYUCcharset LYCharSet_UC[MAXCHARSETS]= */ PUBLIC int LYlowest_eightbit[MAXCHARSETS]={ 160, /* ISO Latin 1 */ - 160, /* ISO 8859-15 (Latin 9)*/ - 128, /* DosLatin1 (cp850) */ - 130, /* WinLatin1 (cp1252) */ - 128, /* DosLatinUS (cp437) */ - 160, /* DEC Multinational */ - 128, /* Macintosh (8 bit) */ - 128, /* NeXT character set */ - 128, /* Chinese */ - 128, /* Japanese (EUC) */ - 128, /* Japanese (SJIS) */ - 128, /* Korean */ - 128, /* Taipei (Big5) */ - 128, /* Vietnamese (VISCII) */ 999, /* 7 bit approximations */ - 128 /* Transparent (???) */ }; diff --git a/src/LYCookie.c b/src/LYCookie.c index 9020d594..d99c0d8f 100644 --- a/src/LYCookie.c +++ b/src/LYCookie.c @@ -67,8 +67,6 @@ #include #include #include -#include -#include #include #include @@ -2656,10 +2654,14 @@ PUBLIC void cookie_domain_flag_set ARGS2( domain_entry *de = NULL; domain_entry *de2 = NULL; HTList *hl = NULL; + char **str = (char **)calloc(1, sizeof(domainstr)); char *dstr = NULL; char *strsmall = NULL; int isexisting = FALSE; + if (str == NULL) + outofmem(__FILE__, "cookie_set_invcheck"); + /* * Is this the first domain we're handling? If so, initialize * domain_list. @@ -2673,7 +2675,9 @@ PUBLIC void cookie_domain_flag_set ARGS2( StrAllocCopy(dstr, domainstr); - while ((strsmall = LYstrsep(&dstr, ",")) != 0) { + *str = dstr; + + while ((strsmall = LYstrsep(str, ",")) != 0) { /* * Check the list of existing domains to see if this is a @@ -2746,6 +2750,7 @@ PUBLIC void cookie_domain_flag_set ARGS2( } FREE(strsmall); + FREE(str); FREE(dstr); } diff --git a/src/LYEdit.c b/src/LYEdit.c index c05156f4..7f225041 100644 --- a/src/LYEdit.c +++ b/src/LYEdit.c @@ -8,7 +8,6 @@ #include #include #include -#include #ifdef VMS #include #endif /* VMS */ @@ -21,16 +20,19 @@ PUBLIC BOOLEAN editor_can_position NOARGS return (strstr(editor, "sedt") || strstr(editor, "SEDT")); #else return (strstr(editor, "emacs") || strstr(editor, "vi") || - strstr(editor, "pico") || strstr(editor, "jove") || - strstr(editor, "jed")); + strstr(editor, "pico") || strstr(editor, "jove") || + strstr(editor, "jed") || strstr(editor, "joe") || + strstr(editor, "jstar") || strstr(editor, "jmacs") || + strstr(editor, "rjoe") || strstr(editor, "jpico")); #endif } /* - * In edit mode invoke either emacs, vi, pico, jove, jed sedt or the - * default editor to display and edit the current file. - * For emacs, vi, pico, jove and jed, Lynx will open the file to the - * same line that the screen cursor is on when editing is invoked. + * In edit mode invoke the given (or default) editor to display and edit the + * current file. For editors listed in 'editor_can_position()', Lynx + * will open the file to the same line that the screen cursor is on (or + * close...) when editing is invoked. + * * Returns FALSE if file is uneditable. */ PUBLIC int edit_current_file ARGS3( diff --git a/src/LYForms.c b/src/LYForms.c index e2addfef..6023d96b 100644 --- a/src/LYForms.c +++ b/src/LYForms.c @@ -515,10 +515,13 @@ breakfor: ** If a 'g' or 'p' suffix is included, that will be ** loaded into c. Otherwise, c is zeroed. - FM & LE */ -PRIVATE int get_popup_option_number ARGS1( - int *, c) +PRIVATE int get_popup_option_number ARGS2( + int *, c, + int *, rel) { char temp[120]; + char *p = temp; + int num; /* * Load the c argument into the prompt buffer. @@ -533,21 +536,38 @@ PRIVATE int get_popup_option_number ARGS1( if (LYgetstr(temp, VISIBLE, sizeof(temp), NORECALL) < 0 || *temp == 0) { HTInfoMsg(CANCELLED); *c = '\0'; + *rel = '\0'; return(0); } + *rel = '\0'; + num = atoi(p); + while ( isdigit(*p) ) + ++p; + switch ( *p ) { + case '+': case '-': + /* 123+ or 123- */ + *rel = *p++; *c = *p; + break; + default: + *c = *p++; + *rel = *p; + } + /* * If we had a 'g' or 'p' suffix, load it into c. * Otherwise, zero c. Then return the number. */ - if (strchr(temp, 'g') != NULL || strchr(temp, 'G') != NULL) { + if ( *p == 'g' || *p == 'G' ) { *c = 'g'; - } else if (strchr(temp, 'p') != NULL || strchr(temp, 'P') != NULL) { + } else if (*p == 'p' || *p == 'P' ) { *c = 'p'; } else { *c = '\0'; } - return(atoi(temp)); + if ( *rel != '+' && *rel != '-' ) + *rel = 0; + return num; } /* Use this rather than the 'wprintw()' function to write a blank-padded @@ -585,7 +605,7 @@ PRIVATE int popup_options ARGS7( * and to position the popup window appropriately, * taking the user_mode setting into account. -- FM */ - int c = 0, cmd = 0, i = 0, j = 0; + int c = 0, cmd = 0, i = 0, j = 0, rel = 0; int orig_selection = cur_selection; #ifndef USE_SLANG WINDOW * form_window; @@ -887,8 +907,27 @@ redraw: * a 'g' or 'p' suffix (which will be loaded * into c). - FM & LE */ - number = get_popup_option_number((int *)&c); - + number = get_popup_option_number((int *)&c,(int *)&rel); + + /* handle + or - suffix */ + CTRACE(tfp,"got popup option number %d, ",number); + CTRACE(tfp,"rel='%c', c='%c', cur_selection=%d\n", + rel,c,cur_selection); + if ( c == 'p' ) { + int curpage = ((cur_selection + 1) > length) ? + (((cur_selection + 1) + (length - 1))/(length)) + : 1; + CTRACE(tfp," curpage=%d\n",curpage); + if ( rel == '+' ) + number = curpage + number; + else if ( rel == '-' ) + number = curpage - number; + } else if ( rel == '+' ) { + number = cur_selection + number + 1; + } else if ( rel == '-' ) { + number = cur_selection - number + 1; + } + if ( rel ) CTRACE(tfp,"new number=%d\n",number); /* * Check for a 'p' suffix. - FM */ diff --git a/src/LYGetFile.c b/src/LYGetFile.c index a87371ff..83ae7c62 100644 --- a/src/LYGetFile.c +++ b/src/LYGetFile.c @@ -944,9 +944,12 @@ PUBLIC int follow_link_number ARGS4( int *, num) { char temp[120]; + char *p = temp; + int rel = 0; int new_top, new_link; BOOL want_go; + CTRACE(tfp,"follow_link_number(%d,%d,...)\n",c,cur); temp[0] = c; temp[1] = '\0'; *num = -1; @@ -958,19 +961,42 @@ PUBLIC int follow_link_number ARGS4( HTInfoMsg(CANCELLED); return(DO_NOTHING); } - *num = atoi(temp); + *num = atoi(p); + while ( isdigit(*p) ) + ++p; + c = *p; /* reuse c; 0 or g or p or + or - */ + switch ( c ) { + case '+': case '-': + /* 123+ or 123- */ + rel = c; c = *++p; + break; + default: + rel = *++p; + } + /* don't currently check for errors typing suffix */ + CTRACE(tfp," temp=%s, *num=%d, rel='%c'\n",temp,*num,rel); /* * Check if we had a 'p' or 'P' following the number as * a flag for displaying the page with that number. - FM */ - if (strchr(temp, 'p') != NULL || strchr(temp, 'P') != NULL) { + if ( c == 'p' || c == 'P' ) { int nlines = HText_getNumOfLines(); int npages = ((nlines + 1) > display_lines) ? (((nlines + 1) + (display_lines - 1))/(display_lines)) : 1; + int curline = doc->line; /* passed from mainloop() */ + int curpage = ((curline + 1) > display_lines) ? + (((curline + 1) + (display_lines - 1))/(display_lines)) + : 1; + CTRACE(tfp," nlines=%d, npages=%d, curline=%d, curpage=%d\n", + nlines,npages,curline,curpage); if (*num < 1) - *num = 1; + *num = rel ? 0 : 1; + if ( rel == '+' ) + *num = curpage + *num; + else if ( rel == '-' ) + *num = curpage - *num; doc->line = (npages <= 1) ? 1 : ((*num <= npages) ? (((*num - 1) * display_lines) + 1) @@ -982,8 +1008,13 @@ PUBLIC int follow_link_number ARGS4( * Check if we want to make the link corresponding to the * number the current link, rather than ACTIVATE-ing it. */ - want_go = (strchr(temp, 'g') != NULL || strchr(temp, 'G') != NULL); + want_go = ( c == 'g' || c == 'G' ); + /* If rel, add or subtract num from current link, or + * nearest previous/subsequent link if current link is not on screen. + */ + if ( rel ) + *num = HTGetRelLinkNum( *num, rel, cur ); /* * If we have a valid number, act on it. */ diff --git a/src/LYGlobalDefs.h b/src/LYGlobalDefs.h index 9b788aaa..1d467e53 100644 --- a/src/LYGlobalDefs.h +++ b/src/LYGlobalDefs.h @@ -265,7 +265,6 @@ extern char *form_get_data; /* User data for get form */ extern char *http_error_file; /* Place HTTP status code in this file */ extern char *authentication_info[2]; /* Id:Password for protected documents */ extern char *proxyauth_info[2]; /* Id:Password for protected proxy server */ -extern char *UC_TEMPcharset; /* temporary in UCGetLYhndl_byMIME */ extern BOOLEAN HEAD_request; /* Do a HEAD request */ extern BOOLEAN scan_for_buried_news_references; extern BOOLEAN bookmark_start; /* Use bookmarks as startfile */ diff --git a/src/LYHistory.c b/src/LYHistory.c index 630c0421..a71f8f05 100644 --- a/src/LYHistory.c +++ b/src/LYHistory.c @@ -76,6 +76,9 @@ PUBLIC void LYAddVisitedLink ARGS1( #endif /* DIRED_SUPPORT */ !strcmp((doc->title ? doc->title : ""), CURRENT_KEYMAP_TITLE) || !strcmp((doc->title ? doc->title : ""), LIST_PAGE_TITLE) || +#ifdef EXP_ADDRLIST_PAGE + !strcmp((doc->title ? doc->title : ""), ADDRLIST_PAGE_TITLE) || +#endif !strcmp((doc->title ? doc->title : ""), SHOWINFO_TITLE) || !strcmp((doc->title ? doc->title : ""), COOKIE_JAR_TITLE) || !strcmp((doc->title ? doc->title : ""), VISITED_LINKS_TITLE) || diff --git a/src/LYKeymap.c b/src/LYKeymap.c index 0663a95d..3a165dce 100644 --- a/src/LYKeymap.c +++ b/src/LYKeymap.c @@ -17,7 +17,7 @@ #ifdef EXP_KEYBOARD_LAYOUT PUBLIC int current_layout = 0; /* Index into LYKbLayouts[] */ -PUBLIC unsigned short * LYKbLayouts[]={ +PUBLIC LYKeymap_t * LYKbLayouts[]={ kb_layout_rot13, kb_layout_jcuken, kb_layout_yawerty @@ -31,7 +31,8 @@ PUBLIC char * LYKbLayoutNames[]={ }; #endif -PRIVATE CONST DocAddress keymap_anchor = {"LYNXKEYMAP", NULL, NULL}; +PRIVATE CONST DocAddress keymap_anchor = {"LYNXKEYMAP", NULL, NULL, + NULL, FALSE, FALSE}; struct _HTStream { @@ -41,7 +42,7 @@ struct _HTStream /* the character gets 1 added to it before lookup, * so that EOF maps to 0 */ -unsigned short keymap[KEYMAP_SIZE] = { +LYKeymap_t keymap[KEYMAP_SIZE] = { 0, /* EOF */ @@ -99,7 +100,7 @@ LYK_8, LYK_9, 0, LYK_TRACE_LOG, LYK_UP_LINK, LYK_INFO, LYK_DOWN_LINK, LYK_HELP, /* < */ /* = */ /* > */ /* ? */ -LYK_RAW_TOGGLE, LYK_ADD_BOOKMARK, LYK_PREV_PAGE, LYK_COMMENT, +LYK_RAW_TOGGLE, LYK_ADDRLIST, LYK_PREV_PAGE, LYK_COMMENT, /* @ */ /* A */ /* B */ /* C */ LYK_DOWNLOAD, LYK_ELGOTO, @@ -371,7 +372,7 @@ LYK_UP_TWO, LYK_DOWN_TWO, LYK_DO_NOTHING, LYK_FASTBACKW_LINK, * allowed at compile time. */ -unsigned short key_override[KEYMAP_SIZE] = { +LYKeymap_t key_override[KEYMAP_SIZE] = { 0, /* EOF */ @@ -632,6 +633,8 @@ struct rmap { CONST char *name; CONST char *doc; }; + +/* The order of this array must match the LYKeymapCode enum in LYKeymap.h */ PRIVATE struct rmap revmap[] = { { "UNMAPPED", NULL }, { "1", NULL }, @@ -711,6 +714,11 @@ PRIVATE struct rmap revmap[] = { { "ELGOTO", "edit the current link's URL or ACTION and go to it" }, { "CHANGE_LINK", "force reset of the current link on the page" }, { "EDITTEXTAREA", "use an external editor to edit a form's textarea" }, +{ "GROWTEXTAREA", "add 5 new blank lines to the bottom of a textarea" }, +{ "INSERTFILE", "insert file into a textarea (just above cursorline)" }, +#ifdef EXP_ADDRLIST_PAGE +{ "ADDRLIST", "like LIST command, but always shows the links URL's" }, +#endif #ifdef USE_EXTERNALS { "EXTERN", "run external program with url" }, #endif @@ -784,8 +792,8 @@ PRIVATE char *pretty ARGS1 (int, c) } PRIVATE char * format_binding ARGS2( - unsigned short *, table, - int, i) + LYKeymap_t *, table, + int, i) { unsigned the_key = table[i]; char *buf = 0; diff --git a/src/LYKeymap.h b/src/LYKeymap.h index 044de878..bad2e226 100644 --- a/src/LYKeymap.h +++ b/src/LYKeymap.h @@ -17,124 +17,137 @@ extern void set_numbers_as_arrows NOPARAMS; extern void set_vi_keys NOPARAMS; extern void set_vms_keys NOPARAMS; +/* We only use unsigned keycodes; if there's a problem matching with enum + * (which is supposed to be 'int'), that would be okay, but not as clean + * for type-checking. + */ +typedef unsigned short LYKeymap_t; + #define KEYMAP_SIZE 661 -extern unsigned short keymap[KEYMAP_SIZE]; /* main keymap matrix */ +extern LYKeymap_t keymap[KEYMAP_SIZE]; /* main keymap matrix */ #ifdef EXP_KEYBOARD_LAYOUT extern int current_layout; -extern unsigned short * LYKbLayouts[]; +extern LYKeymap_t * LYKbLayouts[]; extern char * LYKbLayoutNames[]; extern int LYSetKbLayout PARAMS((char *layout_id)); #endif #if defined(DIRED_SUPPORT) && defined(OK_OVERRIDE) -extern unsigned short key_override[]; +extern LYKeymap_t key_override[]; #endif -#define LYK_1 1 -#define LYK_2 2 -#define LYK_3 3 -#define LYK_4 4 -#define LYK_5 5 -#define LYK_6 6 -#define LYK_7 7 -#define LYK_8 8 -#define LYK_9 9 -#define LYK_SOURCE 10 -#define LYK_RELOAD 11 -#define LYK_PIPE 12 -#define LYK_QUIT 13 -#define LYK_ABORT 14 -#define LYK_NEXT_PAGE 15 -#define LYK_PREV_PAGE 16 -#define LYK_UP_TWO 17 -#define LYK_DOWN_TWO 18 -#define LYK_UP_HALF 19 -#define LYK_DOWN_HALF 20 -#define LYK_REFRESH 21 -#define LYK_HOME 22 -#define LYK_END 23 -#define LYK_PREV_LINK 24 -#define LYK_NEXT_LINK 25 -#define LYK_FASTBACKW_LINK 26 -#define LYK_FASTFORW_LINK 27 -#define LYK_UP_LINK 28 -#define LYK_DOWN_LINK 29 -#define LYK_RIGHT_LINK 30 -#define LYK_LEFT_LINK 31 -#define LYK_HISTORY 32 -#define LYK_PREV_DOC 33 -#define LYK_ACTIVATE 34 -#define LYK_GOTO 35 -#define LYK_ECGOTO 36 -#define LYK_HELP 37 -#define LYK_INDEX 38 -#define LYK_NOCACHE 39 -#define LYK_INTERRUPT 40 -#define LYK_MAIN_MENU 41 -#define LYK_OPTIONS 42 -#define LYK_INDEX_SEARCH 43 -#define LYK_WHEREIS 44 -#define LYK_NEXT 45 -#define LYK_COMMENT 46 -#define LYK_EDIT 47 -#define LYK_INFO 48 -#define LYK_PRINT 49 -#define LYK_ADD_BOOKMARK 50 -#define LYK_DEL_BOOKMARK 51 -#define LYK_VIEW_BOOKMARK 52 -#define LYK_VLINKS 53 -#define LYK_SHELL 54 -#define LYK_DOWNLOAD 55 -#define LYK_TRACE_TOGGLE 56 -#define LYK_TRACE_LOG 57 -#define LYK_IMAGE_TOGGLE 58 -#define LYK_INLINE_TOGGLE 59 -#define LYK_HEAD 60 -#define LYK_DO_NOTHING 61 -#define LYK_TOGGLE_HELP 62 -#define LYK_JUMP 63 -#define LYK_KEYMAP 64 -#define LYK_LIST 65 -#define LYK_TOOLBAR 66 -#define LYK_HISTORICAL 67 -#define LYK_MINIMAL 68 -#define LYK_SOFT_DQUOTES 69 -#define LYK_RAW_TOGGLE 70 -#define LYK_COOKIE_JAR 71 -#define LYK_F_LINK_NUM 72 -#define LYK_CLEAR_AUTH 73 -#define LYK_SWITCH_DTD 74 -#define LYK_ELGOTO 75 -#define LYK_CHANGE_LINK 76 -#define LYK_EDIT_TEXTAREA 77 +/* The order of this enum must match the 'revmap[]' array in LYKeymap.c */ +typedef enum { + LYK_UNKNOWN=0, + LYK_1, + LYK_2, + LYK_3, + LYK_4, + LYK_5, + LYK_6, + LYK_7, + LYK_8, + LYK_9, + LYK_SOURCE, + LYK_RELOAD, + LYK_PIPE, + LYK_QUIT, + LYK_ABORT, + LYK_NEXT_PAGE, + LYK_PREV_PAGE, + LYK_UP_TWO, + LYK_DOWN_TWO, + LYK_UP_HALF, + LYK_DOWN_HALF, + LYK_REFRESH, + LYK_HOME, + LYK_END, + LYK_PREV_LINK, + LYK_NEXT_LINK, + LYK_FASTBACKW_LINK, + LYK_FASTFORW_LINK, + LYK_UP_LINK, + LYK_DOWN_LINK, + LYK_RIGHT_LINK, + LYK_LEFT_LINK, + LYK_HISTORY, + LYK_PREV_DOC, + LYK_ACTIVATE, + LYK_GOTO, + LYK_ECGOTO, + LYK_HELP, + LYK_INDEX, + LYK_NOCACHE, + LYK_INTERRUPT, + LYK_MAIN_MENU, + LYK_OPTIONS, + LYK_INDEX_SEARCH, + LYK_WHEREIS, + LYK_NEXT, + LYK_COMMENT, + LYK_EDIT, + LYK_INFO, + LYK_PRINT, + LYK_ADD_BOOKMARK, + LYK_DEL_BOOKMARK, + LYK_VIEW_BOOKMARK, + LYK_VLINKS, + LYK_SHELL, + LYK_DOWNLOAD, + LYK_TRACE_TOGGLE, + LYK_TRACE_LOG, + LYK_IMAGE_TOGGLE, + LYK_INLINE_TOGGLE, + LYK_HEAD, + LYK_DO_NOTHING, + LYK_TOGGLE_HELP, + LYK_JUMP, + LYK_KEYMAP, + LYK_LIST, + LYK_TOOLBAR, + LYK_HISTORICAL, + LYK_MINIMAL, + LYK_SOFT_DQUOTES, + LYK_RAW_TOGGLE, + LYK_COOKIE_JAR, + LYK_F_LINK_NUM, + LYK_CLEAR_AUTH, + LYK_SWITCH_DTD, + LYK_ELGOTO, + LYK_CHANGE_LINK, + LYK_EDIT_TEXTAREA, + LYK_GROW_TEXTAREA, + LYK_INSERT_FILE, + +#ifdef EXP_ADDRLIST_PAGE + LYK_ADDRLIST, +#else +#define LYK_ADDRLIST LYK_ADD_BOOKMARK +#endif #ifdef USE_EXTERNALS -#define LYK_EXTERN 78 -#if defined(VMS) || defined(DIRED_SUPPORT) -#define LYK_DIRED_MENU 79 -#endif /* VMS || DIRED_SUPPORT */ -#else /* USE_EXTERNALS */ + LYK_EXTERN, +#endif /* !defined(USE_EXTERNALS) */ + #if defined(VMS) || defined(DIRED_SUPPORT) -#define LYK_DIRED_MENU 78 + LYK_DIRED_MENU, +#else +#define LYK_DIRED_MENU LYK_UNKNOWN #endif /* VMS || DIRED_SUPPORT */ -#endif /* !defined(USE_EXTERNALS) */ #ifdef DIRED_SUPPORT -#define LYK_CREATE (LYK_DIRED_MENU+1) -#define LYK_REMOVE (LYK_DIRED_MENU+2) -#define LYK_MODIFY (LYK_DIRED_MENU+3) -#define LYK_TAG_LINK (LYK_DIRED_MENU+4) -#define LYK_UPLOAD (LYK_DIRED_MENU+5) -#define LYK_INSTALL (LYK_DIRED_MENU+6) + LYK_CREATE, + LYK_REMOVE, + LYK_MODIFY, + LYK_TAG_LINK, + LYK_UPLOAD, + LYK_INSTALL, +#else +#define LYK_TAG_LINK LYK_UNKNOWN #endif /* DIRED_SUPPORT */ -#ifndef LYK_DIRED_MENU -#define LYK_DIRED_MENU 0 -#endif +} LYKeymapCodes; -#ifndef LYK_TAG_LINK -#define LYK_TAG_LINK 0 -#endif #endif /* LYKEYMAP_H */ diff --git a/src/LYList.c b/src/LYList.c index e53f51e8..b73bb61d 100644 --- a/src/LYList.c +++ b/src/LYList.c @@ -81,6 +81,11 @@ PUBLIC int showlist ARGS2( LYforce_HTML_mode = TRUE; /* force this file to be HTML */ LYforce_no_cache = TRUE; /* force this file to be new */ +#ifdef EXP_ADDRLIST_PAGE + if (titles != TRUE) + BeginInternalPage(fp0, ADDRLIST_PAGE_TITLE, LIST_PAGE_HELP); + else +#endif BeginInternalPage(fp0, LIST_PAGE_TITLE, LIST_PAGE_HELP); StrAllocCopy(Address, HTLoadedDocumentURL()); diff --git a/src/LYMain.c b/src/LYMain.c index 6db448a7..78974fa1 100644 --- a/src/LYMain.c +++ b/src/LYMain.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -559,7 +558,7 @@ PUBLIC void exit_immediately ARGS1( exit(code); } -#ifdef EBCDIC /* S/390 -- gil -- 1958 */ +#ifdef EBCDIC char un_IBM1047[ 256 ] = ""; unsigned char IBM1047[ 256 ] = /* ATOE OEMVS311 */ { @@ -584,14 +583,18 @@ unsigned char IBM1047[ 256 ] = /* ATOE OEMVS311 */ static void FixCharacters(void) { int c; - int work[256]; + int work1[256], + work2[256]; for (c = 0; c < 256; c++) { un_IBM1047[IBM1047[c]] = c; - work[c] = keymap[c+1]; + work1[c] = keymap[c+1]; + work2[c] = key_override[c+1]; + } + for (c = 0; c < 256; c++) { + keymap [IBM1047[c]+1] = work1[c]; + key_override[IBM1047[c]+1] = work2[c]; } - for (c = 0; c < 256; c++) - keymap[IBM1047[c]+1] = work[c]; } #endif /* EBCDIC */ @@ -610,7 +613,7 @@ PUBLIC int main ARGS2( char filename[LY_MAXPATH]; BOOL LYGetStdinArgs = FALSE; -#ifdef NOT_ASCII /* S/390 -- gil -- 2002 */ +#ifdef NOT_ASCII FixCharacters(); #endif /* NOT_ASCII */ @@ -1121,14 +1124,6 @@ PUBLIC int main ARGS2( LYAddPathToHome(LYTraceLogPath = malloc(LY_MAXPATH), LY_MAXPATH, "Lynx.trace"); LYOpenTraceLog(); - /* - * If TRACE is on, indicate whether the - * anonymous restrictions are set. - FM - */ - if (LYRestricted) { - CTRACE(tfp, "LYMain: Anonymous restrictions set.\n"); - } - /* * Set up the default jump file stuff. - FM */ @@ -2820,7 +2815,7 @@ keys (may be incompatible with some curses packages)" #ifdef DISP_PARTIAL PARSE_SET( "partial", TOGGLE_ARG, &display_partial, - "display partial pages while downloading" + "toggles display partial pages while downloading" ), PARSE_INT( "partial_thres", IGNORE_ARG|INT_ARG, partial_threshold, @@ -2842,7 +2837,8 @@ with partial-display logic" ), PARSE_SET( "preparsed", SET_ARG, &LYPreparsedSource, - "show parsed text/html with -source and in source view" + "show parsed text/html with -source and in source view\n\ + to visualize how lynx behave with invalid HTML" ), PARSE_SET( "print", UNSET_ARG, &no_print, @@ -2969,7 +2965,7 @@ treated '>' as a co-terminator for double-quotes and tags" "width", NEED_FUNCTION_ARG, width_fun, "=NUMBER\nscreen width for formatting of dumps (default is 80)" ), - {NULL} + {NULL, 0, 0, NULL} }; static void print_help_strings ARGS3( diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c index a4ad942e..18cc9044 100644 --- a/src/LYMainLoop.c +++ b/src/LYMainLoop.c @@ -168,6 +168,13 @@ PUBLIC BOOLEAN LYOpenTraceLog NOARGS fflush(stdout); fflush(stderr); fprintf(tfp, "\t\t%s (%s)\n\n", LYNX_TRACELOG_TITLE, LYNX_VERSION); + /* + * If TRACE is on, indicate whether the + * anonymous restrictions are set. - FM + */ + if (LYRestricted) { + CTRACE(tfp, "Anonymous restrictions are set.\n"); + } } return TRUE; } @@ -1586,7 +1593,60 @@ try_again: links[curdoc.link].form->name, links[curdoc.link].form->value); - if (c == '\n' || c == '\r') + if (c == '\n' || c == '\r') { +#ifdef AUTOGROW + /* + * If on the bottom line of a TEXTAREA, and the user hit + * the ENTER key, we add a new line/anchor automatically, + * positioning the cursor on it. + * + * If at the bottom of the screen, we effectively perform + * an LYK_DOWN_HALF-like operation, then move down to the + * new line we just added. --KED 02/14/99 + * + * [There is some redundancy and non-standard indentation + * in the monster-if() below. This is intentional ... to + * try and improve the "readability" (such as it is). + * Caveat emptor to anyone trying to change it.] + */ + if ((links[curdoc.link].type == WWW_FORM_LINK_TYPE && + links[curdoc.link].form->type == F_TEXTAREA_TYPE) + && + ((curdoc.link == nlinks-1) + || + ((curdoc.link < nlinks-1) && + !(links[curdoc.link+1].type == WWW_FORM_LINK_TYPE && + links[curdoc.link+1].form->type == F_TEXTAREA_TYPE)) + || + ((curdoc.link < nlinks-1) && + ((links[curdoc.link+1].type == WWW_FORM_LINK_TYPE && + links[curdoc.link+1].form->type == F_TEXTAREA_TYPE) + && + ((links[curdoc.link].form->number != + links[curdoc.link+1].form->number) || + (strcmp (links[curdoc.link].form->name, + links[curdoc.link+1].form->name) != 0)))))) { + + HText_ExpandTextarea (&links[curdoc.link], 1); + lines_in_file = HText_getNumOfLines(); + + if (links[curdoc.link].ly < display_lines) { + refresh_screen = TRUE; + + } else { + + Newline += (display_lines/2); + if (nlinks > 0 && curdoc.link > -1 && + links[curdoc.link].ly > display_lines/2) { + newdoc.link = curdoc.link; + for (i = 0; links[i].ly <= (display_lines/2); i++) + --newdoc.link; + newdoc.link++; + } + } + } +#endif /* AUTOGROW */ + #ifdef FASTTAB /* * Make return act like down-arrow. @@ -1598,6 +1658,7 @@ try_again: */ c = '\t'; #endif /* FASTTAB */ + } } else { /* * Get a keystroke from the user. @@ -1766,6 +1827,10 @@ new_cmd: /* int lindx = ((nlinks > 0) ? curdoc.link : 0); int number; + /* pass cur line num for use in follow_link_number() + * Note: Current line may not equal links[cur].line + */ + newdoc.line = curdoc.line; switch (follow_link_number(c, lindx, &newdoc, &number)) { case DO_LINK_STUFF: /* @@ -1784,8 +1849,7 @@ new_cmd: /* if (links[lindx].type == WWW_INTERN_LINK_TYPE) { LYinternal_flag = TRUE; newdoc.internal_link = TRUE; - if (0==strcmp((curdoc.title ? curdoc.title : ""), - LIST_PAGE_TITLE) && + if (LYIsListpageTitle(curdoc.title ? curdoc.title : "") && 0==strcmp(HTLoadedDocumentURL(), LYlist_temp_url())) { if (!curdoc.post_data || /* @@ -3153,9 +3217,8 @@ new_cmd: /* * for an internal link within the document the * List Page is about. - kw */ - if (0==strcmp(curdoc.address, LYlist_temp_url()) && - 0==strcmp((curdoc.title ? curdoc.title : ""), - LIST_PAGE_TITLE)) { + if ( 0==strcmp(curdoc.address, LYlist_temp_url()) && + (LIsListpageTitle(curdoc.title ? curdoc.title : ""))) { if (!curdoc.post_data || /* * Normal case - List Page is not associated @@ -4330,9 +4393,11 @@ if (!LYUseFormsOptions) { } break; } - +#ifdef AUTOEXTEDIT /* - * If we're in a forms TEXTAREA, invoke the editor on it. + * If we're in a forms TEXTAREA, invoke the editor on *its* + * contents, rather than attempting to edit the html source + * document. KED */ if (links[curdoc.link].type == WWW_FORM_LINK_TYPE && links[curdoc.link].form->type == F_TEXTAREA_TYPE) { @@ -4346,12 +4411,17 @@ if (!LYUseFormsOptions) { * document with the TEXT field is local, the editor *would* * be invoked on the source .html file; eg, the o(ptions) * form tempfile). + * + * [This is done to avoid possible user confusion, due to + * auto invocation of the editor on the TEXTAREA's contents + * via the above if() statement.] */ if (links[curdoc.link].type == WWW_FORM_LINK_TYPE && links[curdoc.link].form->type == F_TEXT_TYPE) { - HTUserMsg(CANNOT_EDIT_FIELD); - break; + HTUserMsg (CANNOT_EDIT_FIELD); + break; } +#endif /* AUTOEXTEDIT */ #ifdef DIRED_SUPPORT /* @@ -4530,11 +4600,11 @@ if (!LYUseFormsOptions) { /* * TODO: Move cursor "n" lines from the current line to - * position it on the 1st trailing blank line in - * the now edited TEXTAREA. If the target line/ - * anchor requires us to scroll up/down, position - * the target in the approximate center of the - * screen. + * position it on the 1st trailing blank line in + * the now edited TEXTAREA. If the target line/ + * anchor requires us to scroll up/down, position + * the target in the approximate center of the + * screen. */ /* curdoc.link += n;*/ /* works, except for page crossing, */ @@ -4550,6 +4620,56 @@ if (!LYUseFormsOptions) { } break; + case LYK_GROW_TEXTAREA: /* add new lines to bottom of TEXTAREA - KED */ + /* + * See if the current link is in a form TEXTAREA. + */ + if (links[curdoc.link].type == WWW_FORM_LINK_TYPE && + links[curdoc.link].form->type == F_TEXTAREA_TYPE) { + + HText_ExpandTextarea (&links[curdoc.link], TEXTAREA_EXPAND_SIZE); + + lines_in_file = HText_getNumOfLines(); + refresh_screen = TRUE; + + } else { + + HTInfoMsg (NOT_IN_TEXTAREA); + } + break; + + case LYK_INSERT_FILE: /* insert file in TEXTAREA, above cursor - KED */ + /* + * See if the current link is in a form TEXTAREA. + */ + if (links[curdoc.link].type == WWW_FORM_LINK_TYPE && + links[curdoc.link].form->type == F_TEXTAREA_TYPE) { + + n = HText_InsertFile (&links[curdoc.link]); + + lines_in_file = HText_getNumOfLines(); + + /* + * TODO: Move cursor "n" lines from the current line to + * position it on the 1st line following the text + * that was inserted. If the target line/anchor + * requires us to scroll up/down, position the + * target in the approximate center of the screen. + * + * [Current behavior leaves cursor on the same line relative + * to the start of the TEXTAREA that it was on before the + * insertion. This is the same behavior that occurs with + * (my) editor, so this TODO will stay unimplemented.] + */ + + refresh_screen = TRUE; + + } else { + + HTInfoMsg (NOT_IN_TEXTAREA); + } + break; + case LYK_PRINT: /* print the file */ if (LYValidate) { if (old_c != real_c) { @@ -4614,6 +4734,41 @@ if (!LYUseFormsOptions) { } break; +#ifdef EXP_ADDRLIST_PAGE + case LYK_ADDRLIST: /* always list URL's (only) */ + /* + * Don't do if already viewing list addresses page. + */ + if (!strcmp((curdoc.title ? curdoc.title : ""), + ADDRLIST_PAGE_TITLE)) { + /* + * Already viewing list page, so get out. + */ + cmd = LYK_PREV_DOC; + goto new_cmd; + } + + /* + * Print address list page to file. + */ + if (showlist(&newdoc, FALSE) < 0) + break; + StrAllocCopy(newdoc.title, ADDRLIST_PAGE_TITLE); + /* + * showlist will set newdoc's other fields. It may leave + * post_data intact so the list can be used to follow + * internal links in the current document even if it is + * a POST response. - kw + */ + + refresh_screen = TRUE; /* redisplay */ + if (LYValidate || check_realm) { + LYPermitURL = TRUE; + StrAllocCopy(lynxlistfile, newdoc.address); + } + break; +#endif /* EXP_ADDRLIST_PAGE */ + case LYK_VLINKS: /* list links visited during the current session */ if (!strcmp((curdoc.title ? curdoc.title : ""), VISITED_LINKS_TITLE)) { @@ -4862,8 +5017,7 @@ if (!LYUseFormsOptions) { if (nlinks > 0) { if (curdoc.post_data == NULL && curdoc.bookmark == NULL && - strcmp((curdoc.title ? curdoc.title : ""), - LIST_PAGE_TITLE) && + !LYIsListpageTitle(curdoc.title ? curdoc.title : "") && strcmp((curdoc.title ? curdoc.title : ""), VISITED_LINKS_TITLE)) { /* diff --git a/src/LYMainLoop.h b/src/LYMainLoop.h index 82480992..33dd0bd7 100644 --- a/src/LYMainLoop.h +++ b/src/LYMainLoop.h @@ -3,6 +3,10 @@ #include +#define TEXTAREA_EXPAND_SIZE 5 +#define AUTOGROW +#define AUTOEXTEDIT + extern BOOLEAN LYOpenTraceLog NOPARAMS; extern void LYCloseTracelog NOPARAMS; extern int mainloop NOPARAMS; diff --git a/src/LYPrint.c b/src/LYPrint.c index 3aa2a359..0bcdbe0c 100644 --- a/src/LYPrint.c +++ b/src/LYPrint.c @@ -166,11 +166,15 @@ PRIVATE void SetupFilename ARGS2( #define FN_DONE 2 #define FN_QUIT 3 -PRIVATE int RecallFilename ARGS4( +#define PRINT_FLAG 0 +#define GENERIC_FLAG 1 + +PRIVATE int RecallFilename ARGS5( char *, filename, BOOLEAN *, first, int *, now, - int *, total) + int *, total, + int, flag) { int ch; char *cp; @@ -255,9 +259,13 @@ PRIVATE int RecallFilename ARGS4( } /* - * Save cancelled. + * Operation cancelled. */ - HTInfoMsg(SAVE_REQUEST_CANCELLED); + if (flag == PRINT_FLAG) + HTInfoMsg(SAVE_REQUEST_CANCELLED); + else if (flag == GENERIC_FLAG) + return FN_QUIT; + return FN_QUIT; } return FN_DONE; @@ -280,7 +288,7 @@ PRIVATE BOOLEAN confirm_by_pages ARGS3( HTSprintf0(&msg, prompt, pages); _statusline(msg); - FREE(msg); + FREE(msg); c = LYgetch(); #ifdef VMS @@ -325,7 +333,8 @@ retry: strcpy(filename, buffer); } check_recall: - switch (RecallFilename(filename, &FirstRecall, &FnameNum, &FnameTotal)) { + switch (RecallFilename(filename, &FirstRecall, &FnameNum, + &FnameTotal, PRINT_FLAG)) { case FN_INIT: goto retry; case FN_READ: @@ -857,7 +866,8 @@ PRIVATE void send_file_to_printer ARGS4( again: SetupFilename(my_file, sug_filename); check_again: - switch (RecallFilename(my_file, &FirstRecall, &FnameNum, &FnameTotal)) { + switch (RecallFilename(my_file, &FirstRecall, &FnameNum, + &FnameTotal, PRINT_FLAG)) { case FN_INIT: goto again; case FN_READ: @@ -1323,3 +1333,124 @@ PUBLIC int print_options ARGS3( LYforce_no_cache = TRUE; return(0); } + + +/* + * General purpose filename getter. + * + * Returns a pointer to an absolute filename string, if the input + * filename exists, and is readable. Returns NULL if the input + * was cancelled (^G, or CR on empty input). + * + * The pointer to the filename string needs to be free()'d by the + * caller (when non-NULL). + * + * --KED 02/21/99 + */ +PUBLIC char * GetFileName NOARGS +{ + struct stat stat_info; + + FILE *fp; + + char fbuf[LY_MAXPATH]; + char tbuf[LY_MAXPATH]; + char *fn; + + BOOLEAN FirstRecall = TRUE; + int FnameNum = -1; + int FnameTotal; + + + _statusline(FILENAME_PROMPT); + +retry: + /* + * No initial filename. + */ + SetupFilename (fbuf, ""); + +check_recall: + /* + * Go get a filename (it would be nice to do TAB == filename-completion + * as the name is entered, but we'll save doing that for another time. + */ + switch (RecallFilename (fbuf, &FirstRecall, &FnameNum, + &FnameTotal, GENERIC_FLAG)) { + case FN_INIT: + goto retry; + case FN_READ: + goto check_recall; + case FN_QUIT: + goto quit; + default: + break; + } + + /* + * Add raw input form to list ... we may want to reuse/edit it on a + * subsequent call, etc. + */ +#ifdef VMS + if (0 == strncasecomp (fbuf, "sys$disk:", 9)) { + if (0 == strncmp ((fbuf+9), "[]", 2)) { + HTAddSugFilename (fbuf+11); + } else { + HTAddSugFilename (fbuf+9); + } + } else { + HTAddSugFilename (fbuf); + } +#else + HTAddSugFilename (fbuf); +#endif /* VMS */ + + /* + * Expand tilde's, make filename absolute, etc. + */ + if (!LYValidateFilename (tbuf, fbuf)) + goto quit; + + /* + * Check for file existence; readability. + */ + if ((stat (tbuf, &stat_info) < 0) || + (!(S_ISREG(stat_info.st_mode) || S_ISLNK(stat_info.st_mode)))) { + HTInfoMsg (FILE_DOES_NOT_EXIST); + _statusline(FILE_DOES_NOT_EXIST_RE); + FirstRecall = TRUE; + FnameNum = FnameTotal; + goto retry; + } + + if ((fp = fopen (tbuf, "r")) == NULL) { + HTInfoMsg (FILE_NOT_READABLE); + _statusline(FILE_NOT_READABLE_RE); + FirstRecall = TRUE; + FnameNum = FnameTotal; + goto retry; + } else { + fclose (fp); + } + + /* + * We have a valid filename, and readable file. Return it to the + * caller. + * + * The returned pointer should be free()'d by the caller. + * + * [For some silly reason, if we use StrAllocCopy() here, we get an + * "invalid pointer" reported in the Lynx.leaks file (if compiled + * with --enable-find-leaks turned on. Dumb.] + */ + if ((fn = (char *) calloc (1, (strlen (tbuf) + 1))) == NULL) + outofmem(__FILE__, "GetFileName"); + return (strcpy (fn, tbuf)); + + +quit: + /* + * The user cancelled the input (^G, or CR on empty input field). + */ + return (NULL); +} diff --git a/src/LYPrint.h b/src/LYPrint.h index 12efe47c..4ddd33a9 100644 --- a/src/LYPrint.h +++ b/src/LYPrint.h @@ -8,6 +8,7 @@ extern int printfile PARAMS((document *newdoc)); extern int print_options PARAMS((char **newfile, char **printed_url, int lines_in_file)); +extern char * GetFileName NOPARAMS; #endif /* LYPRINT_H */ diff --git a/src/LYReadCFG.c b/src/LYReadCFG.c index 88a04803..45976705 100644 --- a/src/LYReadCFG.c +++ b/src/LYReadCFG.c @@ -1040,7 +1040,7 @@ PUBLIC void free_lynx_cfg NOARGS case CONF_ENV: if (q->str_value != 0) { FREE(*(q->str_value)); - FREE((char *)q->str_value); + FREE(q->str_value); } break; default: diff --git a/src/LYStrings.c b/src/LYStrings.c index d74e2310..4c7ab032 100644 --- a/src/LYStrings.c +++ b/src/LYStrings.c @@ -1782,7 +1782,7 @@ PUBLIC void LYSetupEdit ARGS4( * up, we'll check it here, and ensure that no buffer overrun can * occur by loading only as much of the head as fits. - FM */ - if (strlen(old) >= maxstr) { + if (strlen(old) >= (unsigned)maxstr) { strncpy(edit->buffer, old, maxstr); edit->buffer[maxstr] = '\0'; StrLen = maxstr; diff --git a/src/LYUtils.c b/src/LYUtils.c index ecced083..706fbe1c 100644 --- a/src/LYUtils.c +++ b/src/LYUtils.c @@ -14,6 +14,7 @@ #include #include #include +#include #ifdef DJGPP_KEYHANDLER #include @@ -2188,6 +2189,11 @@ PUBLIC int HTCheckForInterrupt NOARGS else if (display_partial && (NumOfLines_partial > 2)) /* OK, we got several lines from new document and want to scroll... */ { + /* There is a subset of mainloop() actions available at this stage: + ** no new getfile() cyrcle possible until the previous finished. + ** Currently we have scrolling and toggling of trace log here. + */ + int res; switch (keymap[c+1]) { @@ -2252,6 +2258,11 @@ PUBLIC int HTCheckForInterrupt NOARGS break; case LYK_REFRESH : break ; + case LYK_TRACE_TOGGLE: /* Toggle TRACE mode. */ + WWW_TraceFlag = ! WWW_TraceFlag; + if (LYOpenTraceLog()) + HTUserMsg(WWW_TraceFlag ? TRACE_ON : TRACE_OFF); + break; default : return ((int)FALSE) ; } @@ -5457,7 +5468,7 @@ PUBLIC int putenv ARGS1( new_environ[size] = (char *) string; new_environ[size + 1] = NULL; if (last_environ != NULL) - FREE ((char *) last_environ); + FREE (last_environ); last_environ = new_environ; environ = new_environ; } @@ -5876,12 +5887,12 @@ PUBLIC void LYRemoveTemp ARGS1( } else { ly_temp = p->next; } + if (p->file != 0) + fclose(p->file); code = HTSYS_remove(name); CTRACE(tfp, "...LYRemoveTemp done(%d)%s\n", code, (p->file != 0) ? ", closed" : ""); CTRACE_FLUSH(tfp); - if (p->file != 0) - fclose(p->file); FREE(p->name); FREE(p); break; @@ -6111,7 +6122,7 @@ PUBLIC void BeginInternalPage ARGS3( { fprintf(fp0, "\n\n"); LYAddMETAcharsetToFD(fp0, -1); - if (!strcmp(Title, LIST_PAGE_TITLE)) { + if (LYIsListpageTitle(Title)) { if (strchr(HTLoadedDocumentURL(), '"') == NULL) { char *Address = NULL; /* diff --git a/src/LYUtils.h b/src/LYUtils.h index 6652e58c..87b8006f 100644 --- a/src/LYUtils.h +++ b/src/LYUtils.h @@ -39,6 +39,15 @@ #define LYIsPathSep(ch) ((ch) == '/') #endif +#ifdef EXP_ADDRLIST_PAGE +#define LYIsListpageTitle(name) \ + (!strcmp((name), LIST_PAGE_TITLE) || \ + !strcmp((name), ADDRLIST_PAGE_TITLE)) +#else +#define LYIsListpageTitle(name) \ + (!strcmp((name), LIST_PAGE_TITLE)) +#endif + #define LYIsHtmlSep(ch) ((ch) == '/') #define TABLESIZE(v) (sizeof(v)/sizeof(v[0])) diff --git a/src/LYrcFile.c b/src/LYrcFile.c index e0c1304c..aea6fa9c 100644 --- a/src/LYrcFile.c +++ b/src/LYrcFile.c @@ -897,11 +897,10 @@ PUBLIC int save_rc NOPARAMS fprintf(fp, gettext("\ # cookie_accept_domains and cookie_reject_domains are comma-delimited\n\ -# lists of domains (with a leading '.') to automatically accept or\n\ -# reject all cookies from. The accept_all_cookies parameter will\n\ -# override any settings made here. If a single domain is specified in\n\ -# both cookie_accept_domains and in cookie_reject_domains, the rejection\n\ -# will take precedence.\n")); +# lists of domains from which Lynx should automatically accept or reject\n\ +# all cookies. If a domain is specified in both options, rejection will\n\ +# take precedence. The accept_all_cookies parameter will override any\n\ +# settings made here.\n")); fprintf(fp, "cookie_accept_domains=%s\n", (LYCookieAcceptDomains == NULL ? "" : LYCookieAcceptDomains)); @@ -912,9 +911,12 @@ PUBLIC int save_rc NOPARAMS fprintf(fp, gettext("\ # cookie_loose_invalid_domains, cookie_strict_invalid_domains, and\n\ -# cookie_query_invalid_domains control checking incoming cookies'\n\ -# conformance to RFCNNNN.\n\ -# XXX FIXME\n")); +# cookie_query_invalid_domains are comma-delimited lists of which domains\n\ +# should be subjected to varying degrees of validity checking. If a\n\ +# domain is set to strict checking, strict conformance to RFC2109 will\n\ +# be applied. A domain with loose checking will be allowed to set cookies\n\ +# with an invalid path or domain attribute. All domains will default to\n\ +# querying the user for an invalid path or domain.\n")); fprintf(fp, "cookie_loose_invalid_domains=%s\n", (LYCookieLooseCheckDomains == NULL) ? "" : LYCookieLooseCheckDomains); diff --git a/src/UCAuto.c b/src/UCAuto.c index 5a976eb4..35775a2a 100644 --- a/src/UCAuto.c +++ b/src/UCAuto.c @@ -22,7 +22,6 @@ #include #include #include -#include #ifdef EXP_CHARTRANS_AUTOSWITCH diff --git a/src/UCAux.c b/src/UCAux.c index 3c952a33..bf4ab8b0 100644 --- a/src/UCAux.c +++ b/src/UCAux.c @@ -1,6 +1,7 @@ #include #include +#include #include #include #include @@ -17,13 +18,9 @@ PUBLIC BOOL UCCanUniTranslateFrom ARGS1( return NO; if (!strcmp(LYCharSet_UC[from].MIMEname, "x-transparent")) return NO; - if (from == LATIN1) { - if (LYCharSet_UC[from].codepoints & (UCT_CP_SUPERSETOF_LAT1)) - return YES; - } - /* others YES, but check for lost tables to be sure */ - return (LYCharSet_UC[from].UChndl >= 0); + /* others YES */ + return YES; } PUBLIC BOOL UCCanTranslateUniTo ARGS1( @@ -31,6 +28,11 @@ PUBLIC BOOL UCCanTranslateUniTo ARGS1( { if (to < 0) return NO; +/*??? + if (!strcmp(LYCharSet_UC[to].MIMEname, "x-transparent")) + return NO; +*/ + return YES; /* well at least some characters... */ } @@ -51,7 +53,7 @@ PUBLIC BOOL UCCanTranslateFromTo ARGS2( CONST char * toname = LYCharSet_UC[to].MIMEname; if (!strcmp(fromname, "x-transparent") || !strcmp(toname, "x-transparent")) { - return YES; + return YES; /* ??? */ } else if (!strcmp(fromname, "us-ascii")) { return YES; } @@ -80,7 +82,7 @@ PUBLIC BOOL UCCanTranslateFromTo ARGS2( return NO; } } - return (LYCharSet_UC[from].UChndl >= 0); + return YES; /* others YES */ } /* diff --git a/src/UCdomap.c b/src/UCdomap.c index b9f50f8b..809140f8 100644 --- a/src/UCdomap.c +++ b/src/UCdomap.c @@ -28,7 +28,7 @@ #include /* - * Include tables & parameters. + * Include chartrans tables: */ #include /* WinLatin2 (cp1250) */ #include /* WinCyrillic (cp1251) */ @@ -65,9 +65,9 @@ #include /* RFC 1345 Mnemonic */ #include /* NeXT character set */ #include /* RFC 1345 w/o Intro */ -#include /* UNICODE UTF 8 */ +/* #include */ /* UNICODE UTF 8 */ #include /* Vietnamese (VISCII) */ -#include /* Ukrainian Cyrillic (ISO 9945-2) */ +#include /* Ukrainian Cyrillic (ISO 9945-2) */ #include /* Ukrainian Cyrillic (866) */ #include /* Ukrainian Cyrillic (koi8-u */ #ifdef NOTDEFINED @@ -490,10 +490,11 @@ PRIVATE void UC_con_set_trans ARGS3( } /* * The font is always 256 characters - so far. + * (fake 0 for built-in charsets like CJK or x-transparent, use .num_n256) */ con_clear_unimap(); #endif - for (i = 0; i < 256; i++) { + for (i = 0; i < UCInfo[UC_charset_in_hndl].num_n256; i++) { if ((j = UCInfo[UC_charset_in_hndl].unicount[i])) { ptrans[i] = *p; for (; j; j--) { @@ -782,6 +783,12 @@ PUBLIC int UCLYhndl_HTFile_for_unrec = -1; PUBLIC int UCLYhndl_for_unspec = -1; PUBLIC int UCLYhndl_for_unrec = -1; + /* easy to type, will initialize later */ +PUBLIC int LATIN1 = -1; /* UCGetLYhndl_byMIME("iso-8859-1") */ +PUBLIC int US_ASCII = -1; /* UCGetLYhndl_byMIME("us-ascii") */ +PUBLIC int UTF8 = -1; /* UCGetLYhndl_byMIME("utf-8") */ + + PRIVATE int UC_con_set_unimap ARGS2( int, UC_charset_out_hndl, int, update_flag) @@ -803,10 +810,11 @@ PRIVATE int UC_con_set_unimap ARGS2( /* * The font is always 256 characters - so far. + * (fake 0 for built-in charsets like CJK or x-transparent, use .num_n256) */ con_clear_unimap(0); - for (i = 0; i < 256; i++) { + for (i = 0; i < UCInfo[UC_charset_out_hndl].num_n256; i++) { for (j = UCInfo[UC_charset_out_hndl].unicount[i]; j; j--) { con_insert_unipair(*(p++), i, 0); } @@ -1964,6 +1972,7 @@ PUBLIC void UC_Charset_Setup ARGS9( } UCInfo[s].LYNXname = UC_LYNXcharset; UCInfo[s].unicount = unicount; + UCInfo[s].num_n256 = (unicount == NULL) ? 0 : 256 ; /* hack */ UCInfo[s].unitable = unitable; UCInfo[s].num_uni = nnuni; UCInfo[s].replacedesc = replacedesc; @@ -2005,16 +2014,18 @@ PRIVATE void UCcleanup_mem NOARGS PUBLIC void UCInit NOARGS { + UCreset_allocated_LYCharSets(); atexit(UCcleanup_mem); UCconsole_map_init(); - UC_CHARSET_SETUP; /* us-ascii */ /* 7 bit approximations */ - /* * The order of charset names visible in Lynx Options menu * correspond to the order of lines below, - * except for CJK and others described in LYCharSet.c + * except the first two described in LYCharSet.c + * + * Entries whose comment is marked with *** are declared in UCdomap.h, + * others are based on the included tables - UCdomap.c, near the top. */ UC_CHARSET_SETUP_iso_8859_1; /* ISO Latin 1 */ @@ -2028,7 +2039,16 @@ PUBLIC void UCInit NOARGS UC_CHARSET_SETUP_next; /* NeXT character set */ UC_CHARSET_SETUP_hp_roman8; /* HP Roman8 */ + UC_CHARSET_SETUP_euc_cn; /*** Chinese */ + UC_CHARSET_SETUP_euc_jp; /*** Japanese (EUC_JP) */ + UC_CHARSET_SETUP_shift_jis; /*** Japanese (Shift_JIS) */ + UC_CHARSET_SETUP_euc_kr; /*** Korean */ + UC_CHARSET_SETUP_big5; /*** Taipei (Big5) */ + UC_CHARSET_SETUP_viscii; /* Vietnamese (VISCII) */ + UC_CHARSET_SETUP; /* us-ascii */ /* 7 bit approximations */ + + UC_CHARSET_SETUP_x_transparent; /*** Transparent */ UC_CHARSET_SETUP_iso_8859_2; /* ISO Latin 2 */ UC_CHARSET_SETUP_cp852; /* DosLatin2 (cp852) */ @@ -2054,7 +2074,7 @@ PUBLIC void UCInit NOARGS UC_CHARSET_SETUP_iso_8859_9; /* ISO 8859-9 (Latin 5) */ UC_CHARSET_SETUP_iso_8859_10; /* ISO 8859-10 */ - UC_CHARSET_SETUP_utf_8; /* UNICODE UTF-8 */ + UC_CHARSET_SETUP_utf_8; /*** UNICODE UTF-8 */ UC_CHARSET_SETUP_mnemonic_ascii_0; /* RFC 1345 w/o Intro */ UC_CHARSET_SETUP_mnemonic; /* RFC 1345 Mnemonic */ UC_CHARSET_SETUP_iso_9945_2; /* Ukrainian Cyrillic (ISO 9945-2) */ @@ -2068,6 +2088,11 @@ PUBLIC void UCInit NOARGS * To add synonyms for any charset name * check function UCGetLYhndl_byMIME in this file. */ + +/* easy to type: */ + LATIN1 = UCGetLYhndl_byMIME("iso-8859-1"); + US_ASCII = UCGetLYhndl_byMIME("us-ascii"); + UTF8 = UCGetLYhndl_byMIME("utf-8"); } /* diff --git a/src/UCdomap.h b/src/UCdomap.h index 16541353..f4170c59 100644 --- a/src/UCdomap.h +++ b/src/UCdomap.h @@ -41,6 +41,7 @@ struct UC_charset { CONST char *MIMEname; CONST char *LYNXname; CONST u8* unicount; + int num_n256; /* 256 for *.tbl, 0 for CJK and x-transparent (hack) */ CONST u16* unitable; int num_uni; struct unimapdesc_str replacedesc; @@ -56,4 +57,51 @@ extern int UCNumCharsets; extern void UCInit NOARGS; + +/* + * INSTRUCTIONS for adding new character sets which do not have + * Unicode tables. + * + * Several #defines below are declarations for charsets which need no + * tables for mapping to Unicode - CJK multibytes, x-transparent, UTF8 - + * Lynx care of them internally. + * + * The declaration's format is kept in chrtrans/XXX_uni.h - + * keep this in mind when changing ucmaketbl.c, + * see also UC_Charset_Setup() above for details. + */ + + /* + * There is no strict correlation for the next five, since the transfer + * charset gets decoded into Display Char Set by the CJK code (separate + * from Unicode mechanism). For now we use the MIME name that describes + * what is output to the terminal. - KW + */ +#define UC_CHARSET_SETUP_euc_cn UC_Charset_Setup("euc-cn","Chinese",\ + NULL,NULL,0,(struct unimapdesc_str){0,NULL,0,1},\ + 128,UCT_ENC_CJK,0) +#define UC_CHARSET_SETUP_euc_jp UC_Charset_Setup("euc-jp","Japanese (EUC-JP)",\ + NULL,NULL,0,(struct unimapdesc_str){0,NULL,0,1},\ + 128,UCT_ENC_CJK,0) +#define UC_CHARSET_SETUP_shift_jis UC_Charset_Setup("shift_jis","Japanese (Shift_JIS)",\ + NULL,NULL,0,(struct unimapdesc_str){0,NULL,0,1},\ + 128,UCT_ENC_CJK,0) +#define UC_CHARSET_SETUP_euc_kr UC_Charset_Setup("euc-kr","Korean",\ + NULL,NULL,0,(struct unimapdesc_str){0,NULL,0,1},\ + 128,UCT_ENC_CJK,0) +#define UC_CHARSET_SETUP_big5 UC_Charset_Setup("big5","Taipei (Big5)",\ + NULL,NULL,0,(struct unimapdesc_str){0,NULL,0,1},\ + 128,UCT_ENC_CJK,0) + /* + * Placeholder for non-translation mode. - FM + */ +#define UC_CHARSET_SETUP_x_transparent UC_Charset_Setup("x-transparent","Transparent",\ + NULL,NULL,0,(struct unimapdesc_str){0,NULL,0,0},\ + 128,1,0) + +#define UC_CHARSET_SETUP_utf_8 UC_Charset_Setup("utf-8","UNICODE (UTF-8)",\ + NULL,NULL,0,(struct unimapdesc_str){0,NULL,0,0},\ + 128,UCT_ENC_UTF8,0) + + #endif /* UCDOMAP_H */ diff --git a/src/chrtrans/MAKEW32.BAT b/src/chrtrans/MAKEW32.BAT index 4fe285f4..9c3b0a83 100644 --- a/src/chrtrans/MAKEW32.BAT +++ b/src/chrtrans/MAKEW32.BAT @@ -33,7 +33,7 @@ makeuctb iso08_uni.tbl > iso08_uni.h makeuctb iso09_uni.tbl > iso09_uni.h makeuctb iso10_uni.tbl > iso10_uni.h makeuctb iso15_uni.tbl > iso15_uni.h -makeuctb iso9945_uni.tbl > iso9945_uni.h +makeuctb iso9945uni.tbl > iso9945_uni.h makeuctb koi8r_uni.tbl > koi8r_uni.h makeuctb koi8u_uni.tbl > koi8u_uni.h makeuctb mac_uni.tbl > mac_uni.h diff --git a/src/chrtrans/build-chrtrans.com b/src/chrtrans/build-chrtrans.com index df565522..71d6255a 100644 --- a/src/chrtrans/build-chrtrans.com +++ b/src/chrtrans/build-chrtrans.com @@ -140,8 +140,8 @@ $ define/user sys$output 'CHRwhere'iso08_uni.h !ISO 8859-8 Hebrew $ makeuctb iso08_uni.tbl $ define/user sys$output 'CHRwhere'cp862_uni.h !DosHebrew (cp862) $ makeuctb cp862_uni.tbl -$ define/user sys$output 'CHRwhere'iso9945_uni.h !Ukranian -$ makeuctb iso9945_uni.tbl +$ define/user sys$output 'CHRwhere'iso9945uni.h !Ukranian +$ makeuctb iso9945uni.tbl $ define/user sys$output 'CHRwhere'cp1255_uni.h !WinHebrew (cp1255) $ makeuctb cp1255_uni.tbl $ define/user sys$output 'CHRwhere'iso09_uni.h !ISO 8859-9 (Latin 5) diff --git a/src/chrtrans/def7_uni.tbl b/src/chrtrans/def7_uni.tbl index bd6b1b1c..d3549285 100644 --- a/src/chrtrans/def7_uni.tbl +++ b/src/chrtrans/def7_uni.tbl @@ -1,9 +1,12 @@ # Default 7bit replacements. If the MIME name is set to us-ascii, -# this will be identified with the "7 bit approximations" Display +# this will be identified with the "7 bit approximations (US-ASCII)" Display # character set. #The MIME name of this charset. Mus-ascii + +#Name as a Display Charset (used on Options screen) +O7 bit approximations (US-ASCII) # Shall this become the "default" translation table? YES! # There has to be exactly one table marked as "default". diff --git a/src/chrtrans/makefile.dos b/src/chrtrans/makefile.dos index bc665212..5219081d 100644 --- a/src/chrtrans/makefile.dos +++ b/src/chrtrans/makefile.dos @@ -58,7 +58,7 @@ TABLES= \ iso09_uni.h \ iso10_uni.h \ iso15_uni.h \ - iso9945_uni.h \ + iso9945uni.h \ koi8r_uni.h \ koi8u_uni.h \ mac_uni.h \ @@ -111,7 +111,7 @@ iso08_uni.h: iso08_uni.tbl makeuctb.exe iso09_uni.h: iso09_uni.tbl makeuctb.exe iso10_uni.h: iso10_uni.tbl makeuctb.exe iso15_uni.h: iso15_uni.tbl makeuctb.exe -iso9945_uni.h: iso9945_uni.tbl makeuctb.exe +iso9945uni.h: iso9945uni.tbl makeuctb.exe koi8r_uni.h: koi8r_uni.tbl makeuctb.exe koi8u_uni.h: koi8u_uni.tbl makeuctb.exe mac_uni.h: mac_uni.tbl makeuctb.exe diff --git a/src/chrtrans/makefile.in b/src/chrtrans/makefile.in index dbcf4782..45c06a80 100644 --- a/src/chrtrans/makefile.in +++ b/src/chrtrans/makefile.in @@ -77,7 +77,7 @@ TABLES= \ iso09_uni.h \ iso10_uni.h \ iso15_uni.h \ - iso9945_uni.h \ + iso9945uni.h \ koi8r_uni.h \ koi8u_uni.h \ mac_uni.h \ @@ -143,7 +143,7 @@ iso08_uni.h: $(srcdir)/iso08_uni.tbl makeuctb$x iso09_uni.h: $(srcdir)/iso09_uni.tbl makeuctb$x iso10_uni.h: $(srcdir)/iso10_uni.tbl makeuctb$x iso15_uni.h: $(srcdir)/iso15_uni.tbl makeuctb$x -iso9945_uni.h: $(srcdir)/iso9945_uni.tbl makeuctb$x +iso9945uni.h: $(srcdir)/iso9945uni.tbl makeuctb$x koi8r_uni.h: $(srcdir)/koi8r_uni.tbl makeuctb$x koi8u_uni.h: $(srcdir)/koi8u_uni.tbl makeuctb$x mac_uni.h: $(srcdir)/mac_uni.tbl makeuctb$x diff --git a/src/structdump.h b/src/structdump.h index 42b9a07d..90b4a807 100644 --- a/src/structdump.h +++ b/src/structdump.h @@ -8,6 +8,7 @@ /* usage: DUMPSTRUCT_LINK(link_ptr, "message"); */ #define DUMPSTRUCT_LINK(L,X) \ +if ((L)) { \ CTRACE(tfp, "\n" \ "KED: link_ptr=0x%08x sizeof=%d ["X"]\n" \ "link struct {\n" \ @@ -33,11 +34,16 @@ CTRACE(tfp, "\n" \ (L)->hightext, (L)->hightext, (L)->hightext2, (L)->hightext2, \ (L)->hightext2_offset, (L)->inUnderline, (L)->lx, (L)->ly, \ (L)->type, (L)->anchor_number, (L)->anchor_line_num, (L)->form); \ +}else{ \ +CTRACE(tfp, "\n" \ + "KED: link_ptr=0x00000000 (NULL) ["X"]\n"); \ +} \ CTRACE_FLUSH(tfp); /* usage: DUMPSTRUCT_ANCHOR(anchor_ptr, "message"); */ #define DUMPSTRUCT_ANCHOR(A,X) \ +if ((A)) { \ CTRACE(tfp, "\n" \ "KED: anchor_ptr=0x%08x sizeof=%d ["X"]\n" \ "TextAnchor struct {\n" \ @@ -67,11 +73,16 @@ CTRACE(tfp, "\n" \ (A)->hightext2offset, (A)->link_type, \ (A)->input_field, (A)->input_field, (A)->show_anchor, \ (A)->inUnderline, (A)->expansion_anch, (A)->anchor); \ +}else{ \ +CTRACE(tfp, "\n" \ + "KED: anchor_ptr=0x00000000 (NULL) ["X"]\n"); \ +} \ CTRACE_FLUSH(tfp); /* usage: DUMPSTRUCT_FORM(forminfo_ptr, "message"); */ #define DUMPSTRUCT_FORMINFO(F,X) \ +if ((F)) { \ CTRACE(tfp, "\n" \ "KED: forminfo_ptr=0x%08x sizeof=%d ["X"]\n" \ "FormInfo struct {\n" \ @@ -112,11 +123,16 @@ CTRACE(tfp, "\n" \ (F)->no_cache, (F)->cp_submit_value, (F)->orig_submit_value, \ (F)->size_l, (F)->disabled, (F)->name_cs, (F)->value_cs, \ (F)->accept_cs); \ +}else{ \ +CTRACE(tfp, "\n" \ + "KED: forminfo_ptr=0x00000000 (NULL) ["X"]\n"); \ +} \ CTRACE_FLUSH(tfp); /* usage: DUMPSTRUCT_LINE(htline_ptr, "message"); */ #define DUMPSTRUCT_LINE(L,X) \ +if ((L)) { \ CTRACE(tfp, "\n" \ "KED: htline_ptr=0x%08x sizeof=%d ["X"]\n" \ "HTLine struct {\n" \ @@ -134,6 +150,10 @@ CTRACE(tfp, "\n" \ (L), sizeof(*((L))), \ (L)->next, (L)->prev, (L)->offset, (L)->size, (L)->split_after, \ (L)->bullet, (L)->expansion_line, (L)->data, (L)->data); \ +}else{ \ +CTRACE(tfp, "\n" \ + "KED: htline_ptr=0x00000000 (NULL) ["X"]\n"); \ +} \ CTRACE_FLUSH(tfp); #endif /* STRUCTDUMP_H */ -- cgit