diff options
-rw-r--r-- | CHANGES | 12 | ||||
-rw-r--r-- | LYMessages_en.h | 4 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTAAProt.c | 4 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTPlain.c | 233 | ||||
-rw-r--r-- | WWW/Library/Implementation/SGML.c | 3 | ||||
-rw-r--r-- | aclocal.m4 | 2 | ||||
-rwxr-xr-x | configure | 2 | ||||
-rw-r--r-- | src/HTAlert.c | 8 | ||||
-rw-r--r-- | src/HTFWriter.c | 229 | ||||
-rw-r--r-- | src/HTInit.c | 9 | ||||
-rw-r--r-- | src/LYBookmark.c | 71 | ||||
-rw-r--r-- | src/LYCharUtils.c | 15 | ||||
-rw-r--r-- | src/LYClean.c | 8 | ||||
-rw-r--r-- | src/LYClean.h | 3 | ||||
-rw-r--r-- | src/LYDownload.c | 21 | ||||
-rw-r--r-- | src/LYHistory.c | 50 | ||||
-rw-r--r-- | src/LYList.c | 25 | ||||
-rw-r--r-- | src/LYLocal.c | 66 | ||||
-rw-r--r-- | src/LYMail.c | 124 | ||||
-rw-r--r-- | src/LYMain.c | 8 | ||||
-rw-r--r-- | src/LYMainLoop.c | 5 | ||||
-rw-r--r-- | src/LYNews.c | 72 | ||||
-rw-r--r-- | src/LYPrint.c | 136 | ||||
-rw-r--r-- | src/LYShowInfo.c | 24 | ||||
-rw-r--r-- | src/LYUpload.c | 34 | ||||
-rw-r--r-- | src/LYUtils.c | 378 | ||||
-rw-r--r-- | src/LYUtils.h | 23 | ||||
-rw-r--r-- | src/UCdomap.c | 4 | ||||
-rw-r--r-- | test/raw8bit.html | 15 | ||||
-rw-r--r-- | userdefs.h | 2 |
30 files changed, 691 insertions, 899 deletions
diff --git a/CHANGES b/CHANGES index 8ec8f60e..9454729e 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,18 @@ Changes since Lynx 2.8 release ================================================================================ +1998-05-23 (2.8.1dev.13) +* use new function LYLocalFileToUrl to cleanup some pathname references - TD +* eliminate 'tempname()' function, using LYNewTxtFile, etc., with new functions + LYOpenTemp, LYCloseTemp, etc., so that temporary files are opened with + appropriate permissions - TD +* correct use of cache variable in CF_ALT_CHAR_SET (reported by BL) - TD +* spell out the logic in HTPlain.c against 2.7.2: there was a certain problem + with chartrans in text/plain mode (LYRawMode was wrongly interferring, + problem reported by Jacob Poon & FM). - LP +* modify logic for zero-width spaces in conv_uni_to_pc to exclude 0x200a - LP +* supply missing "break", which was forcing raw utf-8 output in URLs (NOT hex + escaped) - LP 1998-05-14 (2.8.1dev.12) * remove unneeded definition used in testing dev.11 from config.hin) - TD 1998-05-14 (2.8.1dev.11) diff --git a/LYMessages_en.h b/LYMessages_en.h index 97640794..4ad5c5ae 100644 --- a/LYMessages_en.h +++ b/LYMessages_en.h @@ -214,13 +214,11 @@ #define BOOKMARK_OPEN_FAILED "ERROR - unable to open bookmark file." #define BOOKMARK_OPEN_FAILED_FOR_DEL \ "Unable to open bookmark file for deletion of link." -#ifdef VMS #define BOOKSCRA_OPEN_FAILED_FOR_DEL \ "Unable to open scratch file for deletion of link." +#ifdef VMS #define ERROR_RENAMING_SCRA "Error renaming scratch file." #else -#define BOOKTEMP_OPEN_FAILED_FOR_DEL \ - "Unable to open temporary file for deletion of link." #define ERROR_RENAMING_TEMP "Error renaming temporary file." #define BOOKTEMP_COPY_FAIL \ "Unable to copy temporary file for deletion of link." diff --git a/WWW/Library/Implementation/HTAAProt.c b/WWW/Library/Implementation/HTAAProt.c index 12c6361a..0c8dac86 100644 --- a/WWW/Library/Implementation/HTAAProt.c +++ b/WWW/Library/Implementation/HTAAProt.c @@ -179,7 +179,7 @@ PUBLIC int HTAA_getGid NOARGS CTRACE(tfp, "%s(%s) returned (%s:%s:%d:...)\n", "HTAA_getGid: getgrgid", current_prot->gid_name, - gr->gr_name, (int) gr->gr_passwd, (int) gr->gr_gid); + gr->gr_name, gr->gr_passwd, (int) gr->gr_gid); #endif return gr->gr_gid; } @@ -190,7 +190,7 @@ PUBLIC int HTAA_getGid NOARGS CTRACE(tfp, "%s(\"%s\") returned (%s:%s:%d:...)\n", "HTAA_getGid: getgrnam", current_prot->gid_name, - gr->gr_name, (int) gr->gr_passwd, (int) gr->gr_gid); + gr->gr_name, gr->gr_passwd, (int) gr->gr_gid); #endif return gr->gr_gid; } diff --git a/WWW/Library/Implementation/HTPlain.c b/WWW/Library/Implementation/HTPlain.c index df6cba9a..5caa4550 100644 --- a/WWW/Library/Implementation/HTPlain.c +++ b/WWW/Library/Implementation/HTPlain.c @@ -33,7 +33,6 @@ #define FREE(x) if (x) {free(x); x = NULL;} -extern BOOLEAN LYRawMode; extern BOOL HTPassEightBitRaw; extern BOOL HTPassHighCtrlRaw; extern HTCJKlang HTCJK; @@ -54,6 +53,7 @@ struct _HTStream { /* ** The node_anchor UCInfo and handle for the output (HTEXT) stage. - FM */ + LYUCcharset * outUCI; int outUCLYhndl; /* ** Counter, value, buffer and pointer for UTF-8 handling. - FM @@ -91,6 +91,7 @@ PRIVATE void HTPlain_getChartransInfo ARGS2( me->outUCLYhndl = HTAnchor_getUCLYhndl(anchor, UCT_STAGE_HTEXT); } me->inUCI = HTAnchor_getUCInfoStage(anchor, UCT_STAGE_PARSER); + me->outUCI = HTAnchor_getUCInfoStage(anchor, UCT_STAGE_HTEXT); } /* Write the buffer out to the socket @@ -136,14 +137,14 @@ PRIVATE void HTPlain_put_character ARGS2( HTPlain_lastraw = c; if (c == '\r') { HText_appendCharacter(me->text, '\n'); - } else if (HTCJK != NOCJK) { - HText_appendCharacter(me->text, c); } else if ((unsigned char)c >= 127) { /* ** For now, don't repeat everything here ** that has been done below - KW */ HTPlain_write(me, &c, 1); + } else if (HTCJK != NOCJK) { + HText_appendCharacter(me->text, c); } else if ((unsigned char)c >= 127 && (unsigned char)c < 161 && HTPassHighCtrlRaw) { HText_appendCharacter(me->text, c); @@ -156,9 +157,9 @@ PRIVATE void HTPlain_put_character ARGS2( HText_appendCharacter(me->text, c); } else if ((unsigned char)c > 160) { if (!HTPassEightBitRaw && - current_char_set != 0) { - size_t len, high, low, i; - int diff = 1; + !((me->outUCLYhndl == 0) || + (me->outUCI->enc & (UCT_CP_SUPERSETOF_LAT1)))) { + int len, high, low, i, diff = 1; CONST char * name; UCode_t value = (UCode_t)((unsigned char)c - 160); @@ -172,7 +173,7 @@ PRIVATE void HTPlain_put_character ARGS2( diff = strncmp(HTML_dtd.entity_names[i], name, len); if (diff == 0) { HText_appendText(me->text, - LYCharSets[current_char_set][i]); + LYCharSets[me->outUCLYhndl][i]); break; } } @@ -218,8 +219,8 @@ PRIVATE void HTPlain_write ARGS3(HTStream *, me, CONST char*, s, int, l) char c; unsigned char c_unsign; BOOL chk; - UCode_t code; - long uck = 0; + UCode_t code, uck; + char saved_char_in = '\0'; for (p = s; p < e; p++) { #ifdef REMOVE_CR_ONLY @@ -252,6 +253,7 @@ PRIVATE void HTPlain_write ARGS3(HTStream *, me, CONST char*, s, int, l) c = *p; c_unsign = (unsigned char)c; code = (UCode_t)c_unsign; + saved_char_in = '\0'; /* ** Combine any UTF-8 multibytes into Unicode ** to check for special characters. - FM @@ -282,8 +284,9 @@ PRIVATE void HTPlain_write ARGS3(HTStream *, me, CONST char*, s, int, l) */ *(me->utf_buf_p) = '\0'; code = me->utf_char; - if (code < 256) { + if (code > 0 && code < 256) { c = FROMASCII((char)code); + c_unsign = (unsigned char)c; } } else { /* @@ -295,9 +298,8 @@ PRIVATE void HTPlain_write ARGS3(HTStream *, me, CONST char*, s, int, l) /* ** Start handling a new multibyte character. - FM */ - me->utf_buf_p = me->utf_buf; me->utf_buf_p[0] = c; - (me->utf_buf_p)++; + me->utf_buf_p = &me->utf_buf[1]; if ((*p & 0xe0) == 0xc0) { me->utf_count = 1; me->utf_char = (c & 0x1f); @@ -318,24 +320,43 @@ PRIVATE void HTPlain_write ARGS3(HTStream *, me, CONST char*, s, int, l) * We got garbage, so ignore it. - FM */ me->utf_count = 0; - me->utf_buf_p = me->utf_buf; me->utf_buf_p[0] = '\0'; + me->utf_buf_p = me->utf_buf; } /* ** Get the next byte. - FM */ continue; } - } else { + } else if (me->utf_count > 0) { /* - ** Got an ASCII character. + ** Got an ASCII character when expecting + ** UTF-8 multibytes, so ignore the buffered + ** multibye characters and fall through with + ** the current ASCII character. - FM */ me->utf_count = 0; me->utf_buf[0] = '\0'; me->utf_buf_p = me->utf_buf; + code = (UCode_t)c_unsign; + } else { + /* + ** Got a valid ASCII character, so fall + ** through with it. - FM + */ + code = (UCode_t)c_unsign; } } - + /* + ** Convert characters from non-UTF-8 charsets + ** to Unicode (if appropriate). - FM + */ + if (!(me->T.decode_utf8 && + (unsigned char)(*p) > 127)) { +#ifdef NOTDEFINED + if (me->T.strip_raw_char_in) + saved_char_in = c; +#endif /* NOTDEFINED */ if (me->T.trans_to_uni && (code >= LYlowest_eightbit[me->inUCLYhndl] || (code < 32 && code != 0 && @@ -345,10 +366,58 @@ PRIVATE void HTPlain_write ARGS3(HTStream *, me, CONST char*, s, int, l) */ code = (UCode_t)UCTransToUni(c, me->inUCLYhndl); if (code > 0) { + saved_char_in = c; if (code < 256) { - c = FROMASCII((char)code); + c = FROMASCII((char)code); + c_unsign = (unsigned char)c; } } + } else if (code < 32 && code != 0 && + me->T.trans_C0_to_uni) { + /* + ** Quote from SGML.c: + ** "This else if may be too ugly to keep. - KW" + */ + if (me->T.trans_from_uni && + (((code = UCTransToUni(c, me->inUCLYhndl)) >= 32) || + (me->T.transp && + (code = UCTransToUni(c, me->inUCLYhndl)) > 0))) { + saved_char_in = c; + if (code < 256) { + c = FROMASCII((char)code); + c_unsign = (unsigned char)c; + } + } else { + uck = -1; + if (me->T.transp) { + uck = UCTransCharStr(replace_buf, 60, c, + me->inUCLYhndl, + me->inUCLYhndl, NO); + } + if (!me->T.transp || uck < 0) { + uck = UCTransCharStr(replace_buf, 60, c, + me->inUCLYhndl, + me->outUCLYhndl, YES); + } + if (uck == 0) { + continue; + } else if (uck < 0) { + me->utf_buf[0] = '\0'; + code = (unsigned char)c; + } else { + c = replace_buf[0]; + if (c && replace_buf[1]) { + HText_appendText(me->text, replace_buf); + continue; + } + } + me->utf_buf[0] = '\0'; + code = (unsigned char)c; + } /* Next line end of ugly stuff for C0. - KW */ + } else { + me->utf_buf[0] = '\0'; + code = (unsigned char)c; + } } /* ** At this point we have either code in Unicode @@ -399,17 +468,16 @@ PRIVATE void HTPlain_write ARGS3(HTStream *, me, CONST char*, s, int, l) c >= LYlowest_eightbit[me->outUCLYhndl]) || *p == '\n' || *p == '\t') { HText_appendCharacter(me->text, c); - - } else if (me->T.use_raw_char_in) { - HText_appendCharacter(me->text, *p); -#ifdef NOTDEFINED /* ** Use an ASCII space (32) for ensp, emsp or thinsp. - FM */ } else if (code == 8194 || code == 8195 || code == 8201) { HText_appendCharacter(me->text, ' '); -#endif /* NOTDEFINED */ - + /* + ** If we want the raw character, pass it now. - FM + */ + } else if (me->T.use_raw_char_in && saved_char_in) { + HText_appendCharacter(me->text, saved_char_in); /****************************************************************** * I. LATIN-1 OR UCS2 TO DISPLAY CHARSET ******************************************************************/ @@ -460,23 +528,29 @@ PRIVATE void HTPlain_write ARGS3(HTStream *, me, CONST char*, s, int, l) ** (somewhat) readable ASCII. */ HText_appendCharacter(me->text, (char)(*p & 0x7f)); +#endif /* NOTDEFINED */ + /* + ** If we don't actually want the character, + ** make it safe and output that now. - FM + */ + } else if ((c_unsign > 0 && + c_unsign < LYlowest_eightbit[me->outUCLYhndl]) || + (me->T.trans_from_uni && !HTPassEightBitRaw)) { /* ** If we do not have the "7-bit approximations" as our ** output character set (in which case we did it already) ** seek a translation for that. Otherwise, or if the ** translation fails, use UHHH notation. - FM */ - } else if (chk && - (chk = (!HTPassEightBitRaw && - (me->outUCLYhndl != - UCGetLYhndl_byMIME("us-ascii")))) && + if ((chk = (me->outUCLYhndl != + UCGetLYhndl_byMIME("us-ascii"))) && (uck = UCTransUniChar(code, UCGetLYhndl_byMIME("us-ascii"))) >= 32 && uck < 127) { /* ** Got an ASCII character (yippey). - FM */ - c = ((char)(uck & 0xff)); + c = FROMASCII((char)uck); HText_appendCharacter(me->text, c); } else if ((chk && uck == -4) && (uck = UCTransUniCharStr(replace_buf, @@ -486,104 +560,33 @@ PRIVATE void HTPlain_write ARGS3(HTStream *, me, CONST char*, s, int, l) /* ** Got a repacement string (yippey). - FM */ - HText_appendText(me->text, replace_buf); - } else if (code == 8204 || code == 8205) { - /* - ** Ignore 8204 (zwnj) or 8205 (zwj), if we get to here. - FM - */ - CTRACE(tfp, "HTPlain_write: Ignoring '%ld'.\n", code); - } else if (code == 8206 || code == 8207) { - /* - ** Ignore 8206 (lrm) or 8207 (rlm), if we get to here. - FM - */ - CTRACE(tfp, "HTPlain_write: Ignoring '%ld'.\n", code); -#endif /* NOTDEFINED */ - } else if (me->T.trans_from_uni && code > 255) { - if (PASSHI8BIT && PASSHICTRL && LYRawMode && - (unsigned char)*p >= LYlowest_eightbit[me->outUCLYhndl]) { - HText_appendCharacter(me->text, *p); - } else { - sprintf(replace_buf, "U%.2lX", code); HText_appendText(me->text, replace_buf); - } - /* - ** If we get to here and HTPassEightBitRaw or the - ** selected character set is not "ISO Latin 1", - ** use the translation tables for 161-255 8-bit - ** characters (173 was handled above). - FM - */ - } else if (code > 160) { - if (!HTPassEightBitRaw && code <= 255 && - me->outUCLYhndl != 0) { + } else if (code == 8204 || code == 8205) { + /* + ** Ignore 8204 (zwnj) or 8205 (zwj), if we get to here. - FM + */ + CTRACE(tfp, "HTPlain_write: Ignoring '%ld'.\n", code); + } else if (code == 8206 || code == 8207) { + /* + ** Ignore 8206 (lrm) or 8207 (rlm), if we get to here. - FM + */ + CTRACE(tfp, "HTPlain_write: Ignoring '%ld'.\n", code); + } else { /* ** Out of luck, so use the UHHH notation (ugh). - FM */ - size_t len, high, low, i; - int diff = 1; - CONST char * name; - int value = (int)(code - 160); - - name = HTMLGetEntityName(value); - len = strlen(name); - for(low = 0, high = HTML_dtd.number_of_entities; - high > low; - diff < 0 ? (low = i+1) : (high = i)) { - /* Binary search */ - i = (low + (high-low)/2); - diff = strncmp(HTML_dtd.entity_names[i], name, len); - if (diff == 0) { - HText_appendText(me->text, - LYCharSets[me->outUCLYhndl][i]); - break; - } - } - if (diff) { - /* - ** Something went wrong in the translation, so - ** either output as UTF8 or a hex representation or - ** pass the raw character and hope it's OK. - */ - if (!PASSHI8BIT) - c = FROMASCII((char)code); - if (me->T.output_utf8 && - *me->utf_buf) { - HText_appendText(me->text, me->utf_buf); - me->utf_buf_p = me->utf_buf; - *(me->utf_buf_p) = '\0'; - - } else if (me->T.trans_from_uni) { + /* do not print UHHH for now sprintf(replace_buf, "U%.2lX", code); HText_appendText(me->text, replace_buf); - } else - HText_appendCharacter(me->text, c); + */ } - } else { /* - ** Didn't attempt a translation. - FM + ** If we get to here and have a monobyte character, + ** pass it. - FM */ - /* Either output as UTF8 or a hex representation or - ** pass the raw character and hope it's OK. - */ - if (code <= 255 && !PASSHI8BIT) - c = FROMASCII((char)code); - if (code > 127 && me->T.output_utf8 && *me->utf_buf) { - HText_appendText(me->text, me->utf_buf); - me->utf_buf_p = me->utf_buf; - *(me->utf_buf_p) = '\0'; - - } else if (LYRawMode && - me->inUCLYhndl != me->outUCLYhndl && - (PASSHI8BIT || PASSHICTRL) && - (unsigned char)c >= - LYlowest_eightbit[me->outUCLYhndl]) { - HText_appendCharacter(me->text, c); - } else if (me->T.trans_from_uni && code >= 127) { - sprintf(replace_buf, "U%.2lX", code); - HText_appendText(me->text, replace_buf); - } else + } else if (c_unsign > 0 && c_unsign < 256) { HText_appendCharacter(me->text, c); } - } #endif /* REMOVE_CR_ONLY */ } } diff --git a/WWW/Library/Implementation/SGML.c b/WWW/Library/Implementation/SGML.c index 32243519..d2a84397 100644 --- a/WWW/Library/Implementation/SGML.c +++ b/WWW/Library/Implementation/SGML.c @@ -329,7 +329,8 @@ PRIVATE void handle_attribute_value ARGS2( ** ** Additional issue, like handling bidirectional text if necessary ** may be called from here: zwnj (8204), zwj (8205), lrm (8206), rlm (8207) -** - currently they are passed to def7_uni.tbl as regular characters. +** - currently they are ignored in SGML.c and LYCharUtils.c +** but also in UCdomap.c because they are non printable... ** */ PRIVATE BOOL put_special_unicodes ARGS2( diff --git a/aclocal.m4 b/aclocal.m4 index 21313bab..0c730769 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -49,7 +49,7 @@ do done ]) AC_MSG_RESULT($cf_cv_alt_char_set) -test $cf_cv_alt_char_set != no && AC_DEFINE_UNQUOTED(ALT_CHAR_SET,$mapname) +test $cf_cv_alt_char_set != no && AC_DEFINE_UNQUOTED(ALT_CHAR_SET,$cf_cv_alt_char_set) ])dnl dnl --------------------------------------------------------------------------- dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES' diff --git a/configure b/configure index 3dd710f2..8d6b1b36 100755 --- a/configure +++ b/configure @@ -6715,7 +6715,7 @@ fi echo "$ac_t""$cf_cv_alt_char_set" 1>&6 test $cf_cv_alt_char_set != no && cat >> confdefs.h <<EOF -#define ALT_CHAR_SET $mapname +#define ALT_CHAR_SET $cf_cv_alt_char_set EOF diff --git a/src/HTAlert.c b/src/HTAlert.c index 6e5013e7..a10d79d9 100644 --- a/src/HTAlert.c +++ b/src/HTAlert.c @@ -32,11 +32,11 @@ PUBLIC void HTAlert ARGS1( CONST char *, Msg) { if (TRACE) { - fprintf(stderr, "\nAlert!: %s", Msg); - fflush(stderr); + fprintf(tfp, "\nAlert!: %s", Msg); + fflush(tfp); _user_message("Alert!: %s", Msg); - fprintf(stderr, "\n\n"); - fflush(stderr); + fprintf(tfp, "\n\n"); + fflush(tfp); } else _user_message("Alert!: %s", Msg); diff --git a/src/HTFWriter.c b/src/HTFWriter.c index 4745f48b..c73e01d6 100644 --- a/src/HTFWriter.c +++ b/src/HTFWriter.c @@ -76,7 +76,7 @@ struct _HTStream { HTParentAnchor * anchor; /* Original stream's anchor. */ HTStream * sink; /* Original stream's sink. */ #ifdef FNAMES_8_3 - int idash; /* remember position to become '.'*/ + BOOLEAN idash; /* remember position to become '.'*/ #endif }; @@ -135,7 +135,7 @@ PRIVATE void HTFWriter_free ARGS1(HTStream *, me) fflush(me->fp); if (me->end_command) { /* Temp file */ - fclose(me->fp); + LYCloseTempFP(me->fp); #ifdef VMS if (0 == strcmp(me->end_command, "SaveVMSBinaryFile")) { /* @@ -227,11 +227,13 @@ PRIVATE void HTFWriter_free ARGS1(HTStream *, me) */ if (skip_loadfile) { char *new_path = NULL; - if (me->idash > 1 && path[me->idash] == '-') { + char *the_dash = me->idash ? strrchr(path, '-') : 0; + if (the_dash != 0) { + unsigned off = (the_dash - path); StrAllocCopy(new_path, path); - new_path[me->idash] = '.'; - if (strlen(new_path + me->idash) > 4) - new_path[me->idash + 4] = '\0'; + new_path[off] = '.'; + if (strlen(new_path + off) > 4) + new_path[off + 4] = '\0'; if (rename(path, new_path) == 0) { FREE(path); path = new_path; @@ -419,7 +421,7 @@ PRIVATE void HTFWriter_abort ARGS2( HTError, e GCC_UNUSED) { CTRACE(tfp,"HTFWriter_abort called\n"); - fclose(me->fp); + LYCloseTempFP(me->fp); FREE(me->viewer_command); if (me->end_command) { /* Temp file */ CTRACE(tfp, "HTFWriter: Aborting: file not executed.\n"); @@ -500,9 +502,7 @@ PUBLIC HTStream* HTSaveAndExecute ARGS3( { char fnam[256]; CONST char *suffix; - char *cp; HTStream* me; - FILE *fp = NULL; if (traversal) { LYCancelledFetch = TRUE; @@ -550,61 +550,27 @@ PUBLIC HTStream* HTSaveAndExecute ARGS3( me->anchor = anchor; me->sink = sink; - if (anchor->FileCache) { - strcpy(fnam, anchor->FileCache); - FREE(anchor->FileCache); - if ((fp = fopen(fnam, "r")) != NULL) { - fclose(fp); - fp = NULL; - remove(fnam); - } + if (LYCachedTemp(fnam, anchor->FileCache)) { + me->fp = LYNewBinFile (fnam); } else { /* - * Lynx routine to create a temporary filename - */ -SaveAndExecute_tempname: - tempname (fnam, NEW_FILE); - /* * Check for a suffix. + * Save the file under a suitably suffixed name. */ - if (((cp = strrchr(fnam, '.')) != NULL) && -#ifdef VMS - NULL == strchr(cp, ']') && -#endif /* VMS */ - NULL == strchr(cp, '/')) { - /* - * Save the file under a suitably suffixed name. - */ - *cp = '\0'; - if (!strcasecomp(pres->rep->name, "text/html")) { - strcat(fnam, HTML_SUFFIX); - } else if (!strcasecomp(pres->rep->name, "text/plain")) { - strcat(fnam, ".txt"); - } else if (!strcasecomp(pres->rep->name, - "application/octet-stream")) { - strcat(fnam, ".bin"); - } else if ((suffix = HTFileSuffix(pres->rep, anchor->content_encoding)) - && *suffix == '.') { - strcat(fnam, suffix); - /* - * It's not one of the suffixes checked for a - * spoof in tempname(), so check it now. - FM - */ - if (strcmp(suffix, HTML_SUFFIX) && - strcmp(suffix, ".txt") && - strcmp(suffix, ".bin") && - (fp = fopen(fnam, "r")) != NULL) { - fclose(fp); - fp = NULL; - goto SaveAndExecute_tempname; - } - } else { - *cp = '.'; - } + if (!strcasecomp(pres->rep->name, "text/html")) { + suffix = HTML_SUFFIX; + } else if (!strcasecomp(pres->rep->name, "text/plain")) { + suffix = ".txt"; + } else if (!strcasecomp(pres->rep->name, + "application/octet-stream")) { + suffix = ".bin"; + } else if ((suffix = HTFileSuffix(pres->rep, anchor->content_encoding)) == 0 + || *suffix != '.') { + suffix = HTML_SUFFIX; } + me->fp = LYOpenTemp(fnam, suffix, "wb"); } - me->fp = LYNewBinFile (fnam); if (!me->fp) { HTAlert(CANNOT_OPEN_TEMP); FREE(me); @@ -664,9 +630,8 @@ PUBLIC HTStream* HTSaveToFile ARGS3( char fnam[256]; CONST char * suffix; char *cp; - int c=0; + int c = 0; BOOL IsBinary = TRUE; - FILE *fp = NULL; ret_obj = (HTStream*)calloc(sizeof(* ret_obj),1); if (ret_obj == NULL) @@ -738,58 +703,32 @@ PUBLIC HTStream* HTSaveToFile ARGS3( /* * Set up a 'D'ownload. */ - if (anchor->FileCache) { - strcpy(fnam, anchor->FileCache); - FREE(anchor->FileCache); - if ((fp = fopen(fnam, "r")) != NULL) { - fclose(fp); - fp = NULL; - remove(fnam); - } + if (LYCachedTemp(fnam, anchor->FileCache)) { + ret_obj->fp = LYNewBinFile (fnam); } else { /* - * Lynx routine to create a temporary filename - */ -SaveToFile_tempname: - tempname(fnam, NEW_FILE); - /* * Check for a suffix. + * Save the file under a suitably suffixed name. */ - if (((cp=strrchr(fnam, '.')) != NULL) && -#ifdef VMS - NULL == strchr(cp, ']') && -#endif /* VMS */ - NULL == strchr(cp, '/')) { - /* - * Save the file under a suitably suffixed name. - */ - *cp = '\0'; - if (!strcasecomp(pres->rep->name, "text/html")) { - strcat(fnam, HTML_SUFFIX); - } else if (!strcasecomp(pres->rep->name, "text/plain")) { - strcat(fnam, ".txt"); - } else if (!strcasecomp(pres->rep->name, + if (!strcasecomp(pres->rep->name, "text/html")) { + suffix = HTML_SUFFIX; + } else if (!strcasecomp(pres->rep->name, "text/plain")) { + suffix = ".txt"; + } else if (!strcasecomp(pres->rep->name, "application/octet-stream")) { - strcat(fnam, ".bin"); - } else if ((suffix = HTFileSuffix(pres->rep, - anchor->content_encoding)) && *suffix == '.') { - strcat(fnam, suffix); - /* - * It's not one of the suffixes checked for a - * spoof in tempname(), so check it now. - FM - */ - if (strcmp(suffix, HTML_SUFFIX) && - strcmp(suffix, ".txt") && - strcmp(suffix, ".bin") && - (fp = fopen(fnam, "r")) != NULL) { - fclose(fp); - fp = NULL; - goto SaveToFile_tempname; - } - } else { - *cp = '.'; - } + suffix = ".bin"; + } else if ((suffix = HTFileSuffix(pres->rep, + anchor->content_encoding)) == 0 + || *suffix != '.') { + suffix = HTML_SUFFIX; } + ret_obj->fp = LYOpenTemp(fnam, suffix, "wb"); + } + + if (!ret_obj->fp) { + HTAlert(CANNOT_OPEN_OUTPUT); + FREE(ret_obj); + return NULL; } if (0==strncasecomp(pres->rep->name, "text/", 5) || @@ -802,13 +741,6 @@ SaveToFile_tempname: */ IsBinary = FALSE; - ret_obj->fp = LYNewBinFile (fnam); - if (!ret_obj->fp) { - HTAlert(CANNOT_OPEN_OUTPUT); - FREE(ret_obj); - return NULL; - } - /* * Any "application/foo" or other non-"text/foo" types that * are actually text but not checked, above, will be treated @@ -930,10 +862,10 @@ PUBLIC HTStream* HTCompressed ARGS3( int n, i; BOOL can_present = FALSE; char fnam[256]; + char temp[256]; CONST char *suffix; char *uncompress_mask = NULL; char *compress_suffix = ""; - char *cp; CONST char *middle; FILE *fp = NULL; @@ -1017,6 +949,9 @@ PUBLIC HTStream* HTCompressed ARGS3( me->output_format = pres->rep_out; me->anchor = anchor; me->sink = sink; +#ifdef FNAMES_8_3 + me->idash = FALSE; +#endif /* * Remove any old versions of the file. - FM @@ -1032,61 +967,45 @@ PUBLIC HTStream* HTCompressed ARGS3( /* * Get a new temporary filename and substitute a suitable suffix. - FM */ -Compressed_tempname: - tempname(fnam, NEW_FILE); - if ((cp = strrchr(fnam, '.')) != NULL) { - middle = NULL; - if (!strcasecomp(anchor->content_type, "text/html")) { - middle = HTML_SUFFIX; - middle++; /* point to 'h' of .htm(l) - kw */ - } else if (!strcasecomp(anchor->content_type, "text/plain")) { - middle = "txt"; - } else if (!strcasecomp(anchor->content_type, - "application/octet-stream")) { - middle = "bin"; - } else if ((suffix = - HTFileSuffix(HTAtom_for(anchor->content_type), NULL)) && - *suffix == '.') { + middle = NULL; + if (!strcasecomp(anchor->content_type, "text/html")) { + middle = HTML_SUFFIX; + middle++; /* point to 'h' of .htm(l) - kw */ + } else if (!strcasecomp(anchor->content_type, "text/plain")) { + middle = "txt"; + } else if (!strcasecomp(anchor->content_type, + "application/octet-stream")) { + middle = "bin"; + } else if ((suffix = + HTFileSuffix(HTAtom_for(anchor->content_type), NULL)) && + *suffix == '.') { #if defined(VMS) || defined(FNAMES_8_3) - if (strchr(suffix + 1, '.') == NULL) + if (strchr(suffix + 1, '.') == NULL) #endif - middle = suffix + 1; - } - if (middle) { - *cp = '\0'; + middle = suffix + 1; + } + + temp[0] = 0; /* construct the suffix */ + if (middle) { #ifdef FNAMES_8_3 - me->idash = strlen(fnam); /* remember position of '-' - kw */ - strcat(fnam, "-"); /* NAME-htm, NAME-txt, etc. - hack for DOS */ + me->idash = TRUE; /* remember position of '-' - kw */ + strcat(temp, "-"); /* NAME-htm, NAME-txt, etc. - hack for DOS */ #else - strcat(fnam, "."); /* NAME.html, NAME-txt etc. */ + strcat(temp, "."); /* NAME.html, NAME-txt etc. */ #endif /* FNAMES_8_3 */ - strcat(fnam, middle); + strcat(temp, middle); #ifdef VMS - strcat(fnam, "-"); /* NAME.html-gz, NAME.txt-gz, NAME.txt-Z etc.*/ + strcat(temp, "-"); /* NAME.html-gz, NAME.txt-gz, NAME.txt-Z etc.*/ #else - strcat(fnam, "."); /* NAME-htm.gz (DOS), NAME.html.gz (UNIX)etc.*/ + strcat(temp, "."); /* NAME-htm.gz (DOS), NAME.html.gz (UNIX)etc.*/ #endif /* VMS */ - } else { - *(cp + 1) = '\0'; - } - } else { - strcat(fnam, "."); - } - strcat(fnam, compress_suffix); - /* - * It's not one of the suffixes checked for a - * spoof in tempname(), so check it now. - FM - */ - if ((fp = fopen(fnam, "r")) != NULL) { - fclose(fp); - fp = NULL; - goto Compressed_tempname; } + strcat(temp, compress_suffix); /* * Open the file for receiving the compressed input stream. - FM */ - me->fp = LYNewBinFile (fnam); + me->fp = LYOpenTemp (fnam, temp, "wb"); if (!me->fp) { HTAlert(CANNOT_OPEN_TEMP); FREE(uncompress_mask); diff --git a/src/HTInit.c b/src/HTInit.c index 9b79ec04..b9e0c4c6 100644 --- a/src/HTInit.c +++ b/src/HTInit.c @@ -412,8 +412,8 @@ PRIVATE int ProcessMailcapEntry ARGS2( } } - FREE(mallocd_string); - s = t; + FREE(mallocd_string); + s = t; } assign_presentation: @@ -550,7 +550,9 @@ PRIVATE int PassesTest ARGS1( /* * Build the command and execute it. */ - tempname(TmpFileName, NEW_FILE); + if (LYOpenTemp(TmpFileName, HTML_SUFFIX, "w") == 0) + ExitWithError(CANNOT_OPEN_TEMP); + LYCloseTemp(TmpFileName); cmd = (char *)malloc(1024); if (!cmd) ExitWithError("Out of memory"); @@ -561,6 +563,7 @@ PRIVATE int PassesTest ARGS1( CTRACE(tfp, "PassesTest: Executing test command: %s\n", cmd); result = system(cmd); FREE(cmd); + LYRemoveTemp(TmpFileName); /* * Free the test command as well since diff --git a/src/LYBookmark.c b/src/LYBookmark.c index 21f61a14..8b7827bc 100644 --- a/src/LYBookmark.c +++ b/src/LYBookmark.c @@ -117,39 +117,11 @@ success: is_mosaic_hotlist = TRUE; fclose(fp); newname = convert_mosaic_bookmark_file(filename_buffer); -#ifdef DOSPATH - sprintf(URL_buffer, "file://localhost/%s", - HTDOS_wwwName((char *)newname)); -#else -#ifdef VMS - sprintf(URL_buffer,"file://localhost%s", - HTVMS_wwwName((char *)newname)); -#else -#ifdef __EMX__ - sprintf(URL_buffer,"file://localhost/%s", newname); -#else - sprintf(URL_buffer,"file://localhost%s", newname); -#endif /* __EMX__ */ -#endif /* VMS */ -#endif /* DOSPATH */ + LYLocalFileToURL(URL_buffer, newname); } else { fclose(fp); is_mosaic_hotlist = FALSE; -#ifdef DOSPATH - sprintf(URL_buffer,"file://localhost/%s", - HTDOS_wwwName((char *)filename_buffer)); -#else -#ifdef VMS - sprintf(URL_buffer,"file://localhost%s", - HTVMS_wwwName((char *)filename_buffer)); -#else -#ifdef __EMX__ - sprintf(URL_buffer,"file://localhost/%s", filename_buffer); -#else - sprintf(URL_buffer,"file://localhost%s", filename_buffer); -#endif /* __EMX__ */ -#endif /* VMS */ -#endif /* DOSPATH */ + LYLocalFileToURL(URL_buffer, filename_buffer); } StrAllocCopy(*URL, URL_buffer); @@ -165,22 +137,13 @@ PRIVATE char * convert_mosaic_bookmark_file ARGS1( char *, filename_buffer) { static char newfile[256]; - static BOOLEAN first = TRUE; FILE *fp, *nfp; char buf[BUFSIZ]; int line = -2; char *endline; - if (first) { - tempname(newfile, NEW_FILE); - first = FALSE; -#ifdef VMS - } else { - remove(newfile); /* Remove duplicates on VMS. */ -#endif /* VMS */ - } - - if ((nfp = fopen(newfile, "w")) == NULL) { + LYRemoveTemp(newfile); + if ((nfp = LYOpenTemp(newfile, HTML_SUFFIX, "w")) == NULL) { LYMBM_statusline(NO_TEMP_FOR_HOTLIST); sleep(AlertSecs); return (""); @@ -213,7 +176,7 @@ PRIVATE char * convert_mosaic_bookmark_file ARGS1( /* else - ignore the line (this gets rid of first two lines) */ line++; } - fclose(nfp); + LYCloseTempFP(nfp); fclose(fp); return(newfile); } @@ -463,18 +426,9 @@ PUBLIC void remove_bookmark_link ARGS2( return; } -#ifdef VMS - sprintf(newfile, "%s-%d", filename_buffer, getpid()); -#else - tempname(newfile, NEW_FILE); -#endif /* VMS */ - if ((nfp = LYNewTxtFile(newfile)) == NULL) { + if ((nfp = LYOpenScratch(newfile, filename_buffer)) == 0) { fclose(fp); -#ifdef VMS _statusline(BOOKSCRA_OPEN_FAILED_FOR_DEL); -#else - _statusline(BOOKTEMP_OPEN_FAILED_FOR_DEL); -#endif /* VMS */ sleep(AlertSecs); return; } @@ -485,10 +439,8 @@ PUBLIC void remove_bookmark_link ARGS2( */ if (stat(filename_buffer, &stat_buf) == 0) { mode = ((stat_buf.st_mode & 0777) | 0600); /* make it writable */ - (void) fclose(nfp); - nfp = NULL; (void) chmod(newfile, mode); - if ((nfp = fopen(newfile, "a")) == NULL) { + if ((nfp = LYReopenTemp(newfile)) == NULL) { (void) fclose(fp); _statusline(BOOKTEMP_REOPEN_FAIL_FOR_DEL); sleep(AlertSecs); @@ -542,7 +494,7 @@ PUBLIC void remove_bookmark_link ARGS2( fclose(fp); fp = NULL; - fclose(nfp); + LYCloseTempFP(nfp); nfp = NULL; #ifdef DOSPATH remove(filename_buffer); @@ -555,7 +507,7 @@ PUBLIC void remove_bookmark_link ARGS2( * it is writable by the current process. * Changed to copy 1998-04-26 -- gil */ - { char buffer[3072]; + { char buffer[3072]; sprintf(buffer, "%s %s %s && %s %s", COPY_PATH, newfile, filename_buffer, @@ -620,11 +572,10 @@ PUBLIC void remove_bookmark_link ARGS2( failure: _statusline(BOOKMARK_DEL_FAILED); sleep(AlertSecs); - if (nfp != NULL) - fclose(nfp); + LYCloseTempFP(nfp); if (fp != NULL) fclose(fp); - remove(newfile); + LYRemoveTemp(newfile); } /* diff --git a/src/LYCharUtils.c b/src/LYCharUtils.c index 4f2054ac..35afffc1 100644 --- a/src/LYCharUtils.c +++ b/src/LYCharUtils.c @@ -1577,6 +1577,20 @@ PRIVATE char *hex = "0123456789ABCDEF"; ** if string translated or translation unnecessary, ** NULL otherwise ** (in which case something probably went wrong.) +** +** +** In general, this somehow ugly function (KW) +** cover three functions from v.2.7.2 (FM): +** extern void LYExpandString PARAMS(( +** HTStructured * me, +** char ** str)); +** extern void LYUnEscapeEntities PARAMS(( +** HTStructured * me, +** char ** str)); +** extern void LYUnEscapeToLatinOne PARAMS(( +** HTStructured * me, +** char ** str, +** BOOLEAN isURL)); */ PRIVATE char ** LYUCFullyTranslateString_1 ARGS9( @@ -2384,6 +2398,7 @@ PRIVATE char ** LYUCFullyTranslateString_1 ARGS9( if (code >= 127 || (code < 32 && (code != 9 && code != 10 && code != 0))) { state = S_put_urlstring; + break; } } REPLACE_STRING(replace_buf); diff --git a/src/LYClean.c b/src/LYClean.c index d67d76cf..0c79b9e6 100644 --- a/src/LYClean.c +++ b/src/LYClean.c @@ -134,15 +134,11 @@ PUBLIC void cleanup_sig ARGS1( /* * Called by Interrupt handler or at quit time. - * Erases the temporary files that lynx created - * temporary files are removed by tempname - * which created them. + * Erases the temporary files that lynx created. */ PUBLIC void cleanup_files NOARGS { - char filename[256]; - - tempname(filename, REMOVE_FILES); + LYCleanupTemp(); FREE(lynx_temp_space); } diff --git a/src/LYClean.h b/src/LYClean.h index e9502010..ec5ee39b 100644 --- a/src/LYClean.h +++ b/src/LYClean.h @@ -12,7 +12,4 @@ extern void cleanup_files NOPARAMS; extern void set_alarm PARAMS((int sig)); extern void reset_alarm NOPARAMS; -#define NEW_FILE 0 -#define REMOVE_FILES 1 - #endif /* LYCLEAN_H */ diff --git a/src/LYDownload.c b/src/LYDownload.c index f355672d..f4e57a30 100644 --- a/src/LYDownload.c +++ b/src/LYDownload.c @@ -608,37 +608,24 @@ PUBLIC int LYdownload_options ARGS2( char *, data_file) { static char tempfile[256]; - static BOOLEAN first = TRUE; static char download_filename[256]; char *sug_filename = NULL; FILE *fp0; lynx_html_item_type *cur_download; int count; - if (first) { - tempname(tempfile, NEW_FILE); - first = FALSE; -#if defined (VMS) || defined (DOSPATH) || defined (__EMX__) - sprintf(download_filename, "file://localhost/%s", tempfile); -#else - sprintf(download_filename, "file://localhost%s", tempfile); -#endif /* VMS */ -#ifdef VMS - } else { - remove(tempfile); /* Remove duplicates on VMS. */ -#endif /* VMS */ - } - /* * Get a suggested filename. */ StrAllocCopy(sug_filename, *newfile); change_sug_filename(sug_filename); - if ((fp0 = LYNewTxtFile(tempfile)) == NULL) { + LYRemoveTemp(tempfile); + if ((fp0 = LYOpenTemp(tempfile, HTML_SUFFIX, "w")) == NULL) { HTAlert(CANNOT_OPEN_TEMP); return(-1); } + LYLocalFileToURL(download_filename, tempfile); LYstrncpy(LYValidDownloadFile, data_file, @@ -690,7 +677,7 @@ No other download methods have been defined yet. You may define\n\ an unlimited number of download methods using the lynx.cfg file.\n"); } fprintf(fp0, "</pre>\n</body>\n"); - fclose(fp0); + LYCloseTempFP(fp0); /* * Free off temp copy. diff --git a/src/LYHistory.c b/src/LYHistory.c index 5bf9294f..38522586 100644 --- a/src/LYHistory.c +++ b/src/LYHistory.c @@ -383,34 +383,19 @@ PUBLIC int showhistory ARGS1( char **, newfile) { static char tempfile[256]; - static BOOLEAN first = TRUE; static char hist_filename[256]; char *Title = NULL; int x = 0; FILE *fp0; - if (first) { - tempname(tempfile, NEW_FILE); - /* - * Make the file a URL now. - */ -#if defined (VMS) || defined (DOSPATH) || defined (__EMX__) - sprintf(hist_filename,"file://localhost/%s", tempfile); -#else - sprintf(hist_filename,"file://localhost%s", tempfile); -#endif /* VMS */ - first = FALSE; -#ifdef VMS - } else { - remove(tempfile); /* Remove duplicates on VMS. */ -#endif /* VMS */ - } - - if ((fp0 = LYNewTxtFile(tempfile)) == NULL) { + LYRemoveTemp(tempfile); + if ((fp0 = LYOpenTemp(tempfile, HTML_SUFFIX, "w")) == NULL) { HTAlert(CANNOT_OPEN_TEMP); return(-1); } + LYLocalFileToURL(hist_filename, tempfile); + StrAllocCopy(*newfile, hist_filename); LYforce_HTML_mode = TRUE; /* force this file to be HTML */ LYforce_no_cache = TRUE; /* force this file to be new */ @@ -454,7 +439,7 @@ PUBLIC int showhistory ARGS1( fprintf(fp0,"</pre>\n</body>\n"); - fclose(fp0); + LYCloseTempFP(fp0); FREE(Title); return(0); } @@ -543,7 +528,6 @@ PUBLIC int LYShowVisitedLinks ARGS1( char **, newfile) { static char tempfile[256]; - static BOOLEAN first = TRUE; static char vl_filename[256]; char *Title = NULL; char *Address = NULL; @@ -555,28 +539,14 @@ PUBLIC int LYShowVisitedLinks ARGS1( if (!cur) return(-1); - if (first) { - tempname(tempfile, NEW_FILE); - /* - * Make the file a URL now. - */ -#if defined (VMS) || defined (DOSPATH) || defined (__EMX__) - sprintf(vl_filename,"file://localhost/%s", tempfile); -#else - sprintf(vl_filename,"file://localhost%s", tempfile); -#endif /* VMS */ - first = FALSE; -#ifdef VMS - } else { - remove(tempfile); /* Remove duplicates on VMS. */ -#endif /* VMS */ - } - - if ((fp0 = LYNewTxtFile(tempfile)) == NULL) { + LYRemoveTemp(tempfile); + if ((fp0 = LYOpenTemp(tempfile, HTML_SUFFIX, "w")) == NULL) { HTAlert(CANNOT_OPEN_TEMP); return(-1); } + LYLocalFileToURL(vl_filename, tempfile); + StrAllocCopy(*newfile, vl_filename); LYforce_HTML_mode = TRUE; /* force this file to be HTML */ LYforce_no_cache = TRUE; /* force this file to be new */ @@ -625,7 +595,7 @@ PUBLIC int LYShowVisitedLinks ARGS1( fprintf(fp0,"</pre>\n</body>\n"); - fclose(fp0); + LYCloseTempFP(fp0); FREE(Title); FREE(Address); return(0); diff --git a/src/LYList.c b/src/LYList.c index d0b28169..f7b31e4c 100644 --- a/src/LYList.c +++ b/src/LYList.c @@ -53,7 +53,6 @@ PUBLIC int showlist ARGS2( int cnt; int refs, hidden_links; static char tempfile[256]; - static BOOLEAN first = TRUE; FILE *fp0; char *Address = NULL, *Title = NULL, *cp = NULL; BOOLEAN intern_w_post = FALSE; @@ -73,29 +72,15 @@ PUBLIC int showlist ARGS2( return(-1); } - if (first) { - tempname(tempfile, NEW_FILE); - /* - * Make the file a URL now. - */ -#if defined (VMS) || defined (DOSPATH) || defined (__EMX__) - sprintf(list_filename, "file://localhost/%s", tempfile); -#else - sprintf(list_filename, "file://localhost%s", tempfile); -#endif /* VMS */ - first = FALSE; -#ifdef VMS - } else { - remove(tempfile); /* Remove duplicates on VMS. */ -#endif /* VMS */ - } - - if ((fp0 = LYNewTxtFile(tempfile)) == NULL) { + LYRemoveTemp(tempfile); + if ((fp0 = LYOpenTemp(tempfile, HTML_SUFFIX, "w")) == NULL) { _statusline(CANNOT_OPEN_TEMP); sleep(MessageSecs); return(-1); } + LYLocalFileToURL(list_filename, tempfile); + StrAllocCopy(newdoc->address, list_filename); LYforce_HTML_mode = TRUE; /* force this file to be HTML */ LYforce_no_cache = TRUE; /* force this file to be new */ @@ -257,7 +242,7 @@ PUBLIC int showlist ARGS2( } newdoc->isHEAD = FALSE; newdoc->safe = FALSE; - fclose(fp0); + LYCloseTempFP(fp0); return(0); } diff --git a/src/LYLocal.c b/src/LYLocal.c index a88bc3e0..828b0779 100644 --- a/src/LYLocal.c +++ b/src/LYLocal.c @@ -966,7 +966,7 @@ PRIVATE BOOLEAN remove_single ARGS1( char *args[5]; /* - * lstat() first in case its a symbolic link. + * lstat() first in case it's a symbolic link. */ if (lstat(testpath, &dir_info) == -1 && stat(testpath, &dir_info) == -1) { @@ -1122,7 +1122,6 @@ PRIVATE BOOLEAN permit_location ARGS3( return(0); #else static char tempfile[256] = "\0"; - static BOOLEAN first = TRUE; char *cp; char tmpbuf[LINESIZE]; struct stat dir_info; @@ -1161,32 +1160,18 @@ PRIVATE BOOLEAN permit_location ARGS3( user_filename = (cp + 1); } - if (first) { - /* - * Get an unused tempfile name. - FM - */ - tempname(tempfile, NEW_FILE); - } - - /* - * Open the tempfile for writing and set its - * protection in case this wasn't done via an - * external umask. - FM - */ - if ((fp0 = LYNewTxtFile(tempfile)) == NULL) { + LYRemoveTemp(tempfile); + if ((fp0 = LYOpenTemp(tempfile, HTML_SUFFIX, "w")) == NULL) { _statusline("Unable to open permit options file"); sleep(AlertSecs); return(0); } - if (first) { - /* - * Make the tempfile a URL. - */ - strcpy(LYPermitFileURL, "file://localhost"); - strcat(LYPermitFileURL, tempfile); - first = FALSE; - } + /* + * Make the tempfile a URL. + */ + strcpy(LYPermitFileURL, "file://localhost"); + strcat(LYPermitFileURL, tempfile); StrAllocCopy(*newpath, LYPermitFileURL); grp = getgrgid(dir_info.st_gid); @@ -1267,7 +1252,7 @@ form to permit %s %s.\n</Ol>\n</Form>\n", (dir_info.st_mode & S_IFMT) == S_IFDIR ? "directory" : "file", user_filename); fprintf(fp0, "</Body></Html>"); - fclose(fp0); + LYCloseTempFP(fp0); LYforce_no_cache = TRUE; return(PERMIT_FORM_RESULT); /* Special flag for LYMainLoop */ @@ -1695,7 +1680,6 @@ PUBLIC int dired_options ARGS2( char **, newfile) { static char tempfile[256]; - static BOOLEAN first = TRUE; char path[512], dir[512]; /* much too large */ char tmpbuf[LINESIZE]; lynx_html_item_type *nxt; @@ -1714,33 +1698,18 @@ PUBLIC int dired_options ARGS2( struct dired_menu *mp; char buf[2048]; - - if (first) { - /* - * Get an unused tempfile name. - FM - */ - tempname(tempfile, NEW_FILE); - } - - /* - * Open the tempfile for writing and set its - * protection in case this wasn't done via an - * external umask. - FM - */ - if ((fp0 = LYNewTxtFile(tempfile)) == NULL) { + LYRemoveTemp(tempfile); + if ((fp0 = LYOpenTemp(tempfile, HTML_SUFFIX, "w")) == NULL) { _statusline("Unable to open file management menu file."); sleep(AlertSecs); return(0); } - if (first) { - /* - * Make the tempfile a URL. - */ - strcpy(LYDiredFileURL, "file://localhost"); - strcat(LYDiredFileURL, tempfile); - first = FALSE; - } + /* + * Make the tempfile a URL. + */ + strcpy(LYDiredFileURL, "file://localhost"); + strcat(LYDiredFileURL, tempfile); StrAllocCopy(*newfile, LYDiredFileURL); cp = doc->address; @@ -1776,6 +1745,7 @@ PUBLIC int dired_options ARGS2( sprintf(tmpbuf, "Unable to get status of '%s'.", path); _statusline(tmpbuf); sleep(AlertSecs); + LYCloseTempFP(fp0); FREE(dir_url); FREE(path_url); return 0; @@ -1887,7 +1857,7 @@ PUBLIC int dired_options ARGS2( } fprintf(fp0, "</body>\n"); - fclose(fp0); + LYCloseTempFP(fp0); FREE(dir_url); FREE(path_url); diff --git a/src/LYMail.c b/src/LYMail.c index 19132764..9ca2a175 100644 --- a/src/LYMail.c +++ b/src/LYMail.c @@ -317,14 +317,7 @@ PUBLIC void mailform ARGS4( } #if defined(VMS) || defined(DOSPATH) - tempname(my_tmpfile, NEW_FILE); - if (((cp = strrchr(my_tmpfile, '.')) != NULL) && - NULL == strchr(cp, ']') && - NULL == strchr(cp, '/')) { - *cp = '\0'; - strcat(my_tmpfile, ".txt"); - } - if ((fd = LYNewTxtFile(my_tmpfile)) == NULL) { + if ((fd = LYOpenTemp(my_tmpfile, ".txt", "w")) == NULL) { HTAlert(FORM_MAILTO_FAILED); FREE(address); FREE(ccaddr); @@ -332,15 +325,9 @@ PUBLIC void mailform ARGS4( return; } if (isPMDF) { - tempname(hdrfile, NEW_FILE); - if (((cp = strrchr(hdrfile, '.')) != NULL) && - NULL == strchr(cp, ']') && - NULL == strchr(cp, '/')) { - *cp = '\0'; - strcat(hdrfile, ".txt"); - } - if ((hfd = LYNewTxtFile(hdrfile)) == NULL) { + if ((hfd = LYOpenTemp(hdrfile, ".txt", "w")) == NULL) { HTAlert(FORM_MAILTO_FAILED); + LYCloseTempFP(fd); FREE(address); FREE(ccaddr); FREE(keywords); @@ -438,7 +425,7 @@ PUBLIC void mailform ARGS4( sleep(MessageSecs); #endif /* UNIX */ #if defined(VMS) || defined(DOSPATH) - fclose(fd); + LYCloseTempFP(fd); #ifdef VMS /* * Set the mail command. - FM @@ -452,7 +439,7 @@ PUBLIC void mailform ARGS4( fprintf(hfd, "Keywords: %s\n", keywords); } fprintf(hfd, "Subject: %s\n\n", subject); - fclose(hfd); + LYCloseTempFP(hfd); /* * Now set up the command. - FM */ @@ -553,8 +540,8 @@ PUBLIC void mailform ARGS4( FREE(command); sleep(AlertSecs); start_curses(); - remove(my_tmpfile); - remove(hdrfile); + LYRemoveTemp(my_tmpfile); + LYRemoveTemp(hdrfile); #else /* DOSPATH */ StrAllocCopy(command, system_mail); StrAllocCat(command, " -t \""); @@ -567,7 +554,7 @@ PUBLIC void mailform ARGS4( FREE(command); sleep(MessageSecs); start_curses(); - remove(my_tmpfile); + LYRemoveTemp(my_tmpfile); #endif #endif /* VMS */ @@ -704,28 +691,14 @@ PUBLIC void mailmsg ARGS4( fprintf(fd, "X-Mailer: Lynx, Version %s\n\n", LYNX_VERSION); #endif /* UNIX */ #if defined(VMS) || defined(DOSPATH) - tempname(my_tmpfile, NEW_FILE); - if (((cp = strrchr(my_tmpfile, '.')) != NULL) && - NULL == strchr(cp, ']') && - NULL == strchr(cp, '/')) { - *cp = '\0'; - strcat(my_tmpfile, ".txt"); - } - if ((fd = LYNewTxtFile(my_tmpfile)) == NULL) { + if ((fd = LYOpenTemp(my_tmpfile, ".txt", "w")) == NULL) { CTRACE(tfp, "mailmsg: Could not fopen '%s'.\n", my_tmpfile); FREE(address); return; } if (isPMDF) { - tempname(hdrfile, NEW_FILE); - if (((cp = strrchr(hdrfile, '.')) != NULL) && - NULL == strchr(cp, ']') && - NULL == strchr(cp, '/')) { - *cp = '\0'; - strcat(hdrfile, ".txt"); - } - if ((hfd = LYNewTxtFile(hdrfile)) == NULL) { + if ((hfd = LYOpenTemp(hdrfile, ".txt", "w")) == NULL) { CTRACE(tfp, "mailmsg: Could not fopen '%s'.\n", hdrfile); FREE(address); @@ -761,7 +734,7 @@ PUBLIC void mailmsg ARGS4( pclose(fd); #endif /* UNIX */ #if defined(VMS) || defined(DOSPATH) - fclose(fd); + LYCloseTempFP(fd); #ifdef VMS if (isPMDF) { /* @@ -769,7 +742,7 @@ PUBLIC void mailmsg ARGS4( * header file and close it. - FM */ fprintf(hfd, "Subject: Lynx Error in %.56s\n\n", filename); - fclose(hfd); + LYCloseTempFP(hfd); /* * Now set up the command. - FM */ @@ -822,9 +795,9 @@ PUBLIC void mailmsg ARGS4( system(command); FREE(command); - remove(my_tmpfile); + LYRemoveTemp(my_tmpfile); if (isPMDF) { - remove(hdrfile); + LYRemoveTemp(hdrfile); } #else /* DOSPATH */ StrAllocCopy(command, system_mail); @@ -834,7 +807,7 @@ PUBLIC void mailmsg ARGS4( StrAllocCat(command, my_tmpfile); system(command); FREE(command); - remove(my_tmpfile); + LYRemoveTemp(my_tmpfile); #endif #endif /* VMS */ @@ -927,29 +900,13 @@ PUBLIC void reply_by_mail ARGS3( return; } - tempname(my_tmpfile, NEW_FILE); - if (((cp = strrchr(my_tmpfile, '.')) != NULL) && -#ifdef VMS - NULL == strchr(cp, ']') && -#endif /* VMS */ - NULL == strchr(cp, '/')) { - *cp = '\0'; - strcat(my_tmpfile, ".txt"); - } - if ((fd = LYNewTxtFile(my_tmpfile)) == NULL) { + if ((fd = LYOpenTemp(my_tmpfile, ".txt", "w")) == NULL) { HTAlert(MAILTO_URL_TEMPOPEN_FAILED); return; } #ifdef VMS if (isPMDF) { - tempname(hdrfile, NEW_FILE); - if (((cp = strrchr(hdrfile, '.')) != NULL) && - NULL == strchr(cp, ']') && - NULL == strchr(cp, '/')) { - *cp = '\0'; - strcat(hdrfile, ".txt"); - } - if ((hfd = LYNewTxtFile(hdrfile)) == NULL) { + if ((hfd = LYOpenTemp(hdrfile, ".txt", "w")) == NULL) { HTAlert(MAILTO_URL_TEMPOPEN_FAILED); return; } @@ -1186,8 +1143,8 @@ PUBLIC void reply_by_mail ARGS3( FREE(ccaddr); FREE(keywords); FREE(body); - fclose(fd); /* Close the tmpfile. */ - remove(my_tmpfile); /* Delete the tmpfile. */ + LYCloseTempFP(fd); /* Close the tmpfile. */ + LYRemoveTemp(my_tmpfile); /* Delete the tmpfile. */ HTAlert(NO_ADDRESS_IN_MAILTO_URL); return; } @@ -1382,7 +1339,7 @@ PUBLIC void reply_by_mail ARGS3( addstr("\n"); _statusline(COMMENT_REQUEST_CANCELLED); sleep(InfoSecs); - fclose(fd); /* Close the tmpfile. */ + LYCloseTempFP(fd); /* Close the tmpfile. */ scrollok(stdscr,FALSE); /* Stop scrolling. */ goto cleanup; } @@ -1425,7 +1382,7 @@ PUBLIC void reply_by_mail ARGS3( addstr("\n"); _statusline(COMMENT_REQUEST_CANCELLED); sleep(InfoSecs); - fclose(fd); /* Close the tmpfile. */ + LYCloseTempFP(fd); /* Close the tmpfile. */ scrollok(stdscr,FALSE); /* Stop scrolling. */ goto cleanup; } @@ -1472,7 +1429,7 @@ PUBLIC void reply_by_mail ARGS3( addstr("\n"); _statusline(COMMENT_REQUEST_CANCELLED); sleep(InfoSecs); - fclose(fd); /* Close the tmpfile. */ + LYCloseTempFP(fd); /* Close the tmpfile. */ scrollok(stdscr,FALSE); /* Stop scrolling. */ goto cleanup; } @@ -1506,7 +1463,7 @@ PUBLIC void reply_by_mail ARGS3( addstr("\n"); _statusline(COMMENT_REQUEST_CANCELLED); sleep(InfoSecs); - fclose(fd); /* Close the tmpfile. */ + LYCloseTempFP(fd); /* Close the tmpfile. */ scrollok(stdscr, FALSE); /* Stop scrolling. */ goto cleanup; } @@ -1600,7 +1557,7 @@ PUBLIC void reply_by_mail ARGS3( print_wwwfile_to_fd(fd, 1); } } - fclose(fd); /* Close the tmpfile. */ + LYCloseTempFP(fd); /* Close the tmpfile. */ scrollok(stdscr,FALSE); /* Stop scrolling. */ if (term_letter || c == 7 || c == 3) @@ -1642,7 +1599,7 @@ PUBLIC void reply_by_mail ARGS3( if (term_letter || c == 7 || c == 3) { addstr(CANCELLED); sleep(InfoSecs); - fclose(fd); /* Close the tmpfile. */ + LYCloseTempFP(fd); /* Close the tmpfile. */ scrollok(stdscr, FALSE); /* Stop scrolling. */ goto cleanup; } @@ -1660,7 +1617,7 @@ PUBLIC void reply_by_mail ARGS3( i--; } refresh(); - fclose(fd); /* Close the tmpfile. */ + LYCloseTempFP(fd); /* Close the tmpfile. */ scrollok(stdscr,FALSE); /* Stop scrolling. */ } else { @@ -1677,7 +1634,7 @@ PUBLIC void reply_by_mail ARGS3( term_letter || STREQ(user_input, ".")) { _statusline(COMMENT_REQUEST_CANCELLED); sleep(InfoSecs); - fclose(fd); /* Close the tmpfile. */ + LYCloseTempFP(fd); /* Close the tmpfile. */ scrollok(stdscr,FALSE); /* Stop scrolling. */ goto cleanup; } @@ -1691,14 +1648,14 @@ PUBLIC void reply_by_mail ARGS3( sizeof(user_input), NORECALL) < 0) { _statusline(COMMENT_REQUEST_CANCELLED); sleep(InfoSecs); - fclose(fd); /* Close the tmpfile. */ + LYCloseTempFP(fd); /* Close the tmpfile. */ scrollok(stdscr,FALSE); /* Stop scrolling. */ goto cleanup; } } fprintf(fd, "\n"); /* Terminate the message. */ - fclose(fd); /* Close the tmpfile. */ + LYCloseTempFP(fd); /* Close the tmpfile. */ scrollok(stdscr,FALSE); /* Stop scrolling. */ } @@ -1760,7 +1717,7 @@ PUBLIC void reply_by_mail ARGS3( fprintf(hfd, "Keywords: %s\n", keywords); } fprintf(hfd, "Subject: %s\n\n", subject); - fclose(hfd); + LYCloseTempFP(hfd); /* * Now set up the command. - FM */ @@ -1869,13 +1826,7 @@ PUBLIC void reply_by_mail ARGS3( _statusline(SENDING_YOUR_MSG); sprintf(cmd, "%s %s", system_mail, system_mail_flags); #ifdef DOSPATH - tempname(tmpfile2, NEW_FILE); - if (((cp = strrchr(tmpfile2, '.')) != NULL) && - NULL == strchr(cp, '/')) { - *cp = '\0'; - strcat(tmpfile2, ".txt"); - } - if ((fp = LYNewTxtFile(tmpfile2)) == NULL) { + if ((fp = LYOpenTemp(tmpfile2, ".txt", "w")) == NULL) { HTAlert(MAILTO_URL_TEMPOPEN_FAILED); return; } @@ -1904,18 +1855,18 @@ PUBLIC void reply_by_mail ARGS3( StrAllocCat(command, address); StrAllocCat(command, "\" -F "); StrAllocCat(command, tmpfile2); - fclose(fp); /* Close the tmpfile. */ + LYCloseTempFP(fp); /* Close the tmpfile. */ stop_curses(); printf("Sending your comment:\n\n$ %s\n\nPlease wait...", command); system(command); FREE(command); sleep(MessageSecs); start_curses(); - remove(tmpfile2); /* Delete the tmpfile. */ + LYRemoveTemp(tmpfile2); /* Delete the tmpfile. */ #else pclose(fp); #endif - fclose(fd); /* Close the tmpfile. */ + LYCloseTempFP(fd); /* Close the tmpfile. */ CTRACE(tfp, "%s\n", cmd); #endif /* VMS */ @@ -1935,14 +1886,11 @@ cleandown: term_letter = FALSE; #ifdef VMS FREE(command); - while (remove(my_tmpfile) == 0) - ; /* Delete the tmpfile(s). */ if (isPMDF) { - remove(hdrfile); /* Delete the hdrfile. */ + LYRemoveTemp(hdrfile); } -#else - remove(my_tmpfile); /* Delete the tmpfile. */ #endif /* VMS */ + LYRemoveTemp(my_tmpfile); FREE(address); FREE(ccaddr); FREE(keywords); diff --git a/src/LYMain.c b/src/LYMain.c index 9a588f6a..6d1ebd79 100644 --- a/src/LYMain.c +++ b/src/LYMain.c @@ -714,10 +714,10 @@ PUBLIC int main ARGS2( else if ((cp = getenv("TMP")) != NULL) StrAllocCopy(lynx_temp_space, cp); else - { - printf("You MUST define a valid TMP or TEMP area!\n"); - exit(-1); - } + { + printf("You MUST define a valid TMP or TEMP area!\n"); + exit(-1); + } #else StrAllocCopy(lynx_temp_space, TEMP_SPACE); #endif diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c index 6ff7b827..52e501ac 100644 --- a/src/LYMainLoop.c +++ b/src/LYMainLoop.c @@ -5104,9 +5104,6 @@ check_add_bookmark_to_self: else WWW_TraceFlag = TRUE; - _statusline(WWW_TraceFlag ? TRACE_ON : TRACE_OFF); - sleep(MessageSecs); - if (TRACE && LYUseTraceLog && LYTraceLogFP == NULL) { /* * We haven't yet started a TRACE log for this @@ -5134,6 +5131,8 @@ check_add_bookmark_to_self: #endif /* VMS */ fprintf(tfp, "\t\t%s\n\n", LYNX_TRACELOG_TITLE); } + _statusline(WWW_TraceFlag ? TRACE_ON : TRACE_OFF); + sleep(MessageSecs); break; case LYK_TRACE_LOG: /* View TRACE log. */ diff --git a/src/LYNews.c b/src/LYNews.c index 6df6a9ff..45d560cb 100644 --- a/src/LYNews.c +++ b/src/LYNews.c @@ -68,8 +68,7 @@ PUBLIC char *LYNewsPost ARGS2( * Open a temporary file for the headers * and message body. - FM */ - tempname(my_tempfile, NEW_FILE); - if ((fd = LYNewTxtFile(my_tempfile)) == NULL) { + if ((fd = LYOpenTemp(my_tempfile, HTML_SUFFIX, "w")) == NULL) { HTAlert(CANNOT_OPEN_TEMP); return(postfile); } @@ -81,16 +80,9 @@ PUBLIC char *LYNewsPost ARGS2( CJKfile[0] = '\0'; if (!strncmp(LYchar_set_names[current_char_set], "Japanese (EUC)", 14) || !strncmp(LYchar_set_names[current_char_set], "Japanese (SJIS)", 15)) { - tempname(CJKfile, NEW_FILE); - if ((fc = LYNewTxtFile(CJKfile)) == NULL) { + if ((fc = LYOpenTemp(CJKfile, HTML_SUFFIX, "w")) == NULL) { HTAlert(CANNOT_OPEN_TEMP); - fclose(fd); -#ifdef VMS - while (remove(my_tempfile) == 0) - ; /* loop through all versions */ -#else - remove(my_tempfile); -#endif /* VMS */ + LYRemoveTemp(my_tempfile); return(postfile); } } @@ -134,8 +126,8 @@ PUBLIC char *LYNewsPost ARGS2( term_message) { _statusline(NEWS_POST_CANCELLED); sleep(InfoSecs); - fclose(fd); /* Close the temp file. */ - scrollok(stdscr, FALSE); /* Stop scrolling. */ + LYCloseTempFP(fd); /* Close the temp file. */ + scrollok(stdscr, FALSE); /* Stop scrolling. */ goto cleanup; } fprintf(fd, "%s\n", user_input); @@ -164,8 +156,8 @@ PUBLIC char *LYNewsPost ARGS2( term_message) { _statusline(NEWS_POST_CANCELLED); sleep(InfoSecs); - fclose(fd); /* Close the temp file. */ - scrollok(stdscr, FALSE); /* Stop scrolling. */ + LYCloseTempFP(fd); /* Close the temp file. */ + scrollok(stdscr, FALSE); /* Stop scrolling. */ goto cleanup; } fprintf(fd,"%s\n",user_input); @@ -200,8 +192,8 @@ PUBLIC char *LYNewsPost ARGS2( term_message) { _statusline(NEWS_POST_CANCELLED); sleep(InfoSecs); - fclose(fd); /* Close the temp file. */ - scrollok(stdscr, FALSE); /* Stop scrolling. */ + LYCloseTempFP(fd); /* Close the temp file. */ + scrollok(stdscr, FALSE); /* Stop scrolling. */ goto cleanup; } fprintf(fd, "%s\n", user_input); @@ -239,8 +231,8 @@ PUBLIC char *LYNewsPost ARGS2( */ print_wwwfile_to_fd(fd, 1); } - fclose(fd); /* Close the temp file. */ - scrollok(stdscr, FALSE); /* Stop scrolling. */ + LYCloseTempFP(fd); /* Close the temp file. */ + scrollok(stdscr, FALSE); /* Stop scrolling. */ if (term_message || c == 7 || c == 3) goto cleanup; @@ -275,7 +267,7 @@ PUBLIC char *LYNewsPost ARGS2( term_message) { _statusline(NEWS_POST_CANCELLED); sleep(InfoSecs); - fclose(fd); /* Close the temp file. */ + LYCloseTempFP(fd); /* Close the temp file. */ scrollok(stdscr, FALSE); /* Stop scrolling. */ goto cleanup; } @@ -287,14 +279,14 @@ PUBLIC char *LYNewsPost ARGS2( sizeof(user_input), NORECALL) < 0) { _statusline(NEWS_POST_CANCELLED); sleep(InfoSecs); - fclose(fd); /* Close the temp file. */ - scrollok(stdscr, FALSE); /* Stop scrolling. */ + LYCloseTempFP(fd); /* Close the temp file. */ + scrollok(stdscr, FALSE); /* Stop scrolling. */ goto cleanup; } } fprintf(fd, "\n"); - fclose(fd); /* Close the temp file. */ - scrollok(stdscr, FALSE); /* Stop scrolling. */ + LYCloseTempFP(fd); /* Close the temp file. */ + scrollok(stdscr, FALSE); /* Stop scrolling. */ } /* @@ -322,7 +314,7 @@ PUBLIC char *LYNewsPost ARGS2( !term_message && c != 7 && c != 3) c = LYgetch(); if (TOUPPER(c) == 'Y') { - if ((fd = fopen(my_tempfile, "a")) != NULL) { + if ((fd = LYAppendToTxtFile (my_tempfile)) != NULL) { fputs("-- \n", fd); while (fgets(user_input, sizeof(user_input), fp) != NULL) { fputs(user_input, fd); @@ -348,16 +340,10 @@ PUBLIC char *LYNewsPost ARGS2( (unsigned char *)CJKinput); fputs(CJKinput, fc); } - fclose(fc); + LYCloseTempFP(fc); StrAllocCopy(postfile, CJKfile); fclose(fd); -#ifdef VMS - while (remove(my_tempfile) == 0) - ; /* loop through all versions */ -#else - remove(my_tempfile); -#endif /* VMS */ - fd = fc; + LYRemoveTemp(my_tempfile); strcpy(my_tempfile, CJKfile); CJKfile[0] = '\0'; } else { @@ -391,23 +377,9 @@ cleanup: signal(SIGINT, cleanup_sig); #endif /* !VMS */ term_message = FALSE; - if (!postfile) { -#ifdef VMS - while (remove(my_tempfile) == 0) - ; /* loop through all versions */ -#else - remove(my_tempfile); -#endif /* VMS */ - } - if (CJKfile[0] != '\0') { -#ifdef VMS - fclose(fc); - while (remove(CJKfile) == 0) - ; /* loop through all versions */ -#else - remove(CJKfile); -#endif /* VMS */ - } + if (!postfile) + LYRemoveTemp(my_tempfile); + LYRemoveTemp(CJKfile); FREE(NewsGroups); return(postfile); diff --git a/src/LYPrint.c b/src/LYPrint.c index 72d7e322..05ff5ee6 100644 --- a/src/LYPrint.c +++ b/src/LYPrint.c @@ -59,8 +59,8 @@ * * incorporate the idea of "lpansi" directly into LYPrint.c - HN */ -#define LPANSI 3 -#define MAIL 4 +#define LPANSI 3 +#define MAIL 4 #define PRINTER 5 #ifdef VMS @@ -71,7 +71,6 @@ PUBLIC int printfile ARGS1( document *, newdoc) { static char tempfile[256]; - static BOOLEAN first = TRUE; char buffer[LINESIZE]; char filename[LINESIZE]; char user_response[256]; @@ -609,44 +608,19 @@ PUBLIC int printfile ARGS1( strcpy(user_response, filename); } - if (first) { - tempname(tempfile, NEW_FILE); - if (isPMDF) { - tempname(hdrfile, NEW_FILE); - if ((len = strlen(hdrfile)) > 4) { - len -= 5; - if (!strcasecomp((hdrfile + len), ".html")) { - hdrfile[len] = '\0'; - strcat(hdrfile, ".txt"); - } - } - } - first = FALSE; - } else { - remove(tempfile); /* remove duplicates */ - } - if (HTisDocumentSource()) { - if ((len = strlen(tempfile)) > 3) { - len -= 4; - if (!strcasecomp((tempfile + len), ".txt")) { - tempfile[len] = '\0'; - strcat(tempfile, ".html"); - } - } - } else if ((len = strlen(tempfile)) > 4) { - len -= 5; - if (!strcasecomp((tempfile + len), ".html")) { - tempfile[len] = '\0'; - strcat(tempfile, ".txt"); - } - } - if ((outfile_fp = LYNewTxtFile(tempfile)) == NULL) { + LYRemoveTemp(tempfile); + outfile_fp = LYOpenTemp(tempfile, + (HTisDocumentSource()) + ? HTML_SUFFIX + : ".txt", + "w"); + if (outfile_fp == NULL) { HTAlert(UNABLE_TO_OPEN_TEMPFILE); break; } if (isPMDF) { - if ((hfd = LYNewTxtFile(hdrfile)) == NULL) { + if ((hfd = LYOpenTemp(hdrfile, ".txt", "w")) == NULL) { HTAlert(UNABLE_TO_OPEN_TEMPFILE); break; } @@ -715,7 +689,7 @@ PUBLIC int printfile ARGS1( print_wwwfile_to_fd(outfile_fp, 0); if (keypad_mode) printlist(outfile_fp, FALSE); - fclose(outfile_fp); + LYCloseTempFP(outfile_fp); if (isPMDF) { /* @@ -723,7 +697,7 @@ PUBLIC int printfile ARGS1( * header file and close it. - FM */ fprintf(hfd, "Subject: %.70s\n\n", sug_filename); - fclose(hfd); + LYCloseTempFP(hfd); /* * Now set up the command. - FM */ @@ -756,29 +730,21 @@ PUBLIC int printfile ARGS1( fflush(stdout); sleep(AlertSecs); start_curses(); - if (isPMDF) { - /* - * Delete the header file. - FM - */ - remove(hdrfile); - } -#else /* Unix: */ - sprintf(buffer, "%s %s", system_mail, system_mail_flags); + if (isPMDF) + LYRemoveTemp(hdrfile); +#else /* Unix or DOS */ #ifdef DOSPATH - sprintf(tempfile, "%s%s", lynx_temp_space, "temp_mail.txt"); - if ((outfile_fp = LYNewTxtFile(tempfile)) == NULL) { - _statusline(MAIL_REQUEST_FAILED); - sleep(AlertSecs); - return; - } + outfile_fp = LYOpenTemp(tempfile, ".txt", "w"); #else - if ((outfile_fp = popen(buffer, "w")) == NULL) { - _statusline(MAIL_REQUEST_FAILED); - sleep(AlertSecs); - break; - } + sprintf(buffer, "%s %s", system_mail, system_mail_flags); + outfile_fp = popen(buffer, "w"); #endif + if (outfile_fp == NULL) { + _statusline(MAIL_REQUEST_FAILED); + sleep(AlertSecs); + break; + } /* * Determine which mail headers should be sent. @@ -884,13 +850,13 @@ PUBLIC int printfile ARGS1( #ifdef DOSPATH sprintf(buffer, "%s -t \"%s\" -F %s", system_mail, user_response, tempfile); - fclose(outfile_fp); /* Close the tmpfile. */ + LYCloseTempFP(outfile_fp); /* Close the tmpfile. */ stop_curses(); printf("Sending \n\n$ %s\n\nPlease wait...", buffer); system(buffer); sleep(MessageSecs); start_curses(); - remove(tempfile); /* Delete the tmpfile. */ + LYRemoveTemp(tempfile); /* Delete the tmpfile. */ #else pclose(outfile_fp); #endif @@ -1012,28 +978,13 @@ PUBLIC int printfile ARGS1( } } - if (first) { - tempname(tempfile, NEW_FILE); - first = FALSE; - } else { - remove(tempfile); /* Remove previous tempfile. */ - } - if (((cp = strrchr(tempfile, '.')) != NULL) && -#ifdef VMS - NULL == strchr(cp, ']') && -#endif /* VMS */ - NULL == strchr(cp, '/')) { - if (HTisDocumentSource() && - strcasecomp(cp, HTML_SUFFIX)) { - *cp = '\0'; - strcat(tempfile, HTML_SUFFIX); - } else if (!HTisDocumentSource() && - strcasecomp(cp, ".txt")) { - *cp = '\0'; - strcat(tempfile, ".txt"); - } - } - if ((outfile_fp = LYNewTxtFile(tempfile)) == NULL) { + LYRemoveTemp(tempfile); + outfile_fp = LYOpenTemp(tempfile, + (HTisDocumentSource()) + ? HTML_SUFFIX + : ".txt", + "w"); + if (outfile_fp == NULL) { HTAlert(FILE_ALLOC_FAILED); break; } @@ -1273,7 +1224,6 @@ PUBLIC int printfile ARGS1( #endif /* !VMS */ sleep(MessageSecs); start_curses(); - /* don't remove(tempfile); */ } /* end switch */ FREE(link_info); @@ -1317,7 +1267,6 @@ PUBLIC int print_options ARGS2( int, lines_in_file) { static char tempfile[256]; - static BOOLEAN first = TRUE; static char print_filename[256]; char buffer[LINESIZE]; int count; @@ -1327,25 +1276,14 @@ PUBLIC int print_options ARGS2( pages = lines_in_file/66 + 1; - if (first) { - tempname(tempfile, NEW_FILE); -#if defined (VMS) || defined (DOSPATH) || defined (__EMX__) - sprintf(print_filename, "file://localhost/%s", tempfile); -#else - sprintf(print_filename, "file://localhost%s", tempfile); -#endif /* VMS */ - first = FALSE; -#ifdef VMS - } else { - remove(tempfile); /* Remove duplicates on VMS. */ -#endif /* !VMS */ - } - - if ((fp0 = LYNewTxtFile(tempfile)) == NULL) { + LYRemoveTemp(tempfile); + if ((fp0 = LYOpenTemp(tempfile, HTML_SUFFIX, "w")) == NULL) { HTAlert(UNABLE_TO_OPEN_PRINTOP_FILE); return(-1); } + LYLocalFileToURL(print_filename, tempfile); + StrAllocCopy(*newfile, print_filename); LYforce_no_cache = TRUE; @@ -1395,7 +1333,7 @@ PUBLIC int print_options ARGS2( fprintf(fp0, "</a>\n"); } fprintf(fp0, "</pre>\n</body>\n"); - fclose(fp0); + LYCloseTempFP(fp0); LYforce_no_cache = TRUE; return(0); diff --git a/src/LYShowInfo.c b/src/LYShowInfo.c index af6a6e71..f0ae2a20 100644 --- a/src/LYShowInfo.c +++ b/src/LYShowInfo.c @@ -36,7 +36,6 @@ PUBLIC int showinfo ARGS4( char *, owner_address) { static char tempfile[256]; - static BOOLEAN first = TRUE; static char info_url[256]; int url_type; FILE *fp0; @@ -49,28 +48,15 @@ PUBLIC int showinfo ARGS4( struct passwd *pw; struct group *grp; #endif /* DIRED_SUPPORT */ - if (first) { - tempname(tempfile, NEW_FILE); - /* - * Make the temporary file a URL now. - */ -#if defined (VMS) || defined (DOSPATH) || defined (__EMX__) - sprintf(info_url, "file://localhost/%s", tempfile); -#else - sprintf(info_url, "file://localhost%s", tempfile); -#endif /* VMS */ - first = FALSE; -#ifdef VMS - } else { - remove(tempfile); /* Remove duplicates on VMS. */ -#endif /* VMS */ - } - if ((fp0 = LYNewTxtFile(tempfile)) == NULL) { + LYRemoveTemp(tempfile); + if ((fp0 = LYOpenTemp (tempfile, HTML_SUFFIX, "w")) == 0) { HTAlert(CANNOT_OPEN_TEMP); return(0); } + LYLocalFileToURL(info_url, tempfile); + /* * Point the address pointer at this Url */ @@ -357,7 +343,7 @@ PUBLIC int showinfo ARGS4( refresh(); - fclose(fp0); + LYCloseTemp(tempfile); FREE(Address); FREE(Title); diff --git a/src/LYUpload.c b/src/LYUpload.c index cf5d55f8..cfbca0e6 100644 --- a/src/LYUpload.c +++ b/src/LYUpload.c @@ -226,30 +226,14 @@ PUBLIC int LYUpload_options ARGS2( char *, directory) { static char tempfile[256]; - static BOOLEAN first = TRUE; FILE *fp0; lynx_html_item_type *cur_upload; int count; static char curloc[256]; char *cp; - if (first) { - /* - * Get an unused tempfile name. - FM - */ - tempname(tempfile, NEW_FILE); -#ifdef VMS - } else { - remove(tempfile); /* Remove duplicates on VMS. */ -#endif /* VMS */ - } - - /* - * Open the tempfile for writing and set it's - * protection in case this wasn't done via an - * external umask. - FM - */ - if ((fp0 = LYNewTxtFile(tempfile)) == NULL) { + LYRemoveTemp(tempfile); + if ((fp0 = LYOpenTemp(tempfile, HTML_SUFFIX, "w")) == NULL) { HTAlert(CANNOT_OPEN_TEMP); return(-1); } @@ -268,17 +252,7 @@ PUBLIC int LYUpload_options ARGS2( curloc[strlen(curloc) - 1] = '\0'; #endif /* VMS */ - if (first) { - /* - * Make the tempfile a URL. - */ -#if defined (VMS) || defined (DOSPATH) || defined (__EMX__) - sprintf(LYUploadFileURL, "file://localhost/%s", tempfile); -#else - sprintf(LYUploadFileURL, "file://localhost%s", tempfile); -#endif /* VMS */ - first = FALSE; - } + LYLocalFileToURL(LYUploadFileURL, tempfile); StrAllocCopy(*newfile, LYUploadFileURL); fprintf(fp0, "<head>\n<title>%s</title>\n</head>\n<body>\n", @@ -307,7 +281,7 @@ an unlimited number of upload methods using the lynx.cfg file.\n"); } fprintf(fp0, "</pre>\n</body>\n"); - fclose(fp0); + LYCloseTempFP(fp0); LYforce_no_cache = TRUE; diff --git a/src/LYUtils.c b/src/LYUtils.c index a6053827..69fbbe83 100644 --- a/src/LYUtils.c +++ b/src/LYUtils.c @@ -2396,9 +2396,9 @@ PUBLIC int LYCheckForProxyURL ARGS1( * matches (and return true in that case). */ static BOOLEAN compare_type ARGS3( - char *, tst, - char *, cmp, - size_t, len) + char *, tst, + char *, cmp, + size_t, len) { if (!strncasecomp(tst, cmp, len)) { if (strncmp(tst, cmp, len)) { @@ -2818,9 +2818,9 @@ PUBLIC void size_change ARGS1( int old_cols = LYcols; #ifdef USE_SLANG -#if defined(VMS) || defined(UNIX) +#if defined(VMS) || defined(UNIX) SLtt_get_screen_size(); -#endif /* VMS || UNIX */ +#endif /* VMS || UNIX */ LYlines = SLtt_Screen_Rows; LYcols = SLtt_Screen_Cols; #ifdef SLANG_MBCS_HACK @@ -3222,122 +3222,41 @@ PUBLIC void change_sug_filename ARGS1( } /* - * Construct a name for 'tempname()' + * Construct a temporary-filename */ PRIVATE char *fmt_tempname ARGS3( - char *, result, + char *, result, unsigned, counter, - char *, suffix) + CONST char *, suffix) { - sprintf(result, + char *leaf; + strcpy(result, lynx_temp_space); + leaf = result + strlen(result); #ifdef FNAMES_8_3 - "%s%u%u%s", + /* + * The 'lynx_temp_space' string ends with a '/' or '\\', so we only have to + * limit the length of the leaf. As received (e.g., from HTCompressed), + * the suffix may contain more than a ".htm", e.g., "-txt.gz", so we trim + * off from the filename portion to make room. + */ + sprintf(leaf, "%u%u", counter, (unsigned)getpid()); + if (strlen(leaf) > 8) + leaf[8] = 0; + if (strlen(suffix) > 4 || *suffix != '.') { + CONST char *tail = strchr(suffix, '.'); + if (tail == 0) + tail = suffix + strlen(suffix); + leaf[8 - (tail - suffix)] = 0; + } + strcat(leaf, suffix); #else - "%sL%u-%uTMP%s", + sprintf(leaf, "L%u-%uTMP%s", (unsigned)getpid(), counter, suffix); #endif - lynx_temp_space, (unsigned)getpid(), counter, suffix); CTRACE(tfp, "-> '%s'\n", result); return result; } /* - * 'tempname()' requires that the resulting file does not exist. Test this - * by trying to open it. - */ -PRIVATE BOOLEAN bad_tempname ARGS3( - char *, result, - unsigned, counter, - char *, suffix) -{ - FILE *fp; - - if ((fp = fopen(fmt_tempname(result, counter, suffix), "r")) != 0) { - fclose(fp); - CTRACE(tfp, "tempname: file '%s' already exists!\n", result); - return TRUE; - } - - return FALSE; -} - -/* - * To create standard temporary file names. - */ -PUBLIC void tempname ARGS2( - char *, namebuffer, - int, action) -{ - static unsigned counter = 0; -#ifdef FNAMES_8_3 - unsigned LYMaxTempCount = 1000; /* Arbitrary limit. Make it configurable? */ -#else - unsigned LYMaxTempCount = 10000; /* Arbitrary limit. Make it configurable? */ -#endif /* FNAMES_8_3 */ - - if (action == REMOVE_FILES) { - /* - * Remove all temporary files with .txt or .html suffixes. - FM - */ - CTRACE(tfp, "tempname REMOVE_FILES (%d)\n", counter); - for (; counter != 0; counter--) { - remove(fmt_tempname(namebuffer, counter-1, ".txt")); - remove(fmt_tempname(namebuffer, counter-1, HTML_SUFFIX)); - } - } else { - /* - * Load a tentative temporary file name into namebuffer. - FM - */ - CTRACE(tfp, "tempname NEW_FILE (%d)\n", counter); - while (counter < LYMaxTempCount) { - /* - * Create names with .txt, then .bin, then - * .html suffixes, and check for their prior - * existence. If any already exist, someone - * might be trying to spoof us, so increment - * the count and try again. Otherwise, return - * with the name which has the .html suffix - * loaded in namebuffer. - FM - * - * Some systems may use .htm instead of .html. This - * should be done consistently by always using HTML_SUFFIX - * where filenames are generated for new local files. - kw - */ - if (bad_tempname(namebuffer, counter, ".txt") - || bad_tempname(namebuffer, counter, ".bin") - || bad_tempname(namebuffer, counter, HTML_SUFFIX)) { - continue; - } - /* - * Return to the calling function, with the tentative - * temporary file name loaded in namebuffer. Note that - * if the calling function will use a suffix other than - * .txt, .bin, or .html, it similarly should do tests for - * a spoof. The file name can be reused if it is written - * to on receipt of this name, and thereafter accessed - * for reading. Note that if writing to a file is to - * be followed by reading it, as is the usual case for - * Lynx, the spoof attempt will be apparent, and the user - * can take appropriate action. - FM - */ - counter++; - return; - } - /* - * The tempfile maximum count has been reached. - * Issue a message and exit. - FM - */ - _statusline(MAX_TEMPCOUNT_REACHED); - sleep(AlertSecs); - exit(-1); - } - - /* - * We were called for a clean up, and have done it. - FM - */ - return; -} - -/* * Convert 4, 6, 2, 8 to left, right, down, up, etc. */ PUBLIC int number2arrows ARGS1( @@ -5519,3 +5438,244 @@ PUBLIC void LYRelaxFilePermissions ARGS1(CONST char *, name) } } #endif + +/* + * Check if the given anchor has an associated file-cache. + */ +PUBLIC BOOLEAN LYCachedTemp ARGS2( + char *, result, + char *, cached) +{ + FILE *fp; + + if (cached) { + strcpy(result, cached); + FREE(cached); + if ((fp = fopen(result, "r")) != NULL) { + fclose(fp); + remove(result); + } + return TRUE; + } + return FALSE; +} + +/* + * Maintain a list of all of the temp-files we create so that we can remove + * them during the cleanup. + */ +typedef struct _LYTemp { + struct _LYTemp *next; + char *name; + FILE *file; +} LY_TEMP; + +static LY_TEMP *ly_temp; + +/* + * Open a temp-file, ensuring that it is unique, and not readable by other + * users. + * + * The mode can be one of: "w", "a", "wb". + */ +PUBLIC FILE *LYOpenTemp ARGS3( + char *, result, + CONST char *, suffix, + CONST char *, mode) +{ + FILE *fp = 0; + BOOL txt = TRUE; + BOOL wrt = 'r'; + LY_TEMP *p; + static unsigned counter; + + CTRACE(tfp, "LYOpenTemp(,%s,%s)\n", suffix, mode); + while (*mode != '\0') { + switch (*mode++) { + case 'w': wrt = 'w'; break; + case 'a': wrt = 'a'; break; + case 'b': txt = FALSE; break; + default: + CTRACE(tfp, "%s @%d: BUG\n", __FILE__, __LINE__); + return fp; + } + } + + do { + (void) fmt_tempname(result, counter++, suffix); + if (txt) { + switch (wrt) { + case 'w': + fp = LYNewTxtFile (result); + break; + case 'a': + fp = LYAppendToTxtFile (result); + break; + } + } else { + fp = LYNewBinFile (result); + } + } while (fp == 0); + + if ((p = (LY_TEMP *)calloc(1, sizeof(LY_TEMP))) != 0) { + p->next = ly_temp; + StrAllocCopy((p->name), result); + p->file = fp; + ly_temp = p; + } + + CTRACE(tfp, "... LYOpenTemp(%s)\n", result); + return fp; +} + +/* + * Reopen a temporary file + */ +PUBLIC FILE *LYReopenTemp ARGS1( + char *, name) +{ + LY_TEMP *p; + FILE *fp; + + LYCloseTemp(name); + for (p = ly_temp; p != 0; p = p->next) { + if (!strcmp(p->name, name)) { + fp = p->file = LYAppendToTxtFile (name); + break; + } + } + return fp; +} + +/* + * Special case of LYOpenTemp, used for manipulating bookmark file, i.e., with + * renaming. + */ +PUBLIC FILE *LYOpenScratch ARGS2( + char *, result, + CONST char *, prefix) +{ + FILE *fp; + LY_TEMP *p; + + sprintf(result, "%s-%u.%s", prefix, getpid(), HTML_SUFFIX); + if ((fp = LYNewTxtFile (result)) != 0) { + if ((p = (LY_TEMP *)calloc(1, sizeof(LY_TEMP))) != 0) { + p->next = ly_temp; + StrAllocCopy((p->name), result); + p->file = fp; + ly_temp = p; + } + } + CTRACE(tfp, "LYOpenScratch(%s)\n", result); + return fp; +} + +/* + * Close a temp-file, given its name + */ +PUBLIC void LYCloseTemp ARGS1( + char *, name) +{ + LY_TEMP *p; + + CTRACE(tfp, "LYCloseTemp(%s)\n", name); + for (p = ly_temp; p != 0; p = p->next) { + if (!strcmp(name, p->name)) { + CTRACE(tfp, "...LYCloseTemp(%s)%s\n", name, + (p->file != 0) ? ", closed" : ""); + if (p->file != 0) { + fclose(p->file); + p->file = 0; + } + break; + } + } +} + +/* + * Close a temp-file, given its file-pointer + */ +PUBLIC void LYCloseTempFP ARGS1( + FILE *, fp) +{ + LY_TEMP *p; + + CTRACE(tfp, "LYCloseTempFP\n"); + for (p = ly_temp; p != 0; p = p->next) { + if (p->file == fp) { + fclose(p->file); + p->file = 0; + break; + } + } +} + +/* + * Close a temp-file, removing it. + */ +PUBLIC void LYRemoveTemp ARGS1( + char *, name) +{ + LY_TEMP *p, *q; + int code; + + if (name != 0 && *name != 0) { + CTRACE(tfp, "LYRemoveTemp(%s)\n", name); + for (p = ly_temp, q = 0; p != 0; q = p, p = p->next) { + if (!strcmp(name, p->name)) { + if (q != 0) { + q->next = p->next; + } else { + ly_temp = p->next; + } +#ifdef VMS + while (remove(name) == 0) + ; +#else + code = remove(name); +#endif + CTRACE(tfp, "...LYRemoveTemp done(%d)%s\n", code, + (p->file != 0) ? ", closed" : ""); + if (p->file != 0) + fclose(p->file); + free(p->name); + free(p); + break; + } + } + } +} + +/* + * Remove all of the temp-files. Note that this assumes that they are closed, + * since some systems will not allow us to remove a file which is open. + */ +PUBLIC void LYCleanupTemp NOARGS +{ + while (ly_temp != 0) { + LYRemoveTemp(ly_temp->name); + } +} + +/* + * Convert a local filename to a URL + */ +PUBLIC void LYLocalFileToURL ARGS2( + char *, target, + char *, source) +{ +#ifdef DOSPATH + sprintf(target, "file://localhost/%s", HTDOS_wwwName(source)); +#else +#ifdef VMS + sprintf(target, "file://localhost%s", HTVMS_wwwName(source)); +#else +#ifdef __EMX__ + sprintf(target, "file://localhost/%s", source); +#else + sprintf(target, "file://localhost%s", source); +#endif /* __EMX__ */ +#endif /* VMS */ +#endif /* DOSPATH */ +} diff --git a/src/LYUtils.h b/src/LYUtils.h index 790d84a2..61baf346 100644 --- a/src/LYUtils.h +++ b/src/LYUtils.h @@ -32,7 +32,6 @@ extern void size_change PARAMS((int sig)); extern void HTSugFilenames_free NOPARAMS; extern void HTAddSugFilename PARAMS((char *fname)); extern void change_sug_filename PARAMS((char *fname)); -extern void tempname PARAMS((char *namebuffer, int action)); extern int number2arrows PARAMS((int number)); extern void parse_restrictions PARAMS((char *s)); extern void checkmail NOPARAMS; @@ -58,12 +57,22 @@ extern time_t LYmktime PARAMS((char *string, BOOL absolute)); extern int putenv PARAMS((CONST char *string)); #endif /* HAVE_PUTENV */ -FILE *LYNewBinFile PARAMS((char * name)); -FILE *LYNewTxtFile PARAMS((char * name)); -FILE *LYAppendToTxtFile PARAMS((char * name)); +extern FILE *LYNewBinFile PARAMS((char * name)); +extern FILE *LYNewTxtFile PARAMS((char * name)); +extern FILE *LYAppendToTxtFile PARAMS((char * name)); #ifdef UNIX extern void LYRelaxFilePermissions PARAMS((CONST char * name)); #endif +extern BOOLEAN LYCachedTemp PARAMS((char *result, char *cached)); +extern FILE *LYOpenTemp PARAMS((char *result, CONST char *suffix, CONST char *mode)); +extern FILE *LYReopenTemp PARAMS((char *name)); +extern FILE *LYOpenScratch PARAMS((char *result, CONST char *prefix)); +extern void LYCloseTemp PARAMS((char *name)); +extern void LYCloseTempFP PARAMS((FILE *fp)); +extern void LYRemoveTemp PARAMS((char *name)); +extern void LYCleanupTemp NOPARAMS; +extern void LYLocalFileToURL PARAMS((char *target, char *source)); + /* * Whether or not the status line must be shown. */ @@ -125,12 +134,6 @@ extern BOOLEAN mustshow; extern HTList *sug_filenames; /* - * For tempname(). - */ -#define NEW_FILE 0 -#define REMOVE_FILES 1 - -/* * Miscellaneous. */ #define ON 1 diff --git a/src/UCdomap.c b/src/UCdomap.c index 1e50a578..52617440 100644 --- a/src/UCdomap.c +++ b/src/UCdomap.c @@ -894,7 +894,7 @@ PRIVATE int conv_uni_to_pc ARGS2( * Not a printable character. */ return -1; - } else if (ucs == 0xfeff || (ucs >= 0x200a && ucs <= 0x200f)) { + } else if (ucs == 0xfeff || (ucs >= 0x200b && ucs <= 0x200f)) { /* * Zero-width space. */ @@ -959,7 +959,7 @@ PRIVATE int conv_uni_to_str ARGS4( * Not a printable character. */ return -1; - } else if (ucs == 0xfeff || (ucs >= 0x200a && ucs <= 0x200f)) { + } else if (ucs == 0xfeff || (ucs >= 0x200b && ucs <= 0x200f)) { /* * Zero-width space. */ diff --git a/test/raw8bit.html b/test/raw8bit.html index 6fcb75a1..d64cf65b 100644 --- a/test/raw8bit.html +++ b/test/raw8bit.html @@ -1,14 +1,19 @@ <HTML> <HEAD> <TITLE> Test of raw 8-bit symbols </TITLE> +<!-- you may uncomment the next line +and set the document's charset directly via META tag --> <!--META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"--> -<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> </HEAD> <BODY> <PRE> -This page has META HTTP-EQUIV="Content-Type" CONTENT= tag, -it currently corresponds to "text/html; charset=iso-8859-1". -To view another charset you may edit META with 'e' command. +This is a test of translation 8-bit letters for different pairs of +document's charset (assumed charset) and display charset, +both can be reached from 'O'ptions menu. + +This page (obviously) corresponds to text/html mode +but you may test text/plain just by pressing '\' +Try also: '@' for ``raw mode'' and '=' for Information Page. 0 1 2 3 4 5 6 7 8 9 A B C D E F @@ -17,7 +22,7 @@ To view another charset you may edit META with 'e' command. 40 @ A B C D E F G H I J K L M N O 50 P Q R S T U V W X Y Z [ \ ] ^ _ 60 ` a b c d e f g h i j k l m n o -70 p q r s t u v w x y z { | } ~ +70 p q r s t u v w x y z { | } ~ 80 90 A0 diff --git a/userdefs.h b/userdefs.h index 059f164c..b6f24a71 100644 --- a/userdefs.h +++ b/userdefs.h @@ -1202,7 +1202,7 @@ * the version definition with the Project Version on checkout. Just * ignore it. - kw */ /* $Format: "#define LYNX_VERSION \"$ProjectVersion$\""$ */ -#define LYNX_VERSION "2.8.1dev.12" +#define LYNX_VERSION "2.8.1dev.13" #ifndef MAXINT #define MAXINT 2147483647 /* max integer */ |