Changeset 12494
- Timestamp:
- 02/21/10 14:33:12 (12 years ago)
- Location:
- trunk/abcl/src/org/armedbear/lisp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/SimpleString.java
r12431 r12494 79 79 } 80 80 81 p rivateSimpleString(char[] chars)81 public SimpleString(char[] chars) 82 82 { 83 83 this.chars = chars; -
trunk/abcl/src/org/armedbear/lisp/StringFunctions.java
r12493 r12494 556 556 StringIndicesAndChars indicesAndChars = 557 557 stringIndicesAndChars(first, second, third); 558 StringBuilder sb = new StringBuilder(indicesAndChars.array1.length); 559 int i; 560 for (i = 0; i < indicesAndChars.start1; i++) 561 sb.append(indicesAndChars.array1[i]); 562 for (i = indicesAndChars.start1; i < indicesAndChars.end1; i++) 563 sb.append(LispCharacter.toUpperCase(indicesAndChars.array1[i])); 564 for (i = indicesAndChars.end1; 565 i < indicesAndChars.array1.length; i++) 566 sb.append(indicesAndChars.array1[i]); 567 return new SimpleString(sb); 558 char[] array = new char[indicesAndChars.array1.length]; 559 System.arraycopy(indicesAndChars.array1, 0, 560 array, 0, 561 indicesAndChars.start1); 562 for (int i = indicesAndChars.start1; i < indicesAndChars.end1; i++) 563 array[i] = LispCharacter.toUpperCase(indicesAndChars.array1[i]); 564 System.arraycopy(indicesAndChars.array1, indicesAndChars.end1, 565 array, indicesAndChars.end1, 566 indicesAndChars.array1.length 567 - indicesAndChars.end1); 568 return new SimpleString(array); 568 569 } 569 570 }; … … 581 582 StringIndicesAndChars indicesAndChars = 582 583 stringIndicesAndChars(first, second, third); 583 StringBuilder sb = new StringBuilder(indicesAndChars.array1.length); 584 int i; 585 for (i = 0; i < indicesAndChars.start1; i++) 586 sb.append(indicesAndChars.array1[i]); 587 for (i = indicesAndChars.start1; i < indicesAndChars.end1; i++) 588 sb.append(LispCharacter.toLowerCase(indicesAndChars.array1[i])); 589 for (i = indicesAndChars.end1; 590 i < indicesAndChars.array1.length; i++) 591 sb.append(indicesAndChars.array1[i]); 592 return new SimpleString(sb); 584 char[] array = new char[indicesAndChars.array1.length]; 585 System.arraycopy(indicesAndChars.array1, 0, 586 array, 0, 587 indicesAndChars.start1); 588 for (int i = indicesAndChars.start1; i < indicesAndChars.end1; i++) 589 array[i] = LispCharacter.toLowerCase(indicesAndChars.array1[i]); 590 System.arraycopy(indicesAndChars.array1, indicesAndChars.end1, 591 array, indicesAndChars.end1, 592 indicesAndChars.array1.length 593 - indicesAndChars.end1); 594 return new SimpleString(array); 593 595 } 594 596 }; … … 608 610 StringIndicesAndChars indicesAndChars = 609 611 stringIndicesAndChars(first, second, third); 610 StringBuilder sb = new StringBuilder(indicesAndChars.array1.length);612 char[] array = new char[indicesAndChars.array1.length]; 611 613 boolean lastCharWasAlphanumeric = false; 612 int i; 613 for (i = 0; i < indicesAndChars.start1; i++) 614 sb.append(indicesAndChars.array1[i]); 615 for (i = indicesAndChars.start1; i < indicesAndChars.end1; i++) { 614 System.arraycopy(indicesAndChars.array1, 0, 615 array, 0, 616 indicesAndChars.start1); 617 for (int i = indicesAndChars.start1; 618 i < indicesAndChars.end1; i++) { 616 619 char c = indicesAndChars.array1[i]; 617 620 if (Character.isLowerCase(c)) { 618 sb.append(lastCharWasAlphanumeric ? c : LispCharacter.toUpperCase(c)); 621 array[i] = lastCharWasAlphanumeric ? 622 c : LispCharacter.toUpperCase(c); 619 623 lastCharWasAlphanumeric = true; 620 624 } else if (Character.isUpperCase(c)) { 621 sb.append(lastCharWasAlphanumeric ? LispCharacter.toLowerCase(c) : c); 625 array[i] = lastCharWasAlphanumeric ? 626 LispCharacter.toLowerCase(c) : c; 622 627 lastCharWasAlphanumeric = true; 623 628 } else { 624 sb.append(c);629 array[i] = c; 625 630 lastCharWasAlphanumeric = Character.isDigit(c); 626 631 } 627 632 } 628 for (i = indicesAndChars.end1; 629 i < indicesAndChars.array1.length; i++) 630 sb.append(indicesAndChars.array1[i]); 631 return new SimpleString(sb); 633 System.arraycopy(indicesAndChars.array1, indicesAndChars.end1, 634 array, indicesAndChars.end1, 635 indicesAndChars.array1.length 636 - indicesAndChars.end1); 637 return new SimpleString(array); 632 638 } 633 639 };
Note: See TracChangeset
for help on using the changeset viewer.