From: handa Date: Fri, 24 Aug 2007 14:09:24 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f3f3090da3bf76beb8d1cc67578534ec14f97f1f;p=m17n%2Fm17n-test.git *** empty log message *** --- diff --git a/.cvsignore b/.cvsignore new file mode 100644 index 0000000..0eba2be --- /dev/null +++ b/.cvsignore @@ -0,0 +1,28 @@ +.deps +COPYING +INSTALL +Makefile +Makefile.in +aclocal.m4 +autom4te.cache +check-fs +compile +config.log +config.status +configure +depcomp +fifotest1 +fifotest2 +flt-gui +flt-otf +flt-hb +imtest +install-h +linebreak +m17n-imconf +mim-list +missing +mkinstalldirs +replace +stamp-h.in +temp* diff --git a/.gdbinit b/.gdbinit new file mode 100644 index 0000000..9fafb7c --- /dev/null +++ b/.gdbinit @@ -0,0 +1,57 @@ +define xchartab +set mdebug_dump_chartab ($, 0) +echo \n +end + +define xsymbol +set mdebug_dump_symbol ($, 0) +echo \n +end + +define xmtext +set mdebug_dump_mtext ($, 1, 0) +echo \n +end + +define xplist +set mdebug_dump_plist ($, 0) +echo \n +end + +define xinterval +set dump_interval ($arg0, 0) +echo \n +end + +define xfont +set mdebug_dump_font ($) +echo \n +end + +define xfontset +set mdebug_dump_fontset ($, 0) +echo \n +end + +define xface +set mdebug_dump_face ($, 0) +echo \n +end + +define xgstring +set dump_gstring (gstring, 0) +echo \n +end + +define xim +set mdebug_dump_im ($, 0) +echo \n +end + +define xflush +call XFlush (display) +end + +define xsynch +call XSynchronize (display, 1) +end diff --git a/check-fs.c b/check-fs.c new file mode 100644 index 0000000..206ac70 --- /dev/null +++ b/check-fs.c @@ -0,0 +1,86 @@ +#include +#include +#include +#include + +void +print_font (MFont *font) +{ + MSymbol family, language, script, otf; + + family = mfont_get_prop (font, Mfamily); + language = mfont_get_prop (font, Mlanguage); + script = mfont_get_prop (font, Mscript); + otf = mfont_get_prop (font, Motf); + + if (family) + printf ("%s", msymbol_name (family)); + if (script) + printf (":script=%s", msymbol_name (script)); + if (language) + printf (":lang=%s", msymbol_name (language)); + if (otf) + printf (":otf=%s", msymbol_name (otf)); +} + +int +main (int argc, char **argv) +{ + MFrame *frame; + MFontset *fontset; + MPlist *plist, *pl, *p, *p0; + + if (argc < 2 + || strcmp ("-h", argv[1]) == 0 || strcmp ("--help", argv[1]) == 0) + { + printf ("Usage: check-fs FONTSET-NAME\n"); + exit (1); + } + + M17N_INIT (); + plist = mplist (); + mplist_add (plist, Mdevice, NULL); + frame = mframe (plist); + m17n_object_unref (plist); + + fontset = mfontset (argv[1]); + for (plist = mfontset_lookup (fontset, Mt, Mnil, Mnil); + plist && mplist_key (plist) != Mnil; plist = mplist_next (plist)) + { + MSymbol script = mplist_key (plist); + + printf ("\n(%s", msymbol_name (script)); + for (pl = mfontset_lookup (fontset, script, Mt, Mnil); + pl && mplist_key (pl) != Mnil; pl = mplist_next (pl)) + { + MSymbol language = mplist_key (pl); + + if (language == Mt) + language = Mnil; + printf ("\n (%s", msymbol_name (language)); + for (p = mfontset_lookup (fontset, script, language, Mnil); + p && mplist_key (p) != Mnil; p = mplist_next (p)) + { + MSymbol flt = mplist_key (p); + MFont *font = mplist_value (p); + + printf ("\n ("); + print_font (font); + if (flt != Mt) + printf (" (with flt %s)", msymbol_name (flt)); + for (p0 = mfont_list (frame, font, Mnil, 0); + p0 && mplist_key (p0) != Mnil; p0 = mplist_next (p0)) + if (! mplist_find_by_key (mplist_next (p0), mplist_key (p0))) + printf ("\n %s", msymbol_name (mplist_key (p0))); + printf (")"); + } + printf (")"); + } + printf (")"); + } + printf ("\n"); + + m17n_object_unref (frame); + M17N_FINI (); + exit (0); +} diff --git a/mim-list.c b/mim-list.c new file mode 100644 index 0000000..a49dba9 --- /dev/null +++ b/mim-list.c @@ -0,0 +1,315 @@ +/* mim-list.c -- List all m17n-lib input methods. */ + +#include +#include + +#include +#include + +/* Frequently used symbols. */ +MSymbol Mutf_8; +MSymbol Mspace; + +/* Print arguments and exit with 1. */ +void +fatal (char *fmt, ...) +{ + va_list ap; + + va_start (ap, fmt); + vprintf (fmt, ap); + va_end (ap); + exit (1); +} + +/* If the key of PLIST is not TYPE, print error and exit. */ +void +check_type (MPlist *plist, MSymbol type) +{ + if (mplist_key (plist) != type) + fatal ("Type \"%s\" must be \"%s\".\n", + msymbol_name (mplist_key (plist)), msymbol_name (type)); +} + + +/* Dump the first line of documentation text MT. */ +void +dump_doc (MText *mt) +{ + int pos = mtext_chr (mt, '\n'); + + if (pos < 0) + mconv_encode_stream (Mutf_8, mt, stdout); + else + { + mt = mtext_duplicate (mt, 0, pos); + mconv_encode_stream (Mutf_8, mt, stdout); + printf (" ..."); + m17n_object_unref (mt); + } +} + +/* Dump the title and icon filename stored in the plist TITLE_ICON. */ +void +dump_title_icon (MPlist *title_icon) +{ + check_type (title_icon, Mtext); + mconv_encode_stream (Mutf_8, (MText *) mplist_value (title_icon), stdout); + title_icon = mplist_next (title_icon); + if (mplist_key (title_icon) == Mtext) + { + printf ("\n ICON file: "); + mconv_encode_stream (Mutf_8, (MText *) mplist_value (title_icon), stdout); + } +} + + +/* Dump the value of plist VAL. If TYPE is not Mnil, check if it + doesn't conflict with VAL. */ +void +dump_val (MPlist *val, MSymbol type) +{ + MSymbol valtype = mplist_key (val); + + if (type != Mnil) + { + /* Check if VALTYPE is valid or not. */ + if (valtype != type + && ! (valtype == Mplist && type == Minteger)) + fatal ("Value type %s not much with %s\n", + msymbol_name (valtype), msymbol_name (type)); + } + if (valtype == Minteger) + printf ("%d", (int) mplist_value (val)); + else if (valtype == Msymbol) + printf ("%s", msymbol_name ((MSymbol) mplist_value (val))); + else if (valtype == Mtext) + mconv_encode_stream (Mutf_8, (MText *) mplist_value (val), stdout); + else if (valtype == Mplist) + { + int from, to; + + val = mplist_value (val); + check_type (val, Minteger); + from = (int) mplist_value (val); + val = mplist_next (val); + check_type (val, Minteger); + to = (int) mplist_value (val); + printf ("%d..%d", from, to); + } + else + fatal ("Invalid type: %s", msymbol_name ((MSymbol) mplist_value (val))); +} + +/* Dump the information about the first variable stored in VARIABLES. + VARIABLES is a plist of this form: + (VARNAME (DOC-MTEXT [ DEFAULT-VALUE [ VALUE ... ] ] ) ...) + Returns `cddr' of VARIABLES. + */ + +MPlist * +dump_var (MPlist *variables) +{ + MSymbol name, type; + MPlist *plist; + MText *mt; + + check_type (variables, Msymbol); + name = mplist_value (variables); + printf ("\n %s: ", msymbol_name (name)); + variables = mplist_next (variables); + check_type (variables, Mplist); + plist = mplist_value (variables); + variables = mplist_next (variables); + if (mplist_key (variables) == Mnil) + variables = NULL; + /* PLIST ::= (DOC-MTEXT [ DEFAULT-VALUE [ VALUE ... ] ] ) */ + if (mplist_key (plist) == Mnil) + { + printf ("No docstring."); + return variables; + } + if (mplist_key (plist) == Msymbol + && (MSymbol) mplist_value (plist) == Mnil) + printf ("No docstring."); + else + { + check_type (plist, Mtext); + mt = mplist_value (plist); + if (mtext_len (mt) > 0) + dump_doc (mt); + } + plist = mplist_next (plist); + if (mplist_key (plist) == Mnil) + { + printf ("\n No default value, no restriction."); + return variables; + } + type = mplist_key (plist); + printf ("\n Default value (%s): ", msymbol_name (type)); + dump_val (plist, Mnil); + plist = mplist_next (plist); + if (mplist_key (plist) == Mnil) + { + printf ("\n No restriction"); + return variables; + } + + while (mplist_key (plist) != Mnil) + { + printf ("\n Valid value: "); + dump_val (plist, type); + plist = mplist_next (plist); + } + return variables; +} + +/* Dump the information about the first command stored in COMMANDS. + COMMANDS is a plist of this form: + (CMDNAME (DOC-MTEXT [ KEYSEQ ... ] ) ...) + Returns `cddr' of COMMANDS. + */ + +MPlist * +dump_cmd (MPlist *commands) +{ + MSymbol name; + MPlist *plist; + MText *mt; + + check_type (commands, Msymbol); + name = mplist_value (commands); + printf ("\n %s: ", msymbol_name (name)); + commands = mplist_next (commands); + check_type (commands, Mplist); + plist = mplist_value (commands); + commands = mplist_next (commands); + if (mplist_key (commands) == Mnil) + commands = NULL; + /* PLIST ::= (DOC-MTEXT [ KEYSEQ ... ] ) */ + if (mplist_key (plist) == Mnil) + { + printf ("No docstring."); + return commands; + } + check_type (plist, Mtext); + mt = mplist_value (plist); + if (mtext_len (mt) > 0) + dump_doc (mt); + plist = mplist_next (plist); + if (mplist_key (plist) == Mnil) + { + printf ("\n No binding."); + return commands; + } + while (mplist_key (plist) != Mnil) + { + MPlist *keyseq; + + check_type (plist, Mplist); + keyseq = mplist_value (plist); + printf ("\n binding:"); + while (mplist_key (keyseq) != Mnil) + { + check_type (keyseq, Msymbol); + if ((MSymbol) mplist_value (keyseq) == Mspace) + printf (" SPC"); + else + printf (" %s", msymbol_name ((MSymbol) mplist_value (keyseq))); + keyseq = mplist_next (keyseq); + } + plist = mplist_next (plist); + } + return commands; +} + +/* Dump information about all input methods. It accepts optional one + command-line argument LANG. If LANG is specified, list only input + methods for LANG. */ + +int +main (int argc, char **argv) +{ + MSymbol lang; + MPlist *plist, *pl; + int num; + + M17N_INIT (); + Mutf_8 = msymbol ("utf-8"); + Mspace = msymbol (" "); + + if (argc > 1) + lang = msymbol (argv[1]); + else + lang = Mnil; + + plist = mdatabase_list (msymbol ("input-method"), lang, Mnil, Mnil); + for (num = 0, pl = plist; pl && mplist_key (pl) != Mnil; + num++, pl = mplist_next (pl)) + { + MSymbol *tags = mdatabase_tag (mplist_value (pl)); + char *lang = tags[1] == Mt ? "generic" : msymbol_name (tags[1]); + MPlist *title_icon, *variables, *commands; + MText *mt; + + if (tags[2] == Mnil) + printf ("\nLanguage:%s Name:%s (for inclusion)", + lang, msymbol_name (tags[3])); + else + printf ("\nLanguage:%s Name:%s", + lang, msymbol_name (tags[2])); + mt = minput_get_description (tags[1], tags[2]); + if (mt) + { + printf ("\n Description: "); + dump_doc (mt); + m17n_object_unref (mt); + } + else + printf ("\n No description"); + + title_icon = minput_get_title_icon (tags[1], tags[2]); + if (title_icon) + { + printf ("\n Title: "); + dump_title_icon (title_icon); + m17n_object_unref (title_icon); + } + else + printf ("\n No title nor icon"); + + variables = minput_get_variables (tags[1], tags[2]); + if (variables) + { + printf ("\n Variables:"); + while ((variables = dump_var (variables)) != NULL); + } + + commands = minput_get_commands (tags[1], tags[2]); + if (commands) + { + printf ("\n Commands:"); + while ((commands = dump_cmd (commands)) != NULL); + } + + if (tags[2] != Mnil) + { + /* Check if the input method is surely available. */ + MInputMethod *im = minput_open_im (tags[1], tags[2], NULL); + MInputContext *ic; + + if (! im) + fatal ("Can not open\n"); + ic = minput_create_ic (im, NULL); + if (! ic) + fatal ("Can not create context\n"); + minput_destroy_ic (ic); + minput_close_im (im); + } + } + printf ("\n#input-methods = %d\n", num); + if (plist) + m17n_object_unref (plist); + M17N_FINI (); + exit (0); +}