diff --git a/inst/js/daff.js b/inst/js/daff.js index cd98b6b..c0bac89 100644 --- a/inst/js/daff.js +++ b/inst/js/daff.js @@ -1,9 +1,9 @@ -// Generated by Haxe 3.4.2 +// Generated by Haxe 4.1.5 (function ($hx_exports, $global) { "use strict"; $hx_exports["coopy"] = $hx_exports["coopy"] || {}; -var $estr = function() { return js_Boot.__string_rec(this,''); }; +var $estr = function() { return js_Boot.__string_rec(this,''); },$hxEnums = $hxEnums || {},$_; function $extend(from, fields) { - function Inherit() {} Inherit.prototype = from; var proto = new Inherit(); + var proto = Object.create(from); for (var name in fields) proto[name] = fields[name]; if( fields.toString !== Object.prototype.toString ) proto.toString = fields.toString; return proto; @@ -18,29 +18,6 @@ HxOverrides.dateStr = function(date) { var s = date.getSeconds(); return date.getFullYear() + "-" + (m < 10 ? "0" + m : "" + m) + "-" + (d < 10 ? "0" + d : "" + d) + " " + (h < 10 ? "0" + h : "" + h) + ":" + (mi < 10 ? "0" + mi : "" + mi) + ":" + (s < 10 ? "0" + s : "" + s); }; -HxOverrides.strDate = function(s) { - var _g = s.length; - switch(_g) { - case 8: - var k = s.split(":"); - var d = new Date(); - d["setTime"](0); - d["setUTCHours"](k[0]); - d["setUTCMinutes"](k[1]); - d["setUTCSeconds"](k[2]); - return d; - case 10: - var k1 = s.split("-"); - return new Date(k1[0],k1[1] - 1,k1[2],0,0,0); - case 19: - var k2 = s.split(" "); - var y = k2[0].split("-"); - var t = k2[1].split(":"); - return new Date(y[0],y[1] - 1,y[2],t[0],t[1],t[2]); - default: - throw new js__$Boot_HaxeError("Invalid date format : " + s); - } -}; HxOverrides.cca = function(s,index) { var x = s.charCodeAt(index); if(x != x) { @@ -60,35 +37,30 @@ HxOverrides.substr = function(s,pos,len) { } return s.substr(pos,len); }; -HxOverrides.iter = function(a) { - return { cur : 0, arr : a, hasNext : function() { - return this.cur < this.arr.length; - }, next : function() { - return this.arr[this.cur++]; - }}; +HxOverrides.remove = function(a,obj) { + var i = a.indexOf(obj); + if(i == -1) { + return false; + } + a.splice(i,1); + return true; +}; +HxOverrides.now = function() { + return Date.now(); }; var Lambda = function() { }; Lambda.__name__ = true; Lambda.array = function(it) { var a = []; - var i = $iterator(it)(); + var i = $getIterator(it); while(i.hasNext()) { var i1 = i.next(); a.push(i1); } return a; }; -Lambda.map = function(it,f) { - var l = new List(); - var x = $iterator(it)(); - while(x.hasNext()) { - var x1 = x.next(); - l.add(f(x1)); - } - return l; -}; Lambda.has = function(it,elt) { - var x = $iterator(it)(); + var x = $getIterator(it); while(x.hasNext()) { var x1 = x.next(); if(x1 == elt) { @@ -97,56 +69,13 @@ Lambda.has = function(it,elt) { } return false; }; -var List = function() { - this.length = 0; -}; -List.__name__ = true; -List.prototype = { - add: function(item) { - var x = new _$List_ListNode(item,null); - if(this.h == null) { - this.h = x; - } else { - this.q.next = x; - } - this.q = x; - this.length++; - } - ,iterator: function() { - return new _$List_ListIterator(this.h); - } - ,__class__: List -}; -var _$List_ListNode = function(item,next) { - this.item = item; - this.next = next; -}; -_$List_ListNode.__name__ = true; -_$List_ListNode.prototype = { - __class__: _$List_ListNode -}; -var _$List_ListIterator = function(head) { - this.head = head; -}; -_$List_ListIterator.__name__ = true; -_$List_ListIterator.prototype = { - hasNext: function() { - return this.head != null; - } - ,next: function() { - var val = this.head.item; - this.head = this.head.next; - return val; - } - ,__class__: _$List_ListIterator -}; Math.__name__ = true; var Reflect = function() { }; Reflect.__name__ = true; Reflect.field = function(o,field) { try { return o[field]; - } catch( e ) { + } catch( _g ) { return null; } }; @@ -184,24 +113,81 @@ Std.string = function(s) { return js_Boot.__string_rec(s,""); }; Std.parseInt = function(x) { - var v = parseInt(x,10); - if(v == 0 && (HxOverrides.cca(x,1) == 120 || HxOverrides.cca(x,1) == 88)) { - v = parseInt(x); - } - if(isNaN(v)) { - return null; + if(x != null) { + var _g = 0; + var _g1 = x.length; + while(_g < _g1) { + var i = _g++; + var c = x.charCodeAt(i); + if(c <= 8 || c >= 14 && c != 32 && c != 45) { + var nc = x.charCodeAt(i + 1); + var v = parseInt(x,nc == 120 || nc == 88 ? 16 : 10); + if(isNaN(v)) { + return null; + } else { + return v; + } + } + } } - return v; + return null; }; var StringBuf = function() { this.b = ""; }; StringBuf.__name__ = true; StringBuf.prototype = { - __class__: StringBuf + b: null + ,__class__: StringBuf }; var StringTools = function() { }; StringTools.__name__ = true; +StringTools.htmlEscape = function(s,quotes) { + var buf_b = ""; + var _g_offset = 0; + var _g_s = s; + while(_g_offset < _g_s.length) { + var s = _g_s; + var index = _g_offset++; + var c = s.charCodeAt(index); + if(c >= 55296 && c <= 56319) { + c = c - 55232 << 10 | s.charCodeAt(index + 1) & 1023; + } + var c1 = c; + if(c1 >= 65536) { + ++_g_offset; + } + var code = c1; + switch(code) { + case 34: + if(quotes) { + buf_b += """; + } else { + buf_b += String.fromCodePoint(code); + } + break; + case 38: + buf_b += "&"; + break; + case 39: + if(quotes) { + buf_b += "'"; + } else { + buf_b += String.fromCodePoint(code); + } + break; + case 60: + buf_b += "<"; + break; + case 62: + buf_b += ">"; + break; + default: + buf_b += String.fromCodePoint(code); + } + } + return buf_b; +}; StringTools.isSpace = function(s,pos) { var c = HxOverrides.cca(s,pos); if(!(c > 8 && c < 14)) { @@ -237,41 +223,37 @@ StringTools.lpad = function(s,c,l) { if(c.length <= 0) { return s; } - while(s.length < l) s = c + s; - return s; + var buf_b = ""; + l -= s.length; + while(buf_b.length < l) buf_b += c == null ? "null" : "" + c; + buf_b += s == null ? "null" : "" + s; + return buf_b; }; StringTools.replace = function(s,sub,by) { return s.split(sub).join(by); }; -var ValueType = { __ename__ : true, __constructs__ : ["TNull","TInt","TFloat","TBool","TObject","TFunction","TClass","TEnum","TUnknown"] }; -ValueType.TNull = ["TNull",0]; -ValueType.TNull.toString = $estr; -ValueType.TNull.__enum__ = ValueType; -ValueType.TInt = ["TInt",1]; -ValueType.TInt.toString = $estr; -ValueType.TInt.__enum__ = ValueType; -ValueType.TFloat = ["TFloat",2]; -ValueType.TFloat.toString = $estr; -ValueType.TFloat.__enum__ = ValueType; -ValueType.TBool = ["TBool",3]; -ValueType.TBool.toString = $estr; -ValueType.TBool.__enum__ = ValueType; -ValueType.TObject = ["TObject",4]; -ValueType.TObject.toString = $estr; -ValueType.TObject.__enum__ = ValueType; -ValueType.TFunction = ["TFunction",5]; -ValueType.TFunction.toString = $estr; -ValueType.TFunction.__enum__ = ValueType; -ValueType.TClass = function(c) { var $x = ["TClass",6,c]; $x.__enum__ = ValueType; $x.toString = $estr; return $x; }; -ValueType.TEnum = function(e) { var $x = ["TEnum",7,e]; $x.__enum__ = ValueType; $x.toString = $estr; return $x; }; -ValueType.TUnknown = ["TUnknown",8]; -ValueType.TUnknown.toString = $estr; -ValueType.TUnknown.__enum__ = ValueType; +var ValueType = $hxEnums["ValueType"] = { __ename__ : true, __constructs__ : ["TNull","TInt","TFloat","TBool","TObject","TFunction","TClass","TEnum","TUnknown"] + ,TNull: {_hx_index:0,__enum__:"ValueType",toString:$estr} + ,TInt: {_hx_index:1,__enum__:"ValueType",toString:$estr} + ,TFloat: {_hx_index:2,__enum__:"ValueType",toString:$estr} + ,TBool: {_hx_index:3,__enum__:"ValueType",toString:$estr} + ,TObject: {_hx_index:4,__enum__:"ValueType",toString:$estr} + ,TFunction: {_hx_index:5,__enum__:"ValueType",toString:$estr} + ,TClass: ($_=function(c) { return {_hx_index:6,c:c,__enum__:"ValueType",toString:$estr}; },$_.__params__ = ["c"],$_) + ,TEnum: ($_=function(e) { return {_hx_index:7,e:e,__enum__:"ValueType",toString:$estr}; },$_.__params__ = ["e"],$_) + ,TUnknown: {_hx_index:8,__enum__:"ValueType",toString:$estr} +}; var Type = function() { }; Type.__name__ = true; -Type["typeof"] = function(v) { - var _g = typeof(v); - switch(_g) { +Type.getInstanceFields = function(c) { + var a = []; + for(var i in c.prototype) a.push(i); + HxOverrides.remove(a,"__class__"); + HxOverrides.remove(a,"__properties__"); + return a; +}; +Type.typeof = function(v) { + switch(typeof(v)) { case "boolean": return ValueType.TBool; case "function": @@ -290,7 +272,7 @@ Type["typeof"] = function(v) { } var e = v.__enum__; if(e != null) { - return ValueType.TEnum(e); + return ValueType.TEnum($hxEnums[e]); } var c = js_Boot.getClass(v); if(c != null) { @@ -320,7 +302,25 @@ var coopy_Alignment = function() { }; coopy_Alignment.__name__ = true; coopy_Alignment.prototype = { - range: function(ha,hb) { + map_a2b: null + ,map_b2a: null + ,ha: null + ,hb: null + ,ta: null + ,tb: null + ,ia: null + ,ib: null + ,map_count: null + ,order_cache: null + ,order_cache_has_reference: null + ,index_columns: null + ,marked_as_identical: null + ,reference: null + ,meta: null + ,comp: null + ,has_addition: null + ,has_removal: null + ,range: function(ha,hb) { this.ha = ha; this.hb = hb; } @@ -366,7 +366,7 @@ coopy_Alignment.prototype = { return this.map_count; } ,toString: function() { - var result = "" + this.map_a2b.toString() + " // " + this.map_b2a.toString(); + var result = "" + (this.map_a2b == null ? "null" : this.map_a2b.toString()) + " // " + (this.map_b2a == null ? "null" : this.map_b2a.toString()); if(this.reference != null) { result += " (" + Std.string(this.reference) + ")"; } @@ -421,56 +421,56 @@ coopy_Alignment.prototype = { unit.r = this.a2b(k1); order.push(unit); } - var k2 = this.map_b2a.keys(); - while(k2.hasNext()) { - var k3 = k2.next(); - if(this.b2a(k3) == -1) { - var unit1 = new coopy_Unit(); - unit1.l = -1; - unit1.r = k3; - order.push(unit1); + var k = this.map_b2a.keys(); + while(k.hasNext()) { + var k1 = k.next(); + if(this.b2a(k1) == -1) { + var unit = new coopy_Unit(); + unit.l = -1; + unit.r = k1; + order.push(unit); } } } else { - var k4 = this.map_a2b.keys(); - while(k4.hasNext()) { - var k5 = k4.next(); - var unit2 = new coopy_Unit(); - unit2.p = k5; - unit2.l = this.reference.a2b(k5); - unit2.r = this.a2b(k5); - order.push(unit2); - } - var k6 = this.reference.map_b2a.keys(); - while(k6.hasNext()) { - var k7 = k6.next(); - if(this.reference.b2a(k7) == -1) { - var unit3 = new coopy_Unit(); - unit3.p = -1; - unit3.l = k7; - unit3.r = -1; - order.push(unit3); - } - } - var k8 = this.map_b2a.keys(); - while(k8.hasNext()) { - var k9 = k8.next(); - if(this.b2a(k9) == -1) { - var unit4 = new coopy_Unit(); - unit4.p = -1; - unit4.l = -1; - unit4.r = k9; - order.push(unit4); + var k = this.map_a2b.keys(); + while(k.hasNext()) { + var k1 = k.next(); + var unit = new coopy_Unit(); + unit.p = k1; + unit.l = this.reference.a2b(k1); + unit.r = this.a2b(k1); + order.push(unit); + } + var k = this.reference.map_b2a.keys(); + while(k.hasNext()) { + var k1 = k.next(); + if(this.reference.b2a(k1) == -1) { + var unit = new coopy_Unit(); + unit.p = -1; + unit.l = k1; + unit.r = -1; + order.push(unit); + } + } + var k = this.map_b2a.keys(); + while(k.hasNext()) { + var k1 = k.next(); + if(this.b2a(k1) == -1) { + var unit = new coopy_Unit(); + unit.p = -1; + unit.l = -1; + unit.r = k1; + order.push(unit); } } } var top = order.length; var remotes = []; var locals = []; - var _g1 = 0; - var _g = top; - while(_g1 < _g) { - var o = _g1++; + var _g = 0; + var _g1 = top; + while(_g < _g1) { + var o = _g++; if(order[o].r >= 0) { remotes.push(o); } else { @@ -480,58 +480,58 @@ coopy_Alignment.prototype = { var remote_sort = function(a,b) { return order[a].r - order[b].r; }; - var local_sort = function(a1,b1) { - if(a1 == b1) { + var local_sort = function(a,b) { + if(a == b) { return 0; } - if(order[a1].l >= 0 && order[b1].l >= 0) { - return order[a1].l - order[b1].l; + if(order[a].l >= 0 && order[b].l >= 0) { + return order[a].l - order[b].l; } - if(order[a1].l >= 0) { + if(order[a].l >= 0) { return 1; } - if(order[b1].l >= 0) { + if(order[b].l >= 0) { return -1; } - return a1 - b1; + return a - b; }; if(this.reference != null) { - remote_sort = function(a2,b2) { - if(a2 == b2) { + remote_sort = function(a,b) { + if(a == b) { return 0; } - var o1 = order[a2].r - order[b2].r; - if(order[a2].p >= 0 && order[b2].p >= 0) { - var o2 = order[a2].p - order[b2].p; + var o1 = order[a].r - order[b].r; + if(order[a].p >= 0 && order[b].p >= 0) { + var o2 = order[a].p - order[b].p; if(o1 * o2 < 0) { return o1; } - var o3 = order[a2].l - order[b2].l; + var o3 = order[a].l - order[b].l; return o3; } return o1; }; - local_sort = function(a3,b3) { - if(a3 == b3) { + local_sort = function(a,b) { + if(a == b) { return 0; } - if(order[a3].l >= 0 && order[b3].l >= 0) { - var o11 = order[a3].l - order[b3].l; - if(order[a3].p >= 0 && order[b3].p >= 0) { - var o21 = order[a3].p - order[b3].p; - if(o11 * o21 < 0) { - return o11; + if(order[a].l >= 0 && order[b].l >= 0) { + var o1 = order[a].l - order[b].l; + if(order[a].p >= 0 && order[b].p >= 0) { + var o2 = order[a].p - order[b].p; + if(o1 * o2 < 0) { + return o1; } - return o21; + return o2; } } - if(order[a3].l >= 0) { + if(order[a].l >= 0) { return 1; } - if(order[b3].l >= 0) { + if(order[b].l >= 0) { return -1; } - return a3 - b3; + return a - b; }; } remotes.sort(remote_sort); @@ -539,10 +539,10 @@ coopy_Alignment.prototype = { var revised_order = []; var at_r = 0; var at_l = 0; - var _g11 = 0; - var _g2 = top; - while(_g11 < _g2) { - var o4 = _g11++; + var _g = 0; + var _g1 = top; + while(_g < _g1) { + var o = _g++; if(at_r < remotes.length && at_l < locals.length) { var ur = order[remotes[at_r]]; var ul = order[locals[at_l]]; @@ -593,13 +593,34 @@ coopy_Alignment.prototype = { var coopy_CellBuilder = function() { }; coopy_CellBuilder.__name__ = true; coopy_CellBuilder.prototype = { - __class__: coopy_CellBuilder + needSeparator: null + ,setSeparator: null + ,setConflictSeparator: null + ,setView: null + ,update: null + ,conflict: null + ,marker: null + ,links: null + ,__class__: coopy_CellBuilder }; var coopy_CellInfo = $hx_exports["coopy"]["CellInfo"] = function() { }; coopy_CellInfo.__name__ = true; coopy_CellInfo.prototype = { - toString: function() { + raw: null + ,value: null + ,pretty_value: null + ,category: null + ,category_given_tr: null + ,separator: null + ,pretty_separator: null + ,updated: null + ,conflicted: null + ,pvalue: null + ,lvalue: null + ,rvalue: null + ,meta: null + ,toString: function() { if(!this.updated) { return this.value; } @@ -614,12 +635,30 @@ var coopy_ColumnChange = $hx_exports["coopy"]["ColumnChange"] = function() { }; coopy_ColumnChange.__name__ = true; coopy_ColumnChange.prototype = { - __class__: coopy_ColumnChange + prevName: null + ,name: null + ,props: null + ,__class__: coopy_ColumnChange }; var coopy_Table = function() { }; coopy_Table.__name__ = true; coopy_Table.prototype = { - __class__: coopy_Table + getCell: null + ,setCell: null + ,getCellView: null + ,isResizable: null + ,resize: null + ,clear: null + ,insertOrDeleteRows: null + ,insertOrDeleteColumns: null + ,trimBlank: null + ,get_width: null + ,get_height: null + ,getData: null + ,clone: null + ,create: null + ,getMeta: null + ,__class__: coopy_Table }; var coopy_CombinedTable = $hx_exports["coopy"]["CombinedTable"] = function(t) { this.t = t; @@ -636,10 +675,10 @@ var coopy_CombinedTable = $hx_exports["coopy"]["CombinedTable"] = function(t) { } this.dx = 1; this.dy = 0; - var _g1 = 0; - var _g = t.get_height(); - while(_g1 < _g) { - var y = _g1++; + var _g = 0; + var _g1 = t.get_height(); + while(_g < _g1) { + var y = _g++; var txt = v.toString(t.getCell(0,y)); if(txt == null || txt == "" || txt == "null") { break; @@ -654,7 +693,14 @@ var coopy_CombinedTable = $hx_exports["coopy"]["CombinedTable"] = function(t) { coopy_CombinedTable.__name__ = true; coopy_CombinedTable.__interfaces__ = [coopy_Table]; coopy_CombinedTable.prototype = { - all: function() { + t: null + ,body: null + ,head: null + ,dx: null + ,dy: null + ,core: null + ,meta: null + ,all: function() { return this.t; } ,getTable: function() { @@ -719,7 +765,12 @@ var coopy_CombinedTableBody = function(parent,dx,dy) { coopy_CombinedTableBody.__name__ = true; coopy_CombinedTableBody.__interfaces__ = [coopy_Table]; coopy_CombinedTableBody.prototype = { - getTable: function() { + parent: null + ,dx: null + ,dy: null + ,all: null + ,meta: null + ,getTable: function() { return this; } ,get_width: function() { @@ -763,17 +814,17 @@ coopy_CombinedTableBody.prototype = { } ,insertOrDeleteRows: function(fate,hfate) { var fate2 = []; - var _g1 = 0; - var _g = this.dy; - while(_g1 < _g) { - var y = _g1++; + var _g = 0; + var _g1 = this.dy; + while(_g < _g1) { + var y = _g++; fate2.push(y); } var hdr = true; - var _g2 = 0; - while(_g2 < fate.length) { - var f = fate[_g2]; - ++_g2; + var _g = 0; + while(_g < fate.length) { + var f = fate[_g]; + ++_g; if(hdr) { hdr = false; continue; @@ -784,16 +835,16 @@ coopy_CombinedTableBody.prototype = { } ,insertOrDeleteColumns: function(fate,wfate) { var fate2 = []; - var _g1 = 0; - var _g = this.dx + 1; - while(_g1 < _g) { - var x = _g1++; + var _g = 0; + var _g1 = this.dx + 1; + while(_g < _g1) { + var x = _g++; fate2.push(x); } - var _g2 = 0; - while(_g2 < fate.length) { - var f = fate[_g2]; - ++_g2; + var _g = 0; + while(_g < fate.length) { + var f = fate[_g]; + ++_g; fate2.push(f >= 0 ? f + this.dx + 1 : f); } return this.all.insertOrDeleteColumns(fate2,wfate + this.dx); @@ -824,7 +875,11 @@ var coopy_CombinedTableHead = function(parent,dx,dy) { coopy_CombinedTableHead.__name__ = true; coopy_CombinedTableHead.__interfaces__ = [coopy_Table]; coopy_CombinedTableHead.prototype = { - getTable: function() { + parent: null + ,dx: null + ,dy: null + ,all: null + ,getTable: function() { return this; } ,get_width: function() { @@ -905,79 +960,91 @@ var coopy_CompareFlags = $hx_exports["coopy"]["CompareFlags"] = function() { this.count_like_a_spreadsheet = true; this.ignore_whitespace = false; this.ignore_case = false; + this.ignore_epsilon = -1; this.terminal_format = null; this.use_glyphs = true; + this.quote_html = true; }; coopy_CompareFlags.__name__ = true; coopy_CompareFlags.prototype = { - filter: function(act,allow) { + ordered: null + ,show_unchanged: null + ,unchanged_context: null + ,always_show_order: null + ,never_show_order: null + ,show_unchanged_columns: null + ,unchanged_column_context: null + ,always_show_header: null + ,acts: null + ,ids: null + ,columns_to_ignore: null + ,tables: null + ,allow_nested_cells: null + ,warnings: null + ,diff_strategy: null + ,padding_strategy: null + ,show_meta: null + ,show_unchanged_meta: null + ,parent: null + ,count_like_a_spreadsheet: null + ,ignore_whitespace: null + ,ignore_case: null + ,ignore_epsilon: null + ,terminal_format: null + ,use_glyphs: null + ,quote_html: null + ,filter: function(act,allow) { if(this.acts == null) { this.acts = new haxe_ds_StringMap(); - var _this = this.acts; - var value = !allow; - if(__map_reserved["update"] != null) { - _this.setReserved("update",value); - } else { - _this.h["update"] = value; - } - var _this1 = this.acts; - var value1 = !allow; - if(__map_reserved["insert"] != null) { - _this1.setReserved("insert",value1); - } else { - _this1.h["insert"] = value1; - } - var _this2 = this.acts; - var value2 = !allow; - if(__map_reserved["delete"] != null) { - _this2.setReserved("delete",value2); - } else { - _this2.h["delete"] = value2; - } + this.acts.h["update"] = !allow; + this.acts.h["insert"] = !allow; + this.acts.h["delete"] = !allow; + this.acts.h["column"] = !allow; } - var _this3 = this.acts; - if(!(__map_reserved[act] != null ? _this3.existsReserved(act) : _this3.h.hasOwnProperty(act))) { + if(!Object.prototype.hasOwnProperty.call(this.acts.h,act)) { return false; } - var _this4 = this.acts; - if(__map_reserved[act] != null) { - _this4.setReserved(act,allow); - } else { - _this4.h[act] = allow; - } + this.acts.h[act] = allow; return true; } ,allowUpdate: function() { if(this.acts == null) { return true; } - var _this = this.acts; - if(__map_reserved["update"] != null) { - return _this.existsReserved("update"); + if(Object.prototype.hasOwnProperty.call(this.acts.h,"update")) { + return this.acts.h["update"]; } else { - return _this.h.hasOwnProperty("update"); + return false; } } ,allowInsert: function() { if(this.acts == null) { return true; } - var _this = this.acts; - if(__map_reserved["insert"] != null) { - return _this.existsReserved("insert"); + if(Object.prototype.hasOwnProperty.call(this.acts.h,"insert")) { + return this.acts.h["insert"]; } else { - return _this.h.hasOwnProperty("insert"); + return false; } } ,allowDelete: function() { if(this.acts == null) { return true; } - var _this = this.acts; - if(__map_reserved["delete"] != null) { - return _this.existsReserved("delete"); + if(Object.prototype.hasOwnProperty.call(this.acts.h,"delete")) { + return this.acts.h["delete"]; } else { - return _this.h.hasOwnProperty("delete"); + return false; + } + } + ,allowColumn: function() { + if(this.acts == null) { + return true; + } + if(Object.prototype.hasOwnProperty.call(this.acts.h,"column")) { + return this.acts.h["column"]; + } else { + return false; } } ,getIgnoredColumns: function() { @@ -985,16 +1052,11 @@ coopy_CompareFlags.prototype = { return null; } var ignore = new haxe_ds_StringMap(); - var _g1 = 0; - var _g = this.columns_to_ignore.length; - while(_g1 < _g) { - var i = _g1++; - var key = this.columns_to_ignore[i]; - if(__map_reserved[key] != null) { - ignore.setReserved(key,true); - } else { - ignore.h[key] = true; - } + var _g = 0; + var _g1 = this.columns_to_ignore.length; + while(_g < _g1) { + var i = _g++; + ignore.h[this.columns_to_ignore[i]] = true; } return ignore; } @@ -1025,6 +1087,36 @@ coopy_CompareFlags.prototype = { ,getWarning: function() { return this.warnings.join("\n"); } + ,getNameByRole: function(name,role) { + var parts = name.split(":"); + if(parts.length <= 1) { + return name; + } + if(role == "parent") { + return parts[0]; + } + if(role == "local") { + return parts[parts.length - 2]; + } + return parts[parts.length - 1]; + } + ,getCanonicalName: function(name) { + return this.getNameByRole(name,"local"); + } + ,getIdsByRole: function(role) { + var result = []; + if(this.ids == null) { + return result; + } + var _g = 0; + var _g1 = this.ids; + while(_g < _g1.length) { + var name = _g1[_g]; + ++_g; + result.push(this.getNameByRole(name,role)); + } + return result; + } ,__class__: coopy_CompareFlags }; var coopy_CompareTable = $hx_exports["coopy"]["CompareTable"] = function(comp) { @@ -1037,7 +1129,9 @@ var coopy_CompareTable = $hx_exports["coopy"]["CompareTable"] = function(comp) { }; coopy_CompareTable.__name__ = true; coopy_CompareTable.prototype = { - run: function() { + comp: null + ,indexes: null + ,run: function() { if(this.useSql()) { this.comp.completed = true; return false; @@ -1081,7 +1175,7 @@ coopy_CompareTable.prototype = { if(db == null && tab3 != null) { db = tab3.getDatabase(); } - var sc = new coopy_SqlCompare(db,tab1,tab2,tab3,align); + var sc = new coopy_SqlCompare(db,tab1,tab2,tab3,align,this.comp.compare_flags); sc.apply(); if(this.comp.p != null) { align.meta.reference = align.reference.meta; @@ -1112,9 +1206,11 @@ coopy_CompareTable.prototype = { var av = a.getCellView(); var ids = null; var ignore = null; + var ordered = true; if(this.comp.compare_flags != null) { ids = this.comp.compare_flags.ids; ignore = this.comp.compare_flags.getIgnoredColumns(); + ordered = this.comp.compare_flags.ordered; } var common_units = []; var ra_header = align.getSourceHeader(); @@ -1128,13 +1224,13 @@ coopy_CompareTable.prototype = { if(ignore != null) { if(unit.l >= 0 && ra_header >= 0 && ra_header < a.get_height()) { var name = av.toString(a.getCell(unit.l,ra_header)); - if(__map_reserved[name] != null ? ignore.existsReserved(name) : ignore.h.hasOwnProperty(name)) { + if(Object.prototype.hasOwnProperty.call(ignore.h,name)) { continue; } } if(unit.r >= 0 && rb_header >= 0 && rb_header < b.get_height()) { var name1 = av.toString(b.getCell(unit.r,rb_header)); - if(__map_reserved[name1] != null ? ignore.existsReserved(name1) : ignore.h.hasOwnProperty(name1)) { + if(Object.prototype.hasOwnProperty.call(ignore.h,name1)) { continue; } } @@ -1145,40 +1241,36 @@ coopy_CompareTable.prototype = { var index_top = null; var pending_ct = ha; var reverse_pending_ct = hb; - var used = new haxe_ds_IntMap(); - var used_reverse = new haxe_ds_IntMap(); + var used_h = { }; + var used_reverse_h = { }; if(ids != null) { index_top = new coopy_IndexPair(this.comp.compare_flags); - var ids_as_map = new haxe_ds_StringMap(); - var _g2 = 0; - while(_g2 < ids.length) { - var id = ids[_g2]; - ++_g2; - if(__map_reserved[id] != null) { - ids_as_map.setReserved(id,true); - } else { - ids_as_map.h[id] = true; - } + var ids_as_map_h = Object.create(null); + var _g = 0; + while(_g < ids.length) { + var id = ids[_g]; + ++_g; + ids_as_map_h[id] = true; } - var _g3 = 0; - while(_g3 < common_units.length) { - var unit1 = common_units[_g3]; - ++_g3; - var na = av.toString(a.getCell(unit1.l,0)); - var nb = av.toString(b.getCell(unit1.r,0)); - if((__map_reserved[na] != null ? ids_as_map.existsReserved(na) : ids_as_map.h.hasOwnProperty(na)) || (__map_reserved[nb] != null ? ids_as_map.existsReserved(nb) : ids_as_map.h.hasOwnProperty(nb))) { - index_top.addColumns(unit1.l,unit1.r); - align.addIndexColumns(unit1); + var _g = 0; + while(_g < common_units.length) { + var unit = common_units[_g]; + ++_g; + var na = av.toString(a.getCell(unit.l,0)); + var nb = av.toString(b.getCell(unit.r,0)); + if(Object.prototype.hasOwnProperty.call(ids_as_map_h,na) || Object.prototype.hasOwnProperty.call(ids_as_map_h,nb)) { + index_top.addColumns(unit.l,unit.r); + align.addIndexColumns(unit); } } index_top.indexTables(a,b,1); if(this.indexes != null) { this.indexes.push(index_top); } - var _g11 = 0; - var _g4 = ha; - while(_g11 < _g4) { - var j = _g11++; + var _g = 0; + var _g1 = ha; + while(_g < _g1) { + var j = _g++; var cross = index_top.queryLocal(j); var spot_a = cross.spot_a; var spot_b = cross.spot_b; @@ -1187,98 +1279,95 @@ coopy_CompareTable.prototype = { } var jb = cross.item_b.lst[0]; align.link(j,jb); - used.h[jb] = 1; - if(!used_reverse.h.hasOwnProperty(j)) { + used_h[jb] = 1; + if(!used_reverse_h.hasOwnProperty(j)) { --reverse_pending_ct; } - used_reverse.h[j] = 1; + used_reverse_h[j] = 1; } } else { var N = 5; var columns = []; if(common_units.length > N) { var columns_eval = []; - var _g12 = 0; - var _g5 = common_units.length; - while(_g12 < _g5) { - var i = _g12++; + var _g = 0; + var _g1 = common_units.length; + while(_g < _g1) { + var i = _g++; var ct = 0; - var mem = new haxe_ds_StringMap(); - var mem2 = new haxe_ds_StringMap(); + var mem_h = Object.create(null); + var mem2_h = Object.create(null); var ca = common_units[i].l; var cb = common_units[i].r; - var _g31 = 0; - var _g21 = ha; - while(_g31 < _g21) { - var j1 = _g31++; - var key = av.toString(a.getCell(ca,j1)); - if(!(__map_reserved[key] != null ? mem.existsReserved(key) : mem.h.hasOwnProperty(key))) { - if(__map_reserved[key] != null) { - mem.setReserved(key,1); - } else { - mem.h[key] = 1; - } + var _g2 = 0; + var _g3 = ha; + while(_g2 < _g3) { + var j = _g2++; + var key = av.toString(a.getCell(ca,j)); + if(!Object.prototype.hasOwnProperty.call(mem_h,key)) { + mem_h[key] = 1; ++ct; } } - var _g32 = 0; - var _g22 = hb; - while(_g32 < _g22) { - var j2 = _g32++; - var key1 = av.toString(b.getCell(cb,j2)); - if(!(__map_reserved[key1] != null ? mem2.existsReserved(key1) : mem2.h.hasOwnProperty(key1))) { - if(__map_reserved[key1] != null) { - mem2.setReserved(key1,1); - } else { - mem2.h[key1] = 1; - } + var _g4 = 0; + var _g5 = hb; + while(_g4 < _g5) { + var j1 = _g4++; + var key1 = av.toString(b.getCell(cb,j1)); + if(!Object.prototype.hasOwnProperty.call(mem2_h,key1)) { + mem2_h[key1] = 1; ++ct; } } columns_eval.push([i,ct]); } - var sorter = function(a1,b1) { - if(a1[1] < b1[1]) { + var sorter = function(a,b) { + if(a[1] < b[1]) { return 1; } - if(a1[1] > b1[1]) { + if(a[1] > b[1]) { return -1; } - if(a1[0] > b1[0]) { + if(a[0] > b[0]) { return 1; } - if(a1[0] < b1[0]) { + if(a[0] < b[0]) { return -1; } return 0; }; columns_eval.sort(sorter); - columns = Lambda.array(Lambda.map(columns_eval,function(v) { - return v[0]; - })); + var _g = []; + var _g_current = 0; + var _g_array = columns_eval; + while(_g_current < _g_array.length) { + var x = _g_array[_g_current++]; + _g.push(x[0]); + } + columns = Lambda.array(_g); columns = columns.slice(0,N); } else { - var _g13 = 0; - var _g6 = common_units.length; - while(_g13 < _g6) { - var i1 = _g13++; - columns.push(i1); + var _g = 0; + var _g1 = common_units.length; + while(_g < _g1) { + var i = _g++; + columns.push(i); } } var top = Math.round(Math.pow(2,columns.length)); var pending = new haxe_ds_IntMap(); - var _g14 = 0; - var _g7 = ha; - while(_g14 < _g7) { - var j3 = _g14++; - pending.h[j3] = j3; + var _g = 0; + var _g1 = ha; + while(_g < _g1) { + var j = _g++; + pending.h[j] = j; } - var added_columns = new haxe_ds_IntMap(); + var added_columns_h = { }; var index_ct = 0; - var _g15 = 0; - var _g8 = top; - while(_g15 < _g8) { - var k = _g15++; + var _g = 0; + var _g1 = top; + while(_g < _g1) { + var k = _g++; if(k == 0) { continue; } @@ -1296,16 +1385,16 @@ coopy_CompareTable.prototype = { ++at; } var index = new coopy_IndexPair(this.comp.compare_flags); - var _g33 = 0; - var _g23 = active_columns.length; - while(_g33 < _g23) { - var k1 = _g33++; + var _g2 = 0; + var _g3 = active_columns.length; + while(_g2 < _g3) { + var k1 = _g2++; var col = active_columns[k1]; - var unit2 = common_units[col]; - index.addColumns(unit2.l,unit2.r); - if(!added_columns.h.hasOwnProperty(col)) { - align.addIndexColumns(unit2); - added_columns.h[col] = true; + var unit = common_units[col]; + index.addColumns(unit.l,unit.r); + if(!added_columns_h.hasOwnProperty(col)) { + align.addIndexColumns(unit); + added_columns_h[col] = true; } } index.indexTables(a,b,1); @@ -1332,31 +1421,31 @@ coopy_CompareTable.prototype = { this.indexes.push(index); } var fixed = []; - var j4 = pending.keys(); - while(j4.hasNext()) { - var j5 = j4.next(); - var cross1 = index.queryLocal(j5); - var spot_a1 = cross1.spot_a; - var spot_b1 = cross1.spot_b; - if(spot_a1 != 1 || spot_b1 != 1) { + var j = pending.keys(); + while(j.hasNext()) { + var j1 = j.next(); + var cross = index.queryLocal(j1); + var spot_a = cross.spot_a; + var spot_b = cross.spot_b; + if(spot_a != 1 || spot_b != 1) { continue; } - var val = cross1.item_b.lst[0]; - if(!used.h.hasOwnProperty(val)) { - fixed.push(j5); - align.link(j5,val); - used.h[val] = 1; - if(!used_reverse.h.hasOwnProperty(j5)) { + var val = cross.item_b.lst[0]; + if(!used_h.hasOwnProperty(val)) { + fixed.push(j1); + align.link(j1,val); + used_h[val] = 1; + if(!used_reverse_h.hasOwnProperty(j1)) { --reverse_pending_ct; } - used_reverse.h[j5] = 1; + used_reverse_h[j1] = 1; } } - var _g34 = 0; - var _g24 = fixed.length; - while(_g34 < _g24) { - var j6 = _g34++; - pending.remove(fixed[j6]); + var _g4 = 0; + var _g5 = fixed.length; + while(_g4 < _g5) { + var j2 = _g4++; + pending.remove(fixed[j2]); --pending_ct; } } @@ -1364,18 +1453,18 @@ coopy_CompareTable.prototype = { if(index_top != null) { var offset = 0; var scale = 1; - var _g9 = 0; - while(_g9 < 2) { - var sgn = _g9++; + var _g = 0; + while(_g < 2) { + var sgn = _g++; if(pending_ct > 0) { var xb = null; if(scale == -1 && hb > 0) { xb = hb - 1; } - var _g25 = 0; - var _g16 = ha; - while(_g25 < _g16) { - var xa0 = _g25++; + var _g1 = 0; + var _g2 = ha; + while(_g1 < _g2) { + var xa0 = _g1++; var xa = xa0 * scale + offset; var xb2 = align.a2b(xa); if(xb2 != null) { @@ -1393,12 +1482,12 @@ coopy_CompareTable.prototype = { if(ka != kb) { continue; } - if(used.h.hasOwnProperty(xb)) { + if(used_h.hasOwnProperty(xb)) { continue; } align.link(xa,xb); - used.h[xb] = 1; - used_reverse.h[xa] = 1; + used_h[xb] = 1; + used_reverse_h[xa] = 1; --pending_ct; xb += scale; if(xb >= hb || xb < 0) { @@ -1414,44 +1503,44 @@ coopy_CompareTable.prototype = { } offset = 0; scale = 1; - var _g10 = 0; - while(_g10 < 2) { - var sgn1 = _g10++; + var _g = 0; + while(_g < 2) { + var sgn = _g++; if(reverse_pending_ct > 0) { - var xa1 = null; + var xa = null; if(scale == -1 && ha > 0) { - xa1 = ha - 1; - } - var _g26 = 0; - var _g17 = hb; - while(_g26 < _g17) { - var xb0 = _g26++; - var xb1 = xb0 * scale + offset; - var xa2 = align.b2a(xb1); + xa = ha - 1; + } + var _g1 = 0; + var _g2 = hb; + while(_g1 < _g2) { + var xb0 = _g1++; + var xb = xb0 * scale + offset; + var xa2 = align.b2a(xb); if(xa2 != null) { - xa1 = xa2 + scale; - if(xa1 >= ha || xa1 < 0) { + xa = xa2 + scale; + if(xa >= ha || xa < 0) { break; } continue; } - if(xa1 == null) { + if(xa == null) { continue; } - var ka1 = index_top.localKey(xa1); - var kb1 = index_top.remoteKey(xb1); - if(ka1 != kb1) { + var ka = index_top.localKey(xa); + var kb = index_top.remoteKey(xb); + if(ka != kb) { continue; } - if(used_reverse.h.hasOwnProperty(xa1)) { + if(used_reverse_h.hasOwnProperty(xa)) { continue; } - align.link(xa1,xb1); - used.h[xb1] = 1; - used_reverse.h[xa1] = 1; + align.link(xa,xb); + used_h[xb] = 1; + used_reverse_h[xa] = 1; --reverse_pending_ct; - xa1 += scale; - if(xa1 >= ha || xa1 < 0) { + xa += scale; + if(xa >= ha || xa < 0) { break; } if(reverse_pending_ct == 0) { @@ -1463,20 +1552,20 @@ coopy_CompareTable.prototype = { scale = -1; } } - var _g18 = 1; - var _g19 = ha; - while(_g18 < _g19) { - var i2 = _g18++; - if(!used_reverse.h.hasOwnProperty(i2)) { - align.link(i2,-1); + var _g = 1; + var _g1 = ha; + while(_g < _g1) { + var i = _g++; + if(!used_reverse_h.hasOwnProperty(i)) { + align.link(i,-1); } } - var _g110 = 1; - var _g20 = hb; - while(_g110 < _g20) { - var i3 = _g110++; - if(!used.h.hasOwnProperty(i3)) { - align.link(-1,i3); + var _g = 1; + var _g1 = hb; + while(_g < _g1) { + var i = _g++; + if(!used_h.hasOwnProperty(i)) { + align.link(-1,i); } } if(ha > 0 && hb > 0) { @@ -1500,37 +1589,29 @@ coopy_CompareTable.prototype = { var rb_header = 0; var ra_uniques = 0; var rb_uniques = 0; - var _g1 = 0; - var _g = slop; - while(_g1 < _g) { - var ra = _g1++; - var _g3 = 0; - var _g2 = slop; - while(_g3 < _g2) { - var rb = _g3++; + var _g = 0; + var _g1 = slop; + while(_g < _g1) { + var ra = _g++; + var _g2 = 0; + var _g3 = slop; + while(_g2 < _g3) { + var rb = _g2++; var ma = new haxe_ds_StringMap(); var mb = new haxe_ds_StringMap(); var ct = 0; var uniques = 0; if(ra < a.get_height()) { - var _g5 = 0; - var _g4 = a.get_width(); - while(_g5 < _g4) { - var ca = _g5++; + var _g4 = 0; + var _g5 = a.get_width(); + while(_g4 < _g5) { + var ca = _g4++; var key = va.toString(a.getCell(ca,ra)); - if(__map_reserved[key] != null ? ma.existsReserved(key) : ma.h.hasOwnProperty(key)) { - if(__map_reserved[key] != null) { - ma.setReserved(key,-1); - } else { - ma.h[key] = -1; - } + if(Object.prototype.hasOwnProperty.call(ma.h,key)) { + ma.h[key] = -1; --uniques; } else { - if(__map_reserved[key] != null) { - ma.setReserved(key,ca); - } else { - ma.h[key] = ca; - } + ma.h[key] = ca; ++uniques; } } @@ -1541,24 +1622,16 @@ coopy_CompareTable.prototype = { } uniques = 0; if(rb < b.get_height()) { - var _g51 = 0; - var _g41 = b.get_width(); - while(_g51 < _g41) { - var cb = _g51++; + var _g6 = 0; + var _g7 = b.get_width(); + while(_g6 < _g7) { + var cb = _g6++; var key1 = vb.toString(b.getCell(cb,rb)); - if(__map_reserved[key1] != null ? mb.existsReserved(key1) : mb.h.hasOwnProperty(key1)) { - if(__map_reserved[key1] != null) { - mb.setReserved(key1,-1); - } else { - mb.h[key1] = -1; - } + if(Object.prototype.hasOwnProperty.call(mb.h,key1)) { + mb.h[key1] = -1; --uniques; } else { - if(__map_reserved[key1] != null) { - mb.setReserved(key1,cb); - } else { - mb.h[key1] = cb; - } + mb.h[key1] = cb; ++uniques; } } @@ -1567,11 +1640,11 @@ coopy_CompareTable.prototype = { rb_uniques = uniques; } } - var key2 = ma.keys(); + var key2 = haxe_ds_StringMap.keysIterator(ma.h); while(key2.hasNext()) { var key3 = key2.next(); - var i0 = __map_reserved[key3] != null ? ma.getReserved(key3) : ma.h[key3]; - var i1 = __map_reserved[key3] != null ? mb.getReserved(key3) : mb.h[key3]; + var i0 = ma.h[key3]; + var i1 = mb.h[key3]; if(i1 != null) { if(i1 >= 0 && i0 >= 0) { ++ct; @@ -1595,26 +1668,26 @@ coopy_CompareTable.prototype = { } return; } - var key4 = ma_best.keys(); - while(key4.hasNext()) { - var key5 = key4.next(); - var i01 = __map_reserved[key5] != null ? ma_best.getReserved(key5) : ma_best.h[key5]; - var i11 = __map_reserved[key5] != null ? mb_best.getReserved(key5) : mb_best.h[key5]; - if(i01 != null && i11 != null) { - align.link(i01,i11); - } else if(i01 != null) { - align.link(i01,-1); - } else if(i11 != null) { - align.link(-1,i11); + var key = haxe_ds_StringMap.keysIterator(ma_best.h); + while(key.hasNext()) { + var key1 = key.next(); + var i0 = ma_best.h[key1]; + var i1 = mb_best.h[key1]; + if(i0 != null && i1 != null) { + align.link(i0,i1); + } else if(i0 != null) { + align.link(i0,-1); + } else if(i1 != null) { + align.link(-1,i1); } } - var key6 = mb_best.keys(); - while(key6.hasNext()) { - var key7 = key6.next(); - var i02 = __map_reserved[key7] != null ? ma_best.getReserved(key7) : ma_best.h[key7]; - var i12 = __map_reserved[key7] != null ? mb_best.getReserved(key7) : mb_best.h[key7]; - if(i02 == null && i12 != null) { - align.link(-1,i12); + var key = haxe_ds_StringMap.keysIterator(mb_best.h); + while(key.hasNext()) { + var key1 = key.next(); + var i0 = ma_best.h[key1]; + var i1 = mb_best.h[key1]; + if(i0 == null && i1 != null) { + align.link(-1,i1); } } align.headers(ra_header,rb_header); @@ -1639,14 +1712,14 @@ coopy_CompareTable.prototype = { return true; } var av = a.getCellView(); - var _g1 = 0; - var _g = a.get_width(); - while(_g1 < _g) { - var i = _g1++; - var _g3 = i + 1; - var _g2 = a.get_width(); - while(_g3 < _g2) { - var j = _g3++; + var _g = 0; + var _g1 = a.get_width(); + while(_g < _g1) { + var i = _g++; + var _g2 = i + 1; + var _g3 = a.get_width(); + while(_g2 < _g3) { + var j = _g2++; if(av.equals(a.getCell(i,0),a.getCell(j,0))) { return false; } @@ -1696,14 +1769,14 @@ coopy_CompareTable.prototype = { return false; } var av = a.getCellView(); - var _g1 = 0; - var _g = a.get_height(); - while(_g1 < _g) { - var i = _g1++; - var _g3 = 0; - var _g2 = a.get_width(); - while(_g3 < _g2) { - var j = _g3++; + var _g = 0; + var _g1 = a.get_height(); + while(_g < _g1) { + var i = _g++; + var _g2 = 0; + var _g3 = a.get_width(); + while(_g2 < _g3) { + var j = _g2++; if(!av.equals(a.getCell(j,i),b.getCell(j,i))) { return false; } @@ -1773,7 +1846,12 @@ var coopy_ConflictInfo = function(row,col,pvalue,lvalue,rvalue) { }; coopy_ConflictInfo.__name__ = true; coopy_ConflictInfo.prototype = { - __class__: coopy_ConflictInfo + row: null + ,col: null + ,pvalue: null + ,lvalue: null + ,rvalue: null + ,__class__: coopy_ConflictInfo }; var coopy_Coopy = $hx_exports["coopy"]["Coopy"] = function(io) { this.init(); @@ -1880,7 +1958,7 @@ coopy_Coopy.keepAround = function() { var hp = new coopy_HighlightPatch(null,null); var csv = new coopy_Csv(); var tm = new coopy_TableModifier(null); - var sc = new coopy_SqlCompare(null,null,null,null); + var sc = new coopy_SqlCompare(null,null,null,null,null); var sq = new coopy_SqliteHelper(); var sm = new coopy_SimpleMeta(null); var ct = new coopy_CombinedTable(null); @@ -1890,26 +1968,25 @@ coopy_Coopy.cellFor = function(x) { return x; }; coopy_Coopy.main = function() { - return 0; }; coopy_Coopy.show = function(t) { var w = t.get_width(); var h = t.get_height(); var txt = ""; - var _g1 = 0; - var _g = h; - while(_g1 < _g) { - var y = _g1++; - var _g3 = 0; - var _g2 = w; - while(_g3 < _g2) { - var x = _g3++; + var _g = 0; + var _g1 = h; + while(_g < _g1) { + var y = _g++; + var _g2 = 0; + var _g3 = w; + while(_g2 < _g3) { + var x = _g2++; txt += Std.string(t.getCell(x,y)); txt += " "; } txt += "\n"; } - console.log(txt); + console.log("coopy/Coopy.hx:1191:",txt); }; coopy_Coopy.jsonify = function(t) { var workbook = new haxe_ds_StringMap(); @@ -1917,25 +1994,21 @@ coopy_Coopy.jsonify = function(t) { var w = t.get_width(); var h = t.get_height(); var txt = ""; - var _g1 = 0; - var _g = h; - while(_g1 < _g) { - var y = _g1++; + var _g = 0; + var _g1 = h; + while(_g < _g1) { + var y = _g++; var row = []; - var _g3 = 0; - var _g2 = w; - while(_g3 < _g2) { - var x = _g3++; + var _g2 = 0; + var _g3 = w; + while(_g2 < _g3) { + var x = _g2++; var v = t.getCell(x,y); row.push(v); } sheet.push(row); } - if(__map_reserved["sheet"] != null) { - workbook.setReserved("sheet",sheet); - } else { - workbook.h["sheet"] = sheet; - } + workbook.h["sheet"] = sheet; return workbook; }; coopy_Coopy.tablify = function(data) { @@ -1946,10 +2019,28 @@ coopy_Coopy.tablify = function(data) { if(get_cell_view != null) { return data; } - return new (typeof exports != 'undefined' ? exports : window).daff.TableView(data); + return new daff.TableView(data); }; coopy_Coopy.prototype = { - init: function() { + format_preference: null + ,delim_preference: null + ,csv_eol_preference: null + ,extern_preference: null + ,output_format: null + ,output_format_set: null + ,nested_output: null + ,order_set: null + ,order_preference: null + ,io: null + ,strategy: null + ,css_output: null + ,fragment: null + ,flags: null + ,cache_txt: null + ,fail_if_diff: null + ,diffs_found: null + ,mv: null + ,init: function() { this.extern_preference = false; this.format_preference = null; this.delim_preference = null; @@ -1964,6 +2055,8 @@ coopy_Coopy.prototype = { this.fragment = false; this.flags = null; this.cache_txt = null; + this.fail_if_diff = false; + this.diffs_found = false; } ,checkFormat: function(name) { if(this.extern_preference) { @@ -2027,6 +2120,7 @@ coopy_Coopy.prototype = { ,getRenderer: function() { var renderer = new coopy_DiffRender(); renderer.usePrettyArrows(this.flags.use_glyphs); + renderer.quoteHtml(this.flags.quote_html); return renderer; } ,applyRenderer: function(name,renderer) { @@ -2112,10 +2206,10 @@ coopy_Coopy.prototype = { need_blank = true; } if(order.length > 1) { - var _g1 = 1; - var _g = order.length; - while(_g1 < _g) { - var i = _g1++; + var _g = 1; + var _g1 = order.length; + while(_g < _g1) { + var i = _g++; var t = os.get(order[i]); if(t != null) { if(need_blank) { @@ -2124,10 +2218,10 @@ coopy_Coopy.prototype = { need_blank = true; txt += order[i] + "\n"; var line = ""; - var _g3 = 0; - var _g2 = order[i].length; - while(_g3 < _g2) { - var i1 = _g3++; + var _g2 = 0; + var _g3 = order[i].length; + while(_g2 < _g3) { + var i1 = _g2++; line += "="; } txt += line + "\n"; @@ -2173,10 +2267,10 @@ coopy_Coopy.prototype = { output = new coopy_SimpleTable(columns.length,rows.length); var has_hash = false; var has_hash_known = false; - var _g3 = 0; - var _g2 = rows.length; - while(_g3 < _g2) { - var i = _g3++; + var _g2 = 0; + var _g3 = rows.length; + while(_g2 < _g3) { + var i = _g2++; var row = rows[i]; if(!has_hash_known) { if(Reflect.fields(row).length == columns.length) { @@ -2186,18 +2280,18 @@ coopy_Coopy.prototype = { } if(!has_hash) { var lst = row; - var _g5 = 0; - var _g4 = columns.length; - while(_g5 < _g4) { - var j = _g5++; + var _g4 = 0; + var _g5 = columns.length; + while(_g4 < _g5) { + var j = _g4++; var val = lst[j]; output.setCell(j,i,coopy_Coopy.cellFor(val)); } } else { - var _g51 = 0; - var _g41 = columns.length; - while(_g51 < _g41) { - var j1 = _g51++; + var _g6 = 0; + var _g7 = columns.length; + while(_g6 < _g7) { + var j1 = _g6++; var val1 = Reflect.field(row,columns[j1]); output.setCell(j1,i,coopy_Coopy.cellFor(val1)); } @@ -2231,8 +2325,14 @@ coopy_Coopy.prototype = { td.hiliteWithNesting(os); var use_color = this.useColor(flags,output); this.saveTables(output,os,use_color,true); + if(this.fail_if_diff) { + var summary = td.getSummary(); + if(summary.different) { + this.diffs_found = true; + } + } } - ,loadTable: function(name) { + ,loadTable: function(name,role) { var ext = this.checkFormat(name); if(ext == "sqlite") { var sql = this.io.openSqliteDatabase(name); @@ -2240,7 +2340,7 @@ coopy_Coopy.prototype = { this.io.writeStderr("! Cannot open database, aborting\n"); return null; } - var tab = new coopy_SqlTables(sql,this.flags); + var tab = new coopy_SqlTables(sql,this.flags,role); return tab; } var txt = this.io.getContent(name); @@ -2252,17 +2352,17 @@ coopy_Coopy.prototype = { } if(ext == "json" || ext == "") { try { - var json = new haxe_format_JsonParser(txt).parseRec(); + var json = new haxe_format_JsonParser(txt).doParse(); this.format_preference = "json"; - var t1 = this.jsonToTables(json); - if(t1 == null) { - throw new js__$Boot_HaxeError("JSON failed"); + var t = this.jsonToTables(json); + if(t == null) { + throw haxe_Exception.thrown("JSON failed"); } - return t1; - } catch( e ) { - if (e instanceof js__$Boot_HaxeError) e = e.val; + return t; + } catch( _g ) { + var e = haxe_Exception.caught(_g).unwrap(); if(ext == "json") { - throw js__$Boot_HaxeError.wrap(e); + throw haxe_Exception.thrown(e); } } } @@ -2278,9 +2378,11 @@ coopy_Coopy.prototype = { } return output; } + ,status: null + ,daff_cmd: null ,command: function(io,cmd,args) { var r = 0; - if(io.async()) { + if(io.hasAsync()) { r = io.command(cmd,args); } if(r != 999) { @@ -2301,7 +2403,7 @@ coopy_Coopy.prototype = { } io.writeStdout("\n"); } - if(!io.async()) { + if(!io.hasAsync()) { r = io.command(cmd,args); } return r; @@ -2313,8 +2415,7 @@ coopy_Coopy.prototype = { this.daff_cmd = ""; } var key = "hello"; - var _this = this.status; - if(!(__map_reserved[key] != null ? _this.existsReserved(key) : _this.h.hasOwnProperty(key))) { + if(!Object.prototype.hasOwnProperty.call(this.status.h,key)) { io.writeStdout("Setting up git to use daff on"); var _g = 0; while(_g < formats.length) { @@ -2323,26 +2424,15 @@ coopy_Coopy.prototype = { io.writeStdout(" *." + format); } io.writeStdout(" files\n"); - var _this1 = this.status; - if(__map_reserved[key] != null) { - _this1.setReserved(key,r); - } else { - _this1.h[key] = r; - } + this.status.h[key] = r; } key = "can_run_git"; - var _this2 = this.status; - if(!(__map_reserved[key] != null ? _this2.existsReserved(key) : _this2.h.hasOwnProperty(key))) { + if(!Object.prototype.hasOwnProperty.call(this.status.h,key)) { r = this.command(io,"git",["--version"]); if(r == 999) { return r; } - var _this3 = this.status; - if(__map_reserved[key] != null) { - _this3.setReserved(key,r); - } else { - _this3.h[key] = r; - } + this.status.h[key] = r; if(r != 0) { io.writeStderr("! Cannot run git, aborting\n"); return 1; @@ -2351,23 +2441,17 @@ coopy_Coopy.prototype = { } var daffs = ["daff","daff.rb","daff.py"]; if(this.daff_cmd == "") { - var _g1 = 0; - while(_g1 < daffs.length) { - var daff = daffs[_g1]; - ++_g1; + var _g = 0; + while(_g < daffs.length) { + var daff = daffs[_g]; + ++_g; var key1 = "can_run_" + daff; - var _this4 = this.status; - if(!(__map_reserved[key1] != null ? _this4.existsReserved(key1) : _this4.h.hasOwnProperty(key1))) { + if(!Object.prototype.hasOwnProperty.call(this.status.h,key1)) { r = this.command(io,daff,["version"]); if(r == 999) { return r; } - var _this5 = this.status; - if(__map_reserved[key1] != null) { - _this5.setReserved(key1,r); - } else { - _this5.h[key1] = r; - } + this.status.h[key1] = r; if(r == 0) { this.daff_cmd = daff; io.writeStdout("- Can run " + daff + " as \"" + daff + "\"\n"); @@ -2380,95 +2464,63 @@ coopy_Coopy.prototype = { return 1; } } - var _g2 = 0; - while(_g2 < formats.length) { - var format1 = formats[_g2]; - ++_g2; - key = "have_diff_driver_" + format1; - var _this6 = this.status; - if(!(__map_reserved[key] != null ? _this6.existsReserved(key) : _this6.h.hasOwnProperty(key))) { - r = this.command(io,"git",["config","--global","--get","diff.daff-" + format1 + ".command"]); + var _g = 0; + while(_g < formats.length) { + var format = formats[_g]; + ++_g; + key = "have_diff_driver_" + format; + if(!Object.prototype.hasOwnProperty.call(this.status.h,key)) { + r = this.command(io,"git",["config","--global","--get","diff.daff-" + format + ".command"]); if(r == 999) { return r; } - var _this7 = this.status; - if(__map_reserved[key] != null) { - _this7.setReserved(key,r); - } else { - _this7.h[key] = r; - } + this.status.h[key] = r; } - var _this8 = this.status; - var have_diff_driver = (__map_reserved[key] != null ? _this8.getReserved(key) : _this8.h[key]) == 0; - key = "add_diff_driver_" + format1; - var _this9 = this.status; - if(!(__map_reserved[key] != null ? _this9.existsReserved(key) : _this9.h.hasOwnProperty(key))) { - r = this.command(io,"git",["config","--global","diff.daff-" + format1 + ".command",this.daff_cmd + " diff --git"]); + var have_diff_driver = this.status.h[key] == 0; + key = "add_diff_driver_" + format; + if(!Object.prototype.hasOwnProperty.call(this.status.h,key)) { + r = this.command(io,"git",["config","--global","diff.daff-" + format + ".command",this.daff_cmd + " diff --git"]); if(r == 999) { return r; } if(have_diff_driver) { - io.writeStdout("- Cleared existing daff diff driver for " + format1 + "\n"); - } - io.writeStdout("- Added diff driver for " + format1 + "\n"); - var _this10 = this.status; - if(__map_reserved[key] != null) { - _this10.setReserved(key,r); - } else { - _this10.h[key] = r; + io.writeStdout("- Cleared existing daff diff driver for " + format + "\n"); } + io.writeStdout("- Added diff driver for " + format + "\n"); + this.status.h[key] = r; } - key = "have_merge_driver_" + format1; - var _this11 = this.status; - if(!(__map_reserved[key] != null ? _this11.existsReserved(key) : _this11.h.hasOwnProperty(key))) { - r = this.command(io,"git",["config","--global","--get","merge.daff-" + format1 + ".driver"]); + key = "have_merge_driver_" + format; + if(!Object.prototype.hasOwnProperty.call(this.status.h,key)) { + r = this.command(io,"git",["config","--global","--get","merge.daff-" + format + ".driver"]); if(r == 999) { return r; } - var _this12 = this.status; - if(__map_reserved[key] != null) { - _this12.setReserved(key,r); - } else { - _this12.h[key] = r; - } + this.status.h[key] = r; } - var _this13 = this.status; - var have_merge_driver = (__map_reserved[key] != null ? _this13.getReserved(key) : _this13.h[key]) == 0; - key = "name_merge_driver_" + format1; - var _this14 = this.status; - if(!(__map_reserved[key] != null ? _this14.existsReserved(key) : _this14.h.hasOwnProperty(key))) { + var have_merge_driver = this.status.h[key] == 0; + key = "name_merge_driver_" + format; + if(!Object.prototype.hasOwnProperty.call(this.status.h,key)) { if(!have_merge_driver) { - r = this.command(io,"git",["config","--global","merge.daff-" + format1 + ".name","daff tabular " + format1 + " merge"]); + r = this.command(io,"git",["config","--global","merge.daff-" + format + ".name","daff tabular " + format + " merge"]); if(r == 999) { return r; } } else { r = 0; } - var _this15 = this.status; - if(__map_reserved[key] != null) { - _this15.setReserved(key,r); - } else { - _this15.h[key] = r; - } + this.status.h[key] = r; } - key = "add_merge_driver_" + format1; - var _this16 = this.status; - if(!(__map_reserved[key] != null ? _this16.existsReserved(key) : _this16.h.hasOwnProperty(key))) { - r = this.command(io,"git",["config","--global","merge.daff-" + format1 + ".driver",this.daff_cmd + " merge --output %A %O %A %B"]); + key = "add_merge_driver_" + format; + if(!Object.prototype.hasOwnProperty.call(this.status.h,key)) { + r = this.command(io,"git",["config","--global","merge.daff-" + format + ".driver",this.daff_cmd + " merge --output %A %O %A %B"]); if(r == 999) { return r; } if(have_merge_driver) { - io.writeStdout("- Cleared existing daff merge driver for " + format1 + "\n"); - } - io.writeStdout("- Added merge driver for " + format1 + "\n"); - var _this17 = this.status; - if(__map_reserved[key] != null) { - _this17.setReserved(key,r); - } else { - _this17.h[key] = r; + io.writeStdout("- Cleared existing daff merge driver for " + format + "\n"); } + io.writeStdout("- Added merge driver for " + format + "\n"); + this.status.h[key] = r; } } if(!io.exists(".git/config")) { @@ -2486,15 +2538,15 @@ coopy_Coopy.prototype = { txt = io.getContent(attr); } var need_update = false; - var _g3 = 0; - while(_g3 < formats.length) { - var format2 = formats[_g3]; - ++_g3; - if(txt.indexOf("*." + format2) >= 0) { - io.writeStderr("- Your .gitattributes file already mentions *." + format2 + "\n"); + var _g = 0; + while(_g < formats.length) { + var format = formats[_g]; + ++_g; + if(txt.indexOf("*." + format) >= 0) { + io.writeStderr("- Your .gitattributes file already mentions *." + format + "\n"); } else { - post += "*." + format2 + " diff=daff-" + format2 + "\n"; - post += "*." + format2 + " merge=daff-" + format2 + "\n"; + post += "*." + format + " diff=daff-" + format + "\n"; + post += "*." + format + " merge=daff-" + format + "\n"; io.writeStdout("- Placing the following lines in .gitattributes:\n"); io.writeStdout(post); if(txt != "" && !need_update) { @@ -2512,7 +2564,7 @@ coopy_Coopy.prototype = { } ,run: function(args,io) { if(io == null) { - console.log("No system interface available"); + console.log("coopy/Coopy.hx:725:","No system interface available"); return 1; } this.init(); @@ -2521,14 +2573,15 @@ coopy_Coopy.prototype = { var output = null; var inplace = false; var git = false; + var help = false; this.flags = new coopy_CompareFlags(); this.flags.always_show_header = true; while(more) { more = false; - var _g1 = 0; - var _g = args.length; - while(_g1 < _g) { - var i = _g1++; + var _g = 0; + var _g1 = args.length; + while(_g < _g1) { + var i = _g++; var tag = args[i]; if(tag == "--output") { more = true; @@ -2551,6 +2604,11 @@ coopy_Coopy.prototype = { this.flags.use_glyphs = false; args.splice(i,1); break; + } else if(tag == "--unquote") { + more = true; + this.flags.quote_html = false; + args.splice(i,1); + break; } else if(tag == "--all") { more = true; this.flags.show_unchanged = true; @@ -2572,13 +2630,7 @@ coopy_Coopy.prototype = { if(this.flags.acts == null) { this.flags.acts = new haxe_ds_StringMap(); } - var _this = this.flags.acts; - var key = args[i + 1]; - if(__map_reserved[key] != null) { - _this.setReserved(key,true); - } else { - _this.h[key] = true; - } + this.flags.acts.h[args[i + 1]] = true; args.splice(i,2); break; } else if(tag == "--context") { @@ -2589,6 +2641,14 @@ coopy_Coopy.prototype = { } args.splice(i,2); break; + } else if(tag == "--context-columns") { + more = true; + var context1 = Std.parseInt(args[i + 1]); + if(context1 >= 0) { + this.flags.unchanged_column_context = context1; + } + args.splice(i,2); + break; } else if(tag == "--inplace") { more = true; inplace = true; @@ -2672,6 +2732,17 @@ coopy_Coopy.prototype = { this.flags.ignore_case = true; args.splice(i,1); break; + } else if(tag == "-d" || tag == "--ignore-epsilon") { + more = true; + var eps = args[i + 1]; + this.flags.ignore_epsilon = parseFloat(eps); + var f = this.flags.ignore_epsilon; + if(isNaN(f)) { + io.writeStderr("Epsilon for numeric comparison must be numeric\n"); + return 1; + } + args.splice(i,2); + break; } else if(tag == "--padding") { more = true; this.flags.padding_strategy = args[i + 1]; @@ -2695,189 +2766,229 @@ coopy_Coopy.prototype = { this.csv_eol_preference = ending; args.splice(i,2); break; + } else if(tag == "--fail-if-diff") { + more = true; + this.fail_if_diff = true; + args.splice(i,1); + break; + } else if(tag == "help" || tag == "-h" || tag == "--help") { + more = true; + args.splice(i,1); + help = true; + break; } } } var cmd = args[0]; - if(args.length < 2) { - if(cmd == "version") { - io.writeStdout(coopy_Coopy.VERSION + "\n"); - return 0; + var ok = true; + if(help) { + cmd = ""; + args = []; + } + try { + if(args.length < 2) { + if(cmd == "version") { + io.writeStdout(coopy_Coopy.VERSION + "\n"); + return 0; + } + if(cmd == "git") { + io.writeStdout("You can use daff to improve git's handling of csv files, by using it as a\ndiff driver (for showing what has changed) and as a merge driver (for merging\nchanges between multiple versions).\n"); + io.writeStdout("\n"); + io.writeStdout("Automatic setup\n"); + io.writeStdout("---------------\n\n"); + io.writeStdout("Run:\n"); + io.writeStdout(" daff git csv\n"); + io.writeStdout("\n"); + io.writeStdout("Manual setup\n"); + io.writeStdout("------------\n\n"); + io.writeStdout("Create and add a file called .gitattributes in the root directory of your\nrepository, containing:\n\n"); + io.writeStdout(" *.csv diff=daff-csv\n"); + io.writeStdout(" *.csv merge=daff-csv\n"); + io.writeStdout("\nCreate a file called .gitconfig in your home directory (or alternatively\nopen .git/config for a particular repository) and add:\n\n"); + io.writeStdout(" [diff \"daff-csv\"]\n"); + io.writeStdout(" command = daff diff --git\n"); + io.writeStderr("\n"); + io.writeStdout(" [merge \"daff-csv\"]\n"); + io.writeStdout(" name = daff tabular merge\n"); + io.writeStdout(" driver = daff merge --output %A %O %A %B\n\n"); + io.writeStderr("Make sure you can run daff from the command-line as just \"daff\" - if not,\nreplace \"daff\" in the driver and command lines above with the correct way\nto call it. Add --no-color if your terminal does not support ANSI colors."); + io.writeStderr("\n"); + return 0; + } + if(args.length < 1) { + io.writeStderr("daff can produce and apply tabular diffs.\n"); + io.writeStderr("Call as:\n"); + io.writeStderr(" daff a.csv b.csv\n"); + io.writeStderr(" daff [--color] [--no-color] [--output OUTPUT.csv] a.csv b.csv\n"); + io.writeStderr(" daff [--output OUTPUT.html] a.csv b.csv\n"); + io.writeStderr(" daff [--www] a.csv b.csv\n"); + io.writeStderr(" daff parent.csv a.csv b.csv\n"); + io.writeStderr(" daff --input-format sqlite a.db b.db\n"); + io.writeStderr(" daff patch [--inplace] a.csv patch.csv\n"); + io.writeStderr(" daff merge [--inplace] parent.csv a.csv b.csv\n"); + io.writeStderr(" daff trim [--output OUTPUT.csv] source.csv\n"); + io.writeStderr(" daff render [--output OUTPUT.html] diff.csv\n"); + io.writeStderr(" daff copy in.csv out.tsv\n"); + io.writeStderr(" daff in.csv\n"); + io.writeStderr(" daff git\n"); + io.writeStderr(" daff version\n"); + io.writeStderr("\n"); + io.writeStderr("The --inplace option to patch and merge will result in modification of a.csv.\n"); + io.writeStderr("\n"); + io.writeStderr("If you need more control, here is the full list of flags:\n"); + io.writeStderr(" daff diff [--output OUTPUT.csv] [--context NUM] [--all] [--act ACT] a.csv b.csv\n"); + io.writeStderr(" --act ACT: show only a certain kind of change (update, insert, delete, column)\n"); + io.writeStderr(" --all: do not prune unchanged rows or columns\n"); + io.writeStderr(" --all-rows: do not prune unchanged rows\n"); + io.writeStderr(" --all-columns: do not prune unchanged columns\n"); + io.writeStderr(" --color: highlight changes with terminal colors (default in terminals)\n"); + io.writeStderr(" --context NUM: show NUM rows of context (0=none)\n"); + io.writeStderr(" --context-columns NUM: show NUM columns of context (0=none)\n"); + io.writeStderr(" --fail-if-diff: return status is 0 if equal, 1 if different, 2 if problem\n"); + io.writeStderr(" --id: specify column name to use as primary key (repeat for multi-column key)\n"); + io.writeStderr(" --ignore: specify column name to ignore completely (can repeat)\n"); + io.writeStderr(" --index: include row/columns numbers from original tables\n"); + io.writeStderr(" --input-format [csv|tsv|ssv|psv|json|sqlite]: set format to expect for input\n"); + io.writeStderr(" --eol [crlf|lf|cr|auto]: separator between rows of csv output.\n"); + io.writeStderr(" --no-color: make sure terminal colors are not used\n"); + io.writeStderr(" --ordered: assume row order is meaningful (default for CSV)\n"); + io.writeStderr(" --output-format [csv|tsv|ssv|psv|json|copy|html]: set format for output\n"); + io.writeStderr(" --padding [dense|sparse|smart]: set padding method for aligning columns\n"); + io.writeStderr(" --table NAME: compare the named table, used with SQL sources. If name changes, use 'n1:n2'\n"); + io.writeStderr(" --unordered: assume row order is meaningless (default for json formats)\n"); + io.writeStderr(" -w / --ignore-whitespace: ignore changes in leading/trailing whitespace\n"); + io.writeStderr(" -i / --ignore-case: ignore differences in case\n"); + io.writeStderr(" -d EPS / --ignore-epsilon EPS: ignore small floating point differences\n"); + io.writeStderr("\n"); + io.writeStderr(" daff render [--output OUTPUT.html] [--css CSS.css] [--fragment] [--plain] diff.csv\n"); + io.writeStderr(" --css CSS.css: generate a suitable css file to go with the html\n"); + io.writeStderr(" --fragment: generate just a html fragment rather than a page\n"); + io.writeStderr(" --plain: do not use fancy utf8 characters to make arrows prettier\n"); + io.writeStderr(" --unquote: do not quote html characters in html diffs\n"); + io.writeStderr(" --www: send output to a browser\n"); + return 1; + } } - if(cmd == "git") { - io.writeStdout("You can use daff to improve git's handling of csv files, by using it as a\ndiff driver (for showing what has changed) and as a merge driver (for merging\nchanges between multiple versions).\n"); - io.writeStdout("\n"); - io.writeStdout("Automatic setup\n"); - io.writeStdout("---------------\n\n"); - io.writeStdout("Run:\n"); - io.writeStdout(" daff git csv\n"); - io.writeStdout("\n"); - io.writeStdout("Manual setup\n"); - io.writeStdout("------------\n\n"); - io.writeStdout("Create and add a file called .gitattributes in the root directory of your\nrepository, containing:\n\n"); - io.writeStdout(" *.csv diff=daff-csv\n"); - io.writeStdout(" *.csv merge=daff-csv\n"); - io.writeStdout("\nCreate a file called .gitconfig in your home directory (or alternatively\nopen .git/config for a particular repository) and add:\n\n"); - io.writeStdout(" [diff \"daff-csv\"]\n"); - io.writeStdout(" command = daff diff --git\n"); - io.writeStderr("\n"); - io.writeStdout(" [merge \"daff-csv\"]\n"); - io.writeStdout(" name = daff tabular merge\n"); - io.writeStdout(" driver = daff merge --output %A %O %A %B\n\n"); - io.writeStderr("Make sure you can run daff from the command-line as just \"daff\" - if not,\nreplace \"daff\" in the driver and command lines above with the correct way\nto call it. Add --no-color if your terminal does not support ANSI colors."); - io.writeStderr("\n"); - return 0; + var cmd = args[0]; + var offset = 1; + if(!Lambda.has(["diff","patch","merge","trim","render","git","version","copy"],cmd)) { + if(cmd.indexOf("--") == 0) { + cmd = "diff"; + offset = 0; + } else if(cmd.indexOf(".") != -1) { + if(args.length == 2) { + cmd = "diff"; + offset = 0; + } else if(args.length == 1) { + cmd = "copy"; + offset = 0; + } + } } - if(args.length < 1) { - io.writeStderr("daff can produce and apply tabular diffs.\n"); - io.writeStderr("Call as:\n"); - io.writeStderr(" daff [--color] [--no-color] [--output OUTPUT.csv] a.csv b.csv\n"); - io.writeStderr(" daff [--output OUTPUT.html] a.csv b.csv\n"); - io.writeStderr(" daff [--output OUTPUT.csv] parent.csv a.csv b.csv\n"); - io.writeStderr(" daff [--output OUTPUT.ndjson] a.ndjson b.ndjson\n"); - io.writeStderr(" daff [--www] a.csv b.csv\n"); - io.writeStderr(" daff patch [--inplace] [--output OUTPUT.csv] a.csv patch.csv\n"); - io.writeStderr(" daff merge [--inplace] [--output OUTPUT.csv] parent.csv a.csv b.csv\n"); - io.writeStderr(" daff trim [--output OUTPUT.csv] source.csv\n"); - io.writeStderr(" daff render [--output OUTPUT.html] diff.csv\n"); - io.writeStderr(" daff copy in.csv out.tsv\n"); - io.writeStderr(" daff in.csv\n"); - io.writeStderr(" daff git\n"); - io.writeStderr(" daff version\n"); - io.writeStderr("\n"); - io.writeStderr("The --inplace option to patch and merge will result in modification of a.csv.\n"); - io.writeStderr("\n"); - io.writeStderr("If you need more control, here is the full list of flags:\n"); - io.writeStderr(" daff diff [--output OUTPUT.csv] [--context NUM] [--all] [--act ACT] a.csv b.csv\n"); - io.writeStderr(" --act ACT: show only a certain kind of change (update, insert, delete)\n"); - io.writeStderr(" --all: do not prune unchanged rows or columns\n"); - io.writeStderr(" --all-rows: do not prune unchanged rows\n"); - io.writeStderr(" --all-columns: do not prune unchanged columns\n"); - io.writeStderr(" --color: highlight changes with terminal colors (default in terminals)\n"); - io.writeStderr(" --context NUM: show NUM rows of context\n"); - io.writeStderr(" --id: specify column to use as primary key (repeat for multi-column key)\n"); - io.writeStderr(" --ignore: specify column to ignore completely (can repeat)\n"); - io.writeStderr(" --index: include row/columns numbers from original tables\n"); - io.writeStderr(" --input-format [csv|tsv|ssv|psv|json]: set format to expect for input\n"); - io.writeStderr(" --eol [crlf|lf|cr|auto]: separator between rows of csv output.\n"); - io.writeStderr(" --no-color: make sure terminal colors are not used\n"); - io.writeStderr(" --ordered: assume row order is meaningful (default for CSV)\n"); - io.writeStderr(" --output-format [csv|tsv|ssv|psv|json|copy|html]: set format for output\n"); - io.writeStderr(" --padding [dense|sparse|smart]: set padding method for aligning columns\n"); - io.writeStderr(" --table NAME: compare the named table, used with SQL sources\n"); - io.writeStderr(" --unordered: assume row order is meaningless (default for json formats)\n"); - io.writeStderr(" -w / --ignore-whitespace: ignore changes in leading/trailing whitespace\n"); - io.writeStderr(" -i / --ignore-case: ignore differences in case\n"); - io.writeStderr("\n"); - io.writeStderr(" daff render [--output OUTPUT.html] [--css CSS.css] [--fragment] [--plain] diff.csv\n"); - io.writeStderr(" --css CSS.css: generate a suitable css file to go with the html\n"); - io.writeStderr(" --fragment: generate just a html fragment rather than a page\n"); - io.writeStderr(" --plain: do not use fancy utf8 characters to make arrows prettier\n"); - io.writeStderr(" --www: send output to a browser\n"); - return 1; + if(cmd == "git") { + var types = args.splice(offset,args.length - offset); + return this.installGitDriver(io,types); } - } - var cmd1 = args[0]; - var offset = 1; - if(!Lambda.has(["diff","patch","merge","trim","render","git","version","copy"],cmd1)) { - if(cmd1.indexOf("--") == 0) { - cmd1 = "diff"; + if(git) { + var ct = args.length - offset; + if(ct != 7 && ct != 9) { + io.writeStderr("Expected 7 or 9 parameters from git, but got " + ct + "\n"); + return 1; + } + var git_args = args.splice(offset,ct); + args.splice(0,args.length); offset = 0; - } else if(cmd1.indexOf(".") != -1) { - if(args.length == 2) { - cmd1 = "diff"; - offset = 0; - } else if(args.length == 1) { - cmd1 = "copy"; - offset = 0; + var old_display_path = git_args[0]; + var new_display_path = git_args[0]; + var old_file = git_args[1]; + var new_file = git_args[4]; + if(ct == 9) { + io.writeStdout(git_args[8]); + new_display_path = git_args[7]; + } + io.writeStdout("--- a/" + old_display_path + "\n"); + io.writeStdout("+++ b/" + new_display_path + "\n"); + args.push(old_file); + args.push(new_file); + } + var parent = null; + if(args.length - offset >= 3) { + parent = this.loadTable(args[offset],"parent"); + ++offset; + } + var aname = args[offset]; + var a = this.loadTable(aname,"local"); + var b = null; + if(args.length - offset >= 2) { + if(cmd != "copy") { + b = this.loadTable(args[1 + offset],"remote"); + } else { + output = args[1 + offset]; } } - } - if(cmd1 == "git") { - var types = args.splice(offset,args.length - offset); - return this.installGitDriver(io,types); - } - if(git) { - var ct = args.length - offset; - if(ct != 7 && ct != 9) { - io.writeStderr("Expected 7 or 9 parameters from git, but got " + ct + "\n"); + this.flags.diff_strategy = this.strategy; + if(inplace) { + if(output != null) { + io.writeStderr("Please do not use --inplace when specifying an output.\n"); + } + output = aname; return 1; } - var git_args = args.splice(offset,ct); - args.splice(0,args.length); - offset = 0; - var old_display_path = git_args[0]; - var new_display_path = git_args[0]; - var old_file = git_args[1]; - var new_file = git_args[4]; - if(ct == 9) { - io.writeStdout(git_args[8]); - new_display_path = git_args[7]; - } - io.writeStdout("--- a/" + old_display_path + "\n"); - io.writeStdout("+++ b/" + new_display_path + "\n"); - args.push(old_file); - args.push(new_file); - } - var parent = null; - if(args.length - offset >= 3) { - parent = this.loadTable(args[offset]); - ++offset; - } - var aname = args[offset]; - var a = this.loadTable(aname); - var b = null; - if(args.length - offset >= 2) { - if(cmd1 != "copy") { - b = this.loadTable(args[1 + offset]); - } else { - output = args[1 + offset]; - } - } - this.flags.diff_strategy = this.strategy; - if(inplace) { - if(output != null) { - io.writeStderr("Please do not use --inplace when specifying an output.\n"); + if(output == null) { + output = "-"; } - output = aname; - return 1; - } - if(output == null) { - output = "-"; - } - var ok = true; - if(cmd1 == "diff") { - if(!this.order_set) { - this.flags.ordered = this.order_preference; - if(!this.flags.ordered) { - this.flags.unchanged_context = 0; + if(cmd == "diff") { + if(!this.order_set) { + this.flags.ordered = this.order_preference; + if(!this.flags.ordered) { + this.flags.unchanged_context = 0; + } } - } - this.flags.allow_nested_cells = this.nested_output; - this.runDiff(parent,a,b,this.flags,output); - } else if(cmd1 == "patch") { - var patcher = new coopy_HighlightPatch(a,b); - patcher.apply(); - this.saveTable(output,a); - } else if(cmd1 == "merge") { - var merger = new coopy_Merger(parent,a,b,this.flags); - var conflicts = merger.apply(); - ok = conflicts == 0; - if(conflicts > 0) { - io.writeStderr(conflicts + " conflict" + (conflicts > 1 ? "s" : "") + "\n"); - } - this.saveTable(output,a); - } else if(cmd1 == "trim") { - this.saveTable(output,a); - } else if(cmd1 == "render") { - this.renderTable(output,a); - } else if(cmd1 == "copy") { - var os = new coopy_Tables(a); - os.add("untitled"); - this.saveTables(output,os,this.useColor(this.flags,output),false); + this.flags.allow_nested_cells = this.nested_output; + if(this.fail_if_diff) { + try { + this.runDiff(parent,a,b,this.flags,output); + } catch( _g ) { + return 2; + } + if(this.diffs_found) { + return 1; + } + } else { + this.runDiff(parent,a,b,this.flags,output); + } + } else if(cmd == "patch") { + var patcher = new coopy_HighlightPatch(a,b); + patcher.apply(); + this.saveTable(output,a); + } else if(cmd == "merge") { + var merger = new coopy_Merger(parent,a,b,this.flags); + var conflicts = merger.apply(); + ok = conflicts == 0; + if(conflicts > 0) { + io.writeStderr(conflicts + " conflict" + (conflicts > 1 ? "s" : "") + "\n"); + } + this.saveTable(output,a); + } else if(cmd == "trim") { + this.saveTable(output,a); + } else if(cmd == "render") { + this.renderTable(output,a); + } else if(cmd == "copy") { + var os = new coopy_Tables(a); + os.add("untitled"); + this.saveTables(output,os,this.useColor(this.flags,output),false); + } + } catch( _g ) { + var e = haxe_Exception.caught(_g).unwrap(); + if(!this.fail_if_diff) { + throw haxe_Exception.thrown(e); + } + return 2; } if(ok) { return 0; + } else if(this.fail_if_diff) { + return 2; } else { return 1; } @@ -2895,7 +3006,11 @@ var coopy_CrossMatch = function() { }; coopy_CrossMatch.__name__ = true; coopy_CrossMatch.prototype = { - __class__: coopy_CrossMatch + spot_a: null + ,spot_b: null + ,item_a: null + ,item_b: null + ,__class__: coopy_CrossMatch }; var coopy_Csv = $hx_exports["coopy"]["Csv"] = function(delim,eol) { if(delim == null) { @@ -2909,48 +3024,59 @@ var coopy_Csv = $hx_exports["coopy"]["Csv"] = function(delim,eol) { }; coopy_Csv.__name__ = true; coopy_Csv.prototype = { - renderTable: function(t) { + cursor: null + ,row_ended: null + ,has_structure: null + ,delim: null + ,discovered_eol: null + ,preferred_eol: null + ,renderTable: function(t) { var eol = this.preferred_eol; if(eol == null) { eol = "\r\n"; } var result = ""; - var txt = ""; var v = t.getCellView(); var stream = new coopy_TableStream(t); var w = stream.width(); + var txts = []; while(stream.fetch()) { - var _g1 = 0; - var _g = w; - while(_g1 < _g) { - var x = _g1++; + var _g = 0; + var _g1 = w; + while(_g < _g1) { + var x = _g++; if(x > 0) { - txt += this.delim; + txts.push(this.delim); } - txt += this.renderCell(v,stream.getCell(x)); + txts.push(this.renderCell(v,stream.getCell(x))); } - txt += eol; + txts.push(eol); } - return txt; + return txts.join(""); } - ,renderCell: function(v,d) { + ,renderCell: function(v,d,force_quote) { + if(force_quote == null) { + force_quote = false; + } if(d == null) { return "NULL"; } var str = v.toString(d); - var need_quote = false; - if(str.length > 0) { - if(str.charAt(0) == " " || str.charAt(str.length - 1) == " ") { - need_quote = true; + var need_quote = force_quote; + if(!need_quote) { + if(str.length > 0) { + if(str.charAt(0) == " " || str.charAt(str.length - 1) == " ") { + need_quote = true; + } } } if(!need_quote) { - var _g1 = 0; - var _g = str.length; - while(_g1 < _g) { - var i = _g1++; + var _g = 0; + var _g1 = str.length; + while(_g < _g1) { + var i = _g++; var ch = str.charAt(i); - if(ch == "\"" || ch == "'" || ch == "\r" || ch == "\n" || ch == "\t") { + if(ch == "\"" || ch == "\r" || ch == "\n" || ch == "\t") { need_quote = true; break; } @@ -2961,10 +3087,10 @@ coopy_Csv.prototype = { } if(i + this.delim.length <= str.length) { var match = true; - var _g3 = 1; - var _g2 = this.delim.length; - while(_g3 < _g2) { - var j = _g3++; + var _g2 = 1; + var _g3 = this.delim.length; + while(_g2 < _g3) { + var j = _g2++; if(str.charAt(i + j) != this.delim.charAt(j)) { match = false; break; @@ -2983,24 +3109,27 @@ coopy_Csv.prototype = { result += "\""; } var line_buf = ""; - var _g11 = 0; - var _g4 = str.length; - while(_g11 < _g4) { - var i1 = _g11++; - var ch1 = str.charAt(i1); - if(ch1 == "\"") { + var _g = 0; + var _g1 = str.length; + while(_g < _g1) { + var i = _g++; + var ch = str.charAt(i); + if(ch == "\"") { result += "\""; } - if(ch1 != "\r" && ch1 != "\n") { + if(ch != "\r" && ch != "\n") { if(line_buf.length > 0) { result += line_buf; line_buf = ""; } - result += ch1; + result += ch; } else { - line_buf += ch1; + line_buf += ch; } } + if(line_buf.length > 0) { + result += line_buf; + } if(need_quote) { result += "\""; } @@ -3028,16 +3157,16 @@ coopy_Csv.prototype = { if(yat > 0) { if(cell != "" && cell != null) { var context = ""; - var _g1 = 0; - var _g = w; - while(_g1 < _g) { - var i = _g1++; + var _g = 0; + var _g1 = w; + while(_g < _g1) { + var i = _g++; if(i > 0) { context += ","; } context += Std.string(tab.getCell(i,yat)); } - console.log("Ignored overflowing row " + yat + " with cell '" + cell + "' after: " + context); + console.log("coopy/Csv.hx:179:","Ignored overflowing row " + yat + " with cell '" + cell + "' after: " + context); } } else { w = at + 1; @@ -3070,10 +3199,10 @@ coopy_Csv.prototype = { var quote = 0; var result = ""; var start = this.cursor; - var _g1 = this.cursor; - var _g = txt.length; - while(_g1 < _g) { - var i = _g1++; + var _g = this.cursor; + var _g1 = txt.length; + while(_g < _g1) { + var i = _g++; var ch = HxOverrides.cca(txt,i); last_processed = i; if(ch != 95 && i < first_non_underscore) { @@ -3087,10 +3216,10 @@ coopy_Csv.prototype = { } if(i + this.delim.length <= txt.length) { var match = true; - var _g3 = 1; - var _g2 = this.delim.length; - while(_g3 < _g2) { - var j = _g3++; + var _g2 = 1; + var _g3 = this.delim.length; + while(_g2 < _g3) { + var j = _g2++; if(txt.charAt(i + j) != this.delim.charAt(j)) { match = false; break; @@ -3108,14 +3237,14 @@ coopy_Csv.prototype = { if(ch2 != ch) { if(ch2 == 13 || ch2 == 10) { if(this.discovered_eol == null) { - this.discovered_eol = String.fromCharCode(ch) + String.fromCharCode(ch2); + this.discovered_eol = String.fromCodePoint(ch) + String.fromCodePoint(ch2); } ++last_processed; } } } if(this.discovered_eol == null) { - this.discovered_eol = String.fromCharCode(ch); + this.discovered_eol = String.fromCodePoint(ch); } this.row_ended = true; break; @@ -3125,14 +3254,14 @@ coopy_Csv.prototype = { quoting = true; quote = ch; if(i != start) { - result += String.fromCharCode(ch); + result += String.fromCodePoint(ch); } continue; } else if(ch == quote) { quoting = true; } } - result += String.fromCharCode(ch); + result += String.fromCodePoint(ch); continue; } if(ch == quote) { @@ -3140,7 +3269,7 @@ coopy_Csv.prototype = { continue; } } - result += String.fromCharCode(ch); + result += String.fromCodePoint(ch); } this.cursor = last_processed; if(quote == 0) { @@ -3174,6 +3303,7 @@ var coopy_DiffRender = $hx_exports["coopy"]["DiffRender"] = function() { this.text_to_insert = []; this.open = false; this.pretty_arrows = true; + this.quote_html = true; }; coopy_DiffRender.__name__ = true; coopy_DiffRender.examineCell = function(x,y,view,raw,vcol,vrow,vcorner,cell,offset) { @@ -3285,7 +3415,7 @@ coopy_DiffRender.examineCell = function(x,y,view,raw,vcol,vrow,vcorner,cell,offs pretty_tokens[0] = coopy_DiffRender.markSpaces(ref,tokens[2]); pretty_tokens[2] = coopy_DiffRender.markSpaces(tokens[2],ref); } - cell.pretty_separator = String.fromCharCode(8594); + cell.pretty_separator = String.fromCodePoint(8594); cell.pretty_value = pretty_tokens.join(cell.pretty_separator); cell.category_given_tr = cell.category = cat; var offset1 = cell.conflicted ? 1 : 0; @@ -3329,7 +3459,7 @@ coopy_DiffRender.markSpaces = function(sl,sr) { } else if(cr == " ") { ++ir; } else { - slo += String.fromCharCode(9251); + slo += String.fromCodePoint(9251); ++il; } } @@ -3343,9 +3473,19 @@ coopy_DiffRender.renderCell = function(tab,view,x,y) { return cell; }; coopy_DiffRender.prototype = { - usePrettyArrows: function(flag) { + text_to_insert: null + ,td_open: null + ,td_close: null + ,open: null + ,pretty_arrows: null + ,quote_html: null + ,section: null + ,usePrettyArrows: function(flag) { this.pretty_arrows = flag; } + ,quoteHtml: function(flag) { + this.quote_html = flag; + } ,insert: function(str) { this.text_to_insert.push(str); } @@ -3427,10 +3567,10 @@ coopy_DiffRender.prototype = { return this; } } - var _g1 = 0; - var _g = tab.get_height(); - while(_g1 < _g) { - var row = _g1++; + var _g = 0; + var _g1 = tab.get_height(); + while(_g < _g1) { + var row = _g++; var open = false; var txt = view.toString(tab.getCell(off,row)); if(txt == null) { @@ -3447,12 +3587,16 @@ coopy_DiffRender.prototype = { this.setSection("body"); } render.beginRow(row_mode); - var _g3 = 0; - var _g2 = tab.get_width(); - while(_g3 < _g2) { - var c = _g3++; + var _g2 = 0; + var _g3 = tab.get_width(); + while(_g2 < _g3) { + var c = _g2++; coopy_DiffRender.examineCell(c,row,view,tab.getCell(c,row),change_row >= 0 ? view.toString(tab.getCell(c,change_row)) : "",txt,corner,cell,off); - render.insertCell(this.pretty_arrows ? cell.pretty_value : cell.value,cell.category_given_tr); + var val = this.pretty_arrows ? cell.pretty_value : cell.value; + if(this.quote_html) { + val = StringTools.htmlEscape(view.toString(val)); + } + render.insertCell(val,cell.category_given_tr); } render.endRow(); } @@ -3461,13 +3605,15 @@ coopy_DiffRender.prototype = { } ,renderTables: function(tabs) { var order = tabs.getOrder(); - if(order.length == 0 || tabs.hasInsDel()) { + var start = 0; + if(order.length <= 1 || tabs.hasInsDel()) { this.render(tabs.one()); + start = 1; } - var _g1 = 1; - var _g = order.length; - while(_g1 < _g) { - var i = _g1++; + var _g = start; + var _g1 = order.length; + while(_g < _g1) { + var i = _g++; var name = order[i]; var tab = tabs.get(name); if(tab.get_height() <= 1) { @@ -3481,7 +3627,7 @@ coopy_DiffRender.prototype = { return this; } ,sampleCss: function() { - return ".highlighter .add { \n background-color: #7fff7f;\n}\n\n.highlighter .remove { \n background-color: #ff7f7f;\n}\n\n.highlighter td.modify { \n background-color: #7f7fff;\n}\n\n.highlighter td.conflict { \n background-color: #f00;\n}\n\n.highlighter .spec { \n background-color: #aaa;\n}\n\n.highlighter .move { \n background-color: #ffa;\n}\n\n.highlighter .null { \n color: #888;\n}\n\n.highlighter table { \n border-collapse:collapse;\n}\n\n.highlighter td, .highlighter th {\n border: 1px solid #2D4068;\n padding: 3px 7px 2px;\n}\n\n.highlighter th, .highlighter .header, .highlighter .meta {\n background-color: #aaf;\n font-weight: bold;\n padding-bottom: 4px;\n padding-top: 5px;\n text-align:left;\n}\n\n.highlighter tr.header th {\n border-bottom: 2px solid black;\n}\n\n.highlighter tr.index td, .highlighter .index, .highlighter tr.header th.index {\n background-color: white;\n border: none;\n}\n\n.highlighter .gap {\n color: #888;\n}\n\n.highlighter td {\n empty-cells: show;\n}\n"; + return ".highlighter .add { \n background-color: #7fff7f;\n}\n\n.highlighter .remove { \n background-color: #ff7f7f;\n}\n\n.highlighter td.modify { \n background-color: #7f7fff;\n}\n\n.highlighter td.conflict { \n background-color: #f00;\n}\n\n.highlighter .spec { \n background-color: #aaa;\n}\n\n.highlighter .move { \n background-color: #ffa;\n}\n\n.highlighter .null { \n color: #888;\n}\n\n.highlighter table { \n border-collapse:collapse;\n}\n\n.highlighter td, .highlighter th {\n border: 1px solid #2D4068;\n padding: 3px 7px 2px;\n}\n\n.highlighter th, .highlighter .header, .highlighter .meta {\n background-color: #aaf;\n font-weight: bold;\n padding-bottom: 4px;\n padding-top: 5px;\n text-align:left;\n}\n\n.highlighter tr.header th {\n border-bottom: 2px solid black;\n}\n\n.highlighter tr.index td, .highlighter .index, .highlighter tr.header th.index {\n background-color: white;\n border: none;\n}\n\n.highlighter .gap {\n color: #888;\n}\n\n.highlighter td {\n empty-cells: show;\n white-space: pre-wrap;\n}\n"; } ,completeHtml: function() { this.text_to_insert.splice(0,0,"\n\n
\n\n