1
0
Fork 0
mirror of git://git.psyc.eu/libpsyc synced 2024-08-15 03:19:02 +00:00

Merge branch 'master' of supraverse.net:libpsyc

This commit is contained in:
Marenz 2011-04-30 15:49:09 +02:00
commit 007aca1a6d
7 changed files with 69 additions and 46 deletions

View file

@ -1,17 +1,18 @@
.PHONY: doc .PHONY: doc
.PHONY: test .PHONY: test
.PHONY: lib
default: default:
@/bin/echo -e "Usage:\n\tmake diet - compile with diet libc\n\tmake glibc - compile with normal gnu libc\n\tmake test\n\tmake doc" @/bin/echo -e "Usage:\n\tmake diet - compile with diet libc\n\tmake glibc - compile with normal gnu libc\n\tmake test\n\tmake doc"
glibc: lib:
make -C src glibc ${MAKE} -C src lib
diet: diet:
make -C src diet ${MAKE} -C src diet
test: test:
make -C test ${MAKE} -C test
doc: doc:
doxygen doxygen

View file

@ -1,24 +1,28 @@
CFLAGS=-I../include -DDEBUG=2 -DPSYC_COMPILE_LIBRARY -g -O0 -Wall OPT = -O2
CC=cc DEBUG = 2
# CC=clang CFLAGS = -I../include -Wall ${OPT}
DIET = diet
test -z "$DIET" || DIET=diet WRAPPER =
S = packet.c misc.c parser.c match.c render.c memmem.c itoa.c variable.c S = packet.c misc.c parser.c match.c render.c memmem.c itoa.c variable.c
O = packet.o misc.o parser.o match.o render.o memmem.o itoa.o variable.o O = packet.o misc.o parser.o match.o render.o memmem.o itoa.o variable.o
default: all: lib
help:
@/bin/echo -e "Usage:\n\tmake diet - compile with diet libc\n\tmake lib - compile with normal gnu libc" @/bin/echo -e "Usage:\n\tmake diet - compile with diet libc\n\tmake lib - compile with normal gnu libc"
diet: debug: CFLAGS += -DDEBUG=${DEBUG} -g
${DIET} ${CC} -static -c -Os $S ${CFLAGS} debug: CFLAGS := $(subst ${OPT},-O0,${CFLAGS})
@test -d ../lib || mkdir ../lib debug: lib
${DIET} ar rcs ../lib/libpsyc.a $O
glibc: $S diet: WRAPPER = ${DIET}
${CC} -static -c -g -O0 $S -lc ${CFLAGS} diet: lib
@test -d ../lib || mkdir ../lib
ar rcs ../lib/libpsyc.a $O lib: CC := ${WRAPPER} ${CC}
lib: $O
@mkdir -p ../lib
${WRAPPER} ar rcs ../lib/libpsyc.a $O
match: match.c match: match.c
${CC} -o $@ -DDEBUG=4 -DCMDTOOL -DTEST $< ${CC} -o $@ -DDEBUG=4 -DCMDTOOL -DTEST $<

View file

