aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2022-07-26 14:39:20 +0000
committerThomas E. Dickey <dickey@invisible-island.net>2022-07-26 14:39:20 +0000
commit09edd94f131ec64c31b17cb3a26fa0a8069af9c6 (patch)
treefc73781c5955ddea8742eb6eaf180877e2c98a0f /src
parenta6450adbbd8476f8df51dfe13818268b88d615b5 (diff)
downloadlynx-snapshots-09edd94f131ec64c31b17cb3a26fa0a8069af9c6.tar.gz
snapshot of project "lynx", label v2-9-0dev_10k
Diffstat (limited to 'src')
-rw-r--r--src/LYBookmark.c55
-rw-r--r--src/LYUtils.c7
2 files changed, 50 insertions, 12 deletions
diff --git a/src/LYBookmark.c b/src/LYBookmark.c
index 47531b13..69622d4a 100644
--- a/src/LYBookmark.c
+++ b/src/LYBookmark.c
@@ -1,5 +1,5 @@
/*
- * $LynxId: LYBookmark.c,v 1.81 2022/04/02 00:12:18 Paul.G.Fox Exp $
+ * $LynxId: LYBookmark.c,v 1.86 2022/07/26 14:39:20 tom Exp $
*/
#include <HTUtils.h>
#include <HTAlert.h>
@@ -17,6 +17,10 @@
#include <GridText.h>
#include <HTCJK.h>
+#ifdef _WINDOWS
+#include <io.h> /* for _chsize() */
+#endif
+
#ifdef VMS
#include <nam.h>
#endif /* VMS */
@@ -176,10 +180,10 @@ static const char *convert_mosaic_bookmark_file(const char *filename_buffer)
if ((line % 2) == 0) { /* even lines */
if (*buf != '\0') {
strtok(buf, " "); /* kill everything after the space */
- fprintf(nfp, "<LI><a href=\"%s\">", buf); /* the URL */
+ fprintf(nfp, "<li><a href=\"%s\">", buf); /* the URL */
}
} else { /* odd lines */
- fprintf(nfp, "%s</a>\n", buf); /* the title */
+ fprintf(nfp, "%s</a></li>\n", buf); /* the title */
}
}
/* else - ignore the line (this gets rid of first two lines) */
@@ -194,6 +198,10 @@ static BOOLEAN havevisible(const char *Title);
static BOOLEAN have8bit(const char *Title);
static char *title_convert8bit(const char *Title);
+#ifdef _WINDOWS
+#define ftruncate(fd, len) _chsize(fd, len)
+#endif
+
/*
* Adds a link to a bookmark file, creating the file if it doesn't already
* exist, and making sure that no_cache is set for a pre-existing, cached file,
@@ -358,28 +366,58 @@ void save_bookmark_link(const char *address,
StrAllocCopy(Address, address);
LYEntify(&Address, FALSE);
+ if (!first_time) {
+ BOOLEAN empty_file = TRUE;
+ FILE *bp = tmpfile();
+ char *buffer = NULL;
+
+ while (LYSafeGets(&buffer, fp)) {
+ empty_file = FALSE;
+ if (LYstrstr(buffer, "</ol>"))
+ break;
+ fprintf(bp, "%s", buffer);
+ }
+
+ fflush(bp);
+ rewind(bp);
+
+ rewind(fp);
+ ftruncate(fileno(fp), 0);
+
+ while (LYSafeGets(&buffer, bp)) {
+ fprintf(fp, "%s", buffer);
+ }
+ fclose(bp);
+
+ if (empty_file)
+ first_time = TRUE;
+ }
+
/*
* If we created a new bookmark file, write the headers. - FM
* Once and forever...
*/
if (first_time) {
+ fprintf(fp, "%s\n", LYNX_DOCTYPE);
+ fprintf(fp, "<html>\n");
fprintf(fp, "<head>\n");
#if defined(SH_EX) && !defined(_WINDOWS) /* 1997/12/11 (Thu) 19:13:40 */
if (HTCJK != JAPANESE)
LYAddMETAcharsetToFD(fp, -1);
else
- fprintf(fp, "<META %s %s>\n",
+ fprintf(fp, "<meta %s %s>\n",
"http-equiv=\"content-type\"",
"content=\"" STR_HTML ";charset=iso-2022-jp\"");
#else
LYAddMETAcharsetToFD(fp, -1);
#endif /* !_WINDOWS */
fprintf(fp, "<title>%s</title>\n</head>\n", BOOKMARK_TITLE);
+ fprintf(fp, "<body>\n");
#ifdef _WINDOWS
- fprintf(fp,
+ fprintf(fp, "<p>%s",
gettext(" You can delete links by the 'R' key<br>\n<ol>\n"));
#else
- fprintf(fp, "%s<br>\n%s\n\n<!--\n%s\n-->\n\n<p>\n<ol>\n",
+ fprintf(fp, "<p>%s<br>\n%s\n\n<!--\n%s\n--></p>\n\n<ol>\n",
gettext("\
You can delete links using the remove bookmark command. It is usually\n\
the 'R' key but may have been remapped by you or your system\n\
@@ -407,7 +445,8 @@ Note: if you edit this file manually\n\
*/
fprintf(fp, "%s %s%s\n", Address, TimeString, Title);
} else {
- fprintf(fp, "<LI><a href=\"%s\">%s</a>\n", Address, Title);
+ fprintf(fp, "<li><a href=\"%s\">%s</a></li>\n", Address, Title);
+ fprintf(fp, "</ol></body></html>\n");
}
LYCloseOutput(fp);
@@ -536,7 +575,7 @@ void remove_bookmark_link(int cur,
retain = TRUE;
seen = 0;
cp = buf;
- if ((cur == 0) && LYstrstr(cp, "<ol><LI>"))
+ if ((cur == 0) && LYstrstr(cp, "<ol><li>"))
keep_ol = TRUE; /* Do not erase, this corrects a bug in an
older version */
while (n < cur && (cp = LYstrstr(cp, "<a href="))) {
diff --git a/src/LYUtils.c b/src/LYUtils.c
index 0838c78c..414fb26b 100644
--- a/src/LYUtils.c
+++ b/src/LYUtils.c
@@ -1,5 +1,5 @@
/*
- * $LynxId: LYUtils.c,v 1.300 2021/10/24 16:25:12 tom Exp $
+ * $LynxId: LYUtils.c,v 1.301 2022/07/25 07:52:04 tom Exp $
*/
#include <HTUtils.h>
#include <HTTCP.h>
@@ -6812,7 +6812,6 @@ void LYLocalFileToURL(char **target,
StrAllocCat(*target, leaf);
}
-#define MY_DOCTYPE "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"
#define PUT_STRING(buf) (*(target)->isa->put_string)(target, buf)
/*
@@ -6823,7 +6822,7 @@ void WriteStreamTitle(HTStream *target, const char *Title)
{
char *buf = 0;
- PUT_STRING(MY_DOCTYPE);
+ PUT_STRING(LYNX_DOCTYPE);
PUT_STRING("<html>\n<head>\n");
LYAddMETAcharsetToStream(target, -1);
HTSprintf0(&buf, "<title>%s</title>\n</head>\n<body>\n", Title);
@@ -6857,7 +6856,7 @@ FILE *InternalPageFP(char *filename,
*/
void WriteInternalTitle(FILE *fp0, const char *Title)
{
- fprintf(fp0, MY_DOCTYPE);
+ fprintf(fp0, LYNX_DOCTYPE);
fprintf(fp0, "<html>\n<head>\n");
LYAddMETAcharsetToFD(fp0, -1);