マクロやタグ名で全角大文字が全角小文字に変換されないように対応。
@@ -208,6 +208,8 @@ | ||
208 | 208 | |
209 | 209 | private boolean mInterrupted; |
210 | 210 | |
211 | + private char[] mWorkChar; | |
212 | + | |
211 | 213 | public KAGParserNI() throws VariantException, TJSException { |
212 | 214 | // 初期値を代入しているものはコメントアウト |
213 | 215 | // mOwner = null; |
@@ -1362,7 +1364,7 @@ | ||
1362 | 1364 | Message.throwExceptionMessage(Message.KAGSyntaxError); |
1363 | 1365 | |
1364 | 1366 | String tagname = mCurLineStr.substring(tagnamestart, mCurPos); |
1365 | - tagname = tagname.toLowerCase(); | |
1367 | + tagname = toLowerCaseHalf(tagname); | |
1366 | 1368 | { |
1367 | 1369 | Variant tag_val = new Variant(tagname); |
1368 | 1370 | mDicObj.propSet( Interface.MEMBERENSURE, __tag_name, tag_val, mDicObj); |
@@ -1710,7 +1712,7 @@ | ||
1710 | 1712 | Variant val = new Variant(); |
1711 | 1713 | mDicObj.propGet( 0, "name", val, mDicObj ); |
1712 | 1714 | mRecordingMacroName = val.asString(); |
1713 | - mRecordingMacroName = mRecordingMacroName.toLowerCase(); | |
1715 | + mRecordingMacroName = toLowerCaseHalf(mRecordingMacroName); // 全角は変換しない toLowerCase | |
1714 | 1716 | if( mRecordingMacroName.length() == 0 ) |
1715 | 1717 | Message.throwExceptionMessage(Message.KAGSyntaxError); |
1716 | 1718 | // missing macro name |
@@ -1772,7 +1774,7 @@ | ||
1772 | 1774 | int attribnameend = mCurPos; |
1773 | 1775 | |
1774 | 1776 | String attribname = mCurLineStr.substring(attribnamestart, attribnameend); |
1775 | - attribname = attribname.toLowerCase(); | |
1777 | + attribname = toLowerCaseHalf(attribname); | |
1776 | 1778 | |
1777 | 1779 | // = |
1778 | 1780 | while( mCurPos < mCurLineStr.length() && isWS(getC()) ) mCurPos++; |
@@ -1933,5 +1935,34 @@ | ||
1933 | 1935 | public void assign(KAGParserNI src) throws VariantException, TJSException { |
1934 | 1936 | copy( src ); |
1935 | 1937 | } |
1938 | + | |
1939 | + /** | |
1940 | + * 半角大文字英字のみを小文字にする | |
1941 | + * @param str 入力文字列 | |
1942 | + * @return 変換後文字列 | |
1943 | + */ | |
1944 | + private String toLowerCaseHalf( String str ) { | |
1945 | + final int count = str.length(); | |
1946 | + if( mWorkChar == null || mWorkChar.length < count ) { | |
1947 | + mWorkChar = str.toCharArray(); | |
1948 | + } else { | |
1949 | + str.getChars( 0, count, mWorkChar, 0 ); | |
1950 | + } | |
1951 | + char[] tmp = mWorkChar; | |
1952 | + boolean ischange = false; | |
1953 | + for( int i = 0; i < count; i++ ) { | |
1954 | + char ch = tmp[i]; | |
1955 | + if( ch >= 'A' && ch <= 'Z' ) { | |
1956 | + ch += 'a'-'A'; | |
1957 | + tmp[i] = ch; | |
1958 | + ischange = true; | |
1959 | + } | |
1960 | + } | |
1961 | + if( ischange ) { | |
1962 | + return new String(tmp); | |
1963 | + } else { | |
1964 | + return str; | |
1965 | + } | |
1966 | + } | |
1936 | 1967 | } |
1937 | 1968 |