summaryrefslogtreecommitdiff
path: root/chardiff_post.c
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2011-06-21 21:44:46 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2011-06-21 21:44:46 -0400
commit896161c483ceef3ed16e2f19a5c05106bed04512 (patch)
tree8e79f92d7b3dfe09fa97f4ae5feb8331ad6fbb52 /chardiff_post.c
I can't believe I didn't have this in git before.
Diffstat (limited to 'chardiff_post.c')
-rw-r--r--chardiff_post.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/chardiff_post.c b/chardiff_post.c
new file mode 100644
index 0000000..2145759
--- /dev/null
+++ b/chardiff_post.c
@@ -0,0 +1,25 @@
+#include <stdio.h>
+
+extern char* program_name;
+
+int
+main (int argc, char* argv[]) {
+ char c;
+ while ((c = getchar()) != EOF) {
+ if (c=='\\') {
+ char c2 = getchar();
+ switch (c2) {
+ case 'n': putchar('\n'); break;
+ case '\\': putchar('\\'); break;
+ default: putchar(c2); break;
+ }
+ }
+ char n = getchar();
+ if (n != '\n') {
+ printf(
+ "%s: found other character when expecting newline: %c",
+ argv[0], n);
+ }
+ }
+}
+