String.st
author Claus Gittinger <cg@exept.de>
Tue, 17 Jan 2006 13:18:40 +0100
changeset 9063 953b305e35d6
parent 8932 76089ecc282d
child 9182 bb8b1eeb08b6
permissions -rw-r--r--
isEmptyOrNil / notEmptyOrNil refactoring
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     1
"
5
67342904af11 *** empty log message ***
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1988 by Claus Gittinger
159
514c749165c3 *** empty log message ***
claus
parents: 95
diff changeset
     3
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     4
a27a279701f8 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
a27a279701f8 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
a27a279701f8 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
a27a279701f8 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
a27a279701f8 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
a27a279701f8 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    11
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
    12
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5312
diff changeset
    13
"{ Package: 'stx:libbasic' }"
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5312
diff changeset
    14
3989
109b4e016f51 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3980
diff changeset
    15
CharacterArray variableByteSubclass:#String
1218
5ed62714c8d1 commentary; ignoredMethods removed
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
    16
	instanceVariableNames:''
7021
c12795ed7ddc string extensions
penk
parents: 7016
diff changeset
    17
	classVariableNames:'CRLF LF'
1218
5ed62714c8d1 commentary; ignoredMethods removed
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
    18
	poolDictionaries:''
5ed62714c8d1 commentary; ignoredMethods removed
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
    19
	category:'Collections-Text'
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    20
!
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    21
216
a8abff749575 *** empty log message ***
claus
parents: 209
diff changeset
    22
!String primitiveDefinitions!
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    23
%{
2894
344aec8ba014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2887
diff changeset
    24
3809
dd1df62365ee use threadsafe fprintf (win32)
Claus Gittinger <cg@exept.de>
parents: 3751
diff changeset
    25
#include <stdio.h>
dd1df62365ee use threadsafe fprintf (win32)
Claus Gittinger <cg@exept.de>
parents: 3751
diff changeset
    26
#define _STDIO_H_INCLUDED_
437
claus
parents: 429
diff changeset
    27
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    28
#include <ctype.h>
359
claus
parents: 357
diff changeset
    29
273
f97f3fcf8214 *** empty log message ***
claus
parents: 267
diff changeset
    30
#ifdef LINUX
359
claus
parents: 357
diff changeset
    31
# define __STRINGDEFS__
claus
parents: 357
diff changeset
    32
# include <linuxIntern.h>
273
f97f3fcf8214 *** empty log message ***
claus
parents: 267
diff changeset
    33
#endif
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
    34
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
    35
/*
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
    36
 * old st/x creates strings with spaces in it;
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
    37
 * new st/x will fill it with zeros (for st-80 compatibility)
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
    38
 * the define below sets old behavior.
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
    39
 */
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
    40
#define INITIALIZE_WITH_SPACE
6370
d82742acb152 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6369
diff changeset
    41
d82742acb152 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6369
diff changeset
    42
#ifdef FAST_MEMCHR
d82742acb152 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6369
diff changeset
    43
 char *memchr();
d82742acb152 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6369
diff changeset
    44
#endif
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    45
%}
216
a8abff749575 *** empty log message ***
claus
parents: 209
diff changeset
    46
! !
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    47
8647
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
    48
!String primitiveFunctions!
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
    49
%{
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
    50
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
    51
static int
8647
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
    52
nextOnKeyboard(char1, char2) {
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
    53
    /* compare two characters if they are next to each other on a (US-) keyboard */
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
    54
    static char *keys[] = { "1234567890-",
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
    55
			    "*qwertyuiop",
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
    56
			    "**asdfghjkl:",
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
    57
			    "***zxcvbnm",
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
    58
			    0 };
8647
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
    59
    char **line1, **line2;
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
    60
    char *col1, *col2;
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
    61
    int diff;
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
    62
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
    63
    for (line1 = keys; *line1 != 0; line1++) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
    64
	for (col1 = *line1; *col1 != 0 && *col1 != char1; col1++)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
    65
	    continue;
8647
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
    66
    }
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
    67
    if (*col1 == 0)
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
    68
	return(0);
8647
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
    69
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
    70
    for (line2 = keys; *line2 != 0; line2++) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
    71
	for (col2 = *line2; *col2 != 0 && *col2 != char2; col2++)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
    72
	    continue;
8647
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
    73
    }
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
    74
    if (*col2 == 0)
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
    75
	return(0);
8647
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
    76
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
    77
    diff = col1 - col2;
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
    78
    if (diff > 1 || diff < -1)
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
    79
	return(0);
8647
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
    80
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
    81
    diff = line1 - line2;
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
    82
    if (diff > 1 || diff < -1)
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
    83
	return(0);
8647
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
    84
    return(1);
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
    85
}
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
    86
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
    87
%}
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
    88
! !
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
    89
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    90
!String class methodsFor:'documentation'!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    91
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    92
copyright
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    93
"
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    94
 COPYRIGHT (c) 1988 by Claus Gittinger
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    95
	      All Rights Reserved
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    96
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    97
 This software is furnished under a license and may be used
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    98
 only in accordance with the terms of that license and with the
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    99
 inclusion of the above copyright notice.   This software may not
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   100
 be provided or otherwise made available to, or used by, any
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   101
 other person.  No title to or ownership of the software is
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   102
 hereby transferred.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   103
"
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   104
!
3
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
   105
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   106
documentation
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   107
"
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   108
    Strings are ByteArrays storing Characters.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   109
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   110
    Strings are kind of kludgy: to allow for easy handling by c-functions,
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   111
    there is always one 0-byte added at the end, which is not counted
4800
118dff933bf3 docu fixed - yes, String does allow storing 0-bytes.
Claus Gittinger <cg@exept.de>
parents: 4745
diff changeset
   112
    in the strings size, and is not accessable from the smalltalk level.
118dff933bf3 docu fixed - yes, String does allow storing 0-bytes.
Claus Gittinger <cg@exept.de>
parents: 4745
diff changeset
   113
    This guarantees, that a smalltalk string can always be passed to a
118dff933bf3 docu fixed - yes, String does allow storing 0-bytes.
Claus Gittinger <cg@exept.de>
parents: 4745
diff changeset
   114
    C- or a system api function without danger (of course, this does not
118dff933bf3 docu fixed - yes, String does allow storing 0-bytes.
Claus Gittinger <cg@exept.de>
parents: 4745
diff changeset
   115
    prevent a nonsense contents ...)
3
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
   116
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   117
    You cannot add any instvars to String, since the the run time system & compiler
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   118
    creates literal strings and knows that strings have no named instvars.
3809
dd1df62365ee use threadsafe fprintf (win32)
Claus Gittinger <cg@exept.de>
parents: 3751
diff changeset
   119
    If you really need strings with instVars, you have to create a subclass
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   120
    of String (the access functions defined here can handle this).
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   121
    A little warning though: not all smalltalk systems allow subclassing String,
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   122
    so your program may become unportable if you do so.
1290
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 1264
diff changeset
   123
7895
Claus Gittinger <cg@exept.de>
parents: 7891
diff changeset
   124
    Strings have an implicit (assumed) encoding of iso8859-1.
Claus Gittinger <cg@exept.de>
parents: 7891
diff changeset
   125
    For strings with other encodings, either keep the encoding separately,
Claus Gittinger <cg@exept.de>
parents: 7891
diff changeset
   126
    or use instances of encodedString.
Claus Gittinger <cg@exept.de>
parents: 7891
diff changeset
   127
1290
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 1264
diff changeset
   128
    [author:]
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   129
	Claus Gittinger
1310
e910406fbecf commentary
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
   130
e910406fbecf commentary
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
   131
    [see also:]
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   132
	Text StringCollection TwoByteString JISEncodedString
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   133
	Symbol
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   134
"
3
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
   135
! !
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
   136
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   137
!String class methodsFor:'instance creation'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   138
a27a279701f8 Initial revision
claus
parents:
diff changeset
   139
basicNew:anInteger
4802
0021d360c891 comments
Claus Gittinger <cg@exept.de>
parents: 4800
diff changeset
   140
    "return a new empty string with anInteger characters.
0021d360c891 comments
Claus Gittinger <cg@exept.de>
parents: 4800
diff changeset
   141
     In contrast to other smalltalks, this returns a string filled
0021d360c891 comments
Claus Gittinger <cg@exept.de>
parents: 4800
diff changeset
   142
     with spaces (instead of a string filled with 0-bytes).
0021d360c891 comments
Claus Gittinger <cg@exept.de>
parents: 4800
diff changeset
   143
     This makes much more sense, in that a freshly created string
0021d360c891 comments
Claus Gittinger <cg@exept.de>
parents: 4800
diff changeset
   144
     can be directly used as separator or for formatting."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   145
a27a279701f8 Initial revision
claus
parents:
diff changeset
   146
%{  /* NOCONTEXT */
a27a279701f8 Initial revision
claus
parents:
diff changeset
   147
a27a279701f8 Initial revision
claus
parents:
diff changeset
   148
    OBJ newString;
a27a279701f8 Initial revision
claus
parents:
diff changeset
   149
    REGISTER int len;
a27a279701f8 Initial revision
claus
parents:
diff changeset
   150
    REGISTER unsigned char *cp;
a27a279701f8 Initial revision
claus
parents:
diff changeset
   151
    REGISTER OBJ *op;
a27a279701f8 Initial revision
claus
parents:
diff changeset
   152
    int nInstVars, instsize;
a27a279701f8 Initial revision
claus
parents:
diff changeset
   153
252
   154
    if (__isSmallInteger(anInteger)) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   155
	len = __intVal(anInteger);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   156
	if (len >= 0) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   157
	    instsize = OHDR_SIZE + len + 1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   158
	    if (self == String) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   159
		if (__CanDoQuickNew(instsize)) {        /* OBJECT ALLOCATION */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   160
		    /*
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   161
		     * the most common case
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   162
		     */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   163
		    __qCheckedNew(newString, instsize);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   164
		    __InstPtr(newString)->o_class = self; /* no need for PROTECT - there was no GC */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   165
		    __qSTORE(newString, self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   166
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   167
		    cp = __stringVal(newString);
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
   168
357
claus
parents: 347
diff changeset
   169
#if defined(memset4) && !defined(NON_ASCII)
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   170
		    {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   171
			/*
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   172
			 * no sizeof(int) here please -
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   173
			 * - memset4 (if defined) fills 4-bytes on ALL machines
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   174
			 */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   175
			int l4 = len >> 2;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   176
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   177
			if (len & 3) l4++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   178
			memset4(cp, 0x20202020, l4);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   179
			cp[len] = '\0';
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   180
		    }
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   181
#else
357
claus
parents: 347
diff changeset
   182
# ifdef FAST_MEMSET
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   183
		    memset(cp, ' ', len);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   184
		    cp[len] = '\0';
357
claus
parents: 347
diff changeset
   185
# else
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   186
		    while (len >= 8) {
3449
84160615c630 oops - basicNew was bad for subclasses of String.
Claus Gittinger <cg@exept.de>
parents: 3403
diff changeset
   187
#  ifndef NON_ASCII       /* i.e. EBCDIC  */
2954
a2f437a0483a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2929
diff changeset
   188
#   ifdef INT64
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   189
			((INT64 *)cp)[0] = 0x2020202020202020L;
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
   190
#   else
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   191
			((int *)cp)[0] = 0x20202020;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   192
			((int *)cp)[1] = 0x20202020;
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
   193
#   endif
357
claus
parents: 347
diff changeset
   194
#  else
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   195
			cp[0] = cp[1] = cp[2] = cp[3] = ' ';
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   196
			cp[4] = cp[5] = cp[6] = cp[7] = ' ';
357
claus
parents: 347
diff changeset
   197
#  endif
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   198
			cp += 8;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   199
			len -= 8;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   200
		    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   201
		    while (len--)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   202
			*cp++ = ' ';
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   203
		    *cp = '\0';
2867
015574e235fd tuned replaceFrom:to:with:startingAt:
Claus Gittinger <cg@exept.de>
parents: 2862
diff changeset
   204
# endif /* not FAST_MEMSET */
015574e235fd tuned replaceFrom:to:with:startingAt:
Claus Gittinger <cg@exept.de>
parents: 2862
diff changeset
   205
#endif /* not memset4 */
015574e235fd tuned replaceFrom:to:with:startingAt:
Claus Gittinger <cg@exept.de>
parents: 2862
diff changeset
   206
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   207
		    RETURN (newString);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   208
		}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   209
		nInstVars = 0;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   210
	    } else {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   211
		nInstVars = __intVal(__ClassInstPtr(self)->c_ninstvars);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   212
		instsize += __OBJS2BYTES__(nInstVars);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   213
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   214
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   215
	    __PROTECT_CONTEXT__;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   216
	    __qNew(newString, instsize);        /* OBJECT ALLOCATION */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   217
	    __UNPROTECT_CONTEXT__;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   218
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   219
	    if (newString == nil) goto fail;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   220
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   221
	    __InstPtr(newString)->o_class = self;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   222
	    __qSTORE(newString, self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   223
8920
19397e1e685e string with instvar fix
Claus Gittinger <cg@exept.de>
parents: 8919
diff changeset
   224
	    cp = __stringVal(newString);
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   225
	    if (nInstVars) {
8920
19397e1e685e string with instvar fix
Claus Gittinger <cg@exept.de>
parents: 8919
diff changeset
   226
		cp += __OBJS2BYTES__(nInstVars);
19397e1e685e string with instvar fix
Claus Gittinger <cg@exept.de>
parents: 8919
diff changeset
   227
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   228
		/*
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   229
		 * nil-out instvars
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   230
		 */
2867
015574e235fd tuned replaceFrom:to:with:startingAt:
Claus Gittinger <cg@exept.de>
parents: 2862
diff changeset
   231
#if defined(memset4)
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   232
		memset4(__InstPtr(newString)->i_instvars, nil, nInstVars);
2867
015574e235fd tuned replaceFrom:to:with:startingAt:
Claus Gittinger <cg@exept.de>
parents: 2862
diff changeset
   233
#else
015574e235fd tuned replaceFrom:to:with:startingAt:
Claus Gittinger <cg@exept.de>
parents: 2862
diff changeset
   234
# if defined(FAST_MEMSET) && ! defined(NEGATIVE_ADDRESSES)
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   235
		/*
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   236
		 * knowing that nil is 0
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   237
		 */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   238
		memset(__InstPtr(newString)->i_instvars, 0, __OBJS2BYTES__(nInstVars));
2867
015574e235fd tuned replaceFrom:to:with:startingAt:
Claus Gittinger <cg@exept.de>
parents: 2862
diff changeset
   239
# else
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   240
		op = __InstPtr(newString)->i_instvars;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   241
		do {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   242
		    *op++ = nil;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   243
		} while (--nInstVars);
357
claus
parents: 347
diff changeset
   244
# endif
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   245
#endif
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   246
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   247
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   248
	    /*
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   249
	     * fill with spaces
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   250
	     */
2867
015574e235fd tuned replaceFrom:to:with:startingAt:
Claus Gittinger <cg@exept.de>
parents: 2862
diff changeset
   251
#ifdef FAST_MEMSET
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   252
	    memset(cp, ' ', len);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   253
	    *(cp + len) = '\0';
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   254
#else
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   255
	    while (len >= 8) {
357
claus
parents: 347
diff changeset
   256
# ifndef NON_ASCII       /* i.e. EBCDIC ;-) */
2954
a2f437a0483a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2929
diff changeset
   257
#  ifdef INT64
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   258
		((INT64 *)cp)[0] = 0x2020202020202020L;
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
   259
#  else
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   260
		((int *)cp)[0] = 0x20202020;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   261
		((int *)cp)[1] = 0x20202020;
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
   262
#  endif
357
claus
parents: 347
diff changeset
   263
# else
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   264
		cp[0] = cp[1] = cp[2] = cp[3] = ' ';
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   265
		cp[4] = cp[5] = cp[6] = cp[7] = ' ';
357
claus
parents: 347
diff changeset
   266
# endif
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   267
		cp += 8;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   268
		len -= 8;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   269
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   270
	    while (len--)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   271
		*cp++ = ' ';
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   272
	    *cp = '\0';
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   273
#endif
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   274
	    RETURN (newString);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   275
	}
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   276
    }
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   277
fail: ;;
1019
db8afc103e37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1015
diff changeset
   278
%}.
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   279
    "
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   280
     invalid argument, or out-of-memory:
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   281
     use error handling in superclass
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   282
    "
6766
a43b97582d4b oops - (String new:-1) did crash the system (atAllPut:)
Michael Beyl <mb@exept.de>
parents: 6599
diff changeset
   283
    (anInteger < 0) ifTrue:[
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   284
	"
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   285
	 the argument is negative,
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   286
	"
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   287
	self error:'bad (negative) argument to new:'.
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   288
	^ nil
6766
a43b97582d4b oops - (String new:-1) did crash the system (atAllPut:)
Michael Beyl <mb@exept.de>
parents: 6599
diff changeset
   289
    ].
a43b97582d4b oops - (String new:-1) did crash the system (atAllPut:)
Michael Beyl <mb@exept.de>
parents: 6599
diff changeset
   290
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5312
diff changeset
   291
    ^ (super basicNew:anInteger+1) atAllPut:(Character space)
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   292
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   293
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   294
new:n
4802
0021d360c891 comments
Claus Gittinger <cg@exept.de>
parents: 4800
diff changeset
   295
    "return a new empty string with anInteger characters.
0021d360c891 comments
Claus Gittinger <cg@exept.de>
parents: 4800
diff changeset
   296
     In contrast to other smalltalks, this returns a string filled
0021d360c891 comments
Claus Gittinger <cg@exept.de>
parents: 4800
diff changeset
   297
     with spaces (instead of a string filled with 0-bytes).
0021d360c891 comments
Claus Gittinger <cg@exept.de>
parents: 4800
diff changeset
   298
     This makes much more sense, in that a freshly created string
0021d360c891 comments
Claus Gittinger <cg@exept.de>
parents: 4800
diff changeset
   299
     can be directly used as separator or for formatting."
0021d360c891 comments
Claus Gittinger <cg@exept.de>
parents: 4800
diff changeset
   300
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   301
    ^ self basicNew:n
347
claus
parents: 345
diff changeset
   302
!
claus
parents: 345
diff changeset
   303
6599
f4b35853b094 consiostency in #readFrom: - allow string argument
Claus Gittinger <cg@exept.de>
parents: 6588
diff changeset
   304
readFrom:aStreamOrString onError:exceptionBlock
347
claus
parents: 345
diff changeset
   305
    "read & return the next String from the (character-)stream aStream;
claus
parents: 345
diff changeset
   306
     skipping all whitespace first; return the value of exceptionBlock,
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   307
     if no string can be read. The sequence of characters as read from the
347
claus
parents: 345
diff changeset
   308
     stream must be one as stored via storeOn: or storeString."
claus
parents: 345
diff changeset
   309
6599
f4b35853b094 consiostency in #readFrom: - allow string argument
Claus Gittinger <cg@exept.de>
parents: 6588
diff changeset
   310
    |str collected char|
347
claus
parents: 345
diff changeset
   311
claus
parents: 345
diff changeset
   312
    "
claus
parents: 345
diff changeset
   313
     this method is not to be inherited
claus
parents: 345
diff changeset
   314
     (i.e. not ok for subclasses; Symbol, for example)
claus
parents: 345
diff changeset
   315
    "
claus
parents: 345
diff changeset
   316
    self ~~ String ifTrue:[
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   317
	^ super readFrom:aStreamOrString onError:exceptionBlock
347
claus
parents: 345
diff changeset
   318
    ].
claus
parents: 345
diff changeset
   319
6599
f4b35853b094 consiostency in #readFrom: - allow string argument
Claus Gittinger <cg@exept.de>
parents: 6588
diff changeset
   320
    str := aStreamOrString readStream.
f4b35853b094 consiostency in #readFrom: - allow string argument
Claus Gittinger <cg@exept.de>
parents: 6588
diff changeset
   321
347
claus
parents: 345
diff changeset
   322
    "skip whiteSpace"
6599
f4b35853b094 consiostency in #readFrom: - allow string argument
Claus Gittinger <cg@exept.de>
parents: 6588
diff changeset
   323
    str skipSeparators.
f4b35853b094 consiostency in #readFrom: - allow string argument
Claus Gittinger <cg@exept.de>
parents: 6588
diff changeset
   324
    (str next == $') ifTrue:[
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   325
	collected := WriteStream on:(String new).
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   326
	[true] whileTrue:[
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   327
	    str atEnd ifTrue:[
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   328
		"/ mhmh - reached the end without a closing quote
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   329
		"/ looks like an error to me ...
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   330
		^ exceptionBlock value
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   331
	    ].
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   332
	    char := str next.
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   333
	    char == $' ifTrue:[
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   334
		"/ look for another quote
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   335
		str peekOrNil == $' ifFalse:[
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   336
		    ^ collected contents
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   337
		].
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   338
		str next.
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   339
	    ].
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   340
	    collected nextPut:char
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   341
	]
347
claus
parents: 345
diff changeset
   342
    ].
claus
parents: 345
diff changeset
   343
    ^ exceptionBlock value
claus
parents: 345
diff changeset
   344
claus
parents: 345
diff changeset
   345
    "
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   346
     String readFrom:('''hello world''' readStream)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   347
     String readFrom:('''hello '''' world''' readStream)
347
claus
parents: 345
diff changeset
   348
     String readFrom:('1 ''hello'' ' readStream)
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   349
     String readFrom:('1 ''hello'' ' readStream) onError:['foobar']
3376
d007727325da checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3335
diff changeset
   350
    "
d007727325da checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3335
diff changeset
   351
d007727325da checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3335
diff changeset
   352
    "Modified: / 14.4.1998 / 18:46:26 / cg"
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   353
!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   354
7684
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   355
uninitializedNew:anInteger
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   356
    "return a new string with anInteger characters but undefined contents.
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   357
     Use this, if the string is filled anyway with new data, for example, if
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   358
     used as a stream buffer."
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   359
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   360
%{  /* NOCONTEXT */
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   361
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   362
    OBJ newString;
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   363
    REGISTER int len;
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   364
    REGISTER unsigned char *cp;
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   365
    REGISTER OBJ *op;
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   366
    int nInstVars, instsize;
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   367
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   368
    if (__isSmallInteger(anInteger)) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   369
	len = __intVal(anInteger);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   370
	if (len >= 0) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   371
	    instsize = OHDR_SIZE + len + 1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   372
	    if (self == String) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   373
		if (__CanDoQuickNew(instsize)) {        /* OBJECT ALLOCATION */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   374
		    /*
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   375
		     * the most common case
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   376
		     */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   377
		    __qCheckedNew(newString, instsize);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   378
		    __InstPtr(newString)->o_class = self; /* no need for PROTECT - there was no GC */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   379
		    __qSTORE(newString, self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   380
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   381
		    cp = __stringVal(newString);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   382
		    cp[len] = '\0';
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   383
		    RETURN (newString);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   384
		}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   385
		nInstVars = 0;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   386
	    } else {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   387
		nInstVars = __intVal(__ClassInstPtr(self)->c_ninstvars);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   388
		instsize += __OBJS2BYTES__(nInstVars);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   389
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   390
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   391
	    __PROTECT_CONTEXT__;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   392
	    __qNew(newString, instsize);        /* OBJECT ALLOCATION */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   393
	    __UNPROTECT_CONTEXT__;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   394
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   395
	    if (newString == nil) goto fail;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   396
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   397
	    __InstPtr(newString)->o_class = self;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   398
	    __qSTORE(newString, self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   399
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   400
	    if (nInstVars) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   401
		/*
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   402
		 * nil-out instvars
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   403
		 */
7684
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   404
#if defined(memset4)
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   405
		memset4(__InstPtr(newString)->i_instvars, nil, nInstVars);
7684
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   406
#else
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   407
# if defined(FAST_MEMSET) && ! defined(NEGATIVE_ADDRESSES)
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   408
		/*
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   409
		 * knowing that nil is 0
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   410
		 */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   411
		memset(__InstPtr(newString)->i_instvars, 0, __OBJS2BYTES__(nInstVars));
7684
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   412
# else
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   413
		op = __InstPtr(newString)->i_instvars;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   414
		do {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   415
		    *op++ = nil;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   416
		} while (--nInstVars);
7684
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   417
# endif
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   418
#endif
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   419
		cp = __stringVal(newString) + __OBJS2BYTES__(nInstVars);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   420
	    } else {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   421
		cp = __stringVal(newString);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   422
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   423
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   424
	    *(cp + len) = '\0';
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   425
	    RETURN (newString);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   426
	}
7684
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   427
    }
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   428
fail: ;;
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   429
%}.
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   430
    "
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   431
     invalid argument, or out-of-memory:
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   432
     use error handling in superclass
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   433
    "
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   434
    (anInteger < 0) ifTrue:[
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   435
	"
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   436
	 the argument is negative,
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   437
	"
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   438
	self error:'bad (negative) argument to new:'.
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   439
	^ nil
7684
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   440
    ].
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   441
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   442
    ^ self basicNew:anInteger
7684
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   443
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   444
    "
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   445
     String uninitializedNew:100
01cf232f73e7 added uninitializedNew:
Claus Gittinger <cg@exept.de>
parents: 7599
diff changeset
   446
    "
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   447
! !
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   448
8438
317f70e84d61 Dolphin compatibility method #lineDelimiter
Stefan Vogel <sv@exept.de>
parents: 8415
diff changeset
   449
!String class methodsFor:'Compatibility-Dolphin'!
317f70e84d61 Dolphin compatibility method #lineDelimiter
Stefan Vogel <sv@exept.de>
parents: 8415
diff changeset
   450
317f70e84d61 Dolphin compatibility method #lineDelimiter
Stefan Vogel <sv@exept.de>
parents: 8415
diff changeset
   451
lineDelimiter
317f70e84d61 Dolphin compatibility method #lineDelimiter
Stefan Vogel <sv@exept.de>
parents: 8415
diff changeset
   452
    "Dolphin compatibility: answer CR LF"
317f70e84d61 Dolphin compatibility method #lineDelimiter
Stefan Vogel <sv@exept.de>
parents: 8415
diff changeset
   453
317f70e84d61 Dolphin compatibility method #lineDelimiter
Stefan Vogel <sv@exept.de>
parents: 8415
diff changeset
   454
    ^ self crlf
317f70e84d61 Dolphin compatibility method #lineDelimiter
Stefan Vogel <sv@exept.de>
parents: 8415
diff changeset
   455
! !
317f70e84d61 Dolphin compatibility method #lineDelimiter
Stefan Vogel <sv@exept.de>
parents: 8415
diff changeset
   456
7302
13a053c255bf category
Claus Gittinger <cg@exept.de>
parents: 7283
diff changeset
   457
!String class methodsFor:'Compatibility-Squeak'!
4981
2ee8cd2c4c8e squeak compatibility
ps
parents: 4802
diff changeset
   458
2ee8cd2c4c8e squeak compatibility
ps
parents: 4802
diff changeset
   459
cr
4994
dbeb92c54dc7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   460
    "return a string consisting of the cr-Character"
4993
569d1fa22e91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4981
diff changeset
   461
7283
779d0ca06226 cr is now a real cr
Claus Gittinger <cg@exept.de>
parents: 7282
diff changeset
   462
    ^ Character return asString
4993
569d1fa22e91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4981
diff changeset
   463
4994
dbeb92c54dc7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4993
diff changeset
   464
    "Modified: / 13.11.1999 / 13:53:36 / cg"
7282
75a51feb84c8 +crlf / +lf
Claus Gittinger <cg@exept.de>
parents: 7219
diff changeset
   465
!
75a51feb84c8 +crlf / +lf
Claus Gittinger <cg@exept.de>
parents: 7219
diff changeset
   466
75a51feb84c8 +crlf / +lf
Claus Gittinger <cg@exept.de>
parents: 7219
diff changeset
   467
crlf
75a51feb84c8 +crlf / +lf
Claus Gittinger <cg@exept.de>
parents: 7219
diff changeset
   468
    "return a string consisting of the cr-lf Characters"
75a51feb84c8 +crlf / +lf
Claus Gittinger <cg@exept.de>
parents: 7219
diff changeset
   469
75a51feb84c8 +crlf / +lf
Claus Gittinger <cg@exept.de>
parents: 7219
diff changeset
   470
    CRLF isNil ifTrue:[
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   471
	CRLF := String
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   472
		    with:Character return
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   473
		    with:Character linefeed
7282
75a51feb84c8 +crlf / +lf
Claus Gittinger <cg@exept.de>
parents: 7219
diff changeset
   474
    ].
75a51feb84c8 +crlf / +lf
Claus Gittinger <cg@exept.de>
parents: 7219
diff changeset
   475
    ^ CRLF
75a51feb84c8 +crlf / +lf
Claus Gittinger <cg@exept.de>
parents: 7219
diff changeset
   476
!
75a51feb84c8 +crlf / +lf
Claus Gittinger <cg@exept.de>
parents: 7219
diff changeset
   477
75a51feb84c8 +crlf / +lf
Claus Gittinger <cg@exept.de>
parents: 7219
diff changeset
   478
lf
75a51feb84c8 +crlf / +lf
Claus Gittinger <cg@exept.de>
parents: 7219
diff changeset
   479
    "return a string consisting of the lf Character"
75a51feb84c8 +crlf / +lf
Claus Gittinger <cg@exept.de>
parents: 7219
diff changeset
   480
75a51feb84c8 +crlf / +lf
Claus Gittinger <cg@exept.de>
parents: 7219
diff changeset
   481
    LF isNil ifTrue:[
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   482
	LF := String with:Character linefeed
7282
75a51feb84c8 +crlf / +lf
Claus Gittinger <cg@exept.de>
parents: 7219
diff changeset
   483
    ].
75a51feb84c8 +crlf / +lf
Claus Gittinger <cg@exept.de>
parents: 7219
diff changeset
   484
    ^ LF
4981
2ee8cd2c4c8e squeak compatibility
ps
parents: 4802
diff changeset
   485
! !
2ee8cd2c4c8e squeak compatibility
ps
parents: 4802
diff changeset
   486
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   487
!String class methodsFor:'binary storage'!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   488
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   489
binaryDefinitionFrom:stream manager:manager
3085
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   490
    "read a binary representation from stream. This is only invoked
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   491
     for long strings. Short strings are stored with 1byte length."
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   492
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   493
    |s len|
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   494
3085
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   495
    "take care of subclasses ..."
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   496
    ((self == String) or:[self == Symbol]) ifTrue:[
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   497
	len := stream nextNumber:4.
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   498
	s := String uninitializedNew:len.
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   499
	stream nextBytes:len into:s startingAt:1.
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   500
	self == Symbol ifTrue:[
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   501
	    ^ s asSymbol
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   502
	].
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   503
	^ s
3085
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   504
    ].
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   505
    ^ super binaryDefinitionFrom:stream manager:manager
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   506
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   507
    "Modified: / 2.11.1997 / 16:18:37 / cg"
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   508
! !
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   509
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   510
!String class methodsFor:'queries'!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   511
2680
18c85df5d930 #defaultPlatformClass for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 2670
diff changeset
   512
defaultPlatformClass
18c85df5d930 #defaultPlatformClass for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 2670
diff changeset
   513
    "dummy for ST-80 compatibility"
18c85df5d930 #defaultPlatformClass for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 2670
diff changeset
   514
18c85df5d930 #defaultPlatformClass for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 2670
diff changeset
   515
    ^ self
18c85df5d930 #defaultPlatformClass for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 2670
diff changeset
   516
18c85df5d930 #defaultPlatformClass for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 2670
diff changeset
   517
    "Created: 6.6.1997 / 18:25:56 / cg"
18c85df5d930 #defaultPlatformClass for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 2670
diff changeset
   518
!
18c85df5d930 #defaultPlatformClass for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 2670
diff changeset
   519
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   520
isBuiltInClass
1264
8d916aa63bce commentary
Claus Gittinger <cg@exept.de>
parents: 1251
diff changeset
   521
    "return true if this class is known by the run-time-system.
8d916aa63bce commentary
Claus Gittinger <cg@exept.de>
parents: 1251
diff changeset
   522
     Here, true is returned for myself, false for subclasses."
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   523
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   524
    ^ self == String
1264
8d916aa63bce commentary
Claus Gittinger <cg@exept.de>
parents: 1251
diff changeset
   525
8d916aa63bce commentary
Claus Gittinger <cg@exept.de>
parents: 1251
diff changeset
   526
    "Modified: 23.4.1996 / 16:00:38 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   527
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   528
a27a279701f8 Initial revision
claus
parents:
diff changeset
   529
!String methodsFor:'accessing'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   530
329
claus
parents: 314
diff changeset
   531
at:index
claus
parents: 314
diff changeset
   532
    "return the character at position index, an Integer.
345
claus
parents: 329
diff changeset
   533
     Reimplemented here to avoid the additional at:->basicAt: send
claus
parents: 329
diff changeset
   534
     (which we can do here, since at: is obviously not redefined in a subclass).
329
claus
parents: 314
diff changeset
   535
     This method is the same as at:."
claus
parents: 314
diff changeset
   536
claus
parents: 314
diff changeset
   537
%{  /* NOCONTEXT */
claus
parents: 314
diff changeset
   538
claus
parents: 314
diff changeset
   539
    REGISTER int indx;
1143
27325100bdf4 can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
   540
    REGISTER OBJ slf, cls;
329
claus
parents: 314
diff changeset
   541
claus
parents: 314
diff changeset
   542
    if (__isSmallInteger(index)) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   543
	slf = self;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   544
	cls = __qClass(slf);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   545
	indx = __intVal(index) - 1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   546
	if (cls != String) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   547
	    if (indx < 0) goto badIndex;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   548
	    indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   549
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   550
	if ((unsigned)indx < (unsigned)(__stringSize(slf))) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   551
	    RETURN ( __MKCHARACTER(__stringVal(slf)[indx] & 0xFF) );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   552
	}
329
claus
parents: 314
diff changeset
   553
    }
