git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v10 9/9] convert: add round trip check based on 'core.checkRoundtripEncoding'

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 7, 2018, 19:59 UTC
Message-ID
<xmqqmuzjzmfi.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20180307173026.30058-10-lars.schneider@autodesk.com>
lars.schneider@autodesk.com writes:
> +static int check_roundtrip(const char* enc_name)
The asterisk sticks to the variable, not type.
Show 23 quoted lines
> +{
> +	/*
> +	 * check_roundtrip_encoding contains a string of space and/or
> +	 * comma separated encodings (eg. "UTF-16, ASCII, CP1125").
> +	 * Search for the given encoding in that string.
> +	 */
> +	const char *found = strcasestr(check_roundtrip_encoding, enc_name);
> +	const char *next;
> +	int len;
> +	if (!found)
> +		return 0;
> +	next = found + strlen(enc_name);
> +	len = strlen(check_roundtrip_encoding);
> +	return (found && (
> +			/*
> +			 * check that the found encoding is at the
> +			 * beginning of check_roundtrip_encoding or
> +			 * that it is prefixed with a space or comma
> +			 */
> +			found == check_roundtrip_encoding || (
> +				found > check_roundtrip_encoding &&
> +				(*(found-1) == ' ' || *(found-1) == ',')
> +			)

The second line is unneeded, as we know a non-NULL found either points at check_roundtrip_encoding or somewhere to the right, and the first test already checked the "points exactly at" case.

This is defined to be a comma separated list, so it is unnecessary to accept <cre,en> == <"FOO, SHIFT-JIS, BAR", "SHIFT-JIS">; if you allow SP, perhaps "isspace(found[-1]) || found[-1] == ','" to also allow HT may also be appropriate. I think "comma or whitespace separated list" is fine; in any case, the comment near the beginning of this function does not match new text in Documentation/config.txt added by this patch.

Previous: lars.schneider@autodesk.comNext: Lars Schneider
Message 28 of 32 in “convert: add support for different encodings”
  1. 0/9 convert: add support for different encodingslars.schneider@autodesk.com, Mar 7, 2018
  2. 1/9 strbuf: remove unnecessary NUL assignment in xstrdup_tolower()lars.schneider@autodesk.com, Mar 7, 2018
  3. 2/9 strbuf: add xstrdup_toupper()lars.schneider@autodesk.com, Mar 7, 2018
  4. 3/9 strbuf: add a case insensitive starts_with()lars.schneider@autodesk.com, Mar 7, 2018
  5. Duy NguyenMar 8, 2018
  6. Junio C HamanoMar 8, 2018
  7. Lars SchneiderMar 9, 2018
  8. Junio C HamanoMar 9, 2018
  9. Ævar Arnfjörð BjarmasonMar 9, 2018
  10. 4/9 utf8: add function to detect prohibited UTF-16/32 BOMlars.schneider@autodesk.com, Mar 7, 2018
  11. 5/9 utf8: add function to detect a missing UTF-16/32 BOMlars.schneider@autodesk.com, Mar 7, 2018
  12. 6/9 convert: add 'working-tree-encoding' attributelars.schneider@autodesk.com, Mar 7, 2018
  13. Eric SunshineMar 7, 2018
  14. Lars SchneiderMar 7, 2018
  15. Junio C HamanoMar 7, 2018
  16. Junio C HamanoMar 7, 2018
  17. 7/9 convert: check for detectable errors in UTF encodingslars.schneider@autodesk.com, Mar 7, 2018
  18. Eric SunshineMar 7, 2018
  19. Lars SchneiderMar 9, 2018
  20. Junio C HamanoMar 7, 2018
  21. Lars SchneiderMar 7, 2018
  22. Junio C HamanoMar 7, 2018
  23. Lars SchneiderMar 7, 2018
  24. Junio C HamanoMar 7, 2018
  25. Lars SchneiderMar 7, 2018
  26. Junio C HamanoMar 7, 2018
  27. 9/9 convert: add round trip check based on 'core.checkRoundtripEncoding'lars.schneider@autodesk.com, Mar 7, 2018
  28. Junio C HamanoMar 7, 2018
  29. Lars SchneiderMar 7, 2018
  30. Junio C HamanoMar 7, 2018
  31. Lars SchneiderMar 7, 2018
  32. 8/9 convert: add tracing for 'working-tree-encoding' attributelars.schneider@autodesk.com, Mar 7, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.