diff options
| author | beatrice <beatrice@dangofactory.net> | 2026-11-22 19:19:03 +0900 |
|---|---|---|
| committer | beatrice <beatrice@dangofactory.net> | 2026-11-22 19:19:03 +0900 |
| commit | bd4611555e18fca7c66afaef0f094e15038b0459 (patch) | |
| tree | 1b1a9109567b61ac259ead146f4bef21a0f886df /mantools/comment.c | |
| parent | 2324a9e97a727bf95690c9fb8fdca0f52301940e (diff) | |
| download | postfix-master.tar.gz postfix-master.zip | |
Release tarball postfix-3.11.7.tar.gz (dist-generated files / local differences from tag)HEADlocal/postfixmaster
Diffstat (limited to 'mantools/comment.c')
| -rw-r--r-- | mantools/comment.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/mantools/comment.c b/mantools/comment.c new file mode 100644 index 000000000..4372d4460 --- /dev/null +++ b/mantools/comment.c @@ -0,0 +1,66 @@ +#include <stdio.h> + +void copy_comment() +{ + int c; + + while ((c = getchar()) != EOF) { + if (c == '*') { + if ((c = getchar()) == '/') { + putchar('\n'); + return; + } + if (c != EOF) + ungetc(c, stdin); + putchar('*'); + } else { + putchar(c); + } + } +} + +void skip_string(int quote) +{ + int c; + + while ((c = getchar()) != EOF) { + if (c == quote) { + return; + } else if (c == '\\') { + getchar(); + } + } +} + +int main() +{ + int c; + + while ((c = getchar()) != EOF) { + switch (c) { + case '/': + if ((c = getchar()) == '*') { + copy_comment(); + } else if (c == '/') { + while ((c = getchar()) != EOF) { + putchar(c); + if (c == '\n') + break; + } + } else { + if (c != EOF) + ungetc(c, stdin); + } + break; + case '"': + case '\'': + skip_string(c); + break; + case '\\': + (void) getchar(); + break; + default: + break; + } + } +} |
