w2tの逆読みをちゃんとした
@@ -1,7 +1,6 @@ | ||
1 | 1 | /* |
2 | 2 | todo |
3 | 3 | 囲み target の場合の、[./] |
4 | --Rの先頭は末尾 | |
5 | 4 | */ |
6 | 5 | #include <stdio.h> |
7 | 6 | #include <stdlib.h> |
@@ -75,7 +74,7 @@ | ||
75 | 74 | fprintf( stderr, "w2s [-e num] [-c num] [-w num] [-g num] [-u] [-s {2|4|5}] [-/] [-f] [-i] [-t] [-r] [-n] [-y] [-d {/|.}] [-m mark] [-p postit] [-R] [-v] [-h] [-?] [ifile]\n" ); |
76 | 75 | break; |
77 | 76 | case TOTARGET: |
78 | - fprintf( stderr, "word2target 1.6\n" ); | |
77 | + fprintf( stderr, "word2target 1.7\n" ); | |
79 | 78 | fprintf( stderr, "w2t [-e num] [-c num] [-w num] [-g num] [-u] [-s {2|4|5}] [-/] [-f] [-i] [-t] [-r] [-n] [-y] [-d {/|.}] [-a] [-m mark] [-R] [-v] [-h] [-?] [ifile]\n" ); |
80 | 79 | break; |
81 | 80 | case TOL2R: |
@@ -481,11 +480,13 @@ | ||
481 | 480 | /* 3 パターン */ |
482 | 481 | /* オリジナルが全小/全大/先大のどれかなら出力しない */ |
483 | 482 | /* 全大とまとめられる場合もあるけど、まいっか */ |
484 | - /* here */ | |
485 | - /* -R の先頭は末尾 */ | |
486 | 483 | if ( !doorMode ) { |
487 | 484 | if ( (needTailCheck && istail[tailChar]) || !needTailCheck ) { |
488 | - make3Pattern( word, threePat ); | |
485 | + if ( reverse ) { | |
486 | + make3PatternR( word, threePat ); | |
487 | + } else { | |
488 | + make3Pattern( word, threePat ); | |
489 | + } | |
489 | 490 | for ( i = 0; i < 3; i++ ) { |
490 | 491 | if ( threePat[i] == NULL ) { |
491 | 492 | goto NEXT; |
@@ -499,23 +500,29 @@ | ||
499 | 500 | } |
500 | 501 | NEXT: |
501 | 502 | /* 9[aA]bcd : 最初に現れるアルファベットのみ大小、残り小 */ |
503 | + /* 逆読みの場合は、最後に現れる(r */ | |
502 | 504 | if ( (needTailCheck && istail[tolower(tailChar)]) || !needTailCheck ) { |
505 | + int alphaIdx; | |
503 | 506 | printf( "%s", head ); |
507 | + if ( reverse ) { | |
508 | + for ( alphaIdx = wordLen - 1; alphaIdx >= 0; alphaIdx-- ) { | |
509 | + if ( isalpha( word[alphaIdx] ) ) { break; } | |
510 | + } | |
511 | + } else { | |
512 | + for ( alphaIdx = 0; alphaIdx < wordLen; alphaIdx++ ) { | |
513 | + if ( isalpha( word[alphaIdx] ) ) { break; } | |
514 | + } | |
515 | + } | |
504 | 516 | for ( i = 0; i < wordLen; i++ ) { |
505 | - if ( isalpha( word[i] ) ) { | |
517 | + if ( i == alphaIdx ) { | |
506 | 518 | putchar( '[' ); |
507 | 519 | putchar( tolower( word[i] ) ); |
508 | 520 | putchar( toupper( word[i] ) ); |
509 | 521 | putchar( ']' ); |
510 | - i++; | |
511 | - break; | |
512 | 522 | } else { |
513 | - putchar( word[i] ); | |
523 | + putchar( tolower( word[i] ) ); | |
514 | 524 | } |
515 | 525 | } |
516 | - for ( ; i < wordLen; i++ ) { | |
517 | - putchar( tolower( word[i] ) ); | |
518 | - } | |
519 | 526 | printf( "%s", tail ); |
520 | 527 | if ( mark[0] != '\0' ) { |
521 | 528 | printf( "\t#%s", mark ); |