fixed a bug in the default log callback

This commit is contained in:
hyunghwan.chung 2018-03-19 09:50:36 +00:00
parent fe31b6fab3
commit 6a5ff66580
5 changed files with 21 additions and 38 deletions

View File

@ -354,7 +354,6 @@ pdfdir = @pdfdir@
prefix = @prefix@ prefix = @prefix@
program_transform_name = @program_transform_name@ program_transform_name = @program_transform_name@
psdir = @psdir@ psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@ sharedstatedir = @sharedstatedir@
srcdir = @srcdir@ srcdir = @srcdir@
@ -585,7 +584,7 @@ distdir: $(DISTFILES)
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r "$(distdir)" || chmod -R a+r "$(distdir)"
dist-gzip: distdir dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz
$(am__post_remove_distdir) $(am__post_remove_distdir)
dist-bzip2: distdir dist-bzip2: distdir
@ -611,7 +610,7 @@ dist-shar: distdir
@echo WARNING: "Support for shar distribution archives is" \ @echo WARNING: "Support for shar distribution archives is" \
"deprecated." >&2 "deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz
$(am__post_remove_distdir) $(am__post_remove_distdir)
dist-zip: distdir dist-zip: distdir
@ -629,7 +628,7 @@ dist dist-all:
distcheck: dist distcheck: dist
case '$(DIST_ARCHIVES)' in \ case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \ *.tar.gz*) \
GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \ *.tar.bz2*) \
bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.lz*) \ *.tar.lz*) \
@ -639,7 +638,7 @@ distcheck: dist
*.tar.Z*) \ *.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \ *.shar.gz*) \
GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\
*.zip*) \ *.zip*) \
unzip $(distdir).zip ;;\ unzip $(distdir).zip ;;\
esac esac

14
moo/configure vendored
View File

@ -786,7 +786,6 @@ infodir
docdir docdir
oldincludedir oldincludedir
includedir includedir
runstatedir
localstatedir localstatedir
sharedstatedir sharedstatedir
sysconfdir sysconfdir
@ -882,7 +881,6 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc' sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com' sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var' localstatedir='${prefix}/var'
runstatedir='${localstatedir}/run'
includedir='${prefix}/include' includedir='${prefix}/include'
oldincludedir='/usr/include' oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@ -1135,15 +1133,6 @@ do
| -silent | --silent | --silen | --sile | --sil) | -silent | --silent | --silen | --sile | --sil)
silent=yes ;; silent=yes ;;
-runstatedir | --runstatedir | --runstatedi | --runstated \
| --runstate | --runstat | --runsta | --runst | --runs \
| --run | --ru | --r)
ac_prev=runstatedir ;;
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
| --run=* | --ru=* | --r=*)
runstatedir=$ac_optarg ;;
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;; ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@ -1281,7 +1270,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \ datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
libdir localedir mandir runstatedir libdir localedir mandir
do do
eval ac_val=\$$ac_var eval ac_val=\$$ac_var
# Remove trailing slashes. # Remove trailing slashes.
@ -1434,7 +1423,6 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var] --localstatedir=DIR modifiable single-machine data [PREFIX/var]
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib] --libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include] --includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include] --oldincludedir=DIR C header files for non-gcc [/usr/include]

View File

@ -397,7 +397,6 @@ pdfdir = @pdfdir@
prefix = @prefix@ prefix = @prefix@
program_transform_name = @program_transform_name@ program_transform_name = @program_transform_name@
psdir = @psdir@ psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@ sharedstatedir = @sharedstatedir@
srcdir = @srcdir@ srcdir = @srcdir@

View File