4388
b4ca5cf130c7 oops - subclasses with instVars allowed for index-less-than-1-access
Claus Gittinger <cg@exept.de>
parents: 4247
diff changeset
   554
badIndex: ;
329
claus
parents: 314
diff changeset
   555
%}.
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5312
diff changeset
   556
    ^ self basicAt:index
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   557
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   558
329
claus
parents: 314
diff changeset
   559
at:index put:aCharacter
claus
parents: 314
diff changeset
   560
    "store the argument, aCharacter at position index, an Integer.
1218
5ed62714c8d1 commentary; ignoredMethods removed
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
   561
     Return aCharacter (sigh).
345
claus
parents: 329
diff changeset
   562
     Reimplemented here to avoid the additional at:put:->basicAt:put: send
claus
parents: 329
diff changeset
   563
     (but only for Strings, since subclasses may redefine basicAt:put:).
329
claus
parents: 314
diff changeset
   564
     This method is the same as basicAt:put:."
claus
parents: 314
diff changeset
   565
claus
parents: 314
diff changeset
   566
%{  /* NOCONTEXT */
claus
parents: 314
diff changeset
   567
claus
parents: 314
diff changeset
   568
    REGISTER int value, indx;
1143
27325100bdf4 can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
   569
    REGISTER OBJ slf;
329
claus
parents: 314
diff changeset
   570
1143
27325100bdf4 can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
   571
    slf = self;
27325100bdf4 can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
   572
27325100bdf4 can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
   573
    if (__isString(slf)) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   574
	if (__isCharacter(aCharacter)) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   575
	    value = __intVal(_characterVal(aCharacter));
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   576
	    if (((unsigned)value <= 0xFF)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   577
	     && __isSmallInteger(index)) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   578
		indx = __intVal(index) - 1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   579
		if ((unsigned)indx < (unsigned)(__stringSize(slf))) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   580
		    __stringVal(slf)[indx] = value;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   581
		    RETURN ( aCharacter );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   582
		}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   583
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   584
	}
329
claus
parents: 314
diff changeset
   585
    }
claus
parents: 314
diff changeset
   586
%}.
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5312
diff changeset
   587
    ^ self basicAt:index put:aCharacter
329
claus
parents: 314
diff changeset
   588
!
claus
parents: 314
diff changeset
   589
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   590
basicAt:index
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   591
    "return the character at position index, an Integer
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   592
     - reimplemented here since we return characters"
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   593
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   594
%{  /* NOCONTEXT */
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   595
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   596
    REGISTER int indx;
1143
27325100bdf4 can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
   597
    REGISTER OBJ slf, cls;
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   598
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   599
    if (__isSmallInteger(index)) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   600
	slf = self;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   601
	cls = __qClass(slf);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   602
	indx = __intVal(index) - 1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   603
	if (cls != String) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   604
	    if (indx < 0) goto badIndex;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   605
	    indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   606
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   607
	if ((unsigned)indx < (unsigned)(__stringSize(slf))) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   608
	    RETURN ( __MKCHARACTER(__stringVal(slf)[indx] & 0xFF) );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   609
	}
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   610
    }
4388
b4ca5cf130c7 oops - subclasses with instVars allowed for index-less-than-1-access
Claus Gittinger <cg@exept.de>
parents: 4247
diff changeset
   611
badIndex: ;
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   612
%}.
3451
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
   613
    index isInteger ifFalse:[
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   614
	^ self indexNotInteger:index
3451
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
   615
    ].
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5312
diff changeset
   616
    index == super basicSize ifTrue:[
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   617
	^ self subscriptBoundsError:index
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5312
diff changeset
   618
    ].
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5312
diff changeset
   619
    ^ Character value:(super basicAt:index)
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   620
!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   621
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   622
basicAt:index put:aCharacter
1218
5ed62714c8d1 commentary; ignoredMethods removed
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
   623
    "store the argument, aCharacter at position index, an Integer.
5ed62714c8d1 commentary; ignoredMethods removed
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
   624
     Returns aCharacter (sigh).
1143
27325100bdf4 can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
   625
     - reimplemented here since we store characters"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   626
a27a279701f8 Initial revision
claus
parents:
diff changeset
   627
%{  /* NOCONTEXT */
a27a279701f8 Initial revision
claus
parents:
diff changeset
   628
a27a279701f8 Initial revision
claus
parents:
diff changeset
   629
    REGISTER int value, indx;
1143
27325100bdf4 can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
   630
    REGISTER OBJ slf;
27325100bdf4 can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
   631
    REGISTER OBJ cls;
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   632
1143
27325100bdf4 can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
   633
    slf = self;
27325100bdf4 can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
   634
27325100bdf4 can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
   635
    if (__isCharacter(aCharacter)) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   636
	value = __intVal(_characterVal(aCharacter));
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   637
	if (((unsigned)value <= 0xFF)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   638
	 && __isSmallInteger(index)) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   639
	    cls = __qClass(slf);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   640
	    indx = __intVal(index) - 1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   641
	    if (cls != String) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   642
		if (indx < 0) goto badIndex;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   643
		indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   644
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   645
	    if ((unsigned)indx < (unsigned)(__stringSize(slf))) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   646
		__stringVal(slf)[indx] = value;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   647
		RETURN ( aCharacter );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   648
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   649
	}
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   650
    }
4388
b4ca5cf130c7 oops - subclasses with instVars allowed for index-less-than-1-access
Claus Gittinger <cg@exept.de>
parents: 4247
diff changeset
   651
badIndex: ;
159
514c749165c3 *** empty log message ***
claus
parents: 95
diff changeset
   652
%}.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   653
    (aCharacter isMemberOf:Character) ifFalse:[
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   654
	"
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   655
	 tried to store something which is not a character
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   656
	"
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   657
	^ self elementNotCharacter
299
bc0645db1ab0 *** empty log message ***
claus
parents: 286
diff changeset
   658
    ].
8093
8ca1e24688d8 Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents: 8049
diff changeset
   659
    (aCharacter codePoint between:1 and:255) ifFalse:[
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   660
	"
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   661
	 tried to store a multibyte character
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   662
	"
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   663
	^ self elementBoundsError:aCharacter
299
bc0645db1ab0 *** empty log message ***
claus
parents: 286
diff changeset
   664
    ].
bc0645db1ab0 *** empty log message ***
claus
parents: 286
diff changeset
   665
    "
bc0645db1ab0 *** empty log message ***
claus
parents: 286
diff changeset
   666
     invalid index
bc0645db1ab0 *** empty log message ***
claus
parents: 286
diff changeset
   667
    "
3451
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
   668
    index isInteger ifFalse:[
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   669
	^ self indexNotInteger:index
3451
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
   670
    ].
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5312
diff changeset
   671
    index == super basicSize ifTrue:[
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   672
	^ self subscriptBoundsError:index
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5312
diff changeset
   673
    ].
8093
8ca1e24688d8 Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents: 8049
diff changeset
   674
    super basicAt:index put:aCharacter codePoint.
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   675
    ^ aCharacter
2
claus
parents: 1
diff changeset
   676
! !
claus
parents: 1
diff changeset
   677
3085
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   678
!String methodsFor:'binary storage'!
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   679
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   680
storeBinaryDefinitionOn:stream manager:manager
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   681
    "append a binary representation of the receiver onto stream.
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   682
     Redefined since short Strings can be stored with a special type code
3085
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   683
     in a more compact way.
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   684
     This is an internal interface for the binary storage mechanism."
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   685
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   686
    |myClass myBasicSize|
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   687
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   688
    "/ not for subclasses with named instVars.
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   689
    (myClass := self class) instSize ~~ 0 ifTrue:[
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
   690
	^ super storeBinaryDefinitionOn:stream manager:manager
3085
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   691
    ].
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   692
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   693
    myBasicSize := self basicSize.
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   694
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   695
    "/ can use a more compact representation;
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   696
    "/ but not for subclasses ...
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   697
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   698
    ((myClass == String)
3085
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   699
    and:[myBasicSize <= 255]) ifTrue:[
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
   700
	"/ special encoding: <codeForString> <len> <bytes> ...
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
   701
	stream nextPut:(manager codeForString); nextPut:myBasicSize.
3085
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   702
    ] ifFalse:[
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
   703
	manager putIdOfClass:myClass on:stream.
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
   704
	stream nextNumber:4 put:myBasicSize.
3085
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   705
    ].
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   706
    stream nextPutBytes:myBasicSize from:self startingAt:1.
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   707
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   708
    "Modified: / 2.11.1997 / 15:28:56 / cg"
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   709
! !
772b3e842c88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   710
53
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
   711
!String methodsFor:'character searching'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   712
1950
2378ed1ae467 must fall back to super searchers, when searching
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
   713
identityIndexOf:aCharacter
2378ed1ae467 must fall back to super searchers, when searching
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
   714
    "return the index of the first occurrences of the argument, aCharacter
2378ed1ae467 must fall back to super searchers, when searching
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
   715
     in the receiver or 0 if not found - reimplemented here for speed."
2378ed1ae467 must fall back to super searchers, when searching
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
   716
2378ed1ae467 must fall back to super searchers, when searching
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
   717
%{  /* NOCONTEXT */
2378ed1ae467 must fall back to super searchers, when searching
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
   718
2378ed1ae467 must fall back to super searchers, when searching
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
   719
    REGISTER unsigned char *cp;
6855
5b77935e0872 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6833
diff changeset
   720
    REGISTER unsigned byteValue;
8921
e62bd67efa18 string-with-instvar fix
Claus Gittinger <cg@exept.de>
parents: 8920
diff changeset
   721
#ifdef FAST_MEMCHR
e62bd67efa18 string-with-instvar fix
Claus Gittinger <cg@exept.de>
parents: 8920
diff changeset
   722
    unsigned char *ncp;
e62bd67efa18 string-with-instvar fix
Claus Gittinger <cg@exept.de>
parents: 8920
diff changeset
   723
#else
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
   724
    REGISTER INT index;
1950
2378ed1ae467 must fall back to super searchers, when searching
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
   725
#endif
8915
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   726
    REGISTER int lastIdx;
1950
2378ed1ae467 must fall back to super searchers, when searching
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
   727
    OBJ cls;
2378ed1ae467 must fall back to super searchers, when searching
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
   728
2378ed1ae467 must fall back to super searchers, when searching
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
   729
    if (__isCharacter(aCharacter)) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   730
	byteValue = __intVal(__characterVal(aCharacter));
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   731
	if (byteValue <= 0xFF) {
8915
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   732
	    cp = __stringVal(self);
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   733
	    lastIdx = __stringSize(self);
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   734
	    if ((cls = __qClass(self)) != String) {
8932
Michael Beyl <mb@exept.de>
parents: 8928
diff changeset
   735
		int numInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
Michael Beyl <mb@exept.de>
parents: 8928
diff changeset
   736
Michael Beyl <mb@exept.de>
parents: 8928
diff changeset
   737
		cp += numInstBytes;
8915
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   738
		lastIdx -= numInstBytes;
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   739
	    }
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   740
6331
3cb5595cf170 Strings do not treat 0-bytes as end of string.
Stefan Vogel <sv@exept.de>
parents: 6007
diff changeset
   741
#ifdef FAST_MEMCHR
8921
e62bd67efa18 string-with-instvar fix
Claus Gittinger <cg@exept.de>
parents: 8920
diff changeset
   742
	    ncp = (unsigned char *) memchr(cp, byteValue, lastIdx);
e62bd67efa18 string-with-instvar fix
Claus Gittinger <cg@exept.de>
parents: 8920
diff changeset
   743
	    if (ncp) {
e62bd67efa18 string-with-instvar fix
Claus Gittinger <cg@exept.de>
parents: 8920
diff changeset
   744
		RETURN ( __mkSmallInteger(ncp - cp + 1) );
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   745
	    }
1950
2378ed1ae467 must fall back to super searchers, when searching
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
   746
#else
8915
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   747
	    for (index=1; index <= lastIdx; index++) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
   748
		if (*cp++ == byteValue) { RETURN ( __mkSmallInteger(index) ); }
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   749
	   }
6833
bc361f384f7f care for twoByteChars in all inline-C code
Claus Gittinger <cg@exept.de>
parents: 6830
diff changeset
   750
#endif
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   751
	}
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
   752
	RETURN ( __mkSmallInteger(0));
1950
2378ed1ae467 must fall back to super searchers, when searching
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
   753
    }
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5312
diff changeset
   754
    /* with identity compares, only characters can be in myself */
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
   755
    RETURN ( __mkSmallInteger(0));
1950
2378ed1ae467 must fall back to super searchers, when searching
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
   756
%}.
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5312
diff changeset
   757
    ^ self primitiveFailed
1950
2378ed1ae467 must fall back to super searchers, when searching
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
   758
2378ed1ae467 must fall back to super searchers, when searching
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
   759
    "
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   760
     'hello world' identityIndexOf:(Character space)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   761
     'hello world' identityIndexOf:$d
6331
3cb5595cf170 Strings do not treat 0-bytes as end of string.
Stefan Vogel <sv@exept.de>
parents: 6007
diff changeset
   762
     'hello world' identityIndexOf:1
3cb5595cf170 Strings do not treat 0-bytes as end of string.
Stefan Vogel <sv@exept.de>
parents: 6007
diff changeset
   763
     #[0 0 1 0 0] asString identityIndexOf:(Character value:1)
3cb5595cf170 Strings do not treat 0-bytes as end of string.
Stefan Vogel <sv@exept.de>
parents: 6007
diff changeset
   764
     #[0 0 1 0 0] asString identityIndexOf:(Character value:0)
1950
2378ed1ae467 must fall back to super searchers, when searching
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
   765
    "
2378ed1ae467 must fall back to super searchers, when searching
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
   766
!
2378ed1ae467 must fall back to super searchers, when searching
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
   767
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   768
includes:aCharacter
a27a279701f8 Initial revision
claus
parents:
diff changeset
   769
    "return true if the argument, aCharacter is included in the receiver
a27a279701f8 Initial revision
claus
parents:
diff changeset
   770
     - reimplemented here for speed"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   771
a27a279701f8 Initial revision
claus
parents:
diff changeset
   772
%{  /* NOCONTEXT */
a27a279701f8 Initial revision
claus
parents:
diff changeset
   773
a27a279701f8 Initial revision
claus
parents:
diff changeset
   774
    REGISTER unsigned char *cp;
a27a279701f8 Initial revision
claus
parents:
diff changeset
   775
    REGISTER int byteValue;
6331
3cb5595cf170 Strings do not treat 0-bytes as end of string.
Stefan Vogel <sv@exept.de>
parents: 6007
diff changeset
   776
#ifndef FAST_MEMCHR
8915
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   777
    REGISTER unsigned int index;
6331
3cb5595cf170 Strings do not treat 0-bytes as end of string.
Stefan Vogel <sv@exept.de>
parents: 6007
diff changeset
   778
#endif
8915
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   779
    REGISTER unsigned int lastIdx;
53
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
   780
    OBJ cls;
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   781
53
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
   782
    if (__isCharacter(aCharacter)) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   783
	byteValue = __intVal(__characterVal(aCharacter));
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   784
	if (byteValue <= 0xFF) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   785
	    cp = __stringVal(self);
8915
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   786
	    lastIdx = __stringSize(self);
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   787
	    if ((cls = __qClass(self)) != String) {
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   788
		int numInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   789
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   790
		cp += numInstBytes;
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   791
		lastIdx -= numInstBytes;
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   792
	    }
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   793
6331
3cb5595cf170 Strings do not treat 0-bytes as end of string.
Stefan Vogel <sv@exept.de>
parents: 6007
diff changeset
   794
#ifdef FAST_MEMCHR
8915
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   795
	    if (memchr(cp, byteValue, lastIdx) != NULL) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   796
		RETURN ( true );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   797
	    }
6833
bc361f384f7f care for twoByteChars in all inline-C code
Claus Gittinger <cg@exept.de>
parents: 6830
diff changeset
   798
#else
8932
Michael Beyl <mb@exept.de>
parents: 8928
diff changeset
   799
	    for (index=0; index < lastIdx; index++) {
Michael Beyl <mb@exept.de>
parents: 8928
diff changeset
   800
		if (cp[index] == byteValue) { RETURN ( true ); }
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   801
	    }
6833
bc361f384f7f care for twoByteChars in all inline-C code
Claus Gittinger <cg@exept.de>
parents: 6830
diff changeset
   802
#endif
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   803
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   804
	RETURN (false);
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   805
    }
