summaryrefslogtreecommitdiffstats
path: root/konsole/tests/quote.c
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit4aed2c8219774f5d797760606b8489a92ddc5163 (patch)
tree3f8c130f7d269626bf6a9447407ef6c35954426a /konsole/tests/quote.c
downloadtdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz
tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'konsole/tests/quote.c')
-rw-r--r--konsole/tests/quote.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/konsole/tests/quote.c b/konsole/tests/quote.c
new file mode 100644
index 000000000..61cf2ac4f
--- /dev/null
+++ b/konsole/tests/quote.c
@@ -0,0 +1,50 @@
+// a silly quotation utitility
+
+#include <stdio.h>
+#include <strings.h>
+
+int skip = 0;
+int empty = 1;
+
+void pchr(int c, int indent)
+{
+ if (skip)
+ {
+ skip = (c != '\n');
+ return;
+ }
+ switch(c)
+ {
+ case '\n':
+ if (!empty)
+ printf("\\n\"\n%*s\"",indent,"");
+ empty = 1;
+ break;
+ case '#' :
+ skip = 1;
+ break;
+ case '"' : case '\\':
+ printf("\\");
+ // fallthrough
+ default:
+ printf("%c",c);
+ empty = 0;
+ break;
+ }
+}
+
+#define INDENT 2
+
+int main(int argc, char* argv[])
+{ int cc; FILE *sysin;
+ if (argc < 2) { fprintf(stderr,"usage: %s filename\n",argv[0]); return 1; }
+ sysin = fopen(argv[1],"r");
+ if (!sysin) { fprintf(stderr,"cannot open %s\n",argv[1]); perror("reason: "); return 1; }
+ printf("%*s/* generated by '%s %s' */\n\n",INDENT,"",argv[0],argv[1]);
+ printf("%*s\"",INDENT,"");
+ while( (cc = fgetc(sysin)) > 0)
+ {
+ pchr(cc,INDENT);
+ }
+ printf("\"\n");
+}