@ -38,7 +38,7 @@ int psyc_inherits(char* sho, size_t slen,
} }
return 0; return 0;
} }
P4(("%*s does not inherit from %*s.\n", llen, lon, slen, sho)) P4(("%.*s does not inherit from %.*s.\n", (int)llen, lon, (int)slen, sho))
return 1; return 1;
} }
@ -68,19 +68,19 @@ int psyc_matches(char* sho, size_t slen,
P1(("Same length but different.\nNo match, but they could be related or have a common type.\n")) P1(("Same length but different.\nNo match, but they could be related or have a common type.\n"))
return -4; return -4;
} }
P3(("# psyc_matches short '%*s' in long '%*s' ?\n", slen, sho, llen, lon)) P3(("# psyc_matches short '%.*s' in long '%.*s' ?\n", (int)slen, sho, (int)llen, lon))
se = sho+slen; se = sho+slen;
le = lon+llen; le = lon+llen;
sho++; lon++; slen--; llen--; sho++; lon++; slen--; llen--;
while(*sho && sho < se) { while(*sho && sho < se) {
P3(("# comparing short '%*s' (%d)\n", slen, sho, slen)) P3(("# comparing short '%.*s' (%d)\n", (int)slen, sho, (int)slen))
unless (s = memchr(sho, '_', slen)) s = se; unless (s = memchr(sho, '_', slen)) s = se;
P4(("# sho goes '%c' and lon goes '%c'\n", *sho, *lon)) P4(("# sho goes '%c' and lon goes '%c'\n", *sho, (int)*lon))
while(*lon && lon < le) { while(*lon && lon < le) {
P3(("# against long '%*s' (%d)\n", llen, lon, llen)) P3(("# against long '%.*s' (%d)\n", (int)llen, lon, (int)llen))
unless (l = memchr(lon, '_', llen)) l = le; unless (l = memchr(lon, '_', llen)) l = le;
P3(("# %d == %d && !strncmp '%*s', '%*s'\n", s-sho, l-lon, s-sho, sho, s-sho, lon)) P3(("# %ld == %ld && !strncmp '%.*s', '%.*s'\n", s-sho, l-lon, (int)(s-sho), sho, (int)(s-sho), lon))
if (l-lon == s-sho && !strncmp(sho, lon, s-sho)) goto foundone; if (l-lon == s-sho && !strncmp(sho, lon, s-sho)) goto foundone;
P4(("# failed\n")) P4(("# failed\n"))
llen -= l-lon + 1; llen -= l-lon + 1;
@ -88,7 +88,7 @@ int psyc_matches(char* sho, size_t slen,
} }
goto failed; goto failed;
foundone: foundone:
P3(("# found %d of short '%*s' and long '%*s'\n", s-sho, s-sho, sho, s-sho, lon)) P3(("# found %ld of short '%.*s' and long '%.*s'\n", s-sho, (int)(s-sho), sho, (int)(s-sho), lon))
llen -= l-lon; llen -= l-lon;
slen -= s-sho; slen -= s-sho;
sho = ++s; sho = ++s;

View file

@ -235,7 +235,7 @@ inline psycParseRC psyc_parseModifier(psycParseState* state, char* oper, psycStr
psycParseRC psyc_parse(psycParseState* state, char* oper, psycString* name, psycString* value) psycParseRC psyc_parse(psycParseState* state, char* oper, psycString* name, psycString* value)
{ {
psycParseRC ret; // a return value psycParseRC ret; // a return value
size_t pos; // a cursor position size_t pos = state->cursor; // a cursor position
// Start position of the current line in the buffer // Start position of the current line in the buffer
// in case we return insufficent, we rewind to this position. // in case we return insufficent, we rewind to this position.
@ -258,7 +258,6 @@ psycParseRC psyc_parse(psycParseState* state, char* oper, psycString* name, psyc
// fall thru // fall thru
case PSYC_PART_ROUTING: case PSYC_PART_ROUTING:
pos = state->cursor;
if (state->routingLength > 0) if (state->routingLength > 0)
{ {
if (state->buffer.ptr[state->cursor] != '\n') if (state->buffer.ptr[state->cursor] != '\n')

View file

@ -1,2 +1,9 @@
/* psyc_text() */ /* psyc_text() */
int psyc_text(char *template, size_t tlen,
char **buffer, size_t *blen,
psyctextCB lookupValue,
char *braceOpen, char *braceClose)
{
}

View file

@ -1,40 +1,51 @@
CFLAGS=-I../include -DDEBUG -g -O0 -Wall OPT = -O2
DEBUG = 2
CFLAGS = -I../include -Wall ${OPT}
LDFLAGS = -L../lib LDFLAGS = -L../lib
LOADLIBES = -lpsyc -lm LOADLIBES = -lpsyc -lm
TARGETS = testServer testParser testMatch testRender isRoutingVar getVarType TARGETS = testServer testParser testMatch testRender isRoutingVar getVarType
WRAPPER =
DIET = diet
PORT = 4440 PORT = 4440
all: $(TARGETS) all: test
diet: WRAPPER = ${DIET}
diet: all
debug: CFLAGS += -DDEBUG=${DEBUG} -g
debug: CFLAGS := $(subst ${OPT},-O0,${CFLAGS})
debug: all
test: ${TARGETS}
./testRender ./testRender
./testMatch ./testMatch
./isRoutingVar ./isRoutingVar
./getVarType ./getVarType
for f in packets/full-*; do echo ">> $$f"; ./testParser $$f; done
test: $(TARGETS)
for f in packets/full-* packets/error-*; do echo ">> $$f"; ./testParser $$f; done
netstart: netstart:
./testServer $(PORT) ./testServer ${PORT}
netstartv: netstartv:
./testServer $(PORT) -v ./testServer ${PORT} -v
nettest: nettest:
for f in packets/full-*; do echo ">> $$f"; cat $$f | nc localhost $(PORT) | diff -u $$f -; done for f in packets/full-*; do echo ">> $$f"; cat $$f | nc localhost ${PORT} | diff -u $$f -; done
nettesterr: nettesterr:
for f in packets/error-*; do echo ">> $$f"; cat $$f | nc localhost $(PORT); done for f in packets/error-*; do echo ">> $$f"; cat $$f | nc localhost ${PORT}; done
splittest: splittest:
for f in packets/full-*; do echo ">> $$f"; ./splittest.pl $$f $(PORT) | diff -u $$f -; done for f in packets/full-*; do echo ">> $$f"; ./splittest.pl $$f ${PORT} | diff -u $$f -; done
nettestp1: nettestp1:
(for f in packets/part-1-p*; do cat $$f; done) | nc localhost $(PORT) | diff -u packets/full-1 - (for f in packets/part-1-p*; do cat $$f; done) | nc localhost ${PORT} | diff -u packets/full-1 -
nettestp2: nettestp2:
(for f in packets/part-1-length-p*; do cat $$f; done) | nc localhost $(PORT) | diff -u packets/full-1-length - (for f in packets/part-1-length-p*; do cat $$f; done) | nc localhost ${PORT} | diff -u packets/full-1-length -
clean: clean:
rm -f $(TARGETS) rm -f ${TARGETS}
it: all it: all

View file

@ -15,8 +15,9 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#include <netdb.h> #include <netdb.h>
#include <math.h> #include <math.h>
#include <assert.h>
#include <psyc/lib.h> #include <psyc.h>
#include <psyc/parser.h> #include <psyc/parser.h>
#include <psyc/render.h> #include <psyc/render.h>
#include <psyc/syntax.h> #include <psyc/syntax.h>