let slug_count returns -1 if error occurs
This commit is contained in:
parent
2774221ab7
commit
7cc84867ce
3 changed files with 4 additions and 8 deletions
|
@ -571,13 +571,8 @@ node * r3_tree_insert_pathl_ex(node *tree, const char *path, int path_len, route
|
|||
// common prefix not found, insert a new edge for this pattern
|
||||
if ( prefix_len == 0 ) {
|
||||
// there are two more slugs, we should break them into several parts
|
||||
char *err = NULL;
|
||||
int slug_cnt = slug_count(path, path_len, &err);
|
||||
if (err) {
|
||||
if(errstr) {
|
||||
*errstr = err;
|
||||
}
|
||||
free(err);
|
||||
int slug_cnt = slug_count(path, path_len, errstr);
|
||||
if (slug_cnt == -1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -172,7 +172,7 @@ int slug_count(const char * needle, int len, char **errstr) {
|
|||
if (errstr) {
|
||||
asprintf(errstr, "Incomplete slug pattern. PATTERN (%d): '%s', OFFSET: %ld, STATE: %d", len, needle, p - needle, state);
|
||||
}
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <assert.h>
|
||||
#include "r3.h"
|
||||
#include "r3_str.h"
|
||||
#include "slug.h"
|
||||
#include "zmalloc.h"
|
||||
|
||||
int r3_pattern_to_opcode(const char * pattern, int len) {
|
||||
|
|
Loading…
Reference in a new issue