@@ -707,88 +707,14 @@ struct moved_entry {
707
707
struct moved_entry * next_line ;
708
708
};
709
709
710
- static int next_byte (const char * * cp , const char * * endp ,
711
- const struct diff_options * diffopt )
712
- {
713
- int retval ;
714
-
715
- if (* cp >= * endp )
716
- return -1 ;
717
-
718
- if (isspace (* * cp )) {
719
- if (DIFF_XDL_TST (diffopt , IGNORE_WHITESPACE_CHANGE )) {
720
- while (* cp < * endp && isspace (* * cp ))
721
- (* cp )++ ;
722
- /*
723
- * After skipping a couple of whitespaces,
724
- * we still have to account for one space.
725
- */
726
- return (int )' ' ;
727
- }
728
-
729
- if (DIFF_XDL_TST (diffopt , IGNORE_WHITESPACE )) {
730
- while (* cp < * endp && isspace (* * cp ))
731
- (* cp )++ ;
732
- /*
733
- * return the first non-ws character via the usual
734
- * below, unless we ate all of the bytes
735
- */
736
- if (* cp >= * endp )
737
- return -1 ;
738
- }
739
- }
740
-
741
- retval = (unsigned char )(* * cp );
742
- (* cp )++ ;
743
- return retval ;
744
- }
745
-
746
710
static int moved_entry_cmp (const struct diff_options * diffopt ,
747
711
const struct moved_entry * a ,
748
712
const struct moved_entry * b ,
749
713
const void * keydata )
750
714
{
751
- const char * ap = a -> es -> line , * ae = a -> es -> line + a -> es -> len ;
752
- const char * bp = b -> es -> line , * be = b -> es -> line + b -> es -> len ;
753
-
754
- if (!(diffopt -> xdl_opts & XDF_WHITESPACE_FLAGS ))
755
- return a -> es -> len != b -> es -> len || memcmp (ap , bp , a -> es -> len );
756
-
757
- if (DIFF_XDL_TST (diffopt , IGNORE_WHITESPACE_AT_EOL )) {
758
- while (ae > ap && isspace (ae [-1 ]))
759
- ae -- ;
760
- while (be > bp && isspace (be [-1 ]))
761
- be -- ;
762
- }
763
-
764
- while (1 ) {
765
- int ca , cb ;
766
- ca = next_byte (& ap , & ae , diffopt );
767
- cb = next_byte (& bp , & be , diffopt );
768
- if (ca != cb )
769
- return 1 ;
770
- if (ca < 0 )
771
- return 0 ;
772
- }
773
- }
774
-
775
- static unsigned get_string_hash (struct emitted_diff_symbol * es , struct diff_options * o )
776
- {
777
- if (o -> xdl_opts & XDF_WHITESPACE_FLAGS ) {
778
- static struct strbuf sb = STRBUF_INIT ;
779
- const char * ap = es -> line , * ae = es -> line + es -> len ;
780
- int c ;
781
-
782
- strbuf_reset (& sb );
783
- while (ae > ap && isspace (ae [-1 ]))
784
- ae -- ;
785
- while ((c = next_byte (& ap , & ae , o )) >= 0 )
786
- strbuf_addch (& sb , c );
787
-
788
- return memhash (sb .buf , sb .len );
789
- } else {
790
- return memhash (es -> line , es -> len );
791
- }
715
+ return !xdiff_compare_lines (a -> es -> line , a -> es -> len ,
716
+ b -> es -> line , b -> es -> len ,
717
+ diffopt -> xdl_opts );
792
718
}
793
719
794
720
static struct moved_entry * prepare_entry (struct diff_options * o ,
@@ -797,7 +723,7 @@ static struct moved_entry *prepare_entry(struct diff_options *o,
797
723
struct moved_entry * ret = xmalloc (sizeof (* ret ));
798
724
struct emitted_diff_symbol * l = & o -> emitted_symbols -> buf [line_no ];
799
725
800
- ret -> ent .hash = get_string_hash ( l , o );
726
+ ret -> ent .hash = xdiff_hash_string ( l -> line , l -> len , o -> xdl_opts );
801
727
ret -> es = l ;
802
728
ret -> next_line = NULL ;
803
729
0 commit comments