]> pd.if.org Git - pdclib.old/commitdiff
PDCLIB-2 PDCLIB-9: MB_CUR_MAX macro and implementation
authorOwen Shepherd <owen.shepherd@e43.eu>
Mon, 31 Dec 2012 20:34:22 +0000 (20:34 +0000)
committerOwen Shepherd <owen.shepherd@e43.eu>
Mon, 31 Dec 2012 20:34:22 +0000 (20:34 +0000)
functions/locale/_PDCLIB_mb_cur_max.c [new file with mode: 0644]
includes/stdlib.h
internals/_PDCLIB_encoding.h
internals/_PDCLIB_int.h
opt/basecodecs/_PDCLIB_ascii.c
opt/basecodecs/_PDCLIB_latin1.c
opt/basecodecs/_PDCLIB_utf8.c

diff --git a/functions/locale/_PDCLIB_mb_cur_max.c b/functions/locale/_PDCLIB_mb_cur_max.c
new file mode 100644 (file)
index 0000000..a5f459d
--- /dev/null
@@ -0,0 +1,27 @@
+/* _PDCLIB_mb_cur_max( void ) 
+
+   This file is part of the Public Domain C Library (PDCLib).
+   Permission is granted to use, modify, and / or redistribute at will.
+*/
+
+#include <locale.h>
+#ifndef REGTEST
+#include <_PDCLIB_locale.h>
+#include <_PDCLIB_encoding.h>
+
+size_t _PDCLIB_mb_cur_max( void )
+{
+    return _PDCLIB_threadlocale()->_Codec->__mb_max;
+}
+
+#endif
+
+#ifdef TEST
+#include <_PDCLIB_test.h>
+
+int main( void )
+{
+    TESTCASE( NO_TESTDRIVER );
+    return TEST_RESULTS;
+}
+#endif
index 22cc80c72b5e52011897f5a9b3fd2b05c7868fa9..1151d1acc23f401b87bb367e557e8b6a158f7b70 100644 (file)
@@ -21,6 +21,11 @@ typedef _PDCLIB_size_t size_t;
 #define NULL _PDCLIB_NULL
 #endif
 
+#ifndef _PDCLIB_MB_CUR_MAX_DEFINED
+#define _PDCLIB_MB_CUR_MAX_DEFINED
+#define MB_CUR_MAX (_PDCLIB_mb_cur_max())
+#endif
+
 /* Numeric conversion functions */
 
 /* TODO: atof(), strtof(), strtod(), strtold() */
index f53d77ab9e9bc67193833bac076766004794481b..9b31735423a84dc20af05713b07caf08d435e352 100644 (file)
@@ -138,6 +138,8 @@ struct _PDCLIB_charcodec {
         _PDCLIB_size_t                           *_PDCLIB_restrict  _P_insz,
         _PDCLIB_mbstate_t                        *_PDCLIB_restrict  _P_ps
     );
+
+    size_t __mb_max;
 };
 
 #endif
index c9988a9d7c2d67e045b2b705702f82a1ac696ee2..52ba8b35f607b82cd5133562abaa042b045dbea9 100644 (file)
@@ -364,6 +364,8 @@ typedef struct _PDCLIB_charcodec *_PDCLIB_charcodec_t;
 typedef struct _PDCLIB_locale    *_PDCLIB_locale_t;
 typedef struct lconv              _PDCLIB_lconv_t;
 
+_PDCLIB_size_t _PDCLIB_mb_cur_max( void );
+
 /* -------------------------------------------------------------------------- */
 /* stdio                                                                      */
 /* -------------------------------------------------------------------------- */
index 86001aff538f2423b58b6c3bb4e9dd90629f55eb..e07e2ba217a341c5199d798f3979d6394ea11d49 100644 (file)
@@ -62,6 +62,7 @@ static bool c32toascii(
 struct _PDCLIB_charcodec _PDCLIB_ascii_codec = {
     .__mbstoc32s = asciitoc32,
     .__c32stombs = c32toascii,
+    .__mb_max    = 1,
 };
 
 #endif
index b397001303921c93f99854aa9ed02da5128e40db..72a344680436c3aaf225084b4af52c8752545121 100644 (file)
@@ -60,6 +60,7 @@ static bool c32tolatin1(
 struct _PDCLIB_charcodec _PDCLIB_latin1_codec = {
     .__mbstoc32s = latin1toc32,
     .__c32stombs = c32tolatin1,
+    .__mb_max    = 1,
 };
 
 #endif
index 2b3f4f6c5fe42465df0f4c6e3cda8cc5568a346c..bac0e824a7f9b5a1d0b662058778f32f34eceb79 100644 (file)
@@ -231,6 +231,7 @@ static bool c32toutf8(
 struct _PDCLIB_charcodec _PDCLIB_utf8_codec = {
     .__mbstoc32s = utf8toc32,
     .__c32stombs = c32toutf8,
+    .__mb_max    = 4,
 };
 
 #endif