mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-28 16:26:35 +00:00
373 lines
38 KiB
HTML
Executable file
373 lines
38 KiB
HTML
Executable file
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
|
|
<meta name="generator" content="ZealOS V1.00">
|
|
<style type="text/css">
|
|
body {background-color:#fef1f0;}
|
|
.cF0{color:#000000;background-color:#fef1f0;}
|
|
.cF1{color:#0148a4;background-color:#fef1f0;}
|
|
.cF2{color:#3b7901;background-color:#fef1f0;}
|
|
.cF3{color:#057c7e;background-color:#fef1f0;}
|
|
.cF4{color:#bb2020;background-color:#fef1f0;}
|
|
.cF5{color:#9e42ae;background-color:#fef1f0;}
|
|
.cF6{color:#b57901;background-color:#fef1f0;}
|
|
.cF7{color:#b2b6af;background-color:#fef1f0;}
|
|
.cF8{color:#555753;background-color:#fef1f0;}
|
|
.cF9{color:#678fbb;background-color:#fef1f0;}
|
|
.cFA{color:#82bc49;background-color:#fef1f0;}
|
|
.cFB{color:#0097a2;background-color:#fef1f0;}
|
|
.cFC{color:#e26a6a;background-color:#fef1f0;}
|
|
.cFD{color:#c671bc;background-color:#fef1f0;}
|
|
.cFE{color:#c7ab00;background-color:#fef1f0;}
|
|
.cFF{color:#fef1f0;background-color:#fef1f0;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<pre style="font-family:monospace;font-size:12pt">
|
|
<a name="l1"></a><span class=cF0>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>"Cmd Line (Typically)"</span><span class=cF0>
|
|
<a name="l2"></a>
|
|
<a name="l3"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>DS_USE_FILE1</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>
|
|
<a name="l4"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>DS_USE_FILE2</span><span class=cF0> </span><span class=cFE>1</span><span class=cF0>
|
|
<a name="l5"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>DS_REMAINDER_1</span><span class=cF0> </span><span class=cFE>2</span><span class=cF0>
|
|
<a name="l6"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>DS_REMAINDER_2</span><span class=cF0> </span><span class=cFE>3</span><span class=cF0>
|
|
<a name="l7"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>DS_ABORT_FILE</span><span class=cF0> </span><span class=cFE>4</span><span class=cF0>
|
|
<a name="l8"></a>
|
|
<a name="l9"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>PopUpDiffMenu</span><span class=cF0>()
|
|
<a name="l10"></a>{
|
|
<a name="l11"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
|
<a name="l12"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc = </span><span class=cF5>DocNew</span><span class=cF0>;
|
|
<a name="l13"></a>
|
|
<a name="l14"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc, </span><span class=cF6>"$CM+LX,2,2$$LTRED$FILE1$FG$ = DST.$CM+LX,24,0$$LTGREEN$FILE2$FG$ = SRC."</span><span class=cF0>
|
|
<a name="l15"></a> </span><span class=cF6>"$CM+LX,2,4$$RED$$BT,\"USE FILE1\",LE=DS_USE_FILE1$"</span><span class=cF0>
|
|
<a name="l16"></a> </span><span class=cF6>"$CM+LX,24,0$$GREEN$$BT,\"USE FILE2\",LE=DS_USE_FILE2$"</span><span class=cF0>
|
|
<a name="l17"></a> </span><span class=cF6>"$CM+LX,2,4$$RED$$BT,\"REMAINDER ALL FILE1\",LE=DS_REMAINDER_1$"</span><span class=cF0>
|
|
<a name="l18"></a> </span><span class=cF6>"$CM+LX,24,0$$GREEN$$BT,\"REMAINDER ALL FILE2\",LE=DS_REMAINDER_2$"</span><span class=cF0>
|
|
<a name="l19"></a> </span><span class=cF6>"$CM+LX,2,4$$FG$$BT,\"ABORT FILE\",LE=DS_ABORT_FILE$"</span><span class=cF0>
|
|
<a name="l20"></a> </span><span class=cF6>"$CM+LX,24,0$$FG$$BT,\"ABORT ALL FILES\",LE=DOCM_CANCEL$\n"</span><span class=cF0>);
|
|
<a name="l21"></a> i = </span><span class=cF5>PopUpMenu</span><span class=cF0>(doc);
|
|
<a name="l22"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc);
|
|
<a name="l23"></a>
|
|
<a name="l24"></a> </span><span class=cF1>return</span><span class=cF0> i;
|
|
<a name="l25"></a>}
|
|
<a name="l26"></a>
|
|
<a name="l27"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>DiffEntriesCompare</span><span class=cF0>(</span><span class=cF9>CDocEntry</span><span class=cF0> *doc_e1, </span><span class=cF9>CDocEntry</span><span class=cF0> *doc_e2)
|
|
<a name="l28"></a>{
|
|
<a name="l29"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>StrCompare</span><span class=cF0>(doc_e1->tag, doc_e2->tag);
|
|
<a name="l30"></a>}
|
|
<a name="l31"></a>
|
|
<a name="l32"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>DF_MODIFIED</span><span class=cF0> </span><span class=cFE>0x01</span><span class=cF0>
|
|
<a name="l33"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>DF_DONT_MODIFIED</span><span class=cF0> </span><span class=cFE>0x02</span><span class=cF0>
|
|
<a name="l34"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>DF_REMAINDER_ALL_FILE1</span><span class=cF0> </span><span class=cFE>0x04</span><span class=cF0>
|
|
<a name="l35"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>DF_REMAINDER_ALL_FILE2</span><span class=cF0> </span><span class=cFE>0x08</span><span class=cF0>
|
|
<a name="l36"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>DF_ABORT_FILE</span><span class=cF0> </span><span class=cFE>0x10</span><span class=cF0>
|
|
<a name="l37"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>DF_ABORT_ALL_FILES</span><span class=cF0> </span><span class=cFE>0x20</span><span class=cF0>
|
|
<a name="l38"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>DF_NO_MORE_PROMPTS_THIS_FILE</span><span class=cF0> </span><span class=cFE>0x40</span><span class=cF0>
|
|
<a name="l39"></a>
|
|
<a name="l40"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>DiffSel</span><span class=cF0>(</span><span class=cF9>CDoc</span><span class=cF0> *doc, </span><span class=cF9>I64</span><span class=cF0> *_df_flags, </span><span class=cF9>I64</span><span class=cF0> j1_lo, </span><span class=cF9>I64</span><span class=cF0> j1_hi, </span><span class=cF9>I64</span><span class=cF0> j2_lo, </span><span class=cF9>I64</span><span class=cF0> j2_hi, </span><span class=cF9>I64</span><span class=cF0> count1, </span><span class=cF9>I64</span><span class=cF0> count2,
|
|
<a name="l41"></a> </span><span class=cF9>CDocEntry</span><span class=cF0> **doc_unsorted1, </span><span class=cF9>CDocEntry</span><span class=cF0> **doc_unsorted2)
|
|
<a name="l42"></a>{
|
|
<a name="l43"></a> </span><span class=cF9>CDocEntry</span><span class=cF0> *doc_e, *doc_e1, *doc_e2;
|
|
<a name="l44"></a> </span><span class=cF1>Bool</span><span class=cF0> use_file1;
|
|
<a name="l45"></a> </span><span class=cF9>I64</span><span class=cF0> i, old_flags;
|
|
<a name="l46"></a> </span><span class=cF9>CDoc</span><span class=cF0> *cur_l;
|
|
<a name="l47"></a>
|
|
<a name="l48"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>*_df_flags & (</span><span class=cF3>DF_ABORT_FILE</span><span class=cF0> | </span><span class=cF3>DF_ABORT_ALL_FILES</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l49"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l50"></a> </span><span class=cF6>"$PURPLE$"</span><span class=cF0>;
|
|
<a name="l51"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFE>0</span><span class=cF0> <= j1_lo < count1)
|
|
<a name="l52"></a> </span><span class=cF6>"%d,"</span><span class=cF0>, doc_unsorted1[j1_lo]->y + </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l53"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFE>0</span><span class=cF0> <= j1_hi - </span><span class=cFE>1</span><span class=cF0> < count1)
|
|
<a name="l54"></a> </span><span class=cF6>"%d,"</span><span class=cF0>, doc_unsorted1[j1_hi - </span><span class=cFE>1</span><span class=cF0>]->y + </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l55"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l56"></a> </span><span class=cF6>"***,"</span><span class=cF0>;
|
|
<a name="l57"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFE>0</span><span class=cF0> <= j2_lo < count2)
|
|
<a name="l58"></a> </span><span class=cF6>"%d"</span><span class=cF0>, doc_unsorted2[j2_lo]->y + </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l59"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFE>0</span><span class=cF0> <= j2_hi - </span><span class=cFE>1</span><span class=cF0> < count2)
|
|
<a name="l60"></a> </span><span class=cF6>"%d"</span><span class=cF0>, doc_unsorted2[j2_hi - </span><span class=cFE>1</span><span class=cF0>]->y + </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l61"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l62"></a> </span><span class=cF6>"***"</span><span class=cF0>;
|
|
<a name="l63"></a> </span><span class=cF6>"---------------------$RED$\n"</span><span class=cF0>;
|
|
<a name="l64"></a> </span><span class=cF1>if</span><span class=cF0> (j1_lo <= </span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l65"></a> i = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l66"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l67"></a> i = j1_lo - </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l68"></a> </span><span class=cF1>while</span><span class=cF0> (i < j1_hi)
|
|
<a name="l69"></a> {
|
|
<a name="l70"></a> </span><span class=cF1>if</span><span class=cF0> (cur_l = </span><span class=cF5>DocPut</span><span class=cF0>)
|
|
<a name="l71"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l72"></a> old_flags = cur_l->flags & </span><span class=cF3>DOCF_PLAIN_TEXT</span><span class=cF0>;
|
|
<a name="l73"></a> cur_l->flags |= </span><span class=cF3>DOCF_PLAIN_TEXT</span><span class=cF0>;
|
|
<a name="l74"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l75"></a> </span><span class=cF6>"%s"</span><span class=cF0>, doc_unsorted1[i++]->tag;
|
|
<a name="l76"></a> </span><span class=cF1>if</span><span class=cF0> (cur_l)
|
|
<a name="l77"></a> cur_l->flags = cur_l->flags & ~</span><span class=cF3>DOCF_PLAIN_TEXT</span><span class=cF0> | old_flags;
|
|
<a name="l78"></a> </span><span class=cF6>'\n'</span><span class=cF0>;
|
|
<a name="l79"></a> }
|
|
<a name="l80"></a> </span><span class=cF6>"$GREEN$"</span><span class=cF0>;
|
|
<a name="l81"></a> </span><span class=cF1>if</span><span class=cF0> (j2_lo <= </span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l82"></a> i = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l83"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l84"></a> i = j2_lo - </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l85"></a> </span><span class=cF1>while</span><span class=cF0> (i < j2_hi)
|
|
<a name="l86"></a> {
|
|
<a name="l87"></a> </span><span class=cF1>if</span><span class=cF0> (cur_l = </span><span class=cF5>DocPut</span><span class=cF0>)
|
|
<a name="l88"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l89"></a> old_flags = cur_l->flags & </span><span class=cF3>DOCF_PLAIN_TEXT</span><span class=cF0>;
|
|
<a name="l90"></a> cur_l->flags |= </span><span class=cF3>DOCF_PLAIN_TEXT</span><span class=cF0>;
|
|
<a name="l91"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l92"></a> </span><span class=cF6>"%s"</span><span class=cF0>, doc_unsorted2[i++]->tag;
|
|
<a name="l93"></a> </span><span class=cF1>if</span><span class=cF0> (cur_l)
|
|
<a name="l94"></a> cur_l->flags = cur_l->flags & ~</span><span class=cF3>DOCF_PLAIN_TEXT</span><span class=cF0> | old_flags;
|
|
<a name="l95"></a> </span><span class=cF6>'\n'</span><span class=cF0>;
|
|
<a name="l96"></a> }
|
|
<a name="l97"></a> </span><span class=cF6>"$FG$"</span><span class=cF0>;
|
|
<a name="l98"></a>
|
|
<a name="l99"></a> use_file1 = </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l100"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>*_df_flags & </span><span class=cF3>DF_NO_MORE_PROMPTS_THIS_FILE</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l101"></a> {
|
|
<a name="l102"></a> </span><span class=cF1>switch</span><span class=cF0> (</span><span class=cF5>PopUpDiffMenu</span><span class=cF0>)
|
|
<a name="l103"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l104"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>DS_USE_FILE1</span><span class=cF0>:
|
|
<a name="l105"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l106"></a>
|
|
<a name="l107"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>DS_USE_FILE2</span><span class=cF0>:
|
|
<a name="l108"></a> use_file1 = </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l109"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l110"></a>
|
|
<a name="l111"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>DS_REMAINDER_1</span><span class=cF0>:
|
|
<a name="l112"></a> *_df_flags = *_df_flags & ~</span><span class=cF3>DF_REMAINDER_ALL_FILE2</span><span class=cF0> | </span><span class=cF3>DF_REMAINDER_ALL_FILE1</span><span class=cF0> | </span><span class=cF3>DF_NO_MORE_PROMPTS_THIS_FILE</span><span class=cF0>;
|
|
<a name="l113"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l114"></a>
|
|
<a name="l115"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>DS_REMAINDER_2</span><span class=cF0>:
|
|
<a name="l116"></a> *_df_flags = *_df_flags & ~</span><span class=cF3>DF_REMAINDER_ALL_FILE1</span><span class=cF0> | </span><span class=cF3>DF_REMAINDER_ALL_FILE2</span><span class=cF0> | </span><span class=cF3>DF_NO_MORE_PROMPTS_THIS_FILE</span><span class=cF0>;
|
|
<a name="l117"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l118"></a>
|
|
<a name="l119"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>DS_ABORT_FILE</span><span class=cF0>:
|
|
<a name="l120"></a> *_df_flags |= </span><span class=cF3>DF_DONT_MODIFIED</span><span class=cF0> | </span><span class=cF3>DF_ABORT_FILE</span><span class=cF0> | </span><span class=cF3>DF_NO_MORE_PROMPTS_THIS_FILE</span><span class=cF0>;
|
|
<a name="l121"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l122"></a>
|
|
<a name="l123"></a> </span><span class=cF1>default</span><span class=cF0>:
|
|
<a name="l124"></a> *_df_flags |= </span><span class=cF3>DF_DONT_MODIFIED</span><span class=cF0> | </span><span class=cF3>DF_ABORT_ALL_FILES</span><span class=cF0> | </span><span class=cF3>DF_NO_MORE_PROMPTS_THIS_FILE</span><span class=cF0>;
|
|
<a name="l125"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l126"></a> }
|
|
<a name="l127"></a> </span><span class=cF1>if</span><span class=cF0> (*_df_flags & </span><span class=cF3>DF_REMAINDER_ALL_FILE2</span><span class=cF0> && !</span><span class=cF7>(</span><span class=cF0>*_df_flags & (</span><span class=cF3>DF_DONT_MODIFIED</span><span class=cF0> | </span><span class=cF3>DF_REMAINDER_ALL_FILE1</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l128"></a> use_file1 = </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l129"></a> </span><span class=cF1>if</span><span class=cF0> (!use_file1)
|
|
<a name="l130"></a> {
|
|
<a name="l131"></a> *_df_flags |= </span><span class=cF3>DF_MODIFIED</span><span class=cF0>;
|
|
<a name="l132"></a> doc_e1 = doc_unsorted1[j1_lo]->last;
|
|
<a name="l133"></a> </span><span class=cF1>if</span><span class=cF0> (j1_lo < j1_hi)
|
|
<a name="l134"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l135"></a> doc_e = doc_unsorted1[j1_lo];
|
|
<a name="l136"></a> </span><span class=cF1>while</span><span class=cF0> (doc_e != doc_unsorted1[j1_hi])
|
|
<a name="l137"></a> {
|
|
<a name="l138"></a> doc_e2 = doc_e->next;
|
|
<a name="l139"></a> </span><span class=cF5>DocEntryDel</span><span class=cF0>(doc, doc_e);
|
|
<a name="l140"></a> doc_e = doc_e2;
|
|
<a name="l141"></a> }
|
|
<a name="l142"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l143"></a> </span><span class=cF1>if</span><span class=cF0> (j2_lo < j2_hi)
|
|
<a name="l144"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l145"></a> doc_e = doc_unsorted2[j2_lo];
|
|
<a name="l146"></a> </span><span class=cF1>while</span><span class=cF0> (doc_e != doc_unsorted2[j2_hi])
|
|
<a name="l147"></a> {
|
|
<a name="l148"></a> doc_e2 = </span><span class=cF5>DocEntryCopy</span><span class=cF0>(doc, doc_e);
|
|
<a name="l149"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(doc_e2, doc_e1);
|
|
<a name="l150"></a> doc_e1 = doc_e2;
|
|
<a name="l151"></a> doc_e = doc_e->next;
|
|
<a name="l152"></a> }
|
|
<a name="l153"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l154"></a> }
|
|
<a name="l155"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l156"></a>}
|
|
<a name="l157"></a>
|
|
<a name="l158"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>DiffSub</span><span class=cF0>(</span><span class=cF9>CDoc</span><span class=cF0> *doc, </span><span class=cF9>I64</span><span class=cF0> *_df_flags, </span><span class=cF9>I64</span><span class=cF0> j1_lo, </span><span class=cF9>I64</span><span class=cF0> j1_hi, </span><span class=cF9>I64</span><span class=cF0> j2_lo, </span><span class=cF9>I64</span><span class=cF0> j2_hi, </span><span class=cF9>I64</span><span class=cF0> count1, </span><span class=cF9>I64</span><span class=cF0> count2,
|
|
<a name="l159"></a> </span><span class=cF9>CDocEntry</span><span class=cF0> **doc_sorted1, </span><span class=cF9>CDocEntry</span><span class=cF0> **doc_sorted2, </span><span class=cF9>CDocEntry</span><span class=cF0> **doc_unsorted1, </span><span class=cF9>CDocEntry</span><span class=cF0> **doc_unsorted2)
|
|
<a name="l160"></a>{
|
|
<a name="l161"></a> </span><span class=cF9>I64</span><span class=cF0> i, i1 = </span><span class=cFE>0</span><span class=cF0>, i2 = </span><span class=cFE>0</span><span class=cF0>, i2b, j1, j2, n, best_j1, best_j2, best_score = </span><span class=cFE>0</span><span class=cF0>, score;
|
|
<a name="l162"></a> </span><span class=cF1>Bool</span><span class=cF0> res = </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l163"></a>
|
|
<a name="l164"></a> </span><span class=cF1>if</span><span class=cF0> (j1_lo >= j1_hi || j2_lo >= j2_hi)
|
|
<a name="l165"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l166"></a> </span><span class=cF1>if</span><span class=cF0> (j1_lo < j1_hi || j2_lo < j2_hi)
|
|
<a name="l167"></a> {
|
|
<a name="l168"></a> </span><span class=cF5>DiffSel</span><span class=cF0>(doc, _df_flags, j1_lo, j1_hi, j2_lo, j2_hi, count1, count2, doc_unsorted1, doc_unsorted2);
|
|
<a name="l169"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l170"></a> }
|
|
<a name="l171"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l172"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l173"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l174"></a>
|
|
<a name="l175"></a> </span><span class=cF2>//Locate longest matching str in intervals</span><span class=cF0>
|
|
<a name="l176"></a> </span><span class=cF1>while</span><span class=cF0> (i1 < count1 && i2 < count2)
|
|
<a name="l177"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l178"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>j1_lo <= doc_sorted1[i1]->user_data < j1_hi</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF2>//user_data is the new y</span><span class=cF0>
|
|
<a name="l179"></a> i1++;
|
|
<a name="l180"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>j2_lo <= doc_sorted2[i2]->user_data < j2_hi</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF2>//user_data is new y</span><span class=cF0>
|
|
<a name="l181"></a> i2++;
|
|
<a name="l182"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l183"></a> {
|
|
<a name="l184"></a> i = </span><span class=cF5>StrCompare</span><span class=cF0>(doc_sorted1[i1]->tag, doc_sorted2[i2]->tag);
|
|
<a name="l185"></a> </span><span class=cF1>if</span><span class=cF0> (i > </span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l186"></a> i2++;
|
|
<a name="l187"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (i < </span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l188"></a> i1++;
|
|
<a name="l189"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l190"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l191"></a> i2b = i2;
|
|
<a name="l192"></a> </span><span class=cF1>while</span><span class=cF0> (!</span><span class=cF5>StrCompare</span><span class=cF7>(</span><span class=cF0>doc_sorted1[i1]->tag, doc_sorted2[i2]->tag</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l193"></a> {
|
|
<a name="l194"></a> </span><span class=cF1>if</span><span class=cF0> (j2_lo <= doc_sorted2[i2]->user_data < j2_hi)
|
|
<a name="l195"></a> </span><span class=cF7>{</span><span class=cF2>//user_data is the new y</span><span class=cF0>
|
|
<a name="l196"></a> score = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l197"></a> j1 = doc_sorted1[i1]->user_data; </span><span class=cF2>//user_data is the new y</span><span class=cF0>
|
|
<a name="l198"></a> j2 = doc_sorted2[i2]->user_data; </span><span class=cF2>//user_data is the new y</span><span class=cF0>
|
|
<a name="l199"></a> n = j1_hi - j1;
|
|
<a name="l200"></a> </span><span class=cF1>if</span><span class=cF0> (j2_hi - j2 < n)
|
|
<a name="l201"></a> n = j2_hi - j2;
|
|
<a name="l202"></a> </span><span class=cF1>while</span><span class=cF0> (score < n)
|
|
<a name="l203"></a> {
|
|
<a name="l204"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>StrCompare</span><span class=cF7>(</span><span class=cF0>doc_unsorted1[j1 + score]->tag, doc_unsorted2[j2 + score]->tag</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l205"></a> score++;
|
|
<a name="l206"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l207"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l208"></a> }
|
|
<a name="l209"></a> </span><span class=cF1>if</span><span class=cF0> (score > best_score)
|
|
<a name="l210"></a> {
|
|
<a name="l211"></a> best_score = score;
|
|
<a name="l212"></a> best_j1 = j1;
|
|
<a name="l213"></a> best_j2 = j2;
|
|
<a name="l214"></a> }
|
|
<a name="l215"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l216"></a> i2++;
|
|
<a name="l217"></a> </span><span class=cF1>if</span><span class=cF0> (i2 >= count2)
|
|
<a name="l218"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l219"></a> }
|
|
<a name="l220"></a> i2 = i2b;
|
|
<a name="l221"></a> i1++;
|
|
<a name="l222"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l223"></a> }
|
|
<a name="l224"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l225"></a> </span><span class=cF1>if</span><span class=cF0> (!best_score)
|
|
<a name="l226"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l227"></a> </span><span class=cF5>DiffSel</span><span class=cF0>(doc, _df_flags, j1_lo, j1_hi, j2_lo, j2_hi, count1, count2, doc_unsorted1, doc_unsorted2);
|
|
<a name="l228"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l229"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l230"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l231"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l232"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>DiffSub</span><span class=cF7>(</span><span class=cF0>doc, _df_flags, j1_lo, best_j1, j2_lo, best_j2, count1, count2,
|
|
<a name="l233"></a> doc_sorted1, doc_sorted2, doc_unsorted1, doc_unsorted2</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l234"></a> res = </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l235"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>DiffSub</span><span class=cF7>(</span><span class=cF0>doc, _df_flags, best_j1 + best_score, j1_hi, best_j2 + best_score, j2_hi, count1, count2,
|
|
<a name="l236"></a> doc_sorted1, doc_sorted2, doc_unsorted1, doc_unsorted2</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l237"></a> res = </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l238"></a>
|
|
<a name="l239"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l240"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l241"></a>}
|
|
<a name="l242"></a>
|
|
<a name="l243"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>DiffBins</span><span class=cF0>(</span><span class=cF9>CDoc</span><span class=cF0> *doc1, </span><span class=cF9>CDoc</span><span class=cF0> *doc2)
|
|
<a name="l244"></a>{
|
|
<a name="l245"></a> </span><span class=cF9>CDocBin</span><span class=cF0> *tmpb1 = doc1->bin_head.next, *tmpb2 = doc2->bin_head.next;
|
|
<a name="l246"></a>
|
|
<a name="l247"></a> </span><span class=cF1>if</span><span class=cF0> (tmpb1->last->last->num != tmpb2->last->last->num)
|
|
<a name="l248"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l249"></a> </span><span class=cF1>while</span><span class=cF0> (tmpb1 != &doc1->bin_head)
|
|
<a name="l250"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l251"></a> </span><span class=cF1>if</span><span class=cF0> (tmpb1->size != tmpb2->size || </span><span class=cF5>MemCompare</span><span class=cF7>(</span><span class=cF0>tmpb1->data, tmpb2->data, tmpb1->size</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l252"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l253"></a> tmpb1 = tmpb1->next;
|
|
<a name="l254"></a> tmpb2 = tmpb2->next;
|
|
<a name="l255"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l256"></a>
|
|
<a name="l257"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l258"></a>}
|
|
<a name="l259"></a>
|
|
<a name="l260"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>Diff</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *dst_file, </span><span class=cF1>U8</span><span class=cF0> *src_file, </span><span class=cF9>I64</span><span class=cF0> *_df_flags=</span><span class=cF3>NULL</span><span class=cF0>)
|
|
<a name="l261"></a>{</span><span class=cF2>//Report differences between two files and merge differences</span><span class=cF0>
|
|
<a name="l262"></a></span><span class=cF2>//from src_file to dst_file.</span><span class=cF0> </span><span class=cF2>Don't use _df_flags arg. (Used by </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Utils/Merge.CC.html#l45"><span class=cF4>Merge</span></a><span class=cF2>().)</span><span class=cF0>
|
|
<a name="l263"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc1 = </span><span class=cF5>DocRead</span><span class=cF0>(dst_file, </span><span class=cF3>DOCF_PLAIN_TEXT_TABS</span><span class=cF0> | </span><span class=cF3>DOCF_NO_CURSOR</span><span class=cF0>),
|
|
<a name="l264"></a> *doc2 = </span><span class=cF5>DocRead</span><span class=cF0>(src_file, </span><span class=cF3>DOCF_PLAIN_TEXT_TABS</span><span class=cF0> | </span><span class=cF3>DOCF_NO_CURSOR</span><span class=cF0>);
|
|
<a name="l265"></a> </span><span class=cF9>CDocEntry</span><span class=cF0> *doc_e, **doc_sorted1, **doc_sorted2, **doc_unsorted1, **doc_unsorted2;
|
|
<a name="l266"></a> </span><span class=cF9>I64</span><span class=cF0> i, count1 = </span><span class=cFE>0</span><span class=cF0>, count2 = </span><span class=cFE>0</span><span class=cF0>,df_flags;
|
|
<a name="l267"></a> </span><span class=cF1>Bool</span><span class=cF0> res = </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l268"></a>
|
|
<a name="l269"></a> </span><span class=cF1>if</span><span class=cF0> (_df_flags)
|
|
<a name="l270"></a> df_flags = *_df_flags;
|
|
<a name="l271"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l272"></a> df_flags = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l273"></a> df_flags &= </span><span class=cF3>DF_ABORT_ALL_FILES</span><span class=cF0>;
|
|
<a name="l274"></a>
|
|
<a name="l275"></a> doc_e = doc1->head.next;
|
|
<a name="l276"></a> </span><span class=cF1>while</span><span class=cF0> (doc_e != doc1)
|
|
<a name="l277"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l278"></a> </span><span class=cF1>if</span><span class=cF0> (doc_e->type_u8 == </span><span class=cF3>DOCT_TEXT</span><span class=cF0>)
|
|
<a name="l279"></a> doc_e->user_data = count1++; </span><span class=cF2>//user_data is the new y</span><span class=cF0>
|
|
<a name="l280"></a> doc_e = doc_e->next;
|
|
<a name="l281"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l282"></a>
|
|
<a name="l283"></a> doc_e = doc2->head.next;
|
|
<a name="l284"></a> </span><span class=cF1>while</span><span class=cF0> (doc_e != doc2)
|
|
<a name="l285"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l286"></a> </span><span class=cF1>if</span><span class=cF0> (doc_e->type_u8 == </span><span class=cF3>DOCT_TEXT</span><span class=cF0>)
|
|
<a name="l287"></a> doc_e->user_data = count2++; </span><span class=cF2>//user_data is the new y</span><span class=cF0>
|
|
<a name="l288"></a> doc_e = doc_e->next;
|
|
<a name="l289"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l290"></a>
|
|
<a name="l291"></a> doc_sorted1 = </span><span class=cF5>MAlloc</span><span class=cF0>(count1 * </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDocEntry</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l292"></a> doc_unsorted1 = </span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF7>(</span><span class=cF0>count1 + </span><span class=cFE>1</span><span class=cF7>)</span><span class=cF0> * </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDocEntry</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l293"></a> i = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l294"></a> doc_e = doc1->head.next;
|
|
<a name="l295"></a> </span><span class=cF1>while</span><span class=cF0> (doc_e != doc1)
|
|
<a name="l296"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l297"></a> </span><span class=cF1>if</span><span class=cF0> (doc_e->type_u8 == </span><span class=cF3>DOCT_TEXT</span><span class=cF0>)
|
|
<a name="l298"></a> {
|
|
<a name="l299"></a> doc_sorted1[i] = doc_e;
|
|
<a name="l300"></a> doc_unsorted1[i++] = doc_e;
|
|
<a name="l301"></a> }
|
|
<a name="l302"></a> doc_e = doc_e->next;
|
|
<a name="l303"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l304"></a> doc_unsorted1[i] = doc1;
|
|
<a name="l305"></a> </span><span class=cF5>QuickSortI64</span><span class=cF0>(doc_sorted1, count1, &</span><span class=cF5>DiffEntriesCompare</span><span class=cF0>);
|
|
<a name="l306"></a>
|
|
<a name="l307"></a> doc_sorted2 = </span><span class=cF5>MAlloc</span><span class=cF0>(count2 * </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDocEntry</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l308"></a> doc_unsorted2 = </span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF7>(</span><span class=cF0>count2 + </span><span class=cFE>1</span><span class=cF7>)</span><span class=cF0> * </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDocEntry</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l309"></a> i = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l310"></a> doc_e = doc2->head.next;
|
|
<a name="l311"></a> </span><span class=cF1>while</span><span class=cF0> (doc_e != doc2)
|
|
<a name="l312"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l313"></a> </span><span class=cF1>if</span><span class=cF0> (doc_e->type_u8 == </span><span class=cF3>DOCT_TEXT</span><span class=cF0>)
|
|
<a name="l314"></a> {
|
|
<a name="l315"></a> doc_sorted2[i] = doc_e;
|
|
<a name="l316"></a> doc_unsorted2[i++] = doc_e;
|
|
<a name="l317"></a> }
|
|
<a name="l318"></a> doc_e = doc_e->next;
|
|
<a name="l319"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l320"></a> doc_unsorted2[i] = doc2;
|
|
<a name="l321"></a> </span><span class=cF5>QuickSortI64</span><span class=cF0>(doc_sorted2, count2, &</span><span class=cF5>DiffEntriesCompare</span><span class=cF0>);
|
|
<a name="l322"></a>
|
|
<a name="l323"></a> res = </span><span class=cF5>DiffSub</span><span class=cF0>(doc1, &df_flags, </span><span class=cFE>0</span><span class=cF0>, count1, </span><span class=cFE>0</span><span class=cF0>, count2, count1, count2,
|
|
<a name="l324"></a> doc_sorted1, doc_sorted2, doc_unsorted1, doc_unsorted2);
|
|
<a name="l325"></a> </span><span class=cF1>if</span><span class=cF0> (df_flags & </span><span class=cF3>DF_MODIFIED</span><span class=cF0> && !</span><span class=cF7>(</span><span class=cF0>df_flags & </span><span class=cF3>DF_DONT_MODIFIED</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l326"></a> </span><span class=cF5>DocWrite</span><span class=cF0>(doc1);
|
|
<a name="l327"></a>
|
|
<a name="l328"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>DiffBins</span><span class=cF7>(</span><span class=cF0>doc1, doc2</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l329"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l330"></a> </span><span class=cF6>"$RED$Bin Data is Different$FG$\n"</span><span class=cF0>;
|
|
<a name="l331"></a> res = </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l332"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l333"></a>
|
|
<a name="l334"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc1);
|
|
<a name="l335"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc2);
|
|
<a name="l336"></a> </span><span class=cF5>Free</span><span class=cF0>(doc_sorted1);
|
|
<a name="l337"></a> </span><span class=cF5>Free</span><span class=cF0>(doc_sorted2);
|
|
<a name="l338"></a> </span><span class=cF5>Free</span><span class=cF0>(doc_unsorted1);
|
|
<a name="l339"></a> </span><span class=cF5>Free</span><span class=cF0>(doc_unsorted2);
|
|
<a name="l340"></a> </span><span class=cF1>if</span><span class=cF0> (_df_flags)
|
|
<a name="l341"></a> *_df_flags = df_flags;
|
|
<a name="l342"></a>
|
|
<a name="l343"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l344"></a>}
|
|
</span></pre></body>
|
|
</html>
|