fixed some wrong code

This commit is contained in:
hyunghwan.chung 2017-01-09 14:52:15 +00:00
parent cd79383202
commit 95885e4dec
9 changed files with 94 additions and 54 deletions

View File

@ -47,10 +47,10 @@ libmoo_la_SOURCES = \
logfmt.c \
gc.c \
heap.c \
moo.c \
obj.c \
proc.c \
rbt.c \
moo.c \
sym.c \
utf8.c \
utl.c

View File

@ -139,8 +139,8 @@ libmoo_la_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1)
am_libmoo_la_OBJECTS = libmoo_la-bigint.lo libmoo_la-comp.lo \
libmoo_la-debug.lo libmoo_la-decode.lo libmoo_la-dic.lo \
libmoo_la-err.lo libmoo_la-exec.lo libmoo_la-logfmt.lo \
libmoo_la-gc.lo libmoo_la-heap.lo libmoo_la-obj.lo \
libmoo_la-proc.lo libmoo_la-rbt.lo libmoo_la-moo.lo \
libmoo_la-gc.lo libmoo_la-heap.lo libmoo_la-moo.lo \
libmoo_la-obj.lo libmoo_la-proc.lo libmoo_la-rbt.lo \
libmoo_la-sym.lo libmoo_la-utf8.lo libmoo_la-utl.lo
libmoo_la_OBJECTS = $(am_libmoo_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
@ -416,10 +416,10 @@ libmoo_la_SOURCES = \
logfmt.c \
gc.c \
heap.c \
moo.c \
obj.c \
proc.c \
rbt.c \
moo.c \
sym.c \
utf8.c \
utl.c
@ -692,6 +692,13 @@ libmoo_la-heap.lo: heap.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmoo_la-heap.lo `test -f 'heap.c' || echo '$(srcdir)/'`heap.c
libmoo_la-moo.lo: moo.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmoo_la-moo.lo -MD -MP -MF $(DEPDIR)/libmoo_la-moo.Tpo -c -o libmoo_la-moo.lo `test -f 'moo.c' || echo '$(srcdir)/'`moo.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmoo_la-moo.Tpo $(DEPDIR)/libmoo_la-moo.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='moo.c' object='libmoo_la-moo.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmoo_la-moo.lo `test -f 'moo.c' || echo '$(srcdir)/'`moo.c
libmoo_la-obj.lo: obj.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmoo_la-obj.lo -MD -MP -MF $(DEPDIR)/libmoo_la-obj.Tpo -c -o libmoo_la-obj.lo `test -f 'obj.c' || echo '$(srcdir)/'`obj.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmoo_la-obj.Tpo $(DEPDIR)/libmoo_la-obj.Plo
@ -713,13 +720,6 @@ libmoo_la-rbt.lo: rbt.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmoo_la-rbt.lo `test -f 'rbt.c' || echo '$(srcdir)/'`rbt.c
libmoo_la-moo.lo: moo.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmoo_la-moo.lo -MD -MP -MF $(DEPDIR)/libmoo_la-moo.Tpo -c -o libmoo_la-moo.lo `test -f 'moo.c' || echo '$(srcdir)/'`moo.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmoo_la-moo.Tpo $(DEPDIR)/libmoo_la-moo.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='moo.c' object='libmoo_la-moo.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmoo_la-moo.lo `test -f 'moo.c' || echo '$(srcdir)/'`moo.c
libmoo_la-sym.lo: sym.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmoo_la-sym.lo -MD -MP -MF $(DEPDIR)/libmoo_la-sym.Tpo -c -o libmoo_la-sym.lo `test -f 'sym.c' || echo '$(srcdir)/'`sym.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmoo_la-sym.Tpo $(DEPDIR)/libmoo_la-sym.Plo

View File

@ -166,7 +166,12 @@ const moo_ooch_t* moo_synerrnumtoerrstr (moo_synerrnum_t errnum)
# include <os2.h>
#elif defined(__DOS__)
# include <dos.h>
# if defined(_INTELC32_)
# define DOS_EXIT 0x4C
# else
# include <dosfunc.h>
# endif
# include <errno.h>
#elif defined(vms) || defined(__vms)
# define __NEW_STARLET 1
# include <starlet.h> /* (SYS$...) */
@ -194,9 +199,17 @@ moo_errnum_t moo_syserrtoerrnum (int e)
case EPERM: return MOO_EPERM;
case ENOTDIR: return MOO_ENOTDIR;
case ENOENT: return MOO_ENOENT;
#if defined(EEXIST)
case EEXIST: return MOO_EEXIST;
#endif
#if defined(EINTR)
case EINTR: return MOO_EINTR;
#endif
#if defined(EPIPE)
case EPIPE: return MOO_EPIPE;
#endif
#if defined(EAGAIN) && defined(EWOULDBLOCK) && (EAGAIN != EWOULDBLOCK)
case EAGAIN:
case EWOULDBLOCK: return MOO_EAGAIN;

View File

@ -35,7 +35,7 @@
# define INCL_DOSERRORS
# include <os2.h>
# include <time.h>
#elif defined(__MSDOS__)
#elif defined(__DOS__)
# include <time.h>
#elif defined(macintosh)
# include <Types.h>
@ -122,7 +122,12 @@
# define LOG_INST_3(moo,fmt,a1,a2,a3)
#endif
#define __PRIMITIVE_NAME__ (&__FUNCTION__[4])
#if defined(__DOS__) && defined(_INTELC32_)
/* the old intel c code builder doesn't support __FUNCTION__ */
# define __PRIMITIVE_NAME__ "<<primitive>>"
#else
# define __PRIMITIVE_NAME__ (&__FUNCTION__[4])
#endif
/* ------------------------------------------------------------------------- */
static MOO_INLINE void vm_gettime (moo_t* moo, moo_ntime_t* now)
@ -140,7 +145,7 @@ static MOO_INLINE void vm_gettime (moo_t* moo, moo_ntime_t* now)
/* it must return NO_ERROR */
MOO_INITNTIME (now, MOO_MSEC_TO_SEC(out), MOO_MSEC_TO_NSEC(out));
#elif defined(__MSDOS__) && defined(_INTELC32_)
#elif defined(__DOS__) && defined(_INTELC32_)
clock_t c;
/* TODO: handle overflow?? */
@ -213,7 +218,7 @@ static MOO_INLINE void vm_sleep (moo_t* moo, const moo_ntime_t* dur)
/* TODO: ... */
#elif defined(__MSDOS__) && defined(_INTELC32_)
#elif defined(__DOS__) && defined(_INTELC32_)
clock_t c;
@ -1763,8 +1768,8 @@ static moo_pfrc_t pf_exceptionize_error (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_FAILURE;
}
// TODO: .......
// MOO_OBJ_SET_FLAGS_EXTRA (rcv, xxx);
/* TODO: .......
MOO_OBJ_SET_FLAGS_EXTRA (rcv, xxx); */
MOO_STACK_SETRETTORCV (moo, nargs);
return MOO_PF_SUCCESS;
}

