From 3c87aa1d3dc1d8dad3efad322852a8e1e76dee55 Mon Sep 17 00:00:00 2001 From: David Chisnall Date: Sun, 20 Nov 2011 14:45:42 +0000 Subject: Implement xlocale APIs from Darwin, mainly for use by libc++. This adds a load of _l suffixed versions of various standard library functions that use the global locale, making them take an explicit locale parameter. Also adds support for per-thread locales. This work was funded by the FreeBSD Foundation. Please test any code you have that uses the C standard locale functions! Reviewed by: das (gdtoa changes) Approved by: dim (mentor) --- lib/libc/stdio/asprintf.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'lib/libc/stdio/asprintf.c') diff --git a/lib/libc/stdio/asprintf.c b/lib/libc/stdio/asprintf.c index 90c62bcea2b0..cd475cd2117e 100644 --- a/lib/libc/stdio/asprintf.c +++ b/lib/libc/stdio/asprintf.c @@ -5,6 +5,11 @@ * This code is derived from software contributed to Berkeley by * Chris Torek. * + * Copyright (c) 2011 The FreeBSD Foundation + * All rights reserved. + * Portions of this software were developed by David Chisnall + * under sponsorship from the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -35,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include int asprintf(char ** __restrict s, char const * __restrict fmt, ...) @@ -47,3 +53,15 @@ asprintf(char ** __restrict s, char const * __restrict fmt, ...) va_end(ap); return (ret); } +int +asprintf_l(char ** __restrict s, locale_t locale, char const * __restrict fmt, + ...) +{ + int ret; + va_list ap; + + va_start(ap, fmt); + ret = vasprintf_l(s, locale, fmt, ap); + va_end(ap); + return (ret); +} -- cgit v1.2.3