From ab1d1ae525ff4bed44e3ca2030fa655ad7c5bc7d Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Thu, 26 Aug 1999 13:39:32 -0400 Subject: snapshot of project "lynx", label v2-8-3dev_7 --- src/GridText.c | 109 ++++++++++++++++----------- src/HTAlert.c | 6 +- src/HTAlert.h | 2 +- src/HTFWriter.c | 6 +- src/HTML.c | 15 ++-- src/LYCharSets.c | 69 ++++++++++++++--- src/LYCharSets.h | 43 ++++++++++- src/LYCharUtils.c | 45 +++++++---- src/LYCookie.c | 4 +- src/LYCurses.c | 30 +++++++- src/LYCurses.h | 4 +- src/LYEdit.c | 5 +- src/LYEditmap.c | 12 +-- src/LYExtern.c | 14 ++-- src/LYForms.c | 4 +- src/LYGetFile.c | 8 +- src/LYGetFile.h | 2 +- src/LYGlobalDefs.h | 4 +- src/LYKeymap.c | 78 ++++++++++--------- src/LYMail.c | 2 +- src/LYMain.c | 112 +++++++++++++++++++--------- src/LYMainLoop.c | 67 +++++++---------- src/LYOptions.c | 194 +++++++++++++++++++++++++++++------------------- src/LYOptions.h | 8 +- src/LYPrettySrc.c | 3 +- src/LYPrettySrc.h | 3 + src/LYPrint.c | 6 +- src/LYReadCFG.c | 110 +++++++++++++++++++++++++-- src/LYSearch.c | 14 ++-- src/LYShowInfo.c | 2 +- src/LYStrings.c | 21 ++++-- src/LYStyle.c | 14 ++-- src/LYTraversal.c | 4 +- src/LYUtils.c | 51 +++++++------ src/LYrcFile.c | 2 +- src/UCAux.c | 30 ++++---- src/UCdomap.c | 152 ++++++++++++++++++++++++++++++++----- src/UCdomap.h | 40 ++++------ src/Xsystem.c | 24 +++--- src/chrtrans/makeuctb.c | 2 +- 40 files changed, 874 insertions(+), 447 deletions(-) (limited to 'src') diff --git a/src/GridText.c b/src/GridText.c index 1d4092a1..456b850c 100644 --- a/src/GridText.c +++ b/src/GridText.c @@ -647,7 +647,13 @@ PUBLIC HText * HText_new ARGS1( else self->source = NO; #else - self->source=( LYpsrc ? psrc_view : HTOutputFormat == WWW_SOURCE); + /* mark_htext_as_source == TRUE if we are parsing html file (and psrc_view is + * set temporary to false at creation time) + * psrc_view == TRUE if source of the text produced by some lynx module + * (like ftp browsers) is requested). - VH + */ + self->source = (BOOL) (LYpsrc ? mark_htext_as_source || psrc_view : HTOutputFormat == WWW_SOURCE); + mark_htext_as_source = FALSE; #endif HTAnchor_setDocument(anchor, (HyperDoc *)self); HTFormNumber = 0; /* no forms started yet */ @@ -1202,7 +1208,7 @@ PRIVATE void display_title ARGS1( } move(0, 0); clrtoeol(); -#ifdef CJK_EX +#if defined(CJK_EX) && defined(SH_EX) addstr(str_kcode(last_kcode)); #endif if (text->top_of_screen > 0 && HText_hasToolbar(text)) { @@ -2248,6 +2254,11 @@ PRIVATE void split_line ARGS2( (previous->data[previous->size-1] == HT_NON_BREAK_SPACE)) && #else (previous->data[previous->size-1] == ' ') && +#endif +#ifdef USE_PSRC + !psrc_view && /*don't strip trailing whites - since next line can + start with LY_SOFT_NEWLINE - so we don't lose spaces when + 'p'rinting this text to file -VH */ #endif (ctrl_chars_on_this_line || HeadTrim || text->first_anchor || underline_on || bold_on || @@ -2856,10 +2867,9 @@ PRIVATE void split_line ARGS2( * be text->Lines-3 */ a2->extent += spare; - else { + else if (onp2sz < a2->extent) a2->extent += justified_text_map[onp1sz-1] - onp1sz + 1; - } } } @@ -2877,6 +2887,12 @@ PRIVATE void split_line ARGS2( } else { /* (ht_num_runs==1) */ /* keep maintaining 'last_anchor_of_previous_line' */ TextAnchor* a2 = last_anchor_of_previous_line; + if (justify_start_position) { + char* p = previous->data; + for( ; p < previous->data + justify_start_position; ++p) + *p = (*p == HT_NON_BREAK_SPACE ? ' ' : *p); + } + if (!a2) a2 = text->first_anchor; else if (a2 == text->last_anchor) @@ -2920,20 +2936,6 @@ PRIVATE void split_line ARGS2( /* else HT_NON_BREAK_SPACEs were substituted with spaces in HText_appendCharacter */ - { - /* keep maintaining 'last_anchor_of_previous_line' */ - TextAnchor* a2 = last_anchor_of_previous_line; - if (!a2) - a2 = text->first_anchor; - else if (a2 == text->last_anchor) - a2 = NULL; - else - a2 = a2->next; /*1st anchor on line we justify */ - - if (a2) - for (; a2 && a2->line_num <= text->Lines-1; - last_anchor_of_previous_line = a2, a2 = a2->next); - } } /* cleanup */ can_justify_this_line = TRUE; @@ -3501,7 +3503,7 @@ PUBLIC void HText_appendCharacter ARGS2( * If we're displaying document source, wrap long lines to keep all of * the source visible. */ - int target = (int)(line->offset + line->size); + int target = (int)(line->offset + line->size) - ctrl_chars_on_this_line; if ((target >= (LYcols-1) - style->rightIndent) && HTisDocumentSource()) { new_line(text); @@ -3592,7 +3594,7 @@ check_IgnoreExcess: ch = ' '; #ifdef EXP_JUSTIFY_ELTS else - have_raw_nbsps = TRUE; + have_raw_nbsps = TRUE; #endif /* we leave raw HT_NON_BREAK_SPACE otherwise (we'll substitute it later) */ @@ -3710,13 +3712,14 @@ check_IgnoreExcess: } #endif else if (HTCJK != NOCJK) { - line->data[line->size++] = (kanji_code != NOKANJI) ? + line->data[line->size++] = (char) ( + (kanji_code != NOKANJI) ? ch : (font & HT_CAPITALS) ? - TOUPPER(ch) : ch; + TOUPPER(ch) : ch); } else { line->data[line->size++] = /* Put character into line */ - font & HT_CAPITALS ? TOUPPER(ch) : ch; + (char) (font & HT_CAPITALS ? TOUPPER(ch) : ch); } line->data[line->size] = '\0'; if (font & HT_DOUBLE) /* Do again if doubled */ @@ -3850,6 +3853,9 @@ PUBLIC int HText_beginAnchor ARGS3( * If we are doing link_numbering add the link number. */ if ((a->number > 0) && +#ifdef USE_PSRC + (text->source ? !psrcview_no_anchor_numbering : 1 ) && +#endif (keypad_mode == LINKS_ARE_NUMBERED || keypad_mode == LINKS_AND_FIELDS_ARE_NUMBERED)) { char saved_lastchar = text->LastChar; @@ -3917,14 +3923,14 @@ PUBLIC void HText_endAnchor ARGS2( * If it goes somewhere... */ int i, j, k, l; - BOOL remove_numbers_on_empty = + BOOL remove_numbers_on_empty = (BOOL) ( ((keypad_mode == LINKS_ARE_NUMBERED || keypad_mode == LINKS_AND_FIELDS_ARE_NUMBERED) && (text->hiddenlinkflag != HIDDENLINKS_MERGE || (LYNoISMAPifUSEMAP && !(text->node_anchor && text->node_anchor->bookmark) && HTAnchor_isISMAPScript( - HTAnchor_followMainLink((HTAnchor *)a->anchor))))); + HTAnchor_followMainLink((HTAnchor *)a->anchor)))))); HTLine *last = text->last_line; HTLine *prev = text->last_line->prev; HTLine *start = last; @@ -4350,21 +4356,24 @@ PUBLIC void HText_appendText ARGS2( } -PRIVATE void remove_special_attr_chars ARGS1( +PRIVATE int remove_special_attr_chars ARGS1( char *, buf) { register char *cp; + register int soft_newline_count = 0; for (cp = buf; *cp != '\0' ; cp++) { /* * Don't print underline chars. */ + soft_newline_count += (*cp == LY_SOFT_NEWLINE); if (!IsSpecialAttrChar(*cp)) { *buf = *cp, buf++; } } *buf = '\0'; + return soft_newline_count; } @@ -4486,6 +4495,7 @@ PUBLIC void HText_trimHightext ARGS2( for (anchor_ptr = text->first_anchor; anchor_ptr; prev_a = anchor_ptr, anchor_ptr=anchor_ptr->next) { + int have_soft_newline_in_1st_line=0; re_parse: /* * Find the right line. @@ -4618,7 +4628,10 @@ re_parse: (anchor_ptr->extent - strlen(anchor_ptr->hightext))); anchor_ptr->hightext2offset = line_ptr2->offset; - remove_special_attr_chars(anchor_ptr->hightext2); + /*handle LY_SOFT_NEWLINEs -VH */ + anchor_ptr->hightext2offset += + remove_special_attr_chars(anchor_ptr->hightext2); + if (anchor_ptr->link_type & HYPERTEXT_ANCHOR) { LYTrimTrailing(anchor_ptr->hightext2); if (anchor_ptr->hightext2[0] == '\0') { @@ -4639,10 +4652,13 @@ re_parse: */ if (anchor_ptr->line_pos > 0) { register int offset = 0, i = 0; - for (; i < anchor_ptr->line_pos; i++) + for (; i < anchor_ptr->line_pos; i++) { if (IS_UTF_EXTRA(line_ptr->data[i]) || - IsSpecialAttrChar(line_ptr->data[i])) + IsSpecialAttrChar(line_ptr->data[i])) { offset++; + have_soft_newline_in_1st_line += (line_ptr->data[i] == LY_SOFT_NEWLINE); + } + } anchor_ptr->line_pos -= offset; } @@ -4652,6 +4668,9 @@ re_parse: anchor_ptr->line_pos += line_ptr->offset; anchor_ptr->line_num = cur_line; + /*handle LY_SOFT_NEWLINEs -VH */ + anchor_ptr->line_pos += have_soft_newline_in_1st_line; + CTRACE(tfp, "GridText: add link on line %d col %d [%d] %s\n", cur_line, anchor_ptr->line_pos, anchor_ptr->number, "in HText_trimHightext"); @@ -5049,7 +5068,7 @@ PRIVATE BOOLEAN same_anchor_or_field ARGS5( return(NO); if (!formA->name || !formB->name) return(YES); - return(strcmp(formA->name, formB->name) == 0); + return (BOOL) (strcmp(formA->name, formB->name) == 0); } #define same_anchor_as_link(i,a) (i >= 0 && a &&\ @@ -5524,9 +5543,9 @@ PUBLIC void HTCheckFnameForCompression ARGS3( *cp = '.'; #endif /* VMS */ cp++; - *cp = TOLOWER(*cp); + *cp = (char) TOLOWER(*cp); cp++; - *cp = TOLOWER(*cp); + *cp = (char) TOLOWER(*cp); } return; } @@ -5554,7 +5573,7 @@ PUBLIC void HTCheckFnameForCompression ARGS3( *cp = '.'; #endif /* VMS */ cp++; - *cp = TOUPPER(*cp); + *cp = (char) TOUPPER(*cp); } return; } @@ -5730,15 +5749,15 @@ PUBLIC int HText_sourceAnchors ARGS1( PUBLIC BOOL HText_canScrollUp ARGS1( HText *, text) { - return (text->top_of_screen != 0); + return (BOOL) (text->top_of_screen != 0); } PUBLIC BOOL HText_canScrollDown NOARGS { HText * text = HTMainText; - return (text != 0) - && ((text->top_of_screen + display_lines) < text->Lines+1); + return (BOOL) ((text != 0) + && ((text->top_of_screen + display_lines) < text->Lines+1)); } /* Scroll actions @@ -6321,7 +6340,7 @@ PUBLIC void print_wwwfile_to_fd ARGS2( #ifndef NO_DUMP_WITH_BACKSPACES HText* text = HTMainText; BOOL in_b=FALSE,in_u=FALSE, - bs=text && with_backspaces && HTCJK==NOCJK && !text->T.output_utf8; + bs=(BOOL)(text && with_backspaces && HTCJK==NOCJK && !text->T.output_utf8); #endif if (!HTMainText) @@ -6439,7 +6458,7 @@ PUBLIC void print_crawl_to_fd ARGS3( #ifndef NO_DUMP_WITH_BACKSPACES HText* text = HTMainText; BOOL in_b=FALSE,in_u=FALSE, - bs=text && with_backspaces && HTCJK==NOCJK && !text->T.output_utf8; + bs=(BOOL)(text && with_backspaces && HTCJK==NOCJK && !text->T.output_utf8); #endif @@ -6538,7 +6557,7 @@ PRIVATE void adjust_search_result ARGS3( int nl_closest = -1; int goal = SEARCH_GOAL_LINE; int max_offset; - BOOL on_screen = (tentative_result > HTMainText->top_of_screen && + BOOL on_screen = (BOOL) (tentative_result > HTMainText->top_of_screen && tentative_result <= HTMainText->top_of_screen+display_lines); if (goal < 1) goal = 1; @@ -7017,7 +7036,7 @@ PUBLIC BOOLEAN HTreparse_document NOARGS ret = HTParseFile(format, HTOutputFormat, HTMainAnchor, fp, NULL); fclose(fp); - ok = (ret == HT_LOADED); + ok = (BOOL) (ret == HT_LOADED); } if (LYCacheSource == SOURCE_CACHE_MEMORY && @@ -7060,7 +7079,7 @@ PUBLIC BOOLEAN HTreparse_document NOARGS } ret = HTParseMem(format, HTOutputFormat, HTMainAnchor, HTMainAnchor->source_cache_chunk, NULL); - ok = (ret == HT_LOADED); + ok = (BOOL) (ret == HT_LOADED); } CTRACE(tfp, "Reparse %s\n", (ok ? "succeeded" : "failed")); @@ -9988,7 +10007,7 @@ PUBLIC void HText_setToolbar ARGS1( PUBLIC BOOL HText_hasToolbar ARGS1( HText *, text) { - return ((text && text->toolbar) ? TRUE : FALSE); + return (BOOL) ((text && text->toolbar) ? TRUE : FALSE); } PUBLIC void HText_setNoCache ARGS1( @@ -10002,13 +10021,13 @@ PUBLIC void HText_setNoCache ARGS1( PUBLIC BOOL HText_hasNoCacheSet ARGS1( HText *, text) { - return ((text && text->no_cache) ? TRUE : FALSE); + return (BOOL) ((text && text->no_cache) ? TRUE : FALSE); } PUBLIC BOOL HText_hasUTF8OutputSet ARGS1( HText *, text) { - return ((text && text->T.output_utf8) ? TRUE : FALSE); + return (BOOL) ((text && text->T.output_utf8) ? TRUE : FALSE); } /* @@ -10311,7 +10330,7 @@ PRIVATE void cleanup_line_for_textarea ARGS2( (((unsigned char)*s > (unsigned char)'\177') && ((unsigned char)*s < (unsigned char)LYlowest_eightbit[current_char_set]))) - ? SPLAT : *s; + ? (char) SPLAT : *s; #else *p = ((unsigned char)*s < (unsigned char)' ') ? SPLAT : *s; #endif diff --git a/src/HTAlert.c b/src/HTAlert.c index 908e52c5..b9f8e746 100644 --- a/src/HTAlert.c +++ b/src/HTAlert.c @@ -263,7 +263,7 @@ PUBLIC void HTReadProgress ARGS2( if (t_rate < 1000) sprintf (line + n, " %6d bytes/sec.", t_rate); else - sprintf (line + n, " %6d,%03d bytes/sec.", + sprintf (line + n, " %6d,%03d bytes/sec.", t_rate / 1000, t_rate % 1000); } } @@ -438,7 +438,7 @@ PUBLIC BOOL HTLastConfirmCancelled NOARGS /* Seek confirmation with default answer. HTConfirmDefault() ** -------------------------------------- */ -PUBLIC BOOL HTConfirmDefault ARGS2(CONST char *, Msg, int, Dft) +PUBLIC int HTConfirmDefault ARGS2(CONST char *, Msg, int, Dft) { char *msg_yes = gettext("yes"); char *msg_no = gettext("no"); @@ -498,7 +498,7 @@ PUBLIC BOOL HTConfirmDefault ARGS2(CONST char *, Msg, int, Dft) */ PUBLIC BOOL HTConfirm ARGS1(CONST char *, Msg) { - return HTConfirmDefault(Msg, DFT_CONFIRM); + return (BOOL) HTConfirmDefault(Msg, DFT_CONFIRM); } /* Prompt for answer and get text back. HTPrompt() diff --git a/src/HTAlert.h b/src/HTAlert.h index b2cc1508..ef3b9a3a 100644 --- a/src/HTAlert.h +++ b/src/HTAlert.h @@ -62,7 +62,7 @@ extern BOOL HTLastConfirmCancelled NOPARAMS; ** If the user enters 'YES', returns TRUE, returns FALSE ** otherwise. */ -extern BOOL HTConfirmDefault PARAMS ((CONST char * Msg, int Dft)); +extern int HTConfirmDefault PARAMS ((CONST char * Msg, int Dft)); /* Display a message, then wait for 'yes' or 'no'. diff --git a/src/HTFWriter.c b/src/HTFWriter.c index 14edbb2a..7252b4d2 100644 --- a/src/HTFWriter.c +++ b/src/HTFWriter.c @@ -13,7 +13,7 @@ #include #include -#if WIN_EX +#ifdef WIN_EX #include #endif @@ -165,7 +165,7 @@ PRIVATE void HTFWriter_free ARGS1(HTStream *, me) * a temporary file for uncompression. - FM */ if (me->anchor->FileCache != NULL) { - BOOL skip_loadfile = (me->viewer_command != NULL); + BOOL skip_loadfile = (BOOL) (me->viewer_command != NULL); /* * Save the path with the "gz" or "Z" suffix trimmed, * and remove any previous uncompressed copy. - FM @@ -598,7 +598,7 @@ PUBLIC HTStream* HTSaveAndExecute ARGS3( cp++; } if (strchr(view_fname, ' ')) - view_fname = quote_pathname(view_fname); + view_fname = (unsigned char *) quote_pathname(view_fname); StrAllocCopy(me->viewer_command, pres->command); diff --git a/src/HTML.c b/src/HTML.c index d6c0370a..7c19502d 100644 --- a/src/HTML.c +++ b/src/HTML.c @@ -156,7 +156,7 @@ extern int hash_code PARAMS((char* i)); PUBLIC void strtolower ARGS1(char*, i) { if (!i) return; - while (*i) { *i=tolower(*i); i++; } + while (*i) { *i=(char)tolower(*i); i++; } } /* Flattening the style structure @@ -845,7 +845,7 @@ PRIVATE void HTML_start_element ARGS6( if (value[i]) { char q='"'; /*0 in dquotes, 1 - in quotes, 2 mixed*/ - char kind= ( !strchr(value[i], '"') ? + char kind= (char) ( !strchr(value[i], '"') ? 0 : !strchr(value[i], '\'') ? q='\'',1 : @@ -1795,7 +1795,7 @@ PRIVATE void HTML_start_element ARGS6( me->sp[0].tag_number == HTML_DD) me->current_default_alignment = HT_LEFT; LYHandlePlike(me, present, value, include, HTML_DIV_ALIGN, TRUE); - me->DivisionAlignments[me->Division_Level] = + me->DivisionAlignments[me->Division_Level] = (short) me->current_default_alignment; } else if (present && present[HTML_DIV_ALIGN] && value[HTML_DIV_ALIGN] && *value[HTML_DIV_ALIGN]) { @@ -4927,7 +4927,8 @@ PRIVATE void HTML_start_element ARGS6( ATTR_CS_IN, I.value_cs, (me->UsePlainSpace && !me->HiddenValue), - me->UsePlainSpace, me->HiddenValue); + me->UsePlainSpace, + me->HiddenValue); I.value = I_value; if (me->UsePlainSpace == TRUE) { /* @@ -5580,7 +5581,7 @@ PRIVATE void HTML_start_element ARGS6( !strcmp(me->sp->style->name, "Preformatted")))) { me->sp->style->alignment = HT_LEFT; } else { - me->sp->style->alignment = me->current_default_alignment; + me->sp->style->alignment = (short) me->current_default_alignment; } if (present && present[HTML_TR_ALIGN] && value[HTML_TR_ALIGN]) { #ifdef SH_EX @@ -6891,7 +6892,7 @@ End_Object: int j; for (j = 0; temp && temp[j]; j++) { if (temp[j] == '\r') - temp[j] = (temp[j+1] ? ' ' : '\0'); + temp[j] = (char) (temp[j+1] ? ' ' : '\0'); } I.value = temp; chars = HText_beginInput(me->text, me->inUnderline, &I); @@ -6924,7 +6925,7 @@ End_Object: int j; for (j = 0; temp && temp[j]; j++) { if (temp[j] == '\r') - temp[j] = (temp[j+1] ? ' ' : '\0'); + temp[j] = (char) (temp[j+1] ? ' ' : '\0'); } I.value = temp; chars = HText_beginInput(me->text, me->inUnderline, &I); diff --git a/src/LYCharSets.c b/src/LYCharSets.c index 5924a4f8..592c8ddb 100644 --- a/src/LYCharSets.c +++ b/src/LYCharSets.c @@ -30,6 +30,19 @@ PUBLIC int current_char_set = -1; /* will be intitialized later in LYMain.c */ PUBLIC CONST char** p_entity_values = NULL; /* Pointer, for HTML_put_entity()*/ /* obsolete and probably not used(???) */ /* will be initialized in HTMLUseCharacterSet */ +#ifdef EXP_CHARSET_CHOICE +PUBLIC charset_subset_t charset_subsets[MAXCHARSETS]; +PUBLIC BOOL custom_display_charset = FALSE; +PUBLIC BOOL custom_assumed_doc_charset = FALSE; +#ifndef ALL_CHARSETS_IN_O_MENU_SCREEN +PUBLIC int display_charset_map[MAXCHARSETS]; +PUBLIC int assumed_doc_charset_map[MAXCHARSETS]; + +PUBLIC CONST char* display_charset_choices[MAXCHARSETS+1]; +PUBLIC CONST char* assumed_charset_choices[MAXCHARSETS+1]; +PUBLIC int displayed_display_charset_idx; +#endif +#endif /* EXP_CHARSET_CHOICE */ /* * New character sets now declared with UCInit() in UCdomap.c @@ -406,19 +419,19 @@ PUBLIC void HTMLSetCharacterHandling ARGS1(int,i) if (i == chndl) LYRawMode = LYUseDefaultRawMode; else - LYRawMode = (!LYUseDefaultRawMode); + LYRawMode = (BOOL) (!LYUseDefaultRawMode); - HTPassEightBitNum = + HTPassEightBitNum = (BOOL) ( ((LYCharSet_UC[i].codepoints & UCT_CP_SUPERSETOF_LAT1) || - (LYCharSet_UC[i].like8859 & UCT_R_HIGH8BIT)); + (LYCharSet_UC[i].like8859 & UCT_R_HIGH8BIT))); if (LYRawMode) { - HTPassEightBitRaw = (LYlowest_eightbit[i] <= 160); + HTPassEightBitRaw = (BOOL) (LYlowest_eightbit[i] <= 160); } else { HTPassEightBitRaw = FALSE; } if (LYRawMode || i == chndl) { - HTPassHighCtrlRaw = (LYlowest_eightbit[i] <= 130); + HTPassHighCtrlRaw = (BOOL) (LYlowest_eightbit[i] <= 130); } else { HTPassHighCtrlRaw = FALSE; } @@ -448,10 +461,10 @@ PUBLIC void HTMLSetCharacterHandling ARGS1(int,i) /* for any CJK: */ if (!LYUseDefaultRawMode) HTCJK = NOCJK; - LYRawMode = (HTCJK != NOCJK) ? TRUE : FALSE; + LYRawMode = (BOOL) ((HTCJK != NOCJK) ? TRUE : FALSE); HTPassEightBitRaw = FALSE; HTPassEightBitNum = FALSE; - HTPassHighCtrlRaw = (HTCJK != NOCJK) ? TRUE : FALSE; + HTPassHighCtrlRaw = (BOOL) ((HTCJK != NOCJK) ? TRUE : FALSE); HTPassHighCtrlNum = FALSE; } @@ -542,7 +555,7 @@ PUBLIC void Set_HTCJK ARGS2( */ PRIVATE void HTMLSetRawModeDefault ARGS1(int,i) { - LYDefaultRawMode = (LYCharSet_UC[i].enc == UCT_ENC_CJK); + LYDefaultRawMode = (BOOL) (LYCharSet_UC[i].enc == UCT_ENC_CJK); return; } @@ -561,7 +574,7 @@ PUBLIC void HTMLSetUseDefaultRawMode ARGS2( if (i == chndl) LYUseDefaultRawMode = modeflag; else - LYUseDefaultRawMode = (!modeflag); + LYUseDefaultRawMode = (BOOL) (!modeflag); } else /* CJK encoding: */ LYUseDefaultRawMode = modeflag; @@ -574,7 +587,7 @@ PUBLIC void HTMLSetUseDefaultRawMode ARGS2( */ PRIVATE void HTMLSetHaveCJKCharacterSet ARGS1(int,i) { - LYHaveCJKCharacterSet = (LYCharSet_UC[i].enc == UCT_ENC_CJK); + LYHaveCJKCharacterSet = (BOOL) (LYCharSet_UC[i].enc == UCT_ENC_CJK); return; } @@ -904,9 +917,43 @@ PUBLIC void HTMLUseCharacterSet ARGS1(int, i) * Initializer, calls initialization function for the * CHARTRANS handling. - KW */ -PUBLIC int LYCharSetsDeclared NOPARAMS +PUBLIC int LYCharSetsDeclared NOARGS { UCInit(); return UCInitialized; } + +#ifdef EXP_CHARSET_CHOICE +PUBLIC void init_charset_subsets NOARGS +{ + int i,n; + int cur_display = 0; + int cur_assumed = 0; + + /* add them to displayed values */ + charset_subsets[UCLYhndl_for_unspec].hide_assumed = FALSE; + charset_subsets[current_char_set].hide_display = FALSE; + +#ifndef ALL_CHARSETS_IN_O_MENU_SCREEN + /*all this stuff is for supporting old menu screen... */ + for (i = 0; i < LYNumCharsets; ++i){ + if (charset_subsets[i].hide_display == FALSE) { + n = cur_display++; + if (i == current_char_set) + displayed_display_charset_idx = n; + display_charset_map[n] = i; + display_charset_choices[n] = LYchar_set_names[i]; + } + if (charset_subsets[i].hide_assumed == FALSE) { + n = cur_assumed++; + assumed_doc_charset_map[n] = i; + assumed_charset_choices[n] = LYCharSet_UC[i].MIMEname; + charset_subsets[i].assumed_idx = n; + } + display_charset_choices[cur_display] = NULL; + assumed_charset_choices[cur_assumed] = NULL; + } +#endif +} +#endif /* EXP_CHARSET_CHOICE */ diff --git a/src/LYCharSets.h b/src/LYCharSets.h index ea132684..5dedc558 100644 --- a/src/LYCharSets.h +++ b/src/LYCharSets.h @@ -50,8 +50,47 @@ extern CONST char * HTMLGetEntityName PARAMS((UCode_t code)); ** the code. Note that unicode number in general may have ** several equivalent entity names because of synonyms. */ - - extern BOOL force_old_UCLYhndl_on_reload; extern int forced_UCLYhdnl; + +#ifndef EXP_CHARSET_CHOICE +# define ALL_CHARSETS_IN_O_MENU_SCREEN 1 +#endif + +#ifdef EXP_CHARSET_CHOICE +typedef struct { + BOOL hide_display; /* if FALSE, show in "display-charset" menu */ + BOOL hide_assumed; /* if FALSE, show in "assumed-charset" menu */ +#ifndef ALL_CHARSETS_IN_O_MENU_SCREEN + int assumed_idx; /* only this field is needed */ +#endif +} charset_subset_t; +/* each element corresponds to charset in LYCharSets */ +extern charset_subset_t charset_subsets[]; +/* all zeros by default - i.e., all charsets allowed */ + +extern BOOL custom_display_charset; /* whether the charset choices for display + charset were requested by user via lynx.cfg. It will remain FALSE if no + "display_charset_choice" settings were encountered in lynx.cfg */ +extern BOOL custom_assumed_doc_charset; /* similar to custom_display_charset */ + +#ifndef ALL_CHARSETS_IN_O_MENU_SCREEN + +/* this stuff is initialized after reading lynx.cfg and .lynxrc */ + +/* these arrays maps index of charset shown in menu to the index in LYCharsets[]*/ +extern int display_charset_map[]; +extern int assumed_doc_charset_map[]; + +/* these arrays are NULL terminated */ +extern CONST char* display_charset_choices[]; +extern CONST char* assumed_charset_choices[]; + +extern int displayed_display_charset_idx; + +#endif +/* this will be called after lynx.cfg and .lynxrc are read */ +extern void init_charset_subsets NOPARAMS; +#endif /* EXP_CHARSET_CHOICE */ + #endif /* LYCHARSETS_H */ diff --git a/src/LYCharUtils.c b/src/LYCharUtils.c index aef1862e..f21aa15e 100644 --- a/src/LYCharUtils.c +++ b/src/LYCharUtils.c @@ -182,7 +182,7 @@ PUBLIC void LYEntify ARGS2( } case S_nonascii_text: - if (*p == '\033') + if (*p == '\033') state = S_esc; *q++ = *p; continue; @@ -1743,12 +1743,12 @@ PRIVATE char ** LYUCFullyTranslateString_1 ARGS9( ** are both iso-8859-1, ** or if we are in CJK mode. */ - no_bytetrans = ((cs_to <= 0 && cs_from == cs_to) || + no_bytetrans = (BOOL) ((cs_to <= 0 && cs_from == cs_to) || HTCJK != NOCJK); /* No need to translate or examine the string any further */ if (!no_bytetrans) - no_bytetrans = (!use_lynx_specials && !Back && + no_bytetrans = (BOOL) (!use_lynx_specials && !Back && UCNeedNotTranslate(cs_from, cs_to)); /* @@ -1776,14 +1776,14 @@ PRIVATE char ** LYUCFullyTranslateString_1 ARGS9( UCTransParams_clear(&T); UCSetTransParams(&T, cs_from, &LYCharSet_UC[cs_from], cs_to, &LYCharSet_UC[cs_to]); - from_is_utf8 = (LYCharSet_UC[cs_from].enc == UCT_ENC_UTF8); + from_is_utf8 = (BOOL) (LYCharSet_UC[cs_from].enc == UCT_ENC_UTF8); output_utf8 = T.output_utf8; repl_translated_C0 = T.repl_translated_C0; puni = p; } else if (do_ent) { - output_utf8 = (LYCharSet_UC[cs_to].enc == UCT_ENC_UTF8 || + output_utf8 = (BOOL) (LYCharSet_UC[cs_to].enc == UCT_ENC_UTF8 || HText_hasUTF8OutputSet(HTMainText)); - repl_translated_C0 = (LYCharSet_UC[cs_to].enc == UCT_ENC_8BIT_C0); + repl_translated_C0 = (BOOL) (LYCharSet_UC[cs_to].enc == UCT_ENC_8BIT_C0); } lowest_8 = LYlowest_eightbit[cs_to]; @@ -1833,7 +1833,7 @@ PRIVATE char ** LYUCFullyTranslateString_1 ARGS9( } else { if (0xA1 <= code && code <= 0xDF) { sjis_str[2] = '\0'; - JISx0201TO0208_SJIS((unsigned char)code, + JISx0201TO0208_SJIS((unsigned char)code, sjis_str, sjis_str + 1); REPLACE_STRING(sjis_str); p++; @@ -1982,7 +1982,7 @@ PRIVATE char ** LYUCFullyTranslateString_1 ARGS9( } rev_c = UCReverseTransChar(*p, cs_to, cs_from); if (rev_c > 127) { - *p = rev_c; + *p = (char) rev_c; code = rev_c; state = S_got_outchar; break; @@ -2400,6 +2400,22 @@ PRIVATE char ** LYUCFullyTranslateString_1 ARGS9( */ state = S_got_outchar; break; + + /* The following disabled section doesn't make sense + ** any more. It used to make sense in the past, when + ** S_check_named would look in "old style" tables + ** in addition to what it does now. + ** Disabling of going to S_check_name here prevents + ** endless looping between S_check_uni and S_check_names + ** states, which could occur here for Latin 1 codes + ** for some cs_to if they had no translation in that + ** cs_to. Normally all cs_to *should* now have valid + ** translations via UCTransUniChar or UCTransUniCharStr + ** for all Latin 1 codes, so that we would not get here + ** anyway, and no loop could occur. Still, if we *do* + ** get here, FALL THROUGH to case S_recover now. - kw + */ +#if 0 /* ** If we get to here, convert and handle ** the character as a named entity. - FM @@ -2408,6 +2424,7 @@ PRIVATE char ** LYUCFullyTranslateString_1 ARGS9( name = HTMLGetEntityName(code - 160); state = S_check_name; break; +#endif } case S_recover: @@ -2620,7 +2637,7 @@ PUBLIC BOOL LYUCTranslateBackFormData ARGS4( ret = (LYUCFullyTranslateString_1(str, cs_from, cs_to, FALSE, NO, plain_space, YES, YES, st_HTML)); - return (ret != NULL); + return (BOOL) (ret != NULL); } /* @@ -2939,14 +2956,14 @@ PUBLIC void LYHandleMETA ARGS4( * of match. */ BOOL given_is_8859 - = (!strncmp(cp4, "iso-8859-", 9) && + = (BOOL) (!strncmp(cp4, "iso-8859-", 9) && isdigit((unsigned char)cp4[9])); BOOL given_is_8859like - = (given_is_8859 || !strncmp(cp4, "windows-", 8) || + = (BOOL) (given_is_8859 || !strncmp(cp4, "windows-", 8) || !strncmp(cp4, "cp12", 4) || !strncmp(cp4, "cp-12", 5)); BOOL given_and_display_8859like - = (given_is_8859like && + = (BOOL) (given_is_8859like && (strstr(LYchar_set_names[current_char_set], "ISO-8859") || strstr(LYchar_set_names[current_char_set], @@ -3270,7 +3287,7 @@ PUBLIC void LYHandlePlike ARGS6( !strcmp(me->sp->style->name, "Preformatted")))) { me->sp->style->alignment = HT_LEFT; } else { - me->sp->style->alignment = me->current_default_alignment; + me->sp->style->alignment = (short) me->current_default_alignment; } if (start) { @@ -3883,7 +3900,7 @@ PUBLIC void LYResetParagraphAlignment ARGS1( !strcmp(me->sp->style->name, "Preformatted")))) { me->sp->style->alignment = HT_LEFT; } else { - me->sp->style->alignment = me->current_default_alignment; + me->sp->style->alignment = (short) me->current_default_alignment; } return; } diff --git a/src/LYCookie.c b/src/LYCookie.c index d1717004..977165b4 100644 --- a/src/LYCookie.c +++ b/src/LYCookie.c @@ -969,7 +969,7 @@ PRIVATE void LYProcessSetCookies ARGS6( p++; value_start = p; while (*p != '\0' && (*p != '"' || escaped)) { - escaped = (!escaped && *p == '\\'); + escaped = (BOOL) (!escaped && *p == '\\'); p++; } if (p != value_start && *p == '"' && !escaped) { @@ -1489,7 +1489,7 @@ PRIVATE void LYProcessSetCookies ARGS6( p++; value_start = p; while (*p != '\0' && (*p != '"' || escaped)) { - escaped = (!escaped && *p == '\\'); + escaped = (BOOL) (!escaped && *p == '\\'); p++; } if (p != value_start && *p == '"' && !escaped) { diff --git a/src/LYCurses.c b/src/LYCurses.c index e554c2d7..0562d962 100644 --- a/src/LYCurses.c +++ b/src/LYCurses.c @@ -160,7 +160,7 @@ PRIVATE void sl_suspend ARGS1( SLang_init_tty(3, 0, 1); #endif /* SLANG_VERSION > 9929 */ signal(SIGTSTP, sl_suspend); -#if !defined(_WINDOWS) && !defined(__DJGPP__) +#ifdef UNIX SLtty_set_suspend_state(1); #endif if (sig == SIGTSTP) @@ -680,7 +680,7 @@ PUBLIC void start_curses NOARGS #if !defined(USE_KEYMAPS) SLtt_get_terminfo(); #endif -#if defined(__DJGPP__) && !defined(DJGPP_KEYHANDLER) +#if (defined(__DJGPP__) && !defined(DJGPP_KEYHANDLER)) || defined(__CYGWIN__) SLkp_init (); #endif /* __DJGPP__ && !DJGPP_KEYHANDLER */ @@ -762,9 +762,9 @@ PUBLIC void start_curses NOARGS scrollok(0,0); SLsmg_Backspace_Moves = 1; #ifndef VMS -#if !defined(_WINDOWS) && !defined(__DJGPP__) +#ifdef UNIX SLtty_set_suspend_state(1); -#endif /* !_WINDOWS */ +#endif /* UNIX */ #ifdef SIGTSTP if (!no_suspend) signal(SIGTSTP, sl_suspend); @@ -1302,6 +1302,28 @@ PUBLIC void LYstopTargetEmphasis NOARGS #endif /* FANCY_CURSES || USE_SLANG */ } +/* + * There's no guarantee that a library won't temporarily write on its input. + * Be safe and copy it when we have const-data. + */ +PUBLIC void LYaddnstr ARGS2( + CONST char *, s, + size_t, len) +{ + if (len != 0) { + char temp[MAX_LINE]; + memcpy(temp, s, len); + temp[len] = 0; + addstr(temp); + } +} + +PUBLIC void LYaddstr ARGS1( + CONST char *, s) +{ + LYaddnstr(s, strlen(s)); +} + #ifdef VMS /* * Cut-down termio -- diff --git a/src/LYCurses.h b/src/LYCurses.h index eefeeeaa..7ae71e94 100644 --- a/src/LYCurses.h +++ b/src/LYCurses.h @@ -163,6 +163,8 @@ extern void stop_curses NOPARAMS; extern BOOLEAN setup PARAMS((char *terminal)); extern void LYstartTargetEmphasis NOPARAMS; extern void LYstopTargetEmphasis NOPARAMS; +extern void LYaddnstr PARAMS((CONST char *s, size_t len)); +extern void LYaddstr PARAMS((CONST char *s)); #ifdef VMS extern int DCLsystem (char *command); @@ -199,7 +201,7 @@ extern unsigned int Lynx_Color_Flags; #define USE_SLANG_MOUSE 1 #endif -#if !defined(__DJGPP__) +#if !defined(__DJGPP__) && !defined(__CYGWIN__) #define USE_KEYMAPS 1 #endif diff --git a/src/LYEdit.c b/src/LYEdit.c index 65d7c495..2463cfd5 100644 --- a/src/LYEdit.c +++ b/src/LYEdit.c @@ -42,7 +42,10 @@ PUBLIC int edit_current_file ARGS3( char *format = "%s %s"; char *command = NULL; char *filename = NULL; - char *colon, *number_sign; +#if (!(defined(VMS) || defined(DOSPATH) || defined(__EMX__)) || defined(SH_EX)) + char *colon; +#endif + char *number_sign; char position[80]; FILE *fp; #ifdef __CYGWIN__ diff --git a/src/LYEditmap.c b/src/LYEditmap.c index 504f9bf7..7314e97b 100644 --- a/src/LYEditmap.c +++ b/src/LYEditmap.c @@ -895,7 +895,7 @@ LYE_FORM_LAC|LYK_DWIMHELP, #endif /* _WINDOWS || __DJGPP__ */ -LYE_UNMOD, LYE_NOP, LYE_UNMOD, LYE_UNMOD, +LYE_UNMOD, LYE_NOP, LYE_UNMOD, LYE_UNMOD, /* Insert key Remove key DO_NOTHING Back tab */ /* 110..18F */ @@ -948,7 +948,7 @@ PUBLIC char * LYLineeditNames[]={ /* * Add the URL (relative to helpfilepath) used for context-dependent * help on form field editing. - * + * * The order must correspond to that of LYLineditNames. */ PUBLIC CONST char * LYLineeditHelpURLs[]={ @@ -1024,17 +1024,17 @@ PUBLIC int LYRemapEditBinding ARGS2( if (c > LAST_MOD1_LKC) return FALSE; else - Mod1Binding[c] = lec; + Mod1Binding[c] = (short) lec; } else if (xlkc & LKC_MOD2) { if (c > LAST_MOD2_LKC) return FALSE; else - Mod2Binding[c] = lec; + Mod2Binding[c] = (short) lec; } else if (xlkc & LKC_MOD3) { if (c > LAST_MOD3_LKC) return FALSE; else - Mod3Binding[c] = lec; + Mod3Binding[c] = (short) lec; } else #endif /* EXP_ALT_BINDINGS */ { @@ -1044,7 +1044,7 @@ PUBLIC int LYRemapEditBinding ARGS2( if ((unsigned int)lec > UCHAR_MAX) return FALSE; /* cannot do, doesn't fit in a char - kw */ for (j = 0; LYLineeditNames[j]; j++) { - LYLineEditors[j][c] = lec; + LYLineEditors[j][c] = (char) lec; } } return TRUE; diff --git a/src/LYExtern.c b/src/LYExtern.c index 0f8a1c4f..05e5d71c 100644 --- a/src/LYExtern.c +++ b/src/LYExtern.c @@ -63,7 +63,7 @@ static char *decode_string(char *s) *p = *s; continue; } - *p = (ASC2HEXD(*(s + 1)) << 4) + ASC2HEXD(*(s + 2)); + *p = (char)((ASC2HEXD(*(s + 1)) << 4) + ASC2HEXD(*(s + 2))); s += 2; } } @@ -204,8 +204,6 @@ void run_external ARGS1(char *, c) if (externals2->command != 0 && !strncasecomp(externals2->name, c, strlen(externals2->name))) { - char *cp; - if (no_externals && !externals2->always_enabled) { HTUserMsg(EXTERNALS_DISABLED); return; @@ -221,7 +219,7 @@ void run_external ARGS1(char *, c) #else /* Unix or DOS/Win: */ #if defined(WIN_EX) if (*c != '\"' && strchr(c, ' ') != NULL) { - cp = quote_pathname(c); + char *cp = quote_pathname(c); sprintf(command, externals2->command, cp); FREE(cp); } else { @@ -283,9 +281,11 @@ void run_external ARGS1(char *, c) } } #else /* Unix */ - cp = HTQuoteParameter(c); - sprintf(command, externals2->command, cp); - FREE(cp); + { + char *cp = HTQuoteParameter(c); + sprintf(command, externals2->command, cp); + FREE(cp); + } #endif #endif /* VMS */ diff --git a/src/LYForms.c b/src/LYForms.c index 282adc91..7c437509 100644 --- a/src/LYForms.c +++ b/src/LYForms.c @@ -388,7 +388,7 @@ PRIVATE int form_getstr ARGS3( */ LYSetupEdit(&MyEdit, value, max_length, (far_col - startcol)); MyEdit.pad = '_'; - MyEdit.hidden = (form->type == F_PASSWORD_TYPE); + MyEdit.hidden = (BOOL) (form->type == F_PASSWORD_TYPE); if (use_last_tfpos && LastTFPos >= 0 && LastTFPos < MyEdit.strlen) { MyEdit.pos = LastTFPos; #ifdef ENHANCED_LINEEDIT @@ -747,7 +747,7 @@ PRIVATE int get_popup_option_number ARGS2( /* * Load the c argument into the prompt buffer. */ - temp[0] = *c; + temp[0] = (char) *c; temp[1] = '\0'; _statusline(SELECT_OPTION_NUMBER); diff --git a/src/LYGetFile.c b/src/LYGetFile.c index aa95cd9e..370bf41f 100644 --- a/src/LYGetFile.c +++ b/src/LYGetFile.c @@ -68,14 +68,14 @@ PUBLIC int HTNoDataOK = 0; * to show for it either. * NULLFILE - requested document not loaded into HTMainText, either * some interactive protocol was requested (like telnet), - * or lynx does not allow access, + * or lynx does not allow access, * The distinction between NOT_FOUND and NULLFILE is not very crucial, * but getting it right prevents mainloop from exiting with the wrong * message if it happens for the first file, and from logging (or not * logging) errors inappropriately with -traversal, and from sending * bogus error mail with MAIL_SYSTEM_ERROR_LOGGING:TRUE. - kw */ -PUBLIC BOOLEAN getfile ARGS1( +PUBLIC int getfile ARGS1( document *, doc) { int url_type = 0; @@ -1103,7 +1103,7 @@ PUBLIC int follow_link_number ARGS4( int curline = *num; /* passed in from mainloop() */ CTRACE(tfp,"follow_link_number(%d,%d,...)\n",c,cur); - temp[0] = c; + temp[0] = (char) c; temp[1] = '\0'; *num = -1; _statusline(FOLLOW_LINK_NUMBER); @@ -1166,7 +1166,7 @@ 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 = ( c == 'g' || c == 'G' ); + want_go = (BOOL) ( 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. diff --git a/src/LYGetFile.h b/src/LYGetFile.h index 93239e83..319efbb6 100644 --- a/src/LYGetFile.h +++ b/src/LYGetFile.h @@ -7,7 +7,7 @@ #define NORMAL 1 #define NULLFILE 3 -extern BOOLEAN getfile PARAMS((document *doc)); +extern int getfile PARAMS((document *doc)); extern int follow_link_number PARAMS(( int c, int cur, diff --git a/src/LYGlobalDefs.h b/src/LYGlobalDefs.h index 22a828dd..81c391e0 100644 --- a/src/LYGlobalDefs.h +++ b/src/LYGlobalDefs.h @@ -422,9 +422,11 @@ extern BOOLEAN focus_window; #ifdef SH_EX extern BOOLEAN show_cfg; extern BOOLEAN mail_is_blat; -extern BOOLEAN no_table_center; +#ifdef WIN_EX extern int debug_delay; #endif +extern BOOLEAN no_table_center; +#endif #if !defined(__CYGWIN__) && defined(__CYGWIN32__) #define __CYGWIN__ diff --git a/src/LYKeymap.c b/src/LYKeymap.c index 32a2e0eb..72f6ebe2 100644 --- a/src/LYKeymap.c +++ b/src/LYKeymap.c @@ -1,3 +1,4 @@ + #include #include #include @@ -32,9 +33,6 @@ PUBLIC char * LYKbLayoutNames[]={ }; #endif /* EXP_KEYBOARD_LAYOUT */ -PRIVATE CONST DocAddress keymap_anchor = {"LYNXKEYMAP", NULL, NULL, - NULL, FALSE, FALSE}; - struct _HTStream { HTStreamClass * isa; @@ -187,7 +185,7 @@ LYK_TAG_LINK, LYK_PREV_DOC, LYK_VIEW_BOOKMARK, 0, LYK_NOCACHE, 0, LYK_INTERRUPT, 0, /* x */ /* y */ /* z */ /* { */ -#if (defined(_WINDOWS) || defined(__DJGPP__)) +#if (defined(_WINDOWS) || defined(__DJGPP__) || defined(__CYGWIN__)) LYK_PIPE, 0, 0, 0, /* | */ /* } */ /* ~ */ @@ -197,7 +195,7 @@ LYK_PIPE, 0, 0, 0, LYK_PIPE, 0, 0, LYK_HISTORY, /* | */ /* } */ /* ~ */ /* del */ -#endif /* _WINDOWS || __DJGPP__ */ +#endif /* _WINDOWS || __DJGPP__ || __CYGWIN__ */ /* 80..9F (illegal ISO-8859-1) 8-bit characters. */ 0, 0, 0, 0, @@ -242,7 +240,7 @@ LYK_PREV_LINK, LYK_NEXT_LINK, LYK_ACTIVATE, LYK_PREV_DOC, LYK_NEXT_PAGE, LYK_PREV_PAGE, LYK_HOME, LYK_END, /* PGDOWN */ /* PGUP */ /* HOME */ /* END */ -#if (defined(_WINDOWS) || defined(__DJGPP__)) +#if (defined(_WINDOWS) || defined(__DJGPP__) || defined(__CYGWIN__)) LYK_HELP, 0, 0, 0, /* F1*/ @@ -251,19 +249,19 @@ LYK_HELP, 0, 0, 0, LYK_HELP, LYK_ACTIVATE, LYK_HOME, LYK_END, /* F1*/ /* Do key */ /* Find key */ /* Select key */ -#endif /* _WINDOWS || __DJGPP__ */ +#endif /* _WINDOWS || __DJGPP__ || __CYGWIN__ */ LYK_UP_TWO, LYK_DOWN_TWO, LYK_DO_NOTHING, LYK_FASTBACKW_LINK, /* Insert key */ /* Remove key */ /* DO_NOTHING*/ /* Back tab */ /* 110..18F */ -#if (defined(_WINDOWS) || defined(__DJGPP__)) && defined(USE_SLANG) && !defined(DJGPP_KEYHANDLER) +#if (defined(_WINDOWS) || defined(__DJGPP__) || defined(__CYGWIN__)) && defined(USE_SLANG) && !defined(DJGPP_KEYHANDLER) LYK_HISTORY, LYK_ACTIVATE, 0, 0, /* Backspace */ /* Enter */ #else 0, 0, 0, 0, -#endif /* USE_SLANG &&(_WINDOWS || __DJGPP) && !DJGPP_KEYHANDLER */ +#endif /* USE_SLANG &&(_WINDOWS || __DJGPP || __CYGWIN__) && !DJGPP_KEYHANDLER */ 0, 0, 0, 0, 0, LYK_DO_NOTHING, 0, 0, /* 0x11d: MOUSE_KEY */ @@ -313,7 +311,7 @@ LYK_UP_TWO, LYK_DOWN_TWO, LYK_DO_NOTHING, LYK_FASTBACKW_LINK, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -#if (defined(_WINDOWS) || defined(__DJGPP__)) && !defined(USE_SLANG) /* PDCurses */ +#if (defined(_WINDOWS) || defined(__DJGPP__) || defined(__CYGWIN__)) && !defined(USE_SLANG) /* PDCurses */ LYK_ABORT, 0, 0, 0, /* ALT_X */ 0, 0, 0, 0, @@ -333,7 +331,7 @@ LYK_UP_TWO, LYK_DOWN_TWO, LYK_DO_NOTHING, LYK_FASTBACKW_LINK, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -#endif /* (_WINDOWS || __DJGPP__) && !USE_SLANG */ +#endif /* (_WINDOWS || __DJGPP__ || __CYGWIN__) && !USE_SLANG */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -997,35 +995,35 @@ PUBLIC int remap ARGS2( char *, key, char *, func) { - int i; - struct rmap *mp; - int c; - - if (func == NULL) - return 0; - c = lkcstring_to_lkc(key); - if (c <= -1) - return 0; - else if (c >= 0) { - /* Remapping of key actions is supported only for basic - * lynxkeycodes, without modifiers etc.! If we get somehow - * called for an invalid lynxkeycode, fail or silently - * modifiers. - kw - */ - if (c & LKC_ISLAC) - return 0; - if ((c & LKC_MASK) != c) - c &= LKC_MASK; - } - if (c + 1 >= KEYMAP_SIZE) + int i; + struct rmap *mp; + int c; + + if (func == NULL) + return 0; + c = lkcstring_to_lkc(key); + if (c <= -1) + return 0; + else if (c >= 0) { + /* Remapping of key actions is supported only for basic + * lynxkeycodes, without modifiers etc.! If we get somehow + * called for an invalid lynxkeycode, fail or silently + * modifiers. - kw + */ + if (c & LKC_ISLAC) return 0; - for (i = 0, mp = revmap; (*mp).name != NULL; mp++, i++) { - if (strcmp((*mp).name, func) == 0) { - keymap[c+1] = i; - return (c ? c : LAC_TO_LKC0(i)); - } - } - return 0; + if ((c & LKC_MASK) != c) + c &= LKC_MASK; + } + if (c + 1 >= KEYMAP_SIZE) + return 0; + for (i = 0, mp = revmap; (*mp).name != NULL; mp++, i++) { + if (strcmp((*mp).name, func) == 0) { + keymap[c+1] = (char) i; + return (c ? c : LAC_TO_LKC0(i)); + } + } + return 0; } @@ -1191,7 +1189,7 @@ PUBLIC BOOL LYisNonAlnumKeyname ARGS2( ch < 0 || ch >= KEYMAP_SIZE) return (FALSE); - return(keymap[ch+1] == key_name); + return (BOOL) (keymap[ch+1] == key_name); } /* diff --git a/src/LYMail.c b/src/LYMail.c index 1112eb2e..274f95e7 100644 --- a/src/LYMail.c +++ b/src/LYMail.c @@ -1743,7 +1743,7 @@ PUBLIC void reply_by_mail ARGS4( /* * Ask if the user wants to include the original message. */ - BOOLEAN is_preparsed = (LYPreparsedSource && + BOOLEAN is_preparsed = (BOOL) (LYPreparsedSource && HTisDocumentSource()); if (HTConfirm(is_preparsed ? INC_PREPARSED_MSG_PROMPT diff --git a/src/LYMain.c b/src/LYMain.c index 83e3cbcf..b58cef3c 100644 --- a/src/LYMain.c +++ b/src/LYMain.c @@ -307,7 +307,9 @@ PUBLIC BOOLEAN system_is_NT = FALSE; #ifdef SH_EX PUBLIC BOOLEAN show_cfg = FALSE; PUBLIC BOOLEAN mail_is_blat = TRUE; +#ifdef WIN_EX PUBLIC int debug_delay = 0; /* 1998/10/06 (Tue) 08:41:20 */ +#endif PUBLIC BOOLEAN no_table_center = FALSE; /* 1998/10/09 (Fri) 15:12:49 */ #endif /* SH_EX */ @@ -479,6 +481,7 @@ PRIVATE BOOLEAN stack_dump = FALSE; PRIVATE char *terminal = NULL; PRIVATE char *pgm; PRIVATE BOOLEAN number_links = FALSE; +PRIVATE BOOLEAN number_fields = FALSE; PRIVATE BOOLEAN LYPrependBase = FALSE; PRIVATE HTList *LYStdinArgs = NULL; @@ -518,7 +521,7 @@ PRIVATE void FatalProblem PARAMS((int sig)); #endif #ifdef __DJGPP__ -PRIVATE int LY_set_ctrl_break(int setting) +PRIVATE void LY_set_ctrl_break(int setting) { (void)signal(SIGINT, (setting ? SIG_DFL : SIG_IGN)); setcbrk(setting); @@ -780,6 +783,10 @@ PUBLIC int main ARGS2( FixCharacters(); #endif /* NOT_ASCII */ +#ifdef EXP_CHARSET_CHOICE + memset((char*)charset_subsets, 0, sizeof(charset_subset_t)*MAXCHARSETS); +#endif + #ifdef _WINDOWS WSADATA WSAData; { @@ -812,7 +819,7 @@ PUBLIC int main ARGS2( #if defined(WIN_EX) /* 1997/10/19 (Sun) 21:40:54 */ - system_is_NT = is_windows_nt(); + system_is_NT = (BOOL) is_windows_nt(); /* 1998/01/13 (Tue) 21:13:47 */ GetWindowsDirectory(filename, sizeof filename); @@ -984,7 +991,11 @@ PUBLIC int main ARGS2( } #endif - if ((cp = strchr(lynx_temp_space, '~'))) { + if ((cp = strchr(lynx_temp_space, '~')) != 0 +#ifdef WIN_EX /* for Windows 2000 ... 1999/08/23 (Mon) 08:24:35 */ + && (access(lynx_temp_space, 0) != 0) +#endif + ) { *(cp++) = '\0'; StrAllocCopy(temp, lynx_temp_space); LYTrimPathSep(temp); @@ -1049,7 +1060,7 @@ PUBLIC int main ARGS2( * command line switch. - FM */ #ifndef DISABLE_NEWS - no_newspost = (LYNewsPosting == FALSE); + no_newspost = (BOOL) (LYNewsPosting == FALSE); #endif /* @@ -1717,10 +1728,13 @@ PUBLIC int main ARGS2( } } - if (number_links && keypad_mode == NUMBERS_AS_ARROWS) - keypad_mode = LINKS_ARE_NUMBERED; - if (keypad_mode == NUMBERS_AS_ARROWS) + if (keypad_mode == NUMBERS_AS_ARROWS) { + if (number_fields) + keypad_mode = LINKS_AND_FIELDS_ARE_NUMBERED; + if (number_links) + keypad_mode = LINKS_ARE_NUMBERED; set_numbers_as_arrows(); + } /* * Check the -popup command line toggle. - FM @@ -1902,29 +1916,29 @@ PUBLIC int main ARGS2( */ if (inlocaldomain()) { #if !defined(HAVE_UTMP) || defined(VMS) /* not selective */ - telnet_ok = !no_inside_telnet && !no_outside_telnet && telnet_ok; + telnet_ok = (BOOL)(!no_inside_telnet && !no_outside_telnet && telnet_ok); #ifndef DISABLE_NEWS - news_ok = !no_inside_news && !no_outside_news && news_ok; + news_ok = (BOOL)(!no_inside_news && !no_outside_news && news_ok); #endif - ftp_ok = !no_inside_ftp && !no_outside_ftp && ftp_ok; - rlogin_ok = !no_inside_rlogin && !no_outside_rlogin && rlogin_ok; + ftp_ok = (BOOL)(!no_inside_ftp && !no_outside_ftp && ftp_ok); + rlogin_ok = (BOOL)(!no_inside_rlogin && !no_outside_rlogin && rlogin_ok); #else CTRACE(tfp, "LYMain: User in Local domain\n"); - telnet_ok = !no_inside_telnet && telnet_ok; + telnet_ok = (BOOL)(!no_inside_telnet && telnet_ok); #ifndef DISABLE_NEWS - news_ok = !no_inside_news && news_ok; + news_ok = (BOOL)(!no_inside_news && news_ok); #endif - ftp_ok = !no_inside_ftp && ftp_ok; - rlogin_ok = !no_inside_rlogin && rlogin_ok; + ftp_ok = (BOOL)(!no_inside_ftp && ftp_ok); + rlogin_ok = (BOOL)(!no_inside_rlogin && rlogin_ok); #endif /* !HAVE_UTMP || VMS */ } else { CTRACE(tfp, "LYMain: User in REMOTE domain\n"); - telnet_ok = !no_outside_telnet && telnet_ok; + telnet_ok = (BOOL)(!no_outside_telnet && telnet_ok); #ifndef DISABLE_NEWS - news_ok = !no_outside_news && news_ok; + news_ok = (BOOL)(!no_outside_news && news_ok); #endif - ftp_ok = !no_outside_ftp && ftp_ok; - rlogin_ok = !no_outside_rlogin && rlogin_ok; + ftp_ok = (BOOL)(!no_outside_ftp && ftp_ok); + rlogin_ok = (BOOL)(!no_outside_rlogin && rlogin_ok); } /* @@ -1944,19 +1958,19 @@ PUBLIC int main ARGS2( StrAllocCopy(MBM_A_subdescript[0], MULTIBOOKMARKS_DEFAULT); } -#if defined (__DJGPP__) - if (watt_debug) - dbug_init(); - sock_init(); +#if defined (__DJGPP__) + if (watt_debug) + dbug_init(); + sock_init(); - __system_flags = - __system_emulate_chdir | /* handle `cd' internally */ - __system_handle_null_commands | /* ignore cmds with no effect */ - __system_allow_long_cmds | /* handle commands > 126 chars */ - __system_use_shell | /* use $SHELL if set */ - __system_allow_multiple_cmds | /* allow `cmd1; cmd2; ...' */ - __system_redirect; /* redirect internally */ -#endif /* __DJGPP__ */ + __system_flags = + __system_emulate_chdir | /* handle `cd' internally */ + __system_handle_null_commands | /* ignore cmds with no effect */ + __system_allow_long_cmds | /* handle commands > 126 chars */ + __system_use_shell | /* use $SHELL if set */ + __system_allow_multiple_cmds | /* allow `cmd1; cmd2; ...' */ + __system_redirect; /* redirect internally */ +#endif /* __DJGPP__ */ /* * Here's where we do all the work. @@ -1966,9 +1980,14 @@ PUBLIC int main ARGS2( * Finish setting up and start a * NON-INTERACTIVE session. - FM */ - if (!crawl && !nolist) { + if (crawl && !number_links && !number_fields) { + keypad_mode = NUMBERS_AS_ARROWS; + } else if (!nolist) { if (keypad_mode == NUMBERS_AS_ARROWS) { - keypad_mode = LINKS_ARE_NUMBERED; + if (number_fields) + keypad_mode = LINKS_AND_FIELDS_ARE_NUMBERED; + else + keypad_mode = LINKS_ARE_NUMBERED; } } @@ -2012,6 +2031,11 @@ PUBLIC int main ARGS2( with_backspaces = FALSE; } #endif + +#ifndef ALL_CHARSETS_IN_O_MENU_SCREEN + init_charset_subsets(); +#endif + ena_csi((BOOLEAN)(LYlowest_eightbit[current_char_set] > 155)); LYOpenCloset(); status = mainloop(); @@ -2094,6 +2118,11 @@ PUBLIC void reload_read_cfg NOARGS StrAllocCopy(LYCookieFile_flag, LYCookieFile); #endif +#ifdef EXP_CHARSET_CHOICE + custom_assumed_doc_charset = FALSE; + custom_display_charset = FALSE; + memset((char*)charset_subsets, 0, sizeof(charset_subset_t)*MAXCHARSETS); +#endif free_lynx_cfg(); /* free downloaders, printers, not always environments */ /* * Process the configuration file. @@ -2105,6 +2134,9 @@ PUBLIC void reload_read_cfg NOARGS */ read_rc(); +#ifdef EXP_CHARSET_CHOICE + init_charset_subsets(); +#endif /* We are not interested in startfile here */ /* but other things may be lost: */ @@ -2838,8 +2870,12 @@ static int version_fun ARGS1( #else #ifdef _MSC_VER printf("Compiled by Microsoft Visual C++ (%s %s).\n", __DATE__, __TIME__); +#else +#ifdef __DJGPP__ + printf("Compiled by DJGPP (%s %s).\n", __DATE__, __TIME__); #else printf("Compiled at (%s %s).\n", __DATE__, __TIME__); +#endif /* __DJGPP__ */ #endif /* _MSC_VER */ #endif /* __BORLANDC__ */ #endif /* __CYGWIN__ */ @@ -2965,7 +3001,7 @@ with -dump, format output as with -traversal, but to stdout" "incremental display stages with MessageSecs delay" ), #endif -#ifdef SH_EX +#if defined(SH_EX) && defined(WIN_EX) PARSE_SET( "delay", NEED_INT_ARG, &debug_delay, "=NNN\nset the NNN msec delay at statusline message" @@ -3188,6 +3224,10 @@ keys (may be incompatible with some curses packages)" "nostatus", SET_ARG, &no_statusline, "disable the miscellaneous information messages" ), + PARSE_SET( + "number_fields", SET_ARG, &number_fields, + "force numbering of links as well as form input fields" + ), PARSE_SET( "number_links", SET_ARG, &number_links, "force numbering of links" @@ -3198,7 +3238,7 @@ keys (may be incompatible with some curses packages)" "toggles display partial pages while downloading" ), PARSE_INT( - "partial_thres", NEED_INT_ARG, &partial_threshold, + "partial_thres", NEED_INT_ARG, &partial_threshold, "[=NUMBER]\nnumber of lines to render before repainting display\n\ with partial-display logic" ), @@ -3642,7 +3682,7 @@ PRIVATE void parse_arg ARGS2( if (next_arg == 0) { switch (p->type & ARG_TYPE_MASK) { case TOGGLE_ARG: - *(q->set_value) = !(*(q->set_value)); + *(q->set_value) = (BOOL) !(*(q->set_value)); break; case SET_ARG: *(q->set_value) = TRUE; diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c index 040159a7..fe5242c0 100644 --- a/src/LYMainLoop.c +++ b/src/LYMainLoop.c @@ -46,22 +46,6 @@ extern char *string_short(char *str, int cut_pos); /* LYExtern.c */ #define CHARSET_TRANS 14 /* "Transparent" in LYCharSets.c */ -#ifdef SH_EX -PRIVATE char *str_sjis(char *to, char *from) -{ - if (!LYRawMode) { - strcpy(to, from); - } else if (last_kcode == EUC) { - EUC_TO_SJIS(from, to); - } else if (last_kcode == SJIS) { - strcpy(to, from); - } else { - TO_SJIS(from, to); - } - return to; -} -#endif - PUBLIC char *str_kcode(HTkcode code) { char *p; @@ -109,15 +93,28 @@ PUBLIC char *str_kcode(HTkcode code) return buff; } +#ifdef WIN_EX + +PRIVATE char *str_sjis(char *to, char *from) +{ + if (!LYRawMode) { + strcpy(to, from); + } else if (last_kcode == EUC) { + EUC_TO_SJIS(from, to); + } else if (last_kcode == SJIS) { + strcpy(to, from); + } else { + TO_SJIS(from, to); + } + return to; +} -#ifdef SH_EX PRIVATE void set_ws_title(char * str) { -#ifdef WIN_EX SetConsoleTitle(str); -#endif } -#endif + +#endif /* WIN_EX */ #endif /* CJK_EX */ @@ -414,7 +411,7 @@ PRIVATE int DoTraversal ARGS2( BOOLEAN rlink_exists; BOOLEAN rlink_allowed; - rlink_exists = (nlinks > 0 && + rlink_exists = (BOOL) (nlinks > 0 && links[curdoc.link].type != WWW_FORM_LINK_TYPE && links[curdoc.link].lname != NULL); @@ -424,11 +421,11 @@ PRIVATE int DoTraversal ARGS2( traversal_host && links[curdoc.link].lname) { if (strncmp(links[curdoc.link].lname, "LYNXIMGMAP:", 11)) { - rlink_allowed = !strncmp(traversal_host, + rlink_allowed = (BOOL) !strncmp(traversal_host, links[curdoc.link].lname, strlen(traversal_host)); } else { - rlink_allowed = !strncmp(traversal_host, + rlink_allowed = (BOOL) !strncmp(traversal_host, links[curdoc.link].lname + 11, strlen(traversal_host)); } @@ -498,10 +495,9 @@ PRIVATE int DoTraversal ARGS2( int mainloop NOARGS { -#if defined(SH_EX) /* 1997/10/08 (Wed) 14:52:06 */ +#if defined(WIN_EX) /* 1997/10/08 (Wed) 14:52:06 */ #undef STRING_MAX #define STRING_MAX 4096 - char title_buff[STRING_MAX]; char temp_buff[STRING_MAX]; #define BUFF_MAX 1024 @@ -1285,13 +1281,6 @@ try_again: * to Newline, so we get a redraw. */ curdoc.line = -1; -#ifdef USE_PSRC - if (psrc_view) - HTMark_asSource(); /* this flag is not set, since when - displaying source, psrc_view is temporary unset when - writing the HTML header - and HTMainText is created - at that time.*/ -#endif break; } /* end switch */ @@ -1690,7 +1679,7 @@ try_again: } -#if defined(CJK_EX) /* 1997/10/08 (Wed) 14:52:06 */ +#if defined(WIN_EX) /* 1997/10/08 (Wed) 14:52:06 */ if (nlinks > 0) { char *p = "LYNX (unknown link type)"; @@ -1743,7 +1732,7 @@ try_again: HTUnEscape(temp_buff); } str_sjis(sjis_buff, temp_buff); - SetConsoleTitle(string_short(sjis_buff, 10)); + set_ws_title(string_short(sjis_buff, 10)); } } } else { @@ -1756,7 +1745,7 @@ try_again: set_ws_title(HTUnEscape(temp_buff)); } } -#endif /* CJK_EX */ +#endif /* WIN_EX */ /* * Report unread or new mail, if appropriate. @@ -1833,7 +1822,7 @@ try_again: links[curdoc.link].form->type == F_TEXTAREA_TYPE)) { BOOLEAN use_last_tfpos; - use_last_tfpos = (real_cmd == LYK_LPOS_PREV_LINK || + use_last_tfpos = (BOOL) (real_cmd == LYK_LPOS_PREV_LINK || real_cmd == LYK_LPOS_NEXT_LINK); #ifndef NO_NONSTICKY_INPUTS @@ -4481,9 +4470,9 @@ if (!LYUseFormsOptions) { BOOLEAN LYUseDefaultRawMode_flag = LYUseDefaultRawMode; BOOLEAN LYSelectPopups_flag = LYSelectPopups; BOOLEAN verbose_img_flag = verbose_img; - BOOLEAN keypad_mode_flag = keypad_mode; + BOOLEAN keypad_mode_flag = (BOOL) keypad_mode; BOOLEAN show_dotfiles_flag = show_dotfiles; - BOOLEAN user_mode_flag = user_mode; + BOOLEAN user_mode_flag = (BOOL) user_mode; int CurrentAssumeCharSet_flag = UCLYhndl_for_unspec; int CurrentCharSet_flag = current_char_set; int HTfileSortMethod_flag = HTfileSortMethod; @@ -6168,7 +6157,7 @@ check_add_bookmark_to_self: HTUserMsg(gettext("charset for this document specified explicitely, sorry...")); break; } else { - LYUseDefaultRawMode = !LYUseDefaultRawMode; + LYUseDefaultRawMode = (BOOL) !LYUseDefaultRawMode; HTUserMsg(LYRawMode ? RAWMODE_OFF : RAWMODE_ON); HTMLSetCharacterHandling(current_char_set); #ifdef SOURCE_CACHE diff --git a/src/LYOptions.c b/src/LYOptions.c index 563dfd8c..575fe13d 100644 --- a/src/LYOptions.c +++ b/src/LYOptions.c @@ -37,7 +37,9 @@ PRIVATE int boolean_choice PARAMS(( int status, int line, int column, - char ** choices)); + CONST char ** choices)); +#define LYChooseBoolean(status, line, column, choices) \ + boolean_choice(status, line, column, (CONST char **)choices) #define MAXCHOICES 10 @@ -158,7 +160,7 @@ PRIVATE void addlbl ARGS1(CONST char *, text) PUBLIC void LYoptions NOARGS { -#ifdef ENABLE_OPTS_CHANGE_EXEC +#if defined(ENABLE_OPTS_CHANGE_EXEC) && (defined(EXEC_LINKS) || defined(EXEC_SCRIPTS)) int itmp; #endif /* ENABLE_OPTS_CHANGE_EXEC */ int response, ch; @@ -242,7 +244,7 @@ PUBLIC void LYoptions NOARGS } old_use_assume_charset = - use_assume_charset = (user_mode == ADVANCED_MODE); + use_assume_charset = (BOOL) (user_mode == ADVANCED_MODE); draw_options: @@ -310,7 +312,7 @@ draw_options: move(L_Charset, 5); addlbl("display (C)haracter set : "); - addstr((char *)LYchar_set_names[current_char_set]); + LYaddstr(LYchar_set_names[current_char_set]); move(L_LANGUAGE, 5); addlbl("preferred document lan(G)uage: "); @@ -326,8 +328,8 @@ draw_options: if (UCAssume_MIMEcharset) addstr(UCAssume_MIMEcharset); else - addstr((UCLYhndl_for_unspec >= 0) ? - (char *)LYCharSet_UC[UCLYhndl_for_unspec].MIMEname + LYaddstr((UCLYhndl_for_unspec >= 0) ? + LYCharSet_UC[UCLYhndl_for_unspec].MIMEname : "NONE"); } @@ -422,7 +424,7 @@ draw_options: addlbl("user (A)gent : "); addstr((LYUserAgent && *LYUserAgent) ? LYUserAgent : "NONE"); -#ifdef ENABLE_OPTS_CHANGE_EXEC +#if defined(ENABLE_OPTS_CHANGE_EXEC) && (defined(EXEC_LINKS) || defined(EXEC_SCRIPTS)) move(L_Exec, 5); addlbl("local e(X)ecution links : "); #ifndef NEVER_ALLOW_REMOTE_EXEC @@ -622,12 +624,12 @@ draw_options: StrAllocCopy(choices[2], "ADVANCED"); choices[3] = NULL; if (!LYSelectPopups) { - LYMultiBookmarks = boolean_choice((LYMultiBookmarks * + LYMultiBookmarks = LYChooseBoolean((LYMultiBookmarks * (1 + LYMBMAdvanced)), L_HOME, C_MULTI, choices); } else { - LYMultiBookmarks = popup_choice((LYMultiBookmarks * + LYMultiBookmarks = LYChoosePopup((LYMultiBookmarks * (1 + LYMBMAdvanced)), L_HOME, (C_MULTI - 1), choices, @@ -750,11 +752,11 @@ draw_options: StrAllocCopy(choices[3], "By Date "); choices[4] = NULL; if (!LYSelectPopups) { - HTfileSortMethod = boolean_choice(HTfileSortMethod, + HTfileSortMethod = LYChooseBoolean(HTfileSortMethod, L_FTPSTYPE, -1, choices); } else { - HTfileSortMethod = popup_choice(HTfileSortMethod, + HTfileSortMethod = LYChoosePopup(HTfileSortMethod, L_FTPSTYPE, -1, choices, 4, FALSE, FALSE); @@ -830,7 +832,7 @@ draw_options: choices[1] = NULL; StrAllocCopy(choices[1], "CASE SENSITIVE "); choices[2] = NULL; - case_sensitive = boolean_choice(case_sensitive, + case_sensitive = LYChooseBoolean(case_sensitive, L_SSEARCH, -1, choices); FREE(choices[0]); FREE(choices[1]); @@ -840,13 +842,13 @@ draw_options: case '\001': /* Change assume_charset setting. */ if (use_assume_charset) { int i, curval; - char ** assume_list; - assume_list = (char **)calloc(LYNumCharsets + 1, sizeof(char *)); + CONST char ** assume_list; + assume_list = typecallocn(CONST char *,(LYNumCharsets + 1)); if (!assume_list) { outofmem(__FILE__, "options"); } for (i = 0; i < LYNumCharsets; i++) { - assume_list[i] = (char *)LYCharSet_UC[i].MIMEname; + assume_list[i] = LYCharSet_UC[i].MIMEname; } curval = UCLYhndl_for_unspec; if (curval == current_char_set && UCAssume_MIMEcharset) { @@ -855,20 +857,34 @@ draw_options: if (curval < 0) curval = LYRawMode ? current_char_set : 0; if (!LYSelectPopups) { - UCLYhndl_for_unspec = boolean_choice(curval, +#ifndef ALL_CHARSETS_IN_O_MENU_SCREEN + UCLYhndl_for_unspec = assumed_doc_charset_map[LYChooseBoolean( + charset_subsets[curval].assumed_idx, + L_ASSUME_CHARSET, -1, + assumed_charset_choices)]; +#else + UCLYhndl_for_unspec = LYChooseBoolean(curval, L_ASSUME_CHARSET, -1, assume_list); +#endif } else { - UCLYhndl_for_unspec = popup_choice(curval, +#ifndef ALL_CHARSETS_IN_O_MENU_SCREEN + UCLYhndl_for_unspec = assumed_doc_charset_map[LYChoosePopup( + charset_subsets[curval].assumed_idx, + L_ASSUME_CHARSET, -1, + assumed_charset_choices, + 0, FALSE, FALSE)]; +#else + UCLYhndl_for_unspec = LYChoosePopup(curval, L_ASSUME_CHARSET, -1, assume_list, - 0, FALSE, FALSE); + 0, FALSE, FALSE); +#endif #if defined(VMS) || defined(USE_SLANG) move(L_ASSUME_CHARSET, COL_OPTION_VALUES); clrtoeol(); if (UCLYhndl_for_unspec >= 0) - addstr((char *) - LYCharSet_UC[UCLYhndl_for_unspec].MIMEname); + LYaddstr(LYCharSet_UC[UCLYhndl_for_unspec].MIMEname); #endif /* VMS || USE_SLANG */ } @@ -882,7 +898,7 @@ draw_options: StrAllocCopy(UCAssume_MIMEcharset, LYCharSet_UC[UCLYhndl_for_unspec].MIMEname); } - LYRawMode = (UCLYhndl_for_unspec == current_char_set); + LYRawMode = (BOOL) (UCLYhndl_for_unspec == current_char_set); HTMLSetUseDefaultRawMode(current_char_set, LYRawMode); HTMLSetCharacterHandling(current_char_set); CurrentAssumeCharSet = UCLYhndl_for_unspec; @@ -896,7 +912,7 @@ draw_options: addstr(LYRawMode ? "ON " : "OFF"); } } - FREE(assume_list); + FREE(TYPECAST(char *,assume_list)); response = ' '; if (LYSelectPopups) { #if !defined(VMS) || defined(USE_SLANG) @@ -919,18 +935,34 @@ draw_options: case 'c': /* Change display charset setting. */ case 'C': if (!LYSelectPopups) { - current_char_set = boolean_choice(current_char_set, +#ifndef ALL_CHARSETS_IN_O_MENU_SCREEN + displayed_display_charset_idx = LYChooseBoolean(displayed_display_charset_idx, L_Charset, -1, - (char **)LYchar_set_names); + display_charset_choices); + current_char_set = display_charset_map[displayed_display_charset_idx]; +#else + current_char_set = LYChooseBoolean(current_char_set, + L_Charset, -1, + LYchar_set_names); +#endif } else { - current_char_set = popup_choice(current_char_set, +#ifndef ALL_CHARSETS_IN_O_MENU_SCREEN + displayed_display_charset_idx = LYChoosePopup(displayed_display_charset_idx, L_Charset, -1, - (char **)LYchar_set_names, + display_charset_choices, 0, FALSE, FALSE); + current_char_set = display_charset_map[displayed_display_charset_idx]; +#else + current_char_set = LYChoosePopup(current_char_set, + L_Charset, -1, + LYchar_set_names, + 0, FALSE, FALSE); +#endif + #if defined(VMS) || defined(USE_SLANG) move(L_Charset, COL_OPTION_VALUES); clrtoeol(); - addstr((char *)LYchar_set_names[current_char_set]); + LYaddstr(LYchar_set_names[current_char_set]); #endif /* VMS || USE_SLANG */ } /* @@ -976,7 +1008,7 @@ draw_options: choices[1] = NULL; StrAllocCopy(choices[1], "ON "); choices[2] = NULL; - LYRawMode = boolean_choice(LYRawMode, L_Rawmode, -1, choices); + LYRawMode = LYChooseBoolean(LYRawMode, L_Rawmode, -1, choices); /* * Set the LYUseDefaultRawMode value and character * handling if LYRawMode was changed. - FM @@ -1073,7 +1105,7 @@ draw_options: choices[1] = NULL; StrAllocCopy(choices[1], "ON "); choices[2] = NULL; - vi_keys = boolean_choice(vi_keys, + vi_keys = LYChooseBoolean(vi_keys, L_Bool_A, C_VIKEYS, choices); if (vi_keys) { @@ -1096,7 +1128,7 @@ draw_options: choices[1] = NULL; StrAllocCopy(choices[1], "ON "); choices[2] = NULL; - emacs_keys = boolean_choice(emacs_keys, + emacs_keys = LYChooseBoolean(emacs_keys, L_Bool_A, C_EMACSKEYS, choices); if (emacs_keys) { @@ -1122,7 +1154,7 @@ draw_options: choices[1] = NULL; StrAllocCopy(choices[1], "ON "); choices[2] = NULL; - show_dotfiles = boolean_choice(show_dotfiles, + show_dotfiles = LYChooseBoolean(show_dotfiles, L_Bool_A, C_SHOW_DOTFILES, choices); @@ -1142,7 +1174,7 @@ draw_options: choices[1] = NULL; StrAllocCopy(choices[1], "ON "); choices[2] = NULL; - LYSelectPopups = boolean_choice(LYSelectPopups, + LYSelectPopups = LYChooseBoolean(LYSelectPopups, L_Bool_B, C_SELECT_POPUPS, choices); @@ -1173,7 +1205,7 @@ draw_options: choices[1] = NULL; StrAllocCopy(choices[1], "ON "); choices[2] = NULL; - LYShowColor = boolean_choice((LYShowColor - 1), + LYShowColor = LYChooseBoolean((LYShowColor - 1), L_Color, C_COLOR, choices); @@ -1204,18 +1236,18 @@ draw_options: choices[4] = NULL; do { if (!LYSelectPopups) { - chosen = boolean_choice(LYChosenShowColor, + chosen = LYChooseBoolean(LYChosenShowColor, L_Color, C_COLOR, choices); } else { - chosen = popup_choice(LYChosenShowColor, + chosen = LYChoosePopup(LYChosenShowColor, L_Color, C_COLOR, choices, 4, FALSE, FALSE); } #if defined(COLOR_CURSES) - again = (chosen == 2 && !has_colors()); + again = (BOOL) (chosen == 2 && !has_colors()); if (again) { char * terminal = getenv("TERM"); if (terminal) @@ -1276,7 +1308,7 @@ draw_options: choices[1] = NULL; StrAllocCopy(choices[1], "ON "); choices[2] = NULL; - LYShowCursor = boolean_choice(LYShowCursor, + LYShowCursor = LYChooseBoolean(LYShowCursor, L_Bool_B, C_SHOW_CURSOR, choices); @@ -1301,11 +1333,11 @@ draw_options: "Links and form fields are numbered"); choices[3] = NULL; if (!LYSelectPopups) { - keypad_mode = boolean_choice(keypad_mode, + keypad_mode = LYChooseBoolean(keypad_mode, L_Keypad, -1, choices); } else { - keypad_mode = popup_choice(keypad_mode, + keypad_mode = LYChoosePopup(keypad_mode, L_Keypad, -1, choices, 3, FALSE, FALSE); @@ -1341,11 +1373,11 @@ draw_options: case 'n': /* Change line editor key bindings. */ case 'N': if (!LYSelectPopups) { - current_lineedit = boolean_choice(current_lineedit, + current_lineedit = LYChooseBoolean(current_lineedit, L_Lineed, -1, LYLineeditNames); } else { - current_lineedit = popup_choice(current_lineedit, + current_lineedit = LYChoosePopup(current_lineedit, L_Lineed, -1, LYLineeditNames, 0, FALSE, FALSE); @@ -1374,11 +1406,11 @@ draw_options: case 'y': /* Change keyboard layout */ case 'Y': if (!LYSelectPopups) { - current_layout = boolean_choice(current_layout, + current_layout = LYChooseBoolean(current_layout, L_Layout, -1, LYKbLayoutNames); } else { - current_layout = popup_choice(current_layout, + current_layout = LYChoosePopup(current_layout, L_Layout, -1, LYKbLayoutNames, 0, FALSE, FALSE); @@ -1418,11 +1450,11 @@ draw_options: StrAllocCopy(choices[2], "Mixed style "); choices[3] = NULL; if (!LYSelectPopups) { - dir_list_style = boolean_choice(dir_list_style, + dir_list_style = LYChooseBoolean(dir_list_style, L_Dired, -1, choices); } else { - dir_list_style = popup_choice(dir_list_style, + dir_list_style = LYChoosePopup(dir_list_style, L_Dired, -1, choices, 3, FALSE, FALSE); @@ -1464,16 +1496,16 @@ draw_options: StrAllocCopy(choices[2], "Advanced "); choices[3] = NULL; if (!LYSelectPopups) { - user_mode = boolean_choice(user_mode, + user_mode = LYChooseBoolean(user_mode, L_User_Mode, -1, choices); - use_assume_charset = (user_mode >= 2); + use_assume_charset = (BOOL) (user_mode >= 2); } else { - user_mode = popup_choice(user_mode, + user_mode = LYChoosePopup(user_mode, L_User_Mode, -1, choices, 3, FALSE, FALSE); - use_assume_charset = (user_mode >= 2); + use_assume_charset = (BOOL) (user_mode >= 2); #if defined(VMS) || defined(USE_SLANG) if (use_assume_charset == old_use_assume_charset) { move(L_User_Mode, COL_OPTION_VALUES); @@ -1517,12 +1549,12 @@ draw_options: StrAllocCopy(choices[1], "ON "); choices[2] = NULL; if (!LYSelectPopups) { - verbose_img = boolean_choice(verbose_img, + verbose_img = LYChooseBoolean(verbose_img, L_VERBOSE_IMAGES, C_VERBOSE_IMAGES, choices); } else { - verbose_img = popup_choice(verbose_img, + verbose_img = LYChoosePopup(verbose_img, L_VERBOSE_IMAGES, C_VERBOSE_IMAGES, choices, @@ -1594,7 +1626,7 @@ draw_options: response = ' '; break; -#ifdef ENABLE_OPTS_CHANGE_EXEC +#if defined(ENABLE_OPTS_CHANGE_EXEC) && (defined(EXEC_LINKS) || defined(EXEC_SCRIPTS)) case 'x': /* Change local exec restriction. */ case 'X': if (exec_frozen && !LYSelectPopups) { @@ -1627,11 +1659,11 @@ draw_options: choices[3] = NULL; #endif /* !NEVER_ALLOW_REMOTE_EXEC */ if (!LYSelectPopups) { - itmp = boolean_choice(itmp, + itmp = LYChooseBoolean(itmp, L_Exec, -1, choices); } else { - itmp = popup_choice(itmp, + itmp = LYChoosePopup(itmp, L_Exec, -1, choices, 0, (exec_frozen ? TRUE : FALSE), @@ -1726,7 +1758,7 @@ PRIVATE int boolean_choice ARGS4( int, cur_choice, int, line, int, column, - char **, choices) + CONST char **, choices) { int response = 0; int cmd = 0; @@ -1752,7 +1784,7 @@ PRIVATE int boolean_choice ARGS4( */ move(line, col); start_reverse(); - addstr(choices[cur_choice]); + LYaddstr(choices[cur_choice]); if (LYShowCursor) move(line, (col - 1)); refresh(); @@ -1841,7 +1873,7 @@ PRIVATE int boolean_choice ARGS4( else cur_choice++; } /* end of switch */ - addstr(choices[cur_choice]); + LYaddstr(choices[cur_choice]); if (LYShowCursor) move(line, (col - 1)); refresh(); @@ -1851,7 +1883,7 @@ PRIVATE int boolean_choice ARGS4( */ move(line, col); stop_reverse(); - addstr(choices[cur_choice]); + LYaddstr(choices[cur_choice]); if (term_options) { term_options = FALSE; @@ -1860,7 +1892,7 @@ PRIVATE int boolean_choice ARGS4( } else { _statusline(VALUE_ACCEPTED); } - return(cur_choice); + return (BOOL) (cur_choice); } } } @@ -2185,7 +2217,7 @@ PRIVATE int get_popup_choice_number ARGS1( /* * Load the c argument into the prompt buffer. */ - temp[0] = *c; + temp[0] = (char) *c; temp[1] = '\0'; _statusline(OPTION_CHOICE_NUMBER); @@ -2226,7 +2258,7 @@ PUBLIC int popup_choice ARGS7( int, cur_choice, int, line, int, column, - char **, choices, + CONST char **, choices, int, i_length, int, disabled, BOOLEAN, for_mouse) @@ -2240,7 +2272,7 @@ PUBLIC int popup_choice ARGS7( #endif /* !USE_SLANG */ int num_choices = 0, top, bottom, length = -1; unsigned width = 0; - char ** Cptr = choices; + CONST char ** Cptr = choices; int window_offset = 0; int DisplayLines = (LYlines - 2); char Cnum[64]; @@ -2450,7 +2482,7 @@ redraw: #ifdef USE_SLANG SLsmg_gotorc(top + ((i + 1) - window_offset), (lx - 1 + 2)); addstr(Cnum); - SLsmg_write_nstring(Cptr[i], width); + LYaddnstr(Cptr[i], width); #else wmove(form_window, ((i + 1) - window_offset), 2); wclrtoeol(form_window); @@ -2486,7 +2518,7 @@ redraw: #ifdef USE_SLANG SLsmg_gotorc((top + ((i + 1) - window_offset)), (lx - 1 + 2)); addstr(Cnum); - SLsmg_write_nstring(Cptr[i], width); + LYaddnstr(Cptr[i], width); #else wmove(form_window, ((i + 1) - window_offset), 2); waddstr(form_window, Cnum); @@ -2503,7 +2535,7 @@ redraw: SLsmg_gotorc((top + ((i + 1) - window_offset)), (lx - 1 + 2)); addstr(Cnum); SLsmg_set_color(2); - SLsmg_write_nstring(Cptr[i], width); + LYaddnstr(Cptr[i], width); SLsmg_set_color(0); /* * If LYShowCursor is ON, move the cursor to the left @@ -3254,7 +3286,7 @@ static char * x_display_string = "display"; static char * editor_string = "editor"; static char * emacs_keys_string = "emacs_keys"; -#ifdef ENABLE_OPTS_CHANGE_EXEC +#if defined(ENABLE_OPTS_CHANGE_EXEC) && (defined(EXEC_LINKS) || defined(EXEC_SCRIPTS)) #define EXEC_ALWAYS 2 #define EXEC_LOCAL 1 #define EXEC_NEVER 0 @@ -3638,7 +3670,7 @@ PUBLIC int postoptions ARGS1( /* Emacs keys: ON/OFF */ if (!strcmp(data[i].tag, emacs_keys_string) && GetOptValues(bool_values, data[i].value, &code)) { - if ((emacs_keys = code) != FALSE) { + if ((emacs_keys = (BOOL) code) != FALSE) { set_emacs_keys(); } else { reset_emacs_keys(); @@ -3646,7 +3678,7 @@ PUBLIC int postoptions ARGS1( } /* Execution links: SELECT */ -#ifdef ENABLE_OPTS_CHANGE_EXEC +#if defined(ENABLE_OPTS_CHANGE_EXEC) && (defined(EXEC_LINKS) || defined(EXEC_SCRIPTS)) if (!strcmp(data[i].tag, exec_links_string) && GetOptValues(exec_links_values, data[i].value, &code)) { #ifndef NEVER_ALLOW_REMOTE_EXEC @@ -3702,7 +3734,7 @@ PUBLIC int postoptions ARGS1( /* Search Type: SELECT */ if (!strcmp(data[i].tag, search_type_string) && GetOptValues(search_type_values, data[i].value, &code)) { - case_sensitive = code; + case_sensitive = (BOOL) code; } #ifndef SH_EX /* 1999/01/19 (Tue) */ @@ -3720,7 +3752,7 @@ PUBLIC int postoptions ARGS1( /* Select Popups: ON/OFF */ if (!strcmp(data[i].tag, select_popups_string) && GetOptValues(bool_values, data[i].value, &code)) { - LYSelectPopups = code; + LYSelectPopups = (BOOL) code; } #if defined(USE_SLANG) || defined(COLOR_CURSES) @@ -3741,7 +3773,7 @@ PUBLIC int postoptions ARGS1( /* Show Cursor: ON/OFF */ if (!strcmp(data[i].tag, show_cursor_string) && GetOptValues(bool_values, data[i].value, &code)) { - LYShowCursor = code; + LYShowCursor = (BOOL) code; } /* User Mode: SELECT */ @@ -3777,7 +3809,7 @@ PUBLIC int postoptions ARGS1( if (!strcmp(data[i].tag, verbose_images_string) && GetOptValues(verbose_images_type_values, data[i].value, &code)) { if (verbose_img != code) { - verbose_img = code; + verbose_img = (BOOL) code; need_reload = TRUE; } } @@ -3785,7 +3817,7 @@ PUBLIC int postoptions ARGS1( /* VI Keys: ON/OFF */ if (!strcmp(data[i].tag, vi_keys_string) && GetOptValues(bool_values, data[i].value, &code)) { - if ((vi_keys = code) != FALSE) { + if ((vi_keys = (BOOL) code) != FALSE) { set_vi_keys(); } else { reset_vi_keys(); @@ -3843,7 +3875,7 @@ PUBLIC int postoptions ARGS1( /* Raw Mode: ON/OFF */ if (!strcmp(data[i].tag, raw_mode_string) && GetOptValues(bool_values, data[i].value, &code)) { - LYRawMode = code; + LYRawMode = (BOOL) code; } /* @@ -3863,7 +3895,7 @@ PUBLIC int postoptions ARGS1( /* Show dot files: ON/OFF */ if (!strcmp(data[i].tag, show_dotfiles_string) && (!no_dotfiles) && GetOptValues(bool_values, data[i].value, &code)) { - show_dotfiles = code; + show_dotfiles = (BOOL) code; } /* Preferred Document Character Set: INPUT */ @@ -3921,7 +3953,7 @@ PUBLIC int postoptions ARGS1( HTMLUseCharacterSet(current_char_set); } if (assume_char_set_changed) { - LYRawMode = (UCLYhndl_for_unspec == current_char_set); + LYRawMode = (BOOL) (UCLYhndl_for_unspec == current_char_set); } if (raw_mode_old != LYRawMode || assume_char_set_changed) { /* @@ -4241,7 +4273,7 @@ PRIVATE int gen_options ARGS1( can_do_colors = 1; #if defined(COLOR_CURSES) if (LYCursesON) /* could crash if called before initialization */ - can_do_colors = has_colors(); + can_do_colors = (BOOL) has_colors(); #endif PutLabel(fp0, gettext("Show color")); MaybeSelect(fp0, !can_do_colors, show_color_string); @@ -4308,6 +4340,9 @@ PRIVATE int gen_options ARGS1( if (len > cset_len) cset_len = len; sprintf(temp, "%d", i); +#ifdef EXP_CHARSET_CHOICE + if (!charset_subsets[i].hide_display) +#endif PutOption(fp0, i==current_char_set, temp, LYchar_set_names[i]); } EndSelect(fp0); @@ -4339,6 +4374,9 @@ PRIVATE int gen_options ARGS1( PutLabel(fp0, gettext("Assumed document character set")); BeginSelect(fp0, assume_char_set_string); for (i = 0; i < LYNumCharsets; i++) { +#ifdef EXP_CHARSET_CHOICE + if (!charset_subsets[i].hide_assumed) +#endif PutOption(fp0, i==curval, LYCharSet_UC[i].MIMEname, LYCharSet_UC[i].MIMEname); @@ -4457,7 +4495,7 @@ PRIVATE int gen_options ARGS1( } /* Execution links: SELECT */ -#ifdef ENABLE_OPTS_CHANGE_EXEC +#if defined(ENABLE_OPTS_CHANGE_EXEC) && (defined(EXEC_LINKS) || defined(EXEC_SCRIPTS)) PutLabel(fp0, gettext("Execution links")); BeginSelect(fp0, exec_links_string); #ifndef NEVER_ALLOW_REMOTE_EXEC diff --git a/src/LYOptions.h b/src/LYOptions.h index d0dc120f..98d829d7 100644 --- a/src/LYOptions.h +++ b/src/LYOptions.h @@ -10,10 +10,12 @@ extern int popup_choice PARAMS(( int cur_choice, int line, int column, - char ** choices, - int i_length, + CONST char ** choices, + int length, int disabled, - BOOLEAN for_mouse)); + BOOLEAN mouse)); +#define LYChoosePopup(cur, line, column, choices, length, disabled, mouse) \ + popup_choice(cur, line, column, (CONST char **)choices, length, disabled, mouse) #ifndef NO_OPTION_FORMS extern int postoptions PARAMS((document *newdoc)); diff --git a/src/LYPrettySrc.c b/src/LYPrettySrc.c index 3ff99b35..f7e5538c 100644 --- a/src/LYPrettySrc.c +++ b/src/LYPrettySrc.c @@ -16,10 +16,11 @@ PUBLIC BOOL LYpsrc = FALSE; /* this tells what will be shown on '\': PUBLIC BOOL sgml_in_psrc_was_initialized; PUBLIC BOOL psrc_nested_call; PUBLIC BOOL psrc_first_tag; - +PUBLIC BOOL mark_htext_as_source=FALSE; /* tagspecs from lynx.cfg are read here. After .lss file is read (is with lss support), the style cache and markup are created before entering the mainloop. */ +PUBLIC BOOL psrcview_no_anchor_numbering = FALSE; PUBLIC char* HTL_tagspecs[HTL_num_lexems] = { /* these values are defaults. They are also listed in comments of distibution's lynx.cfg.*/ diff --git a/src/LYPrettySrc.h b/src/LYPrettySrc.h index 14f53c38..e49b3fd8 100644 --- a/src/LYPrettySrc.h +++ b/src/LYPrettySrc.h @@ -21,6 +21,8 @@ extern BOOL psrc_nested_call;/* this is used when distinguishing whether extern BOOL psrc_first_tag; /* this is also used in HTML.c to trigger the 1st tag to preform special. */ +extern BOOL mark_htext_as_source; + /* here is a list of lexem codes. */ typedef enum _HTlexem { HTL_comm=0, @@ -67,6 +69,7 @@ extern int tagname_transform; extern int attrname_transform; +extern BOOL psrcview_no_anchor_numbering; #endif /* ifdef USE_PSRC */ diff --git a/src/LYPrint.c b/src/LYPrint.c index 4fa44c02..ed3a63d9 100644 --- a/src/LYPrint.c +++ b/src/LYPrint.c @@ -526,7 +526,7 @@ PRIVATE void send_file_to_mail ARGS3( disp_charset = NULL; use_cte = FALSE; } - use_type = (disp_charset || HTisDocumentSource()); + use_type = (BOOL) (disp_charset || HTisDocumentSource()); /* * Use newdoc->title as a subject instead of sug_filename: MORE readable @@ -705,8 +705,8 @@ PRIVATE void send_file_to_mail ARGS3( if (use_cte && !disp_charset) use_cte = FALSE; #endif /* NOTDEFINED */ - use_type = (disp_charset || HTisDocumentSource()); - use_mime = (use_cte || use_type); + use_type = (BOOL) (disp_charset || HTisDocumentSource()); + use_mime = (BOOL) (use_cte || use_type); if (use_mime) { fprintf(outfile_fp, "Mime-Version: 1.0\n"); diff --git a/src/LYReadCFG.c b/src/LYReadCFG.c index 53784dae..98525546 100644 --- a/src/LYReadCFG.c +++ b/src/LYReadCFG.c @@ -661,7 +661,7 @@ static int keymap_fun ARGS1( if (strcasecomp(efunc, "PASS!") == 0) { if (func) { lec = LYE_FORM_LAC|lacname_to_lac(func); - success = LYRemapEditBinding(lkc, lec); + success = (BOOL) LYRemapEditBinding(lkc, lec); } if (!success) fprintf(stderr, @@ -673,7 +673,7 @@ static int keymap_fun ARGS1( } if (!success && strncasecomp(efunc, "PASS", 4) == 0) { lec = LYE_FORM_PASS; - success = LYRemapEditBinding(lkc, lec); + success = (BOOL) LYRemapEditBinding(lkc, lec); } if (!success) { if (lec != -1) { @@ -756,8 +756,8 @@ static int news_max_chunk_fun ARGS1( static int news_posting_fun ARGS1( char *, value) { - LYNewsPosting = is_true(value); - no_newspost = (LYNewsPosting == FALSE); + LYNewsPosting = (BOOL) is_true(value); + no_newspost = (BOOL) (LYNewsPosting == FALSE); return 0; } #endif /* DISABLE_NEWS */ @@ -901,9 +901,9 @@ static int nonrest_sigwinch_fun ARGS1( char *, value) { if (!strncasecomp(value, "XWINDOWS", 8)) { - LYNonRestartingSIGWINCH = (LYgetXDisplay() != NULL); + LYNonRestartingSIGWINCH = (BOOL) (LYgetXDisplay() != NULL); } else { - LYNonRestartingSIGWINCH = is_true(value); + LYNonRestartingSIGWINCH = (BOOL) is_true(value); } return 0; } @@ -957,6 +957,91 @@ static int parse_html_src_spec ARGS3( return 0; } +#ifdef EXP_CHARSET_CHOICE +PRIVATE void matched_charset_choice ARGS2( + BOOL, display_charset, + int, i) +{ + int j; + + if (display_charset && !custom_display_charset) { + for (custom_display_charset = TRUE, j = 0; j < LYNumCharsets; ++j) + charset_subsets[j].hide_display = TRUE; + } else if (!display_charset && !custom_assumed_doc_charset) { + for (custom_assumed_doc_charset = TRUE, j = 0; j < LYNumCharsets; ++j) + charset_subsets[j].hide_assumed = TRUE; + } + if (display_charset) + charset_subsets[i].hide_display = FALSE; + else + charset_subsets[i].hide_assumed = FALSE; +} + +PRIVATE int parse_charset_choice ARGS2( + char *, p, + BOOL, display_charset) /*if FALSE, then assumed doc charset*/ +{ + int len, i; + int matches = 0; + + /*only one charset choice is allowed per line!*/ + LYTrimHead(p); + LYTrimTail(p); + CTRACE(tfp, "parsing charset choice for %s:\"%s\"", + (display_charset ? "display charset" : "assumed doc charset"), p); + len = strlen(p); + if (!len) { + CTRACE(tfp," - EMPTY STRING\n"); + return 1; + } + if (*p == '*' && len == 1) { + if (display_charset) + for (custom_display_charset = TRUE, i = 0 ;i < LYNumCharsets; ++i) + charset_subsets[i].hide_display = FALSE; + else + for (custom_assumed_doc_charset = TRUE, i = 0; i < LYNumCharsets; ++i) + charset_subsets[i].hide_assumed = FALSE; + CTRACE(tfp," - all unhidden\n"); + return 0; + } + if (p[len-1] == '*') { + --len; + for (i = 0 ;i < LYNumCharsets; ++i) { + if ((!strncasecmp(p, LYchar_set_names[i], len)) || + (!strncasecmp(p, LYCharSet_UC[i].MIMEname, len)) ) { + ++matches; + matched_charset_choice(display_charset, i); + } + } + CTRACE(tfp," - %d matches\n", matches); + return 0; + } else { + for (i = 0; i < LYNumCharsets; ++i) { + if ((!strcasecmp(p,LYchar_set_names[i])) || + (!strcasecmp(p,LYCharSet_UC[i].MIMEname)) ) { + matched_charset_choice(display_charset, i); + CTRACE(tfp," - OK\n"); + ++matches; + return 0; + } + } + CTRACE(tfp," - NOT recognised\n"); + return 1; + } +} + +PRIVATE int parse_display_charset_choice ARGS1(char*,p) +{ + return parse_charset_choice(p,1); +} + +PRIVATE int parse_assumed_doc_charset_choice ARGS1(char*,p) +{ + return parse_charset_choice(p,0); +} + +#endif /* EXP_CHARSET_CHOICE */ + #if defined(__STDC__) || defined(_WIN_CC) #define defHTSRC_parse_fun(x) static int html_src_set_##x ARGS1( char*,str) \ { parse_html_src_spec(HTL_##x,str,#x); return 0; } @@ -1035,6 +1120,9 @@ static Config_Type Config_Table [] = PARSE_FUN("assume_charset", CONF_FUN, assume_charset_fun), PARSE_FUN("assume_local_charset", CONF_FUN, assume_local_charset_fun), PARSE_FUN("assume_unrec_charset", CONF_FUN, assume_unrec_charset_fun), +#ifdef EXP_CHARSET_CHOICE + PARSE_FUN("assumed_doc_charset_choice",CONF_FUN,parse_assumed_doc_charset_choice), +#endif PARSE_SET("block_multi_bookmarks", CONF_BOOL, &LYMBMBlocked), PARSE_SET("bold_h1", CONF_BOOL, &bold_H1), PARSE_SET("bold_headers", CONF_BOOL, &bold_headers), @@ -1069,6 +1157,9 @@ static Config_Type Config_Table [] = #endif #ifdef DIRED_SUPPORT PARSE_FUN("dired_menu", CONF_FUN, dired_menu_fun), +#endif +#ifdef EXP_CHARSET_CHOICE + PARSE_FUN("display_charset_choice",CONF_FUN,parse_display_charset_choice), #endif PARSE_ADD("downloader", CONF_ADD_ITEM, downloaders), PARSE_SET("emacs_keys_always_on", CONF_BOOL, &emacs_keys), @@ -1203,6 +1294,9 @@ static Config_Type Config_Table [] = PARSE_SET("prepend_base_to_source", CONF_BOOL, &LYPrependBaseToSource), PARSE_SET("prepend_charset_to_source", CONF_BOOL, &LYPrependCharsetToSource), PARSE_FUN("printer", CONF_FUN, printer_fun), +#ifdef USE_PSRC + PARSE_SET("psrcview_no_anchor_numbering", CONF_BOOL, &psrcview_no_anchor_numbering), +#endif PARSE_SET("quit_default_yes", CONF_BOOL, &LYQuitDefaultYes), PARSE_SET("reuse_tempfiles", CONF_BOOL, &LYReuseTempfiles), #ifndef NO_RULES @@ -1318,7 +1412,7 @@ PRIVATE Config_Type *lookup_config ARGS1( char *, name) { Config_Type *tbl = Config_Table; - char ch = TOUPPER(*name); + char ch = (char) TOUPPER(*name); while (tbl->name != 0) { char ch1 = tbl->name[0]; @@ -1481,7 +1575,7 @@ PRIVATE void do_read_cfg ARGS5( : tbl->type) { case CONF_BOOL: if (q->set_value != 0) - *(q->set_value) = is_true (value); + *(q->set_value) = (BOOL) is_true (value); break; case CONF_FUN: diff --git a/src/LYSearch.c b/src/LYSearch.c index a9cace09..995d8135 100644 --- a/src/LYSearch.c +++ b/src/LYSearch.c @@ -147,23 +147,23 @@ PRIVATE int check_for_target_in_links ARGS2( if (i == nlinks) return(FALSE); - + *cur = i; return(TRUE); } /* * Textsearch checks the prev_target variable to see if it is empty. - * If it is then it requests a new search string. It then searches + * If it is then it requests a new search string. It then searches * the current file for the next instance of the search string and * finds the line number that the string is on - * + * * This is the primary USER search engine and is case sensitive * or case insensitive depending on the 'case_sensitive' global * variable * */ - + PUBLIC BOOL textsearch ARGS3( document *, cur_doc, char *, prev_target, @@ -352,9 +352,9 @@ check_recall: * Found in link, changed cur, we're done. */ highlight(OFF, oldcur, prev_target); - return(TRUE); + return(TRUE); } - + /* * We'll search the text starting from the * link we are on, or the next page. @@ -374,5 +374,5 @@ check_recall: highlight(OFF, oldcur, prev_target); return(TRUE); } - return(www_search_result > 0); + return (BOOL) (www_search_result > 0); } diff --git a/src/LYShowInfo.c b/src/LYShowInfo.c index d7389761..1c8af4d7 100644 --- a/src/LYShowInfo.c +++ b/src/LYShowInfo.c @@ -40,7 +40,7 @@ PUBLIC int showinfo ARGS4( char *name; CONST char *cp; #ifdef ADVANCED_INFO - BOOLEAN LYInfoAdvanced = (user_mode == ADVANCED_MODE); + BOOLEAN LYInfoAdvanced = (BOOL) (user_mode == ADVANCED_MODE); #endif #ifdef DIRED_SUPPORT diff --git a/src/LYStrings.c b/src/LYStrings.c index 1d7976bf..51d3df31 100644 --- a/src/LYStrings.c +++ b/src/LYStrings.c @@ -562,7 +562,11 @@ PUBLIC int LYmbcsstrlen ARGS2( #define GetChar SLkp_getkey #endif /* DJGPP_KEYHANDLER */ #else +#ifdef __CYGWIN__ +#define GetChar SLkp_getkey +#else #define GetChar (int)SLang_getkey +#endif /* __CYGWIN__ */ #endif /* __DJGPP__ */ #endif /* VMS */ #endif /* USE_SLANG */ @@ -1249,11 +1253,11 @@ PRIVATE int LYmouse_menu ARGS4(int, x, int, y, int, atlink, int, code) /* Somehow the mouse is over the number instead of being over the name, so we decrease x. */ - c = popup_choice((atlink ? 2 : 10) - 1, y, (x > 5 ? x-5 : 1), + c = LYChoosePopup((atlink ? 2 : 10) - 1, y, (x > 5 ? x-5 : 1), (atlink ? choices_link : choices), (atlink - ? (sizeof(actions_link)/sizeof(int)) - : (sizeof(actions)/sizeof(int))), FALSE, TRUE); + ? TABLESIZE(actions_link) + : TABLESIZE(actions)), FALSE, TRUE); /* * popup_choice() in LYOptions.c wasn't really meant to be used @@ -1590,7 +1594,7 @@ re_read: current_modifier = LKC_MOD2; c = a; /* We're not yet done if ESC + curses-keysym: */ - done_esc = ((a & ~0xFF) == 0); + done_esc = (BOOL) ((a & ~0xFF) == 0); break; } CTRACE(tfp,"Unknown key sequence: %d:%d:%d\n",c,b,a); @@ -2070,7 +2074,7 @@ re_read: } } #endif /* DGJPP_KEYHANDLER */ -#if defined(USE_SLANG) && defined(__DJGPP__) && !defined(DJGPP_KEYHANDLER) && !defined(USE_KEYMAPS) +#if defined(USE_SLANG) && (defined(__DJGPP__) || defined(__CYGWIN__)) && !defined(DJGPP_KEYHANDLER) && !defined(USE_KEYMAPS) else { switch(c) { case SL_KEY_DOWN: /* The four arrow keys ... */ @@ -2152,7 +2156,7 @@ PUBLIC void LYLowerCase ARGS1( } i++; } else { - buffer[i] = TOLOWER(buffer[i]); + buffer[i] = (unsigned char) TOLOWER(buffer[i]); } } #else @@ -2732,7 +2736,7 @@ PUBLIC int LYEdit1 ARGS4( Pos++; return(0); } - i = Buf[Pos-1]; Buf[Pos-1] = Buf[Pos]; Buf[Pos++] = i; + i = Buf[Pos-1]; Buf[Pos-1] = Buf[Pos]; Buf[Pos++] = (char) i; break; case LYE_SETMARK: @@ -3143,7 +3147,8 @@ again: * Terminate the string and return. */ strcpy(inputline, MyEdit.buffer); - LYAddToCloset(MyEdit.buffer); + if (!hidden) + LYAddToCloset(MyEdit.buffer); return(ch); #if defined(WIN_EX) diff --git a/src/LYStyle.c b/src/LYStyle.c index 4943ca7f..0b8a5dd1 100644 --- a/src/LYStyle.c +++ b/src/LYStyle.c @@ -1,6 +1,6 @@ /* character level styles for Lynx * (c) 1996 Rob Partington -- donated to the Lyncei (if they want it :-) - * @Id: LYStyle.c 1.31 Fri, 13 Aug 1999 07:27:27 -0600 dickey @ + * @Id: LYStyle.c 1.32 Thu, 26 Aug 1999 05:31:19 -0600 dickey @ */ #include #include @@ -33,22 +33,24 @@ PUBLIC int last_colorattr_ptr=0; PUBLIC bucket hashStyles[CSHASHSIZE]; PUBLIC bucket special_bucket = { - "" /* in order something to be in trace. */ + "", /* in order something to be in trace. */ + 0, 0, 0, 0, NULL }; PUBLIC bucket nostyle_bucket = { - "" /* in order something to be in trace. */ + "", /* in order something to be in trace. */ + 0, 0, 0, 0, NULL }; PUBLIC int cached_tag_styles[HTML_ELEMENTS]; PUBLIC int current_tag_style; -PUBLIC BOOL force_current_tag_style=FALSE; +PUBLIC BOOL force_current_tag_style = FALSE; PUBLIC char* forced_classname; PUBLIC BOOL force_classname; /* definitions for the mono attributes we can use */ static int ncursesMono[7] = { - A_NORMAL, A_BOLD, A_REVERSE, A_UNDERLINE, A_STANDOUT, A_BLINK, A_DIM + A_NORMAL, A_BOLD, A_REVERSE, A_UNDERLINE, A_STANDOUT, A_BLINK, A_DIM }; /* @@ -57,7 +59,7 @@ static int ncursesMono[7] = { */ static char *Mono_Strings[7] = { - "normal", "bold", "reverse", "underline", "standout", "blink", "dim" + "normal", "bold", "reverse", "underline", "standout", "blink", "dim" }; /* Remember the hash codes for common elements */ diff --git a/src/LYTraversal.c b/src/LYTraversal.c index 6af29e1c..9aa1d97c 100644 --- a/src/LYTraversal.c +++ b/src/LYTraversal.c @@ -58,7 +58,7 @@ PUBLIC BOOLEAN lookup ARGS1(char *,target) FREE(buffer); fclose(ifp); - return(result); + return (BOOL) (result); } PUBLIC void add_to_table ARGS1(char *,target) @@ -169,5 +169,5 @@ PUBLIC BOOLEAN lookup_reject ARGS1(char *,target) FREE(line); fclose(ifp); - return(result); + return (BOOL) (result); } diff --git a/src/LYUtils.c b/src/LYUtils.c index f15839a3..1501c80b 100644 --- a/src/LYUtils.c +++ b/src/LYUtils.c @@ -17,6 +17,11 @@ #include #include +#ifdef __DJGPP__ +#include +#include +#endif /* __DJGPP__ */ + #ifndef NO_GROUPS #include #endif @@ -130,7 +135,7 @@ PUBLIC void highlight ARGS3( int LenNeeded; BOOL TargetEmphasisON = FALSE; #endif - BOOL utf_flag = (LYCharSet_UC[current_char_set].enc == UCT_ENC_UTF8); + BOOL utf_flag = (BOOL)(LYCharSet_UC[current_char_set].enc == UCT_ENC_UTF8); #if defined(USE_COLOR_STYLE) && !defined(NO_HILIT_FIX) BOOL hl2_drawn=FALSE; /* whether links[cur].hightext2 is already drawn properly */ @@ -2097,7 +2102,7 @@ PUBLIC int LYConsoleInputFD ARGS1( #ifdef USE_SLANG if (!LYCursesON) fd = fileno(stdin); -#if SLANG_VERSION >= 9919 +#if ((SLANG_VERSION >= 9919) && defined(UNIX)) /* SLang_TT_Read_FD introduced in slang 0.99.19, from its changelog: * SLang_TT_Read_FD variable is now available for unix. This is the file * descriptor used by SLang_getkey. */ @@ -2382,13 +2387,13 @@ PUBLIC BOOLEAN LYisAbsPath ARGS1( { BOOLEAN result; #ifdef DOSPATH - result = (LYIsPathSep(path[0]) + result = (BOOL) (LYIsPathSep(path[0]) || (isalpha(path[0]) && (path[1] == ':') && LYIsPathSep(path[2]))); #else result = (LYIsPathSep(path[0])); -#endif /* __DJGPP__ */ +#endif /* DOSPATH */ return result; } @@ -2405,7 +2410,7 @@ PUBLIC BOOLEAN LYisRootPath ARGS1( && LYIsPathSep(path[2])) return TRUE; #endif - return ((strlen(path) == 1) && LYIsPathSep(path[0])); + return (BOOL) ((strlen(path) == 1) && LYIsPathSep(path[0])); } /* @@ -4731,7 +4736,8 @@ PUBLIC int win32_check_interrupt() void sleep(unsigned sec) { - int i, j, c; + unsigned int i, j; + int c; for (j = 0; j < sec; j++) { for (i = 0; i < 10; i++) { @@ -4775,7 +4781,7 @@ PUBLIC BOOLEAN LYExpandHostForURL ARGS3( char *Path = NULL; char *Fragment = NULL; BOOLEAN GotHost = FALSE; - BOOLEAN Startup = (helpfilepath == NULL); + BOOLEAN Startup = (BOOL) (helpfilepath == NULL); #ifdef _WINDOWS int hoststat; struct hostent *phost; /* Pointer to host - See netdb.h */ @@ -4851,11 +4857,8 @@ PUBLIC BOOLEAN LYExpandHostForURL ARGS3( } else if (Startup && !dump_output_immediately) { fprintf(stdout, "%s '%s'%s\n", WWW_FIND_MESSAGE, host, FIRST_SEGMENT); } -#ifndef DJGPP + if (LYGetHostByName(host) != NULL) -#else - if (resolve(host) != 0) -#endif /* DJGPP */ { /* * Clear any residual interrupt. - FM @@ -4875,11 +4878,11 @@ PUBLIC BOOLEAN LYExpandHostForURL ARGS3( FREE(MsgStr); return GotHost; } -#ifndef DJGPP - else if (LYCursesON && (lynx_nsl_status == HT_INTERRUPTED)) -#else /* DJGPP */ +#if defined(__DJGPP__) && !defined(WATT32) else if (LYCursesON && HTCheckForInterrupt()) -#endif /* DJGPP */ +#else /* normal systems */ + else if (LYCursesON && (lynx_nsl_status == HT_INTERRUPTED)) +#endif { /* * Give the user chance to interrupt lookup cycles. - KW & FM @@ -4976,11 +4979,7 @@ PUBLIC BOOLEAN LYExpandHostForURL ARGS3( } else if (Startup && !dump_output_immediately) { fprintf(stdout, "%s '%s'%s\n", WWW_FIND_MESSAGE, host, GUESSING_SEGMENT); } -#ifdef DJGPP - GotHost = (resolve(host) != 0); -#else - GotHost = (LYGetHostByName(host) != NULL); -#endif /* DJGPP */ + GotHost = (BOOL) (LYGetHostByName(host) != NULL); if (HostColon != NULL) { *HostColon = ':'; } @@ -4988,11 +4987,11 @@ PUBLIC BOOLEAN LYExpandHostForURL ARGS3( /* * Give the user chance to interrupt lookup cycles. - KW */ -#ifdef DJGPP +#if defined(__DJGPP__) && !defined(WATT32) if (LYCursesON && HTCheckForInterrupt()) -#else /* !DJGPP */ +#else /* normal systems */ if (LYCursesON && (lynx_nsl_status == HT_INTERRUPTED)) -#endif /* DJGPP */ +#endif { CTRACE(tfp, "LYExpandHostForURL: Interrupted while '%s' failed to resolve.\n", @@ -5206,7 +5205,7 @@ PUBLIC void LYTrimRelFromAbsPath ARGS1( /* * Check whether the path has a terminal slash. - FM */ - TerminalSlash = LYIsPathSep(path[(strlen(path) - 1)]); + TerminalSlash = (BOOL) (LYIsPathSep(path[(strlen(path) - 1)])); /* * Simplify the path and then do any necessary trimming. - FM @@ -6166,7 +6165,7 @@ PRIVATE FILE *OpenHiddenFile ARGS2(char *, name, char *, mode) fd = open(name, O_CREAT|O_EXCL|O_WRONLY, HIDE_CHMOD); } if (fd >= 0) { -#ifdef O_BINARY /* for __CYGWIN_ */ +#if defined(O_BINARY) && defined(__CYGWIN__) if (mode[1] == 'b') setmode(fd, O_BINARY); #endif @@ -6450,7 +6449,7 @@ PUBLIC FILE *LYOpenTempRewrite ARGS3( #ifndef NO_GROUPS writable_exists = HTEditable(fname); /* existing, can write */ #else - writable_exists = (stat(fname, &stat_buf) == 0); /* existing, assume can write */ + writable_exists = (BOOL) (stat(fname, &stat_buf) == 0); /* existing, assume can write */ #endif if (writable_exists) { diff --git a/src/LYrcFile.c b/src/LYrcFile.c index cc9d6221..adcc312f 100644 --- a/src/LYrcFile.c +++ b/src/LYrcFile.c @@ -480,7 +480,7 @@ PUBLIC void read_rc NOPARAMS #endif /* DISP_PARTIAL */ #endif /* NOTUSED */ -#ifdef ENABLE_OPTS_CHANGE_EXEC +#if defined(ENABLE_OPTS_CHANGE_EXEC) && (defined(EXEC_LINKS) || defined(EXEC_SCRIPTS)) /* * Local execution mode - all links. */ diff --git a/src/UCAux.c b/src/UCAux.c index bf4ab8b0..dd8e9cb3 100644 --- a/src/UCAux.c +++ b/src/UCAux.c @@ -172,7 +172,7 @@ PUBLIC void UCSetTransParams ARGS5( ** The "transparent" display character set is a ** "super raw mode". - FM */ - pT->transp = (!strcmp(p_in->MIMEname, "x-transparent") || + pT->transp = (BOOL) (!strcmp(p_in->MIMEname, "x-transparent") || !strcmp(p_out->MIMEname, "x-transparent")); if (pT->transp) { @@ -186,8 +186,8 @@ PUBLIC void UCSetTransParams ARGS5( pT->use_raw_char_in = TRUE; pT->strip_raw_char_in = FALSE; pT->pass_160_173_raw = TRUE; - pT->repl_translated_C0 = (p_out->enc == UCT_ENC_8BIT_C0); - pT->trans_C0_to_uni = (p_in->enc == UCT_ENC_8BIT_C0 || + pT->repl_translated_C0 = (BOOL) (p_out->enc == UCT_ENC_8BIT_C0); + pT->trans_C0_to_uni = (BOOL) (p_in->enc == UCT_ENC_8BIT_C0 || p_out->enc == UCT_ENC_8BIT_C0); } else { /* @@ -199,13 +199,13 @@ PUBLIC void UCSetTransParams ARGS5( ** Set this element if we want to treat ** the input as CJK. - FM */ - pT->do_cjk = ((p_in->enc == UCT_ENC_CJK) && (HTCJK != NOCJK)); + pT->do_cjk = (BOOL) ((p_in->enc == UCT_ENC_CJK) && (HTCJK != NOCJK)); /* ** Set these elements based on whether ** we are dealing with UTF-8. - FM */ - pT->decode_utf8 = (p_in->enc == UCT_ENC_UTF8); - pT->output_utf8 = (p_out->enc == UCT_ENC_UTF8); + pT->decode_utf8 = (BOOL) (p_in->enc == UCT_ENC_UTF8); + pT->output_utf8 = (BOOL) (p_out->enc == UCT_ENC_UTF8); if (pT->do_cjk) { /* ** Set up the structure for a CJK input with @@ -227,7 +227,7 @@ PUBLIC void UCSetTransParams ARGS5( ** equivalent to them, i.e., if we have UCS without ** having to do a table translation. */ - intm_ucs = (cs_in == LATIN1 || pT->decode_utf8 || + intm_ucs = (BOOL) (cs_in == LATIN1 || pT->decode_utf8 || (p_in->codepoints & (UCT_CP_SUBSETOF_LAT1|UCT_CP_SUBSETOF_UCS2))); /* @@ -237,7 +237,7 @@ PUBLIC void UCSetTransParams ARGS5( ** that use the transformation structure, so it is ** treated as already Unicode here. */ - pT->trans_to_uni = (!intm_ucs && + pT->trans_to_uni = (BOOL) (!intm_ucs && UCCanUniTranslateFrom(cs_in)); /* ** We set this if we are translating to Unicode and @@ -245,12 +245,12 @@ PUBLIC void UCSetTransParams ARGS5( ** fact are encoding octets for the input charset ** (presently, this applies to VISCII). - FM */ - pT->trans_C0_to_uni = (pT->trans_to_uni && + pT->trans_C0_to_uni = (BOOL) (pT->trans_to_uni && p_in->enc == UCT_ENC_8BIT_C0); /* ** We set this, presently, for VISCII. - FM */ - pT->repl_translated_C0 = (p_out->enc == UCT_ENC_8BIT_C0); + pT->repl_translated_C0 = (BOOL) (p_out->enc == UCT_ENC_8BIT_C0); /* ** Currently unused for any charset combination. ** Should always be FALSE @@ -260,7 +260,7 @@ PUBLIC void UCSetTransParams ARGS5( ** use_ucs should be set TRUE if we have or will create ** Unicode values for input octets or UTF multibytes. - FM */ - use_ucs = (intm_ucs || pT->trans_to_uni); + use_ucs = (BOOL) (intm_ucs || pT->trans_to_uni); /* ** This is set TRUE if use_ucs was set FALSE. It is ** complementary to the HTPassEightBitRaw flag, which @@ -268,19 +268,19 @@ PUBLIC void UCSetTransParams ARGS5( ** setting in relation to the current Display Character ** Set. - FM */ - pT->do_8bitraw = (!use_ucs); + pT->do_8bitraw = (BOOL) (!use_ucs); /* ** This is set TRUE when 160 and 173 should not be ** treated as nbsp and shy, respectively. - FM */ - pT->pass_160_173_raw = (!use_ucs && + pT->pass_160_173_raw = (BOOL) (!use_ucs && !(p_in->like8859 & UCT_R_8859SPECL)); /* ** This is set when the input and output charsets match, ** and they are not ones which should go through a Unicode ** translation process anyway. - FM */ - pT->use_raw_char_in = (!pT->output_utf8 && + pT->use_raw_char_in = (BOOL) (!pT->output_utf8 && cs_in == cs_out && !pT->trans_C0_to_uni); /* @@ -292,7 +292,7 @@ PUBLIC void UCSetTransParams ARGS5( ** above, but also on HTPassEightBitRaw in any functions ** which use the transformation structure.. - FM */ - pT->trans_from_uni = (use_ucs && !pT->do_8bitraw && + pT->trans_from_uni = (BOOL) (use_ucs && !pT->do_8bitraw && !pT->use_raw_char_in && UCCanTranslateUniTo(cs_out)); } diff --git a/src/UCdomap.c b/src/UCdomap.c index b77bacfd..73b89bcd 100644 --- a/src/UCdomap.c +++ b/src/UCdomap.c @@ -587,7 +587,7 @@ PRIVATE int con_insert_unipair ARGS3( else uni_pagedir[n] = p1; if ( !p1 ) - return -ENOMEM; + return -1; for (i = 0; i < 32; i++) { p1[i] = NULL; @@ -597,7 +597,7 @@ PRIVATE int con_insert_unipair ARGS3( if (!(p2 = p1[n = (unicode >> 6) & 0x1f])) { p2 = p1[n] = (u16 *)malloc(64*sizeof(u16)); if (!p2) - return -ENOMEM; + return -1; for (i = 0; i < 64; i++) { p2[i] = 0xffff; /* No glyph for this character (yet) */ @@ -629,7 +629,7 @@ PRIVATE int con_insert_unipair_str ARGS3( else uni_pagedir_str[n] = p1; if ( !p1 ) - return -ENOMEM; + return -1; for (i = 0; i < 32; i++) { p1[i] = NULL; @@ -640,7 +640,7 @@ PRIVATE int con_insert_unipair_str ARGS3( if (!p1[n]) { p1[n] = (char **)malloc(64*sizeof(char *)); if (!p1[n]) - return -ENOMEM; + return -1; p2 = (CONST char **)p1[n]; for (i = 0; i < 64; i++) { @@ -891,7 +891,7 @@ PRIVATE int con_get_unimap ARGS3( } } *uct = ect; - return ((ect <= ct) ? 0 : -ENOMEM); + return ((ect <= ct) ? 0 : -1); } #endif /* NOTDEFINED */ @@ -1046,6 +1046,8 @@ PUBLIC int UCTransUniChar ARGS2( CONST u16 * ut; if ((UChndl_out = LYCharSet_UC[charset_out].UChndl) < 0) { + if (LYCharSet_UC[charset_out].codepage < 0) + return (unicode < 128) ? (int)unicode : LYCharSet_UC[charset_out].codepage; if ((UChndl_out = default_UChndl) < 0) return -12; isdefault = 1; @@ -1100,6 +1102,8 @@ PUBLIC int UCTransUniCharStr ARGS5( return -13; if ((UChndl_out = LYCharSet_UC[charset_out].UChndl) < 0) { + if (LYCharSet_UC[charset_out].codepage < 0) + return LYCharSet_UC[charset_out].codepage; if ((UChndl_out = default_UChndl) < 0) return -12; isdefault = 1; @@ -1231,6 +1235,8 @@ PUBLIC int UCTransChar ARGS3( if ((UChndl_in = LYCharSet_UC[charset_in].UChndl) < 0) return -11; if ((UChndl_out = LYCharSet_UC[charset_out].UChndl) < 0) { + if (LYCharSet_UC[charset_out].codepage < 0) + return LYCharSet_UC[charset_out].codepage; if ((UChndl_out = default_UChndl) < 0) return -12; isdefault = 1; @@ -1322,7 +1328,7 @@ PUBLIC int UCReverseTransChar ARGS3( int, charset_out) { int Gn; - int rc; + int rc = -1; int UChndl_in, UChndl_out; int isdefault; int i_ch = (unsigned char)ch_out; @@ -1341,6 +1347,8 @@ PUBLIC int UCReverseTransChar ARGS3( if (charset_out < 0) return -12; if ((UChndl_out = LYCharSet_UC[charset_out].UChndl) < 0) { + if (LYCharSet_UC[charset_out].codepage < 0) + return LYCharSet_UC[charset_out].codepage; if ((UChndl_out = default_UChndl) < 0) return -12; isdefault = 1; @@ -1357,19 +1365,14 @@ PUBLIC int UCReverseTransChar ARGS3( */ ut = UCInfo[UChndl_out].unitable; if (ut == UC_current_unitable) { - if ((Gn = UCInfo[UChndl_in].GN) >= 0) { - UC_translate = set_translate(Gn); - rc = inv_translate[i_ch]; - if (rc >= 32) { - return rc; - } - } else { + if ((Gn = UCInfo[UChndl_in].GN) < 0) { Gn = UC_MapGN(UChndl_in,1); - UC_translate = set_translate(Gn); + } + UC_translate = set_translate(Gn); + if (inv_translate) rc = inv_translate[i_ch]; - if (rc >= 32) { - return rc; - } + if (rc >= 32) { + return rc; } } } @@ -1411,6 +1414,8 @@ PUBLIC int UCTransCharStr ARGS6( if (!UCInfo[UChndl_in].num_uni) return -11; if ((UChndl_out = LYCharSet_UC[charset_out].UChndl) < 0) { + if (LYCharSet_UC[charset_out].codepage < 0) + return LYCharSet_UC[charset_out].codepage; if ((UChndl_out = default_UChndl) < 0) return -12; isdefault = 1; @@ -1702,7 +1707,7 @@ PRIVATE CONST char ** UC_setup_LYCharSets_repl ARGS2( CONST char **p; char **prepl; CONST u16 *pp; - CONST char **tp; + char **tp; CONST char *s7; CONST char *s8; size_t i; @@ -1713,7 +1718,7 @@ PRIVATE CONST char ** UC_setup_LYCharSets_repl ARGS2( /* * Create a temporary table for reverse lookup of latin1 codes: */ - tp = (CONST char **)malloc(96 * sizeof(CONST char *)); + tp = (char **)malloc(96 * sizeof(CONST char *)); if (!tp) return NULL; for (i = 0; i < 96; i++) @@ -1758,7 +1763,7 @@ PRIVATE CONST char ** UC_setup_LYCharSets_repl ARGS2( list = UCInfo[UC_charset_in_hndl].replacedesc.entries; while (ct--) { if ((k = list->unicode) >= 160 && k < 256) { - tp[k-160] = list->replace_str; + tp[k-160] = (char *)(list->replace_str); } list++; } @@ -2003,6 +2008,113 @@ PUBLIC void UC_Charset_Setup ARGS9( return; } +/* + * UC_NoUctb_Register_with_LYCharSets, UC_Charset_NoUctb_Setup - + * Alternative functions for adding character set info to the lists + * kept in LYCharSets.c. + * These are for character sets without any real tables of their own. + * We don't keep an entry in UCinfo[] for them. + */ +PRIVATE int UC_NoUctb_Register_with_LYCharSets ARGS5( + CONST char *, UC_MIMEcharset, + CONST char *, UC_LYNXcharset, + int, lowest_eightbit, + int, UC_rawuni, + int, codepage) +{ + int i, LYhndl = -1; + + if (LYNumCharsets == 0) { + /* + * Initialize here; so whoever changes + * LYCharSets.c doesn't have to count... + */ + for (i = 0; (i < MAXCHARSETS) && LYchar_set_names[i]; i++) { + LYNumCharsets = i+1; + } + } + + /* + * Search by MIME name, (LYchar_set_names may differ...) + * ignore if already present! + */ + for (i = 0; i < MAXCHARSETS && LYchar_set_names[i] && LYhndl < 0; i++) { + if (LYCharSet_UC[i].MIMEname && + !strcmp(UC_MIMEcharset, LYCharSet_UC[i].MIMEname)) { + return -1; + } + } + + /* not found */ + if (LYNumCharsets >= MAXCHARSETS) { + CTRACE(tfp, "UC_NoUctb_Register_with_LYCharSets: Too many. Ignoring %s/%s.", + UC_MIMEcharset, UC_LYNXcharset); + return -1; + } + /* + * Add to LYCharSets.c lists. + */ + LYhndl = LYNumCharsets; + LYNumCharsets ++; + LYlowest_eightbit[LYhndl] = lowest_eightbit; + LYCharSets[LYhndl] = SevenBitApproximations; + LYchar_set_names[LYhndl] = UC_LYNXcharset; + LYchar_set_names[LYhndl+1] = NULL; + /* + * Terminating NULL may be looked for by Lynx code. + */ + + LYCharSet_UC[LYhndl].UChndl = -1; /* no corresponding UChndl ! */ + LYCharSet_UC[LYhndl].MIMEname = UC_MIMEcharset; + LYCharSet_UC[LYhndl].enc = UC_rawuni; + LYCharSet_UC[LYhndl].codepage = codepage; + + /* + * @@@ We really SHOULD get more info from the table files, + * and set relevant flags in the LYCharSet_UC[] entry with + * that info... For now, let's try it without. - KW + */ + + return LYhndl; +} + +/* + * A wrapper for the previous function. + */ +PRIVATE void UC_Charset_NoUctb_Setup ARGS6( + CONST char *, UC_MIMEcharset, + CONST char *, UC_LYNXcharset, + int, trydefault, + int, lowest_eight, + int, UC_rawuni, + int, codepage) +{ + int i; + + /* + * Ignore completely if already in slot. + */ + for (i = 0; i < UCNumCharsets; i++) { + if (!strcmp(UCInfo[i].MIMEname, UC_MIMEcharset)) { + return; + } + } + if (UC_rawuni == UCT_ENC_UTF8) + lowest_eight = 128; /* cheat here */ + /* 'codepage' doubles as a flag for 'do not try any table + ** lookup, not even default' when negative. The value will + ** be returned immediately by UCTrans* functions. + */ + if (!trydefault && codepage == 0) + codepage = -12; /* if not already set; any negative should do. */ + UC_NoUctb_Register_with_LYCharSets(UC_MIMEcharset, + UC_LYNXcharset, + lowest_eight, + UC_rawuni, + codepage); + return; +} + #ifdef LY_FIND_LEAKS PRIVATE void UCcleanup_mem NOARGS { diff --git a/src/UCdomap.h b/src/UCdomap.h index 76b56841..18c8e3d6 100644 --- a/src/UCdomap.h +++ b/src/UCdomap.h @@ -79,35 +79,25 @@ extern void UCInit NOARGS; * from Unicode mechanism). For now we use the MIME name that describes * what is output to the terminal. - KW */ -static CONST struct unimapdesc_str dfont_replacedesc_fallback = {0,NULL,0,1}; - -#define UC_CHARSET_SETUP_euc_cn UC_Charset_Setup("euc-cn","Chinese",\ - NULL,NULL,0,dfont_replacedesc_fallback,\ - 128,UCT_ENC_CJK,0) -#define UC_CHARSET_SETUP_euc_jp UC_Charset_Setup("euc-jp","Japanese (EUC-JP)",\ - NULL,NULL,0,dfont_replacedesc_fallback,\ - 128,UCT_ENC_CJK,0) -#define UC_CHARSET_SETUP_shift_jis UC_Charset_Setup("shift_jis","Japanese (Shift_JIS)",\ - NULL,NULL,0,dfont_replacedesc_fallback,\ - 128,UCT_ENC_CJK,0) -#define UC_CHARSET_SETUP_euc_kr UC_Charset_Setup("euc-kr","Korean",\ - NULL,NULL,0,dfont_replacedesc_fallback,\ - 128,UCT_ENC_CJK,0) -#define UC_CHARSET_SETUP_big5 UC_Charset_Setup("big5","Taipei (Big5)",\ - NULL,NULL,0,dfont_replacedesc_fallback,\ - 128,UCT_ENC_CJK,0) + +#define UC_CHARSET_SETUP_euc_cn UC_Charset_NoUctb_Setup("euc-cn","Chinese",\ + 1, 128,UCT_ENC_CJK,0) +#define UC_CHARSET_SETUP_euc_jp UC_Charset_NoUctb_Setup("euc-jp","Japanese (EUC-JP)",\ + 1, 128,UCT_ENC_CJK,0) +#define UC_CHARSET_SETUP_shift_jis UC_Charset_NoUctb_Setup("shift_jis","Japanese (Shift_JIS)",\ + 1, 128,UCT_ENC_CJK,0) +#define UC_CHARSET_SETUP_euc_kr UC_Charset_NoUctb_Setup("euc-kr","Korean",\ + 1, 128,UCT_ENC_CJK,0) +#define UC_CHARSET_SETUP_big5 UC_Charset_NoUctb_Setup("big5","Taipei (Big5)",\ + 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,dfont_replacedesc_fallback,\ - 128,1,0) - -static CONST struct unimapdesc_str dfont_replacedesc_NO_fallback = {0,NULL,0,0}; +#define UC_CHARSET_SETUP_x_transparent UC_Charset_NoUctb_Setup("x-transparent","Transparent",\ + 0, 128,UCT_ENC_8BIT,0) -#define UC_CHARSET_SETUP_utf_8 UC_Charset_Setup("utf-8","UNICODE (UTF-8)",\ - NULL,NULL,0,dfont_replacedesc_NO_fallback,\ - 128,UCT_ENC_UTF8,0) +#define UC_CHARSET_SETUP_utf_8 UC_Charset_NoUctb_Setup("utf-8","UNICODE (UTF-8)",\ + 0, 128,UCT_ENC_UTF8,-4) #endif /* UCDOMAP_H */ diff --git a/src/Xsystem.c b/src/Xsystem.c index 7a759c92..cc66aff0 100644 --- a/src/Xsystem.c +++ b/src/Xsystem.c @@ -1,12 +1,9 @@ -/* $Id: Xsystem.c,v 1.2 1999/07/30 16:06:54 tom Exp $ +/* @Id: Xsystem.c 1.3 Thu, 26 Aug 1999 05:31:19 -0600 dickey @ * like system("cmd") but return with exit code of "cmd" * for Turbo-C/MS-C/LSI-C * This code is in the public domain. * - * $Log: Xsystem.c,v $ - * Revision 1.2 1999/07/30 16:06:54 tom - * 2.8.3dev.3 - * + * @Log: Xsystem.c,v @ * Revision 1.1 1999/07/14 16:44:55 tom * Initial revision * @@ -109,7 +106,9 @@ xrealloc(void *p, size_t n) static int NEAR is_builtin_command(char *s) { +#ifdef WIN_EX extern int system_is_NT; /* 1997/11/05 (Wed) 22:10:35 */ +#endif static char *cmdtab[]= { @@ -124,8 +123,11 @@ is_builtin_command(char *s) l = strlen(s); count = sizeof(cmdtab) / sizeof(cmdtab[0]); - if (!system_is_NT) - count--; + count--; +#ifdef WIN_EX + if (system_is_NT) + count++; +#endif for (i = 0; i < count; i++) { if (stricmp(s, cmdtab[i]) == 0) return 1; @@ -159,7 +161,7 @@ csystem(PRO * p, int flag) if ((cmp = getenv("COMSPEC")) == 0) return -2; - SW[0] = getswchar(); + SW[0] = (char) getswchar(); SW[1] = 'c'; SW[2] = 0; rc = spawnl(flag, cmp, cmp, SW, p->cmd, p->arg, (char *) 0); @@ -273,7 +275,7 @@ pars(char *s) if (li >= ls - 2) lb = xrealloc(lb, ls += STR_MAX); if (isk1(c) && *s) { - lb[li++] = c; + lb[li++] = (char) c; lb[li++] = *s++; } else if ((!q && c == '|') || c == 0 || (c == '\n' && *s == 0)) { lb[li++] = 0; @@ -288,9 +290,9 @@ pars(char *s) break; } else if (c == '"') { q = !q; - lb[li++] = c; + lb[li++] = (char) c; } else { - lb[li++] = c; + lb[li++] = (char) c; } } free(lb); diff --git a/src/chrtrans/makeuctb.c b/src/chrtrans/makeuctb.c index 7e6b18da..4a940b7e 100644 --- a/src/chrtrans/makeuctb.c +++ b/src/chrtrans/makeuctb.c @@ -108,7 +108,7 @@ PRIVATE int getunicode ARGS1( unicode unitable[MAX_FONTLEN][255]; int unicount[MAX_FONTLEN]; -struct unimapdesc_str themap_str = {0, NULL}; +struct unimapdesc_str themap_str = {0, NULL, 0, 0}; char *tblname; -- cgit