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 b1396504b3
7 changed files with 69 additions and 46 deletions

View file

@ -1,17 +1,18 @@
.PHONY: doc
.PHONY: test
.PHONY: lib
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"
glibc:
make -C src glibc
lib:
${MAKE} -C src lib
diet:
make -C src diet
${MAKE} -C src diet
test:
make -C test
${MAKE} -C test
doc:
doxygen

View file

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

View file

@ -38,7 +38,7 @@ int psyc_inherits(char* sho, size_t slen,
}
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;
}
@ -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"))
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;
le = lon+llen;
sho++; lon++; slen--; llen--;
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;
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) {
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;
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;
P4(("# failed\n"))
llen -= l-lon + 1;
@ -88,7 +88,7 @@ int psyc_matches(char* sho, size_t slen,
}
goto failed;
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;
slen -= s-sho;
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 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
// 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
case PSYC_PART_ROUTING:
pos = state->cursor;
if (state->routingLength > 0)
{
if (state->buffer.ptr[state->cursor] != '\n')

View file

@ -1,2 +1,9 @@
/* 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
LDFLAGS=-L../lib
LOADLIBES=-lpsyc -lm
TARGETS=testServer testParser testMatch testRender isRoutingVar getVarType
PORT=4440
OPT = -O2
DEBUG = 2
CFLAGS = -I../include -Wall ${OPT}
LDFLAGS = -L../lib
LOADLIBES = -lpsyc -lm
TARGETS = testServer testParser testMatch testRender isRoutingVar getVarType
WRAPPER =
DIET = diet
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
./testMatch
./isRoutingVar
./getVarType
test: $(TARGETS)
for f in packets/full-* packets/error-*; do echo ">> $$f"; ./testParser $$f; done
for f in packets/full-*; do echo ">> $$f"; ./testParser $$f; done
netstart:
./testServer $(PORT)
./testServer ${PORT}
netstartv:
./testServer $(PORT) -v
./testServer ${PORT} -v
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:
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:
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:
(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:
(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:
rm -f $(TARGETS)
rm -f ${TARGETS}
it: all

View file

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