summaryrefslogtreecommitdiffstats
path: root/src/to_c_cmd.py
blob: 52785f1e4e9b2f9944c33e382d65edbebe6829a8 (plain)
1
2
3
4
5
6
7
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')