porting tio and sio

This commit is contained in:
2008-10-15 04:08:31 +00:00
parent 559d3fba6f
commit 71aed8062f
38 changed files with 15315 additions and 12634 deletions

View File

@ -143,26 +143,3 @@ static ase_ccls_t ccls =
ase_ccls_t* ase_ccls = &ccls;
ase_size_t ase_wctomb (ase_wchar_t wc, ase_mchar_t* mb, ase_size_t mblen)
{
#ifdef HAVE_WCRTOMB
mbstate_t mbs;
if (mblen < MB_CUR_MAX)
{
/* buffer too small */
return -1;
}
/* TODO: it may end with EILSEQ */
return wcrtomb (mb, wc, &mbs);
#else
#error Not Supported
#endif
}
#if 0
ase_wchar_t ase_mbtowc (ase_mchar_t* mb, int mblen)
{
}
#endif

82
ase/lib/cmn/chr_cnv.c Normal file
View File

@ -0,0 +1,82 @@
/*
* $Id$
*/
#include <ase/cmn/chr.h>
#ifdef HAVE_WCHAR_H
#include <wchar.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
ase_size_t ase_mblen (const ase_mchar_t* mb, ase_size_t mblen)
{
#ifdef HAVE_MBRLEN
size_t n;
mbstate_t mbs = { 0 };
n = mbrlen (mb, mblen, &mbs);
if (n == 0) return 1; /* a null character */
if (n == (size_t)-1) return 0; /* invalid sequence */
if (n == (size_t)-2) return mblen + 1; /* incomplete sequence */
return (ase_size_t)n;
#else
#error #### NOT SUPPORTED ####
#endif
}
ase_size_t ase_mbtowc (const ase_mchar_t* mb, ase_size_t mblen, ase_wchar_t* wc)
{
#ifdef HAVE_MBRTOWC
size_t n;
mbstate_t mbs = { 0 };
n = mbrtowc (wc, mb, mblen, &mbs);
if (n == 0)
{
*wc = ASE_WT('\0');
return 1;
}
if (n == (size_t)-1) return 0; /* invalid sequence */
if (n == (size_t)-2) return mblen + 1; /* incomplete sequence */
return (ase_size_t)n;
#else
#error #### NOT SUPPORTED ####
#endif
}
ase_size_t ase_wctomb (ase_wchar_t wc, ase_mchar_t* mb, ase_size_t mblen)
{
#ifdef HAVE_WCRTOMB
size_t n;
mbstate_t mbs = { 0 };
if (mblen < MB_CUR_MAX)
{
/* buffer too small */
return mblen + 1;
}
/* man mbsinit
* For 8-bit encodings, all states are equivalent to the initial state.
* For multibyte encodings like UTF-8, EUC-*, BIG5 or SJIS, the wide char
* acter to multibyte conversion functions never produce non-initial
* states, but the multibyte to wide-character conversion functions like
* mbrtowc(3) do produce non-initial states when interrupted in the middle
* of a character.
*/
n = wcrtomb (mb, wc, &mbs);
if (n == (size_t)-1) n = 0; // illegal character
return n;
#else
#error #### NOT SUPPORTED ####
#endif
}

View File

@ -4,7 +4,7 @@ AM_CFLAGS = -I$(top_builddir)/include
lib_LTLIBRARIES = libasecmn.la
libasecmn_la_SOURCES = mem.h chr.h \
mem.c chr.c rex.c str_bas.c str_cnv.c str_dyn.c \
mem.c chr.c chr_cnv.c rex.c str_bas.c str_cnv.c str_dyn.c \
lda.c map.c sll.c dll.c opt.c \
tio.c tio_get.c tio_put.c \
misc.c

View File

