File: gen_fallback

package info (click to toggle)
xball 3.0-16
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,004 kB
  • ctags: 1,358
  • sloc: ansic: 4,612; sh: 3,415; makefile: 522
file content (18 lines) | stat: -rwxr-xr-x 698 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/sh

# Usage: gen_fallback app-defaults-file
#        Generates a list of fallback resources suitable for including
#        in the fallback resources array

# This shellscript just echos each line in the source file with a " at
# the beginning of the line, and a ", at the and of the line.

echo '/* fallback.h generated by gen_fallback from '$1' - do not edit! */'
echo ""
cat $1 | awk ' \
  BEGIN { first = 1 } \
  /\\$/ && first == 0 { printf("%s\n", $0); } \
  /\\$/ && first == 1 { first = 0; printf("\"%s\n", $0); } \
  $0 !~ /\\$/ && first == 1  { printf("\"%s\",\n", $0); } \
  $0 !~ /\\$/ && first == 0  { first = 1 ; printf("\",\n\"%s\",\n", $0); } \
  END  { printf("NULL\n"); }'