read_file(), move_to_filestruct(), copy_from_filestruct(),
do_justify(), get_totals() (renamed get_totsize()), and
do_cursorpos(). (DLR)
+ - Change the NANO_WIDE #define to ENABLE_UTF8, as the latter is
+ clearer. (DLR)
- files.c:
open_file()
- Assert that filename isn't NULL, and don't do anything special
- configure.ac:
- Since we only use vsnprintf() now, remove the tests for
snprintf(). (DLR)
+ - Change the description of "sufficient wide character support"
+ to "sufficient UTF-8 support", as the latter is clearer. (DLR)
- doc/faq.html:
- Update section 4.10 to mention that pasting from the X
clipboard via the middle mouse button also works when the
test x$ac_cv_func_mbtowc = xyes && \
test x$ac_cv_func_wctomb = xyes && \
test x$ac_cv_func_wcwidth = xyes; then
- AC_DEFINE(NANO_WIDE, 1, [Define this if your system has sufficient wide character support (a wide curses library, iswalnum(), iswpunct(), iswblank() or iswspace(), mblen(), mbstowcs(), mbtowc(), wctomb(), and wcwidth()).])
+ AC_DEFINE(ENABLE_UTF8, 1, [Define this if your system has sufficient UTF-8 support (a wide curses library, iswalnum(), iswpunct(), iswblank() or iswspace(), mblen(), mbstowcs(), mbtowc(), wctomb(), and wcwidth()).])
else
if test x$enable_utf8 = xyes; then
AC_MSG_ERROR([
#include <assert.h>
#include "proto.h"
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
#ifdef HAVE_WCHAR_H
#include <wchar.h>
#endif
}
#endif
-#if !defined(HAVE_ISWBLANK) && defined(NANO_WIDE)
+#if !defined(HAVE_ISWBLANK) && defined(ENABLE_UTF8)
/* This function is equivalent to iswblank(). */
bool niswblank(wchar_t wc)
{
{
assert(c != NULL);
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
if (ISSET(USE_UTF8)) {
wchar_t wc;
int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX);
{
assert(c != NULL);
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
if (ISSET(USE_UTF8)) {
wchar_t wc;
int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX);
(127 <= c && c < 160);
}
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
/* This function is equivalent to iscntrl() for wide characters, except
* in that it also handles wide control characters with their high bits
* set. */
{
assert(c != NULL);
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
if (ISSET(USE_UTF8)) {
wchar_t wc;
int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX);
{
assert(c != NULL);
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
if (ISSET(USE_UTF8)) {
wchar_t wc;
int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX);
return c + 64;
}
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
/* c is a wide control character. It displays as ^@, ^?, or ^[ch],
* where ch is (c + 64). We return that wide character. */
wchar_t control_wrep(wchar_t wc)
{
assert(c != NULL && crep != NULL && crep_len != NULL);
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
if (ISSET(USE_UTF8)) {
wchar_t wc;
#endif
*crep_len = 1;
*crep = control_rep(*c);
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
}
#endif
{
assert(c != NULL);
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
if (ISSET(USE_UTF8)) {
wchar_t wc;
int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX), width;
int mb_cur_max(void)
{
return
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
ISSET(USE_UTF8) ? MB_CUR_MAX :
#endif
1;
assert(chr_mb_len != NULL);
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
if (ISSET(USE_UTF8)) {
chr_mb = charalloc(MB_CUR_MAX);
*chr_mb_len = wctomb(chr_mb, chr);
#endif
*chr_mb_len = 1;
chr_mb = mallocstrncpy(NULL, (char *)&chr, 1);
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
}
#endif
if (bad_chr != NULL)
*bad_chr = FALSE;
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
if (ISSET(USE_UTF8)) {
/* Get the number of bytes in the multibyte character. */
buf_mb_len = mblen(buf, MB_CUR_MAX);
else
(*col)++;
}
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
}
#endif
* strings. */
int mbstrncasecmp(const char *s1, const char *s2, size_t n)
{
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
if (ISSET(USE_UTF8)) {
char *s1_mb = charalloc(MB_CUR_MAX);
char *s2_mb = charalloc(MB_CUR_MAX);
/* This function is equivalent to strcasestr() for multibyte strings. */
const char *mbstrcasestr(const char *haystack, const char *needle)
{
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
if (ISSET(USE_UTF8)) {
char *r_mb = charalloc(MB_CUR_MAX);
char *q_mb = charalloc(MB_CUR_MAX);
const char *mbrevstrcasestr(const char *haystack, const char *needle,
const char *rev_start)
{
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
if (ISSET(USE_UTF8)) {
char *r_mb = charalloc(MB_CUR_MAX);
char *q_mb = charalloc(MB_CUR_MAX);
{
assert(s != NULL);
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
if (ISSET(USE_UTF8)) {
size_t n = 0;
int s_mb_len;
{
assert(s != NULL);
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
if (ISSET(USE_UTF8)) {
char *chr_mb = charalloc(MB_CUR_MAX);
bool retval = FALSE;
{
assert(s != NULL && c != NULL);
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
if (ISSET(USE_UTF8)) {
char *s_mb = charalloc(MB_CUR_MAX);
const char *q = s;
assert(s != NULL);
return
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
ISSET(USE_UTF8) ?
(mbstowcs(NULL, s, 0) != (size_t)-1) :
#endif
#ifdef NANO_SMALL
printf(" --enable-tiny");
#endif
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
printf(" --enable-utf8");
#endif
#ifdef USE_SLANG
};
#endif
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
{
/* If the locale set exists and includes the case-insensitive
* string "UTF8" or "UTF-8", we should use UTF-8. */
#ifndef HAVE_ISBLANK
bool nisblank(int c);
#endif
-#if !defined(HAVE_ISWBLANK) && defined(NANO_WIDE)
+#if !defined(HAVE_ISWBLANK) && defined(ENABLE_UTF8)
bool niswblank(wchar_t wc);
#endif
bool is_byte(int c);
bool is_alnum_mbchar(const char *c);
bool is_blank_mbchar(const char *c);
bool is_cntrl_char(int c);
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
bool is_cntrl_wchar(wchar_t wc);
#endif
bool is_cntrl_mbchar(const char *c);
bool is_punct_mbchar(const char *c);
bool is_word_mbchar(const char *c, bool allow_punct);
char control_rep(char c);
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
wchar_t control_wrep(wchar_t c);
#endif
char *control_mbrep(const char *c, char *crep, int *crep_len);
/* Current position in converted. */
bool bad_char;
/* Whether we have an invalid multibyte character. */
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
const char *bad_buf_mb = "\xEF\xBF\xBD";
/* What to display when we have an invalid multibyte
* character: Unicode 0xFFFD (Replacement Character). */
start_index += buf_mb_len;
}
}
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
else if (ISSET(USE_UTF8) && mbwidth(buf_mb) > 1) {
converted[index++] = ' ';
start_col++;
converted[index++] = '^';
start_col++;
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
/* If buf contains an invalid multibyte control character,
* display it as such. */
if (ISSET(USE_UTF8) && bad_char) {
} else {
int i;
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
/* If buf contains an invalid multibyte non-control
* character, display it as such. */
if (ISSET(USE_UTF8) && bad_char) {
converted[index++] = buf[start_index + i];
start_col += mbwidth(buf_mb);
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
}
#endif
}
* can't dynamically assign it above, using Unicode 00F6 (Latin
* Small Letter O with Diaresis) if applicable. */
credits[14] =
-#ifdef NANO_WIDE
+#ifdef ENABLE_UTF8
ISSET(USE_UTF8) ? "Florian K\xC3\xB6nig" :
#endif
"Florian K\xF6nig";