From 6b3f26b1721acb62029152212847bfd2589c2bba Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Sun, 20 Nov 2016 21:48:03 +0000 Subject: [PATCH] cmm: upload vfc (Visual Text Comparer / Diff tool) git-svn-id: svn://kolibrios.org@6732 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/vfc/32user32.h | 154 ++++++++++++++++++++++++++ programs/cmm/vfc/Tupfile.lua | 6 + programs/cmm/vfc/build.bat | 5 + programs/cmm/vfc/if.h | 181 ++++++++++++++++++++++++++++++ programs/cmm/vfc/objects.h | 182 ++++++++++++++++++++++++++++++ programs/cmm/vfc/vfc.c | 209 +++++++++++++++++++++++++++++++++++ programs/cmm/vfc/vfc_gui.h | 106 ++++++++++++++++++ 7 files changed, 843 insertions(+) create mode 100644 programs/cmm/vfc/32user32.h create mode 100644 programs/cmm/vfc/Tupfile.lua create mode 100644 programs/cmm/vfc/build.bat create mode 100644 programs/cmm/vfc/if.h create mode 100644 programs/cmm/vfc/objects.h create mode 100644 programs/cmm/vfc/vfc.c create mode 100644 programs/cmm/vfc/vfc_gui.h diff --git a/programs/cmm/vfc/32user32.h b/programs/cmm/vfc/32user32.h new file mode 100644 index 0000000000..db31deeb3f --- /dev/null +++ b/programs/cmm/vfc/32user32.h @@ -0,0 +1,154 @@ + + +:static int __wsprintfproc; +:static int cdecl __wsprintf(int buff,mask,...){ + char buffer[MAX_PATH]; + char bufnum[32]; + int bufferlen; + int param; + int length; + int pad; + + struct _wsprintf_mf{ + int precision; + int width; + int minus ; + int plus ; + int diez ; + int zero ; + byte upcase ; + byte _signed;// + }mf; + + $push EBX,ESI,EDI; + param=#mask[sizeof(mask)]; + length=0; + EDX=mask; + EBX=buff; + for(;;){ + mf=0; + mf.precision=0x7FFF; + REPEATSMALL: + if(!DSCHAR[EDX]){ + AL=0; + $call __wsprintfproc; + $pop EDI,ESI,EBX; + return length; + } + if(DSCHAR[EDX]!='%'){ + WRITECHAR: AL=DSCHAR[EDX];$call __wsprintfproc; EDX++;GOTO REPEATSMALL; + } + + GETMASK: + EDX++; + SWITCH(DSCHAR[EDX]){ + CASE '-': mf.minus++;goto GETMASK; + CASE '+': mf.plus ++;goto GETMASK; + CASE '#': mf.diez ++;goto GETMASK; + CASE '0': mf.zero ++;EDX++; + } + + WHILE(DSCHAR[EDX]>='0')&&(DSCHAR[EDX]<='9'){ + $push EDX;mf.width=mf.width*10+DSCHAR[EDX]-'0';$pop EDX;EDX++; + } + if(DSCHAR[EDX]=='.'){ + mf.precision=0; + GETPRECISION: + EDX++; + if(DSCHAR[EDX]>='0') + &&(DSCHAR[EDX]<='9'){ + $push EDX;mf.precision=mf.precision*10+DSCHAR[EDX]-'0';$pop EDX; + GOTO GETPRECISION; + } + } + if(DSCHAR[EDX]=='l'){ + EDX++; + } + if(DSCHAR[EDX]=='h'){ + EDX++; + } + if(DSCHAR[EDX]<'a'){mf.upcase=1;} + SWITCH(DSCHAR[EDX]|0x20){ + CASE 'c': buffer=DSCHAR[param];bufferlen=1;goto FORMAT; + CASE 's': if(!DSDWORD[param])DSDWORD[param]="(null)";//?????? + FOR(bufferlen=0;bufferlen'9'){AL+='A'-'9'-1;if(!mf.upcase)AL|=0x20;} + bufnum[EDI]=AL;EDI++;EDX>>=4; + } + $pop EDX; + WHILE(EDI0)&&(s2>0)&&(!strcmp(s1,s2)) + {//áâப¨ ᮢ¯ ¤ îâ + for(i=0;ititlelen)wsprintf(#temp," ...%s ",strlen(fname)+fname-titlelen+3); + else wsprintf(#temp," %s ",fname); + for(i=0;temp[i];i++){ str[i+1]=temp[i]; attr[i+1]=0x1E; } + if(!shownums) + { + wsprintf(#temp,"[%6d]",line); + CopyMemory(xs1-9+#str,#temp,8); + FillMemory(xs1-8*2+#attr,12,0x19); + } + printstrat(x1,y1,xs1,#str,#attr); +} + +printpanel(dword line,linex ,x1,y1,xs1,ys1 ,x2,y2,xs2,ys2) +{ + int i,j; + int s,d,sl,dl; + int line1,line2; + + for(j=line;jsrcfilenums.Count)linenum=srcfilenums.Count-ys; + if(linenum<0) linenum=0; + +@redraw: + if(!verthoriz) + { + printpanel(linenum,linex + ,0,0 + ,sbi_x/2 ,sbi_y + ,sbi_x/2 ,0 + ,sbi_x/2 ,sbi_y + ); + ys=sbi_y-2; + } + else + { + printpanel(linenum,linex + ,0,0 + ,sbi_x ,sbi_y/2 + ,0 ,sbi_y/2 + ,sbi_x ,sbi_y/2 + ); + if(sbi_y&1) + { + FillMemory(#str,sbi_x,'°'); + FillMemory(#attr,sbi_x*2,0); + printstrat(0,sbi_y-1,sbi_x,#str,#attr); + } + ys=sbi_y/2-2; + } + + if (!ys) goto redraw; + else { + con_set_cursor_pos stdcall (2,0); + ExitProcess(); + } +} diff --git a/programs/cmm/vfc/objects.h b/programs/cmm/vfc/objects.h new file mode 100644 index 0000000000..3da50a6b51 --- /dev/null +++ b/programs/cmm/vfc/objects.h @@ -0,0 +1,182 @@ + + +struct TCollection{ + int Count;//itemcunt + int Delta;//increase buffer Delta + int Items;//pointer to array of item pointers + int Limit;//currently allocated size (in elements) of Items list + + TCollection( int ALimit,ADelta ); + ~TCollection( void ); + + int At( int Index ); + void AtDelete( int Index ); + void AtFree( int Index ); + void AtInsert( int Index, Item ); + void DeleteAll( void ); + void Free( int Item ); + void FreeAll( void ); + void FreeItem( int Item ); + void Insert( int Item ); + void SetLimit( int ALimit ); +}; + +:int TCollection::At( int Index ) +{ + return DSDWORD[ Index*sizeof(int)+Items ]; +} + +:void TCollection::AtDelete( int Index ) +{ +// if(Index<0)||(Index>=Count){/*Error(coIndexError);*/return;} + ECX = Count-Index-1; + EDI = Index*sizeof(int)+Items; ESI = EDI+4; $cld; $rep;$movsd; + Count --; +} + +:void TCollection::AtFree( int Index ) +{ + int Item = At( Index); + AtDelete( Index ); + FreeItem( Item ); +} + +:void TCollection::AtInsert( int Index, Item ) +{ + $pushfd + IF( Count == Limit ) + { + SetLimit( Count+Delta ); + } + ECX = Count-Index; + EDI = Count*sizeof(int)+Items; + ESI = EDI-4; $std $rep $movsd $cld + DSDWORD[ EDI ] = Item; + Count ++; + $popfd +} + +:void TCollection::DeleteAll() +{ + Count=0; +} + +:void TCollection::Free( int Item ) +{ + Delete( Item ); + FreeItem( Item ); +} + +:void TCollection::FreeAll( void ) +{ + int I; + FOR( I = 0; I < Count; I ++ )FreeItem( At(I) ); + Count = 0; +} + +:void TCollection::FreeItem( int Item ) +{ + IF( Item )free( Item );//+++Dispose(PObject(Item), Done); +} + +:void TCollection::Insert( int Item ) +{ + AtInsert( Count, Item ); +} + +:void TCollection::SetLimit( int ALimit ) +{ + int AItems; + + IF( ALimit < Count )ALimit = Count; + IF( ALimit != Limit ) + { + IF( !ALimit ) AItems = 0; + ELSE + { + AItems = malloc(ALimit*sizeof(int) ); + IF( Count )&&( Items ) + { + CopyMemory( AItems, Items, Limit*sizeof(int) ); + } + } + IF( Limit )free( Items ); + Items = AItems; + Limit = ALimit; + } +} + +:TCollection::TCollection( int ALimit, ADelta ) +{ + Items = 0; + Count = 0; + Limit = 0; + Delta = ADelta; + SetLimit( ALimit ); + return this; +} + +:TCollection::~TCollection( void ) +{ + FreeAll(); + SetLimit(0); +} + +struct TSortedCollection:TCollection +{ + int comparemethod; + int Duplicates; + + TSortedCollection( int ALimit, ADelta ); + + int Compare( int Key1, Key2 ); + void Insert( int Item ); + int Search( int Key, Index ); +}; + +:int TSortedCollection::Compare( int Key1, Key2 ) +{ + strcmp( Key1, Key2 ); +} + +:TSortedCollection::TSortedCollection( int ALimit, ADelta ) +:TCollection( ALimit, ADelta ); +{ + comparemethod=#Compare; + return this; +} + +:void TSortedCollection::Insert( int Item ) +{ + int i; + IF( !Search(/*KeyOf(*/Item/*)*/,#i) ) || ( Duplicates )AtInsert( i, Item ); +} + + +:int TSortedCollection::Search( int Key, Index ) +{ + int L, H, I, C; + int S; + + S = 0; + L = 0; + H = Count-1; + WHILE( L <= H ) + { + I = L+H >> 1; + ECX = I*sizeof(int)+Items; + comparemethod( this, /*KeyOf(*/DSDWORD[ECX]/*)*/, Key ); + C = EAX; + IF( C < 0 ){ L = I+1; } + ELSE + { + H = I-1; + IF( !C ){ + S = 1; + IF( !Duplicates )L = I; + } + } + } + DSDWORD[ Index ]=L; + return S; +} diff --git a/programs/cmm/vfc/vfc.c b/programs/cmm/vfc/vfc.c new file mode 100644 index 0000000000..8c1a2e659a --- /dev/null +++ b/programs/cmm/vfc/vfc.c @@ -0,0 +1,209 @@ +//visual text comparer +//by den po - jdp@bk.ru + +#define MEMSIZE 4096 * 60 +#include "../lib/io.h" +#include "../lib/strings.h" +#include "../lib/obj/console.h" +IO io1, io2; + +#define MAX_PATH 260 + +#include "32user32.h" +#include "objects.h" +#include "vfc_gui.h" + +#define mincmpstrings 2 +#define maxcmpstrings 10 +#define maxcmpoffset 100 + +char window_title[] = "Visual Text Comparer (Diff tool)"; + +char* srcfilename; +char* dstfilename; +dword srcfile; +dword dstfile; +dword srcfilesize; +dword dstfilesize; +TCollection srcfilelines; //file lines +TCollection dstfilelines; +TCollection srcfilenums; //lines numbers +TCollection dstfilenums; + +struct TSimpleCollection:TSortedCollection +{ + TSimpleCollection(); + int Compare( int Key1, Key2 ); +}; +int TSimpleCollection::Compare( int Key1, Key2 ){ + return Key1-Key2; +} +TSimpleCollection::TSimpleCollection():TSortedCollection(1000,1000); +{ + comparemethod=#Compare; +} + +TSimpleCollection diffs; //list of differing strings +dword srcfilelinks; //pointer to the previos line with the same first symbol +dword dstfilelinks; // + +getstrings(dword srcfile,srcfilesize,srcfilelines){ + ECX=srcfilesize; + ESI=srcfile; + WHILE(ECX){ + $push ECX,ESI + EAX=srcfilelines; + EAX.TCollection.Insert(ESI); + $pop ESI,ECX + WHILE(ECX){ + $cld $lodsb ECX--; + if(AL==0x0D)||(AL==0x0A)DSBYTE[ESI-1]=0; + if(AL==0x0D)&&(DSBYTE[ESI]==0x0A){$lodsb;ECX--;} + if(AL==0x0D)||(AL==0x0A)BREAK; + } + } +} + +#include "if.h" + +bool getparam() +{ + int i, param_len = strlen(#param); + if (param[0]=='"') { + for (i=1; i=mincmpstrings) + { + WHILE(bdp