View File

@ -45,8 +45,9 @@
# define INCL_DOSPROCESS
# define INCL_DOSERRORS
# include <os2.h>
#elif defined(__MSDOS__)
#elif defined(__DOS__)
# include <dos.h>
# include <time.h>
#elif defined(macintosh)
# include <Timer.h>
#else
@ -69,9 +70,9 @@
# if defined(_WIN32)
# define MOO_DEFAULT_MODPREFIX "moo-"
# elif defined(__OS2__)
# define MOO_DEFAULT_MODPREFIX "st-"
# elif defined(__MSDOS__)
# define MOO_DEFAULT_MODPREFIX "st-"
# define MOO_DEFAULT_MODPREFIX "moo"
# elif defined(__DOS__)
# define MOO_DEFAULT_MODPREFIX "moo"
# else
# define MOO_DEFAULT_MODPREFIX "libmoo-"
# endif
@ -82,7 +83,7 @@
# define MOO_DEFAULT_MODPOSTFIX ""
# elif defined(__OS2__)
# define MOO_DEFAULT_MODPOSTFIX ""
# elif defined(__MSDOS__)
# elif defined(__DOS__)
# define MOO_DEFAULT_MODPOSTFIX ""
# else
# define MOO_DEFAULT_MODPOSTFIX ""
@ -172,7 +173,7 @@ static MOO_INLINE moo_ooi_t open_input (moo_t* moo, moo_ioarg_t* arg)
/* TODO: make bcs relative to the includer */
#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__)
#if defined(__DOS__) || defined(_WIN32) || defined(__OS2__)
fp = fopen (bcs, "rb");
#else
fp = fopen (bcs, "r");
@ -181,7 +182,7 @@ static MOO_INLINE moo_ooi_t open_input (moo_t* moo, moo_ioarg_t* arg)
else
{
/* main stream */
#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__)
#if defined(__DOS__) || defined(_WIN32) || defined(__OS2__)
fp = fopen (xtn->source_path, "rb");
#else
fp = fopen (xtn->source_path, "r");
@ -341,7 +342,7 @@ static void dl_close (moo_t* moo, void* handle)
FreeLibrary ((HMODULE)handle);
#elif defined(__OS2__)
DosFreeModule ((HMODULE)handle);
#elif defined(__MSDOS__) && defined(QSE_ENABLE_DOS_DYNAMIC_MODULE)
#elif defined(__DOS__) && defined(QSE_ENABLE_DOS_DYNAMIC_MODULE)
FreeModule (handle);
#else
/* nothing to do */
@ -438,13 +439,14 @@ static void log_write (moo_t* moo, moo_oow_t mask, const moo_ooch_t* msg, moo_oo
struct tm tm, *tmp;
time_t now;
if (mask & MOO_LOG_GC) return; /* don't show gc logs */
/* TODO: beautify the log message.
* do classification based on mask. */
now = time(NULL);
#if defined(__MSDOS__)
#if defined(__DOS__)
tmp = localtime (&now);
#else
tmp = localtime_r (&now, &tm);
@ -502,7 +504,7 @@ static moo_t* g_moo = MOO_NULL;
/* ========================================================================= */
#if defined(__MSDOS__) && defined(_INTELC32_)
#if defined(__DOS__) && defined(_INTELC32_)
static void (*prev_timer_intr_handler) (void);
#pragma interrupt(timer_intr_handler)
@ -543,7 +545,7 @@ static void arrange_process_switching (int sig)
static void setup_tick (void)
{
#if defined(__MSDOS__) && defined(_INTELC32_)
#if defined(__DOS__) && defined(_INTELC32_)
prev_timer_intr_handler = _dos_getvect (0x1C);
_dos_setvect (0x1C, timer_intr_handler);
@ -579,7 +581,7 @@ static void setup_tick (void)
static void cancel_tick (void)
{
#if defined(__MSDOS__) && defined(_INTELC32_)
#if defined(__DOS__) && defined(_INTELC32_)
_dos_setvect (0x1C, prev_timer_intr_handler);

View File

@ -37,7 +37,7 @@
# include "moo-msw.h"
#elif defined(__OS2__)
# include "moo-os2.h"
#elif defined(__MSDOS__)
#elif defined(__DOS__)
# include "moo-dos.h"
#elif defined(macintosh)
# include "moo-mac.h" /* class mac os */
@ -131,7 +131,7 @@
# define MOO_HAVE_INT32_T
typedef unsigned __int32_t moo_uint32_t;
typedef signed __int32_t moo_int32_t;
#elif defined(__MSDOS__)
#elif defined(__DOS__)
# define MOO_HAVE_UINT32_T
# define MOO_HAVE_INT32_T
typedef unsigned long int moo_uint32_t;

View File

@ -71,12 +71,6 @@ MOO_EXPORT moo_oow_t moo_hashbytes (
# define moo_hashoochars(ptr,len) moo_hashbchars(ptr,len)
#endif
MOO_EXPORT moo_oow_t moo_hashwords (
const moo_oow_t* ptr,
moo_oow_t len
);
/**
* The moo_equaluchars() function determines equality of two strings
* of the same length \a len.

View File

@ -28,15 +28,18 @@
#include "console.h"
#include <moo-utl.h>
#include <unistd.h>
#include <fcntl.h>
#if defined(_WIN32)
#include <stdlib.h> /* getenv */
#elif defined(__DOS__)
#include <curses.h>
#include <term.h>
#include <sys/ioctl.h>
#else
# include <unistd.h>
# include <fcntl.h>
# include <stdlib.h> /* getenv */
# include <curses.h>
# include <term.h>
# include <sys/ioctl.h>
#endif
typedef struct console_t console_t;
struct console_t
@ -66,7 +69,9 @@ static moo_pfrc_t pf_open (moo_t* moo, moo_ooi_t nargs)
/* error */
}
#elif defined(__DOS__)
moo->errnum = MOO_ENOIMPL;
return -1;
#else
console_t* con;
@ -114,11 +119,10 @@ static moo_pfrc_t pf_open (moo_t* moo, moo_ooi_t nargs)
/*write (fd, tparm (cup, wsz.ws_row - 1, 0), strlen(tparm (cup, wsz.ws_row - 1, 0)));*/
write (fd, tiparm (cup, 0, 0), strlen(tiparm (cup, 0, 0)));
}
#endif
#endif
MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP((moo_oow_t)con));
#endif
return MOO_PF_SUCCESS;
}
@ -128,11 +132,14 @@ static moo_pfrc_t pf_close (moo_t* moo, moo_ooi_t nargs)
HANDLE h;
h = MOO_STACK_GETARG (moo, nargs, 0);
#elif defined(__DOS__)
/* TODO */
#else
#endif
console_t* con;
con = MOO_OOP_TO_SMOOI(MOO_STACK_GETARG (moo, nargs, 0));
con = (console_t*)MOO_OOP_TO_SMOOI(MOO_STACK_GETARG (moo, nargs, 0));
/* TODO: sanity check */
if (con->fd_opened) close (con->fd);
@ -140,10 +147,15 @@ static moo_pfrc_t pf_close (moo_t* moo, moo_ooi_t nargs)
moo_freemem (moo, con);
MOO_STACK_SETRETTORCV (moo, nargs);
return MOO_PF_SUCCESS;
#endif
}
static moo_pfrc_t pf_write (moo_t* moo, moo_ooi_t nargs)
{
#if defined(_WIN32)
#elif defined(__DOS__)
#else
console_t* con;
moo_oop_char_t oomsg;
@ -183,10 +195,15 @@ static moo_pfrc_t pf_write (moo_t* moo, moo_ooi_t nargs)
MOO_STACK_SETRETTORCV (moo, nargs); /* TODO: change return code */
return MOO_PF_SUCCESS;
#endif
}
static moo_pfrc_t pf_clear (moo_t* moo, moo_ooi_t nargs)
{
#if defined(_WIN32)
#elif defined(__DOS__)
#else
console_t* con;
con = MOO_OOP_TO_SMOOI(MOO_STACK_GETARG(moo, nargs, 0));
@ -195,10 +212,15 @@ static moo_pfrc_t pf_clear (moo_t* moo, moo_ooi_t nargs)
MOO_STACK_SETRETTORCV (moo, nargs);
return MOO_PF_SUCCESS;
#endif
}
static moo_pfrc_t pf_setcursor (moo_t* moo, moo_ooi_t nargs)
{
#if defined(_WIN32)
#elif defined(__DOS__)
#else
console_t* con;
moo_oop_oop_t point;
char* cup;
@ -217,6 +239,7 @@ static moo_pfrc_t pf_setcursor (moo_t* moo, moo_ooi_t nargs)
MOO_STACK_SETRETTORCV (moo, nargs);
return MOO_PF_SUCCESS;
#endif
}
/* ------------------------------------------------------------------------ */
@ -268,7 +291,6 @@ static void unload (moo_t* moo, moo_mod_t* mod)
/* TODO: close all open handle?? */
}
int moo_mod_console (moo_t* moo, moo_mod_t* mod)
{
mod->query = query;

View File

@ -32,6 +32,10 @@
#include <errno.h>
#include <limits.h>
#if !defined(PATH_MAX)
# define PATH_MAX 256
#endif
typedef struct stdio_t stdio_t;
struct stdio_t
{