… | |
… | |
440 | |
440 | |
441 | ############################################################################# |
441 | ############################################################################# |
442 | |
442 | |
443 | MODULE = Gtk2::CV PACKAGE = Gtk2::CV::Schnauzer |
443 | MODULE = Gtk2::CV PACKAGE = Gtk2::CV::Schnauzer |
444 | |
444 | |
|
|
445 | # currently only works for filenames (octet strings) |
|
|
446 | |
445 | SV * |
447 | SV * |
446 | foldcase (SV *pathsv) |
448 | foldcase (SV *pathsv) |
447 | PROTOTYPE: $ |
449 | PROTOTYPE: $ |
448 | CODE: |
450 | CODE: |
449 | { |
451 | { |
450 | STRLEN plen; |
452 | STRLEN plen; |
451 | U8 *path = (U8 *)SvPVutf8 (pathsv, plen); |
453 | U8 *path = (U8 *)SvPV (pathsv, plen); |
452 | U8 *pend = path + plen; |
454 | U8 *pend = path + plen; |
453 | U8 dst [plen * 6 * 3], *dstp = dst; |
455 | U8 dst [plen * 6 * 3], *dstp = dst; |
454 | |
456 | |
455 | while (path < pend) |
457 | while (path < pend) |
456 | { |
458 | { |
457 | U8 ch = *path; |
459 | U8 ch = *path; |
458 | |
460 | |
459 | if (ch >= 'a' && ch <= 'z') |
461 | if (ch >= 'a' && ch <= 'z') |
460 | *dstp++ = *path++; |
462 | *dstp++ = *path++; |
|
|
463 | else if (ch >= 'A' && ch <= 'Z') |
|
|
464 | *dstp++ = *path++ + ('a' - 'A'); |
461 | else if (ch >= '0' && ch <= '9') |
465 | else if (ch >= '0' && ch <= '9') |
462 | { |
466 | { |
463 | STRLEN el, nl = 0; |
467 | STRLEN el, nl = 0; |
464 | while (*path >= '0' && *path <= '9' && path < pend) |
468 | while (*path >= '0' && *path <= '9' && path < pend) |
465 | path++, nl++; |
469 | path++, nl++; |
… | |
… | |
468 | *dstp++ = '0'; |
472 | *dstp++ = '0'; |
469 | |
473 | |
470 | memcpy (dstp, path - nl, nl); |
474 | memcpy (dstp, path - nl, nl); |
471 | dstp += nl; |
475 | dstp += nl; |
472 | } |
476 | } |
|
|
477 | else |
|
|
478 | *dstp++ = *path++; |
|
|
479 | #if 0 |
473 | else |
480 | else |
474 | { |
481 | { |
475 | STRLEN cl; |
482 | STRLEN cl; |
476 | to_utf8_fold (path, dstp, &cl); |
483 | to_utf8_fold (path, dstp, &cl); |
477 | dstp += cl; |
484 | dstp += cl; |
478 | path += is_utf8_char (path); |
485 | path += is_utf8_char (path); |
479 | } |
486 | } |
|
|
487 | #endif |
480 | } |
488 | } |
481 | |
489 | |
482 | RETVAL = newSVpvn ((const char *)dst, dstp - dst); |
490 | RETVAL = newSVpvn ((const char *)dst, dstp - dst); |
483 | } |
491 | } |
484 | OUTPUT: |
492 | OUTPUT: |