Messages in this thread | | | Date | Mon, 10 Oct 2011 15:42:05 -0700 | From | Andrew Morton <> | Subject | Re: [PATCH] checkpatch: Add a --strict check for utf-8 in commit logs |
| |
On Mon, 10 Oct 2011 15:32:30 -0700 Joe Perches <joe@perches.com> wrote:
> Some find using utf-8 in commit logs inappropriate. > > Some patch commit logs contain unintended utf-8 characters > when doing things like copy/pasting compilation output. > > Look for the start of any commit log by skipping initial > lines that look like email headers and "From: " lines. > > Stop looking for utf-8 at the first signature line. > > Suggested-by: Andrew Morton <akpm@linux-foundation.org> > Signed-off-by: Joe Perches <joe@perches.com> > > --- > > I don't feel strongly that this patch should be applied, > that's why it's a --strict check and not on by default, > but Andrew Morton seems to want something like it...
Mainly because of the non-ascii single-quote chars which gcc emits in its warning/error messages. I use LANG=C to stop gcc from doing that, and also have a proglet to undo this nonsense when I'm merging patches (below) (I totally forget how it works). But I see such things turning up in the tree via other merge paths.
#include <stdio.h> #include <string.h> #include <errno.h> #include <stdlib.h>
static void dump(int *buf) { if (buf[0] == 0xE2 && buf[1] == 0x80 && buf[2] == 0x98) { putchar('`'); buf[0] = 0; buf[1] = 0; buf[2] = 0; } else if (buf[0] == 0xE2 && buf[1] == 0x80 && buf[2] == 0x99) { putchar('\''); buf[0] = 0; buf[1] = 0; buf[2] = 0; } else if (buf[0] == 0xa1) { putchar('`'); goto move; } else if (buf[0] == 0xa2) { putchar('\''); goto move; } else { if (buf[0]) putchar(buf[0]); move: buf[0] = buf[1]; buf[1] = buf[2]; buf[2] = 0; } }
static void doit(FILE *f) { int buf[3] = {}; int c;
while ((c = fgetc(f)) != EOF) { dump(buf); buf[2] = c; } dump(buf); dump(buf); dump(buf); }
int main(int argc, char *argv[]) { if (argc == 1) { doit(stdin); } else { int i;
for (i = 1; i < argc; i++) { FILE *f = fopen(argv[i], "r");
if (f == NULL) { fprintf(stderr, "%s: cannot open `%s': %s\n", argv[0], argv[1], strerror(errno)); exit(1); } doit(f); fclose(f); } } exit(0); }
| |