Better algorithm for function convert_crlf().
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8009 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
de7b3456c4
commit
97149d19a5
17
src/Fl_x.cxx
17
src/Fl_x.cxx
@ -280,15 +280,13 @@ int fl_ready() {
|
|||||||
|
|
||||||
// replace \r\n by \n
|
// replace \r\n by \n
|
||||||
static void convert_crlf(unsigned char *string, long& len) {
|
static void convert_crlf(unsigned char *string, long& len) {
|
||||||
unsigned char *p = string, *q = p + len;
|
unsigned char *a, *b;
|
||||||
while (p + 1 < q) {
|
a = b = string;
|
||||||
if (*p == '\r' && *(p + 1) == '\n') {
|
while (*a) {
|
||||||
memmove(p, p + 1, q - p - 1);
|
if (*a == '\r' && a[1] == '\n') { a++; len--; }
|
||||||
q--;
|
else *b++ = *a++;
|
||||||
len--;
|
|
||||||
}
|
|
||||||
p++;
|
|
||||||
}
|
}
|
||||||
|
*b = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
@ -571,7 +569,6 @@ void fl_init_xim()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void fl_open_display() {
|
void fl_open_display() {
|
||||||
if (fl_display) return;
|
if (fl_display) return;
|
||||||
|
|
||||||
@ -977,8 +974,8 @@ int fl_handle(const XEvent& thisevent)
|
|||||||
if (!remaining) break;
|
if (!remaining) break;
|
||||||
}
|
}
|
||||||
if (buffer) {
|
if (buffer) {
|
||||||
convert_crlf(buffer, bytesread);
|
|
||||||
buffer[bytesread] = 0;
|
buffer[bytesread] = 0;
|
||||||
|
convert_crlf(buffer, bytesread);
|
||||||
}
|
}
|
||||||
Fl::e_text = buffer ? (char*)buffer : (char *)"";
|
Fl::e_text = buffer ? (char*)buffer : (char *)"";
|
||||||
Fl::e_length = bytesread;
|
Fl::e_length = bytesread;
|
||||||
|
Loading…
Reference in New Issue
Block a user