File: text2c

package info (click to toggle)
openvswitch 3.6.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 99,612 kB
  • sloc: sh: 1,683,183; ansic: 313,349; python: 28,192; xml: 21,442; makefile: 548; javascript: 191
file content (16 lines) | stat: -rwxr-xr-x 378 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#! /usr/bin/python3

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 + '"')