-
Minor detail:
Code:
!(pBuffer[i+k] == Keywords[j][k])
would be easier to read as:
Code:
(pBuffer[i+k] != Keywords[j][k])
(And it's shorter to write).
Also, along the lines of what dwks says, there is a lot of code repetition in your functions still - particularly the bit that "take next character and output either itself or >/<. I think all of the loops can be translated into a generic function that loops around until some end condition - perhaps use strchr() to see if it's in a list of characters to terminate the current colour?
--
Mats
-
I was just reading through this thread quickly, and I noticed something that I thought I should comment on:
Code:
(ch == '<')? SS << "<" : (ch == '>')? SS << ">" : SS << ch;
That might be easier to read as
Code:
SS << (ch == '<' ? "<" : (ch == '>' ? ">" : ch));
I really don't like nesting the conditional operator, though, so I'd suggest using if/else or switch instead. Or, better yet, perhaps something like this:
Code:
const char *find = "<>";
const char *replace[] = {"<", ">"};
const char *p;
if((p = strchr(find, ch))) SS << replace[p - find];
else SS << ch;
But maybe that's just overkill. ;)