// If delimiter is a space, it's part of the control word
@@ -163,7 +145,7 @@
}
*_text = 0; // Just put an end of string for the test, it can then be over-written again
- if ( !qstrncmp( tokenText.data()+1, "bin", 4 ) ) // Test the NULL too to avoid catching keywords starting with "bin"
+ if ( !memcmp( tokenText.data()+1, "bin", 4 ) )
{ // We have \bin, so we need to read the bytes
kdDebug(30515) << "Token:" << tokenText << endl;
if (value > 0)
@@ -173,26 +155,15 @@
binaryData.resize(value);
for (int i=0; i<value; i++)
{
- if (fileBufferPtr == fileBufferEnd)
- {
- const int n = infile->readBlock( fileBuffer.data(), fileBuffer.size() );
-
- if (n <= 0)
- {
- kdError(30515) << "\\bin stream hit end of file." << endl;
- type = RTFTokenizer::CloseGroup;
- break;
- }
- fileBufferPtr = (uchar *)fileBuffer.data();
- fileBufferEnd = (fileBufferPtr + n);
+ int n = nextChar();
+ if ( n <= 0 ) {
+ type = RTFTokenizer::CloseGroup;
+ break;
}
- binaryData[i]=*fileBufferPtr++;
+
+ binaryData[i] = n;
}
}
- else
- {
- kdError(30515) << "\\bin with negative value skipping" << endl;
- }
}
}
@@ -200,19 +171,13 @@
{
type = RTFTokenizer::ControlWord;
*_text++ = ch;
- if (fileBufferPtr == fileBufferEnd)
- {
- int n = infile->readBlock( fileBuffer.data(), fileBuffer.size() );
- if (n <= 0)
- {
- // Return CloseGroup on EOF
- type = RTFTokenizer::CloseGroup;
- return;
- }
- fileBufferPtr = (uchar *)fileBuffer.data();
- fileBufferEnd = (fileBufferPtr + n);
- }
+ int n = nextChar();
+
+ if ( n <= 0 ) {
+ type = RTFTokenizer::CloseGroup;
+ return;
+ }
ch = *fileBufferPtr++;
for(int i=0;i<2;i++)
{
@@ -220,22 +185,16 @@
value<<=4;
value=value|((ch + ((ch & 16) ? 0 : 9)) & 0xf);
- if (fileBufferPtr == fileBufferEnd)
- {
- int n = infile->readBlock( fileBuffer.data(), fileBuffer.size() );
+ int n = nextChar();