From 80fd26d51ef8958a6c2089f9768242b689ebcfe7 Mon Sep 17 00:00:00 2001 From: Sami Vaarala Date: Thu, 2 Jan 2014 01:19:25 +0200 Subject: [PATCH] add duktape version to cmdline greet --- examples/cmdline/duk_cmdline.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/examples/cmdline/duk_cmdline.c b/examples/cmdline/duk_cmdline.c index 096bdbde..667098b0 100644 --- a/examples/cmdline/duk_cmdline.c +++ b/examples/cmdline/duk_cmdline.c @@ -10,6 +10,16 @@ #define NO_SIGNAL #endif +#define GREET_CODE(variant) \ + "print(" \ + "'((o) Duktape" variant "'" \ + ", " \ + "Math.floor(__duk__.version / 10000) + '.' + " \ + "Math.floor(__duk__.version / 100) % 100 + '.' + " \ + "__duk__.version % 100" \ + "); " \ + "print(__duk__.build);" + #include #include #include @@ -223,7 +233,7 @@ int handle_interactive(duk_context *ctx) { int retval = 0; int rc; - duk_eval_string(ctx, "print('((o) Duktape [no readline]'); print(__duk__.build);"); + duk_eval_string(ctx, GREET_CODE(" [no readline]")); duk_pop(ctx); buffer = malloc(LINEBUF_SIZE); @@ -279,14 +289,14 @@ int handle_interactive(duk_context *ctx) { return retval; } -#else +#else /* NO_READLINE */ int handle_interactive(duk_context *ctx) { const char *prompt = "duk> "; char *buffer = NULL; int retval = 0; int rc; - duk_eval_string(ctx, "print('((o) Duktape'); print(__duk__.build);"); + duk_eval_string(ctx, GREET_CODE("")); duk_pop(ctx); /*