Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Saturday, April 20, 2024

File: [Platon] / doc / diplomova-praca-rajo / insert-C-source (download)

Revision 1.1, Thu Jul 24 17:50:07 2003 UTC (20 years, 9 months ago) by rajo

Diploma Thesis of Lubomir Host.
Title: Metoda Monte Carlo vo fyzike nizkoteplotnej plazmy. (Slovak language)

#!/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' <rajo AT platon.sk>
# 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

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top