diff options
author | Tomas Heinrich <heinrich.tomas@gmail.com> | 2010-03-18 18:35:37 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-03-18 18:35:37 +0100 |
commit | c5c006c10c060e7f1a97250d039051b93ed390b2 (patch) | |
tree | b281136c99e6a27a530282a0b1b7eaf938704bb2 /libbb/unicode.c | |
parent | 98f1dc12f1554aca6c3743bec1c3d8982a077f7c (diff) | |
download | busybox-w32-c5c006c10c060e7f1a97250d039051b93ed390b2.tar.gz busybox-w32-c5c006c10c060e7f1a97250d039051b93ed390b2.tar.bz2 busybox-w32-c5c006c10c060e7f1a97250d039051b93ed390b2.zip |
lineedit: first shot at optional unicode bidi input support
function old new delta
read_line_input 4886 5003 +117
in_uint16_table - 97 +97
in_interval_table - 78 +78
static.rtl_b - 68 +68
unicode_isrtl - 55 +55
isrtl_str - 51 +51
static.rtl_p - 42 +42
unicode_conv_to_printable2 633 477 -156
------------------------------------------------------------------------------
(add/remove: 6/0 grow/shrink: 1/1 up/down: 508/-156) Total: 352 bytes
Signed-off-by: Tomas Heinrich <heinrich.tomas@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb/unicode.c')
-rw-r--r-- | libbb/unicode.c | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/libbb/unicode.c b/libbb/unicode.c index 7c41ef30b..91667ea72 100644 --- a/libbb/unicode.c +++ b/libbb/unicode.c | |||
@@ -241,6 +241,138 @@ int FAST_FUNC iswpunct(wint_t wc) | |||
241 | 241 | ||
242 | #include "unicode_wcwidth.c" | 242 | #include "unicode_wcwidth.c" |
243 | 243 | ||
244 | # if ENABLE_UNICODE_BIDI_SUPPORT | ||
245 | int FAST_FUNC unicode_isrtl(wint_t wc) | ||
246 | { | ||
247 | /* ranges taken from | ||
248 | * http://www.unicode.org/Public/5.2.0/ucd/extracted/DerivedBidiClass.txt | ||
249 | * Bidi_Class=Left_To_Right | Bidi_Class=Arabic_Letter | ||
250 | */ | ||
251 | static const struct interval rtl_b[] = { | ||
252 | # define BIG_(a,b) { a, b }, | ||
253 | # define PAIR(a,b) | ||
254 | PAIR(0x0590, 0x0590) | ||
255 | PAIR(0x05BE, 0x05BE) | ||
256 | PAIR(0x05C0, 0x05C0) | ||
257 | PAIR(0x05C3, 0x05C3) | ||
258 | PAIR(0x05C6, 0x05C6) | ||
259 | BIG_(0x05C8, 0x05FF) | ||
260 | PAIR(0x0604, 0x0605) | ||
261 | PAIR(0x0608, 0x0608) | ||
262 | PAIR(0x060B, 0x060B) | ||
263 | PAIR(0x060D, 0x060D) | ||
264 | BIG_(0x061B, 0x064A) | ||
265 | PAIR(0x065F, 0x065F) | ||
266 | PAIR(0x066D, 0x066F) | ||
267 | BIG_(0x0671, 0x06D5) | ||
268 | PAIR(0x06E5, 0x06E6) | ||
269 | PAIR(0x06EE, 0x06EF) | ||
270 | BIG_(0x06FA, 0x070E) | ||
271 | PAIR(0x0710, 0x0710) | ||
272 | BIG_(0x0712, 0x072F) | ||
273 | BIG_(0x074B, 0x07A5) | ||
274 | BIG_(0x07B1, 0x07EA) | ||
275 | PAIR(0x07F4, 0x07F5) | ||
276 | BIG_(0x07FA, 0x0815) | ||
277 | PAIR(0x081A, 0x081A) | ||
278 | PAIR(0x0824, 0x0824) | ||
279 | PAIR(0x0828, 0x0828) | ||
280 | BIG_(0x082E, 0x08FF) | ||
281 | PAIR(0x200F, 0x200F) | ||
282 | PAIR(0x202B, 0x202B) | ||
283 | PAIR(0x202E, 0x202E) | ||
284 | BIG_(0xFB1D, 0xFB1D) | ||
285 | BIG_(0xFB1F, 0xFB28) | ||
286 | BIG_(0xFB2A, 0xFD3D) | ||
287 | BIG_(0xFD40, 0xFDCF) | ||
288 | BIG_(0xFDC8, 0xFDCF) | ||
289 | BIG_(0xFDF0, 0xFDFC) | ||
290 | BIG_(0xFDFE, 0xFDFF) | ||
291 | BIG_(0xFE70, 0xFEFE) | ||
292 | /* Probably not necessary | ||
293 | {0x10800, 0x1091E}, | ||
294 | {0x10920, 0x10A00}, | ||
295 | {0x10A04, 0x10A04}, | ||
296 | {0x10A07, 0x10A0B}, | ||
297 | {0x10A10, 0x10A37}, | ||
298 | {0x10A3B, 0x10A3E}, | ||
299 | {0x10A40, 0x10A7F}, | ||
300 | {0x10B36, 0x10B38}, | ||
301 | {0x10B40, 0x10E5F}, | ||
302 | {0x10E7F, 0x10FFF}, | ||
303 | {0x1E800, 0x1EFFF} | ||
304 | */ | ||
305 | # undef BIG_ | ||
306 | # undef PAIR | ||
307 | }; | ||
308 | |||
309 | static const uint16_t rtl_p[] = { | ||
310 | # define BIG_(a,b) | ||
311 | # define PAIR(a,b) (a << 2) | (b-a), | ||
312 | /* Exact copy-n-paste of the above: */ | ||
313 | PAIR(0x0590, 0x0590) | ||
314 | PAIR(0x05BE, 0x05BE) | ||
315 | PAIR(0x05C0, 0x05C0) | ||
316 | PAIR(0x05C3, 0x05C3) | ||
317 | PAIR(0x05C6, 0x05C6) | ||
318 | BIG_(0x05C8, 0x05FF) | ||
319 | PAIR(0x0604, 0x0605) | ||
320 | PAIR(0x0608, 0x0608) | ||
321 | PAIR(0x060B, 0x060B) | ||
322 | PAIR(0x060D, 0x060D) | ||
323 | BIG_(0x061B, 0x064A) | ||
324 | PAIR(0x065F, 0x065F) | ||
325 | PAIR(0x066D, 0x066F) | ||
326 | BIG_(0x0671, 0x06D5) | ||
327 | PAIR(0x06E5, 0x06E6) | ||
328 | PAIR(0x06EE, 0x06EF) | ||
329 | BIG_(0x06FA, 0x070E) | ||
330 | PAIR(0x0710, 0x0710) | ||
331 | BIG_(0x0712, 0x072F) | ||
332 | BIG_(0x074B, 0x07A5) | ||
333 | BIG_(0x07B1, 0x07EA) | ||
334 | PAIR(0x07F4, 0x07F5) | ||
335 | BIG_(0x07FA, 0x0815) | ||
336 | PAIR(0x081A, 0x081A) | ||
337 | PAIR(0x0824, 0x0824) | ||
338 | PAIR(0x0828, 0x0828) | ||
339 | BIG_(0x082E, 0x08FF) | ||
340 | PAIR(0x200F, 0x200F) | ||
341 | PAIR(0x202B, 0x202B) | ||
342 | PAIR(0x202E, 0x202E) | ||
343 | BIG_(0xFB1D, 0xFB1D) | ||
344 | BIG_(0xFB1F, 0xFB28) | ||
345 | BIG_(0xFB2A, 0xFD3D) | ||
346 | BIG_(0xFD40, 0xFDCF) | ||
347 | BIG_(0xFDC8, 0xFDCF) | ||
348 | BIG_(0xFDF0, 0xFDFC) | ||
349 | BIG_(0xFDFE, 0xFDFF) | ||
350 | BIG_(0xFE70, 0xFEFE) | ||
351 | /* Probably not necessary | ||
352 | {0x10800, 0x1091E}, | ||
353 | {0x10920, 0x10A00}, | ||
354 | {0x10A04, 0x10A04}, | ||
355 | {0x10A07, 0x10A0B}, | ||
356 | {0x10A10, 0x10A37}, | ||
357 | {0x10A3B, 0x10A3E}, | ||
358 | {0x10A40, 0x10A7F}, | ||
359 | {0x10B36, 0x10B38}, | ||
360 | {0x10B40, 0x10E5F}, | ||
361 | {0x10E7F, 0x10FFF}, | ||
362 | {0x1E800, 0x1EFFF} | ||
363 | */ | ||
364 | # undef BIG_ | ||
365 | # undef PAIR | ||
366 | }; | ||
367 | |||
368 | if (in_interval_table(wc, rtl_b, ARRAY_SIZE(rtl_b) - 1)) | ||
369 | return 1; | ||
370 | if (in_uint16_table(wc, rtl_p, ARRAY_SIZE(rtl_p) - 1)) | ||
371 | return 1; | ||
372 | return 0; | ||
373 | } | ||
374 | # endif /* UNICODE_BIDI_SUPPORT */ | ||
375 | |||
244 | #endif /* Homegrown Unicode support */ | 376 | #endif /* Homegrown Unicode support */ |
245 | 377 | ||
246 | 378 | ||