summaryrefslogtreecommitdiff
path: root/lib/sh/shmbchar.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sh/shmbchar.c')
-rw-r--r--lib/sh/shmbchar.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/lib/sh/shmbchar.c b/lib/sh/shmbchar.c
index c5badc14..042c9f14 100644
--- a/lib/sh/shmbchar.c
+++ b/lib/sh/shmbchar.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2006, 2009, 2010 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2006, 2009, 2010, 2012 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -89,4 +89,25 @@ mbsmbchar (s)
}
return 0;
}
+
+int
+sh_mbsnlen(src, srclen, maxlen)
+ const char *src;
+ size_t srclen;
+ int maxlen;
+{
+ int count;
+ int sind;
+ DECLARE_MBSTATE;
+
+ for (sind = count = 0; src[sind]; )
+ {
+ count++; /* number of multibyte characters */
+ ADVANCE_CHAR (src, srclen, sind);
+ if (sind > maxlen)
+ break;
+ }
+
+ return count;
+}
#endif