$(NXT_BUILDDIR)/nxt_sha2.o \
$(NXT_BUILDDIR)/nxt_pcre.o \
$(NXT_BUILDDIR)/nxt_time.o \
+ $(NXT_BUILDDIR)/nxt_file.o \
$(NXT_BUILDDIR)/nxt_malloc.o \
$(NXT_BUILDDIR)/nxt_mp.o \
$(NXT_BUILDDIR)/nxt_sprintf.o \
$(NXT_BUILDDIR)/nxt_sha2.o \
$(NXT_BUILDDIR)/nxt_pcre.o \
$(NXT_BUILDDIR)/nxt_time.o \
+ $(NXT_BUILDDIR)/nxt_file.o \
$(NXT_BUILDDIR)/nxt_malloc.o \
$(NXT_BUILDDIR)/nxt_mp.o \
$(NXT_BUILDDIR)/nxt_sprintf.o \
#include <nxt_lvlhsh.h>
#include <nxt_random.h>
#include <nxt_time.h>
+#include <nxt_file.h>
#include <nxt_malloc.h>
#include <nxt_mp.h>
#include <nxt_sprintf.h>
nxt_memzero(&vm_options, sizeof(njs_vm_opt_t));
if (opts.file != NULL) {
- vm_options.file.start = (u_char *) opts.file;
- vm_options.file.length = strlen(opts.file);
+ nxt_file_name(&vm_options.file, opts.file);
+
+ } else {
+ vm_options.file = nxt_string_value("shell");
}
vm_options.init = !opts.interactive;
{
nxt_mp_free(pool, p);
}
-
{"JSON.parse(Error())\r\n"
"JSON.parse(Error())\r\nSyntaxError: Unexpected token at position 0*at JSON.parse (native)"}
{"JSON.parse(Error()\r\n"
- "JSON.parse(Error()\r\nSyntaxError: Unexpected token \"\" in 1"}
+ "JSON.parse(Error()\r\nSyntaxError: Unexpected token \"\" in shell:1"}
}
njs_test {
njs_test {
{"(function() { throw 'test' })()\r\n"
- "test\r\n at anonymous (:1)"}
+ "test\r\n at anonymous (shell:1)"}
}
# Non-ASCII characters
$(NXT_BUILDDIR)/nxt_malloc.o \
$(NXT_BUILDDIR)/nxt_trace.o \
$(NXT_BUILDDIR)/nxt_time.o \
+ $(NXT_BUILDDIR)/nxt_file.o \
$(NXT_BUILDDIR)/nxt_mp.o \
$(NXT_BUILDDIR)/nxt_sprintf.o \
$(NXT_BUILDDIR)/nxt_pcre.o \
$(NXT_BUILDDIR)/nxt_malloc.o \
$(NXT_BUILDDIR)/nxt_time.o \
+ $(NXT_BUILDDIR)/nxt_file.o \
$(NXT_BUILDDIR)/nxt_trace.o \
$(NXT_BUILDDIR)/nxt_mp.o \
$(NXT_BUILDDIR)/nxt_sprintf.o \
-I$(NXT_LIB) \
$(NXT_LIB)/nxt_time.c
+$(NXT_BUILDDIR)/nxt_file.o: \
+ $(NXT_LIB)/nxt_auto_config.h \
+ $(NXT_LIB)/nxt_types.h \
+ $(NXT_LIB)/nxt_clang.h \
+ $(NXT_LIB)/nxt_file.h \
+ $(NXT_LIB)/nxt_file.c \
+
+ $(NXT_CC) -c -o $(NXT_BUILDDIR)/nxt_file.o $(NXT_CFLAGS) \
+ -I$(NXT_LIB) \
+ $(NXT_LIB)/nxt_file.c
+
$(NXT_BUILDDIR)/nxt_trace.o: \
$(NXT_LIB)/nxt_auto_config.h \
$(NXT_LIB)/nxt_types.h \
--- /dev/null
+
+/*
+ * Copyright (C) Igor Sysoev
+ * Copyright (C) NGINX, Inc.
+ */
+
+#include <nxt_auto_config.h>
+#include <nxt_types.h>
+#include <nxt_clang.h>
+#include <nxt_string.h>
+#include <nxt_file.h>
+
+#include <string.h>
+
+
+void
+nxt_file_name(nxt_str_t *name, char *path)
+{
+ char *p;
+ size_t length;
+
+ length = strlen(path);
+
+ for (p = path + length; p >= path; p--) {
+ if (*p == '/') {
+ p++;
+ break;
+ }
+ }
+
+ name->start = (u_char *) p;
+ name->length = length - (p - path);
+}
--- /dev/null
+
+/*
+ * Copyright (C) Igor Sysoev
+ * Copyright (C) NGINX, Inc.
+ */
+
+#ifndef _NXT_FILE_H_INCLUDED_
+#define _NXT_FILE_H_INCLUDED_
+
+
+void nxt_file_name(nxt_str_t *name, char *path);
+
+
+#endif /* _NXT_FILE_H_INCLUDED_ */