• R/O
  • SSH
  • HTTPS

kirikirij: Commit


Commit MetaInfo

Revision189 (tree)
Time2012-08-15 21:48:25
Authorjin1016

Log Message

マクロやタグ名で全角大文字が全角小文字に変換されないように対応。

Change Summary

Incremental Difference

--- base/trunk/src/src/jp/kirikiri/tvp2/utils/KAGParserNI.java (revision 188)
+++ base/trunk/src/src/jp/kirikiri/tvp2/utils/KAGParserNI.java (revision 189)
@@ -208,6 +208,8 @@
208208
209209 private boolean mInterrupted;
210210
211+ private char[] mWorkChar;
212+
211213 public KAGParserNI() throws VariantException, TJSException {
212214 // 初期値を代入しているものはコメントアウト
213215 // mOwner = null;
@@ -1362,7 +1364,7 @@
13621364 Message.throwExceptionMessage(Message.KAGSyntaxError);
13631365
13641366 String tagname = mCurLineStr.substring(tagnamestart, mCurPos);
1365- tagname = tagname.toLowerCase();
1367+ tagname = toLowerCaseHalf(tagname);
13661368 {
13671369 Variant tag_val = new Variant(tagname);
13681370 mDicObj.propSet( Interface.MEMBERENSURE, __tag_name, tag_val, mDicObj);
@@ -1710,7 +1712,7 @@
17101712 Variant val = new Variant();
17111713 mDicObj.propGet( 0, "name", val, mDicObj );
17121714 mRecordingMacroName = val.asString();
1713- mRecordingMacroName = mRecordingMacroName.toLowerCase();
1715+ mRecordingMacroName = toLowerCaseHalf(mRecordingMacroName); // 全角は変換しない toLowerCase
17141716 if( mRecordingMacroName.length() == 0 )
17151717 Message.throwExceptionMessage(Message.KAGSyntaxError);
17161718 // missing macro name
@@ -1772,7 +1774,7 @@
17721774 int attribnameend = mCurPos;
17731775
17741776 String attribname = mCurLineStr.substring(attribnamestart, attribnameend);
1775- attribname = attribname.toLowerCase();
1777+ attribname = toLowerCaseHalf(attribname);
17761778
17771779 // =
17781780 while( mCurPos < mCurLineStr.length() && isWS(getC()) ) mCurPos++;
@@ -1933,5 +1935,34 @@
19331935 public void assign(KAGParserNI src) throws VariantException, TJSException {
19341936 copy( src );
19351937 }
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+ }
19361967 }
19371968
Show on old repository browser