summaryrefslogtreecommitdiff
path: root/build-aux/text2c
blob: cb1f256f177511bad3c5d2b32bd1d8620716cc5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#! /usr/bin/python

import re
import sys

"""This utility reads its input, which should be plain text, and
prints it back transformed into quoted strings that may be #included
into C source code."""

while True:
    line = sys.stdin.readline()
    if not line:
        break

    s = line.replace("\\", "\\\\").replace('"', '\\"').replace("\n", "\\n")
    print('"' + s + '"')