intl/icu/source/io/uscanf.c

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /*
     2 ******************************************************************************
     3 *
     4 *   Copyright (C) 1998-2004, International Business Machines
     5 *   Corporation and others.  All Rights Reserved.
     6 *
     7 ******************************************************************************
     8 *
     9 * File uscanf.c
    10 *
    11 * Modification History:
    12 *
    13 *   Date        Name        Description
    14 *   12/02/98    stephen        Creation.
    15 *   03/13/99    stephen     Modified for new C API.
    16 ******************************************************************************
    17 */
    19 #include "unicode/utypes.h"
    21 #if !UCONFIG_NO_FORMATTING
    23 #include "unicode/putil.h"
    24 #include "unicode/ustdio.h"
    25 #include "unicode/ustring.h"
    26 #include "uscanf.h"
    27 #include "ufile.h"
    28 #include "ufmt_cmn.h"
    30 #include "cmemory.h"
    31 #include "cstring.h"
    34 U_CAPI int32_t U_EXPORT2
    35 u_fscanf(UFILE        *f,
    36          const char    *patternSpecification,
    37          ... )
    38 {
    39     va_list ap;
    40     int32_t converted;
    42     va_start(ap, patternSpecification);
    43     converted = u_vfscanf(f, patternSpecification, ap);
    44     va_end(ap);
    46     return converted;
    47 }
    49 U_CAPI int32_t U_EXPORT2
    50 u_fscanf_u(UFILE        *f,
    51            const UChar    *patternSpecification,
    52            ... )
    53 {
    54     va_list ap;
    55     int32_t converted;
    57     va_start(ap, patternSpecification);
    58     converted = u_vfscanf_u(f, patternSpecification, ap);
    59     va_end(ap);
    61     return converted;
    62 }
    64 U_CAPI int32_t  U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
    65 u_vfscanf(UFILE        *f,
    66           const char    *patternSpecification,
    67           va_list        ap)
    68 {
    69     int32_t converted;
    70     UChar *pattern;
    71     UChar patBuffer[UFMT_DEFAULT_BUFFER_SIZE];
    72     int32_t size = (int32_t)uprv_strlen(patternSpecification) + 1;
    74     /* convert from the default codepage to Unicode */
    75     if (size >= MAX_UCHAR_BUFFER_SIZE(patBuffer)) {
    76         pattern = (UChar *)uprv_malloc(size * sizeof(UChar));
    77         if(pattern == 0) {
    78             return 0;
    79         }
    80     }
    81     else {
    82         pattern = patBuffer;
    83     }
    84     u_charsToUChars(patternSpecification, pattern, size);
    86     /* do the work */
    87     converted = u_vfscanf_u(f, pattern, ap);
    89     /* clean up */
    90     if (pattern != patBuffer) {
    91         uprv_free(pattern);
    92     }
    94     return converted;
    95 }
    97 U_CAPI int32_t  U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
    98 u_vfscanf_u(UFILE       *f,
    99             const UChar *patternSpecification,
   100             va_list     ap)
   101 {
   102     return u_scanf_parse(f, patternSpecification, ap);
   103 }
   105 #endif /* #if !UCONFIG_NO_FORMATTING */

mercurial