From 12fbaf7c9c8ff939a62443c09cf1da31a0d2f0ab Mon Sep 17 00:00:00 2001 From: leitner Date: Sat, 11 May 2002 15:19:56 +0000 Subject: [PATCH] make buffer_get_token write \0 to buffer on end of file so it can be distinguished from a length 0 token. --- CHANGES | 1 + buffer.h | 5 +++++ buffer/buffer_get_token.c | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 3b016f2..9882d5b 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,5 @@ 0.13: + fixed several bugs in test/uudecode.c 0.12: add textcode api for uuencode/uudecode, base64, quoted printable, diff --git a/buffer.h b/buffer.h index bf00102..8d3d26a 100644 --- a/buffer.h +++ b/buffer.h @@ -38,6 +38,11 @@ extern int buffer_bget(buffer* b,char* x,unsigned int len); extern int buffer_feed(buffer* b); extern int buffer_getc(buffer* b,char* x); extern int buffer_getn(buffer* b,char* x,unsigned int len); + +/* read bytes until the destination buffer is full (len bytes), end of + * file is reached or the read char is in charset (setlen bytes). An + * empty line when looking for \n will write '\n' to x and return 0. If + * EOF is reached, \0 is written to the buffer */ extern int buffer_get_token(buffer* b,char* x,unsigned int len,const char* charset,unsigned int setlen); #define buffer_getline(b,x,len) buffer_get_token((b),(x),(len),"\n",1) diff --git a/buffer/buffer_get_token.c b/buffer/buffer_get_token.c index f58e496..e49ff2e 100644 --- a/buffer/buffer_get_token.c +++ b/buffer/buffer_get_token.c @@ -8,7 +8,7 @@ int buffer_get_token(buffer* b,char* x,unsigned int len,const char* charset,unsi for (blen=0;blen