From 68a07bf03b7624c9924065cce9ffa45497225834 Mon Sep 17 00:00:00 2001 From: Akinori Ito Date: Thu, 8 Nov 2001 05:14:08 +0000 Subject: Initial revision --- Bonus/README | 48 + Bonus/README.eng | 49 + Bonus/html2latex | 517 ++++ Bonus/htmldump | 12 + Bonus/makeref | 266 ++ Bonus/scanhist.rb | 88 + Bonus/wrap3m | 33 + Makefile | 42 + Patches/alpha | 19 + Patches/armlinux | 110 + Patches/ews4800 | 34 + Patches/hpux11 | 25 + Patches/linux2.2sparc | 10 + Patches/macosx | 41 + Patches/macppc | 147 + Patches/mipsel | 184 ++ Patches/newsos6 | 27 + Patches/os2 | 39 + README | 3 + Str.c | 556 ++++ Str.h | 83 + XMakefile | 106 + XMakefile.dist | 106 + XXMakefile | 128 + anchor.c | 420 +++ backend.c | 405 +++ buffer.c | 676 +++++ config.h | 201 ++ configure | 1712 +++++++++++ conv.c | 699 +++++ cookie.c | 697 +++++ ctrlcode.h | 153 + dict.c | 137 + display.c | 1064 +++++++ doc-jp/FAQ.html | 238 ++ doc-jp/HISTORY | 4273 +++++++++++++++++++++++++++ doc-jp/HISTORY.kokb | 1220 ++++++++ doc-jp/MANUAL.html | 524 ++++ doc-jp/README | 111 + doc-jp/README.SSL | 46 + doc-jp/README.cookie | 56 + doc-jp/README.cygwin | 27 + doc-jp/README.dict | 41 + doc-jp/README.func | 85 + doc-jp/README.hp | 28 + doc-jp/README.keymap | 58 + doc-jp/README.kokb | 0 doc-jp/README.mailcap | 45 + doc-jp/README.menu | 99 + doc-jp/STORY.html | 190 ++ doc-jp/keymap.default | 115 + doc-jp/keymap.lynx | 109 + doc-jp/menu.default | 33 + doc-jp/menu.submenu | 44 + doc-jp/w3m.1 | 443 +++ doc/FAQ.html | 278 ++ doc/HISTORY | 1989 +++++++++++++ doc/MANUAL.html | 504 ++++ doc/README | 106 + doc/README.cygwin | 18 + doc/README.dict | 39 + doc/README.func | 85 + doc/STORY.html | 209 ++ doc/history | 1750 +++++++++++ doc/keymap.default | 115 + doc/keymap.lynx | 109 + doc/menu.default | 33 + doc/menu.submenu | 44 + doc/w3m.1 | 134 + etc.c | 1493 ++++++++++ file.c | 6002 ++++++++++++++++++++++++++++++++++++++ fm.h | 814 ++++++ form.c | 590 ++++ form.h | 96 + frame.c | 789 +++++ frame.h | 56 + ftp.c | 871 ++++++ func.c | 356 +++ func.h | 28 + funcname.c | 98 + funcname.tab | 97 + funcname0.awk | 13 + funcname1.awk | 10 + funcname1.h | 83 + funcname2.awk | 10 + funcname2.h | 83 + gc/BCC_MAKEFILE | 82 + gc/EMX_MAKEFILE | 141 + gc/MacOS.c | 154 + gc/MacProjects.sit.hqx | 886 ++++++ gc/Mac_files/MacOS_Test_config.h | 91 + gc/Mac_files/MacOS_config.h | 89 + gc/Mac_files/dataend.c | 9 + gc/Mac_files/datastart.c | 9 + gc/Makefile | 445 +++ gc/Makefile.DLLs | 107 + gc/Makefile.dj | 436 +++ gc/NT_MAKEFILE | 59 + gc/OS2_MAKEFILE | 45 + gc/PCR-Makefile | 68 + gc/README | 1517 ++++++++++ gc/README.Mac | 385 +++ gc/README.OS2 | 6 + gc/README.QUICK | 41 + gc/README.alpha | 22 + gc/README.amiga | 180 ++ gc/README.debugging | 58 + gc/README.dj | 12 + gc/README.hp | 11 + gc/README.linux | 50 + gc/README.rs6000 | 9 + gc/README.sgi | 41 + gc/README.solaris2 | 65 + gc/README.uts | 2 + gc/README.win32 | 149 + gc/SCoptions.amiga | 16 + gc/SMakefile.amiga | 48 + gc/WCC_MAKEFILE | 196 ++ gc/add_gc_prefix.c | 14 + gc/allchblk.c | 726 +++++ gc/alloc.c | 884 ++++++ gc/alpha_mach_dep.s | 60 + gc/backptr.h | 56 + gc/barrett_diagram | 106 + gc/base_lib | 1 + gc/blacklst.c | 291 ++ gc/callprocs | 4 + gc/checksums.c | 201 ++ gc/cord/README | 31 + gc/cord/SCOPTIONS.amiga | 14 + gc/cord/SMakefile.amiga | 20 + gc/cord/cord.h | 327 +++ gc/cord/cordbscs.c | 915 ++++++ gc/cord/cordprnt.c | 390 +++ gc/cord/cordtest.c | 228 ++ gc/cord/cordxtra.c | 621 ++++ gc/cord/de.c | 603 ++++ gc/cord/de_cmds.h | 33 + gc/cord/de_win.ICO | Bin 0 -> 766 bytes gc/cord/de_win.RC | 78 + gc/cord/de_win.c | 366 +++ gc/cord/de_win.h | 103 + gc/cord/ec.h | 70 + gc/cord/gc.h | 754 +++++ gc/cord/private/cord_pos.h | 118 + gc/dbg_mlc.c | 799 +++++ gc/dyn_load.c | 799 +++++ gc/finalize.c | 758 +++++ gc/gc.h | 754 +++++ gc/gc.mak | 2087 +++++++++++++ gc/gc.man | 80 + gc/gc_alloc.h | 380 +++ gc/gc_copy_descr.h | 26 + gc/gc_cpp.cc | 60 + gc/gc_cpp.h | 290 ++ gc/gc_hdrs.h | 135 + gc/gc_mark.h | 280 ++ gc/gc_priv.h | 1748 +++++++++++ gc/gc_private.h | 1 + gc/gc_typed.h | 91 + gc/gcc_support.c | 516 ++++ gc/gcconfig.h | 1110 +++++++ gc/headers.c | 351 +++ gc/if_mach.c | 25 + gc/if_not_there.c | 26 + gc/include/backptr.h | 56 + gc/include/cord.h | 327 +++ gc/include/ec.h | 70 + gc/include/gc.h | 754 +++++ gc/include/gc_alloc.h | 380 +++ gc/include/gc_cpp.h | 290 ++ gc/include/gc_inl.h | 103 + gc/include/gc_inline.h | 1 + gc/include/gc_typed.h | 91 + gc/include/javaxfc.h | 41 + gc/include/leak_detector.h | 7 + gc/include/new_gc_alloc.h | 456 +++ gc/include/private/cord_pos.h | 118 + gc/include/private/gc_hdrs.h | 135 + gc/include/private/gc_priv.h | 1748 +++++++++++ gc/include/private/gcconfig.h | 1099 +++++++ gc/include/weakpointer.h | 221 ++ gc/irix_threads.c | 674 +++++ gc/linux_threads.c | 665 +++++ gc/mach_dep.c | 461 +++ gc/makefile.depend | 0 gc/malloc.c | 443 +++ gc/mallocx.c | 375 +++ gc/mark.c | 1161 ++++++++ gc/mark_rts.c | 484 +++ gc/mips_sgi_mach_dep.s | 40 + gc/mips_ultrix_mach_dep.s | 26 + gc/misc.c | 829 ++++++ gc/new_hblk.c | 244 ++ gc/nursery.c | 175 ++ gc/nursery.h | 90 + gc/obj_map.c | 142 + gc/os_dep.c | 2461 ++++++++++++++++ gc/pc_excludes | 15 + gc/pcr_interface.c | 173 ++ gc/ptr_chck.c | 326 +++ gc/real_malloc.c | 36 + gc/reclaim.c | 739 +++++ gc/rs6000_mach_dep.s | 105 + gc/setjmp_t.c | 115 + gc/solaris_pthreads.c | 172 ++ gc/solaris_threads.c | 940 ++++++ gc/solaris_threads.h | 34 + gc/sparc_mach_dep.s | 38 + gc/sparc_sunos4_mach_dep.s | 38 + gc/stubborn.c | 317 ++ gc/test.c | 1263 ++++++++ gc/test_cpp.cc | 265 ++ gc/threadlibs.c | 14 + gc/typd_mlc.c | 814 ++++++ gc/version.h | 11 + gc/weakpointer.h | 221 ++ gc/win32_threads.c | 209 ++ gcmain.c | 27 + hash.c | 26 + hash.h | 82 + history.c | 196 ++ history.h | 29 + html.c | 284 ++ html.h | 325 +++ indep.c | 736 +++++ indep.h | 43 + install.sh | 33 + islang.c | 37 + istream.c | 481 +++ istream.h | 153 + keybind.c | 198 ++ keybind_lynx.c | 149 + linein.c | 1009 +++++++ local.c | 388 +++ local.h | 44 + mailcap.c | 324 ++ main.c | 3990 +++++++++++++++++++++++++ makeallmodel | 20 + map.c | 222 ++ matrix.c | 276 ++ matrix.h | 73 + menu.c | 1547 ++++++++++ menu.h | 53 + mimehead.c | 306 ++ mktable.c | 115 + myctype.c | 51 + myctype.h | 45 + parsetag.c | 56 + parsetag.h | 12 + parsetagx.c | 273 ++ parsetagx.h | 28 + proto.h | 514 ++++ rc.c | 1256 ++++++++ rcparams.h | 76 + regex.c | 433 +++ regex.h | 56 + scripts/bm2menu.pl | 54 + scripts/dirlist.cgi | 501 ++++ scripts/dirlist.in | 501 ++++ scrsize.c | 73 + search.c | 147 + table.c | 3328 +++++++++++++++++++++ table.c.0 | 2878 ++++++++++++++++++ table.h | 147 + tagtable.c | 261 ++ tagtable.tab | 154 + terms.c | 1839 ++++++++++++ terms.h | 38 + textlist.c | 139 + textlist.h | 73 + url.c | 1784 +++++++++++ version.c | 5 + w3m-doc/README.html | 75 + w3m-doc/community.html.in | 45 + w3m-doc/configuration.html.in | 90 + w3m-doc/contain.wd | 14 + w3m-doc/copyright.html.in | 45 + w3m-doc/define.wd | 4 + w3m-doc/detail.html.in | 32 + w3m-doc/developement.html.in | 77 + w3m-doc/faq.html.in | 45 + w3m-doc/function.html.in | 71 + w3m-doc/index.html.in | 113 + w3m-doc/install.html.in | 88 + w3m-doc/mkdocs | 32 + w3m-doc/operation.html.in | 50 + w3m-doc/outline.html.in | 61 + w3m-doc/prologue.html.in | 69 + w3m-doc/sample/README | 41 + w3m-doc/sample/define.wd | 4 + w3m-doc/sample/html.wd | 18 + w3m-doc/sample/keymap.cgi | 268 ++ w3m-doc/sample/s.wd | 8 + w3m-doc/sample/sample.html | 6 + w3m-doc/sample/sample.wd | 11 + w3m-doc/sample/w3mdoc.pl | 102 + w3m-doc/w3mdoc.pl | 102 + w3mbookmark.c | 239 ++ w3mhelp-lynx_en.html | 133 + w3mhelp-lynx_ja.html | 143 + w3mhelp-w3m_en.html | 132 + w3mhelp-w3m_ja.html | 132 + w3mhelperpanel.c | 195 ++ which | 11 + 305 files changed, 104639 insertions(+) create mode 100644 Bonus/README create mode 100644 Bonus/README.eng create mode 100755 Bonus/html2latex create mode 100755 Bonus/htmldump create mode 100755 Bonus/makeref create mode 100644 Bonus/scanhist.rb create mode 100755 Bonus/wrap3m create mode 100644 Makefile create mode 100644 Patches/alpha create mode 100644 Patches/armlinux create mode 100644 Patches/ews4800 create mode 100644 Patches/hpux11 create mode 100644 Patches/linux2.2sparc create mode 100644 Patches/macosx create mode 100644 Patches/macppc create mode 100644 Patches/mipsel create mode 100644 Patches/newsos6 create mode 100644 Patches/os2 create mode 100644 README create mode 100644 Str.c create mode 100644 Str.h create mode 100644 XMakefile create mode 100644 XMakefile.dist create mode 100644 XXMakefile create mode 100644 anchor.c create mode 100644 backend.c create mode 100644 buffer.c create mode 100644 config.h create mode 100755 configure create mode 100644 conv.c create mode 100644 cookie.c create mode 100644 ctrlcode.h create mode 100644 dict.c create mode 100644 display.c create mode 100644 doc-jp/FAQ.html create mode 100644 doc-jp/HISTORY create mode 100644 doc-jp/HISTORY.kokb create mode 100644 doc-jp/MANUAL.html create mode 100644 doc-jp/README create mode 100644 doc-jp/README.SSL create mode 100644 doc-jp/README.cookie create mode 100644 doc-jp/README.cygwin create mode 100644 doc-jp/README.dict create mode 100644 doc-jp/README.func create mode 100644 doc-jp/README.hp create mode 100644 doc-jp/README.keymap create mode 100644 doc-jp/README.kokb create mode 100644 doc-jp/README.mailcap create mode 100644 doc-jp/README.menu create mode 100644 doc-jp/STORY.html create mode 100644 doc-jp/keymap.default create mode 100644 doc-jp/keymap.lynx create mode 100644 doc-jp/menu.default create mode 100644 doc-jp/menu.submenu create mode 100644 doc-jp/w3m.1 create mode 100644 doc/FAQ.html create mode 100644 doc/HISTORY create mode 100644 doc/MANUAL.html create mode 100644 doc/README create mode 100644 doc/README.cygwin create mode 100644 doc/README.dict create mode 100644 doc/README.func create mode 100644 doc/STORY.html create mode 100644 doc/history create mode 100644 doc/keymap.default create mode 100644 doc/keymap.lynx create mode 100644 doc/menu.default create mode 100644 doc/menu.submenu create mode 100644 doc/w3m.1 create mode 100644 etc.c create mode 100644 file.c create mode 100644 fm.h create mode 100644 form.c create mode 100644 form.h create mode 100644 frame.c create mode 100644 frame.h create mode 100644 ftp.c create mode 100644 func.c create mode 100644 func.h create mode 100644 funcname.c create mode 100644 funcname.tab create mode 100644 funcname0.awk create mode 100644 funcname1.awk create mode 100644 funcname1.h create mode 100644 funcname2.awk create mode 100644 funcname2.h create mode 100644 gc/BCC_MAKEFILE create mode 100644 gc/EMX_MAKEFILE create mode 100644 gc/MacOS.c create mode 100644 gc/MacProjects.sit.hqx create mode 100644 gc/Mac_files/MacOS_Test_config.h create mode 100644 gc/Mac_files/MacOS_config.h create mode 100644 gc/Mac_files/dataend.c create mode 100644 gc/Mac_files/datastart.c create mode 100644 gc/Makefile create mode 100644 gc/Makefile.DLLs create mode 100644 gc/Makefile.dj create mode 100644 gc/NT_MAKEFILE create mode 100644 gc/OS2_MAKEFILE create mode 100644 gc/PCR-Makefile create mode 100644 gc/README create mode 100644 gc/README.Mac create mode 100644 gc/README.OS2 create mode 100644 gc/README.QUICK create mode 100644 gc/README.alpha create mode 100644 gc/README.amiga create mode 100644 gc/README.debugging create mode 100644 gc/README.dj create mode 100644 gc/README.hp create mode 100644 gc/README.linux create mode 100644 gc/README.rs6000 create mode 100644 gc/README.sgi create mode 100644 gc/README.solaris2 create mode 100644 gc/README.uts create mode 100644 gc/README.win32 create mode 100644 gc/SCoptions.amiga create mode 100644 gc/SMakefile.amiga create mode 100644 gc/WCC_MAKEFILE create mode 100644 gc/add_gc_prefix.c create mode 100644 gc/allchblk.c create mode 100644 gc/alloc.c create mode 100644 gc/alpha_mach_dep.s create mode 100644 gc/backptr.h create mode 100644 gc/barrett_diagram create mode 100644 gc/base_lib create mode 100644 gc/blacklst.c create mode 100755 gc/callprocs create mode 100644 gc/checksums.c create mode 100644 gc/cord/README create mode 100755 gc/cord/SCOPTIONS.amiga create mode 100644 gc/cord/SMakefile.amiga create mode 100644 gc/cord/cord.h create mode 100644 gc/cord/cordbscs.c create mode 100644 gc/cord/cordprnt.c create mode 100644 gc/cord/cordtest.c create mode 100644 gc/cord/cordxtra.c create mode 100644 gc/cord/de.c create mode 100644 gc/cord/de_cmds.h create mode 100755 gc/cord/de_win.ICO create mode 100644 gc/cord/de_win.RC create mode 100644 gc/cord/de_win.c create mode 100644 gc/cord/de_win.h create mode 100644 gc/cord/ec.h create mode 100644 gc/cord/gc.h create mode 100644 gc/cord/private/cord_pos.h create mode 100644 gc/dbg_mlc.c create mode 100644 gc/dyn_load.c create mode 100644 gc/finalize.c create mode 100644 gc/gc.h create mode 100644 gc/gc.mak create mode 100644 gc/gc.man create mode 100644 gc/gc_alloc.h create mode 100644 gc/gc_copy_descr.h create mode 100644 gc/gc_cpp.cc create mode 100644 gc/gc_cpp.h create mode 100644 gc/gc_hdrs.h create mode 100644 gc/gc_mark.h create mode 100644 gc/gc_priv.h create mode 100644 gc/gc_private.h create mode 100644 gc/gc_typed.h create mode 100644 gc/gcc_support.c create mode 100644 gc/gcconfig.h create mode 100644 gc/headers.c create mode 100644 gc/if_mach.c create mode 100644 gc/if_not_there.c create mode 100644 gc/include/backptr.h create mode 100644 gc/include/cord.h create mode 100644 gc/include/ec.h create mode 100644 gc/include/gc.h create mode 100644 gc/include/gc_alloc.h create mode 100644 gc/include/gc_cpp.h create mode 100644 gc/include/gc_inl.h create mode 100644 gc/include/gc_inline.h create mode 100644 gc/include/gc_typed.h create mode 100644 gc/include/javaxfc.h create mode 100644 gc/include/leak_detector.h create mode 100644 gc/include/new_gc_alloc.h create mode 100644 gc/include/private/cord_pos.h create mode 100644 gc/include/private/gc_hdrs.h create mode 100644 gc/include/private/gc_priv.h create mode 100644 gc/include/private/gcconfig.h create mode 100644 gc/include/weakpointer.h create mode 100644 gc/irix_threads.c create mode 100644 gc/linux_threads.c create mode 100644 gc/mach_dep.c create mode 100644 gc/makefile.depend create mode 100644 gc/malloc.c create mode 100644 gc/mallocx.c create mode 100644 gc/mark.c create mode 100644 gc/mark_rts.c create mode 100644 gc/mips_sgi_mach_dep.s create mode 100644 gc/mips_ultrix_mach_dep.s create mode 100644 gc/misc.c create mode 100644 gc/new_hblk.c create mode 100644 gc/nursery.c create mode 100755 gc/nursery.h create mode 100644 gc/obj_map.c create mode 100644 gc/os_dep.c create mode 100644 gc/pc_excludes create mode 100644 gc/pcr_interface.c create mode 100644 gc/ptr_chck.c create mode 100644 gc/real_malloc.c create mode 100644 gc/reclaim.c create mode 100644 gc/rs6000_mach_dep.s create mode 100644 gc/setjmp_t.c create mode 100644 gc/solaris_pthreads.c create mode 100644 gc/solaris_threads.c create mode 100644 gc/solaris_threads.h create mode 100644 gc/sparc_mach_dep.s create mode 100644 gc/sparc_sunos4_mach_dep.s create mode 100644 gc/stubborn.c create mode 100644 gc/test.c create mode 100644 gc/test_cpp.cc create mode 100644 gc/threadlibs.c create mode 100644 gc/typd_mlc.c create mode 100644 gc/version.h create mode 100644 gc/weakpointer.h create mode 100755 gc/win32_threads.c create mode 100644 gcmain.c create mode 100644 hash.c create mode 100644 hash.h create mode 100644 history.c create mode 100644 history.h create mode 100644 html.c create mode 100644 html.h create mode 100644 indep.c create mode 100644 indep.h create mode 100755 install.sh create mode 100644 islang.c create mode 100644 istream.c create mode 100644 istream.h create mode 100644 keybind.c create mode 100644 keybind_lynx.c create mode 100644 linein.c create mode 100644 local.c create mode 100644 local.h create mode 100644 mailcap.c create mode 100644 main.c create mode 100755 makeallmodel create mode 100644 map.c create mode 100644 matrix.c create mode 100644 matrix.h create mode 100644 menu.c create mode 100644 menu.h create mode 100644 mimehead.c create mode 100644 mktable.c create mode 100644 myctype.c create mode 100644 myctype.h create mode 100644 parsetag.c create mode 100644 parsetag.h create mode 100644 parsetagx.c create mode 100644 parsetagx.h create mode 100644 proto.h create mode 100644 rc.c create mode 100644 rcparams.h create mode 100644 regex.c create mode 100644 regex.h create mode 100644 scripts/bm2menu.pl create mode 100644 scripts/dirlist.cgi create mode 100755 scripts/dirlist.in create mode 100644 scrsize.c create mode 100644 search.c create mode 100644 table.c create mode 100644 table.c.0 create mode 100644 table.h create mode 100644 tagtable.c create mode 100644 tagtable.tab create mode 100644 terms.c create mode 100644 terms.h create mode 100644 textlist.c create mode 100644 textlist.h create mode 100644 url.c create mode 100644 version.c create mode 100644 w3m-doc/README.html create mode 100644 w3m-doc/community.html.in create mode 100644 w3m-doc/configuration.html.in create mode 100644 w3m-doc/contain.wd create mode 100644 w3m-doc/copyright.html.in create mode 100644 w3m-doc/define.wd create mode 100644 w3m-doc/detail.html.in create mode 100644 w3m-doc/developement.html.in create mode 100644 w3m-doc/faq.html.in create mode 100644 w3m-doc/function.html.in create mode 100644 w3m-doc/index.html.in create mode 100644 w3m-doc/install.html.in create mode 100755 w3m-doc/mkdocs create mode 100644 w3m-doc/operation.html.in create mode 100644 w3m-doc/outline.html.in create mode 100644 w3m-doc/prologue.html.in create mode 100644 w3m-doc/sample/README create mode 100644 w3m-doc/sample/define.wd create mode 100644 w3m-doc/sample/html.wd create mode 100755 w3m-doc/sample/keymap.cgi create mode 100644 w3m-doc/sample/s.wd create mode 100644 w3m-doc/sample/sample.html create mode 100644 w3m-doc/sample/sample.wd create mode 100755 w3m-doc/sample/w3mdoc.pl create mode 100755 w3m-doc/w3mdoc.pl create mode 100644 w3mbookmark.c create mode 100644 w3mhelp-lynx_en.html create mode 100644 w3mhelp-lynx_ja.html create mode 100644 w3mhelp-w3m_en.html create mode 100644 w3mhelp-w3m_ja.html create mode 100644 w3mhelperpanel.c create mode 100755 which diff --git a/Bonus/README b/Bonus/README new file mode 100644 index 0000000..1e3a0de --- /dev/null +++ b/Bonus/README @@ -0,0 +1,48 @@ +html2latex + + HTMLの文書をLaTeX に変換します.Rubyスクリプトです.不完全です. + ある程度の役には立つかもしれません. + + 使用法 + + html2latex file.html > file.tex + + ここに置いてある理由 + + makeref のための部品取りです :-) + +makeref + + HTMLの文書を読み,アンカーに番号を振ります.番号を振った文書を + 標準出力に書き出し,最後にその一覧を出力します.Ruby スクリプトです. + + 使用法 + + makeref [-url base_url] [file] + + -url: 文書のURLを指定します.リンクの一覧を出すときに,そのURLを + 補完するために使います. + + バグ + + HTMLの記述ミス( < ではなく < を使う,&... の最後に ; を付けない + 等)があると,悲惨な結果になることがあります. + + 半角カナ(JIS X-0201カナ)に対応していません. + +htmldump + + URL からHTML文書を読み,アンカーに番号を振って整形し,標準出力に + 書き出します. + + 使用法 + + dumphtml [URL] + + URL を省略すると,$WWW_HOME の内容を読みます. + + バグ + + URL の指す文書がHTMLでなかった場合,かわいそうなことになります. + makeref を使っているので,makeref がうまく処理できない文書の表示 + は変になります. diff --git a/Bonus/README.eng b/Bonus/README.eng new file mode 100644 index 0000000..06613ee --- /dev/null +++ b/Bonus/README.eng @@ -0,0 +1,49 @@ +html2latex + + Convert HTML document into LaTeX. Ruby script. incomplete. + + Usage: + + html2latex file.html > file.tex + + Why this script is here? + + To exploit code for makeref. :-) + +makeref + + Read HTML document and number the anchors. Print numbered document + into standard output and append reference index. Ruby script. + + Usage: + + makeref [-u] [-url base_url] [file] + + -url: Specify URL of the document. It is used to complete link + in the document. + + -u: Append URL after each anchor, instead of reference number. + + Bugs + + If there are any error in HTML (unbalanced < , character entity + without ; , etc.), output will be miserable. + +htmldump + + Read HTML document from URL, number the anchors and format it, + and output it on standard output. + + Usage + + htmldump [-u] [URL] + + -u: Append URL after each anchor, instead of reference number. + + If URL is omitted, $WWW_HOME is used instead. + + Bugs + + It assumes that the document on URL is HTML. + As it uses makeref to number the anchor, it can't handle any document + makeref can't handle. diff --git a/Bonus/html2latex b/Bonus/html2latex new file mode 100755 index 0000000..7b894e7 --- /dev/null +++ b/Bonus/html2latex @@ -0,0 +1,517 @@ +#!/usr/local/bin/ruby + +# +# HTML to LaTeX converter +# by A. Ito, 16 June, 1997 +# + +require 'kconv' + +# configuration +def gif2eps(giffile,epsfile) + cmd = "convert #{giffile} #{epsfile}" + STDERR.print cmd,"\n" + system cmd +end + +########################################################################### +class Tag + def initialize(str) + if str =~ /<(.+)>/ then + str = $1 + end + tags = str.split + @tagname = tags.shift.downcase + @vals = {} + tags.each do |t| + if t =~ /=/ then + tn,tv = t.split(/\s*=\s*/,2) + tv.sub!(/^"/,"") + tv.sub!(/"$/,"") + @vals[tn.downcase] = tv + else + @vals[t.downcase] = TRUE + end + end + end + def tagname + return @tagname + end + def each + @vals.each do |k,v| + yield k,v + end + end + def switch(k) + return @vals[k] + end +end + +class TokenStream + TAG_START = ?< + TAG_END = ?> + AMP_START = ?& + AMP_END = ?; + + AMP_REPLACE_TABLE = { + '&' => '\\&', + '>' => '$>$', + '<' => '$<$', + ' ' => '~', + '"' => '"', + } + def initialize(file) + if file.kind_of?(File) then + @f = file + else + @f = File.new(file) + end + @buf = nil + @bpos = 0 + end + + def read_until(endsym) + complete = FALSE + tag = [] + begin + while @bpos < @buf.size + c = @buf[@bpos] + if c == endsym then + tag.push(c.chr) + complete = TRUE + @bpos += 1 + break + end + if c == 10 || c == 13 then + tag.push(' ') + else + tag.push(c.chr) + end + @bpos += 1 + end + unless complete + @buf = @f.gets + @bpos = 0 + break if @f.eof? + end + end until complete + return tag.join('') + end + + def get + while TRUE + if @buf.nil? then + @buf = Kconv.toeuc(@f.gets) + if @f.eof? then + return nil + end + @bpos = 0 + end + if @buf[@bpos] == TAG_START then + return Tag.new(read_until(TAG_END)) + elsif @buf[@bpos] == AMP_START then + return replace_amp(read_until(AMP_END)) + else + i = @bpos + while i < @buf.size && @buf[i] != TAG_START && @buf[i] != AMP_START + i += 1 + end + r = @buf[@bpos,i-@bpos] + if i == @buf.size then + @buf = nil + else + @bpos = i + end + redo if r =~ /^\s+$/ + return r + end + end + end + public :eof? + def eof? + @f.eof? + end + def replace_amp(s) + if AMP_REPLACE_TABLE.key?(s) then + return AMP_REPLACE_TABLE[s] + else + return s + end + end +end + + +def print_header + print ' +\documentstyle[epsf]{jarticle} +\def\hr{\par\hbox to \textwidth{\hrulefill}} +\def\pre{\begin{quote}\def\baselinestretch{0.8}\tt\obeylines} +\def\endpre{\end{quote}} +\makeatletter +\@ifundefined{gt}{\let\gt=\dg}{} +\makeatother +' +end + + +class Environ_stack + def initialize(*envs) + @stack = envs + end + def action(tag) + if tag =~ /^!/ then # comment + return ["",nil] + end + i = @stack.size-1 + while i >= 0 + a = @stack[i].action(tag) + unless a.nil? then + return a + end + i -= 1 + end + return nil + end + def pop + @stack.pop + end + def push(env) + @stack.push(env) + end + def top + @stack[@stack.size-1] + end + def dup + @stack.push(top.clone) + end +end + + +class Environment + def initialize(interp) + @silent = FALSE + @in_table = FALSE + @interp = interp; + @align = nil; + end + def action(tag) + return @interp[tag] + end + + def flush(tok) + if tok.kind_of?(String) then + tok = tok.gsub(/&/,"\\&"); + tok = tok.gsub(/%/,"\\%"); + tok = tok.gsub(/#/,"\\#"); + tok = tok.gsub(/\$/,"\\$"); + tok = tok.gsub(/_/,"\\verb+_+"); + tok = tok.gsub(/\^/,"\\verb+^+"); + tok = tok.gsub(/~/,"\\verb+~+"); + end + if @in_table then + @table[@table_rows][@table_cols] += tok + elsif !@silent then + if !@align.nil? && tok =~ /\n$/ then + print tok.chop,"\\\\\n" + else + print tok + end + end + end + + def set_interp(interp) + @interp = interp + end + + # tag processing methods + + # + def do_silent(tag) + @silent = TRUE + end + + # + def undo_silent(tag) + @silent = FALSE + end + + # + def img_proc(tag) + src = tag.switch('src') + newfile = src.sub(/\.GIF/i,".eps") + gif2eps(src,newfile) + flush "\\epsfile{file=#{newfile}}\n" + end + + # + def starttable(tag) + @table = [] + @tablespan = [] + @table_rows = -1 + @table_cols_max = 0 + @in_table = TRUE + unless tag.switch('border').nil? then + @table_border = TRUE + else + @table_border = FALSE + end + end + + # + def start_row(tag) + @table_rows += 1 + @table[@table_rows] = [] + @tablespan[@table_rows] = [] + @table_cols = -1 + @colspan = 1 + end + + #
+ def start_col(tag) + @colspan = tag.switch('colspan') + if @colspan.nil? then + @colspan = 1 + else + @colspan = @colspan.to_i + end + @tablespan[@table_rows][@table_cols+1] = @colspan + @table_cols += @colspan + if @table_cols > @table_cols_max then + @table_cols_max = @table_cols + end + end + + #
+ def endtable(tag) + @in_table = FALSE + flush "\\begin{tabular}{*{" + flush @table_cols_max+1 + if @table_border then + flush "}{|l}|}\n\\hline\n" + else + flush "}{l}}\n" + end + for i in 0..@table_rows + j = 0 + while j <= @table_cols + span = @tablespan[i][j] + if span == 1 then + flush @table[i][j] + elsif @table_border then + form = "|l" + if j+span > @table_cols then + form = "|l|" + end + flush "\\multicolumn{"+span.to_s+"}{"+form+"}{" + flush @table[i][j+span-1] + flush "}" + else + flush "\\multicolumn{"+span.to_s+"}{l}{" + flush @table[i][j+span-1] + flush "}" + end + j += span + if j <= @table_cols then + flush "&" + end + end + flush "\\\\\n" + flush "\\hline\n" if @table_border + end + flush "\\end{tabular}\n" + end + + #
+ def startcenter(tag) + if @in_table then + flush "\\hfil" + else + flush "\\begin{center}\n" + end + end + + #
+ def endcenter(tag) + if @in_table then + flush "\\hfil" + else + flush "\\end{center}\n" + end + end + + #

+ def paragraph(tag) + align = tag.switch('align') + if align.nil? then + flush "\\par\n" + @endparagraph = "" + else + align = align.downcase + case align + when "left" then + flush "\\begin{flushleft}\n" + @endparagraph = "\\end{flushleft}\n" + when "center" then + flush "\\begin{center}\n" + @endparagraph = "\\end{center}\n" + when "right" then + flush "\\begin{flushright}\n" + @endparagraph = "\\end{flushright}\n" + end + end + @align = align + end + + #

