summaryrefslogtreecommitdiffstats
path: root/smenu.c
diff options
context:
space:
mode:
Diffstat (limited to 'smenu.c')
-rw-r--r--smenu.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/smenu.c b/smenu.c
index b47d8df..680a047 100644
--- a/smenu.c
+++ b/smenu.c
@@ -217,6 +217,12 @@ mb_interpret(char * s, langinfo_t * langinfo);
static int
mb_validate(const char * str, int length);
+char *
+mb_prev(const char * str, const char * p);
+
+char *
+mb_next(char * p);
+
static int
#ifdef __sun
outch(char c);
@@ -3163,6 +3169,39 @@ mb_offset(char * s, int n)
return i;
}
+/* ================================================== */
+/* Points to the previous multibyte glyph in a string */
+/* from the given position */
+/* ================================================== */
+char *
+mb_prev(const char * str, const char * p)
+{
+ while ((*p & 0xc0) == 0x80)
+ p--;
+
+ for (--p; p >= str; --p)
+ {
+ if ((*p & 0xc0) != 0x80)
+ return (char *)p;
+ }
+ return NULL;
+}
+
+/* ============================================== */
+/* Points to the next multibyte glyph in a string */
+/* from the current position */
+/* ============================================== */
+char *
+mb_next(char * p)
+{
+ if (*p)
+ {
+ for (++p; (*p & 0xc0) == 0x80; ++p)
+ ;
+ }
+ return (*p == '\0' ? NULL : p);
+}
+
/* =========================================================== */
/* Replace any multibyte present in s by a dot inplace */
/* s will be modified but its address in meory will not change */