Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: nspr/pr/src/io/prprf.c

Issue 1504923011: Update NSS to 3.21 RTM and NSPR to 4.11 RTM (Closed) Base URL: http://src.chromium.org/svn/trunk/deps/third_party/nss
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public 2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 5
6 /* 6 /*
7 ** Portable safe sprintf code. 7 ** Portable safe sprintf code.
8 ** 8 **
9 ** Author: Kipp E.B. Hickman 9 ** Author: Kipp E.B. Hickman
10 */ 10 */
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 const char *s; 59 const char *s;
60 int *ip; 60 int *ip;
61 #ifdef WIN32 61 #ifdef WIN32
62 const WCHAR *ws; 62 const WCHAR *ws;
63 #endif 63 #endif
64 } u; 64 } u;
65 }; 65 };
66 66
67 #define NAS_DEFAULT_NUM 20 /* default number of NumberedArgument array */ 67 #define NAS_DEFAULT_NUM 20 /* default number of NumberedArgument array */
68 68
69 69 /*
70 ** For numeric types, the signed versions must have even values,
71 ** and their corresponding unsigned versions must have the subsequent
72 ** odd value.
73 */
70 #define TYPE_INT16 0 74 #define TYPE_INT16 0
71 #define TYPE_UINT16 1 75 #define TYPE_UINT16 1
72 #define TYPE_INTN 2 76 #define TYPE_INTN 2
73 #define TYPE_UINTN 3 77 #define TYPE_UINTN 3
74 #define TYPE_INT32 4 78 #define TYPE_INT32 4
75 #define TYPE_UINT32 5 79 #define TYPE_UINT32 5
76 #define TYPE_INT64 6 80 #define TYPE_INT64 6
77 #define TYPE_UINT64 7 81 #define TYPE_UINT64 7
78 #define TYPE_STRING 8 82 #define TYPE_STRING 8
79 #define TYPE_DOUBLE 9 83 #define TYPE_DOUBLE 9
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 } else { 373 } else {
370 slen = strlen(str); 374 slen = strlen(str);
371 } 375 }
372 376
373 /* and away we go */ 377 /* and away we go */
374 return fill2(ss, str, slen, width, flags); 378 return fill2(ss, str, slen, width, flags);
375 } 379 }
376 380
377 /* 381 /*
378 ** BuildArgArray stands for Numbered Argument list Sprintf 382 ** BuildArgArray stands for Numbered Argument list Sprintf
379 ** for example, 383 ** for example,
380 **» fmp = "%4$i, %2$d, %3s, %1d"; 384 **» fmt = "%4$i, %2$d, %3s, %1d";
381 ** the number must start from 1, and no gap among them 385 ** the number must start from 1, and no gap among them
382 */ 386 */
383 387
384 static struct NumArg* BuildArgArray( const char *fmt, va_list ap, int* rv, struc t NumArg* nasArray ) 388 static struct NumArg* BuildArgArray( const char *fmt, va_list ap, int* rv, struc t NumArg* nasArray )
385 { 389 {
386 int number = 0, cn = 0, i; 390 int number = 0, cn = 0, i;
387 const char* p; 391 const char* p;
388 char c; 392 char c;
389 struct NumArg* nas; 393 struct NumArg* nas;
390 394
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 /* XXX not quite sure here */ 512 /* XXX not quite sure here */
509 nas[cn].type = TYPE_INT64; 513 nas[cn].type = TYPE_INT64;
510 c = *p++; 514 c = *p++;
511 } else if (c == 'l') { 515 } else if (c == 'l') {
512 nas[cn].type = TYPE_INT32; 516 nas[cn].type = TYPE_INT32;
513 c = *p++; 517 c = *p++;
514 if (c == 'l') { 518 if (c == 'l') {
515 nas[cn].type = TYPE_INT64; 519 nas[cn].type = TYPE_INT64;
516 c = *p++; 520 c = *p++;
517 } 521 }
522 } else if (c == 'z') {
523 if (sizeof(size_t) == sizeof(PRInt32)) {
524 nas[ cn ].type = TYPE_INT32;
525 } else if (sizeof(size_t) == sizeof(PRInt64)) {
526 nas[ cn ].type = TYPE_INT64;
527 } else {
528 nas[ cn ].type = TYPE_UNKNOWN;
529 }
530 c = *p++;
518 } 531 }
519 532
520 /* format */ 533 /* format */
521 switch (c) { 534 switch (c) {
522 case 'd': 535 case 'd':
523 case 'c': 536 case 'c':
524 case 'i': 537 case 'i':
525 case 'o': 538 case 'o':
526 case 'u': 539 case 'u':
527 case 'x': 540 case 'x':
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 /* XXX not quite sure here */ 815 /* XXX not quite sure here */
803 type = TYPE_INT64; 816 type = TYPE_INT64;
804 c = *fmt++; 817 c = *fmt++;
805 } else if (c == 'l') { 818 } else if (c == 'l') {
806 type = TYPE_INT32; 819 type = TYPE_INT32;
807 c = *fmt++; 820 c = *fmt++;
808 if (c == 'l') { 821 if (c == 'l') {
809 type = TYPE_INT64; 822 type = TYPE_INT64;
810 c = *fmt++; 823 c = *fmt++;
811 } 824 }
825 } else if (c == 'z') {
826 if (sizeof(size_t) == sizeof(PRInt32)) {
827 type = TYPE_INT32;
828 } else if (sizeof(size_t) == sizeof(PRInt64)) {
829 type = TYPE_INT64;
830 }
831 c = *fmt++;
812 } 832 }
813 833
814 /* format */ 834 /* format */
815 hexp = hex; 835 hexp = hex;
816 switch (c) { 836 switch (c) {
817 case 'd': case 'i': /* decimal/integer */ 837 case 'd': case 'i': /* decimal/integer */
818 radix = 10; 838 radix = 10;
819 goto fetch_and_convert; 839 goto fetch_and_convert;
820 840
821 case 'o': /* octal */ 841 case 'o': /* octal */
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 rv = dosprintf(&ss, fmt, ap); 1259 rv = dosprintf(&ss, fmt, ap);
1240 if (rv < 0) { 1260 if (rv < 0) {
1241 if (ss.base) { 1261 if (ss.base) {
1242 PR_DELETE(ss.base); 1262 PR_DELETE(ss.base);
1243 } 1263 }
1244 return 0; 1264 return 0;
1245 } 1265 }
1246 return ss.base; 1266 return ss.base;
1247 } 1267 }
1248 1268
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698