From 854f282025a130c71ad6f9238e382863be7add59 Mon Sep 17 00:00:00 2001 From: des Date: Sun, 21 Mar 2004 04:47:54 +0000 Subject: Support C-style comments in profile. --- usr.bin/indent/args.c | 21 ++++++++++++++++++--- 1 file 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) -- cgit v1.1