summaryrefslogtreecommitdiffstats
path: root/private/crt32/mbstring/strncnt.c
diff options
context:
space:
mode:
Diffstat (limited to 'private/crt32/mbstring/strncnt.c')
-rw-r--r--private/crt32/mbstring/strncnt.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/private/crt32/mbstring/strncnt.c b/private/crt32/mbstring/strncnt.c
new file mode 100644
index 000000000..cce09115e
--- /dev/null
+++ b/private/crt32/mbstring/strncnt.c
@@ -0,0 +1,52 @@
+/***
+*strncnt.c - Return char count of string.
+*
+* Copyright (c) 1987-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Return char count of MBCS string
+*
+*Revision History:
+* 11-19-92 KRS Ported from 16-bit sources.
+*
+*******************************************************************************/
+
+#ifdef _MBCS
+#include <cruntime.h>
+#include <mbdata.h>
+#include <mbctype.h>
+#include <mbstring.h>
+
+/***
+* _strncnt - Return char count of string
+*
+*Purpose:
+* Used for mapping _mbsnbcnt and _mbsnccnt to an equivilent non-MBCS
+* implementation when _MBCS is not defined. Returns the minimum of
+* strlen and bcnt.
+*
+*Entry:
+* const unsigned char *string = pointer to string
+* unsigned int bcnt = number of bytes to scan
+*
+*Exit:
+* Returns number of chars/bytes between string and bcnt.
+*
+* If the end of the string is encountered before bcnt chars were
+* scanned, then the length of the string in chars is returned.
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+size_t _CRTAPI1 _strncnt(string, bcnt)
+const unsigned char *string;
+size_t bcnt;
+{
+ size_t len;
+
+ len = strlen (string);
+
+ return( (len > bcnt) ? (bcnt) : (len) );
+}
+#endif /* _MBCS */