X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lwlib%2Fxlwmenu.c;h=b903917c61844a50ad562db0838ad48b8625c392;hb=24eff1b618c1e709d1748d791bbf53f296329c3c;hp=a35a629c60f45b7b76bfbc6d5f31d8c2c419f51b;hpb=3890a2e3064a7f562107c58e59d928284ec04741;p=chise%2Fxemacs-chise.git- diff --git a/lwlib/xlwmenu.c b/lwlib/xlwmenu.c index a35a629..b903917 100644 --- a/lwlib/xlwmenu.c +++ b/lwlib/xlwmenu.c @@ -479,16 +479,26 @@ massage_resource_name (const char *in, char *out) Boolean firstp = True; while (*in) { - char ch = massaged_resource_char[(unsigned char) *in++]; - if (ch) + if (*in == '%' && *(in + 1) == '_') + in += 2; + else { - int int_ch = (int) (unsigned char) ch; - *out++ = firstp ? tolower (int_ch) : toupper (int_ch); - firstp = False; - while ((ch = massaged_resource_char[(unsigned char) *in++]) != '\0') - *out++ = ch; - if (!*(in-1)) /* Overshot the NULL byte? */ - break; + char ch; + + if (*in == '%' && *(in + 1) == '%') + in++; + ch = massaged_resource_char[(unsigned char) *in++]; + if (ch) + { + int int_ch = (int) (unsigned char) ch; + *out++ = firstp ? tolower (int_ch) : toupper (int_ch); + firstp = False; + while ((ch = massaged_resource_char[(unsigned char) *in++]) + != '\0') + *out++ = ch; + if (!*(in-1)) /* Overshot the NULL byte? */ + break; + } } } *out = 0; @@ -506,23 +516,21 @@ nameResource[] = 0, XtRImmediate, 0 } }; -/* - * This function looks through string searching for parameter - * inserts of the form: - * %[padding]1 - * padding is space (' ') or dash ('-') characters meaning - * padding to the left or right of the inserted parameter. - * In essence all %1 strings are replaced by value in the return - * value (which the caller is expected to free). - * %% means insert one % (like printf). - * %1 means insert value. - * %-1 means insert value followed by one space. The latter is - * not inserted if value is a zero length string. - */ +/* This function searches STRING for parameter inserts of the form: + %[padding]1 + padding is either space (' ') or dash ('-') meaning + padding to the left or right of the inserted parameter. + In essence, all %1 strings are replaced by VALUE in the return value. + The caller is expected to free the return value using XtFree(). + %% means insert one % (like printf). + %1 means insert VALUE. + %-1 means insert VALUE followed by one space. The latter is + not inserted if VALUE is a zero length string. +*/ static char* parameterize_string (const char *string, const char *value) { - char *percent; + const char *percent; char *result; unsigned int done = 0; unsigned int ntimes; @@ -531,24 +539,25 @@ parameterize_string (const char *string, const char *value) { result = XtMalloc(1); result[0] = '\0'; - return (result); + return result; } if (!value) value = ""; - for (ntimes = 1, result = (char *) string; (percent = strchr(result, '%')); + for (ntimes = 1, percent = string; + (percent = strchr (percent, '%')); ntimes++) - result = &percent[1]; + percent++; result = XtMalloc ((ntimes * strlen(value)) + strlen(string) + 4); result[0] = '\0'; - while ((percent = strchr(string, '%'))) + while ((percent = strchr (string, '%'))) { unsigned int left_pad; unsigned int right_pad; - char *p; + const char *p; if (percent[1] == '%') { /* it's a real % */