+ def endparagraph(tag) + unless @align.nil? then + @align = nil + flush @endparagraph + end + end +end + + +enum_interp = { + 'li' => ["\\item ",nil] +} + +item_interp = { + 'li' => ["\\item ",nil] +} + +desc_interp = { + 'dt' => ["\\item[",nil], + 'dd' => ["]\n",nil] +} + +table_interp = { + 'tr' => [:start_row,nil], + 'td' => [:start_col,nil], + '/tr' => ["",nil], + '/td' => ["",nil], +} + +para_interp = { + '/p' => [:endparagraph ,"pop",TRUE], +} + +main_interp = { + 'body' => ["\\begin{document}\n",nil,FALSE], + '/body' => ["\\end{document}\n",nil,FALSE], + 'head' => ["",nil,FALSE], + '/head' => ["",nil,FALSE], + 'html' => ["",nil,FALSE], + '/html' => ["",nil,FALSE], + 'title' => [:do_silent,nil,FALSE], + '/title' => [:undo_silent,nil,FALSE], + '!' => ["",nil,FALSE], + 'h1' => ["\\section{",nil,TRUE], + 'h2' => ["\\subsection{",nil,TRUE], + 'h3' => ["\\subsubsection{",nil,TRUE], + 'h4' => ["\\paragraph{",nil,TRUE], + '/h1' => ["}\n",nil,TRUE], + '/h2' => ["}\n",nil,TRUE], + '/h3' => ["}\n",nil,TRUE], + '/h4' => ["}\n",nil,TRUE], + 'a' => ["",nil,TRUE], + '/a' => ["",nil,TRUE], + 'center' => [:startcenter,nil,TRUE], + '/center' => [:endcenter,nil,TRUE], + 'ol' => ["\\begin{enumerate}\n",enum_interp,TRUE], + '/ol' => ["\\end{enumerate}\n","pop",TRUE], + 'ul' => ["\\begin{itemize}\n",item_interp,TRUE], + '/ul' => ["\\end{itemize}\n","pop",TRUE], + 'dl' => ["\\begin{description}\n",desc_interp,TRUE], + '/dl' => ["\\end{description}\n","pop",TRUE], + 'pre' => ["\\begin{pre}\n",nil,TRUE], + '/pre' => ["\\end{pre}\n",nil,TRUE], + 'p' => [:paragraph ,para_interp,TRUE], + 'br' => ["\\par ",nil,TRUE], + 'img' => [:img_proc,nil,TRUE], + 'hr' => ["\\hr ",nil,TRUE], + 'b' => ["{\\bf\\gt ",nil,TRUE], + '/b' => ["}",nil,TRUE], + 'strong' => ["{\\bf\\gt ",nil,TRUE], + '/strong' => ["}",nil,TRUE], + 'dfn' => ["{\\bf\\gt ",nil,TRUE], + '/dfn' => ["}",nil,TRUE], + 'i' => ["{\\it",nil,TRUE], + '/i' => ["}",nil,TRUE], + 'address' => ["{\\it",nil,TRUE], + '/address'=> ["}",nil,TRUE], + 'cite' => ["{\\it",nil,TRUE], + '/cite' => ["}",nil,TRUE], + 'code' => ["{\\tt",nil,TRUE], + '/code' => ["}",nil,TRUE], + 'kbd' => ["{\\tt",nil,TRUE], + '/kbd' => ["}",nil,TRUE], + 'tt' => ["{\\tt",nil,TRUE], + '/tt' => ["}",nil,TRUE], + 'samp' => ["{\\tt",nil,TRUE], + '/samp' => ["}",nil,TRUE], + 'em' => ["{\\em",nil,TRUE], + '/em' => ["}",nil,TRUE], + 'u' => ["$\\underline{\\mbox{",nil,TRUE], + '/u' => ["}}$",nil,TRUE], + 'sub' => ["${}_\mbox{",nil,TRUE], + '/sub' => ["}$",nil,TRUE], + 'sup' => ["${}^\mbox{",nil,TRUE], + '/sup' => ["}$",nil,TRUE], + 'table' => [:starttable, table_interp,TRUE], + '/table' => [:endtable, "pop",TRUE], + 'font' => ["",nil,TRUE], + '/font' => ["",nil,TRUE], +} + + + + +################################ MAIN #################################### + +$in_document = FALSE +print_header +intp = Environ_stack.new(Environment.new(main_interp)) +f = TokenStream.new(ARGV[0]) +until f.eof? + tok = f.get + if tok.kind_of?(Tag) then + case tok.tagname + when "body" + $in_document = TRUE + when "/body" + $in_document = FALSE + end + act = intp.action(tok.tagname) + if act.nil? then + STDERR.print "tag ",tok.tagname," ignored\n" + else + if act[2] && !$in_document then + print "\\begin{document}\n" + $in_document = TRUE + end + # enviconment push + if act[1].kind_of?(Hash) && + (tok.tagname != "p" || tok.switch('align') != nil) then + intp.dup + intp.top.set_interp(act[1]) + end + + if act[0].kind_of?(String) then + intp.top.flush act[0] + elsif act[0].kind_of?(Fixnum) then # interned symbol + intp.top.send(act[0],tok) + end + + # environment pop + if act[1] == "pop" then + intp.pop + end + end + elsif !tok.nil? then + intp.top.flush tok + end +end +if $in_document then + print "\\end{document}\n" +end diff --git a/Bonus/htmldump b/Bonus/htmldump new file mode 100755 index 0000000..4be60bf --- /dev/null +++ b/Bonus/htmldump @@ -0,0 +1,12 @@ +#!/bin/sh +OPT= +if [ $# -gt 0 -a $1 = "-u" ]; then + OPT=-u + shift +fi +if [ $# = 0 ]; then + URL=$WWW_HOME +else + URL=$1 +fi +w3m -dump_source $URL | makeref $OPT -url $URL | w3m -dump -F -T text/html diff --git a/Bonus/makeref b/Bonus/makeref new file mode 100755 index 0000000..9cb1942 --- /dev/null +++ b/Bonus/makeref @@ -0,0 +1,266 @@ +#!/usr/local/bin/ruby + +# HTML reference generator +# by A.Ito 1999/3/30 + +require 'kconv' + +########################################################################### +class URL + attr 'scheme' + attr 'host' + attr 'port' + attr 'file' + attr 'label' + def initialize(str) + if /([a-zA-Z+\-]+):(.*)/ =~ str then + @scheme = $1 + str = $2 + else + @scheme = 'unknown' + end + hostpart = '' + if %r'//([^/]*)(/.*)' =~ str then + hostpart = $1 + str = $2 + elsif %r'//([^/]*)$' =~ str then + hostpart = str + str = '' + end + if hostpart != '' then + if /(.*):(\d+)/ =~ hostpart then + @host = $1 + @port = $2 + else + @host = hostpart + @port = '' + end + else + @host = @port = '' + end + if /(.*)#(.*)/ =~ str then + @file = $1 + @label = $2 + else + @file = str + @label = '' + end + end + def to_s + s = "#{@scheme}:" + if s == 'news' or s == 'mailto' then + return s+@file + end + s += "//"+@host + s += ":"+@port if @port.size > 0 + s += @file + s += "#"+@label if @label.size > 0 + s + end + def complete(current) + @scheme = current.scheme if @scheme == 'unknown' + @port = current.port if @host == '' and @port == '' + @host = current.host if @host == '' + unless @file =~ %r'^/' then + @file = File.expand_path(File.dirname(current.file)+'/'+@file) + end + self + end +end + +class Tag + def initialize(str) + if str =~ /<(.+)>/ then + str = $1 + end + tags = str.split + @tagname = tags.shift.downcase + @vals = {} + tags.each do |t| + if t =~ /=/ then + tn,tv = t.split(/\s*=\s*/,2) + tv.sub!(/^"/,"") + tv.sub!(/"$/,"") + @vals[tn.downcase] = tv + else + @vals[t.downcase] = TRUE + end + end + end + def tagname + return @tagname + end + def each + @vals.each do |k,v| + yield k,v + end + end + def switch(k) + return @vals[k] + end + def to_s + if tagname =~ /!--/ then + return '' + end + t = "<"+tagname + if @vals.size == 0 then + return t+">" + end + each do |a,v| + if v == true then + t += " #{a}" + else + t += " #{a}=\"#{v}\"" + end + end + t+">" + end +end + +class TokenStream + TAG_START = ?< + TAG_END = ?> + AMP_START = ?& + AMP_END = ?; + + def initialize(file) + if file.kind_of?(IO) then + @f = file + else + @f = File.new(file) + end + @buf = nil + @bpos = 0 + end + + def read_until(endsym) + complete = FALSE + tag = [] + begin + while @bpos < @buf.size + c = @buf[@bpos] + if c == endsym then + tag.push(c.chr) + complete = TRUE + @bpos += 1 + break + end + if c == 10 || c == 13 then + tag.push(' ') + else + tag.push(c.chr) + end + @bpos += 1 + end + unless complete + @buf = @f.gets + @bpos = 0 + break if @f.eof? + end + end until complete + return tag.join('') + end + + def get + while TRUE + if @buf.nil? then + @buf = @f.gets + if @f.eof? then + return nil + end + @buf = Kconv.toeuc(@buf) + @bpos = 0 + end + if @buf[@bpos] == TAG_START then + return Tag.new(read_until(TAG_END)) + elsif @buf[@bpos] == AMP_START then + return read_until(AMP_END) + else + i = @bpos + while i < @buf.size && @buf[i] != TAG_START && @buf[i] != AMP_START + i += 1 + end + r = @buf[@bpos,i-@bpos] + if i == @buf.size then + @buf = nil + else + @bpos = i + end + redo if r =~ /^\s+$/ + return r + end + end + end + public :eof? + def eof? + @f.eof? + end +end + +################################ MAIN #################################### + +refs = [] +refnum = 0 +body_finished = false +html_finished = false +currentURL = nil +immediate_ref = false + +while ARGV[0] =~ /^-/ + case ARGV.shift + when '-url' + currentURL = URL.new(ARGV.shift) + when '-u' + immediate_ref = true + end +end + +if ARGV.size > 0 then + f = TokenStream.new(ARGV[0]) +else + f = TokenStream.new(STDIN) +end + +until f.eof? + tok = f.get + if tok.kind_of?(Tag) then + if tok.tagname == 'a' and !tok.switch('href').nil? then + refs[refnum] = tok.switch('href') + refnum += 1 + elsif tok.tagname == '/a' then + if immediate_ref then + r = refs[refnum-1] + if !currentURL.nil? then + r = URL.new(r).complete(currentURL).to_s + end + print "[#{r}]" + else + print "[#{refnum}]" + end + elsif tok.tagname == '/body' then + body_finished = true + break + elsif tok.tagname == '/html' then + html_finished = true + break + end + print tok.to_s + elsif !tok.nil? then + print tok + end +end +if !immediate_ref and refs.size > 0 then + print "

References

