static int njs_regexp_pattern_compile(njs_vm_t *vm, nxt_regex_t *regex, u_char *source, int options) { uint32_t size; nxt_int_t ret; u_char buf[NJS_EXCEPTION_BUF_LENGTH]; /* Zero length means a zero-terminated string. */ ret = nxt_regex_compile(regex, source, 0, options, vm->regex_context); if (nxt_fast_path(ret == NXT_OK)) { return regex->ncaptures; } if (vm->parser != NULL) { size = snprintf((char *) buf, NJS_EXCEPTION_BUF_LENGTH, "SyntaxError: %s in %u", vm->regex_context->error, vm->parser->lexer->line); } else { size = snprintf((char *) buf, NJS_EXCEPTION_BUF_LENGTH, "SyntaxError: %s", vm->regex_context->error); } return njs_vm_throw_exception(vm, buf, size); }
static u_char * njs_regexp_compile_trace_handler(nxt_trace_t *trace, nxt_trace_data_t *td, u_char *start) { int n; u_char *p; ssize_t size; njs_vm_t *vm; size = sizeof("SyntaxError: ") - 1; memcpy(start, "SyntaxError: ", size); p = start + size; vm = trace->data; trace = trace->next; p = trace->handler(trace, td, p); if (vm->parser != NULL) { size = td->end - start; n = snprintf((char *) p, size, " in %u", vm->parser->lexer->line); if (n < size) { p += n; } } njs_vm_throw_exception(vm, start, p - start); return p; }
njs_ret_t njs_regexp_match_error(njs_vm_t *vm) { uint32_t size; u_char buf[NJS_EXCEPTION_BUF_LENGTH]; size = snprintf((char *) buf, NJS_EXCEPTION_BUF_LENGTH, "RegExpError: %s", vm->regex_context->error); return njs_vm_throw_exception(vm, buf, size); }
static u_char * njs_regexp_match_trace_handler(nxt_trace_t *trace, nxt_trace_data_t *td, u_char *start) { u_char *p; size_t size; njs_vm_t *vm; size = sizeof("RegExpError: ") - 1; memcpy(start, "RegExpError: ", size); p = start + size; vm = trace->data; trace = trace->next; p = trace->handler(trace, td, p); njs_vm_throw_exception(vm, start, p - start); return p; }