299
bc0645db1ab0 *** empty log message ***
claus
parents: 286
diff changeset
   806
%}.
1950
2378ed1ae467 must fall back to super searchers, when searching
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
   807
    ^ super includes:aCharacter
53
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
   808
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   809
    "
6331
3cb5595cf170 Strings do not treat 0-bytes as end of string.
Stefan Vogel <sv@exept.de>
parents: 6007
diff changeset
   810
     'hello world' includes:$d
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   811
     'hello world' includes:$o
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   812
     'hello world' includes:$x
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   813
     'hello world' includes:1
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   814
     'hello world' asTwoByteString includes:$o
6331
3cb5595cf170 Strings do not treat 0-bytes as end of string.
Stefan Vogel <sv@exept.de>
parents: 6007
diff changeset
   815
     #[0 0 1 0 0] asString includes:(Character value:1)
3cb5595cf170 Strings do not treat 0-bytes as end of string.
Stefan Vogel <sv@exept.de>
parents: 6007
diff changeset
   816
     #[0 0 1 0 0] asString includes:(Character value:0)
3cb5595cf170 Strings do not treat 0-bytes as end of string.
Stefan Vogel <sv@exept.de>
parents: 6007
diff changeset
   817
     #[1 2 3 4 5] asString includes:(Character value:0)
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   818
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   819
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   820
10
claus
parents: 5
diff changeset
   821
includesAny:aCollection
claus
parents: 5
diff changeset
   822
    "return true, if the receiver includes any of the characters in the
53
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
   823
     argument, aCollection.
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
   824
     - redefined for speed if the argument is a String."
10
claus
parents: 5
diff changeset
   825
claus
parents: 5
diff changeset
   826
%{  /* NOCONTEXT */
claus
parents: 5
diff changeset
   827
claus
parents: 5
diff changeset
   828
    REGISTER unsigned char *cp;
claus
parents: 5
diff changeset
   829
    REGISTER unsigned char *matchP;
53
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
   830
    OBJ cls;
10
claus
parents: 5
diff changeset
   831
53
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
   832
    if (__isString(aCollection)) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   833
	matchP = __stringVal(aCollection);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   834
	cp = __stringVal(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   835
	if ((cls = __qClass(self)) != String)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   836
	    cp += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   837
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   838
	switch (__stringSize(aCollection)) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   839
	    case 3:
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   840
		/* three character search */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   841
		if (strchr(cp, matchP[2])) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   842
		    RETURN ( true );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   843
		}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   844
		/* fall into */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   845
	    case 2:
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   846
		/* two character search */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   847
		if (strchr(cp, matchP[1])) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   848
		    RETURN ( true );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   849
		}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   850
		/* fall into */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   851
	    case 1:
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   852
		/* single character search */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   853
		if (strchr(cp, matchP[0])) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   854
		    RETURN ( true );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   855
		}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   856
		/* fall into */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   857
	    case 0:
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   858
		RETURN ( false );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   859
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   860
	while (*cp) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   861
	    if (strchr(matchP, *cp)) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   862
		RETURN ( true );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   863
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   864
	    cp++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   865
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   866
	RETURN ( false );
10
claus
parents: 5
diff changeset
   867
    }
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5312
diff changeset
   868
%}.
10
claus
parents: 5
diff changeset
   869
    ^ super includesAny:aCollection
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   870
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   871
    "
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   872
     'hello world' includesAny:'abcd'
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   873
     'hello world' includesAny:'xyz'
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   874
     'hello world' includesAny:'xz'
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   875
     'hello world' includesAny:'od'
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   876
     'hello world' includesAny:'xd'
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   877
     'hello world' includesAny:'dx'
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   878
     'hello world' includesAny:(Array with:$a with:$b with:$d)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   879
     'hello world' includesAny:(Array with:$x with:$y)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   880
     'hello world' includesAny:(Array with:1 with:2)
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   881
    "
10
claus
parents: 5
diff changeset
   882
!
claus
parents: 5
diff changeset
   883
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   884
indexOf:aCharacter
a27a279701f8 Initial revision
claus
parents:
diff changeset
   885
    "return the index of the first occurrences of the argument, aCharacter
a27a279701f8 Initial revision
claus
parents:
diff changeset
   886
     in the receiver or 0 if not found - reimplemented here for speed."
a27a279701f8 Initial revision
claus
parents:
diff changeset
   887
a27a279701f8 Initial revision
claus
parents:
diff changeset
   888
%{  /* NOCONTEXT */
a27a279701f8 Initial revision
claus
parents:
diff changeset
   889
a27a279701f8 Initial revision
claus
parents:
diff changeset
   890
    REGISTER unsigned char *cp;
2858
866ffc52ac8a oops - need unsigned character compares
Claus Gittinger <cg@exept.de>
parents: 2856
diff changeset
   891
    REGISTER unsigned byteValue;
8922
ab8665a8c030 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8921
diff changeset
   892
#ifdef FAST_MEMCHR
ab8665a8c030 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8921
diff changeset
   893
    REGISTER unsigned char *ncp;
ab8665a8c030 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8921
diff changeset
   894
#else
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
   895
    REGISTER INT index;
8922
ab8665a8c030 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8921
diff changeset
   896
#endif
6331
3cb5595cf170 Strings do not treat 0-bytes as end of string.
Stefan Vogel <sv@exept.de>
parents: 6007
diff changeset
   897
    REGISTER int last;
53
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
   898
    OBJ cls;
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   899
53
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
   900
    if (__isCharacter(aCharacter)) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   901
	byteValue = __intVal(__characterVal(aCharacter));
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   902
	if (byteValue <= 0xFF) {
8915
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   903
	    cp = __stringVal(self);
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   904
	    last = __stringSize(self);
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   905
	    if ((cls = __qClass(self)) != String) {
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   906
		int numInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   907
8932
Michael Beyl <mb@exept.de>
parents: 8928
diff changeset
   908
		cp += numInstBytes;
8915
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   909
		last -= numInstBytes;
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   910
	    }
6331
3cb5595cf170 Strings do not treat 0-bytes as end of string.
Stefan Vogel <sv@exept.de>
parents: 6007
diff changeset
   911
3cb5595cf170 Strings do not treat 0-bytes as end of string.
Stefan Vogel <sv@exept.de>
parents: 6007
diff changeset
   912
#ifdef FAST_MEMCHR
8922
ab8665a8c030 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8921
diff changeset
   913
	    ncp = (unsigned char *) memchr(cp, byteValue, last);
ab8665a8c030 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8921
diff changeset
   914
	    if (ncp) {
ab8665a8c030 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8921
diff changeset
   915
		RETURN ( __mkSmallInteger(ncp - cp + 1) );
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   916
	    }
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   917
#else
8932
Michael Beyl <mb@exept.de>
parents: 8928
diff changeset
   918
	    for (index=0; index < last; index++) {
Michael Beyl <mb@exept.de>
parents: 8928
diff changeset
   919
		if (cp[index] == byteValue) { RETURN ( __mkSmallInteger(index+1) ); }
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   920
	    }
6833
bc361f384f7f care for twoByteChars in all inline-C code
Claus Gittinger <cg@exept.de>
parents: 6830
diff changeset
   921
#endif
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   922
	}
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
   923
	RETURN ( __mkSmallInteger(0));
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   924
    }
370
claus
parents: 368
diff changeset
   925
%}.
1950
2378ed1ae467 must fall back to super searchers, when searching
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
   926
    ^ super indexOf:aCharacter
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   927
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   928
    "
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   929
     'hello world' indexOf:(Character space)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   930
     'hello world' indexOf:$A
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   931
     'hello world' indexOf:$d
6331
3cb5595cf170 Strings do not treat 0-bytes as end of string.
Stefan Vogel <sv@exept.de>
parents: 6007
diff changeset
   932
     #[0 0 1 0 0] asString indexOf:(Character value:1)
3cb5595cf170 Strings do not treat 0-bytes as end of string.
Stefan Vogel <sv@exept.de>
parents: 6007
diff changeset
   933
     #[0 0 1 0 0] asString indexOf:(Character value:0)
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   934
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   935
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   936
a27a279701f8 Initial revision
claus
parents:
diff changeset
   937
indexOf:aCharacter startingAt:start
a27a279701f8 Initial revision
claus
parents:
diff changeset
   938
    "return the index of the first occurrence of the argument, aCharacter
a27a279701f8 Initial revision
claus
parents:
diff changeset
   939
     in myself starting at start, anInteger or 0 if not found;
a27a279701f8 Initial revision
claus
parents:
diff changeset
   940
     - reimplemented here for speed"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   941
a27a279701f8 Initial revision
claus
parents:
diff changeset
   942
%{  /* NOCONTEXT */
a27a279701f8 Initial revision
claus
parents:
diff changeset
   943
    REGISTER unsigned char *cp;
8923
ba871e13e4f0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8922
diff changeset
   944
#ifdef FAST_MEMCHR
ba871e13e4f0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8922
diff changeset
   945
    REGISTER unsigned char *ncp;
8925
04f0070787ee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8924
diff changeset
   946
#endif
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
   947
    REGISTER INT index;
2858
866ffc52ac8a oops - need unsigned character compares
Claus Gittinger <cg@exept.de>
parents: 2856
diff changeset
   948
    REGISTER unsigned byteValue;
8924
eb2dd7dd459f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8923
diff changeset
   949
    int last;
53
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
   950
    OBJ cls;
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   951
252
   952
    if (__isSmallInteger(start)) {
8927
1ec0cdcbfc8f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8926
diff changeset
   953
	index = __intVal(start);
1ec0cdcbfc8f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8926
diff changeset
   954
	if (index > 0) {
1ec0cdcbfc8f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8926
diff changeset
   955
	    if (__isCharacter(aCharacter)) {
8932
Michael Beyl <mb@exept.de>
parents: 8928
diff changeset
   956
		byteValue = __intVal(_characterVal(aCharacter));
Michael Beyl <mb@exept.de>
parents: 8928
diff changeset
   957
		if (byteValue <= 0xFF) {
8927
1ec0cdcbfc8f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8926
diff changeset
   958
		    last = __stringSize(self);
1ec0cdcbfc8f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8926
diff changeset
   959
		    cp = __stringVal(self);
1ec0cdcbfc8f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8926
diff changeset
   960
		    if ((cls = __qClass(self)) != String) {
8932
Michael Beyl <mb@exept.de>
parents: 8928
diff changeset
   961
			int numInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
Michael Beyl <mb@exept.de>
parents: 8928
diff changeset
   962
Michael Beyl <mb@exept.de>
parents: 8928
diff changeset
   963
			cp += numInstBytes;
Michael Beyl <mb@exept.de>
parents: 8928
diff changeset
   964
			last += numInstBytes;
8927
1ec0cdcbfc8f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8926
diff changeset
   965
		    }
1ec0cdcbfc8f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8926
diff changeset
   966
		    if (index <= last) {
6331
3cb5595cf170 Strings do not treat 0-bytes as end of string.
Stefan Vogel <sv@exept.de>
parents: 6007
diff changeset
   967
#ifdef FAST_MEMCHR
8932
Michael Beyl <mb@exept.de>
parents: 8928
diff changeset
   968
			ncp = (unsigned char *) memchr(cp+index-1, byteValue, last+1-index);
Michael Beyl <mb@exept.de>
parents: 8928
diff changeset
   969
			if (ncp) {
8927
1ec0cdcbfc8f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8926
diff changeset
   970
			    RETURN ( __mkSmallInteger(ncp - cp + 1) );
8932
Michael Beyl <mb@exept.de>
parents: 8928
diff changeset
   971
			}
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   972
#else
8928
e2ca4ffa55b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8927
diff changeset
   973
# ifdef __UNROLL_LOOPS__
8932
Michael Beyl <mb@exept.de>
parents: 8928
diff changeset
   974
			for (; (index+3) <= last; index += 4) {
8928
e2ca4ffa55b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8927
diff changeset
   975
			    if (cp[index-1] == byteValue) { RETURN ( __mkSmallInteger(index) ); }
e2ca4ffa55b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8927
diff changeset
   976
			    if (cp[index-1+1] == byteValue) { RETURN ( __mkSmallInteger(index+1) ); }
e2ca4ffa55b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8927
diff changeset
   977
			    if (cp[index-1+2] == byteValue) { RETURN ( __mkSmallInteger(index+2) ); }
e2ca4ffa55b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8927
diff changeset
   978
			    if (cp[index-1+3] == byteValue) { RETURN ( __mkSmallInteger(index+3) ); }
8932
Michael Beyl <mb@exept.de>
parents: 8928
diff changeset
   979
			}
8928
e2ca4ffa55b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8927
diff changeset
   980
# endif
8932
Michael Beyl <mb@exept.de>
parents: 8928
diff changeset
   981
			for (; index <= last; index++) {
Michael Beyl <mb@exept.de>
parents: 8928
diff changeset
   982
			    if (cp[index-1] == byteValue) {
Michael Beyl <mb@exept.de>
parents: 8928
diff changeset
   983
				RETURN ( __mkSmallInteger(index) );
8928
e2ca4ffa55b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8927
diff changeset
   984
			    }
8932
Michael Beyl <mb@exept.de>
parents: 8928
diff changeset
   985
			}
6833
bc361f384f7f care for twoByteChars in all inline-C code
Claus Gittinger <cg@exept.de>
parents: 6830
diff changeset
   986
#endif
8927
1ec0cdcbfc8f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8926
diff changeset
   987
		    }
8932
Michael Beyl <mb@exept.de>
parents: 8928
diff changeset
   988
		}
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   989
	    }
8927
1ec0cdcbfc8f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8926
diff changeset
   990
	    RETURN ( __mkSmallInteger(0) );
8932
Michael Beyl <mb@exept.de>
parents: 8928
diff changeset
   991
	}
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   992
    }
370
claus
parents: 368
diff changeset
   993
%}.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   994
    ^ super indexOf:aCharacter startingAt:start
53
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
   995
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   996
    "
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   997
     'hello world' indexOf:$0 startingAt:1
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   998
     'hello world' indexOf:$l startingAt:1
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
   999
     'hello world' indexOf:$l startingAt:5
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1000
     'hello world' indexOf:$d startingAt:5
6331
3cb5595cf170 Strings do not treat 0-bytes as end of string.
Stefan Vogel <sv@exept.de>
parents: 6007
diff changeset
  1001
     #[0 0 1 0 0] asString indexOf:(Character value:1) startingAt:1
3cb5595cf170 Strings do not treat 0-bytes as end of string.
Stefan Vogel <sv@exept.de>
parents: 6007
diff changeset
  1002
     #[0 0 1 0 0] asString indexOf:(Character value:0) startingAt:3
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  1003
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1004
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1005
516
17a170eb1112 speedup indexOfAny:startingAt: if arg is a string
Claus Gittinger <cg@exept.de>
parents: 461
diff changeset
  1006
indexOfAny:aCollectionOfCharacters startingAt:start
17a170eb1112 speedup indexOfAny:startingAt: if arg is a string
Claus Gittinger <cg@exept.de>
parents: 461
diff changeset
  1007
    "return the index of the first occurrence of any character in aCollectionOfCharacters,
17a170eb1112 speedup indexOfAny:startingAt: if arg is a string
Claus Gittinger <cg@exept.de>
parents: 461
diff changeset
  1008
     in myself starting at start, anInteger or 0 if not found;
17a170eb1112 speedup indexOfAny:startingAt: if arg is a string
Claus Gittinger <cg@exept.de>
parents: 461
diff changeset
  1009
     - reimplemented here for speed if aCollectionOfCharacters is a string."
17a170eb1112 speedup indexOfAny:startingAt: if arg is a string
Claus Gittinger <cg@exept.de>
parents: 461
diff changeset
  1010
17a170eb1112 speedup indexOfAny:startingAt: if arg is a string
Claus Gittinger <cg@exept.de>
parents: 461
diff changeset
  1011
%{  /* NOCONTEXT */
17a170eb1112 speedup indexOfAny:startingAt: if arg is a string
Claus Gittinger <cg@exept.de>
parents: 461
diff changeset
  1012
17a170eb1112 speedup indexOfAny:startingAt: if arg is a string
Claus Gittinger <cg@exept.de>
parents: 461
diff changeset
  1013
    REGISTER unsigned char *ccp;
17a170eb1112 speedup indexOfAny:startingAt: if arg is a string
Claus Gittinger <cg@exept.de>
parents: 461
diff changeset
  1014
    REGISTER unsigned char *cp;
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  1015
    REGISTER INT index;
2894
344aec8ba014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2887
diff changeset
  1016
    unsigned char *matchP;
8006
04326d8f2410 tuned includesAny
Claus Gittinger <cg@exept.de>
parents: 7895
diff changeset
  1017
    unsigned char c, min, max;
516
17a170eb1112 speedup indexOfAny:startingAt: if arg is a string
Claus Gittinger <cg@exept.de>
parents: 461
diff changeset
  1018
    int len;
17a170eb1112 speedup indexOfAny:startingAt: if arg is a string
Claus Gittinger <cg@exept.de>
parents: 461
diff changeset
  1019
    OBJ cls;
17a170eb1112 speedup indexOfAny:startingAt: if arg is a string
Claus Gittinger <cg@exept.de>
parents: 461
diff changeset
  1020
17a170eb1112 speedup indexOfAny:startingAt: if arg is a string
Claus Gittinger <cg@exept.de>
parents: 461
diff changeset
  1021
    if (__isSmallInteger(start)
17a170eb1112 speedup indexOfAny:startingAt: if arg is a string
Claus Gittinger <cg@exept.de>
parents: 461
diff changeset
  1022
     && __isString(aCollectionOfCharacters)) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1023
	matchP = __stringVal(aCollectionOfCharacters);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1024
	index = __intVal(start);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1025
	if (index <= 0)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1026
	    index = 1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1027
	if ((cls = __qClass(self)) != String)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1028
	    index += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1029
	len = __stringSize(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1030
	if (index <= len) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1031
	    cp = __stringVal(self) + index - 1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1032
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1033
	    if (matchP[0] == 0) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1034
		/* matchSet is empty */
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  1035
		RETURN ( __mkSmallInteger(0) );
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1036
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1037
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1038
	    if (matchP[1] == 0) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1039
		/* only a single character match */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1040
		unsigned char m = matchP[0];
7774
a9e4385a39a7 indexOfAny: tuned
Claus Gittinger <cg@exept.de>
parents: 7746
diff changeset
  1041
8006
04326d8f2410 tuned includesAny
Claus Gittinger <cg@exept.de>
parents: 7895
diff changeset
  1042
#ifdef FAST_MEMCHR
8923
ba871e13e4f0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8922
diff changeset
  1043
		ccp = (unsigned char *) memchr(cp, m, len-index+1);
ba871e13e4f0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8922
diff changeset
  1044
		if (ccp) {
ba871e13e4f0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8922
diff changeset
  1045
		    RETURN ( __mkSmallInteger(ccp - cp + 1) );
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1046
		}
8006
04326d8f2410 tuned includesAny
Claus Gittinger <cg@exept.de>
parents: 7895
diff changeset
  1047
#else
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1048
		while (c = *cp++) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1049
		    if (c == m) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  1050
			RETURN ( __mkSmallInteger(index) );
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1051
		    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1052
		    index++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1053
		}
8006
04326d8f2410 tuned includesAny
Claus Gittinger <cg@exept.de>
parents: 7895
diff changeset
  1054
#endif
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  1055
		RETURN ( __mkSmallInteger(0) );
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1056
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1057
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1058
	    if (matchP[2] == 0) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1059
		/* two character matches */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1060
		unsigned char m1 = matchP[0];
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1061
		unsigned char m2 = matchP[1];
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1062
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1063
		while (c = *cp++) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1064
		    if ((c == m1) || (c == m2)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  1065
			RETURN ( __mkSmallInteger(index) );
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1066
		    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1067
		    index++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1068
		}
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  1069
		RETURN ( __mkSmallInteger(0) );
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1070
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1071
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1072
	    min = max = matchP[0];
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1073
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1074
	    for (ccp = matchP+1; *ccp ; ccp++) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1075
		unsigned char c = *ccp;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1076
		if (c < min) min = c;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1077
		else if (c > max) max = c;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1078
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1079
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1080
	    while (c = *cp++) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1081
		if ((c >= min) && (c <= max)) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1082
		    for (ccp = matchP; *ccp ; ccp++) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1083
			if (*ccp == c) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  1084
			    RETURN ( __mkSmallInteger(index) );
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1085
			}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1086
		    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1087
		}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1088
		index++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1089
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1090
	}
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  1091
	RETURN ( __mkSmallInteger(0) );
516
17a170eb1112 speedup indexOfAny:startingAt: if arg is a string
Claus Gittinger <cg@exept.de>
parents: 461
diff changeset
  1092
    }
17a170eb1112 speedup indexOfAny:startingAt: if arg is a string
Claus Gittinger <cg@exept.de>
parents: 461
diff changeset
  1093
%}.
17a170eb1112 speedup indexOfAny:startingAt: if arg is a string
Claus Gittinger <cg@exept.de>
parents: 461
diff changeset
  1094
    "/
17a170eb1112 speedup indexOfAny:startingAt: if arg is a string
Claus Gittinger <cg@exept.de>
parents: 461
diff changeset
  1095
    "/ fallback: 1st argument not a string or error
17a170eb1112 speedup indexOfAny:startingAt: if arg is a string
Claus Gittinger <cg@exept.de>
parents: 461
diff changeset
  1096
    "/
17a170eb1112 speedup indexOfAny:startingAt: if arg is a string
Claus Gittinger <cg@exept.de>
parents: 461
diff changeset
  1097
    ^ super indexOfAny:aCollectionOfCharacters startingAt:start
17a170eb1112 speedup indexOfAny:startingAt: if arg is a string
Claus Gittinger <cg@exept.de>
parents: 461
diff changeset
  1098
17a170eb1112 speedup indexOfAny:startingAt: if arg is a string
Claus Gittinger <cg@exept.de>
parents: 461
diff changeset
  1099
    "
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1100
     'hello world' indexOfAny:'eoa' startingAt:1
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1101
     'hello world' indexOfAny:'eoa' startingAt:6
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1102
     'hello world' indexOfAny:'AOE' startingAt:1
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1103
     'hello world' indexOfAny:'o' startingAt:6
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1104
     'hello world' indexOfAny:'o' startingAt:6
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1105
     'hello world§' indexOfAny:'#§$' startingAt:6
516
17a170eb1112 speedup indexOfAny:startingAt: if arg is a string
Claus Gittinger <cg@exept.de>
parents: 461
diff changeset
  1106
    "
17a170eb1112 speedup indexOfAny:startingAt: if arg is a string
Claus Gittinger <cg@exept.de>
parents: 461
diff changeset
  1107
!
17a170eb1112 speedup indexOfAny:startingAt: if arg is a string
Claus Gittinger <cg@exept.de>
parents: 461
diff changeset
  1108
3668
76271941f044 added #indexOfControlCharacterStartingAt:
Claus Gittinger <cg@exept.de>
parents: 3651
diff changeset
  1109
indexOfControlCharacterStartingAt:start
76271941f044 added #indexOfControlCharacterStartingAt:
Claus Gittinger <cg@exept.de>
parents: 3651
diff changeset
  1110
    "return the index of the next control character;
76271941f044 added #indexOfControlCharacterStartingAt:
Claus Gittinger <cg@exept.de>
parents: 3651
diff changeset
  1111
     that is a character with asciiValue < 32.
76271941f044 added #indexOfControlCharacterStartingAt:
Claus Gittinger <cg@exept.de>
parents: 3651
diff changeset
  1112
     Return 0 if none is found."
76271941f044 added #indexOfControlCharacterStartingAt:
Claus Gittinger <cg@exept.de>
parents: 3651
diff changeset
  1113
76271941f044 added #indexOfControlCharacterStartingAt:
Claus Gittinger <cg@exept.de>
parents: 3651
diff changeset
  1114
