From 4124c2778ddaf2a2207cddbdc79cc2e92ab42127 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 21 Nov 2004 19:04:07 +0000 Subject: [PATCH] *** empty log message *** --- src/main.C | 62 ++++++++++++++++++++++++++++++++---------------------- src/misc.C | 9 ++++++++ src/rxvt.h | 1 + 3 files changed, 47 insertions(+), 25 deletions(-) diff --git a/src/main.C b/src/main.C index d650d9fe..20a4d2f2 100644 --- a/src/main.C +++ b/src/main.C @@ -357,7 +357,7 @@ rxvt_term::init (int argc, const char *const *argv) scr_reset (); /* initialize screen */ -#if 0 +#if 1 XSynchronize (display->display, True); #endif @@ -1301,32 +1301,44 @@ rxvt_term::IM_get_IC (const char *modifiers) return false; } - p = rs[Rs_preeditType] ? rs[Rs_preeditType] : "OverTheSpot,OffTheSpot,Root,None"; - s = rxvt_splitcommastring (p); + const char *pet[] = { rs[Rs_preeditType], "OverTheSpot,OffTheSpot,Root,None" }; - for (i = found = 0; !found && s[i]; i++) + for (int pi = 0; pi < 2; pi++) { - if (!strcmp (s[i], "OverTheSpot")) - input_style = (XIMPreeditPosition | XIMStatusNothing); - else if (!strcmp (s[i], "OffTheSpot")) - input_style = (XIMPreeditArea | XIMStatusArea); - else if (!strcmp (s[i], "Root")) - input_style = (XIMPreeditNothing | XIMStatusNothing); - else if (!strcmp (s[i], "None")) - input_style = (XIMPreeditNone | XIMStatusNone); - - for (j = 0; j < xim_styles->count_styles; j++) - if (input_style == xim_styles->supported_styles[j]) - { - found = 1; - break; - } + p = pet[pi]; + + if (!p) + continue; + + s = rxvt_splitcommastring (p); + + for (i = found = 0; !found && s[i]; i++) + { + if (!strcmp (s[i], "OverTheSpot")) + input_style = (XIMPreeditPosition | XIMStatusNothing); + else if (!strcmp (s[i], "OffTheSpot")) + input_style = (XIMPreeditArea | XIMStatusArea); + else if (!strcmp (s[i], "Root")) + input_style = (XIMPreeditNothing | XIMStatusNothing); + else if (!strcmp (s[i], "None")) + input_style = (XIMPreeditNone | XIMStatusNone); + + for (j = 0; j < xim_styles->count_styles; j++) + if (input_style == xim_styles->supported_styles[j]) + { + rxvt_freecommastring (s); + + found = 1; + goto foundpet; + } + + } + + rxvt_freecommastring (s); } - for (i = 0; s[i]; i++) - free (s[i]); +foundpet: - free (s); XFree (xim_styles); if (!found) @@ -1461,6 +1473,7 @@ rxvt_term::im_cb () bool found = false; s = rxvt_splitcommastring (p); + for (i = 0; s[i]; i++) { if (*s[i]) @@ -1474,9 +1487,8 @@ rxvt_term::im_cb () } } } - for (i = 0; s[i]; i++) - free (s[i]); - free (s); + + rxvt_freecommastring (s); if (found) goto done; diff --git a/src/misc.C b/src/misc.C index fd431e1c..440bc08f 100644 --- a/src/misc.C +++ b/src/misc.C @@ -322,6 +322,15 @@ rxvt_splitcommastring (const char *cs) return ret; } +void +rxvt_freecommastring (char **cs) +{ + for (int i = 0; cs[i]; ++i) + free (cs[i]); + + free (cs); +} + /*----------------------------------------------------------------------* * file searching */ diff --git a/src/rxvt.h b/src/rxvt.h index a6613372..600ce5f0 100644 --- a/src/rxvt.h +++ b/src/rxvt.h @@ -101,6 +101,7 @@ const char * rxvt_Str_skip_space (const char *str); char * rxvt_Str_trim (char *str); int rxvt_Str_escaped (char *str); char ** rxvt_splitcommastring (const char *cs); +void rxvt_freecommastring (char **cs); char * rxvt_File_find (const char *file, const char *ext, const char *path); void rxvt_Draw_Shadow (Display *display, Window win, GC topShadow, GC botShadow, int x, int y, int w, int h); void rxvt_Draw_Triangle (Display *display, Window win, GC topShadow, GC botShadow, int x, int y, int w, int type); -- 2.34.1