I use webcpp to automatically color the code snippets in my site...
and I found out that webcpp has a bug when a keyword appears
at the beginning of a line
(I have some Python code, where for example the functions are
defined with a "def" starting at the beginning of the line)
If you check the code in Engine.cpp, (version 0.8.4), you'll see
that when locating a keyword, parseKeys() is calling isKey() with
if(isKey(index-1, (index) + keys[i].size())) {
If the keyword appears at the beginning of the line (e.g. "def" in
Python code), then this causes member isKey to operate on
buffer[-1]...
I did this patch which seems to correct the problems with Python code...
Regards,
Thanassis.
--- engine.cpp Mon Jan 5 02:52:47 2004
+++ engine.cpp.fixed Sat Jul 26 20:17:41 2008
@@ -697,16 +697,23 @@
// asserts word boundaries for keywords ---------------------------------------
bool Engine::isKey(int before, int after) const {
I use webcpp to automatically color the code snippets in my site...
and I found out that webcpp has a bug when a keyword appears
at the beginning of a line
(I have some Python code, where for example the functions are
defined with a "def" starting at the beginning of the line)
If you check the code in Engine.cpp, (version 0.8.4), you'll see
that when locating a keyword, parseKeys() is calling isKey() with
if(isKey(index-1, (index) + keys[i].size())) {
If the keyword appears at the beginning of the line (e.g. "def" in
Python code), then this causes member isKey to operate on
buffer[-1]...
I did this patch which seems to correct the problems with Python code...
Regards,
Thanassis.
--- engine.cpp Mon Jan 5 02:52:47 2004
+++ engine.cpp.fixed Sat Jul 26 20:17:41 2008
@@ -697,16 +697,23 @@
// asserts word boundaries for keywords ---------------------------------------
bool Engine::isKey(int before, int after) const {
- if(buffer[before] == '#') {return false;}
- if(buffer[before] == '_') {return false;}
- if(buffer[after] == '_') {return false;}
- if(isalnum(buffer[before])) {return false;}
- if(isalnum(buffer[after])) {return false;}
+ if (before>=0 && before<buffer.size()) {
+ if(buffer[before] == '#') {return false;}
+ if(buffer[before] == '_') {return false;}
+ }
+ if (after>=0 && after<buffer.size())
+ if(buffer[after] == '_') {return false;}
+ if (before>=0 && before<buffer.size())
+ if(isalnum(buffer[before])) {return false;}
+ if (after>=0 && after<buffer.size())
+ if(isalnum(buffer[after])) {return false;}
Sorry, the patch apparently didn't survive...
Enclosing it now in a preformatted section
<pre>
--- engine.cpp Mon Jan 5 02:52:47 2004
+++ engine.cpp.fixed Sat Jul 26 20:17:41 2008
@@ -697,16 +697,23 @@
// asserts word boundaries for keywords ---------------------------------------
bool Engine::isKey(int before, int after) const {
- if(buffer[before] == '#') {return false;}
- if(buffer[before] == '_') {return false;}
- if(buffer[after] == '_') {return false;}
- if(isalnum(buffer[before])) {return false;}
- if(isalnum(buffer[after])) {return false;}
+ if (before>=0 && before<buffer.size()) {
+ if(buffer[before] == '#') {return false;}
+ if(buffer[before] == '_') {return false;}
+ }
+ if (after>=0 && after<buffer.size())
+ if(buffer[after] == '_') {return false;}
+ if (before>=0 && before<buffer.size())
+ if(isalnum(buffer[before])) {return false;}
+ if (after>=0 && after<buffer.size())
+ if(isalnum(buffer[after])) {return false;}
Last try: uuencoded patch... If this doesn't work, type it
yourself... (stupid web interfaces!)
begin 644 webcpp-0.8.4-src_webcpp_engine.cpp.patch
M+2TM(&5N9VEN92YC<'`)36]N($IA;B`@-2`P,CHU,CHT-R`R,#`T"BLK*R!E
M;F=I;F4N8W!P+F9I>&5D"5-A="!*=6P@,C8@,C`Z,3<Z-#$@,C`P.`I`0"`M
M-CDW+#$V("LV.3<L,C,@0$`*("\O(&%S<V5R=',@=V]R9"!B;W5N9&%R:65S
M(&9O<B!K97EW;W)D<R`M+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM
M+2TM+2TM+2T*(&)O;VP@16YG:6YE.CII<TME>2AI;G0@8F5F;W)E+"!I;G0@
M869T97(I(&-O;G-T('L*(`HM"6EF*&)U9F9E<EMB969O<F5=(#T]("<C)RD@
M("![<F5T=7)N(&9A;'-E.WT*+0EI9BAB=69F97);8F5F;W)E72`]/2`G7R<I
M("`@>W)E='5R;B!F86QS93M]"BT):68H8G5F9F5R6V%F=&5R72`@/3T@)U\G
M*2`@('MR971U<FX@9F%L<V4[?0HM"6EF*&ES86QN=6TH8G5F9F5R6V)E9F]R
M95TI*2![<F5T=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0E]"BL)"2`@("!]"B`)?0H@"7)E='5R;B!T<G5E.PH@?0H`
`
end
This bug was also reported in the Debian package here: http://bugs.debian.org/493131