1 # extract - extract C source files from GTK Tutorial
2 # Copyright (C) Tony Gale 1998
3 # Contact: gale@gtk.org
6 # -c : Just do checking rather than output files
7 # -f <filename> : Extract a specific file
8 # -d : Extract files to current directory
10 BEGIN {in_example=0; check=0; spec_example=""; do_output=0; flatten=0
11 for (i=0 ; i < ARGC ; i++) {
12 if ( ARGV[i] == "-c" ) {
15 } else if ( ARGV[i] == "-f" ) {
16 spec_example=ARGV[i+1];
19 if ( length(spec_example) == 0 ) {
20 print "usage: -f <filename>";
23 } else if ( ARGV[i] == "-d" ) {
30 $2 == "example-start" && in_example == 1 { printf("\nERROR: nested example at line %d\n", NR) > "/dev/stderr";
33 $2 == "example-start" { in_example=1 }
35 $2 == "example-start" && check == 0 \
36 { if ( (spec_example == "") || (spec_example == $4) ) {
40 file_name = sprintf("%s/%s",$3, $4);
41 command = sprintf("mkdir -p %s", $3);
50 in_example==1 && check==0 && do_output==1 { gsub(/&/, "\\&", $0);
53 $2 == "example-end" && in_example == 0 { printf("\nERROR: multiple ends at line %d\n", NR) > "/dev/stderr";
55 $2 == "example-end" { in_example=0; do_output=0 }