%{  /* NOCONTEXT */
76271941f044 added #indexOfControlCharacterStartingAt:
Claus Gittinger <cg@exept.de>
parents: 3651
diff changeset
  1115
76271941f044 added #indexOfControlCharacterStartingAt:
Claus Gittinger <cg@exept.de>
parents: 3651
diff changeset
  1116
#ifndef NON_ASCII       /* i.e. not EBCDIC ;-) */
76271941f044 added #indexOfControlCharacterStartingAt:
Claus Gittinger <cg@exept.de>
parents: 3651
diff changeset
  1117
    REGISTER unsigned char *cp;
76271941f044 added #indexOfControlCharacterStartingAt:
Claus Gittinger <cg@exept.de>
parents: 3651
diff changeset
  1118
    REGISTER unsigned char c;
3734
5d4e741062bd may not finish search with 0-byte
Claus Gittinger <cg@exept.de>
parents: 3712
diff changeset
  1119
    REGISTER unsigned char *cpEnd;
3668
76271941f044 added #indexOfControlCharacterStartingAt:
Claus Gittinger <cg@exept.de>
parents: 3651
diff changeset
  1120
    int len, index;
76271941f044 added #indexOfControlCharacterStartingAt:
Claus Gittinger <cg@exept.de>
parents: 3651
diff changeset
  1121
    OBJ cls;
76271941f044 added #indexOfControlCharacterStartingAt:
Claus Gittinger <cg@exept.de>
parents: 3651
diff changeset
  1122
76271941f044 added #indexOfControlCharacterStartingAt:
Claus Gittinger <cg@exept.de>
parents: 3651
diff changeset
  1123
    index = __intVal(start);
76271941f044 added #indexOfControlCharacterStartingAt:
Claus Gittinger <cg@exept.de>
parents: 3651
diff changeset
  1124
    if (index <= 0) {
4205
56d69caa8f92 threadsafe printf-defines now in ntIntern.h
Claus Gittinger <cg@exept.de>
parents: 4154
diff changeset
  1125
	index = 1;
3668
76271941f044 added #indexOfControlCharacterStartingAt:
Claus Gittinger <cg@exept.de>
parents: 3651
diff changeset
  1126
    }
76271941f044 added #indexOfControlCharacterStartingAt:
Claus Gittinger <cg@exept.de>
parents: 3651
diff changeset
  1127
    if ((cls = __qClass(self)) != String)
4205
56d69caa8f92 threadsafe printf-defines now in ntIntern.h
Claus Gittinger <cg@exept.de>
parents: 4154
diff changeset
  1128
	index += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
3668
76271941f044 added #indexOfControlCharacterStartingAt:
Claus Gittinger <cg@exept.de>
parents: 3651
diff changeset
  1129
    len = __stringSize(self);
3734
5d4e741062bd may not finish search with 0-byte
Claus Gittinger <cg@exept.de>
parents: 3712
diff changeset
  1130
    cpEnd = __stringVal(self) + len;
5d4e741062bd may not finish search with 0-byte
Claus Gittinger <cg@exept.de>
parents: 3712
diff changeset
  1131
    cp = __stringVal(self) + index - 1;
5d4e741062bd may not finish search with 0-byte
Claus Gittinger <cg@exept.de>
parents: 3712
diff changeset
  1132
    if (cp < cpEnd) {
4205
56d69caa8f92 threadsafe printf-defines now in ntIntern.h
Claus Gittinger <cg@exept.de>
parents: 4154
diff changeset
  1133
	while (cp < cpEnd) {
56d69caa8f92 threadsafe printf-defines now in ntIntern.h
Claus Gittinger <cg@exept.de>
parents: 4154
diff changeset
  1134
	    if (*cp++ < ' ') {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  1135
		RETURN ( __mkSmallInteger(cp - __stringVal(self)) );
4205
56d69caa8f92 threadsafe printf-defines now in ntIntern.h
Claus Gittinger <cg@exept.de>
parents: 4154
diff changeset
  1136
	    }
56d69caa8f92 threadsafe printf-defines now in ntIntern.h
Claus Gittinger <cg@exept.de>
parents: 4154
diff changeset
  1137
	}
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  1138
	RETURN ( __mkSmallInteger(0) );
3668
76271941f044 added #indexOfControlCharacterStartingAt:
Claus Gittinger <cg@exept.de>
parents: 3651
diff changeset
  1139
    }
76271941f044 added #indexOfControlCharacterStartingAt:
Claus Gittinger <cg@exept.de>
parents: 3651
diff changeset
  1140
#endif
76271941f044 added #indexOfControlCharacterStartingAt:
Claus Gittinger <cg@exept.de>
parents: 3651
diff changeset
  1141
%}.
76271941f044 added #indexOfControlCharacterStartingAt:
Claus Gittinger <cg@exept.de>
parents: 3651
diff changeset
  1142
    ^ super indexOfControlCharacterStartingAt:start
76271941f044 added #indexOfControlCharacterStartingAt:
Claus Gittinger <cg@exept.de>
parents: 3651
diff changeset
  1143
76271941f044 added #indexOfControlCharacterStartingAt:
Claus Gittinger <cg@exept.de>
parents: 3651
diff changeset
  1144
    "
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1145
     'hello world'             indexOfControlCharacterStartingAt:1
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1146
     'hello world\foo' withCRs indexOfControlCharacterStartingAt:1
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1147
     '1\' withCRs indexOfControlCharacterStartingAt:1
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1148
     '1\' withCRs indexOfControlCharacterStartingAt:2
3668
76271941f044 added #indexOfControlCharacterStartingAt:
Claus Gittinger <cg@exept.de>
parents: 3651
diff changeset
  1149
    "
76271941f044 added #indexOfControlCharacterStartingAt:
Claus Gittinger <cg@exept.de>
parents: 3651
diff changeset
  1150
!
76271941f044 added #indexOfControlCharacterStartingAt:
Claus Gittinger <cg@exept.de>
parents: 3651
diff changeset
  1151
3403
904b613bfc7b checkin from browser
ca
parents: 3376
diff changeset
  1152
indexOfNonSeparatorStartingAt:start
904b613bfc7b checkin from browser
ca
parents: 3376
diff changeset
  1153
    "return the index of the next non-whiteSpace character"
904b613bfc7b checkin from browser
ca
parents: 3376
diff changeset
  1154
904b613bfc7b checkin from browser
ca
parents: 3376
diff changeset
  1155
%{  /* NOCONTEXT */
904b613bfc7b checkin from browser
ca
parents: 3376
diff changeset
  1156
904b613bfc7b checkin from browser
ca
parents: 3376
diff changeset
  1157
    REGISTER unsigned char *cp;
904b613bfc7b checkin from browser
ca
parents: 3376
diff changeset
  1158
    REGISTER unsigned char c;
904b613bfc7b checkin from browser
ca
parents: 3376
diff changeset
  1159
    int len, index;
904b613bfc7b checkin from browser
ca
parents: 3376
diff changeset
  1160
    OBJ cls;
904b613bfc7b checkin from browser
ca
parents: 3376
diff changeset
  1161
904b613bfc7b checkin from browser
ca
parents: 3376
diff changeset
  1162
    index = __intVal(start);
904b613bfc7b checkin from browser
ca
parents: 3376
diff changeset
  1163
    if (index <= 0) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1164
	index = 1;
3403
904b613bfc7b checkin from browser
ca
parents: 3376
diff changeset
  1165
    }
904b613bfc7b checkin from browser
ca
parents: 3376
diff changeset
  1166
    if ((cls = __qClass(self)) != String)
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1167
	index += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
3403
904b613bfc7b checkin from browser
ca
parents: 3376
diff changeset
  1168
    len = __stringSize(self);
904b613bfc7b checkin from browser
ca
parents: 3376
diff changeset
  1169
    if (index > len) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  1170
	RETURN ( __mkSmallInteger(0) );
3403
904b613bfc7b checkin from browser
ca
parents: 3376
diff changeset
  1171
    }
904b613bfc7b checkin from browser
ca
parents: 3376
diff changeset
  1172
    cp = __stringVal(self) + index - 1;
904b613bfc7b checkin from browser
ca
parents: 3376
diff changeset
  1173
    while (c = *cp++) {
904b613bfc7b checkin from browser
ca
parents: 3376
diff changeset
  1174
#ifndef NON_ASCII       /* i.e. EBCDIC ;-) */
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1175
	if (c > ' ')
3403
904b613bfc7b checkin from browser
ca
parents: 3376
diff changeset
  1176
#endif
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1177
	if ((c != ' ') && (c != '\t') && (c != '\n')
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1178
	 && (c != '\r') && (c != '\f')) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  1179
	    RETURN ( __mkSmallInteger(cp - __stringVal(self)) );
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1180
	}
3403
904b613bfc7b checkin from browser
ca
parents: 3376
diff changeset
  1181
    }
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  1182
    RETURN ( __mkSmallInteger(0) );
3403
904b613bfc7b checkin from browser
ca
parents: 3376
diff changeset
  1183
%}.
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5312
diff changeset
  1184
    ^ super indexOfNonSeparatorStartingAt:start
3403
904b613bfc7b checkin from browser
ca
parents: 3376
diff changeset
  1185
904b613bfc7b checkin from browser
ca
parents: 3376
diff changeset
  1186
    "
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1187
     'hello world' indexOfNonWhiteSpaceStartingAt:3
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1188
     'hello world' indexOfNonWhiteSpaceStartingAt:7
3403
904b613bfc7b checkin from browser
ca
parents: 3376
diff changeset
  1189
    "
904b613bfc7b checkin from browser
ca
parents: 3376
diff changeset
  1190
!
904b613bfc7b checkin from browser
ca
parents: 3376
diff changeset
  1191
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1192
indexOfSeparatorStartingAt:start
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1193
    "return the index of the next separator character"
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1194
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1195
%{  /* NOCONTEXT */
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1196
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1197
    REGISTER unsigned char *cp;
2858
866ffc52ac8a oops - need unsigned character compares
Claus Gittinger <cg@exept.de>
parents: 2856
diff changeset
  1198
    REGISTER unsigned char c;
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1199
    int len, index;
53
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
  1200
    OBJ cls;
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1201
1134
7cb7cd7ebeb8 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1019
diff changeset
  1202
    index = __intVal(start);
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1203
    if (index <= 0) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1204
	index = 1;
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1205
    }
329
claus
parents: 314
diff changeset
  1206
    if ((cls = __qClass(self)) != String)
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1207
	index += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
1134
7cb7cd7ebeb8 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1019
diff changeset
  1208
    len = __stringSize(self);
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1209
    if (index > len) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  1210
	RETURN ( __mkSmallInteger(0) );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1211
    }
1134
7cb7cd7ebeb8 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1019
diff changeset
  1212
    cp = __stringVal(self) + index - 1;
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1213
    while (c = *cp++) {
329
claus
parents: 314
diff changeset
  1214
#ifndef NON_ASCII       /* i.e. EBCDIC ;-) */
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1215
	if (c <= ' ')
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1216
#endif
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1217
	if ((c == ' ') || (c == '\t') || (c == '\n')
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1218
	 || (c == '\r') || (c == '\f')) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  1219
	    RETURN ( __mkSmallInteger(cp - __stringVal(self)) );
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1220
	}
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1221
    }
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  1222
    RETURN ( __mkSmallInteger(0) );
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5312
diff changeset
  1223
%}.
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5312
diff changeset
  1224
    ^ super indexOfSeparatorStartingAt:start
53
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
  1225
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  1226
    "
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1227
     'hello world' indexOfSeparatorStartingAt:3
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1228
     'hello world' indexOfSeparatorStartingAt:7
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  1229
    "
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1230
!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1231
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1232
occurrencesOf:aCharacter
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1233
    "count the occurrences of the argument, aCharacter in myself
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1234
      - reimplemented here for speed"
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1235
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1236
%{  /* NOCONTEXT */
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1237
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1238
    REGISTER unsigned char *cp;
2858
866ffc52ac8a oops - need unsigned character compares
Claus Gittinger <cg@exept.de>
parents: 2856
diff changeset
  1239
    REGISTER unsigned byteValue;
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  1240
    REGISTER INT count, limit;
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1241
    OBJ cls;
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1242
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1243
    if (__isCharacter(aCharacter)) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1244
	limit = __stringSize(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1245
	count = 0;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1246
	byteValue = __intVal(_characterVal(aCharacter));
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1247
	if (byteValue <= 0xFF) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1248
	    cp = __stringVal(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1249
	    if ((cls = __qClass(self)) != String) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1250
		int n = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1251
		limit -= n;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1252
		cp += n;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1253
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1254
	    while (limit > 0) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1255
		limit--;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1256
		if (*cp++ == byteValue) count++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1257
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1258
	}
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  1259
	RETURN ( __mkSmallInteger(count) );
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1260
    }
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1261
%}.
1950
2378ed1ae467 must fall back to super searchers, when searching
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  1262
    ^ super occurrencesOf:aCharacter
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1263
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1264
    "
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1265
     'hello world' occurrencesOf:$a
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1266
     'hello world' occurrencesOf:$w
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1267
     'hello world' occurrencesOf:$l
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1268
     'hello world' occurrencesOf:$x
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1269
     'hello world' occurrencesOf:1
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1270
    "
53
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
  1271
! !
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
  1272
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1273
!String methodsFor:'comparing'!
2
claus
parents: 1
diff changeset
  1274
8312
c7a80959b9a1 Define #<
Stefan Vogel <sv@exept.de>
parents: 8295
diff changeset
  1275
< aString
c7a80959b9a1 Define #<
Stefan Vogel <sv@exept.de>
parents: 8295
diff changeset
  1276
    "Compare the receiver with the argument and return true if the
c7a80959b9a1 Define #<
Stefan Vogel <sv@exept.de>
parents: 8295
diff changeset
  1277
     receiver is greater than the argument. Otherwise return false.
c7a80959b9a1 Define #<
Stefan Vogel <sv@exept.de>
parents: 8295
diff changeset
  1278
     No national variants are honored; use after: for this.
c7a80959b9a1 Define #<
Stefan Vogel <sv@exept.de>
parents: 8295
diff changeset
  1279
     In contrast to ST-80, case differences are NOT ignored, thus
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1280
     'foo' < 'Foo' will return false.
8312
c7a80959b9a1 Define #<
Stefan Vogel <sv@exept.de>
parents: 8295
diff changeset
  1281
     This may change."
c7a80959b9a1 Define #<
Stefan Vogel <sv@exept.de>
parents: 8295
diff changeset
  1282
c7a80959b9a1 Define #<
Stefan Vogel <sv@exept.de>
parents: 8295
diff changeset
  1283
%{  /* NOCONTEXT */
c7a80959b9a1 Define #<
Stefan Vogel <sv@exept.de>
parents: 8295
diff changeset
  1284
c7a80959b9a1 Define #<
Stefan Vogel <sv@exept.de>
parents: 8295
diff changeset
  1285
    int len1, len2, cmp;
c7a80959b9a1 Define #<
Stefan Vogel <sv@exept.de>
parents: 8295
diff changeset
  1286
    REGISTER OBJ s = aString;
c7a80959b9a1 Define #<
Stefan Vogel <sv@exept.de>
parents: 8295
diff changeset
  1287
    unsigned char *cp1, *cp2;
c7a80959b9a1 Define #<
Stefan Vogel <sv@exept.de>
parents: 8295
diff changeset
  1288
    OBJ cls;
c7a80959b9a1 Define #<
Stefan Vogel <sv@exept.de>
parents: 8295
diff changeset
  1289
    OBJ myCls;
c7a80959b9a1 Define #<
Stefan Vogel <sv@exept.de>
parents: 8295
diff changeset
  1290
c7a80959b9a1 Define #<
Stefan Vogel <sv@exept.de>
parents: 8295
diff changeset
  1291
    if (__isNonNilObject(s)) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1292
	cls = __qClass(s);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1293
	myCls = __qClass(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1294
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1295
	if ((cls == String) || (cls == Symbol) || (cls == myCls)) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1296
	    cp2 = __stringVal(s);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1297
	    len2 = __stringSize(s);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1298
	    /*
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1299
	     * care for instances of subclasses ...
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1300
	     */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1301
	    if (cls != String) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1302
		int n = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1303
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1304
		cp2 += n;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1305
		len2 -= n;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1306
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1307
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1308
	    cp1 = __stringVal(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1309
	    len1 = __stringSize(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1310
	    /*
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1311
	     * care for instances of subclasses ...
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1312
	     */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1313
	    if (myCls != String) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1314
		int n = __OBJS2BYTES__(__intVal(__ClassInstPtr(myCls)->c_ninstvars));
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1315
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1316
		cp1 += n;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1317
		len1 -= n;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1318
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1319
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1320
	    if (len1 <= len2)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1321
		cmp = strncmp(cp1, cp2, len1);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1322
	    else
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1323
		cmp = strncmp(cp1, cp2, len2);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1324
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1325
	    if (cmp < 0) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1326
		RETURN ( true );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1327
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1328
	    if ((cmp == 0) && (len1 < len2)) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1329
		RETURN ( true );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1330
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1331
	    RETURN ( false );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1332
	}
8312
c7a80959b9a1 Define #<
Stefan Vogel <sv@exept.de>
parents: 8295
diff changeset
  1333
    }
c7a80959b9a1 Define #<
Stefan Vogel <sv@exept.de>
parents: 8295
diff changeset
  1334
%}.
c7a80959b9a1 Define #<
Stefan Vogel <sv@exept.de>
parents: 8295
diff changeset
  1335
    ^ super < aString
c7a80959b9a1 Define #<
Stefan Vogel <sv@exept.de>
parents: 8295
diff changeset
  1336
!
c7a80959b9a1 Define #<
Stefan Vogel <sv@exept.de>
parents: 8295
diff changeset
  1337
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1338
= aString
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1339
    "Compare the receiver with the argument and return true if the
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1340
     receiver is equal to the argument. Otherwise return false.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1341
     This compare is case-sensitive (i.e. 'Foo' is NOT = 'foo').
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1342
     Use sameAs: to compare with case ignored."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1343
375
claus
parents: 370
diff changeset
  1344
%{  /* NOCONTEXT */
claus
parents: 370
diff changeset
  1345
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1346
    int l1, l2;
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1347
    REGISTER OBJ s = aString;
3314
94046261fba0 tuned #~= , #= and #startsWith:
Claus Gittinger <cg@exept.de>
parents: 3281
diff changeset
  1348
    unsigned char *cp1, *cp2;
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1349
    OBJ cls;
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1350
    OBJ myCls;
3335
054b52565a69 oops - need INT for delta
Claus Gittinger <cg@exept.de>
parents: 3314
diff changeset
  1351
    INT addrDelta;
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1352
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1353
    if (s == self) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1354
	RETURN ( true );
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1355
    }
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1356
    if (! __isNonNilObject(s)) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1357
	RETURN ( false );
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1358
    }
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1359
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1360
    cls = __qClass(s);
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1361
    myCls = __qClass(self);
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1362
7868
15204449d62c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7867
diff changeset
  1363
    if ((cls == myCls) || (cls == String) || (cls == Symbol)) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1364
	cp2 = __stringVal(s);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1365
	l2 = __stringSize(s);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1366
	/*
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1367
	 * care for instances of subclasses ...
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1368
	 */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1369
	if (cls != String) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1370
	    int n = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1371
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1372
	    cp2 += n;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1373
	    l2 -= n;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1374
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1375
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1376
	cp1 = __stringVal(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1377
	l1 = __stringSize(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1378
	/*
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1379
	 * care for instances of subclasses ...
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1380
	 */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1381
	if (myCls != String) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1382
	    int n = __OBJS2BYTES__(__intVal(__ClassInstPtr(myCls)->c_ninstvars));
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1383
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1384
	    cp1 += n;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1385
	    l1 -= n;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1386
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1387
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1388
	if (l1 != l2) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1389
	    RETURN ( false );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1390
	}
6331
3cb5595cf170 Strings do not treat 0-bytes as end of string.
Stefan Vogel <sv@exept.de>
parents: 6007
diff changeset
  1391
#ifdef FAST_MEMCMP
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1392
	RETURN ( (memcmp(cp1, cp2, l1) == 0) ? true : false );
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1393
#else
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1394
	addrDelta = cp2 - cp1;
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8917
diff changeset
  1395
# ifdef __UNROLL_LOOPS__
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1396
	while (l1 >= (sizeof(unsigned INT)*4)) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1397
	    if (((unsigned INT *)cp1)[0] != ((unsigned INT *)(cp1+addrDelta))[0]) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1398
		RETURN (false);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1399
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1400
	    if (((unsigned INT *)cp1)[1] != ((unsigned INT *)(cp1+addrDelta))[1]) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1401
		RETURN (false);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1402
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1403
	    if (((unsigned INT *)cp1)[2] != ((unsigned INT *)(cp1+addrDelta))[2]) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1404
		RETURN (false);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1405
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1406
	    if (((unsigned INT *)cp1)[3] != ((unsigned INT *)(cp1+addrDelta))[3]) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1407
		RETURN (false);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1408
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1409
	    l1 -= (sizeof(unsigned INT) * 4);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1410
	    cp1 += (sizeof(unsigned INT) * 4);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1411
	}
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8917
diff changeset
  1412
# endif /* __UNROLL_LOOPS__ */
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1413
	while (l1 >= sizeof(unsigned INT)) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1414
	    if (*((unsigned INT *)cp1) != *((unsigned INT *)(cp1+addrDelta))) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1415
		RETURN (false);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1416
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1417
	    l1 -= sizeof(unsigned INT);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1418
	    cp1 += sizeof(unsigned INT);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1419
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1420
	if (l1 >= sizeof(unsigned short)) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1421
	    if (*((unsigned short *)cp1) != *((unsigned short *)(cp1+addrDelta))) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1422
		RETURN (false);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1423
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1424
	    l1 -= sizeof(unsigned short);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1425
	    cp1 += sizeof(unsigned short);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1426
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1427
	while (l1) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1428
	    if (*cp1 != *(cp1+addrDelta)) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1429
		RETURN (false);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1430
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1431
	    l1--;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1432
	    cp1++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1433
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1434
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1435
	RETURN (true);
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1436
#endif
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1437
    }
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1438
%}.
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1439
    ^ super = aString
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1440
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  1441
    "
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1442
     'foo' = 'Foo'
6331
3cb5595cf170 Strings do not treat 0-bytes as end of string.
Stefan Vogel <sv@exept.de>
parents: 6007
diff changeset
  1443
     'foo' sameAs: 'Foo'
3cb5595cf170 Strings do not treat 0-bytes as end of string.
Stefan Vogel <sv@exept.de>
parents: 6007
diff changeset
  1444
     #[0 0 1 0 0] asString = #[0 0 1 0 0] asString
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  1445
    "
7868
15204449d62c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7867
diff changeset
  1446
    "
15204449d62c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7867
diff changeset
  1447
     |tEmpty tCmp|
15204449d62c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7867
diff changeset
  1448
15204449d62c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7867
diff changeset
  1449
     tEmpty := Time millisecondsToRun:[
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1450
	 1000000 timesRepeat:[]
7868
15204449d62c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7867
diff changeset
  1451
     ].
15204449d62c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7867
diff changeset
  1452
     tCmp := Time millisecondsToRun:[
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1453
	 1000000 timesRepeat:[ '1234567890' = '1234567890' ]
7868
15204449d62c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7867
diff changeset
  1454
     ].
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1455
     tCmp - tEmpty
7868
15204449d62c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7867
diff changeset
  1456
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1457
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1458
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1459
> aString
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1460
    "Compare the receiver with the argument and return true if the
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1461
     receiver is greater than the argument. Otherwise return false.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1462
     No national variants are honored; use after: for this.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1463
     In contrast to ST-80, case differences are NOT ignored, thus
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1464
     'foo' > 'Foo' will return true.
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1465
     This may change."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1466
375
claus
parents: 370
diff changeset
  1467
%{  /* NOCONTEXT */
claus
parents: 370
diff changeset
  1468
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1469
    int len1, len2, cmp;
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1470
    REGISTER OBJ s = aString;
2858
866ffc52ac8a oops - need unsigned character compares
Claus Gittinger <cg@exept.de>
parents: 2856
diff changeset
  1471
    unsigned char *cp1, *cp2;
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1472
    OBJ cls;
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1473
    OBJ myCls;
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1474
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1475
    if (__isNonNilObject(s)) {
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1476
	cls = __qClass(s);
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1477
	myCls = __qClass(self);
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1478
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1479
	if ((cls == String) || (cls == Symbol) || (cls == myCls)) {
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1480
	    cp2 = __stringVal(s);
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1481
	    len2 = __stringSize(s);
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1482
	    /*
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1483
	     * care for instances of subclasses ...
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1484
	     */
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1485
	    if (cls != String) {
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1486
		int n = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1487
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1488
		cp2 += n;
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1489
		len2 -= n;
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1490
	    }
375
claus
parents: 370
diff changeset
  1491
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1492
	    cp1 = __stringVal(self);
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1493
	    len1 = __stringSize(self);
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1494
	    /*
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1495
	     * care for instances of subclasses ...
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1496
	     */
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1497
	    if (myCls != String) {
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1498
		int n = __OBJS2BYTES__(__intVal(__ClassInstPtr(myCls)->c_ninstvars));
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1499
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1500
		cp1 += n;
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1501
		len1 -= n;
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1502
	    }
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1503
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1504
	    if (len1 <= len2)
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1505
		cmp = strncmp(cp1, cp2, len1);
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1506
	    else
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1507
		cmp = strncmp(cp1, cp2, len2);
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1508
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1509
	    if (cmp > 0) {
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1510
		RETURN ( true );
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1511
	    }
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1512
	    if ((cmp == 0) && (len1 > len2)) {
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1513
		RETURN ( true );
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1514
	    }
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1515
	    RETURN ( false );
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1516
	}
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1517
    }
370
claus
parents: 368
diff changeset
  1518
%}.
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1519
    ^ super > aString
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1520
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1521
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1522
after:aString
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1523
    "Compare the receiver with the argument and return true if the
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1524
     receiver should come after the argument in a sorted list.
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1525
     Otherwise return false.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1526
     The comparison is language specific, depending on the value of
1368
2b21ccc98e5e comment in #after:
Claus Gittinger <cg@exept.de>
parents: 1311
diff changeset
  1527
     LC_COLLATE, which is initialized from the environment.
2b21ccc98e5e comment in #after:
Claus Gittinger <cg@exept.de>
parents: 1311
diff changeset
  1528
2b21ccc98e5e comment in #after:
Claus Gittinger <cg@exept.de>
parents: 1311
diff changeset
  1529
     STUPID:
1486
60c770ac10eb dont access stdout on WIN32
Claus Gittinger <cg@exept.de>
parents: 1399
diff changeset
  1530
	#after has a completely different meaning in SeqColl ..."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1531
1251
9a76f8683400 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1246
diff changeset
  1532
    ^ (self compareCollatingWith:aString) > 0
9a76f8683400 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1246
diff changeset
  1533
1368
2b21ccc98e5e comment in #after:
Claus Gittinger <cg@exept.de>
parents: 1311
diff changeset
  1534
    "Modified: 10.5.1996 / 14:02:45 / cg"
1251
9a76f8683400 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1246
diff changeset
  1535
!
9a76f8683400 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1246
diff changeset
  1536
9a76f8683400 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1246
diff changeset
  1537
compareCollatingWith:aString
9a76f8683400 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1246
diff changeset
  1538
    "Compare the receiver with the argument and return 1 if the receiver is
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1539
     greater, 0 if equal and -1 if less than the argument in a sorted list.
1251
9a76f8683400 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1246
diff changeset
  1540
     The comparison is language specific, depending on the value of
9a76f8683400 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1246
diff changeset
  1541
     LC_COLLATE, which is in the shell environment."
9a76f8683400 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1246
diff changeset
  1542
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1543
%{  /* NOCONTEXT */
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1544
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1545
    int cmp;
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1546
    REGISTER OBJ s = aString;
2858
866ffc52ac8a oops - need unsigned character compares
Claus Gittinger <cg@exept.de>
parents: 2856
diff changeset
  1547
    unsigned char *cp1, *cp2;
53
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
  1548
    OBJ cls;
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1549
    OBJ myCls;
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1550
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1551
    if (__isNonNilObject(s)) {
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1552
	cls = __qClass(s);
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1553
	myCls = __qClass(self);
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1554
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1555
	if ((cls == String) || (cls == Symbol) || (cls == myCls)) {
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1556
	    cp1 = __stringVal(self);
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1557
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1558
	    /*
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1559
	     * care for instances of subclasses ...
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1560
	     */
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1561
	    if (myCls != String) {
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1562
		int n = __OBJS2BYTES__(__intVal(__ClassInstPtr(myCls)->c_ninstvars));
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1563
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1564
		cp1 += n;
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1565
	    }
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1566
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1567
	    cp2 = __stringVal(s);
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1568
	    /*
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1569
	     * care for instances of subclasses ...
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1570
	     */
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1571
	    if (cls != String) {
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1572
		int n = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1573
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1574
		cp2 += n;
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1575
	    }
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1576
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1577
#ifdef HAS_STRCOLL
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1578
	    cmp = strcoll(cp1, cp2);
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1579
#else
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1580
	    cmp = strcmp(cp1, cp2);
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1581
#endif
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1582
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1583
	    if (cmp > 0) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  1584
		RETURN ( __mkSmallInteger(1) );
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1585
	    }
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1586
	    if (cmp < 0) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  1587
		RETURN ( __mkSmallInteger(-1) );
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1588
	    }
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  1589
	    RETURN ( __mkSmallInteger(0) );
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1590
	}
370
claus
parents: 368
diff changeset
  1591
    }
329
claus
parents: 314
diff changeset
  1592
%}.
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1593
    "
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1594
     currently, this operation is only defined for strings, symbols
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1595
     and subclasses.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1596
    "
1251
9a76f8683400 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1246
diff changeset
  1597
    ^ self primitiveFailed
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1598
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1599
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1600
~= aString
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1601
    "Compare the receiver with the argument and return true if the
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1602
     receiver is not equal to the argument. Otherwise return false.
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1603
     This compare is case-sensitive (i.e. 'Foo' is NOT = 'foo').
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1604
     Actually, there is no need to redefine that method here,
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1605
     the default (= not as inherited) works ok.
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1606
     However, this may be heavily used and the redefinition saves an
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1607
     extra message send."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1608
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1609
%{  /* NOCONTEXT */
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1610
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1611
    int l1, l2;
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1612
    REGISTER OBJ s = aString;
3314
94046261fba0 tuned #~= , #= and #startsWith:
Claus Gittinger <cg@exept.de>
parents: 3281
diff changeset
  1613
    unsigned char *cp1, *cp2;
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1614
    OBJ cls, myCls;
3335
054b52565a69 oops - need INT for delta
Claus Gittinger <cg@exept.de>
parents: 3314
diff changeset
  1615
    INT addrDelta;
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1616
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1617
    if (s == self) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1618
	RETURN ( false );
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1619
    }
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1620
    if (! __isNonNilObject(s)) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1621
	RETURN ( true );
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1622
    }
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1623
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1624
    cls = __qClass(s);
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1625
    myCls = __qClass(self);
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1626
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1627
    if ((cls == String) || (cls == Symbol) || (cls == myCls)) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1628
	cp1 = __stringVal(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1629
	l1 = __stringSize(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1630
	/*
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1631
	 * care for instances of subclasses ...
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1632
	 */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1633
	if (myCls != String) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1634
	    int n = __OBJS2BYTES__(__intVal(__ClassInstPtr(myCls)->c_ninstvars));
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1635
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1636
	    cp1 += n;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1637
	    l1 -= n;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1638
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1639
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1640
	cp2 = __stringVal(s);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1641
	l2 = __stringSize(s);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1642
	/*
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1643
	 * care for instances of subclasses ...
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1644
	 */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1645
	if (cls != String) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1646
	    int n = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1647
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1648
	    cp2 += n;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1649
	    l2 -= n;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1650
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1651
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1652
	if (l1 != l2) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1653
	    RETURN ( true );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1654
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1655
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1656
	addrDelta = cp2 - cp1;
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8917
diff changeset
  1657
# ifdef __UNROLL_LOOPS__
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1658
	while (l1 >= (sizeof(unsigned INT)*4)) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1659
	    if (((unsigned INT *)cp1)[0] != ((unsigned INT *)(cp1+addrDelta))[0]) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1660
		RETURN (true);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1661
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1662
	    if (((unsigned INT *)cp1)[1] != ((unsigned INT *)(cp1+addrDelta))[1]) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1663
		RETURN (true);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1664
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1665
	    if (((unsigned INT *)cp1)[2] != ((unsigned INT *)(cp1+addrDelta))[2]) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1666
		RETURN (true);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1667
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1668
	    if (((unsigned INT *)cp1)[3] != ((unsigned INT *)(cp1+addrDelta))[3]) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1669
		RETURN (true);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1670
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1671
	    l1 -= (sizeof(unsigned INT) * 4);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1672
	    cp1 += (sizeof(unsigned INT) * 4);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1673
	}
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8917
diff changeset
  1674
# endif /* __UNROLL_LOOPS__ */
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1675
	while (l1 >= sizeof(unsigned INT)) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1676
	    if (*((unsigned INT *)cp1) != *((unsigned INT *)(cp1+addrDelta))) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1677
		RETURN (true);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1678
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1679
	    l1 -= sizeof(unsigned INT);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1680
	    cp1 += sizeof(unsigned INT);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1681
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1682
	if (l1 >= sizeof(unsigned short)) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1683
	    if (*((unsigned short *)cp1) != *((unsigned short *)(cp1+addrDelta))) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1684
		RETURN (true);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1685
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1686
	    l1 -= sizeof(unsigned short);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1687
	    cp1 += sizeof(unsigned short);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1688
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1689
	while (l1) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1690
	    if (*cp1 != *(cp1+addrDelta)) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1691
		RETURN (true);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1692
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1693
	    l1--;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1694
	    cp1++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1695
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1696
	RETURN (false);
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1697
    }
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  1698
%}.
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1699
    ^ super ~= aString
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1700
! !
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1701
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1702
!String methodsFor:'converting'!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1703
6830
97b046007438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6828
diff changeset
  1704
asArrayOfSubstrings
97b046007438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6828
diff changeset
  1705
	"Answer an array with all the substrings of the receiver separated by
97b046007438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6828
diff changeset
  1706
	separator characters (space, cr, tab, linefeed, formfeed, etc)."
97b046007438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6828
diff changeset
  1707
97b046007438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6828
diff changeset
  1708
	| substrings start end |
97b046007438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6828
diff changeset
  1709
	substrings _ OrderedCollection new.
97b046007438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6828
diff changeset
  1710
	start _ 1.
97b046007438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6828
diff changeset
  1711
	[start <= self size] whileTrue: [
97b046007438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6828
diff changeset
  1712
		(self at: start) isSeparator ifFalse: [
97b046007438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6828
diff changeset
  1713
			end _ start + 1.
97b046007438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6828
diff changeset
  1714
			[end <= self size and: [(self at: end) isSeparator not]]
97b046007438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6828
diff changeset
  1715
				whileTrue: [end _ end + 1].
97b046007438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6828
diff changeset
  1716
			substrings add: (self copyFrom: start to: end - 1).
97b046007438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6828
diff changeset
  1717
			start _ end - 1].
97b046007438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6828
diff changeset
  1718
		start _ start + 1].
97b046007438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6828
diff changeset
  1719
	^ substrings asArray
97b046007438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6828
diff changeset
  1720
!
97b046007438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6828
diff changeset
  1721
3281
d108dee000f7 #asBoldText added for often used bold texts in dialogs, etc.
tz
parents: 3234
diff changeset
  1722
asBoldText
d108dee000f7 #asBoldText added for often used bold texts in dialogs, etc.
tz
parents: 3234
diff changeset
  1723
    "return self as a bold text"
d108dee000f7 #asBoldText added for often used bold texts in dialogs, etc.
tz
parents: 3234
diff changeset
  1724
d108dee000f7 #asBoldText added for often used bold texts in dialogs, etc.
tz
parents: 3234
diff changeset
  1725
    ^Text string: self emphasis: #bold
d108dee000f7 #asBoldText added for often used bold texts in dialogs, etc.
tz
parents: 3234
diff changeset
  1726
!
d108dee000f7 #asBoldText added for often used bold texts in dialogs, etc.
tz
parents: 3234
diff changeset
  1727
7877
bef56f06d2f8 asOneByteString -> asSingleByteString
Claus Gittinger <cg@exept.de>
parents: 7869
diff changeset
  1728
asSingleByteString
5760
00f393f89464 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5746
diff changeset
  1729
    "I am a string"
00f393f89464 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5746
diff changeset
  1730
00f393f89464 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5746
diff changeset
  1731
    ^ self
00f393f89464 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5746
diff changeset
  1732
!
00f393f89464 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5746
diff changeset
  1733
7878
0e88e1019955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7877
diff changeset
  1734
asSingleByteStringReplaceInvalidWith:replacementCharacter
0e88e1019955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7877
diff changeset
  1735
    "I am a string"
0e88e1019955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7877
diff changeset
  1736
0e88e1019955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7877
diff changeset
  1737
    ^ self
0e88e1019955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7877
diff changeset
  1738
!
0e88e1019955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7877
diff changeset
  1739
2856
70fe48053cf1 Define #asString.
Stefan Vogel <sv@exept.de>
parents: 2680
diff changeset
  1740
asString
70fe48053cf1 Define #asString.
Stefan Vogel <sv@exept.de>
parents: 2680
diff changeset
  1741
    "I am a string"
70fe48053cf1 Define #asString.
Stefan Vogel <sv@exept.de>
parents: 2680
diff changeset
  1742
70fe48053cf1 Define #asString.
Stefan Vogel <sv@exept.de>
parents: 2680
diff changeset
  1743
    ^ self
70fe48053cf1 Define #asString.
Stefan Vogel <sv@exept.de>
parents: 2680
diff changeset
  1744
70fe48053cf1 Define #asString.
Stefan Vogel <sv@exept.de>
parents: 2680
diff changeset
  1745
    "Created: 14.8.1997 / 11:37:03 / stefan"
70fe48053cf1 Define #asString.
Stefan Vogel <sv@exept.de>
parents: 2680
diff changeset
  1746
!
70fe48053cf1 Define #asString.
Stefan Vogel <sv@exept.de>
parents: 2680
diff changeset
  1747
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1748
asSymbol
3710
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  1749
    "return a unique symbol with the name taken from my characters."
7869
597a8faaf603 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7868
diff changeset
  1750
597a8faaf603 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7868
diff changeset
  1751
%{  /* NOCONTEXT */
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1752
    OBJ newSymbol;
3710
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  1753
    OBJ cls;
7869
597a8faaf603 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7868
diff changeset
  1754
    char *cp = __stringVal(self);
597a8faaf603 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7868
diff changeset
  1755
597a8faaf603 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7868
diff changeset
  1756
    /* care for instances of a subclass with instVars */
3710
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  1757
    cls = __qClass(self);
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  1758
    if (cls != String) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1759
	cp += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
3710
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  1760
    }
7869
597a8faaf603 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7868
diff changeset
  1761
    newSymbol = __MKSYMBOL(cp, (OBJ *)0);
3710
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  1762
    if (newSymbol) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1763
	RETURN ( newSymbol);
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1764
    }
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1765
%}.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1766
    ^ ObjectMemory allocationFailureSignal raise.
3710
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  1767
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  1768
    "
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1769
     'hello' asSymbol
3710
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  1770
    "
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1771
!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1772
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1773
asSymbolIfInterned
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1774
    "if a symbol with the receivers characters is already known, return it.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1775
     Otherwise, return nil. This can be used to query for an existing
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1776
     symbol and is the same as
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1777
	self knownAsSymbol ifTrue:[self asSymbol] ifFalse:[nil]
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1778
     but slightly faster, since the symbol lookup operation is only
3710
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  1779
     performed once."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1780
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1781
%{  /* NOCONTEXT */
3710
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  1782
    OBJ cls;
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  1783
    int indx;
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  1784
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  1785
    cls = __qClass(self);
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  1786
    if (cls != String) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1787
	indx = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
3710
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  1788
    } else {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1789
	indx = 0;
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1790
    }
3710
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  1791
    RETURN ( __SYMBOL_OR_NIL(__stringVal(self) + indx));
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5312
diff changeset
  1792
%}.
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5312
diff changeset
  1793
    self primitiveFailed
3710
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  1794
    "
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  1795
     'hello' asSymbolIfInterned
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  1796
     'fooBarBaz' asSymbolIfInterned
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  1797
    "
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1798
!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1799
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1800
literalArrayEncoding
1246
132a3f6c83bf commentary
Claus Gittinger <cg@exept.de>
parents: 1240
diff changeset
  1801
    "encode myself as an array literal, from which a copy of the receiver
132a3f6c83bf commentary
Claus Gittinger <cg@exept.de>
parents: 1240
diff changeset
  1802
     can be reconstructed with #decodeAsLiteralArray."
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1803
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1804
    ^ self
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1805
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1806
    "Modified: 1.9.1995 / 02:25:45 / claus"
1246
132a3f6c83bf commentary
Claus Gittinger <cg@exept.de>
parents: 1240
diff changeset
  1807
    "Modified: 22.4.1996 / 13:00:50 / cg"
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1808
!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1809
5742
7c02fc4de0ae added #withTabsExpanded: (i.e. arg to specify tab-column width)
Claus Gittinger <cg@exept.de>
parents: 5710
diff changeset
  1810
withTabsExpanded:numSpaces
735
362ce9e28d89 expandTabs now handles multiline strings
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1811
    "return a string with the characters of the receiver where all tabulator characters
5742
7c02fc4de0ae added #withTabsExpanded: (i.e. arg to specify tab-column width)
Claus Gittinger <cg@exept.de>
parents: 5710
diff changeset
  1812
     are expanded into spaces (assuming numSpaces-col tabs).
735
362ce9e28d89 expandTabs now handles multiline strings
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1813
     Notice: if the receiver does not contain any tabs, it is returned unchanged;
362ce9e28d89 expandTabs now handles multiline strings
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1814
     otherwise a new string is returned.
362ce9e28d89 expandTabs now handles multiline strings
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1815
     This does handle multiline strings.
362ce9e28d89 expandTabs now handles multiline strings
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1816
     Rewritten for speed - because this is very heavily used when reading
362ce9e28d89 expandTabs now handles multiline strings
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1817
     big files in the FileBrowser (and therefore speeds up fileReading considerably)."
1138
993e6ffdbf51 removed external decls for VM functions (should look for more)
Claus Gittinger <cg@exept.de>
parents: 1134
diff changeset
  1818
993e6ffdbf51 removed external decls for VM functions (should look for more)
Claus Gittinger <cg@exept.de>
parents: 1134
diff changeset
  1819
%{  /* STACK:700 */
2894
344aec8ba014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2887
diff changeset
  1820
    unsigned char buffer[80*8 + 10];
344aec8ba014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2887
diff changeset
  1821
    unsigned char *srcP, *dstP, *cp0;
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1822
    int idx, sz;
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1823
    int any = 0;
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1824
    OBJ newString;
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1825
    char c;
5742
7c02fc4de0ae added #withTabsExpanded: (i.e. arg to specify tab-column width)
Claus Gittinger <cg@exept.de>
parents: 5710
diff changeset
  1826
    int n;
7c02fc4de0ae added #withTabsExpanded: (i.e. arg to specify tab-column width)
Claus Gittinger <cg@exept.de>
parents: 5710
diff changeset
  1827
7c02fc4de0ae added #withTabsExpanded: (i.e. arg to specify tab-column width)
Claus Gittinger <cg@exept.de>
parents: 5710
diff changeset
  1828
    if ((__qClass(self) == String)
7c02fc4de0ae added #withTabsExpanded: (i.e. arg to specify tab-column width)
Claus Gittinger <cg@exept.de>
parents: 5710
diff changeset
  1829
     && __isSmallInteger(numSpaces)) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1830
	n = __intVal(numSpaces);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1831
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1832
	/*
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1833
	 * for small strings (< 80), do it without a prescan ...
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1834
	 * the buffer is large enough to even convert a
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1835
	 * receiver consisting fully of tabs.
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1836
	 */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1837
	if (__stringSize(self) < 80) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1838
	    idx = 1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1839
	    for (srcP = __stringVal(self), dstP = buffer; (c = *srcP); srcP++) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1840
		if (c == '\t') {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1841
		    any = 1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1842
		    while (idx % n) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1843
			idx++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1844
			*dstP++ = ' ';
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1845
		    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1846
		    idx++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1847
		    *dstP++ = ' ';
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1848
		} else {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1849
		    *dstP++ = c;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1850
		    idx++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1851
		    if (c == '\n') {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1852
			idx = 1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1853
		    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1854
		}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1855
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1856
	    if (! any) RETURN(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1857
	    *dstP = '\0';
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1858
	    RETURN (__MKSTRING_L(buffer, (dstP-buffer)));
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1859
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1860
	/*
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1861
	 * for large strings, we compute the new size, allocate a new string
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1862
	 * and expand it.
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1863
	 *
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1864
	 * first, scan for size ...
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1865
	 */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1866
	idx = 1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1867
	for (srcP = __stringVal(self), sz = 0; (c = *srcP); srcP++) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1868
	    if (c == '\t') {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1869
		any = 1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1870
		while (idx % n) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1871
		    idx++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1872
		    sz++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1873
		}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1874
		idx++; sz ++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1875
	    } else {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1876
		sz++; idx++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1877
		if (c == '\n') {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1878
		    idx = 1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1879
		}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1880
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1881
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1882
	if (! any) RETURN(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1883
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1884
	/*
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1885
	 * get the string
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1886
	 */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1887
	sz = OHDR_SIZE + sz + 1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1888
	__qNew(newString, sz);  /* OBJECT ALLOCATION */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1889
	if (newString != nil) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1890
	    __InstPtr(newString)->o_class = String;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1891
	    __qSTORE(newString, String);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1892
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1893
	    /*
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1894
	     * expand
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1895
	     */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1896
	    idx = 1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1897
	    for (srcP = __stringVal(self), dstP = cp0 = __stringVal(newString); (c = *srcP); srcP++) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1898
		if (c == '\t') {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1899
		    while (idx % n) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1900
			idx++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1901
			*dstP++ = ' ';
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1902
		    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1903
		    idx++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1904
		    *dstP++ = ' ';
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1905
		} else {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1906
		    *dstP++ = c; idx++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1907
		    if (c == '\n') {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1908
			idx = 1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1909
		    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1910
		}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1911
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1912
	    *dstP++ = '\0';
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1913
	    RETURN (newString);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1914
	}
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1915
    }
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1916
%}.
5742
7c02fc4de0ae added #withTabsExpanded: (i.e. arg to specify tab-column width)
Claus Gittinger <cg@exept.de>
parents: 5710
diff changeset
  1917
    ^ super withTabsExpanded:numSpaces
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1918
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1919
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1920
!String methodsFor:'copying'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1921
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1922
, aString
2
claus
parents: 1
diff changeset
  1923
    "return the concatenation of myself and the argument, aString as
claus
parents: 1
diff changeset
  1924
     a String.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1925
     - reimplemented here for speed"
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1926
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1927
%{
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  1928
    int l1, l2, sz;
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1929
    REGISTER OBJ s = aString;
329
claus
parents: 314
diff changeset
  1930
    REGISTER OBJ _string = String;
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  1931
    OBJ myClass, argClass, newString;
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1932
329
claus
parents: 314
diff changeset
  1933
    if (__isNonNilObject(s)) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1934
	myClass = __qClass(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1935
	argClass = __qClass(s);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1936
	/*
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1937
	 * can do it here if both are Strings/Symbols:
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1938
	 */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1939
	if (((myClass == _string) || (myClass == Symbol))
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1940
	 && ((argClass == _string) || (argClass == Symbol))) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1941
	    l1 = __stringSize(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1942
	    l2 = __stringSize(s);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1943
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1944
	    sz = OHDR_SIZE + l1 + l2 + 1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1945
	    __qNew(newString, sz);      /* OBJECT ALLOCATION */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1946
	    if (newString != nil) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1947
		char *cp1, *cp2;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1948
		REGISTER unsigned char *dstp;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1949
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1950
		__InstPtr(newString)->o_class = String;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1951
		__qSTORE(newString, String);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1952
		dstp = __stringVal(newString);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1953
		cp1 = (char *) __stringVal(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1954
		cp2 = (char *) __stringVal(aString);
3651
265d1c30eff5 tuned comma (concatenation) for i386.
Claus Gittinger <cg@exept.de>
parents: 3579
diff changeset
  1955
265d1c30eff5 tuned comma (concatenation) for i386.
Claus Gittinger <cg@exept.de>
parents: 3579
diff changeset
  1956
#ifdef bcopy4
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1957
		/* knowing that allocation is 4-byte aligned and
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1958
		 * size rounded up to next 4-byte, the first copy
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1959
		 * can be done word-wise.
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1960
		 * that speeds up size-10-string , size-10-string
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1961
		 * by 10% on a P5/200.
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1962
		 */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1963
		{
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1964
		    int nw = l1 >> 2;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1965
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1966
		    if (l1 & 3) nw++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1967
		    bcopy4(cp1, dstp, nw);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1968
		    dstp += l1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1969
		}
3673
bf7c72c9037b tuned string concatenation
Claus Gittinger <cg@exept.de>
parents: 3668
diff changeset
  1970
#else
bf7c72c9037b tuned string concatenation
Claus Gittinger <cg@exept.de>
parents: 3668
diff changeset
  1971
# ifdef FAST_MEMCPY
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1972
		memcpy(dstp, cp1, l1);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1973
		dstp += l1;
3673
bf7c72c9037b tuned string concatenation
Claus Gittinger <cg@exept.de>
parents: 3668
diff changeset
  1974
# else
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1975
		while (l1 >= 4) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1976
		    *(int *)dstp = *(int *)cp1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1977
		    dstp += 4; cp1 += 4;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1978
		    l1 -= 4;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1979
		}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1980
		while (l1--) *dstp++ = *cp1++;
3673
bf7c72c9037b tuned string concatenation
Claus Gittinger <cg@exept.de>
parents: 3668
diff changeset
  1981
# endif
3651
265d1c30eff5 tuned comma (concatenation) for i386.
Claus Gittinger <cg@exept.de>
parents: 3579
diff changeset
  1982
#endif
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  1983
3673
bf7c72c9037b tuned string concatenation
Claus Gittinger <cg@exept.de>
parents: 3668
diff changeset
  1984
#ifdef bcopy4
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1985
		if (((INT)dstp & 3) == 0) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1986
		    int nw = l2 >> 2;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1987
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1988
		    if (l2 & 3) nw++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1989
		    bcopy4(cp2, dstp, nw);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1990
		    *(dstp + l2) = '\0';
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1991
		    RETURN ( newString );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1992
		}
3673
bf7c72c9037b tuned string concatenation
Claus Gittinger <cg@exept.de>
parents: 3668
diff changeset
  1993
#endif
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1994
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1995
#ifdef FAST_MEMCPY
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1996
		memcpy(dstp, cp2, l2+1);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1997
		dstp[l2] = '\0';
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1998
#else
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  1999
		while (l2--) *dstp++ = *cp2++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2000
		*dstp = '\0';
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2001
#endif
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2002
		RETURN ( newString );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2003
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2004
	}
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2005
    }
519
0ab6612e060b expand tabs slightly rewritten (no real change)
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
  2006
%}.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2007
    ^ super , aString
6331
3cb5595cf170 Strings do not treat 0-bytes as end of string.
Stefan Vogel <sv@exept.de>
parents: 6007
diff changeset
  2008
3cb5595cf170 Strings do not treat 0-bytes as end of string.
Stefan Vogel <sv@exept.de>
parents: 6007
diff changeset
  2009
    "
7867
1de4b6e5ef92 comment only
Claus Gittinger <cg@exept.de>
parents: 7856
diff changeset
  2010
     'hello' , 'world'
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2011
     #[0 0 0 1] asString, #[0 0 0 2 0] asString
6331
3cb5595cf170 Strings do not treat 0-bytes as end of string.
Stefan Vogel <sv@exept.de>
parents: 6007
diff changeset
  2012
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2013
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2014
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2015
concatenate:string1 and:string2
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2016
    "return the concatenation of myself and the arguments, string1 and string2.
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2017
     This is equivalent to self , string1 , string2
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2018
     - generated by compiler when such a construct is detected"
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2019
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2020
    |newString|
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2021
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2022
%{
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  2023
    int len1, len2, len3, sz;
6331
3cb5595cf170 Strings do not treat 0-bytes as end of string.
Stefan Vogel <sv@exept.de>
parents: 6007
diff changeset
  2024
#if !defined(FAST_MEMCPY)
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2025
    REGISTER unsigned char *srcp;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2026
#endif
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2027
    REGISTER unsigned char *dstp;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2028
53
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
  2029
    if ((__isString(self) || __isSymbol(self))
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
  2030
     && (__isString(string1) || __isSymbol(string1))
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
  2031
     && (__isString(string2) || __isSymbol(string2))) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2032
	len1 = __stringSize(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2033
	len2 = __stringSize(string1);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2034
	len3 = __stringSize(string2);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2035
	sz = OHDR_SIZE + len1 + len2 + len3 + 1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2036
	__qNew(newString, sz);  /* OBJECT ALLOCATION */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2037
	if (newString != nil) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2038
	    __InstPtr(newString)->o_class = String;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2039
	    __qSTORE(newString, String);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2040
	    dstp = __stringVal(newString);
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2041
#ifdef FAST_MEMCPY
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2042
	    memcpy(dstp, __stringVal(self), len1);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2043
	    memcpy(dstp + len1, __stringVal(string1), len2);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2044
	    memcpy(dstp + len1 + len2, __stringVal(string2), len3+1);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2045
	    *(dstp + len1 + len2 + len3) = '\0';
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2046
#else
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2047
	    srcp = __stringVal(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2048
	    while (len1--) *dstp++ = *srcp++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2049
	    srcp = __stringVal(string1);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2050
	    while (len2--) *dstp++ = *srcp++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2051
	    srcp = __stringVal(string2);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2052
	    while (len3--) *dstp++ = *srcp++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2053
	    *dstp = '\0';
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2054
#endif
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2055
	    RETURN ( newString );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2056
	}
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2057
    }
519
0ab6612e060b expand tabs slightly rewritten (no real change)
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
  2058
%}.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2059
    ^ super , string1 , string2
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2060
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2061
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2062
concatenate:string1 and:string2 and:string3
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2063
    "return the concatenation of myself and the string arguments.
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2064
     This is equivalent to self , string1 , string2 , string3
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2065
     - generated by compiler when such a construct is detected"
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2066
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2067
    |newString|
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2068
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2069
%{
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  2070
    int len1, len2, len3, len4, sz;
6331
3cb5595cf170 Strings do not treat 0-bytes as end of string.
Stefan Vogel <sv@exept.de>
parents: 6007
diff changeset
  2071
#if !defined(FAST_MEMCPY)
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2072
    REGISTER unsigned char *srcp;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2073
#endif
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2074
    REGISTER unsigned char *dstp;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2075
53
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
  2076
    if ((__isString(self) || __isSymbol(self))
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
  2077
     && (__isString(string1) || __isSymbol(string1))
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
  2078
     && (__isString(string2) || __isSymbol(string2))
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
  2079
     && (__isString(string3) || __isSymbol(string3))) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2080
	len1 = __stringSize(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2081
	len2 = __stringSize(string1);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2082
	len3 = __stringSize(string2);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2083
	len4 = __stringSize(string3);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2084
	sz = OHDR_SIZE + len1 + len2 + len3 + len4 + 1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2085
	__qNew(newString, sz);  /* OBJECT ALLOCATION */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2086
	if (newString != nil) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2087
	    __InstPtr(newString)->o_class = String;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2088
	    __qSTORE(newString, String);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2089
	    dstp = __stringVal(newString);
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2090
#ifdef FAST_MEMCPY
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2091
	    memcpy(dstp, __stringVal(self), len1);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2092
	    memcpy(dstp + len1, __stringVal(string1), len2);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2093
	    memcpy(dstp + len1 + len2, __stringVal(string2), len3);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2094
	    memcpy(dstp + len1 + len2 + len3, __stringVal(string3), len4+1);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2095
	    *(dstp + len1 + len2 + len3 + len4) = '\0';
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2096
#else
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2097
	    srcp = __stringVal(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2098
	    while (len1--) *dstp++ = *srcp++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2099
	    srcp = __stringVal(string1);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2100
	    while (len2--) *dstp++ = *srcp++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2101
	    srcp = __stringVal(string2);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2102
	    while (len3--) *dstp++ = *srcp++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2103
	    srcp = __stringVal(string3);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2104
	    while (len4--) *dstp++ = *srcp++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2105
	    *dstp = '\0';
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2106
#endif
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2107
	    RETURN ( newString );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2108
	}
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2109
    }
519
0ab6612e060b expand tabs slightly rewritten (no real change)
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
  2110
%}.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2111
    ^ super , string1 , string2 , string3
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2112
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2113
4745
4d2460ed35a7 added #copy
Claus Gittinger <cg@exept.de>
parents: 4682
diff changeset
  2114
copy
4d2460ed35a7 added #copy
Claus Gittinger <cg@exept.de>
parents: 4682
diff changeset
  2115
    "return a copy of the receiver"
4d2460ed35a7 added #copy
Claus Gittinger <cg@exept.de>
parents: 4682
diff changeset
  2116
4d2460ed35a7 added #copy
Claus Gittinger <cg@exept.de>
parents: 4682
diff changeset
  2117
    (self isMemberOf:String) ifTrue:[
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2118
	^ self copyFrom:1
4745
4d2460ed35a7 added #copy
Claus Gittinger <cg@exept.de>
parents: 4682
diff changeset
  2119
    ].
4d2460ed35a7 added #copy
Claus Gittinger <cg@exept.de>
parents: 4682
diff changeset
  2120
    ^ super copy
4d2460ed35a7 added #copy
Claus Gittinger <cg@exept.de>
parents: 4682
diff changeset
  2121
!
4d2460ed35a7 added #copy
Claus Gittinger <cg@exept.de>
parents: 4682
diff changeset
  2122
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2123
copyFrom:start
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2124
    "return the substring from start, anInteger to the end.
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2125
     This method will always return a string, even if the receiver
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2126
     is a subclass-instance. This might change if there is a need.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2127
     - reimplemented here for speed"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2128
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  2129
%{  /* NOCONTEXT */
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2130
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2131
#if !defined(FAST_MEMCPY)
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2132
    REGISTER unsigned char *srcp;
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2133
#endif
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2134
    REGISTER unsigned char *dstp;
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2135
    REGISTER int count;
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2136
    int len, index1, sz;
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2137
    OBJ newString;
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2138
    OBJ myClass;
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2139
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2140
    myClass = __qClass(self);
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2141
2894
344aec8ba014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2887
diff changeset
  2142
#ifndef NO_PRIM_STRING
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2143
    if (__isSmallInteger(start)
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2144
     && ((myClass==String) || (myClass==Symbol))) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2145
	len = __stringSize(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2146
	index1 = __intVal(start);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2147
	if (index1 > 0) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2148
	    if (index1 <= len) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2149
		count = len - index1 + 1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2150
		sz = OHDR_SIZE + count + 1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2151
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2152
		__PROTECT_CONTEXT__
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2153
		__qNew(newString, sz);  /* OBJECT ALLOCATION */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2154
		__UNPROTECT_CONTEXT__
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2155
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2156
		if (newString != nil) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2157
		    __InstPtr(newString)->o_class = String;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2158
		    __qSTORE(newString, String);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2159
		    dstp = __stringVal(newString);
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2160
#ifdef FAST_MEMCPY
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2161
		    memcpy(dstp, __stringVal(self) + index1 - 1, count);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2162
		    dstp[count] = '\0';
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2163
#else
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2164
		    srcp = __stringVal(self) + index1 - 1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2165
		    while (count--) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2166
			*dstp++ = *srcp++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2167
		    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2168
		    *dstp = '\0';
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2169
#endif
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2170
		    RETURN ( newString );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2171
		}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2172
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2173
	}
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  2174
    }
