commit cfa0d9c8662f2bb61df81a6c83d3d84520dfaea4
parent 912d370d6eba229fa9460a466f111859b2874b65
Author: ukai <ukai>
Date: Wed, 22 Jan 2003 16:16:18 +0000
[w3m-dev 03677] view source, edit source
* buffer.c (discardBuffer): unlink header source
* file.c (loadFile): delete skip header
* fm.h (BP_SOURCE): deleted
(SkipHeader): deleted
* main (editBf): cleanup
(vmSrc): cleanup
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
Diffstat:
5 files changed, 29 insertions(+), 91 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,5 +1,15 @@
2003-01-23 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
+ * [w3m-dev 03677] view source, edit source
+ * buffer.c (discardBuffer): unlink header source
+ * file.c (loadFile): delete skip header
+ * fm.h (BP_SOURCE): deleted
+ (SkipHeader): deleted
+ * main (editBf): cleanup
+ (vmSrc): cleanup
+
+2003-01-23 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
+
* [w3m-dev 03676] cleanup for pipe
* etc.c (open_pipe_rw): added
* file.c (uncompress_stream): rewrite using open_pipe_rw
diff --git a/buffer.c b/buffer.c
@@ -102,6 +102,8 @@ discardBuffer(Buffer *buf)
if (buf->real_scheme != SCM_LOCAL || buf->bufferprop & BP_FRAME)
unlink(buf->sourcefile);
}
+ if (buf->header_source)
+ unlink(buf->header_source);
if (buf->mailcap_source)
unlink(buf->mailcap_source);
while (buf->frameset) {
diff --git a/file.c b/file.c
@@ -497,8 +497,6 @@ loadFile(char *path)
if (uf.stream == NULL)
return NULL;
buf = newBuffer(INIT_BUFFER_WIDTH);
- if (SkipHeader)
- readHeader(&uf, buf, TRUE, NULL);
current_content_length = 0;
#ifdef JP_CHARSET
content_charset = '\0';
@@ -1955,11 +1953,6 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,
if (real_type == NULL)
real_type = t;
- if (SkipHeader) {
- if (t_buf == NULL)
- t_buf = newBuffer(INIT_BUFFER_WIDTH);
- readHeader(&f, t_buf, TRUE, NULL);
- }
proc = loadBuffer;
#ifdef USE_IMAGE
cur_baseURL = New(ParsedURL);
diff --git a/fm.h b/fm.h
@@ -172,7 +172,6 @@ void bzero(void *, int);
#define BP_NORMAL 0x0
#define BP_PIPE 0x1
#define BP_FRAME 0x2
-#define BP_SOURCE 0x4
#define BP_INTERNAL 0x8
#define BP_NO_URL 0x10
#define BP_REDIRECTED 0x20
@@ -766,7 +765,6 @@ global char InnerCode init(CODE_INNER_EUC); /* use EUC-JP internally; do not cha
#endif /* JP_CHARSET */
global char SearchHeader init(FALSE);
-global char SkipHeader init(FALSE);
global char *DefaultType init(NULL);
global char RenderFrame init(FALSE);
global char TargetSelf init(FALSE);
diff --git a/main.c b/main.c
@@ -2471,10 +2471,6 @@ void
editBf(void)
{
char *fn = Currentbuf->filename;
- Buffer *buf, *fbuf = NULL, sbuf;
-#ifdef JP_CHARSET
- char old_code;
-#endif
Str cmd;
if (fn == NULL || Currentbuf->pagerSource != NULL || /* Behaving as a pager */
@@ -2484,9 +2480,6 @@ editBf(void)
disp_err_message("Can't edit other than local file", TRUE);
return;
}
- if (Currentbuf->frameset != NULL)
- fbuf = Currentbuf->linkBuffer[LB_FRAME];
- copyBuffer(&sbuf, Currentbuf);
if (Currentbuf->edit)
cmd = unquote_mailcap(Currentbuf->edit, Currentbuf->real_type, fn,
checkHeader(Currentbuf, "Content-Type:"), NULL);
@@ -2496,42 +2489,8 @@ editBf(void)
system(cmd->ptr);
fmInit();
-#ifdef JP_CHARSET
- old_code = DocumentCode;
- DocumentCode = Currentbuf->document_code;
-#endif
- SearchHeader = Currentbuf->search_header;
- DefaultType = Currentbuf->real_type;
- buf = loadGeneralFile(file_to_url(fn), NULL, NO_REFERER, 0, NULL);
-#ifdef JP_CHARSET
- DocumentCode = old_code;
-#endif
- SearchHeader = FALSE;
- DefaultType = NULL;
-
- if (buf == NULL) {
- disp_err_message("Re-loading failed", FALSE);
- buf = nullBuffer();
- }
- else if (buf == NO_BUFFER) {
- buf = nullBuffer();
- }
- if (fbuf != NULL)
- Firstbuf = deleteBuffer(Firstbuf, fbuf);
- repBuffer(Currentbuf, buf);
- if ((buf->type != NULL) && (sbuf.type != NULL) &&
- ((!strcasecmp(buf->type, "text/plain") &&
- !strcasecmp(sbuf.type, "text/html")) ||
- (!strcasecmp(buf->type, "text/html") &&
- !strcasecmp(sbuf.type, "text/plain")))) {
- vwSrc();
- if (Currentbuf != buf)
- Firstbuf = deleteBuffer(Firstbuf, buf);
- }
- Currentbuf->search_header = sbuf.search_header;
- if (Currentbuf->firstLine)
- restorePosition(Currentbuf, &sbuf);
displayBuffer(Currentbuf, B_FORCE_REDRAW);
+ reload();
}
/* Run editor on the current screen */
@@ -4393,7 +4352,6 @@ curURL(void)
void
vwSrc(void)
{
- char *fn;
Buffer *buf;
if (Currentbuf->type == NULL || Currentbuf->bufferprop & BP_FRAME)
@@ -4414,78 +4372,55 @@ vwSrc(void)
return;
saveBuffer(Currentbuf, f);
fclose(f);
- fn = tmpf->ptr;
- Currentbuf->sourcefile = fn;
+ Currentbuf->sourcefile = tmpf->ptr;
}
else {
return;
}
}
- else if (Currentbuf->real_scheme == SCM_LOCAL &&
- !(Currentbuf->real_type &&
- !strcasecmp(Currentbuf->real_type, "local:directory"))) {
- fn = Currentbuf->filename;
- }
- else {
- fn = Currentbuf->sourcefile;
- }
+
+ buf = newBuffer(INIT_BUFFER_WIDTH);
+
if (!strcasecmp(Currentbuf->type, "text/html")) {
-#ifdef JP_CHARSET
- char old_code = DocumentCode;
- DocumentCode = Currentbuf->document_code;
-#endif
- SkipHeader = Currentbuf->search_header;
- buf = loadFile(fn);
-#ifdef JP_CHARSET
- DocumentCode = old_code;
-#endif
- SkipHeader = FALSE;
- if (buf == NULL)
- return;
- buf->search_header = Currentbuf->search_header;
buf->type = "text/plain";
if (Currentbuf->real_type &&
!strcasecmp(Currentbuf->real_type, "text/html"))
buf->real_type = "text/plain";
else
buf->real_type = Currentbuf->real_type;
- buf->bufferprop |= BP_SOURCE;
buf->buffername = Sprintf("source of %s", Currentbuf->buffername)->ptr;
buf->linkBuffer[LB_N_SOURCE] = Currentbuf;
Currentbuf->linkBuffer[LB_SOURCE] = buf;
}
else if (!strcasecmp(Currentbuf->type, "text/plain")) {
- SkipHeader = Currentbuf->search_header;
- DefaultType = "text/html";
- buf = loadGeneralFile(file_to_url(fn), NULL, NO_REFERER, 0, NULL);
- SkipHeader = FALSE;
- DefaultType = NULL;
- if (buf == NULL || buf == NO_BUFFER)
- return;
- buf->search_header = Currentbuf->search_header;
+ buf->type = "text/html";
if (Currentbuf->real_type &&
!strcasecmp(Currentbuf->real_type, "text/plain"))
buf->real_type = "text/html";
else
buf->real_type = Currentbuf->real_type;
- if (!strcmp(buf->buffername, conv_from_system(lastFileName(fn))))
- buf->buffername =
- Sprintf("HTML view of %s", Currentbuf->buffername)->ptr;
+ buf->buffername = Sprintf("HTML view of %s",
+ Currentbuf->buffername)->ptr;
buf->linkBuffer[LB_SOURCE] = Currentbuf;
Currentbuf->linkBuffer[LB_N_SOURCE] = buf;
-#ifdef USE_IMAGE
- if (buf->img)
- buf->need_reshape = TRUE;
-#endif
}
else {
return;
}
buf->currentURL = Currentbuf->currentURL;
buf->real_scheme = Currentbuf->real_scheme;
+ buf->filename = Currentbuf->filename;
buf->sourcefile = Currentbuf->sourcefile;
+ buf->header_source = Currentbuf->header_source;
+ buf->search_header = Currentbuf->search_header;
+#ifdef JP_CHARSET
+ buf->document_code = Currentbuf->document_code;
+#endif
buf->clone = Currentbuf->clone;
(*buf->clone)++;
+
+ buf->need_reshape = TRUE;
+ reshapeBuffer(buf);
pushBuffer(buf);
displayBuffer(Currentbuf, B_NORMAL);
}