summaryrefslogtreecommitdiff
path: root/one/uncom.c
diff options
context:
space:
mode:
authorMichael Hunteman <michael@huntm.net>2023-07-04 17:03:53 -0500
committerMichael Hunteman <michael@huntm.net>2023-07-06 17:23:45 -0500
commitbfce8f0d0d828209ec0bec71371ee94a7ad62d3e (patch)
treebdf49ca788ca1ca030d5b1cccfd0c9dffeb3f69f /one/uncom.c
Initial commit
Diffstat (limited to 'one/uncom.c')
-rw-r--r--one/uncom.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/one/uncom.c b/one/uncom.c
new file mode 100644
index 0000000..455f138
--- /dev/null
+++ b/one/uncom.c
@@ -0,0 +1,34 @@
+#include <stdio.h>
+
+/* XXX: dependent on file size */
+#define MAX 2048
+
+int
+main()
+{
+ char uncomment[MAX];
+ int c, i;
+ i = 0;
+ while (i < MAX && (c = getchar()) != EOF) {
+ if (c == '/') {
+ c = getchar();
+ if (c == '*') {
+ while ((c = getchar()) != '/') {
+ if (c == '\n') {
+ putchar('\n');
+ } else {
+ putchar(' ');
+ }
+ }
+ } else if (c == '/') {
+ while ((c = getchar()) != '\n') {
+ putchar(' ');
+ }
+ putchar('\n');
+ }
+ } else {
+ putchar(c);
+ }
+ }
+ return 0;
+}