From: handa Date: Thu, 5 Jan 2006 06:28:57 +0000 (+0000) Subject: (load_macros): On overwriting a macro, free the old X-Git-Tag: REL-1-3-1~32 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dbcc9e71e1bb441251dd8f52ca3da8e49c6e5d5b;p=m17n%2Fm17n-lib.git (load_macros): On overwriting a macro, free the old definition. (minput__init): Store Mmap in load_im_info_keys. (minput_get_title_icon): If the input method has no title, be sure to return NULL. (minput_get_description): If the input method has no description, be sure to return NULL. (minput_get_variables): Fix documentation. --- diff --git a/src/input.c b/src/input.c index 9db75df..7b8ea5a 100644 --- a/src/input.c +++ b/src/input.c @@ -1055,6 +1055,7 @@ static int load_macros (MPlist *plist, MPlist *macros) { MSymbol name; + MPlist *pl; if (! MPLIST_SYMBOL_P (plist)) MERROR (MERROR_IM, -1); @@ -1063,6 +1064,9 @@ load_macros (MPlist *plist, MPlist *macros) if (MPLIST_TAIL_P (plist) || parse_action_list (plist, macros) < 0) MERROR (MERROR_IM, -1); + pl = mplist_get (macros, name); + if (pl) + M17N_OBJECT_UNREF (pl); mplist_put (macros, name, plist); M17N_OBJECT_REF (plist); return 0; @@ -2992,7 +2996,6 @@ minput__init () NULL, NULL, NULL, "Escape", NULL, NULL, NULL, NULL }; char buf[6], buf2[256]; int i; - MPlist *plist; Minput_method = msymbol ("input-method"); Minput_driver = msymbol ("input-driver"); @@ -3068,7 +3071,8 @@ minput__init () M_variable = msymbol ("variable"); load_im_info_keys = mplist (); - plist = mplist_add (load_im_info_keys, Mstate, Mnil); + mplist_add (load_im_info_keys, Mstate, Mnil); + mplist_push (load_im_info_keys, Mmap, Mnil); buf[0] = 'C'; buf[1] = '-'; @@ -3797,13 +3801,12 @@ minput_get_title_icon (MSymbol language, MSymbol name) if (! plist) return NULL; + if (MPLIST_TAIL_P (plist)) + goto no_title; pl = MPLIST_PLIST (plist); pl = MPLIST_NEXT (pl); if (! MPLIST_MTEXT_P (pl)) - { - M17N_OBJECT_UNREF (plist); - return NULL; - } + goto no_title; M17N_OBJECT_REF (pl); M17N_OBJECT_UNREF (plist); plist = pl; @@ -3842,6 +3845,10 @@ minput_get_title_icon (MSymbol language, MSymbol name) else mplist_set (pl, Mnil, NULL); return plist; + + no_title: + M17N_OBJECT_UNREF (plist); + return NULL; } /*=*/ @@ -3873,10 +3880,15 @@ minput_get_description (MSymbol language, MSymbol name) { MPlist *plist = load_partial_im_info (language, name, Mnil, M_description); MPlist *pl; - MText *mt; + MText *mt = NULL; if (! plist) return NULL; + if (MPLIST_TAIL_P (plist)) + { + M17N_OBJECT_UNREF (plist); + return NULL; + } pl = MPLIST_PLIST (plist); pl = MPLIST_NEXT (pl); if (MPLIST_MTEXT_P (pl)) @@ -4075,36 +4087,26 @@ minput_assign_command_keys (MSymbol language, MSymbol name, The minput_get_variables () function returns a plist (#MPlist) of variables used to control the behavior of the input method - specified by $LANGUAGE and $NAME. The key of an element of the - plist is a symbol representing a variable, and the value is a - plist of the form VAR-INFO (described below) that carries the - information about the variable. - - The first element of VAR-INFO has the key #Mtext or #Msymbol. If - the key is #Mtext, the value is an M-text describing the variable. - If the key is #Msymbol, that value is #Mnil which means the - variable has no description text. - - The second element of VAR-INFO is for the value of the variable. - The key is #Minteger, #Msymbol, or #Mtext, and the value is an - integer, a symbol, or an M-text, respectively. The variable is - set to this value when an input context is created for the input - method. - - If there are no more elements, the variable can take any value - that matches with the above type. Otherwise, the remaining - elements of VAR-INFO are to specify valid values of the variable. - - If the type of the variable is integer, the following elements - have the key #Minteger or #Mplist. If it is #Minteger, the value - is a valid integer value. If it is #Mplist, the value is a plist - of two elements. Both of them have the key #Minteger, and - values are the minimum- and maximum bounds of the valid value - range. - - If the type of the variable is symbol or M-text, the following - elements of the plist have the key #Msymbol or #Mtext, - respectively, and the value must be a valid one. + specified by $LANGUAGE and $NAME. The plist is @e well-formed + (#m17nPlist) of the following format: + +@verbatim + (VARNAME (DOC-MTEXT DEFAULT-VALUE [ VALUE ... ] ) + VARNAME (DOC-MTEXT DEFAULT-VALUE [ VALUE ... ] ) + ...) +@endverbatim + + @c VARNAME is a symbol representing the variable name. + + @c DOC-MTEXT is an M-text describing the variable. + + @c DEFAULT-VALUE is the default value of the varible. It is a + symbol, integer, or M-text. + + @c VALUEs (if any) specifies the possible values of the variable. + If @c DEFAULT-VALUE is an integer, @c VALUE may be a plist (@c FROM + @c TO), where @c FROM and @c TO specifies a range of possible + values. For instance, suppose an input method has the variables: @@ -4117,23 +4119,12 @@ minput_assign_command_keys (MSymbol language, MSymbol name, @li name:txtvar, description:"value is an M-text", initial value:empty text, no value-range (i.e. any text) - Then, the returned plist has the following form ('X:Y' means X is a key and Y is - a value, and '(...)' means a plist): + Then, the returned plist is as follows. @verbatim - plist:(intvar:(mtext:"value is an integer" - integer:0 - plist:(integer:0 integer:3) - integer:10 - integer:20)) - symvar:(mtext:"value is a symbol" - symbol:nil - symbol:a - symbol:b - symbol:c - symbol:nil)) - txtvar:(mtext:"value is an M-text" - mtext:"")) + (intvar ("value is an integer" 0 (0 3) 10 20) + symvar ("value is a symbol" nil a b c nil) + txtvar ("value is an M-text" "")) @endverbatim @return @@ -4144,30 +4135,27 @@ minput_assign_command_keys (MSymbol language, MSymbol name, /***ja @brief ÆþÎϥ᥽¥Ã¥É¤ÎÊÑ¿ô¥ê¥¹¥È¤òÆÀ¤ë. - ´Ø¿ô minput_get_variables () ¤Ï¡¢$LANGUAGE ¤È $NAME - ¤Ë¤è¤Ã¤Æ»ØÄꤵ¤ì¤¿ÆþÎϥ᥽¥Ã¥É¤Î¿¶¤ëÉñ¤¤¤òÀ©¸æ¤¹¤ëÊÑ¿ô¤Î¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È - (#MPlist) ¤òÊÖ¤¹¡£¥ê¥¹¥È¤Î³ÆÍ×ÁǤΥ­¡¼¤ÏÊÑ¿ô¤òɽ¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£ - ³ÆÍ×ÁǤÎÃͤϲ¼µ­¤Î VAR-INFO - ¤Î·Á¼°¤Î¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¤Ç¤¢¤ê¡¢³ÆÊÑ¿ô¤Ë´Ø¤¹¤ë¾ðÊó¤ò¼¨¤·¤Æ¤¤¤ë¡£ + ´Ø¿ô minput_get_variables () ¤Ï¡¢$LANGUAGE ¤È $NAME ¤Ë¤è¤Ã¤Æ»ØÄꤵ + ¤ì¤¿ÆþÎϥ᥽¥Ã¥É¤Î¿¶¤ëÉñ¤¤¤òÀ©¸æ¤¹¤ëÊÑ¿ô¤Î¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È + (#MPlist) ¤òÊÖ¤¹¡£¤³¤Î¥ê¥¹¥È¤Ï @e well-formed ¤Ç¤¢¤ê(#m17nPlist) °Ê + ²¼¤Î·Á¼°¤Ç¤¢¤ë¡£ - VAR-INFO ¤ÎÂè°ìÍ×ÁǤΥ­¡¼¤Ï #Mtext ¤Þ¤¿¤Ï #Msymbol ¤Ç¤¢¤ë¡£¥­¡¼¤¬ - #Mtext ¤Ê¤é¡¢ÃͤϤ½¤ÎÊÑ¿ô¤òÀâÌÀ¤¹¤ë M-text ¤Ç¤¢¤ë¡£¥­¡¼¤¬ #Msymbol - ¤Ê¤éÃÍ¤Ï #Mnil ¤Ç¤¢¤ê¡¢¤³¤ÎÊÑ¿ô¤ÏÀâÌÀ¥Æ¥­¥¹¥È¤ò»ý¤¿¤Ê¤¤¤³¤È¤Ë¤Ê¤ë¡£ +@verbatim + (VARNAME (DOC-MTEXT DEFAULT-VALUE [ VALUE ... ] ) + VARNAME (DOC-MTEXT DEFAULT-VALUE [ VALUE ... ] ) + ...) +@endverbatim - VAR-INFO ¤ÎÂèÆóÍ×ÁǤÏÊÑ¿ô¤ÎÃͤò¼¨¤¹¡£¥­¡¼¤Ï #Minteger, #Msymbol, - #Mtext ¤Î¤¤¤º¤ì¤«¤Ç¤¢¤ê¡¢ÃͤϤ½¤ì¤¾¤ìÀ°¿ôÃÍ¡¢¥·¥ó¥Ü¥ë¡¢M-text ¤Ç¤¢¤ë¡£ - ¤³¤ÎÆþÎϥ᥽¥Ã¥ÉÍѤÎÆþÎÏ¥³¥ó¥Æ¥¹¥È¤¬ºî¤é¤ì¤ë»þÅÀ¤Ç¤Ï¡¢ÊÑ¿ô¤Ï¤³¤ÎÃͤËÀßÄꤵ¤ì¤Æ¤¤¤ë¡£ + @c VARNAME ¤ÏÊÑ¿ô¤Î̾Á°¤ò¼¨¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£ - VAR-INFO ¤Ë¤½¤ì°Ê³°¤ÎÍ×ÁǤ¬Ìµ¤±¤ì¤Ð¡¢ÊÑ¿ô¤Ï¾åµ­¤Î·¿¤Ë¹çÃפ¹¤ë¸Â¤ê¤É¤Î¤è¤¦¤ÊÃͤò¤È¤ë¤³¤È¤â¤Ç¤­¤ë¡£ - ¤½¤¦¤Ç¤Ê¤±¤ì¤Ð¡¢VAR-INFO ¤Î»Ä¤ê¤ÎÍ×ÁǤˤè¤Ã¤ÆÊÑ¿ô¤ÎÍ­¸ú¤ÊÃͤ¬»ØÄꤵ¤ì¤ë¡£ + @c DOC-MTEXT ¤ÏÊÑ¿ô¤òÀâÌÀ¤¹¤ë M-text ¤Ç¤¢¤ë¡£ - ÊÑ¿ô¤Î·¿¤¬À°¿ô¤Ç¤¢¤ì¤Ð¡¢¤½¤ì°Ê¹ß¤ÎÍ×ÁÇ¤Ï #Minteger ¤« #Mplist - ¤ò¥­¡¼¤È¤·¤Æ»ý¤Ä¡£ #Minteger ¤Ç¤¢¤ì¤Ð¡¢ÃͤÏÍ­¸ú¤ÊÃͤò¼¨¤¹À°¿ôÃͤǤ¢¤ë¡£ - #Mplist ¤Ç¤¢¤ì¤Ð¡¢ÃͤÏÆó¤Ä¤ÎÍ×ÁǤò»ý¤Ä¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¤Ç¤¢¤ê¡¢³ÆÍ×ÁǤϥ­¡¼¤È¤·¤Æ - #Minteger ¤ò¡¢ÃͤȤ·¤Æ¤½¤ì¤¾¤ìÍ­¸ú¤ÊÃͤξå¸ÂÃͤȲ¼¸ÂÃͤò¤È¤ë¡£ + @c DEFAULT-VALUE ¤ÏÊÑ¿ô¤Î¥Ç¥Õ¥©¥ë¥ÈÃͤǤ¢¤ê¡¢¥·¥ó¥Ü¥ë¡¢À°¿ô¤â¤·¤¯¤Ï + M-text ¤Ç¤¢¤ë¡£ - ÊÑ¿ô¤Î·¿¤¬¥·¥ó¥Ü¥ë¤« M-text ¤Ç¤¢¤ì¤Ð¡¢¤½¤ì°Ê¹ß¤ÎÍ×ÁǤϥ­¡¼¤È¤·¤Æ¤½¤ì¤¾¤ì - #Msymbol ¤« #Mtext ¤ò»ý¤Á¡¢ÃͤϤ½¤Î·¿¤Ë¹çÃפ¹¤ë¤â¤Î¤Ç¤¢¤ë¡£ + @c VALUE ¤Ï¡¢¤â¤·»ØÄꤵ¤ì¤Æ¤¤¤ì¤ÐÊÑ¿ô¤Î¼è¤êÆÀ¤ëÃͤò¼¨¤¹¡£¤â¤· + @c DEFAULT-VALUE ¤¬À°¿ô¤Ê¤é¡¢ @c VALUE ¤Ï (@c FROM @c TO) ¤È¤¤¤¦·Á + ¤Î¥ê¥¹¥È¤Ç¤âÎɤ¤¡£¤³¤Î¾ì¹ç @c FROM ¤È @c TO ¤Ï²Äǽ¤ÊÃͤÎÈϰϤò¼¨¤¹¡£ Îã¤È¤·¤Æ¡¢¤¢¤ëÆþÎϥ᥽¥Ã¥É¤¬¼¡¤Î¤è¤¦¤ÊÊÑ¿ô¤ò»ý¤Ä¾ì¹ç¤ò¹Í¤¨¤è¤¦¡£ @@ -4180,27 +4168,16 @@ minput_assign_command_keys (MSymbol language, MSymbol name, @li name:txtvar, ÀâÌÀ:"value is an M-text", ½é´üÃÍ:empty text, ÃͤÎÈϰϤʤ·(¤É¤ó¤Ê M-text ¤Ç¤â²Ä) - ¤³¤Î¾ì¹ç¡¢ÊÖ¤µ¤ì¤ë¥ê¥¹¥È¤Ï°Ê²¼¤Î¤è¤¦¤Ë¤Ê¤ë¡£¡Ê'X:Y' ¤È¤¤¤¦µ­Ë¡¤Ï X - ¤¬¥­¡¼¤Ç Y ¤¬ÃͤǤ¢¤ë¤³¤È¤ò¡¢¤Þ¤¿ '(...)' ¤Ï¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¤ò¼¨¤¹¡£¡Ë + ¤³¤Î¾ì¹ç¡¢ÊÖ¤µ¤ì¤ë¥ê¥¹¥È¤Ï°Ê²¼¤Î¤è¤¦¤Ë¤Ê¤ë¡£ @verbatim - plist:(intvar:(mtext:"value is an integer" - integer:0 - plist:(integer:0 integer:3) - integer:10 - integer:20)) - symvar:(mtext:"value is a symbol" - symbol:nil - symbol:a - symbol:b - symbol:c - symbol:nil)) - txtvar:(mtext:"value is an M-text" - mtext:"")) + (intvar ("value is an integer" 0 (0 3) 10 20) + symvar ("value is a symbol" nil a b c nil) + txtvar ("value is an M-text" "")) @endverbatim @return - ÆþÎϥ᥽¥Ã¥É¤¬²¿¤é¤«¤ÎÊÑ¿ô¤ò»ÈÍѤ·¤Æ¤¤¤ì¤Ð #MPlist ¤Ø¤ÎÊÑ¿ô¤òÊÖ¤¹¡£ + ÆþÎϥ᥽¥Ã¥É¤¬²¿¤é¤«¤ÎÊÑ¿ô¤ò»ÈÍѤ·¤Æ¤¤¤ì¤Ð #MPlist ¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£ ÊÖ¤µ¤ì¤ë¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¤Ï¥é¥¤¥Ö¥é¥ê¤Ë¤è¤Ã¤Æ´ÉÍý¤µ¤ì¤Æ¤ª¤ê¡¢¸Æ¤Ó½Ð¤·Â¦¤ÇÊѹ¹¤·¤¿¤ê²òÊü¤·¤¿¤ê¤·¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£ ÆþÎϥ᥽¥Ã¥É¤¬ÊÑ¿ô¤ò°ìÀÚ»ÈÍѤ·¤Æ¤Ê¤±¤ì¤Ð¡¢@c NULL ¤òÊÖ¤¹¡£ */