\n" + for i in 0..refs.size-1 + if currentURL.nil? then + r = refs[i] + else + r = URL.new(refs[i]) + r.complete(currentURL) + r = r.to_s + end + print "[#{i+1}] #{r}
\n" + end +end +print "\n" unless body_finished +print "\n" unless html_finished diff --git a/Bonus/scanhist.rb b/Bonus/scanhist.rb new file mode 100644 index 0000000..69dcc9d --- /dev/null +++ b/Bonus/scanhist.rb @@ -0,0 +1,88 @@ +#!/usr/local/bin/ruby + +# scan history + +def usage + STDERR.print "usage: scanhist -h HISTORY ML-archive1 ML-archive2 ...\n" + exit 1 +end + +def html_quote(s) + s.gsub!(/&/,"&") + s.gsub!(//,">") + s +end + +if ARGV.size == 0 then + usage +end + +histfile = nil + +while ARGV[0] =~ /^-/ + case ARGV.shift + when "-h" + histfile = ARGV.shift + else + usage + end +end + +if histfile.nil? then + usage +end + +patched = {} +histline = {} +f = open(histfile) +while f.gets + if /Subject: (\[w3m-dev.*\])/ then + patched[$1] = true + histline[$1] = $. + end +end +f.close + +archive = {} +subject = nil +for fn in ARGV + f = open(fn) + while f.gets + if /^From / then + # beginning of a mail + subject = nil + elsif subject.nil? and /^Subject: / then + $_ =~ /Subject: (\[w3m-dev.*\])/ + subject = $1 + archive[subject] = [$_.chop.sub(/^Subject:\s*/,""),false,fn+"#"+($.).to_s] + elsif /^\+\+\+/ or /\*\*\*/ or /filename=.*(patch|diff).*/ or /^begin \d\d\d/ + archive[subject][1] = true + end + end + f.close +end + +print "w3m patch configuration\n\n" +print "
\n"
+for sub in archive.keys.sort
+  a = archive[sub]
+  if a[1] then
+    if patched[sub] then
+      print "[+]"
+    else
+      print "[-]"
+    end
+    print ""
+    print "",html_quote(a[0]),"\n"
+  else
+    if patched[sub] then
+      print "[o]"
+    else
+      print "   "
+    end
+    print ""
+    print "",html_quote(a[0]),"\n"
+  end
+end
+print "
\n" diff --git a/Bonus/wrap3m b/Bonus/wrap3m new file mode 100755 index 0000000..9555c9a --- /dev/null +++ b/Bonus/wrap3m @@ -0,0 +1,33 @@ +#!/bin/sh + +HOMEPAGE=http://ei5nazha.yz.yamagata-u.ac.jp/~aito/w3m/ +OPT="" +URL="" +for i in $@ +do + case $i in + -*) + OPT="$OPT $i" + ;; + *) + URL="$URL $i" + ;; + esac +done + +if [ -z "$URL" ]; then + URL=$HOMEPAGE +fi +URLARG="" +for u in $URL +do + if [ `expr $u : '[a-z][a-z]*://'` -gt 0 ]; then + URLARG="$URLARG $u" + elif [ -f $u -o -d $u ]; then + URLARG="$URLARG $u" + else + URLARG="$URLARG http://$u" + fi +done + +w3m $OPTS $URLARG diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f756399 --- /dev/null +++ b/Makefile @@ -0,0 +1,42 @@ +GCLIBTGZ=gc5.0alpha3.tar.gz + +all: XXMakefile + make -f XXMakefile + +install: XXMakefile + make -f XXMakefile install + +uninstall: XXMakefile + make -f XXMakefile uninstall + +proto: XXMakefile + make -f XXMakefile proto + +clean: XXMakefile + make -f XXMakefile clean + +sweep: XXMakefile + make -f XXMakefile sweep + +veryclean: clean sweep + rm XXMakefile + (cd gc; make clean) + rm -f config.param + rm -f */*~ */*.orig */*.rej + +prepare: + rm -rf gc + gzip -dc ../$(GCLIBTGZ) | tar xvf - + cp XMakefile.dist XMakefile + +dist: XXMakefile + make -f XXMakefile dist + +bindist: XXMakefile + make -f XXMakefile bindist + +indent: + indent -orig -nce -ncdb -i4 -di1 -nbc *.c *.h + +XXMakefile: XMakefile config.h + awk '/^#ifdef makefile_parameter/,/^#else/' config.h | cat - XMakefile > XXMakefile diff --git a/Patches/alpha b/Patches/alpha new file mode 100644 index 0000000..422cd26 --- /dev/null +++ b/Patches/alpha @@ -0,0 +1,19 @@ +*** gc/Makefile.orig Thu Jun 24 10:08:17 1999 +--- gc/Makefile Thu Jun 24 10:08:54 1999 +*************** +*** 10,16 **** + ABI_FLAG= + CC=cc $(ABI_FLAG) + CXX=CC $(ABI_FLAG) +! AS=as $(ABI_FLAG) + # The above doesn't work with gas, which doesn't run cpp. + # Define AS as `gcc -c -x assembler-with-cpp' instead. + # Under Irix 6, you will have to specify the ABI (-o32, -n32, or -64) +--- 10,16 ---- + ABI_FLAG= + CC=cc $(ABI_FLAG) + CXX=CC $(ABI_FLAG) +! AS=gcc -c -x assembler-with-cpp + # The above doesn't work with gas, which doesn't run cpp. + # Define AS as `gcc -c -x assembler-with-cpp' instead. + # Under Irix 6, you will have to specify the ABI (-o32, -n32, or -64) diff --git a/Patches/armlinux b/Patches/armlinux new file mode 100644 index 0000000..18dd202 --- /dev/null +++ b/Patches/armlinux @@ -0,0 +1,110 @@ +From lars@junk.nocrew.org Tue Mar 7 04:44 EST 2000 +Return-Path: +Received: from ei5sun.yz.yamagata-u.ac.jp (ei5sun.yz.yamagata-u.ac.jp [133.24.114.42]) + by ei5hp710.yz.yamagata-u.ac.jp (8.9.3/8.9.3) with ESMTP id EAA25953 + for ; Tue, 7 Mar 2000 04:44:51 -0500 (EST) +Received: from junk.nocrew.org (mail@[212.73.17.42]) by ei5sun.yz.yamagata-u.ac.jp (8.8.0/3.5Wbeta) with ESMTP id SAA07952 for ; Tue, 7 Mar 2000 18:54:43 +0900 (JST) +Received: from lars by junk.nocrew.org with local (Exim 3.03 #1 (Debian)) + for aito@ei5sun.yz.yamagata-u.ac.jp + id 12SGVE-0001rh-00; Tue, 07 Mar 2000 10:42:08 +0100 +To: aito@ei5sun.yz.yamagata-u.ac.jp +Subject: ARMLinux patch +From: lars brinkhoff +Date: 07 Mar 2000 10:42:08 +0100 +Message-ID: <85zosbjevj.fsf@junk.nocrew.org> +Lines: 89 +User-Agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.5 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Sender: lars brinkhoff + +This patch is an attempt to make w3m version 0.1.6 work in ARMLinux. +It seems to work well. + +--- gc/gcconfig.h.org Wed Jan 12 05:23:37 2000 ++++ gc/gcconfig.h Sun Mar 5 14:24:52 2000 +@@ -151,6 +151,10 @@ + # define SPARC + # define mach_type_known + # endif ++# if defined(LINUX) && (defined(__arm__) || defined(arm)) ++# define ARM ++# define mach_type_known ++# endif + # if defined(__alpha) || defined(__alpha__) + # define ALPHA + # if !defined(LINUX) +@@ -985,6 +989,39 @@ + # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &_etext) + # define DATAEND (&_end) + # define HEURISTIC2 ++# endif ++ ++# ifdef ARM ++# define MACH_TYPE "ARM" ++# ifdef LINUX ++# define OS_TYPE "LINUX" ++# define HEURISTIC1 ++# define STACKBOTTOM ((ptr_t) 0xbffffffc) ++# ifdef __ELF__ ++# define DYNAMIC_LOADING ++# include ++# if defined(__GLIBC__) && __GLIBC__ >= 2 ++ extern int __data_start; ++# define DATASTART ((ptr_t)(&__data_start)) ++# else ++ extern char **__environ; ++# define DATASTART ((ptr_t)(&__environ)) ++ /* hideous kludge: __environ is the first */ ++ /* word in crt0.o, and delimits the start */ ++ /* of the data segment, no matter which */ ++ /* ld options were passed through. */ ++ /* We could use _etext instead, but that */ ++ /* would include .rodata, which may */ ++ /* contain large read-only data tables */ ++ /* that we'd rather not scan. */ ++# endif ++ extern int _end; ++# define DATAEND (&_end) ++# else ++ ARMLinux non elf ? ++# endif ++# endif ++# define ALIGNMENT 4 + # endif + + # ifndef STACK_GROWS_UP +diff -ur gc/mach_dep.c w3m-0.1.6.lars/gc/mach_dep.c +--- gc/mach_dep.c.org Wed Jan 12 05:23:37 2000 ++++ gc/mach_dep.c Thu Jan 27 21:28:39 2000 +@@ -337,7 +337,7 @@ + /* other machines... */ + # if !(defined M68K) && !(defined VAX) && !(defined RT) + # if !(defined SPARC) && !(defined I386) && !(defined NS32K) +-# if !defined(POWERPC) && !defined(UTS4) ++# if !defined(POWERPC) && !defined(UTS4) && !defined(ARM) + --> bad news <-- + # endif + # endif +diff -ur w3m/gc/os_dep.c w3m-0.1.6.lars/gc/os_dep.c +--- gc/os_dep.c.org Wed Jan 12 05:23:37 2000 ++++ gc/os_dep.c Thu Jan 27 21:37:27 2000 +@@ -72,7 +72,7 @@ + # define NEED_FIND_LIMIT + # endif + +-# if defined(LINUX) && (defined(POWERPC) || defined(SPARC) || defined(ALPHA)) ++# if defined(LINUX) && (defined(POWERPC) || defined(SPARC) || defined(ALPHA) || defined (ARM)) + # define NEED_FIND_LIMIT + # endif + +@@ -139,7 +139,7 @@ + # define OPT_PROT_EXEC 0 + #endif + +-#if defined(LINUX) && (defined(POWERPC) || defined(SPARC) || defined(ALPHA)) ++#if defined(LINUX) && (defined(POWERPC) || defined(SPARC) || defined(ALPHA) || defined(ARM)) + /* The I386 case can be handled without a search. The Alpha case */ + /* used to be handled differently as well, but the rules changed */ + /* for recent Linux versions. This seems to be the easiest way to */ + diff --git a/Patches/ews4800 b/Patches/ews4800 new file mode 100644 index 0000000..954523a --- /dev/null +++ b/Patches/ews4800 @@ -0,0 +1,34 @@ +--- XMakefile.orig Mon Mar 19 10:47:56 2001 ++++ XMakefile Mon Mar 19 21:03:34 2001 +@@ -65,7 +65,7 @@ + $(CC) $(CFLAGS) -o $(HELPER) w3mhelperpanel.o $(LIBS) + + gc/gc.a: +- cd gc; make CC='$(CC)' CFLAGS='$(GCCFLAGS)' ++ cd gc; make CC='$(CC)' CFLAGS='$(GCCFLAGS) -Dmips' + + install: $(TARGETS) + -$(MKDIR) $(DESTDIR)$(BIN_DIR) +--- gc/Makefile.orig Tue Jan 4 14:46:50 2000 ++++ gc/Makefile Thu Mar 22 18:10:10 2001 +@@ -7,7 +7,7 @@ + # and runs some tests of collector and cords. Does not add cords or + # c++ interface to gc.a + # cord/de - builds dumb editor based on cords. +-ABI_FLAG= ++ABI_FLAG=-Kconform_pic + CC=cc $(ABI_FLAG) + CXX=CC $(ABI_FLAG) + AS=as $(ABI_FLAG) +--- gc/gcconfig.h.orig Tue Jun 6 14:39:29 2000 ++++ gc/gcconfig.h Mon Mar 19 21:02:51 2001 +@@ -64,7 +64,8 @@ + # endif + # if defined(mips) || defined(__mips) + # define MIPS +-# if defined(ultrix) || defined(__ultrix) || defined(__NetBSD__) ++# if defined(ultrix) || defined(__ultrix) || defined(__NetBSD__) ||\ ++ defined(nec_ews) + # define ULTRIX + # else + # if !defined(LINUX) diff --git a/Patches/hpux11 b/Patches/hpux11 new file mode 100644 index 0000000..c02893e --- /dev/null +++ b/Patches/hpux11 @@ -0,0 +1,25 @@ +Install note for HP-UX + +If you are running HP-UX 11 or later on PA-RISC 2.0, you +have to apply the following patch on GC library. This patch +is contributed by Dave Eaton . + +If you want to use HP C compiler, answer + + Input your favorite C-compiler. + (Default: cc) cc -Aa -D_HPUX_SOURCE + +If you use just 'cc' without options, you can't compile w3m. +If you are using gcc, no option is needed. + +---------------------------------------------------------------------- +--- gc/gcconfig.h.original Wed May 19 01:38:55 1999 ++++ gc/gcconfig.h Tue Jun 8 12:38:22 1999 +@@ -125,6 +125,7 @@ + # define mach_type_known + # endif + # if defined(_PA_RISC1_0) || defined(_PA_RISC1_1) \ ++ || defined(_PA_RISC2_0) \ + || defined(hppa) || defined(__hppa__) + # define HP_PA + # define mach_type_known diff --git a/Patches/linux2.2sparc b/Patches/linux2.2sparc new file mode 100644 index 0000000..3a5cd80 --- /dev/null +++ b/Patches/linux2.2sparc @@ -0,0 +1,10 @@ +--- gc/gcconfig.h.org ++++ gc/gcconfig.h +@@ -601,7 +601,7 @@ + extern int _end; + # define DATAEND (&_end) + # define SVR4 +-# define STACKBOTTOM ((ptr_t) 0xf0000000) ++# define STACKBOTTOM ((ptr_t) 0xeffff000) + # endif + # endif diff --git a/Patches/macosx b/Patches/macosx new file mode 100644 index 0000000..4d251f1 --- /dev/null +++ b/Patches/macosx @@ -0,0 +1,41 @@ +Jeroen Scheerder (by way of Jeroen Scheerder) +Subject: w3m 0.1.6 on Mac OS X +Content-Type: text/plain; charset="us-ascii" + +Hi, + +I've compiled w3m successfully on Mac OS X (DP3). I'm including +patches, mainly dealing with compiler complaints about possible use of +uninitialized data. + +It compiles with one warning, still: + +url.c:799: warning: variable `p' might be clobbered by `longjmp' or + `vfork' + + +On a related note: I had to modify the makefile; there is no `m' +library, and no `termcap' library, and they're not needed as well -- +but they will cause an ld failure, when present on the ld command line. + +Context diffs (against a 21/1/2000 0.1.6) are included, including the +(trivial) patch to make Boehm gc compile. + + + +*** gc/gcconfig.h Mon Mar 6 12:16:04 2000 +--- gc/gcconfig.h.org Wed Jan 12 04:23:37 2000 +*************** +*** 180,190 **** + # define POWERPC + # define mach_type_known + # endif +- # if defined(__APPLE__) +- # define MACOSX +- # define POWERPC +- # define mach_type_known +- # endif + # if defined(NeXT) && defined(mc68000) + # define M68K + # define NEXT +--- 180,185 ---- diff --git a/Patches/macppc b/Patches/macppc new file mode 100644 index 0000000..c52adc4 --- /dev/null +++ b/Patches/macppc @@ -0,0 +1,147 @@ +Here is a patch to port GC library to NetBSD/macppc. If you are +using NetBSD on PowerMac, apply this patch first. + +This patch is provided by K. Sunagawa (kei_sun@ba2.so-net.ne.jp). + +Index: gc/dyn_load.c +=================================================================== +RCS file: /cvsroot/w3m/gc/dyn_load.c,v +retrieving revision 1.1.1.2 +retrieving revision 1.2 +diff -u -u -r1.1.1.2 -r1.2 +--- gc/dyn_load.c 1999/06/02 19:29:13 1.1.1.2 ++++ gc/dyn_load.c 1999/06/03 12:44:49 1.2 +@@ -48,7 +48,8 @@ + #if !defined(SUNOS4) && !defined(SUNOS5DL) && !defined(IRIX5) && \ + !defined(MSWIN32) && !(defined(ALPHA) && defined(OSF1)) && \ + !defined(HP_PA) && !(defined(LINUX) && defined(__ELF__)) && \ +- !defined(RS6000) && !defined(SCO_ELF) ++ !defined(RS6000) && !defined(SCO_ELF) && \ ++ !(defined(NETBSD) && defined(POWERPC)) + --> We only know how to find data segments of dynamic libraries for the + --> above. Additional SVR4 variants might not be too + --> hard to add. +@@ -260,14 +261,22 @@ + # endif /* !USE_PROC ... */ + # endif /* SUNOS */ + +-#if defined(LINUX) && defined(__ELF__) || defined(SCO_ELF) ++#if defined(LINUX) && defined(__ELF__) || defined(SCO_ELF) || \ ++ (defined(NETBSD) && defined(POWERPC)) + + /* Dynamic loading code for Linux running ELF. Somewhat tested on + * Linux/x86, untested but hopefully should work on Linux/Alpha. + * This code was derived from the Solaris/ELF support. Thanks to + * whatever kind soul wrote that. - Patrick Bridges */ + ++#if defined(NETBSD) ++#include ++#define DT_DEBUG 21 ++#define PT_LOAD 1 ++#define PF_W 0x2 ++#else + #include ++#endif + #include + + /* Newer versions of Linux/Alpha and Linux/x86 define this macro. We +Index: gc/gcconfig.h +=================================================================== +RCS file: /cvsroot/w3m/gc/gcconfig.h,v +retrieving revision 1.1.1.2 +retrieving revision 1.2 +diff -u -u -r1.1.1.2 -r1.2 +--- gc/gcconfig.h 1999/06/02 19:29:18 1.1.1.2 ++++ gc/gcconfig.h 1999/06/03 12:44:49 1.2 +@@ -48,6 +48,11 @@ + # define NETBSD + # define mach_type_known + # endif ++# if defined(__NetBSD__) && defined(__powerpc__) ++# define POWERPC ++# define NETBSD ++# define mach_type_known ++# endif + # if defined(vax) + # define VAX + # ifdef ultrix +@@ -486,8 +491,8 @@ + + # ifdef POWERPC + # define MACH_TYPE "POWERPC" +-# define ALIGNMENT 2 + # ifdef MACOS ++# define ALIGNMENT 2 + # ifndef __LOWMEM__ + # include + # endif +@@ -497,6 +502,7 @@ + # define DATAEND /* not needed */ + # endif + # ifdef LINUX ++# define ALIGNMENT 2 + # define OS_TYPE "LINUX" + # define HEURISTIC1 + # undef STACK_GRAN +@@ -504,6 +510,14 @@ + # define DATASTART GC_data_start + extern int _end; + # define DATAEND (&_end) ++# endif ++# ifdef NETBSD ++# define ALIGNMENT 4 ++# define OS_TYPE "NETBSD" ++# define HEURISTIC2 ++ extern char etext; ++# define DATASTART GC_data_start ++# define DYNAMIC_LOADING + # endif + # endif + +Index: gc/misc.c +=================================================================== +RCS file: /cvsroot/w3m/gc/misc.c,v +retrieving revision 1.1.1.1 +retrieving revision 1.2 +diff -u -u -r1.1.1.1 -r1.2 +--- gc/misc.c 1999/06/02 19:23:56 1.1.1.1 ++++ gc/misc.c 1999/06/03 12:44:50 1.2 +@@ -433,6 +433,9 @@ + # if defined(LINUX) && defined(SPARC) + GC_init_linuxsparc(); + # endif ++# if defined(NETBSD) && defined(POWERPC) ++ GC_init_netbsd_powerpc(); ++# endif + # ifdef SOLARIS_THREADS + GC_thr_init(); + /* We need dirty bits in order to find live stack sections. */ +Index: gc/os_dep.c +=================================================================== +RCS file: /cvsroot/w3m/gc/os_dep.c,v +retrieving revision 1.1.1.2 +retrieving revision 1.2 +diff -u -u -r1.1.1.2 -r1.2 +--- gc/os_dep.c 1999/06/02 19:29:10 1.1.1.2 ++++ gc/os_dep.c 1999/06/03 12:44:50 1.2 +@@ -84,6 +84,19 @@ + # include + #endif + ++#if defined(NETBSD) && defined(POWERPC) ++ ptr_t GC_data_start; ++ ++ void GC_init_netbsd_powerpc() ++ { ++ extern ptr_t GC_find_limit(); ++ extern char **environ; ++ /* This may need to be environ, without the underscore, for */ ++ /* some versions. */ ++ GC_data_start = GC_find_limit((ptr_t)&environ, FALSE); ++ } ++#endif ++ + #ifdef AMIGA + # include + # include + diff --git a/Patches/mipsel b/Patches/mipsel new file mode 100644 index 0000000..c3c6be1 --- /dev/null +++ b/Patches/mipsel @@ -0,0 +1,184 @@ +diff -ur gc/gcconfig.h w3m/gc/gcconfig.h +--- gc/gcconfig.h Tue Jan 4 14:46:50 2000 ++++ gc/gcconfig.h Fri May 26 00:30:56 2000 +@@ -67,11 +67,13 @@ + # if defined(ultrix) || defined(__ultrix) || defined(__NetBSD__) + # define ULTRIX + # else +-# if defined(_SYSTYPE_SVR4) || defined(SYSTYPE_SVR4) || defined(__SYSTYPE_SVR4__) +-# define IRIX5 /* or IRIX 6.X */ +-# else +-# define RISCOS /* or IRIX 4.X */ +-# endif ++# if !defined(LINUX) ++# if defined(_SYSTYPE_SVR4) || defined(SYSTYPE_SVR4) || defined(__SYSTYPE_SVR4__) ++# define IRIX5 /* or IRIX 6.X */ ++# else ++# define RISCOS /* or IRIX 4.X */ ++# endif ++# endif + # endif + # define mach_type_known + # endif +@@ -836,49 +838,58 @@ + + # ifdef MIPS + # define MACH_TYPE "MIPS" +-# ifndef IRIX5 +-# define DATASTART (ptr_t)0x10000000 ++# ifdef LINUX ++# define OS_TYPE "LINUX" ++ extern int __data_start; ++# define DATASTART ((ptr_t)(&__data_start)) ++# define ALIGNMENT 4 ++# define USE_GENERIC_PUSH_REGS 1 ++# define STACKBOTTOM 0x80000000 ++# else /* LINUX */ ++# ifndef IRIX5 ++# define DATASTART (ptr_t)0x10000000 + /* Could probably be slightly higher since */ + /* startup code allocates lots of stuff. */ +-# else +- extern int _fdata; +-# define DATASTART ((ptr_t)(&_fdata)) +-# ifdef USE_MMAP +-# define HEAP_START (ptr_t)0x30000000 + # else +-# define HEAP_START DATASTART +-# endif ++ extern int _fdata; ++# define DATASTART ((ptr_t)(&_fdata)) ++# ifdef USE_MMAP ++# define HEAP_START (ptr_t)0x30000000 ++# else ++# define HEAP_START DATASTART ++# endif + /* Lowest plausible heap address. */ + /* In the MMAP case, we map there. */ + /* In either case it is used to identify */ + /* heap sections so they're not */ + /* considered as roots. */ +-# endif /* IRIX5 */ +-# define HEURISTIC2 ++# endif /* IRIX5 */ ++# define HEURISTIC2 + /* # define STACKBOTTOM ((ptr_t)0x7fff8000) sometimes also works. */ +-# ifdef ULTRIX +-# define OS_TYPE "ULTRIX" +-# define ALIGNMENT 4 +-# endif +-# ifdef RISCOS +-# define OS_TYPE "RISCOS" +-# define ALIGNMENT 4 /* Required by hardware */ +-# endif +-# ifdef IRIX5 +-# define OS_TYPE "IRIX5" +-# define MPROTECT_VDB +-# ifdef _MIPS_SZPTR +-# define CPP_WORDSZ _MIPS_SZPTR +-# define ALIGNMENT (_MIPS_SZPTR/8) +-# if CPP_WORDSZ != 64 ++# ifdef ULTRIX ++# define OS_TYPE "ULTRIX" ++# define ALIGNMENT 4 ++# endif ++# ifdef RISCOS ++# define OS_TYPE "RISCOS" ++# define ALIGNMENT 4 /* Required by hardware */ ++# endif ++# ifdef IRIX5 ++# define OS_TYPE "IRIX5" ++# define MPROTECT_VDB ++# ifdef _MIPS_SZPTR ++# define CPP_WORDSZ _MIPS_SZPTR ++# define ALIGNMENT (_MIPS_SZPTR/8) ++# if CPP_WORDSZ != 64 ++# define ALIGN_DOUBLE ++# endif ++# else ++# define ALIGNMENT 4 + # define ALIGN_DOUBLE + # endif +-# else +-# define ALIGNMENT 4 +-# define ALIGN_DOUBLE +-# endif +-# define DYNAMIC_LOADING +-# endif ++# define DYNAMIC_LOADING ++# endif ++# endif + # endif + + # ifdef RS6000 +diff -ur gc/mach_dep.c w3m/gc/mach_dep.c +--- gc/mach_dep.c Tue Jan 4 14:46:50 2000 ++++ gc/mach_dep.c Fri May 26 00:34:11 2000 +@@ -74,6 +74,21 @@ + # ifdef RT + register long TMP_SP; /* must be bound to r11 */ + # endif ++# if defined(MIPS) && defined(LINUX) ++# define call_push(x) asm("move $4," x ";"); asm("jal GC_push_one") ++ call_push("$2"); ++ call_push("$3"); ++ call_push("$16"); ++ call_push("$17"); ++ call_push("$18"); ++ call_push("$19"); ++ call_push("$20"); ++ call_push("$21"); ++ call_push("$22"); ++ call_push("$23"); ++ call_push("$30"); ++# undef call_push ++# endif /* MIPS && LINUX */ + # ifdef VAX + /* VAX - generic code below does not work under 4.2 */ + /* r1 through r5 are caller save, and therefore */ +@@ -338,7 +353,9 @@ + # if !(defined M68K) && !(defined VAX) && !(defined RT) + # if !(defined SPARC) && !(defined I386) && !(defined NS32K) + # if !defined(POWERPC) && !defined(UTS4) ++# if (!defined(MIPS) && !defined(LINUX)) + --> bad news <-- ++# endif + # endif + # endif + # endif +diff -ur gc/misc.c w3m/gc/misc.c +--- gc/misc.c Tue Jan 4 14:46:50 2000 ++++ gc/misc.c Fri May 26 00:52:59 2000 +@@ -433,7 +433,8 @@ + # ifdef MSWIN32 + GC_init_win32(); + # endif +-# if defined(LINUX) && (defined(POWERPC) || defined(ALPHA) || defined(SPARC)) ++# if defined(LINUX) && (defined(POWERPC) || defined(ALPHA) || \ ++ defined(SPARC) || defined(MIPS)) + GC_init_linux_data_start(); + # endif + # ifdef SOLARIS_THREADS +diff -ur gc/os_dep.c w3m/gc/os_dep.c +--- gc/os_dep.c Tue Jan 4 14:46:50 2000 ++++ gc/os_dep.c Fri May 26 00:37:07 2000 +@@ -72,7 +72,8 @@ + # define NEED_FIND_LIMIT + # endif + +-# if defined(LINUX) && (defined(POWERPC) || defined(SPARC) || defined(ALPHA)) ++# if defined(LINUX) && (defined(POWERPC) || defined(SPARC) || \ ++ defined(ALPHA) || defined(MIPS)) + # define NEED_FIND_LIMIT + # endif + +@@ -139,7 +140,8 @@ + # define OPT_PROT_EXEC 0 + #endif + +-#if defined(LINUX) && (defined(POWERPC) || defined(SPARC) || defined(ALPHA)) ++#if defined(LINUX) && (defined(POWERPC) || defined(SPARC) || \ ++ defined(ALPHA) || defined(MIPS)) + /* The I386 case can be handled without a search. The Alpha case */ + /* used to be handled differently as well, but the rules changed */ + /* for recent Linux versions. This seems to be the easiest way to */ diff --git a/Patches/newsos6 b/Patches/newsos6 new file mode 100644 index 0000000..4205511 --- /dev/null +++ b/Patches/newsos6 @@ -0,0 +1,27 @@ +diff -ur gc/Makefile gc/Makefile +--- gc/Makefile Sat Jul 24 02:53:34 1999 ++++ gc/Makefile Tue Nov 30 14:29:50 1999 +@@ -7,7 +7,7 @@ + # and runs some tests of collector and cords. Does not add cords or + # c++ interface to gc.a + # cord/de - builds dumb editor based on cords. +-ABI_FLAG= ++ABI_FLAG=-KPIC + CC=cc $(ABI_FLAG) + CXX=CC $(ABI_FLAG) + AS=as $(ABI_FLAG) +Only in gc: Makefile.back +Only in gc: Makefile.orig +diff -ur gc/gcconfig.h gc/gcconfig.h +--- gc/gcconfig.h Fri Jul 9 05:03:22 1999 ++++ gc/gcconfig.h Tue Nov 30 14:30:11 1999 +@@ -64,7 +64,8 @@ + # endif + # if defined(mips) || defined(__mips) + # define MIPS +-# if defined(ultrix) || defined(__ultrix) || defined(__NetBSD__) ++# if defined(ultrix) || defined(__ultrix) || defined(__NetBSD__) ||\ ++ defined(nec_ews) || defined(__sony_news) + # define ULTRIX + # else + # if defined(_SYSTYPE_SVR4) || defined(SYSTYPE_SVR4) || defined(__SYSTYPE_SVR4__) diff --git a/Patches/os2 b/Patches/os2 new file mode 100644 index 0000000..7067d71 --- /dev/null +++ b/Patches/os2 @@ -0,0 +1,39 @@ +--- w3m-0.1.10/XMakefile Thu Jun 8 13:26:04 2000 ++++ w3m-0.1.10-6/XMakefile Sun Jun 11 16:37:18 2000 +@@ -8,7 +8,7 @@ + LOBJS=terms.o conv.o url.o ftp.o anchor.o mimehead.o hash.o tagtable.o + LLOBJS=version.o + ALIBOBJS=Str.o indep.o regex.o textlist.o parsetag.o +-ALIB=libindep.a ++ALIB=indep.a + ALLOBJS=$(OBJS) $(LOBJS) $(LLOBJS) + + TARGET=w3m$(EXT) +@@ -31,13 +31,13 @@ + $(CC) $(CFLAGS) -o $(TARGET) $(ALLOBJS) $(LIBS) + + $(ALIB): $(ALIBOBJS) +- $(AR) rv $(ALIB) $(ALIBOBJS) ++ $(AR) srv $(ALIB) $(ALIBOBJS) + $(RANLIB) $(ALIB) + + $(OBJS): fm.h funcname1.h + + tagtable.c: html.h tagtable.tab mktable$(EXT) +- ./mktable 100 tagtable.tab > tagtable.c ++ mktable 100 tagtable.tab > tagtable.c + + func.o: funcname.c + keybind.o: funcname2.h +--- w3m-0.1.10/gc/os_dep.c Tue Jan 4 14:46:50 2000 ++++ w3m-0.1.10-6/gc/os_dep.c Sun Jun 11 16:37:16 2000 +@@ -732,7 +732,9 @@ + if (!(flags & OBJWRITE)) continue; + if (!(flags & OBJREAD)) continue; + if (flags & OBJINVALID) { ++#ifndef __EMX__ + GC_err_printf0("Object with invalid pages?\n"); ++#endif + continue; + } + GC_add_roots_inner(O32_BASE(seg), O32_BASE(seg)+O32_SIZE(seg), FALSE); diff --git a/README b/README new file mode 100644 index 0000000..8778d80 --- /dev/null +++ b/README @@ -0,0 +1,3 @@ +If you can read English, see doc/*. +If you can read Japanese, see doc-jp/*. +If you can read both, read both and correct English. :-) diff --git a/Str.c b/Str.c new file mode 100644 index 0000000..9047a28 --- /dev/null +++ b/Str.c @@ -0,0 +1,556 @@ +/* $Id: Str.c,v 1.1 2001/11/08 05:14:08 a-ito Exp $ */ +/* + * String manipulation library for Boehm GC + * + * (C) Copyright 1998-1999 by Akinori Ito + * + * This software may be redistributed freely for this purpose, in full + * or in part, provided that this entire copyright notice is included + * on any copies of this software and applications and derivations thereof. + * + * This software is provided on an "as is" basis, without warranty of any + * kind, either expressed or implied, as to any matter including, but not + * limited to warranty of fitness of purpose, or merchantability, or + * results obtained from use of this software. + */ +#include +#include +#include +#include +#ifdef __EMX__ +#include +#endif +#include "Str.h" +#include "myctype.h" + +#define INITIAL_STR_SIZE 32 + +#ifdef STR_DEBUG +/* This is obsolete, because "Str" can handle a '\0' character now. */ +#define STR_LENGTH_CHECK(x) if (((x)->ptr==0&&(x)->length!=0)||(strlen((x)->ptr)!=(x)->length))abort(); +#else /* not STR_DEBUG */ +#define STR_LENGTH_CHECK(x) +#endif /* not STR_DEBUG */ + +Str +Strnew() +{ + Str x = GC_MALLOC(sizeof(struct _Str)); + x->ptr = GC_MALLOC_ATOMIC(INITIAL_STR_SIZE); + x->ptr[0] = '\0'; + x->area_size = INITIAL_STR_SIZE; + x->length = 0; + return x; +} + +Str +Strnew_size(int n) +{ + Str x = GC_MALLOC(sizeof(struct _Str)); + x->ptr = GC_MALLOC_ATOMIC(n + 1); + x->ptr[0] = '\0'; + x->area_size = n + 1; + x->length = 0; + return x; +} + +Str +Strnew_charp(char *p) +{ + Str x; + int n; + + if (p == NULL) + return Strnew(); + x = GC_MALLOC(sizeof(struct _Str)); + n = strlen(p) + 1; + x->ptr = GC_MALLOC_ATOMIC(n); + x->area_size = n; + x->length = n - 1; + bcopy((void *)p, (void*)x->ptr, n); + return x; +} + +Str +Strnew_m_charp(char *p,...) +{ + va_list ap; + Str r = Strnew(); + + va_start(ap, p); + while (p != NULL) { + Strcat_charp(r, p); + p = va_arg(ap, char *); + } + return r; +} + +Str +Strnew_charp_n(char *p, int n) +{ + Str x; + + if (p == NULL) + return Strnew_size(n); + x = GC_MALLOC(sizeof(struct _Str)); + x->ptr = GC_MALLOC_ATOMIC(n + 1); + x->area_size = n + 1; + x->length = n; + bcopy((void *)p, (void *)x->ptr, n); + x->ptr[n] = '\0'; + return x; +} + +Str +Strdup(Str s) +{ + Str n = Strnew_size(s->length); + STR_LENGTH_CHECK(s); + Strcopy(n, s); + return n; +} + +void +Strclear(Str s) +{ + s->length = 0; + s->ptr[0] = '\0'; +} + +void +Strfree(Str x) +{ + GC_free(x->ptr); + GC_free(x); +} + +void +Strcopy(Str x, Str y) +{ + STR_LENGTH_CHECK(x); + STR_LENGTH_CHECK(y); + if (x->area_size < y->length + 1) { + GC_free(x->ptr); + x->ptr = GC_MALLOC_ATOMIC(y->length + 1); + x->area_size = y->length + 1; + } + bcopy((void *)y->ptr, (void *)x->ptr, y->length + 1); + x->length = y->length; +} + +void +Strcopy_charp(Str x, char *y) +{ + int len; + + STR_LENGTH_CHECK(x); + if (y == NULL) { + x->length = 0; + return; + } + len = strlen(y); + if (x->area_size < len + 1) { + GC_free(x->ptr); + x->ptr = GC_MALLOC_ATOMIC(len + 1); + x->area_size = len + 1; + } + bcopy((void *)y, (void *)x->ptr, len + 1); + x->length = len; +} + +void +Strcopy_charp_n(Str x, char *y, int n) +{ + int len = n; + + STR_LENGTH_CHECK(x); + if (y == NULL) { + x->length = 0; + return; + } + if (x->area_size < len + 1) { + GC_free(x->ptr); + x->ptr = GC_MALLOC_ATOMIC(len + 1); + x->area_size = len + 1; + } + bcopy((void *)y, (void *)x->ptr, n); + x->ptr[n] = '\0'; + x->length = n; +} + +void +Strcat_charp_n(Str x, char *y, int n) +{ + int newlen; + + STR_LENGTH_CHECK(x); + if (y == NULL) + return; + newlen = x->length + n + 1; + if (x->area_size < newlen) { + char *old = x->ptr; + newlen = newlen * 3 / 2; + x->ptr = GC_MALLOC_ATOMIC(newlen); + x->area_size = newlen; + bcopy((void *)old, (void *)x->ptr, x->length); + GC_free(old); + } + bcopy((void *)y, (void *)&x->ptr[x->length], n); + x->length += n; + x->ptr[x->length] = '\0'; +} + +void +Strcat(Str x, Str y) +{ + STR_LENGTH_CHECK(y); + Strcat_charp_n(x, y->ptr, y->length); +} + +void +Strcat_charp(Str x, char *y) +{ + if (y == NULL) + return; + Strcat_charp_n(x, y, strlen(y)); +} + +void +Strcat_m_charp(Str x,...) +{ + va_list ap; + char *p; + + va_start(ap, x); + while ((p = va_arg(ap, char *)) != NULL) + Strcat_charp_n(x, p, strlen(p)); +} + +void +Strgrow(Str x) +{ + char *old = x->ptr; + int newlen; + newlen = x->length * 6 / 5; + if (newlen == x->length) + newlen += 2; + x->ptr = GC_MALLOC_ATOMIC(newlen); + x->area_size = newlen; + bcopy((void *)old, (void *)x->ptr, x->length); + GC_free(old); +} + +Str +Strsubstr(Str s, int beg, int len) +{ + Str new_s; + int i; + + STR_LENGTH_CHECK(s); + new_s = Strnew(); + if (beg >= s->length) + return new_s; + for (i = 0; i < len && beg + i < s->length; i++) + Strcat_char(new_s, s->ptr[beg + i]); + return new_s; +} + +void +Strlower(Str s) +{ + int i; + STR_LENGTH_CHECK(s); + for (i = 0; i < s->length; i++) + s->ptr[i] = tolower(s->ptr[i]); +} + +void +Strupper(Str s) +{ + int i; + STR_LENGTH_CHECK(s); + for (i = 0; i < s->length; i++) + s->ptr[i] = toupper(s->ptr[i]); +} + +void +Strchop(Str s) +{ + STR_LENGTH_CHECK(s); + while ((s->ptr[s->length - 1] == '\n' || s->ptr[s->length - 1] == '\r') && + s->length > 0) { + s->length--; + } + s->ptr[s->length] = '\0'; +} + +void +Strinsert_char(Str s, int pos, char c) +{ + int i; + STR_LENGTH_CHECK(s); + if (pos < 0 || s->length < pos) + return; + if (s->length + 2 > s->area_size) + Strgrow(s); + for (i = s->length; i > pos; i--) + s->ptr[i] = s->ptr[i - 1]; + s->ptr[++s->length] = '\0'; + s->ptr[pos] = c; +} + +void +Strinsert_charp(Str s, int pos, char *p) +{ + STR_LENGTH_CHECK(s); + while (*p) + Strinsert_char(s, pos++, *(p++)); +} + +void +Strdelete(Str s, int pos, int n) +{ + int i; + STR_LENGTH_CHECK(s); + if (s->length <= pos + n) { + s->ptr[pos] = '\0'; + s->length = pos; + return; + } + for (i = pos; i < s->length - n; i++) + s->ptr[i] = s->ptr[i + n]; + s->ptr[i] = '\0'; + s->length = i; +} + +void +Strtruncate(Str s, int pos) +{ + STR_LENGTH_CHECK(s); + s->ptr[pos] = '\0'; + s->length = pos; +} + +void +Strshrink(Str s, int n) +{ + STR_LENGTH_CHECK(s); + if (n >= s->length) { + s->length = 0; + s->ptr[0] = '\0'; + } + else { + s->length -= n; + s->ptr[s->length] = '\0'; + } +} + +void +Strremovefirstspaces(Str s) +{ + int i; + + STR_LENGTH_CHECK(s); + for (i = 0; i < s->length && IS_SPACE(s->ptr[i]); i++); + if (i == 0) + return; + Strdelete(s, 0, i); +} + +void +Strremovetrailingspaces(Str s) +{ + int i; + + STR_LENGTH_CHECK(s); + for (i = s->length - 1; i >= 0 && IS_SPACE(s->ptr[i]); i--); + s->length = i + 1; + s->ptr[i + 1] = '\0'; +} + +Str +Stralign_left(Str s, int width) +{ + Str n; + int i; + + STR_LENGTH_CHECK(s); + if (s->length >= width) + return Strdup(s); + n = Strnew_size(width); + Strcopy(n, s); + for (i = s->length; i < width; i++) + Strcat_char(n, ' '); + return n; +} + +Str +Stralign_right(Str s, int width) +{ + Str n; + int i; + + STR_LENGTH_CHECK(s); + if (s->length >= width) + return Strdup(s); + n = Strnew_size(width); + for (i = s->length; i < width; i++) + Strcat_char(n, ' '); + Strcat(n, s); + return n; +} + +Str +Stralign_center(Str s, int width) +{ + Str n; + int i, w; + + STR_LENGTH_CHECK(s); + if (s->length >= width) + return Strdup(s); + n = Strnew_size(width); + w = (width - s->length) / 2; + for (i = 0; i < w; i++) + Strcat_char(n, ' '); + Strcat(n, s); + for (i = w + s->length; i < width; i++) + Strcat_char(n, ' '); + return n; +} + +#define SP_NORMAL 0 +#define SP_PREC 1 +#define SP_PREC2 2 + +Str +Sprintf(char *fmt,...) +{ + int len = 0; + int status = SP_NORMAL; + int p; + char *f; + Str s; + va_list ap; + + va_start(ap, fmt); + for (f = fmt; *f; f++) { + redo: + switch (status) { + case SP_NORMAL: + if (*f == '%') { + status = SP_PREC; + p = 0; + } + else + len++; + break; + case SP_PREC: + if (IS_ALPHA(*f)) { + /* conversion char. */ + double vd; + int vi; + char *vs; + void *vp; + + switch (*f) { + case 'l': + case 'h': + case 'L': + case 'w': + continue; + case 'd': + case 'i': + case 'o': + case 'x': + case 'X': + case 'u': + vi = va_arg(ap, int); + len += (p > 0) ? p : 10; + break; + case 'f': + case 'g': + case 'e': + case 'G': + case 'E': + vd = va_arg(ap, double); + len += (p > 0) ? p : 15; + break; + case 'c': + len += 1; + vi = va_arg(ap, int); + break; + case 's': + vs = va_arg(ap, char *); + vi = strlen(vs); + len += (p > vi) ? p : vi; + break; + case 'p': + vp = va_arg(ap, void *); + len += 10; + break; + case 'n': + vp = va_arg(ap, void *); + break; + } + status = SP_NORMAL; + } + else if (IS_DIGIT(*f)) + p = p * 10 + *f - '0'; + else if (*f == '.') + status = SP_PREC2; + else if (*f == '%') { + status = SP_NORMAL; + len++; + } + break; + case SP_PREC2: + if (IS_ALPHA(*f)) { + status = SP_PREC; + goto redo; + } + break; + } + } + va_end(ap); + s = Strnew_size(len * 2); + va_start(ap, fmt); + vsprintf(s->ptr, fmt, ap); + va_end(ap); + s->length = strlen(s->ptr); + if (s->length > len * 2) { + fprintf(stderr, "Sprintf: string too long\n"); + exit(1); + } + return s; +} + +Str +Strfgets(FILE * f) +{ + Str s = Strnew(); + char c; + while (1) { + c = fgetc(f); + if (feof(f) || ferror(f)) + break; + Strcat_char(s, c); + if (c == '\n') + break; + } + return s; +} + +Str +Strfgetall(FILE * f) +{ + Str s = Strnew(); + char c; + while (1) { + c = fgetc(f); + if (feof(f) || ferror(f)) + break; + Strcat_char(s, c); + } + return s; +} diff --git a/Str.h b/Str.h new file mode 100644 index 0000000..b018c6a --- /dev/null +++ b/Str.h @@ -0,0 +1,83 @@ +/* $Id: Str.h,v 1.1 2001/11/08 05:14:10 a-ito Exp $ */ +/* + * String manipulation library for Boehm GC + * + * (C) Copyright 1998-1999 by Akinori Ito + * + * This software may be redistributed freely for this purpose, in full + * or in part, provided that this entire copyright notice is included + * on any copies of this software and applications and derivations thereof. + * + * This software is provided on an "as is" basis, without warranty of any + * kind, either expressed or implied, as to any matter including, but not + * limited to warranty of fitness of purpose, or merchantability, or + * results obtained from use of this software. + */ +#ifndef GC_STR_H +#define GC_STR_H +#include +#include +#ifdef __EMX__ +#define strcasecmp stricmp +#define strncasecmp strnicmp +#endif + +typedef struct _Str { + char *ptr; + int length; + int area_size; +} *Str; + +Str Strnew(); +Str Strnew_size(int); +Str Strnew_charp(char *); +Str Strnew_charp_n(char *, int); +Str Strnew_m_charp(char *,...); +Str Strdup(Str); +void Strclear(Str); +void Strfree(Str); +void Strcopy(Str, Str); +void Strcopy_charp(Str, char *); +void Strcopy_charp_n(Str, char *, int); +void Strcat_charp_n(Str, char *, int); +void Strcat(Str, Str); +void Strcat_charp(Str, char *); +void Strcat_m_charp(Str,...); +Str Strsubstr(Str, int, int); +void Strinsert_char(Str, int, char); +void Strinsert_charp(Str, int, char *); +void Strdelete(Str, int, int); +void Strtruncate(Str, int); +void Strlower(Str); +void Strupper(Str); +void Strchop(Str); +void Strshrink(Str, int); +void Strshrinkfirst(Str, int); +void Strremovefirstspaces(Str); +void Strremovetrailingspaces(Str); +Str Stralign_left(Str, int); +Str Stralign_right(Str, int); +Str Stralign_center(Str, int); + +Str Sprintf(char *fmt,...); + +Str Strfgets(FILE *); +Str Strfgetall(FILE *); + +void Strgrow(Str s); + +#define Strcat_char(x,y) (((x)->length+1>=(x)->area_size)?Strgrow(x),0:0,(x)->ptr[(x)->length++]=(y),(x)->ptr[(x)->length]=0) +#define Strcmp(x,y) strcmp((x)->ptr,(y)->ptr) +#define Strcmp_charp(x,y) strcmp((x)->ptr,(y)) +#define Strncmp(x,y,n) strncmp((x)->ptr,(y)->ptr,(n)) +#define Strncmp_charp(x,y,n) strncmp((x)->ptr,y,(n)) +#define Strcasecmp(x,y) strcasecmp((x)->ptr,(y)->ptr) +#define Strcasecmp_charp(x,y) strcasecmp((x)->ptr,(y)) +#define Strncasecmp(x,y,n) strncasecmp((x)->ptr,(y)->ptr,(n)) +#define Strncasecmp_charp(x,y,n) strncasecmp((x)->ptr,y,(n)) + +#define Strlastchar(s) ((s)->length>0?(s)->ptr[(s)->length-1]:'\0') +#define Strinsert(s,n,p) Strinsert_charp(s,n,(p)->ptr) +#define Strshrinkfirst(s,n) Strdelete(s,0,n) +#define Strfputs(s,f) fwrite((s)->ptr,1,(s)->length,(f)) +#endif /* not GC_STR_H */ diff --git a/XMakefile b/XMakefile new file mode 100644 index 0000000..23e8b11 --- /dev/null +++ b/XMakefile @@ -0,0 +1,106 @@ +SRCS=main.c file.c buffer.c display.c etc.c search.c linein.c table.c local.c \ + form.c map.c frame.c rc.c menu.c mailcap.c\ + func.c cookie.c history.c backend.c $(KEYBIND_SRC) +OBJS=main.o file.o buffer.o display.o etc.o search.o linein.o table.o local.o\ + form.o map.o frame.o rc.o menu.o mailcap.o\ + func.o cookie.o history.o backend.o $(KEYBIND_OBJ) +LSRCS=terms.c conv.c url.c ftp.c anchor.c mimehead.c hash.c parsetagx.c\ + tagtable.c istream.c +LOBJS=terms.o conv.o url.o ftp.o anchor.o mimehead.o hash.o parsetagx.o\ + tagtable.o istream.o +LLOBJS=version.o +ALIBOBJS=Str.o indep.o regex.o textlist.o parsetag.o myctype.o +ALIB=libindep.a +ALLOBJS=$(OBJS) $(LOBJS) $(LLOBJS) + +TARGET=w3m$(EXT) +BOOKMARKER=w3mbookmark$(EXT) +HELPER=w3mhelperpanel$(EXT) +TARGETS=$(TARGET) $(BOOKMARKER) $(HELPER) + +INCLUDES=-I. + +DEFS=$(INCLUDES) # -DDEBUG +CFLAGS=$(MYCFLAGS) $(DEFS) +LIBS=-L. -lindep $(GCLIB) $(MATHLIB) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) +INSTALL=sh install.sh +INSTALL2=sh ../install.sh +AR=ar + +all: $(TARGETS) + +$(TARGET): $(ALLOBJS) $(ALIB) $(GCTARGET) + $(CC) $(CFLAGS) -o $(TARGET) $(ALLOBJS) $(LIBS) + +$(ALIB): $(ALIBOBJS) + $(AR) rv $(ALIB) $(ALIBOBJS) + $(RANLIB) $(ALIB) + +$(OBJS): fm.h funcname1.h + +tagtable.c: html.h tagtable.tab mktable$(EXT) + ./mktable 100 tagtable.tab > tagtable.c + +func.o: funcname.c +keybind.o: funcname2.h +keybind_lynx.o: funcname2.h +parsetagx.o: html.c + +funcname.c: funcname.tab + awk -f funcname0.awk funcname.tab > funcname.c + +funcname1.h: funcname.tab + awk -f funcname1.awk funcname.tab > funcname1.h + +funcname2.h: funcname.tab + awk -f funcname2.awk funcname.tab > funcname2.h + +mktable$(EXT): mktable.o hash.o $(ALIB) $(GCTARGET) + $(CC) $(CFLAGS) -o mktable$(EXT) mktable.o hash.o $(LIBS) + +$(BOOKMARKER): w3mbookmark.o $(ALIB) $(GCTARGET) + $(CC) $(CFLAGS) -o $(BOOKMARKER) w3mbookmark.o $(LIBS) + +$(HELPER): w3mhelperpanel.o $(ALIB) $(GCTARGET) + $(CC) $(CFLAGS) -o $(HELPER) w3mhelperpanel.o $(LIBS) + +gc/gc.a: + cd gc; make CC='$(CC)' CFLAGS='$(GCCFLAGS)' + +install: $(TARGETS) + -$(MKDIR) $(DESTDIR)$(BIN_DIR) + -$(MKDIR) $(DESTDIR)$(HELP_DIR) + -$(MKDIR) $(DESTDIR)$(LIB_DIR) + $(INSTALL) -m 755 $(TARGET) $(DESTDIR)$(BIN_DIR)/$(TARGET) + $(INSTALL) -m 644 w3mhelp-w3m_en.html $(DESTDIR)$(HELP_DIR)/w3mhelp-w3m_en.html + $(INSTALL) -m 644 w3mhelp-w3m_ja.html $(DESTDIR)$(HELP_DIR)/w3mhelp-w3m_ja.html + $(INSTALL) -m 644 w3mhelp-lynx_en.html $(DESTDIR)$(HELP_DIR)/w3mhelp-lynx_en.html + $(INSTALL) -m 644 w3mhelp-lynx_ja.html $(DESTDIR)$(HELP_DIR)/w3mhelp-lynx_ja.html + $(INSTALL) -m 644 $(HELP_FILE) $(DESTDIR)$(HELP_DIR)/w3mhelp.html + for d in $(BOOKMARKER) $(HELPER); do $(INSTALL) -m 755 $$d $(DESTDIR)$(LIB_DIR)/$$d; done + (cd scripts; for i in *.cgi; do $(INSTALL2) -m 755 $$i $(DESTDIR)$(LIB_DIR)/$$i; done) + +uninstall: + -$(RM) $(BIN_DIR)/$(TARGET) + -$(RM) $(HELP_DIR)/w3mhelp-lynx_en.html + -$(RM) $(HELP_DIR)/w3mhelp-lynx_ja.html + -$(RM) $(HELP_DIR)/w3mhelp-w3m_en.html + -$(RM) $(HELP_DIR)/w3mhelp-w3m_ja.html + -$(RM) $(HELP_DIR)/w3mhelp.html + +clean: sweep + rm -f *.o *.a $(TARGETS) mktable$(EXT) + +sweep: + -rm -f core *~ *.bak *.orig *.rej + +depend: + makedepend $(CFLAGS) *.c + +dist: + cd ..; mv w3m w3m-$(VERSION); tar cvfz w3m-$(VERSION).tar.gz w3m-$(VERSION); mv w3m-$(VERSION) w3m + +bindist: + cd ..; mv w3m w3m-$(VERSION); tar cvfz w3m-$(VERSION)-$(MODEL).tar.gz w3m-$(VERSION)/{w3m*,doc*,Bonus*,README,scripts}; mv w3m-$(VERSION) w3m + +# DO NOT DELETE diff --git a/XMakefile.dist b/XMakefile.dist new file mode 100644 index 0000000..6d907c7 --- /dev/null +++ b/XMakefile.dist @@ -0,0 +1,106 @@ +SRCS=main.c file.c buffer.c display.c etc.c search.c linein.c table.c local.c \ + form.c map.c frame.c rc.c menu.c mailcap.c\ + func.c cookie.c history.c $(KEYBIND_SRC) +OBJS=main.o file.o buffer.o display.o etc.o search.o linein.o table.o local.o\ + form.o map.o frame.o rc.o menu.o mailcap.o\ + func.o cookie.o history.o $(KEYBIND_OBJ) +LSRCS=terms.c conv.c url.c ftp.c anchor.c mimehead.c hash.c parsetagx.c\ + tagtable.c istream.c +LOBJS=terms.o conv.o url.o ftp.o anchor.o mimehead.o hash.o parsetagx.o\ + tagtable.o istream.o +LLOBJS=version.o +ALIBOBJS=Str.o indep.o regex.o textlist.o parsetag.o myctype.o +ALIB=libindep.a +ALLOBJS=$(OBJS) $(LOBJS) $(LLOBJS) + +TARGET=w3m$(EXT) +BOOKMARKER=w3mbookmark$(EXT) +HELPER=w3mhelperpanel$(EXT) +TARGETS=$(TARGET) $(BOOKMARKER) $(HELPER) + +INCLUDES=-I. + +DEFS=$(INCLUDES) # -DDEBUG +CFLAGS=$(MYCFLAGS) $(DEFS) +LIBS=-L. -lindep $(GCLIB) $(MATHLIB) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) +INSTALL=sh install.sh +INSTALL2=sh ../install.sh +AR=ar + +all: $(TARGETS) + +$(TARGET): $(ALLOBJS) $(ALIB) $(GCTARGET) + $(CC) $(CFLAGS) -o $(TARGET) $(ALLOBJS) $(LIBS) + +$(ALIB): $(ALIBOBJS) + $(AR) rv $(ALIB) $(ALIBOBJS) + $(RANLIB) $(ALIB) + +$(OBJS): fm.h funcname1.h + +tagtable.c: html.h tagtable.tab mktable$(EXT) + ./mktable 100 tagtable.tab > tagtable.c + +func.o: funcname.c +keybind.o: funcname2.h +keybind_lynx.o: funcname2.h +parsetagx.o: html.c + +funcname.c: funcname.tab + awk -f funcname0.awk funcname.tab > funcname.c + +funcname1.h: funcname.tab + awk -f funcname1.awk funcname.tab > funcname1.h + +funcname2.h: funcname.tab + awk -f funcname2.awk funcname.tab > funcname2.h + +mktable$(EXT): mktable.o hash.o $(ALIB) $(GCTARGET) + $(CC) $(CFLAGS) -o mktable$(EXT) mktable.o hash.o $(LIBS) + +$(BOOKMARKER): w3mbookmark.o $(ALIB) $(GCTARGET) + $(CC) $(CFLAGS) -o $(BOOKMARKER) w3mbookmark.o $(LIBS) + +$(HELPER): w3mhelperpanel.o $(ALIB) $(GCTARGET) + $(CC) $(CFLAGS) -o $(HELPER) w3mhelperpanel.o $(LIBS) + +gc/gc.a: + cd gc; make CC='$(CC)' CFLAGS='$(GCCFLAGS)' + +install: $(TARGETS) + -$(MKDIR) $(DESTDIR)$(BIN_DIR) + -$(MKDIR) $(DESTDIR)$(HELP_DIR) + -$(MKDIR) $(DESTDIR)$(LIB_DIR) + $(INSTALL) -m 755 $(TARGET) $(DESTDIR)$(BIN_DIR)/$(TARGET) + $(INSTALL) -m 644 w3mhelp-w3m_en.html $(DESTDIR)$(HELP_DIR)/w3mhelp-w3m_en.html + $(INSTALL) -m 644 w3mhelp-w3m_ja.html $(DESTDIR)$(HELP_DIR)/w3mhelp-w3m_ja.html + $(INSTALL) -m 644 w3mhelp-lynx_en.html $(DESTDIR)$(HELP_DIR)/w3mhelp-lynx_en.html + $(INSTALL) -m 644 w3mhelp-lynx_ja.html $(DESTDIR)$(HELP_DIR)/w3mhelp-lynx_ja.html + $(INSTALL) -m 644 $(HELP_FILE) $(DESTDIR)$(HELP_DIR)/w3mhelp.html + for d in $(BOOKMARKER) $(HELPER); do $(INSTALL) -m 755 $$d $(DESTDIR)$(LIB_DIR)/$$d; done + (cd scripts; for i in *.cgi; do $(INSTALL2) -m 755 $$i $(DESTDIR)$(LIB_DIR)/$$i; done) + +uninstall: + -$(RM) $(BIN_DIR)/$(TARGET) + -$(RM) $(HELP_DIR)/w3mhelp-lynx_en.html + -$(RM) $(HELP_DIR)/w3mhelp-lynx_ja.html + -$(RM) $(HELP_DIR)/w3mhelp-w3m_en.html + -$(RM) $(HELP_DIR)/w3mhelp-w3m_ja.html + -$(RM) $(HELP_DIR)/w3mhelp.html + +clean: sweep + rm -f *.o *.a $(TARGETS) mktable$(EXT) + +sweep: + -rm -f core *~ *.bak *.orig *.rej + +depend: + makedepend $(CFLAGS) *.c + +dist: + cd ..; mv w3m w3m-$(VERSION); tar cvfz w3m-$(VERSION).tar.gz w3m-$(VERSION); mv w3m-$(VERSION) w3m + +bindist: + cd ..; mv w3m w3m-$(VERSION); tar cvfz w3m-$(VERSION)-$(MODEL).tar.gz w3m-$(VERSION)/{w3m*,doc*,Bonus*,README,scripts}; mv w3m-$(VERSION) w3m + +# DO NOT DELETE diff --git a/XXMakefile b/XXMakefile new file mode 100644 index 0000000..4ebb0c6 --- /dev/null +++ b/XXMakefile @@ -0,0 +1,128 @@ +#ifdef makefile_parameter + +BIN_DIR = /usr/local/bin +HELP_DIR = /usr/local/lib/w3m +LIB_DIR = /usr/local/lib/w3m +HELP_FILE = w3mhelp-w3m_ja.html +SYS_LIBRARIES = -lgpm -lbsd -lnsl -ltermcap -L/usr/local/ssl/lib -lssl -lcrypto +LOCAL_LIBRARIES = +CC = gcc +MYCFLAGS = -g -Wall -I./gc/include -I/usr/local/ssl/include/openssl -I/usr/local/ssl/include +GCCFLAGS = -g -Wall -I./gc/include -DATOMIC_UNCOLLECTABLE -DNO_EXECUTE_PERMISSION -DALL_INTERIOR_POINTERS -DSILENT -DNO_DEBUGGING #-DNO_SIGNALS +KEYBIND_SRC = keybind.c +KEYBIND_OBJ = keybind.o +EXT= +MATHLIB=-lm +GCLIB=gc/gc.a +GCTARGET=gc/gc.a +RANLIB=ranlib +MKDIR=mkdir -p +VERSION=0.2.1 +MODEL=Linux.i686-monster-ja +#else +SRCS=main.c file.c buffer.c display.c etc.c search.c linein.c table.c local.c \ + form.c map.c frame.c rc.c menu.c mailcap.c\ + func.c cookie.c history.c backend.c $(KEYBIND_SRC) +OBJS=main.o file.o buffer.o display.o etc.o search.o linein.o table.o local.o\ + form.o map.o frame.o rc.o menu.o mailcap.o\ + func.o cookie.o history.o backend.o $(KEYBIND_OBJ) +LSRCS=terms.c conv.c url.c ftp.c anchor.c mimehead.c hash.c parsetagx.c\ + tagtable.c istream.c +LOBJS=terms.o conv.o url.o ftp.o anchor.o mimehead.o hash.o parsetagx.o\ + tagtable.o istream.o +LLOBJS=version.o +ALIBOBJS=Str.o indep.o regex.o textlist.o parsetag.o myctype.o +ALIB=libindep.a +ALLOBJS=$(OBJS) $(LOBJS) $(LLOBJS) + +TARGET=w3m$(EXT) +BOOKMARKER=w3mbookmark$(EXT) +HELPER=w3mhelperpanel$(EXT) +TARGETS=$(TARGET) $(BOOKMARKER) $(HELPER) + +INCLUDES=-I. + +DEFS=$(INCLUDES) # -DDEBUG +CFLAGS=$(MYCFLAGS) $(DEFS) +LIBS=-L. -lindep $(GCLIB) $(MATHLIB) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) +INSTALL=sh install.sh +INSTALL2=sh ../install.sh +AR=ar + +all: $(TARGETS) + +$(TARGET): $(ALLOBJS) $(ALIB) $(GCTARGET) + $(CC) $(CFLAGS) -o $(TARGET) $(ALLOBJS) $(LIBS) + +$(ALIB): $(ALIBOBJS) + $(AR) rv $(ALIB) $(ALIBOBJS) + $(RANLIB) $(ALIB) + +$(OBJS): fm.h funcname1.h + +tagtable.c: html.h tagtable.tab mktable$(EXT) + ./mktable 100 tagtable.tab > tagtable.c + +func.o: funcname.c +keybind.o: funcname2.h +keybind_lynx.o: funcname2.h +parsetagx.o: html.c + +funcname.c: funcname.tab + awk -f funcname0.awk funcname.tab > funcname.c + +funcname1.h: funcname.tab + awk -f funcname1.awk funcname.tab > funcname1.h + +funcname2.h: funcname.tab + awk -f funcname2.awk funcname.tab > funcname2.h + +mktable$(EXT): mktable.o hash.o $(ALIB) $(GCTARGET) + $(CC) $(CFLAGS) -o mktable$(EXT) mktable.o hash.o $(LIBS) + +$(BOOKMARKER): w3mbookmark.o $(ALIB) $(GCTARGET) + $(CC) $(CFLAGS) -o $(BOOKMARKER) w3mbookmark.o $(LIBS) + +$(HELPER): w3mhelperpanel.o $(ALIB) $(GCTARGET) + $(CC) $(CFLAGS) -o $(HELPER) w3mhelperpanel.o $(LIBS) + +gc/gc.a: + cd gc; make CC='$(CC)' CFLAGS='$(GCCFLAGS)' + +install: $(TARGETS) + -$(MKDIR) $(DESTDIR)$(BIN_DIR) + -$(MKDIR) $(DESTDIR)$(HELP_DIR) + -$(MKDIR) $(DESTDIR)$(LIB_DIR) + $(INSTALL) -m 755 $(TARGET) $(DESTDIR)$(BIN_DIR)/$(TARGET) + $(INSTALL) -m 644 w3mhelp-w3m_en.html $(DESTDIR)$(HELP_DIR)/w3mhelp-w3m_en.html + $(INSTALL) -m 644 w3mhelp-w3m_ja.html $(DESTDIR)$(HELP_DIR)/w3mhelp-w3m_ja.html + $(INSTALL) -m 644 w3mhelp-lynx_en.html $(DESTDIR)$(HELP_DIR)/w3mhelp-lynx_en.html + $(INSTALL) -m 644 w3mhelp-lynx_ja.html $(DESTDIR)$(HELP_DIR)/w3mhelp-lynx_ja.html + $(INSTALL) -m 644 $(HELP_FILE) $(DESTDIR)$(HELP_DIR)/w3mhelp.html + for d in $(BOOKMARKER) $(HELPER); do $(INSTALL) -m 755 $$d $(DESTDIR)$(LIB_DIR)/$$d; done + (cd scripts; for i in *.cgi; do $(INSTALL2) -m 755 $$i $(DESTDIR)$(LIB_DIR)/$$i; done) + +uninstall: + -$(RM) $(BIN_DIR)/$(TARGET) + -$(RM) $(HELP_DIR)/w3mhelp-lynx_en.html + -$(RM) $(HELP_DIR)/w3mhelp-lynx_ja.html + -$(RM) $(HELP_DIR)/w3mhelp-w3m_en.html + -$(RM) $(HELP_DIR)/w3mhelp-w3m_ja.html + -$(RM) $(HELP_DIR)/w3mhelp.html + +clean: sweep + rm -f *.o *.a $(TARGETS) mktable$(EXT) + +sweep: + -rm -f core *~ *.bak *.orig *.rej + +depend: + makedepend $(CFLAGS) *.c + +dist: + cd ..; mv w3m w3m-$(VERSION); tar cvfz w3m-$(VERSION).tar.gz w3m-$(VERSION); mv w3m-$(VERSION) w3m + +bindist: + cd ..; mv w3m w3m-$(VERSION); tar cvfz w3m-$(VERSION)-$(MODEL).tar.gz w3m-$(VERSION)/{w3m*,doc*,Bonus*,README,scripts}; mv w3m-$(VERSION) w3m + +# DO NOT DELETE diff --git a/anchor.c b/anchor.c new file mode 100644 index 0000000..6005899 --- /dev/null +++ b/anchor.c @@ -0,0 +1,420 @@ +/* $Id: anchor.c,v 1.1 2001/11/08 05:14:10 a-ito Exp $ */ +#ifdef __EMX__ +#include +#endif + +#include "fm.h" +#include "myctype.h" +#include "regex.h" + +#define FIRST_ANCHOR_SIZE 30 + +AnchorList * +putAnchor(AnchorList * al, char *url, char *target, Anchor ** anchor_return, char *referer, int line, int pos) +{ + int n, i, j; + Anchor *a; + BufferPoint bp; + if (al == NULL) { + al = New(AnchorList); + al->anchors = NULL; + al->nanchor = al->anchormax = 0; + al->acache = -1; + } + if (al->anchormax == 0) { + /* first time; allocate anchor buffer */ + al->anchors = New_N(Anchor, FIRST_ANCHOR_SIZE); + al->anchormax = FIRST_ANCHOR_SIZE; + } + if (al->nanchor == al->anchormax) { /* need realloc */ + al->anchormax *= 2; + al->anchors = New_Reuse(Anchor, al->anchors, + al->anchormax); + } + bp.line = line; + bp.pos = pos; + n = al->nanchor; + if (!n || bpcmp(al->anchors[n-1].start, bp) < 0) + i = n; + else + for (i = 0; i < n; i++) { + if (bpcmp(al->anchors[i].start, bp) >= 0) { + for (j = n; j > i; j--) + al->anchors[j] = al->anchors[j - 1]; + break; + } + } + a = &al->anchors[i]; + a->url = url; + a->target = target; + a->referer = referer; + a->start = bp; + a->end = bp; + al->nanchor++; + if (anchor_return) + *anchor_return = a; + return al; +} + + +Anchor * +registerHref(Buffer * buf, char *url, char *target, char *referer, int line, int pos) +{ + Anchor *a; + buf->href = putAnchor(buf->href, url, target, &a, referer, line, pos); + return a; +} + +Anchor * +registerName(Buffer * buf, char *url, int line, int pos) +{ + Anchor *a; + buf->name = putAnchor(buf->name, url, NULL, &a, NULL, line, pos); + return a; +} + +Anchor * +registerImg(Buffer * buf, char *url, int line, int pos) +{ + Anchor *a; + buf->img = putAnchor(buf->img, url, NULL, &a, NULL, line, pos); + return a; +} + +Anchor * +registerForm(Buffer * buf, FormList * flist, struct parsed_tag * tag, int line, int pos) +{ + Anchor *a; + FormItemList *fi; + + fi = formList_addInput(flist, tag); + if (fi == NULL) + return NULL; + buf->formitem = putAnchor(buf->formitem, + (char *) fi, + flist->target, + &a, + NULL, + line, pos); + fi->anchor_num = buf->formitem->nanchor - 1; + return a; +} + +int +onAnchor(Anchor * a, int line, int pos) +{ + BufferPoint bp; + bp.line = line; + bp.pos = pos; + + if (bpcmp(bp, a->start) < 0) + return -1; + if (bpcmp(a->end, bp) <= 0) + return 1; + return 0; +} + +Anchor * +retrieveAnchor(AnchorList * al, int line, int pos) +{ + Anchor *a; + size_t b, e; + int cmp; + + if (al == NULL || al->nanchor == 0) + return NULL; + + if (al->acache < 0 || al->acache >= al->nanchor) + al->acache = 0; + + for (b = 0, e = al->nanchor - 1; b <= e; al->acache = (b + e) / 2) { + a = &al->anchors[al->acache]; + cmp = onAnchor(a, line, pos); + if (cmp == 0) + return a; + else if (cmp > 0) + b = al->acache + 1; + else if (al->acache == 0) + return NULL; + else + e = al->acache - 1; + } + return NULL; +} + +Anchor * +retrieveCurrentAnchor(Buffer * buf) +{ + if (buf->currentLine == NULL) + return NULL; + return retrieveAnchor(buf->href, + buf->currentLine->linenumber, + buf->pos); +} + +Anchor * +retrieveCurrentImg(Buffer * buf) +{ + if (buf->currentLine == NULL) + return NULL; + return retrieveAnchor(buf->img, + buf->currentLine->linenumber, + buf->pos); +} + +Anchor * +retrieveCurrentForm(Buffer * buf) +{ + if (buf->currentLine == NULL) + return NULL; + return retrieveAnchor(buf->formitem, + buf->currentLine->linenumber, + buf->pos); +} + +Anchor * +searchAnchor(AnchorList * al, char *str) +{ + int i; + Anchor *a; + if (al == NULL) + return NULL; + for (i = 0; i < al->nanchor; i++) { + a = &al->anchors[i]; + if (!strcmp(a->url, str)) + return a; + } + return NULL; +} + +Anchor * +searchURLLabel(Buffer * buf, char *url) +{ + return searchAnchor(buf->name, url); +} + +#ifdef USE_NNTP +static Anchor * +_put_anchor_news(Buffer * buf, char *p1, char *p2, int line, int pos) +{ + Str tmp = Strnew_charp("news:"); + + p1++; + if (*(p2 - 1) == '>') + p2--; + while (p1 < p2) { + Strcat_char(tmp, *(p1++)); + } + return registerHref(buf, tmp->ptr, NULL, NO_REFERER, line, pos); +} +#endif /* USE_NNTP */ + +static Anchor * +_put_anchor_all(Buffer * buf, char *p1, char *p2, int line, int pos) +{ + return registerHref(buf, allocStr(p1, p2 - p1), NULL, NO_REFERER, line, pos); +} + +static void +reseq_anchor0(AnchorList * al, short *seqmap) +{ + int i; + Anchor *a; + + if (!al) + return; + + for (i = 0; i < al->nanchor; i++) { + a = &al->anchors[i]; + if (a->hseq >= 0) { + a->hseq = seqmap[a->hseq]; + } + } +} + +/* renumber anchor */ +static void +reseq_anchor(Buffer * buf) +{ + int i, j, n, nmark = (buf->hmarklist) ? buf->hmarklist->nmark : 0; + short *seqmap; + Anchor *a, *a1; + HmarkerList *ml = NULL; + + if (!buf->href) + return; + + n = nmark; + for (i = 0; i < buf->href->nanchor; i++) { + a = &buf->href->anchors[i]; + if (a->hseq == -2) + n++; + } + + if (n == nmark) + return; + + seqmap = NewAtom_N(short, n); + + for (i = 0; i < n; i++) + seqmap[i] = i; + + n = nmark; + for (i = 0; i < buf->href->nanchor; i++) { + a = &buf->href->anchors[i]; + if (a->hseq == -2) { + a->hseq = n; + a1 = closest_next_anchor(buf->href, NULL, a->start.pos, a->start.line); + a1 = closest_next_anchor(buf->formitem, a1, a->start.pos, a->start.line); + if (a1 && a1->hseq >= 0) { + seqmap[n] = seqmap[a1->hseq]; + for (j = a1->hseq; j < nmark; j++) + seqmap[j]++; + } + ml = putHmarker(ml, a->start.line, a->start.pos, seqmap[n]); + n++; + } + } + + for (i = 0; i < nmark; i++) { + ml = putHmarker(ml, buf->hmarklist->marks[i].line, + buf->hmarklist->marks[i].pos, seqmap[i]); + } + buf->hmarklist = ml; + + reseq_anchor0(buf->href, seqmap); + reseq_anchor0(buf->formitem, seqmap); +} + +/* search regexp and register them as anchors */ +/* returns error message if any */ +static char * +reAnchorAny(Buffer * buf, char *re, Anchor * (*anchorproc) (Buffer *, char *, char *, int, int)) +{ + Line *l; + char *p, *p1, *p2; + Anchor *a; + int i; + int spos, epos; + + if (re == NULL || *re == '\0') { + return NULL; + } + if ((re = regexCompile(re, 1)) != NULL) { + return re; + } + for (l = buf->firstLine; l != NULL; l = l->next) { + p = l->lineBuf; + for (;;) { + if (regexMatch(p, &l->lineBuf[l->len] - p, p == l->lineBuf) == 1) { + matchedPosition(&p1, &p2); + spos = p1 - l->lineBuf; + epos = p2 - l->lineBuf; + for (i = spos; i < epos; i++) { + if (l->propBuf[i] & (PE_ANCHOR | PE_FORM)) + goto _next; + } + a = anchorproc(buf, p1, p2, l->linenumber, p1 - l->lineBuf); + a->end.line = l->linenumber; + a->end.pos = epos; + a->hseq = -2; + for (i = a->start.pos; i < a->end.pos; i++) + l->propBuf[i] |= PE_ANCHOR; + _next: + p = p2; + } + else + break; + } + } + reseq_anchor(buf); + return NULL; +} + +char * +reAnchor(Buffer * buf, char *re) +{ + return reAnchorAny(buf, re, _put_anchor_all); +} + +#ifdef USE_NNTP +char * +reAnchorNews(Buffer * buf, char *re) +{ + return reAnchorAny(buf, re, _put_anchor_news); +} +#endif /* USE_NNTP */ + +#define FIRST_MARKER_SIZE 30 +HmarkerList * +putHmarker(HmarkerList * ml, int line, int pos, int seq) +{ + if (ml == NULL) { + ml = New(HmarkerList); + ml->marks = NULL; + ml->nmark = 0; + ml->markmax = 0; + ml->prevhseq = -1; + } + if (ml->markmax == 0) { + ml->markmax = FIRST_MARKER_SIZE; + ml->marks = New_N(BufferPoint, ml->markmax); +#ifdef __CYGWIN__ + bzero((char *) ml->marks, sizeof(BufferPoint) * ml->markmax); +#else /* not __CYGWIN__ */ + bzero(ml->marks, sizeof(BufferPoint) * ml->markmax); +#endif /* not __CYGWIN__ */ + } + if (seq + 1 > ml->nmark) + ml->nmark = seq + 1; + if (ml->nmark >= ml->markmax) { + ml->markmax = ml->nmark * 2; + ml->marks = New_Reuse(BufferPoint, ml->marks, + ml->markmax); + } + ml->marks[seq].line = line; + ml->marks[seq].pos = pos; + return ml; +} + +Anchor * +closest_next_anchor(AnchorList * a, Anchor * an, int x, int y) +{ + int i; + + if (a == NULL || a->nanchor == 0) + return an; + for (i = 0; i < a->nanchor; i++) { + if (a->anchors[i].hseq < 0) + continue; + if (a->anchors[i].start.line > y || + (a->anchors[i].start.line == y && a->anchors[i].start.pos > x)) { + if (an == NULL || an->start.line > a->anchors[i].start.line || + (an->start.line == a->anchors[i].start.line && + an->start.pos > a->anchors[i].start.pos)) + an = &a->anchors[i]; + } + } + return an; +} + +Anchor * +closest_prev_anchor(AnchorList * a, Anchor * an, int x, int y) +{ + int i; + + if (a == NULL || a->nanchor == 0) + return an; + for (i = 0; i < a->nanchor; i++) { + if (a->anchors[i].hseq < 0) + continue; + if (a->anchors[i].end.line < y || + (a->anchors[i].end.line == y && a->anchors[i].end.pos <= x)) { + if (an == NULL || an->end.line < a->anchors[i].end.line || + (an->end.line == a->anchors[i].end.line && + an->end.pos < a->anchors[i].end.pos)) + an = &a->anchors[i]; + } + } + return an; +} diff --git a/backend.c b/backend.c new file mode 100644 index 0000000..3befd72 --- /dev/null +++ b/backend.c @@ -0,0 +1,405 @@ +#include +#include +#include +#include +#include "fm.h" +#include "gc.h" +#include "terms.h" + + +/* Prototype declaration of internal functions */ +#ifdef HAVE_READLINE +#include +#else /* ! HAVE_READLINE */ +static char *readline( char* ); +#endif /* ! HAVE_READLINE */ +static TextList* split( char * ); + + +/* Prototype declaration of command functions */ +static void get( TextList* ); +static void post( TextList* ); +static void set( TextList* ); +static void show( TextList* ); +static void quit( TextList* ); +static void help( TextList* ); + + +/* Table of command functions */ +struct { + const char *name; + const char *option_string; + const char *help; + void (*func)( TextList* ); +} command_table[] = { + { "get", "[-download_only] URL", "Retrieve URL.", get }, + { "post", "[-download_only] [-target TARGET] [-charset CHARSET]" + " [-enctype ENCTYPE] [-body BODY] [-boundary BOUNDARY] [-length LEN] URL", + "Retrieve URL.", post }, + { "set", "VARIABLE VALUE", "Set VALUE to VARIABLE.", set }, + { "show", "VARIABLE", "Show value of VARIABLE.", show }, + { "quit", "", "Quit program.", quit }, + { "help", "", "Display help messages.", help }, + { NULL, NULL, NULL, NULL }, +}; + + +/* Prototype declaration of functions to manipulate configuration variables */ +static void set_column( TextList* ); +static void show_column( TextList* ); + + +/* Table of configuration variables */ +struct { + const char *name; + void (*set_func)( TextList* ); + void (*show_func)( TextList* ); +} variable_table[] = { + { "column", set_column, show_column }, + { NULL, NULL, NULL }, +}; + + +static char* get_mime_charset_name( int coding ){ + Str r; + switch( coding ){ + case CODE_EUC: + r = Strnew_charp( "euc-japan" ); + break; + case CODE_SJIS: + r = Strnew_charp( "shift_jis" ); + break; + case CODE_JIS_m: + case CODE_JIS_n: + case CODE_JIS_N: + case CODE_JIS_j: + case CODE_JIS_J: + r = Strnew_charp( "iso-2022-jp" ); + break; + default: + return NULL; + } + return r->ptr; +} + + +static void print_headers( Buffer *buf, int len ){ + TextListItem *tp; + + if( buf->document_header ){ + for( tp = buf->document_header->first; tp; tp = tp->next ) + printf( "%s\n", tp->ptr ); + } + printf( "w3m-content-type: %s\n", buf->type ); +#ifdef JP_CHARSET + if( buf->document_code ) + printf( "w3m-content-charset: %s\n", + get_mime_charset_name( buf->document_code ) ); +#endif + if( len > 0 ) + printf( "w3m-content-length: %d\n", len ); +} + + +static void print_formlist( int fid, FormList *fp ){ + Str s = Sprintf( "w3m-form: (formlist (fid %d) (action \"%s\") (method \"%s\")", + fid, + fp->action->ptr, + ( fp->method == FORM_METHOD_POST )? "post" + :( ( fp->method == FORM_METHOD_INTERNAL )? "internal" : "get" ) ); + if( fp->target ) + Strcat( s, Sprintf( " (target \"%s\")", fp->target ) ); + if( fp->charset ) + Strcat( s, Sprintf( " (charset '%s)", get_mime_charset_name(fp->charset) ) ); + if( fp->enctype == FORM_ENCTYPE_MULTIPART ) + Strcat_charp( s, " (enctype \"multipart/form-data\")" ); + if( fp->boundary ) + Strcat( s, Sprintf( " (boundary \"%s\")", fp->boundary ) ); + Strcat_charp( s, ")\n" ); + Strfputs( s, stdout ); +} + + +static void internal_get( char *url, int flag, FormList *request ){ + Buffer *buf; + + backend_halfdump_str = Strnew_charp( "
\n" );
+    do_download = flag;
+    buf = loadGeneralFile( url, NULL, NO_REFERER, 0, request );
+    do_download = FALSE;
+    if( buf != NULL && buf != NO_BUFFER ){
+	if( !strcasecmp( buf->type, "text/html" ) ){
+	    Strcat( backend_halfdump_str,
+		    Sprintf( "
%s\n", buf->buffername ) ); + print_headers( buf, backend_halfdump_str->length ); + if( buf->formlist ){ + FormList *fp; + int fid = 0; + for( fp = buf->formlist; fp; fp = fp->next ) fid++; + for( fp = buf->formlist; fp; fp = fp->next ) + print_formlist( --fid, fp ); + } + printf( "\n" ); + Strfputs( backend_halfdump_str, stdout ); + } else { + if( !strcasecmp( buf->type, "text/plain" ) ){ + Line *lp; + int len = 0; + for( lp = buf->firstLine; lp; lp = lp->next ){ + len += lp->len; + if( lp->lineBuf[lp->len-1] != '\n' ) len++; + } + print_headers( buf, len ); + printf( "\n" ); + saveBuffer( buf, stdout ); + } else { + print_headers( buf, 0 ); + } + } + } +} + + +/* Command: get */ +static void get( TextList *argv ){ + char *p, *url = NULL; + int flag = FALSE; + + while(( p = popText( argv ) )){ + if( !strcasecmp( p, "-download_only" ) ) + flag = TRUE; + else + url = p; + } + if( url ){ + internal_get( url, flag, NULL ); + } +} + + +/* Command: post */ +static void post( TextList *argv ){ + FormList *request; + char *p, *target = NULL, *charset = NULL, + *enctype = NULL, *body = NULL, *boundary = NULL, *url = NULL; + int flag = FALSE, length = 0; + + while(( p = popText( argv ) )){ + if( !strcasecmp( p, "-download_only" ) ) + flag = TRUE; + else if( !strcasecmp( p, "-target" ) ) + target = popText( argv ); + else if( !strcasecmp( p, "-charset" ) ) + charset = popText( argv ); + else if( !strcasecmp( p, "-enctype" ) ) + enctype = popText( argv ); + else if( !strcasecmp( p, "-body" ) ) + body = popText( argv ); + else if( !strcasecmp( p, "-boundary" ) ) + boundary = popText( argv ); + else if( !strcasecmp( p, "-length" ) ) + length = atol( popText( argv ) ); + else + url = p; + } + if( url ){ + request = newFormList( NULL, "post", charset, enctype, target, NULL ); + request->body = body; + request->boundary = boundary; + request->length = ( length > 0 )? length : ( body ? strlen(body) : 0 ); + internal_get( url, flag, request ); + } +} + + +/* Command: set */ +static void set( TextList *argv ){ + if( argv->nitem > 1 ){ + int i; + for( i = 0; variable_table[i].name; i++ ){ + if( !strcasecmp( variable_table[i].name, argv->first->ptr ) ){ + popText( argv ); + if( variable_table[i].set_func ) + variable_table[i].set_func( argv ); + break; + } + } + } +} + + +/* Command: show */ +static void show( TextList *argv ){ + if( argv->nitem >= 1 ){ + int i; + for( i = 0; variable_table[i].name; i++ ){ + if( !strcasecmp( variable_table[i].name, argv->first->ptr ) ){ + popText( argv ); + if( variable_table[i].show_func ) + variable_table[i].show_func( argv ); + break; + } + } + } +} + + +/* Command: quit */ +static void quit( TextList *argv ){ + deleteFiles(); +#ifdef USE_COOKIE + save_cookies(); +#endif /* USE_COOKIE */ + exit(0); +} + + +/* Command: help */ +static void help( TextList *argv ){ + int i; + for( i = 0; command_table[i].name; i++ ) + printf( "%s %s\n %s\n", + command_table[i].name, + command_table[i].option_string, + command_table[i].help ); +} + + +/* Sub command: set COLS */ +static void set_column( TextList *argv ){ + if( argv->nitem == 1 ){ + COLS = atol( argv->first->ptr ); + } +} + +/* Sub command: show COLS */ +static void show_column( TextList *argv ){ + fprintf( stdout, "column=%d\n", COLS ); +} + + +/* Call appropriate command function based on given string */ +static void call_command_function( char *str ){ + int i; + TextList *argv = split( str ); + if( argv->nitem > 0 ){ + for( i = 0; command_table[i].name; i++ ){ + if( !strcasecmp( command_table[i].name, argv->first->ptr ) ){ + popText( argv ); + if( command_table[i].func ) + command_table[i].func( argv ); + break; + } + } + } +} + + +/* Main function */ +int backend( void ){ + char *str; + extern int w3m_dump; /* Declared in main.c. */ + + w3m_dump = FALSE; + w3m_halfdump = FALSE; + if (COLS == 0) COLS = 80; +#ifdef MOUSE + mouse_end(); + use_mouse = FALSE; +#endif /* MOUSE */ + + if( backend_batch_commands ){ + while(( str = popText(backend_batch_commands) )) + call_command_function( str ); + } else { + while(( str = readline( "w3m> " ) )) + call_command_function( str ); + } + quit( NULL ); + return 0; +} + + +/* Dummy function of readline(). */ +#ifndef HAVE_READLINE +static char *readline( char *prompt ){ + Str s; + fputs( prompt, stdout ); + fflush( stdout ); + s = Strfgets( stdin ); + if( feof( stdin ) && (strlen( s->ptr ) == 0) ) + return NULL; + else + return s->ptr; +} +#endif /* ! HAVE_READLINE */ + + +/* Splits a string into a list of tokens and returns that list. */ +static TextList* split( char *p ){ + int in_double_quote = FALSE, in_single_quote = FALSE; + Str s = Strnew(); + TextList* tp = newTextList(); + + for( ; *p; p++ ){ + switch( *p ){ + case '"': + if( in_single_quote ) + Strcat_char( s, '"' ); + else + in_double_quote = !in_double_quote; + break; + case '\'': + if( in_double_quote ) + Strcat_char( s, '\'' ); + else + in_single_quote = !in_single_quote; + break; + case '\\': + if( !in_single_quote ){ + /* Process escape characters. */ + p++; + switch( *p ){ + case 't': + Strcat_char( s, '\t' ); + break; + case 'r': + Strcat_char( s, '\r' ); + break; + case 'f': + Strcat_char( s, '\f' ); + break; + case 'n': + Strcat_char( s, '\n' ); + break; + case '\0': + goto LAST; + default: + Strcat_char( s, *p ); + } + } else { + Strcat_char( s, *p ); + } + break; + case ' ': + case '\t': + case '\r': + case '\f': + case '\n': + /* Separators are detected. */ + if( in_double_quote || in_single_quote ){ + Strcat_char( s, *p ); + } else if( s->length > 0 ){ + pushText( tp, s->ptr ); + s = Strnew(); + } + break; + default: + Strcat_char( s, *p ); + } + } +LAST: + if( s->length > 0 ) + pushText( tp, s->ptr ); + return tp; +} diff --git a/buffer.c b/buffer.c new file mode 100644 index 0000000..4ea4982 --- /dev/null +++ b/buffer.c @@ -0,0 +1,676 @@ +#include "fm.h" + +#ifdef MOUSE +#ifdef USE_GPM +#include +#endif +#if defined(USE_GPM) || defined(USE_SYSMOUSE) +extern int do_getch(); +#define getch() do_getch() +#endif /* USE_GPM */ +#endif /* MOUSE */ + +#ifdef __EMX__ +#include +#include +#endif +char *NullLine = ""; +Lineprop NullProp[] = +{0}; + +/* + * Buffer creation + */ +Buffer * +newBuffer(int width) +{ + Buffer *n; + + n = New(Buffer); + if (n == NULL) + return NULL; + bzero((void *) n, sizeof(Buffer)); + n->width = width; + n->currentURL.scheme = SCM_UNKNOWN; + n->baseURL = NULL; + n->baseTarget = NULL; + n->buffername = ""; + n->bufferprop = BP_NORMAL; + n->clone = New(int); + *n->clone = 1; + n->linelen = 0; + n->trbyte = 0; +#ifdef USE_SSL + n->ssl_certificate = NULL; +#endif + return n; +} + +/* + * Create null buffer + */ +Buffer * +nullBuffer(void) +{ + Buffer *b; + + b = newBuffer(COLS); + b->buffername = "*Null*"; + return b; +} + +/* + * clearBuffer: clear buffer content + */ +void +clearBuffer(Buffer * buf) +{ + buf->firstLine = buf->topLine = buf->currentLine = buf->lastLine = NULL; + buf->allLine = 0; +} + +/* + * discardBuffer: free buffer structure + */ + +void +discardBuffer(Buffer * buf) +{ + int i; + Buffer *b; + + clearBuffer(buf); + for (i = 0; i < MAX_LB; i++) { + b = buf->linkBuffer[i]; + if (b == NULL) + continue; + b->linkBuffer[REV_LB[i]] = NULL; + } + if (buf->savecache) + unlink(buf->savecache); + if (--(*buf->clone)) + return; + if (buf->pagerSource) + ISclose(buf->pagerSource); + if (buf->sourcefile) { + if (buf->real_scheme != SCM_LOCAL || buf->bufferprop & BP_FRAME) + unlink(buf->sourcefile); + } + while (buf->frameset) { + deleteFrameSet(buf->frameset); + buf->frameset = popFrameTree(&(buf->frameQ), NULL, NULL); + } +} + +/* + * namedBuffer: Select buffer which have specified name + */ +Buffer * +namedBuffer(Buffer * first, char *name) +{ + Buffer *buf; + + if (!strcmp(first->buffername, name)) { + return first; + } + for (buf = first; buf->nextBuffer != NULL; buf = buf->nextBuffer) { + if (!strcmp(buf->nextBuffer->buffername, name)) { + return buf->nextBuffer; + } + } + return NULL; +} + +/* + * deleteBuffer: delete buffer + */ +Buffer * +deleteBuffer(Buffer * first, Buffer * delbuf) +{ + Buffer *buf, *b; + + if (first == delbuf && first->nextBuffer != NULL) { + buf = first->nextBuffer; + discardBuffer(first); + return buf; + } + if ((buf = prevBuffer(first, delbuf)) != NULL) { + b = buf->nextBuffer; + buf->nextBuffer = b->nextBuffer; + discardBuffer(b); + } + return first; +} + +/* + * replaceBuffer: replace buffer + */ +Buffer * +replaceBuffer(Buffer * first, Buffer * delbuf, Buffer * newbuf) +{ + Buffer *buf; + + if (delbuf == NULL) { + newbuf->nextBuffer = first; + return newbuf; + } + if (first == delbuf) { + newbuf->nextBuffer = delbuf->nextBuffer; + discardBuffer(delbuf); + return newbuf; + } + if (delbuf && (buf = prevBuffer(first, delbuf))) { + buf->nextBuffer = newbuf; + newbuf->nextBuffer = delbuf->nextBuffer; + discardBuffer(delbuf); + return first; + } + newbuf->nextBuffer = first; + return newbuf; +} + +Buffer * +nthBuffer(Buffer * firstbuf, int n) +{ + int i; + Buffer *buf = firstbuf; + + if (n < 0) + return firstbuf; + for (i = 0; i < n; i++) { + if (buf == NULL) + return NULL; + buf = buf->nextBuffer; + } + return buf; +} + +static void +writeBufferName(Buffer * buf, int n) +{ + Str msg; + int all; + + all = buf->allLine; + if (all == 0 && buf->lastLine != NULL) + all = buf->lastLine->linenumber; + move(n, 0); + msg = Sprintf("<%s> [%d lines]", buf->buffername, all); + if (buf->filename != NULL) { + switch (buf->currentURL.scheme) { + case SCM_LOCAL: + case SCM_LOCAL_CGI: + if (strcmp(buf->currentURL.file, "-")) { + Strcat_char(msg, ' '); + Strcat_charp(msg, buf->filename); + } + break; + case SCM_UNKNOWN: + case SCM_MISSING: + break; + default: + Strcat_char(msg, ' '); + Strcat(msg, parsedURL2Str(&buf->currentURL)); + break; + } + } + addnstr_sup(msg->ptr, COLS - 1); +} + + +/* + * gotoLine: go to line number + */ +void +gotoLine(Buffer * buf, int n) +{ + char msg[32]; + Line *l = buf->firstLine; + + if (l == NULL) + return; + if (buf->pagerSource && !(buf->bufferprop & BP_CLOSE)) { + if (buf->lastLine->linenumber < n) + getNextPage(buf, n - buf->lastLine->linenumber); + while ((buf->lastLine->linenumber < n) && + (getNextPage(buf, 1) != NULL)); + } + if (l->linenumber > n) { + sprintf(msg, "First line is #%ld", l->linenumber); + disp_message(msg, FALSE); + buf->topLine = buf->currentLine = l; + return; + } + if (buf->lastLine->linenumber < n) { + l = buf->lastLine; + sprintf(msg, "Last line is #%ld", buf->lastLine->linenumber); + disp_message(msg, FALSE); + buf->currentLine = l; + buf->topLine = lineSkip(buf, buf->currentLine, - (LASTLINE - 1), FALSE); + return; + } + for (; l != NULL; l = l->next) { + if (l->linenumber >= n) { + buf->currentLine = l; + if (n < buf->topLine->linenumber || + buf->topLine->linenumber + LASTLINE <= n) + buf->topLine = lineSkip(buf, l, -(LASTLINE + 1) / 2, FALSE); + break; + } + } +} + +/* + * gotoRealLine: go to real line number + */ +void +gotoRealLine(Buffer * buf, int n) +{ + char msg[32]; + Line *l = buf->firstLine; + + if (l == NULL) + return; + if (buf->pagerSource && !(buf->bufferprop & BP_CLOSE)) { + if (buf->lastLine->real_linenumber < n) + getNextPage(buf, n - buf->lastLine->real_linenumber); + while ((buf->lastLine->real_linenumber < n) && + (getNextPage(buf, 1) != NULL)); + } + if (l->real_linenumber > n) { + sprintf(msg, "First line is #%ld", l->real_linenumber); + disp_message(msg, FALSE); + buf->topLine = buf->currentLine = l; + return; + } + if (buf->lastLine->real_linenumber < n) { + l = buf->lastLine; + sprintf(msg, "Last line is #%ld", buf->lastLine->real_linenumber); + disp_message(msg, FALSE); + buf->currentLine = l; + buf->topLine = lineSkip(buf, buf->currentLine, - (LASTLINE - 1), FALSE); + return; + } + for (; l != NULL; l = l->next) { + if (l->real_linenumber >= n) { + buf->currentLine = l; + if (n < buf->topLine->real_linenumber || + buf->topLine->real_linenumber + LASTLINE <= n) + buf->topLine = lineSkip(buf, l, -(LASTLINE + 1) / 2, FALSE); + break; + } + } +} + + +static Buffer * +listBuffer(Buffer * top, Buffer * current) +{ + int i, c = 0; + Buffer *buf = top; + + move(0, 0); +#ifdef COLOR + if (useColor) { + setfcolor(basic_color); +#ifdef BG_COLOR + setbcolor(bg_color); +#endif /* BG_COLOR */ + } +#endif /* COLOR */ + clrtobotx(); + for (i = 0; i < LASTLINE; i++) { + if (buf == current) { + c = i; + standout(); + } + writeBufferName(buf, i); + if (buf == current) { + standend(); + clrtoeolx(); + move(i, 0); + toggle_stand(); + } + else + clrtoeolx(); + if (buf->nextBuffer == NULL) { + move(i + 1, 0); + clrtobotx(); + break; + } + buf = buf->nextBuffer; + } + standout(); + message("Buffer selection mode: SPC for select / D for delete buffer", 0, 0); + standend(); +/* + * move(LASTLINE, COLS - 1); */ + move(c, 0); + refresh(); + return buf->nextBuffer; +} + + +/* + * Select buffer visually + */ +Buffer * +selectBuffer(Buffer * firstbuf, Buffer * currentbuf, char *selectchar) +{ + int i, cpoint, /* Current Buffer Number */ + spoint, /* Current Line on Screen */ + maxbuf, sclimit = LASTLINE; /* Upper limit of line * number in + * the * screen */ + Buffer *buf, *topbuf; + char c; + + i = cpoint = 0; + for (buf = firstbuf; buf != NULL; buf = buf->nextBuffer) { + if (buf == currentbuf) + cpoint = i; + i++; + } + maxbuf = i; + + if (cpoint >= sclimit) { + spoint = sclimit / 2; + topbuf = nthBuffer(firstbuf, cpoint - spoint); + } + else { + topbuf = firstbuf; + spoint = cpoint; + } + listBuffer(topbuf, currentbuf); + + for (;;) { + if ((c = getch()) == ESC_CODE) { + if ((c = getch()) == '[' || c == 'O') { + switch (c = getch()) { + case 'A': + c = 'k'; + break; + case 'B': + c = 'j'; + break; + case 'C': + c = ' '; + break; + case 'D': + c = 'B'; + break; + } + } + } +#ifdef __EMX__ + else if(!c) + switch(getch()){ + case K_UP: + c='k'; + break; + case K_DOWN: + c='j'; + break; + case K_RIGHT: + c=' '; + break; + case K_LEFT: + c='B'; + } +#endif + switch (c) { + case CTRL_N: + case 'j': + if (spoint < sclimit - 1) { + if (currentbuf->nextBuffer == NULL) + continue; + writeBufferName(currentbuf, spoint); + currentbuf = currentbuf->nextBuffer; + cpoint++; + spoint++; + standout(); + writeBufferName(currentbuf, spoint); + standend(); + move(spoint, 0); + toggle_stand(); + } + else if (cpoint < maxbuf - 1) { + topbuf = currentbuf; + currentbuf = currentbuf->nextBuffer; + cpoint++; + spoint = 1; + listBuffer(topbuf, currentbuf); + } + break; + case CTRL_P: + case 'k': + if (spoint > 0) { + writeBufferName(currentbuf, spoint); + currentbuf = nthBuffer(topbuf, --spoint); + cpoint--; + standout(); + writeBufferName(currentbuf, spoint); + standend(); + move(spoint, 0); + toggle_stand(); + } + else if (cpoint > 0) { + i = cpoint - sclimit; + if (i < 0) + i = 0; + cpoint--; + spoint = cpoint - i; + currentbuf = nthBuffer(firstbuf, cpoint); + topbuf = nthBuffer(firstbuf, i); + listBuffer(topbuf, currentbuf); + } + break; + default: + *selectchar = c; + return currentbuf; + } +/* + * move(LASTLINE, COLS - 1); + */ + move(spoint, 0); + refresh(); + } +} + + +/* + * Reshape HTML buffer + */ +void +reshapeBuffer(Buffer * buf) +{ + URLFile f; + int top, linenum, cursorY, pos, currentColumn; + AnchorList *formitem; + + init_stream(&f, SCM_LOCAL, NULL); + examineFile(buf->sourcefile, &f); + if (f.stream == NULL) + return; + + if (buf->firstLine == NULL) { + top = 1; + linenum = 1; + } else { + top = buf->topLine->linenumber; + linenum = buf->currentLine->linenumber; + } + cursorY = buf->cursorY; + pos = buf->pos; + currentColumn = buf->currentColumn; + clearBuffer(buf); + while (buf->frameset) { + deleteFrameSet(buf->frameset); + buf->frameset = popFrameTree(&(buf->frameQ), NULL, NULL); + } + + formitem = buf->formitem; + buf->href = NULL; + buf->name = NULL; + buf->img = NULL; + buf->formitem = NULL; + buf->width = INIT_BUFFER_WIDTH; + + loadHTMLstream(&f, buf, NULL, FALSE); + UFclose(&f); + + buf->topLine = buf->firstLine; + buf->lastLine = buf->currentLine; + buf->currentLine = buf->firstLine; + buf->height = LASTLINE + 1; + buf->topLine = lineSkip(buf, buf->topLine, top - 1, FALSE); + gotoLine(buf, linenum); + buf->pos = pos; + buf->currentColumn = currentColumn; + arrangeCursor(buf); + if (buf->check_url & CHK_URL) + chkURL(); +#ifdef USE_NNTP + if (buf->check_url & CHK_NMID) + chkNMID(); +#endif + formResetBuffer(buf, formitem); +} + +/* shallow copy */ +void +copyBuffer(Buffer * a, Buffer * b) +{ + readBufferCache(b); + bcopy((void *) b, (void *) a, sizeof(Buffer)); +} + +Buffer * +prevBuffer(Buffer * first, Buffer * buf) +{ + Buffer *b; + + for (b = first; b != NULL && b->nextBuffer != buf; b = b->nextBuffer); + return b; +} + +#define fwrite1(d, f) (fwrite(&d, sizeof(d), 1, f)==0) +#define fread1(d, f) (fread(&d, sizeof(d), 1, f)==0) + +int +writeBufferCache(Buffer *buf) +{ + Str tmp; + FILE *cache = NULL; + Line *l; +#ifdef ANSI_COLOR + int colorflag; +#endif + + if (buf->savecache) + return -1; + + if (buf->firstLine == NULL) + goto _error1; + + tmp = tmpfname(TMPF_CACHE, NULL); + buf->savecache = tmp->ptr; + cache = fopen(buf->savecache, "w"); + if (!cache) + goto _error1; + + if (fwrite1(buf->currentLine->linenumber, cache) || + fwrite1(buf->topLine->linenumber, cache)) + goto _error; + + for (l = buf->firstLine; l; l = l->next) { + if (fwrite1(l->real_linenumber, cache) || + fwrite1(l->usrflags, cache) || + fwrite1(l->width, cache) || + fwrite1(l->len, cache) || + fwrite(l->lineBuf, 1, l->len, cache) < l->len || + fwrite(l->propBuf, sizeof(Lineprop), l->len, cache) < l->len) + goto _error; +#ifdef ANSI_COLOR + colorflag = l->colorBuf ? 1 : 0; + if (fwrite1(colorflag, cache)) + goto _error; + if (colorflag) { + if (fwrite(l->colorBuf, sizeof(Linecolor), l->len, cache) < l->len) + goto _error; + } +#endif + } + + fclose(cache); + return 0; + _error: + fclose(cache); + unlink(buf->savecache); + _error1: + buf->savecache = NULL; + return -1; +} + +int +readBufferCache(Buffer *buf) +{ + FILE *cache; + Line *l = NULL, *prevl; + long lnum = 0, clnum, tlnum; +#ifdef ANSI_COLOR + int colorflag; +#endif + + if (buf->savecache == NULL) + return -1; + + cache = fopen(buf->savecache, "r"); + if (cache == NULL || + fread1(clnum, cache) || + fread1(tlnum, cache)) { + buf->savecache = NULL; + return -1; + } + + while (!feof(cache)) { + lnum++; + prevl = l; + l = New(Line); + l->prev = prevl; + if (prevl) + prevl->next = l; + else + buf->firstLine = l; + l->linenumber = lnum; + if (lnum == clnum) + buf->currentLine = l; + if (lnum == tlnum) + buf->topLine = l; + if (fread1(l->real_linenumber, cache) || + fread1(l->usrflags, cache) || + fread1(l->width, cache) || + fread1(l->len, cache)) + break; + l->lineBuf = New_N(char, l->len + 1); + fread(l->lineBuf, 1, l->len, cache); + l->lineBuf[l->len] = '\0'; + l->propBuf = New_N(Lineprop, l->len); + fread(l->propBuf, sizeof(Lineprop), l->len, cache); +#ifdef ANSI_COLOR + if (fread1(colorflag, cache)) + break; + if (colorflag) { + l->colorBuf = New_N(Linecolor, l->len); + fread(l->colorBuf, sizeof(Linecolor), l->len, cache); + } else { + l->colorBuf = NULL; + } +#endif + } + buf->lastLine = prevl; + buf->lastLine->next = NULL; + fclose(cache); + unlink(buf->savecache); + buf->savecache = NULL; + return 0; +} diff --git a/config.h b/config.h new file mode 100644 index 0000000..db8e478 --- /dev/null +++ b/config.h @@ -0,0 +1,201 @@ +/* + * Configuration for w3m + */ + +#ifndef _CONFIGURED_ +#define _CONFIGURED_ + +/* User Configuration */ + +/* + If you define DICT, you can use dictionary look-up function + in w3m. See README.dict for detail. +*/ +#undef DICT + +/* + If you define USE_MARK, you can use set-mark (C-SPC), + goto-next-mark (ESC p), goto-next-mark (ESC n) and + mark-by-regexp ("). +*/ +#undef USE_MARK + +/* + If you want to load and save URL history. + */ +#define USE_HISTORY + +/* + BG_COLOR enables w3m to set background color. + */ +#define BG_COLOR + +/* + VIEW_UNSEENOBJECTS enables w3m to make a link to unseen objects. + e.g. background image. + */ +#undef VIEW_UNSEENOBJECTS + +/* + VI_PREC_NUM enables vi-like behavior for '2 SPC' or '2 b' + */ +#undef VI_PREC_NUM + +/* + * Do word fill + */ +#undef FORMAT_NICE + +/* + * Support Gopher protocol + */ +#undef USE_GOPHER + +/* + * Support NNTP + */ +#define USE_NNTP + +/* + * Support ANSI color escape sequences + */ +#define ANSI_COLOR + +/* + * Enable id attribute + */ +#define ID_EXT + +/* + * Save Current-buffer Information + */ +#define BUFINFO + +/* + * Support EGD (Entropy Gathering Daemon) + */ +#undef USE_EGD + +/* + * MENU_MAP enables w3m to show image map link with popup menu. + */ +#define MENU_MAP + +/* + * Use Emacs-like key binding for file name completion + */ +#undef EMACS_LIKE_LINEEDIT + +/* + * Remove line trailing spaces in html buffer. + */ +#undef ENABLE_REMOVE_TRAILINGSPACES + +/**********************************************************/ +#ifdef makefile_parameter + +BIN_DIR = /usr/local/bin +HELP_DIR = /usr/local/lib/w3m +LIB_DIR = /usr/local/lib/w3m +HELP_FILE = w3mhelp-w3m_ja.html +SYS_LIBRARIES = -lgpm -lbsd -lnsl -ltermcap -L/usr/local/ssl/lib -lssl -lcrypto +LOCAL_LIBRARIES = +CC = gcc +MYCFLAGS = -g -Wall -I./gc/include -I/usr/local/ssl/include/openssl -I/usr/local/ssl/include +GCCFLAGS = -g -Wall -I./gc/include -DATOMIC_UNCOLLECTABLE -DNO_EXECUTE_PERMISSION -DALL_INTERIOR_POINTERS -DSILENT -DNO_DEBUGGING #-DNO_SIGNALS +KEYBIND_SRC = keybind.c +KEYBIND_OBJ = keybind.o +EXT= +MATHLIB=-lm +GCLIB=gc/gc.a +GCTARGET=gc/gc.a +RANLIB=ranlib +MKDIR=mkdir -p +VERSION=0.2.1 +MODEL=Linux.i686-monster-ja +#else + + +#define DISPLAY_CODE 'E' + +#define JA 0 +#define EN 1 +#define LANG JA +#define KANJI_SYMBOLS +#define COLOR +#define MOUSE +#define USE_GPM +#undef USE_SYSMOUSE +#define MENU +#define USE_COOKIE +#define USE_SSL +#define USE_SSL_VERIFY +#define FTPPASS_HOSTNAMEGEN +#define SHOW_PARAMS + +#define DEF_EDITOR "/bin/vi" +#define DEF_MAILER "/bin/mail" +#define DEF_EXT_BROWSER "/usr/X11R6/bin/netscape" + +#define LIB_DIR "/usr/local/lib/w3m" +#define HELP_DIR "/usr/local/lib/w3m" +#define HELP_FILE "w3mhelp.html" +#define W3MCONFIG "w3mconfig" + +#define RC_DIR "~/.w3m/" +#define BOOKMARK "bookmark.html" +#define CONFIG_FILE "config" +#define KEYMAP_FILE "keymap" +#define MENU_FILE "menu" +#define COOKIE_FILE "cookie" +#define HISTORY_FILE "history" + +#define USER_MAILCAP RC_DIR "/mailcap" +#define SYS_MAILCAP "/etc/mailcap" +#define USER_MIMETYPES "~/.mime.types" +#define SYS_MIMETYPES "/usr/lib/mime.types" + +#define DEF_SAVE_FILE "index.html" + +#define TERMIOS +#define DIRENT +#define STRCASECMP +#define STRCHR +#define STRERROR +#define SYS_ERRLIST +#undef NOBCOPY +#define HAVE_WAITPID +#define HAVE_WAIT3 +#define HAVE_STRFTIME + +#define GETCWD +#define GETWD +#define READLINK +#define HAVE_SETENV +#define HAVE_PUTENV +#define READLINK + + +#define SETJMP(env) sigsetjmp(env,1) +#define LONGJMP(env,val) siglongjmp(env,val) +#define JMP_BUF sigjmp_buf + +typedef void MySignalHandler; +#define SIGNAL_ARG int _dummy +#define SIGNAL_ARGLIST 0 +#define SIGNAL_RETURN return +/* + If you want to use IPv6, define this symbol. + */ +#undef INET6 + +#undef TABLE_EXPAND +#undef TABLE_NO_COMPACT +#define NOWRAP 1 +#define NEW_FORM 1 +#define MATRIX 1 +#undef NO_FLOAT_H + +#endif /* makefile_parameter */ +#endif /* _CONFIGURED_ */ + diff --git a/configure b/configure new file mode 100755 index 0000000..be39e44 --- /dev/null +++ b/configure @@ -0,0 +1,1712 @@ +#!/bin/sh +# +# Configuration. +# + +# +sysname=`uname -s` +sysversion=`uname -r` +host=`hostname` +platform=`uname -m` + +sysversion1=`echo $sysversion | awk -F. '{print $1}'` +sysversion2=`echo $sysversion | awk -F. '{print $2}'` +sysversion3=`echo $sysversion | awk -F. '{print $3}'` + +echo $sysname $sysversion1 $sysversion2 $sysversion3 /$platform at $host + +if [ -f config.param ] ; then + confhost=`awk 'NR==1{print $4}' config.param` + if [ "$confhost" = "$host" ] ; then + . ./config.param + fi +fi + +echo "# Configuretion at $host" > config.param + +# parameters: + +prefix=/usr/local +all_yes=0 +while [ $# -gt 0 ] +do + case "$1" in + -yes|--yes|-nonstop|--nonstop) + all_yes=1 + echo "Setting all parameters to the default..." + ;; + -prefix|--prefix) + prefix=$2 + shift + ;; + -prefix=*|--prefix=*) + prefix=`expr "$1" : "-*prefix=\(.*\)"` + ;; + -lang=en|--lang=en) + pref_lang=2 + ;; + -lang=ja|--lang=ja) + pref_lang=1 + ;; + -model=baby|--model=baby) + dmodel=1 + ;; + -model=little|--model=little) + dmodel=2 + ;; + -model=mouse|--model=mouse) + dmodel=3 + ;; + -model=cookie|--model=cookie) + dmodel=4 + ;; + -model=monster|--model=monster) + dmodel=5 + ;; + -code=*|--code=*) + def_dcode=`expr "$1" : "-*code=\(.*\)"` + ;; + -cflags=*|--cflags=*) + dcflags=`echo $1 | sed -e 's/-*cflags=//'` + ;; + -help|--help) + echo "-yes, -nonstop Set all parameters to the default" + echo "-prefix=DIR Specify prefix (default: /usr/local)" + echo "-lang=(en|ja) Specify default language" + echo "-model=(baby|little|mouse|cookie|monster)" + echo " Specify default model" + echo "-code=(S|E|j|N|n|m)" + echo " Specify derault kanji code" + echo "-cflags=FLAGS Specify C flags" + echo "-help Display help" + exit 0 + ;; + esac + shift +done + +# Version number of Boehm-GC library comes with w3m. +# version number: JMMAAA J: major MM: minor AAA: alpha +# Alpha number of non-alpha version is 255. +# version 4.14alpha1 => 414002 +mygcversion=500003 + +if [ -z "`echo -n aho | grep n`" ] ; then +Echo() +{ + echo -n "$*" +} +else +Echo() +{ + echo "$*\c" +} +fi + + +do_sigtest() +{ + echo "#include " > _zmachdep.c + if [ "$2" = void ]; then + echo "$1 _handler($2) {}" >> _zmachdep.c + else + echo "$1 _handler($2 x) {}" >> _zmachdep.c + fi + echo "int main(void) { $1 (*hdl)($2); hdl = signal(SIGINT,_handler); return 0; }" >> _zmachdep.c + $cc $cflags -o _zmachdep _zmachdep.c > _zwarning 2>&1 + stat=$? + warning=`cat _zwarning` + rm -f _zwarning +} + +readdir() { + if [ "$all_yes" = 0 ]; then + read __dir + else + __dir=$1 + echo "$1" + fi + if [ -z "$__dir" ]; then + _dir=$1 + else + _dir=`echo "$__dir"|sed -e "s;^~;$HOME;"` + fi +} + +readanswer() { + var=$1 + dflt=$2 + ok=$3 + if [ "$all_yes" = 0 -o -z "$dflt$ok" ]; then + read ans + if [ -z "$ans" ]; then + ans=$dflt + fi + else + ans=$dflt + echo "$ans" + fi + eval $var='$ans' +} + +yesno() { + var=$1 + dflt=$2 + ddflt=$3 + if [ -z "$dflt" ]; then + dflt=$ddflt + fi + if [ "$dflt" = y ]; then + ndflt=n + else + ndflt=y + fi + Echo "[$dflt]? " + if [ "$all_yes" = 0 ]; then + read ks_ans + else + ks_ans=$dflt + echo "$dflt" + fi + if [ "$ks_ans" = "$ndflt" ]; then + eval $var='$ndflt' + else + eval $var='$dflt' + fi +} + +save_params() { + echo "use_color=$use_color" >> config.param + echo "use_menu=$use_menu" >> config.param + echo "use_mouse=$use_mouse" >> config.param + echo "use_cookie=$use_cookie" >> config.param + echo "use_ssl=$use_ssl" >> config.param + if [ -n "$dmodel" ]; then + echo "dmodel=$dmodel" >> config.param + fi +} + +find_ssl() { + sslinclude="" + for i1 in /usr /usr/local + do + for i2 in /openssl /ssl / + do + if [ "$i2" = "/" ]; then i2=''; fi + dirname=${i1}${i2} + if [ -f $dirname/include/ssl.h ]; then + sslinclude="-I${dirname}/include" + elif [ -f $dirname/include/openssl/ssl.h ]; then + sslinclude="-I${dirname}/include/openssl -I${dirname}/include" + fi + for i3 in lib/openssl lib + do + dirname=${i1}${i2}/${i3} + for ext in a so + do + if [ -f $dirname/libssl.$ext -o -f $dirname/libcrypto.$ext ]; then + if [ "$ssllib" = -L${dirname} ]; then + ssllib="-L${dirname}" + else + ssllib="$ssllib -L${dirname}" + fi + fi + done + done + done + done + ssllib="$ssllib -lssl -lcrypto" + if [ "$sslinclude" = "" ]; then + echo "Where is ssl.h? (for example, /usr/crypto/include)" + Echo ":" + read ks_ans + sslinclude="-I${ks_ans}" + if [ -d $ks_ans/openssl ]; then + sslinclude="${sslinclude} -I${ks_ans}/openssl" + fi + echo "Where is libssl.a? (for example, /usr/crypto/lib)" + Echo ":" + read ks_ans + ssllib="-L${ks_ans} -lssl -lcrypto" + fi +} + +#-------------------------------------------------------------- +if [ -n "$USER" ]; then + user=$USER +elif [ -n "$LOGNAME" ]; then + user=$LOGNAME +elif [ -n "`whoami`" ]; then + user=`whoami` +else +# Echo "Who are you? " +# read user + user=nobody +fi + +echo "%" +echo "% Hello $user. Let's start configuration process for w3m." +echo "% Please answer some questions." +echo "%" + +if [ -n "`echo $sysname | grep CYGWIN`" ]; then + sysname="CYGWIN" + extension='.exe' +else + extension= +fi + +topdir=$prefix +special_sys='' +case "$sysname" in + aix | AIX ) + special_sys="#define AIX" + ;; + CYGWIN ) + special_sys="#define CYGWIN $sysversion1" + if [ $sysversion1 -eq 0 ]; then + topdir=/cygnus/cygwin-b20/H-i586-cygwin32 + fi + ;; + NetBSD ) +# Newer NetBSD system doesn't define 'unix' symbol anymore, but GC library +# requires it. + special_sys="#define unix" + ;; +esac + +if [ -z "$def_bindir" ]; then + def_bindir="$topdir/bin" +fi +echo "Which directory do you want to put the binary?" +Echo "(default: $def_bindir) " +readdir "$def_bindir" +bindir=$_dir +echo "def_bindir='$bindir'" >> config.param + +if [ -z "$def_libdir" ]; then + case "$sysname" in + *BSD) + def_libdir="$topdir/libexec/w3m" + ;; + *) + def_libdir="$topdir/lib/w3m" + ;; + esac +fi +echo "Which directory do you want to put the support binary files?" +Echo "(default: $def_libdir) " +readdir "$def_libdir" +suplibdir=$_dir +echo "def_libdir='$suplibdir'" >> config.param + +if [ -z "$def_helpdir" ]; then + def_helpdir="$topdir/lib/w3m" +fi +echo "Which directory do you want to put the helpfile?" +Echo "(default: $def_helpdir) " +readdir "$def_helpdir" +helpdir=$_dir +echo "def_helpdir='$helpdir'" >> config.param + +echo "Which language do you prefer?" +echo " 1 - Japanese (charset ISO-2022-JP, EUC-JP, Shift_JIS)" +echo " 2 - English (charset US_ASCII, ISO-8859-1, etc.)" +if [ "$pref_lang" = 2 ]; then + Echo '[2]? ' + def_lg=2 +else + Echo '[1]? ' + def_lg=1 +fi +while : +do + readanswer lg_ans "$def_lg" + if [ "$lg_ans" != 1 -a "$lg_ans" != 2 ]; then + echo "Please choose 1 or 2." + Echo "[$def_lg]? " + continue + else + : + fi + break +done +echo "pref_lang=$lg_ans" >> config.param +if [ "$lg_ans" = 1 ]; then + use_lang="#define LANG JA" + lang=ja +else + use_lang="#define LANG EN" + lang=en +fi + + +if [ "$lang" = ja ]; then + echo "Input your display kanji code." + echo " S - Shift JIS" + echo " E - EUC-JP" + echo ' j - JIS: ESC $@ - ESC (J' + echo ' N - JIS: ESC $B - ESC (J' + echo ' n - JIS: ESC $B - ESC (B' + echo ' m - JIS: ESC $@ - ESC (B' + echo '' + while : + do + if [ -n "$def_dcode" ] ; then + Echo "(default: $def_dcode) " + fi + Echo "Which? " + readanswer ncode "$def_dcode" + case "$ncode" in + [SEjNnm]) + ;; + *) + echo "Illegal code. Try again." + continue + ;; + esac + break + done + echo "def_dcode=$ncode" >> config.param +else + ncode=x +fi + +echo "Do you want to use Lynx-like key binding?" +yesno lynx_key "$lynx_key" n +echo "lynx_key=$lynx_key" >> config.param +if [ "$lynx_key" = y ]; then + keymap_file="keybind_lynx" +else + keymap_file="keybind" +fi + +if [ "$lang" = ja ]; then + if [ "$lynx_key" = y ]; then + helpfile="w3mhelp-lynx_ja.html" + else + helpfile="w3mhelp-w3m_ja.html" + fi +else + if [ "$lynx_key" = y ]; then + helpfile="w3mhelp-lynx_en.html" + else + helpfile="w3mhelp-w3m_en.html" + fi +fi + +if [ "$lang" = ja ]; then + echo "Do you want to use 2-byte character for table border, item, etc." + yesno kanji_symbols "$kanji_symbols" y + echo "kanji_symbols=$kanji_symbols" >> config.param +else + kanji_symbols=n +fi +if [ "$kanji_symbols" = y ]; then + def_kanji_symbols="#define KANJI_SYMBOLS" +else + def_kanji_symbols="#undef KANJI_SYMBOLS" +fi + +echo "Do you want to automatically generate domain parts of passwords for anonymous FTP logins" +yesno ftppass_hostnamegen "$ftppass_hostnamegen" n +echo "ftppass_hostnamegen=$ftppass_hostnamegen" >> config.param +if [ "$ftppass_hostnamegen" = y ]; then + def_ftppass_hostnamegen="#define FTPPASS_HOSTNAMEGEN" +else + def_ftppass_hostnamegen="#undef FTPPASS_HOSTNAMEGEN" +fi + +echo "Do you want listing of options" +yesno show_params "$show_params" n +echo "show_params=$show_params" >> config.param +if [ "$show_params" = y ]; then + def_show_params="#define SHOW_PARAMS" +else + def_show_params="#undef SHOW_PARAMS" +fi + +echo "Do you want NNTP support" +yesno use_nntp "$use_nntp" n +echo "use_nntp=$use_nntp" >> config.param +if [ "$use_nntp" = y ]; then + def_use_nntp="#define USE_NNTP" +else + def_use_nntp="#undef USE_NNTP" +fi + +echo "Do you want ANSI color escape sequences supprot?" +yesno ansi_color "$ansi_color" n +echo "ansi_color=$ansi_color" >> config.param +if [ "$ansi_color" = y ]; then + def_ansi_color="#define ANSI_COLOR" +else + def_ansi_color="#undef ANSI_COLOR" +fi + +echo "" +echo "Let's do some configurations. Choose config option among the list." +echo "" +echo "1 - Baby model (no color, no menu, no mouse, no cookie, no SSL)" +echo "2 - Little model (color, menu, no mouse, no cookie, no SSL)" +echo "3 - Mouse model (color, menu, mouse, no cookie, no SSL)" +echo "4 - Cookie model (color, menu, mouse, cookie, no SSL)" +echo "5 - Monster model (with everything; you need openSSL library)" +echo "6 - Customize" +echo "" +Echo "Which? " +if [ -n "$dmodel" ]; then + Echo "(default: $dmodel) " +fi + +while : +do +readanswer ans "$dmodel" +if [ -z "$ans" -a -n "$dmodel" ]; then + ans=$dmodel +fi +dmodel=$ans +case "$ans" in + 1) + use_color=n; def_color="#undef COLOR" + use_menu=n; def_menu="#undef MENU" + use_mouse=n; def_mouse="#undef MOUSE" + use_cookie=n; def_cookie="#undef USE_COOKIE" + use_ssl=n; def_ssl="#undef USE_SSL" + save_params + customized=y + ;; + 2) + use_color=y; def_color="#define COLOR" + use_menu=y; def_menu="#define MENU" + use_mouse=n; def_mouse="#undef MOUSE" + use_cookie=n; def_cookie="#undef USE_COOKIE" + use_ssl=n; def_ssl="#undef USE_SSL" + save_params + customized=y + ;; + 3) + use_color=y; def_color="#define COLOR" + use_menu=y; def_menu="#define MENU" + use_mouse=y; def_mouse="#define MOUSE" + use_cookie=n; def_cookie="#undef USE_COOKIE" + use_ssl=n; def_ssl="#undef USE_SSL" + save_params + customized=y + ;; + 4) + use_color=y; def_color="#define COLOR" + use_menu=y; def_menu="#define MENU" + use_mouse=y; def_mouse="#define MOUSE" + use_cookie=y; def_cookie="#define USE_COOKIE" + use_ssl=n; def_ssl="#undef USE_SSL" + save_params + customized=y + ;; + 5) + use_color=y; def_color="#define COLOR" + use_menu=y; def_menu="#define MENU" + use_mouse=y; def_mouse="#define MOUSE" + use_cookie=y; def_cookie="#define USE_COOKIE" + use_ssl=y; def_ssl="#define USE_SSL" + find_ssl + save_params + customized=y + ;; + 6) + ;; + *) + echo "Please input 1-6." + Echo "Which? " + continue + ;; +esac +break +done + +if [ "$customized" != y ]; then + +echo "Do you want to use color ESC sequence for kterm/pxvt " +yesno use_color "$use_color" y +echo "use_color=$use_color" >> config.param +if [ "$use_color" = y ]; then + def_color="#define COLOR" +else + def_color="#undef COLOR" +fi + +echo 'Do you want to use mouse? (It requires xterm/kterm)' +yesno use_mouse "$use_mouse" n +echo "use_mouse=$use_mouse" >> config.param +if [ "$use_mouse" = y ]; then + def_mouse="#define MOUSE" +else + def_mouse="#undef MOUSE" +fi + +echo "Do you want to use popup menu?" +yesno use_menu "$use_menu" y +echo "use_menu=$use_menu" >> config.param +if [ "$use_menu" = y ]; then + def_menu="#define MENU" +else + def_menu="#undef MENU" +fi + +#echo "Do you want to use matrix in rendering table?" +#if [ "$use_matrix" = n ]; then +# Echo '[n]? ' +# read ks_ans +# if [ "$ks_ans" = 'y' ]; then +# use_matrix='y' +# fi +#else +# Echo '[y]? ' +# read ks_ans +# if [ "$ks_ans" = 'n' ]; then +# use_matrix='n' +# else +# use_matrix='y' +# fi +#fi +#use_matrix=y +#echo "use_matrix=$use_matrix" >> config.param +#if [ "$use_matrix" = y ]; then +# def_matrix="#define MATRIX 1" +#else +# def_matrix="#undef MATRIX" +#fi + +echo "Do you want to use cookie?" +yesno use_cookie "$use_cookie" n +echo "use_cookie=$use_cookie" >> config.param +if [ "$use_cookie" = y ]; then + def_cookie="#define USE_COOKIE" +else + def_cookie="#undef USE_COOKIE" +fi + +echo "Do you want to use SSL?" +echo '(You need OpenSSL library; Please see http://www.openssl.org/)' +yesno use_ssl "$use_ssl" n +echo "use_ssl=$use_ssl" >> config.param +if [ "$use_ssl" = y ]; then + def_ssl="#define USE_SSL" + find_ssl +else + def_ssl="#undef USE_SSL" + ssllib="" + sslinclude="" +fi + +fi + +if [ "$use_ssl" = y ]; then + echo "Do you want SSL verification support" + echo '(Your SSL library must be version 0.8 or later)' + yesno use_ssl_verify "$use_ssl_verify" n + echo "use_ssl_verify=$use_ssl_verify" >> config.param + if [ "$use_ssl_verify" = y ]; then + def_use_ssl_verify="#define USE_SSL_VERIFY" + else + def_use_ssl_verify="#undef USE_SSL_VERIFY" + fi +else + use_ssl_verify=n + def_use_ssl_verify="#undef USE_SSL_VERIFY" +fi + +if [ -z "$ded" ] ; then ded=`./which \vi` ; fi +if [ -n "`echo $ded | grep 'no'`" ] ; then ded=vi ; fi +echo "Input your favorite editor program." +Echo "(Default: $ded) " +readdir "$ded" +editor=$_dir +echo "ded='$editor'" >> config.param + +if [ -z "$dmail" ] ; then + if ./which \mailx > /dev/null + then + dmail=`./which \mailx` + else + dmail=`./which \mail` + fi + if [ -n "`echo $dmail | grep 'no'`" ] ; then dmail=mailx ; fi +fi +echo "Input your favorite mailer program." +Echo "(Default: $dmail) " +readdir "$dmail" +mailer=$_dir +echo "dmail='$mailer'" >> config.param + + +if [ -z "$dbrowser" ] ; then + if ./which netscape > /dev/null + then + dbrowser=`./which netscape` + elif ./which iexplore > /dev/null + then + dbrowser=`./which iexplore` + else + dbrowser=`./which lynx` + fi + if [ -n "`echo $dbrowser | grep 'no'`" ] ; then dbrowser=netscape ; fi +fi +echo "Input your favorite external browser program." +Echo "(Default: $dbrowser) " +readdir "$dbrowser" +brz=$_dir +echo "dbrowser='$brz'" >> config.param + +if [ -z "$dcc" ] ; then + if ./which gcc >/dev/null + then + dcc=gcc + else + dcc=cc + fi +fi +echo "Input your favorite C-compiler." +Echo "(Default: $dcc) " +readanswer cc "$dcc" +echo "dcc='$cc'" >> config.param + +if [ -z "$dcflags" ] ; then dcflags="-O" ; fi +echo "Input your favorite C flags." +Echo "(Default: $dcflags) " +readanswer cflags "$dcflags" +echo "dcflags='$cflags'" >> config.param + +bsdinclude='' +if [ ! -f /usr/include/netinet/in.h ] ; then + if [ -f /usr/include/bsd/netinet/in.h ] ; then + bsdinclude='-I/usr/include/bsd' + elif [ -f /usr/bsdinclude/netinet/in.h ] ; then + bsdinclude='-I/usr/bsdinclude' + else + echo "It seems you don't have some include files for networking." + fi +fi + +termlib='' +cat > _zmachdep.c << EOF +main() +{ + char bp[100]; + tgetent(bp,getenv("TERM")); +} +EOF + +if [ -z "$dtermlib" ]; then + TERM_LIBS='termcap termlib terminfo mytinfo curses ncurses' + + for lib in $TERM_LIBS + do + for libdir in /lib /usr/lib /usr/local/lib /usr/ucblib /usr/ccslib /usr/ccs/lib + do + if [ -f $libdir/lib$lib.a -o -f $libdir/lib$lib.so ] ; then + # check if the lib works... + Echo "Terminal library -l$lib found at $libdir, " + if $cc $cflags -o _zmachdep _zmachdep.c -l$lib > /dev/null 2>&1 + then + echo "and it seems to work." + termlib=-l$lib + else + echo "but it doesn't seem to work." + fi + fi + done + done + if [ -z "$termlib" ]; then + Echo "termcap/curses library not found; I hope -ltermcap works." + termlib='-ltermcap' + fi + dtermlib=$termlib +fi +echo 'Which terminal library do you want to use? (type "none" if you do not need one)' +Echo "(default: $dtermlib) " +readanswer termlib "$dtermlib" +if [ "$termlib" = none ]; then + termlib="" +else + echo "dtermlib='$termlib'" >> config.param +fi + +## Setup for math library +if [ $sysname = Rhapsody -o $sysname = "Mac OS" ]; then + echo "MacOS X doesn't need -lm." + mathlib="" +else + mathlib="-lm" +fi + +## look for GPM library +use_gpm="" +gpmlib="" +if [ "$use_mouse" = y ]; then + for libdir in /lib /usr/lib /usr/local/lib + do + if [ -f $libdir/libgpm.a -o -f $libdir/libgpm.so ]; then + echo "GPM library found." + use_gpm="#define USE_GPM" + gpmlib="-lgpm" + fi + done +fi + +case $sysname in + freebsd|FreeBSD) + use_sysmouse="#define USE_SYSMOUSE" + ;; + *) + use_sysmouse="#undef USE_SYSMOUSE" + ;; +esac + +extlib='' + +case $sysname in + *bsd) + searchlibs="socket nsl" + ;; + *BSD) + searchlibs="socket nsl" + ;; + *) + searchlibs="bsd BSD 44bsd socket nsl" + ;; +esac +for lib in $searchlibs +do + for libdir in /lib /usr/lib /usr/local/lib /usr/ucblib /usr/ccslib /usr/ccs/lib + do + if [ -f $libdir/lib$lib.a -o -f $libdir/lib$lib.so ] ; then + extlib="$extlib -l$lib" + break + fi + done +done +if [ $sysname = "HP-UX" ]; then + extlib="$extlib -ldld" +fi +if [ -n "$extlib" ]; then + echo "additional library found: $extlib" +fi + +gclib='' +gcinclude='' +gctarget='' +for libdir in /lib /usr/lib /usr/local/lib /usr/ucblib /usr/ccslib /usr/ccs/lib ${HOME}/lib +do + if [ -f $libdir/libgc.a -o -f $libdir/libgc.so ] ; then + echo "$libdir/libgc found" + gclib="-L$libdir -lgc" + break + fi +done +for inc in /usr/include /usr/include/gc /usr/local/include /usr/local/include/gc ${HOME}/include +do + if [ -f $inc/gc.h ]; then + echo "$inc/gc.h found" + gcinclude=$inc + break + fi +done + +case $sysname in + linux|Linux|LINUX|aix|Aix|AIX) + # these OS requires gcmain.c, which include gc/gc_priv.h + # therefore we use gc library comes with w3m + echo "Your OS is $sysname; using gc library comes with w3m." + gcinclude="" + gclib="" + ;; +esac + +if [ -n "$gclib" -a -n "$gcinclude" ]; then + Echo GC library found on your system... + cat > _zmachdep.c << EOF +#include +main() +{ + extern unsigned GC_version; + printf("%d%02d%03d\n",(GC_version>>16)&0xff,(GC_version>>8)&0xff,GC_version&0xff); +} +EOF + if $cc $cflags -I$gcinclude -o _zmachdep _zmachdep.c $gclib > /dev/null 2>&1 + then + echo "and it seems to work." + gcversion=`./_zmachdep` + echo "GC_version is $gcversion." + if [ $gcversion -lt $mygcversion ]; then + echo "GC library on your system seems to be old." + Echo "Do you want to use GC library comes with w3m?[y] " + read ans + if [ "$ans" = 'n' -o "$ans" = 'N' ]; then + cflags="$cflags -I$gcinclude" + else + cflags="$cflags -I./gc/include" + gclib="gc/gc.a" + gctarget=$gclib + fi + else + cflags="$cflags -I$gcinclude" + fi + else + echo "but it doesn't seem to work." + cflags="$cflags -I./gc/include" + gclib="gc/gc.a" + gctarget=$gclib + fi +fi + +if [ -z "$gclib" -o -z "$gcinclude" ]; then + cflags="$cflags -I./gc/include" + gclib="gc/gc.a" + gctarget="$gclib" +fi + +# Apply patch. +if [ "$gclib" = "gc/gc.a" -a ! -f patch_done ]; then + patchfile="" + case "$platform:$sysname" in + [Aa]lpha:Linux) + patchfile=Patches/alpha ;; + [Ss]parc:Linux|sun4*:Linux) + if [ "$sysversion1" = 2 -a "$sysversion2" = 2 ] + then + patchfile=Patches/linux2.2sparc + fi + ;; + ARM*:Linux|arm*:Linux) + patchfile=Patches/armlinux + ;; + [mM]ips*:Linux|MIPS*:Linux) + patchfile=Patches/mipsel + ;; + *:HP-UX) + if [ "$sysversion2" = 11 ] + then + patchfile=Patches/hpux11 + fi + ;; + macppc:NetBSD) + patchfile = Patches/macppc + ;; + R3000:*System_V*|R4000:UNIX_SYSV|R*000:UNIX_SV) + # EWS-4800 + patchfile=Patches/ews4800 + ;; + *:NEWS-OS) + patchfile=Patches/newsos6 + ;; + *:Rhapsody|*:"Mac OS") + # MacOS X + patchfile=Patches/macosx + ;; + *:OS/2) + # OS/2 + patchfile=Patches/os2 + esac + + if [ -n "$patchfile" -a -f "$patchfile" ]; then + patch -p0 < $patchfile + echo "dpatch='$patch'" >> config.param + touch patch_done + fi +fi + + +echo "Input additional LD flags other than listed above, if any:" +if [ -n "$dldflags" ]; then + Echo "(default: $dldflags) : " +else + Echo ": " +fi +readanswer ldflags "$dldflags" ok +if [ -z "$ldflags" ]; then + ldflags=$dldflags +fi +echo "dldflags='$ldflags'" >> config.param + +echo "Checking machine dependency." + +###### mime.types +MIME_TYPES="" +for d in /usr/lib /usr/local/lib /usr/local/lib/mosaic /usr/local/mosaic /usr/local/netscape /usr/local/lib/netscape +do + if [ -f $d/mime.types ]; then + MIME_TYPES="$d/mime.types" + fi +done +if [ -z "$MIME_TYPES" ]; then + echo "Global mime.types not found; Hope /usr/local/lib/mime.types works." + MIME_TYPES=/usr/local/lib/mime.types +fi + +####### ranlib +if ./which ranlib > /dev/null +then + echo "You have ranlib." + ranlib_cmd=ranlib +else + if [ $sysname = "OS/2" ]; then + ranlib_cmd=rem + else + echo "You don't have ranlib." + ranlib_cmd=: + fi +fi + +####### mkdir -p +if mkdir -p hogege +then + echo "You have mkdir -p." + MKDIR="mkdir -p" +else + MKDIR="mkdir" +fi +rm -rf hogege 2>&1 >/dev/null + +####### strcasecmp +cat > _zmachdep.c << EOF +#include +main() +{ + int i; + i = strcasecmp("abc","def"); +} +EOF +if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 +then + echo "You have strcasecmp()." + strcasecmp_flg="#define STRCASECMP" +else + echo "You don't have strcasecmp()." + strcasecmp_flg="#undef STRCASECMP" +fi + +####### strchr +cat > _zmachdep.c << EOF +#include +main() +{ + char *p, *q = "abc"; + p = strchr(q,'c'); +} +EOF +if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 +then + echo "You have strchr()." + strchr_flg="#define STRCHR" +else + echo "You don't have strchr()." + strchr_flg="#undef STRCHR" +fi + +####### strerror +cat > _zmachdep.c << EOF +main() +{ + int i; + i = strerror(0); +} +EOF +if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 +then + echo "You have strerror()." + strerror_flg="#define STRERROR" +else + echo "You don't have strerror()." + strerror_flg="#undef STRERROR" +fi + + +####### sys_errlist +cat > _zmachdep.c << EOF +main() +{ + extern char sys_errlist[]; +} +EOF +if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 +then + echo "You have sys_errlist[]." + syserrlist_flg="#define SYS_ERRLIST" +else + echo "You don't have sys_errlist[]." + syserrlist_flg="#undef SYS_ERRLIST" +fi + +####### bcopy +cat > _zmachdep.c << EOF +main() +{ + char x[1],y[1]; + bzero(x,1); + bcopy(x,y,1); +} +EOF +if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 +then + echo "You have bcopy()." + bcopy_flg="#undef NOBCOPY" +else + echo "You don't have bcopy()." + bcopy_flg="#define NOBCOPY" +fi + +####### waitpid +cat > _zmachdep.c << EOF +#include +#include + +main() +{ + pid_t pid; + int status; + if ((pid = fork()) == 0) { + sleep(10); + exit(1); + } + while(waitpid(pid,&status,WNOHANG)); +} +EOF +if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 +then + echo "You have waitpid()." + waitpid_flg="#define HAVE_WAITPID" +else + echo "You don't have waitpid()." + waitpid_flg="#undef HAVE_WAITPID" +fi + +####### wait3 +cat > _zmachdep.c << EOF +#include +#include +#include +#include +#include +#ifndef NULL +#define NULL 0 +#endif + +main() +{ + int pid; + int status; + if ((pid = fork()) == 0) { + sleep(10); + exit(1); + } + while(wait3(&status,WNOHANG,NULL) > 0); +} +EOF +if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 +then + echo "You have wait3()." + wait3_flg="#define HAVE_WAIT3" +else + echo "You don't have wait3()." + wait3_flg="#undef HAVE_WAIT3" +fi + +####### strftime +cat > _zmachdep.c << EOF +#include + +main() +{ + time_t ct; + struct tm *tm; + char t[80]; + time(&ct); + strftime(t, 80, "%a, %d %b %Y %H:%M:%S GMT",gmtime(&ct)); +} +EOF +if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 +then + echo "You have strftime()." + strftime_flg="#define HAVE_STRFTIME" +else + echo "You don't have strftime()." + strftime_flg="#undef HAVE_STRFTIME" +fi + + +####### getcwd +cat > _zmachdep.c << EOF +#include +#include +main() +{ + char path[MAXPATHLEN]; + getcwd(path,MAXPATHLEN); +} +EOF +if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 +then + echo "You have getcwd()." + getcwd_flg="#define GETCWD" +else + echo "You don't have getcwd()." + getcwd_flg="#undef GETCWD" +fi + +####### getwd +cat > _zmachdep.c << EOF +main() +{ + char path[64]; + getwd(path); +} +EOF +if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 +then + echo "You have getwd()." + getwd_flg="#define GETWD" +else + echo "You don't have getwd()." + getwd_flg="#undef GETWD" +fi + +####### readlink +cat > _zmachdep.c << EOF +main() +{ + char path[64],lpath[64]; + readlink(path,lpath,64); +} +EOF +if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 +then + echo "You have readlink()." + readlink_flg="#define READLINK" +else + echo "You don't have readlink()." + readlink_flg="#undef READLINK" +fi + +####### setenv +cat > _zmachdep.c << EOF +#include +main() +{ + setenv("HOGE","hoge",1); +} +EOF +if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 +then + echo "You have setenv()." + setenv_flg="#define HAVE_SETENV" +else + echo "You don't have setenv()." + setenv_flg="#undef HAVE_SETENV" +fi + +####### putenv +cat > _zmachdep.c << EOF +#include +main() +{ + putenv("HOGE=hoge"); +} +EOF +if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 +then + echo "You have putenv()." + putenv_flg="#define HAVE_PUTENV" +else + echo "You don't have putenv()." + putenv_flg="#undef HAVE_PUTENV" +fi + +####### sigsetjmp +cat > _zmachdep.c << EOF +#include +main() +{ + jmp_buf env; + if (sigsetjmp(env,1) != 0) { + exit(0); + } + siglongjmp(env,1); +} +EOF +if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 +then + echo "You have sigsetjmp()." + setjmp_def="#define SETJMP(env) sigsetjmp(env,1)" + longjmp_def="#define LONGJMP(env,val) siglongjmp(env,val)" + jmpbuf_def="#define JMP_BUF sigjmp_buf" +else + echo "You don't have sigsetjmp()." + setjmp_def="#define SETJMP(env) setjmp(env)" + longjmp_def="#define LONGJMP(env,val) longjmp(env)" + jmpbuf_def="#define JMP_BUF jmp_buf" +fi + +####### fclose +cat > _zmachdep.c << EOF +#include +#include +main() +{ + void (*c)() = fclose; +} +EOF +if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 +then + echo "fclose() is declared." + fclose_dcl='' +else + echo "fclose() is not declared." + fclose_dcl='void fclose(FILE*);' +fi + +####### pclose +cat > _zmachdep.c << EOF +#include +#include +main() +{ + void (*c)() = pclose; +} +EOF +if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 +then + echo "pclose() is declared." + pclose_dcl='' +else + echo "pclose() is not declared." + pclose_dcl='void pclose(FILE*);' +fi + +####### termios/termio/sgtty +term_if='#define SGTTY' +if [ $sysname = "HP-UX" ]; then + echo "Your OS is HP-UX; using termio" + term_if="#define TERMIO" +elif [ $sysname = "CYGWIN" ]; then + echo "Your OS is CYGWIN; using termios" + term_if="#define TERMIOS" +elif [ $sysname = "OS/2" ]; then + echo "Your OS is OS/2; using termios" + term_if='#define TERMIOS' +elif [ -r /usr/include/termios.h ]; then + echo "You have termios." + term_if='#define TERMIOS' +elif [ -r /usr/include/termio.h ]; then + echo "You have termio." + term_if='#define TERMIO' +elif [ -r /usr/include/sgtty.h ]; then + echo "You have sgtty." + term_if='#define SGTTY' +else + echo "Do you have tty interface? I can't find one but I hope sgtty works..." +fi + +####### dirent/direct +dir_if='' +if [ $sysname = "CYGWIN" ]; then + echo "Your OS is CYGWIN; using dirent.h" + dir_if='#define DIRENT' +elif [ $sysname = "OS/2" ]; then + echo "Your OS is OS/2; using dirent.h" + dir_if='#define DIRENT' +elif [ -r /usr/include/dirent.h ]; then + echo "You have dirent.h." + dir_if='#define DIRENT' +elif [ -r /usr/include/sys/dir.h ]; then + echo "You have sys/dir.h." + dir_if='' +else + echo "Do you have directory interface? I can't find one but I hope sys/dir.h works..." +fi + +# check signal handler + +do_sigtest int int +if [ $stat = 0 -a -z "$warning" ] +then + echo 'signal handler is int handler(int).' + sig_type='typedef int MySignalHandler;' + sig_arg='#define SIGNAL_ARG int _dummy' + sig_arglist='#define SIGNAL_ARGLIST 0' + sig_return='#define SIGNAL_RETURN return 0' +else + do_sigtest int void + if [ $stat = 0 -a -z "$warning" ] + then + echo 'signal handler is int handler(void).' + sig_type='typedef int MySignalHandler;' + sig_arg='#define SIGNAL_ARG void' + sig_arglist='#define SIGNAL_ARGLIST' + sig_return='#define SIGNAL_RETURN return 0' + else + do_sigtest void int + if [ $stat = 0 -a -z "$warning" ] + then + echo 'signal handler is void handler(int).' + sig_type='typedef void MySignalHandler;' + sig_arg='#define SIGNAL_ARG int _dummy' + sig_arglist='#define SIGNAL_ARGLIST 0' + sig_return='#define SIGNAL_RETURN return' + else + do_sigtest void void + if [ $stat = 0 -a -z "$warning" ] + then + echo 'signal handler is void handler(void).' + else + echo 'I could not find the type of signal handler. I hope void handler(void) works.' + fi + sig_type='typedef void MySignalHandler;' + sig_arg='#define SIGNAL_ARG void' + sig_arglist='#define SIGNAL_ARGLIST' + sig_return='#define SIGNAL_RETURN return' + fi + fi +fi + +# check for float.h +cat > _zmachdep.c << EOF +#include +main() +{ + ; +} +EOF +if $cc $cflags -c _zmachdep.c > /dev/null 2>&1 +then + echo "You have float.h." + no_float_h='#undef NO_FLOAT_H' +else + no_float_h='#define NO_FLOAT_H 1' +fi + +###### IPv6 support check +cat > _zmachdep.c < +#include +main() +{ + if (socket(AF_INET6, SOCK_STREAM, 0) < 0) + exit(1); + else + exit(0); +} +EOF +ipv6="#undef INET6" +v6lib='' +if $cc $cflags -o _zmachdep _zmachdep.c $extlib > /dev/null 2>&1 +then + if ./_zmachdep; then + ipv6="#define INET6" + fi + case $sysname in + *BSD|*bsd) + cat > _zmachdep.c < +#include +#include + +struct addrinfo *hints, **res; + +int main() { + getaddrinfo("null", "null", hints, res); +} +EOF + if $cc $cflags -o _zmachdep _zmachdep.c $extlib > /dev/null 2>&1 + then + echo "You have getaddrinfo() in libc." + else + for libdir in /usr/local/v6/lib /usr/local/lib /usr/lib + do + if [ -e $libdir/libinet6.a ]; then + if [ "$libdir" != "/usr/lib" ]; then + v6lib="-L$libdir" + fi + v6lib="$v6lib -linet6" + if $cc $cflags -o _zmachdep _zmachdep.c $extlib $v6lib > /dev/null 2>&1 + then + echo "You have getaddrinfo() in libinet6." + fi + break + fi + done + if [ "X$v6lib" = "X" ]; then + echo "You don't have getaddrinfo()." + ipv6="#undef INET6" + fi + fi + ;; + CYGWIN*) + ipv6="#undef INET6" + ;; + esac +fi +if [ "$ipv6" = "#undef INET6" ]; then + echo "You don't have IPv6 support." +else + echo "You have IPv6 support." +fi + + + +rm -f _zmachdep$extension _zmachdep.c _zmachdep.o +echo "------------ Configuration done ------------" + +# set model name +case $dmodel in + 1) modelname=baby;; + 2) modelname=little;; + 3) modelname=mouse;; + 4) modelname=cookie;; + 5) modelname=monster;; + 6) modelname=custom;; +esac + +cat > extrvers.c << EOF +#include +#include +#include "version.c" +main() +{ + char *p = strchr(version,'/'); + if (p == NULL) + printf("unknown\n"); + else + printf("%s\n",p+1); +} +EOF +$cc $cflags -o extrvers extrvers.c > /dev/null 2>&1 +w3mversion=`./extrvers` +echo "Current w3m version is $w3mversion." +rm -f extrvers.c extrvers$extension + +echo "Extracting config.h" +cat > config.h << END_OF_CONFIG_H +/* + * Configuration for w3m + */ + +#ifndef _CONFIGURED_ +#define _CONFIGURED_ + +/* User Configuration */ + +/* + If you define DICT, you can use dictionary look-up function + in w3m. See README.dict for detail. +*/ +#undef DICT + +/* + If you define USE_MARK, you can use set-mark (C-SPC), + goto-next-mark (ESC p), goto-next-mark (ESC n) and + mark-by-regexp ("). +*/ +#undef USE_MARK + +/* + If you want to load and save URL history. + */ +#define USE_HISTORY + +/* + BG_COLOR enables w3m to set background color. + */ +#define BG_COLOR + +/* + VIEW_UNSEENOBJECTS enables w3m to make a link to unseen objects. + e.g. background image. + */ +#undef VIEW_UNSEENOBJECTS + +/* + VI_PREC_NUM enables vi-like behavior for '2 SPC' or '2 b' + */ +#undef VI_PREC_NUM + +/* + * Do word fill + */ +#undef FORMAT_NICE + +/* + * Support Gopher protocol + */ +#undef USE_GOPHER + +/* + * Support NNTP + */ +$def_use_nntp + +/* + * Support ANSI color escape sequences + */ +$def_ansi_color + +/* + * Enable id attribute + */ +#define ID_EXT + +/* + * Save Current-buffer Information + */ +#define BUFINFO + +/* + * Support EGD (Entropy Gathering Daemon) + */ +#undef USE_EGD + +/* + * MENU_MAP enables w3m to show image map link with popup menu. + */ +#define MENU_MAP + +/* + * Use Emacs-like key binding for file name completion + */ +#undef EMACS_LIKE_LINEEDIT + +/* + * Remove line trailing spaces in html buffer. + */ +#undef ENABLE_REMOVE_TRAILINGSPACES + +/**********************************************************/ +#ifdef makefile_parameter + +BIN_DIR = $bindir +HELP_DIR = $helpdir +LIB_DIR = $suplibdir +HELP_FILE = $helpfile +SYS_LIBRARIES = $gpmlib $extlib $termlib $ssllib $v6lib +LOCAL_LIBRARIES = $ldflags +CC = $cc +MYCFLAGS = $cflags $bsdinclude $sslinclude +GCCFLAGS = $cflags -DATOMIC_UNCOLLECTABLE -DNO_EXECUTE_PERMISSION -DALL_INTERIOR_POINTERS -DSILENT -DNO_DEBUGGING #-DNO_SIGNALS +KEYBIND_SRC = $keymap_file.c +KEYBIND_OBJ = $keymap_file.o +EXT=$extension +MATHLIB=$mathlib +GCLIB=$gclib +GCTARGET=$gctarget +RANLIB=$ranlib_cmd +MKDIR=$MKDIR +VERSION=$w3mversion +MODEL=$sysname.$platform-$modelname-$lang +#else +$special_sys + +#define DISPLAY_CODE '$ncode' + +#define JA 0 +#define EN 1 +$use_lang +$def_kanji_symbols +$def_color +$def_mouse +$use_gpm +$use_sysmouse +$def_menu +$def_cookie +$def_ssl +$def_use_ssl_verify +$def_ftppass_hostnamegen +$def_show_params + +#define DEF_EDITOR "$editor" +#define DEF_MAILER "$mailer" +#define DEF_EXT_BROWSER "$brz" + +#define LIB_DIR "$suplibdir" +#define HELP_DIR "$helpdir" +#define HELP_FILE "w3mhelp.html" +#define W3MCONFIG "w3mconfig" + +#define RC_DIR "~/.w3m/" +#define BOOKMARK "bookmark.html" +#define CONFIG_FILE "config" +#define KEYMAP_FILE "keymap" +#define MENU_FILE "menu" +#define COOKIE_FILE "cookie" +#define HISTORY_FILE "history" + +#define USER_MAILCAP RC_DIR "/mailcap" +#define SYS_MAILCAP "/etc/mailcap" +#define USER_MIMETYPES "~/.mime.types" +#define SYS_MIMETYPES "$MIME_TYPES" + +#define DEF_SAVE_FILE "index.html" + +$term_if +$dir_if +$strcasecmp_flg +$strchr_flg +$strerror_flg +$syserrlist_flg +$bcopy_flg +$waitpid_flg +$wait3_flg +$strftime_flg +$getdtablesize_flg +$getcwd_flg +$getwd_flg +$readlink_flg +$setenv_flg +$putenv_flg +$readlink_flg +$fclose_dcl +$pclose_dcl +$setjmp_def +$longjmp_def +$jmpbuf_def + +$sig_type +$sig_arg +$sig_arglist +$sig_return +/* + If you want to use IPv6, define this symbol. + */ +$ipv6 + +#undef TABLE_EXPAND +#undef TABLE_NO_COMPACT +#define NOWRAP 1 +#define NEW_FORM 1 +#define MATRIX 1 +$no_float_h + +#endif /* makefile_parameter */ +#endif /* _CONFIGURED_ */ + +END_OF_CONFIG_H + +echo '' +echo 'config.h is created. See config.h for further configuration.' +echo '' +echo 'Generating dirlist.cgi' + +perl=`./which perl` +if [ `expr "$perl" : 'not found'` != 0 ]; then + perl=/usr/local/bin/perl +fi +if [ $sysname = CYGWIN ]; then + cygwin=1 +else + cygwin=0 +fi +sed -e "s;@PERL@;$perl;" \ + -e "s;@CYGWIN@;$cygwin;" \ + scripts/dirlist.in > scripts/dirlist.cgi + + +echo 'Configuration done. Just type "make".' diff --git a/conv.c b/conv.c new file mode 100644 index 0000000..b7403e4 --- /dev/null +++ b/conv.c @@ -0,0 +1,699 @@ +#include +#include +#include "fm.h" + +#ifdef JP_CHARSET +#include "terms.h" +#include "Str.h" + +#ifdef DEBUG +#include +#endif /* DEBUG */ + +#define uchar unsigned char +#define ushort unsigned short +#define uint unsigned int + +#ifdef TRUE +#undef TRUE +#endif +#ifdef FALSE +#undef FALSE +#endif +#define TRUE 1 +#define FALSE 0 +#ifdef ESC_CODE +#undef ESC_CODE +#endif +#define ESC_CODE '\033' + +#define CODE_NORMAL 0x00 +#define CODE_OK 0x01 +#define CODE_BROKEN 0x02 +#define CODE_ERROR 0x04 +#define EUC_NOSTATE 0x00 +#define EUC_MBYTE1 0x10 +#define EUC_SS2 0x20 +#define EUC_SS3 0x40 +#define SJIS_NOSTATE 0x00 +#define SJIS_SHIFT_L 0x10 +#define SJIS_SHIFT_H 0x20 +#define ISO_NOSTATE 0x00 +#define ISO_ESC 0x10 +#define ISO_CS94 0x20 +#define ISO_MBCS 0x40 +#define ISO_MBYTE1 0x80 +#define CODE_STATE(c) ((c) & 0x0f) +#define EUC_STATE(c) ((c) & 0xf0) +#define SJIS_STATE(c) ((c) & 0xf0) +#define ISO_STATE(c) ((c) & 0xf0) + +#define CSET_ASCII 0 +#define CSET_X0208 1 +#define CSET_X0201K 2 +#define CSET_UNKNOWN 3 + +#define JSIcode "\033$@" +#define JSOcode "\033(H" +#define J2SIcode "\033$@" +#define J2SOcode "\033(J" +#define NSIcode "\033$B" +#define NSOcode "\033(J" +#define N2SIcode "\033$B" +#define N2SOcode "\033(B" +#define N3SIcode "\033$@" +#define N3SOcode "\033(B" +#define USIcode "\033$" +#define USOcode "\033+" + +static char *SIcode, *SOcode; + +static Str cConvEE(Str is); +static Str cConvEJ(Str is); +static Str cConvES(Str is); +static Str cConvSE(Str is); +static Str cConvJE(Str is); +char checkShiftCode(Str buf, uchar); + +static char *han2zen_tab[] = +{ + "!!", "!#", "!V", "!W", "!\"", "!&", "%r", "%!", + "%#", "%%", "%'", "%)", "%c", "%e", "%g", "%C", + "!<", "%\"", "%$", "%&", "%(", "%*", "%+", "%-", + "%/", "%1", "%3", "%5", "%7", "%9", "%;", "%=", + "%?", "%A", "%D", "%F", "%H", "%J", "%K", "%L", + "%M", "%N", "%O", "%R", "%U", "%X", "%[", "%^", + "%_", "%`", "%a", "%b", "%d", "%f", "%h", "%i", + "%j", "%k", "%l", "%m", "%o", "%s", "!+", "!,", +}; + +typedef struct _ConvRoutine { + char key; + Str(*routine) (); + char *ShiftIn, *ShiftOut; +} ConvRoutine; + +static ConvRoutine FromEJ[] = +{ + {CODE_JIS_J, cConvEJ, JSIcode, JSOcode}, + {CODE_JIS_N, cConvEJ, NSIcode, NSOcode}, + {CODE_JIS_n, cConvEJ, N2SIcode, N2SOcode}, + {CODE_JIS_m, cConvEJ, N3SIcode, N3SOcode}, + {CODE_JIS_j, cConvEJ, J2SIcode, J2SOcode}, + {CODE_SJIS, cConvES, "", ""}, + {CODE_EUC, cConvEE, "", ""}, + {'\0', NULL, NULL, NULL} +}; + +static ConvRoutine ToEJ[] = +{ + {CODE_JIS_J, cConvJE, JSIcode, JSOcode}, + {CODE_JIS_N, cConvJE, NSIcode, NSOcode}, + {CODE_JIS_n, cConvJE, N2SIcode, N2SOcode}, + {CODE_JIS_m, cConvJE, N3SIcode, N3SOcode}, + {CODE_JIS_j, cConvJE, J2SIcode, J2SOcode}, + {CODE_SJIS, cConvSE, "", ""}, + {CODE_EUC, cConvEE, "", ""}, + {'\0', NULL, NULL, NULL} +}; + +char * +GetSICode(char key) +{ + int i; + for (i = 0; FromEJ[i].key != '\0' ; i++) + if (FromEJ[i].key == key) + return FromEJ[i].ShiftIn; + return ""; +} + +char * +GetSOCode(char key) +{ + int i; + for (i = 0; FromEJ[i].key != '\0'; i++) + if (FromEJ[i].key == key) + return FromEJ[i].ShiftOut; + return ""; +} + +static void +n_impr(char s) +{ + fprintf(stderr, "conv: option %c(0x%02x) is not implemented yet... sorry\n", s, s); + exit(1); +} + +Str +conv_str(Str is, char fc, char tc) +{ + int i; + Str os; + static char from_code = '\0'; + static char to_code = '\0'; + static Str (*conv_from) (); + static Str (*conv_to) (); + + if (fc == tc || fc == CODE_ASCII || tc == CODE_ASCII) + return is; + + if (fc == CODE_INNER_EUC) + os = is; + else { + if (from_code != fc) { + for (i = 0; ToEJ[i].key != '\0'; i++) { + if (ToEJ[i].key == fc) { + from_code = fc; + conv_from = *ToEJ[i].routine; + goto next; + } + } + n_impr(fc); + return NULL; + } + next: + os = conv_from(is); + } + if (tc == CODE_INNER_EUC || tc == CODE_EUC) + return os; + else { + if (to_code != tc) { + for (i = 0; FromEJ[i].key != '\0'; i++) { + if (FromEJ[i].key == tc) { + SIcode = FromEJ[i].ShiftIn; + SOcode = FromEJ[i].ShiftOut; + to_code = tc; + conv_to = *FromEJ[i].routine; + goto next2; + } + } + n_impr(tc); + return NULL; + } + next2: + return conv_to(os); + } +} + +Str +conv(char *is, char fc, char tc) +{ + return conv_str(Strnew_charp(is), fc, tc); +} + +static uchar +getSLb(uchar * ptr, uchar * ub) +{ /* Get Shift-JIS Lower byte */ + uchar c = *ptr; + + *ub <<= 1; + if (c < 0x9f) { + if (c > 0x7e) + c--; + *ub -= 1; + c -= 0x3f; + } + else { + c -= 0x9e; + } + return c; +} + +static Str +cConvSE(Str is) +{ /* Convert Shift-JIS to EUC-JP */ + uchar *p, ub, lb; + int state = SJIS_NOSTATE; + Str os = Strnew_size(is->length); + uchar *endp = (uchar *) &is->ptr[is->length]; + + for (p = (uchar *) is->ptr; p < endp; p++) { + switch (state) { + case SJIS_NOSTATE: + if (!(*p & 0x80)) /* ASCII */ + Strcat_char(os, (char) (*p)); + else if (0x81 <= *p && *p <= 0x9f) { /* JIS X 0208, + * 0213 */ + ub = *p & 0x7f; + state = SJIS_SHIFT_L; + } + else if (0xe0 <= *p && *p <= 0xef) { /* JIS X 0208 */ + /* } else if (0xe0 <= *p && *p <= 0xfc) { *//* JIS X 0213 */ + ub = (*p & 0x7f) - 0x40; + state = SJIS_SHIFT_H; + } + else if (0xa0 <= *p && *p <= 0xdf) { /* JIS X 0201-Kana + */ + Strcat_char(os, (char) (han2zen_tab[*p - 0xa0][0] | 0x80)); + Strcat_char(os, (char) (han2zen_tab[*p - 0xa0][1] | 0x80)); + } + break; + case SJIS_SHIFT_L: + case SJIS_SHIFT_H: + if ((0x40 <= *p && *p <= 0x7e) || + (0x80 <= *p && *p <= 0xfc)) { /* JIS X 0208, 0213 */ + lb = getSLb(p, &ub); + ub += 0x20; + lb += 0x20; + Strcat_char(os, (char) (ub | 0x80)); + Strcat_char(os, (char) (lb | 0x80)); + } + else if (!(*p & 0x80)) /* broken ? */ + Strcat_char(os, (char) (*p)); + state = SJIS_NOSTATE; + break; + } + } + return os; +} + +static Str +cConvJE(Str is) +{ /* Convert ISO-2022-JP to EUC-JP */ + uchar *p, ub; + char cset = CSET_ASCII; + int state = ISO_NOSTATE; + Str os = Strnew_size(is->length); + uchar *endp = (uchar *) &is->ptr[is->length]; + + for (p = (uchar *) is->ptr; p < endp; p++) { + switch (state) { + case ISO_NOSTATE: + if (*p == ESC_CODE) /* ESC sequence */ + state = ISO_ESC; + else if (cset == CSET_ASCII || *p < 0x21) + Strcat_char(os, (char) (*p)); + else if (cset == CSET_X0208 && *p <= 0x7e) { + /* JIS X 0208 */ + ub = *p; + state = ISO_MBYTE1; + } + else if (cset == CSET_X0201K && *p <= 0x5f) { + /* JIS X 0201-Kana */ + Strcat_char(os, (char) (han2zen_tab[*p - 0x20][0] | 0x80)); + Strcat_char(os, (char) (han2zen_tab[*p - 0x20][1] | 0x80)); + } + break; + case ISO_MBYTE1: + if (*p == ESC_CODE) /* ESC sequence */ + state = ISO_ESC; + else if (0x21 <= *p && *p <= 0x7e) { /* JIS X 0208 */ + Strcat_char(os, (char) (ub | 0x80)); + Strcat_char(os, (char) (*p | 0x80)); + state = ISO_NOSTATE; + } + else { + Strcat_char(os, (char) (*p)); + state = ISO_NOSTATE; + } + break; + case ISO_ESC: + if (*p == '(') /* ESC ( F */ + state = ISO_CS94; + else if (*p == '$') /* ESC $ F, ESC $ ( F */ + state = ISO_MBCS; + else { + Strcat_char(os, ESC_CODE); + Strcat_char(os, (char) (*p)); + state = ISO_NOSTATE; + } + break; + case ISO_CS94: + if (*p == 'B' || *p == 'J' || *p == 'H') + cset = CSET_ASCII; + else if (*p == 'I') + cset = CSET_X0201K; + else { + Strcat_char(os, ESC_CODE); + Strcat_char(os, '('); + Strcat_char(os, (char) (*p)); + } + state = ISO_NOSTATE; + break; + case ISO_MBCS: + if (*p == '(') { /* ESC $ ( F */ + state = ISO_MBCS | ISO_CS94; + break; + } + case ISO_MBCS | ISO_CS94: + if (*p == 'B' || *p == '@') + cset = CSET_X0208; + else { + Strcat_char(os, ESC_CODE); + Strcat_char(os, '$'); + if (state == (ISO_MBCS | ISO_CS94)) + Strcat_char(os, '('); + Strcat_char(os, (char) (*p)); + } + state = ISO_NOSTATE; + break; + } + } + return os; +} + +static Str +_cConvEE(Str is, char is_euc) +{ /* Convert EUC-JP to EUC-JP / ISO-2022-JP + * (no JIS X 0201-Kana, 0212, 0213-2) */ + uchar *p, ub, euc = 0; + int state = EUC_NOSTATE; + char cset = CSET_ASCII; + Str os; + uchar *endp = (uchar *) &is->ptr[is->length]; + + if (is_euc) { + os = Strnew_size(is->length); + euc = 0x80; + } + else + os = Strnew_size(is->length * 3 / 2); + + for (p = (uchar *) is->ptr; p < endp; p++) { + switch (state) { + case EUC_NOSTATE: + if (!(*p & 0x80)) { /* ASCII */ + if (!is_euc && cset != CSET_ASCII) { + Strcat_charp(os, SOcode); + cset = CSET_ASCII; + } + Strcat_char(os, (char) (*p)); + } + else if (0xa1 <= *p && *p <= 0xfe) { /* JIS X 0208, + * 0213-1 */ + ub = *p; + state = EUC_MBYTE1; + } + else if (*p == EUC_SS2_CODE) /* SS2 + JIS X 0201-Kana */ + state = EUC_SS2; + else if (*p == EUC_SS3_CODE) /* SS3 + JIS X 0212, 0213-2 */ + state = EUC_SS3; + break; + case EUC_MBYTE1: + if (0xa1 <= *p && *p <= 0xfe) { /* JIS X 0208, 0213-1 */ + if (!is_euc && cset != CSET_X0208) { + Strcat_charp(os, SIcode); + cset = CSET_X0208; + } + Strcat_char(os, (char) ((ub & 0x7f) | euc)); + Strcat_char(os, (char) ((*p & 0x7f) | euc)); + } + else if (!(*p & 0x80)) { /* broken ? */ + if (!is_euc && cset != CSET_ASCII) { + Strcat_charp(os, SOcode); + cset = CSET_ASCII; + } + Strcat_char(os, (char) (*p)); + } + state = EUC_NOSTATE; + break; + case EUC_SS2: + if (0xa0 <= *p && *p <= 0xdf) { /* JIS X 0201-Kana */ + if (!is_euc && cset != CSET_X0208) { + Strcat_charp(os, SIcode); + cset = CSET_X0208; + } + Strcat_char(os, (char) (han2zen_tab[*p - 0xa0][0] | euc)); + Strcat_char(os, (char) (han2zen_tab[*p - 0xa0][1] | euc)); + } + state = EUC_NOSTATE; + break; + case EUC_SS3: + state = (EUC_SS3 | EUC_MBYTE1); + break; + case EUC_SS3 | EUC_MBYTE1: + state = EUC_NOSTATE; + break; + } + } + if (!is_euc && cset != CSET_ASCII) + Strcat_charp(os, SOcode); + return os; +} + +static Str +cConvEE(Str is) +{ + return _cConvEE(is, TRUE); +} + +static Str +cConvEJ(Str is) +{ + return _cConvEE(is, FALSE); +} + +void +put_sjis(Str os, uchar ub, uchar lb) +{ + ub -= 0x20; + lb -= 0x20; + if ((ub & 1) == 0) + lb += 94; + ub = ((ub - 1) >> 1) + 0x81; + lb += 0x3f; + if (ub > 0x9f) + ub += 0x40; + if (lb > 0x7e) + lb++; + + Strcat_char(os, (char) (ub)); + Strcat_char(os, (char) (lb)); +} + +static Str +cConvES(Str is) +{ /* Convert EUC-JP to Shift-JIS */ + uchar *p, ub; + int state = EUC_NOSTATE; + Str os = Strnew_size(is->length); + uchar *endp = (uchar *) &is->ptr[is->length]; + + for (p = (uchar *) is->ptr; p < endp; p++) { + switch (state) { + case EUC_NOSTATE: + if (!(*p & 0x80)) /* ASCII */ + Strcat_char(os, (char) (*p)); + else if (0xa1 <= *p && *p <= 0xfe) { /* JIS X 0208, + * 0213-1 */ + ub = *p; + state = EUC_MBYTE1; + } + else if (*p == EUC_SS2_CODE) /* SS2 + JIS X 0201-Kana */ + state = EUC_SS2; + else if (*p == EUC_SS3_CODE) /* SS3 + JIS X 0212, 0213-2 */ + state = EUC_SS3; + break; + case EUC_MBYTE1: + if (0xa1 <= *p && *p <= 0xfe) /* JIS X 0208, 0213-1 */ + put_sjis(os, ub & 0x7f, *p & 0x7f); + else if (!(*p & 0x80)) /* broken ? */ + Strcat_char(os, (char) (*p)); + state = EUC_NOSTATE; + break; + case EUC_SS2: + if (0xa0 <= *p && *p <= 0xdf) /* JIS X 0201-Kana */ + put_sjis(os, han2zen_tab[*p - 0xa0][0], + han2zen_tab[*p - 0xa0][1]); + state = EUC_NOSTATE; + break; + case EUC_SS3: + state = (EUC_SS3 | EUC_MBYTE1); + break; + case EUC_SS3 | EUC_MBYTE1: + state = EUC_NOSTATE; + break; + } + } + return os; +} + +/* + * static ushort sjis_shift[8] = { 0x7fff, 0xffff, 0x0, 0x0, 0x0, + * 0x0, 0xffff, 0x0 }; static ushort sjis_second[16] = { 0x0, 0x0, + * 0x0, 0x0, 0xffff, 0xffff, 0xffff, 0xfffe, 0xffff, 0xffff, 0xffff, + * 0xffff, 0xffff, 0xffff, 0xffff, 0xfff8 }; */ + +char +checkShiftCode(Str buf, uchar hint) +{ + uchar *p, si = '\0', so = '\0'; + int euc = (CODE_NORMAL | EUC_NOSTATE), + sjis = (CODE_NORMAL | SJIS_NOSTATE), sjis_kana = CODE_NORMAL, + iso = (CODE_NORMAL | ISO_NOSTATE), iso_kana = CODE_NORMAL; + uchar *endp = (uchar *) &buf->ptr[buf->length]; + + if (hint == CODE_INNER_EUC) + return '\0'; + p = (uchar *) buf->ptr; + while (1) { + if (iso != CODE_ERROR && (si == '\0' || so == '\0')) { + switch (ISO_STATE(iso)) { + case ISO_NOSTATE: + if (*p == ESC_CODE) /* ESC sequence */ + iso = (CODE_STATE(iso) | ISO_ESC); + break; + case ISO_ESC: + if (*p == '(') /* ESC ( F */ + iso = (CODE_STATE(iso) | ISO_CS94); + else if (*p == '$') /* ESC $ F, ESC $ ( F */ + iso = (CODE_STATE(iso) | ISO_MBCS); + else + iso = (CODE_STATE(iso) | ISO_NOSTATE); + break; + case ISO_CS94: + if (*p == 'B' || *p == 'J' || *p == 'H') + so = *p; + else if (*p == 'I') + iso_kana = CODE_OK; + iso = (CODE_STATE(iso) | ISO_NOSTATE); + break; + case ISO_MBCS: + if (*p == '(') { /* ESC $ ( F */ + iso = (CODE_STATE(iso) | ISO_MBCS | ISO_CS94); + break; + } + case ISO_MBCS | ISO_CS94: + if (*p == 'B' || *p == '@') + si = *p; + iso = (CODE_STATE(iso) | ISO_NOSTATE); + break; + } + if (*p & 0x80) + iso = CODE_ERROR; + } + if (euc != CODE_ERROR) { + switch (EUC_STATE(euc)) { + case EUC_NOSTATE: + if (!(*p & 0x80)) /* ASCII */ + ; + else if (0xa1 <= *p && *p <= 0xfe) /* JIS X 0208, + * 0213-1 */ + euc = (CODE_STATE(euc) | EUC_MBYTE1); + else if (*p == EUC_SS2_CODE) /* SS2 + JIS X 0201-Kana */ + euc = (CODE_STATE(euc) | EUC_SS2); + else if (*p == EUC_SS3_CODE) /* SS3 + JIS X 0212, 0213-2 */ + euc = (CODE_STATE(euc) | EUC_SS3); + else + euc = CODE_ERROR; + break; + case EUC_MBYTE1: + if (CODE_STATE(euc) == CODE_NORMAL) + euc = CODE_OK; + case EUC_SS3 | EUC_MBYTE1: + if (0xa1 <= *p && *p <= 0xfe) /* JIS X 0208, 0213-1 */ + euc = (CODE_STATE(euc) | EUC_NOSTATE); + else if (euc & CODE_BROKEN) + euc = CODE_ERROR; + else + euc = (CODE_BROKEN | EUC_NOSTATE); + break; + case EUC_SS2: + if (0xa0 <= *p && *p <= 0xdf) /* JIS X 0201-Kana */ + euc = (CODE_STATE(euc) | EUC_NOSTATE); + else + euc = CODE_ERROR; + break; + case EUC_SS3: + if (0xa1 <= *p && *p <= 0xfe) /* JIS X 0212, 0213-2 */ + euc = (CODE_STATE(euc) | EUC_SS3 | EUC_MBYTE1); + else + euc = CODE_ERROR; + break; + } + } + if (sjis != CODE_ERROR) { + switch (SJIS_STATE(sjis)) { + case SJIS_NOSTATE: + if (!(*p & 0x80)) /* ASCII */ + ; + else if (0x81 <= *p && *p <= 0x9f) + sjis = (CODE_STATE(sjis) | SJIS_SHIFT_L); + else if (0xe0 <= *p && *p <= 0xef) /* JIS X 0208 */ + /* else if (0xe0 <= *p && *p <= 0xfc) */ + /* JIS X 0213 */ + sjis = (CODE_STATE(sjis) | SJIS_SHIFT_H); + else if (0xa0 == *p) + sjis = (CODE_BROKEN | SJIS_NOSTATE); + else if (0xa1 <= *p && *p <= 0xdf) /* JIS X 0201-Kana + */ + sjis_kana = CODE_OK; + else + sjis = CODE_ERROR; + break; + case SJIS_SHIFT_L: + case SJIS_SHIFT_H: + if (CODE_STATE(sjis) == CODE_NORMAL) + sjis = CODE_OK; + if ((0x40 <= *p && *p <= 0x7e) || + (0x80 <= *p && *p <= 0xfc)) /* JIS X 0208, + * 0213 */ + sjis = (CODE_STATE(sjis) | SJIS_NOSTATE); + else if (sjis & CODE_BROKEN) + sjis = CODE_ERROR; + else + sjis = (CODE_BROKEN | SJIS_NOSTATE); + break; + } + } + if (euc == CODE_ERROR || sjis == CODE_ERROR) + break; + if (p == endp) + break; + p++; + } + if (iso != CODE_ERROR) { + if (si == '\0' && so == '\0' && iso_kana != CODE_OK) + return '\0'; + switch (si) { + case '@': + switch (so) { + case 'H': + return CODE_JIS_J; + case 'J': + return CODE_JIS_j; + case 'B': + return CODE_JIS_m; + default: + return CODE_JIS_m; + } + case 'B': + switch (so) { + case 'J': + return CODE_JIS_N; + case 'B': + return CODE_JIS_n; + default: + return CODE_JIS_n; + } + default: + switch (so) { + case 'H': + return CODE_JIS_J; + case 'J': + return CODE_JIS_N; + case 'B': + return CODE_JIS_n; + default: + return CODE_JIS_n; + } + } + } + if (hint == CODE_EUC) { + if (euc != CODE_ERROR) + return CODE_EUC; + } else if (hint == CODE_SJIS) { + if (sjis != CODE_ERROR) + return CODE_SJIS; + } + if (CODE_STATE(euc) == CODE_OK) + return CODE_EUC; + if (CODE_STATE(sjis) == CODE_OK) + return CODE_SJIS; + if (CODE_STATE(euc) == CODE_NORMAL) + return CODE_EUC; + if (CODE_STATE(sjis) == CODE_NORMAL) + return CODE_SJIS; + return CODE_EUC; +} +#endif /* JP_CHARSET */ diff --git a/cookie.c b/cookie.c new file mode 100644 index 0000000..43e55cd --- /dev/null +++ b/cookie.c @@ -0,0 +1,697 @@ +/* $Id: cookie.c,v 1.1 2001/11/08 05:14:17 a-ito Exp $ */ + +/* + * References for version 0 cookie: + * [NETACAPE] http://www.netscape.com/newsref/std/cookie_spec.html + * + * References for version 1 cookie: + * [RFC 2109] http://www.ics.uci.edu/pub/ietf/http/rfc2109.txt + * [DRAFT 12] http://www.ics.uci.edu/pub/ietf/http/draft-ietf-http-state-man-mec-12.txt + */ + +#include "fm.h" +#include "html.h" + +#ifdef __EMX__ +#include +#endif + +#ifdef USE_COOKIE +#include +#include "local.h" +#include "regex.h" +#include "myctype.h" + +static int is_saved = 1; + +#define contain_no_dots(p, ep) (total_dot_number((p),(ep),1)==0) + +static int +total_dot_number(char *p, char *ep, int max_count) +{ + int count = 0; + if (!ep) + ep = p + strlen(p); + + for (; p < ep && count < max_count; p++) { + if (*p == '.') + count++; + } + return count; +} + + +static char * +domain_match(char *host, char *domain) +{ + int m0, m1; + + /* [RFC 2109] s. 2, "domain-match", case 1 + * (both are IP and identical) + */ + regexCompile("[0-9][0-9]*\\.[0-9][0-9]*\\.[0-9][0-9]*\\.[0-9][0-9]*", 0); + m0 = regexMatch(host, 0, 1); + m1 = regexMatch(domain, 0, 1); + if (m0 && m1) { + if (strcasecmp(host, domain) == 0) + return host; + } + else if (!m0 && !m1) { + int offset; + char *domain_p; + /* + * "." match all domains (w3m only), + * and ".local" match local domains ([DRAFT 12] s. 2) + */ + if (strcasecmp(domain, ".") == 0 || + strcasecmp(domain, ".local") == 0) { + offset = strlen(host); + domain_p = &host[offset]; + if (domain[1] == '\0' || contain_no_dots(host, domain_p)) + return domain_p; + } + /* [RFC 2109] s. 2, cases 2, 3 */ + else { + offset = (domain[0] != '.') ? 0 : strlen(host) - strlen(domain); + domain_p = &host[offset]; + if (offset >= 0 && strcasecmp(domain_p, domain) == 0) + return domain_p; + } + } + return NULL; +} + + +static struct portlist * +make_portlist(Str port) +{ + struct portlist *first = NULL, *pl; + char *p; + Str tmp = Strnew(); + + p = port->ptr; + while (*p) { + while (*p && !IS_DIGIT(*p)) + p++; + Strclear(tmp); + while (*p && IS_DIGIT(*p)) + Strcat_char(tmp, *(p++)); + if (tmp->length == 0) + break; + pl = New(struct portlist); + pl->port = atoi(tmp->ptr); + pl->next = first; + first = pl; + } + return first; +} + +static Str +portlist2str(struct portlist *first) +{ + struct portlist *pl; + Str tmp; + + tmp = Sprintf("%d", first->port); + for (pl = first->next; pl; pl = pl->next) + Strcat(tmp, Sprintf(", %d", pl->port)); + return tmp; +} + +static int +port_match(struct portlist *first, int port) +{ + struct portlist *pl; + + for (pl = first; pl; pl = pl->next) { + if (pl->port == port) + return 1; + } + return 0; +} + +static void +check_expired_cookies(void) +{ + struct cookie *p, *p1; + time_t now = time(NULL); + + if (!First_cookie) + return; + + if (First_cookie->expires != (time_t) - 1 && + First_cookie->expires < now) { + if (!(First_cookie->flag & COO_DISCARD)) + is_saved = 0; + First_cookie = First_cookie->next; + } + + for (p = First_cookie; p && p->next; p = p1) { + p1 = p->next; + if (p1->expires != (time_t) - 1 && p1->expires < now) { + if (!(p1->flag & COO_DISCARD)) + is_saved = 0; + p->next = p1->next; + p1 = p; + } + } +} + +static Str +make_cookie(struct cookie *cookie) +{ + Str tmp = Strdup(cookie->name); + Strcat_char(tmp, '='); + Strcat(tmp, cookie->value); + return tmp; +} + +static int +match_cookie(ParsedURL * pu, struct cookie *cookie) +{ + char *domainname = (cookie->version == 0) ? FQDN(pu->host) : pu->host; + + if (!domainname) + return 0; + + if (!domain_match(domainname, cookie->domain->ptr)) + return 0; + if (strncmp(cookie->path->ptr, pu->file, cookie->path->length) != 0) + return 0; +#ifdef USE_SSL + if (cookie->flag & COO_SECURE && pu->scheme != SCM_HTTPS) + return 0; +#else /* not USE_SSL */ + if (cookie->flag & COO_SECURE) + return 0; +#endif /* not USE_SSL */ + if (cookie->portl && !port_match(cookie->portl, pu->port)) + return 0; + + return 1; +} + +struct cookie * +get_cookie_info(Str domain, Str path, Str name) +{ + struct cookie *p; + + for (p = First_cookie; p; p = p->next) { + if (Strcasecmp(p->domain, domain) == 0 && + Strcmp(p->path, path) == 0 && + Strcasecmp(p->name, name) == 0) + return p; + } + return NULL; +} + +Str +find_cookie(ParsedURL * pu) +{ + Str tmp; + struct cookie *p, *p1, *fco = NULL; + int version = 0; + + check_expired_cookies(); + for (p = First_cookie; p; p = p->next) { + if (p->flag & COO_USE && match_cookie(pu, p)) { + for (p1 = fco; p1 && Strcasecmp(p1->name, p->name); p1 = p1->next); + if (p1) + continue; + p1 = New(struct cookie); + bcopy(p, p1, sizeof(struct cookie)); + p1->next = fco; + fco = p1; + if (p1->version > version) + version = p1->version; + } + } + + if (!fco) + return NULL; + + tmp = Strnew(); + if (version > 0) + Strcat(tmp, Sprintf("$Version=\"%d\"; ", version)); + + Strcat(tmp, make_cookie(fco)); + for (p1 = fco->next; p1; p1 = p1->next) { + Strcat_charp(tmp, "; "); + Strcat(tmp, make_cookie(p1)); + if (version > 0) { + if (p1->flag & COO_PATH) + Strcat(tmp, Sprintf("; $Path=\"%s\"", p1->path->ptr)); + if (p1->flag & COO_DOMAIN) + Strcat(tmp, Sprintf("; $Domain=\"%s\"", p1->domain->ptr)); + if (p1->portl) + Strcat(tmp, Sprintf("; $Port=\"%s\"", portlist2str(p1->portl))); + } + } + return tmp; +} + +char *special_domain[] = +{ + ".com", ".edu", ".gov", ".mil", ".net", ".org", ".int", NULL}; + +int +add_cookie(ParsedURL * pu, Str name, Str value, + time_t expires, Str domain, Str path, + int flag, Str comment, int version, + Str port, Str commentURL) +{ + struct cookie *p; + char *domainname = (version == 0) ? FQDN(pu->host) : pu->host; + Str odomain = domain, opath = path; + struct portlist *portlist = NULL; + int use_security = !(flag & COO_OVERRIDE); + +#define COOKIE_ERROR(err) if(!((err) & COO_OVERRIDE_OK) || use_security) return (err) + +#ifdef DEBUG + fprintf(stderr, "host: [%s, %s] %d\n", pu->host, pu->file, flag); + fprintf(stderr, "cookie: [%s=%s]\n", name->ptr, value->ptr); + fprintf(stderr, "expires: [%s]\n", asctime(gmtime(&expires))); + if (domain) + fprintf(stderr, "domain: [%s]\n", domain->ptr); + if (path) + fprintf(stderr, "path: [%s]\n", path->ptr); + fprintf(stderr, "version: [%d]\n", version); + if (port) + fprintf(stderr, "port: [%s]\n", port->ptr); +#endif /* DEBUG */ + /* [RFC 2109] s. 4.3.2 case 2; but this (no request-host) shouldn't happen */ + if (!domainname) + return COO_ENODOT; + + if (domain) { + char *dp; + /* [DRAFT 12] s. 4.2.2 (does not apply in the case that + * host name is the same as domain attribute for version 0 + * cookie) + * I think that this rule has almost the same effect as the + * tail match of [NETSCAPE]. + */ + if (domain->ptr[0] != '.' && + (version > 0 || strcasecmp(domainname, domain->ptr) != 0)) + domain = Sprintf(".%s", domain->ptr); + + if (version == 0) { + /* [NETSCAPE] rule */ + int n = total_dot_number(domain->ptr, + domain->ptr + domain->length, + 3); + if (n < 2) { + COOKIE_ERROR(COO_ESPECIAL); + } else if (n == 2) { + char **sdomain; + int ok = 0; + for (sdomain = special_domain; !ok && *sdomain; sdomain++) { + int offset = domain->length - strlen(*sdomain); + if (offset >= 0 && + strcasecmp(*sdomain, &domain->ptr[offset]) == 0) + ok = 1; + } + if (!ok) + COOKIE_ERROR(COO_ESPECIAL); + } + } else { + /* [DRAFT 12] s. 4.3.2 case 2 */ + if (strcasecmp(domain->ptr, ".local") != 0 && + contain_no_dots(&domain->ptr[1], &domain->ptr[domain->length])) + COOKIE_ERROR(COO_ENODOT); + } + + /* [RFC 2109] s. 4.3.2 case 3 */ + if (!(dp = domain_match(domainname, domain->ptr))) + COOKIE_ERROR(COO_EDOM); + /* [RFC 2409] s. 4.3.2 case 4 */ + /* Invariant: dp contains matched domain */ + if (version > 0 && !contain_no_dots(domainname, dp)) + COOKIE_ERROR(COO_EBADHOST); + } + if (path) { + /* [RFC 2109] s. 4.3.2 case 1 */ + if (version > 0 && strncmp(path->ptr, pu->file, path->length) != 0) + COOKIE_ERROR(COO_EPATH); + } + if (port) { + /* [DRAFT 12] s. 4.3.2 case 5 */ + portlist = make_portlist(port); + if (portlist && !port_match(portlist, pu->port)) + COOKIE_ERROR(COO_EPORT); + } + + if (!domain) + domain = Strnew_charp(domainname); + if (!path) { + path = Strnew_charp(pu->file); + while (path->length > 0 && Strlastchar(path) != '/') + Strshrink(path, 1); + if (Strlastchar(path) == '/') + Strshrink(path, 1); + } + + p = get_cookie_info(domain, path, name); + if (!p) { + p = New(struct cookie); + p->flag = 0; + if (default_use_cookie) + p->flag |= COO_USE; + p->next = First_cookie; + First_cookie = p; + } + + copyParsedURL(&p->url, pu); + p->name = name; + p->value = value; + p->expires = expires; + p->domain = domain; + p->path = path; + p->comment = comment; + p->version = version; + p->portl = portlist; + p->commentURL = commentURL; + + if (flag & COO_SECURE) + p->flag |= COO_SECURE; + else + p->flag &= ~COO_SECURE; + if (odomain) + p->flag |= COO_DOMAIN; + else + p->flag &= ~COO_DOMAIN; + if (opath) + p->flag |= COO_PATH; + else + p->flag &= ~COO_PATH; + if (flag & COO_DISCARD || p->expires == (time_t) - 1) { + p->flag |= COO_DISCARD; + } + else { + p->flag &= ~COO_DISCARD; + is_saved = 0; + } + + check_expired_cookies(); + return 0; +} + +struct cookie * +nth_cookie(int n) +{ + struct cookie *p; + int i; + for (p = First_cookie, i = 0; p; p = p->next, i++) { + if (i == n) + return p; + } + return NULL; +} + +#define str2charp(str) ((str)? (str)->ptr : "") + +void +save_cookies(void) +{ + struct cookie *p; + char *cookie_file; + FILE *fp; + + check_expired_cookies(); + + if (!First_cookie || is_saved || rc_dir_is_tmp) + return; + + cookie_file = rcFile(COOKIE_FILE); + if (!(fp = fopen(cookie_file, "w"))) + return; + + for (p = First_cookie; p; p = p->next) { + if (!(p->flag & COO_USE) || p->flag & COO_DISCARD) + continue; + fprintf(fp, "%s\t%s\t%s\t%ld\t%s\t%s\t%d\t%d\t%s\t%s\t%s\n", + parsedURL2Str(&p->url)->ptr, + p->name->ptr, p->value->ptr, p->expires, + p->domain->ptr, p->path->ptr, p->flag, + p->version, str2charp(p->comment), + (p->portl) ? portlist2str(p->portl)->ptr : "", + str2charp(p->commentURL)); + } + fclose(fp); + chmod(cookie_file, S_IRUSR | S_IWUSR); +} + +static Str +readcol(char **p) +{ + Str tmp = Strnew(); + while (**p && **p != '\n' && **p != '\r' && **p != '\t') + Strcat_char(tmp, *((*p)++)); + if (**p == '\t') + (*p)++; + return tmp; +} + +void +load_cookies(void) +{ + struct cookie *cookie, *p; + FILE *fp; + Str line; + char *str; + + if (!(fp = fopen(rcFile(COOKIE_FILE), "r"))) + return; + + if (First_cookie) { + for (p = First_cookie; p->next; p = p->next); + } + else { + p = NULL; + } + for (;;) { + line = Strfgets(fp); + + if (line->length == 0) + break; + str = line->ptr; + cookie = New(struct cookie); + cookie->next = NULL; + cookie->flag = 0; + cookie->version = 0; + cookie->expires = (time_t) - 1; + cookie->comment = NULL; + cookie->portl = NULL; + cookie->commentURL = NULL; + parseURL(readcol(&str)->ptr, &cookie->url, NULL); + if (!*str) + return; + cookie->name = readcol(&str); + if (!*str) + return; + cookie->value = readcol(&str); + if (!*str) + return; + cookie->expires = (time_t) atol(readcol(&str)->ptr); + if (!*str) + return; + cookie->domain = readcol(&str); + if (!*str) + return; + cookie->path = readcol(&str); + if (!*str) + return; + cookie->flag = atoi(readcol(&str)->ptr); + if (!*str) + return; + cookie->version = atoi(readcol(&str)->ptr); + if (!*str) + return; + cookie->comment = readcol(&str); + if (cookie->comment->length == 0) + cookie->comment = NULL; + if (!*str) + return; + cookie->portl = make_portlist(readcol(&str)); + if (!*str) + return; + cookie->commentURL = readcol(&str); + if (cookie->commentURL->length == 0) + cookie->commentURL = NULL; + + if (p) + p->next = cookie; + else + First_cookie = cookie; + p = cookie; + } + + fclose(fp); +} + +void +initCookie(void) +{ + load_cookies(); + check_expired_cookies(); +} + +Buffer * +cookie_list_panel(void) +{ + Str src = Strnew_charp("Cookies" + "
Cookies
" + "

"); + struct cookie *p; + int i; + char *tmp, tmp2[80]; + + if (!use_cookie || !First_cookie) + return NULL; + + Strcat_charp(src, "
    "); + for (p = First_cookie, i = 0; p; p = p->next, i++) { + tmp = htmlquote_str(parsedURL2Str(&p->url)->ptr); + if (p->expires != (time_t) - 1) { +#ifdef HAVE_STRFTIME + strftime(tmp2, 80, "%a, %d %b %Y %H:%M:%S GMT", gmtime(&p->expires)); +#else /* not HAVE_STRFTIME */ + struct tm *gmt; + static char *dow[] = { + "Sun ", "Mon ", "Tue ", "Wed ", "Thu ", "Fri ", "Sat " + }; + static char *month[] = { + "Jan ", "Feb ", "Mar ", "Apr ", "May ", "Jun ", + "Jul ", "Aug ", "Sep ", "Oct ", "Nov ", "Dec " + }; + gmt = gmtime( &p->expires ); + strcpy(tmp2,dow[gmt->tm_wday]); + sprintf( &tmp2[4], "%02d ", gmt->tm_mday ); + strcpy(&tmp2[7],month[gmt->tm_mon]); + if( gmt->tm_year < 1900 ) + sprintf( &tmp2[11], "%04d %02d:%02d:%02d GMT", + (gmt->tm_year) + 1900, gmt->tm_hour, gmt->tm_min, + gmt->tm_sec ); + else + sprintf( &tmp2[11], "%04d %02d:%02d:%02d GMT", + gmt->tm_year, gmt->tm_hour, gmt->tm_min, gmt->tm_sec ); +#endif /* not HAVE_STRFTIME */ + } + else + tmp2[0] = '\0'; + Strcat_charp(src, "
  1. "); + Strcat_charp(src, "

    "); + Strcat_charp(src, tmp); + Strcat_charp(src, "

    "); + + Strcat_charp(src, ""); + if (!(p->flag & COO_SECURE)) { + Strcat_charp(src, ""); + } + if (p->comment) { + Strcat_charp(src, ""); + } + if (p->commentURL) { + Strcat_charp(src, ""); + } + if (tmp2[0]) { + Strcat_charp(src, ""); + } + Strcat_charp(src, ""); + } + if (p->path) { + Strcat_charp(src, ""); + } + if (p->portl) { + Strcat_charp(src, ""); + } + Strcat_charp(src, "
    Cookie:"); + Strcat_charp(src, htmlquote_str(make_cookie(p)->ptr)); + Strcat_charp(src, "
    Comment:"); + Strcat_charp(src, htmlquote_str(p->comment->ptr)); + Strcat_charp(src, "
    CommentURL:"); + Strcat_charp(src, "commentURL->ptr)); + Strcat_charp(src, "\">"); + Strcat_charp(src, htmlquote_str(p->commentURL->ptr)); + Strcat_charp(src, ""); + Strcat_charp(src, "
    Expires:"); + Strcat_charp(src, tmp2); + if (p->flag & COO_DISCARD) + Strcat_charp(src, " (Discard)"); + Strcat_charp(src, "
    Version:"); + Strcat_charp(src, Sprintf("%d", p->version)->ptr); + Strcat_charp(src, "
    "); + if (p->domain) { + Strcat_charp(src, "
    Domain:"); + Strcat_charp(src, htmlquote_str(p->domain->ptr)); + Strcat_charp(src, "
    Path:"); + Strcat_charp(src, htmlquote_str(p->path->ptr)); + Strcat_charp(src, "
    Port:"); + Strcat_charp(src, htmlquote_str(portlist2str(p->portl)->ptr)); + Strcat_charp(src, "
    Secure:"); + Strcat_charp(src, (p->flag & COO_SECURE) ? "Yes" : "No"); + Strcat_charp(src, "
    "); + + Strcat(src, Sprintf("
    Use:" + "Yes" + "  " + "No", + i, (p->flag & COO_USE) ? " checked" : "", + i, (!(p->flag & COO_USE)) ? " checked" : "")); + Strcat_charp(src, "

    "); + } + Strcat_charp(src, "

"); + return loadHTMLString(src); +} + +void +set_cookie_flag(struct parsed_tagarg *arg) +{ + int n, v; + struct cookie *p; + + while (arg) { + if (arg->arg && *arg->arg && arg->value && *arg->value) { + n = atoi(arg->arg); + v = atoi(arg->value); + if ((p = nth_cookie(n)) != NULL) { + if (v && !(p->flag & COO_USE)) + p->flag |= COO_USE; + else if (!v && p->flag & COO_USE) + p->flag &= ~COO_USE; + if (!(p->flag & COO_DISCARD)) + is_saved = 0; + } + } + arg = arg->next; + } + backBf(); +} + +int +check_cookie_accept_domain(char *domain) +{ + TextListItem *tl; + + if (domain == NULL) + return 0; + + if (Cookie_accept_domains && Cookie_accept_domains->nitem > 0) { + for (tl = Cookie_accept_domains->first; tl != NULL; tl = tl->next) { + if (domain_match(domain, tl->ptr)) + return 1; + } + } + if (Cookie_reject_domains && Cookie_reject_domains->nitem > 0) { + for (tl = Cookie_reject_domains->first; tl != NULL; tl = tl->next) { + if (domain_match(domain, tl->ptr)) + return 0; + } + } + return 1; +} +#endif /* USE_COOKIE */ diff --git a/ctrlcode.h b/ctrlcode.h new file mode 100644 index 0000000..49498b2 --- /dev/null +++ b/ctrlcode.h @@ -0,0 +1,153 @@ + +/* control characters */ + +#define CTRL_A 1 +#define CTRL_B 2 +#define CTRL_C 3 +#define CTRL_D 4 +#define CTRL_E 5 +#define CTRL_F 6 +#define CTRL_G 7 +#define CTRL_H 8 +#define CTRL_I 9 +#define CTRL_J 10 +#define CTRL_K 11 +#define CTRL_L 12 +#define CTRL_M 13 +#define CTRL_N 14 +#define CTRL_O 15 +#define CTRL_P 16 +#define CTRL_Q 17 +#define CTRL_R 18 +#define CTRL_S 19 +#define CTRL_T 20 +#define CTRL_U 21 +#define CTRL_V 22 +#define CTRL_W 23 +#define CTRL_X 24 +#define CTRL_Y 25 +#define CTRL_Z 26 +#define ESC_CODE 27 +#define DEL_CODE 127 + +/* ISO-8859-1 alphabet characters */ + +#define NBSP_CODE 160 +#define IEXCL_CODE 161 +#define CENT_CODE 162 +#define POUND_CODE 163 +#define CURREN_CODE 164 +#define YEN_CODE 165 +#define BRVBAR_CODE 166 +#define SECT_CODE 167 +#define UML_CODE 168 +#define COPY_CODE 169 +#define ORDF_CODE 170 +#define LAQUO_CODE 171 +#define NOT_CODE 172 +#define SHY_CODE 173 +#define REG_CODE 174 +#define MACR_CODE 175 +#define DEG_CODE 176 +#define PLUSMN_CODE 177 +#define SUP2_CODE 178 +#define SUP3_CODE 179 +#define ACUTE_CODE 180 +#define MICRO_CODE 181 +#define PARA_CODE 182 +#define MIDDOT_CODE 183 +#define CEDIL_CODE 184 +#define SUP1_CODE 185 +#define ORDM_CODE 186 +#define RAQUO_CODE 187 +#define FRAC14_CODE 188 +#define FRAC12_CODE 189 +#define FRAC34_CODE 190 +#define IQUEST_CODE 191 +#define AGRAVE_CODE 192 +#define AACUTE_CODE 193 +#define ACIRC_CODE 194 +#define ATILDE_CODE 195 +#define AUML_CODE 196 +#define ARING_CODE 197 +#define AELIG_CODE 198 +#define CCEDIL_CODE 199 +#define EGRAVE_CODE 200 +#define EACUTE_CODE 201 +#define ECIRC_CODE 202 +#define EUML_CODE 203 +#define IGRAVE_CODE 204 +#define IACUTE_CODE 205 +#define ICIRC_CODE 206 +#define IUML_CODE 207 +#define ETH_CODE 208 +#define NTILDE_CODE 209 +#define OGRAVE_CODE 210 +#define OACUTE_CODE 211 +#define OCIRC_CODE 212 +#define OTILDE_CODE 213 +#define OUML_CODE 214 +#define TIMES_CODE 215 +#define OSLASH_CODE 216 +#define UGRAVE_CODE 217 +#define UACUTE_CODE 218 +#define UCIRC_CODE 219 +#define UUML_CODE 220 +#define YACUTE_CODE 221 +#define THORN_CODE 222 +#define SZLIG_CODE 223 +#define aGRAVE_CODE 224 +#define aACUTE_CODE 225 +#define aCIRC_CODE 226 +#define aTILDE_CODE 227 +#define aUML_CODE 228 +#define aRING_CODE 229 +#define aELIG_CODE 230 +#define cCEDIL_CODE 231 +#define eGRAVE_CODE 232 +#define eACUTE_CODE 233 +#define eCIRC_CODE 234 +#define eUML_CODE 235 +#define iGRAVE_CODE 236 +#define iACUTE_CODE 237 +#define iCIRC_CODE 238 +#define iUML_CODE 239 +#define eth_CODE 240 +#define nTILDE_CODE 241 +#define oGRAVE_CODE 242 +#define oACUTE_CODE 243 +#define oCIRC_CODE 244 +#define oTILDE_CODE 245 +#define oUML_CODE 246 +#define DIVIDE_CODE 247 +#define oSLASH_CODE 248 +#define uGRAVE_CODE 249 +#define uACUTE_CODE 250 +#define uCIRC_CODE 251 +#define uUML_CODE 252 +#define yACUTE_CODE 253 +#define thorn_CODE 254 +#define yUML_CODE 255 + +/* EUC control characters */ + +#define EUC_SS2_CODE 0x8e +#define EUC_SS3_CODE 0x8f + +/* internally used characters */ + +/* 0x80-0x8F: use for rule */ + +#define ANSP_CODE 0x90 /* use for empty anchor */ +#define IMSP_CODE 0x91 /* blank around image */ + +#define NBSP "\xa0" +#define ANSP "\x90" +#define IMSP "\x91" + +#include "myctype.h" + +/* Local Variables: */ +/* c-basic-offset: 4 */ +/* tab-width: 8 */ +/* End: */ diff --git a/dict.c b/dict.c new file mode 100644 index 0000000..9191152 --- /dev/null +++ b/dict.c @@ -0,0 +1,137 @@ + +/* + * From g96p0935@mse.waseda.ac.jp Mon Jun 14 09:34:15 1999 Received: from + * ei5sun.yz.yamagata-u.ac.jp (ei5sun.yz.yamagata-u.ac.jp [133.24.114.42]) + * by ei5nazha.yz.yamagata-u.ac.jp (8.9.3/8.9.3) with ESMTP id JAA20673 for + * ; Mon, 14 Jun 1999 09:34:14 +0900 + * (JST) Received: from pandora.mse.waseda.ac.jp + * (root@pandora.mse.waseda.ac.jp [133.9.5.9]) by + * ei5sun.yz.yamagata-u.ac.jp (8.8.0/3.5Wbeta) with ESMTP id JAA23968 for + * ; Mon, 14 Jun 1999 09:35:30 +0900 (JST) + * Received: from localhost (root@[133.9.85.55]) by pandora.mse.waseda.ac.jp + * (8.9.1+3.0W/3.7W) with ESMTP id JAA18473; Mon, 14 Jun 1999 09:30:31 +0900 + * (JST) Message-Id: <199906140030.JAA18473@pandora.mse.waseda.ac.jp> To: + * aito@ei5sun.yz.yamagata-u.ac.jp Subject: w3m:$B1QOB<-E58!:w5!G=Ec:\(B + * Cc: g96p0935@mse.waseda.ac.jp From: Takashi Nishimoto + * X-Mailer: Mew version 1.93 on Emacs 19.34 / + * Mule 2.3 (SUETSUMUHANA) Mime-Version: 1.0 Content-Type: Text/Plain; + * charset=iso-2022-jp Content-Transfer-Encoding: 7bit Date: Mon, 14 Jun + * 1999 09:29:56 +0900 X-Dispatcher: imput version 980506 Lines: 150 + * + * $B@>K\(B@$BAaBg$G$9!#(B + * + * Quick Hack $B$G(B w3m + * $B$K1QOB<-E58!:w5!G=$HC18lC10L$N%+!<%=%k0\F0$r + +#ifdef DICT + +#define DICTCMD "w3mdict " +#define DICTBUFFERNAME "*dictionary*" +/* char *DICTBUFFERNAME="*dictionary*"; */ + +char * +GetWord(char *word) +{ + Line *l = Currentbuf->currentLine; + char *lb = l->lineBuf; + int i, b, e, pos = Currentbuf->pos; + + i = pos; + while (!IS_ALPHA(lb[i]) && i >= 0) + i--; + pos = i; + while (IS_ALPHA(lb[i]) && i >= 0) + i--; + i++; + if (!IS_ALPHA(lb[i])) + return NULL; + b = i; + i = pos; + while (IS_ALPHA(lb[i]) && i <= l->len - 1) + i++; + e = i - 1; + strncpy(word, &lb[b], e - b + 1); + word[e - b + 1] = '\0'; + return word; +} + +void +execdict(char *word) +{ + Buffer *buf; + static char cmd[100], bufname[100]; + MySignalHandler(*prevtrap) (); + + if (word == NULL) + return; + strcpy(cmd, DICTCMD); + strcat(cmd, word); + buf = namedBuffer(Firstbuf, SHELLBUFFERNAME); + if (buf != NULL) + Firstbuf = deleteBuffer(Firstbuf, buf); + + if (cmd == NULL || *cmd == '\0') { + displayBuffer(Currentbuf, B_NORMAL); + return; + } + prevtrap = signal(SIGINT, intTrap); + crmode(); + buf = getshell(cmd); +/* sprintf(bufname,"*dictionary(%s)*",word); */ +/* buf->buffername = bufname; */ + buf->buffername = DICTBUFFERNAME; + buf->filename = word; + signal(SIGINT, prevtrap); + term_raw(); + if (buf == NULL) { + disp_message("Execution failed", FALSE); + } + else if (buf->firstLine == NULL) { + /* if the dictionary doesn't describe the word. */ + char msg[100]; + sprintf(msg, "Word \"%s\" Not Found", word); + disp_message(msg, FALSE); + + } + else { + buf->nextBuffer = Firstbuf; + Currentbuf = Firstbuf = buf; + } + displayBuffer(Currentbuf, B_FORCE_REDRAW); +} + +void +dictword(void) +{ + execdict(inputStr("(dictionary)!", "")); +} + +void +dictwordat(void) +{ + static char word[100]; + execdict(GetWord(word)); +} +#endif /* DICT */ diff --git a/display.c b/display.c new file mode 100644 index 0000000..80c9a3f --- /dev/null +++ b/display.c @@ -0,0 +1,1064 @@ +/* $Id: display.c,v 1.1 2001/11/08 05:14:32 a-ito Exp $ */ +#include +#include "fm.h" + +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#define MIN(a, b) ((a) < (b) ? (a) : (b)) + +#ifdef COLOR + +#define EFFECT_ANCHOR_START effect_anchor_start() +#define EFFECT_ANCHOR_END effect_anchor_end() +#define EFFECT_IMAGE_START effect_image_start() +#define EFFECT_IMAGE_END effect_image_end() +#define EFFECT_FORM_START effect_form_start() +#define EFFECT_FORM_END effect_form_end() +#define EFFECT_ACTIVE_START effect_active_start() +#define EFFECT_ACTIVE_END effect_active_end() +#define EFFECT_VISITED_START effect_visited_start() +#define EFFECT_VISITED_END effect_visited_end() + +/* color: * 0 black * 1 red * 2 green * 3 yellow + * * 4 blue * 5 magenta * 6 cyan * 7 white */ + +#define EFFECT_ANCHOR_START_C setfcolor(anchor_color) +#define EFFECT_IMAGE_START_C setfcolor(image_color) +#define EFFECT_FORM_START_C setfcolor(form_color) +#define EFFECT_ACTIVE_START_C (setfcolor(active_color), underline()) +#define EFFECT_VISITED_START_C setfcolor(visited_color) + +#define EFFECT_IMAGE_END_C setfcolor(basic_color) +#define EFFECT_ANCHOR_END_C setfcolor(basic_color) +#define EFFECT_FORM_END_C setfcolor(basic_color) +#define EFFECT_ACTIVE_END_C (setfcolor(basic_color), underlineend()) +#define EFFECT_VISITED_END_C setfcolor(basic_color) + +#define EFFECT_ANCHOR_START_M underline() +#define EFFECT_ANCHOR_END_M underlineend() +#define EFFECT_IMAGE_START_M standout() +#define EFFECT_IMAGE_END_M standend() +#define EFFECT_FORM_START_M standout() +#define EFFECT_FORM_END_M standend() +#define EFFECT_ACTIVE_START_NC underline() +#define EFFECT_ACTIVE_END_NC underlineend() +#define EFFECT_ACTIVE_START_M bold() +#define EFFECT_ACTIVE_END_M boldend() +#define EFFECT_VISITED_START_M /**/ +#define EFFECT_VISITED_END_M /**/ + +#define define_effect(name_start,name_end,color_start,color_end,mono_start,mono_end) \ +static void name_start { if (useColor) { color_start; } else { mono_start; }}\ +static void name_end { if (useColor) { color_end; } else { mono_end; }} + +define_effect(EFFECT_ANCHOR_START, EFFECT_ANCHOR_END, EFFECT_ANCHOR_START_C, EFFECT_ANCHOR_END_C, EFFECT_ANCHOR_START_M, EFFECT_ANCHOR_END_M) +define_effect(EFFECT_IMAGE_START, EFFECT_IMAGE_END, EFFECT_IMAGE_START_C, EFFECT_IMAGE_END_C, EFFECT_IMAGE_START_M, EFFECT_IMAGE_END_M) +define_effect(EFFECT_FORM_START, EFFECT_FORM_END, EFFECT_FORM_START_C, EFFECT_FORM_END_C, EFFECT_FORM_START_M, EFFECT_FORM_END_M) +static void EFFECT_ACTIVE_START +{ + if (useColor) { + if (useActiveColor) { +#ifdef __EMX__ + if(!getenv("WINDOWID")) + setfcolor(active_color); + else +#endif + { + EFFECT_ACTIVE_START_C; + } + } else { + EFFECT_ACTIVE_START_NC; + } + } else { + EFFECT_ACTIVE_START_M; + } +} + +static void EFFECT_ACTIVE_END +{ + if (useColor) { + if (useActiveColor) { + EFFECT_ACTIVE_END_C; + } else { + EFFECT_ACTIVE_END_NC; + } + } else { + EFFECT_ACTIVE_END_M; + } +} + +static void EFFECT_VISITED_START +{ + if (useVisitedColor) { + if (useColor) { + EFFECT_VISITED_START_C; + } else { + EFFECT_VISITED_START_M; + } + } +} + +static void EFFECT_VISITED_END +{ + if (useVisitedColor) { + if (useColor) { + EFFECT_VISITED_END_C; + } else { + EFFECT_VISITED_END_M; + } + } +} + +#else /* not COLOR */ + +#define EFFECT_ANCHOR_START underline() +#define EFFECT_ANCHOR_END underlineend() +#define EFFECT_IMAGE_START standout() +#define EFFECT_IMAGE_END standend() +#define EFFECT_FORM_START standout() +#define EFFECT_FORM_END standend() +#define EFFECT_ACTIVE_START bold() +#define EFFECT_ACTIVE_END boldend() +#define EFFECT_VISITED_START /**/ +#define EFFECT_VISITED_END /**/ + +#endif /* not COLOR */ + + +#ifndef KANJI_SYMBOLS +static char g_rule[] = "ntwluxkavmqajaaa"; +#endif /* not KANJI_SYMBOLS */ + +/* + * Terminate routine. + */ + +void +fmTerm(void) +{ + if (fmInitialized) { + move(LASTLINE, 0); + clrtoeolx(); + refresh(); +#ifdef MOUSE + if (use_mouse) + mouse_end(); +#endif /* MOUSE */ + reset_tty(); + fmInitialized = FALSE; + } +} + +void +deleteFiles() +{ + Buffer *buf; + char *f; + while (Firstbuf && Firstbuf != NO_BUFFER) { + buf = Firstbuf->nextBuffer; + discardBuffer(Firstbuf); + Firstbuf = buf; + } + while ((f = popText(fileToDelete)) != NULL) + unlink(f); +} + + +/* + * Initialize routine. + */ +void +fmInit(void) +{ + if (!fmInitialized) { + initscr(); + term_raw(); + term_noecho(); +#ifdef MOUSE + if (use_mouse) + mouse_init(); +#endif /* MOUSE */ + } + fmInitialized = TRUE; +} + +/* + * Display some lines. + */ +static Line *cline = NULL; +static int ccolumn = -1; + +static int ulmode = 0, somode = 0, bomode = 0; +static int anch_mode = 0, emph_mode = 0, imag_mode = 0, form_mode = 0, + active_mode = 0, visited_mode = 0; +#ifndef KANJI_SYMBOLS +static int graph_mode = 0; +#endif /* not KANJI_SYMBOLS */ +#ifdef ANSI_COLOR +static Linecolor color_mode = 0; +#endif + +#ifdef BUFINFO +static Buffer *save_current_buf = NULL; +#endif + +static int in_check_url = FALSE; + +void +displayBuffer(Buffer * buf, int mode) +{ + Str msg; + Anchor *aa = NULL; + + if (in_check_url) + return; + if (buf->topLine == NULL && readBufferCache(buf) == 0) { /* clear_buffer */ + mode = B_FORCE_REDRAW; + } + + if (buf->width == 0) + buf->width = COLS; + if (buf->height == 0) + buf->height = LASTLINE + 1; + if (buf->width != INIT_BUFFER_WIDTH && buf->type && !strcmp(buf->type, "text/html")) { + in_check_url = TRUE; + reshapeBuffer(buf); + in_check_url = FALSE; + } + if (mode == B_FORCE_REDRAW || + mode == B_SCROLL || + cline != buf->topLine || + ccolumn != buf->currentColumn) { + if (mode == B_SCROLL && cline && buf->currentColumn == ccolumn) { + int n = buf->topLine->linenumber - cline->linenumber; + if (n > 0 && n < LASTLINE) { + move(LASTLINE, 0); + clrtoeolx(); + refresh(); + scroll(n); + } + else if (n < 0 && n > -LASTLINE) { + rscroll(-n); + } + redrawNLine(buf, n); + } + else + redrawBuffer(buf); + cline = buf->topLine; + ccolumn = buf->currentColumn; + } + if (buf->topLine == NULL) + buf->topLine = buf->firstLine; + +#ifdef MOUSE + if (use_mouse) +#if LANG == JA + msg = Strnew_charp("≪↑↓"); +#else /* LANG != JA */ + msg = Strnew_charp("<=UpDn "); +#endif /* LANG != JA */ + else +#endif /* not MOUSE */ + msg = Strnew(); + Strcat_charp(msg, "Viewing <"); + Strcat_charp(msg, buf->buffername); + if (displayLink) + aa = retrieveCurrentAnchor(buf); + if (aa) { + ParsedURL url; + Str s; + int l; + parseURL2(aa->url, &url, baseURL(buf)); + s = parsedURL2Str(&url); + l = buf->width - 2; + if (s->length > l) { + if (l >= 4) { + msg = Strsubstr(s, 0, (l - 2) / 2); +#if LANG == JA + Strcat_charp(msg, "…"); +#else /* LANG != JA */ + Strcat_charp(msg, ".."); +#endif /* LANG != JA */ + l = buf->width - msg->length; + Strcat(msg, Strsubstr(s, s->length - l, l)); + } else { + msg = s; + } + } else { + l -= s->length; + if (msg->length > l) { +#ifdef JP_CHARSET + char *bn = msg->ptr; + int i, j; + for (i = 0; bn[i]; i += j) { + j = get_mclen(get_mctype(&bn[i])); + if (i + j > l) + break; + } + l = i; +#endif + Strtruncate(msg, l); + } + Strcat_charp(msg, "> "); + Strcat(msg, s); + } + } else { + Strcat_charp(msg, ">"); + } + if (buf->firstLine == NULL) { + Strcat_charp(msg, "\tNo Line"); + clear(); + } + standout(); + message(msg->ptr, buf->cursorX, buf->cursorY); + standend(); + refresh(); +#ifdef BUFINFO + if (Currentbuf != save_current_buf) { + saveBufferInfo(); + save_current_buf = Currentbuf; + } +#endif +} + +void +redrawBuffer(Buffer * buf) +{ + redrawNLine(buf, LASTLINE); +} + +void +redrawNLine(Buffer * buf, int n) +{ + Line *l, *l0; + int i; + +#ifdef COLOR + if (useColor) { + EFFECT_ANCHOR_END_C; +#ifdef BG_COLOR + setbcolor(bg_color); +#endif /* BG_COLOR */ + } +#endif /* COLOR */ + for (i = 0, l = buf->topLine; i < LASTLINE; i++) { + if (i >= LASTLINE - n || i < -n) + l0 = redrawLine(buf, l, i); + else { + l0 = (l) ? l->next : NULL; + } + if (l0 == NULL && l == NULL) + break; + l = l0; + } + if (n > 0) + clrtobotx(); +} + +#define addKanji(pc,pr) (addChar((pc)[0],(pr)[0]),addChar((pc)[1],(pr)[1])) + +Line * +redrawLine(Buffer * buf, Line * l, int i) +{ + int j, pos, rcol, ncol, delta; + int column = buf->currentColumn; + char *p; + Lineprop *pr; +#ifdef ANSI_COLOR + Linecolor *pc; +#endif +#ifdef COLOR + Anchor *a; + ParsedURL url; + int k, vpos = -1; +#endif + + if (l == NULL) { + if (buf->pagerSource) { + l = getNextPage(buf, LASTLINE - i); + if (l == NULL) + return NULL; + } + else + return NULL; + } + move(i, 0); + if (l->width < 0) + l->width = COLPOS(l, l->len); + if (l->len == 0 || l->width - 1 < column) { + clrtoeolx(); + return l->next; + } + /* need_clrtoeol(); */ + pos = columnPos(l, column); + p = &(l->lineBuf[pos]); + pr = &(l->propBuf[pos]); +#ifdef ANSI_COLOR + if (useColor && l->colorBuf) + pc = &(l->colorBuf[pos]); + else + pc = NULL; +#endif + rcol = COLPOS(l, pos); + +#ifndef JP_CHARSET + delta = 1; +#endif + for (j = 0; rcol - column < COLS && pos + j < l->len; j += delta) { +#ifdef COLOR + if (useVisitedColor && vpos <= pos + j && !(pr[j] & PE_VISITED)) { + a = retrieveAnchor(buf->href, l->linenumber, pos + j); + if (a) { + parseURL2(a->url, &url, baseURL(buf)); + if (getHashHist(URLHist, parsedURL2Str(&url)->ptr)) { + for (k = a->start.pos; k < a->end.pos; k++) + pr[k - pos] |= PE_VISITED; + } + vpos = a->end.pos; + } + } +#endif +#ifdef JP_CHARSET + if (CharType(pr[j]) == PC_KANJI1) + delta = 2; + else + delta = 1; +#endif + ncol = COLPOS(l, pos + j + delta); + if (ncol - column > COLS) + break; +#ifdef ANSI_COLOR + if (pc) + do_color(pc[j]); +#endif + if (rcol < column) { + for (rcol = column; rcol < ncol; rcol++) + addChar(' ', 0); + continue; + } + if (p[j] == '\t') { + for (; rcol < ncol; rcol++) + addChar(' ', 0); + } +#ifdef JP_CHARSET + else if (delta == 2) { + addKanji(&p[j], &pr[j]); + } +#endif + else { + addChar(p[j], pr[j]); + } + rcol = ncol; + } + if (somode) { + somode = FALSE; + standend(); + } + if (ulmode) { + ulmode = FALSE; + underlineend(); + } + if (bomode) { + bomode = FALSE; + boldend(); + } + if (emph_mode) { + emph_mode = FALSE; + boldend(); + } + + if (anch_mode) { + anch_mode = FALSE; + EFFECT_ANCHOR_END; + } + if (imag_mode) { + imag_mode = FALSE; + EFFECT_IMAGE_END; + } + if (form_mode) { + form_mode = FALSE; + EFFECT_FORM_END; + } + if (visited_mode) { + visited_mode = FALSE; + EFFECT_VISITED_END; + } + if (active_mode) { + active_mode = FALSE; + EFFECT_ACTIVE_END; + } +#ifndef KANJI_SYMBOLS + if (graph_mode) { + graph_mode = FALSE; + graphend(); + } +#endif /* not KANJI_SYMBOLS */ +#ifdef ANSI_COLOR + if (color_mode) + do_color(0); +#endif + if (rcol - column < COLS) + clrtoeolx(); + return l->next; +} + +int +redrawLineRegion(Buffer * buf, Line * l, int i, int bpos, int epos) +{ + int j, pos, rcol, ncol, delta; + int column = buf->currentColumn; + char *p; + Lineprop *pr; +#ifdef ANSI_COLOR + Linecolor *pc; +#endif + int bcol, ecol; +#ifdef COLOR + Anchor *a; + ParsedURL url; + int k, vpos = -1; +#endif + + if (l == NULL) + return 0; + pos = columnPos(l, column); + p = &(l->lineBuf[pos]); + pr = &(l->propBuf[pos]); +#ifdef ANSI_COLOR + if (useColor && l->colorBuf) + pc = &(l->colorBuf[pos]); + else + pc = NULL; +#endif + rcol = COLPOS(l, pos); + bcol = bpos - pos; + ecol = epos - pos; + +#ifndef JP_CHARSET + delta = 1; +#endif + for (j = 0; rcol - column < COLS && pos + j < l->len; j += delta) { +#ifdef COLOR + if (useVisitedColor && vpos <= pos + j && !(pr[j] & PE_VISITED)) { + a = retrieveAnchor(buf->href, l->linenumber, pos + j); + if (a) { + parseURL2(a->url, &url, baseURL(buf)); + if (getHashHist(URLHist, parsedURL2Str(&url)->ptr)) { + for (k = a->start.pos; k < a->end.pos; k++) + pr[k - pos] |= PE_VISITED; + } + vpos = a->end.pos; + } + } +#endif +#ifdef JP_CHARSET + if (CharType(pr[j]) == PC_KANJI1) + delta = 2; + else + delta = 1; +#endif + ncol = COLPOS(l, pos + j + delta); + if (ncol - column > COLS) + break; +#ifdef ANSI_COLOR + if (pc) + do_color(pc[j]); +#endif + if (j >= bcol && j < ecol) { + if (rcol < column) { + move(i, 0); + for (rcol = column; rcol < ncol; rcol++) + addChar(' ', 0); + continue; + } + move(i, rcol - column); + if (p[j] == '\t') { + for (; rcol < ncol; rcol++) + addChar(' ', 0); + } +#ifdef JP_CHARSET + else if (delta == 2) { + addKanji(&p[j], &pr[j]); + } +#endif + else { + addChar(p[j], pr[j]); + } + } + rcol = ncol; + } + if (somode) { + somode = FALSE; + standend(); + } + if (ulmode) { + ulmode = FALSE; + underlineend(); + } + if (bomode) { + bomode = FALSE; + boldend(); + } + if (emph_mode) { + emph_mode = FALSE; + boldend(); + } + + if (anch_mode) { + anch_mode = FALSE; + EFFECT_ANCHOR_END; + } + if (imag_mode) { + imag_mode = FALSE; + EFFECT_IMAGE_END; + } + if (form_mode) { + form_mode = FALSE; + EFFECT_FORM_END; + } + if (visited_mode) { + visited_mode = FALSE; + EFFECT_VISITED_END; + } + if (active_mode) { + active_mode = FALSE; + EFFECT_ACTIVE_END; + } +#ifndef KANJI_SYMBOLS + if (graph_mode) { + graph_mode = FALSE; + graphend(); + } +#endif /* not KANJI_SYMBOLS */ +#ifdef ANSI_COLOR + if (color_mode) + do_color(0); +#endif + return rcol - column; +} + +#define do_effect1(effect,modeflag,action_start,action_end) \ +if (m & effect) { \ + if (!modeflag) { \ + action_start; \ + modeflag = TRUE; \ + } \ +} + +#define do_effect2(effect,modeflag,action_start,action_end) \ +if (modeflag) { \ + action_end; \ + modeflag = FALSE; \ +} + +void +do_effects(Lineprop m) +{ + /* effect end */ + do_effect2(PE_UNDER, ulmode, underline(), underlineend()); + do_effect2(PE_STAND, somode, standout(), standend()); + do_effect2(PE_BOLD, bomode, bold(), boldend()); + do_effect2(PE_EMPH, emph_mode, bold(), boldend()); + do_effect2(PE_ANCHOR, anch_mode, EFFECT_ANCHOR_START, EFFECT_ANCHOR_END); + do_effect2(PE_IMAGE, imag_mode, EFFECT_IMAGE_START, EFFECT_IMAGE_END); + do_effect2(PE_FORM, form_mode, EFFECT_FORM_START, EFFECT_FORM_END); + do_effect2(PE_VISITED, visited_mode, EFFECT_VISITED_START, EFFECT_VISITED_END); + do_effect2(PE_ACTIVE, active_mode, EFFECT_ACTIVE_START, EFFECT_ACTIVE_END); +#ifndef KANJI_SYMBOLS + if (graph_mode) { + graphend(); + graph_mode = FALSE; + } +#endif /* not KANJI_SYMBOLS */ + + /* effect start */ + do_effect1(PE_UNDER, ulmode, underline(), underlineend()); + do_effect1(PE_STAND, somode, standout(), standend()); + do_effect1(PE_BOLD, bomode, bold(), boldend()); + do_effect1(PE_EMPH, emph_mode, bold(), boldend()); + do_effect1(PE_ANCHOR, anch_mode, EFFECT_ANCHOR_START, EFFECT_ANCHOR_END); + do_effect1(PE_IMAGE, imag_mode, EFFECT_IMAGE_START, EFFECT_IMAGE_END); + do_effect1(PE_FORM, form_mode, EFFECT_FORM_START, EFFECT_FORM_END); + do_effect1(PE_VISITED, visited_mode, EFFECT_VISITED_START, EFFECT_VISITED_END); + do_effect1(PE_ACTIVE, active_mode, EFFECT_ACTIVE_START, EFFECT_ACTIVE_END); +#ifndef KANJI_SYMBOLS + if (m & PC_RULE) { + if (!graph_mode && graph_ok()) { + graphstart(); + graph_mode = TRUE; + } + } +#endif /* not KANJI_SYMBOLS */ +} + +#ifdef ANSI_COLOR +void +do_color(Linecolor c) +{ + if (c & 0x8) + setfcolor(c & 0x7); + else if (color_mode & 0x8) + setfcolor(basic_color); +#ifdef BG_COLOR + if (c & 0x80) + setbcolor((c >> 4) & 0x7); + else if (color_mode & 0x80) + setbcolor(bg_color); +#endif + color_mode = c; +} +#endif + +void +addChar(char c, Lineprop mode) +{ + Lineprop m = CharEffect(mode); + +#ifdef JP_CHARSET + if (CharType(mode) != PC_KANJI2) +#endif /* JP_CHARSET */ + do_effects(m); +#ifndef KANJI_SYMBOLS + if (m & PC_RULE) { + if (graph_mode) + addch(g_rule[c & 0xF]); + else + addch(alt_rule[c & 0xF]); + } else +#endif /* not KANJI_SYMBOLS */ + if (IS_UNPRINTABLE_ASCII(c, mode)) { + addstr(Sprintf("\\%3o", (unsigned char)c)->ptr); + } + else if (c == '\t') { + addch(c); + } + else if (c == DEL_CODE) + addstr("^?"); + else if (IS_UNPRINTABLE_CONTROL(c, mode)) { /* Control code */ + addch('^'); + addch(c + '@'); + } + else if (c != '\n') + addch(c); + else /* \n */ + addch(' '); +} + +GeneralList *message_list = NULL; + +void +record_err_message(char *s) +{ + if (fmInitialized) { + if (!message_list) + message_list = newGeneralList(); + if (message_list->nitem >= LINES) + popValue(message_list); + pushValue(message_list, allocStr(s, 0)); + } +} + +/* + * List of error messages + */ +Buffer * +message_list_panel(void) +{ + Str tmp = Strnew_size(LINES * COLS); + ListItem *p; + + Strcat_charp(tmp, + "List of error messages" + "

List of error messages

\n"); + if (message_list) + for (p = message_list->last ; p ; p = p->prev) + Strcat_m_charp(tmp, "\n", NULL); + else + Strcat_charp(tmp, "\n"); + Strcat_charp(tmp, "
", htmlquote_str(p->ptr), "
(no message recorded)
"); + return loadHTMLString(tmp); +} + +void +message(char *s, int return_x, int return_y) +{ + if (!fmInitialized) + return; + move(LASTLINE, 0); + addnstr(s, COLS - 1); + clrtoeolx(); + move(return_y, return_x); +} + +void +disp_message_nsec(char *s, int redraw_current, int sec, int purge, int mouse) +{ + if (!fmInitialized) { + fprintf(stderr, "%s\n", s); + return; + } + if (Currentbuf != NULL) + message(s, Currentbuf->cursorX, Currentbuf->cursorY); + else + message(s, LASTLINE, 0); + refresh(); +#ifdef MOUSE + if (mouse && use_mouse) + mouse_active(); +#endif + sleep_till_anykey(sec, purge); +#ifdef MOUSE + if (mouse && use_mouse) + mouse_inactive(); +#endif + if (Currentbuf != NULL && redraw_current) + displayBuffer(Currentbuf, B_NORMAL); +} + +void +disp_message(char *s, int redraw_current) +{ + disp_message_nsec(s, redraw_current, 10, FALSE, TRUE); +} +#ifdef MOUSE +void +disp_message_nomouse(char *s, int redraw_current) +{ + disp_message_nsec(s, redraw_current, 10, FALSE, FALSE); +} +#endif + +void +cursorUp(Buffer * buf) +{ + if (buf->firstLine == NULL) + return; + if (buf->cursorY > 0) + cursorUpDown(buf, -1); + else { + buf->topLine = lineSkip(buf, buf->topLine, -(LASTLINE + 1) / 2, FALSE); + if (buf->currentLine->prev != NULL) + buf->currentLine = buf->currentLine->prev; + arrangeLine(buf); + } +} + +void +cursorDown(Buffer * buf) +{ + if (buf->firstLine == NULL) + return; + if (buf->cursorY < LASTLINE - 1) + cursorUpDown(buf, 1); + else { + buf->topLine = lineSkip(buf, buf->topLine, (LASTLINE + 1) / 2, FALSE); + if (buf->currentLine->next != NULL) + buf->currentLine = buf->currentLine->next; + arrangeLine(buf); + } +} + +void +cursorUpDown(Buffer * buf, int n) +{ + Line *cl = buf->currentLine; + + if (buf->firstLine == NULL) + return; + if ((buf->currentLine = currentLineSkip(buf, cl, n, FALSE)) == cl) + return; + arrangeLine(buf); +} + +void +cursorRight(Buffer * buf) +{ + int i, delta = 1, cpos, vpos2; + Line *l = buf->currentLine; + Lineprop *p; + + if (buf->firstLine == NULL) + return; + if (buf->pos == l->len) + return; + i = buf->pos; + p = l->propBuf; +#ifdef JP_CHARSET + if (CharType(p[i]) == PC_KANJI1) + delta = 2; +#endif /* JP_CHARSET */ + if (i + delta < l->len) { + buf->pos = i + delta; + } + else if (l->len == 0) { + buf->pos = 0; + } + else { + buf->pos = l->len -1; +#ifdef JP_CHARSET + if (CharType(p[buf->pos]) == PC_KANJI2) + buf->pos--; +#endif /* JP_CHARSET */ + } + cpos = COLPOS(l, buf->pos); + buf->visualpos = cpos - buf->currentColumn; + delta = 1; +#ifdef JP_CHARSET + if (CharType(p[buf->pos]) == PC_KANJI1) + delta = 2; +#endif /* JP_CHARSET */ + vpos2 = COLPOS(l, buf->pos + delta) - buf->currentColumn - 1; + if (vpos2 >= COLS) { + columnSkip(buf, (COLS / 2) + (vpos2 - COLS) - (vpos2 - COLS) % (COLS / 2)); + buf->visualpos = cpos - buf->currentColumn; + } + buf->cursorX = buf->visualpos; +} + +void +cursorLeft(Buffer * buf) +{ + int i, delta = 1, cpos; + Line *l = buf->currentLine; + Lineprop *p; + + if (buf->firstLine == NULL) + return; + i = buf->pos; + p = l->propBuf; +#ifdef JP_CHARSET + if (i >= 2 && CharType(p[i - 1]) == PC_KANJI2) + delta = 2; +#endif /* JP_CHARSET */ + if (i > delta) + buf->pos = i - delta; + else + buf->pos = 0; + cpos = COLPOS(l, buf->pos); + buf->visualpos = cpos - buf->currentColumn; + if (buf->visualpos < 0) { + columnSkip(buf, -(COLS / 2) + buf->visualpos - buf->visualpos % (COLS / 2)); + buf->visualpos = cpos - buf->currentColumn; + } + buf->cursorX = buf->visualpos; +} + +void +cursorHome(Buffer * buf) +{ + buf->visualpos = 0; + buf->cursorX = buf->cursorY = 0; +} + + +/* + * Arrange line,column and cursor position according to current line and + * current position. + */ +void +arrangeCursor(Buffer * buf) +{ + int col,col2; + int delta = 1; + if (buf == NULL || buf->currentLine == NULL) + return; + /* Arrange line */ + if (buf->currentLine->linenumber - buf->topLine->linenumber >= LASTLINE || + buf->currentLine->linenumber < buf->topLine->linenumber) { + buf->topLine = buf->currentLine; + } + /* Arrange column */ + if (buf->currentLine->len == 0) + buf->pos = 0; + else if (buf->pos >= buf->currentLine->len) + buf->pos = buf->currentLine->len - 1; +#ifdef JP_CHARSET + if (CharType(buf->currentLine->propBuf[buf->pos]) == PC_KANJI2) + buf->pos--; +#endif /* JP_CHARSET */ + col = COLPOS(buf->currentLine, buf->pos); +#ifdef JP_CHARSET + if (CharType(buf->currentLine->propBuf[buf->pos]) == PC_KANJI1) + delta = 2; +#endif /* JP_CHARSET */ + col2 = COLPOS(buf->currentLine, buf->pos + delta); + if (col < buf->currentColumn || col2 > COLS + buf->currentColumn) { + buf->currentColumn = 0; + if (col2 > COLS) + columnSkip(buf, col); + } + /* Arrange cursor */ + buf->cursorY = buf->currentLine->linenumber - buf->topLine->linenumber; + buf->visualpos = buf->cursorX = COLPOS(buf->currentLine, buf->pos) - buf->currentColumn; +#ifdef DISPLAY_DEBUG + fprintf(stderr, "arrangeCursor: column=%d, cursorX=%d, visualpos=%d, pos=%d, len=%d\n", + buf->currentColumn, buf->cursorX, buf->visualpos, + buf->pos, buf->currentLine->len); +#endif +} + +void +arrangeLine(Buffer * buf) +{ + int i, cpos; + + if (buf->firstLine == NULL) + return; + buf->cursorY = buf->currentLine->linenumber - buf->topLine->linenumber; + i = columnPos(buf->currentLine, buf->currentColumn + buf->visualpos); + cpos = COLPOS(buf->currentLine, i) - buf->currentColumn; + if (cpos >= 0) { + buf->cursorX = cpos; + buf->pos = i; + } + else if (Currentbuf->currentLine->len > i) { + int delta = 1; +#ifdef JP_CHARSET + if (Currentbuf->currentLine->len > i + 1 && + CharType(buf->currentLine->propBuf[i + 1]) == PC_KANJI2) + delta = 2; +#endif + buf->cursorX = 0; + buf->pos = i; + if (COLPOS(buf->currentLine, i + delta) <= buf->currentColumn) + buf->pos += delta; + } + else { + buf->cursorX = 0; + buf->pos = 0; + } +#ifdef DISPLAY_DEBUG + fprintf(stderr, "arrangeLine: column=%d, cursorX=%d, visualpos=%d, pos=%d, len=%d\n", + buf->currentColumn, buf->cursorX, buf->visualpos, + buf->pos, buf->currentLine->len); +#endif +} + +void +cursorXY(Buffer * buf, int x, int y) +{ + int oldX; + + cursorUpDown(buf, y - buf->cursorY); + + if (buf->cursorX > x) { + while (buf->cursorX > x) + cursorLeft(buf); + } + else if (buf->cursorX < x) { + while (buf->cursorX < x) { + oldX = buf->cursorX; + + cursorRight(buf); + + if (oldX == buf->cursorX) + break; + } + if (buf->cursorX > x) + cursorLeft(buf); + } +} + +/* Local Variables: */ +/* c-basic-offset: 4 */ +/* tab-width: 8 */ +/* End: */ diff --git a/doc-jp/FAQ.html b/doc-jp/FAQ.html new file mode 100644 index 0000000..257f512 --- /dev/null +++ b/doc-jp/FAQ.html @@ -0,0 +1,238 @@ + + +W3M FAQ + + +

w3mに関して良く聞かれる(であろう)質問とその答え

+
+伊藤 彰則
+aito@ei5sun.yz.yamagata-u.ac.jp +
+ +
+

一般的なこと,入手方法,動作環境

+
+
+
``w3m''は何と読むのですか? +
「だぶりゅーさんえむ」または「だぶりゅーすりーえむ」です. +``w3m''と書いてプテラノドンと読んだりはしません. +

+

どうして``w3m''という名前なの? +
WWW-wo-Miru(WWWを見る)から付けました. +

+

どういう環境で動くの? +
一般的なUNIXで動きます.最新版またはそれに近いバージョンで動作が確認されているのは, +
+
+Solaris 2.5 以上
+SunOS 4.1.x
+HP-UX 9.x, 10.x
+Linux 2.0.30
+FreeBSD 2.2.8, 3.1
+EWS4800 Release12.2 Rev.A
+
+などです.その他のものでも,メジャーなUNIXシステムなら動くでしょう. +

+version 990226 から,OS/2 で動くようです. +

+version 990303 から,Windows+cygwin32 で動くようになりました. +

+

Windows 9x/NT では動かないの? +
Cygwin32を使えば動きます. +

+

w3mに関する情報はどこから手に入るの? +
+http://ei5nazha.yz.yamagata-u.ac.jp/~aito/w3m/に w3m のページ +があります. +

+

最新版はどこから手に入るの? +
+ftp://ei5nazha.yz.yamagata-u.ac.jp/w3m/から手に入ります. +

+

w3m に関するMLはありませんか? +
+開発者向けML(w3m-dev(日本語)とw3m-dev-en(英語))があります。詳しくは +w3m のページ +をご覧ください。開発関連以外で +何か言いたいことがある場合には,作者に +直接メールするか,あるいは +作者の運営する掲示板に書いてください. +

+

バイナリ配布はしないの? +
+いくつかのプラットフォームについて,w3mのバイナリ配布をやって +くださっているサイトがあります.詳しくは + +w3mのページをごらんください. + +
+ + +

コンパイルとインストール

+特に問題なし :-) + + +

