414 |
414 |
415 "Modified: / 28-06-1997 / 20:09:35 / cg" |
415 "Modified: / 28-06-1997 / 20:09:35 / cg" |
416 "Created: / 03-08-1997 / 18:16:40 / cg" |
416 "Created: / 03-08-1997 / 18:16:40 / cg" |
417 "Modified: / 16-01-2018 / 18:59:04 / stefan" |
417 "Modified: / 16-01-2018 / 18:59:04 / stefan" |
418 ! ! |
418 ! ! |
|
419 |
419 |
420 |
420 !CharacterArray class methodsFor:'cleanup'! |
421 !CharacterArray class methodsFor:'cleanup'! |
421 |
422 |
422 lowSpaceCleanup |
423 lowSpaceCleanup |
423 "cleanup in low-memory situations" |
424 "cleanup in low-memory situations" |
1084 characterSize <= 8 ifTrue:[^ String]. |
1086 characterSize <= 8 ifTrue:[^ String]. |
1085 characterSize <= 16 ifTrue:[^ Unicode16String]. |
1087 characterSize <= 16 ifTrue:[^ Unicode16String]. |
1086 ^ Unicode32String |
1088 ^ Unicode32String |
1087 ! ! |
1089 ! ! |
1088 |
1090 |
|
1091 |
1089 !CharacterArray class methodsFor:'utilities'! |
1092 !CharacterArray class methodsFor:'utilities'! |
1090 |
1093 |
1091 through:aCharacter in:inStream |
1094 through:aCharacter in:inStream |
1092 "read all characters through aCharacter and return a |
1095 "read all characters through aCharacter and return a |
1093 dense strings for it (i.e. String/TwoByteString, if possible). |
1096 dense strings for it (i.e. String/TwoByteString, if possible). |
1507 "return the index of the last space character; 0 if there is none. |
1510 "return the index of the last space character; 0 if there is none. |
1508 Added for Squeak/Pharo compatibility" |
1511 Added for Squeak/Pharo compatibility" |
1509 |
1512 |
1510 "/ CG: is this correct? separator or space only??? |
1513 "/ CG: is this correct? separator or space only??? |
1511 ^ self lastIndexOfSeparator |
1514 ^ self lastIndexOfSeparator |
1512 ! |
|
1513 |
|
1514 lineIndicesDo: aBlock |
|
1515 "execute aBlock with 3 arguments for each line: |
|
1516 - start index of line |
|
1517 - end index of line without line delimiter |
|
1518 - end index of line including line delimiter(s) CR, LF or CRLF" |
|
1519 |
|
1520 | cr lf start sz nextLF nextCR | |
|
1521 |
|
1522 start := 1. |
|
1523 sz := self size. |
|
1524 Smalltalk isSmalltalkX ifTrue:[ |
|
1525 cr := Character return |
|
1526 ] ifFalse:[ |
|
1527 cr := Character cr. |
|
1528 ]. |
|
1529 nextCR := self indexOf: cr startingAt: 1. |
|
1530 lf := Character lf. |
|
1531 nextLF := self indexOf: lf startingAt: 1. |
|
1532 [ start <= sz ] whileTrue: [ |
|
1533 (nextLF == 0 and: [ nextCR == 0 ]) |
|
1534 ifTrue: [ "No more CR, nor LF, the string is over" |
|
1535 aBlock value: start value: sz value: sz. |
|
1536 ^self ]. |
|
1537 (nextCR ~= 0 or: [ 0 < nextLF and: [ nextLF < nextCR ] ]) |
|
1538 ifTrue: [ "Found a LF" |
|
1539 aBlock value: start value: nextLF - 1 value: nextLF. |
|
1540 start := 1 + nextLF. |
|
1541 nextLF := self indexOf: lf startingAt: start ] |
|
1542 ifFalse: [ 1 + nextCR = nextLF |
|
1543 ifTrue: [ "Found a CR-LF pair" |
|
1544 aBlock value: start value: nextCR - 1 value: nextLF. |
|
1545 start := 1 + nextLF. |
|
1546 nextCR := self indexOf: cr startingAt: start. |
|
1547 nextLF := self indexOf: lf startingAt: start ] |
|
1548 ifFalse: [ "Found a CR" |
|
1549 aBlock value: start value: nextCR - 1 value: nextCR. |
|
1550 start := 1 + nextCR. |
|
1551 nextCR := self indexOf: cr startingAt: start ]]] |
|
1552 ! |
1515 ! |
1553 |
1516 |
1554 linesDo:aBlock |
1517 linesDo:aBlock |
1555 "evaluate the argument, aBlock for all lines, |
1518 "evaluate the argument, aBlock for all lines, |
1556 up to the end" |
1519 up to the end" |
5685 |
5648 |
5686 self atAllPut:(Character value:0) |
5649 self atAllPut:(Character value:0) |
5687 ! ! |
5650 ! ! |
5688 |
5651 |
5689 |
5652 |
|
5653 |
|
5654 |
5690 !CharacterArray methodsFor:'matching - glob expressions'! |
5655 !CharacterArray methodsFor:'matching - glob expressions'! |
5691 |
5656 |
5692 compoundMatch:aString |
5657 compoundMatch:aString |
5693 "like match, but the receiver may be a compound match pattern, |
5658 "like match, but the receiver may be a compound match pattern, |
5694 consisting of multiple simple GLOB patterns, separated by semicolons. |
5659 consisting of multiple simple GLOB patterns, separated by semicolons. |
7715 |
7680 |
7716 "Created: 12.5.1996 / 20:09:29 / cg" |
7681 "Created: 12.5.1996 / 20:09:29 / cg" |
7717 "Modified: 17.4.1997 / 12:50:23 / cg" |
7682 "Modified: 17.4.1997 / 12:50:23 / cg" |
7718 ! ! |
7683 ! ! |
7719 |
7684 |
|
7685 |
7720 !CharacterArray methodsFor:'special string converting'! |
7686 !CharacterArray methodsFor:'special string converting'! |
7721 |
7687 |
7722 asUnixFilenameString |
7688 asUnixFilenameString |
7723 "return a new string consisting of receiver's characters |
7689 "return a new string consisting of receiver's characters |
7724 with all \-characters replaced by /-characters. |
7690 with all \-characters replaced by /-characters. |
7763 'hello %1 %(abc)' expandNumericPlaceholdersWith:#('world') |
7729 'hello %1 %(abc)' expandNumericPlaceholdersWith:#('world') |
7764 " |
7730 " |
7765 |
7731 |
7766 " |
7732 " |
7767 'hello %1' expandPlaceholdersWith:#('world') |
7733 'hello %1' expandPlaceholdersWith:#('world') |
7768 'hello %1 %abc' expandPlaceholdersWith:#('world') |
7734 'hello %1 %abc' expandNumericPlaceholdersWith:#('world' 'nononono') |
7769 'hello %1 %(abc)' expandPlaceholdersWith:#('world') |
7735 'hello %1 %abc' expandPlaceholdersWith:#('world' 'nononono') |
|
7736 'hello %1 %(abc)' expandNumericPlaceholdersWith:#('world' 'nononono') |
|
7737 'hello %1 %(abc)' expandPlaceholdersWith:#('world' 'nononono') |
7770 " |
7738 " |
7771 |
7739 |
7772 "Modified: / 01-07-1997 / 00:53:24 / cg" |
7740 "Modified: / 01-07-1997 / 00:53:24 / cg" |
7773 "Modified: / 14-07-2018 / 09:23:31 / Claus Gittinger" |
7741 "Modified: / 14-07-2018 / 09:23:31 / Claus Gittinger" |
|
7742 "Modified (comment): / 09-09-2019 / 13:58:20 / Stefan Vogel" |
7774 ! |
7743 ! |
7775 |
7744 |
7776 expandPlaceholders |
7745 expandPlaceholders |
7777 "return a copy of the receiver, where %<special> escapes are expanded. |
7746 "return a copy of the receiver, where %<special> escapes are expanded. |
7778 %<..> |
7747 %<..> |
9704 (' ' , Character tab asString , ' foo ') withoutTrailingSeparators inspect |
9673 (' ' , Character tab asString , ' foo ') withoutTrailingSeparators inspect |
9705 (' foo' , Character tab asString) withoutTrailingSeparators inspect |
9674 (' foo' , Character tab asString) withoutTrailingSeparators inspect |
9706 " |
9675 " |
9707 ! ! |
9676 ! ! |
9708 |
9677 |
|
9678 |
9709 !CharacterArray methodsFor:'substring searching'! |
9679 !CharacterArray methodsFor:'substring searching'! |
9710 |
9680 |
9711 findRangeOfString:subString |
9681 findRangeOfString:subString |
9712 "find a substring. if found, return the start- and endIndex; |
9682 "find a substring. if found, return the start- and endIndex; |
9713 if not found, return an empty interval." |
9683 if not found, return an empty interval." |