name: duk_pcompile_lstring proto: | duk_int_t duk_pcompile_lstring(duk_context *ctx, duk_uint_t flags, const char *src, duk_size_t len); stack: | [ ... ] -> [ ... function! ] (if success, return value == 0) [ ... ] -> [ ... err! ] (if failure, return value != 0) summary: |

Like duk_pcompile(), but the compile input is given as a C string with explicit length. The filename associated with the function is "input".

example: | const char *src = /* ... */; duk_size_t len = /* ... */; if (duk_pcompile_lstring(ctx, 0, src, len) != 0) { printf("compile failed: %s\n", duk_safe_to_string(ctx, -1)); } else { duk_call(ctx, 0); /* [ func ] -> [ result ] */ printf("program result: %s\n", duk_safe_to_string(ctx, -1)); } duk_pop(ctx); tags: - compile - protected - string introduced: 1.0.0