* The RTF parser only accepted lower case hex numbers which prevented the

prices.rtf to be parsed correctly as reported by humdinger.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36884 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2010-05-21 11:39:19 +00:00
parent db90422897
commit b70311a396
+21 -7
View File
@@ -1,17 +1,25 @@
/* /*
* Copyright 2004-2005, Axel Dörfler, [email protected]. All rights reserved. * Copyright 2004-2010, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#include "RTF.h" #include "RTF.h"
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <DataIO.h> #include <DataIO.h>
#include <stdlib.h>
#include <stdio.h> //#define TRACE_RTF
#include <string.h> #ifdef TRACE_RTF
#include <ctype.h> # define TRACE(x...) printf(x)
#else
# define TRACE(x...) ;
#endif
static const char *kDestinationControlWords[] = { static const char *kDestinationControlWords[] = {
@@ -49,7 +57,8 @@ read_char(BDataIO &stream, bool endOfFileAllowed) throw (status_t)
static int32 static int32
parse_integer(char first, BDataIO &stream, char &_last, int32 base) throw (status_t) parse_integer(char first, BDataIO &stream, char &_last, int32 base)
throw (status_t)
{ {
const char *kDigits = "0123456789abcdef"; const char *kDigits = "0123456789abcdef";
int32 integer = 0; int32 integer = 0;
@@ -63,7 +72,7 @@ parse_integer(char first, BDataIO &stream, char &_last, int32 base) throw (statu
while (true) { while (true) {
int32 pos = 0; int32 pos = 0;
for (; pos < base; pos++) { for (; pos < base; pos++) {
if (kDigits[pos] == digit) { if (kDigits[pos] == tolower(digit)) {
integer = integer * base + pos; integer = integer * base + pos;
count++; count++;
break; break;
@@ -634,6 +643,8 @@ Command::Parse(char first, BDataIO &stream, char &last) throw (status_t)
} else } else
fName.SetTo(name, length); fName.SetTo(name, length);
TRACE("command: %s\n", fName.String());
// parse numeric option // parse numeric option
if (c == '-') if (c == '-')
@@ -659,6 +670,9 @@ Command::Parse(char first, BDataIO &stream, char &last) throw (status_t)
if (isspace(last)) if (isspace(last))
last = read_char(stream); last = read_char(stream);
} }
if (HasOption())
TRACE(" option: %ld\n", fOption);
} }