diff --git a/include/lib/buf.h b/include/lib/buf.h
index 72536b2..8255d2b 100644
--- a/include/lib/buf.h
+++ b/include/lib/buf.h
@@ -167,8 +167,8 @@ size_t vbprintf(Buffer_t *, const char *, va_list);
error_t bgetc(Buffer_t *, uchar *);
size_t bread(Buffer_t *, uchar *, size_t);
-size_t bscanf(Buffer_t *, size_t *, const char *, ...);
-size_t vbscanf(Buffer_t *, size_t *, const char *, va_list);
+size_t bscanf(Buffer_t *, const char *, ...);
+size_t vbscanf(Buffer_t *, const char *, va_list);
error_t bemptybuf(Buffer_t *);
error_t bscrolldown(Buffer_t *);
diff --git a/kaleid/libbuf/bscan.c b/kaleid/libbuf/bscan.c
index cb31ee8..f7b5c25 100644
--- a/kaleid/libbuf/bscan.c
+++ b/kaleid/libbuf/bscan.c
@@ -21,7 +21,7 @@
// You should have received a copy of the GNU General Public License //
// along with OS/K. If not, see . //
//----------------------------------------------------------------------------//
-#if 0
+
#include
//
@@ -43,7 +43,7 @@ size_t BScanFromBuf(Buffer_t *buf, const char *fmt, ...)
size_t BScanFromBufV(Buffer_t *buf, const char *fmt, va_list ap)
{
- size_t rc;
+ size_t sz;
ExAcquireLock(&buf->lock);
sz = vbscanf(buf, fmt, ap);
@@ -70,13 +70,14 @@ size_t vbscanf(Buffer_t *buf, const char *fmt, va_list ap)
size_t readcnt = 0;
uchar ch = 0;
+ char *chptr;
bool l, h;
size_t width;
bool ignore; // '*' modifier, don't write to va_list for current mod
- if (!buf || !fmt) { seterrnp(EINVAL); return 0; }
+ if (!buf || !fmt) { seterrno(EINVAL); return 0; }
if (buf->flags & (BF_EOF|BF_ERR)) { seterrno(EENDF); return 0; }
if (buf->state != BS_RDWR && buf->state != BS_WRONLY) {
seterrno(EBADF);
@@ -84,7 +85,7 @@ size_t vbscanf(Buffer_t *buf, const char *fmt, va_list ap)
}
// Progress in format string
- for (*fmt && !rc) {
+ while (*fmt && !rc) {
// Skip all kinds of whitespaces
if (isspace(*fmt)) {
@@ -154,8 +155,6 @@ size_t vbscanf(Buffer_t *buf, const char *fmt, va_list ap)
fmt++;
}
- assert(!(width < 0));
-
//
// Extract length field
//
@@ -167,7 +166,7 @@ size_t vbscanf(Buffer_t *buf, const char *fmt, va_list ap)
else if (*fmt == 'h') {
h = 1;
- fmt++
+ fmt++;
}
//
@@ -183,16 +182,17 @@ size_t vbscanf(Buffer_t *buf, const char *fmt, va_list ap)
for (; width; width--) {
rc = bgetc(buf, &ch);
if (!rc) break;
+ if (ignore) continue;
- char *chptr = va_arg(ap, char *);
- *chptr = (char)ch;
- readcnt++;
+ chptr = va_arg(ap, char *);
+ *chptr = (char)ch;
+ readcnt++;
}
}
// Decimal integer
else if (*fmt == 'd') {
-
+ ;
}
}
@@ -205,10 +205,6 @@ size_t vbscanf(Buffer_t *buf, const char *fmt, va_list ap)
-#endif
-
-
-