#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#ifdef HANDLE_MULTIBYTE
+# include <wchar.h>
+# include "mbswidth.h"
+#endif
#include "misc.h"
#ifdef ABOOK_SRC
# include "abook.h"
#ifdef ABOOK_SRC
(char *) abook_malloc (size);
#else
- (char *) malloc (size);
+ (char *) xmalloc (size);
#endif
assert(format != NULL);
#ifdef ABOOK_SRC
(char *) abook_realloc (buffer, size);
#else
- (char *) realloc (buffer, size);
+ (char *) xrealloc (buffer, size);
#endif
}
}
#ifdef ABOOK_SRC
abook_malloc(l);
#else
- malloc(l);
+ xmalloc(l);
#endif
if(concat == NULL)
return NULL;
#define INITIAL_SIZE 128
#ifndef ABOOK_SRC
-# define abook_malloc(X) malloc(X)
-# define abook_realloc(X, XX) realloc(X, XX)
+# define abook_malloc(X) xmalloc(X)
+# define abook_realloc(X, XX) xrealloc(X, XX)
#endif
char *
return buf;
}
+int
+strwidth(const char *s)
+{
+ assert(s);
+#ifdef HANDLE_MULTIBYTE
+ return (int)mbswidth(s, 0);
+#else
+ return strlen(s);
+#endif
+}
+
+int
+bytes2width(const char *s, int width)
+{
+ assert(s);
+#ifdef HANDLE_MULTIBYTE
+ return mbsnbytes(s, strlen(s), width, 0);
+#else
+ return width;
+#endif
+}
+
/**************************************************************
* Original:
* Patrick Powell Tue Apr 11 09:48:21 PDT 1995