This patch replaces a couple of 255s with (N(yytext)-1), which keeps up with 
changes in the size of yytext. As a bonus it communicates with me what the 
significance of the value to me. The macro recogniser could still be improved 
(take 1 character and look for multiple character if the catcode, aka lexcode, 
is the right thing). I think the right thing is letter, but check the nearest 
copy of the TeXbook.
Once that has happenned the spaces can be icorporated into the main hash table.

This patch does not do the last stage because MathEd scares me :-)

If yytext changes into wide charcaters then the use of N macro will mean the 
patch will continue to do the right thing. The N macro is declared in several 
X11 headers, I think.

P.S. If you I going to ive you new math_hash.C, do you want ANSI C or a C++ 
class? If the latter what do you want in called?

Duncan (-:

-- src/mathed/math_parser.C.dist       Tue Feb 20 17:48:28 2001
+++ src/mathed/math_parser.C    Tue Feb 20 18:02:32 2001
@@ -46,6 +46,10 @@
 #include "mathed/support.h"
 #include "boost/array.hpp"
 
+#ifndef N
+#define N(x) (sizeof(x)/sizeof(x[0]))
+#endif /* N */
+
 using std::istream;
 using std::endl;
 
@@ -210,7 +214,7 @@
       if (c == lf) ++bcnt;
       if (c == rg) --bcnt;
       if ((c > ' ' || (c == ' ' && accept_spaces)) && bcnt > 0) *(p++) = c;
-   } while (bcnt > 0 && yyis->good() && p - yytext.data() < 255);
+   } while (bcnt > 0 && yyis->good() && p - yytext.data() < (N(yytext)-1));
    *p = '\0';
    return rg;
 }
@@ -310,7 +314,7 @@
         if (lexcode[c] == LexAlpha || lexcode[c] == LexDigit) {
            char * p = &yytext[0];
            while ((lexcode[c] == LexAlpha || lexcode[c] == LexDigit)
-                  && p - yytext.data() < 255) {
+                  && p - yytext.data() < (N(yytext)-1)) {
               *p = c;
               yyis->get(cc);
               c = cc;


-- 
Duncan (-:
"software industry, the: unique industry where selling substandard goods is
legal and you can charge extra for fixing the problems."


Reply via email to