ICU-8579 added u_printf
X-SVN-Rev: 30677
This commit is contained in:
parent
4e3ef555e0
commit
b199eb07ee
@ -1,7 +1,7 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2001-2006, International Business Machines *
|
||||
* Copyright (C) 2001-2011, International Business Machines *
|
||||
* Corporation and others. All Rights Reserved. *
|
||||
* *
|
||||
******************************************************************************
|
||||
@ -26,6 +26,7 @@ as the functions are suppose to be called. */
|
||||
typedef enum ECleanupIOType {
|
||||
UCLN_IO_START = -1,
|
||||
UCLN_IO_LOCBUND,
|
||||
UCLN_IO_PRINTF,
|
||||
UCLN_IO_COUNT /* This must be last */
|
||||
} ECleanupIOType;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1998-2010, International Business Machines
|
||||
* Copyright (C) 1998-2011, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
******************************************************************************
|
||||
@ -441,6 +441,17 @@ U_STABLE UConverter* U_EXPORT2 u_fgetConverter(UFILE *f);
|
||||
|
||||
/* Output functions */
|
||||
|
||||
/**
|
||||
* Write formatted data to <TT>stdout</TT>.
|
||||
* @param patternSpecification A pattern specifying how <TT>u_printf</TT> will
|
||||
* interpret the variable arguments received and format the data.
|
||||
* @return The number of Unicode characters written to <TT>stdout</TT>
|
||||
* @draft ICU 49
|
||||
*/
|
||||
U_DRAFT int32_t U_EXPORT2
|
||||
u_printf(const char *patternSpecification,
|
||||
... );
|
||||
|
||||
/**
|
||||
* Write formatted data to a UFILE.
|
||||
* @param f The UFILE to which to write.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1998-2004, International Business Machines
|
||||
* Copyright (C) 1998-2011, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
******************************************************************************
|
||||
@ -30,10 +30,31 @@
|
||||
|
||||
#include "uprintf.h"
|
||||
#include "ufile.h"
|
||||
#include "ucln_io.h"
|
||||
#include "locbund.h"
|
||||
|
||||
#include "cmemory.h"
|
||||
|
||||
UFILE *gStdOut = NULL;
|
||||
|
||||
static UBool U_CALLCONV uprintf_cleanup()
|
||||
{
|
||||
if (gStdOut != NULL) {
|
||||
u_fclose(gStdOut);
|
||||
gStdOut = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static UFILE * U_EXPORT2
|
||||
u_get_stdout()
|
||||
{
|
||||
if (gStdOut == NULL) {
|
||||
gStdOut = u_finit(stdout, NULL, NULL);
|
||||
ucln_io_registerCleanup(UCLN_IO_PRINTF, &uprintf_cleanup);
|
||||
}
|
||||
return gStdOut;
|
||||
}
|
||||
|
||||
static int32_t U_EXPORT2
|
||||
u_printf_write(void *context,
|
||||
const UChar *str,
|
||||
@ -92,6 +113,18 @@ u_fprintf( UFILE *f,
|
||||
return count;
|
||||
}
|
||||
|
||||
U_CAPI int32_t U_EXPORT2
|
||||
u_printf(const char *patternSpecification,
|
||||
...)
|
||||
{
|
||||
va_list ap;
|
||||
int32_t count;
|
||||
va_start(ap, patternSpecification);
|
||||
count = u_vfprintf(u_get_stdout(), patternSpecification, ap);
|
||||
va_end(ap);
|
||||
return count;
|
||||
}
|
||||
|
||||
U_CAPI int32_t U_EXPORT2
|
||||
u_fprintf_u( UFILE *f,
|
||||
const UChar *patternSpecification,
|
||||
|
Loading…
Reference in New Issue
Block a user