@@ -122,30 +122,35 @@ static void cwk_path_terminate_output(char *buffer, size_t buffer_size,
122122}
123123
124124static bool cwk_path_is_string_equal (const char * first ,const char * second ,
125- size_t n )
125+ size_t first_size , size_t second_size )
126126{
127+ // THe two strings are not equal if the sizes are not equal.
128+ if (first_size != second_size ) {
129+ return false;
130+ }
131+
127132// If the path style is UNIX, we will compare case sensitively. This can be
128133// done easily using strncmp.
129134if (path_style == CWK_STYLE_UNIX ) {
130- return strncmp (first ,second ,n )== 0 ;
135+ return strncmp (first ,second ,first_size )== 0 ;
131136 }
132137
133138// However, if this is windows we will have to compare case insensitively.
134139// Since there is no standard method to do that we will have to do it on our
135140// own.
136- while (* first && * second && n > 0 ) {
141+ while (* first && * second && first_size > 0 ) {
137142// We can consider the string to be not equal if the two lowercase
138143// characters are not equal.
139144if (tolower (* first ++ )!= tolower (* second ++ )) {
140145return false;
141146 }
142147
143- -- n ;
148+ -- first_size ;
144149 }
145150
146- //We can consider the stringto be equalif we either reached n == 0 or both
147- //cursors point to a null character .
148- return n == 0 || ( * first == '\0' && * second == '\0' ) ;
151+ //The stringmust be equalsince they both have the same length and all the
152+ //characters are the same .
153+ return true ;
149154}
150155
151156static const char * cwk_path_find_next_stop (const char * c )
@@ -437,9 +442,7 @@ cwk_path_segment_will_be_removed(const struct cwk_segment_joined *sj,
437442// First we check whether this is a CWK_CURRENT or CWK_BACK segment, since
438443// those will always be dropped.
439444type = cwk_path_get_segment_type (& sj -> segment );
440- if (type == CWK_CURRENT ) {
441- return true;
442- }else if (type == CWK_BACK && absolute ) {
445+ if (type == CWK_CURRENT || (type == CWK_BACK && absolute )) {
443446return true;
444447 }else if (type == CWK_BACK ) {
445448return cwk_path_segment_back_will_be_removed (& sjc );
@@ -701,7 +704,7 @@ static void cwk_path_skip_segments_until_diverge(struct cwk_segment_joined *bsj,
701704// Compare the content of both segments. We are done if they are not equal,
702705// since they diverge.
703706if (!cwk_path_is_string_equal (bsj -> segment .begin ,osj -> segment .begin ,
704- bsj -> segment .size )) {
707+ bsj -> segment .size , osj -> segment . size )) {
705708break ;
706709 }
707710
@@ -729,7 +732,8 @@ size_t cwk_path_get_relative(const char *base_directory, const char *path,
729732cwk_path_get_root (base_directory ,& base_root_length );
730733cwk_path_get_root (path ,& path_root_length );
731734if (base_root_length != path_root_length ||
732- !cwk_path_is_string_equal (base_directory ,path ,base_root_length )) {
735+ !cwk_path_is_string_equal (base_directory ,path ,base_root_length ,
736+ path_root_length )) {
733737cwk_path_terminate_output (buffer ,buffer_size ,pos );
734738return pos ;
735739 }
@@ -1126,7 +1130,8 @@ size_t cwk_path_get_intersection(const char *path_base, const char *path_other)
11261130// absolute.
11271131cwk_path_get_root (path_base ,& base_root_length );
11281132cwk_path_get_root (path_other ,& other_root_length );
1129- if (!cwk_path_is_string_equal (path_base ,path_other ,base_root_length )) {
1133+ if (!cwk_path_is_string_equal (path_base ,path_other ,base_root_length ,
1134+ other_root_length )) {
11301135return 0 ;
11311136 }
11321137
@@ -1165,7 +1170,7 @@ size_t cwk_path_get_intersection(const char *path_base, const char *path_other)
11651170 }
11661171
11671172if (!cwk_path_is_string_equal (base .segment .begin ,other .segment .begin ,
1168- base .segment .size )) {
1173+ base .segment .size , other . segment . size )) {
11691174// So the content of those two segments are not equal. We will return the
11701175// size up to the beginning.
11711176return (size_t )(end - path_base );