@ -1,8 +1,8 @@
# makefile.in generated by automake 1.9.2 from makefile.am.
# makefile.in generated by automake 1.10.1 from makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 Free Software Foundation, Inc.
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@ -14,17 +14,11 @@
@SET_MAKE@
SOURCES = $(libasecmn_la_SOURCES)
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ../..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
@ -57,29 +51,31 @@ am__installdirs = "$(DESTDIR)$(libdir)"
libLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(lib_LTLIBRARIES)
libasecmn_la_LIBADD =
am_libasecmn_la_OBJECTS = mem.lo chr.lo rex.lo str_bas.lo str_cnv.lo \
str_dyn.lo lda.lo map.lo sll.lo dll.lo opt.lo tio.lo \
tio_get.lo tio_put.lo misc.lo
am_libasecmn_la_OBJECTS = mem.lo chr.lo chr_cnv.lo rex.lo str_bas.lo \
str_cnv.lo str_dyn.lo lda.lo map.lo sll.lo dll.lo opt.lo \
tio.lo tio_get.lo tio_put.lo misc.lo
libasecmn_la_OBJECTS = $(am_libasecmn_la_OBJECTS)
libasecmn_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(libasecmn_la_LDFLAGS) $(LDFLAGS) -o $@
DEFAULT_INCLUDES =
depcomp = $(SHELL) $(top_srcdir)/autoconf/depcomp
am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link --tag=CC $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
SOURCES = $(libasecmn_la_SOURCES)
DIST_SOURCES = $(libasecmn_la_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AR = @AR@
AUTOCONF = @AUTOCONF@
@ -104,18 +100,18 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DSYMUTIL = @DSYMUTIL@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
ENABLE_CXX_FALSE = @ENABLE_CXX_FALSE@
ENABLE_CXX_TRUE = @ENABLE_CXX_TRUE@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
GREP = @GREP@
HAVE_CXX = @HAVE_CXX@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
@ -133,6 +129,8 @@ LIBTOOL_DEPS = @LIBTOOL_DEPS@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
NMEDIT = @NMEDIT@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@ -143,23 +141,18 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
RM = @RM@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
ac_ct_AR = @ac_ct_AR@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_ct_CJ = @ac_ct_CJ@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
ac_ct_GREP = @ac_ct_GREP@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_RM = @ac_ct_RM@
ac_ct_STRIP = @ac_ct_STRIP@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
@ -171,33 +164,44 @@ build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = nostdinc
AM_CFLAGS = -I$(top_builddir)/include
lib_LTLIBRARIES = libasecmn.la
libasecmn_la_SOURCES = mem.h chr.h \
mem.c chr.c rex.c str_bas.c str_cnv.c str_dyn.c \
mem.c chr.c chr_cnv.c rex.c str_bas.c str_cnv.c str_dyn.c \
lda.c map.c sll.c dll.c opt.c \
tio.c tio_get.c tio_put.c \
misc.c
@ -238,21 +242,21 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)"
test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
if test -f $$p; then \
f=$(am__strip_dir) \
echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
$(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
else :; fi; \
done
uninstall-libLTLIBRARIES:
@$(NORMAL_UNINSTALL)
@set -x; list='$(lib_LTLIBRARIES)'; for p in $$list; do \
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
p=$(am__strip_dir) \
echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \
$(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \
done
clean-libLTLIBRARIES:
@ -264,7 +268,7 @@ clean-libLTLIBRARIES:
rm -f "$${dir}/so_locations"; \
done
libasecmn.la: $(libasecmn_la_OBJECTS) $(libasecmn_la_DEPENDENCIES)
$(LINK) -rpath $(libdir) $(libasecmn_la_LDFLAGS) $(libasecmn_la_OBJECTS) $(libasecmn_la_LIBADD) $(LIBS)
$(libasecmn_la_LINK) -rpath $(libdir) $(libasecmn_la_OBJECTS) $(libasecmn_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@ -273,6 +277,7 @@ distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chr.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chr_cnv.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dll.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lda.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/map.Plo@am__quote@
@ -289,22 +294,22 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tio_put.Plo@am__quote@
.c.o:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
@ -315,17 +320,13 @@ mostlyclean-libtool:
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
$(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
@ -337,8 +338,8 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@ -348,13 +349,12 @@ ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
@ -368,22 +368,21 @@ distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
@ -399,7 +398,7 @@ check: check-am
all-am: makefile $(LTLIBRARIES)
installdirs:
for dir in "$(DESTDIR)$(libdir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
@ -434,7 +433,7 @@ distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-libtool distclean-tags
distclean-tags
dvi: dvi-am
@ -448,12 +447,20 @@ info-am:
install-data-am:
install-dvi: install-dvi-am
install-exec-am: install-libLTLIBRARIES
install-html: install-html-am
install-info: install-info-am
install-man:
install-pdf: install-pdf-am
install-ps: install-ps-am
installcheck-am:
maintainer-clean: maintainer-clean-am
@ -474,20 +481,23 @@ ps: ps-am
ps-am:
uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES
uninstall-am: uninstall-libLTLIBRARIES
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libLTLIBRARIES clean-libtool ctags distclean \
distclean-compile distclean-generic distclean-libtool \
distclean-tags distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-exec \
install-exec-am install-info install-info-am \
install-libLTLIBRARIES install-man install-strip installcheck \
install install-am install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am \
install-libLTLIBRARIES install-man install-pdf install-pdf-am \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-info-am \
uninstall-libLTLIBRARIES
tags uninstall uninstall-am uninstall-libLTLIBRARIES
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.

View File

@ -81,7 +81,8 @@ const ase_char_t* ase_tio_geterrstr (ase_tio_t* tio)
ASE_T("no error"),
ASE_T("out of memory"),
ASE_T("no more space"),
ASE_T("illegal sequence"),
ASE_T("illegal multibyte sequence"),
ASE_T("illegal wide character"),
ASE_T("no input function attached"),
ASE_T("input function returned an error"),
ASE_T("input function failed to open"),
@ -94,8 +95,8 @@ const ase_char_t* ase_tio_geterrstr (ase_tio_t* tio)
};
return __errstr[
(tio->errnum < 0 || tio->errnum >= ase_countof(__errstr))?
ase_countof(__errstr) - 1: tio->errnum];
(tio->errnum < 0 || tio->errnum >= ASE_COUNTOF(__errstr))?
ASE_COUNTOF(__errstr) - 1: tio->errnum];
}
int ase_tio_attin (ase_tio_t* tio, ase_tio_io_t input, void* arg)
@ -203,7 +204,7 @@ ase_ssize_t ase_tio_flush (ase_tio_t* tio)
if (n == 0) break;
left -= n;
ase_memcpy (tio->outbuf, &tio->inbuf[n], left);
ASE_MEMCPY (tio->outbuf, &tio->inbuf[n], left);
}
count = tio->outbuf_len - left;

