]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_parser.C
removed a warning from screen and added CFLAGS in lyx.spec.in.
[lyx.git] / src / mathed / math_parser.C
index eee0c2b370dcac2a35322cde4857513f0742f046..e2c136d79fdd3b6ddf95b4decc376307e539bf04 100644 (file)
@@ -28,7 +28,7 @@
 #include "math_inset.h"
 #include "math_macro.h"
 #include "math_root.h"
-#include "error.h"
+#include "debug.h"
 
 enum {
        FLAG_BRACE      = 1,    //  A { needed
@@ -47,7 +47,7 @@ YYSTYPE yylval;
 
 static short mathed_env = LM_EN_INTEXT;
 
-char *mathed_label = NULL;
+char *mathed_label = 0;
 
 char const *latex_mathenv[] = { 
    "math", 
@@ -100,7 +100,8 @@ char *strnew(char const* s)
 
 static void mathPrintError(char const *msg) 
 {
-    fprintf(stderr, "Line ~%d: Math parse error: %s\n", yylineno, msg); 
+       lyxerr << "Line ~" << yylineno << ": Math parse error: "
+              << msg << endl;
 }
 
 
@@ -144,13 +145,15 @@ static char LexGetArg(char lf, bool accept_spaces=false)
       if (c>' ') {
         if (!lf) lf = c; else
         if (c!=lf)
-          fprintf(stderr, "Math parse error: unexpected '%c'\n", c);
+                lyxerr << "Math parse error: unexpected '"
+                       << c << "'" << endl;
         break;
       }
    }
    rg = (lf=='{') ? '}': ((lf=='[') ? ']': ((lf=='(') ? ')': 0));
    if (!rg) {
-      fprintf(stderr, "Math parse error: unknown bracket '%c'\n", lf);
+          lyxerr << "Math parse error: unknown bracket '"
+                 << lf << "'" << endl;
       return '\0';
    } 
    do {
@@ -320,7 +323,7 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m
    int brace = 0;
    int acc_brace = 0;
    int acc_braces[8];
-   MathParInset *mt = (mtx) ? *mtx: 0;//(MathParInset*)NULL;
+   MathParInset *mt = (mtx) ? *mtx: 0;//(MathParInset*)0;
     MathedRowSt *crow = (mt) ? mt->getRowSt(): 0;
 
    plevel++;
@@ -461,16 +464,16 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m
     case '^':
       {  
         MathParInset *p = new MathParInset(size, "", LM_OT_SCRIPT);
-        LyxArrayBase * ar = mathed_parse(FLAG_BRACE_OPT|FLAG_BRACE_LAST, NULL);
+        LyxArrayBase * ar = mathed_parse(FLAG_BRACE_OPT|FLAG_BRACE_LAST, 0);
         p->SetData(ar);
-//      fprintf(stderr, "UP[%d]", p->GetStyle());
+//      lyxerr << "UP[" << p->GetStyle() << "]" << endl;
         data.Insert (p, LM_TC_UP);
         break;
       }
     case '_':
       {
         MathParInset *p = new MathParInset(size, "", LM_OT_SCRIPT);
-        LyxArrayBase * ar = mathed_parse(FLAG_BRACE_OPT|FLAG_BRACE_LAST, NULL);
+        LyxArrayBase * ar = mathed_parse(FLAG_BRACE_OPT|FLAG_BRACE_LAST, 0);
         p->SetData(ar);
         data.Insert (p, LM_TC_DOWN);
         break;
@@ -480,7 +483,7 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m
       {
         if (binset) {
            binset->SetLimits((bool)(yylval.l->id));
-           binset = NULL;
+           binset = 0;
         }
         break;
       }
@@ -493,8 +496,8 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m
         } else 
            mathPrintError("Unexpected tab");
         // debug info. [made that conditional -JMarc]
-        if (lyxerr.debugging(Error::MATHED))
-                fprintf(stderr, "%d %d\n", data.getCol(), mt->GetColumns());
+        if (lyxerr.debugging(Debug::MATHED))
+                lyxerr << data.getCol() << " " << mt->GetColumns() << endl;
        break;
       }
     case LM_TK_NEWLINE:
@@ -600,16 +603,16 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m
         lfd=yylex();
         if (lfd==LM_TK_SYM || lfd==LM_TK_STR || lfd==LM_TK_BOP|| lfd==LM_TK_SPECIAL)
           lfd = (lfd==LM_TK_SYM) ? yylval.l->id: yylval.i;
-//      fprintf(stderr, "L[%d %c]", lfd, lfd);
+//      lyxerr << "L[" << lfd << " " << lfd << "]";
         LyxArrayBase* a = mathed_parse(FLAG_RIGHT);
         rgd=yylex();
-//      fprintf(stderr, "R[%d]", rgd);
+//      lyxerr << "R[" << rgd << "]";
         if (rgd==LM_TK_SYM || rgd==LM_TK_STR || rgd==LM_TK_BOP || rgd==LM_TK_SPECIAL)
           rgd = (rgd==LM_TK_SYM) ? yylval.l->id: yylval.i;      
         MathDelimInset *dl = new MathDelimInset(lfd, rgd);
         dl->SetData(a);
         data.Insert(dl, LM_TC_ACTIVE_INSET);
-//      fprintf(stderr, "RL[%d %d]", lfd, rgd);
+//      lyxerr << "RL[" << lfd << " " << rgd << "]";
         break;
       }
     case LM_TK_RIGHT:
