Browse Source

Merge pull request #45 from ymattw/diff-of-diff

Diff of diff
Matthew Wang 9 years ago
parent
commit
ffa865c38f

+ 1
- 1
.travis.yml View File

10
 
10
 
11
 before_install:
11
 before_install:
12
     - pip --quiet install docutils
12
     - pip --quiet install docutils
13
-    - pip --quiet install Pygments
13
+    - pip --quiet install Pygments==1.6
14
     - pip --quiet install coverage
14
     - pip --quiet install coverage
15
     - coverage --version
15
     - coverage --version
16
     - sudo apt-get --quiet=2 install patchutils
16
     - sudo apt-get --quiet=2 install patchutils

+ 6
- 2
cdiff.py View File

547
                 if changed:
547
                 if changed:
548
                     if not old[0]:
548
                     if not old[0]:
549
                         left = '%*s' % (width, ' ')
549
                         left = '%*s' % (width, ' ')
550
-                        right = right.lstrip('\x00+').rstrip('\x01')
550
+                        right = right.rstrip('\x01')
551
+                        if right.startswith('\x00+'):
552
+                            right = right[2:]
551
                         right = _fit_with_marker(
553
                         right = _fit_with_marker(
552
                             right, self._markup_new, width)
554
                             right, self._markup_new, width)
553
                     elif not new[0]:
555
                     elif not new[0]:
554
-                        left = left.lstrip('\x00-').rstrip('\x01')
556
+                        left = left.rstrip('\x01')
557
+                        if left.startswith('\x00-'):
558
+                            left = left[2:]
555
                         left = _fit_with_marker(left, self._markup_old, width)
559
                         left = _fit_with_marker(left, self._markup_old, width)
556
                         right = ''
560
                         right = ''
557
                     else:
561
                     else:

+ 37
- 0
tests/diff-of-diff/in.diff View File

