/newlib/metod.awk
AWK | 671 lines | 564 code | 79 blank | 28 comment | 0 complexity | 60d154a4f8a56cf46d37f33335932837 MD5 | raw file
- ## Prefix="##{"
- ## Suffix="}"
- ## Enc="1251"
- ## End
-
-
-
-
-
-
-
- ##{A}
-
- ##{BEGIN}
-
-
-
- BEGIN {
-
-
-
-
-
- PicFline="";
- PicFOn=0;
-
- PicDir="picx/"
-
- BeginTeX="\\batchmode\\documentclass{article}\\begin{document}\\thispagestyle{empty}"
- EndTeX= "\\end{document}"
-
-
-
-
-
- OutTex="out.tex";
-
- CopyPicBat="tmpcppic.bat"
-
- ReadJobFile(JobFile);
-
-
-
- #InpFileList[1]="text.tex"
- #InpPatchFileList[1]="text2.tex"
-
- BlockCount=2;
-
- ERR=0;
-
-
- GoForFiles(InpFileList , 1);
-
- BorderBlocks=BlockCount;
- BlockCount++;
-
- GoForFiles(InpPatchFileList , 2);
-
-
-
- #ActAlabel["SistUrNeskResh"]=1;
-
- MkActualBandL();
-
- for (i in ActAlabel) ActLabel[i]=1
- for (i in ActBlabel) ActLabel[i]=1
-
- MkActLine(ActLabel);
-
-
- print("") >OutTex;
-
- PrintAll()
-
-
- #for (i in ActAlabel) print ("ActAlabel", i ,ActAlabel[i])
- #for (i in ActBlabel) print ("ActBlabel", i ,ActBlabel[i])
-
-
- #for (i in ActLabel) print ("ActLabel", i ,ActLabel[i], "Blok- " LabelToBlock[i])
-
- #for (i in ActBegin) print ("ActBegin", i ,ActBegin[i])
- #for (i in ActEnd) print ("ActEnd", i ,ActEnd[i])
- #for (i in IgnoreLine) print ("IgnoreLine", i ,IgnoreLine[i])
-
- #for (i in ActABlock) print ("ActABlock", i ,ActABlock[i])
- #for (i in ActBBlock) print ("ActBBlock", i ,ActBBlock[i])
-
-
-
-
-
- #for (i in BlockToFile) print ("BlockToFile", i ,BlockToFile[i])
-
- #for (i in LabelToBlock) print ("LabelToBlock", i , LabelToBlock[i])
-
- #for (i in BlockToBeginLine) print ("BlockToBeginLine", i , BlockToBeginLine[i])
-
- #for (i in BlockToEndLine) print ("BlockToEndLine", i , BlockToEndLine[i])
-
- #for (i in OldToNewBlock) print ("OldToNewBlock", i , OldToNewBlock[i])
- #for (i in NewToOldBlock) print ("NewToOldBlock", i , NewToOldBlock[i])
-
- #for (i in BlockToAref) print ("BlockToAref", i , BlockToAref[i])
- #for (i in BlockToBref) print ("BlockToBref", i , BlockToBref[i])
- #for (i in BlockToCref) print ("BlockToCref", i , BlockToCref[i])
-
- #for (i in PlaceRef) print ("PlaceRef", i , PlaceRef[i])
-
- }
-
-
-
-
- ##{}
-
-
- function Eror(Mess){
-
- ERR=1;
-
- print(Mess);
-
- exit;
-
- }
-
-
-
-
- function printt(l){print(l) >> OutTex}
-
- function printX(l, f){
-
- f="" PicDir ccod(l)".tex";
- print(l) > f;
- close(f)
- }
-
- function ForCopyPic(n, a ){
-
- print("copy picx\\" n ".png .") >CopyPicBat
-
- }
-
-
- ##{PrintOut}
-
- #function PrintOut(l){ print(l) >> OutTex }
-
-
- function PrintOut(l , i,cod){
-
-
- if (l ~ "\\\\end{PicFormula}" ) {
-
- PicFOn=0;
-
- PicFline=PicFline "\n" EndTeX;
-
- printX(PicFline) ;
-
- cod=ccod(PicFline);
-
- ForCopyPic(cod);
-
- printt("}{"cod"}")
-
- }
- else if (l ~ "\\\\begin{PicFormula}" ) {
-
- PicFOn=1;
- PicFline=BeginTeX ;
-
-
- printt("\\PicFormula{%")
-
- }
- else {
-
- printt(l)
-
- if (PicFOn) PicFline=PicFline "\n" l;
-
- }
-
-
-
- }
-
-
-
-
-
-
-
-
-
- ##{ReadJobFile}
- function ReadJobFile(JF, line,Arr,i,n){
-
-
- while ( (getline line <JF) >0) {
-
-
- if ( line ~ /MetodFiles/ ) {
-
- sub(/.*MetodFiles/,"",line);
-
- n=split(line,Arr);
- for ( i = 1 ; i<=n ; i++) {
-
- InpFileList[i]=Arr[i]
-
- }
-
- }
-
- if ( line ~ /MetodDopFiles/ ) {
-
- sub(/.*MetodDopFiles/,"",line);
-
- n=split(line,Arr);
- for ( i = 1 ; i<=n ; i++) {
-
- InpPatchFileList[i]=Arr[i]
-
- }
-
-
- }
-
- # ActAlabel["SistUrNeskResh"]=1;
-
- if ( line ~ /MetodLabel/ ) {
-
- sub(/.*MetodLabel/,"",line);
-
- n=split(line,Arr);
- for ( i = 1 ; i<=n ; i++) {
-
- ActAlabel[Arr[i]]=1
-
- }
-
-
- }
-
-
- }
-
- }
-
- ##{GoForFiles}
- function GoForFiles(List,Tip, i ) {
- for (i=1 ; i in List ; i++) ReadFiles(List[i],Tip)
- }
-
- ##{ReadFiles}
-
- function ReadFiles(InpFile,Tip, IgnoreRead,lineCount,line){
-
- IgnoreRead=1;
- lineCount=0
-
- while ( (getline line <InpFile) >0) {
-
- lineCount++;
-
- if (line ~ /bblock/ ) {
-
- if ( !IgnoreRead) BlockToEndLine[BlockCount]=lineCount-1; #??
-
- IgnoreRead=0;
-
- BlockCount++;
-
- BlockToFile[BlockCount]=InpFile;
- BlockToBeginLine[BlockCount]=lineCount;
-
- continue;
- }
-
- if (IgnoreRead) { continue; } ############
-
- if (line ~ /eblock/ ) {
- IgnoreRead=1;
- BlockToEndLine[BlockCount]=lineCount;
- continue;
- }
-
-
- if (line ~ /^[ \t]*%/ ) { continue; }
-
-
- if (line ~ "\\\\label{") {
-
- sub(/^.*\\label{[ \t]*/,"",line);
- sub(/[ \t]*}.*$/,"",line);
-
- if (Tip == 1) {
-
- if (line in LabelToBlock) Eror("Duble Label "line" in "InpFile" in "lineCount )
-
- LabelToBlock[line] = BlockCount;
- }
-
- if (Tip == 2) {
-
- if ( !(line in LabelToBlock)) Eror("Unknown Label "line" in "InpFile" in "lineCount )
-
- OldToNewBlock[LabelToBlock[line]] = BlockCount;
- NewToOldBlock[BlockCount] = LabelToBlock[line]
-
- LabelToBlock[line] = BlockCount;
- }
-
- continue;
-
- }
-
- if (line ~ /\\aref.*{/) {
-
- sub(/^.*\\aref[^{]*{[ \t]*/,"",line);
- sub(/[ \t]*}.*$/,"",line);
-
- BlockToAref[BlockCount] = BlockToAref[BlockCount] " " line
-
- PlaceRef[lineCount "," InpFile] = line;
-
- continue;
- }
-
- if (line ~ /\\bref.*{/) {
-
- sub(/^.*\\bref[^{]*{[ \t]*/,"",line);
- sub(/[ \t]*}.*$/,"",line);
-
- BlockToBref[BlockCount] = BlockToBref[BlockCount] " " line
-
- PlaceRef[lineCount "," InpFile] = line;
-
- continue;
-
- }
-
- if (line ~ /\\cref.*{/) {
-
- sub(/^.*\\cref[^{]*{[ \t]*/,"",line);
- sub(/[ \t]*}.*$/,"",line);
-
- BlockToCref[BlockCount] = BlockToCref[BlockCount] " " line
-
- PlaceRef[lineCount "," InpFile] = line;
-
- continue;
- }
-
-
- }
-
- close(InpFile);
-
-
- }
-
- ##{MkActualBandL}
- function MkActualBandL( i,n,l,Blk,Arr,Enough){
-
-
- do{
- Enough=1;
-
-
- for ( i in ActAlabel ){
-
- Blk=LabelToBlock[i];
-
- ActABlock[Blk]=1;
-
- }
-
- for ( i in ActBlabel ){
-
- Blk=LabelToBlock[i];
-
- ActBBlock[Blk]=1;
-
- }
-
-
- for ( n in ActABlock) {
-
- split(BlockToAref[n],Arr);
-
- for (i in Arr) {
-
- l=Arr[i];
- if ( !(l in ActAlabel) ) {Enough=0; ActAlabel[l]=1; }
- }
-
-
- split(BlockToBref[n],Arr);
-
- for (i in Arr) {
-
- l=Arr[i];
- if ( !(l in ActBlabel) ) {Enough=0; ActBlabel[l]=1; }
- }
-
-
- }
-
- for ( n in ActBBlock) {
-
- split(BlockToAref[n],Arr);
-
- for (i in Arr) {
-
- l=Arr[i];
- if ( !(l in ActBlabel) ) {Enough=0; ActBlabel[l]=1; }
- }
-
-
- }
-
-
-
-
- if (Enough) break;
-
- }while(1)
-
- #for ( i in ActABlock ) if ( i in ActBBlock) delete ActBBlock[i]
-
- #for ( i in ActAlabel ) if ( i in ActBlabel) delete ActBlabel[i]
- }
-
-
-
-
- ##{MkActLine}
- function MkActLine(ActLabel, ActB,AllActLabel,i,l,n,nn,Bl,El,Fl){
-
- for(l in ActLabel) {
-
- n=LabelToBlock[l];
-
- ActB[n]=1;
- }
-
- for ( n in ActB){
-
- if (n in NewToOldBlock) {
-
- nn=NewToOldBlock[n];
-
- Bl=BlockToBeginLine[nn];
- El=BlockToEndLine[nn];
- Fl=BlockToFile[nn];
- rez=n
- }
- else {
-
- Bl=BlockToBeginLine[n];
- El=BlockToEndLine[n];
- Fl=BlockToFile[n];
- rez=1;
- }
-
- ActBegin[Bl","Fl]=rez;
- ActEnd[El","Fl]=1;
- }
-
- for (l in LabelToBlock) if (LabelToBlock[l] in ActB) AllActLabel[l]=1
-
- for (i in PlaceRef) if ( !(PlaceRef[i] in AllActLabel) ) IgnoreLine[i]=1
-
- }
-
-
- ##{PrintBlock}
-
- function PrintBlock(n, B,E,F,line,lineCount){
-
- lineCount=0;
-
- B=BlockToBeginLine[n];
- E=BlockToEndLine[n];
- F=BlockToFile[n];
-
- #print(B,E,F)
-
-
- PrintOut("% " B "-" E " "F)
-
- while ( (getline line <F) >0) {
-
- lineCount++;
-
- if( lineCount >= B && lineCount <= E && !( (lineCount "," F) in IgnoreLine ) ) PrintOut(line)
-
- }
-
- close(F)
-
- }
-
-
- ##{PrintAll}
- function PrintAll(NomFile,F,line,lineCount,YesPrint,tmp,n){
-
- for(NomFile=1 ; NomFile in InpFileList ; NomFile++) {
-
- F=InpFileList[NomFile];
-
- lineCount=0;
-
- YesPrint=0;
-
- while ( (getline line <F) >0) {
-
- lineCount++;
-
- tmp=""lineCount","F;
-
- if ( tmp in ActBegin ) {
-
- n=ActBegin[tmp]
- if ( n == 1) {
-
- YesPrint=1
-
- PrintOut("% "tmp)
- }
- else { PrintBlock(n) }
- }
-
- if (YesPrint) {
- if ( (tmp in IgnoreLine)) { PrintOut("% ignor ref % "line); }
- else {PrintOut(line);}
- }
-
- if ( (tmp) in ActEnd ) {
-
- YesPrint=0;
- }
- }
-
- close(F)
- }
-
-
-
- }
-
-
-
- ##{}
-
-
-
-
-
-
-
- #function ccod(A){ return "" xcod(A,0) "" xcod(A,1)}
- function ccod(A){ return "" xcod(A) }
-
- function xcod(W, Tip, i,x,Sum,A,B,Chislo,Smpl){
-
-
- if (Tip == "") Tip=0;
-
- Sum=0;
-
- Chislo=32768; # =2^15
-
- if (Tip == 0) Smpl=32749;
- else if (Tip == 1) Smpl=32771;
-
- # 65521 65536
-
- A=1; B=0;
-
- for(i=1 ; i<=length(W) ; i++) {
-
- x=substr(W,i,1);
-
- A = (A + LetterToNom[x]) % Smpl ;
- B = (B + A) % Smpl ;
-
- #Sum=(Sum+LetterToNom[x]*1111111111)%100000001;
- #Sum=(Sum+LetterToNom[x]*i*1100011000)%100000001;
- }
- return (B * Chislo + A);
- }
-
-
-
-
-
-
-
- BEGIN { ###htmbegin
-
- ##nach=systime();
-
-
- Strr= "";
- Strr= Strr "\000\001\002\003\004\005\006\007";
- Strr= Strr "\010\011\012\013\014\015\016\017";
- Strr= Strr "\020\021\022\023\024\025\026\027";
- Strr= Strr "\030\031\032\033\034\035\036\037";
- Strr= Strr "\040\041\042\043\044\045\046\047";
- Strr= Strr "\050\051\052\053\054\055\056\057";
- Strr= Strr "\060\061\062\063\064\065\066\067";
- Strr= Strr "\070\071\072\073\074\075\076\077";
-
-
- Strr= Strr "\100\101\102\103\104\105\106\107";
- Strr= Strr "\110\111\112\113\114\115\116\117";
- Strr= Strr "\120\121\122\123\124\125\126\127";
- Strr= Strr "\130\131\132\133\134\135\136\137";
- Strr= Strr "\140\141\142\143\144\145\146\147";
- Strr= Strr "\150\151\152\153\154\155\156\157";
- Strr= Strr "\160\161\162\163\164\165\166\167";
- Strr= Strr "\170\171\172\173\174\175\176\177";
-
-
- Strr= Strr "\200\201\202\203\204\205\206\207";
- Strr= Strr "\210\211\212\213\214\215\216\217";
- Strr= Strr "\220\221\222\223\224\225\226\227";
- Strr= Strr "\230\231\232\233\234\235\236\237";
- Strr= Strr "\240\241\242\243\244\245\246\247";
- Strr= Strr "\250\251\252\253\254\255\256\257";
- Strr= Strr "\260\261\262\263\264\265\266\267";
- Strr= Strr "\270\271\272\273\274\275\276\277";
-
-
- Strr= Strr "\300\301\302\303\304\305\306\307";
- Strr= Strr "\310\311\312\313\314\315\316\317";
- Strr= Strr "\320\321\322\323\324\325\326\327";
- Strr= Strr "\330\331\332\333\334\335\336\337";
- Strr= Strr "\340\341\342\343\344\345\346\347";
- Strr= Strr "\350\351\352\353\354\355\356\357";
- Strr= Strr "\360\361\362\363\364\365\366\367";
- Strr= Strr "\370\371\372\373\374\375\376\377";
-
-
-
- #print(S);
- split(Strr,AllLetter,"");
-
- for (i in AllLetter) LetterToNom[AllLetter[i]]=i;
- Strr="";
-
- }
-
-
-
-
-
-
-
-
-
-
-
-
-