MCPcopy Create free account
hub / github.com/RsyncProject/rsync / trailing_N_elements

Function trailing_N_elements

lib/wildmatch.c:260–285  ·  view source on GitHub ↗

Return the last "count" path elements from the concatenated string. * We return a string pointer to the start of the string, and update the * array pointer-pointer to point to any remaining string elements. */

Source from the content-addressed store, hash-verified

258 * We return a string pointer to the start of the string, and update the
259 * array pointer-pointer to point to any remaining string elements. */
260static const uchar *trailing_N_elements(const uchar*const **a_ptr, int count)
261{
262 const uchar*const *a = *a_ptr;
263 const uchar*const *first_a = a;
264
265 while (*a)
266 a++;
267
268 while (a != first_a) {
269 const uchar *s = *--a;
270 s += strlen((char*)s);
271 while (--s >= *a) {
272 if (*s == '/' && !--count) {
273 *a_ptr = a+1;
274 return s+1;
275 }
276 }
277 }
278
279 if (count == 1) {
280 *a_ptr = a+1;
281 return *a;
282 }
283
284 return NULL;
285}
286
287/* Match the "pattern" against the "text" string. */
288int wildmatch(const char *pattern, const char *text)

Callers 2

wildmatch_arrayFunction · 0.85
litmatch_arrayFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected