MCPcopy Index your code
hub / github.com/git/git / check_roundtrip

Function check_roundtrip

convert.c:347–383  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

345}
346
347static int check_roundtrip(const char *enc_name)
348{
349 /*
350 * check_roundtrip_encoding contains a string of comma and/or
351 * space separated encodings (eg. "UTF-16, ASCII, CP1125").
352 * Search for the given encoding in that string.
353 */
354 const char *encoding = check_roundtrip_encoding ?
355 check_roundtrip_encoding : "SHIFT-JIS";
356 const char *found = strcasestr(encoding, enc_name);
357 const char *next;
358 int len;
359 if (!found)
360 return 0;
361 next = found + strlen(enc_name);
362 len = strlen(encoding);
363 return (found && (
364 /*
365 * Check that the found encoding is at the beginning of
366 * encoding or that it is prefixed with a space or
367 * comma.
368 */
369 found == encoding || (
370 (isspace(found[-1]) || found[-1] == ',')
371 )
372 ) && (
373 /*
374 * Check that the found encoding is at the end of
375 * encoding or that it is suffixed with a space
376 * or comma.
377 */
378 next == encoding + len || (
379 next < encoding + len &&
380 (isspace(next[0]) || next[0] == ',')
381 )
382 ));
383}
384
385static const char *default_encoding = "UTF-8";
386

Callers 1

encode_to_gitFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected