69 #define DEFAULT_BUFFER_LENGTH 256
97 string = OREF_NULLSTRING;
102 string = OREF_NULLSTRING;
111 defaultSize = bufferLength;
117 bufferLength =
string->getLength();
128 newBuffer->
sendMessage(OREF_INIT, args, argc > 2 ? argc - 2 : 0, named_argc);
138 newBuffer->
messageSend(OREF_INIT_EXTENDED, args, argc, named_argc, result,
false);
187 void *RexxMutableBuffer::operator
new(
size_t size)
202 void *RexxMutableBuffer::operator
new(
size_t size,
RexxClass *bufferClass)
205 newObj->
setBehaviour(bufferClass->getInstanceBehaviour());
266 size_t resultLength = this->
dataLength + addedLength;
303 if (newLength > capacity)
305 newLength = capacity;
312 if (newLength > oldLength)
314 this->
setData(oldLength,
'\0', newLength - oldLength);
431 bool padInserted =
false;
432 bool padIsASCII = ((padChar & 0x80) == 0);
435 size_t padLength = insertLength - copyLength;
443 if (insertLength == 0)
494 bool stringIsASCII =
string->checkIsASCII();
514 bool padInserted =
false;
515 bool padIsASCII = ((padChar & 0x80) == 0);
555 bool stringIsASCII =
string->checkIsASCII();
587 size_t newLength =
string->getLength();
591 bool padInserted =
false;
592 bool padIsASCII = ((padChar & 0x80) == 0);
614 finalLength = begin - replaceLength + newLength;
618 finalLength =
dataLength - replaceLength + newLength;
639 if (replaceLength != newLength && begin + replaceLength <
dataLength)
642 adjustGap(begin, replaceLength, newLength);
662 bool stringIsASCII =
string->checkIsASCII();
977 size_t needleLength = needle->
getLength();
978 size_t newLength = newNeedle->
getLength();
980 size_t resultLength = this->
getLength() - (matches * needleLength) + (matches * newLength);
987 if (needleLength == newLength)
992 for (
size_t i = 0; i < matches; i++)
996 size_t matchPos =
StringUtil::pos(source, sourceLength, needle, _start, sourceLength);
999 _start = matchPos + newLength - 1;
1003 else if (needleLength > newLength)
1006 size_t copyOffset = 0;
1013 for (
size_t i = 0; i < matches; i++)
1016 size_t matchPos =
StringUtil::pos(source, sourceLength, needle, _start, sourceLength);
1017 size_t copyLength = (matchPos - 1) - _start;
1019 if (copyLength != 0)
1021 copyData(copyOffset, source + _start, copyLength);
1022 copyOffset += copyLength;
1027 copyData(copyOffset, newPtr, newLength);
1028 copyOffset += newLength;
1030 _start = matchPos + needleLength - 1;
1033 if (_start < sourceLength)
1035 copyData(copyOffset, source + _start, sourceLength - _start);
1042 size_t growth = (newLength - needleLength) * matches;
1045 size_t copyOffset = 0;
1052 openGap(0, growth, sourceLength);
1055 for (
size_t i = 0; i < matches; i++)
1058 size_t matchPos =
StringUtil::pos(source, sourceLength, needle, _start, sourceLength);
1059 size_t copyLength = (matchPos - 1) - _start;
1061 if (copyLength != 0)
1063 copyData(copyOffset, source + _start, copyLength);
1064 copyOffset += copyLength;
1069 copyData(copyOffset, newPtr, newLength);
1070 copyOffset += newLength;
1072 _start = matchPos + needleLength - 1;
1075 if (_start < sourceLength)
1077 copyData(copyOffset, source + _start, sourceLength - _start);
1086 if (!newNeedleIsASCII) this->
setIsASCII(
false);
1120 if (matches > count)
1129 size_t needleLength = needle->
getLength();
1130 size_t newLength = newNeedle->
getLength();
1132 size_t resultLength = this->
getLength() - (matches * needleLength) + (matches * newLength);
1139 if (needleLength == newLength)
1144 for (
size_t i = 0; i < matches; i++)
1151 _start = matchPos + newLength - 1;
1155 else if (needleLength > newLength)
1158 size_t copyOffset = 0;
1165 for (
size_t i = 0; i < matches; i++)
1169 size_t copyLength = (matchPos - 1) - _start;
1171 if (copyLength != 0)
1173 copyData(copyOffset, source + _start, copyLength);
1174 copyOffset += copyLength;
1179 copyData(copyOffset, newPtr, newLength);
1180 copyOffset += newLength;
1182 _start = matchPos + needleLength - 1;
1185 if (_start < sourceLength)
1187 copyData(copyOffset, source + _start, sourceLength - _start);
1194 size_t growth = (newLength - needleLength) * matches;
1197 size_t copyOffset = 0;
1204 openGap(0, growth, sourceLength);
1207 for (
size_t i = 0; i < matches; i++)
1211 size_t copyLength = (matchPos - 1) - _start;
1213 if (copyLength != 0)
1215 copyData(copyOffset, source + _start, copyLength);
1216 copyOffset += copyLength;
1221 copyData(copyOffset, newPtr, newLength);
1222 copyOffset += newLength;
1224 _start = matchPos + needleLength - 1;
1227 if (_start < sourceLength)
1229 copyData(copyOffset, source + _start, sourceLength - _start);
1238 if (!newNeedleIsASCII) this->
setIsASCII(
false);
1274 if (rangeLength == 0)
1279 char *bufferData =
getData() + startPos;
1281 for (
size_t i = 0; i < rangeLength; i++)
1283 *bufferData = tolower(*bufferData);
1315 if (rangeLength == 0)
1320 char *bufferData =
getData() + startPos;
1322 for (
size_t i = 0; i < rangeLength; i++)
1324 *bufferData = toupper(*bufferData);
1348 return this->
upper(_start, _range);
1353 size_t outTableLength = tableo->
getLength();
1357 size_t inTableLength = tablei->
getLength();
1362 bool padInserted =
false;
1363 bool padIsASCII = ((padChar & 0x80) == 0);
1368 if (startPos >
getLength() || range == 0)
1374 char *scanPtr =
getData() + startPos - 1;
1375 size_t scanLength = range;
1377 bool translateIsASCII =
true;
1378 while (scanLength-- != 0)
1383 if (tablei != OREF_NULLSTRING)
1390 position = ((size_t)ch) & 0xff;
1392 if (position != (
size_t)(-1))
1394 if (position < outTableLength)
1397 *scanPtr = *(outTable + position);
1398 if (*scanPtr & 0x80) translateIsASCII =
false;
1402 *scanPtr = (char)padChar;
1409 if (!translateIsASCII) this->
setIsASCII(
false);
1410 else if (padInserted && !padIsASCII) this->
setIsASCII(
false);
1454 if ((offset + len - 1) > other->
getLength())
1498 if ((offset + len - 1) > other->
getLength())
1588 if (_matchChar == matchSet->
getChar(i))
1621 _matchChar = toupper((
int)_matchChar);
1627 if (_matchChar == toupper(matchSet->
getChar(i)))
1802 const char *nextSite = NULL;
1805 while (--_wordPos > 0 && _wordLength != 0)
1817 while (--count > 0 && _wordLength != 0)
1828 size_t gapSize =
dataLength - (deletePosition + length);
1830 closeGap(deletePosition, gapSize, length);
1859 bool padInserted =
false;
1860 bool padIsASCII = ((padChar & 0x80) == 0);
1865 const char padC =
' ';
1866 const size_t padL = 1;
1883 size_t writePos = 0;
1885 const char *nextSite = NULL;
1891 while (_wordLength != 0)
1894 copyData(writePos, _word, _wordLength);
1895 writePos += _wordLength;
1899 if (_wordLength == 0)
1906 setData(writePos, padChar, padLength);
1907 writePos += padLength;
1913 setData(writePos, padC, padL);
1920 if ( padLength > 1 )
1922 size_t growth = count * (padLength-1);
1932 setData(writePos, padC, padL);
1941 const char *nextSite = NULL;
1946 while (_wordLength != 0)
1949 copyData(writePos, _word, _wordLength);
1950 writePos += _wordLength;
1954 if (_wordLength != 0)
1956 setData(writePos, padChar, padLength);
1957 writePos += padLength;
void reportException(wholenumber_t error)
RexxBuffer * new_buffer(size_t s)
RexxInteger * new_integer(wholenumber_t v)
#define DEFAULT_BUFFER_LENGTH
codepoint_t optionalPadArgument(RexxObject *o, codepoint_t d, size_t p)
RexxString * stringArgument(RexxObject *object, RexxString *kind, size_t position)
size_t optionalPositive(RexxObject *o, size_t d, RexxString *kind, size_t p)
size_t optionalNonNegative(RexxObject *o, size_t d, RexxString *kind, size_t p)
size_t optionalLengthArgument(RexxObject *o, size_t d, size_t p)
size_t optionalPositionArgument(RexxObject *o, size_t d, size_t p)
RexxString * optionalStringArgument(RexxObject *o, RexxString *d, RexxString *kind, size_t p)
#define Error_Incorrect_method_position
#define Error_Incorrect_method_length
#define memory_mark(oref)
RexxObject * new_object(size_t s)
#define flatten_reference(oref, envel)
#define CLASS_CREATE(name, id, className)
#define memory_mark_general(oref)
#define setUpFlatten(type)
RexxString * new_string(const char *s, stringsize_t l)
stringsize_t positionArgument(RexxObject *argument, size_t position)
stringsize_t lengthArgument(RexxObject *argument, size_t position)
static const wholenumber_t MAX_WHOLENUMBER
static wholenumber_t minVal(wholenumber_t n1, wholenumber_t n2)
void setDataLength(size_t l)
void copyData(size_t offset, const char *string, size_t l)
void setBehaviour(RexxBehaviour *b)
RexxMutableBuffer * newRexx(RexxObject **, size_t, size_t)
RexxInteger * isASCIIRexx()
RexxInteger * caselessLastPos(RexxString *needle, RexxInteger *_start, RexxInteger *_range)
RexxMutableBuffer * caselessChangeStr(RexxString *needle, RexxString *newNeedle, RexxInteger *countArg)
RexxMutableBuffer * translate(RexxString *tableo, RexxString *tablei, RexxString *pad, RexxInteger *, RexxInteger *)
RexxMutableBuffer * appendCstring(const char *, size_t blength)
void closeGap(size_t offset, size_t _size, size_t tailSize)
bool primitiveCaselessMatch(stringsize_t start, RexxString *other, stringsize_t offset, stringsize_t len)
RexxString * subchar(RexxInteger *startPosition)
void setData(size_t offset, codepoint_t character, size_t l)
void openGap(size_t offset, size_t _size, size_t tailSize)
void setIsASCII(bool value=true)
RexxMutableBuffer * mydelete(RexxObject *, RexxObject *)
RexxArray * subWords(RexxInteger *, RexxInteger *)
RexxMutableBuffer * changeStr(RexxString *needle, RexxString *newNeedle, RexxInteger *countArg)
void liveGeneral(int reason)
RexxInteger * verify(RexxString *, RexxString *, RexxInteger *, RexxInteger *)
RexxMutableBuffer * lower(RexxInteger *_start, RexxInteger *_length)
static void createInstance()
void flatten(RexxEnvelope *envelope)
const char * getStringData()
RexxMutableBuffer * append(RexxObject *)
RexxInteger * posRexx(RexxString *needle, RexxInteger *_start, RexxInteger *_range)
RexxMutableBuffer * space(RexxInteger *space_count, RexxString *pad)
RexxMutableBuffer * delWord(RexxInteger *position, RexxInteger *plength)
RexxInteger * wordPos(RexxString *, RexxInteger *)
bool primitiveMatch(stringsize_t start, RexxString *other, stringsize_t offset, stringsize_t len)
void setIsASCIIChecked(bool value=true)
size_t setDataLength(size_t l)
RexxInteger * caselessWordPos(RexxString *, RexxInteger *)
RexxObject * setBufferLength(size_t)
RexxInteger * caselessMatch(RexxInteger *start_, RexxString *other, RexxInteger *offset_, RexxInteger *len_)
RexxMutableBuffer * upper(RexxInteger *_start, RexxInteger *_length)
RexxInteger * countStrRexx(RexxString *needle)
RexxInteger * matchChar(RexxInteger *position_, RexxString *matchSet)
void copyData(size_t offset, const char *string, size_t l)
RexxString * makeString()
void adjustGap(size_t offset, size_t _size, size_t _newSize)
RexxObject * lengthRexx()
RexxInteger * caselessCountStrRexx(RexxString *needle)
RexxInteger * wordLength(RexxInteger *)
RexxInteger * wordIndex(RexxInteger *)
RexxObject * setBufferSize(RexxInteger *)
static RexxClass * classInstance
void ensureCapacity(size_t addedLength)
RexxInteger * lastPos(RexxString *needle, RexxInteger *_start, RexxInteger *_range)
RexxMutableBuffer * overlay(RexxObject *, RexxObject *, RexxObject *, RexxObject *)
RexxInteger * caselessMatchChar(RexxInteger *position_, RexxString *matchSet)
char * setCapacity(size_t newLength)
RexxMutableBuffer * replaceAt(RexxObject *str, RexxObject *pos, RexxObject *len, RexxObject *pad)
char getCharB(size_t offset)
RexxString * subWord(RexxInteger *, RexxInteger *)
RexxString * primitiveMakeString()
RexxInteger * match(RexxInteger *start_, RexxString *other, RexxInteger *offset_, RexxInteger *len_)
RexxInteger * caselessPos(RexxString *needle, RexxInteger *_start, RexxInteger *_range)
RexxString * word(RexxInteger *)
RexxString * substr(RexxInteger *startPosition, RexxInteger *len, RexxString *pad)
RexxMutableBuffer * insert(RexxObject *, RexxObject *, RexxObject *, RexxObject *)
void sendMessage(RexxString *, RexxArray *, RexxDirectory *, ProtectedObject &)
bool messageSend(RexxString *, RexxObject **, size_t, size_t, ProtectedObject &, bool processUnknown=true, bool dynamicTarget=true)
RexxObject * makeArrayRexx()
const char * getStringData()
static size_t pos(const char *stringData, size_t haystack_length, RexxString *needle, size_t _start, size_t _range)
static RexxInteger * caselessWordPos(const char *data, size_t length, RexxString *phrase, RexxInteger *pstart)
static RexxInteger * wordIndex(const char *data, size_t length, RexxInteger *position)
static RexxArray * subWords(const char *data, size_t length, RexxInteger *position, RexxInteger *plength)
static bool checkIsASCII(const char *s, size_t length)
static size_t memPos(const char *string, size_t length, char target)
static void skipBlanks(const char **String, size_t *StringLength)
static size_t caselessLastPos(const char *stringData, size_t haystackLen, RexxString *needle, size_t _start, size_t range)
static size_t wordCount(const char *String, size_t StringLength)
static RexxString * subWord(const char *data, size_t length, RexxInteger *position, RexxInteger *plength)
static int caselessCompare(const char *, const char *, size_t)
static RexxInteger * lastPosRexx(const char *stringData, size_t haystackLen, RexxString *needle, RexxInteger *_start, RexxInteger *_range)
static size_t caselessPos(const char *stringData, size_t haystack_length, RexxString *needle, size_t _start, size_t _range)
static size_t nextWord(const char **String, size_t *StringLength, const char **NextString)
static RexxInteger * wordPos(const char *data, size_t length, RexxString *phrase, RexxInteger *pstart)
static RexxInteger * wordLength(const char *data, size_t length, RexxInteger *position)
static RexxArray * makearray(const char *start, size_t length, RexxString *separator)
static size_t countStr(const char *hayStack, size_t hayStackLength, RexxString *needle)
static size_t caselessCountStr(const char *hayStack, size_t hayStackLength, RexxString *needle)
static RexxInteger * verify(const char *data, size_t stringLen, RexxString *ref, RexxString *option, RexxInteger *_start, RexxInteger *range)
static RexxString * word(const char *data, size_t length, RexxInteger *position)
static RexxString * subchar(const char *stringData, size_t stringLength, RexxInteger *positionArg)
static RexxString * substr(const char *, size_t, RexxInteger *, RexxInteger *, RexxString *)
static RexxInteger * posRexx(const char *stringData, size_t length, RexxString *needle, RexxInteger *pstart, RexxInteger *range)