2894
344aec8ba014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2887
diff changeset
  2175
#endif
51
9b7ae5e18f3e *** empty log message ***
claus
parents: 42
diff changeset
  2176
%}.
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2177
    "fall back in case of non-integer index or out-of-bound index;
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2178
     will eventually lead to an out-of-bound signal raise"
51
9b7ae5e18f3e *** empty log message ***
claus
parents: 42
diff changeset
  2179
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2180
    ^ super copyFrom:start
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2181
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2182
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2183
copyFrom:start to:stop
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2184
    "return the substring starting at index start, anInteger and ending
53
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
  2185
     at stop, anInteger. This method will always return a string, even
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
  2186
     if the receiver is a subclass-instance. This might change if there is a need.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2187
     - reimplemented here for speed"
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2188
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  2189
%{  /* NOCONTEXT */
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  2190
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2191
    REGISTER unsigned char *srcp;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2192
    REGISTER unsigned char *dstp;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2193
    REGISTER int count;
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  2194
    int len, sz, index1, index2;
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  2195
    OBJ newString;
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2196
    OBJ myClass;
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2197
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2198
    myClass = __qClass(self);
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2199
2894
344aec8ba014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2887
diff changeset
  2200
#ifndef NO_PRIM_STRING
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2201
    if (__bothSmallInteger(start, stop)
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2202
     && ((myClass==String) || (myClass==Symbol))) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2203
	len = __stringSize(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2204
	index1 = __intVal(start);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2205
	index2 = __intVal(stop);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2206
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2207
	if ((index1 <= index2) && (index1 > 0)) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2208
	    if (index2 <= len) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2209
		count = index2 - index1 + 1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2210
		sz = OHDR_SIZE + count + 1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2211
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2212
		__PROTECT_CONTEXT__
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2213
		__qNew(newString, sz);  /* OBJECT ALLOCATION */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2214
		__UNPROTECT_CONTEXT__
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2215
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2216
		if (newString != nil) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2217
		    __InstPtr(newString)->o_class = String;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2218
		    __qSTORE(newString, String);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2219
		    dstp = __stringVal(newString);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2220
		    srcp = __stringVal(self) + index1 - 1;
2894
344aec8ba014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2887
diff changeset
  2221
#ifdef bcopy4
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2222
		    {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2223
			int nw = count >> 2;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2224
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2225
			if (count & 3) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2226
			    nw++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2227
			}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2228
			bcopy4(srcp, dstp, nw);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2229
			dstp[count] = '\0';
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2230
		    }
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2231
#else
2894
344aec8ba014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2887
diff changeset
  2232
# ifdef FAST_MEMCPY
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2233
		    memcpy(dstp, srcp, count);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2234
		    dstp[count] = '\0';
209
ecc004f196e6 fixed concatenate bug (crash)
claus
parents: 202
diff changeset
  2235
# else
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2236
		    while (count--) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2237
			*dstp++ = *srcp++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2238
		    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2239
		    *dstp = '\0';
209
ecc004f196e6 fixed concatenate bug (crash)
claus
parents: 202
diff changeset
  2240
# endif
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  2241
#endif
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2242
		    RETURN ( newString );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2243
		}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2244
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2245
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2246
	/*
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2247
	 * allow empty copy
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2248
	 */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2249
	if (index1 > index2) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2250
	    __PROTECT_CONTEXT__
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2251
	    __qNew(newString, OHDR_SIZE+1);     /* OBJECT ALLOCATION */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2252
	    __UNPROTECT_CONTEXT__
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2253
	    if (newString != nil) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2254
		__InstPtr(newString)->o_class = String;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2255
		(__stringVal(newString))[0] = '\0';
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2256
		RETURN ( newString );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2257
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2258
	}
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2259
    }
2894
344aec8ba014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2887
diff changeset
  2260
#endif
51
9b7ae5e18f3e *** empty log message ***
claus
parents: 42
diff changeset
  2261
%}.
9b7ae5e18f3e *** empty log message ***
claus
parents: 42
diff changeset
  2262
    "fall back in case of non-integer index or out-of-bound index;
9b7ae5e18f3e *** empty log message ***
claus
parents: 42
diff changeset
  2263
     will eventually lead to an out-of-bound signal raise"
9b7ae5e18f3e *** empty log message ***
claus
parents: 42
diff changeset
  2264
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2265
    ^ super copyFrom:start to:stop
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2266
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2267
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2268
copyWith:aCharacter
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2269
    "return a new string containing the receivers characters
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2270
     and the single new character, aCharacter.
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2271
     This is different from concatentation, which expects another string
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2272
     as argument, but equivalent to copy-and-addLast.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2273
     Reimplemented here for more speed"
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2274
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2275
%{  /* NOCONTEXT */
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2276
2887
4523d179636e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2886
diff changeset
  2277
    int count;
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2278
    int sz;
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2279
    REGISTER unsigned char *dstp;
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2280
    OBJ cls, newString;
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2281
    OBJ myClass;
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2282
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2283
    myClass = __qClass(self);
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2284
2894
344aec8ba014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2887
diff changeset
  2285
#ifndef NO_PRIM_STRING
6833
bc361f384f7f care for twoByteChars in all inline-C code
Claus Gittinger <cg@exept.de>
parents: 6830
diff changeset
  2286
    if (__isCharacter(aCharacter)) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2287
	unsigned int cVal = __intVal(__characterVal(aCharacter));
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2288
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2289
	if ((cVal <= 0xFF)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2290
	 && ((myClass==String) || (myClass==Symbol))) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2291
	    count = __stringSize(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2292
	    sz = OHDR_SIZE + count + 1 + 1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2293
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2294
	    __PROTECT_CONTEXT__
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2295
	    __qNew(newString, sz);  /* OBJECT ALLOCATION */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2296
	    __UNPROTECT_CONTEXT__
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2297
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2298
	    if (newString) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2299
		__InstPtr(newString)->o_class = String;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2300
		__qSTORE(newString, String);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2301
		dstp = __stringVal(newString);
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2302
2887
4523d179636e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2886
diff changeset
  2303
#ifdef bcopy4
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2304
		{
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2305
		    int nw = count >> 2;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2306
		    char *srcp = (char *)__stringVal(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2307
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2308
		    if (count & 3) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2309
			nw++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2310
		    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2311
		    bcopy4(srcp, dstp, nw);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2312
		    dstp += count;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2313
		}
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2314
#else
2887
4523d179636e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2886
diff changeset
  2315
# ifdef FAST_MEMCPY
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2316
		memcpy(dstp, __stringVal(self), count);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2317
		dstp += count;
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2318
# else
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2319
		{
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2320
		    REGISTER unsigned char *srcp;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2321
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2322
		    srcp = __stringVal(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2323
		    while ((*dstp = *srcp++) != '\0')
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2324
			dstp++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2325
		}
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2326
# endif
2887
4523d179636e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2886
diff changeset
  2327
# endif
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2328
		*dstp++ = cVal;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2329
		*dstp = '\0';
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2330
		RETURN (newString );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2331
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2332
	}
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2333
    }
2894
344aec8ba014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2887
diff changeset
  2334
#endif
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2335
%}.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2336
    "fall back in case of non-character arg;
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2337
     will eventually lead to an bad element signal raise"
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2338
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2339
    ^ super copyWith:aCharacter
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2340
!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2341
2886
aa4d70a6717e repaired bad checking
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2342
deepCopy
aa4d70a6717e repaired bad checking
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2343
    "return a copy of the receiver"
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2344
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2345
    "
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2346
     could be an instance of a subclass which needs deepCopy
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2347
     of its named instvars ...
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2348
    "
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2349
    (self isMemberOf:String) ifTrue:[
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2350
	^ self copyFrom:1
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2351
    ].
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2352
    ^ super deepCopy
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2353
!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2354
2886
aa4d70a6717e repaired bad checking
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2355
deepCopyUsing:aDictionary
8383
dea5311899c5 comments in copy methods
Claus Gittinger <cg@exept.de>
parents: 8312
diff changeset
  2356
    "return a deep copy of the receiver - reimplemented to be a bit faster"
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2357
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2358
    "
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2359
     could be an instance of a subclass which needs deepCopy
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2360
     of its named instvars ...
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2361
    "
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2362
    (self isMemberOf:String) ifTrue:[
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2363
	^ self copyFrom:1
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2364
    ].
7881
26b22247f5f1 deepCopyUsing fixed.
martin
parents: 7878
diff changeset
  2365
    ^ super deepCopyUsing:aDictionary
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2366
!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2367
2886
aa4d70a6717e repaired bad checking
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2368
shallowCopy
aa4d70a6717e repaired bad checking
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2369
    "return a copy of the receiver"
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2370
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2371
    (self isMemberOf:String) ifTrue:[
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2372
	^ self copyFrom:1
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2373
    ].
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2374
    ^ super shallowCopy
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2375
!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2376
2886
aa4d70a6717e repaired bad checking
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2377
simpleDeepCopy
aa4d70a6717e repaired bad checking
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2378
    "return a copy of the receiver"
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2379
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2380
    "
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2381
     could be an instance of a subclass which needs deepCopy
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2382
     of its named instvars ...
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2383
    "
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2384
    (self isMemberOf:String) ifTrue:[
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2385
	^ self copyFrom:1
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2386
    ].
7881
26b22247f5f1 deepCopyUsing fixed.
martin
parents: 7878
diff changeset
  2387
    ^ super simpleDeepCopy
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2388
! !
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2389
4154
6938d9274ee4 category rename
Claus Gittinger <cg@exept.de>
parents: 4123
diff changeset
  2390
!String methodsFor:'filling & replacing'!
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2391
2886
aa4d70a6717e repaired bad checking
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2392
atAllPut:aCharacter
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2393
    "replace all elements with aCharacter
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2394
     - reimplemented here for speed"
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2395
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  2396
%{  /* NOCONTEXT */
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  2397
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2398
#ifndef FAST_MEMSET
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2399
    REGISTER unsigned char *dst;
6766
a43b97582d4b oops - (String new:-1) did crash the system (atAllPut:)
Michael Beyl <mb@exept.de>
parents: 6599
diff changeset
  2400
#endif
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2401
    REGISTER int l;
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2402
    REGISTER int byteValue;
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2403
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2404
    if (__isCharacter(aCharacter) && __isString(self)) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2405
	byteValue = __intVal(_characterVal(aCharacter));
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2406
	if ((unsigned)byteValue <= 0xFF) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2407
	    l = __stringSize(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2408
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2409
#ifdef FAST_MEMSET
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2410
	    if (l > 0) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2411
		memset(__stringVal(self), byteValue, l);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2412
	    }
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2413
#else
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2414
	    {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2415
		INT v;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2416
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2417
		v = (byteValue << 8) | byteValue;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2418
		v = (v << 16) | v;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2419
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2420
		dst = __stringVal(self);
3712
f93cb659b10d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3711
diff changeset
  2421
f93cb659b10d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3711
diff changeset
  2422
# ifdef FAST_MEMSET4 /* sorry intel: your stosd instruction is slower ... */
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2423
		if (l > 0) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2424
		    memset4(dst, v, l>>2);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2425
		    l = l & 3;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2426
		}
3712
f93cb659b10d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3711
diff changeset
  2427
# else
f93cb659b10d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3711
diff changeset
  2428
#  ifdef UINT64
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2429
		{
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2430
		    UINT64 v64;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2431
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2432
		    v64 = v;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2433
		    v64 = (v64 << 32) | v;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2434
		    while (l >= 8) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2435
			((UINT64 *)dst)[0] = v64;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2436
			dst += 8;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2437
			l -= 8;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2438
		    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2439
		}
3712
f93cb659b10d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3711
diff changeset
  2440
#  else /* no UINT64 */
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2441
		while (l >= 16) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2442
		    ((int *)dst)[0] = v;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2443
		    ((int *)dst)[1] = v;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2444
		    ((int *)dst)[2] = v;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2445
		    ((int *)dst)[3] = v;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2446
		    dst += 16;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2447
		    l -= 16;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2448
		}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2449
		if (l >= 8) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2450
		    ((int *)dst)[0] = v;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2451
		    ((int *)dst)[1] = v;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2452
		    dst += 8;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2453
		    l -= 8;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2454
		}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2455
		if (l >= 4) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2456
		    ((int *)dst)[0] = v;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2457
		    dst += 4;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2458
		    l -= 4;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2459
		}
3712
f93cb659b10d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3711
diff changeset
  2460
#   if 0
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2461
		if (l >= 2) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2462
		    ((short *)dst)[0] = v;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2463
		    dst += 2;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2464
		    l -= 2;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2465
		}
3712
f93cb659b10d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3711
diff changeset
  2466
#   endif
f93cb659b10d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3711
diff changeset
  2467
5648
5bc58204662e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5557
diff changeset
  2468
#  endif /* UINT64 */
5bc58204662e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5557
diff changeset
  2469
# endif /* FAST_MEMSET4 */
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2470
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2471
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2472
	    /*
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2473
	     * remaining bytes
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2474
	     */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2475
	    while (l-- > 0)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2476
		*dst++ = byteValue;
3712
f93cb659b10d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3711
diff changeset
  2477
3711
bdb2e9d06d33 20% speedup (p6/266) in #atAllPut:
Claus Gittinger <cg@exept.de>
parents: 3710
diff changeset
  2478
#endif /* no FAST_MEMSET */
bdb2e9d06d33 20% speedup (p6/266) in #atAllPut:
Claus Gittinger <cg@exept.de>
parents: 3710
diff changeset
  2479
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2480
	    RETURN ( self );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2481
	}
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2482
    }
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2483
%}.
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2484
    ^ super atAllPut:aCharacter
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2485
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2486
    "
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2487
     (String new:10) atAllPut:$*
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2488
     String new:10 withAll:$*
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2489
    "
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2490
!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2491
2929
ca74fdc386cc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2898
diff changeset
  2492
replaceAll:oldCharacter with:newCharacter
4120
5ad76c8d8e77 comment
Claus Gittinger <cg@exept.de>
parents: 3989
diff changeset
  2493
    "replace all oldCharacters by newCharacter in the receiver.
5ad76c8d8e77 comment
Claus Gittinger <cg@exept.de>
parents: 3989
diff changeset
  2494
5ad76c8d8e77 comment
Claus Gittinger <cg@exept.de>
parents: 3989
diff changeset
  2495
     Notice: This operation modifies the receiver, NOT a copy;