オプション,コマンド,使いかた

+
+
w3m と入力したら,何も表示せずに終わっちゃいました.何が悪いの? +
w3m はページャです.ですから,何も指定しないで起動すれば +そのまま終了します.何か表示させたい場合には, +
    +
  1. 引数にファイル名かURLを書く. +
  2. 標準入力に何か入れてあげる. +
  3. -B オプション(ブックマーク表示)をつける. +
  4. 環境変数 HTTP_HOME か WWW_HOME に,見たいページのURLを入れておく. +
+のどれかをやってください. +

+

w3mを起動したら,画面が真っ黒になってしまいました.どうして? +
w3mをカラー表示の設定でコンパイルすると,最初は背景色が白で +文字色が黒の設定になります.そのため,ふだん背景を黒にしている状態で +w3mを起動すると,字が見えなくなります.

+こういう場合は,次のようにして色を設定します. +

    +
  • w3m -M で w3m を起動し,白黒モードで表示する. +
  • "o" コマンドでオプション設定画面にする. +
  • カラー表示モードをONにし,適当な文字色を選んで, +[OK]を選択する. +
+
カラー表示をさせるにはどうするの? +
コンパイル時に,configure の質問 +

+

+Let's do some configurations. Choose config option among the list."
+
+1 - Baby model    (no color, no menu, no mouse, no cookie, no SSL)
+2 - Little model  (color, menu, no mouse, no cookie, no SSL)
+3 - Mouse model   (color, menu, mouse, no cookie, no SSL)
+4 - Cookie model  (color, menu, mouse, cookie, no SSL)
+5 - Monster model (with everything; you need openSSL library)
+6 - Customize
+Which? 
+
+

