diff options
author | des <des@FreeBSD.org> | 2004-03-21 04:47:54 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2004-03-21 04:47:54 +0000 |
commit | 854f282025a130c71ad6f9238e382863be7add59 (patch) | |
tree | 9e8ca7af9dbfbc8be7dc9a58517acba8208e2953 | |
parent | 909ef067602b4d862fda341da66a84cade67626d (diff) | |
download | FreeBSD-src-854f282025a130c71ad6f9238e382863be7add59.zip FreeBSD-src-854f282025a130c71ad6f9238e382863be7add59.tar.gz |
Support C-style comments in profile.
-rw-r--r-- | usr.bin/indent/args.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/usr.bin/indent/args.c b/usr.bin/indent/args.c index 25078f6..6f50948 100644 --- a/usr.bin/indent/args.c +++ b/usr.bin/indent/args.c @@ -185,12 +185,27 @@ set_profile(void) static void scan_profile(FILE *f) { - int i; - char *p; + int comment, i; + char *p; char buf[BUFSIZ]; while (1) { - for (p = buf; (i = getc(f)) != EOF && (*p = i) > ' '; ++p); + p = buf; + comment = 0; + while ((i = getc(f)) != EOF) { + if (i == '*' && !comment && p > buf && p[-1] == '/') { + comment = p - buf; + *p++ = i; + } else if (i == '/' && comment && p > buf && p[-1] == '*') { + p = buf + comment - 1; + comment = 0; + } else if (isspace(i)) { + if (p > buf && !comment) + break; + } else { + *p++ = i; + } + } if (p != buf) { *p++ = 0; if (verbose) |