View File

@ -16,7 +16,7 @@ ase_ssize_t ase_tio_getc (ase_tio_t* tio, ase_char_t* c)
ase_size_t seqlen;
#endif
/* TODO: more efficient to check this...
/* TODO: more efficient way to check this?
* maybe better to use ASE_ASSERT
* ASE_ASSERT (tio->input_func != ASE_NULL);
*/
@ -35,10 +35,10 @@ ase_ssize_t ase_tio_getc (ase_tio_t* tio, ase_char_t* c)
if (tio->inbuf_curp >= tio->inbuf_len)
{
getc_conv:
getc_conv:
n = tio->input_func (
ASE_TIO_IO_DATA, tio->input_arg,
&tio->inbuf[left], ASE_COUINTOF(tio->inbuf) - left);
&tio->inbuf[left], ASE_COUNTOF(tio->inbuf) - left);
if (n == 0) return 0;
if (n <= -1)
{
@ -53,27 +53,50 @@ getc_conv:
#ifdef ASE_CHAR_IS_MCHAR
curc = tio->inbuf[tio->inbuf_curp++];
#else
seqlen = ase_mcseqlen (tio->inbuf[tio->inbuf_curp]);
if (seqlen == 0) {
left = tio->inbuf_len - tio->inbuf_curp;
seqlen = ase_mblen (tio->inbuf[tio->inbuf_curp], left);
if (seqlen == 0)
{
/* illegal sequence */
tio->inbuf_curp++; /* skip one byte */
tio->errnum = ASE_TIO_EILSEQ;
return -1;
}
left = tio->inbuf_len - tio->inbuf_curp;
if (left < seqlen) {
ase_memcpy (tio->inbuf, &tio->inbuf[tio->inbuf_curp], left);
tio->inbuf_curp = 0;
tio->inbuf_len = left;
if (seqlen > left)
{
/* incomplete sequence */
if (tio->inbuf_curp > 0)
{
ASE_MEMCPY (tio->inbuf, &tio->inbuf[tio->inbuf_curp], left);
tio->inbuf_curp = 0;
tio->inbuf_len = left;
}
goto getc_conv;
}
n = ase_mctowc (&tio->inbuf[tio->inbuf_curp], seqlen, &curc);
if (n == 0) {
n = ase_mbtowc (&tio->inbuf[tio->inbuf_curp], seqlen, &curc);
if (n == 0)
{
/* illegal sequence */
tio->inbuf_curp++; /* skip one byte */
tio->errnum = ASE_TIO_EILSEQ;
return -1;
}
if (n > seqlen)
{
/* incomplete sequence -
* this check might not be needed because ase_mblen has
* checked it. would ASE_ASSERT (n <= seqlen) be enough? */
if (tio->inbuf_curp > 0)
{
ASE_MEMCPY (tio->inbuf, &tio->inbuf[tio->inbuf_curp], left);
tio->inbuf_curp = 0;
tio->inbuf_len = left;
}
goto getc_conv;
}
tio->inbuf_curp += n;
#endif
@ -89,7 +112,7 @@ ase_ssize_t ase_tio_gets (ase_tio_t* tio, ase_char_t* buf, ase_size_t size)
if (size <= 0) return 0;
n = ase_tio_getsx (tio, buf, size - 1);
if (n == -1) return -1;
buf[n] = ASE_CHAR('\0');
buf[n] = ASE_T('\0');
return n;
}
@ -116,7 +139,7 @@ ase_ssize_t ase_tio_getsx (ase_tio_t* tio, ase_char_t* buf, ase_size_t size)
if (n == 0) break;
*p++ = c;
if (c == ASE_CHAR('\n')) break;
if (c == ASE_T('\n')) break;
}
return p - buf;
@ -149,7 +172,7 @@ ase_ssize_t ase_tio_getstr (ase_tio_t* tio, ase_str_t* buf)
return -1;
}
if (c == ASE_CHAR('\n')) break;
if (c == ASE_T('\n')) break;
}
return ASE_STR_LEN(buf);