@ -558,8 +558,6 @@ static void free_heap (moo_t* moo, void* ptr)
/* nothing to do */ /* nothing to do */
#else #else
static int write_all (int fd, const moo_bch_t* ptr, moo_oow_t len) static int write_all (int fd, const moo_bch_t* ptr, moo_oow_t len)
{ {
while (len > 0) while (len > 0)
@ -595,7 +593,7 @@ static int write_all (int fd, const moo_bch_t* ptr, moo_oow_t len)
} }
#endif #endif
static int write_log (moo_t* moo, const moo_bch_t* ptr, moo_oow_t len) static int write_log (moo_t* moo, int fd, const moo_bch_t* ptr, moo_oow_t len)
{ {
xtn_t* xtn; xtn_t* xtn;
@ -618,7 +616,7 @@ static int write_log (moo_t* moo, const moo_bch_t* ptr, moo_oow_t len)
if (xtn->logbuf.len >= MOO_COUNTOF(xtn->logbuf.buf)) if (xtn->logbuf.len >= MOO_COUNTOF(xtn->logbuf.buf))
{ {
int n; int n;
n = write_all(xtn->logfd, xtn->logbuf.buf, xtn->logbuf.len); n = write_all(fd, xtn->logbuf.buf, xtn->logbuf.len);
xtn->logbuf.len = 0; xtn->logbuf.len = 0;
if (n <= -1) return -1; if (n <= -1) return -1;
} }
@ -630,7 +628,7 @@ static int write_log (moo_t* moo, const moo_bch_t* ptr, moo_oow_t len)
rcapa = MOO_COUNTOF(xtn->logbuf.buf); rcapa = MOO_COUNTOF(xtn->logbuf.buf);
if (len >= rcapa) if (len >= rcapa)
{ {
if (write_all(xtn->logfd, ptr, rcapa) <= -1) return -1; if (write_all(fd, ptr, rcapa) <= -1) return -1;
ptr += rcapa; ptr += rcapa;
len -= rcapa; len -= rcapa;
} }
@ -648,13 +646,13 @@ static int write_log (moo_t* moo, const moo_bch_t* ptr, moo_oow_t len)
return 0; return 0;
} }
static void flush_log (moo_t* moo) static void flush_log (moo_t* moo, int fd)
{ {
xtn_t* xtn; xtn_t* xtn;
xtn = moo_getxtn(moo); xtn = moo_getxtn(moo);
if (xtn->logbuf.len > 0) if (xtn->logbuf.len > 0)
{ {
write_all (xtn->logfd, xtn->logbuf.buf, xtn->logbuf.len); write_all (fd, xtn->logbuf.buf, xtn->logbuf.len);
xtn->logbuf.len = 0; xtn->logbuf.len = 0;
} }
} }
@ -718,14 +716,14 @@ static void log_write (moo_t* moo, unsigned int mask, const moo_ooch_t* msg, moo
tslen = 25; tslen = 25;
} }
#endif #endif
write_log (moo, ts, tslen); write_log (moo, logfd, ts, tslen);
} }
if (xtn->logfd_istty) if (logfd == xtn->logfd && xtn->logfd_istty)
{ {
if (mask & MOO_LOG_FATAL) write_log (moo, "\x1B[1;31m", 7); if (mask & MOO_LOG_FATAL) write_log (moo, logfd, "\x1B[1;31m", 7);
else if (mask & MOO_LOG_ERROR) write_log (moo, "\x1B[1;32m", 7); else if (mask & MOO_LOG_ERROR) write_log (moo, logfd, "\x1B[1;32m", 7);
else if (mask & MOO_LOG_WARN) write_log (moo, "\x1B[1;33m", 7); else if (mask & MOO_LOG_WARN) write_log (moo, logfd, "\x1B[1;33m", 7);
} }
#if defined(MOO_OOCH_IS_UCH) #if defined(MOO_OOCH_IS_UCH)
@ -735,7 +733,7 @@ static void log_write (moo_t* moo, unsigned int mask, const moo_ooch_t* msg, moo
ucslen = len; ucslen = len;
bcslen = MOO_COUNTOF(buf); bcslen = MOO_COUNTOF(buf);
n = moo_convootobchars (moo, &msg[msgidx], &ucslen, buf, &bcslen); n = moo_convootobchars(moo, &msg[msgidx], &ucslen, buf, &bcslen);
if (n == 0 || n == -2) if (n == 0 || n == -2)
{ {
/* n = 0: /* n = 0:
@ -747,7 +745,7 @@ static void log_write (moo_t* moo, unsigned int mask, const moo_ooch_t* msg, moo
MOO_ASSERT (moo, ucslen > 0); /* if this fails, the buffer size must be increased */ MOO_ASSERT (moo, ucslen > 0); /* if this fails, the buffer size must be increased */
/* attempt to write all converted characters */ /* attempt to write all converted characters */
if (write_log (moo, buf, bcslen) <= -1) break; if (write_log(moo, logfd, buf, bcslen) <= -1) break;
if (n == 0) break; if (n == 0) break;
else else
@ -763,15 +761,15 @@ static void log_write (moo_t* moo, unsigned int mask, const moo_ooch_t* msg, moo
} }
} }
#else #else
write_log (moo, msg, len); write_log (moo, logfd, msg, len);
#endif #endif
if (xtn->logfd_istty) if (logfd == xtn->logfd && xtn->logfd_istty)
{ {
if (mask & (MOO_LOG_FATAL | MOO_LOG_ERROR | MOO_LOG_WARN)) write_log (moo, "\x1B[0m", 4); if (mask & (MOO_LOG_FATAL | MOO_LOG_ERROR | MOO_LOG_WARN)) write_log (moo, logfd, "\x1B[0m", 4);
} }
flush_log (moo); flush_log (moo, logfd);
} }
static void syserrstrb (moo_t* moo, int syserr, moo_bch_t* buf, moo_oow_t len) static void syserrstrb (moo_t* moo, int syserr, moo_bch_t* buf, moo_oow_t len)

View File

@ -423,7 +423,6 @@ pdfdir = @pdfdir@
prefix = @prefix@ prefix = @prefix@
program_transform_name = @program_transform_name@ program_transform_name = @program_transform_name@
psdir = @psdir@ psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@ sharedstatedir = @sharedstatedir@
srcdir = @srcdir@ srcdir = @srcdir@