summaryrefslogtreecommitdiffstats
path: root/mantools/comment.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 16:18:56 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 16:18:56 +0000
commitb7c15c31519dc44c1f691e0466badd556ffe9423 (patch)
treef944572f288bab482a615e09af627d9a2b6727d8 /mantools/comment.c
parentInitial commit. (diff)
downloadpostfix-upstream.tar.xz
postfix-upstream.zip
Adding upstream version 3.7.10.upstream/3.7.10upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'mantools/comment.c')
-rw-r--r--mantools/comment.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/mantools/comment.c b/mantools/comment.c
new file mode 100644
index 0000000..4372d44
--- /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;
+ }
+ }
+}