diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 2013-05-03 23:53:30 -0400 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 2013-05-03 23:53:30 -0400 |
commit | 398cc2f5cbd84d35293b2a4cd68c73fe854fbddb (patch) | |
tree | c8bb658b5538d7f91e75aca69c834902fb254129 /WWW | |
parent | 844a17014bd45706a13ee5318b36a56fbcf6924c (diff) | |
download | lynx-snapshots-398cc2f5cbd84d35293b2a4cd68c73fe854fbddb.tar.gz |
snapshot of project "lynx", label v2-8-8dev_15d
Diffstat (limited to 'WWW')
-rw-r--r-- | WWW/Library/Implementation/HTAAUtil.c | 5 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTFTP.c | 178 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTMIME.c | 4 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTMLGen.c | 15 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTRules.c | 4 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTString.c | 44 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTVMSUtils.c | 8 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTVMS_WaisUI.c | 21 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTVMS_WaisUI.h | 12 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTWAIS.c | 4 |
10 files changed, 129 insertions, 166 deletions
diff --git a/WWW/Library/Implementation/HTAAUtil.c b/WWW/Library/Implementation/HTAAUtil.c index 2113b400..f7ed67c1 100644 --- a/WWW/Library/Implementation/HTAAUtil.c +++ b/WWW/Library/Implementation/HTAAUtil.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTAAUtil.c,v 1.34 2013/04/30 23:16:09 tom Exp $ + * $LynxId: HTAAUtil.c,v 1.35 2013/05/03 20:32:37 tom Exp $ * * MODULE HTAAUtil.c * COMMON PARTS OF ACCESS AUTHORIZATION MODULE @@ -495,8 +495,7 @@ void HTAA_setupReader(char *start_of_headers, #endif start_pointer = buffer; if (start_of_headers) { - StrNCpy(buffer, start_of_headers, length); - buffer[length] = '\0'; + LYStrNCpy(buffer, start_of_headers, length); end_pointer = buffer + length; } else { *start_pointer = '\0'; diff --git a/WWW/Library/Implementation/HTFTP.c b/WWW/Library/Implementation/HTFTP.c index 43e3083e..b4b78f52 100644 --- a/WWW/Library/Implementation/HTFTP.c +++ b/WWW/Library/Implementation/HTFTP.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTFTP.c,v 1.116 2013/05/01 10:46:59 tom Exp $ + * $LynxId: HTFTP.c,v 1.120 2013/05/03 23:53:30 tom Exp $ * * File Transfer Protocol (FTP) Client * for a WorldWideWeb browser @@ -1452,15 +1452,15 @@ static void set_years_and_date(void) char day[8], month[8], date[12]; time_t NowTime; int i; + char *printable; NowTime = time(NULL); - StrNCpy(day, (char *) ctime(&NowTime) + 8, 2); - day[2] = '\0'; + printable = ctime(&NowTime); + LYStrNCpy(day, printable + 8, 2); if (day[0] == ' ') { day[0] = '0'; } - StrNCpy(month, (char *) ctime(&NowTime) + 4, 3); - month[3] = '\0'; + LYStrNCpy(month, printable + 4, 3); for (i = 0; i < 12; i++) { if (!strcasecomp(month, months[i])) { break; @@ -1469,8 +1469,7 @@ static void set_years_and_date(void) i++; sprintf(date, "9999%02d%.2s", i, day); TheDate = atoi(date); - strcpy(ThisYear, (char *) ctime(&NowTime) + 20); - ThisYear[4] = '\0'; + LYStrNCpy(ThisYear, printable + 20, 4); sprintf(LastYear, "%d", (atoi(ThisYear) - 1)); HaveYears = TRUE; } @@ -1611,8 +1610,7 @@ static void parse_eplf_line(char *line, while (*(++cp) && (*cp != ',')) secs = (secs * 10) + (*cp - '0'); secs += base; /* assumes that time_t is #seconds */ - strcpy(ct, ctime(&secs)); - ct[24] = 0; + LYStrNCpy(ct, ctime(&secs), 24); StrAllocCopy(info->date, ct); break; case '/': @@ -2604,133 +2602,99 @@ static EntryInfo *parse_dir_entry(char *entry, return (entry_info); } +static void formatDate(char target[16], EntryInfo *entry) +{ + char temp[8], month[4]; + int i; + + /* + * Set up for sorting in reverse chronological order. - FM + */ + if (entry->date[9] == ':') { + strcpy(target, "9999"); + LYStrNCpy(temp, &entry->date[7], 5); + if (temp[0] == ' ') { + temp[0] = '0'; + } + } else { + LYStrNCpy(target, &entry->date[8], 4); + strcpy(temp, "00:00"); + } + LYStrNCpy(month, entry->date, 3); + for (i = 0; i < 12; i++) { + if (!strcasecomp(month, months[i])) { + break; + } + } + i++; + sprintf(month, "%02d", i); + strcat(target, month); + StrNCat(target, &entry->date[4], 2); + if (target[6] == ' ' || target[6] == HT_NON_BREAK_SPACE) { + target[6] = '0'; + } + + /* If no year given, assume last year if it would otherwise be in the + * future by more than one day. The one day tolerance is to account for a + * possible timezone difference. - kw + */ + if (target[0] == '9' && atoi(target) > TheDate + 1) { + for (i = 0; i < 4; i++) { + target[i] = LastYear[i]; + } + } + strcat(target, temp); +} + static int compare_EntryInfo_structs(EntryInfo *entry1, EntryInfo *entry2) { - int i, status; - char date1[16], date2[16], time1[8], time2[8], month[4]; + int status; + char date1[16], date2[16]; + int result = strcmp(entry1->filename, entry2->filename); switch (HTfileSortMethod) { case FILE_BY_SIZE: /* both equal or both 0 */ - if (entry1->size == entry2->size) - return (strcmp(entry1->filename, entry2->filename)); - else if (entry1->size > entry2->size) - return (1); - else - return (-1); + if (entry1->size > entry2->size) + result = 1; + else if (entry1->size < entry2->size) + result = -1; + break; case FILE_BY_TYPE: if (entry1->type && entry2->type) { status = strcasecomp(entry1->type, entry2->type); if (status) - return (status); - /* else fall to filename comparison */ + result = status; } - return (strcmp(entry1->filename, entry2->filename)); + break; case FILE_BY_DATE: - if (entry1->date && entry2->date) { + if (entry1->date && entry2->date && + strlen(entry1->date) == 12 && + strlen(entry2->date) == 12) { /* - * Make sure we have the correct length. - FM - */ - if (strlen(entry1->date) != 12 || strlen(entry2->date) != 12) { - return (strcmp(entry1->filename, entry2->filename)); - } - /* - * Set the years and date, - * if we don't have them yet. + * Set the years and date, if we don't have them yet. */ if (!HaveYears) { set_years_and_date(); } - /* - * Set up for sorting in reverse - * chronological order. - FM - */ - if (entry1->date[9] == ':') { - strcpy(date1, "9999"); - strcpy(time1, &entry1->date[7]); - if (time1[0] == ' ') { - time1[0] = '0'; - } - } else { - strcpy(date1, &entry1->date[8]); - strcpy(time1, "00:00"); - } - StrNCpy(month, entry1->date, 3); - month[3] = '\0'; - for (i = 0; i < 12; i++) { - if (!strcasecomp(month, months[i])) { - break; - } - } - i++; - sprintf(month, "%02d", i); - strcat(date1, month); - StrNCat(date1, &entry1->date[4], 2); - date1[8] = '\0'; - if (date1[6] == ' ' || date1[6] == HT_NON_BREAK_SPACE) { - date1[6] = '0'; - } - /* If no year given, assume last year if it would otherwise be in - * the future by more than one day. The one day tolerance is to - * account for a possible timezone difference. - kw - */ - if (date1[0] == '9' && atoi(date1) > TheDate + 1) { - for (i = 0; i < 4; i++) { - date1[i] = LastYear[i]; - } - } - strcat(date1, time1); - if (entry2->date[9] == ':') { - strcpy(date2, "9999"); - strcpy(time2, &entry2->date[7]); - if (time2[0] == ' ') { - time2[0] = '0'; - } - } else { - strcpy(date2, &entry2->date[8]); - strcpy(time2, "00:00"); - } - StrNCpy(month, entry2->date, 3); - month[3] = '\0'; - for (i = 0; i < 12; i++) { - if (!strcasecomp(month, months[i])) { - break; - } - } - i++; - sprintf(month, "%02d", i); - strcat(date2, month); - StrNCat(date2, &entry2->date[4], 2); - date2[8] = '\0'; - if (date2[6] == ' ' || date2[6] == HT_NON_BREAK_SPACE) { - date2[6] = '0'; - } - /* If no year given, assume last year if it would otherwise be in - * the future by more than one day. The one day tolerance is to - * account for a possible timezone difference. - kw - */ - if (date2[0] == '9' && atoi(date2) > TheDate + 1) { - for (i = 0; i < 4; i++) { - date2[i] = LastYear[i]; - } - } - strcat(date2, time2); + formatDate(date1, entry1); + formatDate(date2, entry2); /* * Do the comparison. - FM */ status = strcasecomp(date2, date1); if (status) - return (status); - /* else fall to filename comparison */ + result = status; } - return (strcmp(entry1->filename, entry2->filename)); + break; case FILE_BY_NAME: default: - return (strcmp(entry1->filename, entry2->filename)); + break; } + return result; } #ifdef LONG_LIST diff --git a/WWW/Library/Implementation/HTMIME.c b/WWW/Library/Implementation/HTMIME.c index 8a420736..0c5934cf 100644 --- a/WWW/Library/Implementation/HTMIME.c +++ b/WWW/Library/Implementation/HTMIME.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTMIME.c,v 1.84 2013/04/30 08:46:21 tom Exp $ + * $LynxId: HTMIME.c,v 1.86 2013/05/03 20:52:54 tom Exp $ * * MIME Message Parse HTMIME.c * ================== @@ -273,7 +273,7 @@ static int pumpData(HTStream *me) FREE(me->compression_encoding); StrAllocCopy(me->compression_encoding, new_encoding); - strcpy(me->value, new_content); + LYStrNCpy(me->value, new_content, VALUE_SIZE - 1); StrAllocCopy(me->anchor->content_type_params, me->value); me->format = HTAtom_for(me->value); } diff --git a/WWW/Library/Implementation/HTMLGen.c b/WWW/Library/Implementation/HTMLGen.c index 3fc55e9b..b345c9d3 100644 --- a/WWW/Library/Implementation/HTMLGen.c +++ b/WWW/Library/Implementation/HTMLGen.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTMLGen.c,v 1.37 2012/02/10 18:32:26 tom Exp $ + * $LynxId: HTMLGen.c,v 1.39 2013/05/03 20:53:46 tom Exp $ * * HTML Generator * ============== @@ -43,10 +43,9 @@ #include <LYLeaks.h> #ifdef USE_COLOR_STYLE -char class_string[TEMPSTRINGSIZE]; +char class_string[TEMPSTRINGSIZE + 1]; static char *Style_className = NULL; -static char myHash[128]; static int hcode; #endif @@ -325,15 +324,16 @@ static int HTMLGen_start_element(HTStructured * me, int element_number, char *title_tmp = NULL; if (LYPreparsedSource) { + char *myHash = NULL; + /* * Same logic as in HTML_start_element, copied from there. - kw */ HTSprintf(&Style_className, ";%s", HTML_dtd.tags[element_number].name); - strcpy(myHash, HTML_dtd.tags[element_number].name); + StrAllocCopy(myHash, HTML_dtd.tags[element_number].name); if (class_string[0]) { - int len = (int) strlen(myHash); - - sprintf(myHash + len, ".%.*s", (int) sizeof(myHash) - len - 2, class_string); + StrAllocCat(myHash, "."); + StrAllocCat(myHash, class_string); HTSprintf(&Style_className, ".%s", class_string); } class_string[0] = '\0'; @@ -369,6 +369,7 @@ static int HTMLGen_start_element(HTStructured * me, int element_number, do_cstyle_flush(me); HText_characterStyle(me->text, hcode, 1); } + FREE(myHash); } #endif /* USE_COLOR_STYLE */ me->preformatted = YES; /* free text within tags */ diff --git a/WWW/Library/Implementation/HTRules.c b/WWW/Library/Implementation/HTRules.c index 941d19af..5756c3a6 100644 --- a/WWW/Library/Implementation/HTRules.c +++ b/WWW/Library/Implementation/HTRules.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTRules.c,v 1.43 2013/05/01 00:45:32 tom Exp $ + * $LynxId: HTRules.c,v 1.44 2013/05/03 09:42:04 tom Exp $ * * Configuration manager for Hypertext Daemon HTRules.c * ========================================== @@ -464,7 +464,7 @@ int HTSetConfiguration(char *config) int status; StrAllocCopy(line, config); - { + if (line != NULL) { char *p = line; /* Chop off comments */ diff --git a/WWW/Library/Implementation/HTString.c b/WWW/Library/Implementation/HTString.c index e22c937e..2a9fae52 100644 --- a/WWW/Library/Implementation/HTString.c +++ b/WWW/Library/Implementation/HTString.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTString.c,v 1.69 2012/02/09 22:02:21 tom Exp $ + * $LynxId: HTString.c,v 1.70 2013/05/03 09:44:08 tom Exp $ * * Case-independent string comparison HTString.c * @@ -395,29 +395,31 @@ char *HTSACopy_extra(char **dest, char *HTNextField(char **pstr) { char *p = *pstr; - char *start; /* start of field */ + char *start = NULL; /* start of field */ - while (*p && WHITE(*p)) - p++; /* Strip white space */ - if (!*p) { - *pstr = p; - return NULL; /* No first field */ - } - if (*p == '"') { /* quoted field */ - p++; - start = p; - for (; *p && *p != '"'; p++) { - if (*p == '\\' && p[1]) - p++; /* Skip escaped chars */ + if (p != NULL) { + while (*p && WHITE(*p)) + p++; /* Strip white space */ + if (!*p) { + *pstr = p; + } else { + if (*p == '"') { /* quoted field */ + p++; + start = p; + for (; *p && *p != '"'; p++) { + if (*p == '\\' && p[1]) + p++; /* Skip escaped chars */ + } + } else { + start = p; + while (*p && !WHITE(*p)) + p++; /* Skip first field */ + } + if (*p) + *p++ = '\0'; + *pstr = p; } - } else { - start = p; - while (*p && !WHITE(*p)) - p++; /* Skip first field */ } - if (*p) - *p++ = '\0'; - *pstr = p; return start; } diff --git a/WWW/Library/Implementation/HTVMSUtils.c b/WWW/Library/Implementation/HTVMSUtils.c index 85ca863a..5449ae95 100644 --- a/WWW/Library/Implementation/HTVMSUtils.c +++ b/WWW/Library/Implementation/HTVMSUtils.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTVMSUtils.c,v 1.37 2010/09/25 11:39:49 tom Exp $ + * $LynxId: HTVMSUtils.c,v 1.38 2013/05/03 20:32:37 tom Exp $ * * MODULE HTVMSUtil.c * VMS Utility Routines @@ -645,8 +645,7 @@ int compare_VMSEntryInfo_structs(VMSEntryInfo * entry1, VMSEntryInfo * entry2) strcpy(date1, (char *) &entry1->date[8]); strcpy(time1, "00:00"); } - StrNCpy(month, entry1->date, 3); - month[3] = '\0'; + LYStrNCpy(month, entry1->date, 3); for (i = 0; i < 12; i++) { if (!strcasecomp(month, months[i])) { break; @@ -668,8 +667,7 @@ int compare_VMSEntryInfo_structs(VMSEntryInfo * entry1, VMSEntryInfo * entry2) strcpy(date2, (char *) &entry2->date[8]); strcpy(time2, "00:00"); } - StrNCpy(month, entry2->date, 3); - month[3] = '\0'; + LYStrNCpy(month, entry2->date, 3); for (i = 0; i < 12; i++) { if (!strcasecomp(month, months[i])) { break; diff --git a/WWW/Library/Implementation/HTVMS_WaisUI.c b/WWW/Library/Implementation/HTVMS_WaisUI.c index d8f73019..6e127517 100644 --- a/WWW/Library/Implementation/HTVMS_WaisUI.c +++ b/WWW/Library/Implementation/HTVMS_WaisUI.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTVMS_WaisUI.c,v 1.17 2010/10/29 21:10:14 tom Exp $ + * $LynxId: HTVMS_WaisUI.c,v 1.19 2013/05/03 20:51:49 tom Exp $ * HTVMS_WAISUI.c * * Adaptation for Lynx by F.Macrides (macrides@sci.wfeb.edu) @@ -243,8 +243,7 @@ static long transport_message(long connection, { char length_array[11]; - StrNCpy(length_array, header.msg_len, 10); - length_array[10] = '\0'; + LYStrNCpy(length_array, header.msg_len, 10); response_length = atol(length_array); /* if(verbose){ @@ -1833,12 +1832,12 @@ query_term *makeAttributeTerm(char *use, qt->TermType = TT_Attribute; /* copy in the attributes */ - StrNCpy(qt->Use, use, ATTRIBUTE_SIZE); - StrNCpy(qt->Relation, relation, ATTRIBUTE_SIZE); - StrNCpy(qt->Position, position, ATTRIBUTE_SIZE); - StrNCpy(qt->Structure, structure, ATTRIBUTE_SIZE); - StrNCpy(qt->Truncation, truncation, ATTRIBUTE_SIZE); - StrNCpy(qt->Completeness, completeness, ATTRIBUTE_SIZE); + LYStrNCpy(qt->Use, use, ATTRIBUTE_SIZE); + LYStrNCpy(qt->Relation, relation, ATTRIBUTE_SIZE); + LYStrNCpy(qt->Position, position, ATTRIBUTE_SIZE); + LYStrNCpy(qt->Structure, structure, ATTRIBUTE_SIZE); + LYStrNCpy(qt->Truncation, truncation, ATTRIBUTE_SIZE); + LYStrNCpy(qt->Completeness, completeness, ATTRIBUTE_SIZE); qt->Term = duplicateAny(term); @@ -1870,7 +1869,7 @@ query_term *makeOperatorTerm(char *operatorCode) qt->TermType = TT_Operator; - StrNCpy(qt->Operator, operatorCode, OPERATOR_SIZE); + LYStrNCpy(qt->Operator, operatorCode, OPERATOR_SIZE); qt->Term = NULL; qt->ResultSetID = NULL; @@ -1914,7 +1913,7 @@ char *writeQueryTerm(query_term *qt, char *buffer, long *len) switch (qt->TermType) { case TT_Attribute: - StrNCpy(attributes, qt->Use, ATTRIBUTE_LIST_SIZE); + LYStrNCpy(attributes, qt->Use, ATTRIBUTE_LIST_SIZE); s_strncat(attributes, AT_DELIMITER, sizeof(AT_DELIMITER) + 1, ATTRIBUTE_LIST_SIZE); s_strncat(attributes, qt->Relation, ATTRIBUTE_SIZE, ATTRIBUTE_LIST_SIZE); s_strncat(attributes, AT_DELIMITER, sizeof(AT_DELIMITER) + 1, ATTRIBUTE_LIST_SIZE); diff --git a/WWW/Library/Implementation/HTVMS_WaisUI.h b/WWW/Library/Implementation/HTVMS_WaisUI.h index 4f072a51..a2b2d07f 100644 --- a/WWW/Library/Implementation/HTVMS_WaisUI.h +++ b/WWW/Library/Implementation/HTVMS_WaisUI.h @@ -439,12 +439,12 @@ extern "C" { /* type */ long TermType; /* for term */ - char Use[ATTRIBUTE_SIZE]; - char Relation[ATTRIBUTE_SIZE]; - char Position[ATTRIBUTE_SIZE]; - char Structure[ATTRIBUTE_SIZE]; - char Truncation[ATTRIBUTE_SIZE]; - char Completeness[ATTRIBUTE_SIZE]; + char Use[ATTRIBUTE_SIZE + 1]; + char Relation[ATTRIBUTE_SIZE + 1]; + char Position[ATTRIBUTE_SIZE + 1]; + char Structure[ATTRIBUTE_SIZE + 1]; + char Truncation[ATTRIBUTE_SIZE + 1]; + char Completeness[ATTRIBUTE_SIZE + 1]; any *Term; /* for result set */ any *ResultSetID; diff --git a/WWW/Library/Implementation/HTWAIS.c b/WWW/Library/Implementation/HTWAIS.c index 5c998ea8..5e95e7dc 100644 --- a/WWW/Library/Implementation/HTWAIS.c +++ b/WWW/Library/Implementation/HTWAIS.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTWAIS.c,v 1.36 2011/06/11 12:13:32 tom Exp $ + * $LynxId: HTWAIS.c,v 1.37 2013/05/03 20:53:27 tom Exp $ * * WorldWideWeb - Wide Area Informaion Server Access HTWAIS.c * ================================================== @@ -818,7 +818,7 @@ int HTLoadWAIS(const char *arg, char *p; HTStructured *target; - StrNCpy(keywords, key, MAX_KEYWORDS_LENGTH); + LYStrNCpy(keywords, key, MAX_KEYWORDS_LENGTH); while ((p = strchr(keywords, '+')) != 0) *p = ' '; |