[SCM] Gerris Flow Solver branch, upstream, updated. b3aa46814a06c9cb2912790b23916ffb44f1f203
Stephane Popinet
s.popinet at niwa.co.nz
Fri May 15 02:51:46 UTC 2009
The following commit has been merged in the upstream branch:
commit 6c4792dae96d23eb2b8e4acccf013683d3eda630
Author: Stephane Popinet <s.popinet at niwa.co.nz>
Date: Mon Apr 4 09:56:21 2005 +1000
Fixed problems with C expressions in GfsFunction
Also added check for pkg-config in configure. pkg-config is required for
inlined functions in parameter files.
darcs-hash:20050403235621-fbd8f-a12f409b5a4fc54e58f59ca688e1b6b78737f962.gz
diff --git a/configure.in b/configure.in
index 7b2b75f..38f401c 100644
--- a/configure.in
+++ b/configure.in
@@ -226,6 +226,19 @@ AC_MSG_RESULT($have_gmodule)
CFLAGS=$OLD_CFLAGS
LIBS=$OLD_LIBS
+# checks for pkg-config
+if test "$have_gmodule" = "yes"; then
+ AC_CHECK_PROG(have_pkg_config, pkg-config, yes, no)
+ if test "$have_pkg_config" = "no"; then
+ AC_MSG_WARN([pkg-config is required for functions in parameter files.])
+ fi
+fi
+if test x"$have_pkg_config" = x"yes"; then
+ AC_DEFINE(HAVE_PKG_CONFIG, 1, [Define to 1 if GModule are supported and if you have pkg-config.])
+else
+ AC_DEFINE(HAVE_PKG_CONFIG, 0)
+fi
+
# check if module support is disabled
AC_ARG_ENABLE(modules,
[ --disable-modules link modules statically with the executables],
diff --git a/src/utils.c b/src/utils.c
index f16e5f9..ca24d82 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -22,6 +22,7 @@
#include <unistd.h>
#include <signal.h>
#include <math.h>
+#include "config.h"
#include "utils.h"
#include "solid.h"
#include "simulation.h"
@@ -101,8 +102,8 @@ static void function_read (GtsObject ** o, GtsFile * fp)
/* fall through */
/* compile C expression */
- case '{':
- if (!g_module_supported ()) {
+ case '(': case '{':
+ if (!HAVE_PKG_CONFIG) {
gts_file_error (fp, "expecting a number (val)");
return;
}
@@ -154,9 +155,21 @@ static void function_read (GtsObject ** o, GtsFile * fp)
}
fprintf (fin, " }\n#line %d \"GfsFunction\"\n", fp->line);
- if (type == GTS_STRING) {
+ if (type == '(' || type == GTS_STRING) {
f->expr = g_string_new (fp->token->str);
- fprintf (fin, "return %s;\n", fp->token->str);
+ if (type == '(' || fp->next_token != '\0') {
+ gint c, scope = type == '(' ? 1 : 0;
+ if (fp->next_token != '\0')
+ g_string_append_c (f->expr, fp->next_token);
+ c = gts_file_getc (fp);
+ while (c != EOF && (scope > 0 || (c != ' ' && c != '\n'))) {
+ if (c == '(') scope++;
+ if (c == ')') scope--;
+ g_string_append_c (f->expr, c);
+ c = gts_file_getc (fp);
+ }
+ }
+ fprintf (fin, "return %s;\n", f->expr->str);
fputs ("}\n", fin);
fclose (fin);
}
@@ -235,8 +248,8 @@ static void function_read (GtsObject ** o, GtsFile * fp)
remove (foutname);
close (ferrd);
remove (ferrname);
- if (type == GTS_STRING)
- gts_file_next_token (fp);
+ if ((type == '(' || type == GTS_STRING) && fp->next_token != '\0')
+ gts_file_next_token (fp);
}
break;
--
Gerris Flow Solver
More information about the debian-science-commits
mailing list