diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 1998-11-21 16:40:42 -0500 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 1998-11-21 16:40:42 -0500 |
commit | d4a8ec3c8922a91d418bb9bc130c256c4e00d030 (patch) | |
tree | cfbc95b0f99be65ea5ffa312c9055552db804dfc /WWW | |
parent | 6d7ee0488b037f002a9fec0d060cc9842d5f8acd (diff) | |
download | lynx-snapshots-d4a8ec3c8922a91d418bb9bc130c256c4e00d030.tar.gz |
snapshot of project "lynx", label v2-8-2dev_5
Diffstat (limited to 'WWW')
-rw-r--r-- | WWW/Library/Implementation/HTAnchor.c | 27 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTFile.c | 40 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTMIME.c | 2 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTPlain.c | 2 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTString.c | 54 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTString.h | 6 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTTCP.c | 22 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTUtils.h | 21 | ||||
-rw-r--r-- | WWW/Library/Implementation/LYexit.h | 1 | ||||
-rw-r--r-- | WWW/Library/Implementation/SGML.c | 6 | ||||
-rw-r--r-- | WWW/Library/Implementation/UCDefs.h | 2 | ||||
-rw-r--r-- | WWW/Library/Implementation/tcp.h | 2 |
12 files changed, 135 insertions, 50 deletions
diff --git a/WWW/Library/Implementation/HTAnchor.c b/WWW/Library/Implementation/HTAnchor.c index ec332eb3..a141213c 100644 --- a/WWW/Library/Implementation/HTAnchor.c +++ b/WWW/Library/Implementation/HTAnchor.c @@ -68,6 +68,8 @@ PRIVATE HTParentAnchor * HTParentAnchor_new NOARGS { HTParentAnchor *newAnchor = (HTParentAnchor *)calloc(1, sizeof(HTParentAnchor)); /* zero-filled */ + if (newAnchor == NULL) + outofmem(__FILE__, "HTParentAnchor_new"); newAnchor->parent = newAnchor; newAnchor->bookmark = NULL; /* Bookmark filename. - FM */ newAnchor->isISMAPScript = FALSE; /* Lynx appends ?0,0 if TRUE. - FM */ @@ -194,6 +196,8 @@ PUBLIC HTChildAnchor * HTAnchor_findChild ARGS2( } child = HTChildAnchor_new(); + if (child == NULL) + outofmem(__FILE__, "HTChildAnchor_new"); CTRACE(tfp, "new Anchor %p named `%s' is child of %p\n", (void *)child, tag ? tag : (CONST char *)"", @@ -245,6 +249,29 @@ PUBLIC HTChildAnchor * HTAnchor_findChildAndLink ARGS4( parsed_doc.safe = FALSE; dest = HTAnchor_findAddress(&parsed_doc); +#define DUPLICATE_ANCHOR_NAME_WORKAROUND + +#ifdef DUPLICATE_ANCHOR_NAME_WORKAROUND + if (tag && *tag) { + HTAnchor *testdest1; + int nlinks; + testdest1 = child->mainLink.dest; + if (testdest1) { + nlinks = 1 + HTList_count(child->links); + CTRACE(tfp, + "*** Duplicate ChildAnchor %p named `%s' with %d links", + child, tag, nlinks); + if (dest == testdest1 && ltype == child->mainLink.type) { + CTRACE(tfp,", same dest %p and type, keeping it\n", + testdest1); + } else { + CTRACE(tfp,", different dest %p, creating unnamed child\n", + testdest1); + child = HTAnchor_findChild(parent, 0); + } + } + } +#endif HTAnchor_link((HTAnchor *)child, dest, ltype); FREE(parsed_doc.address); FREE(relative_to); diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c index 70811025..3e030de0 100644 --- a/WWW/Library/Implementation/HTFile.c +++ b/WWW/Library/Implementation/HTFile.c @@ -105,6 +105,8 @@ typedef struct _HTSuffix { #define MAYBE_END(e) if (HTML_dtd.tags[e].contents != SGML_EMPTY) \ (*target->isa->end_element)(target, e, 0) #define FREE_TARGET (*target->isa->_free)(target) +#define ABORT_TARGET (*targetClass._abort)(target, NULL); + struct _HTStructured { CONST HTStructuredClass * isa; /* ... */ @@ -1985,6 +1987,7 @@ PUBLIC int HTLoadFile ARGS4( { HTBTree * bt = HTBTree_new((HTComparer)strcmp); + status = HT_LOADED; /* assume we don't get interrupted */ while ((dirbuf = readdir(dp)) != NULL) { /* ** While there are directory entries to be read... @@ -2075,6 +2078,11 @@ PUBLIC int HTLoadFile ARGS4( while (next_element != NULL) { char *entry, *file_extra; + if (HTCheckForInterrupt()) { + _HTProgress ("Data transfer interrupted."); + status = HT_PARTIAL_CONTENT; + break; + } StrAllocCopy(tmpfilename,localname); if (strcmp(localname, "/")) /* @@ -2172,14 +2180,16 @@ PUBLIC int HTLoadFile ARGS4( /* pick up the next element of the list; if none, return NULL*/ } - if (state == 'I') { - START(HTML_P); - PUTS(gettext("Empty Directory")); - } + if (status == HT_LOADED) { + if (state == 'I') { + START(HTML_P); + PUTS("Empty Directory"); + } #ifndef LONG_LIST - else - END(HTML_DIR); + else + END(HTML_DIR); #endif /* !LONG_LIST */ + } } /* end while directory entries left to read */ closedir(dp); @@ -2188,12 +2198,16 @@ PUBLIC int HTLoadFile ARGS4( FREE(tail); HTBTreeAndObject_free(bt); - if (HTDirReadme == HT_DIR_README_BOTTOM) - do_readme(target, localname); - FREE_TARGET; + if (status == HT_LOADED) { + if (HTDirReadme == HT_DIR_README_BOTTOM) + do_readme(target, localname); + FREE_TARGET; + } else { + ABORT_TARGET; + } FREE(localname); FREE(nodename); - return HT_LOADED; /* document loaded */ + return status; /* document loaded, maybe partial */ } } /* end if localname is directory */ @@ -2204,7 +2218,13 @@ PUBLIC int HTLoadFile ARGS4( */ #endif /* HAVE_READDIR */ { +# ifdef __EMX__ + int len = strlen(localname); + int bin = ((len > 3) && !strcasecomp(localname + len - 3, ".gz")); + FILE * fp = fopen(localname, (bin ? "rb" : "r")); +# else /* !( defined __EMX__ ) */ FILE * fp = fopen(localname, "r"); +# endif CTRACE (tfp, "HTLoadFile: Opening `%s' gives %p\n", localname, (void*)fp); diff --git a/WWW/Library/Implementation/HTMIME.c b/WWW/Library/Implementation/HTMIME.c index 6e64fb1d..a7417f78 100644 --- a/WWW/Library/Implementation/HTMIME.c +++ b/WWW/Library/Implementation/HTMIME.c @@ -1843,7 +1843,7 @@ PUBLIC HTStream* HTNetMIME ARGS3( #ifdef ESC #undef ESC #endif /* ESC */ -#include "LYCharVals.h" /* S/390 -- gil -- 0163 */ +#include <LYCharVals.h> /* S/390 -- gil -- 0163 */ #define ESC CH_ESC PRIVATE char HTmm64[] = diff --git a/WWW/Library/Implementation/HTPlain.c b/WWW/Library/Implementation/HTPlain.c index 832aa360..a07ede9d 100644 --- a/WWW/Library/Implementation/HTPlain.c +++ b/WWW/Library/Implementation/HTPlain.c @@ -147,7 +147,7 @@ PRIVATE void HTPlain_put_character ARGS2( } else if (TOASCII((unsigned char)c) >= 127 && TOASCII((unsigned char)c) < 161 && HTPassHighCtrlRaw) { HText_appendCharacter(me->text, c); - } else if ((unsigned char)c == CH_NBSP) { /* S/390 -- gil -- 0341 */ + } else if ((unsigned char)c == CH_NBSP) { /* S/390 -- gil -- 0341 */ HText_appendCharacter(me->text, ' '); } else if ((unsigned char)c == CH_SHY) { return; diff --git a/WWW/Library/Implementation/HTString.c b/WWW/Library/Implementation/HTString.c index b3b0115f..00cefcd7 100644 --- a/WWW/Library/Implementation/HTString.c +++ b/WWW/Library/Implementation/HTString.c @@ -359,9 +359,9 @@ PRIVATE char *HTAlloc ARGS2(char *, ptr, size_t, length) */ typedef enum { Flags, Width, Prec, Type, Format } PRINTF; -#define VA_INTGR(type) ival = va_arg(ap, type) -#define VA_FLOAT(type) fval = va_arg(ap, type) -#define VA_POINT(type) pval = (void *)va_arg(ap, type) +#define VA_INTGR(type) ival = va_arg((*ap), type) +#define VA_FLOAT(type) fval = va_arg((*ap), type) +#define VA_POINT(type) pval = (void *)va_arg((*ap), type) #define NUM_WIDTH 10 /* allow for width substituted for "*" in "%*s" */ #define GROW_EXPR(n) (((n) * 3) / 2) @@ -371,13 +371,14 @@ PRIVATE char * StrAllocVsprintf ARGS4( char **, pstr, size_t, dst_len, CONST char *, fmt, - va_list, ap) + va_list *, ap) { size_t tmp_len = GROW_SIZE; size_t have, need; char *tmp_ptr = 0; char *fmt_ptr; char *dst_ptr = *pstr; + CONST char *format = fmt; if (fmt == 0 || *fmt == '\0') return 0; @@ -466,9 +467,11 @@ PRIVATE char * StrAllocVsprintf ARGS4( case 'E': /* FALLTHRU */ case 'g': /* FALLTHRU */ case 'G': /* FALLTHRU */ +#if 0 /* we don't need this, it doesn't work on SunOS 4.x */ if (type == 'L') VA_FLOAT(long double); else +#endif VA_FLOAT(double); used = 'f'; break; @@ -495,6 +498,8 @@ PRIVATE char * StrAllocVsprintf ARGS4( used = 0; break; default: + CTRACE(tfp, "unknown format character '%c' in %s\n", + *fmt, format); break; } } else if (*fmt == '.') { @@ -540,22 +545,30 @@ PRIVATE char * StrAllocVsprintf ARGS4( * for its arguments. Unlike sprintf, this always concatenates to the destination * buffer. */ -#if USE_STDARG_H +#if ANSI_VARARGS PUBLIC char * HTSprintf (char ** pstr, CONST char * fmt, ...) #else -PUBLIC char * HTSprintf (pstr, fmt, va_alist) - char ** pstr; - CONST char * fmt; +PUBLIC char * HTSprintf (va_alist) va_dcl #endif { + char *result = 0; + size_t inuse = 0; va_list ap; LYva_start(ap,fmt); - StrAllocVsprintf(pstr, (pstr && *pstr) ? strlen(*pstr) : 0, fmt, ap); + { +#if !ANSI_VARARGS + char ** pstr = va_arg(ap, char **); + CONST char * fmt = va_arg(ap, CONST char *); +#endif + if (pstr != 0 && *pstr != 0) + inuse = strlen(*pstr); + result = StrAllocVsprintf(pstr, inuse, fmt, &ap); + } va_end(ap); - return (*pstr); + return (result); } /* @@ -563,22 +576,27 @@ PUBLIC char * HTSprintf (pstr, fmt, va_alist) * needed for its arguments. Like sprintf, this always resets the destination * buffer. */ -#if USE_STDARG_H +#if ANSI_VARARGS PUBLIC char * HTSprintf0 (char ** pstr, CONST char * fmt, ...) #else -PUBLIC char * HTSprintf0 (pstr, fmt, va_alist) - char ** pstr; - CONST char * fmt; +PUBLIC char * HTSprintf0 (va_alist) va_dcl #endif { + char *result = 0; va_list ap; LYva_start(ap,fmt); - if (pstr != 0 && *pstr != 0) - *pstr = 0; - StrAllocVsprintf(pstr, 0, fmt, ap); + { +#if !ANSI_VARARGS + char ** pstr = va_arg(ap, char **); + CONST char * fmt = va_arg(ap, CONST char *); +#endif + if (pstr != 0) + *pstr = 0; + result = StrAllocVsprintf(pstr, 0, fmt, &ap); + } va_end(ap); - return (*pstr); + return (result); } diff --git a/WWW/Library/Implementation/HTString.h b/WWW/Library/Implementation/HTString.h index 85ca5d7f..6b039896 100644 --- a/WWW/Library/Implementation/HTString.h +++ b/WWW/Library/Implementation/HTString.h @@ -53,14 +53,14 @@ extern char * HTNextField PARAMS ((char** pstr)); extern char * HTNextTok PARAMS((char ** pstr, CONST char * delims, CONST char * bracks, char * found)); -#if USE_STDARG_H +#if ANSI_VARARGS extern char * HTSprintf PARAMS((char ** pstr, CONST char * fmt, ...)) GCC_PRINTFLIKE(2,3); extern char * HTSprintf0 PARAMS((char ** pstr, CONST char * fmt, ...)) GCC_PRINTFLIKE(2,3); #else -extern char * HTSprintf PARAMS((char ** pstr, CONST char * fmt, va_alist)); -extern char * HTSprintf0 PARAMS((char ** pstr, CONST char * fmt, va_alist)); +extern char * HTSprintf () GCC_PRINTFLIKE(2,3); +extern char * HTSprintf0 () GCC_PRINTFLIKE(2,3); #endif #endif /* HTSTRING_H */ diff --git a/WWW/Library/Implementation/HTTCP.c b/WWW/Library/Implementation/HTTCP.c index 3dd09f07..6abde5f5 100644 --- a/WWW/Library/Implementation/HTTCP.c +++ b/WWW/Library/Implementation/HTTCP.c @@ -454,6 +454,7 @@ PUBLIC int HTParseInet ARGS2( struct timeval timeout; int dns_patience = 30; /* how many seconds will we wait for DNS? */ int child_exited = 0; + int ok_to_select_stdin = -1; /* ** Reap any children that have terminated since last time @@ -526,19 +527,32 @@ PUBLIC int HTParseInet ARGS2( */ cycle++; - timeout.tv_sec = 1; - timeout.tv_usec = 0; FD_ZERO(&readfds); - FD_SET(pfd[0], &readfds); #ifndef USE_SLANG /* ** This allows us to abort immediately, not after 1-second ** timeout, when user hits abort key. Can't do this when ** using SLANG (or at least I don't know how), so SLANG ** users must live with up-to-1s timeout. -BL + ** + ** Whoops -- we need to make sure stdin is actually + ** selectable! /dev/null isn't, on some systems, which + ** makes some useful Lynx invocations fail. -BL */ - FD_SET(0, &readfds); /* stdin -BL */ + if (ok_to_select_stdin == -1) { + timeout.tv_sec = 0; + timeout.tv_usec = 0; + FD_SET(0, &readfds); /* stdin -BL */ + selret = select(1, &readfds, NULL, NULL, &timeout); + if (selret >= 0) ok_to_select_stdin = 1; + else ok_to_select_stdin = 0; + FD_ZERO(&readfds); + } + if (ok_to_select_stdin) FD_SET(0, &readfds); #endif /* USE_SLANG */ + timeout.tv_sec = 1; + timeout.tv_usec = 0; + FD_SET(pfd[0], &readfds); /* ** Return when data received, interrupted, or failed. diff --git a/WWW/Library/Implementation/HTUtils.h b/WWW/Library/Implementation/HTUtils.h index 29417483..d72c48ae 100644 --- a/WWW/Library/Implementation/HTUtils.h +++ b/WWW/Library/Implementation/HTUtils.h @@ -32,6 +32,11 @@ #define NO_FILIO_H #endif +#if defined(__STDC__) || defined(VMS) +#define ANSI_VARARGS +#define HAVE_STDARGS_H +#endif + /* FIXME: these will be removed after completing auto-configure script */ /* Accommodate pre-autoconf Makefile */ @@ -318,19 +323,19 @@ Sucess (>=0) and failure (<0) codes #define HT_BAD_EOF -12 /* Premature EOF */ #ifndef va_arg -#if defined(__STDC__) || defined(VMS) -#include <stdarg.h> -#else -#include <varargs.h> -#endif +# if HAVE_STDARG_H +# include <stdarg.h> +# else +# if HAVE_VARARGS_H +# include <varargs.h> +# endif +# endif #endif -#if defined(__STDC__) || defined(VMS) +#if ANSI_VARARGS #define LYva_start(ap,format) va_start(ap,format) -#define USE_STDARG_H 1 #else #define LYva_start(ap,format) va_start(ap) -#define USE_STDARG_H 0 #endif /* diff --git a/WWW/Library/Implementation/LYexit.h b/WWW/Library/Implementation/LYexit.h index f53561a4..62907a64 100644 --- a/WWW/Library/Implementation/LYexit.h +++ b/WWW/Library/Implementation/LYexit.h @@ -47,6 +47,7 @@ /* * Function declarations */ +extern void exit_immediately PARAMS((int status)); /* in LYMain.c */ extern void LYexit PARAMS((int status)); #ifdef __STDC__ extern int LYatexit(void (*function)(void)); diff --git a/WWW/Library/Implementation/SGML.c b/WWW/Library/Implementation/SGML.c index aa99eafe..53005d65 100644 --- a/WWW/Library/Implementation/SGML.c +++ b/WWW/Library/Implementation/SGML.c @@ -398,7 +398,7 @@ PRIVATE void handle_entity ARGS2( char, term) { UCode_t code; - long uck; + long uck = -1; CONST char *p; CONST char *s = context->string->data; @@ -481,7 +481,7 @@ PRIVATE void handle_entity ARGS2( /* ** If entity string not found, display as text. */ - CTRACE(tfp, "SGML: Unknown entity '%s' %d %d\n", s, code, uck); /* S/390 -- gil -- 0695 */ + CTRACE(tfp, "SGML: Unknown entity '%s' %ld %ld\n", s, (long)code, uck); /* S/390 -- gil -- 0695 */ PUTC('&'); for (p = s; *p; p++) { PUTC(*p); @@ -3325,7 +3325,7 @@ PUBLIC void JISx0201TO0208_SJIS ARGS3( { unsigned char SJCODE[2]; - JISx0201TO0208_EUC('\216', I, OHI, OLO); + JISx0201TO0208_EUC(216, I, OHI, OLO); JIS_TO_SJIS1(*OHI&0x7F, *OLO&0x7F, SJCODE); *OHI = SJCODE[0]; *OLO = SJCODE[1]; diff --git a/WWW/Library/Implementation/UCDefs.h b/WWW/Library/Implementation/UCDefs.h index 1e213abc..0cfb383f 100644 --- a/WWW/Library/Implementation/UCDefs.h +++ b/WWW/Library/Implementation/UCDefs.h @@ -9,7 +9,7 @@ typedef struct _LYUCcharset { int UChndl; CONST char * MIMEname; int enc; - int codepage; + int codepage; /* IBM specific number */ /* parameters below are not used by chartrans mechanism, */ /* they describe some relationships against built-in Latin1 charset...*/ diff --git a/WWW/Library/Implementation/tcp.h b/WWW/Library/Implementation/tcp.h index 7fe9a22b..79c42c73 100644 --- a/WWW/Library/Implementation/tcp.h +++ b/WWW/Library/Implementation/tcp.h @@ -134,7 +134,7 @@ extern unsigned char IBM1047[]; #else /* EBCDIC */ #if '0' != 48 -#error Host character set is not ASCII. + error Host character set is not ASCII. #endif #define TOASCII(c) (c) |