fix several bugs

This commit is contained in:
leitner
2004-03-12 23:21:24 +00:00
parent 7bf8213396
commit 989695af67
7 changed files with 54 additions and 11 deletions

View File

@@ -39,6 +39,9 @@ ifneq ($(DEBUG),)
DIET=/opt/diet/bin/diet
CFLAGS=-pipe -I. -Wall -W -g
endif
ifneq ($(DIET),)
LIBS+=-llatin1
endif
%.o: %.c
$(DIET) $(CC) $(CFLAGS) -c $<

View File

@@ -60,11 +60,23 @@ int main(int argc,char* argv[]) {
x+=8;
buffer_puts(buffer_1,"dn:");
uint32_unpack(x,&k);
buffer_flush(buffer_1);
dumpbstr(map+k);
buffer_flush(buffer_1);
buffer_puts(buffer_1,"\nobjectClass:");
buffer_flush(buffer_1);
x+=4;
uint32_unpack(x,&k);
dumpbstr(map+k);
buffer_flush(buffer_1);
// buffer_puts(buffer_1,map+k);
buffer_puts(buffer_1,"\n");
x+=4;
@@ -79,6 +91,7 @@ int main(int argc,char* argv[]) {
x+=8;
}
buffer_puts(buffer_1,"\n");
buffer_flush(buffer_1);
}
}
buffer_flush(buffer_1);

View File

@@ -37,7 +37,7 @@ static void addattribute(struct ldaprec** l,long name,long val) {
++(*l)->n;
} else {
buffer_puts(buffer_2,"LDIF parse error: too many attributes!:\n ");
buffer_puts(buffer_2,attributes.strings.root+name);
buffer_puts(buffer_2,attributes.Strings->root+name);
buffer_puts(buffer_2,"\nat dn\n ");
buffer_puts(buffer_2,(*l)->dn+stringtable.root);
buffer_putnlflush(buffer_2);
@@ -153,7 +153,7 @@ lookagain:
#if 0
buffer_puts(buffer_2,"feld \"");
buffer_puts(buffer_2,attributes.strings.root+tmp);
buffer_puts(buffer_2,attributes.Strings->root+tmp);
buffer_puts(buffer_2,"\", wert \"");
buffer_put(buffer_2,payload.s,len);
buffer_putsflush(buffer_2,"\".\n");
@@ -208,7 +208,7 @@ lookagain:
#if 0
buffer_puts(buffer_2,"feld \"");
buffer_puts(buffer_2,attributes.strings.root+tmp);
buffer_puts(buffer_2,attributes.Strings->root+tmp);
buffer_puts(buffer_2,"\", wert \"");
buffer_put(buffer_2,payload.s,len);
buffer_putsflush(buffer_2,"\".\n");

View File

@@ -1,4 +1,5 @@
#include <string.h>
#include "bstr.h"
#include "case.h"
#include "ldif.h"
@@ -6,14 +7,16 @@
int matchcasestring(struct string* s,const char* c) {
unsigned int l,l1,i;
if (!c) return -1;
l1=l=strlen(c);
l1=l=bstrlen(c);
if (s->l<l1) l1=s->l;
c=bstrfirst(c);
i=case_diffb(s->s,l1,c);
if (i) return i;
/* one is a prefix of the other */
/* same length? */
if (l==s->l) return 0;
if (c[l1]) /* is c the longer string? */
/* one is a prefix of the other */
if (l1<l) /* we cut off c */
return c[l1];
return -(int)(s->s[l1]);
return (int)(s->s[l1]);
}

View File

@@ -11,10 +11,11 @@ int matchstring(struct string* s,const char* c) {
c=bstrfirst(c);
i=byte_diff(s->s,l1,c);
if (i) return i;
/* one is a prefix of the other */
/* same length? */
if (l==s->l) return 0;
if (c[l1]) /* is c the longer string? */
/* one is a prefix of the other */
if (l1<l) /* we cut off c */
return c[l1];
return -(int)(s->s[l1]);
return (int)(s->s[l1]);
}

View File

@@ -11,8 +11,10 @@ long mstorage_add_bin(mstorage_t* p,const char* s,unsigned long n) {
static char zero;
long x;
char intbuf[4];
if (n==0) goto encodebinary;
for (i=0; i<n-1; ++i)
if (!s[i]) {
encodebinary:
x=mstorage_add(p,&zero,1);
uint32_pack(intbuf,n);
mstorage_add(p,intbuf,4);
@@ -20,6 +22,7 @@ long mstorage_add_bin(mstorage_t* p,const char* s,unsigned long n) {
return x;
}
x=mstorage_add(p,s,n);
mstorage_add(p,&zero,1);
if (s[n-1])
mstorage_add(p,&zero,1);
return x;
}

View File

@@ -288,10 +288,24 @@ static void tagmatches(uint32* index,unsigned int elements,struct string* s,
int l;
k=uint32_read(&index[mid]);
#ifdef DEBUG
buffer_puts(buffer_2,"match[");
buffer_putulong(buffer_2,bottom);
buffer_puts(buffer_2,"..");
buffer_putulong(buffer_2,top);
buffer_puts(buffer_2,"]: ");
buffer_put(buffer_2,s->s,s->l);
buffer_puts(buffer_2," <-> ");
buffer_puts(buffer_2,map+k);
buffer_putsflush(buffer_2,": ");
#endif
if ((l=match(s,map+k))==0) {
/* match! */
long rec;
uint32 m;
#ifdef DEBUG
buffer_putsflush(buffer_2,"MATCH!\n");
#endif
if ((rec=findrec(k))>=0)
setbit(bitfield,rec);
/* there may be multiple matches.
@@ -314,11 +328,17 @@ static void tagmatches(uint32* index,unsigned int elements,struct string* s,
}
if (l<0) {
#ifdef DEBUG
buffer_putsflush(buffer_2,"smaller!\n");
#endif
if (mid)
top=mid-1;
else
break; /* since our offsets are unsigned, we need to avoid the -1 case */
} else
#ifdef DEBUG
buffer_putsflush(buffer_2,"larger!\n"),
#endif
bottom=mid+1;
}
}