projects
/
yaz-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added wrbuf_cut_right which cuts WRBUF by a number of characters (chop
[yaz-moved-to-github.git]
/
src
/
wrbuf.c
diff --git
a/src/wrbuf.c
b/src/wrbuf.c
index
fb5968b
..
973f080
100644
(file)
--- a/
src/wrbuf.c
+++ b/
src/wrbuf.c
@@
-2,7
+2,7
@@
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: wrbuf.c,v 1.15 2007-01-06 16:05:24 adam Exp $
+ * $Id: wrbuf.c,v 1.17 2007-03-18 12:59:56 adam Exp $
*/
/**
*/
/**
@@
-20,6
+20,7
@@
#include <stdarg.h>
#include <yaz/wrbuf.h>
#include <stdarg.h>
#include <yaz/wrbuf.h>
+#include <yaz/snprintf.h>
#include <yaz/yaz-iconv.h>
WRBUF wrbuf_alloc(void)
#include <yaz/yaz-iconv.h>
WRBUF wrbuf_alloc(void)
@@
-159,16
+160,7
@@
void wrbuf_printf(WRBUF b, const char *fmt, ...)
char buf[4096];
va_start(ap, fmt);
char buf[4096];
va_start(ap, fmt);
-#ifdef WIN32
- _vsnprintf(buf, sizeof(buf)-1, fmt, ap);
-#else
-/* !WIN32 */
-#if HAVE_VSNPRINTF
- vsnprintf(buf, sizeof(buf)-1, fmt, ap);
-#else
- vsprintf(buf, fmt, ap);
-#endif
-#endif
+ yaz_vsnprintf(buf, sizeof(buf)-1, fmt, ap);
wrbuf_puts (b, buf);
va_end(ap);
wrbuf_puts (b, buf);
va_end(ap);
@@
-239,6
+231,13
@@
const char *wrbuf_cstr(WRBUF b)
return b->buf;
}
return b->buf;
}
+void wrbuf_cut_right(WRBUF b, size_t no_to_remove)
+{
+ if (no_to_remove > b->pos)
+ no_to_remove = b->pos;
+ b->pos = b->pos - no_to_remove;
+}
+
/*
* Local variables:
* c-basic-offset: 4
/*
* Local variables:
* c-basic-offset: 4