]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_parser.C
Hopefully fix the problem with stateText() in lyxfont.C
[lyx.git] / src / mathed / math_parser.C
index 289d6a1f417c9a23810428970482b82ff31898aa..2c8c7053cfaec4d5abacf8e7662dac005ab000bb 100644 (file)
@@ -7,7 +7,7 @@
  *
  *  Dependencies: Xlib, XForms
  *
- *  Copyright: (c) 1996, Alejandro Aguilar Sierra
+ *  Copyright: 1996, Alejandro Aguilar Sierra
  *
  *   Version: 0.8beta.
  *
@@ -30,6 +30,9 @@
 #include "math_root.h"
 #include "debug.h"
 
+using std::istream;
+using std::endl;
+
 enum {
        FLAG_BRACE      = 1,    //  A { needed
        FLAG_BRACE_ARG  = 2,    //  Next { is argument
@@ -98,14 +101,16 @@ char * strnew(char const * s)
 }
 
 
-static void mathPrintError(char const * msg) 
+static
+void mathPrintError(char const * msg) 
 {
        lyxerr << "Line ~" << yylineno << ": Math parse error: "
               << msg << endl;
 }
 
 
-static void LexInitCodes()
+static
+void LexInitCodes()
 {
    for (int i = 0;  i <= 255; ++i)     {
      if (isalpha(i)) lexcode[i] = LexAlpha;
@@ -134,7 +139,8 @@ static void LexInitCodes()
 }
 
 
-static char LexGetArg(char lf, bool accept_spaces= false)
+static
+char LexGetArg(char lf, bool accept_spaces= false)
 {
        char rg;
        char * p = &yytext[0];
@@ -170,7 +176,8 @@ static char LexGetArg(char lf, bool accept_spaces= false)
 }
 
 
-static int yylex(void)
+static
+int yylex(void)
 {
    static int init_done = 0;
    unsigned char c;
@@ -232,7 +239,7 @@ static int yylex(void)
               *p = c;
               yyis->get(cc);
               c = cc;
-              p++;
+              ++p;
            }
            *p = '\0';
            if (yyis->good()) yyis->putback(c);
@@ -241,10 +248,10 @@ static int yylex(void)
               if (l->token == LM_TK_BEGIN || l->token == LM_TK_END) { 
                  int i;
                  LexGetArg('{');
-//               for (i= 0; i<5 && strncmp(yytext, latex_mathenv[i],
-//                             strlen(latex_mathenv[i])); i++);
+//               for (i = 0; i < 5 && strncmp(yytext, latex_mathenv[i],
+//                             strlen(latex_mathenv[i])); ++i);
                  
-                 for (i = 0; i < 6 && strcmp(yytext, latex_mathenv[i]); i++);
+                 for (i = 0; i < 6 && strcmp(yytext, latex_mathenv[i]); ++i);
                  yylval.i = i;
               } else
               if (l->token == LM_TK_SPACE) 
@@ -330,7 +337,7 @@ LyxArrayBase * mathed_parse(unsigned flags, LyxArrayBase * array,
    int brace = 0;
    int acc_brace = 0;
    int acc_braces[8];
-   MathParInset * mt = (mtx) ? *mtx: 0;//(MathParInset*)0;
+   MathParInset * mt = (mtx) ? *mtx : 0;//(MathParInset*)0;
     MathedRowSt * crow = (mt) ? mt->getRowSt() : 0;
 
    ++plevel;
@@ -399,7 +406,7 @@ LyxArrayBase * mathed_parse(unsigned flags, LyxArrayBase * array,
       }
     case LM_TK_OPEN:
       {
-       brace++;
+       ++brace;
        if  (accent && tprev == LM_TK_ACCENT) {
            acc_braces[acc_brace++] = brace;
            break;
@@ -418,14 +425,14 @@ LyxArrayBase * mathed_parse(unsigned flags, LyxArrayBase * array,
       }
     case LM_TK_CLOSE:
       {
-        brace--;        
+        --brace;        
         if (brace < 0) {
            mathPrintError("Unmatching braces");
            panic = true;
            break;
         }
         if (acc_brace && brace == acc_braces[acc_brace-1]-1) {
-            acc_brace--;
+            --acc_brace;
             break;
         }
         if (flags & FLAG_BRACE_FONT) {
@@ -435,7 +442,7 @@ LyxArrayBase * mathed_parse(unsigned flags, LyxArrayBase * array,
            break;
         }
         if (brace == 0 && (flags & FLAG_BRACE_LAST)) {
-           plevel--;
+           --plevel;
            return array;
         } else {
            data.Insert ('}', LM_TC_TEX);
@@ -461,7 +468,7 @@ LyxArrayBase * mathed_parse(unsigned flags, LyxArrayBase * array,
     case ']':
       {
          if (flags & FLAG_BRACK_END) {
-             plevel--;
+             --plevel;
              return array;
          } else
            data.Insert (']');
@@ -625,7 +632,7 @@ LyxArrayBase * mathed_parse(unsigned flags, LyxArrayBase * array,
     case LM_TK_RIGHT:
       {
         if (flags & FLAG_RIGHT) { 
-           plevel--;
+           --plevel;
            return array;
         } else {
            mathPrintError("Unmatched right delimiter");
@@ -684,7 +691,7 @@ LyxArrayBase * mathed_parse(unsigned flags, LyxArrayBase * array,
             data.Insert(doAccent(p), p->getTCode());
           else
             data.Insert(p, p->getTCode());
-          for (int i = 0; p->setArgumentIdx(i); i++)
+          for (int i = 0; p->setArgumentIdx(i); ++i)
             p->SetData(mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST));
        }
        else {
@@ -704,7 +711,7 @@ LyxArrayBase * mathed_parse(unsigned flags, LyxArrayBase * array,
         // debug info [made that conditional -JMarc]
         if (lyxerr.debugging(Debug::MATHED))
                 lyxerr << "[" << yylval.i << "]" << endl;
-        plevel--;
+        --plevel;
         if (mt) { // && (flags & FLAG_END)) {
            mt->SetData(array);
            array = 0;
@@ -766,7 +773,7 @@ LyxArrayBase * mathed_parse(unsigned flags, LyxArrayBase * array,
                 data.Insert(p, p->getTCode());
                 p->setArgumentIdx(0);
                 mathed_parse(FLAG_END, p->GetData(), reinterpret_cast<MathParInset**>(&p));
-//              for (int i= 0; p->setArgumentIdx(i); i++)
+//              for (int i = 0; p->setArgumentIdx(i); ++i)
 //                p->SetData(mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST));
             } else 
               mathPrintError("Unrecognized environment");
@@ -834,7 +841,7 @@ LyxArrayBase * mathed_parse(unsigned flags, LyxArrayBase * array,
        break;
     }
    }
-   plevel--;
+   --plevel;
    return array;
 }