diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 2010-09-26 14:26:23 -0400 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 2010-09-26 14:26:23 -0400 |
commit | bf9ea0cbb0562934c45170f94ebfe2ac609a44a8 (patch) | |
tree | f4bde48763d66ed00b176397aee2b3fd6e9fc7f5 /src | |
parent | 69a1a751cb798556c786e3ef66d473bf8a88abdc (diff) | |
download | lynx-snapshots-bf9ea0cbb0562934c45170f94ebfe2ac609a44a8.tar.gz |
snapshot of project "lynx", label v2-8-8dev_5e
Diffstat (limited to 'src')
66 files changed, 894 insertions, 806 deletions
diff --git a/src/GridText.c b/src/GridText.c index 3c86ee69..f2e79fba 100644 --- a/src/GridText.c +++ b/src/GridText.c @@ -1,5 +1,5 @@ /* - * $LynxId: GridText.c,v 1.194 2010/09/23 09:32:45 tom Exp $ + * $LynxId: GridText.c,v 1.198 2010/09/25 12:43:30 tom Exp $ * * Character grid hypertext object * =============================== @@ -84,8 +84,7 @@ #define FirstHTLine(text) ((text)->last_line->next) #define LastHTLine(text) ((text)->last_line) -static void HText_trimHightext(HText *text, BOOLEAN final, - int stop_before); +static void HText_trimHightext(HText *text, int final, int stop_before); struct _HTStream { /* only know it as object */ const HTStreamClass *isa; @@ -247,7 +246,7 @@ There are 3 functions - POOL_NEW, POOL_FREE, and ALLOC_IN_POOL. #define POOLallocstyles(ptr, n) ptr = ALLOC_IN_POOL(&HTMainText->pool, (unsigned) ((n) * sizeof(pool_data))) #define POOLallocHTLine(ptr, size) ptr = (HTLine*) ALLOC_IN_POOL(&HTMainText->pool, (unsigned) LINE_SIZE(size)) #define POOLallocstring(ptr, len) ptr = (char*) ALLOC_IN_POOL(&HTMainText->pool, (unsigned) (len + 1)) -#define POOLtypecalloc(T, ptr) ptr = (T*) ALLOC_IN_POOL(&HTMainText->pool, sizeof(T)) +#define POOLtypecalloc(T, ptr) ptr = (T*) ALLOC_IN_POOL(&HTMainText->pool, (unsigned) sizeof(T)) /**************************************************************************/ /* @@ -277,7 +276,7 @@ static pool_data *ALLOC_IN_POOL(HTPool ** ppoolptr, unsigned request) ptr = pool->data + pool->used; pool->used += n; } else { - HTPool *newpool = (HTPool *) LY_CALLOC(1, sizeof(HTPool)); + HTPool *newpool = (HTPool *) LY_CALLOC((size_t) 1, sizeof(HTPool)); if (!newpool) { ptr = NULL; @@ -297,7 +296,7 @@ static pool_data *ALLOC_IN_POOL(HTPool ** ppoolptr, unsigned request) */ static HTPool *POOL_NEW(void) { - HTPool *poolptr = (HTPool *) LY_CALLOC(1, sizeof(HTPool)); + HTPool *poolptr = (HTPool *) LY_CALLOC((size_t) 1, sizeof(HTPool)); if (poolptr) { poolptr->prev = NULL; @@ -618,9 +617,9 @@ HTList *search_queries = NULL; /* isindex and whereis queries */ static void free_all_texts(void); #endif -static BOOL HText_TrueEmptyLine(HTLine *line, HText *text, BOOL IgnoreSpaces); +static BOOL HText_TrueEmptyLine(HTLine *line, HText *text, int IgnoreSpaces); -static int HText_TrueLineSize(HTLine *line, HText *text, BOOL IgnoreSpaces); +static int HText_TrueLineSize(HTLine *line, HText *text, int IgnoreSpaces); #ifdef CHECK_FREE_MEM @@ -656,7 +655,7 @@ static void HText_halt(void) * which might make the situation worse depending how allocation works. * There should be a better way... - kw */ -static BOOL mem_is_avail(size_t factor, size_t bytes) +static BOOL mem_is_avail(int factor, size_t bytes) { void *p; @@ -664,7 +663,7 @@ static BOOL mem_is_avail(size_t factor, size_t bytes) bytes = MIN_NEEDED_MEM; if (factor == 0) factor = 1; - p = malloc(factor * bytes); + p = malloc((size_t) factor * bytes); if (p) { FREE(p); return YES; @@ -708,12 +707,12 @@ static void *LY_check_calloc(size_t nmemb, size_t size) if (!HTMainText || HTMainText->halted <= 1) { if (!mem_is_avail(2, nmemb * size)) { HText_halt(); - if (mem_is_avail(0, 700)) { + if (mem_is_avail(0, (size_t) 700)) { HTAlert(gettext("Memory exhausted, display interrupted!")); } } else { if ((!HTMainText || HTMainText->halted == 0) && - mem_is_avail(0, 700)) { + mem_is_avail(0, (size_t) 700)) { HTAlert(gettext("Memory exhausted, will interrupt transfer!")); if (HTMainText) HTMainText->halted = 1; @@ -790,7 +789,7 @@ static void LYSetHiText(TextAnchor *a, { if (text != NULL) { POOLallocstring(a->lites.hl_base.hl_text, len + 1); - memcpy(a->lites.hl_base.hl_text, text, len); + memcpy(a->lites.hl_base.hl_text, text, (size_t) len); *(a->lites.hl_base.hl_text + len) = '\0'; a->lites.hl_len = 1; @@ -805,11 +804,11 @@ static void LYAddHiText(TextAnchor *a, int x) { HiliteInfo *have = a->lites.hl_info; - unsigned need = (unsigned) (a->lites.hl_len - 1); - unsigned want; + size_t need = (unsigned) (a->lites.hl_len - 1); + size_t want; a->lites.hl_len = (short) (a->lites.hl_len + 1); - want = (unsigned) (a->lites.hl_len) * (unsigned) sizeof(HiliteInfo); + want = (size_t) (a->lites.hl_len) * sizeof(HiliteInfo); if (have != NULL) { have = (HiliteInfo *) realloc(have, want); } else { @@ -1182,13 +1181,13 @@ HText *HText_new(HTParentAnchor *anchor) /* * Create an array of dots for the UNDERSCORES macro. -FM */ - memset(underscore_string, '.', (MAX_LINE - 1)); + memset(underscore_string, '.', (size_t) (MAX_LINE - 1)); underscore_string[(MAX_LINE - 1)] = '\0'; underscore_string[MAX_LINE] = '\0'; /* * Create an array of underscores for the STARS macro. -FM */ - memset(star_string, '_', (MAX_LINE - 1)); + memset(star_string, '_', (size_t) (MAX_LINE - 1)); star_string[(MAX_LINE - 1)] = '\0'; star_string[MAX_LINE] = '\0'; } @@ -1587,7 +1586,7 @@ static int display_line(HTLine *line, LastDisplayChar = 'M'; } if (utf_extra) { - strncpy(&buffer[1], data, utf_extra); + StrNCpy(&buffer[1], data, utf_extra); buffer[utf_extra + 1] = '\0'; LYaddstr(buffer); buffer[1] = '\0'; @@ -2209,7 +2208,7 @@ static void display_page(HText *text, */ utf_extra = utf8_length(text->T.output_utf8, data + itmp); if (utf_extra) { - strncpy(&tmp[1], &line->data[itmp + 1], utf_extra); + StrNCpy(&tmp[1], &line->data[itmp + 1], utf_extra); tmp[utf_extra + 1] = '\0'; itmp += utf_extra; LYaddstr(tmp); @@ -2563,15 +2562,15 @@ void HText_beginAppend(HText *text) static int set_style_by_embedded_chars(char *s, char *e, - unsigned char start_c, - unsigned char end_c) + unsigned start_c, + unsigned end_c) { int ret = NO; while (--e >= s) { - if (UCH(*e) == end_c) + if (UCH(*e) == UCH(end_c)) break; - if (UCH(*e) == start_c) { + if (UCH(*e) == UCH(start_c)) { ret = YES; break; } @@ -2849,7 +2848,7 @@ static void split_line(HText *text, unsigned split) line = TEMP_LINE(text, 0); if (line == NULL) return; - memset(line, 0, LINE_SIZE(0)); + memset(line, 0, (size_t) LINE_SIZE(0)); ctrl_chars_on_this_line = 0; /*reset since we are going to a new line */ utfxtra_on_this_line = 0; /*reset too, we'll count them */ @@ -4569,12 +4568,12 @@ void _internal_HTC(HText *text, int style, int dir) /* Set LastChar element in the text object. * ---------------------------------------- */ -void HText_setLastChar(HText *text, char ch) +void HText_setLastChar(HText *text, int ch) { if (!text) return; - text->LastChar = ch; + text->LastChar = (char) ch; } /* Get LastChar element in the text object. @@ -4867,7 +4866,7 @@ void HText_cancelStbl(HText *me) /* Start simple table handling */ -void HText_startStblTABLE(HText *me, short alignment) +void HText_startStblTABLE(HText *me, int alignment) { #ifdef EXP_NESTED_TABLES STable_info *current = me->stbl; @@ -4980,7 +4979,7 @@ BOOLEAN HText_endStblTABLE(HText *me) /* Start simple table row */ -void HText_startStblTR(HText *me, short alignment) +void HText_startStblTR(HText *me, int alignment) { if (!me || !me->stbl) return; @@ -5001,8 +5000,8 @@ void HText_endStblTR(HText *me) */ void HText_startStblTD(HText *me, int colspan, int rowspan, - short alignment, - BOOL isheader) + int alignment, + int isheader) { if (!me || !me->stbl) return; @@ -5039,8 +5038,8 @@ void HText_endStblTD(HText *me) /* Remember COL info / Start a COLGROUP and remember info */ void HText_startStblCOL(HText *me, int span, - short alignment, - BOOL isgroup) + int alignment, + int isgroup) { if (!me || !me->stbl) return; @@ -5066,7 +5065,7 @@ void HText_endStblCOLGROUP(HText *me) /* Start a THEAD / TFOOT / TBODY - remember its alignment info */ -void HText_startStblRowGroup(HText *me, short alignment) +void HText_startStblRowGroup(HText *me, int alignment) { if (!me || !me->stbl) return; @@ -5077,7 +5076,7 @@ void HText_startStblRowGroup(HText *me, short alignment) /* Anchor handling * --------------- */ -static void add_link_number(HText *text, TextAnchor *a, BOOL save_position) +static void add_link_number(HText *text, TextAnchor *a, int save_position) { char marker[32]; @@ -5105,7 +5104,7 @@ static void add_link_number(HText *text, TextAnchor *a, BOOL save_position) /* Start an anchor field */ -int HText_beginAnchor(HText *text, BOOL underline, +int HText_beginAnchor(HText *text, int underline, HTChildAnchor *anc) { TextAnchor *a; @@ -5117,7 +5116,7 @@ int HText_beginAnchor(HText *text, BOOL underline, assert(a != NULL); - a->inUnderline = underline; + a->inUnderline = (BOOLEAN) underline; a->sgml_offset = SGML_offset(); a->line_num = text->Lines; @@ -5776,7 +5775,7 @@ void HText_endAppend(HText *text) * form it expects when it sets the links[] elements. */ static void HText_trimHightext(HText *text, - BOOLEAN final, + int final, int stop_before) { int cur_line, cur_shift; @@ -6427,7 +6426,7 @@ static BOOLEAN same_anchor_or_field(int numberA, FormInfo * formA, int numberB, FormInfo * formB, - BOOLEAN ta_same) + int ta_same) { if (numberA > 0 || numberB > 0) { if (numberA == numberB) @@ -6536,7 +6535,7 @@ int HTGetLinkOrFieldStart(int curlink, int *go_line, int *linknum, int direction, - BOOLEAN ta_skip) + int ta_skip) { TextAnchor *a; int anchors_this_line = 0; @@ -6726,7 +6725,7 @@ int HTGetLinkOrFieldStart(int curlink, * TRUE is returned. -FM */ BOOL HText_getFirstTargetInLine(HText *text, int line_num, - BOOL utf_flag, + int utf_flag, int *offset, int *tLen, char **data, @@ -6865,7 +6864,7 @@ const char *HText_getSugFname(void) */ void HTCheckFnameForCompression(char **fname, HTParentAnchor *anchor, - BOOLEAN strip_ok) + int strip_ok) { char *fn = *fname; char *dot = NULL; @@ -7618,7 +7617,7 @@ int do_www_search(DocInfo *doc) * Use its query as the default. */ PreviousSearch = TRUE; - LYstrncpy(searchstring, ++cp, sizeof(searchstring) - 1); + LYStrNCpy(searchstring, ++cp, sizeof(searchstring) - 1); for (cp = searchstring; *cp; cp++) if (*cp == '+') *cp = ' '; @@ -7651,7 +7650,7 @@ int do_www_search(DocInfo *doc) (!PreviousSearch && QueryTotal >= 1)) ? RECALL_URL : NORECALL); QueryNum = QueryTotal; get_query: - if ((ch = LYgetstr(searchstring, VISIBLE, + if ((ch = LYGetStr(searchstring, VISIBLE, sizeof(searchstring), recall)) < 0 || *searchstring == '\0' || ch == UPARROW || ch == DNARROW) { if (recall && ch == UPARROW) { @@ -7674,7 +7673,7 @@ int do_www_search(DocInfo *doc) QueryNum = 0; if ((cp = (char *) HTList_objectAt(search_queries, QueryNum)) != NULL) { - LYstrncpy(searchstring, cp, sizeof(searchstring) - 1); + LYStrNCpy(searchstring, cp, sizeof(searchstring) - 1); if (*temp && !strcmp(temp, searchstring)) { _statusline(EDIT_CURRENT_QUERY); } else if ((*temp && QueryTotal == 2) || @@ -7705,7 +7704,7 @@ int do_www_search(DocInfo *doc) QueryNum = QueryTotal - 1; if ((cp = (char *) HTList_objectAt(search_queries, QueryNum)) != NULL) { - LYstrncpy(searchstring, cp, sizeof(searchstring) - 1); + LYStrNCpy(searchstring, cp, sizeof(searchstring) - 1); if (*temp && !strcmp(temp, searchstring)) { _statusline(EDIT_CURRENT_QUERY); } else if ((*temp && QueryTotal == 2) || @@ -8023,8 +8022,8 @@ static void freeAnchorIndex(AnchorIndex ** inx, unsigned inx_size) #define FieldFirst(p) (this_wrap ? 0 : (p)->offset) #define FieldLast(p) (FieldFirst(p) + (p)->size - this_wrap) void print_wwwfile_to_fd(FILE *fp, - BOOLEAN is_email, - BOOLEAN is_reply) + int is_email, + int is_reply) { int line_num, byte_num, byte_count; int first = TRUE; @@ -8074,7 +8073,7 @@ void print_wwwfile_to_fd(FILE *fp, first = FALSE; if (is_reply) { fputc('>', fp); - } else if (is_email && !strncmp(line->data, "From ", 5)) { + } else if (is_email && !StrNCmp(line->data, "From ", 5)) { fputc('>', fp); } } else if (line->data[0] != LY_SOFT_NEWLINE) { @@ -8084,7 +8083,7 @@ void print_wwwfile_to_fd(FILE *fp, */ if (is_reply) { fputc('>', fp); - } else if (is_email && !strncmp(line->data, "From ", 5)) { + } else if (is_email && !StrNCmp(line->data, "From ", 5)) { fputc('>', fp); } } @@ -9054,14 +9053,14 @@ const char *HTLoadedDocumentBookmark(void) return (NULL); } -int HText_LastLineSize(HText *text, BOOL IgnoreSpaces) +int HText_LastLineSize(HText *text, int IgnoreSpaces) { if (!text || !text->last_line || !text->last_line->size) return 0; return HText_TrueLineSize(text->last_line, text, IgnoreSpaces); } -BOOL HText_LastLineEmpty(HText *text, BOOL IgnoreSpaces) +BOOL HText_LastLineEmpty(HText *text, int IgnoreSpaces) { if (!text || !text->last_line || !text->last_line->size) return TRUE; @@ -9075,7 +9074,7 @@ int HText_LastLineOffset(HText *text) return text->last_line->offset; } -int HText_PreviousLineSize(HText *text, BOOL IgnoreSpaces) +int HText_PreviousLineSize(HText *text, int IgnoreSpaces) { HTLine *line; @@ -9086,7 +9085,7 @@ int HText_PreviousLineSize(HText *text, BOOL IgnoreSpaces) return HText_TrueLineSize(line, text, IgnoreSpaces); } -BOOL HText_PreviousLineEmpty(HText *text, BOOL IgnoreSpaces) +BOOL HText_PreviousLineEmpty(HText *text, int IgnoreSpaces) { HTLine *line; @@ -9100,7 +9099,7 @@ BOOL HText_PreviousLineEmpty(HText *text, BOOL IgnoreSpaces) /* * Compute the "true" line size. */ -static int HText_TrueLineSize(HTLine *line, HText *text, BOOL IgnoreSpaces) +static int HText_TrueLineSize(HTLine *line, HText *text, int IgnoreSpaces) { size_t i; int true_size = 0; @@ -9134,7 +9133,7 @@ static int HText_TrueLineSize(HTLine *line, HText *text, BOOL IgnoreSpaces) * HText_TrueLineSize(), and most lines are not empty. So it is faster to * do this check than to check if the line size happens to be zero. */ -static BOOL HText_TrueEmptyLine(HTLine *line, HText *text, BOOL IgnoreSpaces) +static BOOL HText_TrueEmptyLine(HTLine *line, HText *text, int IgnoreSpaces) { size_t i; @@ -9536,7 +9535,7 @@ void HText_endForm(HText *text) void HText_beginSelect(char *name, int name_cs, - BOOLEAN multiple, + int multiple, char *size) { /* @@ -9657,7 +9656,7 @@ static char *HText_skipOptionNumPrefix(char *opname) char *HText_setLastOptionValue(HText *text, char *value, char *submit_value, int order, - BOOLEAN checked, + int checked, int val_cs, int submit_val_cs) { @@ -9931,7 +9930,8 @@ char *HText_setLastOptionValue(HText *text, char *value, * Returns the number of characters to leave * blank so that the input field can fit. */ -int HText_beginInput(HText *text, BOOL underline, +int HText_beginInput(HText *text, + int underline, InputFieldData * I) { TextAnchor *a; @@ -9956,7 +9956,7 @@ int HText_beginInput(HText *text, BOOL underline, assert(f != NULL); a->sgml_offset = SGML_offset(); - a->inUnderline = underline; + a->inUnderline = (BOOLEAN) underline; a->line_num = text->Lines; a->line_pos = (short) text->last_line->size; @@ -10569,7 +10569,7 @@ static void load_a_file(const char *val_used, if ((fd = fopen(val_used, BIN_R)) == 0) { HTAlert(gettext("Can't open file for uploading")); } else { - while ((bytes = fread(buffer, sizeof(char), 256, fd)) != 0) { + while ((bytes = fread(buffer, sizeof(char), (size_t) 256, fd)) != 0) { HTSABCat(result, buffer, (int) bytes); } LYCloseInput(fd); @@ -12082,14 +12082,14 @@ void HText_setKcode(HText *text, const char *charset, && ((p_in && (p_in->enc == UCT_ENC_CJK)) || !strcmp(charset, "x-euc") || /* 1997/11/28 (Fri) 18:11:24 */ !strcmp(charset, "euc-jp") || - !strncmp(charset, "x-euc-", 6) || + !StrNCmp(charset, "x-euc-", 6) || !strcmp(charset, "euc-kr") || !strcmp(charset, "iso-2022-kr") || !strcmp(charset, "big5") || !strcmp(charset, "cn-big5") || !strcmp(charset, "euc-cn") || !strcmp(charset, "gb2312") || - !strncmp(charset, "cn-gb", 5) || + !StrNCmp(charset, "cn-gb", 5) || !strcmp(charset, "iso-2022-cn"))) { text->kcode = EUC; } else { @@ -12482,7 +12482,7 @@ static int increment_tagged_htline(HTLine *ht, TextAnchor *a, int *lx_val, * Keep track of any digits added, for the next * pass through. */ - s = strncpy(s, lx, (size_t) pre_n) + pre_n; + s = StrNCpy(s, lx, pre_n) + pre_n; lx += pre_n; strcpy(ht->next->data, lx); @@ -12882,7 +12882,7 @@ static int finish_ExtEditForm(LinkInfo * form_link, TextAnchor *start_anchor, assert(ebuf != NULL); fp = fopen(ed_temp, "r"); - size = fread(ebuf, 1, size, fp); + size = fread(ebuf, (size_t) 1, size, fp); LYCloseInput(fp); ebuf[size] = '\0'; /* Terminate! - kw */ } @@ -12899,8 +12899,8 @@ static int finish_ExtEditForm(LinkInfo * form_link, TextAnchor *start_anchor, * struct. Add new lines to the TEXTAREA if needed. (Always leave * the user with a blank line at the end of the TEXTAREA.) */ - if ((line = (char *) malloc(MAX_LINE)) == 0) - outofmem(__FILE__, "HText_ExtEditForm"); + if ((line = typeMallocn(char, MAX_LINE)) == 0) + outofmem(__FILE__, "HText_ExtEditForm"); assert(line != NULL); @@ -12916,7 +12916,7 @@ static int finish_ExtEditForm(LinkInfo * form_link, TextAnchor *start_anchor, if (skip_at) { len0 = (int) (skip_at - lp); - strncpy(line, lp, (size_t) len0); + StrNCpy(line, lp, len0); line[len0] = '\0'; lp = skip_at + skip_num; skip_at = NULL; @@ -13113,7 +13113,8 @@ int HText_ExtEditForm(LinkInfo * form_link) CTRACE((tfp, "GridText: entered HText_ExtEditForm()\n")); - ed_temp = (char *) malloc(LY_MAXPATH); + ed_temp = typeMallocn(char, LY_MAXPATH); + if ((fp = LYOpenTemp(ed_temp, "", "w")) == 0) { FREE(ed_temp); return (0); @@ -13364,7 +13365,7 @@ int HText_InsertFile(LinkInfo * form_link) HTAlert(FILE_CANNOT_OPEN_R); return 0; } - size = fread(fbuf, 1, size, fp); + size = fread(fbuf, (size_t) 1, size, fp); LYCloseInput(fp); FREE(fn); fbuf[size] = '\0'; /* Terminate! - kw */ @@ -13494,8 +13495,8 @@ int HText_InsertFile(LinkInfo * form_link) * * Begin with the new line/anchor we just added (above the cursorline). */ - if ((line = (char *) malloc(MAX_LINE)) == 0) - outofmem(__FILE__, "HText_InsertFile"); + if ((line = typeMallocn(char, MAX_LINE)) == 0) + outofmem(__FILE__, "HText_InsertFile"); assert(line != NULL); @@ -13519,7 +13520,7 @@ int HText_InsertFile(LinkInfo * form_link) if (lp[len]) lp[len + 1] = '\0'; /* prevent next iteration */ } - strncpy(line, lp, (size_t) len); + StrNCpy(line, lp, len); *(line + len) = '\0'; /* @@ -13730,7 +13731,7 @@ static void redraw_part_of_line(HTLine *line, const char *str, LastDisplayChar = 'M'; } if (utf_extra) { - strncpy(&buffer[1], data, utf_extra); + StrNCpy(&buffer[1], data, utf_extra); buffer[utf_extra + 1] = '\0'; LYaddstr(buffer); buffer[1] = '\0'; @@ -13815,7 +13816,7 @@ static void move_to_glyph(int YP, const char *target, const char *hightext, int flags, - BOOL utf_flag) + int utf_flag) { char buffer[7]; const char *end_of_data; @@ -14210,7 +14211,7 @@ static void move_to_glyph(int YP, } #endif if (utf_extra) { - strncpy(&buffer[1], data, utf_extra); + StrNCpy(&buffer[1], data, utf_extra); buffer[utf_extra + 1] = '\0'; if (!drawing && i >= XP_draw_min) { LYmove(YP, i - 1); @@ -14303,8 +14304,8 @@ void LYMoveToLink(int cur, const char *target, const char *hightext, int flag, - BOOL inU, - BOOL utf_flag) + int inU, + int utf_flag) { #define pvtTITLE_HEIGHT 1 HTLine *todr; diff --git a/src/GridText.h b/src/GridText.h index a3ed2b6e..c4f72813 100644 --- a/src/GridText.h +++ b/src/GridText.h @@ -1,5 +1,5 @@ /* - * $LynxId: GridText.h,v 1.61 2009/01/01 23:02:02 tom Exp $ + * $LynxId: GridText.h,v 1.63 2010/09/24 23:01:59 tom Exp $ * * Specialities of GridText as subclass of HText */ @@ -90,7 +90,7 @@ US-ASCII control characters <32 which are not defined in Unicode standard extern int HText_locateAnchor(HText *text, int anchor_number); extern int HText_anchorRelativeTo(HText *text, int top_lineno, int anchor_num); - extern void HText_setLastChar(HText *text, char ch); + extern void HText_setLastChar(HText *text, int ch); extern char HText_getLastChar(HText *text); extern int HText_sourceAnchors(HText *text); @@ -100,7 +100,7 @@ US-ASCII control characters <32 which are not defined in Unicode standard extern const char *HText_getSugFname(void); extern void HTCheckFnameForCompression(char **fname, HTParentAnchor *anchor, - BOOLEAN strip_ok); + int strip_ok); extern const char *HText_getLastModified(void); extern const char *HText_getDate(void); extern const char *HText_getHttpHeaders(void); @@ -115,7 +115,7 @@ US-ASCII control characters <32 which are not defined in Unicode standard extern const char *HText_getStyle(void); #endif extern void HText_setMainTextOwner(const char *owner); - extern void print_wwwfile_to_fd(FILE *fp, BOOLEAN is_email, BOOLEAN is_reply); + extern void print_wwwfile_to_fd(FILE *fp, int is_email, int is_reply); extern BOOL HText_select(HText *text); extern BOOL HText_POSTReplyLoaded(DocInfo *doc); extern BOOL HTFindPoundSelector(const char *selector); @@ -132,10 +132,10 @@ US-ASCII control characters <32 which are not defined in Unicode standard int *go_line, int *linknum, int direction, - BOOLEAN ta_skip); + int ta_skip); extern BOOL HText_getFirstTargetInLine(HText *text, int line_num, - BOOL utf_flag, + int utf_flag, int *offset, int *tLen, char **data, @@ -150,8 +150,8 @@ US-ASCII control characters <32 which are not defined in Unicode standard #endif extern BOOL HTLoadedDocumentEightbit(void); - extern BOOL HText_LastLineEmpty(HText *me, BOOL IgnoreSpaces); - extern BOOL HText_PreviousLineEmpty(HText *me, BOOL IgnoreSpaces); + extern BOOL HText_LastLineEmpty(HText *me, int IgnoreSpaces); + extern BOOL HText_PreviousLineEmpty(HText *me, int IgnoreSpaces); extern BOOL HText_inLineOne(HText *text); extern BOOLEAN HTLoadedDocumentIsHEAD(void); extern BOOLEAN HTLoadedDocumentIsSafe(void); @@ -163,8 +163,8 @@ US-ASCII control characters <32 which are not defined in Unicode standard 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); - extern int HText_PreviousLineSize(HText *me, BOOL IgnoreSpaces); + extern int HText_LastLineSize(HText *me, int IgnoreSpaces); + extern int HText_PreviousLineSize(HText *me, int IgnoreSpaces); extern int HText_getCurrentColumn(HText *text); extern int HText_getLines(HText *text); extern int HText_getMaximumColumn(HText *text); @@ -187,11 +187,11 @@ US-ASCII control characters <32 which are not defined in Unicode standard extern void HText_endStblCOLGROUP(HText *); extern void HText_endStblTD(HText *); extern void HText_endStblTR(HText *); - extern void HText_startStblCOL(HText *, int, short, BOOL); - extern void HText_startStblRowGroup(HText *, short); - extern void HText_startStblTABLE(HText *, short); - extern void HText_startStblTD(HText *, int, int, short, BOOL); - extern void HText_startStblTR(HText *, short); + extern void HText_startStblCOL(HText *, int, int, int); + extern void HText_startStblRowGroup(HText *, int); + extern void HText_startStblTABLE(HText *, int); + extern void HText_startStblTD(HText *, int, int, int, int); + extern void HText_startStblTR(HText *, int); /* forms stuff */ extern void HText_beginForm(char *action, @@ -202,18 +202,18 @@ US-ASCII control characters <32 which are not defined in Unicode standard extern void HText_endForm(HText *text); extern void HText_beginSelect(char *name, int name_cs, - BOOLEAN multiple, + int multiple, char *len); extern int HText_getOptionNum(HText *text); extern char *HText_setLastOptionValue(HText *text, char *value, char *submit_value, int order, - BOOLEAN checked, + int checked, int val_cs, int submit_val_cs); extern int HText_beginInput(HText *text, - BOOL underline, + int underline, InputFieldData * I); extern void HText_endInput(HText *text); extern int HText_SubmitForm(FormInfo * submit_item, DocInfo *doc, @@ -268,8 +268,8 @@ US-ASCII control characters <32 which are not defined in Unicode standard const char *target, const char *hightext, int flag, - BOOL inU, - BOOL utf_flag); + int inU, + int utf_flag); #ifdef USE_PRETTYSRC extern void HTMark_asSource(void); diff --git a/src/HTAlert.c b/src/HTAlert.c index d31002b9..d46f04e0 100644 --- a/src/HTAlert.c +++ b/src/HTAlert.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTAlert.c,v 1.90 2010/09/23 20:43:49 tom Exp $ + * $LynxId: HTAlert.c,v 1.92 2010/09/25 11:19:25 tom Exp $ * * Displaying messages and getting input for Lynx Browser * ========================================================== @@ -629,10 +629,10 @@ char *HTPrompt(const char *Msg, const char *deflt) _statusline(Msg); if (deflt) - strncpy(Tmp, deflt, sizeof(Tmp) - 1); + StrNCpy(Tmp, deflt, sizeof(Tmp) - 1); if (!dump_output_immediately) - LYgetstr(Tmp, VISIBLE, sizeof(Tmp), NORECALL); + LYGetStr(Tmp, VISIBLE, sizeof(Tmp), NORECALL); StrAllocCopy(rep, Tmp); @@ -652,7 +652,7 @@ char *HTPromptPassword(const char *Msg) if (!dump_output_immediately) { _statusline(Msg ? Msg : PASSWORD_PROMPT); - LYgetstr(pw, HIDDEN, sizeof(pw), NORECALL); /* hidden */ + LYGetStr(pw, HIDDEN, sizeof(pw), NORECALL); /* hidden */ StrAllocCopy(result, pw); } else { printf("\n%s\n", PASSWORD_REQUIRED); @@ -687,7 +687,7 @@ char *HTPromptPassword(const char *Msg) void HTPromptUsernameAndPassword(const char *Msg, char **username, char **password, - BOOL IsProxy) + int IsProxy) { if ((IsProxy == FALSE && authentication_info[0] && authentication_info[1]) || diff --git a/src/HTAlert.h b/src/HTAlert.h index 0e093bbd..a2ad1f59 100644 --- a/src/HTAlert.h +++ b/src/HTAlert.h @@ -1,4 +1,7 @@ -/* Displaying messages and getting input for WWW Library +/* + * $LynxId: HTAlert.h,v 1.33 2010/09/25 11:36:09 tom Exp $ + * + * Displaying messages and getting input for WWW Library * ===================================================== * * May 92 Created By C.T. Barker @@ -113,7 +116,7 @@ extern "C" { extern void HTPromptUsernameAndPassword(const char *Msg, char **username, char **password, - BOOL IsProxy); + int IsProxy); /* Confirm a cookie operation. HTConfirmCookie() * --------------------------- diff --git a/src/HTFWriter.c b/src/HTFWriter.c index 2398c882..6140d011 100644 --- a/src/HTFWriter.c +++ b/src/HTFWriter.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTFWriter.c,v 1.94 2010/09/22 22:53:58 tom Exp $ + * $LynxId: HTFWriter.c,v 1.97 2010/09/25 01:00:57 tom Exp $ * * FILE WRITER HTFWrite.h * =========== @@ -109,7 +109,7 @@ static void HTFWriter_error(HTStream *me, const char *id) /* Character handling * ------------------ */ -static void HTFWriter_put_character(HTStream *me, char c) +static void HTFWriter_put_character(HTStream *me, int c) { if (me->fp) { putc(c, me->fp); @@ -134,7 +134,7 @@ static void HTFWriter_write(HTStream *me, const char *s, int l) size_t result; if (me->fp) { - result = fwrite(s, 1, (unsigned) l, me->fp); + result = fwrite(s, (size_t) 1, (size_t) l, me->fp); if (result != (size_t) l) { HTFWriter_error(me, "HTFWriter_write"); } @@ -610,7 +610,7 @@ HTStream *HTSaveAndExecute(HTPresentation *pres, if (!local_exec) { if (local_exec_on_local_files && (LYJumpFileURL || - !strncmp(anchor->address, "file://localhost", 16))) { + !StrNCmp(anchor->address, "file://localhost", 16))) { /* allow it to continue */ ; } else { @@ -653,7 +653,7 @@ HTStream *HTSaveAndExecute(HTPresentation *pres, me->fp = LYOpenTempRewrite(fnam, BIN_SUFFIX, BIN_W); } else { #if defined(WIN_EX) && !defined(__CYGWIN__) /* 1998/01/04 (Sun) */ - if (!strncmp(anchor->address, "file://localhost", 16)) { + if (!StrNCmp(anchor->address, "file://localhost", 16)) { /* 1998/01/23 (Fri) 17:38:26 */ unsigned char *cp, *view_fname; @@ -664,7 +664,7 @@ HTStream *HTSaveAndExecute(HTPresentation *pres, me->fp = NULL; view_fname = fnam + 3; - LYstrncpy(view_fname, anchor->address + 17, sizeof(fnam) - 5); + LYStrNCpy(view_fname, anchor->address + 17, sizeof(fnam) - 5); HTUnEscape(view_fname); if (strchr(view_fname, ':') == NULL) { @@ -1212,7 +1212,7 @@ HTStream *HTCompressed(HTPresentation *pres, (local_exec || (local_exec_on_local_files && (LYJumpFileURL || - !strncmp(anchor->address, "file://localhost", 16)))))) + !StrNCmp(anchor->address, "file://localhost", 16)))))) #endif /* EXEC_LINKS || EXEC_SCRIPTS */ ) { StrAllocCopy(me->viewer_command, Pres->command); diff --git a/src/HTForms.h b/src/HTForms.h index ec994051..59903231 100644 --- a/src/HTForms.h +++ b/src/HTForms.h @@ -1,5 +1,5 @@ /* - * $LynxId: HTForms.h,v 1.27 2009/05/28 22:49:51 tom Exp $ + * $LynxId: HTForms.h,v 1.28 2010/09/24 09:40:07 tom Exp $ */ #ifndef HTFORMS_H #define HTFORMS_H @@ -16,15 +16,15 @@ extern "C" { */ extern int change_form_link(int cur, DocInfo *newdoc, BOOLEAN *refresh_screen, - BOOLEAN use_last_tfpos, - BOOLEAN immediate_submit); + int use_last_tfpos, + int immediate_submit); extern int change_form_link_ex(int cur, DocInfo *newdoc, BOOLEAN *refresh_screen, - BOOLEAN use_last_tfpos, - BOOLEAN immediate_submit, - BOOLEAN draw_only); + int use_last_tfpos, + int immediate_submit, + int draw_only); /* InputFieldData is used to pass the info between HTML.c and Gridtext.c in * HText_beginInput() diff --git a/src/HTInit.c b/src/HTInit.c index 4d6e921a..4989be12 100644 --- a/src/HTInit.c +++ b/src/HTInit.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTInit.c,v 1.73 2010/06/17 08:13:52 tom Exp $ + * $LynxId: HTInit.c,v 1.77 2010/09/25 18:08:10 tom Exp $ * * Configuration-specific Initialization HTInit.c * ---------------------------------------- @@ -43,13 +43,13 @@ static int HTLoadExtensionsConfigFile(char *fn); HTSetSuffix5(suffix, mimetype, type, description, 1.0) #define SET_PRESENT(mimetype, command, quality, delay) \ - HTSetPresentation(mimetype, command, 0, quality, delay, 0.0, 0, media) + HTSetPresentation(mimetype, command, 0, quality, delay, 0.0, 0L, media) #define SET_EXTERNL(rep_in, rep_out, command, quality) \ - HTSetConversion(rep_in, rep_out, command, quality, 3.0, 0.0, 0, mediaEXT) + HTSetConversion(rep_in, rep_out, command, quality, 3.0, 0.0, 0L, mediaEXT) #define SET_INTERNL(rep_in, rep_out, command, quality) \ - HTSetConversion(rep_in, rep_out, command, quality, 0.0, 0.0, 0, mediaINT) + HTSetConversion(rep_in, rep_out, command, quality, 0.0, 0.0, 0L, mediaINT) void HTFormatInit(void) { @@ -581,7 +581,7 @@ static char *LYGetContentType(const char *name, test = LYSkipCBlanks(test); next = LYSkipToken(test); if ((next - test) == (int) length - && !strncmp(test, name, length)) { + && !StrNCmp(test, name, length)) { found = TRUE; } test = LYSkipCBlanks(next); @@ -1397,11 +1397,13 @@ static int HTGetLine(char *s, int n, FILE *f) } } -static void HTGetWord(char *word, char *line, char stop, char stop2) +static void HTGetWord(char *word, char *line, int stop, int stop2) { int x = 0, y; - for (x = 0; line[x] && line[x] != stop && line[x] != stop2; x++) { + for (x = 0; (line[x] + && UCH(line[x]) != UCH(stop) + && UCH(line[x]) != UCH(stop2)); x++) { word[x] = line[x]; } @@ -1410,7 +1412,9 @@ static void HTGetWord(char *word, char *line, char stop, char stop2) ++x; y = 0; - while ((line[y++] = line[x++])) ; + while ((line[y++] = line[x++])) { + ; + } return; } @@ -1430,7 +1434,7 @@ static int HTLoadExtensionsConfigFile(char *fn) return count; } - while (!(HTGetLine(line, sizeof(line), f))) { + while (!(HTGetLine(line, (int) sizeof(line), f))) { HTGetWord(word, line, ' ', '\t'); if (line[0] == '\0' || word[0] == '#') continue; diff --git a/src/HTML.c b/src/HTML.c index 3981724e..e578c6b0 100644 --- a/src/HTML.c +++ b/src/HTML.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTML.c,v 1.141 2010/09/23 09:18:00 tom Exp $ + * $LynxId: HTML.c,v 1.146 2010/09/25 17:00:36 tom Exp $ * * Structured stream to Rich hypertext converter * ============================================ @@ -287,14 +287,18 @@ void LYShowBadHTML(const char *message) /* Character handling * ------------------ */ -void HTML_put_character(HTStructured * me, char c) +void HTML_put_character(HTStructured * me, int c) { + unsigned uc = UCH(c); + /* * Ignore all non-MAP content when just scanning a document for MAPs. - FM */ if (LYMapsOnly && me->sp[0].tag_number != HTML_OBJECT) return; + c = (int) uc; + /* * Do EOL conversion if needed. - FM * @@ -323,7 +327,7 @@ void HTML_put_character(HTStructured * me, char c) if (c == LY_SOFT_HYPHEN) return; if (c != '\n' && c != '\t' && c != '\r') { - HTChunkPutc(&me->title, UCH(c)); + HTChunkPutc(&me->title, uc); } else if (FIX_JAPANESE_SPACES) { if (c == '\t') { HTChunkPutc(&me->title, ' '); @@ -336,28 +340,28 @@ void HTML_put_character(HTStructured * me, char c) return; case HTML_STYLE: - HTChunkPutc(&me->style_block, UCH(c)); + HTChunkPutc(&me->style_block, uc); return; case HTML_SCRIPT: - HTChunkPutc(&me->script, UCH(c)); + HTChunkPutc(&me->script, uc); return; case HTML_OBJECT: - HTChunkPutc(&me->object, UCH(c)); + HTChunkPutc(&me->object, uc); return; case HTML_TEXTAREA: - HTChunkPutc(&me->textarea, UCH(c)); + HTChunkPutc(&me->textarea, uc); return; case HTML_SELECT: case HTML_OPTION: - HTChunkPutc(&me->option, UCH(c)); + HTChunkPutc(&me->option, uc); return; case HTML_MATH: - HTChunkPutc(&me->math, UCH(c)); + HTChunkPutc(&me->math, uc); return; default: @@ -375,7 +379,7 @@ void HTML_put_character(HTStructured * me, char c) */ if (me->sp[0].tag_number == HTML_A) break; - HTChunkPutc(&me->option, UCH(c)); + HTChunkPutc(&me->option, uc); return; } break; @@ -770,7 +774,7 @@ static void addClassName(const char *prefix, #ifdef USE_PRETTYSRC -static void HTMLSRC_apply_markup(HTStructured * context, HTlexeme lexeme, BOOL start, +static void HTMLSRC_apply_markup(HTStructured * context, HTlexeme lexeme, int start, int tag_charset) { HT_tagspec *ts = *((start ? lexeme_start : lexeme_end) + lexeme); @@ -787,18 +791,19 @@ static void HTMLSRC_apply_markup(HTStructured * context, HTlexeme lexeme, BOOL s CTRACE((tfp, ts->start ? "SRCSTART %d\n" : "SRCSTOP %d\n", (int) lexeme)); if (ts->start) HTML_start_element(context, - ts->element, + (int) ts->element, ts->present, (const char **) ts->value, tag_charset, NULL); else HTML_end_element(context, - ts->element, + (int) ts->element, NULL); ts = ts->next; } } + # define START TRUE # define STOP FALSE @@ -841,12 +846,12 @@ static void LYStartArea(HTStructured * obj, const char *href, static void LYHandleFIG(HTStructured * me, const BOOL *present, const char **value, - BOOL isobject, - BOOL imagemap, + int isobject, + int imagemap, const char *id, const char *src, - BOOL convert, - BOOL start, + int convert, + int start, BOOL *intern_flag GCC_UNUSED) { if (start == TRUE) { @@ -1009,7 +1014,7 @@ static int HTML_start_element(HTStructured * me, int element_number, if (tagname_transform != 0) PUTS(tag->name); else { - LYstrncpy(buf, tag->name, sizeof(buf) - 1); + LYStrNCpy(buf, tag->name, sizeof(buf) - 1); LYLowerCase(buf); PUTS(buf); } @@ -1021,7 +1026,7 @@ static int HTML_start_element(HTStructured * me, int element_number, if (attrname_transform != 0) PUTS(tag->attributes[i].name); else { - LYstrncpy(buf, + LYStrNCpy(buf, tag->attributes[i].name, sizeof(buf) - 1); LYLowerCase(buf); @@ -1103,7 +1108,7 @@ static int HTML_start_element(HTStructured * me, int element_number, addClassName(";", HTML_dtd.tags[element_number].name, - HTML_dtd.tags[element_number].name_len); + (size_t) HTML_dtd.tags[element_number].name_len); class_name = (force_classname ? forced_classname : class_string); force_classname = FALSE; @@ -1240,7 +1245,7 @@ static int HTML_start_element(HTStructured * me, int element_number, * Create the host[:port] field. */ temp = HTParse(base, "", PARSE_HOST + PARSE_PUNCTUATION); - if (!strncmp(temp, "//", 2)) { + if (!StrNCmp(temp, "//", 2)) { StrAllocCat(me->base_href, temp); if (!strcmp(me->base_href, "file://")) { StrAllocCat(me->base_href, "localhost"); @@ -2914,7 +2919,7 @@ static int HTML_start_element(HTStructured * me, int element_number, /* * Deal with our ftp gateway kludge. - FM */ - if (!url_type && !strncmp(href, "/foo/..", 7) && + if (!url_type && !StrNCmp(href, "/foo/..", 7) && (isFTP_URL(me->node_anchor->address) || isFILE_URL(me->node_anchor->address))) { for (i = 0; (href[i] = href[i + 7]) != 0; i++) ; @@ -5641,7 +5646,7 @@ static int HTML_end_element(HTStructured * me, int element_number, if (tagname_transform != 0) PUTS(tag->name); else { - LYstrncpy(buf, tag->name, sizeof(buf) - 1); + LYStrNCpy(buf, tag->name, sizeof(buf) - 1); LYLowerCase(buf); PUTS(buf); } @@ -6296,7 +6301,7 @@ static int HTML_end_element(HTStructured * me, int element_number, * up if invalid comments are present in the content, or if an * OBJECT end tag is present in a quoted attribute. - FM */ - if (!strncmp(cp, "<!--", 4)) { + if (!StrNCmp(cp, "<!--", 4)) { data = LYFindEndOfComment(cp); cp = data; } else if (s == 0 && !strncasecomp(cp, "<PARAM", 6) && @@ -7760,7 +7765,7 @@ HTStructured *HTML_new(HTParentAnchor *anchor, atexit(free_Style_className); } #endif - addClassName("", "", 0); + addClassName("", "", (size_t) 0); class_string[0] = '\0'; #endif @@ -7913,7 +7918,7 @@ static void CacheThru_abort(HTStream *me, HTError e) /* * FIXME: never used! */ -static void CacheThru_put_character(HTStream *me, char c_in) +static void CacheThru_put_character(HTStream *me, int c_in) { if (me->status == HT_OK) { if (me->fp) { @@ -7948,7 +7953,7 @@ static void CacheThru_write(HTStream *me, const char *str, int l) { if (me->status == HT_OK && l != 0) { if (me->fp) { - if (fwrite(str, 1, (size_t) l, me->fp) < (size_t) l + if (fwrite(str, (size_t) 1, (size_t) l, me->fp) < (size_t) l || ferror(me->fp)) { me->status = HT_ERROR; } diff --git a/src/HTML.h b/src/HTML.h index 27c15d07..03eec899 100644 --- a/src/HTML.h +++ b/src/HTML.h @@ -1,4 +1,7 @@ -/* HTML to rich text converter for libwww +/* + * $LynxId: HTML.h,v 1.32 2010/09/25 11:36:37 tom Exp $ + * + * HTML to rich text converter for libwww * * THE HTML TO RTF OBJECT CONVERTER * @@ -213,7 +216,7 @@ extern "C" { /* * Semi-Private functions. - FM */ - extern void HTML_put_character(HTStructured * me, char c); + extern void HTML_put_character(HTStructured * me, int c); extern void HTML_put_string(HTStructured * me, const char *s); extern void HTML_write(HTStructured * me, const char *s, int l); extern int HTML_put_entity(HTStructured * me, int entity_number); diff --git a/src/LYBookmark.c b/src/LYBookmark.c index fb75d458..08420ead 100644 --- a/src/LYBookmark.c +++ b/src/LYBookmark.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYBookmark.c,v 1.66 2010/09/22 09:36:12 tom Exp $ + * $LynxId: LYBookmark.c,v 1.69 2010/09/25 11:19:25 tom Exp $ */ #include <HTUtils.h> #include <HTAlert.h> @@ -120,7 +120,7 @@ const 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)) { + && !StrNCmp(string_buffer, "ncsa-xmosaic-hotlist-format-1", 29)) { const char *newname; /* @@ -243,7 +243,7 @@ void save_bookmark_link(const char *address, FREE(bookmark_URL); return; } - LYstrncpy(filename_buffer, filename, sizeof(filename_buffer) - 1); + LYStrNCpy(filename_buffer, filename, sizeof(filename_buffer) - 1); } /* @@ -290,13 +290,13 @@ void save_bookmark_link(const char *address, default: break; } - LYstrncpy(string_buffer, tmp_buffer, sizeof(string_buffer) - 1); + LYStrNCpy(string_buffer, tmp_buffer, sizeof(string_buffer) - 1); } else { - LYstrncpy(string_buffer, title, sizeof(string_buffer) - 1); + LYStrNCpy(string_buffer, title, sizeof(string_buffer) - 1); } LYReduceBlanks(string_buffer); LYMBM_statusline(TITLE_PROMPT); - LYgetstr(string_buffer, VISIBLE, sizeof(string_buffer), NORECALL); + LYGetStr(string_buffer, VISIBLE, sizeof(string_buffer), NORECALL); if (*string_buffer == '\0') { LYMBM_statusline(CANCELLED); LYSleepMsg(); @@ -1057,7 +1057,7 @@ static char *title_convert8bit(const char *Title) for (; *p; p++) { char temp[2]; - LYstrncpy(temp, p, sizeof(temp) - 1); + LYStrNCpy(temp, p, sizeof(temp) - 1); if (UCH(*temp) <= 127) { StrAllocCat(comment, temp); StrAllocCat(ncr, temp); @@ -1065,7 +1065,7 @@ static char *title_convert8bit(const char *Title) long unicode; char replace_buf[32]; - if (UCTransCharStr(replace_buf, sizeof(replace_buf), *temp, + if (UCTransCharStr(replace_buf, (int) sizeof(replace_buf), *temp, charset_in, charset_out, YES) > 0) StrAllocCat(comment, replace_buf); diff --git a/src/LYCgi.c b/src/LYCgi.c index 11911267..e2a7dec6 100644 --- a/src/LYCgi.c +++ b/src/LYCgi.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYCgi.c,v 1.59 2010/09/22 22:51:03 tom Exp $ + * $LynxId: LYCgi.c,v 1.61 2010/09/25 00:54:31 tom Exp $ * Lynx CGI support LYCgi.c * ================ * @@ -212,7 +212,7 @@ static int LYLoadCGI(const char *arg, return (status); } else { - if (strncmp(arg, "lynxcgi://localhost", 19) == 0) { + if (StrNCmp(arg, "lynxcgi://localhost", 19) == 0) { StrAllocCopy(pgm, arg + 19); } else { StrAllocCopy(pgm, arg + 8); @@ -435,7 +435,7 @@ static int LYLoadCGI(const char *arg, if ((pid = fork()) > 0) { /* The good, */ ssize_t chars; - int total_chars; + off_t total_chars; close(fd2[1]); @@ -457,7 +457,7 @@ static int LYLoadCGI(const char *arg, remaining = BStrLen(anAnchor->post_data); while ((written = write(fd1[1], BStrData(anAnchor->post_data) + total_written, - (unsigned) remaining)) != 0) { + (size_t) remaining)) != 0) { if (written < 0) { #ifdef EINTR if (errno == EINTR) @@ -484,7 +484,7 @@ static int LYLoadCGI(const char *arg, close(fd1[1]); } - HTReadProgress(total_chars = 0, 0); + HTReadProgress(total_chars = 0, (off_t) 0); while ((chars = read(fd2[0], buf, sizeof(buf))) != 0) { if (chars < 0) { #ifdef EINTR @@ -499,7 +499,7 @@ static int LYLoadCGI(const char *arg, break; } total_chars += (int) chars; - HTReadProgress(total_chars, 0); + HTReadProgress(total_chars, (off_t) 0); CTRACE((tfp, "LYNXCGI: Rx: %.*s\n", (int) chars, buf)); (*target->isa->put_block) (target, buf, (int) chars); } diff --git a/src/LYCharSets.c b/src/LYCharSets.c index 900478e0..343625b4 100644 --- a/src/LYCharSets.c +++ b/src/LYCharSets.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYCharSets.c,v 1.64 2009/11/21 15:52:05 tom Exp $ + * $LynxId: LYCharSets.c,v 1.66 2010/09/25 12:46:05 tom Exp $ */ #include <HTUtils.h> #include <HTCJK.h> @@ -494,7 +494,7 @@ void HTMLSetCharacterHandling(int i) } #endif /* USE_SLANG */ - ena_csi((BOOLEAN) (LYlowest_eightbit[current_char_set] > 155)); + ena_csi(LYlowest_eightbit[current_char_set] > 155); /* some diagnostics */ if (TRACE) { @@ -565,18 +565,18 @@ static void HTMLSetRawModeDefault(int i) * character set and the current LYRawMode value. - FM */ void HTMLSetUseDefaultRawMode(int i, - BOOLEAN modeflag) + int modeflag) { if (LYCharSet_UC[i].enc != UCT_ENC_CJK) { int chndl = safeUCGetLYhndl_byMIME(UCAssume_MIMEcharset); if (i == chndl) - LYUseDefaultRawMode = modeflag; + LYUseDefaultRawMode = (BOOLEAN) modeflag; else LYUseDefaultRawMode = (BOOL) (!modeflag); } else /* CJK encoding: */ - LYUseDefaultRawMode = modeflag; + LYUseDefaultRawMode = (BOOLEAN) modeflag; return; } diff --git a/src/LYCharSets.h b/src/LYCharSets.h index 0b698be1..c7e83a97 100644 --- a/src/LYCharSets.h +++ b/src/LYCharSets.h @@ -1,5 +1,5 @@ /* - * $LynxId: LYCharSets.h,v 1.32 2009/11/21 15:52:05 tom Exp $ + * $LynxId: LYCharSets.h,v 1.33 2010/09/25 01:01:58 tom Exp $ */ #ifndef LYCHARSETS_H #define LYCHARSETS_H @@ -52,7 +52,7 @@ extern "C" { extern LYUCcharset LYCharSet_UC[]; extern int UCGetLYhndl_byAnyName(char *value); extern void HTMLSetCharacterHandling(int i); - extern void HTMLSetUseDefaultRawMode(int i, BOOLEAN modeflag); + extern void HTMLSetUseDefaultRawMode(int i, int modeflag); extern void HTMLUseCharacterSet(int i); extern UCode_t HTMLGetEntityUCValue(const char *name); extern void Set_HTCJK(const char *inMIMEname, const char *outMIMEname); diff --git a/src/LYCharUtils.c b/src/LYCharUtils.c index 92f8fe07..0b2c6382 100644 --- a/src/LYCharUtils.c +++ b/src/LYCharUtils.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYCharUtils.c,v 1.106 2010/09/22 08:35:31 tom Exp $ + * $LynxId: LYCharUtils.c,v 1.108 2010/09/24 09:56:59 tom Exp $ * * Functions associated with LYCharSets.c and the Lynx version of HTML.c - FM * ========================================================================== @@ -52,7 +52,7 @@ int OL_VOID = -29998; /* flag for whether a count is set */ * converts any angle-brackets to "<" or ">". - FM */ void LYEntify(char **str, - BOOLEAN isTITLE) + int isTITLE) { char *p = *str; char *q = NULL, *cp = NULL; @@ -356,7 +356,7 @@ char *LYFindEndOfComment(char *str) */ return NULL; - if (strncmp(str, "<!--", 4)) + if (StrNCmp(str, "<!--", 4)) /* * We don't have the start of a comment, so return the beginning of the * string. - FM @@ -465,7 +465,7 @@ void LYFillLocalFileURL(char **href, if (isEmpty(*href)) return; - if (!strcmp(*href, "//") || !strncmp(*href, "///", 3)) { + if (!strcmp(*href, "//") || !StrNCmp(*href, "///", 3)) { if (base != NULL && isFILE_URL(base)) { StrAllocCopy(temp, STR_FILE_URL); StrAllocCat(temp, *href); @@ -477,10 +477,10 @@ void LYFillLocalFileURL(char **href, StrAllocCat(*href, "//localhost"); } else if (!strcmp(*href, "file://")) { StrAllocCat(*href, "localhost"); - } else if (!strncmp(*href, "file:///", 8)) { + } else if (!StrNCmp(*href, "file:///", 8)) { StrAllocCopy(temp, (*href + 7)); LYLocalFileToURL(href, temp); - } else if (!strncmp(*href, "file:/", 6) && !LYIsHtmlSep(*(*href + 6))) { + } else if (!StrNCmp(*href, "file:/", 6) && !LYIsHtmlSep(*(*href + 6))) { StrAllocCopy(temp, (*href + 5)); LYLocalFileToURL(href, temp); } @@ -496,7 +496,7 @@ void LYFillLocalFileURL(char **href, } /* use below: strlen("file://localhost/") = 17 */ - if (!strncmp(*href, "file://localhost/", 17) + if (!StrNCmp(*href, "file://localhost/", 17) && (strlen(*href) == 19) && LYIsDosDrive(*href + 17)) { /* @@ -1074,11 +1074,11 @@ static const char *hex = "0123456789ABCDEF"; char **LYUCFullyTranslateString(char **str, int cs_from, int cs_to, - BOOLEAN do_ent, - BOOL use_lynx_specials, - BOOLEAN plain_space, - BOOLEAN hidden, - BOOL Back, + int do_ent, + int use_lynx_specials, + int plain_space, + int hidden, + int Back, CharUtil_st stype) { char *p; @@ -1679,7 +1679,8 @@ char **LYUCFullyTranslateString(char **str, */ } else if (code == 8204 || code == 8205 || code == 8206 || code == 8207) { - CTRACE((tfp, "LYUCFullyTranslateString: Ignoring '%ld'.\n", code)); + CTRACE((tfp, "LYUCFullyTranslateString: Ignoring '%" + PRI_UCode_t "'.\n", code)); replace_buf[0] = '\0'; state = S_got_outstring; break; @@ -1752,7 +1753,7 @@ char **LYUCFullyTranslateString(char **str, } else if (!T.output_utf8 && stype == st_HTML && !hidden && !(HTPassEightBitRaw && UCH(*p) >= lowest_8)) { - sprintf(replace_buf, "U%.2lX", code); + sprintf(replace_buf, "U%.2" PRI_UCode_t "", code); state = S_got_outstring; } else { puni = p; @@ -1904,9 +1905,9 @@ char **LYUCFullyTranslateString(char **str, BOOL LYUCTranslateHTMLString(char **str, int cs_from, int cs_to, - BOOL use_lynx_specials, - BOOLEAN plain_space, - BOOLEAN hidden, + int use_lynx_specials, + int plain_space, + int hidden, CharUtil_st stype) { BOOL ret = YES; @@ -1923,7 +1924,7 @@ BOOL LYUCTranslateHTMLString(char **str, BOOL LYUCTranslateBackFormData(char **str, int cs_from, int cs_to, - BOOLEAN plain_space) + int plain_space) { char **ret; @@ -2323,12 +2324,12 @@ void LYHandleMETA(HTStructured * me, const BOOL *present, * be like ISO-8859 in structure, pretend we have some kind of * match. */ - BOOL given_is_8859 = (BOOL) (!strncmp(cp4, "iso-8859-", 9) && + BOOL given_is_8859 = (BOOL) (!StrNCmp(cp4, "iso-8859-", 9) && isdigit(UCH(cp4[9]))); BOOL given_is_8859like = (BOOL) (given_is_8859 - || !strncmp(cp4, "windows-", 8) - || !strncmp(cp4, "cp12", 4) - || !strncmp(cp4, "cp-12", 5)); + || !StrNCmp(cp4, "windows-", 8) + || !StrNCmp(cp4, "cp12", 4) + || !StrNCmp(cp4, "cp-12", 5)); BOOL given_and_display_8859like = (BOOL) (given_is_8859like && (strstr(LYchar_set_names[current_char_set], "ISO-8859") || @@ -2428,7 +2429,7 @@ void LYHandleMETA(HTStructured * me, const BOOL *present, #ifndef DONT_TRACK_INTERNAL_LINKS /* id_string seems to be used wrong below if given. not that it matters much. avoid setting it here. - kw */ - if ((strncmp(href, "http", 4) == 0) && + if ((StrNCmp(href, "http", 4) == 0) && (cp = strchr(href, '#')) != NULL) { StrAllocCopy(id_string, cp); *cp = '\0'; @@ -2564,7 +2565,7 @@ void LYHandlePlike(HTStructured * me, const BOOL *present, const char **value, char **include GCC_UNUSED, int align_idx, - BOOL start) + int start) { if (TRUE) { /* @@ -2670,7 +2671,7 @@ void LYHandlePlike(HTStructured * me, const BOOL *present, void LYHandleSELECT(HTStructured * me, const BOOL *present, const char **value, char **include GCC_UNUSED, - BOOL start) + int start) { int i; @@ -2861,8 +2862,8 @@ void LYHandleSELECT(HTStructured * me, const BOOL *present, * URLs. - FM */ int LYLegitimizeHREF(HTStructured * me, char **href, - BOOL force_slash, - BOOL strip_dots) + int force_slash, + int strip_dots) { int url_type = 0; char *p = NULL; @@ -2956,7 +2957,7 @@ int LYLegitimizeHREF(HTStructured * me, char **href, temp = HTParse(*href, Base, PARSE_ALL); path = HTParse(temp, "", PARSE_PATH + PARSE_PUNCTUATION); - if (!strncmp(path, "/..", 3)) { + if (!StrNCmp(path, "/..", 3)) { cp = (path + 3); if (LYIsHtmlSep(*cp) || *cp == '\0') { if (Base[4] == 's') { @@ -2974,7 +2975,7 @@ int LYLegitimizeHREF(HTStructured * me, char **href, if (*cp == '\0') { StrAllocCopy(*href, "/"); } else if (LYIsHtmlSep(*cp)) { - while (!strncmp(cp, "/..", 3)) { + while (!StrNCmp(cp, "/..", 3)) { if (*(cp + 3) == '/') { cp += 3; continue; @@ -3281,7 +3282,7 @@ BOOLEAN LYCommentHacks(HTParentAnchor *anchor, if (!(anchor && anchor->address)) return FALSE; - if (strncmp(comment, "!--X-Message-Id: ", 17) == 0) { + if (StrNCmp(comment, "!--X-Message-Id: ", 17) == 0) { char *messageid = NULL; char *p; @@ -3326,7 +3327,7 @@ BOOLEAN LYCommentHacks(HTParentAnchor *anchor, return FALSE; } } - if (strncmp(comment, "!--X-Subject: ", 14) == 0) { + if (StrNCmp(comment, "!--X-Subject: ", 14) == 0) { char *subject = NULL; char *p; diff --git a/src/LYCharUtils.h b/src/LYCharUtils.h index 6209778e..ccafda37 100644 --- a/src/LYCharUtils.h +++ b/src/LYCharUtils.h @@ -1,5 +1,5 @@ /* - * $LynxId: LYCharUtils.h,v 1.24 2009/01/19 23:53:27 tom Exp $ + * $LynxId: LYCharUtils.h,v 1.26 2010/09/24 09:57:20 tom Exp $ */ #ifndef LYCHARUTILS_H #define LYCHARUTILS_H @@ -21,25 +21,25 @@ extern "C" { extern char **LYUCFullyTranslateString(char **str, int cs_from, int cs_to, - BOOLEAN do_ent, - BOOL use_lynx_specials, - BOOLEAN plain_space, - BOOLEAN hidden, - BOOL Back, + int do_ent, + int use_lynx_specials, + int plain_space, + int hidden, + int Back, CharUtil_st stype); extern BOOL LYUCTranslateHTMLString(char **str, int cs_from, int cs_to, - BOOL use_lynx_specials, - BOOLEAN plain_space, - BOOLEAN hidden, + int use_lynx_specials, + int plain_space, + int hidden, CharUtil_st stype); extern BOOL LYUCTranslateBackFormData(char **str, int cs_from, int cs_to, - BOOLEAN plain_space); + int plain_space); extern void LYEntify(char **str, - BOOLEAN isTITLE); + int isTITLE); extern const char *LYEntifyTitle(char **target, const char *source); extern const char *LYEntifyValue(char **target, const char *source); extern void LYTrimHead(char *str); @@ -73,14 +73,14 @@ extern "C" { const char **value, char **include, int align_idx, - BOOL start); + int start); extern void LYHandleSELECT(HTStructured * me, const BOOL *present, const char **value, char **include, - BOOL start); + int start); extern int LYLegitimizeHREF(HTStructured * me, char **href, - BOOL force_slash, - BOOL strip_dots); + int force_slash, + int strip_dots); extern void LYCheckForContentBase(HTStructured * me); extern void LYCheckForID(HTStructured * me, const BOOL *present, const char **value, diff --git a/src/LYCookie.c b/src/LYCookie.c index 04f18313..cbc7f80c 100644 --- a/src/LYCookie.c +++ b/src/LYCookie.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYCookie.c,v 1.102 2010/09/22 21:24:00 tom Exp $ + * $LynxId: LYCookie.c,v 1.105 2010/09/24 23:53:47 tom Exp $ * * Lynx Cookie Support LYCookie.c * =================== @@ -134,7 +134,7 @@ static void MemAllocCopy(char **dest, temp = typecallocn(char, (unsigned)(end - start) + 1); if (temp == NULL) outofmem(__FILE__, "MemAllocCopy"); - LYstrncpy(temp, start, (int) (end - start)); + LYStrNCpy(temp, start, (int) (end - start)); HTSACopy(dest, temp); FREE(temp); } @@ -285,7 +285,7 @@ static BOOL is_prefix(const char *a, const char *b) if (len_a > len_b) { return FALSE; } else { - if (strncmp(a, b, (unsigned) len_a) != 0) { + if (StrNCmp(a, b, (unsigned) len_a) != 0) { return FALSE; } if (len_a < len_b && (len_a > 1 || a[0] != '/')) { @@ -670,7 +670,7 @@ static char *scan_cookie_sublist(char *hostname, int port, HTList *sublist, char *header, - BOOL secure) + int secure) { HTList *hl; cookie *co; @@ -857,7 +857,7 @@ static char *alloc_attr_value(const char *value_start, if (value == NULL) outofmem(__FILE__, "LYProcessSetCookies"); - LYstrncpy(value, value_start, value_len); + LYStrNCpy(value, value_start, value_len); } return value; } @@ -1837,7 +1837,7 @@ void LYSetCookie(const char *SetCookie, char *LYAddCookieHeader(char *hostname, char *path, int port, - BOOL secure) + int secure) { char *header = NULL; HTList *hl = domain_list, *next = NULL; @@ -1955,7 +1955,7 @@ void LYLoadCookies(char *cookie_file) for (tok_loop = 0; tok_out && tok_values[tok_loop].s; tok_loop++) { CTrace((tfp, "\t%d:[%03d]:[%s]\n", tok_loop, (int) (tok_out - buf), tok_out)); - LYstrncpy(tok_values[tok_loop].s, + LYStrNCpy(tok_values[tok_loop].s, tok_out, (int) tok_values[tok_loop].n); /* diff --git a/src/LYCookie.h b/src/LYCookie.h index 3b0e109b..e1bf835f 100644 --- a/src/LYCookie.h +++ b/src/LYCookie.h @@ -1,3 +1,4 @@ +/* $LynxId: LYCookie.h,v 1.19 2010/09/25 11:35:24 tom Exp $ */ #ifndef LYCOOKIES_H #define LYCOOKIES_H @@ -46,7 +47,7 @@ extern "C" { extern char *LYAddCookieHeader(char *hostname, char *partialpath, int port, - BOOL secure); + int secure); extern void LYStoreCookies(char *cookie_file); extern void LYLoadCookies(char *cookie_file); extern void LYConfigCookies(void); diff --git a/src/LYCurses.c b/src/LYCurses.c index 347f8749..24da4743 100644 --- a/src/LYCurses.c +++ b/src/LYCurses.c @@ -1,4 +1,4 @@ -/* $LynxId: LYCurses.c,v 1.153 2010/09/23 09:06:19 tom Exp $ */ +/* $LynxId: LYCurses.c,v 1.156 2010/09/25 00:48:03 tom Exp $ */ #include <HTUtils.h> #include <HTAlert.h> @@ -295,7 +295,7 @@ static char *attr_to_string(int code) /* * This function boxes windows for (n)curses. */ -void LYbox(WINDOW * win, BOOLEAN formfield GCC_UNUSED) +void LYbox(WINDOW * win, int formfield GCC_UNUSED) { #ifdef USE_SLANG SLsmg_draw_box(win->top_y, @@ -1576,7 +1576,7 @@ BOOLEAN setup(char *terminal) printf("%s%s\n", gettext("Terminal ="), term); if ((strlen(term) < 5) || - strncmp(term, "vt", 2) || !isdigit(term[2])) { + StrNCmp(term, "vt", 2) || !isdigit(term[2])) { printf("%s\n", gettext("You must use a vt100, 200, etc. terminal with this program.")); printf(CONFIRM_PROCEED, "n/y"); @@ -1658,7 +1658,7 @@ BOOLEAN setup(char *terminal) * from all other links. The workaround here is to disable the 'rev' * capability. */ - if ((strncmp((const char *) ttytype, "sun", 3) == 0)) { + if ((StrNCmp((const char *) ttytype, "sun", 3) == 0)) { LYnoVideo(2); } #endif /* HAVE_TTYTYPE */ @@ -1993,7 +1993,7 @@ static int LYstrExtent0(const char *string, int len, int maxCells GCC_UNUSED, - BOOL retCellNum GCC_UNUSED) + int retCellNum GCC_UNUSED) { int used = (len < 0 ? (int) strlen(string) : len); int result = used; diff --git a/src/LYCurses.h b/src/LYCurses.h index c1377994..9bb6d814 100644 --- a/src/LYCurses.h +++ b/src/LYCurses.h @@ -1,4 +1,4 @@ -/* $LynxId: LYCurses.h,v 1.84 2010/09/23 09:06:29 tom Exp $ */ +/* $LynxId: LYCurses.h,v 1.85 2010/09/25 00:48:03 tom Exp $ */ #ifndef LYCURSES_H #define LYCURSES_H @@ -338,7 +338,7 @@ extern "C" { #define LYstopPopup() LYsubwindow(0) #endif /* NCURSES */ - extern void LYbox(WINDOW * win, BOOLEAN formfield); + extern void LYbox(WINDOW * win, int formfield); extern WINDOW *LYstartPopup(int *top_y, int *left_x, int *height, int *width); /* diff --git a/src/LYDownload.c b/src/LYDownload.c index 18dc5f5f..7822cdea 100644 --- a/src/LYDownload.c +++ b/src/LYDownload.c @@ -1,4 +1,4 @@ -/* $LynxId: LYDownload.c,v 1.59 2008/12/14 18:26:03 tom Exp $ */ +/* $LynxId: LYDownload.c,v 1.62 2010/09/25 11:19:25 tom Exp $ */ #include <HTUtils.h> #include <HTParse.h> #include <HTList.h> @@ -88,9 +88,9 @@ void LYDownload(char *line) } #if defined(DIRED_SUPPORT) /* FIXME: use HTLocalName */ - if (!strncmp(file, "file://localhost", 16)) { + if (!StrNCmp(file, "file://localhost", 16)) { #ifdef __DJGPP__ - if (!strncmp(file + 16, "/dev/", 5)) + if (!StrNCmp(file + 16, "/dev/", 5)) file += 16; else { file += 17; @@ -104,9 +104,9 @@ void LYDownload(char *line) HTUnEscape(file); #else #if defined(_WINDOWS) /* 1997/10/15 (Wed) 16:27:38 */ - if (!strncmp(file, "file://localhost/", 17)) + if (!StrNCmp(file, "file://localhost/", 17)) file += 17; - else if (!strncmp(file, "file:/", 6)) + else if (!StrNCmp(file, "file:/", 6)) file += 6; HTUnEscape(file); #endif /* _WINDOWS */ @@ -134,11 +134,11 @@ void LYDownload(char *line) _statusline(FILENAME_PROMPT); retry: if (sug_file) - LYstrncpy(buffer, sug_file, ((sizeof(buffer) / 2) - 1)); + LYStrNCpy(buffer, sug_file, ((sizeof(buffer) / 2) - 1)); else *buffer = '\0'; check_recall: - if ((ch = LYgetstr(buffer, + if ((ch = LYGetStr(buffer, VISIBLE, (sizeof(buffer) / 2), recall)) < 0 || *buffer == '\0' || ch == UPARROW || ch == DNARROW) { if (recall && ch == UPARROW) { @@ -165,7 +165,7 @@ void LYDownload(char *line) goto retry; } else if ((cp = (char *) HTList_objectAt(sug_filenames, FnameNum)) != NULL) { - LYstrncpy(buffer, cp, sizeof(buffer) - 1); + LYStrNCpy(buffer, cp, sizeof(buffer) - 1); if (FnameTotal == 1) { _statusline(EDIT_THE_PREV_FILENAME); } else { @@ -197,7 +197,7 @@ void LYDownload(char *line) goto retry; } else if ((cp = (char *) HTList_objectAt(sug_filenames, FnameNum)) != NULL) { - LYstrncpy(buffer, cp, sizeof(buffer) - 1); + LYStrNCpy(buffer, cp, sizeof(buffer) - 1); if (FnameTotal == 1) { _statusline(EDIT_THE_PREV_FILENAME); } else { @@ -301,12 +301,12 @@ void LYDownload(char *line) _statusline(FILENAME_PROMPT); again: if (sug_file) { - strncpy(buffer, sug_file, (sizeof(buffer) / 2) - 1); + StrNCpy(buffer, sug_file, (sizeof(buffer) / 2) - 1); } else { *buffer = '\0'; } check_again: - if ((ch = LYgetstr(buffer, VISIBLE, + if ((ch = LYGetStr(buffer, VISIBLE, sizeof(buffer), recall)) < 0 || *buffer == '\0' || ch == UPARROW || ch == DNARROW) { if (recall && ch == UPARROW) { @@ -334,7 +334,7 @@ void LYDownload(char *line) } else if ((cp = (char *) HTList_objectAt(sug_filenames, FnameNum)) != NULL) { - LYstrncpy(buffer, cp, sizeof(buffer) - 1); + LYStrNCpy(buffer, cp, sizeof(buffer) - 1); if (FnameTotal == 1) { _statusline(EDIT_THE_PREV_FILENAME); } else { @@ -367,7 +367,7 @@ void LYDownload(char *line) } else if ((cp = (char *) HTList_objectAt(sug_filenames, FnameNum)) != NULL) { - LYstrncpy(buffer, cp, sizeof(buffer) - 1); + LYStrNCpy(buffer, cp, sizeof(buffer) - 1); if (FnameTotal == 1) { _statusline(EDIT_THE_PREV_FILENAME); } else { @@ -429,7 +429,7 @@ void LYDownload(char *line) if (SecondS == TRUE) { #ifdef VMS if (0 == strncasecomp(buffer, "sys$disk:", 9)) { - if (0 == strncmp((buffer + 9), "[]", 2)) { + if (0 == StrNCmp((buffer + 9), "[]", 2)) { HTAddSugFilename(buffer + 11); } else { HTAddSugFilename(buffer + 9); @@ -494,7 +494,7 @@ int LYdownload_options(char **newfile, char *data_file) StrAllocCopy(downloaded_url, *newfile); LYLocalFileToURL(newfile, tempfile); - LYstrncpy(LYValidDownloadFile, + LYStrNCpy(LYValidDownloadFile, data_file, (sizeof(LYValidDownloadFile) - 1)); LYforce_no_cache = TRUE; /* don't cache this doc */ diff --git a/src/LYEdit.c b/src/LYEdit.c index 4763652f..0b1780bb 100644 --- a/src/LYEdit.c +++ b/src/LYEdit.c @@ -1,4 +1,4 @@ -/* $LynxId: LYEdit.c,v 1.40 2009/11/22 17:25:19 tom Exp $ */ +/* $LynxId: LYEdit.c,v 1.41 2010/09/24 00:07:26 tom Exp $ */ #include <HTUtils.h> #include <HTParse.h> #include <HTAlert.h> @@ -116,7 +116,7 @@ int edit_current_file(char *newfile, goto done; } #else /* something like UNIX */ - if (strncmp(newfile, "file://localhost/", 16) == 0) + if (StrNCmp(newfile, "file://localhost/", 16) == 0) colon = newfile + 16; else colon = strchr(newfile, ':'); @@ -214,14 +214,14 @@ void edit_temporary_file(char *filename, #endif } #ifdef DOSPATH - else if (strncmp(editor, "VZ", 2) == 0) { + else if (StrNCmp(editor, "VZ", 2) == 0) { /* for Vz editor */ format = "%s %s -%s"; HTAddXpand(&command, format, params++, editor); HTAddParam(&command, format, params++, HTDOS_short_name(filename)); HTAddParam(&command, format, params++, position); HTEndParam(&command, format, params); - } else if (strncmp(editor, "edit", 4) == 0) { + } else if (StrNCmp(editor, "edit", 4) == 0) { /* for standard editor */ HTAddXpand(&command, format, params++, editor); HTAddParam(&command, format, params++, HTDOS_short_name(filename)); diff --git a/src/LYExtern.c b/src/LYExtern.c index 0e5783c8..ba3492d3 100644 --- a/src/LYExtern.c +++ b/src/LYExtern.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYExtern.c,v 1.42 2009/01/01 22:07:00 tom Exp $ + * $LynxId: LYExtern.c,v 1.45 2010/09/25 00:54:06 tom Exp $ * External application support. This feature allows lynx to pass a given URL to an external program. @@ -170,7 +170,7 @@ static char *format_command(char *command, if (strnicmp("file://localhost/", param, 17) == 0) { /* decode local path parameter for programs to be able to interpret - TH */ - LYstrncpy(pram_string, param, sizeof(pram_string) - 1); + LYStrNCpy(pram_string, param, sizeof(pram_string) - 1); decode_string(pram_string); param = pram_string; } else { @@ -185,7 +185,7 @@ static char *format_command(char *command, char host[sizeof(pram_string)]; int last_pos; - LYstrncpy(host, param + 9, sizeof(host)); + LYStrNCpy(host, param + 9, sizeof(host)); last_pos = strlen(host) - 1; if (last_pos > 1 && host[last_pos] == '/') host[last_pos] = '\0'; @@ -236,7 +236,7 @@ static char *format_command(char *command, * allow the user to select one. Return the selected command. */ static char *lookup_external(char *param, - BOOL only_overriders) + int only_overriders) { int pass, num_disabled, num_matched, num_choices, cur_choice; int length = 0; @@ -310,7 +310,7 @@ static char *lookup_external(char *param, } BOOL run_external(char *param, - BOOL only_overriders) + int only_overriders) { #ifdef WIN_EX int status; diff --git a/src/LYExtern.h b/src/LYExtern.h index e88bbd6d..89c84c9b 100644 --- a/src/LYExtern.h +++ b/src/LYExtern.h @@ -1,4 +1,4 @@ -/* $LynxId: LYExtern.h,v 1.13 2008/12/29 18:59:39 tom Exp $ */ +/* $LynxId: LYExtern.h,v 1.14 2010/09/24 09:39:20 tom Exp $ */ #ifndef EXTERNALS_H #define EXTERNALS_H @@ -9,7 +9,7 @@ #ifdef __cplusplus extern "C" { #endif - extern BOOL run_external(char *c, BOOL only_overriders); + extern BOOL run_external(char *c, int only_overriders); #ifdef __cplusplus } #endif diff --git a/src/LYForms.c b/src/LYForms.c index 17396902..21bb6b9f 100644 --- a/src/LYForms.c +++ b/src/LYForms.c @@ -1,4 +1,4 @@ -/* $LynxId: LYForms.c,v 1.85 2010/09/22 23:01:41 tom Exp $ */ +/* $LynxId: LYForms.c,v 1.86 2010/09/24 09:40:44 tom Exp $ */ #include <HTUtils.h> #include <HTCJK.h> #include <HTTP.h> @@ -27,8 +27,8 @@ #endif /* VMS && !USE_SLANG */ static int form_getstr(int cur, - BOOLEAN use_last_tfpos, - BOOLEAN redraw_only); + int use_last_tfpos, + int redraw_only); /* * Returns an array of pointers to the given list @@ -60,9 +60,9 @@ static char **options_list(OptionType * opt_ptr) int change_form_link_ex(int cur, DocInfo *newdoc, BOOLEAN *refresh_screen, - BOOLEAN use_last_tfpos, - BOOLEAN immediate_submit, - BOOLEAN redraw_only) + int use_last_tfpos, + int immediate_submit, + int redraw_only) { FormInfo *form = links[cur].l_form; char *link_name = form->name; @@ -341,8 +341,8 @@ int change_form_link_ex(int cur, int change_form_link(int cur, DocInfo *newdoc, BOOLEAN *refresh_screen, - BOOLEAN use_last_tfpos, - BOOLEAN immediate_submit) + int use_last_tfpos, + int immediate_submit) { /*pass all our args and FALSE as last arg */ return change_form_link_ex(cur, @@ -361,8 +361,8 @@ static void LYSetLastTFPos(int pos) } static int form_getstr(int cur, - BOOLEAN use_last_tfpos, - BOOLEAN redraw_only) + int use_last_tfpos, + int redraw_only) { FormInfo *form = links[cur].l_form; char *value = form->value; diff --git a/src/LYGetFile.c b/src/LYGetFile.c index 453d3731..7b312a4d 100644 --- a/src/LYGetFile.c +++ b/src/LYGetFile.c @@ -1,4 +1,4 @@ -/* $LynxId: LYGetFile.c,v 1.82 2010/09/23 22:43:44 tom Exp $ */ +/* $LynxId: LYGetFile.c,v 1.84 2010/09/25 11:19:25 tom Exp $ */ #include <HTUtils.h> #include <HTTP.h> #include <HTAnchor.h> /* Anchor class */ @@ -222,7 +222,7 @@ int getfile(DocInfo *doc, int *target) return (NULLFILE); } } else if (check_realm && !LYPermitURL && !LYJumpFileURL) { - if (!(0 == strncmp(startrealm, WWWDoc.address, + if (!(0 == StrNCmp(startrealm, WWWDoc.address, strlen(startrealm)) || url_type == LYNXHIST_URL_TYPE || url_type == LYNXKEYMAP_URL_TYPE || @@ -571,7 +571,7 @@ int getfile(DocInfo *doc, int *target) #endif url_type != LYNXCGI_URL_TYPE && !(url_type == NEWS_URL_TYPE && - strncmp(doc->address, "news://", 7)) && + StrNCmp(doc->address, "news://", 7)) && !(LYisLocalHost(doc->address) || LYisLocalAlias(doc->address))) { HTUserMsg(ACCESS_ONLY_LOCALHOST); @@ -670,7 +670,7 @@ int getfile(DocInfo *doc, int *target) *cp = '\0'; StrAllocCopy(temp, doc->address); cp += 3; - if (*cp && strncmp(cp, "%09", 3)) { + if (*cp && StrNCmp(cp, "%09", 3)) { StrAllocCat(temp, "?"); StrAllocCat(temp, cp); if ((cp = strstr(temp, "%09")) != NULL) { @@ -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 && - 0 == strncmp(++cp, "hGET%20/", 8)) { + 0 == StrNCmp(++cp, "hGET%20/", 8)) { StrAllocCopy(tmp, "http://"); CTRACE((tfp, "getfile: URL '%s'\n", doc->address)); @@ -1138,7 +1138,7 @@ int follow_link_number(int c, /* * Get the number, possibly with a letter suffix, from the user. */ - if (LYgetstr(temp, VISIBLE, sizeof(temp), NORECALL) < 0 || *temp == 0) { + if (LYGetStr(temp, VISIBLE, sizeof(temp), NORECALL) < 0 || *temp == 0) { HTInfoMsg(CANCELLED); return (DO_NOTHING); } diff --git a/src/LYHash.c b/src/LYHash.c index 4b86c6e6..9aaf146f 100644 --- a/src/LYHash.c +++ b/src/LYHash.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYHash.c,v 1.16 2008/12/31 22:10:38 tom Exp $ + * $LynxId: LYHash.c,v 1.17 2010/09/24 09:43:18 tom Exp $ * * A hash table for the (fake) CSS support in Lynx-rp * (c) 1996 Rob Partington @@ -40,7 +40,7 @@ int hash_code_lowercase_on_fly(const char *string) return hash; } -int hash_code_aggregate_char(char c, int hash) +int hash_code_aggregate_char(int c, int hash) { return HASH_OF(hash, c); } diff --git a/src/LYHash.h b/src/LYHash.h index c60e24d6..e961e83d 100644 --- a/src/LYHash.h +++ b/src/LYHash.h @@ -1,4 +1,4 @@ -/* $LynxId: LYHash.h,v 1.23 2007/07/22 23:08:36 tom Exp $ */ +/* $LynxId: LYHash.h,v 1.24 2010/09/24 10:57:49 tom Exp $ */ #ifndef _LYHASH_H_ #define _LYHASH_H_ 1 @@ -38,7 +38,7 @@ extern "C" { extern bucket nostyle_bucket; extern int hash_code_lowercase_on_fly(const char *string); - extern int hash_code_aggregate_char(char c, int hash); + extern int hash_code_aggregate_char(int c, int hash); extern int hash_code_aggregate_lower_str(const char *c, int hash_was); extern int s_a; diff --git a/src/LYHistory.c b/src/LYHistory.c index 34ec0b1a..b970dec1 100644 --- a/src/LYHistory.c +++ b/src/LYHistory.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYHistory.c,v 1.78 2010/09/22 10:49:45 tom Exp $ + * $LynxId: LYHistory.c,v 1.80 2010/09/25 11:22:51 tom Exp $ */ #include <HTUtils.h> #include <HTTP.h> @@ -111,8 +111,8 @@ void LYAddVisitedLink(DocInfo *doc) */ if (doc->post_data || doc->isHEAD || doc->bookmark || ( /* special url or a temp file */ - (!strncmp(doc->address, "LYNX", 4) || - !strncmp(doc->address, "file://localhost/", 17)))) { + (!StrNCmp(doc->address, "LYNX", 4) || + !StrNCmp(doc->address, "file://localhost/", 17)))) { int related = 1; /* First approximation only */ if (LYIsUIPage(doc->address, UIP_HISTORY) || @@ -243,7 +243,7 @@ BOOLEAN LYwouldPush(const char *title, if (docurl) { size_t ulen; - if (strncmp(docurl, "file://localhost/", 17) != 0 || + if (StrNCmp(docurl, "file://localhost/", 17) != 0 || (ulen = strlen(docurl)) <= strlen(HTML_SUFFIX) || strcmp(docurl + ulen - strlen(HTML_SUFFIX), HTML_SUFFIX) != 0) { /* @@ -350,9 +350,9 @@ void LYAllocHistory(int entries) want = (unsigned) size_history *(unsigned) sizeof(*history); if (history == 0) { - history = (HistInfo *) malloc(want); + history = typeMallocn(HistInfo, want); } else { - history = (HistInfo *) realloc(history, want); + history = typeRealloc(HistInfo, history, want); } if (history == 0) outofmem(__FILE__, "LYAllocHistory"); @@ -369,7 +369,7 @@ void LYAllocHistory(int entries) /* * Push the current filename, link and line number onto the history list. */ -int LYpush(DocInfo *doc, BOOLEAN force_push) +int LYpush(DocInfo *doc, int force_push) { /* * Don't push NULL file names. diff --git a/src/LYHistory.h b/src/LYHistory.h index 260ba45e..68ec5248 100644 --- a/src/LYHistory.h +++ b/src/LYHistory.h @@ -1,5 +1,5 @@ /* - * $LynxId: LYHistory.h,v 1.20 2009/06/07 16:57:13 tom Exp $ + * $LynxId: LYHistory.h,v 1.21 2010/09/25 00:45:55 tom Exp $ */ #ifndef LYHISTORY_H #define LYHISTORY_H @@ -15,7 +15,7 @@ extern "C" { extern BOOLEAN historytarget(DocInfo *newdoc); extern int LYShowVisitedLinks(char **newfile); extern int LYhist_next(DocInfo *doc, DocInfo *newdoc); - extern int LYpush(DocInfo *doc, BOOLEAN force_push); + extern int LYpush(DocInfo *doc, int force_push); extern int showhistory(char **newfile); extern void LYAddVisitedLink(DocInfo *doc); extern void LYAllocHistory(int entries); diff --git a/src/LYJump.c b/src/LYJump.c index dbf0dd67..e3346567 100644 --- a/src/LYJump.c +++ b/src/LYJump.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYJump.c,v 1.36 2010/05/02 20:17:37 tom Exp $ + * $LynxId: LYJump.c,v 1.39 2010/09/25 11:19:37 tom Exp $ */ #include <HTUtils.h> #include <HTAlert.h> @@ -230,7 +230,7 @@ char *LYJump(int key) } statusline(jtp->msg); - if ((ch = LYgetstr(buf, VISIBLE, (sizeof(buf) - 4), recall)) < 0) { + if ((ch = LYGetStr(buf, VISIBLE, (sizeof(buf) - 4), recall)) < 0) { /* * User cancelled the Jump via ^G. - FM */ @@ -240,7 +240,7 @@ char *LYJump(int key) check_recall: bp = buf; - if (TOUPPER(key) == 'G' && strncmp(buf, "o ", 2) == 0) + if (TOUPPER(key) == 'G' && StrNCmp(buf, "o ", 2) == 0) bp++; bp = LYSkipBlanks(bp); if (*bp == '\0' && @@ -289,7 +289,7 @@ char *LYJump(int key) ShortcutNum = 0; if ((cp = (char *) HTList_objectAt(jtp->history, ShortcutNum)) != NULL) { - LYstrncpy(buf, cp, sizeof(buf) - 1); + LYStrNCpy(buf, cp, sizeof(buf) - 1); if (jump_buffer && jtp->shortcut && !strcmp(buf, jtp->shortcut)) { _statusline(EDIT_CURRENT_SHORTCUT); @@ -299,7 +299,7 @@ char *LYJump(int key) } else { _statusline(EDIT_A_PREV_SHORTCUT); } - if ((ch = LYgetstr(buf, VISIBLE, + if ((ch = LYGetStr(buf, VISIBLE, sizeof(buf), recall)) < 0) { /* * User cancelled the jump via ^G. @@ -329,7 +329,7 @@ char *LYJump(int key) ShortcutNum = ShortcutTotal - 1; if ((cp = (char *) HTList_objectAt(jtp->history, ShortcutNum)) != NULL) { - LYstrncpy(buf, cp, sizeof(buf) - 1); + LYStrNCpy(buf, cp, sizeof(buf) - 1); if (jump_buffer && jtp->shortcut && !strcmp(buf, jtp->shortcut)) { _statusline(EDIT_CURRENT_SHORTCUT); @@ -339,7 +339,7 @@ char *LYJump(int key) } else { _statusline(EDIT_A_PREV_SHORTCUT); } - if ((ch = LYgetstr(buf, VISIBLE, sizeof(buf), recall)) < 0) { + if ((ch = LYGetStr(buf, VISIBLE, sizeof(buf), recall)) < 0) { /* * User cancelled the jump via ^G. */ @@ -352,7 +352,7 @@ char *LYJump(int key) seeking.key = bp; found = (JumpDatum *) bsearch((char *) &seeking, (char *) jtp->table, - jtp->nel, sizeof(JumpDatum), LYCompare); + (size_t) jtp->nel, sizeof(JumpDatum), LYCompare); if (!found) { user_message("Unknown target '%s'", buf); LYSleepAlert(); @@ -453,7 +453,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) { + if (StrNCmp(cp, "<!--", 4) == 0 || StrNCmp(cp, "<dl>", 4) == 0) { cp = strchr(cp, '\n'); if (cp == NULL) break; diff --git a/src/LYKeymap.c b/src/LYKeymap.c index 505297df..49587fdf 100644 --- a/src/LYKeymap.c +++ b/src/LYKeymap.c @@ -1,4 +1,4 @@ -/* $LynxId: LYKeymap.c,v 1.70 2010/09/22 23:02:55 tom Exp $ */ +/* $LynxId: LYKeymap.c,v 1.72 2010/09/25 12:44:34 tom Exp $ */ #include <HTUtils.h> #include <LYUtils.h> #include <LYGlobalDefs.h> @@ -1156,7 +1156,7 @@ Kcmd *LYStringToKcmd(const char *name) } char *LYKeycodeToString(int c, - BOOLEAN upper8) + int upper8) { static char buf[30]; unsigned n; @@ -1296,8 +1296,7 @@ static char *format_binding(LYKeymap_t * table, int i) /* if both is true, produce an additional line for the corresponding uppercase key if its binding is different. - kw */ -static void print_binding(HTStream *target, int i, - BOOLEAN both) +static void print_binding(HTStream *target, int i, int both) { char *buf; LYKeymapCode lac1 = LYK_UNKNOWN; /* 0 */ @@ -1473,7 +1472,7 @@ GLOBALDEF HTProtocol LYLynxKeymap = */ int remap(char *key, const char *func, - BOOLEAN for_dired) + int for_dired) { Kcmd *mp; int c; @@ -1521,12 +1520,12 @@ typedef struct { /* * Save the given keys in the table, setting them to the map'd value. */ -static void set_any_keys(ANY_KEYS * table, int size) +static void set_any_keys(ANY_KEYS * table, size_t size) { - int j, k; + size_t j, k; for (j = 0; j < size; ++j) { - k = table[j].code + 1; + k = (size_t) (table[j].code + 1); table[j].save = keymap[k]; keymap[k] = table[j].map; } @@ -1535,12 +1534,12 @@ static void set_any_keys(ANY_KEYS * table, int size) /* * Restore the given keys from the table. */ -static void reset_any_keys(ANY_KEYS * table, int size) +static void reset_any_keys(ANY_KEYS * table, size_t size) { - int j, k; + size_t j, k; for (j = 0; j < size; ++j) { - k = table[j].code + 1; + k = (size_t) (table[j].code + 1); keymap[k] = table[j].save; } } diff --git a/src/LYKeymap.h b/src/LYKeymap.h index aa49c17b..ae263074 100644 --- a/src/LYKeymap.h +++ b/src/LYKeymap.h @@ -1,3 +1,4 @@ +/* $LynxId: LYKeymap.h,v 1.42 2010/09/25 11:35:30 tom Exp $ */ #ifndef LYKEYMAP_H #define LYKEYMAP_H @@ -10,7 +11,7 @@ extern "C" { #endif extern BOOLEAN LYisNonAlnumKeyname(int ch, int KeyName); extern HTList *LYcommandList(void); - extern char *LYKeycodeToString(int c, BOOLEAN upper8); + extern char *LYKeycodeToString(int c, int upper8); extern char *fmt_keys(int lkc_first, int lkc_second); extern char *key_for_func(int func); extern char *key_for_func_ext(int lac, int context_code); @@ -19,7 +20,7 @@ extern "C" { 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, const char *func, BOOLEAN for_dired); + extern int remap(char *key, const char *func, int for_dired); extern void print_keymap(char **newfile); extern void reset_emacs_keys(void); extern void reset_numbers_as_arrows(void); diff --git a/src/LYList.c b/src/LYList.c index f1687986..2922748a 100644 --- a/src/LYList.c +++ b/src/LYList.c @@ -1,4 +1,7 @@ -/* Lynx Document Reference List Support LYList.c +/* + * $LynxId: LYList.c,v 1.45 2010/09/25 12:46:05 tom Exp $ + * + * Lynx Document Reference List Support LYList.c * ==================================== * * Author: FM Foteos Macrides (macrides@sci.wfbr.edu) @@ -36,7 +39,7 @@ * Clear: we only get addresses. */ -int showlist(DocInfo *newdoc, BOOLEAN titles) +int showlist(DocInfo *newdoc, int titles) { int cnt; int refs, hidden_links; @@ -68,7 +71,7 @@ int showlist(DocInfo *newdoc, BOOLEAN titles) LYRegisterUIPage(newdoc->address, titles ? UIP_LIST_PAGE : UIP_ADDRLIST_PAGE); - last_titles = titles; + last_titles = (BOOLEAN) titles; LYforce_HTML_mode = TRUE; /* force this file to be HTML */ LYforce_no_cache = TRUE; /* force this file to be new */ @@ -152,7 +155,7 @@ int showlist(DocInfo *newdoc, BOOLEAN titles) HTSprintf0(&LinkTitle, "(internal)"); } else if (titles && child->type && dest == child->dest && - !strncmp(HTAtom_name(child->type), + !StrNCmp(HTAtom_name(child->type), "RelTitle: ", 10)) { HTSprintf0(&LinkTitle, "(%s)", HTAtom_name(child->type) + 10); } else { @@ -232,7 +235,7 @@ int showlist(DocInfo *newdoc, BOOLEAN titles) return (0); } -static void print_refs(FILE *fp, BOOLEAN titles, int refs) +static void print_refs(FILE *fp, int titles, int refs) { int cnt; char *address = NULL; @@ -320,7 +323,7 @@ static void print_hidden_refs(FILE *fp, int refs, int hidden_links) * titles Set: if we want titles where available * Clear: we only get addresses. */ -void printlist(FILE *fp, BOOLEAN titles) +void printlist(FILE *fp, int titles) { int refs, hidden_links; diff --git a/src/LYList.h b/src/LYList.h index 3d99adbe..f6afbc51 100644 --- a/src/LYList.h +++ b/src/LYList.h @@ -1,3 +1,4 @@ +/* $LynxId: LYList.h,v 1.12 2010/09/25 11:35:35 tom Exp $ */ #ifndef LYLIST_H #define LYLIST_H @@ -6,8 +7,8 @@ #ifdef __cplusplus extern "C" { #endif - extern int showlist(DocInfo *newdoc, BOOLEAN titles); - extern void printlist(FILE *fp, BOOLEAN titles); + extern int showlist(DocInfo *newdoc, int titles); + extern void printlist(FILE *fp, int titles); #ifdef __cplusplus } diff --git a/src/LYLocal.c b/src/LYLocal.c index a4a4502f..caead794 100644 --- a/src/LYLocal.c +++ b/src/LYLocal.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYLocal.c,v 1.108 2010/06/17 21:18:00 tom Exp $ + * $LynxId: LYLocal.c,v 1.112 2010/09/25 16:26:16 tom Exp $ * * Routines to manipulate the local filesystem. * Written by: Rick Mallett, Carleton University @@ -93,8 +93,8 @@ static char *render_item ( const char * s, const char * path, const char * dir, char * buf, - int bufsize, - BOOLEAN url_syntax); + size_t bufsize, + int url_syntax); struct dired_menu { int cond; @@ -376,6 +376,38 @@ static BOOLEAN ok_localname(char *dst, const char *src) } #endif /* OK_INSTALL */ +#define MAX_ARGC 10 + +static char **make_argv(const char *command,...) +{ + static char *result[MAX_ARGC]; + int argc = 0; + char *value; + va_list ap; + + va_start(ap, command); + StrAllocCopy(result[argc++], command); + do { + result[argc] = 0; + value = (char *) va_arg(ap, char *); + + if (value != 0) + StrAllocCopy(result[argc], value); + } while (result[argc++] != 0); + va_end(ap); + + return result; +} + +static void free_argv(char **argv) +{ + int argc; + + for (argc = 0; argv[argc] != 0; ++argc) { + free(argv[argc]); + } +} + /* * Execute DIRED command, return -1 or 0 on failure, 1 success. */ @@ -485,15 +517,16 @@ static int make_directory(char *path) const char *program; if ((program = HTGetProgramPath(ppMKDIR)) != NULL) { - char *args[5]; + char **args; char *msg = 0; HTSprintf0(&msg, "make directory %s", path); - args[0] = "mkdir"; - args[1] = path; - args[2] = (char *) 0; + args = make_argv("mkdir", + path, + NULL); code = (LYExecv(program, args, msg) <= 0) ? -1 : 1; FREE(msg); + free_argv(args); } else { #ifdef _WINDOWS code = mkdir(path) ? -1 : 1; @@ -511,16 +544,17 @@ static int remove_file(char *path) const char *program; if ((program = HTGetProgramPath(ppRM)) != NULL) { - char *args[5]; + char **args; char *tmpbuf = NULL; - args[0] = "rm"; - args[1] = "-f"; - args[2] = path; - args[3] = (char *) 0; + args = make_argv("rm", + "-f", + path, + NULL); HTSprintf0(&tmpbuf, gettext("remove %s"), path); code = LYExecv(program, args, tmpbuf); FREE(tmpbuf); + free_argv(args); } else { code = remove(path) ? -1 : 1; CTRACE((tfp, "builtin remove ->%d\n\t%s\n", code, path)); @@ -534,15 +568,16 @@ static int remove_directory(char *path) const char *program; if ((program = HTGetProgramPath(ppRMDIR)) != NULL) { - char *args[5]; + char **args; char *tmpbuf = NULL; - args[0] = "rmdir"; - args[1] = path; - args[2] = (char *) 0; + args = make_argv("rmdir", + path, + NULL); HTSprintf0(&tmpbuf, gettext("remove %s"), path); code = LYExecv(program, args, tmpbuf); FREE(tmpbuf); + free_argv(args); } else { code = rmdir(path) ? -1 : 1; CTRACE((tfp, "builtin rmdir ->%d\n\t%s\n", code, path)); @@ -556,15 +591,16 @@ static int touch_file(char *path) const char *program; if ((program = HTGetProgramPath(ppTOUCH)) != NULL) { - char *args[5]; + char **args; char *msg = NULL; HTSprintf0(&msg, gettext("touch %s"), path); - args[0] = "touch"; - args[1] = path; - args[2] = (char *) 0; + args = make_argv("touch", + path, + NULL); code = (LYExecv(program, args, msg) <= 0) ? -1 : 1; FREE(msg); + free_argv(args); } else { FILE *fp; @@ -586,15 +622,16 @@ static int move_file(char *source, char *target) if ((program = HTGetProgramPath(ppMV)) != NULL) { char *msg = 0; - char *args[5]; + char **args; HTSprintf0(&msg, gettext("move %s to %s"), source, target); - args[0] = "mv"; - args[1] = source; - args[2] = target; - args[3] = (char *) 0; + args = make_argv("mv", + source, + target, + NULL); code = (LYExecv(program, args, msg) <= 0) ? -1 : 1; FREE(msg); + free_argv(args); } else { struct stat sb; char *actual = 0; @@ -770,7 +807,7 @@ static int modify_tagged(char *testpath) _statusline(gettext("Enter new location for tagged items: ")); given_target[0] = '\0'; - LYgetstr(given_target, VISIBLE, sizeof(given_target), NORECALL); + LYGetStr(given_target, VISIBLE, sizeof(given_target), NORECALL); if (strlen(given_target)) { /* * Replace ~/ references to the home directory. @@ -785,7 +822,7 @@ static int modify_tagged(char *testpath) FREE(cp1); return 0; } - LYstrncpy(given_target, cp1, sizeof(given_target) - 1); + LYStrNCpy(given_target, cp1, sizeof(given_target) - 1); FREE(cp1); } @@ -872,7 +909,7 @@ static int modify_name(char *testpath) } else { return ok_file_or_dir(&dir_info); } - LYstrncpy(tmpbuf, LYPathLeaf(testpath), sizeof(tmpbuf) - 1); + LYStrNCpy(tmpbuf, LYPathLeaf(testpath), sizeof(tmpbuf) - 1); if (get_filename(cp, tmpbuf, sizeof(tmpbuf)) == NULL) return 0; @@ -933,7 +970,7 @@ static int modify_location(char *testpath) } else { return ok_file_or_dir(&dir_info); } - LYstrncpy(tmpbuf, testpath, sizeof(tmpbuf) - 1); + LYStrNCpy(tmpbuf, testpath, sizeof(tmpbuf) - 1); *LYPathLeaf(tmpbuf) = '\0'; if (get_filename(cp, tmpbuf, sizeof(tmpbuf)) == NULL) return 0; @@ -948,7 +985,7 @@ static int modify_location(char *testpath) && (tmpbuf[1] == '\0' || LYIsPathSep(tmpbuf[1]))) { StrAllocCopy(newpath, Home_Dir()); StrAllocCat(newpath, (tmpbuf + 1)); - LYstrncpy(tmpbuf, newpath, sizeof(tmpbuf) - 1); + LYStrNCpy(tmpbuf, newpath, sizeof(tmpbuf) - 1); } if (LYisAbsPath(tmpbuf)) { StrAllocCopy(newpath, tmpbuf); @@ -1026,7 +1063,7 @@ int local_modify(DocInfo *doc, char **newpath) FREE(cp); return 0; } - LYstrncpy(testpath, cp, sizeof(testpath) - 1); + LYStrNCpy(testpath, cp, sizeof(testpath) - 1); FREE(cp); if (ans == 'N') { @@ -1338,7 +1375,7 @@ static int permit_location(char *destpath, LYRegisterUIPage(*newpath, UIP_PERMIT_OPTIONS); group_name = HTAA_GidToName((int) dir_info.st_gid); - LYstrncpy(LYValidPermitFile, + LYStrNCpy(LYValidPermitFile, srcpath, (sizeof(LYValidPermitFile) - 1)); @@ -1490,7 +1527,7 @@ static int permit_location(char *destpath, if (*cr != '\0') { *cr++ = '\0'; } - if (strncmp(cp, "mode=", 5) == 0) { /* Magic string. */ + if (StrNCmp(cp, "mode=", 5) == 0) { /* Magic string. */ long mask = permit_bits(cp + 5); if (mask != 0) { @@ -1520,20 +1557,21 @@ static int permit_location(char *destpath, */ code = 1; if ((program = HTGetProgramPath(ppCHMOD)) != NULL) { - char *args[5]; + char **args; char amode[10]; char *tmpbuf = NULL; HTSprintf0(&tmpbuf, "chmod %.4o %s", (unsigned int) new_mode, destpath); sprintf(amode, "%.4o", (unsigned int) new_mode); - args[0] = "chmod"; - args[1] = amode; - args[2] = destpath; - args[3] = (char *) 0; + args = make_argv("chmod", + amode, + destpath, + NULL); if (LYExecv(program, args, tmpbuf) <= 0) { code = -1; } FREE(tmpbuf); + free_argv(args); } else { if (chmod(destpath, new_mode) < 0) { code = -1; @@ -1629,7 +1667,7 @@ static char *LYonedot(char *line) static char line1[LY_MAXPATH]; if (pathconf(line, _PC_NAME_MAX) <= 12) { - LYstrncpy(line1, line, sizeof(line1) - 1); + LYStrNCpy(line1, line, sizeof(line1) - 1); for (;;) { if ((dot = strrchr(line1, '.')) == 0 || LYLastPathSep(dot) != 0) { @@ -1651,10 +1689,10 @@ static char *LYonedot(char *line) static char *match_op(const char *prefix, char *data) { - int len = (int) strlen(prefix); + size_t len = strlen(prefix); - if (!strncmp("LYNXDIRED://", data, 12) - && !strncmp(prefix, data + 12, (unsigned) len)) { + if (!StrNCmp("LYNXDIRED://", data, 12) + && !StrNCmp(prefix, data + 12, len)) { len += 12; #if defined(USE_DOS_DRIVES) if (data[len] == '/') { /* this is normal */ @@ -2166,7 +2204,7 @@ static char *get_filename(const char *prompt, _statusline(prompt); - LYgetstr(buf, VISIBLE, bufsize, NORECALL); + LYGetStr(buf, VISIBLE, bufsize, NORECALL); if (strstr(buf, "../") != NULL) { HTAlert(gettext("Illegal filename; request ignored.")); return NULL; @@ -2377,7 +2415,7 @@ BOOLEAN local_install(char *destpath, savepath); FREE(tmpdest); return (-1); /* don't do it */ - } else if (!strncmp(savepath, destpath, strlen(destpath)) && + } else if (!StrNCmp(savepath, destpath, strlen(destpath)) && LYIsPathSep(savepath[strlen(destpath)]) && LYLastPathSep(savepath + strlen(destpath) + 1) == 0) { HTUserMsg2(gettext("Already in target directory: %s"), @@ -2408,7 +2446,7 @@ BOOLEAN local_install(char *destpath, args[src]); FREE(args[src]); continue; /* skip this source file */ - } else if (!strncmp(args[src], destpath, strlen(destpath)) && + } else if (!StrNCmp(args[src], destpath, strlen(destpath)) && LYIsPathSep(args[src][strlen(destpath)]) && LYLastPathSep(args[src] + strlen(destpath) + 1) == 0) { HTUserMsg2(gettext("Already in target directory: %s"), @@ -2540,8 +2578,8 @@ static char *render_item(const char *s, const char *path, const char *dir, char *buf, - int bufsize, - BOOLEAN url_syntax) + size_t bufsize, + int url_syntax) { const char *cp; char *bp; diff --git a/src/LYMail.c b/src/LYMail.c index 40eec44c..6da72e6f 100644 --- a/src/LYMail.c +++ b/src/LYMail.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYMail.c,v 1.74 2010/09/23 09:15:58 tom Exp $ + * $LynxId: LYMail.c,v 1.76 2010/09/25 11:22:16 tom Exp $ */ #include <HTUtils.h> #include <HTParse.h> @@ -134,7 +134,7 @@ static void extract_subject(char *dst, *cp1 = '\0'; } if (*cp) { - strncpy(dst, cp, MAX_SUBJECT); + StrNCpy(dst, cp, MAX_SUBJECT); dst[MAX_SUBJECT] = '\0'; SafeHTUnEscape(dst); } @@ -258,7 +258,7 @@ static int header_prompt(const char *label, if (*result != 0) { LYaddstr(CTRL_U_TO_ERASE); - LYstrncpy(buffer, *result, sizeof(buffer) - 1); + LYStrNCpy(buffer, *result, sizeof(buffer) - 1); } else *buffer = 0; @@ -267,7 +267,7 @@ static int header_prompt(const char *label, LYaddstr(gettext(label)); LYaddstr(": "); - ok = (LYgetstr(buffer, VISIBLE, limit, NORECALL) >= 0 + ok = (LYGetStr(buffer, VISIBLE, limit, NORECALL) >= 0 && !term_letter); LYaddstr("\n"); @@ -648,13 +648,13 @@ void mailform(const char *mailto_address, */ if (subject[0] == '\0') { if (non_empty(mailto_subject)) { - LYstrncpy(subject, mailto_subject, MAX_SUBJECT); + LYStrNCpy(subject, mailto_subject, MAX_SUBJECT); } else { sprintf(subject, "mailto:%.63s", address); } } _statusline(SUBJECT_PROMPT); - if (LYgetstr(subject, VISIBLE, MAX_SUBJECT, NORECALL) < 0) { + if (LYGetStr(subject, VISIBLE, MAX_SUBJECT, NORECALL) < 0) { /* * User cancelled via ^G. - FM */ @@ -669,7 +669,7 @@ void mailform(const char *mailto_address, sprintf(self, "%.*s", MAX_SUBJECT, isEmpty(personal_mail_address) ? "" : personal_mail_address); _statusline("Cc: "); - if (LYgetstr(self, VISIBLE, MAX_SUBJECT, NORECALL) < 0) { + if (LYGetStr(self, VISIBLE, MAX_SUBJECT, NORECALL) < 0) { /* * User cancelled via ^G. - FM */ @@ -772,7 +772,7 @@ void mailform(const char *mailto_address, i = 0; len = (int) strlen(mailto_content); while (len > 78) { - strncpy(buf, &mailto_content[i], 78); + StrNCpy(buf, &mailto_content[i], 78); buf[78] = '\0'; fprintf(fd, "%s\n", buf); i += 78; @@ -784,7 +784,7 @@ void mailform(const char *mailto_address, i = 0; len = (int) strlen(mailto_content); while (len > 78) { - strncpy(buf, &mailto_content[i], 78); + StrNCpy(buf, &mailto_content[i], 78); buf[78] = '\0'; fprintf(fd, "%s\n", buf); i += 78; @@ -1231,7 +1231,7 @@ void reply_by_mail(char *mail_address, * Set the default subject. - FM */ if ((default_subject[0] == '\0') && non_empty(title)) { - strncpy(default_subject, title, MAX_SUBJECT); + StrNCpy(default_subject, title, MAX_SUBJECT); default_subject[MAX_SUBJECT] = '\0'; } @@ -1526,7 +1526,7 @@ void reply_by_mail(char *mail_address, LYaddstr("\n\n"); LYrefresh(); *user_input = '\0'; - if (LYgetstr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0 || + if (LYGetStr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0 || term_letter || STREQ(user_input, ".")) { goto cancelled; } @@ -1536,7 +1536,7 @@ void reply_by_mail(char *mail_address, remove_tildes(user_input); fprintf(fd, "%s\n", user_input); *user_input = '\0'; - if (LYgetstr(user_input, VISIBLE, + if (LYGetStr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0) { goto cancelled; } @@ -1671,8 +1671,8 @@ void reply_by_mail(char *mail_address, #else fputs(header, fp); #endif - while ((nbytes = fread(buf, 1, sizeof(buf), fd)) != 0) { - if (fwrite(buf, 1, (size_t) nbytes, fp) < nbytes) + while ((nbytes = fread(buf, (size_t) 1, sizeof(buf), fd)) != 0) { + if (fwrite(buf, (size_t) 1, (size_t) nbytes, fp) < nbytes) break; } #if CAN_PIPE_TO_MAILER diff --git a/src/LYMain.c b/src/LYMain.c index 337dff17..a046f784 100644 --- a/src/LYMain.c +++ b/src/LYMain.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYMain.c,v 1.218 2010/09/23 09:52:26 tom Exp $ + * $LynxId: LYMain.c,v 1.221 2010/09/25 11:12:44 tom Exp $ */ #include <HTUtils.h> #include <HTTP.h> @@ -650,7 +650,7 @@ static void print_help_and_exit(int exit_status) GCC_NORETURN; static void print_help_strings(const char *name, const char *help, const char *value, - BOOLEAN option); + int option); #ifndef VMS BOOLEAN LYNoCore = NO_FORCED_CORE_DUMP; @@ -866,10 +866,10 @@ static void FixCharacters(void) #endif /* EBCDIC */ static BOOL GetStdin(char **buf, - BOOL marker) + int marker) { if (LYSafeGets(buf, stdin) != 0 - && (!marker || strncmp(*buf, "---", 3) != 0)) { + && (!marker || StrNCmp(*buf, "---", 3) != 0)) { LYTrimTrailing(*buf); CTRACE((tfp, "...data: %s\n", *buf)); return TRUE; @@ -916,7 +916,7 @@ static void append_ssl_version(char **target, #ifdef LYNX_SSL_VERSION if (*separator == ' ') StrAllocCat(*target, ","); - LYstrncpy(SSLLibraryVersion, LYNX_SSL_VERSION, sizeof(SSLLibraryVersion) - 1); + LYStrNCpy(SSLLibraryVersion, LYNX_SSL_VERSION, sizeof(SSLLibraryVersion) - 1); if ((SSLcp = strchr(SSLLibraryVersion, ' ')) != NULL) { *SSLcp++ = *separator; if ((SSLcp = strchr(SSLcp, ' ')) != NULL) { @@ -1082,7 +1082,7 @@ int main(int argc, ccp = FNAME_LYNX_TRACE; LYTraceLogPath = typeMallocn(char, LY_MAXPATH); - LYAddPathToHome(LYTraceLogPath, LY_MAXPATH, ccp); + LYAddPathToHome(LYTraceLogPath, (size_t) LY_MAXPATH, ccp); /* * Act on -version, -trace and -trace-mask NOW. @@ -1497,7 +1497,7 @@ int main(int argc, /* * Set the compilation default signature file. - FM */ - LYstrncpy(filename, LYNX_SIG_FILE, sizeof(filename) - 1); + LYStrNCpy(filename, LYNX_SIG_FILE, sizeof(filename) - 1); if (LYPathOffHomeOK(filename, sizeof(filename))) { StrAllocCopy(LynxSigFile, filename); LYAddPathToHome(filename, sizeof(filename), LynxSigFile); @@ -1686,7 +1686,7 @@ int main(int argc, if (LYCookieFile == NULL) { LYCookieFile = typeMallocn(char, LY_MAXPATH); - LYAddPathToHome(LYCookieFile, LY_MAXPATH, FNAME_LYNX_COOKIES); + LYAddPathToHome(LYCookieFile, (size_t) LY_MAXPATH, FNAME_LYNX_COOKIES); } else { LYTildeExpand(&LYCookieFile, FALSE); } @@ -1973,7 +1973,7 @@ int main(int argc, /* * Check for a valid traversal request. - FM */ - if (traversal && strncmp(startfile, "http", 4)) { + if (traversal && StrNCmp(startfile, "http", 4)) { fprintf(stderr, "The '-traversal' switch is for http URLs and cannot be used for\n'%s'.\n", startfile); @@ -3964,7 +3964,7 @@ with filenames of these images" static void print_help_strings(const char *name, const char *help, const char *value, - BOOLEAN option) + int option) { int pad; int c; diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c index 6f5b1782..a9a3793e 100644 --- a/src/LYMainLoop.c +++ b/src/LYMainLoop.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYMainLoop.c,v 1.167 2010/09/22 09:36:30 tom Exp $ + * $LynxId: LYMainLoop.c,v 1.172 2010/09/25 14:57:53 tom Exp $ */ #include <HTUtils.h> #include <HTAccess.h> @@ -153,8 +153,8 @@ HTAtom *WWW_SOURCE = 0; #define NONINTERNAL_OR_PHYS_DIFFERENT(p,n) are_different(p,n) #endif /* TRACK_INTERNAL_LINKS */ -static void exit_immediately_with_error_message(int state, BOOLEAN first_file); -static void status_link(char *curlink_name, BOOLEAN show_more, BOOLEAN show_indx); +static void exit_immediately_with_error_message(int state, int first_file); +static void status_link(char *curlink_name, int show_more, int show_indx); static void show_main_statusline(const LinkInfo curlink, int for_what); static void form_noviceline(int); static int are_different(DocInfo *doc1, DocInfo *doc2); @@ -663,7 +663,7 @@ static void do_check_goto_URL(char *user_input_buffer, for (n = 0; n < TABLESIZE(table); n++) { if (*(table[n].flag) - && !strncmp(user_input_buffer, table[n].name, strlen(table[n].name))) { + && !StrNCmp(user_input_buffer, table[n].name, strlen(table[n].name))) { found = TRUE; HTUserMsg2(GOTO_XXXX_DISALLOWED, table[n].name); break; @@ -736,7 +736,7 @@ static BOOL do_check_recall(int ch, LYAddPathSep0(user_input_buffer); } else { HTUserMsg2(WWW_ILLEGAL_URL_MESSAGE, user_input_buffer); - LYstrncpy(user_input_buffer, *old_user_input, MAX_LINE - 1); + LYStrNCpy(user_input_buffer, *old_user_input, MAX_LINE - 1); FREE(*old_user_input); ret = FALSE; break; @@ -749,7 +749,7 @@ static BOOL do_check_recall(int ch, LYTrimAllStartfile(user_input_buffer); if (*user_input_buffer == '\0' && !(recall && (ch == UPARROW || ch == DNARROW))) { - LYstrncpy(user_input_buffer, *old_user_input, MAX_LINE - 1); + LYStrNCpy(user_input_buffer, *old_user_input, MAX_LINE - 1); FREE(*old_user_input); HTInfoMsg(CANCELLED); ret = FALSE; @@ -775,7 +775,7 @@ static BOOL do_check_recall(int ch, *URLNum = 0; if ((cp = (char *) HTList_objectAt(Goto_URLs, *URLNum)) != NULL) { - LYstrncpy(user_input_buffer, cp, MAX_LINE - 1); + LYStrNCpy(user_input_buffer, cp, MAX_LINE - 1); if (goto_buffer && **old_user_input && !strcmp(*old_user_input, user_input_buffer)) { @@ -786,14 +786,14 @@ static BOOL do_check_recall(int ch, } else { _statusline(EDIT_A_PREV_GOTO); } - if ((ch = LYgetstr(user_input_buffer, VISIBLE, - MAX_LINE, + if ((ch = LYGetStr(user_input_buffer, VISIBLE, + (size_t) MAX_LINE, recall)) < 0) { /* * User cancelled the Goto via ^G. Restore * user_input_buffer and break. - FM */ - LYstrncpy(user_input_buffer, *old_user_input, MAX_LINE - 1); + LYStrNCpy(user_input_buffer, *old_user_input, MAX_LINE - 1); FREE(*old_user_input); HTInfoMsg(CANCELLED); ret = FALSE; @@ -820,7 +820,7 @@ static BOOL do_check_recall(int ch, */ *URLNum = URLTotal - 1; if ((cp = (char *) HTList_objectAt(Goto_URLs, *URLNum)) != NULL) { - LYstrncpy(user_input_buffer, cp, MAX_LINE - 1); + LYStrNCpy(user_input_buffer, cp, MAX_LINE - 1); if (goto_buffer && **old_user_input && !strcmp(*old_user_input, user_input_buffer)) { _statusline(EDIT_CURRENT_GOTO); @@ -830,14 +830,14 @@ static BOOL do_check_recall(int ch, } else { _statusline(EDIT_A_PREV_GOTO); } - if ((ch = LYgetstr(user_input_buffer, VISIBLE, - MAX_LINE, + if ((ch = LYGetStr(user_input_buffer, VISIBLE, + (size_t) MAX_LINE, recall)) < 0) { /* * User cancelled the Goto via ^G. Restore * user_input_buffer and break. - FM */ - LYstrncpy(user_input_buffer, *old_user_input, MAX_LINE - 1); + LYStrNCpy(user_input_buffer, *old_user_input, MAX_LINE - 1); FREE(*old_user_input); HTInfoMsg(CANCELLED); ret = FALSE; @@ -921,11 +921,11 @@ static int DoTraversal(int c, traversal_host && links[curdoc.link].lname) { if (!isLYNXIMGMAP(links[curdoc.link].lname)) { - rlink_allowed = (BOOL) !strncmp(traversal_host, + rlink_allowed = (BOOL) !StrNCmp(traversal_host, links[curdoc.link].lname, strlen(traversal_host)); } else { - rlink_allowed = (BOOL) !strncmp(traversal_host, + rlink_allowed = (BOOL) !StrNCmp(traversal_host, links[curdoc.link].lname + LEN_LYNXIMGMAP, strlen(traversal_host)); } @@ -1010,7 +1010,7 @@ static BOOLEAN check_history(void) ? HDOC(nhist - 1).address : HDOC(nhist - 1).address + LEN_LYNXIMGMAP; - if (!strncmp(base, text, strlen(base))) { + if (!StrNCmp(base, text, strlen(base))) { /* * Normal case - as best as we can check, the document at the top * of the history stack seems to be the document the List Page is @@ -1190,10 +1190,10 @@ static int handle_LYK_ACTIVATE(int *c, *c = change_form_link(curdoc.link, &newdoc, refresh_screen, FALSE, - (BOOLEAN) (real_cmd == LYK_SUBMIT || - real_cmd == LYK_NOCACHE || - real_cmd == LYK_DOWNLOAD || - real_cmd == LYK_HEAD)); + (real_cmd == LYK_SUBMIT || + real_cmd == LYK_NOCACHE || + real_cmd == LYK_DOWNLOAD || + real_cmd == LYK_HEAD)); if (*c != LKC_DONE || *refresh_screen) { /* * Cannot have been a submit field for which newdoc was filled @@ -1287,7 +1287,7 @@ static int handle_LYK_ACTIVATE(int *c, isLYNXCOOKIE(curdoc.address) || isLYNXCACHE(curdoc.address)) && #endif - !strncmp(links[curdoc.link].lname, + !StrNCmp(links[curdoc.link].lname, helpfilepath, strlen(helpfilepath)))) { HTAlert(FILE_SERVED_LINKS_DISALLOWED); @@ -1707,7 +1707,7 @@ static int handle_LYK_COMMAND(char *user_input_buffer) *user_input_buffer = 0; _statusline(": "); - if (LYgetstr(user_input_buffer, VISIBLE, MAX_LINE, RECALL_CMD) >= 0) { + if (LYGetStr(user_input_buffer, VISIBLE, (size_t) MAX_LINE, RECALL_CMD) >= 0) { src = LYSkipBlanks(user_input_buffer); tmp = LYSkipNonBlanks(src); *tmp = 0; @@ -2172,7 +2172,7 @@ static int handle_LYK_DOWNLOAD(int *cmd, */ LYforce_no_cache = TRUE; - } else if (!strncmp(links[curdoc.link].lname, "data:", 5)) { + } else if (!StrNCmp(links[curdoc.link].lname, "data:", 5)) { if (*old_c != real_c) { *old_c = real_c; HTAlert(UNSUPPORTED_DATA_URL); @@ -2396,7 +2396,7 @@ static int handle_LYK_ECGOTO(int *ch, * document's address. */ StrAllocCopy(*old_user_input, user_input_buffer); - LYstrncpy(user_input_buffer, + LYStrNCpy(user_input_buffer, curdoc.address, (MAX_LINE - 1)); @@ -2411,7 +2411,7 @@ static int handle_LYK_ECGOTO(int *ch, * Offer the current document's URL for editing. - FM */ _statusline(EDIT_CURDOC_URL); - if (((*ch = LYgetstr(user_input_buffer, VISIBLE, + if (((*ch = LYGetStr(user_input_buffer, VISIBLE, MAX_LINE, RECALL_URL)) >= 0) && user_input_buffer[0] != '\0' && strcmp(user_input_buffer, curdoc.address)) { @@ -2424,7 +2424,7 @@ static int handle_LYK_ECGOTO(int *ch, * User cancelled via ^G, a full deletion, or not modifying the URL. - FM */ HTInfoMsg(CANCELLED); - LYstrncpy(user_input_buffer, *old_user_input, MAX_LINE - 1); + LYStrNCpy(user_input_buffer, *old_user_input, MAX_LINE - 1); FREE(*old_user_input); return 0; } @@ -2641,7 +2641,7 @@ static int handle_LYK_ELGOTO(int *ch, * address. - FM */ StrAllocCopy(*old_user_input, user_input_buffer); - LYstrncpy(user_input_buffer, + LYStrNCpy(user_input_buffer, ((links[curdoc.link].type == WWW_FORM_LINK_TYPE) ? links[curdoc.link].l_form->submit_action : links[curdoc.link].lname), @@ -2651,7 +2651,7 @@ static int handle_LYK_ELGOTO(int *ch, * Offer the current link's URL for editing. - FM */ _statusline(EDIT_CURLINK_URL); - if (((*ch = LYgetstr(user_input_buffer, VISIBLE, + if (((*ch = LYGetStr(user_input_buffer, VISIBLE, MAX_LINE, RECALL_URL)) >= 0) && user_input_buffer[0] != '\0' && strcmp(user_input_buffer, @@ -2667,7 +2667,7 @@ static int handle_LYK_ELGOTO(int *ch, * User cancelled via ^G, a full deletion, or not modifying the URL. - FM */ HTInfoMsg(CANCELLED); - LYstrncpy(user_input_buffer, *old_user_input, MAX_LINE - 1); + LYStrNCpy(user_input_buffer, *old_user_input, MAX_LINE - 1); FREE(*old_user_input); return 0; } @@ -2905,13 +2905,13 @@ static BOOLEAN handle_LYK_GOTO(int *ch, * Ask the user. */ _statusline(URL_TO_OPEN); - if ((*ch = LYgetstr(user_input_buffer, VISIBLE, + if ((*ch = LYGetStr(user_input_buffer, VISIBLE, MAX_LINE, *recall)) < 0) { /* * User cancelled the Goto via ^G. Restore user_input_buffer and * break. - FM */ - LYstrncpy(user_input_buffer, *old_user_input, MAX_LINE - 1); + LYStrNCpy(user_input_buffer, *old_user_input, MAX_LINE - 1); FREE(*old_user_input); HTInfoMsg(CANCELLED); return FALSE; @@ -2981,13 +2981,13 @@ static BOOLEAN handle_LYK_HEAD(int *cmd) } } else if (c == 'L') { if (links[curdoc.link].type != WWW_FORM_LINK_TYPE && - strncmp(links[curdoc.link].lname, "http", 4) && - strncmp(links[curdoc.link].lname, + StrNCmp(links[curdoc.link].lname, "http", 4) && + StrNCmp(links[curdoc.link].lname, "LYNXIMGMAP:http", 15) && LYCanDoHEAD(links[curdoc.link].lname) != TRUE && (links[curdoc.link].type != WWW_INTERN_LINK_TYPE || !curdoc.address || - strncmp(curdoc.address, "http", 4))) { + StrNCmp(curdoc.address, "http", 4))) { HTUserMsg(LINK_NOT_HTTP_URL); } else if (links[curdoc.link].type == WWW_FORM_LINK_TYPE && links[curdoc.link].l_form->disabled) { @@ -2995,7 +2995,7 @@ static BOOLEAN handle_LYK_HEAD(int *cmd) } else if (links[curdoc.link].type == WWW_FORM_LINK_TYPE && links[curdoc.link].l_form->submit_action != 0 && !isLYNXCGI(links[curdoc.link].l_form->submit_action) && - strncmp(links[curdoc.link].l_form->submit_action, + StrNCmp(links[curdoc.link].l_form->submit_action, "http", 4)) { HTUserMsg(FORM_ACTION_NOT_HTTP_URL); } else if (links[curdoc.link].type == WWW_FORM_LINK_TYPE && @@ -3127,7 +3127,7 @@ static void handle_LYK_HISTORICAL(void) return; } -static BOOLEAN handle_LYK_HISTORY(BOOLEAN ForcePush) +static BOOLEAN handle_LYK_HISTORY(int ForcePush) { if (curdoc.title && !LYIsUIPage(curdoc.address, UIP_HISTORY)) { /* @@ -3167,7 +3167,7 @@ static BOOLEAN handle_LYK_HISTORY(BOOLEAN ForcePush) LYPermitURL = TRUE; } return TRUE; - } /* end if strncmp */ + } /* end if StrNCmp */ return FALSE; } @@ -3212,7 +3212,7 @@ static void handle_LYK_INDEX(int *old_c, } static void handle_LYK_INDEX_SEARCH(BOOLEAN *force_load, - BOOLEAN ForcePush, + int ForcePush, int *old_c, int real_c) { @@ -3432,7 +3432,7 @@ static BOOLEAN handle_LYK_JUMP(int c, return FALSE; } ret = HTParse((ret + 3), startfile, PARSE_ALL); - LYstrncpy(user_input_buffer, ret, MAX_LINE - 1); + LYStrNCpy(user_input_buffer, ret, MAX_LINE - 1); FREE(ret); return TRUE; } @@ -3691,7 +3691,7 @@ static BOOLEAN handle_LYK_OPTIONS(int *cmd, ((strcmp(CurrentUserAgent, NonNull(LYUserAgent)) || strcmp(CurrentNegoLanguage, NonNull(language)) || strcmp(CurrentNegoCharset, NonNull(pref_charset))) && - (!strncmp(curdoc.address, "http", 4) || + (!StrNCmp(curdoc.address, "http", 4) || isLYNXCGI(curdoc.address)))) { BOOLEAN canreparse_post = FALSE; @@ -3713,7 +3713,7 @@ static BOOLEAN handle_LYK_OPTIONS(int *cmd, if (((strcmp(CurrentUserAgent, NonNull(LYUserAgent)) || strcmp(CurrentNegoLanguage, NonNull(language)) || strcmp(CurrentNegoCharset, NonNull(pref_charset))) && - (strncmp(curdoc.address, "http", 4) == 0 || + (StrNCmp(curdoc.address, "http", 4) == 0 || !isLYNXCGI(curdoc.address) == 0))) { /* * An option has changed which may influence content @@ -4450,7 +4450,7 @@ static void handle_LYK_TAG_LINK(void) if (dir_list_style == MIXED_STYLE) { if (!strcmp(LYGetHiliteStr(curdoc.link, 0), "../")) return; - } else if (!strncmp(LYGetHiliteStr(curdoc.link, 0), "Up to ", 6)) + } else if (!StrNCmp(LYGetHiliteStr(curdoc.link, 0), "Up to ", 6)) return; { /* @@ -4794,7 +4794,7 @@ void handle_LYK_WHEREIS(int cmd, */ *prev_target = '\0'; } - found = textsearch(&curdoc, prev_target, sizeof(prev_target) - 1, + found = textsearch(&curdoc, prev_target, (int) sizeof(prev_target) - 1, (cmd == LYK_WHEREIS) ? 0 : ((cmd == LYK_NEXT) @@ -4964,7 +4964,7 @@ static void handle_LYK_digit(int c, sprintf(user_input_buffer, LINK_ALREADY_CURRENT, number); HTUserMsg(user_input_buffer); - LYstrncpy(user_input_buffer, temp, MAX_LINE - 1); + LYStrNCpy(user_input_buffer, temp, MAX_LINE - 1); FREE(temp); } else { /* @@ -4997,7 +4997,7 @@ static void handle_LYK_digit(int c, sprintf(user_input_buffer, ALREADY_AT_PAGE, number); HTUserMsg(user_input_buffer); - LYstrncpy(user_input_buffer, temp, MAX_LINE - 1); + LYStrNCpy(user_input_buffer, temp, MAX_LINE - 1); FREE(temp); } } @@ -5028,7 +5028,7 @@ void handle_LYK_CHDIR(void) /* some people may prefer automatic clearing of the previous user input, here, to do this, just uncomment next line - VH */ /* buf[0]='\0'; */ - if (LYgetstr(buf, VISIBLE, sizeof(buf) - 1, NORECALL) < 0 || !*buf) { + if (LYGetStr(buf, VISIBLE, sizeof(buf) - 1, NORECALL) < 0 || !*buf) { HTInfoMsg(CANCELLED); return; } @@ -5171,7 +5171,7 @@ static BOOLEAN handle_LYK_LINEWRAP_TOGGLE(int *cmd, /* Somehow the mouse is over the number instead of being over the name, so we decrease x. */ c = LYChoosePopup(!LYwideLines, LYlines / 2 - 2, LYcolLimit / 2 - 6, - choices, TABLESIZE(choices) - 1, FALSE, TRUE); + choices, (int) TABLESIZE(choices) - 1, FALSE, TRUE); /* * LYhandlePopupList() wasn't really meant to be used outside of old-style * Options menu processing. One result of mis-using it here is that we @@ -5826,7 +5826,7 @@ int mainloop(void) if (!strncasecomp(temp, name, len) && strlen(temp) > len) #else - if (!strncmp(temp, name, len) && + if (!StrNCmp(temp, name, len) && strlen(temp) > len) #endif /* VMS */ { @@ -5871,7 +5871,7 @@ int mainloop(void) wwwName(Home_Dir())); StrAllocCat(newdoc.address, "/"); StrAllocCat(newdoc.address, - (strncmp(BookmarkPage, "./", 2) ? + (StrNCmp(BookmarkPage, "./", 2) ? BookmarkPage : (BookmarkPage + 2))); StrAllocCopy(newdoc.title, BOOKMARK_TITLE); @@ -6173,7 +6173,7 @@ int mainloop(void) /* * Set up the traversal_host comparison string. */ - if (strncmp((curdoc.address ? curdoc.address : "NULL"), + if (StrNCmp((curdoc.address ? curdoc.address : "NULL"), "http", 4)) { StrAllocCopy(traversal_host, NO_NOTHING); } else if (check_realm) { @@ -6506,17 +6506,19 @@ int mainloop(void) print_crawl_to_fd(cfp, curdoc.address, curdoc.title); LYCloseOutput(cfp); } else { - if (!dump_output_immediately) - cleanup(); - fprintf( #ifdef UNIX - (dump_output_immediately + FILE *fp = (dump_output_immediately ? stderr - : stdout), + : stdout); + #else - stdout, + FILE *fp = stdout; #endif - gettext("Fatal error - could not open output file %s\n"), cfile); + if (!dump_output_immediately) + cleanup(); + fprintf(fp, + gettext("Fatal error - could not open output file %s\n"), + cfile); if (!dump_output_immediately) { exit_immediately(EXIT_FAILURE); } @@ -6972,8 +6974,9 @@ int mainloop(void) len = (unsigned) (e - s + 1); if (len < MAX_LINE) len = MAX_LINE; /* Required for do_check_goto_URL() */ - buf = (char *) malloc(len); - strncpy(buf, (const char *) s, (unsigned) (e - s)); + buf = typeMallocn(char, len); + + StrNCpy(buf, (const char *) s, (e - s)); buf[e - s] = '\0'; t = (unsigned char *) buf; @@ -7733,8 +7736,7 @@ static void form_noviceline(int disabled) } } -static void exit_immediately_with_error_message(int state, - BOOLEAN first_file) +static void exit_immediately_with_error_message(int state, int first_file) { char *buf = 0; char *buf2 = 0; @@ -7788,8 +7790,8 @@ static void exit_immediately_with_error_message(int state, } static void status_link(char *curlink_name, - BOOLEAN show_more, - BOOLEAN show_indx) + int show_more, + int show_indx) { #define MAX_STATUS (LYcolLimit - 1) #define MIN_STATUS 0 diff --git a/src/LYMap.c b/src/LYMap.c index 3640029f..b347f39c 100644 --- a/src/LYMap.c +++ b/src/LYMap.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYMap.c,v 1.38 2010/09/22 09:48:58 tom Exp $ + * $LynxId: LYMap.c,v 1.40 2010/09/24 22:31:41 tom Exp $ * Lynx Client-side Image MAP Support LYMap.c * ================================== * @@ -215,7 +215,7 @@ BOOL LYAddMapElement(char *map, char *address, char *title, HTParentAnchor *node_anchor, - BOOL intern_flag GCC_UNUSED) + int intern_flag GCC_UNUSED) { LYMapElement *tmp = NULL; LYImageMap *theMap = NULL; @@ -627,7 +627,7 @@ void LYPrintImgMaps(FILE *fp) if (HTList_count(outer) > 0) { while (NULL != (map = (LYImageMap *) HTList_nextObject(outer))) { if (only_len != 0) { - if (strncmp(only, map->address, only_len) + if (StrNCmp(only, map->address, only_len) || (map->address[only_len] != '\0' && map->address[only_len] != '#')) { continue; diff --git a/src/LYMap.h b/src/LYMap.h index 28a60178..7c0b9ffa 100644 --- a/src/LYMap.h +++ b/src/LYMap.h @@ -1,3 +1,4 @@ +/* $LynxId: LYMap.h,v 1.12 2010/09/25 11:35:42 tom Exp $ */ #ifndef LYMAP_H #define LYMAP_H @@ -19,7 +20,7 @@ extern "C" { HTParentAnchor *node_anchor); extern BOOL LYAddMapElement(char *map, char *address, char *title, HTParentAnchor *node_anchor, - BOOL intern_flag); + int intern_flag); extern BOOL LYHaveImageMap(char *address); #ifdef __cplusplus diff --git a/src/LYNews.c b/src/LYNews.c index afebe0ee..df4139d5 100644 --- a/src/LYNews.c +++ b/src/LYNews.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYNews.c,v 1.54 2009/01/01 23:09:57 tom Exp $ + * $LynxId: LYNews.c,v 1.57 2010/09/25 11:20:13 tom Exp $ */ #include <HTUtils.h> #ifndef DISABLE_NEWS @@ -83,7 +83,7 @@ static BOOLEAN message_has_content(const char *filename, * snewsreply URLs. - FM */ char *LYNewsPost(char *newsgroups, - BOOLEAN followup) + int followup) { char user_input[MAX_LINE]; char CJKinput[MAX_LINE]; @@ -195,7 +195,7 @@ char *LYNewsPost(char *newsgroups, LYaddstr(gettext("\n\n Please provide your mail address for the From: header\n")); sprintf(user_input, "From: %.*s", (int) sizeof(user_input) - 8, NonNull(personal_mail_address)); - if (LYgetstr(user_input, VISIBLE, + if (LYGetStr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0 || term_message) { HTInfoMsg(NEWS_POST_CANCELLED); @@ -238,10 +238,10 @@ char *LYNewsPost(char *newsgroups, strcat(user_input, "Re: "); } len = (int) strlen(user_input); - LYstrncpy(user_input + len, kp, (int) sizeof(user_input) - len - 1); + LYStrNCpy(user_input + len, kp, (int) sizeof(user_input) - len - 1); } cp = NULL; - if (LYgetstr(user_input, VISIBLE, + if (LYGetStr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0 || term_message) { HTInfoMsg(NEWS_POST_CANCELLED); @@ -283,7 +283,7 @@ char *LYNewsPost(char *newsgroups, if (p != 0 && (p - fname) < sizeof(fname) - 15) { strcpy(p + 1, "LYNX_ETC.TXT"); if ((fp = fopen(fname, TXT_R)) != NULL) { - if (fgets(user_input, sizeof(user_input), fp) != NULL) { + if (fgets(user_input, (int) sizeof(user_input), fp) != NULL) { if ((org = strchr(user_input, '\n')) != NULL) { *org = '\0'; } @@ -297,10 +297,10 @@ char *LYNewsPost(char *newsgroups, } #endif /* _WINDOWS */ #endif /* !UNIX */ - LYstrncpy(user_input, cp, (sizeof(user_input) - 16)); + LYStrNCpy(user_input, cp, (sizeof(user_input) - 16)); FREE(cp); LYaddstr(gettext("\n\n Please provide or edit the Organization: header\n")); - if (LYgetstr(user_input, VISIBLE, + if (LYGetStr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0 || term_message) { HTInfoMsg(NEWS_POST_CANCELLED); @@ -362,7 +362,7 @@ char *LYNewsPost(char *newsgroups, LYaddstr("\n\n"); LYrefresh(); *user_input = '\0'; - if (LYgetstr(user_input, VISIBLE, + if (LYGetStr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0 || term_message) { HTInfoMsg(NEWS_POST_CANCELLED); @@ -376,7 +376,7 @@ char *LYNewsPost(char *newsgroups, if (!nonempty && strlen(user_input)) nonempty = TRUE; *user_input = '\0'; - if (LYgetstr(user_input, VISIBLE, + if (LYGetStr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0) { HTInfoMsg(NEWS_POST_CANCELLED); LYCloseTempFP(fd); /* Close the temp file. */ diff --git a/src/LYNews.h b/src/LYNews.h index 780f8fa6..9a6a3f67 100644 --- a/src/LYNews.h +++ b/src/LYNews.h @@ -1,3 +1,4 @@ +/* $LynxId: LYNews.h,v 1.10 2010/09/25 11:35:12 tom Exp $ */ #ifndef LYNEWSPOST_H #define LYNEWSPOST_H @@ -10,7 +11,7 @@ extern "C" { #endif extern BOOLEAN term_message; - extern char *LYNewsPost(char *newsgroups, BOOLEAN followup); + extern char *LYNewsPost(char *newsgroups, int followup); #ifdef __cplusplus } diff --git a/src/LYOptions.c b/src/LYOptions.c index 676f9d99..c20d34c9 100644 --- a/src/LYOptions.c +++ b/src/LYOptions.c @@ -1,4 +1,4 @@ -/* $LynxId: LYOptions.c,v 1.138 2010/09/22 09:36:44 tom Exp $ */ +/* $LynxId: LYOptions.c,v 1.141 2010/09/25 11:20:21 tom Exp $ */ #include <HTUtils.h> #include <HTFTP.h> #include <HTTP.h> /* 'reloading' flag */ @@ -643,7 +643,7 @@ void LYoptions(void) _statusline(EDITOR_LOCKED); } else { if (non_empty(editor)) - LYstrncpy(display_option, editor, sizeof(display_option) - 1); + LYStrNCpy(display_option, editor, sizeof(display_option) - 1); else { /* clear the NONE */ LYmove(L_EDITOR, COL_OPTION_VALUES); LYaddstr(" "); @@ -652,7 +652,7 @@ void LYoptions(void) _statusline(ACCEPT_DATA); LYmove(L_EDITOR, COL_OPTION_VALUES); lynx_start_bold(); - ch = LYgetstr(display_option, VISIBLE, + ch = LYGetStr(display_option, VISIBLE, sizeof(display_option), NORECALL); lynx_stop_bold(); LYmove(L_EDITOR, COL_OPTION_VALUES); @@ -679,7 +679,7 @@ void LYoptions(void) case 'D': /* Change the display. */ if (non_empty(x_display)) { - LYstrncpy(display_option, x_display, sizeof(display_option) - 1); + LYStrNCpy(display_option, x_display, sizeof(display_option) - 1); } else { /* clear the NONE */ LYmove(L_DISPLAY, COL_OPTION_VALUES); LYaddstr(" "); @@ -688,7 +688,7 @@ void LYoptions(void) _statusline(ACCEPT_DATA); LYmove(L_DISPLAY, COL_OPTION_VALUES); lynx_start_bold(); - ch = LYgetstr(display_option, VISIBLE, + ch = LYGetStr(display_option, VISIBLE, sizeof(display_option), NORECALL); lynx_stop_bold(); LYmove(L_DISPLAY, COL_OPTION_VALUES); @@ -796,7 +796,7 @@ void LYoptions(void) goto draw_options; } if (non_empty(bookmark_page)) { - LYstrncpy(display_option, + LYStrNCpy(display_option, bookmark_page, sizeof(display_option) - 1); } else { /* clear the NONE */ @@ -807,7 +807,7 @@ void LYoptions(void) _statusline(ACCEPT_DATA); LYmove(L_HOME, C_DEFAULT); lynx_start_bold(); - ch = LYgetstr(display_option, VISIBLE, + ch = LYGetStr(display_option, VISIBLE, sizeof(display_option), NORECALL); lynx_stop_bold(); LYmove(L_HOME, C_DEFAULT); @@ -865,7 +865,7 @@ void LYoptions(void) case 'P': /* Change personal mail address for From headers. */ if (non_empty(personal_mail_address)) { - LYstrncpy(display_option, + LYStrNCpy(display_option, personal_mail_address, sizeof(display_option) - 1); } else { /* clear the NONE */ @@ -876,7 +876,7 @@ void LYoptions(void) _statusline(ACCEPT_DATA); LYmove(L_MAIL_ADDRESS, COL_OPTION_VALUES); lynx_start_bold(); - ch = LYgetstr(display_option, VISIBLE, + ch = LYGetStr(display_option, VISIBLE, sizeof(display_option), NORECALL); lynx_stop_bold(); LYmove(L_MAIL_ADDRESS, COL_OPTION_VALUES); @@ -1081,7 +1081,7 @@ void LYoptions(void) case 'G': /* Change language preference. */ if (non_empty(language)) { - LYstrncpy(display_option, language, sizeof(display_option) - 1); + LYStrNCpy(display_option, language, sizeof(display_option) - 1); } else { /* clear the NONE */ LYmove(L_LANGUAGE, COL_OPTION_VALUES); LYaddstr(" "); @@ -1090,7 +1090,7 @@ void LYoptions(void) _statusline(ACCEPT_DATA); LYmove(L_LANGUAGE, COL_OPTION_VALUES); lynx_start_bold(); - ch = LYgetstr(display_option, VISIBLE, + ch = LYGetStr(display_option, VISIBLE, sizeof(display_option), NORECALL); lynx_stop_bold(); LYmove(L_LANGUAGE, COL_OPTION_VALUES); @@ -1116,7 +1116,7 @@ void LYoptions(void) case 'H': /* Change charset preference. */ if (non_empty(pref_charset)) { - LYstrncpy(display_option, + LYStrNCpy(display_option, pref_charset, sizeof(display_option) - 1); } else { /* clear the NONE */ @@ -1127,7 +1127,7 @@ void LYoptions(void) _statusline(ACCEPT_DATA); LYmove(L_PREF_CHARSET, COL_OPTION_VALUES); lynx_start_bold(); - ch = LYgetstr(display_option, VISIBLE, + ch = LYGetStr(display_option, VISIBLE, sizeof(display_option), NORECALL); lynx_stop_bold(); LYmove(L_PREF_CHARSET, COL_OPTION_VALUES); @@ -1450,7 +1450,7 @@ void LYoptions(void) case 'A': /* Change user agent string. */ if (!no_useragent) { if (non_empty(LYUserAgent)) { - LYstrncpy(display_option, + LYStrNCpy(display_option, LYUserAgent, sizeof(display_option) - 1); } else { /* clear the NONE */ @@ -1461,7 +1461,7 @@ void LYoptions(void) _statusline(ACCEPT_DATA_OR_DEFAULT); LYmove(L_User_Agent, COL_OPTION_VALUES); lynx_start_bold(); - ch = LYgetstr(display_option, VISIBLE, + ch = LYGetStr(display_option, VISIBLE, sizeof(display_option), NORECALL); lynx_stop_bold(); LYmove(L_User_Agent, COL_OPTION_VALUES); @@ -1782,7 +1782,7 @@ void edit_bookmarks(void) #define MULTI_OFFSET 8 int a; /* misc counter */ - char MBM_tmp_line[LY_MAXPATH]; /* buffer for LYgetstr */ + char MBM_tmp_line[LY_MAXPATH]; /* buffer for LYGetStr */ /* * We need (MBM_V_MAXFILES + MULTI_OFFSET) lines to display the whole list @@ -1981,11 +1981,11 @@ void edit_bookmarks(void) 9); else LYmove((3 + a), 9); - LYstrncpy(MBM_tmp_line, + LYStrNCpy(MBM_tmp_line, (!MBM_A_subdescript[a] ? "" : MBM_A_subdescript[a]), sizeof(MBM_tmp_line) - 1); - (void) LYgetstr(MBM_tmp_line, VISIBLE, + (void) LYGetStr(MBM_tmp_line, VISIBLE, sizeof(MBM_tmp_line), NORECALL); lynx_stop_bold(); @@ -2019,10 +2019,10 @@ void edit_bookmarks(void) LYaddstr("| "); lynx_start_bold(); - LYstrncpy(MBM_tmp_line, + LYStrNCpy(MBM_tmp_line, NonNull(MBM_A_subbookmark[a]), sizeof(MBM_tmp_line) - 1); - (void) LYgetstr(MBM_tmp_line, VISIBLE, + (void) LYGetStr(MBM_tmp_line, VISIBLE, sizeof(MBM_tmp_line), NORECALL); lynx_stop_bold(); @@ -2077,7 +2077,7 @@ int popup_choice(int cur_choice, const char **choices, int i_length, int disabled, - BOOLEAN for_mouse) + int for_mouse) { if (column < 0) column = (COL_OPTION_VALUES - 1); @@ -3270,7 +3270,7 @@ int postoptions(DocInfo *newdoc) * old-style LYK_OPTIONS (mainloop): */ if ((need_end_reload == TRUE && - (strncmp(newdoc->address, "http", 4) == 0 || + (StrNCmp(newdoc->address, "http", 4) == 0 || isLYNXCGI(newdoc->address) == 0))) { /* * An option has changed which may influence content negotiation, and diff --git a/src/LYOptions.h b/src/LYOptions.h index 2e402613..ede60134 100644 --- a/src/LYOptions.h +++ b/src/LYOptions.h @@ -1,3 +1,4 @@ +/* $LynxId: LYOptions.h,v 1.29 2010/09/25 11:40:36 tom Exp $ */ #ifndef LYOPTIONS_H #define LYOPTIONS_H @@ -17,7 +18,7 @@ extern "C" { const char **choices, int length, int disabled, - BOOLEAN mouse); + int mouse); #define LYChoosePopup(cur, line, column, choices, length, disabled, mouse) \ popup_choice(cur, line, column, (const char **)choices, length, disabled, mouse) diff --git a/src/LYPrettySrc.c b/src/LYPrettySrc.c index de9394e3..97681147 100644 --- a/src/LYPrettySrc.c +++ b/src/LYPrettySrc.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYPrettySrc.c,v 1.22 2010/09/22 09:39:40 tom Exp $ + * $LynxId: LYPrettySrc.c,v 1.24 2010/09/24 22:06:29 tom Exp $ * * HTML source syntax highlighting * by Vlad Harchev <hvv@hippo.ru> @@ -181,8 +181,8 @@ static void append_open_tag(char *tagname, /* returns FALSE if incorrect */ int html_src_parse_tagspec(char *ts, HTlexeme lexeme, - BOOL checkonly, - BOOL isstart) + int checkonly, + int isstart) { BOOL stop = FALSE; BOOL code = FALSE; @@ -393,7 +393,7 @@ static void failed_init(const char *tag, int lexeme) exit_immediately(EXIT_FAILURE); } -void HTMLSRC_init_caches(BOOL dont_exit) +void HTMLSRC_init_caches(int dont_exit) { int i; char *p; @@ -402,7 +402,7 @@ void HTMLSRC_init_caches(BOOL dont_exit) CTRACE2(TRACE_CFG, (tfp, "HTMLSRC_init_caches(%d tagspecs)\n", HTL_num_lexemes)); for (i = 0; i < HTL_num_lexemes; ++i) { /*we assume that HT_tagspecs was NULLs at when program started */ - LYstrncpy(buf, + LYStrNCpy(buf, HTL_tagspecs[i] ? HTL_tagspecs[i] : HTL_tagspecs_defaults[i], diff --git a/src/LYPrettySrc.h b/src/LYPrettySrc.h index 0031eb7c..66f84302 100644 --- a/src/LYPrettySrc.h +++ b/src/LYPrettySrc.h @@ -1,5 +1,5 @@ /* - * $LynxId: LYPrettySrc.h,v 1.10 2009/03/11 00:40:00 tom Exp $ + * $LynxId: LYPrettySrc.h,v 1.12 2010/09/24 09:42:58 tom Exp $ */ #ifndef LYPrettySrc_H #define LYPrettySrc_H @@ -72,13 +72,13 @@ extern "C" { extern HT_tagspec *lexeme_end[HTL_num_lexemes]; extern int html_src_parse_tagspec(char *ts, HTlexeme lexeme, - BOOL checkonly, BOOL isstart); - extern void HTMLSRC_init_caches(BOOL dont_exit); + int checkonly, int isstart); + extern void HTMLSRC_init_caches(int dont_exit); extern void html_src_clean_item(HTlexeme l); extern void html_src_clean_data(void); extern void html_src_on_lynxcfg_reload(void); -/* these 2 vars tell what kind of transform should be appiled to tag names +/* these 2 vars tell what kind of transform should be applied to tag names and attribute names. 0 - lowercase, 1 - as is, 2 uppercase. */ extern int tagname_transform; extern int attrname_transform; diff --git a/src/LYPrint.c b/src/LYPrint.c index ba71a6d5..1d972403 100644 --- a/src/LYPrint.c +++ b/src/LYPrint.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYPrint.c,v 1.87 2010/04/29 23:46:07 tom Exp $ + * $LynxId: LYPrint.c,v 1.90 2010/09/25 11:20:29 tom Exp $ */ #include <HTUtils.h> #include <HTAccess.h> @@ -139,7 +139,7 @@ static void SetupFilename(char *filename, HTAtom *encoding; char *cp; - LYstrncpy(filename, sug_filename, LY_MAXPATH - 1); /* add suggestion info */ + LYStrNCpy(filename, sug_filename, LY_MAXPATH - 1); /* add suggestion info */ /* make the sug_filename conform to system specs */ change_sug_filename(filename); if (!(HTisDocumentSource()) @@ -182,7 +182,7 @@ static int RecallFilename(char *filename, } recall = ((*total >= 1) ? RECALL_URL : NORECALL); - if ((ch = LYgetstr(filename, VISIBLE, LY_MAXPATH, recall)) < 0 || + if ((ch = LYGetStr(filename, VISIBLE, LY_MAXPATH, recall)) < 0 || *filename == '\0' || ch == UPARROW || ch == DNARROW) { if (recall && ch == UPARROW) { if (*first) { @@ -208,7 +208,7 @@ static int RecallFilename(char *filename, return FN_INIT; } else if ((cp = (char *) HTList_objectAt(sug_filenames, *now)) != NULL) { - LYstrncpy(filename, cp, LY_MAXPATH - 1); + LYStrNCpy(filename, cp, LY_MAXPATH - 1); if (*total == 1) { _statusline(EDIT_THE_PREV_FILENAME); } else { @@ -239,7 +239,7 @@ static int RecallFilename(char *filename, return FN_INIT; } else if ((cp = (char *) HTList_objectAt(sug_filenames, *now)) != NULL) { - LYstrncpy(filename, cp, LY_MAXPATH - 1); + LYStrNCpy(filename, cp, LY_MAXPATH - 1); if (*total == 1) { _statusline(EDIT_THE_PREV_FILENAME); } else { @@ -445,7 +445,7 @@ static void send_file_to_file(DocInfo *newdoc, #ifdef VMS if (0 == strncasecomp(buffer, "sys$disk:", 9)) { - if (0 == strncmp((buffer + 9), "[]", 2)) { + if (0 == StrNCmp((buffer + 9), "[]", 2)) { HTAddSugFilename(buffer + 11); } else { HTAddSugFilename(buffer + 9); @@ -500,8 +500,8 @@ static void send_file_to_mail(DocInfo *newdoc, } _statusline(MAIL_ADDRESS_PROMPT); - LYstrncpy(user_response, personal_mail_address, sizeof(user_response) - 1); - if (LYgetstr(user_response, + LYStrNCpy(user_response, personal_mail_address, sizeof(user_response) - 1); + if (LYGetStr(user_response, VISIBLE, sizeof(user_response), RECALL_MAIL) < 0 || @@ -553,7 +553,7 @@ static void send_file_to_mail(DocInfo *newdoc, char *temp = 0; HTSprintf0(&temp, mail_adrs, user_response); - LYstrncpy(user_response, temp, sizeof(user_response) - 1); + LYStrNCpy(user_response, temp, sizeof(user_response) - 1); FREE(temp); } @@ -956,7 +956,7 @@ static void send_file_to_printer(DocInfo *newdoc, static void send_file_to_screen(DocInfo *newdoc, char *content_base, - BOOLEAN Lpansi) + int Lpansi) { FILE *outfile_fp; char prompt[80]; @@ -968,7 +968,7 @@ static void send_file_to_screen(DocInfo *newdoc, } *prompt = '\0'; - if (LYgetstr(prompt, VISIBLE, sizeof(prompt), NORECALL) < 0) { + if (LYGetStr(prompt, VISIBLE, sizeof(prompt), NORECALL) < 0) { CancelPrint(PRINT_REQUEST_CANCELLED); } @@ -1392,7 +1392,7 @@ char *GetFileName(void) */ #ifdef VMS if (0 == strncasecomp(fbuf, "sys$disk:", 9)) { - if (0 == strncmp((fbuf + 9), "[]", 2)) { + if (0 == StrNCmp((fbuf + 9), "[]", 2)) { HTAddSugFilename(fbuf + 11); } else { HTAddSugFilename(fbuf + 9); diff --git a/src/LYReadCFG.c b/src/LYReadCFG.c index fd028104..4e9357ec 100644 --- a/src/LYReadCFG.c +++ b/src/LYReadCFG.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYReadCFG.c,v 1.152 2010/09/23 20:53:32 tom Exp $ + * $LynxId: LYReadCFG.c,v 1.154 2010/09/24 22:57:51 tom Exp $ */ #ifndef NO_RULES #include <HTRules.h> @@ -200,7 +200,7 @@ static void add_item_to_list(char *buffer, if (cur_item->name == NULL) outofmem(__FILE__, "read_cfg"); - LYstrncpy(cur_item->name, buffer, (int) (colon - buffer)); + LYStrNCpy(cur_item->name, buffer, (int) (colon - buffer)); remove_backslashes(cur_item->name); /* @@ -217,7 +217,7 @@ static void add_item_to_list(char *buffer, if (cur_item->command == NULL) outofmem(__FILE__, "read_cfg"); - LYstrncpy(cur_item->command, + LYStrNCpy(cur_item->command, colon + 1, (int) (next_colon - (colon + 1))); remove_backslashes(cur_item->command); @@ -249,8 +249,9 @@ lynx_list_item_type *find_item_by_number(lynx_list_item_type *list_ptr, return list_ptr; } -int match_item_by_name(lynx_list_item_type *ptr, char *name, - BOOLEAN only_overriders) +int match_item_by_name(lynx_list_item_type *ptr, + const char *name, + int only_overriders) { return (ptr->command != 0 @@ -789,7 +790,7 @@ static int lynx_sig_file_fun(char *value) { char temp[LY_MAXPATH]; - LYstrncpy(temp, value, sizeof(temp) - 1); + LYStrNCpy(temp, value, sizeof(temp) - 1); if (LYPathOffHomeOK(temp, sizeof(temp))) { StrAllocCopy(LynxSigFile, temp); LYAddPathToHome(temp, sizeof(temp), LynxSigFile); @@ -998,7 +999,7 @@ static int system_editor_fun(char *value) } #define SetViewer(mime_type, viewer) \ - HTSetPresentation(mime_type, viewer, 0, 1.0, 3.0, 0.0, 0, mediaCFG) + HTSetPresentation(mime_type, viewer, 0, 1.0, 3.0, 0.0, 0L, mediaCFG) static int viewer_fun(char *value) { @@ -1054,7 +1055,7 @@ static int nonrest_sigwinch_fun(char *value) } #ifdef USE_CHARSET_CHOICE -static void matched_charset_choice(BOOL display_charset, +static void matched_charset_choice(int display_charset, int i) { int j; @@ -1073,7 +1074,7 @@ static void matched_charset_choice(BOOL display_charset, } static int parse_charset_choice(char *p, - BOOL display_charset) /*if FALSE, then assumed doc charset */ + int display_charset) /*if FALSE, then assumed doc charset */ { int len, i; int matches = 0; diff --git a/src/LYReadCFG.h b/src/LYReadCFG.h index 2175f3fe..498d0669 100644 --- a/src/LYReadCFG.h +++ b/src/LYReadCFG.h @@ -1,5 +1,5 @@ /* - * $LynxId: LYReadCFG.h,v 1.24 2010/09/23 20:53:47 tom Exp $ + * $LynxId: LYReadCFG.h,v 1.25 2010/09/24 09:41:51 tom Exp $ */ #ifndef LYREADCFG_H #define LYREADCFG_H @@ -59,7 +59,7 @@ extern "C" { *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); + extern int match_item_by_name(lynx_list_item_type *ptr, const char *name, int only_overriders); extern lynx_list_item_type *find_item_by_number(lynx_list_item_type * list_ptr, char *number); diff --git a/src/LYSearch.c b/src/LYSearch.c index 3f6b22cd..a70103f2 100644 --- a/src/LYSearch.c +++ b/src/LYSearch.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYSearch.c,v 1.24 2010/05/05 09:19:31 tom Exp $ + * $LynxId: LYSearch.c,v 1.26 2010/09/25 11:20:40 tom Exp $ */ #include <HTUtils.h> #include <HTAlert.h> @@ -184,7 +184,7 @@ BOOL textsearch(DocInfo *cur_doc, char *prev_target, * LYK_NEXT or LYK_PREV was pressed, so copy the buffer into * prev_target. */ - LYstrncpy(prev_target, prev_target_buffer, target_size); + LYStrNCpy(prev_target, prev_target_buffer, target_size); if (strlen(prev_target) == 0) { /* @@ -194,13 +194,13 @@ BOOL textsearch(DocInfo *cur_doc, char *prev_target, */ _statusline(ENTER_WHEREIS_QUERY); - ch = LYgetstr(prev_target, VISIBLE, (unsigned) target_size, recall); + ch = LYGetStr(prev_target, VISIBLE, (unsigned) target_size, recall); if (ch < 0) { /* * User cancelled the search via ^G. Restore prev_target and * return. - FM */ - LYstrncpy(prev_target, prev_target_buffer, target_size); + LYStrNCpy(prev_target, prev_target_buffer, target_size); HTInfoMsg(CANCELLED); return (FALSE); } @@ -249,7 +249,7 @@ BOOL textsearch(DocInfo *cur_doc, char *prev_target, QueryNum = 0; if ((cp = (char *) HTList_objectAt(search_queries, QueryNum)) != NULL) { - LYstrncpy(prev_target, cp, target_size); + LYStrNCpy(prev_target, cp, target_size); if (*prev_target_buffer && !strcmp(prev_target_buffer, prev_target)) { _statusline(EDIT_CURRENT_QUERY); @@ -259,13 +259,13 @@ BOOL textsearch(DocInfo *cur_doc, char *prev_target, } else { _statusline(EDIT_A_PREV_QUERY); } - ch = LYgetstr(prev_target, VISIBLE, (unsigned) target_size, recall); + ch = LYGetStr(prev_target, VISIBLE, (unsigned) target_size, recall); if (ch < 0) { /* * User canceled the search via ^G. Restore prev_target and * return. - FM */ - LYstrncpy(prev_target, prev_target_buffer, target_size); + LYStrNCpy(prev_target, prev_target_buffer, target_size); HTInfoMsg(CANCELLED); return (FALSE); } @@ -301,7 +301,7 @@ BOOL textsearch(DocInfo *cur_doc, char *prev_target, QueryNum = QueryTotal - 1; if ((cp = (char *) HTList_objectAt(search_queries, QueryNum)) != NULL) { - LYstrncpy(prev_target, cp, target_size); + LYStrNCpy(prev_target, cp, target_size); if (*prev_target_buffer && !strcmp(prev_target_buffer, prev_target)) { _statusline(EDIT_CURRENT_QUERY); @@ -311,13 +311,13 @@ BOOL textsearch(DocInfo *cur_doc, char *prev_target, } else { _statusline(EDIT_A_PREV_QUERY); } - ch = LYgetstr(prev_target, VISIBLE, (unsigned) target_size, recall); + ch = LYGetStr(prev_target, VISIBLE, (unsigned) target_size, recall); if (ch < 0) { /* * User cancelled the search via ^G. Restore prev_target and * return. - FM */ - LYstrncpy(prev_target, prev_target_buffer, target_size); + LYStrNCpy(prev_target, prev_target_buffer, target_size); HTInfoMsg(CANCELLED); return (FALSE); } @@ -327,7 +327,7 @@ BOOL textsearch(DocInfo *cur_doc, char *prev_target, /* * Replace the search string buffer with the new target. - FM */ - LYstrncpy(prev_target_buffer, prev_target, sizeof(prev_target_buffer) - 1); + LYStrNCpy(prev_target_buffer, prev_target, sizeof(prev_target_buffer) - 1); HTAddSearchQuery(prev_target_buffer); if (direction < 0) { diff --git a/src/LYShowInfo.c b/src/LYShowInfo.c index fe2eb498..f3b7f8fb 100644 --- a/src/LYShowInfo.c +++ b/src/LYShowInfo.c @@ -1,4 +1,4 @@ -/* $LynxId: LYShowInfo.c,v 1.70 2010/09/22 09:35:55 tom Exp $ */ +/* $LynxId: LYShowInfo.c,v 1.72 2010/09/25 00:47:28 tom Exp $ */ #include <HTUtils.h> #include <HTFile.h> #include <HTParse.h> @@ -29,7 +29,7 @@ #define END_DL() fprintf(fp0, "\n</dl>\n") #define ADD_SS(label,value) dt_String(fp0, label, value) -#define ADD_NN(label,value,units) dt_Number(fp0, label, value, units) +#define ADD_NN(label,value,units) dt_Number(fp0, label, (long) value, units) static int label_columns; @@ -61,7 +61,7 @@ const char *LYVersionDate(void) { static char temp[LYNX_DATE_LEN + 1]; - LYstrncpy(temp, &LYNX_DATE[LYNX_DATE_OFF], LYNX_DATE_LEN); + LYStrNCpy(temp, &LYNX_DATE[LYNX_DATE_OFF], LYNX_DATE_LEN); return temp; } diff --git a/src/LYStrings.c b/src/LYStrings.c index 647ad4a2..79424f63 100644 --- a/src/LYStrings.c +++ b/src/LYStrings.c @@ -1,4 +1,4 @@ -/* $LynxId: LYStrings.c,v 1.175 2010/09/23 08:44:00 tom Exp $ */ +/* $LynxId: LYStrings.c,v 1.181 2010/09/25 15:20:49 tom Exp $ */ #include <HTUtils.h> #include <HTCJK.h> #include <UCAux.h> @@ -319,7 +319,7 @@ static char *LYFindInCloset(RecallType recall, char *base) while (!HTList_isEmpty(list)) { data = (char *) HTList_nextObject(list); - if (data != NULL && !strncmp(base, data, len)) + if (data != NULL && !StrNCmp(base, data, len)) return (data); } @@ -583,7 +583,7 @@ char *LYstrncpy(char *dst, if (n < 0) n = 0; - val = strncpy(dst, src, (unsigned) n); + val = StrNCpy(dst, src, n); if (len < n) *(dst + len) = '\0'; else @@ -604,7 +604,7 @@ char *LYmbcsstrncpy(char *dst, const char *src, int n_bytes, int n_glyphs, - BOOL utf_flag) + int utf_flag) { char *val = dst; int i_bytes = 0, i_glyphs = 0; @@ -635,7 +635,7 @@ char *LYmbcsstrncpy(char *dst, */ const char *LYmbcs_skip_glyphs(const char *data, int n_glyphs, - BOOL utf_flag) + int utf_flag) { int i_glyphs = 0; @@ -669,7 +669,7 @@ const char *LYmbcs_skip_glyphs(const char *data, */ const char *LYmbcs_skip_cells(const char *data, int n_cells, - BOOL utf_flag) + int utf_flag) { const char *result; int actual; @@ -691,8 +691,8 @@ const char *LYmbcs_skip_cells(const char *data, * (Full- width characters in CJK mode count as one.) - kw */ int LYmbcsstrlen(const char *str, - BOOL utf_flag, - BOOL count_gcells) + int utf_flag, + int count_gcells) { int i, j, len = 0; @@ -884,9 +884,9 @@ static int sl_read_mouse_event(int code) #endif /* USE_SLANG and USE_MOUSE */ static BOOLEAN csi_is_csi = TRUE; -void ena_csi(BOOLEAN flag) +void ena_csi(int flag) { - csi_is_csi = flag; + csi_is_csi = (BOOLEAN) flag; } #if defined(USE_KEYMAPS) @@ -989,12 +989,12 @@ static const char *expand_tiname(const char *first, size_t len, char **result, c char name[BUFSIZ]; int code; - strncpy(name, first, len); + StrNCpy(name, first, len); name[len] = '\0'; if ((code = lookup_tiname(name, strnames)) >= 0 || (code = lookup_tiname(name, strfnames)) >= 0) { if (cur_term->type.Strings[code] != 0) { - LYstrncpy(*result, cur_term->type.Strings[code], (int) (final - *result)); + LYStrNCpy(*result, cur_term->type.Strings[code], (int) (final - *result)); (*result) += strlen(*result); } } @@ -1058,7 +1058,7 @@ static const char *expand_tichar(const char *first, char **result, char *final) char *last = 0; char tmp[80]; - LYstrncpy(tmp, first, limit); + LYStrNCpy(tmp, first, limit); value = (int) strtol(tmp, &last, radix); if (last != 0 && last != tmp) first += (last - tmp); @@ -1094,7 +1094,7 @@ static BOOLEAN expand_substring(char *dst, if (s == 0) s = first + strlen(first); - first = expand_tiname(first, (unsigned) (s - first), &dst, final); + first = expand_tiname(first, (size_t) (s - first), &dst, final); if (dst == was) return FALSE; if (*first) @@ -1171,7 +1171,7 @@ int map_string_to_keysym(const char *str, int *keysym) char buf[BUFSIZ]; if (othersym >= 0 && other - str - 4 < BUFSIZ) { - strncpy(buf, str + 4, (unsigned) (other - str - 4)); + StrNCpy(buf, str + 4, (other - str - 4)); buf[other - str - 4] = '\0'; *keysym = lacname_to_lac(buf); if (*keysym >= 0) { @@ -1395,7 +1395,7 @@ static int read_keymap_file(void) for (n = 0; n < TABLESIZE(table); n++) { size_t len = strlen(table[n].name); - if (strlen(s) > len && !strncmp(s, table[n].name, len) + if (strlen(s) > len && !StrNCmp(s, table[n].name, len) && (*(table[n].func)) (LYSkipBlanks(s + len)) < 0) fprintf(stderr, FAILED_READING_KEYMAP, linenum, file); } @@ -2780,7 +2780,7 @@ char *LYElideString(char *str, static char s_str[MAX_LINE]; int len; - LYstrncpy(buff, str, sizeof(buff) - 1); + LYStrNCpy(buff, str, (int) sizeof(buff) - 1); len = (int) strlen(buff); if (len > (LYcolLimit - 9)) { buff[cut_pos] = '.'; @@ -2908,7 +2908,7 @@ void LYSetupEdit(EDREC * edit, char *old, Margin = 10; } - LYstrncpy(Buf, old, maxstr); + LYStrNCpy(Buf, old, maxstr); StrLen = (int) strlen(Buf); } @@ -3015,7 +3015,7 @@ static int map_active = 0; int LYEditInsert(EDREC * edit, unsigned const char *s, int len, int map GCC_UNUSED, - BOOL maxMessage) + int maxMessage) { int length = (int) strlen(Buf); int remains = MaxLen - (length + len); @@ -3070,7 +3070,7 @@ int LYEditInsert(EDREC * edit, unsigned const char *s, } else utfbuf[0] = (char) ucode; } - strncpy(Buf + off, utfbuf, (unsigned) l); + StrNCpy(Buf + off, utfbuf, l); edited = 1; off += l; s++; @@ -3087,7 +3087,7 @@ int LYEditInsert(EDREC * edit, unsigned const char *s, int ch; if (*s < 128 && LYKbLayouts[current_layout][*s]) { - ch = UCTransUniChar(LYKbLayouts[current_layout][*s], + ch = UCTransUniChar((UCode_t) LYKbLayouts[current_layout][*s], current_char_set); if (ch < 0) ch = '?'; @@ -3100,7 +3100,7 @@ int LYEditInsert(EDREC * edit, unsigned const char *s, } else #endif /* defined EXP_KEYBOARD_LAYOUT */ { - strncpy(Buf + Pos, (const char *) s, (unsigned) len); + StrNCpy(Buf + Pos, (const char *) s, len); edited = 1; } @@ -3128,7 +3128,7 @@ int LYEditInsert(EDREC * edit, unsigned const char *s, */ int LYEdit1(EDREC * edit, int ch, int action, - BOOL maxMessage) + int maxMessage) { int i; int length; @@ -3469,7 +3469,7 @@ int LYEdit1(EDREC * edit, int ch, { int reglen = Pos - Mark; - LYstrncpy(killbuffer, &Buf[Mark], + LYStrNCpy(killbuffer, &Buf[Mark], HTMIN(reglen, (int) sizeof(killbuffer) - 1)); for (i = Mark; Buf[i + reglen]; i++) Buf[i] = Buf[i + reglen]; @@ -3545,7 +3545,7 @@ int get_popup_number(const char *msg, /* * Get the number, possibly with a suffix, from the user. */ - if (LYgetstr(temp, VISIBLE, sizeof(temp), NORECALL) < 0 || *temp == 0) { + if (LYGetStr(temp, VISIBLE, sizeof(temp), NORECALL) < 0 || *temp == 0) { HTInfoMsg(CANCELLED); *c = '\0'; *rel = '\0'; @@ -3930,11 +3930,11 @@ static int normalCmpList(const void *a, return strcmp(*(const char *const *) a, *(const char *const *) b); } -static char **sortedList(HTList *list, BOOL ignorecase) +static char **sortedList(HTList *list, int ignorecase) { - unsigned count = (unsigned) HTList_count(list); - unsigned j = 0; - unsigned k, jk; + size_t count = (unsigned) HTList_count(list); + size_t j = 0; + size_t k, jk; char **result = typecallocn(char *, count + 1); if (result == 0) @@ -4004,7 +4004,7 @@ static void FormatChoiceNum(char *dst, digits, (choice + 1), MAX_LINE - 9 - digits, value); } else { - LYstrncpy(dst, value, MAX_LINE - 1); + LYStrNCpy(dst, value, MAX_LINE - 1); } } @@ -4026,7 +4026,7 @@ static unsigned options_width(const char **list) static void draw_option(WINDOW * win, int entry, int width, - BOOL reversed, + int reversed, int num_choices, int number, const char *value) @@ -4084,7 +4084,7 @@ int LYhandlePopupList(int cur_choice, int width, int i_length, int disabled, - BOOLEAN for_mouse) + int for_mouse) { BOOLEAN numbered = (BOOLEAN) (keypad_mode != NUMBERS_AS_ARROWS); int c = 0, cmd = 0, i = 0, j = 0, rel = 0; @@ -4316,7 +4316,7 @@ int LYhandlePopupList(int cur_choice, max_choices, i, choices[i]); } } - LYbox(form_window, (BOOLEAN) !numbered); + LYbox(form_window, !numbered); Cptr = NULL; /* @@ -4331,7 +4331,7 @@ int LYhandlePopupList(int cur_choice, | (num_choices - window_offset >= length ? CAN_SCROLL_DOWN : 0)); if (~can_scroll & can_scroll_was) { /* Need to redraw */ - LYbox(form_window, (BOOLEAN) !numbered); + LYbox(form_window, !numbered); can_scroll_was = 0; } if (can_scroll & ~can_scroll_was & CAN_SCROLL_UP) { @@ -4752,7 +4752,7 @@ int LYhandlePopupList(int cur_choice, */ if ((cp = (char *) HTList_objectAt(search_queries, 0)) != NULL) { - LYstrncpy(prev_target_buffer, + LYStrNCpy(prev_target_buffer, cp, sizeof(prev_target_buffer) - 1); QueryNum = 0; @@ -4764,7 +4764,7 @@ int LYhandlePopupList(int cur_choice, case LYK_WHEREIS: if (*prev_target == '\0') { _statusline(ENTER_WHEREIS_QUERY); - if ((ch = LYgetstr(prev_target, VISIBLE, + if ((ch = LYGetStr(prev_target, VISIBLE, sizeof(prev_target_buffer), recall)) < 0) { /* @@ -4818,7 +4818,7 @@ int LYhandlePopupList(int cur_choice, } if ((cp = (char *) HTList_objectAt(search_queries, QueryNum)) != NULL) { - LYstrncpy(prev_target, cp, sizeof(prev_target) - 1); + LYStrNCpy(prev_target, cp, sizeof(prev_target) - 1); if (*prev_target_buffer && !strcmp(prev_target_buffer, prev_target)) { _statusline(EDIT_CURRENT_QUERY); @@ -4829,7 +4829,7 @@ int LYhandlePopupList(int cur_choice, } else { _statusline(EDIT_A_PREV_QUERY); } - if ((ch = LYgetstr(prev_target, VISIBLE, + if ((ch = LYGetStr(prev_target, VISIBLE, sizeof(prev_target_buffer), recall)) < 0) { /* * User cancelled the search via ^G. - FM @@ -4872,7 +4872,7 @@ int LYhandlePopupList(int cur_choice, } if ((cp = (char *) HTList_objectAt(search_queries, QueryNum)) != NULL) { - LYstrncpy(prev_target, cp, sizeof(prev_target) - 1); + LYStrNCpy(prev_target, cp, sizeof(prev_target) - 1); if (*prev_target_buffer && !strcmp(prev_target_buffer, prev_target)) { _statusline(EDIT_CURRENT_QUERY); @@ -4884,7 +4884,7 @@ int LYhandlePopupList(int cur_choice, } else { _statusline(EDIT_A_PREV_QUERY); } - if ((ch = LYgetstr(prev_target, VISIBLE, + if ((ch = LYGetStr(prev_target, VISIBLE, sizeof(prev_target_buffer), recall)) < 0) { /* @@ -5070,7 +5070,7 @@ int LYgetstr(char *inputline, } if (recall != NORECALL && (ch == UPARROW || ch == DNARROW)) { - LYstrncpy(inputline, MyEdit.buffer, (int) bufsize); + LYStrNCpy(inputline, MyEdit.buffer, (int) bufsize); LYAddToCloset(recall, MyEdit.buffer); CTRACE((tfp, "LYgetstr(%s) recall\n", inputline)); return (ch); @@ -5163,7 +5163,7 @@ int LYgetstr(char *inputline, /* * Terminate the string and return. */ - LYstrncpy(inputline, MyEdit.buffer, (int) bufsize); + LYStrNCpy(inputline, MyEdit.buffer, (int) bufsize); if (!hidden) LYAddToCloset(recall, MyEdit.buffer); CTRACE((tfp, "LYgetstr(%s) LYE_ENTER\n", inputline)); @@ -5285,14 +5285,14 @@ const char *LYLineeditHelpURL(void) if (lasthelp_lineedit == current_lineedit) return &helpbuf[0]; if (lasthelp_lineedit == -1) { - LYstrncpy(helpbuf, helpfilepath, sizeof(helpbuf) - 1); + LYStrNCpy(helpbuf, helpfilepath, sizeof(helpbuf) - 1); phelp += strlen(helpbuf); } if (LYLineeditHelpURLs[current_lineedit] && strlen(LYLineeditHelpURLs[current_lineedit]) && (strlen(LYLineeditHelpURLs[current_lineedit]) <= sizeof(helpbuf) - (unsigned) (phelp - helpbuf))) { - LYstrncpy(phelp, LYLineeditHelpURLs[current_lineedit], + LYStrNCpy(phelp, LYLineeditHelpURLs[current_lineedit], (int) (sizeof(helpbuf) - (unsigned) (phelp - helpbuf) - 1)); lasthelp_lineedit = current_lineedit; return (&helpbuf[0]); @@ -5542,8 +5542,8 @@ const char *LYno_attr_char_strstr(const char *chptr, */ const char *LYno_attr_mbcs_case_strstr(const char *chptr, const char *tarptr, - BOOL utf_flag, - BOOL count_gcells, + int utf_flag, + int count_gcells, int *nstartp, int *nendp) { @@ -5705,8 +5705,8 @@ const char *LYno_attr_mbcs_case_strstr(const char *chptr, */ const char *LYno_attr_mbcs_strstr(const char *chptr, const char *tarptr, - BOOL utf_flag, - BOOL count_gcells, + int utf_flag, + int count_gcells, int *nstartp, int *nendp) { @@ -5854,7 +5854,7 @@ char *SNACopy(char **dest, outofmem(__FILE__, "SNACopy"); assert(*dest != NULL); } - strncpy(*dest, src, (unsigned) n); + StrNCpy(*dest, src, n); *(*dest + n) = '\0'; /* terminate */ } return *dest; @@ -5871,11 +5871,12 @@ char *SNACat(char **dest, if (*dest) { int length = (int) strlen(*dest); - *dest = (char *) realloc(*dest, (unsigned) (length + n + 1)); + *dest = typeRealloc(char, *dest, length + n + 1); + if (*dest == NULL) outofmem(__FILE__, "SNACat"); assert(*dest != NULL); - strncpy(*dest + length, src, (unsigned) n); + StrNCpy(*dest + length, src, n); *(*dest + length + n) = '\0'; /* terminate */ } else { *dest = typeMallocn(char, (unsigned) n + 1); @@ -5883,7 +5884,7 @@ char *SNACat(char **dest, if (*dest == NULL) outofmem(__FILE__, "SNACat"); assert(*dest != NULL); - memcpy(*dest, src, (unsigned) n); + MemCpy(*dest, src, n); (*dest)[n] = '\0'; /* terminate */ } } @@ -5991,7 +5992,7 @@ char *LYSafeGets(char **src, if (result != 0) *result = 0; - while (fgets(buffer, sizeof(buffer), fp) != NULL) { + while (fgets(buffer, (int) sizeof(buffer), fp) != NULL) { if (*buffer) result = StrAllocCat(result, buffer); if (strchr(buffer, '\n') != 0) diff --git a/src/LYStrings.h b/src/LYStrings.h index b3c95ff1..c31360f1 100644 --- a/src/LYStrings.h +++ b/src/LYStrings.h @@ -1,5 +1,5 @@ /* - * $LynxId: LYStrings.h,v 1.75 2010/05/05 09:19:31 tom Exp $ + * $LynxId: LYStrings.h,v 1.78 2010/09/25 11:18:47 tom Exp $ */ #ifndef LYSTRINGS_H #define LYSTRINGS_H @@ -33,7 +33,8 @@ extern "C" { extern char *LYstrncpy(char *dst, const char *src, int n); - extern void ena_csi(BOOLEAN flag); +#define LYStrNCpy(dst,src,n) LYstrncpy(dst,src,(int)(n)) + extern void ena_csi(int flag); extern int get_popup_number(const char *msg, int *c, int *rel); @@ -47,6 +48,8 @@ extern "C" { int hidden, size_t bufsize, RecallType recall); +#define LYGetStr(input,hidden,bufsize,recall) \ + LYgetstr(input,hidden,(size_t)(bufsize),recall) extern int LYscanFloat(const char *source, float *result); extern int LYscanFloat2(const char **source, float *result); extern char *LYstrsep(char **stringp, @@ -57,27 +60,27 @@ extern "C" { const char *src, int n_bytes, int n_glyphs, - BOOL utf_flag); + int utf_flag); extern const char *LYmbcs_skip_cells(const char *data, int n_cells, - BOOL utf_flag); + int utf_flag); extern const char *LYmbcs_skip_glyphs(const char *data, int n_glyphs, - BOOL utf_flag); + int utf_flag); extern int LYmbcsstrlen(const char *str, - BOOL utf_flag, - BOOL count_gcells); + int utf_flag, + int count_gcells); extern const char *LYno_attr_mbcs_strstr(const char *chptr, const char *tarptr, - BOOL utf_flag, - BOOL count_gcells, + int utf_flag, + int 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 utf_flag, + int count_gcells, int *nstartp, int *nendp); @@ -327,7 +330,7 @@ extern "C" { extern int LYEditKeyForAction(int lac, int *pmodkey); /* LYEditmap.c */ extern int LYEdit1(EditFieldData *edit, int ch, int action, - BOOL maxMessage); + int maxMessage); extern void LYCloseCloset(RecallType recall); extern int LYhandlePopupList(int cur_choice, int ly, @@ -336,7 +339,7 @@ extern "C" { int width, int i_length, int disabled, - BOOLEAN for_mouse); + int for_mouse); typedef unsigned char LYEditCode; @@ -359,7 +362,7 @@ extern "C" { extern int LYEditInsert(EditFieldData *edit, unsigned const char *s, int len, int map_active, - BOOL maxMessage); + int maxMessage); #ifdef __cplusplus } diff --git a/src/LYStyle.c b/src/LYStyle.c index 62b8a014..61dc30d4 100644 --- a/src/LYStyle.c +++ b/src/LYStyle.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYStyle.c,v 1.68 2010/09/22 09:47:49 tom Exp $ + * $LynxId: LYStyle.c,v 1.69 2010/09/24 22:07:20 tom Exp $ * * character level styles for Lynx * (c) 1996 Rob Partington -- donated to the Lyncei (if they want it :-) @@ -727,7 +727,7 @@ void cache_tag_styles(void) int i; for (i = 0; i < HTML_ELEMENTS; ++i) { - LYstrncpy(buf, HTML_dtd.tags[i].name, sizeof(buf) - 1); + LYStrNCpy(buf, HTML_dtd.tags[i].name, sizeof(buf) - 1); LYLowerCase(buf); cached_tag_styles[i] = hash_code(buf); } diff --git a/src/LYTraversal.c b/src/LYTraversal.c index 5f357654..2aa95faa 100644 --- a/src/LYTraversal.c +++ b/src/LYTraversal.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYTraversal.c,v 1.28 2010/09/22 09:42:40 tom Exp $ + * $LynxId: LYTraversal.c,v 1.30 2010/09/24 22:57:01 tom Exp $ */ #include <HTUtils.h> #include <LYGlobalDefs.h> @@ -14,7 +14,7 @@ /* routines to handle special traversal feature */ -static void final_perror(const char *msg, BOOLEAN clean_flag) +static void final_perror(const char *msg, int clean_flag) { int saved_errno = errno; @@ -162,7 +162,7 @@ BOOLEAN lookup_reject(char *target) if (len != 0) { /* if not an empty line */ if (buffer[len - 1] == '*') { /* if last char is * and the rest of the chars match */ - if ((len == 1) || (strncmp(line, buffer, len - 1) == 0)) { + if ((len == 1) || (StrNCmp(line, buffer, len - 1) == 0)) { result = TRUE; } } else { diff --git a/src/LYUpload.c b/src/LYUpload.c index 7556ed06..8f405b07 100644 --- a/src/LYUpload.c +++ b/src/LYUpload.c @@ -1,4 +1,6 @@ /* + * $LynxId: LYUpload.c,v 1.35 2010/09/25 11:34:51 tom Exp $ + * * Routines to upload files to the local filesystem. * Created by: Rick Mallett, Carleton University * Report problems to rmallett@ccs.carleton.ca @@ -86,7 +88,7 @@ int LYUpload(char *line) _statusline(FILENAME_PROMPT); retry: *tmpbuf = '\0'; - if (LYgetstr(tmpbuf, VISIBLE, sizeof(tmpbuf), NORECALL) < 0) + if (LYGetStr(tmpbuf, VISIBLE, sizeof(tmpbuf), NORECALL) < 0) goto cancelled; if (*tmpbuf == '\0') diff --git a/src/LYUtils.c b/src/LYUtils.c index 8fe8fbc2..a87b9e18 100644 --- a/src/LYUtils.c +++ b/src/LYUtils.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYUtils.c,v 1.198 2010/09/23 09:39:14 tom Exp $ + * $LynxId: LYUtils.c,v 1.203 2010/09/25 13:04:06 tom Exp $ */ #include <HTUtils.h> #include <HTTCP.h> @@ -311,7 +311,7 @@ int ascii_isupper(int i) * Check for UTF-8 data, returning the length past the first character. * Return zero if we found an ordinary character rather than UTF-8. */ -size_t utf8_length(BOOL utf_flag, +size_t utf8_length(int utf_flag, const char *data) { size_t utf_extra = 0; @@ -452,8 +452,8 @@ static BOOL show_whereis_targets(int flag, int cur, int count, const char *target, - BOOL TargetEmphasisON, - BOOL utf_flag) + int TargetEmphasisON, + int utf_flag) { const char *Data = NULL; const char *cp; @@ -492,7 +492,7 @@ static BOOL show_whereis_targets(int flag, */ LYmbcsstrncpy(buffer, NonNull(LYGetHiliteStr(cur, count)), - (sizeof(buffer) - 1), + (int) (sizeof(buffer) - 1), (LYcolLimit - LYGetHilitePos(cur, count)), utf_flag); hlen = (int) strlen(buffer); @@ -547,7 +547,7 @@ static BOOL show_whereis_targets(int flag, tmp[0] = data[itmp]; utf_extra = utf8_length(utf_flag, data + itmp); if (utf_extra) { - LYstrncpy(&tmp[1], &data[itmp + 1], (int) utf_extra); + LYStrNCpy(&tmp[1], &data[itmp + 1], (int) utf_extra); itmp += (int) utf_extra; /* * Start emphasis immediately if we are making the link @@ -618,7 +618,7 @@ static BOOL show_whereis_targets(int flag, */ utf_extra = utf8_length(utf_flag, data + itmp); if (utf_extra) { - LYstrncpy(&tmp[1], &data[itmp + 1], (int) utf_extra); + LYStrNCpy(&tmp[1], &data[itmp + 1], (int) utf_extra); itmp += (int) utf_extra; /* * Make sure we don't restore emphasis to the last @@ -744,7 +744,7 @@ static BOOL show_whereis_targets(int flag, tmp[0] = data[itmp]; utf_extra = utf8_length(utf_flag, data + itmp); if (utf_extra) { - LYstrncpy(&tmp[1], &data[itmp + 1], (int) utf_extra); + LYStrNCpy(&tmp[1], &data[itmp + 1], (int) utf_extra); itmp += (int) utf_extra; /* * Start emphasis immediately if we are making the link @@ -818,7 +818,7 @@ static BOOL show_whereis_targets(int flag, */ utf_extra = utf8_length(utf_flag, data + itmp); if (utf_extra) { - LYstrncpy(&tmp[1], &data[itmp + 1], (int) utf_extra); + LYStrNCpy(&tmp[1], &data[itmp + 1], (int) utf_extra); itmp += (int) utf_extra; /* * Make sure we don't restore emphasis to the last @@ -938,7 +938,7 @@ static BOOL show_whereis_targets(int flag, */ utf_extra = utf8_length(utf_flag, data + itmp); if (utf_extra) { - LYstrncpy(&tmp[1], &data[itmp + 1], (int) utf_extra); + LYStrNCpy(&tmp[1], &data[itmp + 1], (int) utf_extra); itmp += (int) utf_extra; /* * Make sure we don't restore emphasis to the @@ -1008,7 +1008,7 @@ static BOOL show_whereis_targets(int flag, } highlight_search_done: FREE(theData); - return TargetEmphasisON; + return (BOOLEAN) TargetEmphasisON; } #endif /* SHOW_WHEREIS_TARGETS */ @@ -1100,7 +1100,7 @@ void LYhighlight(int flag, /* * Bugs in the history code might cause -1 to be sent for cur, which yields - * a crash when LYstrncpy() is called with a nonsense pointer. As far as I + * a crash when LYStrNCpy() is called with a nonsense pointer. As far as I * know, such bugs have been squashed, but if they should reappear, this * works around them. -FM */ @@ -1157,7 +1157,7 @@ void LYhighlight(int flag, avail_space = links[cur].l_form->size; len = (int) (LYmbcs_skip_cells(text, avail_space, utf_flag) - text); - LYwaddnstr(LYwin, text, (unsigned) len); + LYwaddnstr(LYwin, text, (size_t) len); while (len++ < avail_space) LYaddch('_'); @@ -1176,7 +1176,7 @@ void LYhighlight(int flag, */ LYmbcsstrncpy(buffer, NonNull(LYGetHiliteStr(cur, 0)), - (sizeof(buffer) - 1), + (int) (sizeof(buffer) - 1), (LYcolLimit - LXP), utf_flag); LYaddstr(buffer); @@ -1278,7 +1278,7 @@ void free_and_clear(char **pointer) * space. - FM */ void convert_to_spaces(char *string, - BOOL condense) + int condense) { char *s = string; char *ns; @@ -1379,7 +1379,7 @@ void statusline(const char *text) mustshow = FALSE; /* "LYNXDOWNLOAD://Method=-1/File=%s/SugFile=%s%s\">Save to disk</a>\n" */ - LYstrncpy(text_buff, text, sizeof(text_buff) - 1); + LYStrNCpy(text_buff, text, sizeof(text_buff) - 1); p = strchr(text_buff, '\n'); if (p) *p = '\0'; @@ -1456,7 +1456,7 @@ void statusline(const char *text) len = (int) strlen(text_buff); if (len >= (int) (sizeof(buffer) - 1)) len = (int) (sizeof(buffer) - 1); - strncpy(buffer, text_buff, (size_t) len)[len] = '\0'; + StrNCpy(buffer, text_buff, len)[len] = '\0'; /* FIXME: a binary search might be faster */ while (len > 0 && LYstrExtent(buffer, len, len) > max_length) buffer[--len] = '\0'; @@ -1523,7 +1523,7 @@ void statusline(const char *text) /* draw the status bar in the STATUS style */ { int y, x; - int a = ((strncmp(buffer, ALERT_FORMAT, ALERT_PREFIX_LEN) + int a = ((StrNCmp(buffer, ALERT_FORMAT, ALERT_PREFIX_LEN) || !hashStyles[s_alert].name) ? s_status : s_alert); @@ -1673,7 +1673,7 @@ int LYReopenInput(void) * only if select() is possible - actually, currently only checks if fd is * connected to a tty. - kw */ -int LYConsoleInputFD(BOOLEAN need_selectable) +int LYConsoleInputFD(int need_selectable) { int fd = INVSOC; @@ -1704,7 +1704,7 @@ int LYConsoleInputFD(BOOLEAN need_selectable) static int fake_zap = 0; -void LYFakeZap(BOOL set) +void LYFakeZap(int set) { if (set && fake_zap < 1) { CTRACE((tfp, "\r *** Set simulated 'Z'")); @@ -2238,7 +2238,7 @@ static BOOLEAN compare_type(char *tst, size_t len) { if (!strncasecomp(tst, cmp, (int) len)) { - if (strncmp(tst, cmp, len)) { + if (StrNCmp(tst, cmp, len)) { size_t i; for (i = 0; i < len; i++) @@ -2248,12 +2248,13 @@ static BOOLEAN compare_type(char *tst, } return FALSE; } +#define CompareType(tst,cmp,len) compare_type((tst),(cmp),(size_t)(len)) #define DoubleHtmlSep(s) (LYIsHtmlSep((s)[0]) && LYIsHtmlSep((s)[1])) #define compare_two(tst,cmp,len,limit) \ ((len + 2) <= limit \ && DoubleHtmlSep(tst + len) \ - && compare_type(tst, cmp, len)) + && CompareType(tst, cmp, len)) /* * Must recognize a URL and return the type. @@ -2310,7 +2311,7 @@ UrlTypes is_url(char *filename) * Lynx internal pages ("LYNXfoo:" or "lynxfoo:") start with 'l' or * 'L', other URLs aren't. */ - if (compare_type(cp, STR_LYNXEXEC, LEN_LYNXEXEC)) { + if (CompareType(cp, STR_LYNXEXEC, LEN_LYNXEXEC)) { /* * Special External Lynx type to handle execution of commands * or scripts which require a pause to read the screen upon @@ -2318,7 +2319,7 @@ UrlTypes is_url(char *filename) */ result = LYNXEXEC_URL_TYPE; - } else if (compare_type(cp, STR_LYNXPROG, LEN_LYNXPROG)) { + } else if (CompareType(cp, STR_LYNXPROG, LEN_LYNXPROG)) { /* * Special External Lynx type to handle execution of commands, * scripts or programs with do not require a pause to read @@ -2326,75 +2327,75 @@ UrlTypes is_url(char *filename) */ result = LYNXPROG_URL_TYPE; - } else if (compare_type(cp, STR_LYNXCGI, LEN_LYNXCGI)) { + } else if (CompareType(cp, STR_LYNXCGI, LEN_LYNXCGI)) { /* * Special External Lynx type to handle cgi scripts. */ result = LYNXCGI_URL_TYPE; - } else if (compare_type(cp, STR_LYNXPRINT, LEN_LYNXPRINT)) { + } else if (CompareType(cp, STR_LYNXPRINT, LEN_LYNXPRINT)) { /* * Special Internal Lynx type. */ result = LYNXPRINT_URL_TYPE; - } else if (compare_type(cp, STR_LYNXOPTIONS, LEN_LYNXOPTIONS)) { + } else if (CompareType(cp, STR_LYNXOPTIONS, LEN_LYNXOPTIONS)) { /* * Special Internal Lynx type. */ result = LYNXOPTIONS_URL_TYPE; - } else if (compare_type(cp, STR_LYNXCFG, LEN_LYNXCFG)) { + } else if (CompareType(cp, STR_LYNXCFG, LEN_LYNXCFG)) { /* * Special Internal Lynx type. */ result = LYNXCFG_URL_TYPE; - } else if (compare_type(cp, STR_LYNXMESSAGES, LEN_LYNXMESSAGES)) { + } else if (CompareType(cp, STR_LYNXMESSAGES, LEN_LYNXMESSAGES)) { /* * Special Internal Lynx type. */ result = LYNXMESSAGES_URL_TYPE; - } else if (compare_type(cp, STR_LYNXCFLAGS, LEN_LYNXCFLAGS)) { + } else if (CompareType(cp, STR_LYNXCFLAGS, LEN_LYNXCFLAGS)) { /* * Special Internal Lynx type. */ result = LYNXCOMPILE_OPTS_URL_TYPE; - } else if (compare_type(cp, STR_LYNXDOWNLOAD, LEN_LYNXDOWNLOAD)) { + } else if (CompareType(cp, STR_LYNXDOWNLOAD, LEN_LYNXDOWNLOAD)) { /* * Special Internal Lynx type. */ result = LYNXDOWNLOAD_URL_TYPE; - } else if (compare_type(cp, STR_LYNXDIRED, LEN_LYNXDIRED)) { + } else if (CompareType(cp, STR_LYNXDIRED, LEN_LYNXDIRED)) { /* * Special Internal Lynx type. */ result = LYNXDIRED_URL_TYPE; - } else if (compare_type(cp, STR_LYNXHIST, LEN_LYNXHIST)) { + } else if (CompareType(cp, STR_LYNXHIST, LEN_LYNXHIST)) { /* * Special Internal Lynx type. */ result = LYNXHIST_URL_TYPE; #ifdef USE_CACHEJAR - } else if (compare_type(cp, STR_LYNXCACHE, LEN_LYNXCACHE)) { + } else if (CompareType(cp, STR_LYNXCACHE, LEN_LYNXCACHE)) { /* * Special Internal Lynx type. */ result = LYNXCACHE_URL_TYPE; #endif - } else if (compare_type(cp, STR_LYNXKEYMAP, LEN_LYNXKEYMAP)) { + } else if (CompareType(cp, STR_LYNXKEYMAP, LEN_LYNXKEYMAP)) { /* * Special Internal Lynx type. */ result = LYNXKEYMAP_URL_TYPE; - } else if (compare_type(cp, STR_LYNXIMGMAP, LEN_LYNXIMGMAP)) { + } else if (CompareType(cp, STR_LYNXIMGMAP, LEN_LYNXIMGMAP)) { /* * Special Internal Lynx type. */ @@ -2402,7 +2403,7 @@ UrlTypes is_url(char *filename) (void) is_url(&cp[LEN_LYNXIMGMAP]); result = LYNXIMGMAP_URL_TYPE; - } else if (compare_type(cp, STR_LYNXCOOKIE, LEN_LYNXCOOKIE)) { + } else if (CompareType(cp, STR_LYNXCOOKIE, LEN_LYNXCOOKIE)) { /* * Special Internal Lynx type. */ @@ -2415,19 +2416,19 @@ UrlTypes is_url(char *filename) */ case 'N': case 'n': - if (compare_type(cp, STR_NEWS_URL, LEN_NEWS_URL)) { + if (CompareType(cp, STR_NEWS_URL, LEN_NEWS_URL)) { result = NEWS_URL_TYPE; - } else if (compare_type(cp, STR_NNTP_URL, LEN_NNTP_URL)) { + } else if (CompareType(cp, STR_NNTP_URL, LEN_NNTP_URL)) { result = NNTP_URL_TYPE; - } else if (compare_type(cp, "newspost:", 9)) { + } else if (CompareType(cp, "newspost:", 9)) { /* * Special Lynx type to handle news posts. */ result = NEWSPOST_URL_TYPE; - } else if (compare_type(cp, "newsreply:", 10)) { + } else if (CompareType(cp, "newsreply:", 10)) { /* * Special Lynx type to handle news replies (followups). */ @@ -2440,16 +2441,16 @@ UrlTypes is_url(char *filename) */ case 'S': case 's': - if (compare_type(cp, STR_SNEWS_URL, LEN_SNEWS_URL)) { + if (CompareType(cp, STR_SNEWS_URL, LEN_SNEWS_URL)) { result = SNEWS_URL_TYPE; - } else if (compare_type(cp, "snewspost:", 10)) { + } else if (CompareType(cp, "snewspost:", 10)) { /* * Special Lynx type to handle snews posts. */ result = NEWSPOST_URL_TYPE; - } else if (compare_type(cp, "snewsreply:", 11)) { + } else if (CompareType(cp, "snewsreply:", 11)) { /* * Special Lynx type to handle snews replies (followups). */ @@ -2459,14 +2460,14 @@ UrlTypes is_url(char *filename) #endif case 'M': case 'm': - if (compare_type(cp, STR_MAILTO_URL, LEN_MAILTO_URL)) { + if (CompareType(cp, STR_MAILTO_URL, LEN_MAILTO_URL)) { result = MAILTO_URL_TYPE; } break; case 'F': case 'f': - if (compare_type(cp, STR_FILE_URL, LEN_FILE_URL)) { + if (CompareType(cp, STR_FILE_URL, LEN_FILE_URL)) { if (LYisLocalFile(cp)) { result = FILE_URL_TYPE; } else if (DoubleHtmlSep(cp + LEN_FILE_URL)) { @@ -2488,7 +2489,7 @@ UrlTypes is_url(char *filename) case 'B': case 'b': #ifndef DISABLE_BIBP - if (compare_type(cp, STR_BIBP_URL, LEN_BIBP_URL)) { + if (CompareType(cp, STR_BIBP_URL, LEN_BIBP_URL)) { result = BIBP_URL_TYPE; } #endif @@ -2496,7 +2497,7 @@ UrlTypes is_url(char *filename) case 'D': case 'd': - if (compare_type(cp, "data:", 5)) { + if (CompareType(cp, "data:", 5)) { result = DATA_URL_TYPE; } break; @@ -2521,10 +2522,10 @@ UrlTypes is_url(char *filename) switch (*cp) { case 'H': case 'h': - if (compare_type(cp, STR_HTTP_URL, LEN_HTTP_URL)) { + if (CompareType(cp, STR_HTTP_URL, LEN_HTTP_URL)) { result = HTTP_URL_TYPE; - } else if (compare_type(cp, STR_HTTPS_URL, LEN_HTTPS_URL)) { + } else if (CompareType(cp, STR_HTTPS_URL, LEN_HTTPS_URL)) { result = HTTPS_URL_TYPE; } break; @@ -2532,7 +2533,7 @@ UrlTypes is_url(char *filename) #ifndef DISABLE_GOPHER case 'G': case 'g': - if (compare_type(cp, STR_GOPHER_URL, LEN_GOPHER_URL)) { + if (CompareType(cp, STR_GOPHER_URL, LEN_GOPHER_URL)) { if (strlen(cp) >= 11 && (cp1 = strchr(cp + 11, '/')) != NULL) { @@ -2553,45 +2554,45 @@ UrlTypes is_url(char *filename) #endif case 'W': case 'w': - if (compare_type(cp, STR_WAIS_URL, LEN_WAIS_URL)) { + if (CompareType(cp, STR_WAIS_URL, LEN_WAIS_URL)) { result = WAIS_URL_TYPE; } break; case 'T': case 't': - if (compare_type(cp, STR_TELNET_URL, LEN_TELNET_URL)) { + if (CompareType(cp, STR_TELNET_URL, LEN_TELNET_URL)) { result = TELNET_URL_TYPE; - } else if (compare_type(cp, STR_TN3270_URL, LEN_TN3270_URL)) { + } else if (CompareType(cp, STR_TN3270_URL, LEN_TN3270_URL)) { result = TN3270_URL_TYPE; } break; case 'R': case 'r': - if (compare_type(cp, STR_RLOGIN_URL, LEN_RLOGIN_URL)) { + if (CompareType(cp, STR_RLOGIN_URL, LEN_RLOGIN_URL)) { result = RLOGIN_URL_TYPE; } break; case 'C': case 'c': - if (compare_type(cp, STR_CSO_URL, LEN_CSO_URL)) { + if (CompareType(cp, STR_CSO_URL, LEN_CSO_URL)) { result = CSO_URL_TYPE; } break; case 'A': case 'a': - if (compare_type(cp, "afs:", 4)) { + if (CompareType(cp, "afs:", 4)) { result = AFS_URL_TYPE; } break; case 'P': case 'p': - if (compare_type(cp, "prospero:", 9)) { + if (CompareType(cp, "prospero:", 9)) { result = PROSPERO_URL_TYPE; } break; @@ -2680,7 +2681,7 @@ BOOLEAN LYCanDoHEAD(const char *address) if (!non_empty(address)) return FALSE; - if (!strncmp(address, "http", 4)) + if (!StrNCmp(address, "http", 4)) return TRUE; /* Make copy for is_url() since caller may not care for case changes */ StrAllocCopy(temp0, address); @@ -2853,7 +2854,7 @@ BOOLEAN inlocaldomain(void) if (mytty && (fp = fopen(UTMP_FILE, "r")) != NULL) { mytty++; do { - n = (int) fread((char *) &me, sizeof(struct utmp), 1, fp); + n = (int) fread((char *) &me, sizeof(struct utmp), (size_t) 1, fp); } while (n > 0 && !STREQ(me.ut_line, mytty)); (void) LYCloseInput(fp); @@ -3030,7 +3031,7 @@ void size_change(int sig GCC_UNUSED) } #else #ifdef TIOCGWINSZ - if (ioctl(0, TIOCGWINSZ, &win) == 0) { + if (ioctl(0, (long) TIOCGWINSZ, &win) == 0) { if (win.ws_row != 0) { LYlines = win.ws_row; } @@ -3157,7 +3158,7 @@ void change_sug_filename(char *fname) } else { HTSprintf0(&temp, "file://localhost/%s" PID_FMT, cp2, GETPID()); } - if (!strncmp(fname, temp, strlen(temp))) { + if (!StrNCmp(fname, temp, strlen(temp))) { cp = strrchr(fname, '.'); if (strlen(cp) > (strlen(temp) - 4)) cp = NULL; @@ -3812,7 +3813,7 @@ void print_restrictions_to_fd(FILE *fp) /* if "goto" is restricted, don't bother tell about its * refinements */ - if (strncmp(restrictions[i].name, "goto_", 5) + if (StrNCmp(restrictions[i].name, "goto_", 5) || !no_goto) fprintf(fp, " %s\n", restrictions[i].name); } @@ -4071,7 +4072,7 @@ void LYConvertToURL(char **AllocatedString, goto have_VMS_URL; } else { fragment = trimPoundSelector(old_string); - LYstrncpy(url_file, old_string, sizeof(url_file) - 1); + LYStrNCpy(url_file, old_string, sizeof(url_file) - 1); } url_file_dsc.dsc$w_length = (short) strlen(url_file); if (1 & lib$find_file(&url_file_dsc, &file_name_dsc, &context, @@ -4254,7 +4255,7 @@ void LYConvertToURL(char **AllocatedString, if (old_string[1] != ':' && old_string[1] != '|') { StrAllocCopy(temp, wwwName(curdir)); LYAddHtmlSep(&temp); - LYstrncpy(curdir, temp, (sizeof(curdir) - 1)); + LYStrNCpy(curdir, temp, (sizeof(curdir) - 1)); StrAllocCat(temp, old_string); } else { curdir[0] = '\0'; @@ -4566,8 +4567,8 @@ BOOLEAN LYExpandHostForURL(char **AllocatedString, /* * If it's a partial or relative path, don't continue pointlessly. - FM */ - if (!strncmp(*AllocatedString, "..", 2) || - !strncmp(*AllocatedString, "./", 2)) { + if (!StrNCmp(*AllocatedString, "..", 2) || + !StrNCmp(*AllocatedString, "./", 2)) { return GotHost; } @@ -4771,7 +4772,7 @@ BOOLEAN LYExpandHostForURL(char **AllocatedString, while (*EndS && !WHITE(*EndS) && *EndS != ',') { EndS++; /* Find separator */ } - LYstrncpy(DomainSuffix, StartS, (int) (EndS - StartS)); + LYStrNCpy(DomainSuffix, StartS, (int) (EndS - StartS)); } } while ((GotHost == FALSE) && (*DomainSuffix != '\0')); @@ -4787,7 +4788,7 @@ BOOLEAN LYExpandHostForURL(char **AllocatedString, while (*EndP && !WHITE(*EndP) && *EndP != ',') { EndP++; /* Find separator */ } - LYstrncpy(DomainPrefix, StartP, (int) (EndP - StartP)); + LYStrNCpy(DomainPrefix, StartP, (int) (EndP - StartP)); } } while ((GotHost == FALSE) && (*DomainPrefix != '\0')); @@ -5028,7 +5029,7 @@ void LYDoCSI(char *url, if (cp == NULL) return; - if (strncmp(cp, "!--#", 4)) + if (StrNCmp(cp, "!--#", 4)) return; cp += 4; @@ -5083,7 +5084,7 @@ char *Current_Dir(char *pathname) char *result; #ifdef HAVE_GETCWD - result = getcwd(pathname, LY_MAXPATH); + result = getcwd(pathname, (size_t) LY_MAXPATH); #else result = getwd(pathname); #endif /* NO_GETCWD */ @@ -5365,7 +5366,7 @@ BOOLEAN LYPathOffHomeOK(char *fbuffer, /* * Check if it has a pointless "./". - FM */ - if (!strncmp(cp, "./", 2)) { + if (!StrNCmp(cp, "./", 2)) { if (strchr((cp + 2), '/') == NULL) { cp += 2; } @@ -5387,7 +5388,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 @@ -5409,7 +5410,7 @@ BOOLEAN LYPathOffHomeOK(char *fbuffer, * Search for a leading tilde, optionally embedded. If found, return a pointer * to the tilde. If not found, return the original parameter. */ -static char *FindLeadingTilde(char *pathname, BOOL embedded) +static char *FindLeadingTilde(char *pathname, int embedded) { char *result = pathname; @@ -5455,7 +5456,7 @@ char *LYAbsOrHomePath(char **fname) * "embedded" is true, allow that "leading" tilde to follow a path separator. */ char *LYTildeExpand(char **pathname, - BOOL embedded) + int embedded) { char *temp = FindLeadingTilde(*pathname, embedded); @@ -5543,7 +5544,7 @@ void LYAddPathToHome(char *fbuffer, * what fits of the home path and return. This will fail, but we need * something in the buffer. - FM */ - LYstrncpy(fbuffer, home, (int) (fbuffer_size - 1)); + LYStrNCpy(fbuffer, home, (int) (fbuffer_size - 1)); FREE(home); return; } @@ -5551,7 +5552,7 @@ void LYAddPathToHome(char *fbuffer, /* * Check whether we have a subdirectory path or just a filename. - FM */ - if (!strncmp(file, "./", 2)) { + if (!StrNCmp(file, "./", 2)) { /* * We have a subdirectory path. - FM */ @@ -5583,7 +5584,7 @@ void LYAddPathToHome(char *fbuffer, * Check whether we have a subdirectory path or just a filename. - FM */ sprintf(fbuffer, "%s/%.*s", home, len, - (strncmp(file, "./", 2) ? file : (file + 2))); + (StrNCmp(file, "./", 2) ? file : (file + 2))); #endif /* VMS */ FREE(home); } @@ -5660,7 +5661,7 @@ int putenv(const char *string) /* Remove the variable from the environment. */ size = strlen(string); for (ep = environ; *ep != NULL; ++ep) - if (!strncmp(*ep, string, size) && (*ep)[size] == '=') { + if (!StrNCmp(*ep, string, size) && (*ep)[size] == '=') { while (ep[1] != NULL) { ep[0] = ep[1]; ++ep; @@ -5672,7 +5673,7 @@ int putenv(const char *string) size = 0; for (ep = environ; *ep != NULL; ++ep) - if (!strncmp(*ep, string, name_end - string) && + if (!StrNCmp(*ep, string, name_end - string) && (*ep)[name_end - string] == '=') break; else @@ -5721,7 +5722,7 @@ static BOOL IsOurSymlink(const char *name) char *buffer = typeMallocn(char, (unsigned) size); if (buffer != 0) { - while ((used = (int) readlink(name, buffer, (unsigned) (size - 1))) == size + while ((used = (int) readlink(name, buffer, (size_t) (size - 1))) == size - 1) { buffer = typeRealloc(char, buffer, (unsigned) (size *= 2)); @@ -5973,7 +5974,7 @@ BOOLEAN LYCachedTemp(char *result, char **cached) { if (*cached) { - LYstrncpy(result, *cached, LY_MAXPATH); + LYStrNCpy(result, *cached, LY_MAXPATH); FREE(*cached); if (LYCanReadFile(result)) { remove(result); @@ -6237,7 +6238,7 @@ FILE *LYOpenTempRewrite(char *fname, * We truncate and then append, this avoids having a small window * in which the file doesn't exist. - kw */ - if (truncate(fname, 0) != 0) { + if (truncate(fname, (off_t) 0) != 0) { CTRACE((tfp, "... truncate(%s,0) failed: %s\n", fname, LYStrerror(errno))); return (LYOpenTemp(fname, suffix, mode)); @@ -6393,7 +6394,7 @@ void LYCleanupTemp(void) if (lynx_temp_subspace > 0) { char result[LY_MAXPATH]; - LYstrncpy(result, lynx_temp_space, sizeof(result) - 1); + LYStrNCpy(result, lynx_temp_space, sizeof(result) - 1); LYTrimPathSep(result); CTRACE((tfp, "LYCleanupTemp removing %s\n", result)); rmdir(result); @@ -6509,7 +6510,7 @@ BOOL LYIsUIPage3(const char *url, if (!ly_uip[i].url) { return NO; } else if ((flagparam & UIP_P_FRAG) ? - (!strncmp(ly_uip[i].url, url, (l = strlen(ly_uip[i].url))) + (!StrNCmp(ly_uip[i].url, url, (l = strlen(ly_uip[i].url))) && (url[l] == '\0' || url[l] == '#')) : !strcmp(ly_uip[i].url, url)) { return YES; @@ -6519,7 +6520,7 @@ BOOL LYIsUIPage3(const char *url, while ((p = (char *) HTList_nextObject(l0)) != NULL) { if ((flagparam & UIP_P_FRAG) ? - (!strncmp(p, url, (l = strlen(p))) + (!StrNCmp(p, url, (l = strlen(p))) && (url[l] == '\0' || url[l] == '#')) : !strcmp(p, url)) return YES; @@ -6634,7 +6635,7 @@ BOOLEAN LYValidateFilename(char *result, HTUserMsg(SPAWNING_DISABLED); code = FALSE; } else { - LYstrncpy(result, given, LY_MAXPATH); + LYStrNCpy(result, given, LY_MAXPATH); } #endif } else { @@ -7007,8 +7008,8 @@ int LYCopyFile(char *src, if ((fin = fopen(src, BIN_R)) != 0) { if ((fout = fopen(dst, BIN_W)) != 0) { code = 0; - while ((len = fread(buff, 1, sizeof(buff), fin)) != 0) { - if (fwrite(buff, 1, len, fout) < len + while ((len = fread(buff, (size_t) 1, sizeof(buff), fin)) != 0) { + if (fwrite(buff, (size_t) 1, len, fout) < len || ferror(fout)) { code = EOF; break; @@ -7535,9 +7536,13 @@ char *get_clip_grab(void) return NULL; if (paste_buf) FREE(paste_buf); - paste_buf = (char *) malloc(PASTE_BUFFER); + paste_buf = typeMallocn(char, PASTE_BUFFER); + while (1) { - len = (int) fread(paste_buf + off, 1, PASTE_BUFFER - 1, paste_handle); + len = (int) fread(paste_buf + off, + (size_t) 1, + (size_t) PASTE_BUFFER - 1, + paste_handle); paste_buf[off + len] = '\0'; if (len < PASTE_BUFFER - 1) break; @@ -7563,7 +7568,7 @@ int put_clip(const char *s) fh = popen(cmd, TXT_W); if (!fh) return -1; - res = fwrite(s, 1, l, fh); + res = fwrite(s, (size_t) 1, l, fh); if (pclose(fh) != 0 || res != l) return -1; return 0; @@ -7815,7 +7820,7 @@ void LYSyslog(char *arg) if (is_url(arg)) { /* proto://user:password@host/path:port */ /* ^this colon */ if ((colon1 = strchr(arg, ':')) != 0 - && !strncmp(colon1, "://", 3) + && !StrNCmp(colon1, "://", 3) && (colon2 = strchr(colon1 + 3, ':')) != 0 && (atsign = strchr(colon1, '@')) != 0 && (colon2 < atsign) diff --git a/src/LYUtils.h b/src/LYUtils.h index f6d7c49a..780a70c3 100644 --- a/src/LYUtils.h +++ b/src/LYUtils.h @@ -1,4 +1,4 @@ -/* $LynxId: LYUtils.h,v 1.83 2010/06/19 15:36:34 tom Exp $ */ +/* $LynxId: LYUtils.h,v 1.85 2010/09/24 09:58:04 tom Exp $ */ #ifndef LYUTILS_H #define LYUTILS_H @@ -134,7 +134,7 @@ extern "C" { extern char *LYGetEnv(const char *name); extern char *LYLastPathSep(const char *path); extern char *LYPathLeaf(char *pathname); - extern char *LYTildeExpand(char **pathname, BOOL embedded); + extern char *LYTildeExpand(char **pathname, int embedded); extern char *LYgetXDisplay(void); extern char *strip_trailing_slash(char *my_dirname); extern char *trimPoundSelector(char *address); @@ -144,7 +144,7 @@ extern "C" { extern const char *index_to_restriction(unsigned inx); extern const char *wwwName(const char *pathname); extern int HTCheckForInterrupt(void); - extern int LYConsoleInputFD(BOOLEAN need_selectable); + extern int LYConsoleInputFD(int need_selectable); extern int LYCopyFile(char *src, char *dst); extern int LYGetHilitePos(int cur, int count); extern int LYRemoveTemp(char *name); @@ -153,8 +153,8 @@ extern "C" { extern int LYValidateOutput(char *filename); extern int find_restriction(const char *name, int len); 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 size_t utf8_length(int utf_flag, const char *data); + extern time_t LYmktime(char *string, int absolute); extern void BeginInternalPage(FILE *fp0, const char *Title, const char *HelpURL); extern void EndInternalPage(FILE *fp0); extern void HTAddSugFilename(char *fname); @@ -174,7 +174,7 @@ extern "C" { extern void LYConvertToURL(char **AllocatedString, int fixit); extern void LYDoCSI(char *url, const char *comment, char **csi); extern void LYEnsureAbsoluteURL(char **href, const char *name, int fixit); - extern void LYFakeZap(BOOL set); + extern void LYFakeZap(int set); extern void LYFixCursesOn(const char *reason); extern void LYFreeHilites(int first, int last); extern void LYFreeStringList(HTList *list); @@ -190,7 +190,7 @@ extern "C" { extern void LYsetXDisplay(char *new_display); 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 convert_to_spaces(char *string, int condense); extern void free_and_clear(char **obj); extern void noviceline(int more_flag); extern void parse_restrictions(const char *s); @@ -514,8 +514,8 @@ extern "C" { */ #define ON 1 #define OFF 0 -#define STREQ(a,b) (strcmp(a,b) == 0) -#define STRNEQ(a,b,c) (strncmp(a,b,c) == 0) +#define STREQ(a,b) (strcmp(a,b) == 0) +#define STRNEQ(a,b,c) (StrNCmp(a,b,c) == 0) #define HIDE_CHMOD 0600 #define HIDE_UMASK 0077 diff --git a/src/LYmktime.c b/src/LYmktime.c index 32de4275..ca66b200 100644 --- a/src/LYmktime.c +++ b/src/LYmktime.c @@ -1,4 +1,4 @@ -/* $LynxId: LYmktime.c,v 1.9 2008/12/27 00:46:30 tom Exp $ */ +/* $LynxId: LYmktime.c,v 1.11 2010/09/25 00:51:53 tom Exp $ */ #include <LYStrings.h> #include <LYUtils.h> @@ -20,7 +20,7 @@ char *LYstrncpy(char *dst, if (n < 0) n = 0; - val = strncpy(dst, src, n); + val = StrNCpy(dst, src, n); if (len < n) *(dst + len) = '\0'; else @@ -54,7 +54,7 @@ FILE *TraceFP(void) * - FM */ time_t LYmktime(char *string, - BOOL absolute) + int absolute) { #if USE_PARSDATE time_t result = 0; diff --git a/src/TRSTable.c b/src/TRSTable.c index 460d00fc..a86e284a 100644 --- a/src/TRSTable.c +++ b/src/TRSTable.c @@ -1,5 +1,5 @@ /* - * $LynxId: TRSTable.c,v 1.26 2010/09/22 09:42:06 tom Exp $ + * $LynxId: TRSTable.c,v 1.28 2010/09/25 12:47:08 tom Exp $ * Simple table object * =================== * Authors @@ -230,14 +230,14 @@ static const char *cellstate_s(cellstate_t state) return result; } -struct _STable_info *Stbl_startTABLE(short alignment) +struct _STable_info *Stbl_startTABLE(int alignment) { STable_info *me = typecalloc(STable_info); CTRACE2(TRACE_TRST, (tfp, "TRST:Stbl_startTABLE(align=%d)\n", (int) alignment)); if (me) { - me->alignment = alignment; + me->alignment = (short) alignment; me->rowgroup_align = HT_ALIGN_NONE; me->pending_colgroup_align = HT_ALIGN_NONE; me->s.x_td = -1; @@ -1655,9 +1655,10 @@ int Stbl_finishCellInTable(STable_info *me, int end_td, /* * Returns -1 on error, otherwise 0. */ -int Stbl_addColInfo(STable_info *me, int colspan, - short alignment, - BOOL isgroup) +int Stbl_addColInfo(STable_info *me, + int colspan, + int alignment, + int isgroup) { STable_cellinfo *sumcols, *sumcol; int i, icolinfo; @@ -1671,7 +1672,7 @@ int Stbl_addColInfo(STable_info *me, int colspan, me->pending_colgroup_next = me->ncolinfo + colspan; if (me->ncolinfo > 0) me->sumcols[me->ncolinfo - 1].cLine = EOCOLG; - me->pending_colgroup_align = alignment; + me->pending_colgroup_align = (short) alignment; } else { for (i = me->pending_colgroup_next - 1; i >= me->ncolinfo + colspan; i--) @@ -1735,11 +1736,11 @@ int Stbl_finishColGroup(STable_info *me) return 0; } -int Stbl_addRowGroup(STable_info *me, short alignment) +int Stbl_addRowGroup(STable_info *me, int alignment) { CTRACE2(TRACE_TRST, (tfp, "TRST:Stbl_addRowGroup()\n")); Stbl_cancelRowSpans(me); - me->rowgroup_align = alignment; + me->rowgroup_align = (short) alignment; return 0; /* that's all! */ } diff --git a/src/TRSTable.h b/src/TRSTable.h index ef11cd54..ffebf4a6 100644 --- a/src/TRSTable.h +++ b/src/TRSTable.h @@ -1,3 +1,4 @@ +/* $LynxId: TRSTable.h,v 1.16 2010/09/25 11:40:05 tom Exp $ */ #ifndef TRSTABLE_H #define TRSTABLE_H @@ -7,16 +8,16 @@ extern "C" { #endif /* TRST_MAXCOLSPAN and TRST_MAXCOLSPAN are defined in userdefs.h */ typedef struct _STable_info STable_info; - extern STable_info *Stbl_startTABLE(short); + extern STable_info *Stbl_startTABLE(int); extern int Stbl_finishTABLE(STable_info *); extern void Stbl_free(STable_info *); extern int Stbl_addRowToTable(STable_info *, int, int); extern int Stbl_addCellToTable(STable_info *, int, int, int, int, int, int, int); extern int Stbl_finishCellInTable(STable_info *, int, int, int, int); - extern int Stbl_addColInfo(STable_info *, int, short, BOOL); + extern int Stbl_addColInfo(STable_info *, int, int, int); extern int Stbl_finishColGroup(STable_info *); - extern int Stbl_addRowGroup(STable_info *, short); + extern int Stbl_addRowGroup(STable_info *, int); #define TRST_ENDCELL_ENDTD 1 #define TRST_ENDCELL_LINEBREAK 0 diff --git a/src/UCAuto.c b/src/UCAuto.c index 37b736f3..a7547674 100644 --- a/src/UCAuto.c +++ b/src/UCAuto.c @@ -1,5 +1,5 @@ /* - * $LynxId: UCAuto.c,v 1.43 2010/05/02 22:23:54 tom Exp $ + * $LynxId: UCAuto.c,v 1.45 2010/09/25 00:51:53 tom Exp $ * * This file contains code for changing the Linux console mode. * Currently some names for font files are hardwired in here. @@ -371,7 +371,7 @@ void UCChangeTerminalCodepage(int newcs, * Also some cpNNN fonts used below are not in the kbd-data. - kw */ - if (!strncmp(name, "iso-8859-1", 10) && + if (!StrNCmp(name, "iso-8859-1", 10) && (!name[10] || !isdigit(UCH(name[10])))) { if ((lastHasUmap == Is_Set) && !strcmp(lastname, "cp850")) { /* @@ -407,7 +407,7 @@ void UCChangeTerminalCodepage(int newcs, TransT = GN_Blat1; /* bogus! */ HasUmap = Dunno; /* distributed lat0 files have bogus map data! */ Utf = Is_Unset; - } else if (!strncmp(name, "iso-8859-", 9)) { + } else if (!StrNCmp(name, "iso-8859-", 9)) { if (strlen(name) <= 10 || !isdigit(UCH(name[10]))) HTSprintf0(&tmpbuf1, "iso0%s", &name[9]); else @@ -495,7 +495,7 @@ void UCChangeTerminalCodepage(int newcs, Utf = Dont_Care; } else if (!strcmp(name, "us-ascii")) { Utf = Dont_Care; - } else if (!strncmp(name, "mnem", 4)) { + } else if (!StrNCmp(name, "mnem", 4)) { Utf = Dont_Care; } @@ -641,7 +641,7 @@ int Find_Best_Display_Charset(int ord) HTInfoMsg(gettext("Charset name in CHARSET_SWITCH_RULES too long")); return ord; } - strncpy(buf, r, s - r); + StrNCpy(buf, r, s - r); buf[s - r] = '\0'; n = UCGetLYhndl_byMIME(buf); if (n < 0) { diff --git a/src/UCAux.c b/src/UCAux.c index 92a4d51b..22cd0ee9 100644 --- a/src/UCAux.c +++ b/src/UCAux.c @@ -1,5 +1,5 @@ /* - * $LynxId: UCAux.c,v 1.41 2010/04/29 09:10:58 tom Exp $ + * $LynxId: UCAux.c,v 1.43 2010/09/25 15:36:51 tom Exp $ */ #include <HTUtils.h> @@ -366,7 +366,7 @@ void UCSetBoxChars(int cset, /* *INDENT-OFF* */ static struct { int mapping; - int internal; + UCode_t internal; int external; } table[] = { { 'j', 0x2518, 0 }, /* BOX DRAWINGS LIGHT UP AND LEFT */ @@ -386,7 +386,8 @@ void UCSetBoxChars(int cset, unsigned n; if (first) { - char *map = tigetstr("acsc"); + static char acsc_name[] = "acsc"; + char *map = tigetstr(acsc_name); if (map != 0) { CTRACE((tfp, "build terminal line-drawing map\n")); @@ -394,7 +395,8 @@ void UCSetBoxChars(int cset, for (n = 0; n < TABLESIZE(table); ++n) { if (table[n].mapping == map[0]) { table[n].external = UCH(map[1]); - CTRACE((tfp, " map[%c] %#x -> %#x\n", + CTRACE((tfp, + " map[%c] %#" PRI_UCode_t " -> %#x\n", table[n].mapping, table[n].internal, table[n].external)); @@ -462,7 +464,7 @@ void UCSetBoxChars(int cset, #define PUTC(ch) ((*myPutc)(target, (char)(ch))) #define PUTC2(ch) ((*myPutc)(target,(char)(0x80|(0x3f &(ch))))) -BOOL UCPutUtf8_charstring(HTStream *target, putc_func_t * myPutc, long code) +BOOL UCPutUtf8_charstring(HTStream *target, putc_func_t * myPutc, UCode_t code) { if (code < 128) return NO; /* indicate to caller we didn't handle it */ diff --git a/src/UCdomap.c b/src/UCdomap.c index 4fffd8a3..f610666d 100644 --- a/src/UCdomap.c +++ b/src/UCdomap.c @@ -1,5 +1,5 @@ /* - * $LynxId: UCdomap.c,v 1.80 2010/09/22 09:41:36 tom Exp $ + * $LynxId: UCdomap.c,v 1.86 2010/09/25 15:31:34 tom Exp $ * * UCdomap.c * ========= @@ -280,15 +280,15 @@ static void set_inverse_transl(int i); static u16 *set_translate(int m); static int UC_valid_UC_charset(int UC_charset_hndl); static void UC_con_set_trans(int UC_charset_in_hndl, int Gn, int update_flag); -static int con_insert_unipair(u16 unicode, u16 fontpos, int fordefault); -static int con_insert_unipair_str(u16 unicode, const char *replace_str, int fordefault); +static int con_insert_unipair(unsigned unicode, unsigned fontpos, int fordefault); +static int con_insert_unipair_str(unsigned unicode, const char *replace_str, int fordefault); static void con_clear_unimap(int fordefault); static void con_clear_unimap_str(int fordefault); static void con_set_default_unimap(void); static int UC_con_set_unimap(int UC_charset_out_hndl, int update_flag); -static int UC_con_set_unimap_str(u16 ct, struct unipair_str *list, int fordefault); +static int UC_con_set_unimap_str(unsigned ct, struct unipair_str *list, int fordefault); static int conv_uni_to_pc(long ucs, int usedefault); -static int conv_uni_to_str(char *outbuf, int buflen, long ucs, int usedefault); +static int conv_uni_to_str(char *outbuf, int buflen, UCode_t ucs, int usedefault); static void UCconsole_map_init(void); static int UC_MapGN(int UChndl, int update_flag); static int UC_FindGN_byMIME(const char *UC_MIMEcharset); @@ -318,7 +318,8 @@ static void set_inverse_transl(int i) */ q = inverse_translations[i] = ((i == LAT1_MAP) ? inv_norm_transl : - (unsigned char *) malloc(MAX_GLYPH)); + typeMallocn(unsigned char, MAX_GLYPH)); + if (!q) return; } @@ -326,7 +327,7 @@ static void set_inverse_transl(int i) q[j] = 0; for (j = 0; j < E_TABSZ; j++) { - glyph = conv_uni_to_pc(p[j], 0); + glyph = conv_uni_to_pc((long) p[j], 0); if (glyph >= 0 && glyph < MAX_GLYPH && q[glyph] < 32) { /* * Prefer '-' above SHY etc. @@ -444,9 +445,10 @@ static char ***unidefault_pagedir_str[32] = static const u16 *UC_default_unitable = 0; static const struct unimapdesc_str *UC_default_unitable_str = 0; -static int con_insert_unipair(u16 unicode, u16 fontpos, int fordefault) +static int con_insert_unipair(unsigned unicode, unsigned fontpos, int fordefault) { - int i, n; + int i; + unsigned n; u16 **p1, *p2; if (fordefault) @@ -477,15 +479,16 @@ static int con_insert_unipair(u16 unicode, u16 fontpos, int fordefault) } } - p2[unicode & 0x3f] = fontpos; + p2[unicode & 0x3f] = (u16) fontpos; return 0; } -static int con_insert_unipair_str(u16 unicode, const char *replace_str, +static int con_insert_unipair_str(unsigned unicode, const char *replace_str, int fordefault) { - int i, n; + int i; + unsigned n; char ***p1; const char **p2; @@ -675,7 +678,7 @@ static int UC_con_set_unimap(int UC_charset_out_hndl, return 0; } -static int UC_con_set_unimap_str(u16 ct, struct unipair_str *list, +static int UC_con_set_unimap_str(unsigned ct, struct unipair_str *list, int fordefault) { int err = 0, err1; @@ -763,7 +766,7 @@ static int conv_uni_to_pc(long ucs, */ static int conv_uni_to_str(char *outbuf, int buflen, - long ucs, + UCode_t ucs, int usedefault) { char *h; @@ -805,7 +808,7 @@ static int conv_uni_to_str(char *outbuf, if (p1 && (p2 = p1[(ucs >> 6) & 0x1f]) && (h = p2[ucs & 0x3f])) { - strncpy(outbuf, h, (size_t) (buflen - 1)); + StrNCpy(outbuf, h, (buflen - 1)); return 1; /* ok ! */ } @@ -832,7 +835,7 @@ static void UCconsole_map_init(void) /* * OK now, finally, some stuff that is more specifically for Lynx: - KW */ -int UCTransUniChar(long unicode, +int UCTransUniChar(UCode_t unicode, int charset_out) { int rc = 0; @@ -878,10 +881,10 @@ int UCTransUniChar(long unicode, } } if (!isdefault && (rc == ucNotFound)) { - rc = conv_uni_to_pc(0xfffd, 0); + rc = conv_uni_to_pc(0xfffdL, 0); } if ((isdefault || trydefault) && (rc == ucNotFound)) { - rc = conv_uni_to_pc(0xfffd, 1); + rc = conv_uni_to_pc(0xfffdL, 1); } return rc; } @@ -891,7 +894,7 @@ int UCTransUniChar(long unicode, */ int UCTransUniCharStr(char *outbuf, int buflen, - long unicode, + UCode_t unicode, int charset_out, int chk_single_flag) { @@ -996,7 +999,8 @@ int UCTransUniCharStr(char *outbuf, iconv_close(cd); if ((pout - outbuf) == 3) { CTRACE((tfp, - "It seems to be a JIS X 0201 code(%ld). Not supported.\n", unicode)); + "It seems to be a JIS X 0201 code(%" PRI_UCode_t + "). Not supported.\n", unicode)); pin = str; inleft = 2; pout = outbuf; @@ -1014,17 +1018,17 @@ int UCTransUniCharStr(char *outbuf, } if (rc == ucNotFound) { if (!isdefault) - rc = conv_uni_to_str(outbuf, buflen, 0xfffd, 0); + rc = conv_uni_to_str(outbuf, buflen, 0xfffdL, 0); if ((rc == ucNotFound) && (isdefault || trydefault)) - rc = conv_uni_to_str(outbuf, buflen, 0xfffd, 1); + rc = conv_uni_to_str(outbuf, buflen, 0xfffdL, 1); if (rc >= 0) return (int) strlen(outbuf); } if (chk_single_flag && src == ucNotFound) { if (!isdefault) - rc = conv_uni_to_pc(0xfffd, 0); + rc = conv_uni_to_pc(0xfffdL, 0); if ((rc == ucNotFound) && (isdefault || trydefault)) - rc = conv_uni_to_pc(0xfffd, 1); + rc = conv_uni_to_pc(0xfffdL, 1); if (rc >= 32) { outbuf[0] = (char) rc; outbuf[1] = '\0'; @@ -1075,11 +1079,12 @@ static int UC_MapGN(int UChndl, return Gn; } -int UCTransChar(char ch_in, +int UCTransChar(int ch_in, int charset_in, int charset_out) { - int unicode, Gn; + UCode_t unicode; + int Gn; int rc = ucNotFound; int UChndl_in, UChndl_out; int isdefault, trydefault = 0; @@ -1135,18 +1140,18 @@ int UCTransChar(char ch_in, rc = conv_uni_to_pc(unicode, 1); } if ((rc == ucNotFound) && !isdefault) { - rc = conv_uni_to_pc(0xfffd, 0); + rc = conv_uni_to_pc(0xfffdL, 0); } if ((rc == ucNotFound) && (isdefault || trydefault)) { - rc = conv_uni_to_pc(0xfffd, 1); + rc = conv_uni_to_pc(0xfffdL, 1); } return rc; } #ifdef EXP_JAPANESEUTF8_SUPPORT -long int UCTransJPToUni(char *inbuf, - int buflen, - int charset_in) +UCode_t UCTransJPToUni(char *inbuf, + int buflen, + int charset_in) { char outbuf[3], *pin, *pout; size_t ilen, olen; @@ -1172,13 +1177,14 @@ long int UCTransJPToUni(char *inbuf, * returns ucNeedMore, based on its internal state. To reset the state, * call this with charset_in < 0. */ -long int UCTransToUni(char ch_in, - int charset_in) +UCode_t UCTransToUni(int ch_in, + int charset_in) { static char buffer[10]; static unsigned inx = 0; - int unicode, Gn; + UCode_t unicode; + int Gn; unsigned char ch_iu = UCH(ch_in); int UChndl_in; @@ -1191,7 +1197,7 @@ long int UCTransToUni(char ch_in, } else if (charset_in == LATIN1) { return ch_iu; } else if (charset_in == UTF8_handle) { - if (is8bits(ch_in)) { + if (is8bits(ch_iu)) { unsigned need; char *ptr; @@ -1225,13 +1231,13 @@ long int UCTransToUni(char ch_in, if (inx == 0) { if (IS_SJIS_HI1(ch_iu) || IS_SJIS_HI2(ch_iu)) { - buffer[0] = ch_in; + buffer[0] = (char) ch_in; inx = 1; return ucNeedMore; } } else { if (IS_SJIS_LO(ch_iu)) { - buffer[1] = ch_in; + buffer[1] = (char) ch_in; buffer[2] = 0; cd = iconv_open("UTF-16BE", "Shift_JIS"); @@ -1247,13 +1253,13 @@ long int UCTransToUni(char ch_in, if (strcmp(LYCharSet_UC[charset_in].MIMEname, "euc-jp") == 0) { if (inx == 0) { if (IS_EUC_HI(ch_iu)) { - buffer[0] = ch_in; + buffer[0] = (char) ch_in; inx = 1; return ucNeedMore; } } else { if (IS_EUC_LOX(ch_iu)) { - buffer[1] = ch_in; + buffer[1] = (char) ch_in; buffer[2] = 0; cd = iconv_open("UTF-16BE", "EUC-JP"); @@ -1294,7 +1300,7 @@ long int UCTransToUni(char ch_in, return unicode; } -int UCReverseTransChar(char ch_out, +int UCReverseTransChar(int ch_out, int charset_in, int charset_out) { @@ -1353,12 +1359,13 @@ int UCReverseTransChar(char ch_out, */ int UCTransCharStr(char *outbuf, int buflen, - char ch_in, + int ch_in, int charset_in, int charset_out, int chk_single_flag) { - int unicode, Gn; + UCode_t unicode; + int Gn; int rc = ucUnknown, src = 0; int UChndl_in, UChndl_out; int isdefault, trydefault = 0; @@ -1369,7 +1376,7 @@ int UCTransCharStr(char *outbuf, if (buflen < 2) return ucBufferTooSmall; if (chk_single_flag && charset_in == charset_out) { - outbuf[0] = ch_in; + outbuf[0] = (char) ch_in; outbuf[1] = '\0'; return 1; } @@ -1446,17 +1453,17 @@ int UCTransCharStr(char *outbuf, } if (rc == ucNotFound) { if (!isdefault) - rc = conv_uni_to_str(outbuf, buflen, 0xfffd, 0); + rc = conv_uni_to_str(outbuf, buflen, 0xfffdL, 0); if ((rc == ucNotFound) && (isdefault || trydefault)) - rc = conv_uni_to_str(outbuf, buflen, 0xfffd, 1); + rc = conv_uni_to_str(outbuf, buflen, 0xfffdL, 1); if (rc >= 0) return (int) strlen(outbuf); } if (chk_single_flag && src == ucNotFound) { if (!isdefault) - rc = conv_uni_to_pc(0xfffd, 0); + rc = conv_uni_to_pc(0xfffdL, 0); if ((rc == ucNotFound) && (isdefault || trydefault)) - rc = conv_uni_to_pc(0xfffd, 1); + rc = conv_uni_to_pc(0xfffdL, 1); if (rc >= 32) { outbuf[0] = (char) rc; outbuf[1] = '\0'; @@ -1549,7 +1556,7 @@ int UCGetLYhndl_byMIME(const char *value) return UCGetLYhndl_byMIME("utf-8"); } #endif - if (!strncasecomp(value, "iso", 3) && !strncmp(value + 3, "8859", 4)) { + if (!strncasecomp(value, "iso", 3) && !StrNCmp(value + 3, "8859", 4)) { return getLYhndl_byCP("iso-", value + 3); } #if !NO_CHARSET_euc_jp @@ -2128,7 +2135,7 @@ static void UCcleanup_mem(void) #ifdef EXP_CHARTRANS_AUTOSWITCH #ifdef CAN_AUTODETECT_DISPLAY_CHARSET # ifdef __EMX__ -static int CpOrdinal(const unsigned long cp, const int other) +static int CpOrdinal(const unsigned UCode_t cp, const int other) { char lyName[80]; char myMimeName[80]; @@ -2246,8 +2253,8 @@ void UCInit(void) #ifdef CAN_AUTODETECT_DISPLAY_CHARSET # ifdef __EMX__ { - unsigned long lst[3]; - unsigned long len, rc; + unsigned UCode_t lst[3]; + unsigned UCode_t len, rc; rc = DosQueryCp(sizeof(lst), lst, &len); if (rc == 0) { diff --git a/src/Xsystem.c b/src/Xsystem.c index fa3e6b96..f1583975 100644 --- a/src/Xsystem.c +++ b/src/Xsystem.c @@ -1,4 +1,4 @@ -/* $LynxId: Xsystem.c,v 1.23 2009/03/10 15:21:42 tom Exp $ +/* $LynxId: Xsystem.c,v 1.24 2010/09/24 22:07:35 tom Exp $ * like system("cmd") but return with exit code of "cmd" * for Turbo-C/MS-C/LSI-C * This code is in the public domain. @@ -335,7 +335,7 @@ static int NEAR prog_go(PRO * p, int flag) if (s < p->cmd) { /* cmd has no PATH nor Drive */ ep = LYGetEnv("PATH"); - LYstrncpy(cmdb, p->cmd, sizeof(cmdb) - 1); + LYStrNCpy(cmdb, p->cmd, sizeof(cmdb) - 1); for (;;) { if (extp) { /* has extension */ if ((rc = open(cmdb, O_RDONLY)) >= 0) { @@ -358,7 +358,7 @@ static int NEAR prog_go(PRO * p, int flag) if (i > 0 && lc != ':' && lc != '\\' && lc != '/') cmdb[i++] = '\\'; cmdb[i] = 0; - LYstrncpy(cmdb + i, p->cmd, sizeof(cmdb) - 1 - i); + LYStrNCpy(cmdb + i, p->cmd, sizeof(cmdb) - 1 - i); } else { if (rc == -2) return rc; @@ -385,7 +385,7 @@ static char *NEAR tmpf(char *tp) int i; if ((ev = LYGetEnv("TMP")) != 0) { - LYstrncpy(tplate, ev, sizeof(tplate) - 2 - strlen(tp)); + LYStrNCpy(tplate, ev, sizeof(tplate) - 2 - strlen(tp)); i = strlen(ev); if (i && ev[i - 1] != '\\' && ev[i - 1] != '/') strcat(tplate, "\\"); diff --git a/src/chrtrans/makeuctb.c b/src/chrtrans/makeuctb.c index 1858474c..e76e0f6f 100644 --- a/src/chrtrans/makeuctb.c +++ b/src/chrtrans/makeuctb.c @@ -1,5 +1,5 @@ /* - * $LynxId: makeuctb.c,v 1.45 2010/09/22 08:31:45 tom Exp $ + * $LynxId: makeuctb.c,v 1.46 2010/09/24 09:52:56 tom Exp $ * * makeuctb.c, derived from conmakehash.c - kw * @@ -361,7 +361,7 @@ int main(int argc, char **argv) /* * Now we comes to the tricky part. Parse the input table. */ - while (fgets(buffer, sizeof(buffer), ctbl) != NULL) { + while (fgets(buffer, (int) sizeof(buffer), ctbl) != NULL) { if ((p = strchr(buffer, '\n')) != NULL) { *p = '\0'; } else { @@ -649,7 +649,7 @@ int main(int argc, char **argv) while (*p == ' ' || *p == '\t') { p++; } - if (!strncmp(p, "idem", 4)) { + if (!StrNCmp(p, "idem", 4)) { for (i = fp0; i <= fp1; i++) { addpair(i, i); } @@ -697,7 +697,7 @@ int main(int argc, char **argv) while (*p == ' ' || *p == '\t') { p++; } - if (!strncmp(p, "idem", 4)) { + if (!StrNCmp(p, "idem", 4)) { addpair(fp0, fp0); p += 4; } @@ -743,9 +743,9 @@ int main(int argc, char **argv) } if (argc > 3) { - strncpy(this_MIMEcharset, argv[3], UC_MAXLEN_MIMECSNAME); + StrNCpy(this_MIMEcharset, argv[3], UC_MAXLEN_MIMECSNAME); } else if (this_MIMEcharset[0] == '\0') { - strncpy(this_MIMEcharset, tblname, UC_MAXLEN_MIMECSNAME); + StrNCpy(this_MIMEcharset, tblname, UC_MAXLEN_MIMECSNAME); if ((p = strchr(this_MIMEcharset, '.')) != 0) { *p = '\0'; } @@ -754,13 +754,13 @@ int main(int argc, char **argv) *p = (char) TOLOWER(*p); } if (argc > 4) { - strncpy(this_LYNXcharset, argv[4], UC_MAXLEN_LYNXCSNAME); + StrNCpy(this_LYNXcharset, argv[4], UC_MAXLEN_LYNXCSNAME); } else if (this_LYNXcharset[0] == '\0') { - strncpy(this_LYNXcharset, this_MIMEcharset, UC_MAXLEN_LYNXCSNAME); + StrNCpy(this_LYNXcharset, this_MIMEcharset, UC_MAXLEN_LYNXCSNAME); } if (this_isDefaultMap == -1) { - this_isDefaultMap = !strncmp(this_MIMEcharset, "iso-8859-1", 10); + this_isDefaultMap = !StrNCmp(this_MIMEcharset, "iso-8859-1", 10); } fprintf(stderr, "makeuctb: %s: %stranslation map", |