diff options
author | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-01-16 16:49:53 +0000 |
---|---|---|
committer | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-01-16 16:49:53 +0000 |
commit | 9d4b26e1e491e2a0e8348f0b1d4fc2e288db851f (patch) | |
tree | 1fcb1933b15718d8e41caae1dec93b6015518ca9 | |
parent | [w3m-dev 02855] (diff) | |
download | w3m-9d4b26e1e491e2a0e8348f0b1d4fc2e288db851f.tar.gz w3m-9d4b26e1e491e2a0e8348f0b1d4fc2e288db851f.zip |
[w3m-dev 02859]
* config.h.dist (DEF_MIGEMO_COMMAND): added
* configure (DEF_MIGEMO_COMMAND): added
* fm.h (migemo_command): initial value is DEF_MIGEMO_COMMAND
* main.c (migemostr): remove here, move search.c
* main.c (srchcore): dont migemostr() here
* proto.h (init_migemo): added
* rc.c (sync_with_option): init_migemo()
* search.c (init_migemo): added
* search.c (open_migemo): added
* search.c (migemostr): communicate background migemo
* search.c (forwardSearch): if regexCompile for migemostr failed,
try original str
* search.c (backwardSearch): ditto
From: Fumitoshi UKAI <ukai@debian.or.jp>
Diffstat (limited to '')
-rw-r--r-- | ChangeLog | 19 | ||||
-rw-r--r-- | config.h.dist | 3 | ||||
-rwxr-xr-x | configure | 5 | ||||
-rw-r--r-- | fm.h | 4 | ||||
-rw-r--r-- | main.c | 26 | ||||
-rw-r--r-- | proto.h | 5 | ||||
-rw-r--r-- | rc.c | 5 | ||||
-rw-r--r-- | search.c | 91 |
8 files changed, 127 insertions, 31 deletions
@@ -1,5 +1,22 @@ 2002-01-17 Fumitoshi UKAI <ukai@debian.or.jp> + * [w3m-dev 02859] + * config.h.dist (DEF_MIGEMO_COMMAND): added + * configure (DEF_MIGEMO_COMMAND): added + * fm.h (migemo_command): initial value is DEF_MIGEMO_COMMAND + * main.c (migemostr): remove here, move search.c + * main.c (srchcore): dont migemostr() here + * proto.h (init_migemo): added + * rc.c (sync_with_option): init_migemo() + * search.c (init_migemo): added + * search.c (open_migemo): added + * search.c (migemostr): communicate background migemo + * search.c (forwardSearch): if regexCompile for migemostr failed, + try original str + * search.c (backwardSearch): ditto + +2002-01-17 Fumitoshi UKAI <ukai@debian.or.jp> + * [w3m-dev 02855] * main.c (dispincsrch): for C-s C-s, revert some changes @@ -2040,4 +2057,4 @@ * release-0-2-1 * import w3m-0.2.1 -$Id: ChangeLog,v 1.230 2002/01/16 16:11:35 ukai Exp $ +$Id: ChangeLog,v 1.231 2002/01/16 16:49:53 ukai Exp $ diff --git a/config.h.dist b/config.h.dist index ec389fe..49c06a9 100644 --- a/config.h.dist +++ b/config.h.dist @@ -130,6 +130,9 @@ MODEL=Linux.i686-monster-ja #define DEF_IMAGE_VIEWER "xv" #define DEF_AUDIO_PLAYER "showaudio" +/* for USE_MIGEMO */ +#define DEF_MIGEMO_COMMAND "migemo -t egrep /usr/share/migemo/migemo-dict" + #define LIB_DIR "/usr/local/lib/w3m" #define HELP_DIR "/usr/local/lib/w3m" #define ETC_DIR "/usr/local/etc/w3m" @@ -1,5 +1,5 @@ #!/bin/sh -# $Id: configure,v 1.50 2002/01/15 17:23:29 ukai Exp $ +# $Id: configure,v 1.51 2002/01/16 16:49:54 ukai Exp $ # Configuration. # @@ -2066,6 +2066,9 @@ $def_use_help_cgi #define DEF_IMAGE_VIEWER "$def_image_viewer" #define DEF_AUDIO_PLAYER "$def_audio_player" +/* for USE_MIGEMO */ +#define DEF_MIGEMO_COMMAND "migemo -t egrep /usr/share/migemo/migemo-dict" + #define LIB_DIR "$libdir" #define HELP_DIR "$helpdir" #define ETC_DIR "$sysconfdir" @@ -1,4 +1,4 @@ -/* $Id: fm.h,v 1.39 2002/01/16 15:37:06 ukai Exp $ */ +/* $Id: fm.h,v 1.40 2002/01/16 16:49:54 ukai Exp $ */ /* * w3m: WWW wo Miru utility * @@ -777,7 +777,7 @@ global int FoldTextarea init(FALSE); #ifdef USE_MIGEMO global int use_migemo init(FALSE); -global char *migemo_command init("migemoc"); +global char *migemo_command init(DEF_MIGEMO_COMMAND); #endif /* USE_MIGEMO */ global struct auth_cookie *Auth_cookie init(NULL); @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.61 2002/01/16 16:11:38 ukai Exp $ */ +/* $Id: main.c,v 1.62 2002/01/16 16:49:54 ukai Exp $ */ #define MAINPROGRAM #include "fm.h" #include <signal.h> @@ -1333,24 +1333,6 @@ rdrwSc(void) displayBuffer(Currentbuf, B_FORCE_REDRAW); } -#ifdef USE_MIGEMO -/* Migemo: romaji --> kana+kanji in regexp */ -static char * -migemostr(char *str) -{ - FILE *f; - Str tmp; - - tmp = Strnew_m_charp(migemo_command, " ", shell_quote(str), NULL); - if (!(f = popen(tmp->ptr, "r"))) - return str; - tmp = Strfgets(f); - Strchop(tmp); - pclose(f); - return tmp->ptr; -} -#endif /* USE_MIGEMO */ - static void clear_mark(Line *l) { @@ -1369,11 +1351,7 @@ srchcore(char *str, int (*func) (Buffer *, char *)) volatile int i, result = SR_NOTFOUND; if (str != NULL && str != SearchString) - SearchString = -#ifdef USE_MIGEMO - use_migemo ? migemostr(str) : -#endif /* USE_MIGEMO */ - str; + SearchString = str; if (SearchString == NULL || *SearchString == '\0') return SR_NOTFOUND; @@ -1,4 +1,4 @@ -/* $Id: proto.h,v 1.25 2002/01/16 15:37:07 ukai Exp $ */ +/* $Id: proto.h,v 1.26 2002/01/16 16:49:54 ukai Exp $ */ /* * This file was automatically generated by version 1.7 of cextract. * Manual editing not recommended. @@ -255,6 +255,9 @@ extern char *mydirname(char *s); extern int next_status(char c, int *status); extern int read_token(Str buf, char **instr, int *status, int pre, int append); extern Str correct_irrtag(int status); +#ifdef USE_MIGEMO +extern void init_migemo(void); +#endif extern int forwardSearch(Buffer *buf, char *str); extern int backwardSearch(Buffer *buf, char *str); extern void pcmap(void); @@ -1,4 +1,4 @@ -/* $Id: rc.c,v 1.30 2002/01/16 15:37:07 ukai Exp $ */ +/* $Id: rc.c,v 1.31 2002/01/16 16:49:54 ukai Exp $ */ /* * Initialization file etc. */ @@ -1124,6 +1124,9 @@ sync_with_option(void) #ifdef USE_EXTERNAL_URI_LOADER initURIMethods(); #endif +#ifdef USE_MIGEMO + init_migemo(); +#endif if (AcceptLang == NULL || *AcceptLang == '\0') { #if LANG == JA @@ -1,4 +1,4 @@ -/* $Id: search.c,v 1.8 2002/01/16 15:37:07 ukai Exp $ */ +/* $Id: search.c,v 1.9 2002/01/16 16:49:55 ukai Exp $ */ #include "fm.h" #include "regex.h" @@ -9,6 +9,75 @@ set_mark(Line *l, int pos, int epos) l->propBuf[pos] |= PE_MARK; } +#ifdef USE_MIGEMO +/* Migemo: romaji --> kana+kanji in regexp */ +static FILE *migemor, *migemow; + +void +init_migemo() +{ + if (migemor != NULL) + fclose(migemor); + if (migemow != NULL) + fclose(migemow); + migemor = migemow = NULL; +} + +static int +open_migemo(char *migemo_command) +{ + int fdr[2]; + int fdw[2]; + int pid; + if (pipe(fdr) < 0) + goto err0; + if (pipe(fdw) < 0) + goto err1; + + /* migemow:fdw[1] -|-> fdw[0]=0 {migemo} fdr[1]=1 -|-> fdr[0]:migemor */ + pid = fork(); + if (pid < 0) + goto err2; + if (pid == 0) { + /* child */ + close(fdr[0]); + close(fdw[1]); + dup2(fdw[0], 0); + dup2(fdr[1], 1); + system(migemo_command); + exit(1); + } + close(fdr[1]); + close(fdw[0]); + migemor = fdopen(fdr[0], "r"); + migemow = fdopen(fdw[1], "w"); + return 1; +err2: + close(fdw[0]); + close(fdw[1]); +err1: + close(fdr[0]); + close(fdr[1]); +err0: + use_migemo = 0; + return 0; +} + +static char * +migemostr(char *str) +{ + Str tmp = NULL; + if (migemor == NULL || migemow == NULL) + if (open_migemo(migemo_command) == 0) + return str; + fprintf(migemow, "%s\n", str); + fflush(migemow); + tmp = Strfgets(migemor); + Strchop(tmp); + return tmp->ptr; +} +#endif /* USE_MIGEMO */ + int forwardSearch(Buffer *buf, char *str) { @@ -17,6 +86,16 @@ forwardSearch(Buffer *buf, char *str) int wrapped = FALSE; int pos; +#ifdef USE_MIGEMO + if (use_migemo) { + if (((p = regexCompile(migemostr(str), IgnoreCase)) != NULL) + && ((p = regexCompile(str, IgnoreCase)) != NULL)) { + message(p, 0, 0); + return SR_NOTFOUND; + } + } + else +#endif if ((p = regexCompile(str, IgnoreCase)) != NULL) { message(p, 0, 0); return SR_NOTFOUND; @@ -85,6 +164,16 @@ backwardSearch(Buffer *buf, char *str) int wrapped = FALSE; int pos; +#ifdef USE_MIGEMO + if (use_migemo) { + if (((p = regexCompile(migemostr(str), IgnoreCase)) != NULL) + && ((p = regexCompile(str, IgnoreCase)) != NULL)) { + message(p, 0, 0); + return SR_NOTFOUND; + } + } + else +#endif if ((p = regexCompile(str, IgnoreCase)) != NULL) { message(p, 0, 0); return SR_NOTFOUND; |