home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / rxjis096.zip / jiscase.cmd < prev    next >
OS/2 REXX Batch file  |  1998-09-26  |  8KB  |  251 lines

  1. /* product name: RXJIS                                                */
  2. /* Version:      0.92                                                 */
  3. /* author:       YANO Takashi                                         */
  4. /* target:       OS/2 Warp J3.0+ (J2.1 is possible)                   */
  5. /* source name:  JISCASE.CMD                                          */
  6. /* address:      tyano@ca2.so-net.or.jp or tyano@yamato.ibm.co.jp     */
  7. /* comment:      RXJIS is a utility functions for REXX.               */
  8. /*               This header file is a interface to be called from    */
  9. /*               C/C++.                                               */
  10. /* History:                                                           */
  11. /* 1997-9-5 0.92 Add RxJisKanjiAlias/JisKanjiAlias function           */
  12. /* 1998-9-30 0.95 Fix RxJisToAscii Conv problem                       */
  13. /*                                                                    */
  14. /* This is a part of build tool.                                      */
  15. fn = 'jiscase1.dat'
  16. cfn = 'jiscase.cpp'
  17. tb. = 0
  18. do while lines(fn)
  19.    parse value linein(fn) with lo up .
  20.    if length(lo) = 1 then do
  21.       h = 0
  22.       l = c2d(lo)
  23.    end /* do */
  24.    else do
  25.       h = c2d(left(lo, 1))
  26.       l = c2d(substr(lo, 2, 1))
  27.    end /* do */
  28.    i = h + 1
  29.    if tb.i = 0 then do
  30.       do j = 1 to 256
  31.          tb.i.j = right('0' || d2x(i - 1), 2) || right('0' || d2x(j - 1), 2)
  32.       end /* do */
  33.       tb.i = 1
  34.    end /* do */
  35.    options 'EXMODE'
  36.    j = l + 1
  37.    tb.i.j = c2x(up)
  38.    options 'NOEXMODE'
  39. end /* do */
  40. call SysFileDelete cfn
  41. call lineout cfn, '#include <limits.h>'
  42. call lineout cfn, '#include <os2.h>'
  43. call lineout cfn, '#include "jiscase.hpp"'
  44. call lineout cfn, '#pragma data_seg(rxjistbl)'
  45. do i = 1 to 256
  46.    if tb.i = 0 then iterate
  47.    call lineout cfn, 'static wchar_t uppercasetable_' || d2x(i - 1) || '[UCHAR_MAX+1] = {'
  48.    do j = 1 to 256
  49.       call lineout cfn, '0x' || tb.i.j || ','
  50.    end /* do */
  51.    call lineout cfn, '};'
  52. end /* do */
  53. call lineout cfn, 'PWCHAR_T _Export UppercaseTable[UCHAR_MAX+1] = {'
  54. do i = 1 to 256
  55.    if tb.i = 0 then call lineout cfn, 'NULL,'
  56.    else call lineout cfn, 'uppercasetable_' || d2x(i - 1) || ','
  57. end /* do */
  58. call lineout cfn, '};'
  59. fn = 'jiscase2.dat'
  60. tb. = 0
  61. tb.33 = 8140
  62. do while lines(fn)
  63.    parse value linein(fn) with sc dc .
  64.    i = c2d(sc) + 1
  65.    options 'EXMODE'
  66.    tb.i = c2x(dc)
  67.    options 'NOEXMODE'
  68. end /* do */
  69. call lineout cfn, 'wchar_t _Export ToDbcsTable1[UCHAR_MAX+1] = {'
  70. do i = 1 to 256
  71.    call lineout cfn, "L'\x" || right('0000' || tb.i, 4) || "',"
  72. end /* do */
  73. call lineout cfn, '};'
  74. fn = 'jiscase3.dat'
  75. tb. = 0
  76. do while lines(fn)
  77.    parse value linein(fn) with sc dc .
  78.    i = c2d(left(sc, 1)) + 1
  79.    options 'EXMODE'
  80.    tb.i = c2x(dc)
  81.    options 'NOEXMODE'
  82. end /* do */
  83. call lineout cfn, 'wchar_t _Export ToDbcsTable2[UCHAR_MAX+1] = {'
  84. do i = 1 to 256
  85.    call lineout cfn, "L'\x" || right('0000' || tb.i, 4) || "',"
  86. end /* do */
  87. call lineout cfn, '};'
  88. fn = 'jiscase4.dat'
  89. tb. = 0
  90. do while lines(fn)
  91.    parse value linein(fn) with sc dc .
  92.    i = c2d(left(sc, 1)) + 1
  93.    options 'EXMODE'
  94.    tb.i = c2x(dc)
  95.    options 'NOEXMODE'
  96. end /* do */
  97. call lineout cfn, 'wchar_t _Export ToDbcsTable3[UCHAR_MAX+1] = {'
  98. do i = 1 to 256
  99.    call lineout cfn, "L'\x" || right('0000' || tb.i, 4) || "',"
  100. end /* do */
  101. call lineout cfn, '};'
  102. fn = 'jiscase5.dat'
  103. tb. = 0
  104. do while lines(fn)
  105.    parse value linein(fn) with d1 d2 .
  106.    h = c2d(left(d1, 1))
  107.    l = c2d(substr(d1, 2, 1))
  108.    i = h + 1
  109.    if tb.i = 0 then do
  110.       do j = 1 to 256
  111.          tb.i.j = right('0' || d2x(i - 1), 2) || right('0' || d2x(j - 1), 2)
  112.       end /* do */
  113.       tb.i = 1
  114.    end /* do */
  115.    options 'EXMODE'
  116.    j = l + 1
  117.    tb.i.j = c2x(d2)
  118.    options 'NOEXMODE'
  119. end /* do */
  120. do i = 1 to 256
  121.    if tb.i = 0 then iterate
  122.    call lineout cfn, 'static wchar_t todbcstable4_' || d2x(i - 1) || '[UCHAR_MAX+1] = {'
  123.    do j = 1 to 256
  124.       call lineout cfn, '0x' || tb.i.j || ','
  125.    end /* do */
  126.    call lineout cfn, '};'
  127. end /* do */
  128. call lineout cfn, 'PWCHAR_T _Export ToDbcsTable4[UCHAR_MAX+1] = {'
  129. do i = 1 to 256
  130.    if tb.i = 0 then call lineout cfn, 'NULL,'
  131.    else call lineout cfn, 'todbcstable4_' || d2x(i - 1) || ','
  132. end /* do */
  133. call lineout cfn, '};'
  134. fn = 'jiscase6.dat'
  135. tb. = 0
  136. do while lines(fn)
  137.    parse value linein(fn) with d1 d2 .
  138.    h = c2d(left(d1, 1))
  139.    l = c2d(substr(d1, 2, 1))
  140.    i = h + 1
  141.    if tb.i = 0 then do
  142.       do j = 1 to 256
  143.          tb.i.j = 0
  144.       end /* do */
  145.       tb.i = 1
  146.    end /* do */
  147.    options 'EXMODE'
  148.    j = l + 1
  149.    tb.i.j = c2x(d2)
  150.    options 'NOEXMODE'
  151. end /* do */
  152. do i = 1 to 256
  153.    if tb.i = 0 then iterate
  154.    call lineout cfn, 'static wchar_t todbcstable5_' || d2x(i - 1) || '[UCHAR_MAX+1] = {'
  155.    do j = 1 to 256
  156.       call lineout cfn, '0x' || tb.i.j || ','
  157.    end /* do */
  158.    call lineout cfn, '};'
  159. end /* do */
  160. call lineout cfn, 'PWCHAR_T _Export ToDbcsTable5[UCHAR_MAX+1] = {'
  161. do i = 1 to 256
  162.    if tb.i = 0 then call lineout cfn, 'NULL,'
  163.    else call lineout cfn, 'todbcstable5_' || d2x(i - 1) || ','
  164. end /* do */
  165. call lineout cfn, '};'
  166. fn = 'jiscase7.dat'
  167. tb. = 0
  168. i = x2d('81') + 1
  169. j = x2d('40') + 1
  170. tb.i = 1
  171. tb.i.j = '\x20'
  172. do while lines(fn)
  173.    parse value linein(fn) with d1 s1 .
  174.    h = c2d(left(d1, 1))
  175.    l = c2d(substr(d1, 2, 1))
  176.    i = h + 1
  177.    if tb.i = 0 then do
  178.       do j = 1 to 256
  179.          tb.i.j = 0
  180.       end /* do */
  181.       tb.i = 1
  182.    end /* do */
  183.    v = ''
  184.    do j = 1 to length(s1)
  185.       v = v || '\x' || right('0' || c2x(substr(s1, j, 1)), 2)
  186.    end /* do */
  187.    j = l + 1
  188.    tb.i.j = v
  189. end /* do */
  190. do i = 1 to 256
  191.    if tb.i = 0 then iterate
  192.    call lineout cfn, 'static PCHAR tosbcstable_' || d2x(i - 1) || '[UCHAR_MAX+1] = {'
  193.    do j = 1 to 256
  194.       if tb.i.j = 0 then call lineout cfn, "NULL,"
  195.       else call lineout cfn, '"' || tb.i.j || '",'
  196.    end /* do */
  197.    call lineout cfn, '};'
  198. end /* do */
  199. call lineout cfn, 'PCHAR* _Export ToSbcsTable[UCHAR_MAX+1] = {'
  200. do i = 1 to 256
  201.    if tb.i = 0 then call lineout cfn, 'NULL,'
  202.    else call lineout cfn, 'tosbcstable_' || d2x(i - 1) || ','
  203. end /* do */
  204. call lineout cfn, '};'
  205. fn = 'jiscase8.dat'
  206. tb. = ''
  207. m = 0
  208. do while lines(fn)
  209.    a = linein(fn)
  210.    z = a
  211.    c = ''
  212.    options 'EXMODE'
  213.    m = max(m, length(a))
  214.    do i = 1 by 1 while a <> ''
  215.       parse var a c.i 2 a
  216.       c = c || '\x' || c2x(c.i)
  217.    end /* do */
  218.    options 'NOEXMODE'
  219.    c.0 = i - 1
  220.    do n = 1 to c.0
  221.       h = c2d(left(c.n, 1))
  222.       l = c2d(substr(c.n, 2, 1))
  223.       i = h + 1
  224.       v = ''
  225.       j = l + 1
  226.       if tb.i.j <> '' then do
  227.          say z
  228.       end /* do */
  229.       tb.i.j = c
  230.       tb.i = 1
  231.    end /* do */
  232. end /* do */
  233. do i = 1 to 256
  234.    if tb.i = '' then iterate
  235.    call lineout cfn, 'static PWCHAR_T kanjialiastable_' || d2x(i - 1) || '[UCHAR_MAX+1] = {'
  236.    do j = 1 to 256
  237.       if tb.i.j = '' then call lineout cfn, "NULL,"
  238.       else call lineout cfn, 'L"' || tb.i.j || '",'
  239.    end /* do */
  240.    call lineout cfn, '};'
  241. end /* do */
  242. call lineout cfn, 'PWCHAR_T* _Export KanjiAliasTable[UCHAR_MAX+1] = {'
  243. do i = 1 to 256
  244.    if tb.i = '' then call lineout cfn, 'NULL,'
  245.    else call lineout cfn, 'kanjialiastable_' || d2x(i - 1) || ','
  246. end /* do */
  247. call lineout cfn, '};'
  248. call lineout cfn, 'const int _Export maxKanjiAliasSize =' m + 1 || ';'
  249. call stream cfn, 'c', 'close'
  250. exit
  251.