One more round of simplification and fixing.
git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@407 94f232f2-1747-11df-bad5-a5bfde151594
This commit is contained in:
committed by
Alexandre Deckner
parent
f9977c07c1
commit
a26e66b548
@@ -317,25 +317,19 @@ void
|
|||||||
URLInputGroup::URLTextView::InsertText(const char* inText, int32 inLength,
|
URLInputGroup::URLTextView::InsertText(const char* inText, int32 inLength,
|
||||||
int32 inOffset, const text_run_array* inRuns)
|
int32 inOffset, const text_run_array* inRuns)
|
||||||
{
|
{
|
||||||
char* buffer = NULL;
|
// Filter all line breaks, note that inText is not terminated.
|
||||||
|
if (inLength == 1) {
|
||||||
if (strpbrk(inText, "\r\n") && inLength <= 1024) {
|
if (*inText == '\n' || *inText == '\r')
|
||||||
buffer = (char*)malloc(inLength + 1);
|
BTextView::InsertText(" ", 1, inOffset, inRuns);
|
||||||
|
else
|
||||||
if (buffer) {
|
BTextView::InsertText(inText, 1, inOffset, inRuns);
|
||||||
strlcpy(buffer, inText, inLength + 1);
|
} else {
|
||||||
|
BString filteredText(inText, inLength);
|
||||||
for (int32 i = 0; i < inLength; i++) {
|
filteredText.ReplaceAll('\n', ' ');
|
||||||
if (buffer[i] == '\r' || buffer[i] == '\n')
|
filteredText.ReplaceAll('\r', ' ');
|
||||||
buffer[i] = ' ';
|
BTextView::InsertText(filteredText.String(), inLength, inOffset,
|
||||||
}
|
inRuns);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BTextView::InsertText(buffer ? buffer : inText, inLength, inOffset,
|
|
||||||
inRuns);
|
|
||||||
|
|
||||||
free(buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user