MCPcopy Create free account
hub / github.com/git/git / match_string_spaces

Function match_string_spaces

combine-diff.c:139–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137};
138
139static int match_string_spaces(const char *line1, int len1,
140 const char *line2, int len2,
141 long flags)
142{
143 if (flags & XDF_WHITESPACE_FLAGS) {
144 for (; len1 > 0 && XDL_ISSPACE(line1[len1 - 1]); len1--);
145 for (; len2 > 0 && XDL_ISSPACE(line2[len2 - 1]); len2--);
146 }
147
148 if (!(flags & (XDF_IGNORE_WHITESPACE | XDF_IGNORE_WHITESPACE_CHANGE)))
149 return (len1 == len2 && !memcmp(line1, line2, len1));
150
151 while (len1 > 0 && len2 > 0) {
152 len1--;
153 len2--;
154 if (XDL_ISSPACE(line1[len1]) || XDL_ISSPACE(line2[len2])) {
155 if ((flags & XDF_IGNORE_WHITESPACE_CHANGE) &&
156 (!XDL_ISSPACE(line1[len1]) || !XDL_ISSPACE(line2[len2])))
157 return 0;
158
159 for (; len1 > 0 && XDL_ISSPACE(line1[len1]); len1--);
160 for (; len2 > 0 && XDL_ISSPACE(line2[len2]); len2--);
161 }
162 if (line1[len1] != line2[len2])
163 return 0;
164 }
165
166 if (flags & XDF_IGNORE_WHITESPACE) {
167 /* Consume remaining spaces */
168 for (; len1 > 0 && XDL_ISSPACE(line1[len1 - 1]); len1--);
169 for (; len2 > 0 && XDL_ISSPACE(line2[len2 - 1]); len2--);
170 }
171
172 /* We matched full line1 and line2 */
173 if (!len1 && !len2)
174 return 1;
175
176 return 0;
177}
178
179enum coalesce_direction { MATCH, BASE, NEW };
180

Callers 1

coalesce_linesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected