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

  1. /* product name: RXJIS                                                */
  2. /* Version:      0.90                                                 */
  3. /* author:       YANO Takashi                                         */
  4. /* target:       OS/2 Warp J3.0+ (J2.1 is possible)                   */
  5. /* source name:  IBM2JIS.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. /*                                                                    */
  11. /* This is a part of build tool.                                      */
  12. arg fn
  13. if fn = '' then fn = directory() || '\ibm2jis.dat'
  14. parse value filespec('N', fn) with cfn '.' .
  15. cfn = directory() || '\' || cfn || '.cpp'
  16. tb. = ''
  17. m = 0
  18. do while lines(fn)
  19.    parse value linein(fn) with cd st .
  20.    m = max(m, conststrlen(st))
  21.    i = x2d(left(cd, 2)) + 1
  22.    j = x2d(right(cd, 2)) + 1
  23.    tb.i.j = st
  24.    tb.i = 1
  25. end /* do */
  26. call SysFileDelete cfn
  27. call lineout cfn, '#include <limits.h>'
  28. call lineout cfn, '#include <os2.h>'
  29. call lineout cfn, '#pragma data_seg(rxjistbl)'
  30. call lineout cfn, '#include "ibm2jis.hpp"'
  31. do i = 1 to 256
  32.    if tb.i = '' then iterate
  33.    call lineout cfn, 'static const PCHAR ibmToJisTable_' || d2x(i - 1) || '[UCHAR_MAX+1] = {'
  34.    do j = 1 to 256
  35.       if tb.i.j = '' then call lineout cfn, 'NULL,'
  36.       else call lineout cfn, tb.i.j || ','
  37.    end /* do */
  38.    call lineout cfn, '};'
  39. end /* do */
  40. call lineout cfn, 'const PCHAR _Export *IbmToJisTable[UCHAR_MAX+1] = {'
  41. do i = 1 to 256
  42.    if tb.i = '' then call lineout cfn, 'NULL,'
  43.    else call lineout cfn, 'ibmToJisTable_' || d2x(i - 1) || ','
  44. end /* do */
  45. call lineout cfn, '};'
  46. call lineout cfn, 'int _Export maxIbm2JisSize =' m || ';'
  47. call stream cfn, 'c', 'close'
  48. exit
  49.  
  50. conststrlen: procedure
  51. parse arg '"' a '"'
  52. l = 0
  53. do while length(a) > 0
  54.    select
  55.       when translate(left(a, 2)) = '\X' then a = substr(a, 5)
  56.    otherwise
  57.      a = substr(a, 2)
  58.    end  /* select */
  59.    l = l + 1
  60. end /* do */
  61. return l
  62.