@@ -691,12 +694,12 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m
          if (mathed_env != yylval.i && yylval.i!=LM_EN_ARRAY)
           mathPrintError("Unmatched environment");
         // debug info [made that conditional -JMarc]
-        if (lyxerr.debugging(Error::MATHED))
-                fprintf(stderr, "[%d]\n", yylval.i);
+        if (lyxerr.debugging(Debug::MATHED))
+                lyxerr << "[" << yylval.i << "]" << endl;
         plevel--;
         if (mt) { // && (flags & FLAG_END)) {
            mt->SetData(array);
-           array = NULL;
+           array = 0;
         }
         return array;
       }
@@ -723,7 +726,7 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m
                 break;
             }
             if (!mt) {
-                mathPrintError("NULL paragraph.");
+                mathPrintError("0 paragraph.");
                 panic = true;
             }
             
@@ -745,10 +748,10 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m
             }
                               
 #ifdef DEBUG
-              fprintf(stderr, "MATH BEGIN[%d]\n", mathed_env);
+            lyxerr << "MATH BEGIN[" << mathed_env << "]" << endl;
 #endif
         } else {
-//          fprintf(stderr, "MATHCRO[%s]",yytext);
+//          lyxerr << "MATHCRO[" << yytext << "]";
             MathMacro* p = 
               MathMacroTable::mathMTable.getMacro(yytext);
             if (p) {
@@ -783,7 +786,7 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m
          if (rg != '}') {
             mathPrintError("Expected '{'");
              // debug info
-             fprintf(stderr, "[%s]\n", yytext); fflush(stderr);
+            lyxerr << "[" << yytext << "]" << endl;
              panic = true;
             break;
          } 
@@ -799,19 +802,19 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m
                  mathed_label = strnew(yytext);
          }
 #ifdef DEBUG
-         fprintf(stderr, "Label[%d]\n", mathed_label);
+         lyxerr << "Label[" << mathed_label << "]" << endl;
 #endif
          break;
        } 
      default:
        mathPrintError("Unrecognized token");
        // debug info
-       fprintf(stderr, "[%d %s]\n", t, yytext);
+       lyxerr << "[" << t << " " << yytext << "]" << endl;
        break;
     }
     tprev = t;
     if (panic) {
-       fprintf(stderr, " Math Panic, expect problems!\n"); 
+           lyxerr << " Math Panic, expect problems!" << endl;
        //   Search for the end command. 
        do t = yylex (); while (t != LM_TK_END && t);
     } else