Merge branch 'slugfix' of github.com:c9s/r3 into slugfix
This commit is contained in:
commit
fcc00deadb
4 changed files with 27 additions and 24 deletions
13
configure.ac
13
configure.ac
|
@ -1,5 +1,6 @@
|
||||||
AC_INIT([r3], 1.0.0)
|
AC_INIT([r3], 1.0.0)
|
||||||
AC_PREREQ([2.64])
|
AC_PREREQ([2.64])
|
||||||
|
AC_USE_SYSTEM_EXTENSIONS
|
||||||
AC_CONFIG_HEADERS(config.h)
|
AC_CONFIG_HEADERS(config.h)
|
||||||
AC_CONFIG_MACRO_DIR([m4])
|
AC_CONFIG_MACRO_DIR([m4])
|
||||||
AM_INIT_AUTOMAKE([foreign subdir-objects])
|
AM_INIT_AUTOMAKE([foreign subdir-objects])
|
||||||
|
@ -18,9 +19,6 @@ AC_TYPE_SIZE_T
|
||||||
AC_FUNC_MALLOC
|
AC_FUNC_MALLOC
|
||||||
AC_FUNC_REALLOC
|
AC_FUNC_REALLOC
|
||||||
AC_CHECK_FUNCS([gettimeofday memset strchr strdup strndup strstr])
|
AC_CHECK_FUNCS([gettimeofday memset strchr strdup strndup strstr])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PKG_PROG_PKG_CONFIG
|
PKG_PROG_PKG_CONFIG
|
||||||
|
|
||||||
|
|
||||||
|
@ -100,8 +98,13 @@ AM_CONDITIONAL(ENABLE_JSON, test "x$enable_json" = "xyes")
|
||||||
|
|
||||||
# This does not work because configure does not look into /opt/local/include...
|
# This does not work because configure does not look into /opt/local/include...
|
||||||
# AC_CHECK_HEADERS([check.h],[ enable_check=yes ],[ enable_check=unset ])
|
# AC_CHECK_HEADERS([check.h],[ enable_check=yes ],[ enable_check=unset ])
|
||||||
AC_ARG_ENABLE(check, AS_HELP_STRING([--enable-check], [enable unit testing]))
|
|
||||||
if test "$enable_check" = "xyes"; then
|
|
||||||
|
AC_ARG_ENABLE(check,
|
||||||
|
AS_HELP_STRING([--enable-check],
|
||||||
|
[enable unit testing]),
|
||||||
|
, enable_check=unset)
|
||||||
|
if test "x$enable_check" != "xunset" ; then
|
||||||
PKG_CHECK_MODULES(CHECK,[check >= 0.9.4],:,[
|
PKG_CHECK_MODULES(CHECK,[check >= 0.9.4],:,[
|
||||||
ifdef([AM_PATH_CHECK],
|
ifdef([AM_PATH_CHECK],
|
||||||
[AM_PATH_CHECK(,[have_check="yes"])],
|
[AM_PATH_CHECK(,[have_check="yes"])],
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
*
|
*
|
||||||
* Distributed under terms of the MIT license.
|
* Distributed under terms of the MIT license.
|
||||||
*/
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -19,6 +20,8 @@ inline int contains_slug_char(const char * str) {
|
||||||
|
|
||||||
r3_slug_t * r3_slug_new(char * path, int path_len) {
|
r3_slug_t * r3_slug_new(char * path, int path_len) {
|
||||||
r3_slug_t * s = zmalloc(sizeof(r3_slug_t));
|
r3_slug_t * s = zmalloc(sizeof(r3_slug_t));
|
||||||
|
if (!s)
|
||||||
|
return NULL;
|
||||||
s->path = path;
|
s->path = path;
|
||||||
s->path_len = path_len;
|
s->path_len = path_len;
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,7 @@
|
||||||
# INCLUDES = @CHECK_CFLAGS@
|
|
||||||
# if HAVE_CHECK
|
|
||||||
# TESTS = check_tree
|
|
||||||
# else
|
|
||||||
# TESTS =
|
|
||||||
# endif
|
|
||||||
TESTS =
|
TESTS =
|
||||||
|
|
||||||
AM_CFLAGS=$(DEPS_CFLAGS) $(GVC_DEPS_CFLAGS) $(JSONC_CFLAGS) -I$(top_builddir) -I$(top_builddir)/include -I$(top_builddir)/src -I$(top_builddir)/3rdparty -Wall -std=c99 -ggdb -Wall
|
AM_CFLAGS=$(DEPS_CFLAGS) $(GVC_DEPS_CFLAGS) $(JSONC_CFLAGS) @CHECK_CFLAGS@ -I$(top_builddir) -I$(top_builddir)/include -I$(top_builddir)/src -I$(top_builddir)/3rdparty -Wall -std=c99 -ggdb -Wall
|
||||||
AM_LDFLAGS=$(DEPS_LIBS) $(GVC_DEPS_LIBS) $(JSONC_LIBS) -L$(top_builddir) -lcheck @CHECK_LIBS@ $(top_builddir)/libr3.la
|
AM_LDFLAGS=$(DEPS_LIBS) $(GVC_DEPS_LIBS) $(JSONC_LIBS) @CHECK_LIBS@ $(top_builddir)/libr3.la
|
||||||
|
|
||||||
if USE_JEMALLOC
|
if USE_JEMALLOC
|
||||||
AM_CFLAGS += -ljemalloc
|
AM_CFLAGS += -ljemalloc
|
||||||
|
@ -24,7 +18,6 @@ dist_noinst_DATA = \
|
||||||
TESTS += check_slug
|
TESTS += check_slug
|
||||||
check_slug_SOURCES = check_slug.c
|
check_slug_SOURCES = check_slug.c
|
||||||
|
|
||||||
|
|
||||||
TESTS += check_tree
|
TESTS += check_tree
|
||||||
check_tree_SOURCES = check_tree.c
|
check_tree_SOURCES = check_tree.c
|
||||||
|
|
||||||
|
|
|
@ -100,11 +100,13 @@ START_TEST (test_slug_parse_with_pattern)
|
||||||
{
|
{
|
||||||
char * pattern = "/user/{name:\\d{3}}";
|
char * pattern = "/user/{name:\\d{3}}";
|
||||||
char * errstr = NULL;
|
char * errstr = NULL;
|
||||||
r3_slug_t *s = r3_slug_parse(pattern, strlen(pattern), pattern, &errstr);
|
const r3_slug_t *s = r3_slug_parse(pattern, strlen(pattern), pattern, &errstr);
|
||||||
|
ck_assert(s);
|
||||||
|
|
||||||
char * out = r3_slug_to_str(s);
|
char * out = r3_slug_to_str(s);
|
||||||
|
ck_assert(out);
|
||||||
printf("%s\n",out);
|
printf("%s\n",out);
|
||||||
zfree(out);
|
free(out);
|
||||||
|
|
||||||
r3_slug_free(s);
|
r3_slug_free(s);
|
||||||
}
|
}
|
||||||
|
@ -115,11 +117,13 @@ START_TEST (test_slug_parse_without_pattern)
|
||||||
{
|
{
|
||||||
char * pattern = "/user/{name}";
|
char * pattern = "/user/{name}";
|
||||||
char * errstr = NULL;
|
char * errstr = NULL;
|
||||||
r3_slug_t *s = r3_slug_parse(pattern, strlen(pattern), pattern, &errstr);
|
const r3_slug_t *s = r3_slug_parse(pattern, strlen(pattern), pattern, &errstr);
|
||||||
|
ck_assert(s);
|
||||||
|
|
||||||
char * out = r3_slug_to_str(s);
|
char * out = r3_slug_to_str(s);
|
||||||
|
ck_assert(out);
|
||||||
printf("%s\n",out);
|
printf("%s\n",out);
|
||||||
zfree(out);
|
free(out);
|
||||||
|
|
||||||
r3_slug_free(s);
|
r3_slug_free(s);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue