[SCM] Gerris Flow Solver branch, upstream, updated. b3aa46814a06c9cb2912790b23916ffb44f1f203
Stephane Popinet
popinet at users.sf.net
Fri May 15 02:55:24 UTC 2009
The following commit has been merged in the upstream branch:
commit 8b2ab5193d9f4dc9115c57e8c62f2fa806db2bd4
Author: Stephane Popinet <popinet at users.sf.net>
Date: Tue Jun 10 22:49:55 2008 +1000
New gfs-highlight script
Uses GNU source-highlight for syntax highlighting of simulation files.
darcs-hash:20080610124955-d4795-1673b85158663ed4682859426ca2b0a3956fb19c.gz
diff --git a/configure.in b/configure.in
index 1228d3d..41dc39c 100644
--- a/configure.in
+++ b/configure.in
@@ -456,5 +456,6 @@ doc/Makefile
doc/tutorial/Makefile
doc/examples/Makefile
doc/examples/gfs2doc
+doc/examples/gfs-highlight
desktop/Makefile
])
diff --git a/debian/control.sh b/debian/control.sh
index e0fb3d5..c748b86 100644
--- a/debian/control.sh
+++ b/debian/control.sh
@@ -15,7 +15,7 @@ Architecture: any
Depends: libc6-dev | libc-dev, libgts-snapshot-dev (>= $GTS_VERSION), pkg-config, gcc, sed, gawk, m4, proj, libnetcdf3, libgsl0
Conflicts: gerris
Replaces: gerris
-Recommends: gfsview-snapshot
+Recommends: gfsview-snapshot, source-highlight
Suggests: imagemagick, ffmpeg
Description: Gerris Flow Solver (development snapshot)
Gerris is a system for the solution of the partial differential
diff --git a/doc/examples/Makefile.am b/doc/examples/Makefile.am
index db77c2c..4b9b186 100644
--- a/doc/examples/Makefile.am
+++ b/doc/examples/Makefile.am
@@ -24,20 +24,23 @@ test.sh: $(EXAMPLES)
@chmod +x test.sh
bin_SCRIPTS = \
- gfs2doc
+ gfs2doc gfs-highlight
BUILT_SOURCES= \
- gfs2doc gfsclasses.py
+ gfs2doc gfs-highlight gfs.lang
CLEANFILES = $(BUILT_SOURCES) Makefile.deps
-pkglib_DATA = gfs2tex.py gfsclasses.py
+pkglib_DATA = gfs2tex.py
+pkgdata_DATA = gfs.lang
-gfsclasses.py: classes
- $(srcdir)/classes > gfsclasses.py
+gfs.lang: classes
+ $(srcdir)/classes > gfs.lang
gfs2doc: gfs2doc.in
+gfs-highlight: gfs-highlight.in
+
clean-generic:
$(RM) *.dvi *.aux *.log *.toc *.out examples.tex *.pyc test.sh gfs2doc
diff --git a/doc/examples/classes.c b/doc/examples/classes.c
index d5fe8bc..138169b 100644
--- a/doc/examples/classes.c
+++ b/doc/examples/classes.c
@@ -1,9 +1,20 @@
+#include <string.h>
#include "init.h"
-#define WIKI "http://gfs.sf.net/wiki/index.php/"
+#define WIKI "http\\://gfs.sf.net/wiki/index.php/"
-static void key_value_pair (const char * key)
+static void key_value_pair (const char * key, FILE * lang)
{
- printf ("'%s' : '" WIKI "%s',\\\n", key, key);
+ static int first = 1;
+ if (first) {
+ fprintf (lang, "gfs_keyword = ");
+ first = 0;
+ }
+ else
+ fprintf (lang, ",\n");
+
+ /* keywords must start with Gfs */
+ g_assert (strstr (key, "Gfs") == key);
+ fprintf (lang, " '(Gfs){0,1}%s'", &(key[3]));
}
int main (int argc, char * argv[])
@@ -12,14 +23,23 @@ int main (int argc, char * argv[])
gfs_init (&argc, &argv);
klass = gfs_classes ();
- printf ("klass = {\\\n");
- key_value_pair ("Define");
- key_value_pair ("GfsProjectionParams");
- key_value_pair ("GfsApproxProjectionParams");
+
+ printf ("# Language file for source-highlight\n"
+ "# Generated automatically by classes.c\n"
+ "\n"
+ "include \"cpp.lang\"\n"
+ "\n"
+ "comment start \"#\"\n"
+ "\n"
+ "redef preproc = \"C preprocessor command is not compatible with"
+ " the use of # as comment character in GTS\"\n"
+ "\n");
+ key_value_pair ("GfsDefine", stdout);
+ key_value_pair ("GfsProjectionParams", stdout);
+ key_value_pair ("GfsApproxProjectionParams", stdout);
while (*klass) {
- key_value_pair ((*klass)->info.name);
+ key_value_pair ((*klass)->info.name, stdout);
klass++;
}
- printf ("}\n");
return 0;
}
diff --git a/doc/examples/gfs-highlight b/doc/examples/gfs-highlight
new file mode 100755
index 0000000..7ced931
--- /dev/null
+++ b/doc/examples/gfs-highlight
@@ -0,0 +1,75 @@
+#!/bin/sh
+
+wiki="http:\/\/gfs.sf.net\/wiki\/index.php"
+title="Gerris simulation"
+css="darcs.css"
+
+path="/usr/local/share/gerris"
+
+usage()
+{
+ cat <<EOF
+Usage: gfs-highlight [OPTIONS] < input.gfs > output.html
+
+Syntax highlighting/hypertext linking of Gerris simulation files.
+
+Options:
+ [--title=TITLE] sets the page title
+ [--css=FILE] sets the CSS stylesheet filename
+ [--help] displays this message and exits
+EOF
+ exit $1
+}
+
+while test $# -gt 0; do
+ case "$1" in
+ -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) optarg= ;;
+ esac
+
+ case $1 in
+ --title=*)
+ title=$optarg
+ ;;
+ --css=*)
+ css=$optarg
+ ;;
+ --help)
+ usage 0 1>&2
+ ;;
+ *)
+ usage 0 1>&2
+ ;;
+ esac
+ shift
+done
+
+cat <<EOF
+<html>
+<head>
+<title>$title</title>
+<link rel="stylesheet" type="text/css" href="$css">
+</head>
+<body><tt class="gfs">
+EOF
+
+file=`mktemp gfs-highlight.XXXXXX`
+ln -s -f $path/gfs.lang $file
+
+awk 'BEGIN{ infile=0 } {
+ if ($2 == "Generated" && $3 == "files:") {
+ infile = 1;
+ while ($1 == "#") getline;
+ print $0;
+ } else if (infile)
+ print $0;
+ }' | \
+source-highlight --lang-def=$file --out-format=html-css | \
+sed "s/\"gfs_keyword\">\(Gfs\)\{0,1\}\([a-zA-Z0-9_]*\)<\/span>/"gfs_keyword"><a href=\"$wiki\/Gfs\2\">\1\2<\/a><\/span>/g"
+
+rm -f $file
+
+cat <<EOF
+</tt></body>
+</html>
+EOF
diff --git a/doc/examples/gfs-highlight.in b/doc/examples/gfs-highlight.in
new file mode 100755
index 0000000..056d7c8
--- /dev/null
+++ b/doc/examples/gfs-highlight.in
@@ -0,0 +1,75 @@
+#!/bin/sh
+
+wiki="http:\/\/gfs.sf.net\/wiki\/index.php"
+title="Gerris simulation"
+css="darcs.css"
+
+path="@prefix@/share/gerris"
+
+usage()
+{
+ cat <<EOF
+Usage: gfs-highlight [OPTIONS] < input.gfs > output.html
+
+Syntax highlighting/hypertext linking of Gerris simulation files.
+
+Options:
+ [--title=TITLE] sets the page title
+ [--css=FILE] sets the CSS stylesheet filename
+ [--help] displays this message and exits
+EOF
+ exit $1
+}
+
+while test $# -gt 0; do
+ case "$1" in
+ -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) optarg= ;;
+ esac
+
+ case $1 in
+ --title=*)
+ title=$optarg
+ ;;
+ --css=*)
+ css=$optarg
+ ;;
+ --help)
+ usage 0 1>&2
+ ;;
+ *)
+ usage 0 1>&2
+ ;;
+ esac
+ shift
+done
+
+cat <<EOF
+<html>
+<head>
+<title>$title</title>
+<link rel="stylesheet" type="text/css" href="$css">
+</head>
+<body><tt class="gfs">
+EOF
+
+file=`mktemp gfs-highlight.XXXXXX`
+ln -s -f $path/gfs.lang $file
+
+awk 'BEGIN{ infile=0 } {
+ if ($2 == "Generated" && $3 == "files:") {
+ infile = 1;
+ while ($1 == "#") getline;
+ print $0;
+ } else if (infile)
+ print $0;
+ }' | \
+source-highlight --lang-def=$file --out-format=html-css | \
+sed "s/\"gfs_keyword\">\(Gfs\)\{0,1\}\([a-zA-Z0-9_]*\)<\/span>/"gfs_keyword"><a href=\"$wiki\/Gfs\2\">\1\2<\/a><\/span>/g"
+
+rm -f $file
+
+cat <<EOF
+</tt></body>
+</html>
+EOF
diff --git a/doc/examples/gfs2doc.in b/doc/examples/gfs2doc.in
index ff82d1e..4ff71a6 100755
--- a/doc/examples/gfs2doc.in
+++ b/doc/examples/gfs2doc.in
@@ -8,7 +8,6 @@ import tempfile
sys.path.append("@prefix@/lib/gerris")
import gfs2tex
-import gfsclasses
if len(sys.argv) < 2:
print "usage: gfs2doc DIR1 DIR2..."
@@ -20,7 +19,7 @@ def myexit(s):
for d in sys.argv[1:]:
example = gfs2tex.Example(d)
- example.write(gfsclasses.klass)
+ example.write()
wdname = tempfile.mkdtemp()
tex = open(wdname + "/" + example.name + ".tex", "w")
tex.write(r"""
diff --git a/doc/examples/gfs2tex b/doc/examples/gfs2tex
index afefcc0..d2588a0 100755
--- a/doc/examples/gfs2tex
+++ b/doc/examples/gfs2tex
@@ -5,7 +5,6 @@ import os
import os.path
import glob
import gfs2tex
-import gfsclasses
if not os.access("examples",os.F_OK):
os.mkdir("examples")
@@ -16,4 +15,4 @@ for start in sys.argv[1:]:
example = gfs2tex.Example(root)
if not os.access("examples/" + example.path,os.F_OK):
os.symlink("../" + example.path, "examples/" + example.path)
- example.write(gfsclasses.klass,style="examples.css")
+ example.write(style="examples.css")
diff --git a/doc/examples/gfs2tex.py b/doc/examples/gfs2tex.py
index e6ca389..fd3c479 100644
--- a/doc/examples/gfs2tex.py
+++ b/doc/examples/gfs2tex.py
@@ -95,7 +95,7 @@ class Example:
else:
self.runtime = None
- def write(self,dico,file=None,style=None):
+ def write(self,file=None,style=""):
if file == None:
file = open(self.path + "/" + self.name + ".tex", 'w')
file.write(self.section + "{\\label{" + self.name + "}")
@@ -118,69 +118,15 @@ class Example:
file.write("\\item[Running time]" + self.time + "\n")
file.write("\\end{description}\n")
file.write("\n".join(self.description))
- self.colorize(dico,style)
+ self.colorize(style)
- def colorize(self,dico,style=None):
- file = open(self.path + "/" + self.name + ".gfs")
- out = open(self.path + "/" + self.name + ".gfs.html", 'w')
- path = "../" * (self.path.count("/") + 3) + "reference/"
- out.write("<html><head><title>\n" + self.name + ".gfs")
- if style == None:
- out.write('</title></head><body><tt class="gfs">\n')
- else:
- out.write('</title><link rel="stylesheet" type="text/css" href="' + \
- ["../","../../"][self.path.count("/")] + \
- style + '"></head><body><tt class="gfs">\n')
- infile = insthg = 0
- for line in file:
- tab = ""
- l = ""
- first = 1
- comment = 0
- for c in line:
- if c == " " and first:
- tab += " "
- else:
- if first and c == "#":
- comment = 1
- first = 0
- if c == '<':
- l += "<"
- elif c == '>':
- l += ">"
- elif c == '&':
- l += "&"
- else:
- l += c
- if comment:
- if infile:
- record = line.split()
- if insthg or len(record) > 1:
- out.write('<div class="comment">')
- out.write(tab)
- out.write(l)
- out.write('</div>')
- insthg = 1
- else:
- record = line.split()
- if len(record) > 2 and record[1] == "Generated" and record[2] == "files:":
- infile = 1
- insthg = 0
- else:
- out.write(tab)
- record = l.split()
- for r in record:
- key = None
- if dico.has_key(r):
- key = r
- elif dico.has_key("Gfs" + r):
- key = "Gfs" + r
- if key != None:
- out.write("<a href=\"" + dico[key] + "\">" + r + "</a> ")
- else:
- out.write(r + " ")
- out.write("<br>\n")
- out.write("</tt></body>\n</html>\n")
+ def colorize(self,style=""):
+ basename = self.path + "/" + self.name
+ if style != "":
+ style = " --css=" + ["../","../../"][self.path.count("/")] + style
+ os.system("gfs-highlight " + \
+ "--title=" + self.name + ".gfs" + style + \
+ " < " + basename + ".gfs > " + basename + ".gfs.html")
def test(self):
wdname = tempfile.mkdtemp()
diff --git a/src/m4.awk b/src/m4.awk
index f4e777f..15e22e1 100644
--- a/src/m4.awk
+++ b/src/m4.awk
@@ -9,7 +9,7 @@ BEGIN {
print "m4_changecom()m4_dnl";
}
{
- if ($1 == "Define") {
+ if ($1 == "GfsDefine" || $1 == "Define") {
macro = $2;
delete b;
if (match(macro, /(.+)\((.+)\)/, a)) {
--
Gerris Flow Solver
More information about the debian-science-commits
mailing list