summaryrefslogtreecommitdiff
path: root/main/snprintf.c
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2007-02-24 18:20:46 +0000
committerMarcus Boerger <helly@php.net>2007-02-24 18:20:46 +0000
commit1345740fa5fbfce210d0c68d1f032b26d6973236 (patch)
treec673e0fccb6bd014a4bab580fa483101433c6634 /main/snprintf.c
parent3588f9eed61804ab475ae2ed5c4160d92590e771 (diff)
downloadphp-git-1345740fa5fbfce210d0c68d1f032b26d6973236.tar.gz
- Add [v]slprintf to overcome the returnvalues issue of snprintf
Diffstat (limited to 'main/snprintf.c')
-rw-r--r--main/snprintf.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/main/snprintf.c b/main/snprintf.c
index d0376a6ce5..8cbd88b112 100644
--- a/main/snprintf.c
+++ b/main/snprintf.c
@@ -1161,6 +1161,34 @@ static void strx_printv(int *ccp, char *buf, size_t len, const char *format,
}
+PHPAPI int ap_php_slprintf(char *buf, size_t len, const char *format,...)
+{
+ int cc;
+ va_list ap;
+
+ va_start(ap, format);
+ strx_printv(&cc, buf, len, format, ap);
+ va_end(ap);
+ if (cc >= len) {
+ cc = len -1;
+ buf[cc] = '\0';
+ }
+ return cc;
+}
+
+
+PHPAPI int ap_php_vslprintf(char *buf, size_t len, const char *format, va_list ap)
+{
+ int cc;
+
+ strx_printv(&cc, buf, len, format, ap);
+ if (cc >= len) {
+ cc = len -1;
+ buf[cc] = '\0';
+ }
+ return cc;
+}
+
PHPAPI int ap_php_snprintf(char *buf, size_t len, const char *format,...)
{
int cc;