1
+Index: patch-Alias.xs
2
+===================================================================
3
+--- patch-Alias.xs	(revision 384635)
4
++++ patch-Alias.xs	(revision 384636)
5
+@@ -140,17 +140,21 @@
6
+  	tmp = kLISTOP->op_first;
7
+  	if (inside)
8
+  		op_null(tmp);
9
+-@@ -2001,6 +2035,9 @@ STATIC OP *da_ck_entersub(pTHX_ OP *o) {
10
++@@ -2001,6 +2035,13 @@ STATIC OP *da_ck_entersub(pTHX_ OP *o) {
11
+  	while (kid->op_sibling != last)
12
+  		kid = kid->op_sibling;
13
+  	kid->op_sibling = Nullop;
14
+ +#ifdef op_sibling_splice
15
+++#if (PERL_COMBI_VERSION >= 5021011)
16
+++	kid->op_moresib = 0;
17
+++#else
18
+ +	kid->op_lastsib = 1;
19
+ +#endif
20
+++#endif
21
+  	cLISTOPx(cUNOPo->op_first)->op_last = kid;
22
+  	if (kid->op_type == OP_NULL && inside)
23
+  		kid->op_flags &= ~OPf_SPECIAL;
24
+-@@ -2008,6 +2045,14 @@ STATIC OP *da_ck_entersub(pTHX_ OP *o) {
25
++@@ -2008,6 +2049,14 @@ STATIC OP *da_ck_entersub(pTHX_ OP *o) {
26
+  	return o;
27
+  }
28
+  
29
+@@ -165,7 +169,7 @@
30
+  
31
+  MODULE = Data::Alias  PACKAGE = Data::Alias
32
+  
33
+-@@ -2025,6 +2070,10 @@ BOOT:
34
++@@ -2025,6 +2074,10 @@ BOOT:
35
+  		PL_check[OP_RV2CV] = da_ck_rv2cv;
36
+  		da_old_ck_entersub = PL_check[OP_ENTERSUB];
37
+  		PL_check[OP_ENTERSUB] = da_ck_entersub;

+ 38
- 0
tests/diff-of-diff/out.normal View File

1
+Index: patch-Alias.xs
2
+===================================================================
3
+--- patch-Alias.xs	(revision 384635)
4
++++ patch-Alias.xs	(revision 384636)
5
+@@ -140,17 +140,21 @@
6
+  	tmp = kLISTOP->op_first;
7
+  	if (inside)
8
+  		op_null(tmp);
9
+-@@ -2001,6 +2035,9 @@ STATIC OP *da_ck_entersub(pTHX_ OP *o) {
10
++@@ -2001,6 +2035,13 @@ STATIC OP *da_ck_entersub(pTHX_ OP *o) {
11
+  	while (kid->op_sibling != last)
12
+  		kid = kid->op_sibling;
13
+  	kid->op_sibling = Nullop;
14
+ +#ifdef op_sibling_splice
15
+++#if (PERL_COMBI_VERSION >= 5021011)
16
+++	kid->op_moresib = 0;
17
+++#else
18
+ +	kid->op_lastsib = 1;
19
+++#endif
20
+ +#endif
21
+  	cLISTOPx(cUNOPo->op_first)->op_last = kid;
22
+  	if (kid->op_type == OP_NULL && inside)
23
+  		kid->op_flags &= ~OPf_SPECIAL;
24
+-@@ -2008,6 +2045,14 @@ STATIC OP *da_ck_entersub(pTHX_ OP *o) {
25
++@@ -2008,6 +2049,14 @@ STATIC OP *da_ck_entersub(pTHX_ OP *o) {
26
+  	return o;
27
+  }
28
+  
29
+@@ -165,7 +169,7 @@
30
+  
31
+  MODULE = Data::Alias  PACKAGE = Data::Alias
32
+  
33
+-@@ -2025,6 +2070,10 @@ BOOT:
34
++@@ -2025,6 +2074,10 @@ BOOT:
35
+  		PL_check[OP_RV2CV] = da_ck_rv2cv;
36
+  		da_old_ck_entersub = PL_check[OP_ENTERSUB];
37
+  		PL_check[OP_ENTERSUB] = da_ck_entersub;
38
+

+ 34
- 0
tests/diff-of-diff/out.side-by-side View File

1
+Index: patch-Alias.xs
2
+===================================================================
3
+--- patch-Alias.xs	(revision 384635)
4
++++ patch-Alias.xs	(revision 384636)
5
+@@ -140,17 +140,21 @@
6
+140          tmp = kLISTOP->op_first;                                                140          tmp = kLISTOP->op_first;
7
+141          if (inside)                                                             141          if (inside)
8
+142                  op_null(tmp);                                                   142                  op_null(tmp);
9
+143 @@ -2001,6 +2035,9 @@ STATIC OP *da_ck_entersub(pTHX_ OP *o) {                   143 @@ -2001,6 +2035,13 @@ STATIC OP *da_ck_entersub(pTHX_ OP *o) {
10
+144          while (kid->op_sibling != last)                                         144          while (kid->op_sibling != last)
11
+145                  kid = kid->op_sibling;                                          145                  kid = kid->op_sibling;
12
+146          kid->op_sibling = Nullop;                                               146          kid->op_sibling = Nullop;
13
+147 +#ifdef op_sibling_splice                                                        147 +#ifdef op_sibling_splice
14
+                                                                                     148 +#if (PERL_COMBI_VERSION >= 5021011)
15
+                                                                                     149 +        kid->op_moresib = 0;
16
+                                                                                     150 +#else
17
+148 +        kid->op_lastsib = 1;                                                    151 +        kid->op_lastsib = 1;
18
+                                                                                     152 +#endif
19
+149 +#endif                                                                          153 +#endif
20
+150          cLISTOPx(cUNOPo->op_first)->op_last = kid;                              154          cLISTOPx(cUNOPo->op_first)->op_last = kid;
21
+151          if (kid->op_type == OP_NULL && inside)                                  155          if (kid->op_type == OP_NULL && inside)
22
+152                  kid->op_flags &= ~OPf_SPECIAL;                                  156                  kid->op_flags &= ~OPf_SPECIAL;
23
+153 @@ -2008,6 +2045,14 @@ STATIC OP *da_ck_entersub(pTHX_ OP *o) {                  157 @@ -2008,6 +2049,14 @@ STATIC OP *da_ck_entersub(pTHX_ OP *o) {
24
+154          return o;                                                               158          return o;
25
+155  }                                                                               159  }
26
+156                                                                                  160  
27
+@@ -165,7 +169,7 @@
28
+165                                                                                  169  
29
+166  MODULE = Data::Alias  PACKAGE = Data::Alias                                     170  MODULE = Data::Alias  PACKAGE = Data::Alias
30
+167                                                                                  171  
31
+168 @@ -2025,6 +2070,10 @@ BOOT:                                                     172 @@ -2025,6 +2074,10 @@ BOOT:
32
+169                  PL_check[OP_RV2CV] = da_ck_rv2cv;                               173                  PL_check[OP_RV2CV] = da_ck_rv2cv;
33
+170                  da_old_ck_entersub = PL_check[OP_ENTERSUB];                     174                  da_old_ck_entersub = PL_check[OP_ENTERSUB];
34
+171                  PL_check[OP_ENTERSUB] = da_ck_entersub;                         175                  PL_check[OP_ENTERSUB] = da_ck_entersub;

+ 34
- 0
tests/diff-of-diff/out.w70 View File

1
+Index: patch-Alias.xs
2
+===================================================================
3
+--- patch-Alias.xs	(revision 384635)
4
++++ patch-Alias.xs	(revision 384636)
5
+@@ -140,17 +140,21 @@
6
+140          tmp = kLISTOP->op_first;                                      140          tmp = kLISTOP->op_first;
7
+141          if (inside)                                                   141          if (inside)
8
+142                  op_null(tmp);                                         142                  op_null(tmp);
9
+143 @@ -2001,6 +2035,9 @@ STATIC OP *da_ck_entersub(pTHX_ OP *o) {         143 @@ -2001,6 +2035,13 @@ STATIC OP *da_ck_entersub(pTHX_ OP *o) {
10
+144          while (kid->op_sibling != last)                               144          while (kid->op_sibling != last)
11
+145                  kid = kid->op_sibling;                                145                  kid = kid->op_sibling;
12
+146          kid->op_sibling = Nullop;                                     146          kid->op_sibling = Nullop;
13
+147 +#ifdef op_sibling_splice                                              147 +#ifdef op_sibling_splice
14
+                                                                           148 +#if (PERL_COMBI_VERSION >= 5021011)
15
+                                                                           149 +        kid->op_moresib = 0;
16
+                                                                           150 +#else
17
+148 +        kid->op_lastsib = 1;                                          151 +        kid->op_lastsib = 1;
18
+                                                                           152 +#endif
19
+149 +#endif                                                                153 +#endif
20
+150          cLISTOPx(cUNOPo->op_first)->op_last = kid;                    154          cLISTOPx(cUNOPo->op_first)->op_last = kid;
21
+151          if (kid->op_type == OP_NULL && inside)                        155          if (kid->op_type == OP_NULL && inside)
22
+152                  kid->op_flags &= ~OPf_SPECIAL;                        156                  kid->op_flags &= ~OPf_SPECIAL;
23
+153 @@ -2008,6 +2045,14 @@ STATIC OP *da_ck_entersub(pTHX_ OP *o) {        157 @@ -2008,6 +2049,14 @@ STATIC OP *da_ck_entersub(pTHX_ OP *o) {
24
+154          return o;                                                     158          return o;
25
+155  }                                                                     159  }
26
+156                                                                        160  
27
+@@ -165,7 +169,7 @@
28
+165                                                                        169  
29
+166  MODULE = Data::Alias  PACKAGE = Data::Alias                           170  MODULE = Data::Alias  PACKAGE = Data::Alias
30
+167                                                                        171  
31
+168 @@ -2025,6 +2070,10 @@ BOOT:                                           172 @@ -2025,6 +2074,10 @@ BOOT:
32
+169                  PL_check[OP_RV2CV] = da_ck_rv2cv;                     173                  PL_check[OP_RV2CV] = da_ck_rv2cv;
33
+170                  da_old_ck_entersub = PL_check[OP_ENTERSUB];           174                  da_old_ck_entersub = PL_check[OP_ENTERSUB];
34
+171                  PL_check[OP_ENTERSUB] = da_ck_entersub;               175                  PL_check[OP_ENTERSUB] = da_ck_entersub;