File: txt2h.pl

package info (click to toggle)
gtimer 2.0.0-1.2
  • links: PTS
  • area: main
  • in suites: bullseye, buster, jessie, jessie-kfreebsd, sid, stretch
  • size: 1,380 kB
  • ctags: 849
  • sloc: ansic: 8,122; sh: 821; perl: 651; makefile: 86
file content (29 lines) | stat: -rw-r--r-- 627 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/perl
# Tool for converting a plain text file into a C string (char *) that
# can be used in a C program.
#
# This is a rewrite of this perl script.  i lost the original in the
# unfortunate hard disk crash of 2006 :-(
#
# Usage:
#	perl txt2h.pl < plaintext.txt > output
# History:
#	25 Mar 2010	Craig Knudsen <craig@k5n.us>
#			Created (again!)
#
############################################################################

$varname = 'changelog_text';

print 'static char *' . $varname . ' = "\\' . "\n";
while ( <> ) {
  chop ();
  s/\\/\\\\/g;
  s/"/\\"/g;
  print;
  print "\\n\\\n";
}
print "\";\n";

exit 0;