~ubuntu-branches/ubuntu/oneiric/nspr/oneiric-security

« back to all changes in this revision

Viewing changes to mozilla/nsprpub/pr/src/io/prprf.c

  • Committer: Package Import Robot
  • Author(s): Jamie Strandboge
  • Date: 2013-01-10 12:35:22 UTC
  • mfrom: (1.2.4)
  • Revision ID: package-import@ubuntu.com-20130110123522-pnodrf50v6mkn4hs
Tags: 4.9.4-0ubuntu0.11.10.1
* New upstream release to support security fixes in nss. Dropped the
  following patches:
  - debian/patches/30_pkgconfig.patch (included upstream)
  - debian/patches/40_fix_arm_ftbfs.patch (no longer required)
* debian/patches/30_config_64bits.patch: refresh
* debian/patches/99_configure.patch: regenerate per debian/rules
* debian/libnsp4.symbols: added PR_GetThreadName@Base, PR_GetVersion@Base
  and PR_SetCurrentThreadName@Base

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
 
/* ***** BEGIN LICENSE BLOCK *****
3
 
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
 
 *
5
 
 * The contents of this file are subject to the Mozilla Public License Version
6
 
 * 1.1 (the "License"); you may not use this file except in compliance with
7
 
 * the License. You may obtain a copy of the License at
8
 
 * http://www.mozilla.org/MPL/
9
 
 *
10
 
 * Software distributed under the License is distributed on an "AS IS" basis,
11
 
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
 
 * for the specific language governing rights and limitations under the
13
 
 * License.
14
 
 *
15
 
 * The Original Code is the Netscape Portable Runtime (NSPR).
16
 
 *
17
 
 * The Initial Developer of the Original Code is
18
 
 * Netscape Communications Corporation.
19
 
 * Portions created by the Initial Developer are Copyright (C) 1998-2000
20
 
 * the Initial Developer. All Rights Reserved.
21
 
 *
22
 
 * Contributor(s):
23
 
 *
24
 
 * Alternatively, the contents of this file may be used under the terms of
25
 
 * either the GNU General Public License Version 2 or later (the "GPL"), or
26
 
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
 
 * in which case the provisions of the GPL or the LGPL are applicable instead
28
 
 * of those above. If you wish to allow use of your version of this file only
29
 
 * under the terms of either the GPL or the LGPL, and not to allow others to
30
 
 * use your version of this file under the terms of the MPL, indicate your
31
 
 * decision by deleting the provisions above and replace them with the notice
32
 
 * and other provisions required by the GPL or the LGPL. If you do not delete
33
 
 * the provisions above, a recipient may use your version of this file under
34
 
 * the terms of any one of the MPL, the GPL or the LGPL.
35
 
 *
36
 
 * ***** END LICENSE BLOCK ***** */
 
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
 
4
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
37
5
 
38
6
/*
39
7
** Portable safe sprintf code.
86
54
        double d;
87
55
        const char *s;
88
56
        int *ip;
 
57
#ifdef WIN32
 
58
        const WCHAR *ws;
 
59
#endif
89
60
    } u;
90
61
};
91
62
 
103
74
#define TYPE_STRING     8
104
75
#define TYPE_DOUBLE     9
105
76
#define TYPE_INTSTR     10
 
77
#ifdef WIN32
 
78
#define TYPE_WSTRING    11
 
79
#endif
106
80
#define TYPE_UNKNOWN    20
107
81
 
108
82
#define FLAG_LEFT       0x1
573
547
            }
574
548
            break;
575
549
 
 
550
        case 'S':
 
551
#ifdef WIN32
 
552
            nas[ cn ].type = TYPE_WSTRING;
 
553
            break;
 
554
#endif
576
555
        case 'C':
577
 
        case 'S':
578
556
        case 'E':
579
557
        case 'G':
580
558
            /* XXX not supported I suppose */
653
631
            nas[cn].u.s = va_arg( ap, char* );
654
632
            break;
655
633
 
 
634
#ifdef WIN32
 
635
        case TYPE_WSTRING:
 
636
            nas[cn].u.ws = va_arg( ap, WCHAR* );
 
637
            break;
 
638
#endif
 
639
 
656
640
        case TYPE_INTSTR:
657
641
            nas[cn].u.ip = va_arg( ap, int* );
658
642
            break;
690
674
        double d;
691
675
        const char *s;
692
676
        int *ip;
 
677
#ifdef WIN32
 
678
        const WCHAR *ws;
 
679
#endif
693
680
    } u;
694
681
    const char *fmt0;
695
682
    static char *hex = "0123456789abcdef";
701
688
    struct NumArg  nasArray[ NAS_DEFAULT_NUM ];
702
689
    char  pattern[20];
703
690
    const char* dolPt = NULL;  /* in "%4$.2f", dolPt will point to . */
704
 
 
 
691
#ifdef WIN32
 
692
    char *pBuf = NULL;
 
693
#endif
705
694
 
706
695
    /*
707
696
    ** build an argument array, IF the fmt is numbered argument
965
954
            radix = 16;
966
955
            goto fetch_and_convert;
967
956
 
 
957
#ifndef WIN32
 
958
          case 'S':
 
959
            /* XXX not supported I suppose */
 
960
            PR_ASSERT(0);
 
961
            break;
 
962
#endif
 
963
 
968
964
#if 0
969
965
          case 'C':
970
 
          case 'S':
971
966
          case 'E':
972
967
          case 'G':
973
968
            /* XXX not supported I suppose */
975
970
            break;
976
971
#endif
977
972
 
 
973
#ifdef WIN32
 
974
          case 'S':
 
975
            u.ws = nas ? nap->u.ws : va_arg(ap, const WCHAR*);
 
976
 
 
977
            /* Get the required size in rv */
 
978
            rv = WideCharToMultiByte(CP_ACP, 0, u.ws, -1, NULL, 0, NULL, NULL);
 
979
            if (rv == 0)
 
980
                rv = 1;
 
981
            pBuf = PR_MALLOC(rv);
 
982
            WideCharToMultiByte(CP_ACP, 0, u.ws, -1, pBuf, (int)rv, NULL, NULL);
 
983
            pBuf[rv-1] = '\0';
 
984
 
 
985
            rv = cvt_s(ss, pBuf, width, prec, flags);
 
986
 
 
987
            /* We don't need the allocated buffer anymore */
 
988
            PR_Free(pBuf);
 
989
            if (rv < 0) {
 
990
                return rv;
 
991
            }
 
992
            break;
 
993
 
 
994
#endif
 
995
 
978
996
          case 's':
979
997
            u.s = nas ? nap->u.s : va_arg(ap, const char*);
980
998
            rv = cvt_s(ss, u.s, width, prec, flags);