5ad76c8d8e77 comment
Claus Gittinger <cg@exept.de>
parents: 3989
diff changeset
  2496
     therefore the change may affect all others referencing the receiver."
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2497
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2498
%{  /* NOCONTEXT */
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2499
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2500
    REGISTER unsigned char *srcp;
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2501
    REGISTER unsigned oldVal, newVal;
4120
5ad76c8d8e77 comment
Claus Gittinger <cg@exept.de>
parents: 3989
diff changeset
  2502
    unsigned char c, cNext;
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2503
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2504
    if (__isCharacter(oldCharacter)
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2505
     && __isCharacter(newCharacter)
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2506
     && __isString(self)) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2507
	srcp = (unsigned char *)__stringVal(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2508
	oldVal = __intVal(_characterVal(oldCharacter));
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2509
	newVal = __intVal(_characterVal(newCharacter));
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2510
	if ((oldVal <= 0xFF)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2511
	 && (newVal <= 0xFF)) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2512
	    cNext = *srcp;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2513
	    while ((c = cNext) != '\0') {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2514
		cNext = srcp[1];
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2515
		if (c == oldVal)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2516
		    *srcp = newVal;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2517
		srcp++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2518
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2519
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2520
	RETURN ( self );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2521
    }
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2522
%}.
2929
ca74fdc386cc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2898
diff changeset
  2523
    ^ super replaceAll:oldCharacter with:newCharacter
51
9b7ae5e18f3e *** empty log message ***
claus
parents: 42
diff changeset
  2524
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2525
    "
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2526
     'helloWorld' copy replaceAll:$o with:$O
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2527
     'helloWorld' copy replaceAll:$d with:$*
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2528
     'helloWorld' copy replaceAll:$h with:$*
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2529
    "
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2530
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2531
2886
aa4d70a6717e repaired bad checking
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2532
replaceFrom:start to:stop with:aString startingAt:repStart
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2533
    "replace the characters starting at index start, anInteger and ending
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2534
     at stop, anInteger with characters from aString starting at repStart.
3234
4cc58bc6a8ed comment
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  2535
     Return the receiver.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2536
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2537
     - reimplemented here for speed"
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2538
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2539
%{  /* NOCONTEXT */
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2540
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2541
    REGISTER unsigned char *srcp, *dstp;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2542
    REGISTER int count;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2543
    int len, index1, index2;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2544
    int repLen, repIndex;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2545
2894
344aec8ba014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2887
diff changeset
  2546
#ifndef NO_PRIM_STRING
53
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
  2547
    if ((__isString(aString) || __isSymbol(aString))
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
  2548
     && __isString(self)
252
  2549
     && __bothSmallInteger(start, stop)) {
3451
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2550
	len = __stringSize(self);
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2551
	index1 = __intVal(start);
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2552
	index2 = __intVal(stop);
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2553
	count = index2 - index1 + 1;
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2554
	if (count <= 0) {
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2555
	     RETURN (self);
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2556
	}
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2557
	if ((index2 <= len) && (index1 > 0)) {
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2558
	    repLen = __stringSize(aString);
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2559
	    repIndex = __intVal(repStart);
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2560
	    if ((repIndex > 0) && ((repIndex + count - 1) <= repLen)) {
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2561
		srcp = __stringVal(aString) + repIndex - 1;
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2562
		dstp = __stringVal(self) + index1 - 1;
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2563
		if (aString == self) {
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2564
		    /* take care of overlapping copy */
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2565
		    if (srcp < dstp) {
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2566
			/* must do a reverse copy */
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2567
			srcp += count;
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2568
			dstp += count;
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2569
			while (count-- > 0) {
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2570
			    *--dstp = *--srcp;
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2571
			}
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2572
			RETURN (self);
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2573
		    }
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2574
		}
2867
015574e235fd tuned replaceFrom:to:with:startingAt:
Claus Gittinger <cg@exept.de>
parents: 2862
diff changeset
  2575
#ifdef bcopy4
3451
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2576
		/* copy quadbytes if pointers are aligned */
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2577
		/*
3451
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2578
		 * no sizeof(int) here please -
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2579
		 * - bcopy4 (if defined) copies 4-bytes on ALL machines
3451
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2580
		 */
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2581
		if ((count > 12)
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2582
		 && (((unsigned INT)srcp & 3) == 0)
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2583
		 && (((unsigned INT)dstp & 3) == 0)) {
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2584
		    int n;
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2585
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2586
		    n = count >> 2;        /* make it quads */
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2587
		    bcopy4(srcp, dstp, n);
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2588
		    n <<= 2;               /* back to chars */
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2589
		    dstp += n;
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2590
		    srcp += n;
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2591
		    count -= n;
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2592
		}
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2593
		while (count-- > 0) {
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2594
		    *dstp++ = *srcp++;
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2595
		}
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2596
#else
2867
015574e235fd tuned replaceFrom:to:with:startingAt:
Claus Gittinger <cg@exept.de>
parents: 2862
diff changeset
  2597
# ifdef FAST_MEMCPY
3451
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2598
		bcopy(srcp, dstp, count);
2867
015574e235fd tuned replaceFrom:to:with:startingAt:
Claus Gittinger <cg@exept.de>
parents: 2862
diff changeset
  2599
# else
3451
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2600
		/* copy longs if pointers are aligned */
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2601
		if ((((unsigned INT)srcp & (sizeof(INT)-1)) == 0)
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2602
		 && (((unsigned INT)dstp & (sizeof(INT)-1)) == 0)) {
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2603
		    while (count >= sizeof(INT)) {
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2604
			*((unsigned INT *)dstp) = *((unsigned INT *)srcp);
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2605
			dstp += sizeof(INT);
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2606
			srcp += sizeof(INT);
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2607
			count -= sizeof(INT);
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2608
		    }
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2609
		}
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2610
		while (count-- > 0) {
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2611
		    *dstp++ = *srcp++;
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2612
		}
2867
015574e235fd tuned replaceFrom:to:with:startingAt:
Claus Gittinger <cg@exept.de>
parents: 2862
diff changeset
  2613
# endif
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2614
#endif
3451
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2615
		RETURN (self);
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2616
	    }
be63b5abd89a indexNotInteger error
Claus Gittinger <cg@exept.de>
parents: 3449
diff changeset
  2617
	}
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2618
    }
2894
344aec8ba014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2887
diff changeset
  2619
#endif
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2620
%}.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2621
    ^ super replaceFrom:start to:stop with:aString startingAt:repStart
2867
015574e235fd tuned replaceFrom:to:with:startingAt:
Claus Gittinger <cg@exept.de>
parents: 2862
diff changeset
  2622
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2623
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2624
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2625
reverse
7338
7a1a2514b6aa comment
Claus Gittinger <cg@exept.de>
parents: 7302
diff changeset
  2626
    "in-place reverse the characters of the string.
7a1a2514b6aa comment
Claus Gittinger <cg@exept.de>
parents: 7302
diff changeset
  2627
     WARNING: this is a destructive operation, which modifies the receiver."
53
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
  2628
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
  2629
    "Q: is there a need to redefine it here ?"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2630
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2631
%{  /* NOCONTEXT */
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2632
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2633
    REGISTER char c;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2634
    REGISTER unsigned char *hip, *lowp;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2635
53
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
  2636
    if (__isString(self)) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2637
	lowp = __stringVal(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2638
	hip = lowp + __stringSize(self) - 1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2639
	while (lowp < hip) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2640
	    c = *lowp;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2641
	    *lowp = *hip;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2642
	    *hip = c;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2643
	    lowp++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2644
	    hip--;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2645
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2646
	RETURN ( self );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2647
    }
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2648
%}.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2649
    ^ super reverse
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2650
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2651
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2652
withoutSeparators
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2653
    "return a string containing the chars of myself
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2654
     without leading and trailing whitespace.
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2655
     If there is no whitespace, the receiver is returned.
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  2656
     Notice, this is different from String>>withoutSpaces."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2657
42
e33491f6f260 *** empty log message ***
claus
parents: 41
diff changeset
  2658
    |startIndex "{ Class: SmallInteger }"
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2659
     endIndex   "{ Class: SmallInteger }"
51
9b7ae5e18f3e *** empty log message ***
claus
parents: 42
diff changeset
  2660
     sz|
9b7ae5e18f3e *** empty log message ***
claus
parents: 42
diff changeset
  2661
53
77ed1ef5c018 *** empty log message ***
claus
parents: 51
diff changeset
  2662
    startIndex := 0.
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2663
51
9b7ae5e18f3e *** empty log message ***
claus
parents: 42
diff changeset
  2664
%{
2884
1e0bdf34b3b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
  2665
    REGISTER unsigned char *cp;
1e0bdf34b3b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
  2666
    REGISTER unsigned char *ep;
1e0bdf34b3b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
  2667
    REGISTER unsigned char c;
51
9b7ae5e18f3e *** empty log message ***
claus
parents: 42
diff changeset
  2668
    REGISTER unsigned char *cp0;
2884
1e0bdf34b3b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
  2669
    REGISTER unsigned char *ep0;
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2670
51
9b7ae5e18f3e *** empty log message ***
claus
parents: 42
diff changeset
  2671
    /* ignore instances of subclasses ... */
329
claus
parents: 314
diff changeset
  2672
    if (__qClass(self) == String) {
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2673
	cp = cp0 = __stringVal(self);
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2674
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2675
	/*
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2676
	 * find first non-whiteSpace from beginning
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2677
	 */
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2678
#ifndef NON_ASCII
2954
a2f437a0483a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2929
diff changeset
  2679
# ifdef UINT64
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2680
	while (*((UINT64 *)cp) == 0x2020202020202020L) {
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2681
	    cp += 8;
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2682
	}
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2683
# endif
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2684
	while (*((unsigned *)cp) == 0x20202020) {
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2685
	    cp += 4;
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2686
	}
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2687
#endif
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2688
	while ((c = *cp)
329
claus
parents: 314
diff changeset
  2689
#ifndef NON_ASCII       /* i.e. EBCDIC ;-) */
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2690
	 && (c <= ' ')
329
claus
parents: 314
diff changeset
  2691
#endif
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2692
	 && ((c == ' ') || (c == '\n') || (c == '\t')
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2693
			|| (c == '\r') || (c == '\f'))
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2694
	) {
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2695
	    cp++;
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2696
	}
2884
1e0bdf34b3b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
  2697
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2698
	/*
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2699
	 * find first non-whiteSpace from end
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2700
	 */
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2701
	ep = ep0 = cp0 + __stringSize(self) - 1;
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2702
	while ((ep >= cp) && (*ep == ' ')) ep--;
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2703
	c = *ep;
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2704
	while ((ep >= cp) &&
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2705
#ifndef NON_ASCII
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2706
	       (c <= ' ') &&
329
claus
parents: 314
diff changeset
  2707
#endif
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2708
	       ((c == ' ') || (c == '\n') || (c == '\t')
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2709
			   || (c == '\r') || (c == '\f'))) {
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2710
	    ep--;
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2711
	    c = *ep;
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2712
	}
2884
1e0bdf34b3b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
  2713
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2714
	/*
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2715
	 * no whiteSpace ?
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2716
	 */
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2717
	if ((cp == cp0) && (ep == ep0)) {
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2718
	    RETURN(self);
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2719
	}
2884
1e0bdf34b3b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
  2720
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  2721
	startIndex = __mkSmallInteger(cp - cp0 + 1);
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  2722
	endIndex = __mkSmallInteger(ep - cp0 + 1);
51
9b7ae5e18f3e *** empty log message ***
claus
parents: 42
diff changeset
  2723
    }
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 186
diff changeset
  2724
%}.
40ca7cc6fb9c *** empty log message ***
claus
parents: 186
diff changeset
  2725
    startIndex == 0 ifTrue:[^ super withoutSeparators].
40ca7cc6fb9c *** empty log message ***
claus
parents: 186
diff changeset
  2726
40ca7cc6fb9c *** empty log message ***
claus
parents: 186
diff changeset
  2727
    startIndex > endIndex ifTrue:[^ ''].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2728
    ^ self copyFrom:startIndex to:endIndex
2884
1e0bdf34b3b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
  2729
1e0bdf34b3b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
  2730
    "
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2731
     'hello' withoutSeparators
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2732
     '    hello' withoutSeparators
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2733
     '    hello ' withoutSeparators
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2734
     '    hello  ' withoutSeparators
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2735
     '    hello   ' withoutSeparators
2884
1e0bdf34b3b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
  2736
     '    hello    ' withoutSeparators
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2737
     '        ' withoutSeparators
2884
1e0bdf34b3b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
  2738
    "
1e0bdf34b3b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
  2739
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2740
!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2741
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2742
withoutSpaces
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2743
    "return a string containing the characters of myself
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2744
     without leading and trailing spaces.
2884
1e0bdf34b3b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
  2745
     If there are no spaces, the receiver is returned unchanged.
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2746
     Notice, this is different from String>>withoutSeparators."
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2747
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2748
    |startIndex "{ Class: SmallInteger }"
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2749
     endIndex   "{ Class: SmallInteger }"
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2750
     sz blank|
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2751
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2752
    startIndex := 0.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2753
%{
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2754
    REGISTER unsigned char *cp;
2884
1e0bdf34b3b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
  2755
    REGISTER unsigned char *ep;
1e0bdf34b3b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
  2756
    unsigned char *cp0;
1e0bdf34b3b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
  2757
    unsigned char *ep0;
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2758
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2759
    /* ignore instances of subclasses ... */
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2760
    if (__qClass(self) == String) {
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2761
	cp = cp0 = __stringVal(self);
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2762
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2763
	/*
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2764
	 * find first non-blank from beginning
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2765
	 */
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2766
#ifndef NON_ASCII
2954
a2f437a0483a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2929
diff changeset
  2767
# ifdef UINT64
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2768
	while (*((UINT64 *)cp) == 0x2020202020202020L) {
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2769
	    cp += 8;
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2770
	}
2954
a2f437a0483a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2929
diff changeset
  2771
# endif /* UINT64 */
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2772
	while (*((unsigned *)cp) == 0x20202020) {
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2773
	    cp += 4;
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2774
	}
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2775
#endif
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2776
	while (*cp == ' ') cp++;
2884
1e0bdf34b3b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
  2777
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2778
	/*
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2779
	 * find first non-blank from end
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2780
	 */
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2781
	ep = ep0 = cp0 + __stringSize(self) - 1;
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2782
	while ((ep >= cp) && (*ep == ' ')) ep--;
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  2783
3111
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2784
	/*
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2785
	 * no blanks ?
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2786
	 */
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2787
	if ((cp == cp0) && (ep == ep0)) {
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2788
	    RETURN(self);
a23fa6d08ce7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3085
diff changeset
  2789
	}
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2790
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  2791
	startIndex = __mkSmallInteger(cp - cp0 + 1);
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  2792
	endIndex = __mkSmallInteger(ep - cp0 + 1);
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2793
    }
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2794
%}.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2795
    startIndex == 0 ifTrue:[^ super withoutSpaces].
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2796
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2797
    startIndex > endIndex ifTrue:[^ ''].
2886
aa4d70a6717e repaired bad checking
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2798
    ((startIndex == 1) and:[endIndex == self size]) ifTrue:[^ self].
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2799
    ^ self copyFrom:startIndex to:endIndex
2884
1e0bdf34b3b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
  2800
1e0bdf34b3b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
  2801
    "
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2802
     '    hello' withoutSpaces
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2803
     '    hello ' withoutSpaces
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2804
     '    hello  ' withoutSpaces
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2805
     '    hello   ' withoutSpaces
2884
1e0bdf34b3b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
  2806
     '    hello    ' withoutSpaces
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2807
     '        ' withoutSpaces
2884
1e0bdf34b3b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2867
diff changeset
  2808
    "
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2809
! !
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2810
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2811
!String methodsFor:'printing & storing'!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2812
2886
aa4d70a6717e repaired bad checking
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2813
isLiteral
4660
eec23cd7c7ed Added tracing support.
Claus Gittinger <cg@exept.de>
parents: 4631
diff changeset
  2814
    "return true, if the receiver can be used as a literal constant in ST syntax
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2815
     (i.e. can be used in constant arrays)"
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2816
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2817
    ^ true
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2818
!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2819
2886
aa4d70a6717e repaired bad checking
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2820
print
aa4d70a6717e repaired bad checking
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2821
    "print the receiver on standard output.
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2822
     This method does NOT (by purpose) use the stream classes and
5746
cf5e42cb72ef do not overwrite the standard printing conventions
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2823
     will therefore work even in case of emergency (but only, if Stdout is nil)."
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2824
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2825
%{  /* NOCONTEXT */
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2826
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2827
    if (__qClass(self) == String) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2828
	if (@global(Stdout) == nil) {
1486
60c770ac10eb dont access stdout on WIN32
Claus Gittinger <cg@exept.de>
parents: 1399
diff changeset
  2829
#ifdef WIN32
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2830
	    fprintf(stdout, "%s" , __stringVal(self));
1486
60c770ac10eb dont access stdout on WIN32
Claus Gittinger <cg@exept.de>
parents: 1399
diff changeset
  2831
#else
4631
f07d1701b537 use fwrite instead of puts.
Claus Gittinger <cg@exept.de>
parents: 4390
diff changeset
  2832
/*cg: used to have fputs here, but that seems to be NOT prepared
f07d1701b537 use fwrite instead of puts.
Claus Gittinger <cg@exept.de>
parents: 4390
diff changeset
  2833
 * for eintr arriving and thus sometimes sends the string twice ...
f07d1701b537 use fwrite instead of puts.
Claus Gittinger <cg@exept.de>
parents: 4390
diff changeset
  2834
 *
f07d1701b537 use fwrite instead of puts.
Claus Gittinger <cg@exept.de>
parents: 4390
diff changeset
  2835
 *        fputs(__stringVal(self), stdout);
f07d1701b537 use fwrite instead of puts.
Claus Gittinger <cg@exept.de>
parents: 4390
diff changeset
  2836
 */
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2837
	    fwrite(__stringVal(self), 1, __stringSize(self), stdout);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2838
	    fflush(stdout);
1486
60c770ac10eb dont access stdout on WIN32
Claus Gittinger <cg@exept.de>
parents: 1399
diff changeset
  2839
#endif
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2840
	    RETURN (self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2841
	}
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2842
    }
3751
e2913a6c124b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3734
diff changeset
  2843
%}.
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2844
    ^ super print
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2845
!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2846
3751
e2913a6c124b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3734
diff changeset
  2847
printCR
e2913a6c124b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3734
diff changeset
  2848
    "print the receiver on standard output, followed by a cr.
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2849
     This method does NOT (by purpose) use the stream classes and
5746
cf5e42cb72ef do not overwrite the standard printing conventions
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2850
     will therefore work even in case of emergency (but only, if Stdout is nil)."
3751
e2913a6c124b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3734
diff changeset
  2851
e2913a6c124b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3734
diff changeset
  2852
%{  /* NOCONTEXT */
e2913a6c124b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3734
diff changeset
  2853
e2913a6c124b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3734
diff changeset
  2854
    if (__qClass(self) == String) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2855
	if (@global(Stdout) == nil) {
3751
e2913a6c124b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3734
diff changeset
  2856
#ifdef WIN32
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2857
	    fprintf(stdout, "%s\n" , __stringVal(self));
3751
e2913a6c124b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3734
diff changeset
  2858
#else
4631
f07d1701b537 use fwrite instead of puts.
Claus Gittinger <cg@exept.de>
parents: 4390
diff changeset
  2859
/*cg: used to have fputs here, but that seems to be NOT prepared
f07d1701b537 use fwrite instead of puts.
Claus Gittinger <cg@exept.de>
parents: 4390
diff changeset
  2860
 * for eintr arriving and thus sometimes sends the string twice ...
f07d1701b537 use fwrite instead of puts.
Claus Gittinger <cg@exept.de>
parents: 4390
diff changeset
  2861
 *
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2862
 * fputs(__stringVal(self), stdout); fputs("\n", stdout);
4631
f07d1701b537 use fwrite instead of puts.
Claus Gittinger <cg@exept.de>
parents: 4390
diff changeset
  2863
 */
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2864
	    fwrite(__stringVal(self), 1, __stringSize(self), stdout);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2865
	    fwrite("\n", 1, 1, stdout);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2866
	    fflush(stdout);
3751
e2913a6c124b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3734
diff changeset
  2867
#endif
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2868
	    RETURN (self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2869
	}
3751
e2913a6c124b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3734
diff changeset
  2870
    }
e2913a6c124b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3734
diff changeset
  2871
%}.
e2913a6c124b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3734
diff changeset
  2872
    ^ super printCR
e2913a6c124b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3734
diff changeset
  2873
!
e2913a6c124b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3734
diff changeset
  2874
2886
aa4d70a6717e repaired bad checking
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2875
printfPrintString:formatString
7746
4a4208ef7699 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7685
diff changeset
  2876
    "non-standard but sometimes useful.
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2877
     Return a printed representation of the receiver as specified by formatString,
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2878
     which is defined by printf.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2879
     This method is NONSTANDARD and may be removed without notice."
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2880
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2881
%{  /* STACK: 1000 */
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2882
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2883
    char buffer[800];
8415
7e0f1105bc9f Security: use snprintf() instead of sprintf()
Stefan Vogel <sv@exept.de>
parents: 8383
diff changeset
  2884
    char *buf = buffer;
7e0f1105bc9f Security: use snprintf() instead of sprintf()
Stefan Vogel <sv@exept.de>
parents: 8383
diff changeset
  2885
    int bufsize = sizeof(buffer);
7e0f1105bc9f Security: use snprintf() instead of sprintf()
Stefan Vogel <sv@exept.de>
parents: 8383
diff changeset
  2886
    char *mallocbuf = NULL;
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2887
    char *cp;
8415
7e0f1105bc9f Security: use snprintf() instead of sprintf()
Stefan Vogel <sv@exept.de>
parents: 8383
diff changeset
  2888
    int len;
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2889
    OBJ s;
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2890
    extern void *malloc();
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2891
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2892
    if (__isString(formatString)) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2893
	cp = (char *)__stringVal(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2894
	if (__qClass(self) != String) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2895
	    cp += __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(self))->c_ninstvars));
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2896
	}
8415
7e0f1105bc9f Security: use snprintf() instead of sprintf()
Stefan Vogel <sv@exept.de>
parents: 8383
diff changeset
  2897
again:
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2898
	/*
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2899
	 * actually only needed on sparc: since thisContext is
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2900
	 * in a global register, which gets destroyed by printf,
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2901
	 * manually save it here - very stupid ...
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2902
	 */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2903
	__BEGIN_PROTECT_REGISTERS__
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2904
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2905
	len = snprintf(buf, bufsize, (char *)__stringVal(formatString), cp);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2906
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2907
	__END_PROTECT_REGISTERS__
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2908
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2909
	if ((len < 0) || (len > bufsize)) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2910
	    if (len < 0) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2911
		bufsize = bufsize * 2;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2912
	    } else {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2913
		bufsize = len + 1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2914
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2915
	    if (mallocbuf)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2916
		free(mallocbuf);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2917
	    buf = mallocbuf = malloc(bufsize);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2918
	    if (buf == NULL)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2919
		goto fail;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2920
	    goto again;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2921
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2922
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2923
	s = __MKSTRING_L(buf, len);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2924
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2925
	if (mallocbuf)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2926
	    free(mallocbuf);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2927
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2928
	if (s != nil) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2929
	    RETURN (s);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2930
	}
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2931
    }
8415
7e0f1105bc9f Security: use snprintf() instead of sprintf()
Stefan Vogel <sv@exept.de>
parents: 8383
diff changeset
  2932
fail:;
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2933
%}.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2934
    self primitiveFailed
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2935
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2936
    "
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2937
     'hello' printfPrintString:'%%s -> %s'
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2938
     (String new:900) printfPrintString:'%%s -> %s'
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2939
     'hello' printfPrintString:'%%10s -> %10s'
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2940
     'hello' printfPrintString:'%%-10s -> %-10s'
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2941
     'hello' printfPrintString:'%%900s -> %900s'
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2942
     'hello' printfPrintString:'%%-900s -> %-900s'
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2943
    "
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2944
!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2945
2886
aa4d70a6717e repaired bad checking
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2946
storeOn:aStream
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2947
    "put the storeString of myself on aStream"
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2948
7599
188489aaaacd #storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents: 7338
diff changeset
  2949
    aStream nextPut:$'.
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2950
    (self includes:$') ifTrue:[
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2951
	self printWithQuotesDoubledOn:aStream
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2952
    ] ifFalse:[
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2953
	aStream nextPutAll:self
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2954
    ].
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2955
    aStream nextPut:$'
3579
7d9a4ec2be4f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3546
diff changeset
  2956
7d9a4ec2be4f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3546
diff changeset
  2957
    "Modified: / 15.6.1998 / 17:21:51 / cg"
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2958
!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2959
2886
aa4d70a6717e repaired bad checking
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2960
storeString
aa4d70a6717e repaired bad checking
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2961
    "return a String for storing myself"
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2962
8049
ccd0e8f26439 printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents: 8038
diff changeset
  2963
    ^ self basicStoreString.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2964
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2965
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2966
!String methodsFor:'queries'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2967
5557
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  2968
basicSize
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  2969
    "return the number of characters in myself.
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  2970
     Redefined here to exclude the 0-byte at the end."
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  2971
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  2972
%{  /* NOCONTEXT */
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  2973
    REGISTER OBJ slf, cls;
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  2974
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  2975
    slf = self;
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  2976
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  2977
    cls = __qClass(slf);
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  2978
    if (cls == String) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  2979
	RETURN ( __mkSmallInteger(__stringSize(slf)) );
5557
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  2980
    }
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  2981
    RETURN ( __mkSmallInteger(__stringSize(slf)
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2982
			  - __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars))));
5557
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  2983
%}.
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  2984
    ^ super basicSize - 1
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  2985
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  2986
!
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  2987
2886
aa4d70a6717e repaired bad checking
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2988
bitsPerCharacter
1239
91a688ac83de commentary
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
  2989
    "return the number of bits each character has.
91a688ac83de commentary
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
  2990
     Here, 8 is returned (storing single byte characters)."
91a688ac83de commentary
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
  2991
1218
5ed62714c8d1 commentary; ignoredMethods removed
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  2992
    ^ 8
1239
91a688ac83de commentary
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
  2993
91a688ac83de commentary
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
  2994
    "Modified: 20.4.1996 / 23:08:42 / cg"
1218
5ed62714c8d1 commentary; ignoredMethods removed
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  2995
!
5ed62714c8d1 commentary; ignoredMethods removed
Claus Gittinger <cg@exept.de>
parents: 1143
diff changeset
  2996
8458
b10d8cb3ab00 *** empty log message ***
penk
parents: 8457
diff changeset
  2997
contains8BitCharacters
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  2998
    "return true, if the underlying string contains 8BitCharacters (or widers)
8458
b10d8cb3ab00 *** empty log message ***
penk
parents: 8457
diff changeset
  2999
     (i.e. if it is non-ascii)"
b10d8cb3ab00 *** empty log message ***
penk
parents: 8457
diff changeset
  3000
b10d8cb3ab00 *** empty log message ***
penk
parents: 8457
diff changeset
  3001