+で、2,3,4,5のどれかを答えればカラー表示ができるようになります。 +

+

白黒で表示したいんだけど? +
方法は3つあります. +
    +
  1. 上記の質問に 1 と答えてコンパイルする. +
  2. -M オプションをつけて起動する. +
  3. "o" コマンドでオプション設定パネルを起動し,カラー表示をOFFにする. +
+
画面をはみ出した部分を見るには? +
カーソルを画面の端に移動させれば,それに合わせて画面全体がずれます. +また,">"と"<"で画面全体をずらすことができます. +

+

カーソル移動がわずらわしい. +
TABで次のアンカーに移動するので,Lynxと似た感覚で使えるでしょう. +また,C-uおよびESC TABで前のアンカーに戻ります. +

+

Netscapeでは赤い文字になっている部分が,w3m では黒いまま.なぜ? +
w3mは,<FONT COLOR="..">による文字の色指定には対応していません. +対応は不可能ではないですが,文字の色が背景と同じになったりして見づらく +なるのがオチなので,あまり対応する気になりません. +

+

アンカー/画像/formの色を変えるには? +
990309版から,オプションで切りかえられるようになりました."o" コマンド +で設定パネルを表示させ,好きな色を選んでください.字の表示色が背景と同じに +なって何も見えないという場合には,-M オプションで白黒表示にしてから設定を +するとよいでしょう. +

