The Samba-Bugzilla – Attachment 2076 Details for
Bug 3986
Let snprintf support C99 z modifier
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Prelimary patch
snprintf-z.diff (text/plain), 2.43 KB, created by
Heinrich Schmidt
on 2006-08-02 07:31:00 UTC
(
hide
)
Description:
Prelimary patch
Filename:
MIME Type:
Creator:
Heinrich Schmidt
Created:
2006-08-02 07:31:00 UTC
Size:
2.43 KB
patch
obsolete
>Index: snprintf.c >=================================================================== >--- snprintf.c (revision 17375) >+++ snprintf.c (working copy) >@@ -197,6 +197,7 @@ > #define DP_C_LONG 3 > #define DP_C_LDOUBLE 4 > #define DP_C_LLONG 5 >+#define DP_C_SIZET 6 > > /* Chunk types */ > #define CNK_FMT_STR 0 >@@ -467,6 +468,10 @@ > cnk->cflags = DP_C_LDOUBLE; > ch = *format++; > break; >+ case 'z': >+ cnk->cflags = DP_C_SIZET; >+ ch = *format++; >+ break; > default: > break; > } >@@ -575,6 +580,8 @@ > cnk->value = va_arg (args, long int); > else if (cnk->cflags == DP_C_LLONG) > cnk->value = va_arg (args, LLONG); >+ else if (cnk->cflags == DP_C_LLONG) >+ cnk->value = va_arg (args, ssize_t); > else > cnk->value = va_arg (args, int); > >@@ -592,6 +599,8 @@ > cnk->value = (long)va_arg (args, unsigned long int); > else if (cnk->cflags == DP_C_LLONG) > cnk->value = (LLONG)va_arg (args, unsigned LLONG); >+ else if (cnk->cflags == DP_C_SIZET) >+ cnk->value = (LLONG)va_arg (args, size_t); > else > cnk->value = (long)va_arg (args, unsigned int); > >@@ -644,6 +653,8 @@ > cnk->pnum = va_arg (args, long int *); > else if (cnk->cflags == DP_C_LLONG) > cnk->pnum = va_arg (args, LLONG *); >+ else if (cnk->cflags == DP_C_SIZET) >+ cnk->pnum = va_arg (args, ssize_t); > else > cnk->pnum = va_arg (args, int *); > >@@ -725,6 +736,8 @@ > *((long int *)(cnk->pnum)) = (long int)currlen; > else if (cnk->cflags == DP_C_LLONG) > *((LLONG *)(cnk->pnum)) = (LLONG)currlen; >+ else if (cnk->cflags == DP_C_SIZET) >+ *((ssize_t *)(cnk->pnum)) = (ssize_t)currlen; > else > *((int *)(cnk->pnum)) = (int)currlen; > break; >@@ -1406,6 +1419,26 @@ > "%4$*1$d %2$s %3$*1$.*1$f", l1, buf1, l2, buf2); > fail++; > } >+ >+ { >+ size_t sizenum = 123456789; >+ ssize_t size1, size2; >+ >+ buf1[0] = buf2[0] = '\0'; >+ l1 = snprintf(buf1, sizeof(buf1), "test z %zu %zn", sizenum, &size1); >+ l2 = sprintf(buf2, "test z %zu %zn", sizenum, &size2); >+ buf1[1023] = buf1[1023] = '\0'; >+ if (strcmp(buf1, buf2)) { >+ printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", >+ "test z %zu %zn", l1, buf1, l2, buf2); >+ fail++; >+ } >+ if (size1 != size2) { >+ printf("snprintf does not calc 'n' oorrectly:\nsnprintf: %zu\nsprintf: %zu\n", >+ size1, size2); >+ fail++; >+ } >+ } > #if 0 > buf1[0] = buf2[0] = '\0'; > l1 = snprintf(buf1, sizeof(buf1), "%lld", (LLONG)1234567890);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 3986
: 2076