From: Arnaud Giersch Date: Fri, 25 Feb 2011 11:03:30 +0000 (+0100) Subject: Automatically update "options.cpp". X-Git-Tag: v0.1~100 X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/commitdiff_plain/db5fb322a04cdb13328247938ec14bbf85fba338?ds=inline Automatically update "options.cpp". --- diff --git a/new_loba.sh b/new_loba.sh index f564a5c..7519afc 100755 --- a/new_loba.sh +++ b/new_loba.sh @@ -1,5 +1,11 @@ #!/bin/bash +# Local variables: +# mode: sh +# End: + +set -e + if [ "$1" = "-n" ]; then echo "# Dry run mode!" >&2 create_files=0 @@ -9,8 +15,12 @@ else fi if [ $# -ne 1 ]; then - echo "Usage: $0 name" >&2 - echo " Create files loba_name.h and loba_name.cpp." + cat >&2 <= h_file) { + if ($2 != h_file) + print "#include " h_file; + included = 1; + } + print; + next; +} + +!included && include_line { + print include_line; + included = 1; +} + +/loba_algorithms_type::loba_algorithms_type\(\)/ { + nol_compare = "NOL_INSERT(\"" name "\"," + nol_string = " " nol_compare " \"describe your algorithm here...\",\n"; + nol_string = nol_string " loba_" name ");" + nol_insert = 1; +} + +nol_insert && $1 ~ /\}/ { + if (!nol_inserted) + print nol_string; + nol_insert = 0; +} + +nol_insert && !nol_inserted && /NOL_INSERT/ { + if ($1 > nol_compare) { + print nol_string; + nol_inserted = 1; + } +} + +{ print } +' options.cpp > $tmp + +if [ "$create_files" = "1" ]; then + mv options.cpp options.cpp~ + mv $tmp options.cpp +else + if type colordiff &> /dev/null; then + diff -u options.cpp $tmp | colordiff + else + diff -u options.cpp $tmp + fi +fi + cat >&2 <