+

環境変数 EDITOR を設定したけど,効かないのはなぜ? +
"o"コマンドでオプションを表示させてみてください. +エディタの項目に何か書いてあれば,それが優先されます. +環境変数を効かせたい場合は,この欄を空白にしてオプションを +更新してください. +

+

サーチやURL入力を途中でやめるには? +
+ C-c で戻ります. + +
+ + +

WWWを使う場合の質問

+
+
formに入力するにはどうするの? +
formの部分は,画面上で赤(または反転)で表示されていますので, +そこにカーソルを持っていってリターンを押します.すると, +
    +
  • text の場合は,画面最下行で入力待ちになりますので,文字を入力します. +
  • radio, checkbox の場合は,その項目が選ばれます. +
  • textarea の場合は,エディタが起動しますので,文章を入力します. +このとき,必ず表示用漢字コードと同じ漢字コードでファイルを保存してください. +
  • submit, reset の場合は,formの内容を送信/クリアします. +
+
文書の表示が遅いんだけど? +
w3mはHTML文書を2パスで整形するので,文書全体を読みこまないと +表示ができません.Netscapeなどは文書を読みながら表示するので, +表示が速いように思えるのでしょう. +

+

一度読んだ文書を2度目に読んだときに,読みこみが速くならないんだけど? +
他の多くのブラウザと違い,w3mはキャッシュを持っていません. +そのため,文書を読むたびにWWWサーバから文書を転送します.もし可能なら, +キャッシュサーバを利用すると快適です.設定はプロキシの設定と同じです. +

