diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/GridText.c | 18 | ||||
| -rw-r--r-- | src/HTAlert.c | 4 | ||||
| -rw-r--r-- | src/HTFWriter.c | 14 | ||||
| -rw-r--r-- | src/HTInit.c | 14 | ||||
| -rw-r--r-- | src/HTML.c | 24 | ||||
| -rw-r--r-- | src/LYBookmark.c | 4 | ||||
| -rw-r--r-- | src/LYCgi.c | 6 | ||||
| -rw-r--r-- | src/LYCharUtils.c | 26 | ||||
| -rw-r--r-- | src/LYCookie.c | 14 | ||||
| -rw-r--r-- | src/LYCurses.c | 16 | ||||
| -rw-r--r-- | src/LYEdit.c | 6 | ||||
| -rw-r--r-- | src/LYEditmap.c | 4 | ||||
| -rw-r--r-- | src/LYExtern.c | 18 | ||||
| -rw-r--r-- | src/LYGetFile.c | 34 | ||||
| -rw-r--r-- | src/LYJump.c | 12 | ||||
| -rw-r--r-- | src/LYKeymap.c | 6 | ||||
| -rw-r--r-- | src/LYLocal.c | 18 | ||||
| -rw-r--r-- | src/LYMail.c | 38 | ||||
| -rw-r--r-- | src/LYMain.c | 26 | ||||
| -rw-r--r-- | src/LYMainLoop.c | 22 | ||||
| -rw-r--r-- | src/LYMap.c | 6 | ||||
| -rw-r--r-- | src/LYNews.c | 6 | ||||
| -rw-r--r-- | src/LYOptions.c | 13 | ||||
| -rw-r--r-- | src/LYPrettySrc.c | 4 | ||||
| -rw-r--r-- | src/LYPrint.c | 10 | ||||
| -rw-r--r-- | src/LYReadCFG.c | 42 | ||||
| -rw-r--r-- | src/LYSession.c | 20 | ||||
| -rw-r--r-- | src/LYStrings.c | 20 | ||||
| -rw-r--r-- | src/LYStyle.c | 143 | ||||
| -rw-r--r-- | src/LYUpload.c | 4 | ||||
| -rw-r--r-- | src/LYUtils.c | 187 | ||||
| -rw-r--r-- | src/LYUtils.h | 5 | ||||
| -rw-r--r-- | src/LYexit.c | 41 | ||||
| -rw-r--r-- | src/LYrcFile.c | 8 | ||||
| -rw-r--r-- | src/UCAuto.c | 12 | ||||
| -rw-r--r-- | src/chrtrans/makeuctb.c | 6 |
36 files changed, 448 insertions, 403 deletions
diff --git a/src/GridText.c b/src/GridText.c index 7dce2483..6a172ebf 100644 --- a/src/GridText.c +++ b/src/GridText.c @@ -1,5 +1,5 @@ /* - * $LynxId: GridText.c,v 1.273 2013/10/13 20:23:07 tom Exp $ + * $LynxId: GridText.c,v 1.274 2013/11/28 11:16:50 tom Exp $ * * Character grid hypertext object * =============================== @@ -7657,7 +7657,7 @@ int do_www_search(DocInfo *doc) /* * Load the default query buffer */ - if ((cp = strchr(doc->address, '?')) != NULL) { + if ((cp = StrChr(doc->address, '?')) != NULL) { /* * This is an index from a previous search. * Use its query as the default. @@ -7799,7 +7799,7 @@ int do_www_search(DocInfo *doc) /* * Show the URL with the new query. */ - if ((cp = strchr(doc->address, '?')) != NULL) + if ((cp = StrChr(doc->address, '?')) != NULL) *cp = '\0'; StrAllocCopy(tmpaddress, doc->address); StrAllocCat(tmpaddress, "?"); @@ -10495,7 +10495,7 @@ static double get_trans_q(int cs_from, if (!givenmime || !(*givenmime)) return 0.0; - if ((p = strchr(givenmime, ';')) != NULL) { + if ((p = StrChr(givenmime, ';')) != NULL) { *p++ = '\0'; } if (!strcmp(givenmime, "*")) @@ -11624,7 +11624,7 @@ int HText_SubmitForm(FormInfo * submit_item, DocInfo *doc, * default. -FM */ if (Boundary) { - *(strchr(escaped1, '=') + 1) = '\0'; + *(StrChr(escaped1, '=') + 1) = '\0'; HTBprintf(&my_query, "%s\"%s.x\"\r\n\r\n0\r\n--%s\r\n%s\"%s.y\"\r\n\r\n0", escaped1, @@ -12517,7 +12517,7 @@ static int increment_tagged_htline(HTLine *ht, TextAnchor *a, int *lx_val, val += incr; sprintf(lx, "%d", val); new_n = (int) strlen(lx); - if ((r = strchr(ht->next->data, ']')) == 0) { + if ((r = StrChr(ht->next->data, ']')) == 0) { r = ""; } strcat(lx, r); @@ -12995,7 +12995,7 @@ static int finish_ExtEditForm(LinkInfo * form_link, TextAnchor *start_anchor, } line[len0] = '\0'; - if ((cp = strchr(lp, '\n')) != 0) + if ((cp = StrChr(lp, '\n')) != 0) len = (int) (cp - lp); else len = (int) strlen(lp); @@ -13003,7 +13003,7 @@ static int finish_ExtEditForm(LinkInfo * form_link, TextAnchor *start_anchor, if (wanted_fieldlen_wrap < 0 && !wrapalert && len0 + len >= display_size && - (cp = strchr(lp, ' ')) != NULL && + (cp = StrChr(lp, ' ')) != NULL && (cp - lp) < display_size - 1) { LYFixCursesOn("ask for confirmation:"); @@ -13637,7 +13637,7 @@ int HText_InsertFile(LinkInfo * form_link) while (*lp) { - if ((cp = strchr(lp, '\n')) != 0) + if ((cp = StrChr(lp, '\n')) != 0) len = (int) (cp - lp); else len = (int) strlen(lp); diff --git a/src/HTAlert.c b/src/HTAlert.c index 59569d4e..34ddfa9f 100644 --- a/src/HTAlert.c +++ b/src/HTAlert.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTAlert.c,v 1.100 2013/10/12 14:52:24 tom Exp $ + * $LynxId: HTAlert.c,v 1.101 2013/11/28 11:17:04 tom Exp $ * * Displaying messages and getting input for Lynx Browser * ========================================================== @@ -940,7 +940,7 @@ BOOL HTConfirmCookie(domain_entry * de, const char *server, char *p = gettext("Y/N/A/V"); /* placeholder for comment */ const char *s = "YNAV\007\003"; /* see ADVANCED_COOKIE_CONFIRMATION */ - if (strchr(s, ch) == 0 + if (StrChr(s, ch) == 0 && isalpha(ch) && (p = strrchr(prompt, L_PAREN)) != 0) { diff --git a/src/HTFWriter.c b/src/HTFWriter.c index be2b63be..b893ea22 100644 --- a/src/HTFWriter.c +++ b/src/HTFWriter.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTFWriter.c,v 1.105 2013/07/21 00:41:24 tom Exp $ + * $LynxId: HTFWriter.c,v 1.106 2013/11/28 11:17:04 tom Exp $ * * FILE WRITER HTFWrite.h * =========== @@ -665,7 +665,7 @@ HTStream *HTSaveAndExecute(HTPresentation *pres, LYStrNCpy(view_fname, anchor->address + 17, sizeof(fnam) - 5); HTUnEscape(view_fname); - if (strchr(view_fname, ':') == NULL) { + if (StrChr(view_fname, ':') == NULL) { fnam[0] = windows_drive[0]; fnam[1] = windows_drive[1]; fnam[2] = '/'; @@ -683,7 +683,7 @@ HTStream *HTSaveAndExecute(HTPresentation *pres, } cp++; } - if (strchr(view_fname, ' ')) + if (StrChr(view_fname, ' ')) view_fname = quote_pathname(view_fname); StrAllocCopy(me->viewer_command, pres->command); @@ -803,7 +803,7 @@ HTStream *HTSaveToFile(HTPresentation *pres, return (NULL); } - if (((cp = strchr(pres->rep->name, ';')) != NULL) && + if (((cp = StrChr(pres->rep->name, ';')) != NULL) && strstr((cp + 1), "charset") != NULL) { _user_message(MSG_DOWNLOAD_OR_CANCEL, pres->rep->name); } else if (*(pres->rep->name) != '\0') { @@ -1090,7 +1090,7 @@ HTStream *HTCompressed(HTPresentation *pres, } if (can_present == FALSE || /* no presentation mapping */ uncompress_mask == NULL || /* not gzip or compress */ - strchr(anchor->content_type, ';') || /* wrong charset */ + StrChr(anchor->content_type, ';') || /* wrong charset */ HTOutputFormat == HTAtom_for("www/download") || /* download */ !strcasecomp(pres->rep_out->name, "www/download") || /* download */ (traversal && /* only handle html or plain text for traversals */ @@ -1100,7 +1100,7 @@ HTStream *HTCompressed(HTPresentation *pres, * Cast the Content-Encoding to a Content-Type and pass it back to be * handled as that type. - FM */ - if (strchr(anchor->content_encoding, '/') == NULL) { + if (StrChr(anchor->content_encoding, '/') == NULL) { /* * Use "x-" prefix, none of the types we are likely to construct * here are official. That is we generate "application/x-gzip" and @@ -1164,7 +1164,7 @@ HTStream *HTCompressed(HTPresentation *pres, HTFileSuffix(HTAtom_for(anchor->content_type), NULL)) && *suffix == '.') { #if defined(VMS) || defined(FNAMES_8_3) - if (strchr(suffix + 1, '.') == NULL) + if (StrChr(suffix + 1, '.') == NULL) #endif middle = suffix + 1; } diff --git a/src/HTInit.c b/src/HTInit.c index ecefe149..cb6b80e4 100644 --- a/src/HTInit.c +++ b/src/HTInit.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTInit.c,v 1.84 2013/05/05 19:49:29 tom Exp $ + * $LynxId: HTInit.c,v 1.85 2013/11/28 11:17:21 tom Exp $ * * Configuration-specific Initialization HTInit.c * ---------------------------------------- @@ -382,7 +382,7 @@ static int ProcessMailcapEntry(FILE *fp, struct MailcapEntry *mc, AcceptMedia me FREE(rawentry); return (0); } - s = strchr(rawentry, ';'); + s = StrChr(rawentry, ';'); if (s == NULL) { CTrace((tfp, "ProcessMailcapEntry: Ignoring invalid mailcap entry: %s\n", @@ -423,7 +423,7 @@ static int ProcessMailcapEntry(FILE *fp, struct MailcapEntry *mc, AcceptMedia me t = GetCommand(s, &mallocd_string); arg = mallocd_string; - eq = strchr(arg, '='); + eq = StrChr(arg, '='); if (eq) { *eq++ = '\0'; eq = LYSkipBlanks(eq); @@ -518,7 +518,7 @@ static const char *LYSkipToken(const char *s) { static const char tspecials[] = "\"()<>@,;:\\/[]?.="; - while (*s != '\0' && !WHITE(*s) && strchr(tspecials, *s) == 0) { + while (*s != '\0' && !WHITE(*s) && StrChr(tspecials, *s) == 0) { ++s; } return s; @@ -573,7 +573,7 @@ static char *LYGetContentType(const char *name, if (params != 0) { if (name != 0) { size_t length = strlen(name); - const char *test = strchr(params, ';'); /* skip type/subtype */ + const char *test = StrChr(params, ';'); /* skip type/subtype */ const char *next; while (test != 0) { @@ -639,7 +639,7 @@ BOOL LYMailcapUsesPctS(const char *controlstring) result = TRUE; break; case L_CURL: - next = strchr(from, R_CURL); + next = StrChr(from, R_CURL); if (next != 0) { from = next; break; @@ -705,7 +705,7 @@ static int BuildCommand(HTChunk *cmd, } break; case L_CURL: - next = strchr(from, R_CURL); + next = StrChr(from, R_CURL); if (next != 0) { if (params != 0) { ++from; @@ -1,5 +1,5 @@ /* - * $LynxId: HTML.c,v 1.163 2013/10/13 14:24:33 tom Exp $ + * $LynxId: HTML.c,v 1.164 2013/11/28 11:17:39 tom Exp $ * * Structured stream to Rich hypertext converter * ============================================ @@ -1042,9 +1042,9 @@ static int HTML_start_element(HTStructured * me, int element_number, char q = '"'; /*0 in dquotes, 1 - in quotes, 2 mixed */ - char kind = (char) (!strchr(value[i], '"') ? + char kind = (char) (!StrChr(value[i], '"') ? 0 : - !strchr(value[i], '\'') ? + !StrChr(value[i], '\'') ? q = '\'', 1 : 2); @@ -1272,7 +1272,7 @@ static int HTML_start_element(HTStructured * me, int element_number, */ temp = HTParse(base, "", PARSE_PATH + PARSE_PUNCTUATION); if (*temp != '\0') { - char *p = strchr(temp, '?'); + char *p = StrChr(temp, '?'); if (p) *p = '\0'; @@ -3540,7 +3540,7 @@ static int HTML_start_element(HTStructured * me, int element_number, * LYSeekFragAREAinCur is set. - FM && KW */ StrAllocCopy(me->map_address, me->node_anchor->address); - if ((cp = strchr(me->map_address, '#')) != NULL) + if ((cp = StrChr(me->map_address, '#')) != NULL) *cp = '\0'; StrAllocCat(me->map_address, "#"); StrAllocCat(me->map_address, id_string); @@ -4395,7 +4395,7 @@ static int HTML_start_element(HTStructured * me, int element_number, if (!(present && present[HTML_BUTTON_NAME] && value[HTML_BUTTON_NAME])) { I.name = ""; - } else if (strchr(value[HTML_BUTTON_NAME], '&') == NULL) { + } else if (StrChr(value[HTML_BUTTON_NAME], '&') == NULL) { I.name = value[HTML_BUTTON_NAME]; } else { StrAllocCopy(I_name, value[HTML_BUTTON_NAME]); @@ -4637,7 +4637,7 @@ static int HTML_start_element(HTStructured * me, int element_number, if (!(present && present[HTML_INPUT_NAME] && non_empty(value[HTML_INPUT_NAME]))) { I.name = ""; - } else if (strchr(value[HTML_INPUT_NAME], '&') == NULL) { + } else if (StrChr(value[HTML_INPUT_NAME], '&') == NULL) { I.name = value[HTML_INPUT_NAME]; } else { StrAllocCopy(I_name, value[HTML_INPUT_NAME]); @@ -4989,7 +4989,7 @@ static int HTML_start_element(HTStructured * me, int element_number, value[HTML_TEXTAREA_NAME]) { StrAllocCopy(me->textarea_name, value[HTML_TEXTAREA_NAME]); me->textarea_name_cs = ATTR_CS_IN; - if (strchr(value[HTML_TEXTAREA_NAME], '&') != NULL) { + if (StrChr(value[HTML_TEXTAREA_NAME], '&') != NULL) { UNESCAPE_FIELDNAME_TO_STD(&me->textarea_name); } } else { @@ -6304,7 +6304,7 @@ static int HTML_end_element(HTStructured * me, int element_number, HTChunkTerminate(&me->object); data = me->object.data; - while ((cp = strchr(data, '<')) != NULL) { + while ((cp = StrChr(data, '<')) != NULL) { /* * Look for nested OBJECTs. This procedure could get tripped * up if invalid comments are present in the content, or if an @@ -6892,7 +6892,7 @@ static int HTML_end_element(HTStructured * me, int element_number, /* * Load the first text line, or set up for all blank rows. - FM */ - if ((cp = strchr(data, '\n')) != NULL) { + if ((cp = StrChr(data, '\n')) != NULL) { *cp = '\0'; StrAllocCopy(temp, data); *cp = '\n'; @@ -6925,7 +6925,7 @@ static int HTML_end_element(HTStructured * me, int element_number, if (*data == '\n') { FREE(temp); data++; - } else if ((cp = strchr(data, '\n')) != NULL) { + } else if ((cp = StrChr(data, '\n')) != NULL) { *cp = '\0'; StrAllocCopy(temp, data); *cp = '\n'; @@ -6958,7 +6958,7 @@ static int HTML_end_element(HTStructured * me, int element_number, if (*data == '\n') { FREE(temp); data++; - } else if ((cp = strchr(data, '\n')) != NULL) { + } else if ((cp = StrChr(data, '\n')) != NULL) { *cp = '\0'; StrAllocCopy(temp, data); *cp = '\n'; diff --git a/src/LYBookmark.c b/src/LYBookmark.c index b5425f4c..d1a624ec 100644 --- a/src/LYBookmark.c +++ b/src/LYBookmark.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYBookmark.c,v 1.75 2013/10/12 14:51:18 tom Exp $ + * $LynxId: LYBookmark.c,v 1.76 2013/11/28 11:17:59 tom Exp $ */ #include <HTUtils.h> #include <HTAlert.h> @@ -40,7 +40,7 @@ int LYMBM2index(int ch) { if ((ch = TOUPPER(ch)) > 0) { const char *letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - const char *result = strchr(letters, ch); + const char *result = StrChr(letters, ch); if (result != 0 && (result - letters) <= MBM_V_MAXFILES) diff --git a/src/LYCgi.c b/src/LYCgi.c index d65f7827..caa6b6d4 100644 --- a/src/LYCgi.c +++ b/src/LYCgi.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYCgi.c,v 1.65 2013/01/04 09:44:59 tom Exp $ + * $LynxId: LYCgi.c,v 1.67 2013/11/28 11:35:56 tom Exp $ * Lynx CGI support LYCgi.c * ================ * @@ -117,7 +117,7 @@ static void add_environment_value(const char *env_value) assert(env != NULL); } - env[envc++] = (char *) env_value; + env[envc++] = DeConst(env_value); env[envc] = NULL; /* Make sure it is always properly terminated */ } @@ -213,7 +213,7 @@ static int LYLoadCGI(const char *arg, } else { StrAllocCopy(pgm, arg + 8); } - if ((cp = strchr(pgm, '?')) != NULL) { /* Need to terminate executable */ + if ((cp = StrChr(pgm, '?')) != NULL) { /* Need to terminate executable */ *cp++ = '\0'; pgm_args = cp; } diff --git a/src/LYCharUtils.c b/src/LYCharUtils.c index ded061b2..01d6a4b6 100644 --- a/src/LYCharUtils.c +++ b/src/LYCharUtils.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYCharUtils.c,v 1.126 2013/10/19 19:12:09 tom Exp $ + * $LynxId: LYCharUtils.c,v 1.127 2013/11/28 11:17:59 tom Exp $ * * Functions associated with LYCharSets.c and the Lynx version of HTML.c - FM * ========================================================================== @@ -51,7 +51,7 @@ static size_t count_char(const char *value, int ch) const char *found; size_t result = 0; - while ((*value != '\0') && (found = strchr(value, ch)) != NULL) { + while ((*value != '\0') && (found = StrChr(value, ch)) != NULL) { ++result; value = (found + 1); } @@ -223,7 +223,7 @@ static BOOL MustEntify(const char *source) BOOL result; #ifdef CJK_EX - if (IS_CJK_TTY && strchr(source, '\033') != 0) { + if (IS_CJK_TTY && StrChr(source, '\033') != 0) { result = TRUE; } else #endif @@ -352,7 +352,7 @@ char *LYFindEndOfComment(char *str) */ return cp; - if ((cp1 = strchr(cp, '>')) == NULL) + if ((cp1 = StrChr(cp, '>')) == NULL) /* * We don't have an end character, so return the beginning of the * string. - FM @@ -508,7 +508,7 @@ void LYFillLocalFileURL(char **href, * Check for pathological cases - current dir has chars which MUST BE * URL-escaped - kw */ - if (strchr(temp2, '%') != NULL || strchr(temp2, '#') != NULL) { + if (StrChr(temp2, '%') != NULL || StrChr(temp2, '#') != NULL) { FREE(temp); temp = HTEscape(temp2, URL_PATH); StrAllocCat(*href, temp); @@ -1152,7 +1152,7 @@ char **LYUCFullyTranslateString(char **str, /* * Save malloc/calloc overhead in simple case - kw */ - if (do_ent && hidden && (stype != st_URL) && (strchr(*str, '&') == NULL)) + if (do_ent && hidden && (stype != st_URL) && (StrChr(*str, '&') == NULL)) do_ent = FALSE; /* Can't do, caller should figure out what to do... */ @@ -1923,7 +1923,7 @@ char *LYParseTagParam(char *from, char *string = from; do { - if ((string = strchr(string, ';')) == NULL) + if ((string = StrChr(string, ';')) == NULL) return NULL; while (*string != '\0' && (*string == ';' || isspace(UCH(*string)))) { string++; @@ -2426,7 +2426,7 @@ void LYHandleMETA(HTStructured * me, const BOOL *present, not that it matters much. avoid setting it here. - kw */ if (track_internal_links && (StrNCmp(href, "http", 4) == 0) && - (cp = strchr(href, '#')) != NULL) { + (cp = StrChr(href, '#')) != NULL) { StrAllocCopy(id_string, cp); *cp = '\0'; } @@ -2493,7 +2493,7 @@ void LYHandleMETA(HTStructured * me, const BOOL *present, if (*cp != '\0') { StrAllocCopy(me->node_anchor->SugFname, cp); if (*me->node_anchor->SugFname == '"') { - if ((cp = strchr((me->node_anchor->SugFname + 1), + if ((cp = StrChr((me->node_anchor->SugFname + 1), '"')) != NULL) { *(cp + 1) = '\0'; HTMIME_TrimDoubleQuotes(me->node_anchor->SugFname); @@ -2694,7 +2694,7 @@ void LYHandleSELECT(HTStructured * me, const BOOL *present, if (!(present && present[HTML_SELECT_NAME] && non_empty(value[HTML_SELECT_NAME]))) { StrAllocCopy(name, ""); - } else if (strchr(value[HTML_SELECT_NAME], '&') == NULL) { + } else if (StrChr(value[HTML_SELECT_NAME], '&') == NULL) { StrAllocCopy(name, value[HTML_SELECT_NAME]); } else { StrAllocCopy(name, value[HTML_SELECT_NAME]); @@ -2894,12 +2894,12 @@ int LYLegitimizeHREF(HTStructured * me, char **href, * it may actually have blanks in the name. * Try to accommodate. See also HTParse(). */ - if (LYRemoveNewlines(p) || strchr(p, '\t') != 0) { + if (LYRemoveNewlines(p) || StrChr(p, '\t') != 0) { LYRemoveBlanks(p); /* a compromise... */ } if (pound != NULL) { - p = strchr(p, '\0'); + p = StrChr(p, '\0'); *pound = '#'; /* restore */ convert_to_spaces(pound, FALSE); if (p < pound) @@ -3300,7 +3300,7 @@ BOOLEAN LYCommentHacks(HTParentAnchor *anchor, FREE(messageid); return FALSE; } - if ((p = strchr(messageid, '@')) == NULL || p[1] == '\0') { + if ((p = StrChr(messageid, '@')) == NULL || p[1] == '\0') { FREE(messageid); return FALSE; } diff --git a/src/LYCookie.c b/src/LYCookie.c index 9b89a9f4..04ee12fd 100644 --- a/src/LYCookie.c +++ b/src/LYCookie.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYCookie.c,v 1.127 2011/06/11 12:35:50 tom Exp $ + * $LynxId: LYCookie.c,v 1.128 2013/11/28 11:18:12 tom Exp $ * * Lynx Cookie Support LYCookie.c * =================== @@ -215,7 +215,7 @@ static void LYCookieJar_free(void) static BOOLEAN has_embedded_dot(char *value) { BOOLEAN result = NO; - char *first_dot = strchr(value, '.'); + char *first_dot = StrChr(value, '.'); if (first_dot != NULL && first_dot[1] != '\0') { result = YES; @@ -438,7 +438,7 @@ static void store_cookie(cookie * co, const char *hostname, /* * The hostname does not contain a dot. */ - if (strchr(hostname, '.') == NULL) { + if (StrChr(hostname, '.') == NULL) { CTrace((tfp, "store_cookie: Rejecting because '%s' has no dot.\n", hostname)); freeCookie(co); @@ -500,7 +500,7 @@ static void store_cookie(cookie * co, const char *hostname, * INVCHECK_QUERY. */ ptr = ((hostname + strlen(hostname)) - strlen(co->domain)); - if (strchr(hostname, '.') < ptr) { + if (StrChr(hostname, '.') < ptr) { invcheck_behaviour_t invcheck_bv = (de ? de->invcheck_bv : DEFAULT_INVCHECK_BV); @@ -982,7 +982,7 @@ static unsigned parse_attribute(unsigned flags, */ if (value[0] != '.' && value[0] != '\0' && value[1] != '\0' && strcasecomp(value, hostname)) { - char *ptr = strchr(value, '.'); + char *ptr = StrChr(value, '.'); if (ptr != NULL && ptr[1] != '\0') { ptr = value; @@ -1779,7 +1779,7 @@ void LYSetCookie(const char *SetCookie, * cookie(s) only if LYSetCookies is TRUE. - FM */ if (((hostname = HTParse(address, "", PARSE_HOST)) != NULL) && - (ptr = strchr(hostname, ':')) != NULL) { + (ptr = StrChr(hostname, ':')) != NULL) { /* * Replace default port number. */ @@ -1798,7 +1798,7 @@ void LYSetCookie(const char *SetCookie, * Trim off any parameters to provide something that we can compare * against the cookie's path for verifying if it has the proper prefix. */ - if ((ptr = strchr(path, '?')) != NULL) { + if ((ptr = StrChr(path, '?')) != NULL) { CTrace((tfp, "discarding params \"%s\" in request URI\n", ptr)); *ptr = '\0'; } diff --git a/src/LYCurses.c b/src/LYCurses.c index 1f9c7a00..c4c5e0f4 100644 --- a/src/LYCurses.c +++ b/src/LYCurses.c @@ -1,4 +1,4 @@ -/* $LynxId: LYCurses.c,v 1.177 2013/10/20 16:24:43 tom Exp $ */ +/* $LynxId: LYCurses.c,v 1.178 2013/11/28 11:52:34 tom Exp $ */ #include <HTUtils.h> #include <HTAlert.h> @@ -1750,13 +1750,15 @@ void stop_curses(void) /* ifdef's for non-Unix curses or slang */ #if defined(__MINGW32__) - chtype bb; + { + chtype bb; - bb = getbkgd(stdscr); - bkgdset(0); - clear(); - refresh(); - bkgdset(bb); + bb = getbkgd(stdscr); + bkgdset(0); + clear(); + refresh(); + bkgdset(bb); + } #if defined(PDCURSES) endwin(); #endif /* PDCURSES */ diff --git a/src/LYEdit.c b/src/LYEdit.c index 0b1780bb..ee0b8329 100644 --- a/src/LYEdit.c +++ b/src/LYEdit.c @@ -1,4 +1,4 @@ -/* $LynxId: LYEdit.c,v 1.41 2010/09/24 00:07:26 tom Exp $ */ +/* $LynxId: LYEdit.c,v 1.42 2013/11/28 11:18:19 tom Exp $ */ #include <HTUtils.h> #include <HTParse.h> #include <HTAlert.h> @@ -119,7 +119,7 @@ int edit_current_file(char *newfile, if (StrNCmp(newfile, "file://localhost/", 16) == 0) colon = newfile + 16; else - colon = strchr(newfile, ':'); + colon = StrChr(newfile, ':'); StrAllocCopy(filename, (colon + 1)); HTUnEscape(filename); if (!LYCanReadFile(filename)) { @@ -230,7 +230,7 @@ void edit_temporary_file(char *filename, #endif else { #ifdef _WINDOWS - if (strchr(editor, ' ')) + if (StrChr(editor, ' ')) HTAddXpand(&command, format, params++, HTDOS_short_name(editor)); else HTAddXpand(&command, format, params++, editor); diff --git a/src/LYEditmap.c b/src/LYEditmap.c index 7786f508..653f7080 100644 --- a/src/LYEditmap.c +++ b/src/LYEditmap.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYEditmap.c,v 1.71 2013/10/20 20:03:24 tom Exp $ + * $LynxId: LYEditmap.c,v 1.72 2013/11/28 11:18:33 tom Exp $ * * LYEditMap.c * Keybindings for line and form editing. @@ -1695,7 +1695,7 @@ static void checkEditMap(LYEditConfig * table) if (Non_Empty(what)) { sprintf(comment, "\t/* %s%s */", what, - ((strchr(what, '_') != 0) + ((StrChr(what, '_') != 0) ? "" : "_KEY")); } else { diff --git a/src/LYExtern.c b/src/LYExtern.c index f0a7c84d..846b652c 100644 --- a/src/LYExtern.c +++ b/src/LYExtern.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYExtern.c,v 1.52 2013/05/04 13:01:06 tom Exp $ + * $LynxId: LYExtern.c,v 1.53 2013/11/28 11:18:33 tom Exp $ * External application support. This feature allows lynx to pass a given URL to an external program. @@ -78,7 +78,7 @@ static void delete_danger_characters(char *src) char *dst; for (dst = src; *src != '\0'; src++) { - if (strchr("<>|%\"", *src) == NULL) { + if (StrChr("<>|%\"", *src) == NULL) { *dst = *src; dst++; } @@ -99,14 +99,14 @@ static char *escapeParameter(CONST char *parameter) char *needs_escaped_NT = "%&^"; for (i = 0; i < last; ++i) { - if (strchr(needs_encoded, parameter[i]) != NULL) { + if (StrChr(needs_encoded, parameter[i]) != NULL) { ++encoded; } if (system_is_NT) { - if (strchr(needs_escaped_NT, parameter[i]) != NULL) { + if (StrChr(needs_escaped_NT, parameter[i]) != NULL) { ++escaped; } - } else if (strchr(needs_escaped, parameter[i]) != NULL) { + } else if (StrChr(needs_escaped, parameter[i]) != NULL) { ++escaped; } } @@ -117,18 +117,18 @@ static char *escapeParameter(CONST char *parameter) n = 0; for (i = 0; i < last; i++) { - if (strchr(needs_encoded, parameter[i]) != NULL) { + if (StrChr(needs_encoded, parameter[i]) != NULL) { sprintf(result + n, "%%%02X", (unsigned char) parameter[i]); n += 3; continue; } if (system_is_NT) { - if (strchr(needs_escaped_NT, parameter[i]) != NULL) { + if (StrChr(needs_escaped_NT, parameter[i]) != NULL) { result[n++] = '^'; result[n++] = parameter[i]; continue; } - } else if (strchr(needs_escaped, parameter[i]) != NULL) { + } else if (StrChr(needs_escaped, parameter[i]) != NULL) { result[n++] = '%'; /* parameter[i] is '%' */ result[n++] = parameter[i]; continue; @@ -197,7 +197,7 @@ static char *format_command(char *command, p = param + 17; delete_danger_characters(p); *e_buff = 0; - if (strchr(p, ':') == NULL) { + if (StrChr(p, ':') == NULL) { sprintf(e_buff, "%.3s/", windows_drive); } strncat(e_buff, p, sizeof(e_buff) - strlen(e_buff) - 1); diff --git a/src/LYGetFile.c b/src/LYGetFile.c index 866d780e..af926301 100644 --- a/src/LYGetFile.c +++ b/src/LYGetFile.c @@ -1,4 +1,4 @@ -/* $LynxId: LYGetFile.c,v 1.91 2013/10/19 01:08:57 tom Exp $ */ +/* $LynxId: LYGetFile.c,v 1.92 2013/11/28 11:18:56 tom Exp $ */ #include <HTUtils.h> #include <HTTP.h> #include <HTAnchor.h> /* Anchor class */ @@ -144,7 +144,7 @@ int getfile(DocInfo *doc, int *target) strlen(temp) > 3) { char *cp1; - if ((cp1 = strchr(temp, '@')) == NULL) + if ((cp1 = StrChr(temp, '@')) == NULL) cp1 = temp; if ((cp = strrchr(cp1, ':')) != NULL) { long int value; @@ -382,8 +382,8 @@ int getfile(DocInfo *doc, int *target) LYNoRefererForThis = TRUE; } if (LYNoRefererForThis == FALSE && - (cp = strchr(ref_url, '?')) != NULL && - strchr(cp, '=') != NULL) { + (cp = StrChr(ref_url, '?')) != NULL && + StrChr(cp, '=') != NULL) { /* * Don't send a Referer header if the URL is the reply from a * form with method GET, in case the content has personal data @@ -544,7 +544,7 @@ int getfile(DocInfo *doc, int *target) title = ""; } } - cp = strchr(doc->address, ':') + 1; + cp = StrChr(doc->address, ':') + 1; reply_by_mail(cp, ((HTMainAnchor && !LYUserSpecifiedURL) ? (char *) HTMainAnchor->address @@ -589,7 +589,7 @@ int getfile(DocInfo *doc, int *target) if (!telnet_ok) { HTUserMsg(TELNET_DISABLED); return (NULLFILE); - } else if (no_telnet_port && strchr(doc->address + 7, ':')) { + } else if (no_telnet_port && StrChr(doc->address + 7, ':')) { HTUserMsg(TELNET_PORT_SPECS_DISABLED); return (NULLFILE); /* @@ -660,7 +660,7 @@ int getfile(DocInfo *doc, int *target) * already attached then do this. Otherwise just load it! */ } else if (url_type == INDEX_GOPHER_URL_TYPE && - strchr(doc->address, '?') == NULL) { + StrChr(doc->address, '?') == NULL) { int status; /* @@ -718,7 +718,7 @@ int getfile(DocInfo *doc, int *target) /* * If tuple's Path=GET%20/... convert to an http URL. */ - if ((cp = strchr(doc->address + 9, '/')) != NULL && + if ((cp = StrChr(doc->address + 9, '/')) != NULL && 0 == StrNCmp(++cp, "hGET%20/", 8)) { StrAllocCopy(tmp, "http://"); CTRACE((tfp, "getfile: URL '%s'\n", @@ -728,7 +728,7 @@ int getfile(DocInfo *doc, int *target) /* * If the port is defaulted, it should stay 70. */ - if (strchr(tmp + 6, ':') == NULL) { + if (StrChr(tmp + 6, ':') == NULL) { StrAllocCat(tmp, "70/"); tmp[strlen(tmp) - 4] = ':'; } @@ -1340,7 +1340,7 @@ void add_trusted(char *str, first = FALSE; } - path = strchr(src, '\t'); + path = StrChr(src, '\t'); if (path) { *path++ = '\0'; after_tab = path; @@ -1398,11 +1398,11 @@ BOOLEAN exec_ok(const char *source, /* * Security: reject on relative path. */ - if ((cp = strchr(linktext, '[')) != NULL) { + if ((cp = StrChr(linktext, '[')) != NULL) { char *cp1; - if (((cp1 = strchr(cp, '-')) != NULL) && - strchr(cp1, ']') != NULL) { + if (((cp1 = StrChr(cp, '-')) != NULL) && + StrChr(cp1, ']') != NULL) { while (cp1[1] == '-') cp1++; if (cp1[1] == ']' || @@ -1429,7 +1429,7 @@ BOOLEAN exec_ok(const char *source, else allowed_extra_chars = " _-:./@~$+=\t"; for (cp = linktext; *cp != '\0'; cp++) { - if (!isalnum(UCH(*cp)) && !strchr(allowed_extra_chars, *cp)) { + if (!isalnum(UCH(*cp)) && !StrChr(allowed_extra_chars, *cp)) { char *buf = 0; HTSprintf0(&buf, @@ -1516,7 +1516,7 @@ static int fix_httplike_urls(DocInfo *doc, UrlTypes type) } else if (type == NCFTP_URL_TYPE) { char *path = NULL; char *first = doc->address; - char *second = strchr(first, ':'); + char *second = StrChr(first, ':'); CTRACE((tfp, "fix_httplike_urls: URL '%s'\n", doc->address)); if (second == 0) @@ -1541,7 +1541,7 @@ static int fix_httplike_urls(DocInfo *doc, UrlTypes type) } if (type == HTTP_URL_TYPE || type == HTTPS_URL_TYPE) { - if ((slash - 2) != strchr(doc->address, ':')) { + if ((slash - 2) != StrChr(doc->address, ':')) { /* * Turns out we were not looking at the right slash after all, * there must have been more than one "://" which is valid at @@ -1550,7 +1550,7 @@ static int fix_httplike_urls(DocInfo *doc, UrlTypes type) */ return (0); } - if (strchr(doc->address, '?')) { + if (StrChr(doc->address, '?')) { /* * If there is a question mark that appears to be part of the * hostname, don't append anything either. Leave it to HTParse diff --git a/src/LYJump.c b/src/LYJump.c index 70886b8a..ebe09d61 100644 --- a/src/LYJump.c +++ b/src/LYJump.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYJump.c,v 1.48 2013/10/13 20:23:07 tom Exp $ + * $LynxId: LYJump.c,v 1.49 2013/11/28 11:19:08 tom Exp $ */ #include <HTUtils.h> #include <HTAlert.h> @@ -258,7 +258,7 @@ char *LYJump(int key) return NULL; } #ifdef PERMIT_GOTO_FROM_JUMP - if (strchr(bp, ':') || strchr(bp, '/')) { + if (StrChr(bp, ':') || StrChr(bp, '/')) { char *temp = NULL; LYJumpFileURL = FALSE; @@ -448,7 +448,7 @@ static unsigned LYRead_Jumpfile(struct JumpTable *jtp) /* quick scan for approximate number of entries */ nel = 0; cp = mp; - while ((cp = strchr(cp, '\n')) != NULL) { + while ((cp = StrChr(cp, '\n')) != NULL) { nel++; cp++; } @@ -463,7 +463,7 @@ static unsigned LYRead_Jumpfile(struct JumpTable *jtp) cp = jtp->mp = mp; for (i = 0; i < nel;) { if (StrNCmp(cp, "<!--", 4) == 0 || StrNCmp(cp, "<dl>", 4) == 0) { - cp = strchr(cp, '\n'); + cp = StrChr(cp, '\n'); if (cp == NULL) break; cp++; @@ -484,12 +484,12 @@ static unsigned LYRead_Jumpfile(struct JumpTable *jtp) break; cp += 6; jtp->table[i].url = cp; - cp = strchr(cp, '"'); + cp = StrChr(cp, '"'); if (cp == NULL) break; *cp = '\0'; cp++; - cp = strchr(cp, '\n'); + cp = StrChr(cp, '\n'); if (cp == NULL) break; cp++; diff --git a/src/LYKeymap.c b/src/LYKeymap.c index 5c144c2a..73f6c0a0 100644 --- a/src/LYKeymap.c +++ b/src/LYKeymap.c @@ -1,4 +1,4 @@ -/* $LynxId: LYKeymap.c,v 1.108 2013/10/20 22:26:42 tom Exp $ */ +/* $LynxId: LYKeymap.c,v 1.109 2013/11/28 11:19:31 tom Exp $ */ #include <HTUtils.h> #include <LYUtils.h> #include <LYGlobalDefs.h> @@ -1361,7 +1361,7 @@ BOOLEAN LYisNonAlnumKeyname(int ch, if (ch >= 0 && (ch + 1) < KEYMAP_SIZE) { if ((ch <= 0 - || strchr("0123456789" + || StrChr("0123456789" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz", ch) == NULL) && (keymap[ch + 1] == KeyName)) { @@ -1484,7 +1484,7 @@ static void checkKeyMap(LYEditConfig * table) if (non_empty(what)) { sprintf(comment, "\t/* %s%s */", what, - ((strchr(what, '_') != 0) + ((StrChr(what, '_') != 0) ? "" : "_KEY")); } else { diff --git a/src/LYLocal.c b/src/LYLocal.c index 4ee4325b..64fc6880 100644 --- a/src/LYLocal.c +++ b/src/LYLocal.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYLocal.c,v 1.126 2013/10/12 14:51:18 tom Exp $ + * $LynxId: LYLocal.c,v 1.127 2013/11/28 11:19:31 tom Exp $ * * Routines to manipulate the local filesystem. * Written by: Rick Mallett, Carleton University @@ -1063,7 +1063,7 @@ int local_modify(DocInfo *doc, char **newpath) #endif /* OK_PERMIT */ ans = LYgetch_single(); - if (strchr("NLP", ans) != NULL) { + if (StrChr("NLP", ans) != NULL) { cp = HTfullURL_toFile(links[doc->link].lname); if (strlen(cp) >= DIRED_MAXBUF) { FREE(cp); @@ -1114,7 +1114,7 @@ static int create_file(char *current_location) if (strstr(tmpbuf->str, "//") != NULL) { HTAlert(gettext("Illegal redirection \"//\" found! Request ignored.")); } else if (strlen(tmpbuf->str) && - strchr(BadChars(), tmpbuf->str[0]) == NULL) { + StrChr(BadChars(), tmpbuf->str[0]) == NULL) { StrAllocCopy(testpath, current_location); LYAddPathSep(&testpath); @@ -1151,7 +1151,7 @@ static int create_directory(char *current_location) if (strstr(tmpbuf->str, "//") != NULL) { HTAlert(gettext("Illegal redirection \"//\" found! Request ignored.")); } else if (strlen(tmpbuf->str) && - strchr(BadChars(), tmpbuf->str[0]) == NULL) { + StrChr(BadChars(), tmpbuf->str[0]) == NULL) { StrAllocCopy(testpath, current_location); LYAddPathSep(&testpath); @@ -1543,7 +1543,7 @@ static int permit_location(char *destpath, * directories. */ if (!no_change_exec_perms - || strchr(cp + 5, 'X') == NULL + || StrChr(cp + 5, 'X') == NULL || S_ISDIR(dir_info.st_mode)) { new_mode |= (mode_t) mask; } @@ -2515,7 +2515,7 @@ void add_menu_item(char *str) /* * Conditional on tagged != NULL ? */ - if ((cp = strchr(str, ':')) != 0) { + if ((cp = StrChr(str, ':')) != 0) { *cp++ = '\0'; if (strcasecomp(str, "tag") == 0) { tmp->cond = DE_TAG; @@ -2533,17 +2533,17 @@ void add_menu_item(char *str) * Conditional on matching suffix. */ str = cp; - if ((cp = strchr(str, ':')) != 0) { + if ((cp = StrChr(str, ':')) != 0) { *cp++ = '\0'; StrAllocCopy(tmp->sfx, str); str = cp; - if ((cp = strchr(str, ':')) != 0) { + if ((cp = StrChr(str, ':')) != 0) { *cp++ = '\0'; StrAllocCopy(tmp->link, str); str = cp; - if ((cp = strchr(str, ':')) != 0) { + if ((cp = StrChr(str, ':')) != 0) { *cp++ = '\0'; StrAllocCopy(tmp->rest, str); diff --git a/src/LYMail.c b/src/LYMail.c index ec86dff5..846e62a2 100644 --- a/src/LYMail.c +++ b/src/LYMail.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYMail.c,v 1.95 2013/10/12 14:51:18 tom Exp $ + * $LynxId: LYMail.c,v 1.96 2013/11/28 11:23:37 tom Exp $ */ #include <HTUtils.h> #include <HTParse.h> @@ -94,7 +94,7 @@ static void extract_field(char **dst, if ((*(cp - 1) == '?' || *(cp - 1) == '&') && !strncasecomp(cp, keyword, len)) { cp += len; - if ((cp1 = strchr(cp, '&')) != NULL) { + if ((cp1 = StrChr(cp, '&')) != NULL) { *cp1 = '\0'; } comma_append(dst, cp); @@ -130,7 +130,7 @@ static void extract_subject(char *dst, } if (*cp) { cp += len; - if ((cp1 = strchr(cp, '&')) != NULL) { + if ((cp1 = StrChr(cp, '&')) != NULL) { *cp1 = '\0'; } if (*cp) { @@ -161,7 +161,7 @@ static void extract_body(char **dst, if ((*(cp - 1) == '?' || *(cp - 1) == '&') && !strncasecomp(cp, keyword, len)) { cp += len; - if ((cp1 = strchr(cp, '&')) != NULL) { + if ((cp1 = StrChr(cp, '&')) != NULL) { *cp1 = '\0'; } if (*cp) { @@ -172,7 +172,7 @@ static void extract_body(char **dst, StrAllocCopy(temp, cp); HTUnEscape(temp); cp0 = temp; - while ((cp = strchr(cp0, '\n')) != NULL) { + while ((cp = StrChr(cp0, '\n')) != NULL) { *cp = '\0'; if (cp > cp0) { if (*(cp - 1) == '\r') { @@ -233,9 +233,9 @@ static BOOLEAN convert_explorer(char *address) char *cp0; char *cp1; - while ((cp1 = strchr(cp, '@')) != NULL) { + while ((cp1 = StrChr(cp, '@')) != NULL) { cp1++; - if ((cp0 = strchr(cp1, ';')) != NULL) { + if ((cp0 = StrChr(cp1, ';')) != NULL) { *cp0 = ','; cp1 = cp0 + 1; } @@ -283,7 +283,7 @@ static void show_addresses(char *addresses) char *cp = addresses; char *cp1; - while ((cp1 = strchr(cp, ',')) != NULL) { + while ((cp1 = StrChr(cp, ',')) != NULL) { *cp1 = '\0'; while (*cp == ' ') cp++; @@ -457,7 +457,7 @@ static void vms_append_addrs(char **cmd, char *address, char *option) address_ptr1 = address; do { - if ((cp = strchr(address_ptr1, ',')) != NULL) { + if ((cp = StrChr(address_ptr1, ',')) != NULL) { address_ptr2 = (cp + 1); *cp = '\0'; } else { @@ -485,7 +485,7 @@ static void vms_append_addrs(char **cmd, char *address, char *option) static void remove_quotes(char *string) { while (*string != 0) { - if (strchr("\"&|", *string) != 0) + if (StrChr("\"&|", *string) != 0) *string = ' '; string++; } @@ -622,14 +622,14 @@ void mailform(const char *mailto_address, subject[0] = '\0'; self[0] = '\0'; - if ((cp = (char *) strchr(mailto_address, '\n')) != NULL) + if ((cp = StrChr(mailto_address, '\n')) != NULL) *cp = '\0'; StrAllocCopy(address, mailto_address); /* * Check for a ?searchpart. - FM */ - if ((cp = strchr(address, '?')) != NULL) { + if ((cp = StrChr(address, '?')) != NULL) { StrAllocCopy(searchpart, cp); *cp = '\0'; cp = (searchpart + 1); @@ -811,7 +811,7 @@ void mailform(const char *mailto_address, * into account. Otherwise, the actual newline characters in the content * are hex escaped. - FM */ - while ((cp = strchr(mailto_content, '\n')) != NULL) { + while ((cp = StrChr(mailto_content, '\n')) != NULL) { *cp = '\0'; i = 0; len = (int) strlen(mailto_content); @@ -947,7 +947,7 @@ void mailmsg(int cur, if (isEmpty(owner_address)) return; - if ((cp = (char *) strchr(owner_address, '\n')) != NULL) { + if ((cp = StrChr(owner_address, '\n')) != NULL) { #ifdef ALERTMAIL if (skip_parsing) return; /* invalidly defined - ignore - kw */ @@ -975,7 +975,7 @@ void mailmsg(int cur, /* * Check for a ?searchpart. - FM */ - if ((cp = strchr(address, '?')) != NULL) { + if ((cp = StrChr(address, '?')) != NULL) { StrAllocCopy(searchpart, cp); *cp = '\0'; cp = (searchpart + 1); @@ -1203,7 +1203,7 @@ void reply_by_mail(char *mail_address, /* * Check for a ?searchpart. - FM */ - if ((cp = strchr(to_address, '?')) != NULL) { + if ((cp = StrChr(to_address, '?')) != NULL) { StrAllocCopy(searchpart, cp); *cp = '\0'; cp = (searchpart + 1); @@ -1355,7 +1355,7 @@ void reply_by_mail(char *mail_address, (isPMDF == TRUE) && #endif /* VMS */ (cp = ccaddr) != NULL) { - if (strchr(cp, ',') != NULL) { + if (StrChr(cp, ',') != NULL) { LYaddstr(WITH_COPIES_TO); } else { LYaddstr(WITH_COPY_TO); @@ -1489,7 +1489,7 @@ void reply_by_mail(char *mail_address, if (body) { cp1 = body; - while ((cp = strchr(cp1, '\n')) != NULL) { + while ((cp = StrChr(cp1, '\n')) != NULL) { *cp++ = '\0'; fprintf(fd, "%s\n", cp1); cp1 = cp; @@ -1528,7 +1528,7 @@ void reply_by_mail(char *mail_address, LYrefresh(); cp1 = body; i = (LYlines - 5); - while ((cp = strchr(cp1, '\n')) != NULL) { + while ((cp = StrChr(cp1, '\n')) != NULL) { if (i <= 0) { LYaddstr(RETURN_TO_CONTINUE); LYrefresh(); diff --git a/src/LYMain.c b/src/LYMain.c index 90be6c39..7a2ef0ef 100644 --- a/src/LYMain.c +++ b/src/LYMain.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYMain.c,v 1.250 2013/10/21 20:25:19 tom Exp $ + * $LynxId: LYMain.c,v 1.251 2013/11/28 11:20:21 tom Exp $ */ #include <HTUtils.h> #include <HTTP.h> @@ -955,9 +955,9 @@ static void append_ssl_version(char **target, if (*separator == ' ') StrAllocCat(*target, ","); LYStrNCpy(SSLLibraryVersion, LYNX_SSL_VERSION, sizeof(SSLLibraryVersion) - 1); - if ((SSLcp = strchr(SSLLibraryVersion, ' ')) != NULL) { + if ((SSLcp = StrChr(SSLLibraryVersion, ' ')) != NULL) { *SSLcp++ = *separator; - if ((SSLcp = strchr(SSLcp, ' ')) != NULL) { + if ((SSLcp = StrChr(SSLcp, ' ')) != NULL) { *SSLcp = '\0'; StrAllocCat(*target, " "); StrAllocCat(*target, SSLLibraryVersion); @@ -1282,7 +1282,7 @@ int main(int argc, } #ifdef VMS LYLowerCase(lynx_temp_space); - if (strchr(lynx_temp_space, '/') != NULL) { + if (StrChr(lynx_temp_space, '/') != NULL) { if (strlen(lynx_temp_space) == 1) { StrAllocCopy(lynx_temp_space, "sys$scratch:"); } else { @@ -1292,8 +1292,8 @@ int main(int argc, FREE(temp); } } - if (strchr(lynx_temp_space, ':') == NULL && - strchr(lynx_temp_space, ']') == NULL) { + if (StrChr(lynx_temp_space, ':') == NULL && + StrChr(lynx_temp_space, ']') == NULL) { StrAllocCat(lynx_temp_space, ":"); } #else @@ -1780,7 +1780,7 @@ int main(int argc, LYTildeExpand(&lynx_save_space, TRUE); #ifdef VMS LYLowerCase(lynx_save_space); - if (strchr(lynx_save_space, '/') != NULL) { + if (StrChr(lynx_save_space, '/') != NULL) { if (strlen(lynx_save_space) == 1) { StrAllocCopy(lynx_save_space, "sys$login:"); } else { @@ -1790,8 +1790,8 @@ int main(int argc, FREE(temp); } } - if (strchr(lynx_save_space, ':') == NULL && - strchr(lynx_save_space, ']') == NULL) { + if (StrChr(lynx_save_space, ':') == NULL && + StrChr(lynx_save_space, ']') == NULL) { StrAllocCat(lynx_save_space, ":"); } #else @@ -2471,7 +2471,7 @@ static int parse_authentication(char *next_arg, if (auth_info != 0) { char *cp; - if ((cp = strchr(auth_info, ':')) != 0) { /* Pw */ + if ((cp = StrChr(auth_info, ':')) != 0) { /* Pw */ *cp++ = '\0'; /* Terminate ID */ HTUnEscape(cp); StrAllocCopy(result[1], cp); @@ -2600,7 +2600,7 @@ static int convert_to_fun(char *next_arg) StrAllocCopy(outformat, next_arg); /* not lowercased, to allow for experimentation - kw */ /*LYLowerCase(outformat); */ - if ((cp1 = strchr(outformat, ';')) != NULL) { + if ((cp1 = StrChr(outformat, ';')) != NULL) { if ((cp2 = LYstrstr(cp1, "charset")) != NULL) { cp2 += 7; while (*cp2 == ' ' || *cp2 == '=' || *cp2 == '"') @@ -3279,7 +3279,7 @@ static int scrsize_fun(char *next_arg) if (next_arg != 0) { char *cp; - if ((cp = strchr(next_arg, ',')) != 0) { + if ((cp = StrChr(next_arg, ',')) != 0) { *cp++ = '\0'; /* Terminate ID */ scrsize_x = atoi(next_arg); scrsize_y = atoi(cp); @@ -4052,7 +4052,7 @@ static void print_help_strings(const char *name, first = pad; } - if (strchr(help, '\n') == 0) { + if (StrChr(help, '\n') == 0) { fprintf(stdout, "%s", help); } else { while ((c = *help) != 0) { diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c index 7c56991a..6fa2af27 100644 --- a/src/LYMainLoop.c +++ b/src/LYMainLoop.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYMainLoop.c,v 1.229 2013/10/20 21:14:17 tom Exp $ + * $LynxId: LYMainLoop.c,v 1.230 2013/11/28 11:20:34 tom Exp $ */ #include <HTUtils.h> #include <HTAccess.h> @@ -1845,7 +1845,7 @@ static void handle_LYK_COMMENT(BOOLEAN *refresh_screen, /* * It's a ~user URL so guess user@host. - FM */ - if ((cp = strchr((temp + 1), '/')) != NULL) + if ((cp = StrChr((temp + 1), '/')) != NULL) *cp = '\0'; StrAllocCopy(address, STR_MAILTO_URL); StrAllocCat(address, (temp + 1)); @@ -1896,11 +1896,11 @@ static void handle_LYK_COMMENT(BOOLEAN *refresh_screen, } } - if (strchr(*owner_address_p, ':') != NULL) + if (StrChr(*owner_address_p, ':') != NULL) /* * Send a reply. The address is after the colon. */ - reply_by_mail(strchr(*owner_address_p, ':') + 1, + reply_by_mail(StrChr(*owner_address_p, ':') + 1, curdoc.address, NonNull(kp), id); else @@ -3535,7 +3535,7 @@ static char *urlencode(char *str) *ptr = '+'; ptr++; } else if (ch > 127 || - strchr(":/?#[]@!$&'()*+,;=", ch) != 0) { + StrChr(":/?#[]@!$&'()*+,;=", ch) != 0) { *ptr++ = '%'; *ptr++ = HEX(ch >> 4); *ptr++ = HEX(ch); @@ -6123,7 +6123,7 @@ int mainloop(void) */ cp = NULL; if (temp[len] == '/') { - if (strchr(&temp[(len + 1)], '/')) { + if (StrChr(&temp[(len + 1)], '/')) { HTSprintf0(&cp, ".%s", &temp[len]); } else { StrAllocCopy(cp, &temp[(len + 1)]); @@ -6724,7 +6724,7 @@ int mainloop(void) if (strlen(p) < (sizeof(sjis_buff) / 10)) { strcpy(temp_buff, p); - if (strchr(temp_buff, '%')) { + if (StrChr(temp_buff, '%')) { HTUnEscape(temp_buff); } str_sjis(sjis_buff, temp_buff); @@ -7251,9 +7251,9 @@ int mainloop(void) break; len2 = (int) strlen((const char *) s); e = s + len2; - while (s < e && strchr(" \t\n\r", *s)) + while (s < e && StrChr(" \t\n\r", *s)) s++; - while (s < e && strchr(" \t\n\r", e[-1])) + while (s < e && StrChr(" \t\n\r", e[-1])) e--; if (s[0] == '<' && e > s && e[-1] == '>') { s++; @@ -7274,11 +7274,11 @@ int mainloop(void) t = (unsigned char *) buf; while (s < e) { - if (strchr(" \t\n\r", *s)) { + if (StrChr(" \t\n\r", *s)) { int nl2 = 0; /* Keep whitespace without NL - file names! */ unsigned char *s1 = s; - while (strchr(" \t\n\r", *s)) { + while (StrChr(" \t\n\r", *s)) { if (!nl2 && *s == '\n') nl2 = 1; s++; diff --git a/src/LYMap.c b/src/LYMap.c index 3ec8cf78..b975ecaf 100644 --- a/src/LYMap.c +++ b/src/LYMap.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYMap.c,v 1.47 2013/05/06 00:53:46 tom Exp $ + * $LynxId: LYMap.c,v 1.48 2013/11/28 11:21:09 tom Exp $ * Lynx Client-side Image MAP Support LYMap.c * ================================== * @@ -417,7 +417,7 @@ static int LYLoadIMGmap(const char *arg, if (isLYNXIMGMAP(arg)) { address = (arg + LEN_LYNXIMGMAP); } - if (!(address && strchr(address, ':'))) { + if (!(address && StrChr(address, ':'))) { HTAlert(MISDIRECTED_MAP_REQUEST); return (HT_NOT_LOADED); } @@ -537,7 +537,7 @@ static int LYLoadIMGmap(const char *arg, } else if (non_empty(LYRequestTitle) && strcasecomp(LYRequestTitle, NO_MAP_TITLE)) { StrAllocCopy(MapTitle, LYRequestTitle); - } else if ((cp = strchr(address, '#')) != NULL) { + } else if ((cp = StrChr(address, '#')) != NULL) { StrAllocCopy(MapTitle, (cp + 1)); } if (isEmpty(MapTitle)) { diff --git a/src/LYNews.c b/src/LYNews.c index 8d0a54a6..81a362eb 100644 --- a/src/LYNews.c +++ b/src/LYNews.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYNews.c,v 1.60 2013/10/12 14:51:18 tom Exp $ + * $LynxId: LYNews.c,v 1.61 2013/11/28 11:21:09 tom Exp $ */ #include <HTUtils.h> #ifndef DISABLE_NEWS @@ -160,7 +160,7 @@ char *LYNewsPost(char *newsgroups, StrAllocCat(References, ">"); } HTUnEscape(References); - if (!((cp = strchr(References, '@')) && cp > References + 1 && + if (!((cp = StrChr(References, '@')) && cp > References + 1 && isalnum(UCH(cp[1])))) { FREE(References); } @@ -284,7 +284,7 @@ char *LYNewsPost(char *newsgroups, strcpy(p + 1, "LYNX_ETC.TXT"); if ((fp = fopen(fname, TXT_R)) != NULL) { if (fgets(user_input, (int) sizeof(user_input), fp) != NULL) { - if ((org = strchr(user_input, '\n')) != NULL) { + if ((org = StrChr(user_input, '\n')) != NULL) { *org = '\0'; } if (user_input[0] != '\0') { diff --git a/src/LYOptions.c b/src/LYOptions.c index d725f0d2..077379dd 100644 --- a/src/LYOptions.c +++ b/src/LYOptions.c @@ -1,4 +1,4 @@ -/* $LynxId: LYOptions.c,v 1.163 2013/10/24 00:08:39 tom Exp $ */ +/* $LynxId: LYOptions.c,v 1.164 2013/10/25 01:10:17 tom Exp $ */ #include <HTUtils.h> #include <HTFTP.h> #include <HTTP.h> /* 'reloading' flag */ @@ -2497,10 +2497,21 @@ static BOOLEAN GetOptValues(OptValues * table, char *value, } #ifdef USE_COLOR_STYLE +#ifdef LY_FIND_LEAKS +static void free_colorstyle_leaks(void) +{ + FREE(color_style_values); +} +#endif + void build_lss_enum(HTList *list) { int count = HTList_count(list); +#ifdef LY_FIND_LEAKS + atexit(free_colorstyle_leaks); +#endif + FREE(color_style_values); if (count != 0) { LSS_NAMES *obj; diff --git a/src/LYPrettySrc.c b/src/LYPrettySrc.c index 38e342d8..974b9fd9 100644 --- a/src/LYPrettySrc.c +++ b/src/LYPrettySrc.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYPrettySrc.c,v 1.28 2013/05/06 00:53:30 tom Exp $ + * $LynxId: LYPrettySrc.c,v 1.29 2013/11/28 11:21:09 tom Exp $ * * HTML source syntax highlighting * by Vlad Harchev <hvv@hippo.ru> @@ -424,7 +424,7 @@ void HTMLSRC_init_caches(int dont_exit) CTRACE2(TRACE_CFG, (tfp, "parsing lexeme %d: %s\n", i + 1, buf)); - if ((p = strchr(buf, ':')) != 0) + if ((p = StrChr(buf, ':')) != 0) *p = '\0'; if (!html_src_parse_tagspec(buf, (HTlexeme) i, diff --git a/src/LYPrint.c b/src/LYPrint.c index f5543ffe..781eca02 100644 --- a/src/LYPrint.c +++ b/src/LYPrint.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYPrint.c,v 1.101 2013/10/13 20:23:07 tom Exp $ + * $LynxId: LYPrint.c,v 1.102 2013/11/28 11:21:09 tom Exp $ */ #include <HTUtils.h> #include <HTAccess.h> @@ -548,10 +548,10 @@ static void send_file_to_mail(DocInfo *newdoc, StrAllocCat(subject, newdoc->address); } #if USE_VMS_MAILER - if (strchr(user_response->str, '@') && - !strchr(user_response->str, ':') && - !strchr(user_response->str, '%') && - !strchr(user_response->str, '"')) { + if (StrChr(user_response->str, '@') && + !StrChr(user_response->str, ':') && + !StrChr(user_response->str, '%') && + !StrChr(user_response->str, '"')) { char *temp = 0; HTSprintf0(&temp, mail_adrs, user_response->str); diff --git a/src/LYReadCFG.c b/src/LYReadCFG.c index 4adbd664..b4008041 100644 --- a/src/LYReadCFG.c +++ b/src/LYReadCFG.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYReadCFG.c,v 1.178 2013/10/23 21:26:29 tom Exp $ + * $LynxId: LYReadCFG.c,v 1.181 2013/11/28 11:21:09 tom Exp $ */ #ifndef NO_RULES #include <HTRules.h> @@ -648,7 +648,9 @@ static int color_fun(char *value) parse_color(value); return 0; } +#endif +#ifdef USE_COLOR_STYLE static int lynx_lss_file_fun(char *value) { add_to_lss_list(value, NULL); @@ -752,9 +754,9 @@ static int keymap_fun(char *key) { char *func, *efunc; - if ((func = strchr(key, ':')) != NULL) { + if ((func = StrChr(key, ':')) != NULL) { *func++ = '\0'; - efunc = strchr(func, ':'); + efunc = StrChr(func, ':'); /* Allow comments on the ends of key remapping lines. - DT */ /* Allow third field for line-editor action. - kw */ if (efunc == func) { /* have 3rd field, but 2nd field empty */ @@ -979,20 +981,20 @@ static int suffix_fun(char *value) double q = 1.0; if ((strlen(value) < 3) - || (NULL == (mime_type = strchr(value, ':')))) { + || (NULL == (mime_type = StrChr(value, ':')))) { CTRACE((tfp, "Invalid SUFFIX:%s ignored.\n", value)); return 0; } *mime_type++ = '\0'; if (*mime_type) { - if ((parsed = strchr(mime_type, ':')) != NULL) { + if ((parsed = StrChr(mime_type, ':')) != NULL) { *parsed++ = '\0'; - if ((sq = strchr(parsed, ':')) != NULL) { + if ((sq = StrChr(parsed, ':')) != NULL) { *sq++ = '\0'; - if ((description = strchr(sq, ':')) != NULL) { + if ((description = StrChr(sq, ':')) != NULL) { *description++ = '\0'; - if ((p = strchr(sq, ':')) != NULL) + if ((p = StrChr(sq, ':')) != NULL) *p = '\0'; LYTrimTail(description); } @@ -1096,7 +1098,7 @@ static int viewer_fun(char *value) mime_type = value; if ((strlen(value) < 3) - || (NULL == (viewer = strchr(mime_type, ':')))) + || (NULL == (viewer = StrChr(mime_type, ':')))) return 0; *viewer++ = '\0'; @@ -1262,7 +1264,7 @@ static int parse_html_src_spec(HTlexeme lexeme_code, char *value, #define BS() html_src_bad_syntax(value,option_name) - ts2 = strchr(value, ':'); + ts2 = StrChr(value, ':'); if (!ts2) BS(); @@ -1310,7 +1312,7 @@ static int psrcspec_fun(char *s) int found; - e = strchr(s, ':'); + e = StrChr(s, ':'); if (!e) { CTRACE((tfp, "bad format of PRETTYSRC_SPEC setting value, ignored %s\n", @@ -1382,7 +1384,7 @@ static int screen_size_fun(char *value) { char *cp; - if ((cp = strchr(value, ',')) != 0) { + if ((cp = StrChr(value, ',')) != 0) { *cp++ = '\0'; /* Terminate ID */ scrsize_x = atoi(value); scrsize_y = atoi(cp); @@ -1791,7 +1793,7 @@ void free_lynx_cfg(void) case CONF_ENV: if (q->str_value != 0) { char *name = *(q->str_value); - char *eqls = strchr(name, '='); + char *eqls = StrChr(name, '='); if (eqls != 0) { *eqls = 0; @@ -1873,7 +1875,9 @@ static char *actual_filename(const char *cfg_filename, *LYPathLeaf(my_filename) = '\0'; StrAllocCat(my_filename, cfg_filename); if (!LYCanReadFile(my_filename)) { - StrAllocCopy(my_filename, cfg_filename); + StrAllocCopy(my_filename, + LYFindConfigFile(cfg_filename, + dft_filename)); } } } @@ -2103,7 +2107,7 @@ static void do_read_cfg(const char *cfg_filename, continue; /* Significant lines are of the form KEYWORD:WHATEVER */ - if ((value = strchr(name, ':')) == 0) { + if ((value = StrChr(name, ':')) == 0) { /* fprintf (stderr, "Bad line-- no :\n"); */ CTRACE((tfp, "LYReadCFG: missing ':' %s\n", name)); continue; @@ -2121,7 +2125,7 @@ static void do_read_cfg(const char *cfg_filename, */ if ((cp = strrchr(value, ':')) == 0) cp = value; - if ((cp = strchr(cp, '#')) != 0) { + if ((cp = StrChr(cp, '#')) != 0) { cp--; if (isspace(UCH(*cp))) *cp = 0; @@ -2193,7 +2197,7 @@ static void do_read_cfg(const char *cfg_filename, LYLocalFileToURL(&url, my_file); FREE(my_file); StrAllocCopy(cp1, value); - if (strchr(value, '&') || strchr(value, '<')) { + if (StrChr(value, '&') || StrChr(value, '<')) { LYEntify(&cp1, TRUE); } @@ -2282,7 +2286,7 @@ static void do_read_cfg(const char *cfg_filename, default: if (fp0 != 0) { - if (strchr(value, '&') || strchr(value, '<')) { + if (StrChr(value, '&') || StrChr(value, '<')) { char *cp1 = NULL; StrAllocCopy(cp1, value); @@ -2519,7 +2523,7 @@ int lynx_cfg_infopage(DocInfo *newdoc) LYLocalFileToURL(&temp, lynx_cfg_file); StrAllocCopy(cp1, lynx_cfg_file); - if (strchr(lynx_cfg_file, '&') || strchr(lynx_cfg_file, '<')) { + if (StrChr(lynx_cfg_file, '&') || StrChr(lynx_cfg_file, '<')) { LYEntify(&cp1, TRUE); } fprintf(fp0, "\n #<em>%s <a href=\"%s\">%s</a></em>\n", diff --git a/src/LYSession.c b/src/LYSession.c index 37b47e0f..99884d1b 100644 --- a/src/LYSession.c +++ b/src/LYSession.c @@ -1,4 +1,4 @@ -/* $LynxId: LYSession.c,v 1.8 2012/02/09 20:00:59 tom Exp $ */ +/* $LynxId: LYSession.c,v 1.9 2013/11/28 11:21:22 tom Exp $ */ #include <LYSession.h> @@ -93,7 +93,7 @@ void RestoreSession(void) LYTrimNewline(buffer); if (*buffer == '/') { #ifdef SEARCH_OUT_SESSION - if ((value1 = strchr(buffer, ' ')) == 0) { + if ((value1 = StrChr(buffer, ' ')) == 0) { continue; } else { value1++; @@ -102,7 +102,7 @@ void RestoreSession(void) #endif /* SEARCH_OUT_SESSION */ } else if (*buffer == 'g') { #ifdef GOTOURL_OUT_SESSION - if ((value1 = strchr(buffer, ' ')) == 0) + if ((value1 = StrChr(buffer, ' ')) == 0) continue; else { value1++; @@ -111,19 +111,19 @@ void RestoreSession(void) #endif /* GOTOURL_OUT_SESSION */ } else if (*buffer == 'h') { #ifdef HISTORY_OUT_SESSION - if ((rsline = strchr(buffer, ' ')) == 0) + if ((rsline = StrChr(buffer, ' ')) == 0) continue; else { rsline++; - if ((linktext = strchr(rsline, ' ')) == 0) + if ((linktext = StrChr(rsline, ' ')) == 0) continue; else *linktext++ = 0; - if ((value1 = strchr(linktext, ' ')) == 0) + if ((value1 = StrChr(linktext, ' ')) == 0) continue; else *value1++ = 0; - if ((value2 = strchr(value1, '\t')) != 0) { + if ((value2 = StrChr(value1, '\t')) != 0) { *value2++ = 0; doc.line = atoi(rsline); doc.link = atoi(linktext); @@ -135,15 +135,15 @@ void RestoreSession(void) #endif /* HISTORY_OUT_SESSION */ } else if (*buffer == 'V') { #ifdef VLINK_OUT_SESSION - if ((rslevel = strchr(buffer, ' ')) == 0) + if ((rslevel = StrChr(buffer, ' ')) == 0) continue; else { rslevel++; - if ((value1 = strchr(rslevel, ' ')) == 0) + if ((value1 = StrChr(rslevel, ' ')) == 0) continue; else *value1++ = 0; - if ((value2 = strchr(value1, '\t')) != 0) { + if ((value2 = StrChr(value1, '\t')) != 0) { *value2++ = 0; StrAllocCopy(doc.address, value1); StrAllocCopy(doc.title, value2); diff --git a/src/LYStrings.c b/src/LYStrings.c index ce537668..491d2079 100644 --- a/src/LYStrings.c +++ b/src/LYStrings.c @@ -1,4 +1,4 @@ -/* $LynxId: LYStrings.c,v 1.256 2013/10/20 21:31:45 tom Exp $ */ +/* $LynxId: LYStrings.c,v 1.258 2013/11/28 11:57:39 tom Exp $ */ #include <HTUtils.h> #include <HTCJK.h> #include <UCAux.h> @@ -908,8 +908,8 @@ void ena_csi(int flag) #if SLANG_VERSION < 20000 #define expand_substring(target, first, last, final) \ (SLexpand_escaped_string(target, \ - (char *)first, \ - (char *)last), 1) + DeConst(first), \ + DeConst(last), 1) static int SLang_get_error(void) { return SLang_Error; @@ -919,8 +919,8 @@ int LY_Slang_UTF8_Mode = 0; #define expand_substring(target, first, last, final) \ (SLexpand_escaped_string(target, \ - (char *)first, \ - (char *)last, \ + DeConst(first), \ + DeConst(last), \ LY_Slang_UTF8_Mode), 1) #endif @@ -1104,7 +1104,7 @@ static BOOLEAN expand_substring(char *target, case '^': ch = *first++; if (ch == LPAREN) { - const char *s = strchr(first, RPAREN); + const char *s = StrChr(first, RPAREN); char *was = target; if (s == 0) @@ -1195,7 +1195,7 @@ int map_string_to_keysym(const char *str, int *keysym) *keysym = -1; if (strncasecomp(str, "LAC:", 4) == 0) { - char *other = strchr(str + 4, ':'); + char *other = StrChr(str + 4, ':'); if (other) { int othersym = lecname_to_lec(other + 1); @@ -5399,7 +5399,7 @@ int LYscanFloat2(const char **source, float *result) src = LYSkipCBlanks(src); *result = 0.0; - if (strchr(src, '.') != 0) { + if (StrChr(src, '.') != 0) { long frc_part = 0; float scale = 1.0; @@ -5424,7 +5424,7 @@ int LYscanFloat2(const char **source, float *result) src = temp; } } - if (src != 0 && *src != '\0' && strchr(" \t+", *src) == 0) { + if (src != 0 && *src != '\0' && StrChr(" \t+", *src) == 0) { char *extra = (char *) malloc(2 + strlen(src)); if (extra != 0) { @@ -6042,7 +6042,7 @@ char *LYSafeGets(char **target, while (fgets(buffer, (int) sizeof(buffer), fp) != NULL) { if (*buffer) result = StrAllocCat(result, buffer); - if (strchr(buffer, '\n') != 0) + if (StrChr(buffer, '\n') != 0) break; } if (ferror(fp)) { diff --git a/src/LYStyle.c b/src/LYStyle.c index 669620dd..41f8d473 100644 --- a/src/LYStyle.c +++ b/src/LYStyle.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYStyle.c,v 1.87 2013/10/23 23:58:52 tom Exp $ + * $LynxId: LYStyle.c,v 1.94 2013/11/28 11:37:02 tom Exp $ * * character level styles for Lynx * (c) 1996 Rob Partington -- donated to the Lyncei (if they want it :-) @@ -34,7 +34,6 @@ #ifdef USE_COLOR_STYLE static HTList *list_of_lss_files; -static char default_lss_file[] = LYNX_LSS_FILE; /* because curses isn't started when we parse the config file, we * need to remember the STYLE: lines we encounter and parse them @@ -113,6 +112,8 @@ static unsigned char our_pairs[2] [MAX_COLOR + 1] [MAX_COLOR + 1]; +static void style_initialiseHashTable(void); + static bucket *new_bucket(const char *name) { bucket *result = typecalloc(bucket); @@ -157,7 +158,7 @@ static void parse_either(const char *attrs, char *to_free = temp_attrs; while (*temp_attrs != '\0') { - char *next = strchr(temp_attrs, '+'); + char *next = StrChr(temp_attrs, '+'); char save = (char) ((next != NULL) ? *next : '\0'); if (next == NULL) @@ -333,7 +334,7 @@ static void parse_style(char *param) return; TrimLowercase(buffer); - if ((tmp = strchr(buffer, ':')) == 0) { + if ((tmp = StrChr(buffer, ':')) == 0) { fprintf(stderr, gettext("\ Syntax Error parsing style in lss file:\n\ [%s]\n\ @@ -346,7 +347,7 @@ where OBJECT is one of EM,STRONG,B,I,U,BLINK etc.\n\n"), buffer); element = buffer; mono = tmp + 1; - tmp = strchr(mono, ':'); + tmp = StrChr(mono, ':'); if (!tmp) { fg = "nocolor"; @@ -354,7 +355,7 @@ where OBJECT is one of EM,STRONG,B,I,U,BLINK etc.\n\n"), buffer); } else { *tmp = '\0'; fg = tmp + 1; - tmp = strchr(fg, ':'); + tmp = StrChr(fg, ':'); if (!tmp) bg = "default"; else { @@ -412,6 +413,32 @@ static void style_deleteStyleList(void) lss_styles = NULL; } +#ifdef LY_FIND_LEAKS +static void free_colorstyle_leaks(void) +{ + LSS_NAMES *obj; + + while ((obj = HTList_objectAt(list_of_lss_files, 0)) != 0) { + if (HTList_unlinkObject(list_of_lss_files, obj)) { + FREE(obj->given); + FREE(obj->actual); + FREE(obj); + } else { + break; + } + } + HTList_delete(list_of_lss_files); +} +#endif + +static void free_colorstylestuff(void) +{ + style_initialiseHashTable(); + style_deleteStyleList(); + memset(our_pairs, 0, sizeof(our_pairs)); + FreeCachedStyles(); +} + /* Set all the buckets in the hash table to be empty */ static void style_initialiseHashTable(void) { @@ -431,6 +458,7 @@ static void style_initialiseHashTable(void) firsttime = 0; #ifdef LY_FIND_LEAKS atexit(free_colorstylestuff); + atexit(free_colorstyle_leaks); #endif } s_alink = hash_code("alink"); @@ -446,14 +474,6 @@ static void style_initialiseHashTable(void) #endif } -static void free_colorstylestuff(void) -{ - style_initialiseHashTable(); - style_deleteStyleList(); - memset(our_pairs, 0, sizeof(our_pairs)); - FreeCachedStyles(); -} - /* * Initialise the default style sheet to match the vanilla-curses lynx. */ @@ -817,82 +837,7 @@ void update_color_style(void) static char *find_lss_file(const char *nominal) { - const char *dftfile = default_lss_file; - char *result = 0; - char *path = 0; - char *head = 0; - char *leaf; - char *item; - - if (non_empty(nominal)) { - StrAllocCopy(result, nominal); - - /* - * Look for it in as-is - first expanding any tilde. - */ - LYTildeExpand(&result, TRUE); - if (!LYCanReadFile(result)) { - const char *cfg_path; - char *list = 0; - BOOLEAN found = FALSE; - - /* - * Now try in the config-path. - */ - if ((cfg_path = LYGetEnv("LYNX_CFG_PATH")) == NULL) - cfg_path = LYNX_CFG_PATH; - - StrAllocCopy(list, cfg_path); - path = list; - while ((item = LYstrsep(&path, PATH_SEPARATOR)) != 0) { - if (isEmpty(item)) - continue; - HTSprintf0(&result, "%s%s%s", item, FILE_SEPARATOR, nominal); - LYTildeExpand(&result, TRUE); - if (LYCanReadFile(result)) { - found = TRUE; - break; - } - } - FREE(list); - - if (!found) { - /* - * If not, try finding it in the same directory as the - * compiled-in location of the default file. - */ - StrAllocCopy(head, dftfile); - if (strcmp(nominal, dftfile) && - (leaf = LYPathLeaf(head)) != head) { - - head[leaf - head] = '\0'; - StrAllocCopy(result, head); - StrAllocCat(result, nominal); - - if (!LYCanReadFile(result)) { - FREE(result); - } - } -#ifdef USE_PROGRAM_DIR - else { - /* - * Finally, try in the same directory as the executable. - */ - StrAllocCopy(result, program_dir); - LYAddPathSep(&result); - StrAllocCat(result, nominal); - LYTildeExpand(&result, TRUE); - if (!LYCanReadFile(result)) { - FREE(result); - } - } -#endif - } - } - - } - FREE(head); - return result; + return LYFindConfigFile(nominal, LYNX_LSS_FILE); } /* @@ -905,16 +850,14 @@ void add_to_lss_list(const char *source, const char *resolved) BOOLEAN found = FALSE; int position = 0; +#ifdef LY_FIND_LEAKS + atexit(free_colorstyle_leaks); +#endif + CTRACE((tfp, "add_to_lss_list(\"%s\", \"%s\")\n", NonNull(source), NonNull(resolved))); - obj = typecalloc(LSS_NAMES); - if (obj == NULL) - outofmem(__FILE__, "add_to_lss_list"); - - StrAllocCopy(obj->given, source); - StrAllocCopy(obj->actual, resolved); if (list_of_lss_files == 0) { list_of_lss_files = HTList_new(); } @@ -930,6 +873,12 @@ void add_to_lss_list(const char *source, const char *resolved) } if (!found) { + obj = typecalloc(LSS_NAMES); + if (obj == NULL) + outofmem(__FILE__, "add_to_lss_list"); + + StrAllocCopy(obj->given, source); + StrAllocCopy(obj->actual, resolved); HTList_appendObject(list_of_lss_files, obj); } } @@ -973,7 +922,7 @@ void init_color_styles(char **from_cmdline, const char *default_styles) (cp = LYGetEnv("lynx_lss")) != NULL) { lynx_lss_file = find_lss_file(cp); } else { - lynx_lss_file = find_lss_file(cp = default_lss_file); + lynx_lss_file = find_lss_file(cp = DeConst(LYNX_LSS_FILE)); } CTRACE1((tfp, "init_color_styles(%s)\n", NonNull(lynx_lss_file))); diff --git a/src/LYUpload.c b/src/LYUpload.c index b65c0e12..20cfd5a3 100644 --- a/src/LYUpload.c +++ b/src/LYUpload.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYUpload.c,v 1.39 2013/10/12 14:52:04 tom Exp $ + * $LynxId: LYUpload.c,v 1.40 2013/11/28 11:22:34 tom Exp $ * * Routines to upload files to the local filesystem. * Created by: Rick Mallett, Carleton University @@ -97,7 +97,7 @@ int LYUpload(char *line) if (strstr(tmpbuf, "../") != NULL) { HTAlert(gettext("Illegal redirection \"../\" found! Request ignored.")); goto cancelled; - } else if (strchr(tmpbuf, '/') != NULL) { + } else if (StrChr(tmpbuf, '/') != NULL) { HTAlert(gettext("Illegal character \"/\" found! Request ignored.")); goto cancelled; } else if (tmpbuf[0] == '~') { diff --git a/src/LYUtils.c b/src/LYUtils.c index f2aa60cf..0a1a9141 100644 --- a/src/LYUtils.c +++ b/src/LYUtils.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYUtils.c,v 1.257 2013/10/23 22:14:03 tom Exp $ + * $LynxId: LYUtils.c,v 1.261 2013/11/28 11:35:34 tom Exp $ */ #include <HTUtils.h> #include <HTTCP.h> @@ -407,7 +407,7 @@ void LYFreeHilites(int first, int last) void LYSetHilite(int cur, const char *text) { - links[cur].list.hl_base.hl_text = (char *) text; + links[cur].list.hl_base.hl_text = DeConst(text); links[cur].list.hl_len = (short) ((text != NULL) ? 1 : 0); FREE(links[cur].list.hl_info); } @@ -1415,7 +1415,7 @@ void statusline(const char *text) /* "LYNXDOWNLOAD://Method=-1/File=%s/SugFile=%s%s\">Save to disk</a>\n" */ LYStrNCpy(text_buff, text, sizeof(text_buff) - 1); - p = strchr(text_buff, '\n'); + p = StrChr(text_buff, '\n'); if (p) *p = '\0'; @@ -2069,7 +2069,7 @@ BOOLEAN LYisLocalFile(const char *filename) return NO; } - if ((cp = strchr(host, ':')) != NULL) + if ((cp = StrChr(host, ':')) != NULL) *cp = '\0'; if ((acc_method = HTParse(filename, "", PARSE_ACCESS))) { @@ -2105,7 +2105,7 @@ BOOLEAN LYisLocalHost(const char *filename) return NO; } - if ((cp = strchr(host, ':')) != NULL) + if ((cp = StrChr(host, ':')) != NULL) *cp = '\0'; if ((LYSameFilename(host, "localhost") || @@ -2187,7 +2187,7 @@ BOOLEAN LYisLocalAlias(const char *filename) return NO; } - if ((cp = strchr(host, ':')) != NULL) + if ((cp = StrChr(host, ':')) != NULL) *cp = '\0'; while (NULL != (alias = (char *) HTList_nextObject(cur))) { @@ -2231,8 +2231,8 @@ UrlTypes LYCheckForProxyURL(char *filename) * Check for a colon, and if present, * see if we have proxying set up. */ - if ((cp1 = strchr((cp + 1), ':')) != NULL) { - if ((cp2 = strchr((cp + 1), '/')) != NULL && cp2 < cp1) + if ((cp1 = StrChr((cp + 1), ':')) != NULL) { + if ((cp2 = StrChr((cp + 1), '/')) != NULL && cp2 < cp1) return (NOT_A_URL_TYPE); *cp1 = '\0'; cp2 = NULL; @@ -2318,7 +2318,7 @@ UrlTypes is_url(char *filename) * Can't be a URL if it lacks a colon and if it starts with '[' it's * probably IPv6 adress. */ - if (NULL == strchr(cp, ':') || cp[0] == '[') + if (NULL == StrChr(cp, ':') || cp[0] == '[') return (result); /* @@ -2501,7 +2501,7 @@ UrlTypes is_url(char *filename) default: if (limit >= 3 - && ((cp1 = strchr(cp + 3, ':')) == NULL + && ((cp1 = StrChr(cp + 3, ':')) == NULL || !DoubleHtmlSep(cp1 + 1))) { /* * If it doesn't contain "://", and it's not one of the the @@ -2532,7 +2532,7 @@ UrlTypes is_url(char *filename) case 'g': if (CompareType(cp, STR_GOPHER_URL, LEN_GOPHER_URL)) { if (strlen(cp) >= 11 - && (cp1 = strchr(cp + 11, '/')) != NULL) { + && (cp1 = StrChr(cp + 11, '/')) != NULL) { if (TOUPPER(*(cp1 + 1)) == 'H' || *(cp1 + 1) == 'w') /* if this is a gopher html type */ @@ -2650,7 +2650,7 @@ BOOLEAN LYFixCursesOnForAccess(const char *addr, isRLOGIN_URL(addr) || isTN3270_URL(addr) || (!isGOPHER_URL(addr) && - (cp1 = strchr(addr + 11, '/')) != NULL && + (cp1 = StrChr(addr + 11, '/')) != NULL && (*(cp1 + 1) == 'T' || *(cp1 + 1) == '8')))) { /* * If actual access that will be done is ok with curses off, then @@ -2704,12 +2704,12 @@ BOOLEAN LYCanDoHEAD(const char *address) char *temp = HTParse(address, "", PARSE_PATH); char *cp = strrchr(temp, '/'); - if (strchr((cp ? cp : temp), '@') != NULL) { + if (StrChr((cp ? cp : temp), '@') != NULL) { FREE(temp0); FREE(temp); return TRUE; } - if (cp && isdigit(UCH(cp[1])) && strchr(cp, '-') == NULL) { + if (cp && isdigit(UCH(cp[1])) && StrChr(cp, '-') == NULL) { FREE(temp0); FREE(temp); return TRUE; @@ -2826,6 +2826,85 @@ BOOLEAN LYCanReadFile(const char *filename) return result; } +char *LYFindConfigFile(const char *nominal, const char *dftfile) +{ + char *result = 0; + char *path = 0; + char *head = 0; + char *leaf; + char *item; + + if (non_empty(nominal)) { + StrAllocCopy(result, nominal); + + /* + * Look for it in as-is - first expanding any tilde. + */ + LYTildeExpand(&result, TRUE); + if (!LYCanReadFile(result)) { + const char *cfg_path; + char *list = 0; + BOOLEAN found = FALSE; + + /* + * Now try in the config-path. + */ + if ((cfg_path = LYGetEnv("LYNX_CFG_PATH")) == NULL) + cfg_path = LYNX_CFG_PATH; + + StrAllocCopy(list, cfg_path); + path = list; + while ((item = LYstrsep(&path, PATH_SEPARATOR)) != 0) { + if (isEmpty(item)) + continue; + HTSprintf0(&result, "%s%s%s", item, FILE_SEPARATOR, nominal); + LYTildeExpand(&result, TRUE); + if (LYCanReadFile(result)) { + found = TRUE; + break; + } + } + FREE(list); + + if (!found) { + /* + * If not found, try finding it in the same directory as the + * compiled-in location of the default file. + */ + StrAllocCopy(head, dftfile); + if (strcmp(nominal, dftfile) && + (leaf = LYPathLeaf(head)) != head) { + + head[leaf - head] = '\0'; + StrAllocCopy(result, head); + StrAllocCat(result, nominal); + + if (!LYCanReadFile(result)) { + FREE(result); + } + } +#ifdef USE_PROGRAM_DIR + else { + /* + * Finally, try in the same directory as the executable. + */ + StrAllocCopy(result, program_dir); + LYAddPathSep(&result); + StrAllocCat(result, nominal); + LYTildeExpand(&result, TRUE); + if (!LYCanReadFile(result)) { + FREE(result); + } + } +#endif + } + } + + } + FREE(head); + return result; +} + /* * Remove backslashes from any string. */ @@ -3228,7 +3307,7 @@ void change_sug_filename(char *fname) /* * Trim off VMS device and/or directory specs, if present. */ - if ((cp = strchr(fname, '[')) != NULL && + if ((cp = StrChr(fname, '[')) != NULL && (cp1 = strrchr(cp, ']')) != NULL && strlen(cp1) > 1) { cp1++; for (cp = fname; *cp1 != '\0'; cp1++) { @@ -3321,18 +3400,18 @@ void change_sug_filename(char *fname) if ((dot = strrchr(fname, '.')) != NULL) { if (TOUPPER(fname[j]) == 'Z') { if ((fname[j - 1] == '.') && - (((cp = strchr(fname, '.')) != NULL) && cp < dot)) { + (((cp = StrChr(fname, '.')) != NULL) && cp < dot)) { *dot = '_'; dot = strrchr(fname, '.'); } else if (((TOUPPER(fname[j - 1]) == 'G') && fname[j - 2] == '.') && - (((cp = strchr(fname, '.')) != NULL) && cp < dot)) { + (((cp = StrChr(fname, '.')) != NULL) && cp < dot)) { *dot = '-'; dot = strrchr(fname, '.'); } } cp = fname; - while ((cp = strchr(cp, '.')) != NULL && cp < dot) { + while ((cp = StrChr(cp, '.')) != NULL && cp < dot) { *cp = '_'; } @@ -3501,7 +3580,7 @@ static int fmt_tempname(char *result, if (strlen(leaf) > 8) leaf[8] = 0; if (strlen(suffix) > 4 || *suffix != '.') { - const char *tail = strchr(suffix, '.'); + const char *tail = StrChr(suffix, '.'); if (tail == 0) tail = suffix + strlen(suffix); @@ -4070,7 +4149,7 @@ void LYConvertToURL(char **AllocatedString, * assume the rest of the path, if any, has SHELL syntax. */ StrAllocCat(*AllocatedString, HTVMS_wwwName(Home_Dir())); - if ((cp = strchr(old_string, '/')) != NULL) { + if ((cp = StrChr(old_string, '/')) != NULL) { /* * Append rest of path, if present, skipping "user" if "~user" * was entered, simplifying, and eliminating any residual @@ -4092,12 +4171,12 @@ void LYConvertToURL(char **AllocatedString, /* * We found the file. Convert to a URL pathspec. */ - if ((cp = strchr(file_name, ';')) != NULL) { + if ((cp = StrChr(file_name, ';')) != NULL) { *cp = '\0'; } LYLowerCase(file_name); StrAllocCat(*AllocatedString, HTVMS_wwwName(file_name)); - if ((cp = strchr(old_string, ';')) != NULL) { + if ((cp = StrChr(old_string, ';')) != NULL) { StrAllocCat(*AllocatedString, cp); } if (fragment != NULL) { @@ -4128,8 +4207,8 @@ void LYConvertToURL(char **AllocatedString, * if we can't rule out a bad VMS path. */ fragment = NULL; - if (strchr(old_string, '[') || - ((cp = strchr(old_string, ':')) != NULL && + if (StrChr(old_string, '[') || + ((cp = StrChr(old_string, ':')) != NULL && !isdigit(UCH(cp[1]))) || !LYExpandHostForURL(&old_string, URLDomainPrefixes, @@ -4165,8 +4244,8 @@ void LYConvertToURL(char **AllocatedString, restorePoundSelector(fragment); fragment = NULL; - if (strchr(old_string, '[') || - ((cp = strchr(old_string, ':')) != NULL && + if (StrChr(old_string, '[') || + ((cp = StrChr(old_string, ':')) != NULL && !isdigit(UCH(cp[1]))) || !LYExpandHostForURL(&old_string, URLDomainPrefixes, @@ -4288,7 +4367,7 @@ void LYConvertToURL(char **AllocatedString, /* especially when we really have file://localhost/ */ /* at the beginning. To avoid any confusion we allow */ /* escaping the path if URL specials % or # present. */ - if (strchr(temp, '#') == NULL && strchr(temp, '%') == NULL) + if (StrChr(temp, '#') == NULL && StrChr(temp, '%') == NULL) StrAllocCopy(cp, temp); else cp = HTEscape(temp, URL_PATH); @@ -4345,8 +4424,8 @@ void LYConvertToURL(char **AllocatedString, old_string, *AllocatedString)); is_local = TRUE; - } else if (strchr(curdir, '#') != NULL || - strchr(curdir, '%') != NULL) { + } else if (StrChr(curdir, '#') != NULL || + StrChr(curdir, '%') != NULL) { /* * If PWD has some unusual characters, construct a filename * in temp where those are escaped. This is mostly to @@ -4459,7 +4538,7 @@ void LYConvertToURL(char **AllocatedString, * lead slash. - FM */ StrAllocCat(*AllocatedString, wwwName(Home_Dir())); - if ((cp = strchr((old_string + 1), '/')) != NULL) { + if ((cp = StrChr((old_string + 1), '/')) != NULL) { /* * Append rest of path, if present, skipping "user" if "~user" * was entered, simplifying, and eliminating any residual @@ -4583,7 +4662,7 @@ BOOLEAN LYExpandHostForURL(char **AllocatedString, * filling in the Host[:port] field. - FM */ StrAllocCopy(Str, *AllocatedString); - if ((Path = strchr(Str, '/')) != NULL) { + if ((Path = StrChr(Str, '/')) != NULL) { /* * Have a path. Any fragment should already be included in Path. - FM */ @@ -4602,7 +4681,7 @@ BOOLEAN LYExpandHostForURL(char **AllocatedString, * field after filling in the host field. - FM */ if ((StrColon = strrchr(Str, ':')) != NULL && - isdigit(UCH(StrColon[1])) && strchr(StrColon, ']') == NULL) { + isdigit(UCH(StrColon[1])) && StrChr(StrColon, ']') == NULL) { if (StrColon == Str) { goto cleanup; } @@ -4803,7 +4882,7 @@ BOOLEAN LYExpandHostForURL(char **AllocatedString, * the original string with the expanded Host[:port] field included. - FM */ if (GotHost) { - if (StrColon && strchr(Host, ':') == NULL) { + if (StrColon && StrChr(Host, ':') == NULL) { *StrColon = ':'; StrAllocCat(Host, StrColon); } @@ -5244,7 +5323,7 @@ char *LYPathLeaf(char *pathname) int n; for (leaf = 0, n = strlen(pathname) - 1; n >= 0; n--) { - if (strchr("\\/:", pathname[n]) != 0) { + if (StrChr("\\/:", pathname[n]) != 0) { leaf = pathname + n + 1; break; } @@ -5308,7 +5387,7 @@ BOOLEAN LYPathOffHomeOK(char *fbuffer, if (LYIsTilde(cp[0])) { if (LYIsPathSep(cp[1])) { if (cp[2] != '\0') { - if (strchr((cp + 2), '/') != NULL) { + if (StrChr((cp + 2), '/') != NULL) { /* * Convert "~/subdir(s)/file" to "./subdir(s)/file". - FM */ @@ -5327,10 +5406,10 @@ BOOLEAN LYPathOffHomeOK(char *fbuffer, return (FALSE); } } else if ((*(cp + 1) != '\0') && - (cp1 = strchr((cp + 1), '/')) != NULL) { + (cp1 = StrChr((cp + 1), '/')) != NULL) { cp = (cp1 - 1); if (*(cp + 2) != '\0') { - if (strchr((cp + 2), '/') != NULL) { + if (StrChr((cp + 2), '/') != NULL) { /* * Convert "~user/subdir(s)/file" to "./subdir(s)/file". * If user is someone else, we covered a spoof. Otherwise, @@ -5362,7 +5441,7 @@ BOOLEAN LYPathOffHomeOK(char *fbuffer, /* * Check for VMS path specs, and reject if still present. - FM */ - if (strchr(cp, ':') != NULL || strchr(cp, ']') != NULL) { + if (StrChr(cp, ':') != NULL || StrChr(cp, ']') != NULL) { FREE(file); return (FALSE); } @@ -5385,7 +5464,7 @@ BOOLEAN LYPathOffHomeOK(char *fbuffer, * Check if it has a pointless "./". - FM */ if (!StrNCmp(cp, "./", 2)) { - if (strchr((cp + 2), '/') == NULL) { + if (StrChr((cp + 2), '/') == NULL) { cp += 2; } } @@ -5406,7 +5485,7 @@ BOOLEAN LYPathOffHomeOK(char *fbuffer, * Load what we have at this point into fbuffer, trimming if too long, and * claim it's OK. - FM */ - if (fbuffer_size > 3 && StrNCmp(cp, "./", 2) && strchr(cp, '/')) { + if (fbuffer_size > 3 && StrNCmp(cp, "./", 2) && StrChr(cp, '/')) { /* * We have a subdirectory and no lead "./", so prefix it to make the * situation clear. - FM @@ -5694,7 +5773,7 @@ extern char **environ; */ int putenv(const char *string) { - char *name_end = strchr(string, '='); + char *name_end = StrChr(string, '='); register size_t size; register char **ep; @@ -5880,7 +5959,7 @@ static FILE *OpenHiddenFile(const char *name, const char *mode) { FILE *fp = 0; struct stat data; - BOOLEAN binary = (BOOLEAN) (strchr(mode, 'b') != 0); + BOOLEAN binary = (BOOLEAN) (StrChr(mode, 'b') != 0); #if defined(O_CREAT) && defined(O_EXCL) /* we have fcntl.h or kindred? */ /* @@ -6696,14 +6775,14 @@ BOOLEAN LYValidateFilename(bstring **result, FREE(cp1); } #ifdef VMS - if (strchr((*given)->str, '/') != NULL) { + if (StrChr((*given)->str, '/') != NULL) { BStrCopy0(*result, HTVMS_name("", (*given)->str)); BStrCopy(*given, *result); } if ((*given)->str[0] != '/' - && strchr((*given)->str, ':') == NULL) { + && StrChr((*given)->str, ':') == NULL) { BStrCopy0(*result, "sys$disk:"); - if (strchr((*given)->str, ']') == NULL) + if (StrChr((*given)->str, ']') == NULL) BStrCat0(*result, "[]"); BStrCat(*result, (*given)); } else { @@ -6714,7 +6793,7 @@ BOOLEAN LYValidateFilename(bstring **result, #ifndef __EMX__ if (!LYisAbsPath((*given)->str)) { #if defined(__DJGPP__) || defined(_WINDOWS) - if (strchr((*result)->str, ':') != NULL) + if (StrChr((*result)->str, ':') != NULL) cp = NULL; else #endif /* __DJGPP__ || _WINDOWS */ @@ -6871,7 +6950,7 @@ void WriteInternalTitle(FILE *fp0, const char *Title) fprintf(fp0, "<html>\n<head>\n"); LYAddMETAcharsetToFD(fp0, -1); if (LYIsListpageTitle(Title)) { - if (strchr(HTLoadedDocumentURL(), '"') == NULL) { + if (StrChr(HTLoadedDocumentURL(), '"') == NULL) { char *Address = NULL; /* @@ -7204,7 +7283,7 @@ int LYSystem(char *command) while (*p == ' ') p++; - if (strchr(p, '\\') == NULL) { + if (StrChr(p, '\\') == NULL) { /* for Windows Application */ cygwin_conv_to_full_win32_path(p, win32_name); sprintf(new_command, "%.*s \"%.*s\"", @@ -7604,8 +7683,8 @@ char *get_clip_grab(void) paste_buf[off + len] = '\0'; if (len < PASTE_BUFFER - 1) break; - if (strchr(paste_buf + off, '\r') - || strchr(paste_buf + off, '\n')) + if (StrChr(paste_buf + off, '\r') + || StrChr(paste_buf + off, '\n')) break; paste_buf = typeRealloc(char, paste_buf, size += PASTE_BUFFER - 1); @@ -7877,10 +7956,10 @@ void LYSyslog(char *arg) if (is_url(arg)) { /* proto://user:password@host/path:port */ /* ^this colon */ - if ((colon1 = strchr(arg, ':')) != 0 + if ((colon1 = StrChr(arg, ':')) != 0 && !StrNCmp(colon1, "://", 3) - && (colon2 = strchr(colon1 + 3, ':')) != 0 - && (atsign = strchr(colon1, '@')) != 0 + && (colon2 = StrChr(colon1 + 3, ':')) != 0 + && (atsign = StrChr(colon1, '@')) != 0 && (colon2 < atsign) && looks_like_password(colon2 + 1, atsign - 1)) { char *buf = NULL; @@ -8002,7 +8081,7 @@ int unsafe_filename(const char *fname) } else { char *q; - q = strchr(cp, '.'); + q = StrChr(cp, '.'); if (q) *q = '\0'; if (is_device(cp)) { diff --git a/src/LYUtils.h b/src/LYUtils.h index ac6609bb..e24a1de7 100644 --- a/src/LYUtils.h +++ b/src/LYUtils.h @@ -1,4 +1,4 @@ -/* $LynxId: LYUtils.h,v 1.94 2013/10/23 22:14:03 tom Exp $ */ +/* $LynxId: LYUtils.h,v 1.96 2013/11/28 11:22:53 tom Exp $ */ #ifndef LYUTILS_H #define LYUTILS_H @@ -118,7 +118,7 @@ extern "C" { #define LYIsTilde(ch) ((ch) == '~') #define LYIsHtmlSep(ch) ((ch) == '/') -#define findPoundSelector(address) strchr(address, '#') +#define findPoundSelector(address) StrChr(address, '#') #define restorePoundSelector(pound) if ((pound) != NULL) *(pound) = '#' extern BOOL strn_dash_equ(const char *p1, const char *p2, int len); @@ -151,6 +151,7 @@ extern "C" { extern char *Current_Dir(char *pathname); extern char *LYAbsOrHomePath(char **fname); extern char *LYAddPathToSave(char *fname); + extern char *LYFindConfigFile(const char *nominal, const char *dftfile); extern char *LYGetEnv(const char *name); extern char *LYLastPathSep(const char *path); extern char *LYPathLeaf(char *pathname); diff --git a/src/LYexit.c b/src/LYexit.c index 296f61f7..425c85c0 100644 --- a/src/LYexit.c +++ b/src/LYexit.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYexit.c,v 1.35 2009/03/10 00:12:52 tom Exp $ + * $LynxId: LYexit.c,v 1.36 2013/10/24 09:16:37 tom Exp $ * * Copyright (c) 1994, University of Kansas, All Rights Reserved * (most of this file was rewritten in 1996 and 2004). @@ -28,31 +28,30 @@ static void (*callstack[ATEXITSIZE]) (void); static int topOfStack = 0; /* - * Purpose: Registers termination function. - * Arguments: function The function to register. - * Return Value: int 0 registered - * !0 no more space to register - * Remarks/Portability/Dependencies/Restrictions: - * Revision History: - * 06-15-94 created Lynx 2-3-1 Garrett Arch Blythe + * Capture "atexit()" calls for our own accounting. */ - int LYatexit(void (*function) (void)) { - /* - * Check for available space. - */ - if (topOfStack == ATEXITSIZE) { + int result = 0; + + if (topOfStack >= ATEXITSIZE) { CTRACE((tfp, "(LY)atexit: Too many functions, ignoring one!\n")); - return (-1); + result = -1; + } else { + int n; + BOOLEAN found = FALSE; + + for (n = 0; n < topOfStack; ++n) { + if (callstack[n] == function) { + found = TRUE; + break; + } + } + if (!found) { + callstack[topOfStack++] = function; + } } - - /* - * Register the function. - */ - callstack[topOfStack] = function; - topOfStack++; - return (0); + return result; } /* diff --git a/src/LYrcFile.c b/src/LYrcFile.c index f34e4fa7..fd751e49 100644 --- a/src/LYrcFile.c +++ b/src/LYrcFile.c @@ -1,4 +1,4 @@ -/* $LynxId: LYrcFile.c,v 1.91 2013/10/12 13:06:01 tom Exp $ */ +/* $LynxId: LYrcFile.c,v 1.92 2013/11/28 11:22:53 tom Exp $ */ #include <HTUtils.h> #include <HTFTP.h> #include <LYUtils.h> @@ -731,7 +731,7 @@ BOOL LYsetRcValue(const char *name, const char *param) sprintf(MBM_line, "multi_bookmark%c", LYindex2MBM(n)); if (!strcasecomp(name, MBM_line)) { - if ((notes = strchr(value, ',')) != 0) { + if ((notes = StrChr(value, ',')) != 0) { *notes++ = '\0'; LYTrimTrailing(value); notes = LYSkipBlanks(notes); @@ -798,7 +798,7 @@ void read_rc(FILE *fp) /* * Parse the "name=value" strings. */ - if ((value = strchr(name, '=')) == 0) { + if ((value = StrChr(name, '=')) == 0) { CTRACE((tfp, "LYrcFile: missing '=' %s\n", name)); continue; } @@ -1054,7 +1054,7 @@ BOOL will_save_rc(const char *name) int enable_lynxrc(char *value) { Config_Type *tbl; - char *colon = strchr(value, ':'); + char *colon = StrChr(value, ':'); if (colon != 0) { *colon++ = 0; diff --git a/src/UCAuto.c b/src/UCAuto.c index d7f168e1..81765f36 100644 --- a/src/UCAuto.c +++ b/src/UCAuto.c @@ -1,5 +1,5 @@ /* - * $LynxId: UCAuto.c,v 1.51 2013/05/04 13:14:39 tom Exp $ + * $LynxId: UCAuto.c,v 1.52 2013/11/28 11:22:53 tom Exp $ * * This file contains code for changing the Linux console mode. * Currently some names for font files are hardwired in here. @@ -600,7 +600,7 @@ int Find_Best_Display_Charset(int ord) if (!lowercase++) LYLowerCase(charset_switch_rules); while (1) { - while (*s && strchr(" \t,", *s)) + while (*s && StrChr(" \t,", *s)) s++; /* Go to start of a name or ':' */ if (!*s && source) return ord; /* OK to find nothing */ @@ -613,23 +613,23 @@ int Find_Best_Display_Charset(int ord) } if (*s == ':') { /* Before the replacement name */ - while (*s && strchr(" \t:", *s)) + while (*s && StrChr(" \t:", *s)) s++; /* Go to the replacement */ /* At start of the replacement name */ r = s; - while (*s && !strchr(" \t,:", *s)) + while (*s && !StrChr(" \t,:", *s)) s++; /* Skip the replacement */ if (source) continue; break; } /* At start of the source name */ - if (source && !strnicmp(name, s, n) && strchr(" \t,", s[n])) { /* Found! */ + if (source && !strnicmp(name, s, n) && StrChr(" \t,", s[n])) { /* Found! */ source = 0; s += n; continue; /* Look for the replacement */ } - while (*s && !strchr(" \t,:", *s)) + while (*s && !StrChr(" \t,:", *s)) s++; /* Skip the other source names */ } /* Here r point to the replacement, s to the end of the replacement. */ diff --git a/src/chrtrans/makeuctb.c b/src/chrtrans/makeuctb.c index 4a0e734a..6cbd070b 100644 --- a/src/chrtrans/makeuctb.c +++ b/src/chrtrans/makeuctb.c @@ -1,5 +1,5 @@ /* - * $LynxId: makeuctb.c,v 1.48 2013/07/21 00:42:39 tom Exp $ + * $LynxId: makeuctb.c,v 1.49 2013/11/28 11:28:53 tom Exp $ * * makeuctb.c, derived from conmakehash.c - kw * @@ -365,7 +365,7 @@ int main(int argc, char **argv) * Now we comes to the tricky part. Parse the input table. */ while (fgets(buffer, (int) sizeof(buffer), ctbl) != NULL) { - if ((p = strchr(buffer, '\n')) != NULL) { + if ((p = StrChr(buffer, '\n')) != NULL) { *p = '\0'; } else { fprintf(stderr, @@ -749,7 +749,7 @@ int main(int argc, char **argv) StrNCpy(this_MIMEcharset, argv[3], UC_MAXLEN_MIMECSNAME); } else if (this_MIMEcharset[0] == '\0') { StrNCpy(this_MIMEcharset, tblname, UC_MAXLEN_MIMECSNAME); - if ((p = strchr(this_MIMEcharset, '.')) != 0) { + if ((p = StrChr(this_MIMEcharset, '.')) != 0) { *p = '\0'; } } |