>> Sender: naddy@mips.rhein-neckar.de
>> If you call w3m without any arguments, you get a usage() output.
>> By now this help text is longer than 23 lines, which means it
>> doesn't fit on a standard terminal screen. However, if you try to
>> direct the usage message into a pager
>>
>> $ w3m 2>&1 | less
>>
>> all you get is "w3m: Can't redirect". You can't view the help text
>> (without going through some contortions)!
I already fixed it. I'm sorry to forget sending to w3m-dev-en ML.
Please try the following patch.
-----------------------------------
Hironori Sakamoto <hsaka@mth.biglobe.ne.jp>
http://www2u.biglobe.ne.jp/~hsaka/
--- main.c.orig Fri Jan 21 16:18:58 2000
+++ main.c Tue Jan 25 00:51:26 2000
@@ -338,21 +338,72 @@
Currentbuf = NULL;
if (BookmarkFile == NULL)
BookmarkFile = rcFile(BOOKMARK);
- if (load_bookmark || load_argc > 0) {
- /* if any arguments are given... */
- if (!w3m_dump && !w3m_halfdump)
- fmInit();
- if (w3m_halfdump)
- printf("<pre>\n");
- if (load_bookmark) {
+
+ if (!isatty(1) && !w3m_dump && !w3m_halfdump) { /* redirected output */
+ w3m_dump = T;
+ if (COLS == 0)
+ COLS = 80;
+ }
+ if (!w3m_dump && !w3m_halfdump)
+ fmInit();
+ if (w3m_halfdump)
+ printf("<pre>\n");
+
+ if (load_argc == 0) {
+ if (!isatty(0)) {
+ redin = fdopen(dup(0), "r");
+ newbuf = openGeneralPagerBuffer(redin);
+ dup2(1, 0);
+ } else if (load_bookmark) {
newbuf = loadGeneralFile(BookmarkFile, NULL,NO_REFERER,0,NULL);
- if (newbuf == NULL) {
- fprintf(stderr, "w3m: Can't load bookmark\n");
- } else {
- Firstbuf = Currentbuf = newbuf;
- }
+ if (newbuf == NULL)
+ fprintf(stderr, "w3m: Can't load bookmark\n");
+ } else if ((p = getenv("HTTP_HOME")) != NULL ||
+ (p = getenv("WWW_HOME")) != NULL) {
+ newbuf = loadGeneralFile(p,NULL,NO_REFERER,0,NULL);
+ if (newbuf == NULL)
+ fprintf(stderr, "w3m: Can't load %s\n", p);
+ } else if (visual_start) {
+ Str s_page;
+ s_page = Strnew_charp("<title>W3M startup page</title><center><b>Welcome to ");
+#ifdef JP_CHARSET
+ Strcat_charp(s_page,"<a href='http://ei5nazha.yz.yamagata-u.ac.jp/~aito/w3m/'>");
+#else
+ Strcat_charp(s_page,"<a href='http://ei5nazha.yz.yamagata-u.ac.jp/~aito/w3m/eng'>");
+#endif
+ Strcat_m_charp(s_page,
+ "w3m</a>!<p><p>This is w3m version ",
+ version,
+ "<br>Written by <a href='mailto:aito@ei5sun.yz.yamagata-u.ac.jp'>Akinori Ito</a>",
+ NULL);
+#ifdef DEBIAN
+ Strcat_m_charp(s_page,
+ "<p>Debian package is maintained by <a href='mailto:ukai@debian.or.jp'>Fumitoshi UKAI</a>.",
+ "You can read <a href='file:///usr/share/doc/w3m/'>w3m documents on your local system</a>.",
+ NULL);
+#endif
+ newbuf = loadHTMLString(s_page->ptr);
+ if (newbuf == NULL)
+ fprintf(stderr, "w3m: Can't load string\n");
+ else
+ newbuf->bufferprop |= (BP_INTERNAL | BP_NO_URL);
+ } else {
+ if (fmInitialized)
+ fmTerm();
+ usage();
}
- for (i = 0; i < load_argc; i++) {
+ if (newbuf == NULL) {
+ deleteFiles();
+ if (fmInitialized)
+ fmTerm();
+ exit(2);
+ }
+ i = -1;
+ } else {
+ i = 0;
+ }
+ for (; i < load_argc; i++) {
+ if (i >= 0) {
if (w3m_dump && w3m_dump_head) {
request = New(FormList);
request->method = FORM_METHOD_HEAD;
@@ -377,108 +428,39 @@
insertHist(URLHist, load_argv[i]);
break;
}
- if (w3m_halfdump) {
- Currentbuf = Firstbuf = newbuf;
- printf("</pre><title>%s</title>\n",newbuf->buffername);
- deleteFiles();
- exit(0);
- }
- if (w3m_dump) {
- Currentbuf = Firstbuf = newbuf;
- if (w3m_dump_source) {
- dump_source(Currentbuf);
- }
- else if (w3m_dump_head) {
- dump_head(Currentbuf);
- }
- else {
- if (Currentbuf->frameset != NULL && RenderFrame) {
- rFrame();
- }
- saveBuffer(Currentbuf,stdout);
- }
- deleteFiles();
-#ifdef USE_COOKIE
- save_cookies();
-#endif
- exit(0);
- }
- if (Currentbuf == NULL)
- Firstbuf = Currentbuf = newbuf;
- else {
- Currentbuf->nextBuffer = newbuf;
- Currentbuf = newbuf;
- }
- if (Currentbuf->frameset != NULL && RenderFrame) {
- rFrame();
- Currentbuf = newbuf;
- }
}
- }
- else {
- /* When no arguments other than options are given... */
- if (!isatty(1) || w3m_dump) { /* redirected output */
- if (isatty(0)) {
- fprintf(stderr, "w3m: Can't redirect\n");
- exit(1);
- }
- /* when -T option is given, behave as an HTML formatter */
- newbuf = openGeneralPagerBuffer(stdin);
- if (newbuf != NO_BUFFER) {
- saveBuffer(newbuf,stdout);
- discardBuffer(newbuf);
- }
+ if (w3m_halfdump) {
+ Currentbuf = Firstbuf = newbuf;
+ printf("</pre><title>%s</title>\n",newbuf->buffername);
deleteFiles();
exit(0);
}
- if (!isatty(0)) { /* redirected input */
- fmInit();
- redin = fdopen(dup(0), "r");
- newbuf = openGeneralPagerBuffer(redin);
- dup2(1, 0);
- Firstbuf = Currentbuf = newbuf;
- }
- }
-
- if ((Firstbuf == NULL) && (newbuf == NULL) &&
- (((p = getenv("HTTP_HOME")) != NULL) ||
- ((p = getenv("WWW_HOME")) != NULL))) {
- fmInit();
- newbuf = loadGeneralFile(p,NULL,NO_REFERER,0,NULL);
- if (newbuf == NULL)
- fprintf(stderr, "w3m: Can't load %s\n", p);
+ if (w3m_dump) {
+ Currentbuf = Firstbuf = newbuf;
+ if (w3m_dump_source)
+ dump_source(Currentbuf);
+ else if (w3m_dump_head)
+ dump_head(Currentbuf);
else {
- Firstbuf = Currentbuf = newbuf;
- if (Currentbuf->frameset != NULL && RenderFrame)
+ if (Currentbuf->frameset != NULL && RenderFrame)
rFrame();
+ saveBuffer(Currentbuf,stdout);
}
- }
- if ((Firstbuf == NULL) && (newbuf == NULL) && visual_start) {
- Str s_page;
- fmInit();
- s_page = Strnew_charp("<title>W3M startup page</title><center><b>Welcome to ");
-#ifdef JP_CHARSET
- Strcat_charp(s_page,"<a href='http://ei5nazha.yz.yamagata-u.ac.jp/~aito/w3m/'>");
-#else
- Strcat_charp(s_page,"<a href='http://ei5nazha.yz.yamagata-u.ac.jp/~aito/w3m/eng'>");
-#endif
- Strcat_m_charp(s_page,
- "w3m</a>!<p><p>This is w3m version ",
- version,
- "<br>Written by <a href='mailto:aito@ei5sun.yz.yamagata-u.ac.jp'>Akinori Ito</a>",
- NULL);
-#ifdef DEBIAN
- Strcat_m_charp(s_page,
- "<p>Debian package is maintained by <a href='mailto:ukai@debian.or.jp'>Fumitoshi UKAI</a>.",
- "You can read <a href='file:///usr/share/doc/w3m/'>w3m documents on your local system</a>.",
- NULL);
+ deleteFiles();
+#ifdef USE_COOKIE
+ save_cookies();
#endif
- newbuf = loadHTMLString(s_page->ptr);
- if (newbuf == NULL)
- fprintf(stderr, "w3m: Can't load string\n");
+ exit(0);
+ }
+ if (Currentbuf == NULL)
+ Firstbuf = Currentbuf = newbuf;
else {
- newbuf->bufferprop |= (BP_INTERNAL | BP_NO_URL);
- Firstbuf = Currentbuf = newbuf;
+ Currentbuf->nextBuffer = newbuf;
+ Currentbuf = newbuf;
+ }
+ if (Currentbuf->frameset != NULL && RenderFrame) {
+ rFrame();
+ Currentbuf = newbuf;
}
}
if (Firstbuf == NULL) {
@@ -488,9 +470,11 @@
quitfm();
}
deleteFiles();
- fmTerm();
- usage();
+ if (fmInitialized)
+ fmTerm();
+ exit(2);
}
+
#ifdef SIGWINCH
signal(SIGWINCH, resize_hook);
#endif
This archive was generated by hypermail 2b29 : Wed Jul 19 2000 - 10:30:43 CDT