%{  /* NOCONTEXT */
b10d8cb3ab00 *** empty log message ***
penk
parents: 8457
diff changeset
  3002
b10d8cb3ab00 *** empty log message ***
penk
parents: 8457
diff changeset
  3003
    REGISTER unsigned char *cp;
b10d8cb3ab00 *** empty log message ***
penk
parents: 8457
diff changeset
  3004
    REGISTER unsigned char *last;
b10d8cb3ab00 *** empty log message ***
penk
parents: 8457
diff changeset
  3005
    OBJ cls;
b10d8cb3ab00 *** empty log message ***
penk
parents: 8457
diff changeset
  3006
b10d8cb3ab00 *** empty log message ***
penk
parents: 8457
diff changeset
  3007
    cp = __stringVal(self);
8915
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
  3008
    last = cp + __stringSize(self);
8458
b10d8cb3ab00 *** empty log message ***
penk
parents: 8457
diff changeset
  3009
    if ((cls = __qClass(self)) != String) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3010
	cp += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
8458
b10d8cb3ab00 *** empty log message ***
penk
parents: 8457
diff changeset
  3011
    }
8916
a75290b18fa6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8915
diff changeset
  3012
    while ((cp+4) <= last) {
8915
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
  3013
	if (*(int *)cp & 0x80808080) {
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
  3014
	    RETURN ( true );
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
  3015
	}
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
  3016
	cp += 4;
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
  3017
    }
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
  3018
    while (cp < last) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3019
	if (*cp & 0x80) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3020
	    RETURN ( true );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3021
	}
8915
eb2652ce257d fixed includes/indexOf for subclasses of string with instVars;
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
  3022
	cp++;
8458
b10d8cb3ab00 *** empty log message ***
penk
parents: 8457
diff changeset
  3023
    }
b10d8cb3ab00 *** empty log message ***
penk
parents: 8457
diff changeset
  3024
    RETURN (false);
b10d8cb3ab00 *** empty log message ***
penk
parents: 8457
diff changeset
  3025
%}.
b10d8cb3ab00 *** empty log message ***
penk
parents: 8457
diff changeset
  3026
b10d8cb3ab00 *** empty log message ***
penk
parents: 8457
diff changeset
  3027
    "
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3028
     'hello world' contains8BitCharacters
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3029
     'hello world' asTwoByteString contains8BitCharacters
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3030
     ('hello world' , (Character value:16r88) asString) contains8BitCharacters
8458
b10d8cb3ab00 *** empty log message ***
penk
parents: 8457
diff changeset
  3031
    "
b10d8cb3ab00 *** empty log message ***
penk
parents: 8457
diff changeset
  3032
!
b10d8cb3ab00 *** empty log message ***
penk
parents: 8457
diff changeset
  3033
2886
aa4d70a6717e repaired bad checking
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  3034
knownAsSymbol
aa4d70a6717e repaired bad checking
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  3035
    "return true, if there is a symbol with same characters in the
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  3036
     system.
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  3037
     Can be used to check for existance of a symbol without creating one"
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3038
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3039
%{  /* NOCONTEXT */
3710
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  3040
    OBJ cls;
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  3041
    int indx;
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  3042
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  3043
    cls = __qClass(self);
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  3044
    if (cls != String) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3045
	indx = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
3710
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  3046
    } else {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3047
	indx = 0;
3710
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  3048
    }
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  3049
    RETURN ( __KNOWNASSYMBOL(__stringVal(self) + indx) );
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5312
diff changeset
  3050
%}.
6007
f55ba7370814 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5762
diff changeset
  3051
"/    ^ self asSymbolIfInterned notNil.
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5312
diff changeset
  3052
    self primitiveFailed
3710
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  3053
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  3054
    "
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3055
     'hello' knownAsSymbol
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3056
     'fooBarBaz' knownAsSymbol
3710
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  3057
    "
5557
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  3058
!
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  3059
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  3060
size
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  3061
    "return the number of characters in myself.
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  3062
     Reimplemented here to avoid the additional size->basicSize send
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  3063
     (which we can do here, since size is obviously not redefined in a subclass).
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  3064
     This method is the same as basicSize."
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  3065
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  3066
%{  /* NOCONTEXT */
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  3067
    REGISTER OBJ cls, slf;
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  3068
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  3069
    slf = self;
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  3070
    cls = __qClass(slf);
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  3071
    if (cls == String) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  3072
	RETURN ( __mkSmallInteger(__stringSize(slf)) );
5557
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  3073
    }
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  3074
    RETURN ( __mkSmallInteger(__stringSize(slf)
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3075
			 - __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars))));
5557
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  3076
%}.
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
  3077
    ^ self basicSize
8038
d2884b02987c stringSpecies query
Claus Gittinger <cg@exept.de>
parents: 8006
diff changeset
  3078
!
d2884b02987c stringSpecies query
Claus Gittinger <cg@exept.de>
parents: 8006
diff changeset
  3079
d2884b02987c stringSpecies query
Claus Gittinger <cg@exept.de>
parents: 8006
diff changeset
  3080
stringSpecies
d2884b02987c stringSpecies query
Claus Gittinger <cg@exept.de>
parents: 8006
diff changeset
  3081
    ^ String
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  3082
! !
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3083
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3084
!String methodsFor:'testing'!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3085
2886
aa4d70a6717e repaired bad checking
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  3086
endsWith:aStringOrChar
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  3087
    "return true, if the receiver ends with something, aStringOrChar."
1380
9873f7ae0785 category change
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
  3088
9873f7ae0785 category change
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
  3089
%{  /* NOCONTEXT */
9873f7ae0785 category change
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
  3090
9873f7ae0785 category change
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
  3091
    int len1, len2;
9873f7ae0785 category change
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
  3092
    REGISTER unsigned char *src1, *src2;
2858
866ffc52ac8a oops - need unsigned character compares
Claus Gittinger <cg@exept.de>
parents: 2856
diff changeset
  3093
    unsigned char c;
3545
5238e4d15d64 better code for endsWith: / startsWith: for single-character arg.
Claus Gittinger <cg@exept.de>
parents: 3451
diff changeset
  3094
    REGISTER OBJ slf = self;
5238e4d15d64 better code for endsWith: / startsWith: for single-character arg.
Claus Gittinger <cg@exept.de>
parents: 3451
diff changeset
  3095
5238e4d15d64 better code for endsWith: / startsWith: for single-character arg.
Claus Gittinger <cg@exept.de>
parents: 3451
diff changeset
  3096
    if ((__isString(slf) || __isSymbol(slf))
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  3097
     && (__isString(aStringOrChar) || __isSymbol(aStringOrChar))) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3098
	len1 = __qSize(slf);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3099
	len2 = __qSize(aStringOrChar);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3100
	if (len1 < len2) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3101
	    RETURN ( false );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3102
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3103
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3104
	src1 = __stringVal(slf) + (len1 - len2);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3105
	src2 = __stringVal(aStringOrChar);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3106
	while (c = *src2++) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3107
	    if (c != *src1++) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3108
		RETURN ( false );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3109
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3110
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3111
	RETURN (true);
3545
5238e4d15d64 better code for endsWith: / startsWith: for single-character arg.
Claus Gittinger <cg@exept.de>
parents: 3451
diff changeset
  3112
    }
5238e4d15d64 better code for endsWith: / startsWith: for single-character arg.
Claus Gittinger <cg@exept.de>
parents: 3451
diff changeset
  3113
    if (__isCharacter(aStringOrChar)) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3114
	int val;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3115
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3116
	val = __intVal(_characterVal(aStringOrChar));
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3117
	if ((unsigned)val <= 0xFF) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3118
	    len1 = __stringSize(slf);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3119
	    if (len1 > 0) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3120
		RETURN ( (__stringVal(slf)[len1-1] == val) ? true : false);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3121
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3122
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3123
	RETURN ( false );
1380
9873f7ae0785 category change
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
  3124
    }
9873f7ae0785 category change
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
  3125
%}.
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  3126
    ^ super endsWith:aStringOrChar
1380
9873f7ae0785 category change
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
  3127
9873f7ae0785 category change
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
  3128
    "
9873f7ae0785 category change
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
  3129
     'hello world' endsWith:'world'
9873f7ae0785 category change
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
  3130
     'hello world' endsWith:'earth'
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3131
     'hello world' endsWith:$d
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3132
     'hello world' endsWith:$e
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3133
     '' endsWith:$d
1380
9873f7ae0785 category change
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
  3134
     'hello world' endsWith:#($r $l $d)
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3135
     'hello world' endsWith:''
1380
9873f7ae0785 category change
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
  3136
    "
9873f7ae0785 category change
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
  3137
!
9873f7ae0785 category change
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
  3138
2886
aa4d70a6717e repaired bad checking
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  3139
isBlank
aa4d70a6717e repaired bad checking
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  3140
    "return true, if the receivers size is 0 or if it contains only spaces.
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3141
     Q: should we care for whiteSpace in general here ?"
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3142
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3143
%{  /* NOCONTEXT */
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3144
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3145
    REGISTER unsigned char *src;
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3146
    REGISTER unsigned char c;
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3147
    OBJ cls;
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3148
1134
7cb7cd7ebeb8 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1019
diff changeset
  3149
    src = __stringVal(self);
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3150
    if ((cls = __qClass(self)) != String)
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3151
	src += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3152
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3153
#ifndef NON_ASCII
2954
a2f437a0483a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2929
diff changeset
  3154
# ifdef UINT64
a2f437a0483a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2929
diff changeset
  3155
    while (*((UINT64 *)src) == 0x2020202020202020L) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3156
	src += 8;
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  3157
    }
2954
a2f437a0483a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2929
diff changeset
  3158
# endif /* UINT64 */
3710
6ee8b3c37d09 allow subclass-insts of String
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
  3159
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3160
    while (*((unsigned *)src) == 0x20202020) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3161
	src += 4;
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3162
    }
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  3163
#endif /* ascii */
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  3164
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  3165
    while (c = *src++) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3166
	if (c != ' ') {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3167
	    RETURN ( false );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3168
	}
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  3169
    }
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5312
diff changeset
  3170
    RETURN ( true );
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3171
%}.
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5312
diff changeset
  3172
    ^ super isBlank
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3173
!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3174
5556
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3175
isEmpty
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3176
    "return true if the receiver is empty (i.e. if size == 0)
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3177
     Redefined here for performance"
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3178
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3179
%{  /* NOCONTEXT */
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3180
    OBJ cls;
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3181
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3182
    cls = __qClass(self);
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3183
    if ((cls == String) || (cls == Symbol)) {
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3184
	RETURN ( (__stringSize(self) == 0) ? true : false);
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3185
    }
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3186
%}.
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3187
    ^ self size == 0
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3188
!
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3189
8647
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
  3190
levenshteinTo:aString s:substWeight k:kbdTypoWeight c:caseWeight i:insrtWeight d:deleteWeight
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3191
    "parametrized levenshtein. arguments are the costs for
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3192
     substitution, case-change, insertion and deletion of a character."
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3193
1138
993e6ffdbf51 removed external decls for VM functions (should look for more)
Claus Gittinger <cg@exept.de>
parents: 1134
diff changeset
  3194
%{  /* STACK: 2000 */
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3195
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3196
    /*
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3197
     * this is very heavy used when correcting errors
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3198
     * (all symbols are searched for best match) - therefore it must be fast
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3199
     */
8647
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
  3200
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3201
    unsigned short *data;
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3202
    int l1, l2;
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3203
    REGISTER int sz;
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3204
    unsigned char *s1, *s2;
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  3205
    int v1, v2, v3;
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8898
diff changeset
  3206
    INT m;
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3207
    REGISTER unsigned short *dp;
8647
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
  3208
    REGISTER int rowDelta;
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3209
    REGISTER int j;
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3210
    int i;
8647
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
  3211
    int iW, cW, sW, kW, dW;
1486
60c770ac10eb dont access stdout on WIN32
Claus Gittinger <cg@exept.de>
parents: 1399
diff changeset
  3212
#   define FASTSIZE 30  /* increase STACK if you increase this ... */
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3213
    unsigned short fastData[(FASTSIZE + 1) * (FASTSIZE + 1)];
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3214
    extern void *malloc();
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3215
8647
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
  3216
    if (__isStringLike(self) && __isStringLike(aString)
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3217
	&& __bothSmallInteger(insrtWeight, caseWeight)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3218
	&& __bothSmallInteger(substWeight, deleteWeight)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3219
	&& __isSmallInteger(kbdTypoWeight)
8647
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
  3220
    ) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3221
	iW = __intVal(insrtWeight);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3222
	cW = __intVal(caseWeight);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3223
	sW = __intVal(substWeight);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3224
	kW = __intVal(kbdTypoWeight);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3225
	dW = __intVal(deleteWeight);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3226
	s1 = __stringVal(self);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3227
	s2 = __stringVal(aString);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3228
	l1 = strlen(s1);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3229
	l2 = strlen(s2);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3230
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3231
	sz = (l1 < l2) ? l2 : l1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3232
	rowDelta = sz + 1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3233
	if (sz <= FASTSIZE) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3234
	    data = fastData;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3235
	} else {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3236
	    /* add ifdef ALLOCA here ... */
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3237
	    data = (unsigned short *)malloc(rowDelta * rowDelta * sizeof(short));
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3238
	    if (! data) goto mallocFailed;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3239
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3240
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3241
	data[0] = 0;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3242
	for (j=1, dp=data+1; j<=sz; j++, dp++)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3243
	    *dp = dp[-1] + iW;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3244
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3245
	for (i=1, dp=data+rowDelta; i<=sz; i++, dp+=rowDelta)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3246
	    *dp = dp[-rowDelta] + dW;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3247
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3248
	for (i=0; i<l1; i++) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3249
	    for (j=0; j<l2; j++) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3250
		if (s1[i] == s2[j])
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3251
		    m = 0;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3252
		else if (tolower(s1[i]) == tolower(s2[j]))
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3253
		    m = cW;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3254
		else if (sW != kW && nextOnKeyboard(tolower(s1[i]), tolower(s2[j])))
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3255
		    m = kW;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3256
		else
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3257
		    m = sW;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3258
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3259
		dp = data + ((i+1)*rowDelta) + j;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3260
		v2 = dp[0] + iW;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3261
		v1 = dp[-rowDelta] + m;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3262
		v3 = dp[-rowDelta+1] + dW;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3263
		if (v1 < v2) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3264
		    if (v1 < v3)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3265
			m = v1;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3266
		    else
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3267
			m = v3;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3268
		} else {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3269
		    if (v2 < v3)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3270
			m = v2;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3271
		    else
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3272
			m = v3;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3273
		}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3274
		dp[1] = m;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3275
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3276
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3277
	m = data[l1*rowDelta + l2];
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3278
	if (sz > FASTSIZE)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3279
	    free(data);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3280
	RETURN ( __mkSmallInteger(m) );
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3281
    }
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3282
mallocFailed: ;
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3283
%}.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3284
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3285
    ^ super levenshteinTo:aString
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3286
			s:substWeight k:kbdTypoWeight c:caseWeight
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3287
			i:insrtWeight d:deleteWeight
8647
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
  3288
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
  3289
    "
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
  3290
     'ocmprt' levenshteinTo:'computer'
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3291
     'computer' levenshteinTo:'computer'
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3292
     'ocmputer' levenshteinTo:'computer'
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3293
     'cmputer' levenshteinTo:'computer'
8647
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
  3294
     'computer' levenshteinTo:'cmputer'
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
  3295
     'computer' levenshteinTo:'vomputer'
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
  3296
     'computer' levenshteinTo:'bomputer'
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
  3297
     'Computer' levenshteinTo:'computer'
2f59b57bcc4d Fix #levenshtein:... C-code.
Stefan Vogel <sv@exept.de>
parents: 8458
diff changeset
  3298
    "
1380
9873f7ae0785 category change
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
  3299
!
9873f7ae0785 category change
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
  3300
5556
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3301
notEmpty
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3302
    "return true if the receiver is not empty (i.e. if size ~~ 0)
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3303
     Redefined here for performance"
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3304
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3305
%{  /* NOCONTEXT */
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3306
    OBJ cls;
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3307
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3308
    cls = __qClass(self);
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3309
    if ((cls == String) || (cls == Symbol)) {
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3310
	RETURN ( (__stringSize(self) != 0) ? true : false);
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3311
    }
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3312
%}.
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3313
    ^ self size ~~ 0
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3314
!
1056cc5d6ce0 category change
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  3315
2886
aa4d70a6717e repaired bad checking
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  3316
startsWith:aStringOrChar
4389
3655a0fea430 definite (true) return for zero-length arg in #startsWith:
Claus Gittinger <cg@exept.de>
parents: 4388
diff changeset
  3317
    "return true, if the receiver starts with something, aStringOrChar.
3655a0fea430 definite (true) return for zero-length arg in #startsWith:
Claus Gittinger <cg@exept.de>
parents: 4388
diff changeset
  3318
     If the argument is empty, true is returned."
1380
9873f7ae0785 category change
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
  3319
9873f7ae0785 category change
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
  3320
%{  /* NOCONTEXT */
9873f7ae0785 category change
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
  3321
9873f7ae0785 category change
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
  3322
    int len1, len2;
9873f7ae0785 category change
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
  3323
    REGISTER unsigned char *src1, *src2;
2858
866ffc52ac8a oops - need unsigned character compares
Claus Gittinger <cg@exept.de>
parents: 2856
diff changeset
  3324
    unsigned char c;
3545
5238e4d15d64 better code for endsWith: / startsWith: for single-character arg.
Claus Gittinger <cg@exept.de>
parents: 3451
diff changeset
  3325
    REGISTER OBJ slf = self;
5238e4d15d64 better code for endsWith: / startsWith: for single-character arg.
Claus Gittinger <cg@exept.de>
parents: 3451
diff changeset
  3326
5238e4d15d64 better code for endsWith: / startsWith: for single-character arg.
Claus Gittinger <cg@exept.de>
parents: 3451
diff changeset
  3327
    if (((__qClass(slf)==String) || (__qClass(slf)==Symbol))
3314
94046261fba0 tuned #~= , #= and #startsWith:
Claus Gittinger <cg@exept.de>
parents: 3281
diff changeset
  3328
     && __isNonNilObject(aStringOrChar)
94046261fba0 tuned #~= , #= and #startsWith:
Claus Gittinger <cg@exept.de>
parents: 3281
diff changeset
  3329
     && ((__qClass(aStringOrChar)==String) || (__qClass(aStringOrChar)==Symbol))) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3330
	src1 = __stringVal(slf);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3331
	src2 = __stringVal(aStringOrChar);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3332
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3333
	if (src1[0] != src2[0]) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3334
	    if (__qSize(aStringOrChar) == (OHDR_SIZE+1) /* 1 for the 0-byte */) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3335
		RETURN (true);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3336
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3337
	    RETURN ( false );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3338
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3339
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3340
	len1 = __qSize(slf);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3341
	len2 = __qSize(aStringOrChar);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3342
	if (len1 < len2) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3343
	    RETURN ( false );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3344
	}
3545
5238e4d15d64 better code for endsWith: / startsWith: for single-character arg.
Claus Gittinger <cg@exept.de>
parents: 3451
diff changeset
  3345
4247
42504c49fe2a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4205
diff changeset
  3346
#ifdef UINT64
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3347
	while (len2 > (OHDR_SIZE+sizeof(UINT64))) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3348
	    if ( ((UINT64 *)src1)[0] != ((UINT64 *)src2)[0] ) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3349
		RETURN (false);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3350
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3351
	    len2 -= sizeof(UINT64);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3352
	    src1 += sizeof(UINT64);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3353
	    src2 += sizeof(UINT64);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3354
	}
4247
42504c49fe2a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4205
diff changeset
  3355
#else
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8917
diff changeset
  3356
# ifdef __UNROLL_LOOPS__
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3357
	while (len2 > (OHDR_SIZE+sizeof(INT)*4)) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3358
	    if ( ((unsigned INT *)src1)[0] != ((unsigned INT *)src2)[0]) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3359
		RETURN (false);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3360
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3361
	    if ( ((unsigned INT *)src1)[1] != ((unsigned INT *)src2)[1]) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3362
		RETURN (false);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3363
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3364
	    if ( ((unsigned INT *)src1)[2] != ((unsigned INT *)src2)[2]) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3365
		RETURN (false);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3366
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3367
	    if ( ((unsigned INT *)src1)[3] != ((unsigned INT *)src2)[3]) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3368
		RETURN (false);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3369
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3370
	    len2 -= sizeof(INT)*4;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3371
	    src1 += sizeof(INT)*4;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3372
	    src2 += sizeof(INT)*4;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3373
	}
8919
707a9ff7f9b2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8917
diff changeset
  3374
# endif /* __UNROLL_LOOPS__ */
4247
42504c49fe2a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4205
diff changeset
  3375
#endif /* UINT64 */
3546
00984e13534a 8-byte compares (if possible) in startsWith:
Claus Gittinger <cg@exept.de>
parents: 3545
diff changeset
  3376
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3377
	while (len2 > (OHDR_SIZE+sizeof(INT))) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3378
	    if ( ((unsigned INT *)src1)[0] != ((unsigned INT *)src2)[0]) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3379
		RETURN (false);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3380
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3381
	    len2 -= sizeof(INT);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3382
	    src1 += sizeof(INT);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3383
	    src2 += sizeof(INT);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3384
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3385
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3386
	while (c = *src2++) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3387
	    if (c != *src1) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3388
		RETURN ( false );
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3389
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3390
	    src1++;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3391
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3392
	RETURN (true);
3545
5238e4d15d64 better code for endsWith: / startsWith: for single-character arg.
Claus Gittinger <cg@exept.de>
parents: 3451
diff changeset
  3393
    }
5238e4d15d64 better code for endsWith: / startsWith: for single-character arg.
Claus Gittinger <cg@exept.de>
parents: 3451
diff changeset
  3394
    if (__isCharacter(aStringOrChar)) {
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3395
	int val;
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3396
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3397
	val = __intVal(_characterVal(aStringOrChar));
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3398
	if ((unsigned)val <= 0xFF) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3399
	    len1 = __stringSize(slf);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3400
	    if (len1 > 0) {
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3401
		RETURN ( (__stringVal(slf)[0] == val) ? true : false);
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3402
	    }
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3403
	}
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3404
	RETURN ( false );
1380
9873f7ae0785 category change
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
  3405
    }
9873f7ae0785 category change
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
  3406
%}.
2862
5cf60c544968 faster withoutSpaces
Claus Gittinger <cg@exept.de>
parents: 2858
diff changeset
  3407
    ^ super startsWith:aStringOrChar
1380
9873f7ae0785 category change
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
  3408
9873f7ae0785 category change
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
  3409
    "
3314
94046261fba0 tuned #~= , #= and #startsWith:
Claus Gittinger <cg@exept.de>
parents: 3281
diff changeset
  3410
     'hello world' startsWith:'hello'
94046261fba0 tuned #~= , #= and #startsWith:
Claus Gittinger <cg@exept.de>
parents: 3281
diff changeset
  3411
     'hello world' startsWith:'hella'
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3412
     'hello world' startsWith:'hi'
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3413
     'hello world' startsWith:$h
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3414
     'hello world' startsWith:$H
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3415
     'hello world' startsWith:(Character value:16rFF00)
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3416
     'hello world' startsWith:60
1380
9873f7ae0785 category change
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
  3417
     'hello world' startsWith:#($h $e $l)
8898
de2d00a37ae7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8861
diff changeset
  3418
     'hello world' startsWith:''
1380
9873f7ae0785 category change
Claus Gittinger <cg@exept.de>
parents: 1368
diff changeset
  3419
    "
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3420
! !
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  3421
4660
eec23cd7c7ed Added tracing support.
Claus Gittinger <cg@exept.de>
parents: 4631
diff changeset
  3422
!String methodsFor:'tracing'!
eec23cd7c7ed Added tracing support.
Claus Gittinger <cg@exept.de>
parents: 4631
diff changeset
  3423
4682
4158042a9c8c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4660
diff changeset
  3424
traceInto:aRequestor level:level from:referrer
4660
eec23cd7c7ed Added tracing support.
Claus Gittinger <cg@exept.de>
parents: 4631
diff changeset
  3425
    "double dispatch into tracer, passing my type implicitely in the selector"
eec23cd7c7ed Added tracing support.
Claus Gittinger <cg@exept.de>
parents: 4631
diff changeset
  3426
4682
4158042a9c8c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4660
diff changeset
  3427
    ^ aRequestor traceString:self level:level from:referrer
4660
eec23cd7c7ed Added tracing support.
Claus Gittinger <cg@exept.de>
parents: 4631
diff changeset
  3428
eec23cd7c7ed Added tracing support.
Claus Gittinger <cg@exept.de>
parents: 4631
diff changeset
  3429
eec23cd7c7ed Added tracing support.
Claus Gittinger <cg@exept.de>
parents: 4631
diff changeset
  3430
! !
eec23cd7c7ed Added tracing support.
Claus Gittinger <cg@exept.de>
parents: 4631
diff changeset
  3431
633
46e996b3c18f version at the end
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
  3432
!String class methodsFor:'documentation'!
46e996b3c18f version at the end
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
  3433
2886
aa4d70a6717e repaired bad checking
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  3434
version
8932
Michael Beyl <mb@exept.de>
parents: 8928
diff changeset
  3435
    ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.229 2005-07-13 08:42:50 mb Exp $'
633
46e996b3c18f version at the end
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
  3436
! !