diff --git a/graf2d/graf/src/TLatex.cxx b/graf2d/graf/src/TLatex.cxx index 6809766..7c2e3aa 100644 --- a/graf2d/graf/src/TLatex.cxx +++ b/graf2d/graf/src/TLatex.cxx @@ -2136,201 +2136,222 @@ Int_t TLatex::CheckLatexSyntax(TString &text) { // Check if the Latex syntax is correct - const Char_t *kWord1[] = {"{}^{","{}_{","^{","_{","#scale{","#color{","#font{","#sqrt{","#[]{","#{}{","#||{", - "#bar{","#vec{","#dot{","#hat{","#ddot{","#acute{","#grave{","#check{","#tilde{","#slash{","#bf{","#it{","#mbox{", - "\\scale{","\\color{","\\font{","\\sqrt{","\\[]{","\\{}{","\\||{","#(){","\\(){", - "\\bar{","\\vec{","\\dot{","\\hat{","\\ddot{","\\acute{","\\grave{","\\check{","\\bf{","\\it{","\\mbox{"}; // check for } - const Char_t *kWord2[] = {"#scale[","#color[","#font[","#sqrt[","#kern[","#lower[","\\scale[","\\color[","\\font[","\\sqrt[","\\kern[","\\lower["}; // check for ]{ + } - const Char_t *kWord3[] = {"#frac{","\\frac{","#splitline{","\\splitline{"}; // check for }{ then } - const Char_t *kLeft1[] = {"#left[","\\left[","#left{","\\left{","#left|","\\left|","#left(","\\left("}; - const Char_t *kLeft2[] = {"#[]{","#[]{","#{}{","#{}{","#||{","#||{","#(){","#(){"}; - const Char_t *kRight[] = {"#right]","\\right]","#right}","\\right}","#right|","\\right|","#right)","\\right)"}; - const Int_t lkWord1[] = {4,4,2,2,7,7,6,6,4,4,4,5,5,5,5,6,7,7,7,7,7,4,4,6,7,7,6,6,4,4,4,4,4,5,5,5,5,6,7,7,7,4,4,6}; - const Int_t lkWord2[] = {7,7,6,6,6,7,7,7,6,6,6,7} ; - const Int_t lkWord3[] = {6,6,11,11} ; - Int_t nkWord1 = 44, nkWord2 = 12, nkWord3 = 4; - Int_t i,k ; - Int_t nLeft1 , nRight , nOfLeft, nOfRight; - Int_t lLeft1 = 6 ; - Int_t lLeft2 = 4 ; - Int_t lRight = 7 ; - nLeft1 = nRight = 8 ; - nOfLeft = nOfRight = 0 ; - - Char_t buf[11] ; for (i=0;i<11;i++) buf[i]=0; - Bool_t opFound ; - Int_t opFrac = 0; + Int_t i=0,k=0 ; + + const Char_t *kWord1[] = {"{}^{","{}_{","^{","_{", + "#scale{", "#color{", "#font{", "#sqrt{", "#[]{", "#{}{", "#||{", "#(){", "#bar{", "#vec{", "#dot{", "#hat{", "#ddot{", "#acute{", "#grave{", "#check{", "#tilde{", "#slash{", "#bf{", "#it{", "#mbox{", + "\\scale{","\\color{","\\font{","\\sqrt{","\\[]{","\\{}{","\\||{","\\(){","\\bar{","\\vec{","\\dot{","\\hat{","\\ddot{","\\acute{","\\grave{","\\check{","\\tilde{","\\slash{","\\bf{","\\it{","\\mbox{"}; // check for } + Int_t nkWord1 = Int_t(sizeof(kWord1)/sizeof(kWord1[0])) ; // n = number of elements + Int_t lmaxkWord1=-1 ; Int_t * lkWord1 = new Int_t [nkWord1] ; for (i=0;ilmaxkWord1 ) { lmaxkWord1=lkWord1[i] ; } } // l = length of each element ('\\'='\', first backslash is escape character) + + const Char_t *kWord2[] = { "#scale[", "#color[", "#font[", "#sqrt[", "#kern[", "#lower[", + "\\scale[","\\color[","\\font[","\\sqrt[","\\kern[","\\lower["}; // check for ]{ then } + Int_t nkWord2 = Int_t(sizeof(kWord2)/sizeof(kWord2[0])) ; + Int_t lmaxkWord2=-1 ; Int_t * lkWord2 = new Int_t [nkWord2] ; for (i=0;ilmaxkWord2 ) { lmaxkWord2=lkWord2[i] ; } } + + const Char_t *kWord3[] = { "#frac{", "#splitline{", + "\\frac{","\\splitline{"}; // check for }{ then } + Int_t nkWord3 = Int_t(sizeof(kWord3)/sizeof(kWord3[0])) ; + Int_t lmaxkWord3=-1 ; Int_t * lkWord3 = new Int_t [nkWord3] ; for (i=0;ilmaxkWord3 ) { lmaxkWord3=lkWord3[i] ; } } + + const Char_t *kLeft1[] = { "#left[", "#left{", "#left|", "#left(", + "\\left[","\\left{","\\left|","\\left("}; + Int_t nkLeft1 = 8 ; + Int_t lkLeft1 = 6 ; + + const Char_t *kLeft2[] = { "#[]{", "#{}{", "#||{", "#(){", + "#[]{", "#{}{", "#||{", "#(){"}; // kLeft2 "=" kLeft1 + //Int_t nkLeft2 = 8 ; /// useless (nkLeft2=nkLeft1=nkLeft in the following) + Int_t lkLeft2 = 4 ; + + const Char_t *kRight[] = { "#right]", "#right}", "#right|", "#right)", + "\\right]","\\right}","\\right|","\\right)"}; + Int_t nkRight = 8 ; + Int_t lkRight = 7 ; + + Int_t lmaxkLeftRight = 7 ; //TMath::Max(lkLeft1,lkRight) ; + Int_t lmaxkWords = TMath::Max(TMath::Max(lmaxkWord1,lmaxkWord2),lmaxkWord3) ; // = 11 ("#splitline{") + + Int_t nOfWord1=0, nOfWord2=0, nOfWord3=0, nOfLeft=0, nOfRight=0 ; // number of occurences found in text + Int_t nOfCurly=0 ; // number of '{' or '}' brackets associated to an operator found in text + Int_t nOfSquareCurly =0, nOfCurlyCurly =0 ; // number of ']{' and '}{' mixed brackets found in text (associated to Word2 and Word3 type operators respectively) + Int_t nOfSquareCurlyOp=0, nOfCurlyCurlyOp=0 ; // number of Word2 (#op[]{}) and Word3 (#op{}{}) type operators found in text + + Int_t error=0 ; // return variable + Bool_t opFound=kFALSE ; // an operator has been found + + Char_t * buf = new Char_t[lmaxkWords] ; for (i=0;i 0) { + else if (nOfCurly > 0) { error = 1 ; fError = "Missing \"}\"" ; } - else if (nOfSquareBracket < 0) { - error = 1 ; - fError = "Missing \"[\"" ; - } - else if (nOfSquareBracket > 0) { - error = 1 ; - fError = "Missing \"]\"" ; - } + delete[] lkWord1 ; lkWord1=NULL ; + delete[] lkWord2 ; lkWord2=NULL ; + delete[] lkWord3 ; lkWord3=NULL ; + delete[] buf ; buf =NULL ; ERROR_END: return error ; }