cut: fix appending to unused cut buffer and support for wide characters
[nvi.git] / common / multibyte.h
blob92b651283a4d7500d704801ff3ae731ec4cd9b5d
1 #ifndef MULTIBYTE_H
2 #define MULTIBYTE_H
4 #ifdef USE_WIDECHAR
5 #include <wchar.h>
6 #include <wctype.h>
8 typedef wchar_t RCHAR_T;
9 #define RCHAR_T_MAX ((1 << 24)-1)
10 typedef wchar_t CHAR_T;
11 #define MAX_CHAR_T 0xffffff /* XXXX */
12 typedef u_int UCHAR_T;
13 #define RCHAR_BIT 24
15 #define ISUPPER iswupper
16 #define STRLEN wcslen
17 #define STRTOL wcstol
18 #define STRTOUL wcstoul
19 #define SPRINTF swprintf
20 #define STRCHR wcschr
21 #define STRCMP wcscmp
22 #define STRPBRK wcspbrk
23 #define TOLOWER towlower
24 #define TOUPPER towupper
25 #define STRSET wmemset
27 #define L(ch) L ## ch
29 #else
30 typedef char RCHAR_T;
31 #define RCHAR_T_MAX CHAR_MAX
32 typedef u_char CHAR_T;
33 #define MAX_CHAR_T 0xff
34 typedef u_char UCHAR_T;
35 #define RCHAR_BIT CHAR_BIT
37 #define ISUPPER isupper
38 #define STRLEN strlen
39 #define STRTOL strtol
40 #define STRTOUL strtoul
41 #define SPRINTF snprintf
42 #define STRCHR strchr
43 #define STRCMP strcmp
44 #define STRPBRK strpbrk
45 #define TOLOWER tolower
46 #define TOUPPER toupper
47 #define STRSET memset
49 #define L(ch) ch
51 #endif
53 #define MEMCMP(to, from, n) \
54 memcmp(to, from, (n) * sizeof(*(to)))
55 #define MEMMOVE(p, t, len) memmove(p, t, (len) * sizeof(*(p)))
56 #define MEMCPY(p, t, len) memcpy(p, t, (len) * sizeof(*(p)))
57 #define SIZE(w) (sizeof(w)/sizeof(*w))
59 #endif