… | |
… | |
79 | *p++ = w; |
79 | *p++ = w; |
80 | else if (w < 0x000800) |
80 | else if (w < 0x000800) |
81 | *p++ = 0xc0 | ( w >> 6), |
81 | *p++ = 0xc0 | ( w >> 6), |
82 | *p++ = 0x80 | ( w & 0x3f); |
82 | *p++ = 0x80 | ( w & 0x3f); |
83 | else if (w < 0x010000) |
83 | else if (w < 0x010000) |
84 | *p++ = 0xe0 | ( w >> 12 ), |
84 | *p++ = 0xe0 | ( w >> 12), |
85 | *p++ = 0x80 | ((w >> 6) & 0x3f), |
85 | *p++ = 0x80 | ((w >> 6) & 0x3f), |
86 | *p++ = 0x80 | ( w & 0x3f); |
86 | *p++ = 0x80 | ( w & 0x3f); |
87 | else if (w < 0x110000) |
87 | else if (w < 0x110000) |
88 | *p++ = 0xf0 | ( w >> 18), |
88 | *p++ = 0xf0 | ( w >> 18), |
89 | *p++ = 0x80 | ((w >> 12) & 0x3f), |
89 | *p++ = 0x80 | ((w >> 12) & 0x3f), |
… | |
… | |
116 | if (len == 0) |
116 | if (len == 0) |
117 | break; |
117 | break; |
118 | else if (s[0] < 0x80) |
118 | else if (s[0] < 0x80) |
119 | *p++ = *s++; |
119 | *p++ = *s++; |
120 | else if (len >= 2 |
120 | else if (len >= 2 |
121 | && s[0] >= 0xc2 && s[0] <= 0xdf |
121 | && s[0] >= 0xc2 && s[0] <= 0xdf |
122 | && (s[1] & 0xc0) == 0x80) |
122 | && (s[1] & 0xc0) == 0x80) |
123 | { |
123 | { |
124 | *p++ = ((s[0] & 0x1f) << 6) |
124 | *p++ = ((s[0] & 0x1f) << 6) |
125 | | (s[1] & 0x3f); |
125 | | (s[1] & 0x3f); |
126 | s += 2; |
126 | s += 2; |
… | |
… | |
144 | || (s[0] == 0xf4 && s[1] >= 0x80 && s[1] <= 0x8f) |
144 | || (s[0] == 0xf4 && s[1] >= 0x80 && s[1] <= 0x8f) |
145 | ) |
145 | ) |
146 | && (s[2] & 0xc0) == 0x80 |
146 | && (s[2] & 0xc0) == 0x80 |
147 | && (s[3] & 0xc0) == 0x80) |
147 | && (s[3] & 0xc0) == 0x80) |
148 | { |
148 | { |
149 | *p++ = ((s[0] & 0x07) << 18) |
149 | *p++ = ((s[0] & 0x07) << 18) |
150 | | ((s[1] & 0x3f) << 12) |
150 | | ((s[1] & 0x3f) << 12) |
151 | | ((s[2] & 0x3f) << 6) |
151 | | ((s[2] & 0x3f) << 6) |
152 | | (s[3] & 0x3f); |
152 | | (s[3] & 0x3f); |
153 | s += 4; |
153 | s += 4; |
154 | } |
154 | } |
155 | else |
155 | else |
156 | { |
156 | { |
… | |
… | |
235 | } |
235 | } |
236 | |
236 | |
237 | /* |
237 | /* |
238 | * remove leading/trailing space in place. |
238 | * remove leading/trailing space in place. |
239 | */ |
239 | */ |
240 | char * |
240 | char * |
241 | rxvt_strtrim (char *str) NOTHROW |
241 | rxvt_strtrim (char *str) NOTHROW |
242 | { |
242 | { |
243 | char *r, *s; |
243 | char *r, *s; |
244 | |
244 | |
245 | if (!str || !*str) /* shortcut */ |
245 | if (!str || !*str) /* shortcut */ |
… | |
… | |
262 | } |
262 | } |
263 | |
263 | |
264 | /* |
264 | /* |
265 | * Split a comma-separated string into an array, stripping leading and |
265 | * Split a comma-separated string into an array, stripping leading and |
266 | * trailing spaces from each entry. Empty strings are properly returned |
266 | * trailing spaces from each entry. Empty strings are properly returned |
267 | * Caller should free each entry and array when done |
|
|
268 | */ |
267 | */ |
269 | char ** |
268 | char ** |
270 | rxvt_splitcommastring (const char *cs) NOTHROW |
269 | rxvt_splitcommastring (const char *cs) NOTHROW |
271 | { |
270 | { |
272 | int l, n, p; |
271 | int l, n, p; |
273 | const char *s, *t; |
272 | const char *s, *t; |
274 | char **ret; |
273 | char **ret; |