diff options
Diffstat (limited to 'src')
55 files changed, 670 insertions, 567 deletions
diff --git a/src/GridText.c b/src/GridText.c index 4e5e3ba8..8fd637fe 100644 --- a/src/GridText.c +++ b/src/GridText.c @@ -117,8 +117,8 @@ HTkcode last_kcode = NOKANJI; /* 1997/11/14 (Fri) 09:09:26 */ HText *HTMainText = NULL; /* Equivalent of main window */ HTParentAnchor *HTMainAnchor = NULL; /* Anchor for HTMainText */ -char *HTAppName = LYNX_NAME; /* Application name */ -char *HTAppVersion = LYNX_VERSION; /* Application version */ +const char *HTAppName = LYNX_NAME; /* Application name */ +const char *HTAppVersion = LYNX_VERSION; /* Application version */ static int HTFormNumber = 0; static int HTFormFields = 0; @@ -128,10 +128,10 @@ int HTCurSelectGroupType = F_RADIO_TYPE; /* Group type */ char *HTCurSelectGroupSize = NULL; /* Length of select */ static char *HTCurSelectedOptionValue = NULL; /* Select choice */ -char *checked_box = "[X]"; -char *unchecked_box = "[ ]"; -char *checked_radio = "(*)"; -char *unchecked_radio = "( )"; +const char *checked_box = "[X]"; +const char *unchecked_box = "[ ]"; +const char *checked_radio = "(*)"; +const char *unchecked_radio = "( )"; static BOOLEAN underline_on = OFF; static BOOLEAN bold_on = OFF; @@ -728,7 +728,7 @@ static void LYClearHiText(TextAnchor *a) /* * Set the initial highlight information for a given anchor. */ -static void LYSetHiText(TextAnchor *a, char *text, +static void LYSetHiText(TextAnchor *a, const char *text, int len) { if (text != NULL) { @@ -743,7 +743,7 @@ static void LYSetHiText(TextAnchor *a, char *text, /* * Add highlight information for the next line of a anchor. */ -static void LYAddHiText(TextAnchor *a, char *text, +static void LYAddHiText(TextAnchor *a, const char *text, int x) { HiliteInfo *have = a->lites.hl_info; @@ -1887,13 +1887,13 @@ static void display_scrollbar(HText *text) * ------------- */ static void display_page(HText *text, int line_number, - char *target) + const char *target) { HTLine *line = NULL; int i; #if defined(USE_COLOR_STYLE) && defined(SHOW_WHEREIS_TARGETS) - char *cp; + const char *cp; #endif char tmp[7]; int last_screen; @@ -5989,7 +5989,7 @@ HTChildAnchor *HText_childNextNumber(int number, void **prev) * for the field. -FM & LE */ void HText_FormDescNumber(int number, - char **desc) + const char **desc) { TextAnchor *a; @@ -6623,7 +6623,7 @@ BOOL HText_getFirstTargetInLine(HText *text, int line_num, HTLine *line; char *LineData; int LineOffset, HitOffset, LenNeeded, i; - char *cp; + const char *cp; /* * Make sure we have an HText structure, that line_num is @@ -6739,7 +6739,7 @@ void HTCheckFnameForCompression(char **fname, char *fn = *fname; char *dot = NULL; char *cp = NULL; - char *suffix = ""; + const char *suffix = ""; const char *ct = NULL; const char *ce = NULL; CompressFileType method = cftNone; @@ -6806,7 +6806,9 @@ void HTCheckFnameForCompression(char **fname, * we have a gzip or compress suffix. -FM */ if ((dot = strrchr(fn, '.')) != NULL) { - if (HTCompressFileType(fn, ".", &cp) != cftNone) { + int rootlen = 0; + + if (HTCompressFileType(fn, ".", &rootlen) != cftNone) { if (method == cftNone) { /* * It has a suffix which signifies a gzipped @@ -6817,7 +6819,8 @@ void HTCheckFnameForCompression(char **fname, } return; } - if ((second = HTCompressFileType(fn, "-_", &cp)) != cftNone) { + if ((second = HTCompressFileType(fn, "-_", &rootlen)) != cftNone) { + cp = fn + rootlen; if (method == cftNone) { /* * It has a tail which signifies a gzipped @@ -7839,7 +7842,8 @@ static void adjust_search_result(DocInfo *doc, int tentative_result, static BOOL anchor_has_target(TextAnchor *a, char *target) { OptionType *option; - char *stars = NULL, *cp; + char *stars = NULL, *sp; + const char *cp; int count; /* @@ -7868,8 +7872,8 @@ static BOOL anchor_has_target(TextAnchor *a, char *target) return TRUE; } StrAllocCopy(stars, a->input_field->value); - for (cp = stars; *cp != '\0'; cp++) - *cp = '*'; + for (sp = stars; *sp != '\0'; sp++) + *sp = '*'; if (LYno_attr_strstr(stars, target)) { FREE(stars); return TRUE; @@ -8443,7 +8447,7 @@ int HTisDocumentSource(void) return (HTMainText != 0) ? HTMainText->source : FALSE; } -char *HTLoadedDocumentURL(void) +const char *HTLoadedDocumentURL(void) { if (!HTMainText) return (""); @@ -8464,7 +8468,7 @@ bstring *HTLoadedDocumentPost_data(void) return (0); } -char *HTLoadedDocumentTitle(void) +const char *HTLoadedDocumentTitle(void) { if (!HTMainText) return (""); @@ -8497,7 +8501,7 @@ BOOLEAN HTLoadedDocumentIsSafe(void) return (FALSE); } -char *HTLoadedDocumentCharset(void) +const char *HTLoadedDocumentCharset(void) { if (!HTMainText) return (NULL); @@ -8525,7 +8529,7 @@ void HText_setNodeAnchorBookmark(const char *bookmark) HTAnchor_setBookmark(HTMainText->node_anchor, bookmark); } -char *HTLoadedDocumentBookmark(void) +const char *HTLoadedDocumentBookmark(void) { if (!HTMainText) return (NULL); @@ -8829,7 +8833,7 @@ int HText_HiddenLinkCount(HText *text) * a hidden link, at the position (zero-based) in the * text->hidden_links list of the number argument. -FM */ -char *HText_HiddenLinkAt(HText *text, int number) +const char *HText_HiddenLinkAt(HText *text, int number) { char *href = NULL; @@ -9538,8 +9542,8 @@ int HText_beginInput(HText *text, BOOL underline, /* * Set SIZE. */ - if (I->size != NULL) { - f->size = atoi(I->size); + if (I->size != 0) { + f->size = I->size; /* * Leave at zero for option lists. */ @@ -10001,7 +10005,7 @@ static int find_best_target_cs(char **best_csname, } #ifdef USE_FILE_UPLOAD -static void load_a_file(char *val_used, +static void load_a_file(const char *val_used, bstring **result) { FILE *fd; @@ -10048,10 +10052,10 @@ static void cannot_transcode(BOOL *had_warning, #define SPECIAL_8BIT 1 #define SPECIAL_FORM 2 -static unsigned check_form_specialchars(char *value) +static unsigned check_form_specialchars(const char *value) { unsigned result = 0; - char *p; + const char *p; for (p = value; non_empty(p) && (result != (SPECIAL_8BIT | SPECIAL_FORM)); @@ -10097,7 +10101,7 @@ static void UpdateBoundary(char **Boundary, /* * Convert a string to base64 */ -static char *convert_to_base64(char *src, +static char *convert_to_base64(const char *src, int len) { #define B64_LINE 76 @@ -10108,7 +10112,9 @@ static char *convert_to_base64(char *src, char *dest; int rlen; /* length of result string */ unsigned char c1, c2, c3; - char *eol, *r, *str; + const char *eol; + char *r; + const char *str; int eollen; int chunk; @@ -10132,8 +10138,8 @@ static char *convert_to_base64(char *src, /* encode */ for (chunk = 0; len > 0; len -= 3, chunk++) { if (chunk == (B64_LINE / 4)) { - char *c = eol; - char *e = eol + eollen; + const char *c = eol; + const char *e = eol + eollen; while (c < e) *r++ = *c++; @@ -10157,8 +10163,8 @@ static char *convert_to_base64(char *src, } if (rlen) { /* append eol to the result string */ - char *c = eol; - char *e = eol + eollen; + const char *c = eol; + const char *e = eol + eollen; while (c < e) *r++ = *c++; @@ -10184,9 +10190,9 @@ typedef struct { QuoteData quote; /* how to quote/translate the data */ } PostData; -static char *escape_or_quote_name(char *name, +static char *escape_or_quote_name(const char *name, QuoteData quoting, - char *MultipartContentType) + const char *MultipartContentType) { char *escaped1 = NULL; @@ -10211,7 +10217,7 @@ static char *escape_or_quote_name(char *name, return escaped1; } -static char *escape_or_quote_value(char *value, +static char *escape_or_quote_value(const char *value, QuoteData quoting) { char *escaped2 = NULL; @@ -10301,9 +10307,9 @@ int HText_SubmitForm(FormInfo * submit_item, DocInfo *doc, char *link_name, char *escaped1 = NULL; char *escaped2 = NULL; char *last_textarea_name = NULL; - char *name_used = ""; + const char *name_used = ""; char *previous_blanks = NULL; - char *val_used = ""; + const char *val_used = ""; int anchor_count = 0; int anchor_limit = 0; int form_number = submit_item->number; @@ -11074,11 +11080,11 @@ int HText_SubmitForm(FormInfo * submit_item, DocInfo *doc, char *link_name, escaped2, ((PlainText && *escaped2) ? "\n" : "")); } else { - char *marker = (PlainText - ? "\n" - : (Boundary - ? "\r\n" - : "%0d%0a")); + const char *marker = (PlainText + ? "\n" + : (Boundary + ? "\r\n" + : "%0d%0a")); /* * This is a continuation of a previous textarea. @@ -13085,13 +13091,13 @@ int HText_InsertFile(LinkInfo * form_link) * (since no support for lss is availble for Slang) -HV. */ #ifdef USE_COLOR_STYLE -static void redraw_part_of_line(HTLine *line, char *str, +static void redraw_part_of_line(HTLine *line, const char *str, int len, HText *text) { register int i; char buffer[7]; - char *data, *end_of_data; + const char *data, *end_of_data; size_t utf_extra = 0; #ifdef USE_COLOR_STYLE @@ -13265,11 +13271,11 @@ static void redraw_part_of_line(HTLine *line, char *str, static void move_to_glyph(int YP, int XP, int XP_draw_min, - char *data, + const char *data, int datasize, unsigned offset, const char *target, - char *hightext, + const char *hightext, int flags, BOOL utf_flag) { @@ -13291,7 +13297,7 @@ static void move_to_glyph(int YP, BOOL incurlink = NO; BOOL drawingtarget = NO; BOOL flag = NO; - char *sdata = data; + const char *sdata = data; char LastDisplayChar = ' '; int i = (int) offset; /* FIXME: should be columns, not offset? */ @@ -13755,7 +13761,7 @@ static void move_to_glyph(int YP, */ void LYMoveToLink(int cur, const char *target, - char *hightext, + const char *hightext, int flag, BOOL inU, BOOL utf_flag) @@ -13819,7 +13825,7 @@ void redraw_lines_of_link(int cur GCC_UNUSED) HTLine *todr1; int lines_back; int row, col, count; - char *text; + const char *text; if (HTMainText->next_line == HTMainText->last_line) { /* we are at the last page - that is partially filled */ diff --git a/src/GridText.h b/src/GridText.h index 242ca376..ac0b4285 100644 --- a/src/GridText.h +++ b/src/GridText.h @@ -64,7 +64,7 @@ extern int HTVirtualMemorySize; #endif /* VMS && VAXC && !__DECC */ extern HTChildAnchor *HText_childNextNumber(int n, void **prev); -extern void HText_FormDescNumber(int n, char **desc); +extern void HText_FormDescNumber(int n, const char **desc); /* Is there any file left? */ @@ -149,11 +149,11 @@ extern BOOL HText_inLineOne(HText *text); extern BOOLEAN HTLoadedDocumentIsHEAD(void); extern BOOLEAN HTLoadedDocumentIsSafe(void); extern bstring *HTLoadedDocumentPost_data(void); -extern char *HTLoadedDocumentBookmark(void); -extern char *HTLoadedDocumentCharset(void); -extern char *HTLoadedDocumentTitle(void); -extern char *HTLoadedDocumentURL(void); -extern char *HText_HiddenLinkAt(HText *text, int number); +extern const char *HTLoadedDocumentBookmark(void); +extern const char *HTLoadedDocumentCharset(void); +extern const char *HTLoadedDocumentTitle(void); +extern const char *HTLoadedDocumentURL(void); +extern const char *HText_HiddenLinkAt(HText *text, int number); extern int HText_HiddenLinkCount(HText *text); extern int HText_LastLineOffset(HText *me); extern int HText_LastLineSize(HText *me, BOOL IgnoreSpaces); @@ -257,7 +257,7 @@ extern int HText_InsertFile(LinkInfo * form_link); extern void redraw_lines_of_link(int cur); extern void LYMoveToLink(int cur, const char *target, - char *hightext, + const char *hightext, int flag, BOOL inU, BOOL utf_flag); diff --git a/src/HTAlert.c b/src/HTAlert.c index 6105cf26..a733c5ca 100644 --- a/src/HTAlert.c +++ b/src/HTAlert.c @@ -84,7 +84,7 @@ void HTAlwaysAlert(const char *extra_prefix, void HTInfoMsg(const char *Msg) { _statusline(Msg); - if (Msg && *Msg) { + if (non_empty(Msg)) { CTRACE((tfp, "Info message: %s\n", Msg)); LYstore_message(Msg); LYSleepInfo(); @@ -97,7 +97,7 @@ void HTInfoMsg(const char *Msg) void HTUserMsg(const char *Msg) { _statusline(Msg); - if (Msg && *Msg) { + if (non_empty(Msg)) { CTRACE((tfp, "User message: %s\n", Msg)); LYstore_message(Msg); #if !(defined(USE_SLANG) || defined(WIDEC_CURSES)) @@ -113,7 +113,7 @@ void HTUserMsg(const char *Msg) void HTUserMsg2(const char *Msg2, const char *Arg) { _user_message(Msg2, Arg); - if (Msg2 && *Msg2) { + if (non_empty(Msg2)) { CTRACE((tfp, "User message: ")); CTRACE((tfp, Msg2, Arg)); CTRACE((tfp, "\n")); @@ -326,7 +326,7 @@ BOOL HTLastConfirmCancelled(void) int HTForcedPrompt(int option, const char *msg, int dft) { int result = FALSE; - char *show = NULL; + const char *show = NULL; char *msg2 = NULL; if (option == FORCE_PROMPT_DFT) { @@ -381,8 +381,8 @@ int HTConfirmDefault(const char *Msg, int Dft) * Lynx will also accept y Y n N as responses unless there is a conflict * with the first letter of the "yes" or "no" translation. */ - char *msg_yes = gettext("yes"); - char *msg_no = gettext("no"); + const char *msg_yes = gettext("yes"); + const char *msg_no = gettext("no"); int result = -1; /* If they're not really distinct in the first letter, revert to English */ @@ -722,7 +722,7 @@ void HTPromptUsernameAndPassword(const char *Msg, } else { FREE(authentication_info[1]); } - } else if (*username != NULL && *username[0] != '\0') { + } else if (non_empty(*username)) { /* * We have a non-zero length username, * so prompt for the password. - FM @@ -756,7 +756,7 @@ BOOL HTConfirmCookie(domain_entry * de, const char *server, const char *value) { int ch; - char *prompt = ADVANCED_COOKIE_CONFIRMATION; + const char *prompt = ADVANCED_COOKIE_CONFIRMATION; if (de == NULL) return FALSE; diff --git a/src/HTFWriter.c b/src/HTFWriter.c index 4b3b98c1..edb9594a 100644 --- a/src/HTFWriter.c +++ b/src/HTFWriter.c @@ -530,7 +530,7 @@ static char *mailcap_substitute(HTParentAnchor *anchor, /* if we don't have a "%s" token, expect to provide the file via stdin */ if (!LYMailcapUsesPctS(pres->command)) { char *prepend = 0; - char *format = "( %s ) < %s"; + const char *format = "( %s ) < %s"; HTSprintf(&prepend, "( %s", result); /* ...avoid quoting */ HTAddParam(&prepend, format, 2, fnam); /* ...to quote if needed */ @@ -891,9 +891,9 @@ HTStream *HTSaveToFile(HTPresentation *pres, */ char *temp = NULL; - if (anchor->content_base && *anchor->content_base) { + if (non_empty(anchor->content_base)) { StrAllocCopy(temp, anchor->content_base); - } else if (anchor->content_location && *anchor->content_location) { + } else if (non_empty(anchor->content_location)) { StrAllocCopy(temp, anchor->content_location); } if (temp) { @@ -905,10 +905,10 @@ HTStream *HTSaveToFile(HTPresentation *pres, fprintf(ret_obj->fp, "<!-- X-URL: %s -->\n", anchor->address); - if (anchor->date && *anchor->date) { + if (non_empty(anchor->date)) { fprintf(ret_obj->fp, "<!-- Date: %s -->\n", anchor->date); - if (anchor->last_modified && *anchor->last_modified + if (non_empty(anchor->last_modified) && strcmp(anchor->last_modified, anchor->date) && strcmp(anchor->last_modified, "Thu, 01 Jan 1970 00:00:01 GMT")) { @@ -933,7 +933,7 @@ HTStream *HTSaveToFile(HTPresentation *pres, */ char *temp = NULL; - if (anchor->charset && *anchor->charset) { + if (non_empty(anchor->charset)) { StrAllocCopy(temp, anchor->charset); LYRemoveBlanks(temp); fprintf(ret_obj->fp, @@ -963,7 +963,7 @@ HTStream *HTCompressed(HTPresentation *pres, char temp[LY_MAXPATH]; /* actually stores just a suffix */ const char *suffix; char *uncompress_mask = NULL; - char *compress_suffix = ""; + const char *compress_suffix = ""; const char *middle; /* diff --git a/src/HTForms.h b/src/HTForms.h index 75587213..71ef376d 100644 --- a/src/HTForms.h +++ b/src/HTForms.h @@ -41,7 +41,7 @@ typedef struct _InputFieldData { const char *md; const char *min; const char *name; - const char *size; + int size; const char *src; const char *type; char *value; diff --git a/src/HTInit.c b/src/HTInit.c index 85ef10de..24f62f61 100644 --- a/src/HTInit.c +++ b/src/HTInit.c @@ -59,7 +59,7 @@ void HTFormatInit(void) #else if (LYgetXDisplay() != 0) { /* Must have X11 */ SET_PRESENT("application/postscript", "ghostview %s&", 1.0, 3.0); - if (XLoadImageCommand && *XLoadImageCommand) { + if (non_empty(XLoadImageCommand)) { /* *INDENT-OFF* */ SET_PRESENT("image/gif", XLoadImageCommand, 1.0, 3.0); SET_PRESENT("image/x-xbm", XLoadImageCommand, 1.0, 3.0); @@ -226,7 +226,7 @@ struct MailcapEntry { long int maxbytes; }; -static int ExitWithError(char *txt); +static int ExitWithError(const char *txt); static int PassesTest(struct MailcapEntry *mc); static char *GetCommand(char *s, char **t) @@ -241,7 +241,7 @@ static char *GetCommand(char *s, char **t) ExitWithError(MEMORY_EXHAUSTED_ABORT); *t = s2; - while (s && *s) { + while (non_empty(s)) { if (quoted) { if (*s == '%') *s2++ = '%'; /* Quote through next level, ugh! */ @@ -411,7 +411,7 @@ static int ProcessMailcapEntry(FILE *fp, struct MailcapEntry *mc, AcceptMedia me *eq++ = '\0'; eq = LYSkipBlanks(eq); } - if (arg && *arg) { + if (non_empty(arg)) { arg = Cleanse(arg); if (!strcmp(arg, "needsterminal")) { mc->needsterminal = 1; @@ -928,7 +928,7 @@ static int ProcessMailcapFile(char *file, AcceptMedia media) return (0 == 0); } -static int ExitWithError(char *txt) +static int ExitWithError(const char *txt) { if (txt) fprintf(tfp, "Lynx: %s\n", txt); diff --git a/src/HTML.c b/src/HTML.c index 1408f55d..c34a1b47 100644 --- a/src/HTML.c +++ b/src/HTML.c @@ -80,6 +80,19 @@ #define STACKLEVEL(me) ((me->stack + MAX_NESTING - 1) - me->sp) +#define DFT_TEXTAREA_COLS 60 +#define DFT_TEXTAREA_ROWS 4 + +#define MAX_TEXTAREA_COLS LYcolLimit +#define MAX_TEXTAREA_ROWS (3 * LYlines) + +#define LimitValue(name, value) \ + if (name > value) { \ + CTRACE((tfp, "Limited " #name " to %d, was %d\n", \ + value, name)); \ + name = value; \ + } + struct _HTStream { const HTStreamClass *isa; #ifdef USE_SOURCE_CACHE @@ -106,7 +119,7 @@ static HTStyle *styles[HTML_ELEMENTS + LYNX_HTML_EXTRA_ELEMENTS]; /* and 3 div alignment styles */ static HTStyle *default_style = NULL; -char *LYToolbarName = "LynxPseudoToolbar"; +const char *LYToolbarName = "LynxPseudoToolbar"; /* used to turn off a style if the HTML author forgot to static int i_prior_style = -1; @@ -764,7 +777,7 @@ static void LYStartArea(HTStructured * obj, const char *href, new_present[HTML_AREA_ALT] = YES; new_value[HTML_AREA_ALT] = (const char *) alt; } - if (title && *title) { + if (non_empty(title)) { new_present[HTML_AREA_TITLE] = YES; new_value[HTML_AREA_TITLE] = (const char *) title; } @@ -801,7 +814,7 @@ static void LYHandleFIG(HTStructured * me, const BOOL *present, me->inFIGwithP = FALSE; HTML_put_character(me, ' '); /* space char may be ignored */ } - if (id && *id) { + if (non_empty(id)) { if (present && convert) { CHECK_ID(HTML_FIG_ID); } else @@ -810,7 +823,7 @@ static void LYHandleFIG(HTStructured * me, const BOOL *present, me->in_word = NO; me->inP = FALSE; - if (clickable_images && src && *src) { + if (clickable_images && non_empty(src)) { char *href = NULL; StrAllocCopy(href, src); @@ -1134,7 +1147,7 @@ static int HTML_start_element(HTStructured * me, int element_number, case HTML_BASE: if (present && present[HTML_BASE_HREF] && !local_host_only && - value[HTML_BASE_HREF] && *value[HTML_BASE_HREF]) { + non_empty(value[HTML_BASE_HREF])) { char *base = NULL; const char *related = NULL; @@ -1428,7 +1441,7 @@ static int HTML_start_element(HTStructured * me, int element_number, * default to the REL value that was loaded into title. - FM */ if (present && present[HTML_LINK_TITLE] && - value[HTML_LINK_TITLE] && *value[HTML_LINK_TITLE] != '\0') { + non_empty(value[HTML_LINK_TITLE])) { StrAllocCopy(title, value[HTML_LINK_TITLE]); TRANSLATE_AND_UNESCAPE_ENTITIES(&title, TRUE, FALSE); LYTrimHead(title); @@ -1436,7 +1449,7 @@ static int HTML_start_element(HTStructured * me, int element_number, pdoctitle = &title; FREE(temp); /* forget about recording RelTitle - kw */ } - if (!(title && *title)) { + if (isEmpty(title)) { FREE(href); FREE(title); break; @@ -1473,7 +1486,7 @@ static int HTML_start_element(HTStructured * me, int element_number, if (dest == me->node_anchor) dest = NULL; if (present[HTML_LINK_CHARSET] && - value[HTML_LINK_CHARSET] && *value[HTML_LINK_CHARSET] != '\0') { + non_empty(value[HTML_LINK_CHARSET])) { dest_char_set = UCGetLYhndl_byMIME(value[HTML_LINK_CHARSET]); if (dest_char_set < 0) dest_char_set = UCLYhndl_for_unrec; @@ -1506,7 +1519,7 @@ static int HTML_start_element(HTStructured * me, int element_number, HText_appendCharacter(me->text, LY_BOLD_START_CHAR); #ifdef USE_COLOR_STYLE if (present && present[HTML_LINK_CLASS] && - value && *value[HTML_LINK_CLASS] != '\0') { + non_empty(value[HTML_LINK_CLASS])) { char *tmp = 0; HTSprintf0(&tmp, "link.%s.%s", value[HTML_LINK_CLASS], title); @@ -1564,7 +1577,7 @@ static int HTML_start_element(HTStructured * me, int element_number, */ if (present && present[HTML_ISINDEX_PROMPT] && - value[HTML_ISINDEX_PROMPT] && *value[HTML_ISINDEX_PROMPT]) { + non_empty(value[HTML_ISINDEX_PROMPT])) { StrAllocCopy(temp, value[HTML_ISINDEX_PROMPT]); TRANSLATE_AND_UNESCAPE_ENTITIES(&temp, TRUE, FALSE); LYTrimHead(temp); @@ -1611,14 +1624,14 @@ static int HTML_start_element(HTStructured * me, int element_number, case HTML_FRAME: if (present && present[HTML_FRAME_NAME] && - value[HTML_FRAME_NAME] && *value[HTML_FRAME_NAME]) { + non_empty(value[HTML_FRAME_NAME])) { StrAllocCopy(id_string, value[HTML_FRAME_NAME]); TRANSLATE_AND_UNESCAPE_ENTITIES(&id_string, TRUE, FALSE); LYTrimHead(id_string); LYTrimTail(id_string); } if (present && present[HTML_FRAME_SRC] && - value[HTML_FRAME_SRC] && *value[HTML_FRAME_SRC]) { + non_empty(value[HTML_FRAME_SRC])) { StrAllocCopy(href, value[HTML_FRAME_SRC]); LYLegitimizeHREF(me, &href, TRUE, TRUE); @@ -1664,14 +1677,14 @@ static int HTML_start_element(HTStructured * me, int element_number, case HTML_IFRAME: if (present && present[HTML_IFRAME_NAME] && - value[HTML_IFRAME_NAME] && *value[HTML_IFRAME_NAME]) { + non_empty(value[HTML_IFRAME_NAME])) { StrAllocCopy(id_string, value[HTML_IFRAME_NAME]); TRANSLATE_AND_UNESCAPE_ENTITIES(&id_string, TRUE, FALSE); LYTrimHead(id_string); LYTrimTail(id_string); } if (present && present[HTML_IFRAME_SRC] && - value[HTML_IFRAME_SRC] && *value[HTML_IFRAME_SRC]) { + non_empty(value[HTML_IFRAME_SRC])) { StrAllocCopy(href, value[HTML_IFRAME_SRC]); LYLegitimizeHREF(me, &href, TRUE, TRUE); @@ -1770,7 +1783,7 @@ static int HTML_start_element(HTStructured * me, int element_number, 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]) { + non_empty(value[HTML_DIV_ALIGN])) { if (!strcasecomp(value[HTML_DIV_ALIGN], "center")) { me->DivisionAlignments[me->Division_Level] = HT_CENTER; change_paragraph_style(me, styles[HTML_DCENTER]); @@ -1852,7 +1865,7 @@ static int HTML_start_element(HTStructured * me, int element_number, } if (present && present[HTML_H_ALIGN] && - value[HTML_H_ALIGN] && *value[HTML_H_ALIGN]) { + non_empty(value[HTML_H_ALIGN])) { if (!strcasecomp(value[HTML_H_ALIGN], "center")) change_paragraph_style(me, styles[HTML_HCENTER]); else if (!strcasecomp(value[HTML_H_ALIGN], "right")) @@ -2061,7 +2074,7 @@ static int HTML_start_element(HTStructured * me, int element_number, CTRACE((tfp, "HTML: Not HT_LEFT. Using space instead of TAB.\n")); } else if ((present[HTML_TAB_TO] && - value[HTML_TAB_TO] && *value[HTML_TAB_TO]) || + non_empty(value[HTML_TAB_TO])) || (present[HTML_TAB_INDENT] && value[HTML_TAB_INDENT] && isdigit(UCH(*value[HTML_TAB_INDENT])))) { @@ -2078,7 +2091,7 @@ static int HTML_start_element(HTStructured * me, int element_number, if (*temp) { target = HText_getTabIDColumn(me->text, temp); } - } else if (!(temp && *temp) && present[HTML_TAB_INDENT] && + } else if (isEmpty(temp) && present[HTML_TAB_INDENT] && value[HTML_TAB_INDENT] && isdigit(UCH(*value[HTML_TAB_INDENT]))) { /* @@ -2113,7 +2126,7 @@ static int HTML_start_element(HTStructured * me, int element_number, * column we've reached. - FM */ if (present[HTML_TAB_ID] && - value[HTML_TAB_ID] && *value[HTML_TAB_ID]) { + non_empty(value[HTML_TAB_ID])) { StrAllocCopy(temp, value[HTML_TAB_ID]); TRANSLATE_AND_UNESCAPE_TO_STD(&temp); if (*temp) @@ -2427,10 +2440,10 @@ static int HTML_start_element(HTStructured * me, int element_number, * the "wheel" as "we'll"). - FM */ if (present[HTML_OL_SEQNUM] && - value[HTML_OL_SEQNUM] && *value[HTML_OL_SEQNUM]) { + non_empty(value[HTML_OL_SEQNUM])) { seqnum = atoi(value[HTML_OL_SEQNUM]); } else if (present[HTML_OL_START] && - value[HTML_OL_START] && *value[HTML_OL_START]) { + non_empty(value[HTML_OL_START])) { seqnum = atoi(value[HTML_OL_START]); } else { seqnum = 1; @@ -2816,10 +2829,10 @@ static int HTML_start_element(HTStructured * me, int element_number, * Load id_string if we have an ID or NAME. - FM */ if (present && present[HTML_A_ID] && - value[HTML_A_ID] && *value[HTML_A_ID]) { + non_empty(value[HTML_A_ID])) { StrAllocCopy(id_string, value[HTML_A_ID]); } else if (present && present[HTML_A_NAME] && - value[HTML_A_NAME] && *value[HTML_A_NAME]) { + non_empty(value[HTML_A_NAME])) { StrAllocCopy(id_string, value[HTML_A_NAME]); } if (id_string) @@ -2892,7 +2905,7 @@ static int HTML_start_element(HTStructured * me, int element_number, if (me->CurrentA && present) { if (present[HTML_A_TITLE] && - value[HTML_A_TITLE] && *value[HTML_A_TITLE] != '\0') { + non_empty(value[HTML_A_TITLE])) { StrAllocCopy(title, value[HTML_A_TITLE]); TRANSLATE_AND_UNESCAPE_ENTITIES(&title, TRUE, FALSE); LYTrimHead(title); @@ -2904,7 +2917,7 @@ static int HTML_start_element(HTStructured * me, int element_number, if (present[HTML_A_ISMAP]) dest_ismap = TRUE; if (present[HTML_A_CHARSET] && - value[HTML_A_CHARSET] && *value[HTML_A_CHARSET] != '\0') { + non_empty(value[HTML_A_CHARSET])) { /* * Set up to load the anchor's chartrans structures * appropriately for the current display character set if it @@ -2997,7 +3010,7 @@ static int HTML_start_element(HTStructured * me, int element_number, * If there's a USEMAP, resolve it. - FM */ if (present && present[HTML_IMG_USEMAP] && - value[HTML_IMG_USEMAP] && *value[HTML_IMG_USEMAP]) { + non_empty(value[HTML_IMG_USEMAP])) { StrAllocCopy(map_href, value[HTML_IMG_USEMAP]); CHECK_FOR_INTERN(intern_flag, map_href); url_type = LYLegitimizeHREF(me, &map_href, TRUE, TRUE); @@ -3050,7 +3063,7 @@ static int HTML_start_element(HTStructured * me, int element_number, * Check for a TITLE attribute. - FM */ if (present && present[HTML_IMG_TITLE] && - value[HTML_IMG_TITLE] && *value[HTML_IMG_TITLE]) { + non_empty(value[HTML_IMG_TITLE])) { StrAllocCopy(title, value[HTML_IMG_TITLE]); TRANSLATE_AND_UNESCAPE_ENTITIES(&title, TRUE, FALSE); LYTrimHead(title); @@ -3153,7 +3166,7 @@ static int HTML_start_element(HTStructured * me, int element_number, * Check for an ID attribute. - FM */ if (present && present[HTML_IMG_ID] && - value[HTML_IMG_ID] && *value[HTML_IMG_ID]) { + non_empty(value[HTML_IMG_ID])) { StrAllocCopy(id_string, value[HTML_IMG_ID]); TRANSLATE_AND_UNESCAPE_TO_STD(&id_string); if (*id_string == '\0') { @@ -3166,7 +3179,7 @@ static int HTML_start_element(HTStructured * me, int element_number, */ if (clickable_images && present && present[HTML_IMG_SRC] && - value[HTML_IMG_SRC] && *value[HTML_IMG_SRC]) { + non_empty(value[HTML_IMG_SRC])) { StrAllocCopy(href, value[HTML_IMG_SRC]); LYLegitimizeHREF(me, &href, TRUE, TRUE); @@ -3427,10 +3440,10 @@ static int HTML_start_element(HTStructured * me, int element_number, * Load id_string if we have a NAME or ID. - FM */ if (present && present[HTML_MAP_NAME] && - value[HTML_MAP_NAME] && *value[HTML_MAP_NAME]) { + non_empty(value[HTML_MAP_NAME])) { StrAllocCopy(id_string, value[HTML_MAP_NAME]); } else if (present && present[HTML_MAP_ID] && - value[HTML_MAP_ID] && *value[HTML_MAP_ID]) { + non_empty(value[HTML_MAP_ID])) { StrAllocCopy(id_string, value[HTML_MAP_ID]); } if (id_string) { @@ -3467,7 +3480,7 @@ static int HTML_start_element(HTStructured * me, int element_number, StrAllocCat(me->map_address, id_string); FREE(id_string); if (present && present[HTML_MAP_TITLE] && - value[HTML_MAP_TITLE] && *value[HTML_MAP_TITLE] != '\0') { + non_empty(value[HTML_MAP_TITLE])) { StrAllocCopy(title, value[HTML_MAP_TITLE]); TRANSLATE_AND_UNESCAPE_ENTITIES(&title, TRUE, FALSE); LYTrimHead(title); @@ -3484,7 +3497,7 @@ static int HTML_start_element(HTStructured * me, int element_number, case HTML_AREA: if (me->map_address && present && present[HTML_AREA_HREF] && - value[HTML_AREA_HREF] && *value[HTML_AREA_HREF]) { + non_empty(value[HTML_AREA_HREF])) { /* * Resolve the HREF. - FM */ @@ -3507,10 +3520,10 @@ static int HTML_start_element(HTStructured * me, int element_number, * Check for an ALT. - FM */ if (present[HTML_AREA_ALT] && - value[HTML_AREA_ALT] && *value[HTML_AREA_ALT]) { + non_empty(value[HTML_AREA_ALT])) { StrAllocCopy(alt_string, value[HTML_AREA_ALT]); } else if (present[HTML_AREA_TITLE] && - value[HTML_AREA_TITLE] && *value[HTML_AREA_TITLE]) { + non_empty(value[HTML_AREA_TITLE])) { /* * Use the TITLE as an ALT. - FM */ @@ -3595,7 +3608,7 @@ static int HTML_start_element(HTStructured * me, int element_number, if (present[HTML_OBJECT_ISMAP]) me->object_ismap = TRUE; if (present[HTML_OBJECT_USEMAP] && - value[HTML_OBJECT_USEMAP] && *value[HTML_OBJECT_USEMAP]) { + non_empty(value[HTML_OBJECT_USEMAP])) { StrAllocCopy(me->object_usemap, value[HTML_OBJECT_USEMAP]); TRANSLATE_AND_UNESCAPE_TO_STD(&me->object_usemap); if (*me->object_usemap == '\0') { @@ -3603,7 +3616,7 @@ static int HTML_start_element(HTStructured * me, int element_number, } } if (present[HTML_OBJECT_ID] && - value[HTML_OBJECT_ID] && *value[HTML_OBJECT_ID]) { + non_empty(value[HTML_OBJECT_ID])) { StrAllocCopy(me->object_id, value[HTML_OBJECT_ID]); TRANSLATE_AND_UNESCAPE_TO_STD(&me->object_id); if (*me->object_id == '\0') { @@ -3611,7 +3624,7 @@ static int HTML_start_element(HTStructured * me, int element_number, } } if (present[HTML_OBJECT_TITLE] && - value[HTML_OBJECT_TITLE] && *value[HTML_OBJECT_TITLE]) { + non_empty(value[HTML_OBJECT_TITLE])) { StrAllocCopy(me->object_title, value[HTML_OBJECT_TITLE]); TRANSLATE_AND_UNESCAPE_ENTITIES(&me->object_title, TRUE, FALSE); LYTrimHead(me->object_title); @@ -3621,7 +3634,7 @@ static int HTML_start_element(HTStructured * me, int element_number, } } if (present[HTML_OBJECT_DATA] && - value[HTML_OBJECT_DATA] && *value[HTML_OBJECT_DATA]) { + non_empty(value[HTML_OBJECT_DATA])) { StrAllocCopy(me->object_data, value[HTML_OBJECT_DATA]); TRANSLATE_AND_UNESCAPE_TO_STD(&me->object_data); if (*me->object_data == '\0') { @@ -3629,7 +3642,7 @@ static int HTML_start_element(HTStructured * me, int element_number, } } if (present[HTML_OBJECT_TYPE] && - value[HTML_OBJECT_TYPE] && *value[HTML_OBJECT_TYPE]) { + non_empty(value[HTML_OBJECT_TYPE])) { StrAllocCopy(me->object_type, value[HTML_OBJECT_TYPE]); TRANSLATE_AND_UNESCAPE_ENTITIES(&me->object_type, TRUE, FALSE); LYTrimHead(me->object_type); @@ -3675,7 +3688,7 @@ static int HTML_start_element(HTStructured * me, int element_number, } } if (present[HTML_OBJECT_NAME] && - value[HTML_OBJECT_NAME] && *value[HTML_OBJECT_NAME]) { + non_empty(value[HTML_OBJECT_NAME])) { StrAllocCopy(me->object_name, value[HTML_OBJECT_NAME]); TRANSLATE_AND_UNESCAPE_ENTITIES(&me->object_name, TRUE, FALSE); LYTrimHead(me->object_name); @@ -3769,7 +3782,7 @@ static int HTML_start_element(HTStructured * me, int element_number, case HTML_OVERLAY: if (clickable_images && me->inFIG && present && present[HTML_OVERLAY_SRC] && - value[HTML_OVERLAY_SRC] && *value[HTML_OVERLAY_SRC]) { + non_empty(value[HTML_OVERLAY_SRC])) { StrAllocCopy(href, value[HTML_OVERLAY_SRC]); LYLegitimizeHREF(me, &href, TRUE, TRUE); if (*href) { @@ -3808,10 +3821,10 @@ static int HTML_start_element(HTStructured * me, int element_number, * Load id_string if we have an ID or NAME. - FM */ if (present && present[HTML_APPLET_ID] && - value[HTML_APPLET_ID] && *value[HTML_APPLET_ID]) { + non_empty(value[HTML_APPLET_ID])) { StrAllocCopy(id_string, value[HTML_APPLET_ID]); } else if (present && present[HTML_APPLET_NAME] && - value[HTML_APPLET_NAME] && *value[HTML_APPLET_NAME]) { + non_empty(value[HTML_APPLET_NAME])) { StrAllocCopy(id_string, value[HTML_APPLET_NAME]); } if (id_string) { @@ -3854,7 +3867,7 @@ static int HTML_start_element(HTStructured * me, int element_number, * If we're making all sources links, get the source. - FM */ if (clickable_images && present && present[HTML_APPLET_CODE] && - value[HTML_APPLET_CODE] && *value[HTML_APPLET_CODE]) { + non_empty(value[HTML_APPLET_CODE])) { char *base = NULL; Base = (me->inBASE) @@ -3864,7 +3877,7 @@ static int HTML_start_element(HTStructured * me, int element_number, * Check for a CODEBASE attribute. - FM */ if (present[HTML_APPLET_CODEBASE] && - value[HTML_APPLET_CODEBASE] && *value[HTML_APPLET_CODEBASE]) { + non_empty(value[HTML_APPLET_CODEBASE])) { StrAllocCopy(base, value[HTML_APPLET_CODEBASE]); LYRemoveBlanks(base); TRANSLATE_AND_UNESCAPE_TO_STD(&base); @@ -3928,7 +3941,7 @@ static int HTML_start_element(HTStructured * me, int element_number, * If we're making all sources links, get the source. - FM */ if (clickable_images && present && present[HTML_BGSOUND_SRC] && - value[HTML_BGSOUND_SRC] && *value[HTML_BGSOUND_SRC]) { + non_empty(value[HTML_BGSOUND_SRC])) { StrAllocCopy(href, value[HTML_BGSOUND_SRC]); LYLegitimizeHREF(me, &href, TRUE, TRUE); if (*href == '\0') { @@ -3974,10 +3987,10 @@ static int HTML_start_element(HTStructured * me, int element_number, * Load id_string if we have an ID or NAME. - FM */ if (present && present[HTML_EMBED_ID] && - value[HTML_EMBED_ID] && *value[HTML_EMBED_ID]) { + non_empty(value[HTML_EMBED_ID])) { StrAllocCopy(id_string, value[HTML_EMBED_ID]); } else if (present && present[HTML_EMBED_NAME] && - value[HTML_EMBED_NAME] && *value[HTML_EMBED_NAME]) { + non_empty(value[HTML_EMBED_NAME])) { StrAllocCopy(id_string, value[HTML_EMBED_NAME]); } if (id_string) { @@ -4020,7 +4033,7 @@ static int HTML_start_element(HTStructured * me, int element_number, * If we're making all sources links, get the source. - FM */ if (clickable_images && present && present[HTML_EMBED_SRC] && - value[HTML_EMBED_SRC] && *value[HTML_EMBED_SRC]) { + non_empty(value[HTML_EMBED_SRC])) { StrAllocCopy(href, value[HTML_EMBED_SRC]); LYLegitimizeHREF(me, &href, TRUE, TRUE); if (*href) { @@ -4206,7 +4219,7 @@ static int HTML_start_element(HTStructured * me, int element_number, value[HTML_FORM_METHOD] : "GET"); if (present && present[HTML_FORM_ENCTYPE] && - value[HTML_FORM_ENCTYPE] && *value[HTML_FORM_ENCTYPE]) { + non_empty(value[HTML_FORM_ENCTYPE])) { StrAllocCopy(enctype, value[HTML_FORM_ENCTYPE]); LYLowerCase(enctype); } @@ -4225,7 +4238,7 @@ static int HTML_start_element(HTStructured * me, int element_number, *value[HTML_FORM_SUBJECT] != '\0') { StrAllocCopy(title, value[HTML_FORM_SUBJECT]); } - if (title != NULL && *title != '\0') { + if (non_empty(title)) { TRANSLATE_AND_UNESCAPE_ENTITIES(&title, TRUE, FALSE); LYTrimHead(title); LYTrimTail(title); @@ -4285,7 +4298,7 @@ static int HTML_start_element(HTStructured * me, int element_number, I.md = NULL; I.min = NULL; I.name = NULL; - I.size = NULL; + I.size = 0; I.src = NULL; I.type = NULL; I.value = NULL; @@ -4356,7 +4369,7 @@ static int HTML_start_element(HTStructured * me, int element_number, } if (present && present[HTML_BUTTON_VALUE] && - value[HTML_BUTTON_VALUE] && *value[HTML_BUTTON_VALUE]) { + non_empty(value[HTML_BUTTON_VALUE])) { /* * Convert any HTML entities or decimal escaping. - FM */ @@ -4383,17 +4396,17 @@ static int HTML_start_element(HTStructured * me, int element_number, I.disabled = YES; if (present && present[HTML_BUTTON_CLASS] && /* Not yet used. */ - value[HTML_BUTTON_CLASS] && *value[HTML_BUTTON_CLASS]) + non_empty(value[HTML_BUTTON_CLASS])) I.class = value[HTML_BUTTON_CLASS]; if (present && present[HTML_BUTTON_ID] && - value[HTML_BUTTON_ID] && *value[HTML_BUTTON_ID]) { + non_empty(value[HTML_BUTTON_ID])) { I.id = value[HTML_BUTTON_ID]; CHECK_ID(HTML_BUTTON_ID); } if (present && present[HTML_BUTTON_LANG] && /* Not yet used. */ - value[HTML_BUTTON_LANG] && *value[HTML_BUTTON_LANG]) + non_empty(value[HTML_BUTTON_LANG])) I.lang = value[HTML_BUTTON_LANG]; chars = HText_beginInput(me->text, me->inUnderline, &I); @@ -4480,7 +4493,7 @@ static int HTML_start_element(HTStructured * me, int element_number, I.md = NULL; I.min = NULL; I.name = NULL; - I.size = NULL; + I.size = 0; I.src = NULL; I.type = NULL; I.value = NULL; @@ -4512,8 +4525,8 @@ static int HTML_start_element(HTStructured * me, int element_number, * Get the TYPE and make sure we can handle it. - FM */ if (present && present[HTML_INPUT_TYPE] && - value[HTML_INPUT_TYPE] && *value[HTML_INPUT_TYPE]) { - char *not_impl = NULL; + non_empty(value[HTML_INPUT_TYPE])) { + const char *not_impl = NULL; char *usingval = NULL; I.type = value[HTML_INPUT_TYPE]; @@ -4623,10 +4636,10 @@ static int HTML_start_element(HTStructured * me, int element_number, I.name = I_name; } if ((present && present[HTML_INPUT_ALT] && - value[HTML_INPUT_ALT] && *value[HTML_INPUT_ALT] && + non_empty(value[HTML_INPUT_ALT]) && I.type && !strcasecomp(I.type, "image")) && !(present && present[HTML_INPUT_VALUE] && - value[HTML_INPUT_VALUE] && *value[HTML_INPUT_VALUE])) { + non_empty(value[HTML_INPUT_VALUE]))) { /* * This is a TYPE="image" using an ALT rather than VALUE * attribute to indicate the link string for text clients or @@ -4637,12 +4650,12 @@ static int HTML_start_element(HTStructured * me, int element_number, } if (verbose_img && !clickable_images && present && present[HTML_INPUT_SRC] && - value[HTML_INPUT_SRC] && *value[HTML_INPUT_SRC] && + non_empty(value[HTML_INPUT_SRC]) && I.type && !strcasecomp(I.type, "image")) { ImageSrc = MakeNewImageValue(value); } else if (clickable_images == TRUE && present && present[HTML_INPUT_SRC] && - value[HTML_INPUT_SRC] && *value[HTML_INPUT_SRC] && + non_empty(value[HTML_INPUT_SRC]) && I.type && !strcasecomp(I.type, "image")) { StrAllocCopy(href, value[HTML_INPUT_SRC]); /* @@ -4773,43 +4786,45 @@ static int HTML_start_element(HTStructured * me, int element_number, if (present && present[HTML_INPUT_CHECKED]) I.checked = YES; if (present && present[HTML_INPUT_SIZE] && - value[HTML_INPUT_SIZE] && *value[HTML_INPUT_SIZE]) - I.size = value[HTML_INPUT_SIZE]; + non_empty(value[HTML_INPUT_SIZE])) + I.size = atoi(value[HTML_INPUT_SIZE]); + LimitValue(I.size, MAX_LINE); if (present && present[HTML_INPUT_MAXLENGTH] && - value[HTML_INPUT_MAXLENGTH] && *value[HTML_INPUT_MAXLENGTH]) + non_empty(value[HTML_INPUT_MAXLENGTH])) I.maxlength = value[HTML_INPUT_MAXLENGTH]; if (present && present[HTML_INPUT_DISABLED]) I.disabled = YES; if (present && present[HTML_INPUT_ACCEPT_CHARSET]) { /* Not yet used. */ - I.accept_cs = value[HTML_INPUT_ACCEPT_CHARSET] ? - value[HTML_INPUT_ACCEPT_CHARSET] : "UNKNOWN"; + I.accept_cs = (value[HTML_INPUT_ACCEPT_CHARSET] + ? value[HTML_INPUT_ACCEPT_CHARSET] + : "UNKNOWN"); } if (present && present[HTML_INPUT_ALIGN] && /* Not yet used. */ - value[HTML_INPUT_ALIGN] && *value[HTML_INPUT_ALIGN]) + non_empty(value[HTML_INPUT_ALIGN])) I.align = value[HTML_INPUT_ALIGN]; if (present && present[HTML_INPUT_CLASS] && /* Not yet used. */ - value[HTML_INPUT_CLASS] && *value[HTML_INPUT_CLASS]) + non_empty(value[HTML_INPUT_CLASS])) I.class = value[HTML_INPUT_CLASS]; if (present && present[HTML_INPUT_ERROR] && /* Not yet used. */ - value[HTML_INPUT_ERROR] && *value[HTML_INPUT_ERROR]) + non_empty(value[HTML_INPUT_ERROR])) I.error = value[HTML_INPUT_ERROR]; if (present && present[HTML_INPUT_HEIGHT] && /* Not yet used. */ - value[HTML_INPUT_HEIGHT] && *value[HTML_INPUT_HEIGHT]) + non_empty(value[HTML_INPUT_HEIGHT])) I.height = value[HTML_INPUT_HEIGHT]; if (present && present[HTML_INPUT_WIDTH] && /* Not yet used. */ - value[HTML_INPUT_WIDTH] && *value[HTML_INPUT_WIDTH]) + non_empty(value[HTML_INPUT_WIDTH])) I.width = value[HTML_INPUT_WIDTH]; if (present && present[HTML_INPUT_ID] && - value[HTML_INPUT_ID] && *value[HTML_INPUT_ID]) { + non_empty(value[HTML_INPUT_ID])) { I.id = value[HTML_INPUT_ID]; CHECK_ID(HTML_INPUT_ID); } if (present && present[HTML_INPUT_LANG] && /* Not yet used. */ - value[HTML_INPUT_LANG] && *value[HTML_INPUT_LANG]) + non_empty(value[HTML_INPUT_LANG])) I.lang = value[HTML_INPUT_LANG]; if (present && present[HTML_INPUT_MD] && /* Not yet used. */ - value[HTML_INPUT_MD] && *value[HTML_INPUT_MD]) + non_empty(value[HTML_INPUT_MD])) I.md = value[HTML_INPUT_MD]; chars = HText_beginInput(me->text, me->inUnderline, &I); @@ -5008,27 +5023,29 @@ static int HTML_start_element(HTStructured * me, int element_number, if (present && present[HTML_TEXTAREA_COLS] && value[HTML_TEXTAREA_COLS] && isdigit(UCH(*value[HTML_TEXTAREA_COLS]))) - StrAllocCopy(me->textarea_cols, value[HTML_TEXTAREA_COLS]); + me->textarea_cols = atoi(value[HTML_TEXTAREA_COLS]); else { int width; width = LYcolLimit - me->new_style->leftIndent - me->new_style->rightIndent; if (dump_output_immediately) /* don't waste too much for this */ - width = HTMIN(width, 60); + width = HTMIN(width, DFT_TEXTAREA_COLS); if (width > 1 && (width - 1) * 6 < MAX_LINE - 3 - me->new_style->leftIndent - me->new_style->rightIndent) - HTSprintf0(&me->textarea_cols, "%d", width); + me->textarea_cols = width; else - StrAllocCopy(me->textarea_cols, "60"); + me->textarea_cols = DFT_TEXTAREA_COLS; } + LimitValue(me->textarea_cols, MAX_TEXTAREA_COLS); if (present && present[HTML_TEXTAREA_ROWS] && value[HTML_TEXTAREA_ROWS] && isdigit(UCH(*value[HTML_TEXTAREA_ROWS]))) me->textarea_rows = atoi(value[HTML_TEXTAREA_ROWS]); else - me->textarea_rows = 4; + me->textarea_rows = DFT_TEXTAREA_ROWS; + LimitValue(me->textarea_rows, MAX_TEXTAREA_ROWS); if (present && present[HTML_TEXTAREA_DISABLED]) me->textarea_disabled = YES; @@ -5036,7 +5053,7 @@ static int HTML_start_element(HTStructured * me, int element_number, me->textarea_disabled = NO; if (present && present[HTML_TEXTAREA_ID] - && value[HTML_TEXTAREA_ID] && *value[HTML_TEXTAREA_ID]) { + && non_empty(value[HTML_TEXTAREA_ID])) { StrAllocCopy(id_string, value[HTML_TEXTAREA_ID]); TRANSLATE_AND_UNESCAPE_TO_STD(&id_string); if ((id_string != '\0') && @@ -5157,7 +5174,7 @@ static int HTML_start_element(HTStructured * me, int element_number, I.md = NULL; I.min = NULL; I.name = NULL; - I.size = NULL; + I.size = 0; I.src = NULL; I.type = NULL; I.value = NULL; @@ -5196,7 +5213,7 @@ static int HTML_start_element(HTStructured * me, int element_number, I.disabled = YES; if (present && present[HTML_OPTION_ID] - && value[HTML_OPTION_ID] && *value[HTML_OPTION_ID]) { + && non_empty(value[HTML_OPTION_ID])) { if ((ID_A = HTAnchor_findChildAndLink(me->node_anchor, /* Parent */ value[HTML_OPTION_ID], /* Tag */ NULL, /* Addresss */ @@ -5328,7 +5345,7 @@ static int HTML_start_element(HTStructured * me, int element_number, MAX_NESTING)); } if (present && present[HTML_TABLE_ALIGN] && - value[HTML_TABLE_ALIGN] && *value[HTML_TABLE_ALIGN]) { + non_empty(value[HTML_TABLE_ALIGN])) { if (!strcasecomp(value[HTML_TABLE_ALIGN], "center")) { if (no_table_center) { me->DivisionAlignments[me->Division_Level] = HT_LEFT; @@ -5897,9 +5914,9 @@ static int HTML_end_element(HTStructured * me, int element_number, * the SGML parser so that any 8 bit or multibyte/CJK characters will * be handled by the parser's state and charset routines. - FM */ - if (me->node_anchor->bookmark && *me->node_anchor->bookmark) { + if (non_empty(me->node_anchor->bookmark)) { if ((LYMultiBookmarks != MBM_OFF) || - ((bookmark_page && *bookmark_page) && + (non_empty(bookmark_page) && strcmp(me->node_anchor->bookmark, bookmark_page))) { if (!include) include = &me->xinclude; @@ -6237,7 +6254,7 @@ static int HTML_end_element(HTStructured * me, int element_number, */ me->inA = FALSE; #ifdef MARK_HIDDEN_LINKS - if (hidden_link_marker && *hidden_link_marker && + if (non_empty(hidden_link_marker) && HText_isAnchorBlank(me->text, me->CurrentANum)) { HText_appendText(me->text, hidden_link_marker); } @@ -6408,7 +6425,7 @@ static int HTML_end_element(HTStructured * me, int element_number, * present, and discard the content (sigh 8-). - FM */ if (me->object_declare == TRUE) { - if (me->object_id && *me->object_id && !LYMapsOnly) + if (non_empty(me->object_id) && !LYMapsOnly) LYHandleID(me, me->object_id); CTRACE((tfp, "HTML: DECLAREd OBJECT. Ignoring!\n")); goto End_Object; @@ -6420,7 +6437,7 @@ static int HTML_end_element(HTStructured * me, int element_number, * we have code to handle these. (sigh 8-). - FM */ if (me->object_name != NULL && !LYMapsOnly) { - if (me->object_id && *me->object_id) + if (non_empty(me->object_id)) LYHandleID(me, me->object_id); CTRACE((tfp, "HTML: NAMEd OBJECT. Ignoring!\n")); goto End_Object; @@ -6613,7 +6630,7 @@ static int HTML_end_element(HTStructured * me, int element_number, /* * Add an ID link if needed. - FM */ - if (me->object_id && *me->object_id && !LYMapsOnly) + if (non_empty(me->object_id) && !LYMapsOnly) LYHandleID(me, me->object_id); /* @@ -6803,7 +6820,7 @@ static int HTML_end_element(HTStructured * me, int element_number, I.md = NULL; I.min = NULL; I.name = NULL; - I.size = NULL; + I.size = 0; I.src = NULL; I.type = NULL; I.value = NULL; @@ -6953,7 +6970,7 @@ static int HTML_end_element(HTStructured * me, int element_number, } I.value = temp; chars = HText_beginInput(me->text, me->inUnderline, &I); - for (chars = atoi(me->textarea_cols); chars > 0; chars--) + for (chars = me->textarea_cols; chars > 0; chars--) HTML_put_character(me, '_'); HText_appendCharacter(me->text, '\r'); if (*data == '\n') { @@ -6978,7 +6995,6 @@ static int HTML_end_element(HTStructured * me, int element_number, HTChunkClear(&me->textarea); FREE(me->textarea_name); me->textarea_name_cs = -1; - FREE(me->textarea_cols); FREE(me->textarea_id); break; } @@ -7065,7 +7081,7 @@ static int HTML_end_element(HTStructured * me, int element_number, } HText_setIgnoreExcess(me->text, TRUE); } - for (; ptr && *ptr != '\0'; ptr++) { + for (; non_empty(ptr); ptr++) { if (*ptr == ' ') HText_appendCharacter(me->text, HT_NON_BREAK_SPACE); else { @@ -7521,7 +7537,6 @@ static void HTML_abort(HTStructured * me, HTError e) FREE(me->map_address); FREE(me->textarea_name); FREE(me->textarea_accept_cs); - FREE(me->textarea_cols); FREE(me->textarea_id); FREE(me->LastOptionValue); FREE(me->xinclude); @@ -7702,7 +7717,7 @@ HTStructured *HTML_new(HTParentAnchor *anchor, me->textarea_name = NULL; me->textarea_name_cs = -1; me->textarea_accept_cs = NULL; - me->textarea_cols = NULL; + me->textarea_cols = 0; me->textarea_rows = 4; me->textarea_disabled = NO; me->textarea_id = NULL; @@ -8287,7 +8302,7 @@ static char *MakeNewMapValue(const char **value, const char *mapstr) StrAllocCopy(newtitle, "["); StrAllocCat(newtitle, mapstr); /* ISMAP or USEMAP */ - if (verbose_img && value[HTML_IMG_SRC] && *value[HTML_IMG_SRC]) { + if (verbose_img && non_empty(value[HTML_IMG_SRC])) { StrAllocCat(newtitle, ":"); ptr = strrchr(value[HTML_IMG_SRC], '/'); if (!ptr) { diff --git a/src/HTML.h b/src/HTML.h index 3fe857b2..a8626270 100644 --- a/src/HTML.h +++ b/src/HTML.h @@ -103,7 +103,7 @@ struct _HTStructured { char *textarea_name; int textarea_name_cs; char *textarea_accept_cs; - char *textarea_cols; + int textarea_cols; int textarea_rows; int textarea_disabled; char *textarea_id; diff --git a/src/LYBookmark.c b/src/LYBookmark.c index 8354d6bf..0c238fec 100644 --- a/src/LYBookmark.c +++ b/src/LYBookmark.c @@ -24,7 +24,7 @@ char *MBM_A_subbookmark[MBM_V_MAXFILES + 1]; char *MBM_A_subdescript[MBM_V_MAXFILES + 1]; static BOOLEAN is_mosaic_hotlist = FALSE; -static char *convert_mosaic_bookmark_file(char *filename_buffer); +static const char *convert_mosaic_bookmark_file(const char *filename_buffer); int LYindex2MBM(int n) { @@ -36,8 +36,8 @@ int LYindex2MBM(int n) int LYMBM2index(int ch) { if ((ch = TOUPPER(ch)) > 0) { - char *letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - char *result = strchr(letters, ch); + const char *letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + const char *result = strchr(letters, ch); if (result != 0 && (result - letters) <= MBM_V_MAXFILES) @@ -68,7 +68,7 @@ static void show_bookmark_not_defined(void) * BookmarkPage but not *URL is the selection is valid but the file doesn't yet * exist. - FM */ -char *get_bookmark_filename(char **URL) +const char *get_bookmark_filename(char **URL) { static char filename_buffer[LY_MAXPATH]; char *string_buffer = 0; @@ -118,7 +118,7 @@ char *get_bookmark_filename(char **URL) if (LYSafeGets(&string_buffer, fp) != 0 && *LYTrimNewline(string_buffer) != '\0' && !strncmp(string_buffer, "ncsa-xmosaic-hotlist-format-1", 29)) { - char *newname; + const char *newname; /* * It is a mosaic hotlist file. @@ -143,7 +143,7 @@ char *get_bookmark_filename(char **URL) * Converts a Mosaic hotlist file into an HTML file for handling as a Lynx * bookmark file. - FM */ -static char *convert_mosaic_bookmark_file(char *filename_buffer) +static const char *convert_mosaic_bookmark_file(const char *filename_buffer) { static char newfile[LY_MAXPATH]; FILE *fp, *nfp; @@ -196,12 +196,12 @@ static char *title_convert8bit(const char *Title); * exist, and making sure that no_cache is set for a pre-existing, cached file, * so that the change will be evident on return to to that file. - FM */ -void save_bookmark_link(char *address, - char *title) +void save_bookmark_link(const char *address, + const char *title) { FILE *fp; BOOLEAN first_time = FALSE; - char *filename; + const char *filename; char *bookmark_URL = NULL; char filename_buffer[LY_MAXPATH]; char string_buffer[BUFSIZ]; @@ -216,7 +216,7 @@ void save_bookmark_link(char *address, /* * Make sure we were passed something to save. - FM */ - if (!(address && *address)) { + if (isEmpty(address)) { HTAlert(MALFORMED_ADDRESS); return; } @@ -945,7 +945,7 @@ BOOLEAN LYHaveSubBookmarks(void) int i; for (i = 1; i < MBM_V_MAXFILES; i++) { - if (MBM_A_subbookmark[i] != NULL && *MBM_A_subbookmark[i] != '\0') + if (non_empty(MBM_A_subbookmark[i])) return (TRUE); } @@ -959,7 +959,7 @@ BOOLEAN LYHaveSubBookmarks(void) * want to use _statusline() so that any multibyte/CJK characters in the string * will be handled properly. - FM */ -void LYMBM_statusline(char *text) +void LYMBM_statusline(const char *text) { if (LYMultiBookmarks != MBM_OFF && user_mode == NOVICE_MODE) { LYStatusLine = (LYlines - 1); diff --git a/src/LYBookmark.h b/src/LYBookmark.h index 5e2d837e..a0a2816f 100644 --- a/src/LYBookmark.h +++ b/src/LYBookmark.h @@ -7,14 +7,14 @@ #endif /* LYSTRUCTS_H */ extern BOOLEAN LYHaveSubBookmarks(void); -extern char *get_bookmark_filename(char **name); +extern const char *get_bookmark_filename(char **name); extern int LYMBM2index(int ch); extern int LYindex2MBM(int n); extern int select_menu_multi_bookmarks(void); extern int select_multi_bookmarks(void); -extern void LYMBM_statusline(char *text); +extern void LYMBM_statusline(const char *text); extern void remove_bookmark_link(int cur, char *cur_bookmark_page); -extern void save_bookmark_link(char *address, char *title); +extern void save_bookmark_link(const char *address, const char *title); extern void set_default_bookmark_page(char *value); #endif /* LYBOOKMARK_H */ diff --git a/src/LYCgi.c b/src/LYCgi.c index 77f708f3..638543da 100644 --- a/src/LYCgi.c +++ b/src/LYCgi.c @@ -63,7 +63,7 @@ static char *accept_language = NULL; static char *post_len = NULL; #endif /* LYNXCGI_LINKS */ -static void add_environment_value(char *env_value); +static void add_environment_value(const char *env_value); #define PERROR(msg) CTRACE((tfp, "LYNXCGI: %s: %s\n", msg, LYStrerror(errno))) @@ -100,7 +100,7 @@ static void remember_alloced(void *ptr) * Simple routine for expanding the environment array and adding a value to * it */ -static void add_environment_value(char *env_value) +static void add_environment_value(const char *env_value) { if (envc == envc_size) { /* Need some more slots */ envc_size += 10; @@ -118,7 +118,7 @@ static void add_environment_value(char *env_value) } } - env[envc++] = env_value; + env[envc++] = (char *) env_value; env[envc] = NULL; /* Make sure it is always properly terminated */ } @@ -500,12 +500,12 @@ static int LYLoadCGI(const char *arg, dup2(fd2[1], fileno(stderr)); close(fd2[1]); - if (language && *language) { + if (non_empty(language)) { HTSprintf0(&accept_language, "HTTP_ACCEPT_LANGUAGE=%s", language); add_environment_value(accept_language); } - if (pref_charset && *pref_charset) { + if (non_empty(pref_charset)) { cp = NULL; StrAllocCopy(cp, "HTTP_ACCEPT_CHARSET="); StrAllocCat(cp, pref_charset); diff --git a/src/LYCharSets.c b/src/LYCharSets.c index 48c6833f..ee0ebe36 100644 --- a/src/LYCharSets.c +++ b/src/LYCharSets.c @@ -879,7 +879,7 @@ UCode_t HTMLGetEntityUCValue(const char *name) /* * Make sure we have a non-zero length name. - FM */ - if (!(name && *name)) + if (isEmpty(name)) return (value); /* diff --git a/src/LYCharUtils.c b/src/LYCharUtils.c index 13d81621..30581988 100644 --- a/src/LYCharUtils.c +++ b/src/LYCharUtils.c @@ -2042,7 +2042,7 @@ BOOL LYUCTranslateBackFormData(char **str, * Parse a parameter from an HTML META tag, i.e., the CONTENT. */ char *LYParseTagParam(char *from, - char *name) + const char *name) { size_t len = strlen(name); char *result = NULL; @@ -2128,7 +2128,7 @@ void LYHandleMETA(HTStructured * me, const BOOL *present, * Load the attributes for possible use by Lynx. - FM */ if (present[HTML_META_HTTP_EQUIV] && - value[HTML_META_HTTP_EQUIV] && *value[HTML_META_HTTP_EQUIV]) { + non_empty(value[HTML_META_HTTP_EQUIV])) { StrAllocCopy(http_equiv, value[HTML_META_HTTP_EQUIV]); convert_to_spaces(http_equiv, TRUE); LYUCTranslateHTMLString(&http_equiv, me->tag_charset, me->tag_charset, @@ -2138,7 +2138,7 @@ void LYHandleMETA(HTStructured * me, const BOOL *present, } } if (present[HTML_META_NAME] && - value[HTML_META_NAME] && *value[HTML_META_NAME]) { + non_empty(value[HTML_META_NAME])) { StrAllocCopy(name, value[HTML_META_NAME]); convert_to_spaces(name, TRUE); LYUCTranslateHTMLString(&name, me->tag_charset, me->tag_charset, @@ -2148,7 +2148,7 @@ void LYHandleMETA(HTStructured * me, const BOOL *present, } } if (present[HTML_META_CONTENT] && - value[HTML_META_CONTENT] && *value[HTML_META_CONTENT]) { + non_empty(value[HTML_META_CONTENT])) { /* * Technically, we should be creating a comma-separated list, but META * tags come one at a time, and we'll handle (or ignore) them as each @@ -2286,7 +2286,7 @@ void LYHandleMETA(HTStructured * me, const BOOL *present, * Check for a text/html Content-Type with a charset directive, if we * didn't already set the charset via a server's header. - AAC & FM */ - } else if (!(me->node_anchor->charset && *me->node_anchor->charset) && + } else if (isEmpty(me->node_anchor->charset) && !strcasecomp(NonNull(http_equiv), "Content-Type")) { LYUCcharset *p_in = NULL; LYUCcharset *p_out = NULL; @@ -2585,7 +2585,7 @@ void LYHandleMETA(HTStructured * me, const BOOL *present, * filename=name.suffix in it, if we don't already have it via a server * header. - FM */ - } else if (!(me->node_anchor->SugFname && *me->node_anchor->SugFname) && + } else if (isEmpty(me->node_anchor->SugFname) && !strcasecomp((http_equiv ? http_equiv : ""), "Content-Disposition")) { cp = content; @@ -2816,7 +2816,7 @@ void LYHandleSELECT(HTStructured * me, const BOOL *present, me->inSELECT = TRUE; if (!(present && present[HTML_SELECT_NAME] && - value[HTML_SELECT_NAME] && *value[HTML_SELECT_NAME])) { + non_empty(value[HTML_SELECT_NAME]))) { StrAllocCopy(name, ""); } else if (strchr(value[HTML_SELECT_NAME], '&') == NULL) { StrAllocCopy(name, value[HTML_SELECT_NAME]); @@ -2829,7 +2829,7 @@ void LYHandleSELECT(HTStructured * me, const BOOL *present, if (present && present[HTML_SELECT_DISABLED]) me->select_disabled = TRUE; if (present && present[HTML_SELECT_SIZE] && - value[HTML_SELECT_SIZE] && *value[HTML_SELECT_SIZE]) { + non_empty(value[HTML_SELECT_SIZE])) { /* * Let the size be determined by the number of OPTIONs. - FM */ @@ -2941,7 +2941,7 @@ void LYHandleSELECT(HTStructured * me, const BOOL *present, } HText_setIgnoreExcess(me->text, TRUE); } - for (; ptr && *ptr != '\0'; ptr++) { + for (; non_empty(ptr); ptr++) { if (*ptr == ' ') HText_appendCharacter(me->text, HT_NON_BREAK_SPACE); else @@ -3191,7 +3191,7 @@ void LYCheckForID(HTStructured * me, const BOOL *present, return; if (present && present[attribute] - && value[attribute] && *value[attribute]) { + && non_empty(value[attribute])) { /* * Translate any named or numeric character references. - FM */ @@ -3225,7 +3225,7 @@ void LYHandleID(HTStructured * me, const char *id) HTChildAnchor *ID_A = NULL; if (!(me && me->text) || - !(id && *id)) + isEmpty(id)) return; /* diff --git a/src/LYCharUtils.h b/src/LYCharUtils.h index 7790918d..45c2b384 100644 --- a/src/LYCharUtils.h +++ b/src/LYCharUtils.h @@ -45,7 +45,7 @@ extern void LYAddMETAcharsetToFD(FILE *fd, extern void LYformTitle(char **dst, const char *src); extern char *LYParseTagParam(char *from, - char *name); + const char *name); extern void LYParseRefreshURL(char *content, char **p_seconds, char **p_address); diff --git a/src/LYCookie.c b/src/LYCookie.c index 0426df25..903d0ab8 100644 --- a/src/LYCookie.c +++ b/src/LYCookie.c @@ -1103,8 +1103,8 @@ static void LYProcessSetCookies(const char *SetCookie, BOOL Quoted = FALSE; unsigned parse_flags = 0; - if (!(SetCookie && *SetCookie) && - !(SetCookie2 && *SetCookie2)) { + if (isEmpty(SetCookie) && + isEmpty(SetCookie2)) { /* * Yuk! Garbage in, so nothing out. - FM */ @@ -1424,7 +1424,7 @@ static void LYProcessSetCookies(const char *SetCookie, cookie_len = 0; NumCookies = 0; cur_cookie = NULL; - p = ((SetCookie && !(SetCookie2 && *SetCookie2)) ? SetCookie : ""); + p = ((SetCookie && isEmpty(SetCookie2)) ? SetCookie : ""); if (SetCookie2 && *p) { CTRACE((tfp, "LYProcessSetCookies: Using Set-Cookie header.\n")); } @@ -1769,8 +1769,8 @@ void LYSetCookie(const char *SetCookie, *ptr = '\0'; } } - if (!(SetCookie && *SetCookie) && - !(SetCookie2 && *SetCookie2)) { + if (isEmpty(SetCookie) && + isEmpty(SetCookie2)) { /* * Yuk, something must have gone wrong in HTMIME.c or HTTP.c because * both SetCookie and SetCookie2 are NULL or zero-length. - FM diff --git a/src/LYCurses.c b/src/LYCurses.c index 9c3ca53b..5430287d 100644 --- a/src/LYCurses.c +++ b/src/LYCurses.c @@ -222,7 +222,7 @@ static void sl_suspend(int sig) /* *INDENT-OFF* */ /* definitions for the mono attributes we can use */ static struct { - char *name; + const char *name; int code; } Mono_Attrs[7] = { diff --git a/src/LYDownload.c b/src/LYDownload.c index 2a7d2c52..721c75ed 100644 --- a/src/LYDownload.c +++ b/src/LYDownload.c @@ -455,7 +455,7 @@ void LYDownload(char *line) * Compare a filename with a given suffix, which we have set to give a rough * idea of its content. */ -static int SuffixIs(char *filename, char *suffix) +static int SuffixIs(char *filename, const char *suffix) { size_t have = strlen(filename); size_t need = strlen(suffix); diff --git a/src/LYEdit.c b/src/LYEdit.c index c61c2bc8..12a01d35 100644 --- a/src/LYEdit.c +++ b/src/LYEdit.c @@ -163,15 +163,15 @@ int edit_current_file(char *newfile, } void edit_temporary_file(char *filename, - char *position, - char *message) + const char *position, + const char *message) { #ifdef UNIX struct stat stat_info; #endif - char *format = "%s %s"; + const char *format = "%s %s"; char *command = NULL; - char *editor_arg = ""; + const char *editor_arg = ""; int params = 1; int rv; diff --git a/src/LYEdit.h b/src/LYEdit.h index a3db4a55..8b417e19 100644 --- a/src/LYEdit.h +++ b/src/LYEdit.h @@ -7,6 +7,6 @@ extern BOOLEAN editor_can_position(void); extern int edit_current_file(char *newfile, int cur, int lineno); -extern void edit_temporary_file(char *filename, char *position, char *message); +extern void edit_temporary_file(char *filename, const char *position, const char *message); #endif /* LYEDIT_H */ diff --git a/src/LYEditmap.c b/src/LYEditmap.c index f5573071..2b30e1c7 100644 --- a/src/LYEditmap.c +++ b/src/LYEditmap.c @@ -940,7 +940,7 @@ LYEditCode *LYLineEditors[] = * Add the name that the user will see below. * The order of LYLineEditors and LYLineditNames MUST be the same. */ -char *LYLineeditNames[] = +const char *LYLineeditNames[] = { "Default Binding", #ifdef EXP_ALT_BINDINGS diff --git a/src/LYExtern.c b/src/LYExtern.c index 77f53b49..e042820c 100644 --- a/src/LYExtern.c +++ b/src/LYExtern.c @@ -267,7 +267,7 @@ BOOL run_external(char *param, #endif cmdbuf = lookup_external(param, only_overriders); - if (cmdbuf != 0 && *cmdbuf != '\0') { + if (non_empty(cmdbuf)) { #ifdef WIN_EX /* 1997/10/17 (Fri) 14:07:50 */ int len; char buff[LY_MAXPATH]; diff --git a/src/LYForms.c b/src/LYForms.c index f15754a8..05e6861d 100644 --- a/src/LYForms.c +++ b/src/LYForms.c @@ -841,7 +841,7 @@ static int form_getstr(int cur, * character set has been set truthfully) the user confirms by changing * the field that the character encoding is right. - kw */ - if (form->value && *form->value) + if (non_empty(form->value)) form->value_cs = current_char_set; } return (ch); @@ -908,7 +908,7 @@ void show_formlink_statusline(const FormInfo * form, char *submit_str = NULL; char *xkey_info = key_for_func_ext(LYK_NOCACHE, for_what); - if (xkey_info && *xkey_info) { + if (non_empty(xkey_info)) { #ifdef TEXTFIELDS_MAY_NEED_ACTIVATION if (for_what == FOR_PANEL) HTSprintf0(&submit_str, FORM_TEXT_SUBMIT_MESSAGE_INA_X, @@ -1011,7 +1011,7 @@ void show_formlink_statusline(const FormInfo * form, xkey_info = key_for_func_ext(LYK_DWIMEDIT, for_what); #endif } - if (xkey_info && *xkey_info) { + if (non_empty(xkey_info)) { #ifdef TEXTFIELDS_MAY_NEED_ACTIVATION if (for_what == FOR_PANEL) HTSprintf0(&submit_str, FORM_LINK_TEXTAREA_MESSAGE_INA_E, diff --git a/src/LYGetFile.c b/src/LYGetFile.c index 48d63959..0627a81a 100644 --- a/src/LYGetFile.c +++ b/src/LYGetFile.c @@ -365,7 +365,7 @@ int getfile(DocInfo *doc) if (LYNoRefererHeader == FALSE && LYNoRefererForThis == FALSE) { - char *ref_url = HTLoadedDocumentURL(); + const char *ref_url = HTLoadedDocumentURL(); if (isLYNXIMGMAP(ref_url)) ref_url += LEN_LYNXIMGMAP; @@ -534,7 +534,7 @@ int getfile(DocInfo *doc) title = HTAnchor_title(tmpanchor); } else if (HTMainAnchor && !LYUserSpecifiedURL) { title = HTAnchor_subject(HTMainAnchor); - if (title && *title) { + if (non_empty(title)) { if (strncasecomp(title, "Re:", 3)) { StrAllocCopy(tmptitle, "Re: "); StrAllocCat(tmptitle, title); @@ -851,7 +851,7 @@ int getfile(DocInfo *doc) temp = HTParse(use_this_url_instead, WWWDoc.address, PARSE_ALL); - if (temp && *temp) { + if (non_empty(temp)) { StrAllocCopy(use_this_url_instead, temp); } FREE(temp); diff --git a/src/LYGlobalDefs.h b/src/LYGlobalDefs.h index a60b258a..7e7fa95d 100644 --- a/src/LYGlobalDefs.h +++ b/src/LYGlobalDefs.h @@ -234,9 +234,6 @@ extern char *LYRequestTitle; /* newdoc.title in calls to getfile() */ extern char *LYTransferName; /* abbreviation for Kilobytes */ extern char *LynxHome; extern char *LynxSigFile; /* Signature file, in or off home */ -extern char *checked_box; /* form boxes */ -extern char *checked_radio; /* form radio buttons */ -extern char *empty_string; extern char *ftp_lasthost; extern char *helpfile; extern char *helpfilepath; @@ -255,9 +252,12 @@ extern char *pref_charset; /* Lynx's preferred character set - MM */ extern char *startfile; extern char *system_mail; extern char *system_mail_flags; -extern char *unchecked_box; /* form boxes */ -extern char *unchecked_radio; /* form radio buttons */ extern char *x_display; +extern char empty_string[]; +extern const char *checked_box; /* form boxes */ +extern const char *checked_radio; /* form radio buttons */ +extern const char *unchecked_box; /* form boxes */ +extern const char *unchecked_radio; /* form radio buttons */ extern int LYAcceptEncoding; extern int LYAcceptMedia; @@ -400,7 +400,7 @@ extern char *startrealm; extern BOOLEAN more_links; extern int crawl_count; extern BOOLEAN LYCancelledFetch; -extern char *LYToolbarName; +extern const char *LYToolbarName; extern int AlertSecs; extern int InfoSecs; diff --git a/src/LYHistory.c b/src/LYHistory.c index 0b96d6a4..ec885f6d 100644 --- a/src/LYHistory.c +++ b/src/LYHistory.c @@ -95,9 +95,9 @@ void LYAddVisitedLink(DocInfo *doc) { VisitedLink *new; HTList *cur; - char *title = (doc->title ? doc->title : NO_TITLE); + const char *title = (doc->title ? doc->title : NO_TITLE); - if (!(doc->address && *doc->address)) { + if (isEmpty(doc->address)) { PrevVisitedLink = NULL; return; } @@ -788,7 +788,7 @@ int LYShowVisitedLinks(char **newfile) HTList *cur = Visited_Links; int offset; int ret = 0; - char *arrow, *post_arrow; + const char *arrow, *post_arrow; if (!cur) return (-1); @@ -866,7 +866,7 @@ int LYShowVisitedLinks(char **newfile) offset = LYcols * 3 / 4; } else offset = (x > 99 ? 0 : x < 10 ? 2 : 1); - if (vl->title != NULL && *vl->title != '\0') { + if (non_empty(vl->title)) { StrAllocCopy(Title, vl->title); LYEntify(&Title, TRUE); LYTrimLeading(Title); @@ -876,7 +876,7 @@ int LYShowVisitedLinks(char **newfile) } else { StrAllocCopy(Title, NO_TITLE); } - if (vl->address != NULL && *vl->address != '\0') { + if (non_empty(vl->address)) { StrAllocCopy(Address, vl->address); LYEntify(&Address, FALSE); fprintf(fp0, diff --git a/src/LYJump.c b/src/LYJump.c index 951ff600..419963ea 100644 --- a/src/LYJump.c +++ b/src/LYJump.c @@ -62,7 +62,7 @@ void LYAddJumpShortcut(HTList *historyp, char *shortcut) char *old; HTList *cur = historyp; - if (!historyp || !(shortcut && *shortcut)) + if (!historyp || isEmpty(shortcut)) return; StrAllocCopy(new, shortcut); @@ -163,7 +163,7 @@ BOOL LYJumpInit(char *config) if (cp) { jtp->key = remap(cp, "JUMP", FALSE); /* key is present, (re)map it */ cp = strtok(NULL, "\n"); /* get prompt, if present */ - if (cp && *cp) + if (non_empty(cp)) StrAllocCopy(jtp->msg, cp); /* prompt is present, load it */ else cp = NULL; @@ -208,9 +208,9 @@ char *LYJump(int key) if (jtp->nel == 0) return NULL; - if (!jump_buffer || !(jtp->shortcut && *jtp->shortcut)) + if (!jump_buffer || isEmpty(jtp->shortcut)) *buf = '\0'; - else if (jtp->shortcut && *jtp->shortcut) { + else if (non_empty(jtp->shortcut)) { if (strlen(jtp->shortcut) > 119) jtp->shortcut[119] = '\0'; strcpy(buf, jtp->shortcut); diff --git a/src/LYKeymap.c b/src/LYKeymap.c index 604a508a..3e81e27d 100644 --- a/src/LYKeymap.c +++ b/src/LYKeymap.c @@ -28,7 +28,7 @@ LYKbLayout_t *LYKbLayouts[] = kb_layout_yawerty }; -char *LYKbLayoutNames[] = +const char *LYKbLayoutNames[] = { "ROT13'd keyboard layout", "JCUKEN Cyrillic, for AT 101-key kbd", @@ -1122,7 +1122,7 @@ Kcmd *LYStringToKcmd(const char *name) Kcmd *result = 0; Kcmd *maybe = 0; - if (name != 0 && *name != 0) { + if (non_empty(name)) { for (j = 0; revmap[j].name != 0; j++) { if (!strcasecomp(revmap[j].name, name)) { result = revmap + j; @@ -1344,7 +1344,7 @@ int lecname_to_lec(const char *func) int i; struct emap *mp; - if (func != NULL && *func != '\0') { + if (non_empty(func)) { for (i = 0, mp = ekmap; (*mp).name != NULL; mp++, i++) { if (strcmp((*mp).name, func) == 0) { return (*mp).code; @@ -1460,7 +1460,7 @@ GLOBALDEF HTProtocol LYLynxKeymap = * returns lynxkeycode value != 0 if the mapping was made, 0 if not. */ int remap(char *key, - char *func, + const char *func, BOOLEAN for_dired) { Kcmd *mp; diff --git a/src/LYKeymap.h b/src/LYKeymap.h index b2f3cdea..2df5de6e 100644 --- a/src/LYKeymap.h +++ b/src/LYKeymap.h @@ -16,7 +16,7 @@ extern int LYStringToKeycode(char *src); extern int lacname_to_lac(const char *func); extern int lecname_to_lec(const char *func); extern int lkcstring_to_lkc(const char *src); -extern int remap(char *key, char *func, BOOLEAN for_dired); +extern int remap(char *key, const char *func, BOOLEAN for_dired); extern void print_keymap(char **newfile); extern void reset_emacs_keys(void); extern void reset_numbers_as_arrows(void); @@ -39,7 +39,7 @@ extern LYKeymap_t keymap[KEYMAP_SIZE]; /* main keymap matrix */ typedef unsigned short LYKbLayout_t; extern int current_layout; extern LYKbLayout_t *LYKbLayouts[]; -extern char *LYKbLayoutNames[]; +extern const char *LYKbLayoutNames[]; extern int LYSetKbLayout(char *layout_id); #endif diff --git a/src/LYList.c b/src/LYList.c index dd8a801b..25efb9f9 100644 --- a/src/LYList.c +++ b/src/LYList.c @@ -14,6 +14,7 @@ #include <LYGlobalDefs.h> #include <LYCharUtils.h> #include <LYCharSets.h> +#include <LYStrings.h> #include <LYHistory.h> #ifdef DIRED_SUPPORT @@ -44,7 +45,7 @@ int showlist(DocInfo *newdoc, BOOLEAN titles) char *Address = NULL, *Title = NULL, *cp = NULL; char *LinkTitle = NULL; /* Rel stored as property of link, not of dest */ BOOLEAN intern_w_post = FALSE; - char *desc = "unknown field or link"; + const char *desc = "unknown field or link"; void *helper; refs = HText_sourceAnchors(HTMainText); @@ -80,8 +81,9 @@ int showlist(DocInfo *newdoc, BOOLEAN titles) StrAllocCopy(Address, HTLoadedDocumentURL()); LYEntify(&Address, FALSE); fprintf(fp0, "%s%s<p>\n", gettext("References in "), - ((Address != NULL && *Address != '\0') ? Address : - gettext("this document:"))); + (non_empty(Address) + ? Address + : gettext("this document:"))); FREE(Address); if (refs > 0) { fprintf(fp0, "<%s compact>\n", ((keypad_mode == NUMBERS_AS_ARROWS) ? @@ -158,7 +160,7 @@ int showlist(DocInfo *newdoc, BOOLEAN titles) StrAllocCopy(Address, address); FREE(address); LYEntify(&Address, TRUE); - if (title && *title) { + if (non_empty(title)) { LYformTitle(&Title, title); LYEntify(&Title, TRUE); if (*Title) { @@ -194,7 +196,7 @@ int showlist(DocInfo *newdoc, BOOLEAN titles) for (cnt = 0; cnt < hidden_links; cnt++) { StrAllocCopy(Address, HText_HiddenLinkAt(HTMainText, cnt)); LYEntify(&Address, FALSE); - if (!(Address && *Address)) { + if (isEmpty(Address)) { FREE(Address); continue; } @@ -243,7 +245,7 @@ void printlist(FILE *fp, BOOLEAN titles) int cnt; int refs, hidden_links; char *address = NULL; - char *desc = gettext("unknown field or link"); + const char *desc = gettext("unknown field or link"); void *helper; refs = HText_sourceAnchors(HTMainText); @@ -309,7 +311,7 @@ void printlist(FILE *fp, BOOLEAN titles) gettext("Hidden links:")); for (cnt = 0; cnt < hidden_links; cnt++) { StrAllocCopy(address, HText_HiddenLinkAt(HTMainText, cnt)); - if (!(address && *address)) { + if (isEmpty(address)) { FREE(address); continue; } diff --git a/src/LYLocal.c b/src/LYLocal.c index d0e59e8a..c06576d9 100644 --- a/src/LYLocal.c +++ b/src/LYLocal.c @@ -77,7 +77,7 @@ #endif /* FNAMES_8_3 */ #endif /* OK_INSTALL */ -static char *get_filename(char *prompt, +static char *get_filename(const char *prompt, char *buf, size_t bufsize); @@ -680,7 +680,7 @@ static int modify_tagged(char *testpath) * This test used to always fail from the dired menu... changed to * something that hopefully makes more sense - KW */ - if (testpath && *testpath && 0 != strcmp(testpath, "/")) { + if (non_empty(testpath) && 0 != strcmp(testpath, "/")) { /* * testpath passed in and is not empty and not a single "/" (which * would probably be bogus) - use it. @@ -810,7 +810,7 @@ static int modify_tagged(char *testpath) */ static int modify_name(char *testpath) { - char *cp; + const char *cp; char tmpbuf[DIRED_MAXBUF]; char *newpath = NULL; struct stat dir_info; @@ -866,7 +866,8 @@ static int modify_name(char *testpath) */ static int modify_location(char *testpath) { - char *cp; + const char *cp; + char *sp; dev_t dev; ino_t inode; int owner; @@ -918,8 +919,8 @@ static int modify_location(char *testpath) } if (LYisAbsPath(tmpbuf)) { StrAllocCopy(newpath, tmpbuf); - } else if ((cp = LYLastPathSep(newpath)) != NULL) { - *++cp = '\0'; + } else if ((sp = LYLastPathSep(newpath)) != NULL) { + *++sp = '\0'; StrAllocCat(newpath, tmpbuf); } else { HTAlert(gettext("Unexpected failure - unable to find trailing path separator")); @@ -1034,7 +1035,7 @@ static int create_file(char *current_location) int code = FALSE; char tmpbuf[DIRED_MAXBUF]; char *testpath = NULL; - char *bad_chars = ".~/"; + const char *bad_chars = ".~/"; tmpbuf[0] = '\0'; if (get_filename(gettext("Enter name of file to create: "), @@ -1075,7 +1076,7 @@ static int create_directory(char *current_location) int code = FALSE; char tmpbuf[DIRED_MAXBUF]; char *testpath = NULL; - char *bad_chars = ".~/"; + const char *bad_chars = ".~/"; tmpbuf[0] = '\0'; if (get_filename(gettext("Enter name for new directory: "), @@ -1291,7 +1292,7 @@ static int permit_location(char *destpath, */ FILE *fp0; char *user_filename; - char *group_name; + const char *group_name; srcpath = strip_trailing_slash(srcpath); @@ -2126,7 +2127,7 @@ int dired_options(DocInfo *doc, char **newfile) /* * Check DIRED filename. */ -static char *get_filename(char *prompt, +static char *get_filename(const char *prompt, char *buf, size_t bufsize) { diff --git a/src/LYMail.c b/src/LYMail.c index 124342d5..86043541 100644 --- a/src/LYMail.c +++ b/src/LYMail.c @@ -81,7 +81,7 @@ static void comma_append(char **dst, static void extract_field(char **dst, char *src, - char *keyword) + const char *keyword) { int len = strlen(keyword); char *cp, *cp1; @@ -246,7 +246,7 @@ static BOOLEAN convert_explorer(char *address) * reply_by_mail() prompts line-by-line for header information, allowing * scrolling of the screen. */ -static int header_prompt(char *label, +static int header_prompt(const char *label, char **result, unsigned limit) { @@ -1097,7 +1097,7 @@ void reply_by_mail(char *mail_address, #endif char user_input[LINESIZE]; FILE *fd, *fp; - char *label = NULL; + const char *label = NULL; char *from_address = NULL; char *cc_address = NULL; char *to_address = NULL; diff --git a/src/LYMain.c b/src/LYMain.c index 5bfa4ac0..bb5c30ca 100644 --- a/src/LYMain.c +++ b/src/LYMain.c @@ -150,7 +150,9 @@ BOOLEAN enable_scrollback = TRUE; BOOLEAN enable_scrollback = FALSE; #endif /* REVERSE_CLEAR_SCREEN_PROBLEM */ -char *empty_string = "\0"; +char empty_string[] = +{'\0'}; + int display_lines; /* number of lines in display */ int www_search_result = -1; @@ -571,7 +573,7 @@ BOOLEAN FileInitAlreadyDone = FALSE; static BOOLEAN stack_dump = FALSE; static char *terminal = NULL; -static char *pgm; +static const char *pgm; static BOOLEAN no_numbers = FALSE; static BOOLEAN number_links = FALSE; static BOOLEAN number_fields = FALSE; @@ -888,7 +890,7 @@ static BOOL cleanup_win32(DWORD fdwCtrlType) */ #ifdef USE_SSL static void append_ssl_version(char **target, - char *separator) + const char *separator) { char SSLLibraryVersion[256]; char *SSLcp; @@ -1599,7 +1601,7 @@ int main(int argc, if (startfile_stdin) { char result[LY_MAXPATH]; char *buf = NULL; - char *tty = NULL; + const char *tty = NULL; # ifdef HAVE_TTYNAME tty = ttyname(fileno(stderr)); @@ -1978,7 +1980,7 @@ int main(int argc, * If we don't have a homepage specified, set it to startfile. Otherwise, * reset LynxHome. - FM */ - if (!(homepage && *homepage)) { + if (isEmpty(homepage)) { StrAllocCopy(homepage, startfile); } else { StrAllocCopy(LynxHome, homepage); @@ -2031,7 +2033,7 @@ int main(int argc, LYOpenlog(syslog_txt); #endif - if (x_display != NULL && *x_display != '\0') { + if (non_empty(x_display)) { LYisConfiguredForX = TRUE; } @@ -2849,9 +2851,9 @@ static int post_data_fun(char *next_arg GCC_UNUSED) return 0; } -static char *show_restriction(const char *name) +static const char *show_restriction(const char *name) { - char *value = 0; + const char *value = 0; switch (find_restriction(name, -1)) { case TRUE: diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c index 9a5368c9..1c4550d4 100644 --- a/src/LYMainLoop.c +++ b/src/LYMainLoop.c @@ -854,7 +854,7 @@ static int find_link_near_col(int col, while ((delta > 0 ? (i < nlinks) : (i >= 0)) && cy == links[i].ly) { int cx = links[i].lx; - char *text = LYGetHiliteStr(i, 0); + const char *text = LYGetHiliteStr(i, 0); if (text != NULL) cx += strlen(text) / 2; @@ -1748,7 +1748,7 @@ static void handle_LYK_COMMENT(BOOLEAN *refresh_screen, if (!kp && HTMainAnchor) { kp = HTAnchor_subject(HTMainAnchor); - if (kp && *kp) { + if (non_empty(kp)) { if (strncasecomp(kp, "Re: ", 4)) { StrAllocCopy(tmptitle, "Re: "); StrAllocCat(tmptitle, kp); @@ -2198,7 +2198,7 @@ static void handle_LYK_DOWN_LINK(int *follow_col, int newlink; if (*follow_col == -1) { - char *text = LYGetHiliteStr(curdoc.link, 0); + const char *text = LYGetHiliteStr(curdoc.link, 0); *follow_col = links[curdoc.link].lx; @@ -2376,7 +2376,7 @@ static void handle_LYK_EDIT(int *old_c, * Allow the user to edit the link rather than curdoc in edit mode. */ if (lynx_edit_mode && - editor && *editor != '\0' && !no_dired_support) { + non_empty(editor) && !no_dired_support) { if (nlinks > 0) { cp = links[curdoc.link].lname; if (is_url(cp) == FILE_URL_TYPE) { @@ -2415,7 +2415,7 @@ static void handle_LYK_EDIT(int *old_c, } } else #endif /* DIRED_SUPPORT */ - if (editor && *editor != '\0') { + if (non_empty(editor)) { if (edit_current_file(newdoc.address, curdoc.link, Newline)) { HTuncache_current_document(); LYforce_no_cache = TRUE; /*force reload of document */ @@ -4176,7 +4176,13 @@ static void handle_LYK_SHELL(BOOLEAN *refresh_screen, Cygwin_Shell(); } else #endif - LYSystem(LYSysShell()); + { + static char *shell = NULL; + + if (shell == 0) + StrAllocCopy(shell, LYSysShell()); + LYSystem(shell); + } start_curses(); *refresh_screen = TRUE; /* for an HText_pageDisplay() */ } else { @@ -4530,7 +4536,7 @@ static void handle_LYK_UP_LINK(int *follow_col, int newlink; if (*follow_col == -1) { - char *text = LYGetHiliteStr(curdoc.link, 0); + const char *text = LYGetHiliteStr(curdoc.link, 0); *follow_col = links[curdoc.link].lx; @@ -4594,7 +4600,7 @@ static void handle_LYK_VIEW_BOOKMARK(BOOLEAN *refresh_screen, int *old_c, int real_c) { - char *cp; + const char *cp; if (LYValidate) { if (*old_c != real_c) { @@ -5047,7 +5053,7 @@ static void handle_LYK_SHIFT_RIGHT(BOOLEAN *flag, int count) static BOOLEAN handle_LYK_LINEWRAP_TOGGLE(int *cmd, BOOLEAN *flag) { - static char *choices[] = + static const char *choices[] = { "Try to fit screen width", "No line wrap in columns", @@ -5229,12 +5235,14 @@ int mainloop(void) bookmark_start = FALSE; goto initialize; } else { + const char *cp1; + /* * See if a bookmark page exists. If it does, replace * newdoc.address with its name */ - if ((cp = get_bookmark_filename(&newdoc.address)) != NULL && - *cp != '\0' && strcmp(cp, " ")) { + if ((cp1 = get_bookmark_filename(&newdoc.address)) != NULL && + *cp1 != '\0' && strcmp(cp1, " ")) { StrAllocCopy(newdoc.title, BOOKMARK_TITLE); StrAllocCopy(newdoc.bookmark, BookmarkPage); StrAllocCopy(startrealm, newdoc.address); @@ -5700,7 +5708,7 @@ int mainloop(void) */ if (((first_file == TRUE) && (dump_output_immediately == FALSE) && - !(newdoc.bookmark && *newdoc.bookmark)) && + isEmpty(newdoc.bookmark)) && ((LYisLocalFile(newdoc.address) == TRUE) && !(strcmp(NonNull(HText_getTitle()), BOOKMARK_TITLE))) && @@ -7455,7 +7463,7 @@ void HTAddGotoURL(char *url) char *old; HTList *cur; - if (!(url && *url)) + if (isEmpty(url)) return; CTRACE((tfp, "HTAddGotoURL %s\n", url)); @@ -7529,7 +7537,7 @@ static void show_main_statusline(const LinkInfo curlink, * Let them know if it's an index -- very rare. */ if (is_www_index) { - char *indx = gettext("-index-"); + const char *indx = gettext("-index-"); LYmove(LYlines - 1, LYcolLimit - strlen(indx)); lynx_start_reverse(); @@ -7751,9 +7759,9 @@ static void status_link(char *curlink_name, } } -char *LYDownLoadAddress(void) +const char *LYDownLoadAddress(void) { - char *s = newdoc.address ? newdoc.address : ""; + const char *s = newdoc.address ? newdoc.address : ""; return s; } diff --git a/src/LYMainLoop.h b/src/LYMainLoop.h index 117e7721..c1cef7c4 100644 --- a/src/LYMainLoop.h +++ b/src/LYMainLoop.h @@ -8,8 +8,9 @@ #ifdef DISP_PARTIAL extern BOOL LYMainLoop_pageDisplay(int line_num); #endif + extern BOOLEAN LYOpenTraceLog(void); -extern char *LYDownLoadAddress(void); +extern const char *LYDownLoadAddress(void); extern int LYGetNewline(void); extern int mainloop(void); extern void HTAddGotoURL(char *url); diff --git a/src/LYMap.c b/src/LYMap.c index b36ed71e..c401a27e 100644 --- a/src/LYMap.c +++ b/src/LYMap.c @@ -19,6 +19,7 @@ #include <LYKeymap.h> #include <LYCharUtils.h> #include <LYCharSets.h> +#include <LYStrings.h> #ifdef DIRED_SUPPORT #include <LYUpload.h> @@ -131,7 +132,7 @@ BOOL LYAddImageMap(char *address, HTList *curele = NULL; LYMapElement *ele = NULL; - if (!(address && *address)) + if (isEmpty(address)) return FALSE; if (!(node_anchor && node_anchor->address)) return FALSE; @@ -195,7 +196,7 @@ BOOL LYAddImageMap(char *address, return FALSE; } StrAllocCopy(new->address, address); - if (title && *title) + if (non_empty(title)) StrAllocCopy(new->title, title); if (new != old) HTList_addObject(theList, new); @@ -217,7 +218,7 @@ BOOL LYAddMapElement(char *map, HTList *theList = NULL; HTList *cur = NULL; - if (!(map && *map && address && *address)) + if (isEmpty(map) || isEmpty(address)) return FALSE; if (!(node_anchor && node_anchor->address)) return FALSE; @@ -274,7 +275,7 @@ BOOL LYAddMapElement(char *map, return FALSE; } StrAllocCopy(new->address, address); - if (title && *title) + if (non_empty(title)) StrAllocCopy(new->title, title); else StrAllocCopy(new->title, address); @@ -294,7 +295,7 @@ BOOL LYHaveImageMap(char *address) LYImageMap *Map; HTList *cur = LynxMaps; - if (!(cur && address && *address != '\0')) + if (!(cur && non_empty(address))) return FALSE; while (NULL != (Map = (LYImageMap *) HTList_nextObject(cur))) { @@ -370,7 +371,7 @@ static HTList *get_the_list(DocAddress *wwwdoc, char *address, { if (anchor && anchor->post_data) { fill_DocAddress(wwwdoc, address, anchor, punderlying); - if (punderlying && *punderlying) + if (non_empty(punderlying)) return (*punderlying)->imaps; return anchor->imaps; } else { @@ -524,17 +525,17 @@ static int LYLoadIMGmap(const char *arg, return (HT_NOT_LOADED); } - if (theMap->title && *theMap->title) { + if (non_empty(theMap->title)) { StrAllocCopy(MapTitle, theMap->title); - } else if (anAnchor->title && *anAnchor->title) { + } else if (non_empty(anAnchor->title)) { StrAllocCopy(MapTitle, anAnchor->title); - } else if (LYRequestTitle && *LYRequestTitle && + } else if (non_empty(LYRequestTitle) && strcasecomp(LYRequestTitle, "[USEMAP]")) { StrAllocCopy(MapTitle, LYRequestTitle); } else if ((cp = strchr(address, '#')) != NULL) { StrAllocCopy(MapTitle, (cp + 1)); } - if (!(MapTitle && *MapTitle)) { + if (isEmpty(MapTitle)) { StrAllocCopy(MapTitle, "[USEMAP]"); } else { LYEntify(&MapTitle, TRUE); diff --git a/src/LYNews.c b/src/LYNews.c index 94902bf2..1034d86d 100644 --- a/src/LYNews.c +++ b/src/LYNews.c @@ -104,7 +104,7 @@ char *LYNewsPost(char *newsgroups, * Make sure a non-zero length newspost, newsreply, snewspost or snewsreply * path was sent to us. - FM */ - if (!(newsgroups && *newsgroups)) + if (isEmpty(newsgroups)) return (postfile); /* @@ -318,7 +318,7 @@ char *LYNewsPost(char *newsgroups, /* * Have the user create the message body. */ - if (!no_editor && editor && *editor != '\0') { + if (!no_editor && non_empty(editor)) { if (followup && nhist > 0) { /* diff --git a/src/LYOptions.c b/src/LYOptions.c index 25f995fa..43e1e3c6 100644 --- a/src/LYOptions.c +++ b/src/LYOptions.c @@ -44,7 +44,7 @@ static BOOLEAN can_do_colors = FALSE; BOOLEAN LYCheckUserAgent(void) { - if (LYUserAgent && *LYUserAgent) { + if (non_empty(LYUserAgent)) { if (strstr(LYUserAgent, "Lynx") == 0 && strstr(LYUserAgent, "lynx") == 0 && strstr(LYUserAgent, "L_y_n_x") == 0 @@ -266,19 +266,19 @@ static void addlbl(const char *text) void LYoptions(void) { #define ShowBool(value) LYaddstr((value) ? "ON " : "OFF") - static char *bool_choices[] = + static const char *bool_choices[] = { "OFF", "ON", NULL }; - static char *caseless_choices[] = + static const char *caseless_choices[] = { "CASE INSENSITIVE", "CASE SENSITIVE", NULL }; - static char *dirList_choices[] = + static const char *dirList_choices[] = { "Directories first", "Files first", @@ -287,7 +287,7 @@ void LYoptions(void) }; #if defined(ENABLE_OPTS_CHANGE_EXEC) && (defined(EXEC_LINKS) || defined(EXEC_SCRIPTS)) - static char *exec_choices[] = + static const char *exec_choices[] = { "ALWAYS OFF", "FOR LOCAL FILES ONLY", @@ -297,7 +297,7 @@ void LYoptions(void) NULL }; #endif - static char *fileSort_choices[] = + static const char *fileSort_choices[] = { "By Filename", "By Type", @@ -305,21 +305,21 @@ void LYoptions(void) "By Date", NULL }; - static char *keypad_choices[] = + static const char *keypad_choices[] = { "Numbers act as arrows", "Links are numbered", "Links and form fields are numbered", NULL }; - static char *mbm_choices[] = + static const char *mbm_choices[] = { "OFF ", "STANDARD", "ADVANCED", NULL }; - static char *userMode_choices[] = + static const char *userMode_choices[] = { "Novice", "Intermediate", @@ -416,11 +416,11 @@ void LYoptions(void) lynx_stop_h1_color(); LYmove(L_EDITOR, 5); addlbl("(E)ditor : "); - LYaddstr((editor && *editor) ? editor : "NONE"); + LYaddstr(non_empty(editor) ? editor : "NONE"); LYmove(L_DISPLAY, 5); addlbl("(D)ISPLAY variable : "); - LYaddstr((x_display && *x_display) ? x_display : "NONE"); + LYaddstr(non_empty(x_display) ? x_display : "NONE"); LYmove(L_HOME, 5); addlbl("mu(L)ti-bookmarks: "); @@ -430,7 +430,7 @@ void LYoptions(void) addlbl("review/edit (B)ookmarks files"); } else { addlbl("(B)ookmark file: "); - LYaddstr((bookmark_page && *bookmark_page) ? bookmark_page : "NONE"); + LYaddstr(non_empty(bookmark_page) ? bookmark_page : "NONE"); } LYmove(L_FTPSTYPE, 5); @@ -442,7 +442,7 @@ void LYoptions(void) LYmove(L_MAIL_ADDRESS, 5); addlbl("(P)ersonal mail address : "); - LYaddstr((personal_mail_address && *personal_mail_address) ? + LYaddstr(non_empty(personal_mail_address) ? personal_mail_address : "NONE"); LYmove(L_SSEARCH, 5); @@ -455,11 +455,11 @@ void LYoptions(void) LYmove(L_LANGUAGE, 5); addlbl("preferred document lan(G)uage: "); - LYaddstr((language && *language) ? language : "NONE"); + LYaddstr(non_empty(language) ? language : "NONE"); LYmove(L_PREF_CHARSET, 5); addlbl("preferred document c(H)arset : "); - LYaddstr((pref_charset && *pref_charset) ? pref_charset : "NONE"); + LYaddstr(non_empty(pref_charset) ? pref_charset : "NONE"); if (use_assume_charset) { LYmove(L_ASSUME_CHARSET, 5); @@ -562,7 +562,7 @@ void LYoptions(void) LYmove(L_User_Agent, 5); addlbl("user (A)gent : "); - LYaddstr((LYUserAgent && *LYUserAgent) ? LYUserAgent : "NONE"); + LYaddstr(non_empty(LYUserAgent) ? LYUserAgent : "NONE"); #if defined(ENABLE_OPTS_CHANGE_EXEC) && (defined(EXEC_LINKS) || defined(EXEC_SCRIPTS)) LYmove(L_Exec, 5); @@ -628,7 +628,7 @@ void LYoptions(void) } else if (system_editor) { _statusline(EDITOR_LOCKED); } else { - if (editor && *editor) + if (non_empty(editor)) LYstrncpy(display_option, editor, sizeof(display_option) - 1); else { /* clear the NONE */ LYmove(L_EDITOR, COL_OPTION_VALUES); @@ -643,7 +643,7 @@ void LYoptions(void) lynx_stop_bold(); LYmove(L_EDITOR, COL_OPTION_VALUES); if (term_options || ch == -1) { - LYaddstr((editor && *editor) ? + LYaddstr(non_empty(editor) ? editor : "NONE"); } else if (*display_option == '\0') { FREE(editor); @@ -664,7 +664,7 @@ void LYoptions(void) break; case 'D': /* Change the display. */ - if (x_display && *x_display) { + if (non_empty(x_display)) { LYstrncpy(display_option, x_display, sizeof(display_option) - 1); } else { /* clear the NONE */ LYmove(L_DISPLAY, COL_OPTION_VALUES); @@ -692,7 +692,7 @@ void LYoptions(void) * Cancelled, or a non-NULL display string wasn't changed. - * FM */ - LYaddstr((x_display && *x_display) ? x_display : "NONE"); + LYaddstr(non_empty(x_display) ? x_display : "NONE"); LYclrtoeol(); if (ch == -1) { HTInfoMsg(CANCELLED); @@ -760,7 +760,7 @@ void LYoptions(void) LYaddstr(gettext("review/edit B)ookmarks files")); } else { LYaddstr(gettext("B)ookmark file: ")); - LYaddstr((bookmark_page && *bookmark_page) ? + LYaddstr(non_empty(bookmark_page) ? bookmark_page : "NONE"); } } @@ -781,7 +781,7 @@ void LYoptions(void) signal(SIGINT, terminate_options); goto draw_options; } - if (bookmark_page && *bookmark_page) { + if (non_empty(bookmark_page)) { LYstrncpy(display_option, bookmark_page, sizeof(display_option) - 1); @@ -799,11 +799,11 @@ void LYoptions(void) LYmove(L_HOME, C_DEFAULT); if (term_options || ch == -1 || *display_option == '\0') { - LYaddstr((bookmark_page && *bookmark_page) ? + LYaddstr(non_empty(bookmark_page) ? bookmark_page : "NONE"); } else if (!LYPathOffHomeOK(display_option, sizeof(display_option))) { - LYaddstr((bookmark_page && *bookmark_page) ? + LYaddstr(non_empty(bookmark_page) ? bookmark_page : "NONE"); LYclrtoeol(); _statusline(USE_PATH_OFF_HOME); @@ -850,7 +850,7 @@ void LYoptions(void) break; case 'P': /* Change personal mail address for From headers. */ - if (personal_mail_address && *personal_mail_address) { + if (non_empty(personal_mail_address)) { LYstrncpy(display_option, personal_mail_address, sizeof(display_option) - 1); @@ -1065,7 +1065,7 @@ void LYoptions(void) break; case 'G': /* Change language preference. */ - if (language && *language) { + if (non_empty(language)) { LYstrncpy(display_option, language, sizeof(display_option) - 1); } else { /* clear the NONE */ LYmove(L_LANGUAGE, COL_OPTION_VALUES); @@ -1080,7 +1080,7 @@ void LYoptions(void) lynx_stop_bold(); LYmove(L_LANGUAGE, COL_OPTION_VALUES); if (term_options || ch == -1) { - LYaddstr((language && *language) ? + LYaddstr(non_empty(language) ? language : "NONE"); } else if (*display_option == '\0') { FREE(language); @@ -1100,7 +1100,7 @@ void LYoptions(void) break; case 'H': /* Change charset preference. */ - if (pref_charset && *pref_charset) { + if (non_empty(pref_charset)) { LYstrncpy(display_option, pref_charset, sizeof(display_option) - 1); @@ -1117,7 +1117,7 @@ void LYoptions(void) lynx_stop_bold(); LYmove(L_PREF_CHARSET, COL_OPTION_VALUES); if (term_options || ch == -1) { - LYaddstr((pref_charset && *pref_charset) ? + LYaddstr(non_empty(pref_charset) ? pref_charset : "NONE"); } else if (*display_option == '\0') { FREE(pref_charset); @@ -1438,7 +1438,7 @@ void LYoptions(void) case 'A': /* Change user agent string. */ if (!no_useragent) { - if (LYUserAgent && *LYUserAgent) { + if (non_empty(LYUserAgent)) { LYstrncpy(display_option, LYUserAgent, sizeof(display_option) - 1); @@ -2133,26 +2133,26 @@ static OptValues bool_values[] = {0, 0, 0} }; -static char *secure_string = "secure"; +static const char *secure_string = "secure"; static char *secure_value = NULL; -static char *save_options_string = "save_options"; +static const char *save_options_string = "save_options"; /* * Personal Preferences */ -static char *cookies_string = RC_SET_COOKIES; -static char *cookies_ignore_all_string = N_("ignore"); -static char *cookies_up_to_user_string = N_("ask user"); -static char *cookies_accept_all_string = N_("accept all"); -static char *x_display_string = RC_DISPLAY; -static char *editor_string = RC_FILE_EDITOR; -static char *emacs_keys_string = RC_EMACS_KEYS; +static const char *cookies_string = RC_SET_COOKIES; +static const char *cookies_ignore_all_string = N_("ignore"); +static const char *cookies_up_to_user_string = N_("ask user"); +static const char *cookies_accept_all_string = N_("accept all"); +static const char *x_display_string = RC_DISPLAY; +static const char *editor_string = RC_FILE_EDITOR; +static const char *emacs_keys_string = RC_EMACS_KEYS; #if defined(ENABLE_OPTS_CHANGE_EXEC) && (defined(EXEC_LINKS) || defined(EXEC_SCRIPTS)) #define EXEC_ALWAYS 2 #define EXEC_LOCAL 1 #define EXEC_NEVER 0 -static char *exec_links_string = RC_RUN_ALL_EXECUTION_LINKS; +static const char *exec_links_string = RC_RUN_ALL_EXECUTION_LINKS; static OptValues exec_links_values[] = { {EXEC_NEVER, N_("ALWAYS OFF"), "ALWAYS OFF"}, @@ -2165,9 +2165,9 @@ static OptValues exec_links_values[] = #endif /* ENABLE_OPTS_CHANGE_EXEC */ #ifdef EXP_KEYBOARD_LAYOUT -static char *kblayout_string = RC_KBLAYOUT; +static const char *kblayout_string = RC_KBLAYOUT; #endif -static char *keypad_mode_string = RC_KEYPAD_MODE; +static const char *keypad_mode_string = RC_KEYPAD_MODE; static OptValues keypad_mode_values[] = { {NUMBERS_AS_ARROWS, N_("Numbers act as arrows"), @@ -2182,9 +2182,9 @@ static OptValues keypad_mode_values[] = "forms_numbered"}, {0, 0, 0} }; -static char *lineedit_mode_string = RC_LINEEDIT_MODE; -static char *mail_address_string = RC_PERSONAL_MAIL_ADDRESS; -static char *search_type_string = RC_CASE_SENSITIVE_SEARCHING; +static const char *lineedit_mode_string = RC_LINEEDIT_MODE; +static const char *mail_address_string = RC_PERSONAL_MAIL_ADDRESS; +static const char *search_type_string = RC_CASE_SENSITIVE_SEARCHING; static OptValues search_type_values[] = { {FALSE, N_("Case insensitive"), "case_insensitive"}, @@ -2193,7 +2193,7 @@ static OptValues search_type_values[] = }; #if defined(USE_SLANG) || defined(COLOR_CURSES) -static char *show_color_string = RC_SHOW_COLOR; +static const char *show_color_string = RC_SHOW_COLOR; static OptValues show_color_values[] = { {SHOW_COLOR_NEVER, never_string, never_string}, @@ -2204,12 +2204,12 @@ static OptValues show_color_values[] = }; #endif -static char *show_cursor_string = RC_SHOW_CURSOR; +static const char *show_cursor_string = RC_SHOW_CURSOR; -static char *underline_links_string = RC_UNDERLINE_LINKS; +static const char *underline_links_string = RC_UNDERLINE_LINKS; #ifdef USE_SCROLLBAR -static char *show_scrollbar_string = RC_SCROLLBAR; +static const char *show_scrollbar_string = RC_SCROLLBAR; #endif static const char prompt_dft_string[] = N_("prompt normally"); @@ -2223,13 +2223,13 @@ static OptValues prompt_values[] = {0, 0, 0} }; -static char *cookie_prompt_string = RC_FORCE_COOKIE_PROMPT; +static const char *cookie_prompt_string = RC_FORCE_COOKIE_PROMPT; #ifdef USE_SSL -static char *ssl_prompt_string = RC_FORCE_SSL_PROMPT; +static const char *ssl_prompt_string = RC_FORCE_SSL_PROMPT; #endif -static char *user_mode_string = RC_USER_MODE; +static const char *user_mode_string = RC_USER_MODE; static OptValues user_mode_values[] = { {NOVICE_MODE, N_("Novice"), "Novice"}, @@ -2238,9 +2238,9 @@ static OptValues user_mode_values[] = {0, 0, 0} }; -static char *vi_keys_string = RC_VI_KEYS; +static const char *vi_keys_string = RC_VI_KEYS; -static char *visited_links_string = RC_VISITED_LINKS; +static const char *visited_links_string = RC_VISITED_LINKS; static OptValues visited_links_values[] = { {VISITED_LINKS_AS_FIRST_V, N_("By First Visit"), "first_visited"}, @@ -2256,7 +2256,7 @@ static OptValues visited_links_values[] = /* * Document Layout */ -static char *DTD_recovery_string = RC_TAGSOUP; +static const char *DTD_recovery_string = RC_TAGSOUP; static OptValues DTD_type_values[] = { /* Old_DTD variable */ @@ -2265,13 +2265,13 @@ static OptValues DTD_type_values[] = {0, 0, 0} }; -static char *select_popups_string = RC_SELECT_POPUPS; -static char *images_string = "images"; -static char *images_ignore_all_string = N_("ignore"); -static char *images_use_label_string = N_("as labels"); -static char *images_use_links_string = N_("as links"); +static const char *select_popups_string = RC_SELECT_POPUPS; +static const char *images_string = "images"; +static const char *images_ignore_all_string = N_("ignore"); +static const char *images_use_label_string = N_("as labels"); +static const char *images_use_links_string = N_("as links"); -static char *verbose_images_string = RC_VERBOSE_IMAGES; +static const char *verbose_images_string = RC_VERBOSE_IMAGES; static OptValues verbose_images_type_values[] = { /* verbose_img variable */ @@ -2283,7 +2283,7 @@ static OptValues verbose_images_type_values[] = /* * Bookmark Options */ -static char *mbm_string = RC_MULTI_BOOKMARK; +static const char *mbm_string = RC_MULTI_BOOKMARK; static OptValues mbm_values[] = { {MBM_OFF, N_("OFF"), "OFF"}, @@ -2292,26 +2292,26 @@ static OptValues mbm_values[] = {0, 0, 0} }; -static char *single_bookmark_string = RC_BOOKMARK_FILE; +static const char *single_bookmark_string = RC_BOOKMARK_FILE; /* * Character Set Options */ -static char *assume_char_set_string = RC_ASSUME_CHARSET; -static char *display_char_set_string = RC_CHARACTER_SET; -static char *raw_mode_string = RC_RAW_MODE; +static const char *assume_char_set_string = RC_ASSUME_CHARSET; +static const char *display_char_set_string = RC_CHARACTER_SET; +static const char *raw_mode_string = RC_RAW_MODE; #ifdef EXP_LOCALE_CHARSET -static char *locale_charset_string = RC_LOCALE_CHARSET; +static const char *locale_charset_string = RC_LOCALE_CHARSET; #endif /* * File Management Options */ -static char *show_dotfiles_string = RC_SHOW_DOTFILES; +static const char *show_dotfiles_string = RC_SHOW_DOTFILES; #ifdef DIRED_SUPPORT -static char *dired_list_string = RC_DIR_LIST_STYLE; +static const char *dired_list_string = RC_DIR_LIST_STYLE; static OptValues dired_list_values[] = { {DIRS_FIRST, N_("Directories first"), "dired_dir"}, @@ -2321,7 +2321,7 @@ static OptValues dired_list_values[] = }; #ifdef LONG_LIST -static char *dired_sort_string = RC_DIR_LIST_ORDER; +static const char *dired_sort_string = RC_DIR_LIST_ORDER; static OptValues dired_sort_values[] = { {ORDER_BY_NAME, N_("By Name"), "dired_by_name"}, @@ -2338,7 +2338,7 @@ static OptValues dired_sort_values[] = #endif /* LONG_LIST */ #endif /* DIRED_SUPPORT */ -static char *ftp_sort_string = RC_FILE_SORTING_METHOD; +static const char *ftp_sort_string = RC_FILE_SORTING_METHOD; static OptValues ftp_sort_values[] = { {FILE_BY_NAME, N_("By Name"), "ftp_by_name"}, @@ -2349,7 +2349,7 @@ static OptValues ftp_sort_values[] = }; #ifdef USE_READPROGRESS -static char *show_rate_string = RC_SHOW_KB_RATE; +static const char *show_rate_string = RC_SHOW_KB_RATE; static OptValues rate_values[] = { {rateOFF, N_("Do not show rate"), "rate_off"}, @@ -2366,7 +2366,7 @@ static OptValues rate_values[] = /* * Presentation (MIME) types used in "Accept". */ -static char *preferred_media_string = RC_PREFERRED_MEDIA_TYPES; +static const char *preferred_media_string = RC_PREFERRED_MEDIA_TYPES; static OptValues media_values[] = { {mediaOpt1, N_("Accept lynx's internal types"), "media_opt1"}, @@ -2377,7 +2377,7 @@ static OptValues media_values[] = {0, 0, 0} }; -static char *preferred_encoding_string = RC_PREFERRED_ENCODING; +static const char *preferred_encoding_string = RC_PREFERRED_ENCODING; static OptValues encoding_values[] = { {encodingNONE, N_("None"), "encoding_none"}, @@ -2398,9 +2398,9 @@ static OptValues encoding_values[] = /* * Headers transferred to remote server */ -static char *preferred_doc_char_string = RC_PREFERRED_CHARSET; -static char *preferred_doc_lang_string = RC_PREFERRED_LANGUAGE; -static char *user_agent_string = RC_USERAGENT; +static const char *preferred_doc_char_string = RC_PREFERRED_CHARSET; +static const char *preferred_doc_lang_string = RC_PREFERRED_LANGUAGE; +static const char *user_agent_string = RC_USERAGENT; #define PutTextInput(fp, Name, Value, Size, disable) \ fprintf(fp,\ @@ -3227,6 +3227,8 @@ int postoptions(DocInfo *newdoc) static char *NewSecureValue(void) { + static char oops[] = "?"; + FREE(secure_value); if ((secure_value = malloc(80)) != 0) { #if defined(RAND_MAX) @@ -3238,7 +3240,7 @@ static char *NewSecureValue(void) sprintf(secure_value, "%ld", key); return secure_value; } - return "?"; + return oops; } #define LABEL_LEN 33 @@ -3247,8 +3249,8 @@ static char *NewSecureValue(void) * Note: the 'value' we are passing here is a local copy of the "same" string * as is used in LYrcFile.c to index the savable options. */ -static void PutLabel(FILE *fp, char *name, - char *value) +static void PutLabel(FILE *fp, const char *name, + const char *value) { int have = strlen(name); int want = LABEL_LEN; @@ -3278,10 +3280,10 @@ static void PutLabel(FILE *fp, char *name, * so, return that name, so the subsequence will_save_rc() check in PutLabel() * will flag the composite as not-saved. */ -static char *check_if_write_lynxrc(char **table) +static const char *check_if_write_lynxrc(const char **table) { int n; - char *result = NULL; + const char *result = NULL; for (n = 0; table[n] != 0; ++n) { result = table[n]; @@ -3296,9 +3298,9 @@ static char *check_if_write_lynxrc(char **table) * from lynx.cfg (and perhaps .lynxrc) as a set of booleans. Check if any are * not writable to .lynxrc, so we can show the user. */ -static char *will_save_cookies(void) +static const char *will_save_cookies(void) { - static char *table[] = + static const char *table[] = { RC_SET_COOKIES, /* LYSetCookies */ RC_ACCEPT_ALL_COOKIES, /* LYAcceptAllCookies */ @@ -3313,9 +3315,9 @@ static char *will_save_cookies(void) * read from lynx.cfg (and perhaps .lynxrc) as a set of booleans. Check if any * are not writable to .lynxrc, so we can show the user. */ -static char *will_save_images(void) +static const char *will_save_images(void) { - static char *table[] = + static const char *table[] = { RC_MAKE_PSEUDO_ALTS_FOR_INLINES, /* pseudo_inline_alts */ RC_MAKE_LINKS_FOR_ALL_IMAGES, /* clickable_images */ diff --git a/src/LYPrettySrc.c b/src/LYPrettySrc.c index e45c8e00..d4a46304 100644 --- a/src/LYPrettySrc.c +++ b/src/LYPrettySrc.c @@ -30,7 +30,7 @@ BOOL mark_htext_as_source = FALSE; support), the style cache and markup are created before entering the mainloop. */ BOOL psrcview_no_anchor_numbering = FALSE; -static char *HTL_tagspecs_defaults[HTL_num_lexemes] = +static const char *HTL_tagspecs_defaults[HTL_num_lexemes] = { /* these values are defaults. They are also listed in comments of distibution's lynx.cfg. */ @@ -146,7 +146,7 @@ static void append_open_tag(char *tagname, #ifdef USE_COLOR_STYLE hcode = hash_code_lowercase_on_fly(tagname); - if (classname && *classname) { + if (non_empty(classname)) { # if 0 /* diff --git a/src/LYPrint.c b/src/LYPrint.c index 91d46516..a547d06d 100644 --- a/src/LYPrint.c +++ b/src/LYPrint.c @@ -88,7 +88,7 @@ static void set_environ(int name, char temp[80]; StrAllocCopy(envbuffer, value); - if (!(envbuffer && *envbuffer)) + if (isEmpty(envbuffer)) StrAllocCopy(envbuffer, no_value); Define_VMSLogical(strcpy(temp, names[name]), envbuffer); FREE(envbuffer); @@ -142,7 +142,7 @@ static char *suggested_filename(DocInfo *newdoc) } static void SetupFilename(char *filename, - char *sug_filename) + const char *sug_filename) { HTFormat format; HTAtom *encoding; @@ -269,7 +269,7 @@ static int RecallFilename(char *filename, return FN_DONE; } -static BOOLEAN confirm_by_pages(char *prompt, +static BOOLEAN confirm_by_pages(const char *prompt, int lines_in_file, int lines_per_page) { @@ -1066,7 +1066,7 @@ int printfile(DocInfo *newdoc) if (HText_getContentBase()) { StrAllocCopy(content_base, HText_getContentBase()); LYRemoveBlanks(content_base); - if (!(content_base && *content_base)) { + if (isEmpty(content_base)) { FREE(content_base); } } @@ -1078,7 +1078,7 @@ int printfile(DocInfo *newdoc) if (HText_getContentLocation()) { StrAllocCopy(content_location, HText_getContentLocation()); LYRemoveBlanks(content_location); - if (!(content_location && *content_location)) { + if (isEmpty(content_location)) { FREE(content_location); } } diff --git a/src/LYReadCFG.c b/src/LYReadCFG.c index 0ce9e480..4a91f2bf 100644 --- a/src/LYReadCFG.c +++ b/src/LYReadCFG.c @@ -790,7 +790,7 @@ static int cern_rulesfile_fun(char *value) } fprintf(stderr, gettext("Lynx: cannot start, CERN rules file %s is not available\n"), - (rulesfile2 && *rulesfile2) ? rulesfile2 : gettext("(no name)")); + non_empty(rulesfile2) ? rulesfile2 : gettext("(no name)")); exit_immediately(EXIT_FAILURE); return 0; /* though redundant, for compiler-warnings */ } @@ -816,7 +816,9 @@ static int referer_with_query_fun(char *value) static int suffix_fun(char *value) { char *mime_type, *p; - char *encoding = NULL, *sq = NULL, *description = NULL; + char *encoding = NULL; + char *sq = NULL; + char *description = NULL; double q = 1.0; if ((strlen(value) < 3) @@ -1597,9 +1599,9 @@ static Config_Type *lookup_config(char *name) * Note: only read files from the current directory if there's no parent * filename, otherwise it leads to user surprise. */ -static char *actual_filename(char *cfg_filename, - char *parent_filename, - char *dft_filename) +static char *actual_filename(const char *cfg_filename, + const char *parent_filename, + const char *dft_filename) { char *my_filename = NULL; @@ -1628,9 +1630,9 @@ static char *actual_filename(char *cfg_filename, return my_filename; } -FILE *LYOpenCFG(char *cfg_filename, - char *parent_filename, - char *dft_filename) +FILE *LYOpenCFG(const char *cfg_filename, + const char *parent_filename, + const char *dft_filename) { char *my_file = actual_filename(cfg_filename, parent_filename, dft_filename); FILE *result; @@ -1753,8 +1755,8 @@ void LYSetConfigValue(char *name, * file can also include other files with a list of acceptable options, these * lists are ANDed. */ -static void do_read_cfg(char *cfg_filename, - char *parent_filename, +static void do_read_cfg(const char *cfg_filename, + const char *parent_filename, int nesting_level, FILE *fp0, optidx_set_t * allowed) @@ -1894,7 +1896,7 @@ static void do_read_cfg(char *cfg_filename, char *url = NULL; char *cp1 = NULL; - char *sep = NULL; + const char *sep = NULL; if ((p1 = strstr(value, sep = " for ")) != 0 #if defined(UNIX) && !defined(USE_DOS_DRIVES) @@ -2047,8 +2049,8 @@ static void do_read_cfg(char *cfg_filename, } /* this is a public interface to do_read_cfg */ -void read_cfg(char *cfg_filename, - char *parent_filename, +void read_cfg(const char *cfg_filename, + const char *parent_filename, int nesting_level, FILE *fp0) { @@ -2057,8 +2059,8 @@ void read_cfg(char *cfg_filename, } #ifndef NO_CONFIG_INFO -static void extra_cfg_link(FILE *fp, char *href, - char *name) +static void extra_cfg_link(FILE *fp, const char *href, + const char *name) { fprintf(fp, "<a href=\"%s\">%s</a>", href, name); diff --git a/src/LYReadCFG.h b/src/LYReadCFG.h index 32f52640..7853904a 100644 --- a/src/LYReadCFG.h +++ b/src/LYReadCFG.h @@ -49,14 +49,14 @@ extern int check_color(char *color, int the_default); extern const char *lookup_color(int code); #endif -extern void read_cfg(char *cfg_filename, - char *parent_filename, +extern void read_cfg(const char *cfg_filename, + const char *parent_filename, int nesting_level, FILE *fp0); extern void free_lynx_cfg(void); extern BOOLEAN have_read_cfg; -extern FILE *LYOpenCFG(char *cfg_filename, char *parent_filename, char *dft_filename); +extern FILE *LYOpenCFG(const char *cfg_filename, const char *parent_filename, const char *dft_filename); extern int lynx_cfg_infopage(DocInfo *newdoc); extern int lynx_compile_opts(DocInfo *newdoc); extern int match_item_by_name(lynx_list_item_type *ptr, char *name, BOOLEAN only_overriders); diff --git a/src/LYSearch.c b/src/LYSearch.c index 155b8bf3..8bf4ad27 100644 --- a/src/LYSearch.c +++ b/src/LYSearch.c @@ -13,7 +13,8 @@ static BOOL link_has_target(int cur, { LinkInfo *a = &links[cur]; OptionType *option; - char *stars = NULL, *cp; + char *stars = NULL; + const char *cp; int count; /* @@ -21,7 +22,7 @@ static BOOL link_has_target(int cur, * setting into account. */ for (count = 0;; ++count) { - char *text = LYGetHiliteStr(cur, count); + const char *text = LYGetHiliteStr(cur, count); if (text == NULL) break; @@ -44,8 +45,7 @@ static BOOL link_has_target(int cur, return TRUE; } StrAllocCopy(stars, a->l_form->value); - for (cp = stars; *cp != '\0'; cp++) - *cp = '*'; + memset(stars, '*', strlen(stars)); if (LYno_attr_strstr(stars, target)) { FREE(stars); return TRUE; diff --git a/src/LYShowInfo.c b/src/LYShowInfo.c index 9a763cd8..6f5e5dc3 100644 --- a/src/LYShowInfo.c +++ b/src/LYShowInfo.c @@ -47,7 +47,7 @@ BOOL LYVersionIsRelease(void) return (BOOL) (strstr(LYNX_VERSION, "rel") != 0); } -char *LYVersionStatus(void) +const char *LYVersionStatus(void) { if (LYVersionIsRelease()) return REL_VERSION; @@ -56,7 +56,7 @@ char *LYVersionStatus(void) return DEV_VERSION; } -char *LYVersionDate(void) +const char *LYVersionDate(void) { static char temp[LYNX_DATE_LEN + 1]; @@ -116,7 +116,7 @@ int LYShowInfo(DocInfo *doc, int url_type; FILE *fp0; char *Title = NULL; - char *name; + const char *name; const char *cp; char *temp = 0; @@ -326,7 +326,7 @@ int LYShowInfo(DocInfo *doc, HTAnchor_getUCLYhndl(HTMainAnchor, UCT_STAGE_PARSER) < 0) { p_in = HTAnchor_getUCInfoStage(HTMainAnchor, UCT_STAGE_MIME); } - if (p_in && p_in->MIMEname && *(p_in->MIMEname) && + if (p_in && non_empty(p_in->MIMEname) && HTAnchor_getUCLYhndl(HTMainAnchor, UCT_STAGE_MIME) >= 0) { HTSprintf(&temp, "%s %s", p_in->MIMEname, diff --git a/src/LYShowInfo.h b/src/LYShowInfo.h index 59c0ab84..2a5f1348 100644 --- a/src/LYShowInfo.h +++ b/src/LYShowInfo.h @@ -6,8 +6,8 @@ #endif /* LYSTRUCTS_H */ extern BOOL LYVersionIsRelease(void); -extern char *LYVersionStatus(void); -extern char *LYVersionDate(void); +extern const char *LYVersionStatus(void); +extern const char *LYVersionDate(void); extern int LYShowInfo(DocInfo *doc, int size_of_file, DocInfo *newdoc, diff --git a/src/LYStrings.c b/src/LYStrings.c index 8c6983c3..365d48c9 100644 --- a/src/LYStrings.c +++ b/src/LYStrings.c @@ -455,7 +455,7 @@ static int set_clicked_link(int x, for (i = 0; i < nlinks; i++) { int len, lx = links[i].lx, is_text = 0; int count = 0; - char *text = LYGetHiliteStr(i, count); + const char *text = LYGetHiliteStr(i, count); if (links[i].type == WWW_FORM_LINK_TYPE && F_TEXTLIKE(links[i].l_form->type)) @@ -620,9 +620,9 @@ char *LYmbcsstrncpy(char *dst, * and returns the resulting pointer. It takes account of UTF-8 encoded * characters. - KW */ -char *LYmbcs_skip_glyphs(char *data, - int n_glyphs, - BOOL utf_flag) +const char *LYmbcs_skip_glyphs(const char *data, + int n_glyphs, + BOOL utf_flag) { int i_glyphs = 0; @@ -653,7 +653,7 @@ char *LYmbcs_skip_glyphs(char *data, * mode count as two.) Counts character glyphs if count_gcells is unset. * (Full- width characters in CJK mode count as one.) - kw */ -int LYmbcsstrlen(char *str, +int LYmbcsstrlen(const char *str, BOOL utf_flag, BOOL count_gcells) { @@ -865,7 +865,7 @@ static SLKeyMap_List_Type *Keymap_List; #endif typedef struct { - char *string; + const char *string; int value; } Keysym_String_List; /* *INDENT-OFF* */ @@ -928,7 +928,7 @@ static const char *expand_tichar(const char *first, char **result, char *final) int limit = 0; int radix = 0; int value = 0; - char *name = 0; + const char *name = 0; switch (ch = *first++) { case 'E': @@ -1414,7 +1414,7 @@ static int LYmouse_menu(int x, int y, int atlink, int code) #define ENT_ONLY_LINK 2 /* *INDENT-OFF* */ static const struct { - char *txt; + const char *txt; int action; unsigned int flag; } possible_entries[] = { @@ -1448,7 +1448,7 @@ static int LYmouse_menu(int x, int y, int atlink, int code) /* *INDENT-ON* */ #define TOTAL_MENUENTRIES TABLESIZE(possible_entries) - char *choices[TOTAL_MENUENTRIES + 1]; + const char *choices[TOTAL_MENUENTRIES + 1]; int actions[TOTAL_MENUENTRIES]; int c, c1, retlac, filter_out = (atlink ? ENT_ONLY_DOC : ENT_ONLY_LINK); @@ -2842,7 +2842,7 @@ static int map_active = 0; #define map_active 0 #endif -int LYEditInsert(EDREC * edit, unsigned char *s, +int LYEditInsert(EDREC * edit, unsigned const char *s, int len, int map, BOOL maxMessage) @@ -2870,7 +2870,7 @@ int LYEditInsert(EDREC * edit, unsigned char *s, map = map_active; if (map && LYCharSet_UC[current_char_set].enc == UCT_ENC_UTF8) { int off = Pos; - unsigned char *e = s + len; + unsigned const char *e = s + len; char *tail = 0; while (s < e) { @@ -2910,7 +2910,8 @@ int LYEditInsert(EDREC * edit, unsigned char *s, len = off - Pos; FREE(tail); } else if (map) { - unsigned char *e = s + len, *t = (unsigned char *) Buf + Pos; + unsigned const char *e = s + len; + unsigned char *t = (unsigned char *) Buf + Pos; while (s < e) { int ch; @@ -2929,7 +2930,7 @@ int LYEditInsert(EDREC * edit, unsigned char *s, } else #endif /* defined EXP_KEYBOARD_LAYOUT */ { - strncpy(Buf + Pos, (char *) s, len); + strncpy(Buf + Pos, (const char *) s, len); edited = 1; } @@ -3385,7 +3386,7 @@ int LYEdit1(EDREC * edit, int ch, * If a 'g' or 'p' suffix is included, that will be * loaded into c. Otherwise, c is zeroed. - FM & LE */ -int get_popup_number(char *msg, +int get_popup_number(const char *msg, int *c, int *rel) { @@ -3877,7 +3878,7 @@ int LYhandlePopupList(int cur_choice, BOOLEAN ReDraw = FALSE; int number; char buffer[MAX_LINE]; - char *popup_status_msg = NULL; + const char *popup_status_msg = NULL; const char **Cptr = NULL; #define CAN_SCROLL_DOWN 1 @@ -4961,7 +4962,7 @@ int LYgetstr(char *inputline, s = e1; if (*e1 == '\t') { /* Replace by space */ LYEditInsert(&MyEdit, - (unsigned char *) " ", + (unsigned const char *) " ", 1, map_active, TRUE); @@ -5121,10 +5122,10 @@ char *LYstrstr(char *chptr, * if present in chptr. * It is a case insensitive search. */ -char *LYno_attr_char_case_strstr(char *chptr, - char *tarptr) +const char *LYno_attr_char_case_strstr(const char *chptr, + const char *tarptr) { - register char *tmpchptr, *tmptarptr; + register const char *tmpchptr, *tmptarptr; if (!chptr) return (NULL); @@ -5174,10 +5175,10 @@ char *LYno_attr_char_case_strstr(char *chptr, * if present in chptr. * It is a case sensitive search. */ -char *LYno_attr_char_strstr(char *chptr, - char *tarptr) +const char *LYno_attr_char_strstr(const char *chptr, + const char *tarptr) { - register char *tmpchptr, *tmptarptr; + register const char *tmpchptr, *tmptarptr; if (!chptr) return (NULL); @@ -5237,14 +5238,14 @@ char *LYno_attr_char_strstr(char *chptr, * It assumes UTF8 if utf_flag is set. * It is a case insensitive search. - KW & FM */ -char *LYno_attr_mbcs_case_strstr(char *chptr, - const char *tarptr, - BOOL utf_flag, - BOOL count_gcells, - int *nstartp, - int *nendp) +const char *LYno_attr_mbcs_case_strstr(const char *chptr, + const char *tarptr, + BOOL utf_flag, + BOOL count_gcells, + int *nstartp, + int *nendp) { - char *tmpchptr; + const char *tmpchptr; const char *tmptarptr; int len = 0; int offset; @@ -5400,14 +5401,14 @@ char *LYno_attr_mbcs_case_strstr(char *chptr, * It assumes UTF8 if utf_flag is set. * It is a case sensitive search. - KW & FM */ -char *LYno_attr_mbcs_strstr(char *chptr, - const char *tarptr, - BOOL utf_flag, - BOOL count_gcells, - int *nstartp, - int *nendp) +const char *LYno_attr_mbcs_strstr(const char *chptr, + const char *tarptr, + BOOL utf_flag, + BOOL count_gcells, + int *nstartp, + int *nendp) { - char *tmpchptr; + const char *tmpchptr; const char *tmptarptr; int len = 0; int offset; diff --git a/src/LYStrings.h b/src/LYStrings.h index 4b52d88c..f6dffb02 100644 --- a/src/LYStrings.h +++ b/src/LYStrings.h @@ -25,7 +25,7 @@ extern char *LYstrncpy(char *dst, const char *src, int n); extern void ena_csi(BOOLEAN flag); -extern int get_popup_number(char *msg, +extern int get_popup_number(const char *msg, int *c, int *rel); extern int LYarrayLength(const char **list); @@ -47,25 +47,25 @@ extern char *LYmbcsstrncpy(char *dst, int n_bytes, int n_glyphs, BOOL utf_flag); -extern char *LYmbcs_skip_glyphs(char *data, - int n_glyphs, - BOOL utf_flag); -extern int LYmbcsstrlen(char *str, +extern const char *LYmbcs_skip_glyphs(const char *data, + int n_glyphs, + BOOL utf_flag); +extern int LYmbcsstrlen(const char *str, BOOL utf_flag, BOOL count_gcells); -extern char *LYno_attr_mbcs_strstr(char *chptr, - const char *tarptr, - BOOL utf_flag, - BOOL count_gcells, - int *nstartp, - int *nendp); -extern char *LYno_attr_mbcs_case_strstr(char *chptr, - const char *tarptr, - BOOL utf_flag, - BOOL count_gcells, - int *nstartp, - int *nendp); +extern const char *LYno_attr_mbcs_strstr(const char *chptr, + const char *tarptr, + BOOL utf_flag, + BOOL count_gcells, + int *nstartp, + int *nendp); +extern const char *LYno_attr_mbcs_case_strstr(const char *chptr, + const char *tarptr, + BOOL utf_flag, + BOOL count_gcells, + int *nstartp, + int *nendp); #define non_empty(s) !isEmpty(s) @@ -74,10 +74,10 @@ extern char *LYno_attr_mbcs_case_strstr(char *chptr, ? LYno_attr_mbcs_strstr(chptr, tarptr, utf_flag, count_gcells, nstartp, nendp) \ : LYno_attr_mbcs_case_strstr(chptr, tarptr, utf_flag, count_gcells, nstartp, nendp)) -extern char *LYno_attr_char_strstr(char *chptr, - char *tarptr); -extern char *LYno_attr_char_case_strstr(char *chptr, - char *tarptr); +extern const char *LYno_attr_char_strstr(const char *chptr, + const char *tarptr); +extern const char *LYno_attr_char_case_strstr(const char *chptr, + const char *tarptr); #define LYno_attr_strstr(chptr, tarptr) \ (case_sensitive \ @@ -324,7 +324,7 @@ extern int LYhandlePopupList(int cur_choice, typedef unsigned char LYEditCode; extern int current_lineedit; -extern char *LYLineeditNames[]; +extern const char *LYLineeditNames[]; extern LYEditCode *LYLineEditors[]; extern const char *LYLineeditHelpURLs[]; @@ -338,7 +338,7 @@ extern int escape_bound; extern int LYEditmapDeclared(void); extern int LYEditInsert(EditFieldData *edit, - unsigned char *s, + unsigned const char *s, int len, int map_active, BOOL maxMessage); diff --git a/src/LYUtils.c b/src/LYUtils.c index 7f456979..4e0ba289 100644 --- a/src/LYUtils.c +++ b/src/LYUtils.c @@ -268,9 +268,9 @@ size_t utf8_length(BOOL utf_flag, * Set the initial highlight information for a given link. */ void LYSetHilite(int cur, - char *text) + const char *text) { - links[cur].list.hl_base.hl_text = text; + links[cur].list.hl_base.hl_text = (char *) text; links[cur].list.hl_len = (text != NULL) ? 1 : 0; FREE(links[cur].list.hl_info); } @@ -300,10 +300,10 @@ void LYAddHilite(int cur, /* * Get the highlight text, counting from zero. */ -char *LYGetHiliteStr(int cur, - int count) +const char *LYGetHiliteStr(int cur, + int count) { - char *result; + const char *result; if (count >= links[cur].list.hl_len) result = NULL; @@ -356,12 +356,12 @@ int LYGetHilitePos(int cur, static BOOL show_whereis_targets(int flag, int cur, int count, - char *target, + const char *target, BOOL TargetEmphasisON, BOOL utf_flag) { - char *Data = NULL; - char *cp; + const char *Data = NULL; + const char *cp; char *theData = NULL; char buffer[MAX_LINE]; char tmp[7]; @@ -384,7 +384,7 @@ static BOOL show_whereis_targets(int flag, &theData, target)) { int itmp, written, len, y, offset; - char *data; + const char *data; int tlen = strlen(target); int hlen, hLen; int hLine = links[cur].ly + count; @@ -987,14 +987,14 @@ static int find_cached_style(int cur, */ void LYhighlight(int flag, int cur, - char *target) + const char *target) { char buffer[MAX_LINE]; int i; int hi_count; int hi_offset; char tmp[7]; - char *hi_string; + const char *hi_string; #ifdef SHOW_WHEREIS_TARGETS BOOL TargetEmphasisON = FALSE; @@ -1048,7 +1048,7 @@ void LYhighlight(int flag, if (links[cur].type == WWW_FORM_LINK_TYPE) { int len; int avail_space = (LYcolLimit - links[cur].lx); - char *text = LYGetHiliteStr(cur, 0); + const char *text = LYGetHiliteStr(cur, 0); if (avail_space > links[cur].l_form->size) avail_space = links[cur].l_form->size; @@ -1424,7 +1424,7 @@ void statusline(const char *text) return; } -static char *novice_lines(int lineno) +static const char *novice_lines(int lineno) { switch (lineno) { case 0: @@ -1468,7 +1468,7 @@ void noviceline(int more_flag GCC_UNUSED) if (LYUseNoviceLineTwo) LYaddstr(NOVICE_LINE_TWO); else - LYaddstr((char *) novice_lines(lineno)); + LYaddstr(novice_lines(lineno)); LYrefresh(); return; @@ -1688,7 +1688,7 @@ int HTCheckForInterrupt(void) break; #ifdef CAN_CUT_AND_PASTE case LYK_TO_CLIPBOARD:{ /* ^S */ - char *s = LYDownLoadAddress(); + const char *s = LYDownLoadAddress(); if (!s || !*s || put_clip(s)) HTInfoMsg(gettext("Copy to clipboard failed.")); @@ -4346,8 +4346,10 @@ BOOLEAN LYExpandHostForURL(char **AllocatedString, char *prefix_list, char *suffix_list) { - char DomainPrefix[80], *StartP, *EndP; - char DomainSuffix[80], *StartS, *EndS; + char DomainPrefix[80]; + const char *StartP, *EndP; + char DomainSuffix[80]; + const char *StartS, *EndS; char *Str = NULL, *StrColon = NULL, *MsgStr = NULL; char *Host = NULL, *HostColon = NULL, *host = NULL; char *Path = NULL; @@ -4645,7 +4647,7 @@ BOOLEAN LYExpandHostForURL(char **AllocatedString, * was made. - FM */ BOOLEAN LYAddSchemeForURL(char **AllocatedString, - char *default_scheme) + const char *default_scheme) { char *Str = NULL; BOOLEAN GotScheme = FALSE; @@ -5216,10 +5218,10 @@ BOOLEAN LYPathOffHomeOK(char *fbuffer, */ void LYAddPathToHome(char *fbuffer, size_t fbuffer_size, - char *fname) + const char *fname) { char *home = NULL; - char *file = fname; + const char *file = fname; int len; /* @@ -5694,7 +5696,7 @@ int remove(char *name) * special case of its directory being pointed to by a link from a directory * owned by root and not writable by other users. */ -static BOOL IsOurFile(char *name) +static BOOL IsOurFile(const char *name) { struct stat data; @@ -5757,7 +5759,7 @@ static BOOL IsOurFile(char *name) /* * Open a file that we don't want other users to see. */ -static FILE *OpenHiddenFile(char *name, char *mode) +static FILE *OpenHiddenFile(const char *name, const char *mode) { FILE *fp = 0; struct stat data; @@ -5813,7 +5815,7 @@ static FILE *OpenHiddenFile(char *name, char *mode) } #endif /* MULTI_USER_UNIX */ -FILE *LYNewBinFile(char *name) +FILE *LYNewBinFile(const char *name) { #ifdef VMS FILE *fp = fopen(name, BIN_W, "mbc=32"); @@ -5825,7 +5827,7 @@ FILE *LYNewBinFile(char *name) return fp; } -FILE *LYNewTxtFile(char *name) +FILE *LYNewTxtFile(const char *name) { FILE *fp; @@ -5843,7 +5845,7 @@ FILE *LYNewTxtFile(char *name) return fp; } -FILE *LYAppendToTxtFile(char *name) +FILE *LYAppendToTxtFile(const char *name) { FILE *fp; @@ -6724,7 +6726,7 @@ FILE *InternalPageFP(char *filename, /* * This part is shared by all internal pages. */ -void WriteInternalTitle(FILE *fp0, char *Title) +void WriteInternalTitle(FILE *fp0, const char *Title) { fprintf(fp0, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"); @@ -6753,8 +6755,8 @@ void WriteInternalTitle(FILE *fp0, char *Title) * This is used to start most internal pages, except for special cases where * the embedded HREF's in the title differ. */ -void BeginInternalPage(FILE *fp0, char *Title, - char *HelpURL) +void BeginInternalPage(FILE *fp0, const char *Title, + const char *HelpURL) { WriteInternalTitle(fp0, Title); @@ -7186,9 +7188,9 @@ int Cygwin_Shell(void) } #endif -char *LYSysShell(void) +const char *LYSysShell(void) { - char *shell = 0; + const char *shell = 0; #ifdef DOSPATH #ifdef WIN_EX @@ -7306,7 +7308,7 @@ int size_clip(void) /* Code partially stolen from FED editor. */ -int put_clip(char *s) +int put_clip(const char *s) { int sz = strlen(s) + 1; int ret = EOF, nl = 0; @@ -7450,7 +7452,7 @@ char *get_clip_grab(void) return paste_buf; } -int put_clip(char *s) +int put_clip(const char *s) { char *cmd = LYGetEnv("RL_CLCOPY_CMD"); FILE *fh; diff --git a/src/LYUtils.h b/src/LYUtils.h index e8751592..a9857e2a 100644 --- a/src/LYUtils.h +++ b/src/LYUtils.h @@ -101,7 +101,7 @@ #define restorePoundSelector(pound) if ((pound) != NULL) *(pound) = '#' extern BOOL strn_dash_equ(const char *p1, const char *p2, int len); -extern BOOLEAN LYAddSchemeForURL(char **AllocatedString, char *default_scheme); +extern BOOLEAN LYAddSchemeForURL(char **AllocatedString, const char *default_scheme); extern BOOLEAN LYCachedTemp(char *result, char **cached); extern BOOLEAN LYCanDoHEAD(const char *address); extern BOOLEAN LYCanReadFile(const char *name); @@ -119,9 +119,9 @@ extern BOOLEAN LYisLocalHost(const char *filename); extern BOOLEAN LYisRootPath(const char *path); extern BOOLEAN inlocaldomain(void); extern FILE *InternalPageFP(char *filename, int reuse_flag); -extern FILE *LYAppendToTxtFile(char *name); -extern FILE *LYNewBinFile(char *name); -extern FILE *LYNewTxtFile(char *name); +extern FILE *LYAppendToTxtFile(const char *name); +extern FILE *LYNewBinFile(const char *name); +extern FILE *LYNewTxtFile(const char *name); extern FILE *LYOpenScratch(char *result, const char *prefix); extern FILE *LYOpenTemp(char *result, const char *suffix, const char *mode); extern FILE *LYOpenTempRewrite(char *result, const char *suffix, const char *mode); @@ -129,14 +129,14 @@ extern FILE *LYReopenTemp(char *name); extern char *Current_Dir(char *pathname); extern char *LYAddPathToSave(char *fname); extern char *LYGetEnv(const char *name); -extern char *LYGetHiliteStr(int cur, int count); extern char *LYLastPathSep(const char *path); extern char *LYPathLeaf(char *pathname); -extern char *LYSysShell(void); extern char *LYgetXDisplay(void); extern char *strip_trailing_slash(char *my_dirname); extern char *trimPoundSelector(char *address); extern const char *Home_Dir(void); +extern const char *LYGetHiliteStr(int cur, int count); +extern const char *LYSysShell(void); extern const char *index_to_restriction(int inx); extern const char *wwwName(const char *pathname); extern int HTCheckForInterrupt(void); @@ -152,7 +152,7 @@ extern int is_url(char *filename); extern int number2arrows(int number); extern size_t utf8_length(BOOL utf_flag, const char *data); extern time_t LYmktime(char *string, BOOL absolute); -extern void BeginInternalPage(FILE *fp0, char *Title, char *HelpURL); +extern void BeginInternalPage(FILE *fp0, const char *Title, const char *HelpURL); extern void EndInternalPage(FILE *fp0); extern void HTAddSugFilename(char *fname); extern void HTSugFilenames_free(void); @@ -162,7 +162,7 @@ extern void LYAddHtmlSep0(char *path); extern void LYAddLocalhostAlias(char *alias); extern void LYAddPathSep(char **path); extern void LYAddPathSep0(char *path); -extern void LYAddPathToHome(char *fbuffer, size_t fbuffer_size, char *fname); +extern void LYAddPathToHome(char *fbuffer, size_t fbuffer_size, const char *fname); extern void LYCheckBibHost(void); extern void LYCheckMail(void); extern void LYCleanupTemp(void); @@ -176,14 +176,14 @@ extern void LYFixCursesOn(const char *reason); extern void LYLocalFileToURL(char **target, const char *source); extern void LYLocalhostAliases_free(void); extern void LYRenamedTemp(char *oldname, char *newname); -extern void LYSetHilite(int cur, char *text); +extern void LYSetHilite(int cur, const char *text); extern void LYTrimHtmlSep(char *path); extern void LYTrimPathSep(char *path); extern void LYTrimRelFromAbsPath(char *path); -extern void LYhighlight(int flag, int cur, char *target); +extern void LYhighlight(int flag, int cur, const char *target); extern void LYmsec_delay(unsigned msec); extern void LYsetXDisplay(char *new_display); -extern void WriteInternalTitle(FILE *fp0, char *Title); +extern void WriteInternalTitle(FILE *fp0, const char *Title); extern void change_sug_filename(char *fname); extern void convert_to_spaces(char *string, BOOL condense); extern void free_and_clear(char **obj); @@ -241,7 +241,7 @@ extern void LYRegisterUIPage(const char *url, UIP_t type); extern void LYUIPages_free(void); #ifdef CAN_CUT_AND_PASTE -extern int put_clip(char *szBuffer); +extern int put_clip(const char *szBuffer); /* get_clip_grab() returns a pointer to the string in the system area. get_clip_release() should be called ASAP after this. */ diff --git a/src/LYrcFile.c b/src/LYrcFile.c index c7437d92..a8451022 100644 --- a/src/LYrcFile.c +++ b/src/LYrcFile.c @@ -235,10 +235,10 @@ typedef struct config_type { int enabled; /* see lynx.cfg ENABLE_LYNXRC "off" lines */ Conf_Types type; ParseData; - char **strings; + const char **strings; Config_Enum *table; void (*write_it) (FILE *fp, struct config_type *); - char *note; + const char *note; } Config_Type; static int get_assume_charset(char *value) @@ -592,7 +592,7 @@ in the Visited Links Page.\n\ }; /* *INDENT-ON* */ -static Config_Type *lookup_config(char *name) +static Config_Type *lookup_config(const char *name) { Config_Type *tbl = Config_Table; char ch = (char) TOUPPER(*name); @@ -665,7 +665,7 @@ void read_rc(FILE *fp) tbl = lookup_config(name); if (tbl->name == 0) { - char *special = RC_MULTI_BOOKMARK; + const char *special = RC_MULTI_BOOKMARK; if (!strncasecomp(name, special, strlen(special))) { tbl = lookup_config(special); @@ -777,7 +777,7 @@ void read_rc(FILE *fp) * Write a set of comments. Doing it this way avoids preprocessor problems * with the leading '#', makes it simpler to use gettext. */ -static void write_list(FILE *fp, char *list) +static void write_list(FILE *fp, const char *list) { int first = TRUE; @@ -952,7 +952,7 @@ It is not this file.\n\ /* * Returns true if the given name would be saved in .lynxrc */ -BOOL will_save_rc(char *name) +BOOL will_save_rc(const char *name) { Config_Type *tbl = lookup_config(name); diff --git a/src/LYrcFile.h b/src/LYrcFile.h index 22b18b15..a4f63053 100644 --- a/src/LYrcFile.h +++ b/src/LYrcFile.h @@ -245,7 +245,7 @@ extern Config_Enum tbl_transfer_rate[]; extern Config_Enum tbl_user_mode[]; extern BOOL LYgetEnum(Config_Enum * table, char *name, int *result); -extern BOOL will_save_rc(char *name); +extern BOOL will_save_rc(const char *name); extern const char *LYputEnum(Config_Enum * table, int value); extern int enable_lynxrc(char *value); extern int get_tagsoup(char *value); diff --git a/src/chrtrans/build-chrtrans.com b/src/chrtrans/build-chrtrans.com index ac8c932d..11e44c02 100644 --- a/src/chrtrans/build-chrtrans.com +++ b/src/chrtrans/build-chrtrans.com @@ -1,4 +1,5 @@ -$ v = 'f$verify(0)' +$ v0 = 0 +$ v = f$verify(v0) $! BUILD-CHRTRANS.COM $! $! Command file to build MAKEUCTB.EXE on VMS systems @@ -27,8 +28,10 @@ $ v1 = f$verify(1) $! $! Compile the Lynx [.SRC.CHRTRANS]makeuctb module. $! -$ v1 = 'f$verify(0)' -$ IF f$trnlnm("VAXCMSG") .eqs. "DECC$MSG" .or. - +$ v1 = f$verify(v0) +$ IF f$getsyi("ARCH_NAME") .eqs. "Alpha" .or. - + f$getsyi("ARCH_NAME") .eqs. "IA64" .or. - + f$trnlnm("VAXCMSG") .eqs. "DECC$MSG" .or. - f$trnlnm("DECC$CC_DEFAULT") .eqs. "/DECC" .or. - f$trnlnm("DECC$CC_DEFAULT") .eqs. "/VAXC" $ THEN @@ -37,7 +40,7 @@ $ v1 = f$verify(1) $! DECC: $ cc := cc/decc/prefix=all /nomember 'CHRcc_opts'- /INCLUDE=([],[-],[--],[--.WWW.Library.Implementation]) -$ v1 = 'f$verify(0)' +$ v1 = f$verify(v0) $ ELSE $ IF f$search("gnu_cc:[000000]gcclib.olb") .nes. "" $ THEN @@ -45,19 +48,19 @@ $ CHRcompiler := "GNUC" $ v1 = f$verify(1) $! GNUC: $ cc := gcc 'CHRcc_opts'/INCLUDE=([],[-],[--],[--.WWW.Library.Implementation]) -$ v1 = 'f$verify(0)' +$ v1 = f$verify(v0) $ ELSE $ CHRcompiler := "VAXC" $ v1 = f$verify(1) $! VAXC: $ cc := cc 'CHRcc_opts'/INCLUDE=([],[-],[--],[--.WWW.Library.Implementation]) -$ v1 = 'f$verify(0)' +$ v1 = f$verify(v0) $ ENDIF $ ENDIF $! $ v1 = f$verify(1) $ cc makeuctb -$ v1 = 'f$verify(0)' +$ v1 = f$verify(v0) $! $ Link_makeuctb: $!============= @@ -65,9 +68,15 @@ $ v1 = f$verify(1) $! $! Link the Lynx [.SRC.CHRTRANS]makeuctb module. $! -$ link/exe=makeuctb.exe'CHRlink_opts' makeuctb, - -sys$disk:[-]'CHRcompiler'.opt/opt -$ v1 = 'f$verify(0)' +$ IF f$getsyi("ARCH_NAME") .eqs. "IA64" +$ THEN +$ optslibs="" +$ ELSE +$ optslibs=", sys$disk:[-]''CHRcompiler'.opt/opt" +$ ENDIF +$ +$ link/exe=makeuctb.exe'CHRlink_opts' makeuctb 'optslibs +$ v1 = f$verify(v0) $! $ Create_headers: $!============== @@ -118,11 +127,11 @@ $ makeuctb pt154_uni.tbl $ makeuctb rfc_suni.tbl $ makeuctb utf8_uni.tbl $ makeuctb viscii_uni.tbl -$ v1 = 'f$verify(0)' +$ v1 = f$verify(v0) $ exit $! $ CLEANUP: -$ v1 = 'f$verify(0)' +$ v1 = f$verify(0) $ write sys$output "Default directory:" $ show default $ v1 = f$verify(v) diff --git a/src/chrtrans/build-header.com b/src/chrtrans/build-header.com index c1e9d087..ff8a6f52 100644 --- a/src/chrtrans/build-header.com +++ b/src/chrtrans/build-header.com @@ -1,4 +1,5 @@ -$ v = 'f$verify(0)' +$ v0 = 0 +$ v = f$verify(v0) $! BUILD-HEADER.COM $! $! Command file to use MAKEUCTB.EXE on VMS systems for creating @@ -25,11 +26,11 @@ $! Create a Lynx [.SRC.CHRTRANS] header file. $! $ makeuctb := $'CHRwhere'makeuctb $ makeuctb 'P1'.tbl -$ v1 = 'f$verify(0)' +$ v1 = f$verify(v0) $ exit $! $ CLEANUP: -$ v1 = 'f$verify(0)' +$ v1 = f$verify(v0) $ write sys$output "Default directory:" $ show default $ v1 = f$verify(v) diff --git a/src/chrtrans/def7_uni.tbl b/src/chrtrans/def7_uni.tbl index f25e84f1..211e2614 100644 --- a/src/chrtrans/def7_uni.tbl +++ b/src/chrtrans/def7_uni.tbl @@ -6,7 +6,7 @@ # # Note: there are a few rare replacement strings with trailing spaces # which should be enclosed as C strings like "... " to make things obvious -# (and doing that we should escape \ as \134 and escape " as \" or \042 +# (and doing that we should escape \ as \134 and escape " as \" or \042 # but this is really rare). # @@ -1858,20 +1858,49 @@ U+25d9:Ic U+25e2:Fd U+25e3:Bd U+25ef:Ci +U+2600:SU # cf. U+263c U+2605:*2 U+2606:*1 U+260e:TEL U+260f:tel +U+261a:<== +U+261b:==> U+261c:<-- U+261e:--> -U+2621 "CAUTION " +U+2620:!X! # or "POISON ", cf. U+2621 +U+2621:!C! # previously "CAUTION " - or is it better to leave it spelled out in English? +U+2622:!R! # or "RADIOACTIVE ", cf. U+2621 +U+2623:!B! # or "BIOHAZARD ", cf. U+2621 +U+2624:|S U+2627:XP +U+262f:Pd U+2639::-( U+263a::-) U+263b:(-: -U+263c:SU -U+2640:f. -U+2642:m. +U+263c:su # previously "SU" - cf. U+2600, typical to have "dark" character in uppercase, eg. U+260e, U+260f +U+263d:Lun1 # Luna, 1st quarter +U+263e:Lun3 # Luna, 3rd quarter +U+263f:Mer +U+2640:Ven # previously "f." - this section labeled as astrological symbols +U+2641:Ter # Terra, to go with other Latin names +U+2642:Mar # previously "m." - this section labeled as astrological symbols +U+2643:Jup +U+2644:Sat +U+2645:Ura +U+2646:Nep +U+2647:Plu +U+2648:Ari # Standard astronomical abbreviation +U+2649:Tau # Standard astronomical abbreviation +U+264a:Gem # Standard astronomical abbreviation +U+264b:Cnc # Standard astronomical abbreviation +U+264c:Leo # Standard astronomical abbreviation +U+264d:Vir # Standard astronomical abbreviation +U+264e:Lib # Standard astronomical abbreviation +U+264f:Sco # Standard astronomical abbreviation +U+2650:Sgr # Standard astronomical abbreviation +U+2651:Cap # Standard astronomical abbreviation +U+2652:Aqr # Standard astronomical abbreviation +U+2653:Psc # Standard astronomical abbreviation U+2660:cS U+2661:cH U+2662:cD @@ -1887,6 +1916,26 @@ U+266c:M16 U+266d:b U+266e:Mx U+266f:# +U+2672:recyc +U+2673:Recy1 +U+2674:Recy2 +U+2675:Recy3 +U+2676:Recy4 +U+2677:Recy5 +U+2678:Recy6 +U+2679:Recy7 +U+267a:Recy +U+267b:Recyc +U+267c:oRecy +U+267d:orecy +U+2680:d1 +U+2681:d2 +U+2682:d3 +U+2683:d4 +U+2684:d5 +U+2685:d6 +U+26a0:!W! # or "WARNING ", cf. U+2621 +U+26a1:!V! # or "VOLTAGE ", cf. U+2621 0x58 U+2713 U+2717 # check marks -> x U+2720:-X # CJK area: diff --git a/src/chrtrans/entities.h b/src/chrtrans/entities.h index f843be3b..e5cf2c8b 100644 --- a/src/chrtrans/entities.h +++ b/src/chrtrans/entities.h @@ -23,7 +23,7 @@ otherwise relaxed. #include <UCkd.h> /* typedef u16 */ typedef struct { - char *name; /* sorted alphabetically (case-sensitive) */ + const char *name; /* sorted alphabetically (case-sensitive) */ u16 code; } UC_entity_info; diff --git a/src/chrtrans/makeuctb.c b/src/chrtrans/makeuctb.c index a71cf20c..a5a1c122 100644 --- a/src/chrtrans/makeuctb.c +++ b/src/chrtrans/makeuctb.c @@ -141,8 +141,8 @@ int unicount[MAX_FONTLEN]; struct unimapdesc_str themap_str = {0, NULL, 0, 0}; -static char *tblname; -static char *hdrname; +static const char *tblname; +static const char *hdrname; static int RawOrEnc = 0; static int Raw_found = 0; /* whether explicit R directive found */ @@ -248,7 +248,7 @@ int lowest_eight = 999; int main(int argc, char **argv) { - static char *first_ifdefs[] = + static const char *first_ifdefs[] = { "/*", " * Compile-in this chunk of code unless we've turned it off specifically", @@ -279,7 +279,7 @@ int main(int argc, char **argv) "#define UC_CHARSET_SETUP%s /*nothing*/", "#else" }; - static char *last_ifdefs[] = + static const char *last_ifdefs[] = { "", "#endif /* NO_CHARSET%s */", @@ -323,7 +323,8 @@ int main(int argc, char **argv) chdr = stdout; hdrname = "stdout"; } else { - strcpy(hdrname = outname, tblname); + strcpy(outname, tblname); + hdrname = outname; if ((p = strrchr(outname, '.')) == 0) p = outname + strlen(outname); strcpy(p, ".h"); |