This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Re: [RFC][PATCH] Locale convenience funtions


Hi,
I started the assignment process. but if there are anyone who want to add this convenience functions, let's build a tower together.
In aspect of I18n & L10n, I think, there is no doubt that these kind functions will be helpful for developers.

Thanks and regards,
Seung-yeon.
s.choe@samsung.com

diff --git a/libio/stdio.h b/libio/stdio.h
index 754301f..db05fd6 100644
--- a/libio/stdio.h
+++ b/libio/stdio.h
@@ -394,6 +394,14 @@ __END_NAMESPACE_C99
 #endif
 
 #ifdef __USE_GNU
+# include <xlocale.h>
+/* Locale convenience functions */
+extern int snprintf_l (char *__restrict __s, locale_t loc, size_t __maxlen,
+                       const char *__restrict __format, ...)
+     __THROWNL __attribute__ ((__format__ (__printf__, 4, 5)));
+#endif
+
+#ifdef __USE_GNU
 /* Write formatted output to a string dynamically allocated with `malloc'.
    Store the address of the string in *PTR.  */
 extern int vasprintf (char **__restrict __ptr, const char *__restrict __f,
diff --git a/stdio-common/Makefile b/stdio-common/Makefile
index 658804b..1113692 100644
--- a/stdio-common/Makefile
+++ b/stdio-common/Makefile
@@ -37,7 +37,8 @@ routines	:=							      \
 	flockfile ftrylockfile funlockfile				      \
 	isoc99_scanf isoc99_vscanf isoc99_fscanf isoc99_vfscanf isoc99_sscanf \
 	isoc99_vsscanf							      \
-	psiginfo
+	psiginfo							      \
+	snprintf_l
 
 include ../Makeconfig
 
diff --git a/stdio-common/snprintf_l.c b/stdio-common/snprintf_l.c
new file mode 100644
index 0000000..ab40193
--- /dev/null
+++ b/stdio-common/snprintf_l.c
@@ -0,0 +1,41 @@
+/* Copyright (C) 1991-2013 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <libioP.h>
+#include <xlocale.h>
+#define __vsnprintf(s, l, f, a) _IO_vsnprintf (s, l, f, a)
+
+/* Write formatted output into S, according to the format
+   string FORMAT, writing no more than MAXLEN characters.  */
+/* VARARGS3 */
+int
+__snprintf_l (char *s, locale_t loc, size_t maxlen, const char *format, ...)
+{
+  va_list arg;
+  int done;
+  locale_t old_loc = uselocale (loc);
+
+  va_start (arg, format);
+  done = __vsnprintf (s, maxlen, format, arg);
+  va_end (arg);
+
+  uselocale (old_loc);
+  return done;
+}
+ldbl_weak_alias (__snprintf_l, snprintf_l)



-----Original Message-----
From: Ond?ej B?lka [mailto:neleai@seznam.cz] 
Sent: Monday, June 17, 2013 2:39 PM
To: Seung-yeon Choe
Cc: libc-alpha@sourceware.org; libc-locales@sourceware.org
Subject: Re: [RFC][PATCH] Locale convenience funtions

On Mon, Jun 17, 2013 at 02:23:08AM +0000, Seung-yeon Choe wrote:
> Dear, glibc locale maintainers.
>  
> I'd like to discuss about additional functions for locale convenience which are supported by the other libc library (eg. bsd libc library).
> For example, to support a snprintf_l convenience funciton, I think we can write an implemantation as the following patch set.
> And likewise the other functions too. (asprintf_l, fprintf_l, 
> printf_l, sprintf_l, vasprintf_l, vfprintf_l, vprintf_l, vsnprintf_l, vsprintf_l) Please let me know whether this approach is acceptable or not.
>  
Hi,

As we are close to 2.18 freeze it will take month before this patch becomes relevant again.

Does your company have copyrigth assignment? This takes some time to process so it is better to handle it first than having patch waiting only for assignment.

Attachment: snprintf_l.patch
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]