View File

@ -26,10 +26,15 @@ ase_ssize_t ase_tio_putc (ase_tio_t* tio, ase_char_t c)
return ase_tio_flush (tio);
#else
n = ase_wctomc (c, mc, ASE_COUNTOF(mc));
n = ase_wctomb (c, mc, ASE_COUNTOF(mc));
if (n == 0)
{
tio->errnum = ASE_TIO_EILSEQ;
tio->errnum = ASE_TIO_EILCHR;
return -1;
}
else if (n > ASE_COUNTOF(mc))
{
tio->errnum = ASE_TIO_ENOSPC;
return -1;
}
@ -43,7 +48,7 @@ ase_ssize_t ase_tio_putc (ase_tio_t* tio, ase_char_t c)
}
#endif
if (c == ASE_CHAR('\n') && tio->outbuf_len > 0)
if (c == ASE_T('\n') && tio->outbuf_len > 0)
{
if (ase_tio_flush(tio) == -1) return -1;
}
@ -56,7 +61,7 @@ ase_ssize_t ase_tio_puts (ase_tio_t* tio, const ase_char_t* str)
ase_ssize_t n;
const ase_char_t* p;
for (p = str; *p != ASE_CHAR('\0'); p++)
for (p = str; *p != ASE_T('\0'); p++)
{
n = ase_tio_putc (tio, *p);
if (n == -1) return -1;
@ -118,7 +123,7 @@ ase_ssize_t ase_tio_putsv (ase_tio_t* tio, ase_va_list ap)
while ((p = ase_va_arg (ap, const ase_char_t*)) != ASE_NULL)
{
if (p[0] == ASE_CHAR('\0')) continue;
if (p[0] == ASE_T('\0')) continue;
n = ase_tio_puts (tio, p);
if (n == -1) return -1;