+

リンク先のファイルを直接保存する方法はないの? +
'a' (Lynx 風キーバインドの場合は 'd') または ESC RETでリンク先の文書を +保存します.画像を保存する場合は ESC I です. +

+

プロキシの設定はどうするの? +
環境変数 HTTP_proxy を設定するか,"o" コマンドのオプション設定パネル +で設定します.例えば proxy.hogege.com というホストの 8000番ポートを +利用する場合, +

+

+    http://proxy.hogege.com:8000/
+
+

+と設定します. +

+

外部ブラウザを起動すると,w3mが固まってしまいます. +何とかなりませんか? +
"o"コマンドで設定パネルを表示し,外部ブラウザの項目に,例えば +

+

+    netscape %s &
+
+

+のように入力します.この場合,%s の部分が URL に置きかわってブラウザが起動し +ます. +

+

画像のビューアを変えたいんだけど,どうするの? +
初期設定では画像を見るのに xv を使うようになっていますが,これを +例えば display に変える場合は,~/.mailcap または /etc/mailcap に次のよ +うな記述を入れます. +

+

+image/*; display %s
+
+

+同じように,他のタイプのデータを処理するプログラムを指定することも +できます. +

+

+image/*;                     display %s
+application/postscript;      ghostview %s
+application/x-dvi;           xdvi %s
+
+ +
+ + +

その他

+
+
設定ファイルはどこにあるの? +
~/.w3m ディレクトリの下の config です. +

+

~/.w3m の下に w3mXXXXXX のようなファイルがたくさんあるけど,何? +
WWWサーバからファイルを読んでいるときに,それを一時的に保存する +ファイルです.いわゆるキャッシュファイルではありません. +w3m を終了すれば消去されるはずですが,w3mが異常終了した場合には残る +ことがあります.そういう場合は手で消してください. +

+

+ + + diff --git a/doc-jp/HISTORY b/doc-jp/HISTORY new file mode 100644 index 0000000..ce90974 --- /dev/null +++ b/doc-jp/HISTORY @@ -0,0 +1,4273 @@ +2001/3/23 ============================================================== +From: Hironori Sakamoto +Subject: [w3m-dev 01807] Re: w3m-0.2.0 +* url.c が USE_NNTP や __EMX__ でコンパイルできない。 +* EWS4800 用の patch (間に合いませんでしたね。坂根さん) +* ssl_forbid_method がらみで #define USE_SSL で #undef USE_SSL_VERIFY + の場合の処理。(rc.c と url.c) + # hsaka24 でアナウンスせずに修正を入れてしまったのが問題でしたね。 + # すみません。 +* rc.c に一部 ISO-2022-JP があるものを修正。 + # 添付の patch であたるかどうか… +* saveBufferDelNum で del==TRUE の時、":" 以前が2回削除される。 +* main.c の URL履歴を保存する位置の修正。 + # これも hsaka24 でアナウンスせずに修正を入れてました。 + +From: TSUCHIYA Masatoshi +Subject: [w3m-dev 01810] deflate (was: w3m-0.2.0) +0.2.0 には Content-encoding: deflate に対応するためのパッチ [w3m-dev 01684] +も含まれているようですが、これだけでは http://cvs.m17n.org/~akr/diary/ +は閲覧できませんでした。 + +From: Fumitoshi UKAI +Subject: [w3m-dev 01808] Re: w3m-0.2.0 +GNU/Linux で glibc 2.2系だと sin.ss_len がないので +IPv6 でコンパイルできません。 + +From: Hironori Sakamoto +Subject: [w3m-dev-en 00399] Re: w3m-0.2.0 + >> From: Dan Fandrich + >> Version 0.2.0 still contains the following bugs which I fixed two months + >> ago and sent patches for to this list, namely: + >> - core dumps on startup if given a URL requiring a needsterminal mailcap + >> handler + >> - destroys most of an existing ~/.mailcap file without warning when editing + >> - mailcap handling is still wrong as MIME type should be case insensitive + >> - private mailcap extension has an illegal name + +From: SATO Seichi +Subject: w3mの正規表現検索におけるバグ +検索文字列として $* を渡すと Segmentation fault が +発生するようです。(全然無意味な文字列なんですが) + +2001/3/22 ============================================================== + +From: Hironori Sakamoto +Subject: [w3m-dev 01664] Re: Patch for anonymizer.com +HTTP(HTTPS)の場合に URL が + http:///: ... +となっていれば cleanupName() を呼ばない様にしてみました。 + +From: Hironori Sakamoto +Subject: [w3m-dev 01670] Re: w3m-0.1.11-pre-kokb24-test1 +Str.c の strcpy/strncpy を bcopy or memcpy にする件ですが、 +bcopy 系と memcpy 系を統一するのは後にするとしても、とりあえず全て +bcopy に置き換えた方がいいと思います。 +ついでに、saveBufferDelNum で一部 '\0' が扱えなくなっているバグの修正です。 + +From: TSUCHIYA Masatoshi +Subject: [w3m-dev 01618] backend patch +Subject: [w3m-dev 01671] backend patch for w3m-0.1.11-pre-kokb24-test1 +w3m を対話的なクライアントとして働く機能を追加するパッチです。 + +From: hsaka@mth.biglobe.ne.jp (Hironori Sakamoto) +Subject: [w3m-dev 01673] SEGV in append_frame_info() +>w3m/0.1.11-pre-kokb23-m17n-0.8 を使っていますが、Der Angriff のトップページ ( +>http://i.am/goebbels/)で、ページの情報を見ようと「=」キーを押したら、 +>Segmentation Fault してしまいました。 +との指摘がありました。m17n 版に限らないので、とりあえず対処しておきます。 + +From: hsaka@mth.biglobe.ne.jp (Hironori Sakamoto) +Subject: [w3m-dev 01674] image map +> AREAで作ったクライアントサイドイメージマップのhrefが"#test"のような場合に、 +> ジャンプ出来ません。 +> Image map links の画面では、URLだけでなく、altやtitleも表示した方が良いと +> 思います。 +との指摘がありましたので修正/対応してみました。ただし、 +* #undef MENU_MAP の場合、#label のみであっても reload になる。 + 別のバッファからの呼び出しなので、こうしないとちょっと難しいです。 + なお、内部で作成したバッファからの呼び出しは全てそうなる様にしました。 + バッファを作らない #define MENU_MAP の方がいいかと思います。 +* 追加した属性は alt のみ (title って何?) + MapList 構造体を変えた方が良いようにも思いましたが、面倒なので止めました。 +となってます。 + +From: hsaka@mth.biglobe.ne.jp (Hironori Sakamoto) +Subject: [w3m-dev 01675] goto label +GOTO や #define MENU_MAP の場合のイメージマップ +で #label のみの URL が指定された場合に reload しない様にしました。 +それから、[w3m-dev 01101] space in URL で追加された処理を goURL() に移し +ました。ただし、inputLineHist() で URL を入力する場合、空白文字は ^V を +使わないと入力できないので必要ないとも思います。そういうこともあって +後ろの空白の処理は外しました。 + +From: Tsutomu Okada +Subject: [w3m-dev 01676] Re: w3m-0.1.11-pre-kokb24-test1 +Subject: [w3m-dev 01678] Re: w3m-0.1.11-pre-kokb24-test1 +須藤さんの [w3m-dev 01627] のパッチのうち、GC_warn 関連と細かなソース +の修正は当てておいたほうがいいように思います。 + +From: Hironori Sakamoto +Subject: [w3m-dev 01680] Re: w3m-0.1.11-pre-kokb24-test1 + >> 岡田です。 + >> 私の環境では、-pedantic によって + >> warning: ANSI forbids assignment between function pointer and `void *' + >> warning: pointer targets in initialization differ in signedness +う、ごめんなさい。私ですね。墓穴を掘ってしまった... + >> warning: overflow in implicit constant conmplicit con version + >> warning: pointer targets in passing arg 2 of `Strcat_charp_n' differ in signedness + >> という警告が出ましたが、これらも修正すべきでしょうか? +修正するにこしたことはないので patch を出します。 + +From: Hironori Sakamoto +Subject: [w3m-dev 01684] Re: http://cvs.m17n.org/~akr/diary/ +application/x-deflate 対応. + +From: Moritz Barsnick +Subject: [w3m-dev-en 00318] Information about current page +Subject: [w3m-dev-en 00320] Re: Information about current page +Subject: [w3m-dev-en 00322] Re: Information about current page +Subject: [w3m-dev-en 00323] Buglet (Was: Re: Information about current page) +Changes 'URL of the current anchor' on the info page into +'full' URL. When the cursor is on a form element, +`Method/type of current form' will be displayed. + +From: c603273@vus069.trl.telstra.com.au (Brian Keck) +Subject: [w3m-dev-en 00343] patch for proxy user:passwd on command line +Subject: [w3m-dev-en 00351] Re: patch for proxy user:passwd on command line +This patch to w3m-0.1.11-pre-kokb23 adds the lynx-like option + + -pauth username:password + +so I don't have to retype username & password every time I run w3m, +which is often. It's so simple I wonder whether it's against policy, +but it would be nice for me & some others if it was in the official +0.1.11. + +From: Hironori Sakamoto +Subject: [w3m-dev 01772] Re: visited anchor +Subject: [w3m-dev 01773] Re: visited anchor + * visited anhor color。 + * textlist ベースの history。hash 化された (URL) history。 + * #undef KANJI_SYMBOLS の場合の rule の実装の変更。 + +From: Hironori Sakamoto +Subject: [w3m-dev 01786] Re: w3m-0.1.11-pre-hsaka24 +Subject: [w3m-dev 01787] Re: w3m-0.1.11-pre-hsaka24 + >> 1. http://www.tomoya.com/ で、 の文書を表示させ(フレームの自 + >> 動表示が ON なら、F を押す)、MAIN のフレームを表示させようとすると、 + >> main.c:2082 の Sprintf で落ちる(gotoLabel を label=0x0 で呼びだしてい + >> る)。 +[w3m-dev 01675] の致命的なバグ。すみません。 + >> 2. 掲示板α http://133.5.222.232/keijiban/index.htm を表示させようとす + >> ると、frame.c:668 の strcasecmp で落ちる +こっちは前々から。 + +From: Hironori Sakamoto +Subject: [w3m-dev 01788] Re: w3m-0.1.11-pre-hsaka24 +w3m-0.1.11-pre-hsaka24 のバグ修正です。 + +From: Hironori Sakamoto +Subject: [w3m-dev 01792] Re: w3m-0.1.11-pre-hsaka24 + >> 全然別件なのですが、useVisitedColor が TRUE のとき + >> http://www.kusastro.kyoto-u.ac.jp/%7Ebaba/wais/other-system.html にお + >> いて、最後の画面の表示が 1〜2 秒ほど待たされます。具体的には、goLineL +retrieveAnchor() が linear search だったのが原因でした。 +binary search に変えてみました。どうでしょう。 + +From: hsaka@mth.biglobe.ne.jp (Hironori Sakamoto) +Subject: [w3m-dev 01793]
  • +
  • タグの type 属性ですが、その
  • にのみ有効なのではなくて、 +
        での指定を上書きする(以降の
      • にも有効となる)様 +ですので修正しました。 + +From: hsaka@mth.biglobe.ne.jp (Hironori Sakamoto) +Subject: [w3m-dev 01801] some fixes. +frame を表示していて、2重に出力されている部分がありました。 +その修正です。 + +Subject: IPv6 support for w3m's ftp +From: Hajimu UMEMOTO + w3m の HTTP は IPv6 対応されているのですが、残念ながら FTP 機能の方 +は IPv6 対応していません。FTP 機能に対する IPv6 対応パッチを作成しまし +たので、非公式パッチに含めて頂けないでしょうか? + +2001/3/16 ================================================================== +From: hsaka@mth.biglobe.ne.jp (Hironori Sakamoto) +Subject: [w3m-dev 01711] Authorization +・http://user:pass@hostname/ に対応. + +From: hsaka@mth.biglobe.ne.jp +Subject: [w3m-dev 01724] buf->type when mailcap is used. +mailcap を使った場合(copiousoutput, htmloutput) にも、 +buf->type を設定する様にしました。 +'v', 'E' を使いたいのと、m17n の方でバッファが text/html だという +情報が必要な箇所があるので。 + +From: hsaka@mth.biglobe.ne.jp (Hironori Sakamoto) +Subject: [w3m-dev 01726] anchor jump too slow by TAB-key on STDIN. +標準入力からHTMLを読んでいる場合, +リンク先の URL が相対 path 指定だったりすると、常に、currentdir() が +呼ばれているために速度が低下していました. +そこで立ち上げた時点で一度 カレントディレクトリを設定する様にしました。 +ついでに標準入力からの場合の変な URL "file:///-" を "-" だけにしました。 + +From: sakane@d4.bsd.nes.nec.co.jp (Yoshinobu Sakane) +Subject: [w3m-dev 01727] C-z when stdin +% cat main.c | w3m +して、C-z した際にシェルプロンプトに戻らない件に対するパッチ +です。 + +From: Hironori Sakamoto +Subject: [w3m-dev 01729] ignore_null_img_alt +ignore_null_img_alt が OFF だと、 という ALT 属性が +無い場合でも何も表示しなくなっていたので修正しました。 +それから、 の様な指定の場合に、 +
        で置き換えると、width 属性が無視され改行が入ってしまうのが +いまいちなので
        と同様の処理を入れる様にしました。 + +From: Hironori Sakamoto +Subject: [w3m-dev 01730] Re:
        in a table +
        の改良. + +From: Hironori Sakamoto +Subject: [w3m-dev 01731] completion list +最下行入力でのファイル名の補完時に + +----- Completion list ----- +X11R6/ compat/ include/ libdata/ local/ nfs/ ports/ share/ +bin/ games/ lib/ libexec/ mdec/ obj/ sbin/ src/ +(Load)Filename? /usr/ + +の様に表示させるための patch です。 + +From: Kiyokazu SUTO +Subject: [w3m-dev 01733] A patch concerning SSL +SSLを使う時に +1. 使わないメソッドを指定するオプション「ssl_forbid_method」を追加する、 +2. 接続確立に失敗したときにエラーメッセージを表示する、 + +From: Kiyokazu SUTO +Subject: [w3m-dev 01735] Re: A patch concerning SSL +Subject: [w3m-dev 01737] Re: A patch concerning SSL +1. ssl_forbid_methodの「データ型」をP_STRINGからP_SSLPATHに変えて、起 + 動後のオプション設定パネルによる変更でもSSL接続に使われるメソッドの + 選択に反映されるようにした、 +2. 各種エラーメッセージをある程度取っておいて後で見れるようにした(mule + 2.3 base on emacs 19.34の機能のパクリ、他のemacsenにあるかは知らず)、 + +From: sakane@d4.bsd.nes.nec.co.jp (Yoshinobu Sakane) +Subject: [w3m-dev 01738] [w3m-doc] w3m document maintenance +w3m連絡帳(http://mi.med.tohoku.ac.jp/~satodai/w3m/bbs/spool/log.html) +にも書きましたが、懸案であったw3mのドキュメント整備を始めた +いと思います。 + +From: kiwamu +Subject: [w3m-dev 01739] ホイールマウス対応 patch +w3mをホイールマウス対応させてみました。 +rxvtとxtermで使用できます。 +ktermだとホイールの上下が同じコントロールコードを返してしまうので +実現不可能みたいです。 + +From: Fumitoshi UKAI +Subject: [w3m-dev 01742] w3mmee 0.1.11p16-6 segfault +w3mmee 0.1.11p16-6 ですが、mime.types の内容によっては segfault します。 +# 空行があるとダメ + +From: Hironori Sakamoto +Subject: [w3m-dev 01752] SEGV in search_param() + > >> ・w3m -o 1 等で SEGV します。 + > search_param() で size_t が unsigned のため i = 0 のとき + > e = 4294967295 になってしまっているようです。 + +From: Hironori Sakamoto +Subject: [w3m-dev 01753] empty 〜 に