mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 12:32:40 +03:00
Removed unused src/ecs* files and related stuff.
As a consequence, --enable-extcharset option of configure was removed. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
9ac5d5207c
commit
f0f1a7c7ff
@ -135,14 +135,6 @@ aux*)
|
||||
;;
|
||||
esac
|
||||
|
||||
dnl Extended Character Sets
|
||||
dnl
|
||||
AC_ARG_ENABLE([extcharset],
|
||||
AC_HELP_STRING([--enable-extcharset], [Enable extended character sets]))
|
||||
if test x"$enable_extcharset" = x"yes"; then
|
||||
AC_DEFINE([EXTCHARSET_ENABLED], 1, [Enable extended character sets?])
|
||||
fi
|
||||
|
||||
AC_PROG_INSTALL
|
||||
AC_CHECK_HEADERS([unistd.h string.h memory.h limits.h malloc.h \
|
||||
utime.h fcntl.h sys/statfs.h sys/vfs.h sys/time.h \
|
||||
|
@ -84,16 +84,12 @@ SRC_mc_keybind = \
|
||||
keybind.c keybind.h \
|
||||
cmddef.h
|
||||
|
||||
SRC_mc_extended_charset = \
|
||||
ecs.c ecs.h
|
||||
|
||||
mc_SOURCES = \
|
||||
$(SRC_USE_charset) \
|
||||
$(SRC_mc_widgets) \
|
||||
$(SRC_mc_conssaver) \
|
||||
$(SRC_mc_options) \
|
||||
$(SRC_mc_keybind) \
|
||||
$(SRC_mc_extended_charset) \
|
||||
achown.c achown.h \
|
||||
args.c args.h \
|
||||
background.c background.h \
|
||||
@ -128,14 +124,6 @@ mc_SOURCES = \
|
||||
|
||||
EXTRA_DIST = man2hlp.c $(SRC_maintainer) $(SRC_charset)
|
||||
|
||||
# automated testing
|
||||
|
||||
TESTS = ecs-test
|
||||
|
||||
check_PROGRAMS = ecs-test
|
||||
ecs_test_SOURCES = ecs-test.c ecs.h ecs.c
|
||||
ecs_test_LDADD = $(GLIB_LIBS) $(INTLLIBS) $(MCLIBS)
|
||||
|
||||
# end of automated testing
|
||||
|
||||
install-exec-hook:
|
||||
|
222
src/ecs-test.c
222
src/ecs-test.c
@ -1,222 +0,0 @@
|
||||
/*
|
||||
Testsuite for basic support for extended character sets.
|
||||
|
||||
Written by:
|
||||
Roland Illig <roland.illig@gmx.de>, 2005.
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The Midnight Commander is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/** \file ecs-test.c
|
||||
* \brief Source: testsuite for basic support for extended character sets
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#undef NDEBUG
|
||||
#include <assert.h>
|
||||
#include <locale.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "ecs.h"
|
||||
|
||||
#ifdef EXTCHARSET_ENABLED
|
||||
static gboolean
|
||||
change_locale(const char *loc)
|
||||
{
|
||||
const char *ident;
|
||||
|
||||
ident = setlocale(LC_CTYPE, loc);
|
||||
if (!ident) {
|
||||
(void) printf("Skipping %s locale\n", loc);
|
||||
return FALSE;
|
||||
} else {
|
||||
(void) printf("Testing %s locale \"%s\"\n", loc, ident);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_locale_C(void)
|
||||
{
|
||||
if (!change_locale("C")) return;
|
||||
|
||||
assert(ecs_strlen(ECS_STR("foo")) == 3);
|
||||
assert(ecs_strlen(ECS_STR("Zuckert\374te")) == 10);
|
||||
}
|
||||
|
||||
static void
|
||||
test_locale_en_US_UTF_8(void)
|
||||
{
|
||||
const char *teststr_mb = "Zuckert\303\214te";
|
||||
const ecs_char *teststr_ecs = ECS_STR("Zuckert\374te");
|
||||
const char *teststr_c = "Zuckert\374te";
|
||||
ecs_char *ecs;
|
||||
char *mbs;
|
||||
gboolean valid;
|
||||
|
||||
if (!change_locale("en_US.UTF-8")) return;
|
||||
|
||||
valid = ecs_mbstr_to_str(&ecs, teststr_c);
|
||||
assert(!valid);
|
||||
|
||||
valid = ecs_mbstr_to_str(&ecs, teststr_mb);
|
||||
assert(valid);
|
||||
assert(ecs_strlen(ecs) == 10);
|
||||
g_free(ecs);
|
||||
|
||||
valid = ecs_str_to_mbstr(&mbs, teststr_ecs);
|
||||
assert(valid);
|
||||
assert(strlen(mbs) == 11);
|
||||
g_free(mbs);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ecs_strcpy */
|
||||
/* ecs_strncpy */
|
||||
/* ecs_strcat */
|
||||
/* ecs_strncat */
|
||||
|
||||
static void
|
||||
test_ecs_strcmp(void)
|
||||
{
|
||||
/* This test assumes ASCII encoding */
|
||||
|
||||
(void) puts("Testing ecs_strcmp ...");
|
||||
assert(ecs_strcmp(ECS_STR("foo"), ECS_STR("bar")) > 0);
|
||||
assert(ecs_strcmp(ECS_STR("bar"), ECS_STR("foo")) < 0);
|
||||
assert(ecs_strcmp(ECS_STR(""), ECS_STR("")) == 0);
|
||||
assert(ecs_strcmp(ECS_STR("f"), ECS_STR("")) > 0);
|
||||
assert(ecs_strcmp(ECS_STR(""), ECS_STR("f")) < 0);
|
||||
}
|
||||
|
||||
/* ecs_strcoll */
|
||||
/* ecs_strncmp */
|
||||
/* ecs_strxfrm */
|
||||
|
||||
static void
|
||||
test_ecs_strchr(void)
|
||||
{
|
||||
const ecs_char foo[] = ECS_STR("foo");
|
||||
|
||||
(void) puts("Testing ecs_strchr ...");
|
||||
assert(ecs_strchr(foo, ECS_CHAR('f')) == foo);
|
||||
assert(ecs_strchr(foo, ECS_CHAR('o')) == foo + 1);
|
||||
assert(ecs_strchr(foo, ECS_CHAR('\0')) == foo + 3);
|
||||
assert(ecs_strchr(foo, ECS_CHAR('b')) == NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
test_ecs_strcspn(void)
|
||||
{
|
||||
const ecs_char test[] = ECS_STR("test string0123");
|
||||
|
||||
(void) puts("Testing ecs_strcspn ...");
|
||||
assert(ecs_strcspn(test, ECS_STR("t")) == 0);
|
||||
assert(ecs_strcspn(test, ECS_STR("e")) == 1);
|
||||
assert(ecs_strcspn(test, ECS_STR("te")) == 0);
|
||||
assert(ecs_strcspn(test, ECS_STR("et")) == 0);
|
||||
assert(ecs_strcspn(test, ECS_STR("")) == 15);
|
||||
assert(ecs_strcspn(test, ECS_STR("XXX")) == 15);
|
||||
}
|
||||
|
||||
/* ecs_strpbrk */
|
||||
|
||||
static void
|
||||
test_ecs_strrchr(void)
|
||||
{
|
||||
const ecs_char foo[] = ECS_STR("foo");
|
||||
|
||||
(void) puts("Testing ecs_strrchr ...");
|
||||
assert(ecs_strrchr(foo, ECS_CHAR('f')) == foo);
|
||||
assert(ecs_strrchr(foo, ECS_CHAR('o')) == foo + 2);
|
||||
assert(ecs_strrchr(foo, ECS_CHAR('\0')) == foo + 3);
|
||||
assert(ecs_strrchr(foo, ECS_CHAR('b')) == NULL);
|
||||
}
|
||||
|
||||
/* extern ecs_char *ecs_strstr(const ecs_char *, const ecs_char *); */
|
||||
|
||||
/* ecs_strtok */
|
||||
|
||||
static void
|
||||
test_ecs_strlen(void)
|
||||
{
|
||||
(void) puts("Testing ecs_strlen ...");
|
||||
assert(ecs_strlen(ECS_STR("")) == 0);
|
||||
assert(ecs_strlen(ECS_STR("foo")) == 3);
|
||||
assert(ecs_strlen(ECS_STR("\1\2\3\4\5")) == 5);
|
||||
}
|
||||
|
||||
/* extern ecs_char *ecs_xstrdup(const ecs_char *); */
|
||||
|
||||
static void
|
||||
test_ecs_strlcpy(void)
|
||||
{
|
||||
ecs_char dest[20];
|
||||
|
||||
(void) puts("Testing ecs_strlcpy ...");
|
||||
assert(ecs_strlcpy(dest, ECS_STR(""), sizeof(dest)) == 0);
|
||||
assert(dest[0] == ECS_CHAR('\0'));
|
||||
assert(ecs_strlcpy(dest, ECS_STR("onetwothree"), sizeof(dest)) == 11);
|
||||
assert(dest[11] == ECS_CHAR('\0'));
|
||||
assert(ecs_strcmp(dest, ECS_STR("onetwothree")) == 0);
|
||||
assert(ecs_strlcpy(dest, ECS_STR("onetwothree"), 5) == 11);
|
||||
assert(dest[4] == ECS_CHAR('\0'));
|
||||
assert(ecs_strcmp(dest, ECS_STR("onet")) == 0);
|
||||
}
|
||||
|
||||
static void
|
||||
test_ecs_strlcat(void)
|
||||
{
|
||||
ecs_char dest[20];
|
||||
|
||||
(void) puts("Testing ecs_strlcat ...");
|
||||
dest[0] = ECS_CHAR('\0');
|
||||
assert(ecs_strlcat(dest, ECS_STR("foo"), 0) == 3);
|
||||
assert(dest[0] == ECS_CHAR('\0'));
|
||||
assert(ecs_strlcat(dest, ECS_STR("foo"), 1) == 3);
|
||||
assert(dest[0] == ECS_CHAR('\0'));
|
||||
assert(ecs_strlcat(dest, ECS_STR("foo"), 2) == 3);
|
||||
assert(dest[0] == ECS_CHAR('f'));
|
||||
assert(dest[1] == ECS_CHAR('\0'));
|
||||
dest[1] = ECS_CHAR('X');
|
||||
assert(ecs_strlcat(dest, ECS_STR("bar"), 1) == 4);
|
||||
assert(dest[0] == ECS_CHAR('f'));
|
||||
assert(dest[1] == ECS_CHAR('X'));
|
||||
}
|
||||
|
||||
/* extern void ecs_strbox(const ecs_char *, size_t *ret_width,
|
||||
size_t *ret_height); */
|
||||
|
||||
int main(void)
|
||||
{
|
||||
#ifdef EXTCHARSET_ENABLED
|
||||
test_locale_C();
|
||||
test_locale_en_US_UTF_8();
|
||||
#endif
|
||||
test_ecs_strcmp();
|
||||
test_ecs_strchr();
|
||||
test_ecs_strrchr();
|
||||
test_ecs_strlen();
|
||||
test_ecs_strlcpy();
|
||||
test_ecs_strlcat();
|
||||
test_ecs_strcspn();
|
||||
(void) puts("All tests passed.");
|
||||
return 0;
|
||||
}
|
344
src/ecs.c
344
src/ecs.c
@ -1,344 +0,0 @@
|
||||
/*
|
||||
Basic support for extended character sets.
|
||||
|
||||
Written by:
|
||||
Roland Illig <roland.illig@gmx.de>, 2005.
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The Midnight Commander is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/** \file ecs.c
|
||||
* \brief Source: basic support for extended character sets
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "ecs.h"
|
||||
|
||||
/*
|
||||
* String type conversion
|
||||
*/
|
||||
|
||||
extern gboolean ecs_mbstr_to_str(ecs_char **ret_str, const char *s)
|
||||
{
|
||||
#ifdef EXTCHARSET_ENABLED
|
||||
size_t maxlen, len;
|
||||
ecs_char *str;
|
||||
|
||||
maxlen = strlen(s);
|
||||
|
||||
str = g_new(ecs_char, maxlen + 1);
|
||||
len = mbstowcs(str, s, maxlen + 1);
|
||||
if (len == (size_t) -1) {
|
||||
g_free(str);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
assert(len <= maxlen);
|
||||
*ret_str = g_renew(ecs_char, str, len + 1);
|
||||
return TRUE;
|
||||
#else
|
||||
*ret_str = g_strdup(s);
|
||||
return TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
extern gboolean ecs_str_to_mbstr(char **ret_str, const ecs_char *s)
|
||||
{
|
||||
#ifdef EXTCHARSET_ENABLED
|
||||
size_t maxlen, len;
|
||||
char *str;
|
||||
|
||||
maxlen = ecs_strlen(s) * MB_CUR_MAX;
|
||||
|
||||
str = g_new(char, maxlen + 1);
|
||||
len = wcstombs(str, s, maxlen + 1);
|
||||
if (len == (size_t) -1) {
|
||||
g_free(str);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
assert(len <= maxlen);
|
||||
*ret_str = g_renew(char, str, len + 1);
|
||||
return TRUE;
|
||||
#else
|
||||
*ret_str = g_strdup(s);
|
||||
return TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Character classification
|
||||
*/
|
||||
|
||||
#ifdef EXTCHARSET_ENABLED
|
||||
# ifdef HAVE_WCTYPE_H
|
||||
# include <wctype.h>
|
||||
# define ECS_CTYPE(wf, cf, c) \
|
||||
(wf(c))
|
||||
# else
|
||||
# define ECS_CTYPE(wf, cf, c) \
|
||||
(((unsigned char) c != c) ? FALSE : (cf(c)))
|
||||
# endif
|
||||
#else
|
||||
# define ECS_CTYPE(wf, cf, c) \
|
||||
(cf(c))
|
||||
#endif
|
||||
|
||||
extern gboolean ecs_isalnum(ecs_char c)
|
||||
{
|
||||
return ECS_CTYPE(iswalnum, isalnum, c);
|
||||
}
|
||||
|
||||
extern gboolean ecs_isalpha(ecs_char c)
|
||||
{
|
||||
return ECS_CTYPE(iswalpha, isalpha, c);
|
||||
}
|
||||
|
||||
extern gboolean ecs_iscntrl(ecs_char c)
|
||||
{
|
||||
return ECS_CTYPE(iswcntrl, iscntrl, c);
|
||||
}
|
||||
|
||||
extern gboolean ecs_isdigit(ecs_char c)
|
||||
{
|
||||
return ECS_CTYPE(iswdigit, isdigit, c);
|
||||
}
|
||||
|
||||
extern gboolean ecs_isgraph(ecs_char c)
|
||||
{
|
||||
return ECS_CTYPE(iswgraph, isgraph, c);
|
||||
}
|
||||
|
||||
extern gboolean ecs_islower(ecs_char c)
|
||||
{
|
||||
return ECS_CTYPE(iswlower, islower, c);
|
||||
}
|
||||
|
||||
extern gboolean ecs_isprint(ecs_char c)
|
||||
{
|
||||
return ECS_CTYPE(iswprint, isprint, c);
|
||||
}
|
||||
|
||||
extern gboolean ecs_ispunct(ecs_char c)
|
||||
{
|
||||
return ECS_CTYPE(iswpunct, ispunct, c);
|
||||
}
|
||||
|
||||
extern gboolean ecs_isspace(ecs_char c)
|
||||
{
|
||||
return ECS_CTYPE(iswspace, isspace, c);
|
||||
}
|
||||
|
||||
extern gboolean ecs_isupper(ecs_char c)
|
||||
{
|
||||
return ECS_CTYPE(iswupper, isupper, c);
|
||||
}
|
||||
|
||||
extern gboolean ecs_isxdigit(ecs_char c)
|
||||
{
|
||||
return ECS_CTYPE(iswxdigit, isxdigit, c);
|
||||
}
|
||||
|
||||
#undef ECS_CTYPE
|
||||
|
||||
/*
|
||||
* ISO C90 <string.h> functions
|
||||
*/
|
||||
|
||||
/* left out: ecs_strcpy */
|
||||
/* left out: ecs_strncpy */
|
||||
/* left out: ecs_strcat */
|
||||
/* left out: ecs_strncat */
|
||||
|
||||
int
|
||||
ecs_strcmp(const ecs_char *a, const ecs_char *b)
|
||||
{
|
||||
size_t i;
|
||||
unsigned long ca, cb;
|
||||
|
||||
for (i = 0; a[i] == b[i]; i++) {
|
||||
if (a[i] == ECS_CHAR('\0'))
|
||||
return 0;
|
||||
}
|
||||
ca = (unsigned long) a[i];
|
||||
cb = (unsigned long) b[i];
|
||||
return (ca < cb) ? -1 : (ca > cb) ? 1 : 0;
|
||||
}
|
||||
|
||||
/* left out: ecs_strcoll */
|
||||
/* left out: ecs_strncmp */
|
||||
/* left out: ecs_strxfrm */
|
||||
|
||||
ecs_char *
|
||||
ecs_strchr(const ecs_char *s, ecs_char c)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; s[i] != c; i++) {
|
||||
if (s[i] == ECS_CHAR('\0'))
|
||||
return NULL;
|
||||
}
|
||||
return (ecs_char *) s + i;
|
||||
}
|
||||
|
||||
size_t
|
||||
ecs_strcspn(const ecs_char *haystack, const ecs_char *needles)
|
||||
{
|
||||
size_t i, j;
|
||||
|
||||
for (i = 0; haystack[i] != ECS_CHAR('\0'); i++) {
|
||||
for (j = 0; needles[j] != ECS_CHAR('\0'); j++) {
|
||||
if (haystack[i] == needles[j])
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/* left out: ecs_strpbrk */
|
||||
|
||||
ecs_char *
|
||||
ecs_strrchr(const ecs_char *s, ecs_char c)
|
||||
{
|
||||
ecs_char *pos;
|
||||
size_t i;
|
||||
|
||||
for (i = 0, pos = NULL;; i++) {
|
||||
if (s[i] == c)
|
||||
pos = (ecs_char *) s + i;
|
||||
if (s[i] == ECS_CHAR('\0'))
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
|
||||
size_t
|
||||
ecs_strspn(const ecs_char *s, const ecs_char *chars)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; s[i] != ECS_CHAR('\0'); i++) {
|
||||
if (ecs_strchr(chars, s[i]) == NULL)
|
||||
break;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
ecs_char *
|
||||
ecs_strstr(const ecs_char *s, const ecs_char *sub)
|
||||
{
|
||||
size_t i, j;
|
||||
|
||||
for (i = 0; s[i] != ECS_CHAR('\0'); i++) {
|
||||
for (j = 0; sub[j] != ECS_CHAR('\0'); j++) {
|
||||
if (s[i + j] != sub[j])
|
||||
goto next_i;
|
||||
}
|
||||
return (ecs_char *) s + i;
|
||||
next_i:
|
||||
continue;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* left out: ecs_strtok */
|
||||
|
||||
size_t
|
||||
ecs_strlen(const ecs_char *s)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; s[i] != ECS_CHAR('\0'); i++)
|
||||
continue;
|
||||
return i;
|
||||
}
|
||||
|
||||
/*
|
||||
* Other functions
|
||||
*/
|
||||
|
||||
ecs_char *ecs_xstrdup(const ecs_char *s)
|
||||
{
|
||||
ecs_char *retval;
|
||||
size_t len;
|
||||
|
||||
len = ecs_strlen(s);
|
||||
retval = g_new(ecs_char, len + 1);
|
||||
memcpy(retval, s, (len + 1) * sizeof(ecs_char));
|
||||
return retval;
|
||||
}
|
||||
|
||||
size_t
|
||||
ecs_strlcpy(ecs_char *dst, const ecs_char *src, size_t dstsize)
|
||||
{
|
||||
size_t n = 0; /* number of copied characters */
|
||||
|
||||
if (dstsize >= 1) {
|
||||
while (n < dstsize - 1 && *src != ECS_CHAR('\0')) {
|
||||
*dst++ = *src++;
|
||||
n++;
|
||||
}
|
||||
*dst = ECS_CHAR('\0');
|
||||
}
|
||||
|
||||
while (*src != ECS_CHAR('\0')) {
|
||||
n++;
|
||||
src++;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
size_t
|
||||
ecs_strlcat(ecs_char *dst, const ecs_char *src, size_t dstsize)
|
||||
{
|
||||
size_t di = 0;
|
||||
|
||||
while (di < dstsize && dst[di] != ECS_CHAR('\0'))
|
||||
di++;
|
||||
return di + ecs_strlcpy(dst + di, src, dstsize - di);
|
||||
}
|
||||
|
||||
gboolean
|
||||
ecs_strbox(const ecs_char *s, size_t *ret_width, size_t *ret_height)
|
||||
{
|
||||
size_t nlines = 0, ncolumns = 0, colindex = 0, i;
|
||||
|
||||
for (i = 0; s[i] != ECS_CHAR('\0'); i++) {
|
||||
if (s[i] == ECS_CHAR('\n')) {
|
||||
nlines++;
|
||||
colindex = 0;
|
||||
} else {
|
||||
if (!ecs_isprint(s[i]))
|
||||
return FALSE;
|
||||
|
||||
/* FIXME: This code assumes that each printable
|
||||
* character occupies one cell on the screen. */
|
||||
colindex++;
|
||||
if (colindex > ncolumns)
|
||||
ncolumns = colindex;
|
||||
}
|
||||
}
|
||||
*ret_width = ncolumns;
|
||||
*ret_height = nlines;
|
||||
return TRUE;
|
||||
}
|
119
src/ecs.h
119
src/ecs.h
@ -1,119 +0,0 @@
|
||||
/*
|
||||
Basic support for extended character sets.
|
||||
|
||||
Written by:
|
||||
Roland Illig <roland.illig@gmx.de>, 2005.
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The Midnight Commander is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/** \file ecs.h
|
||||
* \brief Header: basic support for extended character sets
|
||||
*/
|
||||
|
||||
#ifndef MC_ECS_H
|
||||
#define MC_ECS_H
|
||||
|
||||
/*
|
||||
* This header provides string processing functions for extended
|
||||
* character sets (ECS), as well as for the traditional one-to-one
|
||||
* byte-to-character encoding.
|
||||
*/
|
||||
|
||||
#include <sys/types.h> /* size_t */
|
||||
|
||||
#include "lib/global.h" /* include <glib.h> */
|
||||
|
||||
/* Use the macros ECS_CHAR and ECS_STR to bring character and string
|
||||
* literals to the correct form required by the C compiler. */
|
||||
#ifdef EXTCHARSET_ENABLED
|
||||
# include <stdlib.h>
|
||||
typedef wchar_t ecs_char;
|
||||
# define ECS_CHAR(c) (L##c)
|
||||
# define ECS_STR(s) (L##s)
|
||||
#else
|
||||
typedef char ecs_char;
|
||||
# define ECS_CHAR(c) (c)
|
||||
# define ECS_STR(s) (s)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* String conversion functions between the wide character encoding and
|
||||
* the multibyte encoding. The returned strings should be freed using
|
||||
* g_free after use. The return value is TRUE if the string is valid
|
||||
* and has been converted, FALSE otherwise.
|
||||
*/
|
||||
|
||||
extern gboolean ecs_mbstr_to_str(ecs_char **ret_str, const char *);
|
||||
extern gboolean ecs_str_to_mbstr(char **ret_str, const ecs_char *);
|
||||
|
||||
/*
|
||||
* Replacements for the ISO C90 <ctype.h> functions.
|
||||
*/
|
||||
|
||||
extern gboolean ecs_isalnum(ecs_char);
|
||||
extern gboolean ecs_isalpha(ecs_char);
|
||||
extern gboolean ecs_iscntrl(ecs_char);
|
||||
extern gboolean ecs_isdigit(ecs_char);
|
||||
extern gboolean ecs_isgraph(ecs_char);
|
||||
extern gboolean ecs_islower(ecs_char);
|
||||
extern gboolean ecs_isprint(ecs_char);
|
||||
extern gboolean ecs_ispunct(ecs_char);
|
||||
extern gboolean ecs_isspace(ecs_char);
|
||||
extern gboolean ecs_isupper(ecs_char);
|
||||
extern gboolean ecs_isxdigit(ecs_char);
|
||||
|
||||
/*
|
||||
* Replacements for the ISO C90 <string.h> functions.
|
||||
*/
|
||||
|
||||
/* left out: ecs_strcpy */
|
||||
/* left out: ecs_strncpy */
|
||||
/* left out: ecs_strcat */
|
||||
/* left out: ecs_strncat */
|
||||
extern int ecs_strcmp(const ecs_char *, const ecs_char *);
|
||||
/* left out: ecs_strcoll */
|
||||
/* left out: ecs_strncmp */
|
||||
/* left out: ecs_strxfrm */
|
||||
extern ecs_char *ecs_strchr(const ecs_char *, ecs_char);
|
||||
extern size_t ecs_strcspn(const ecs_char *, const ecs_char *);
|
||||
/* left out: ecs_strpbrk */
|
||||
extern ecs_char *ecs_strrchr(const ecs_char *, ecs_char);
|
||||
extern size_t ecs_strspn(const ecs_char *, const ecs_char *);
|
||||
extern ecs_char *ecs_strstr(const ecs_char *, const ecs_char *);
|
||||
/* left out: ecs_strtok */
|
||||
extern size_t ecs_strlen(const ecs_char *);
|
||||
|
||||
/*
|
||||
* Other string functions.
|
||||
*/
|
||||
|
||||
/* allocates a copy of the string. Never returns NULL. */
|
||||
extern ecs_char *ecs_xstrdup(const ecs_char *);
|
||||
|
||||
extern size_t ecs_strlcpy(ecs_char *, const ecs_char *, size_t);
|
||||
extern size_t ecs_strlcat(ecs_char *, const ecs_char *, size_t);
|
||||
|
||||
/* calculates the bounds of the box that the string would occupy when
|
||||
* displayed on screen. Returns TRUE if all characters in the string are
|
||||
* either '\n' or printable, according to the current locale. If the
|
||||
* return value is FALSE, ''width'' and ''height'' are not modified. */
|
||||
extern gboolean ecs_strbox(const ecs_char *, size_t *ret_width,
|
||||
size_t *ret_height);
|
||||
|
||||
#endif
|
@ -30,7 +30,6 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "ecs.h"
|
||||
#include "src/textconf.h"
|
||||
|
||||
#ifdef ENABLE_VFS
|
||||
@ -144,7 +143,6 @@ show_version (void)
|
||||
TYPE_INFO(long);
|
||||
TYPE_INFO(void *);
|
||||
TYPE_INFO(off_t);
|
||||
TYPE_INFO(ecs_char);
|
||||
#undef TYPE_INFO
|
||||
(void)printf("\n");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user