and NANO_APPEND_KEY are. Changes to shortcut_init(), usage(),
main(), search_init(), nanorc.sample, nano.1, nanorc.5,
nano.texi, etc. (DLR)
+ - Various cleanups in chars.c. Remove some unnecessary ctype
+ wrappers, change other ctype wrappers to take wint_t instead
+ of wchar_t, and rename some functions for consistency. Changes
+ to is_alnum_mbchar(), is_blank_char() (renamed nisblank()),
+ is_blank_mbchar(), is_blank_wchar() (renamed niswblank()), and
+ is_cntrl_wchar(), etc.; removal of is_alnum_char() and
+ is_alnum_wchar(). (DLR)
- chars.c:
make_mbstring()
- Change erroneous ENABLE_EXTRA #ifdef to NANO_EXTRA to fix a
processing, and rename to disable_extended_io(). (DLR)
- nano.h:
- Add macro charset(), a wrapper that calls memset(). (DLR)
+ - Readd #defines for the isblank() and iswblank() equivalents.
+ (DLR)
- rcfile.c:
color_to_int()
- Since colorname's being NULL is handled elsewhere now, assert
return ((unsigned int)c == (unsigned char)c);
}
-/* This function is equivalent to isalnum(). */
-bool is_alnum_char(int c)
-{
- return isalnum(c);
-}
-
/* This function is equivalent to isalnum() for multibyte characters. */
bool is_alnum_mbchar(const char *c)
{
wc = (unsigned char)*c;
}
- return is_alnum_wchar(wc);
+ return iswalnum(wc);
} else
#endif
- return is_alnum_char((unsigned char)*c);
+ return isalnum((unsigned char)*c);
}
-#ifdef NANO_WIDE
-/* This function is equivalent to isalnum() for wide characters. */
-bool is_alnum_wchar(wchar_t wc)
+#ifndef HAVE_ISBLANK
+/* This function is equivalent to isblank(). */
+bool nisblank(int c)
{
- return iswalnum(wc);
+ return isspace(c) && (c == '\t' || !is_cntrl_char(c));
}
#endif
-/* This function is equivalent to isblank(). */
-bool is_blank_char(int c)
+#if defined(NANO_WIDE) && !defined(HAVE_ISWBLANK)
+/* This function is equivalent to iswblank(). */
+bool niswblank(wint_t wc)
{
- return
-#ifdef HAVE_ISBLANK
- isblank(c)
-#else
- isspace(c) && (c == '\t' || !is_cntrl_char(c))
-#endif
- ;
+ return iswspace(wc) && (wc == '\t' || !is_cntrl_wchar(wc));
}
+#endif
/* This function is equivalent to isblank() for multibyte characters. */
bool is_blank_mbchar(const char *c)
wc = (unsigned char)*c;
}
- return is_blank_wchar(wc);
+ return iswblank(wc);
} else
#endif
- return is_blank_char((unsigned char)*c);
-}
-
-#ifdef NANO_WIDE
-/* This function is equivalent to isblank() for wide characters. */
-bool is_blank_wchar(wchar_t wc)
-{
- return
-#ifdef HAVE_ISWBLANK
- iswblank(wc)
-#else
- iswspace(wc) && (wc == '\t' || !is_cntrl_wchar(wc))
-#endif
- ;
+ return isblank((unsigned char)*c);
}
-#endif
/* This function is equivalent to iscntrl(), except in that it also
* handles control characters with their high bits set. */
(127 <= c && c < 160);
}
+#ifdef NANO_WIDE
+/* This function is equivalent to iscntrl() for wide characters, except
+ * in that it also handles wide control characters with their high bits
+ * set. */
+bool is_cntrl_wchar(wint_t wc)
+{
+ return (-128 <= wc && wc < -96) || (0 <= wc && wc < 32) ||
+ (127 <= wc && wc < 160);
+}
+#endif
+
/* This function is equivalent to iscntrl() for multibyte characters,
* except in that it also handles multibyte control characters with
* their high bits set. */
return is_cntrl_char((unsigned char)*c);
}
-#ifdef NANO_WIDE
-/* This function is equivalent to iscntrl() for wide characters, except
- * in that it also handles wide control characters with their high bits
- * set. */
-bool is_cntrl_wchar(wchar_t wc)
-{
- return (0 <= wc && wc < 32) || (127 <= wc && wc < 160);
-}
-#endif
-
/* c is a control character. It displays as ^@, ^?, or ^[ch], where ch
* is c + 64. We return that character. */
unsigned char control_rep(unsigned char c)
return c + 64;
}
-/* c is a multibyte control character. It displays as ^@, ^?, or ^[ch]
+#ifdef NANO_WIDE
+/* 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)
+{
+ /* Treat newlines embedded in a line as encoded nulls. */
+ if (wc == '\n')
+ return '@';
+ else if (wc == NANO_CONTROL_8)
+ return '?';
+ else
+ return wc + 64;
+}
+#endif
+
+/* c is a multibyte control character. It displays as ^@, ^?, or ^[ch],
* where ch is c + 64. We return that multibyte character. */
char *control_mbrep(const char *c, char *crep, int *crep_len)
{
#endif
}
-#ifdef NANO_WIDE
-/* 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)
-{
- /* Treat newlines embedded in a line as encoded nulls. */
- if (wc == '\n')
- return '@';
- else if (wc == NANO_CONTROL_8)
- return '?';
- else
- return wc + 64;
-}
-#endif
-
/* This function is equivalent to wcwidth() for multibyte characters. */
int mbwidth(const char *c)
{
#endif
#endif
-/* If no strcasecmp(), strncasecmp(), strcasestr(), strnlen(),
- * getdelim(), or getline(), use the versions we have. */
+/* If no isblank(), iswblank(), strcasecmp(), strncasecmp(),
+ * strcasestr(), strnlen(), getdelim(), or getline(), use the versions
+ * we have. */
+#ifndef HAVE_ISBLANK
+#define isblank nisblank
+#endif
+#ifndef HAVE_ISWBLANK
+#define iswblank niswblank
+#endif
#ifndef HAVE_STRCASECMP
#define strcasecmp nstrcasecmp
#endif
/* Public functions in chars.c. */
bool is_byte(int c);
-bool is_alnum_char(int c);
bool is_alnum_mbchar(const char *c);
-#ifdef NANO_WIDE
-bool is_alnum_wchar(wchar_t wc);
+#ifndef HAVE_ISBLANK
+bool nisblank(int c);
#endif
-bool is_blank_char(int c);
-bool is_blank_mbchar(const char *c);
-#ifdef NANO_WIDE
-bool is_blank_wchar(wchar_t wc);
+#if defined(NANO_WIDE) && !defined(HAVE_ISWBLANK)
+bool niswblank(wint_t wc);
#endif
+bool is_blank_mbchar(const char *c);
bool is_cntrl_char(int c);
-bool is_cntrl_mbchar(const char *c);
#ifdef NANO_WIDE
-bool is_cntrl_wchar(wchar_t wc);
+bool is_cntrl_wchar(wint_t wc);
#endif
+bool is_cntrl_mbchar(const char *c);
unsigned char control_rep(unsigned char c);
-char *control_mbrep(const char *c, char *crep, int *crep_len);
#ifdef NANO_WIDE
wchar_t control_wrep(wchar_t c);
#endif
+char *control_mbrep(const char *c, char *crep, int *crep_len);
int mbwidth(const char *c);
int mb_cur_max(void);
char *make_mbchar(int chr, int *chr_mb_len);
* the end of the line. */
char *parse_next_word(char *ptr)
{
- while (!is_blank_char(*ptr) && *ptr != '\0')
+ while (!isblank(*ptr) && *ptr != '\0')
ptr++;
if (*ptr == '\0')
/* Null-terminate and advance ptr. */
*ptr++ = '\0';
- while (is_blank_char(*ptr))
+ while (isblank(*ptr))
ptr++;
return ptr;
ptr = last_quote + 1;
}
if (ptr != NULL)
- while (is_blank_char(*ptr))
+ while (isblank(*ptr))
ptr++;
return ptr;
}
/* Continue until the end of the line, or a " followed by a space, a
* blank character, or \0. */
- while ((*ptr != '"' || (!is_blank_char(*(ptr + 1)) &&
+ while ((*ptr != '"' || (!isblank(*(ptr + 1)) &&
*(ptr + 1) != '\0')) && *ptr != '\0')
ptr++;
/* Null terminate and advance ptr. */
*ptr++ = '\0';
- while (is_blank_char(*ptr))
+ while (isblank(*ptr))
ptr++;
return ptr;
lineno++;
ptr = buf;
- while (is_blank_char(*ptr))
+ while (isblank(*ptr))
ptr++;
/* If we have a blank line or a comment, skip to the next