diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 2008-02-10 23:30:04 -0500 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 2008-02-10 23:30:04 -0500 |
commit | acdfec8f90ac4aa21cfc20b6b7ad3ecb7e56ea90 (patch) | |
tree | 86c9e3563afd079f3dde28d94be992c75627c8fa /WWW/Library | |
parent | 92e120361baf8d55566015fe7bf09ac91f06a6e6 (diff) | |
download | lynx-snapshots-acdfec8f90ac4aa21cfc20b6b7ad3ecb7e56ea90.tar.gz |
snapshot of project "lynx", label v2-8-7dev_c-pbm
Diffstat (limited to 'WWW/Library')
-rw-r--r-- | WWW/Library/Implementation/HTParse.c | 10 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTString.c | 67 |
2 files changed, 51 insertions, 26 deletions
diff --git a/WWW/Library/Implementation/HTParse.c b/WWW/Library/Implementation/HTParse.c index 37b1208e..bf0b9665 100644 --- a/WWW/Library/Implementation/HTParse.c +++ b/WWW/Library/Implementation/HTParse.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTParse.c,v 1.47 2007/07/22 22:24:37 tom Exp $ + * $LynxId: HTParse.c,v 1.48 2008/01/10 00:57:31 tom Exp $ * * Parse HyperText Document Address HTParse.c * ================================ @@ -294,11 +294,14 @@ char *HTParse(const char *aName, if (given.access && given.host && !given.relative && !given.absolute) { if (!strcmp(given.access, "http") || !strcmp(given.access, "https") || - !strcmp(given.access, "ftp")) + !strcmp(given.access, "ftp")) { + static char empty_string[] = ""; + /* * Assume root. */ - given.absolute = ""; + given.absolute = empty_string; + } } acc_method = given.access ? given.access : related.access; if (wanted & PARSE_ACCESS) { @@ -574,6 +577,7 @@ char *HTParse(const char *aName, case LYNXKEYMAP_URL_TYPE: case LYNXIMGMAP_URL_TYPE: case LYNXCOOKIE_URL_TYPE: + case LYNXCACHE_URL_TYPE: case LYNXDIRED_URL_TYPE: case LYNXOPTIONS_URL_TYPE: case LYNXCFG_URL_TYPE: diff --git a/WWW/Library/Implementation/HTString.c b/WWW/Library/Implementation/HTString.c index 014e7ce7..58e9deed 100644 --- a/WWW/Library/Implementation/HTString.c +++ b/WWW/Library/Implementation/HTString.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTString.c,v 1.49 2007/05/16 21:44:23 tom Exp $ + * $LynxId: HTString.c,v 1.50 2008/01/09 00:06:06 tom Exp $ * * Case-independent string comparison HTString.c * @@ -619,6 +619,46 @@ PUBLIC_IF_FIND_LEAKS char *StrAllocVsprintf(char **pstr, const char *fmt, va_list * ap) { +#ifdef HAVE_VASPRINTF + /* + * Use vasprintf() if we have it, since it is simplest. + */ + char *result = 0; + char *temp = 0; + + /* discard old destination if no length was given */ + if (pstr && !dst_len) { + if (*pstr) + FREE(*pstr); + } + + if (vasprintf(&temp, fmt, *ap) >= 0) { + if (dst_len != 0) { + int src_len = strlen(temp); + int new_len = dst_len + src_len + 1; + + result = HTAlloc(pstr ? *pstr : 0, new_len); + if (result != 0) { + strcpy(result + dst_len, temp); + mark_malloced(temp, new_len); + } + free(temp); + } else { + result = temp; + mark_malloced(temp, strlen(temp)); + } + } + + if (pstr != 0) + *pstr = result; + + return result; +#else /* !HAVE_VASPRINTF */ + /* + * If vasprintf() is not available, this works - but does not implement + * the POSIX '$' formatting character which may be used in some of the + * ".po" files. + */ #ifdef SAVE_TIME_NOT_SPACE static size_t tmp_len = 0; static size_t fmt_len = 0; @@ -634,20 +674,9 @@ PUBLIC_IF_FIND_LEAKS char *StrAllocVsprintf(char **pstr, char *dst_ptr = *pstr; const char *format = fmt; - if (fmt == 0 || *fmt == '\0') + if (isEmpty(fmt)) return 0; -#ifdef USE_VASPRINTF - if (pstr && !dst_len) { - if (*pstr) - FREE(*pstr); - if (vasprintf(pstr, fmt, *ap) >= 0) { - mark_malloced(*pstr, strlen(*pstr) + 1); - return (*pstr); - } - } -#endif /* USE_VASPRINTF */ - need = strlen(fmt) + 1; #ifdef SAVE_TIME_NOT_SPACE if (!fmt_ptr || fmt_len < need * NUM_WIDTH) { @@ -848,6 +877,7 @@ PUBLIC_IF_FIND_LEAKS char *StrAllocVsprintf(char **pstr, if (pstr) *pstr = dst_ptr; return (dst_ptr); +#endif /* HAVE_VASPRINTF */ } #undef SAVE_TIME_NOT_SPACE @@ -895,16 +925,7 @@ char *HTSprintf0(char **pstr, const char *fmt,...) LYva_start(ap, fmt); { -#ifdef USE_VASPRINTF - if (pstr) { - if (*pstr) - FREE(*pstr); - if (vasprintf(pstr, fmt, ap) >= 0) /* else call outofmem?? */ - mark_malloced(*pstr, strlen(*pstr) + 1); - result = *pstr; - } else -#endif /* USE_VASPRINTF */ - result = StrAllocVsprintf(pstr, 0, fmt, &ap); + result = StrAllocVsprintf(pstr, 0, fmt, &ap); } va_end(ap); |