#!/usr/bin/awk -f # # process *.tex file, look for '\beginCsource{file.c}' and replace # all lines between '\beginCsource{file.c}' and '\endCsource' with # contents of 'file.c' # # Developed by Lubomir Host 'rajo' # Copyright (c) 2003 Platon SDG # Licensed under terms of GNU General Public License. # All rights reserved. # # $Platon$ BEGIN { skip = 0; file = ""; printf "%% This is automaticaly generated file !!\n" >> "/dev/stderr"; printf "%% Please, DON'T delete them\n" >> "/dev/stderr"; } # get filename to insert and read it /\\beginCsource\{/ { print; gsub(/^\\beginCsource{/, ""); gsub(/}.*$/, ""); file = $0; line = getline < file; while (line) { print; line = getline < file; } skip = 1; next; } /\\endCsource/ { print; skip = 0; next; } # remember numbers of marked lines /\[LINE [a-z]+\]/ { #printf "%d: %s\n", NR, $0 >> "/dev/stderr"; str = $0; sub(/^[^\[]*\[LINE /, "LINE", str); sub(/\][^\]]*$/, "", str); #printf "%d: %s\n", NR, str >> "/dev/stderr"; #printf "%d: %s\n", NR, str >> "/dev/stderr"; printf "\\def\\%s{%d}\n", str, NR - 19 >> "/dev/stderr"; } // { if (!skip) print; next; } # vim: cindent