aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-05-31 09:35:25 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2011-05-31 09:35:25 +0300
commit5ad301c57c5143f7d132b6acc22cb665c7058a64 (patch)
tree4acf15d7abe82139ebff4ca498282e6a99bb162f
parentd6747f8b74f56046c676f94eb13a7df16718e53c (diff)
downloadcfpeek-5ad301c57c5143f7d132b6acc22cb665c7058a64.tar.gz
cfpeek-5ad301c57c5143f7d132b6acc22cb665c7058a64.tar.bz2
Improvements in scripting code.
* src/cfpeek.c (script_init_expr): New variable. * src/cfpeek.h: Likewise. * src/cmdline.opt: New option --init. * src/guile.c (guile_init): Eval script_init_expr, if defined. * src/script.c: Bugfixes: Use grecs_error for error reporting.
-rw-r--r--src/cfpeek.c1
-rw-r--r--src/cfpeek.h1
-rw-r--r--src/cmdline.opt8
-rw-r--r--src/guile.c4
-rw-r--r--src/script.c6
5 files changed, 17 insertions, 3 deletions
diff --git a/src/cfpeek.c b/src/cfpeek.c
index 7136813..3111d96 100644
--- a/src/cfpeek.c
+++ b/src/cfpeek.c
@@ -28,6 +28,7 @@ char *parent_option;
char *script_file;
char *script_expr;
+char *script_init_expr;
#define MODE_GLOB 0
#define MODE_LITERAL 1
diff --git a/src/cfpeek.h b/src/cfpeek.h
index 5f39ff2..c5694cf 100644
--- a/src/cfpeek.h
+++ b/src/cfpeek.h
@@ -34,6 +34,7 @@
extern char *program_name;
extern char *script_file;
extern char *script_expr;
+extern char *script_init_expr;
void script_select(const char *lang);
void script_init(void);
diff --git a/src/cmdline.opt b/src/cmdline.opt
index a8d134d..5553978 100644
--- a/src/cmdline.opt
+++ b/src/cmdline.opt
@@ -259,7 +259,7 @@ BEGIN
END
OPTION(file,f,FILE,
- [<apply this script FILE to each node found>])
+ [<load the script FILE>])
BEGIN
script_file = optarg;
END
@@ -270,6 +270,12 @@ BEGIN
script_expr = optarg;
END
+OPTION(init,i,EXPR,
+ [<initial setup expession>])
+BEGIN
+ script_init_expr = optarg;
+END
+
GROUP(Preprocessor control)
OPTION(include-directory,I,DIR,
diff --git a/src/guile.c b/src/guile.c
index dba7559..6da81b0 100644
--- a/src/guile.c
+++ b/src/guile.c
@@ -750,6 +750,9 @@ guile_init()
exit(EX_CONFIG);
}
}
+
+ if (script_init_expr)
+ scm_c_eval_string(script_init_expr);
guile_inited = 1;
}
@@ -780,3 +783,4 @@ guile_apply(struct grecs_node *node)
NULL, NULL);
}
}
+
diff --git a/src/script.c b/src/script.c
index 643d685..869df55 100644
--- a/src/script.c
+++ b/src/script.c
@@ -62,7 +62,8 @@ script_select(const char *lang)
{
cur_script = script_find_by_lang(lang);
if (!cur_script) {
- error("unsupported scripting language: %s", lang);
+ grecs_error(NULL, 0, "unsupported scripting language: %s",
+ lang);
exit(EX_USAGE);
}
}
@@ -83,7 +84,8 @@ script_init()
cur_script = script_tab;
if (!cur_script->lang) {
- error("scripting support not compiled in");
+ grecs_error(NULL, 0,
+ "scripting support not compiled in");
exit(EX_USAGE);
}
}

Return to:

Send suggestions and report system problems to the System administrator.