summaryrefslogtreecommitdiffstats
path: root/src/to_c_cmd.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/to_c_cmd.py')
-rwxr-xr-xsrc/to_c_cmd.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/to_c_cmd.py b/src/to_c_cmd.py
new file mode 100755
index 0000000..52785f1
--- /dev/null
+++ b/src/to_c_cmd.py
@@ -0,0 +1,8 @@
+# place " at begin of each line
+# escape existing '\' and '"'
+# remove \n at the end of the line (sometimes the last line does not have a \n
+# so we cannot do a replacement with some other text)
+# place an escaped \n and " at the end of each line
+import sys
+for line in sys.stdin:
+ sys.stdout.write('"' + line.replace('\\','\\\\').replace('"','\\"').replace('\n','') + '\\n"\n')