substitued syserr for errno wrongly used in err.c

This commit is contained in:
hyunghwan.chung 2018-01-28 12:35:12 +00:00
parent f3ee24447f
commit 1bae32bf30
4 changed files with 62 additions and 5 deletions

View File

@ -208,6 +208,7 @@ const moo_ooch_t* moo_synerrnum_to_errstr (moo_synerrnum_t errnum)
# include <ssdef.h> /* (SS$...) */ # include <ssdef.h> /* (SS$...) */
# include <lib$routines.h> /* (lib$...) */ # include <lib$routines.h> /* (lib$...) */
#elif defined(macintosh) #elif defined(macintosh)
# include <MacErrors.h>
# include <Process.h> # include <Process.h>
# include <Dialogs.h> # include <Dialogs.h>
# include <TextUtils.h> # include <TextUtils.h>
@ -241,6 +242,24 @@ moo_errnum_t moo_syserr_to_errnum (int e)
/*TODO: add more mappings */ /*TODO: add more mappings */
default: return MOO_ESYSERR; default: return MOO_ESYSERR;
} }
#elif defined(macintosh)
switch (e)
{
case notEnoughMemoryErr: return MOO_ESYSMEM;
case paramErr: return MOO_EINVAL;
case qErr: /* queue element not found during deletion */
case fnfErr: /* file not found */
case dirNFErr: /* direcotry not found */
case resNotFound: /* resource not found */
case resFNotFound: /* resource file not found */
case nbpNotFound: /* name not found on remove */
return MOO_ENOENT;
/*TODO: add more mappings */
default: return MOO_ESYSERR;
}
#else #else
switch (e) switch (e)
{ {
@ -317,13 +336,13 @@ void moo_seterrwithsyserr (moo_t* moo, int syserr)
if (moo->vmprim.syserrstrb) if (moo->vmprim.syserrstrb)
{ {
moo->vmprim.syserrstrb (moo, syserr, moo->errmsg.tmpbuf.bch, MOO_COUNTOF(moo->errmsg.tmpbuf.bch)); moo->vmprim.syserrstrb (moo, syserr, moo->errmsg.tmpbuf.bch, MOO_COUNTOF(moo->errmsg.tmpbuf.bch));
moo_seterrbfmt (moo, moo_syserr_to_errnum(errno), "%hs", moo->errmsg.tmpbuf.bch); moo_seterrbfmt (moo, moo_syserr_to_errnum(syserr), "%hs", moo->errmsg.tmpbuf.bch);
} }
else else
{ {
MOO_ASSERT (moo, moo->vmprim.syserrstru != MOO_NULL); MOO_ASSERT (moo, moo->vmprim.syserrstru != MOO_NULL);
moo->vmprim.syserrstru (moo, syserr, moo->errmsg.tmpbuf.uch, MOO_COUNTOF(moo->errmsg.tmpbuf.uch)); moo->vmprim.syserrstru (moo, syserr, moo->errmsg.tmpbuf.uch, MOO_COUNTOF(moo->errmsg.tmpbuf.uch));
moo_seterrbfmt (moo, moo_syserr_to_errnum(errno), "%ls", moo->errmsg.tmpbuf.uch); moo_seterrbfmt (moo, moo_syserr_to_errnum(syserr), "%ls", moo->errmsg.tmpbuf.uch);
} }
} }

38
moo/lib/main-mac.c Normal file
View File

@ -0,0 +1,38 @@
#include <Types.h>
#include <Memory.h>
#include <QuickDraw.h>
#include <Fonts.h>
#include <Events.h>
#include <Menus.h>
#include <TextEdit.h>
#include <MacWindows.h>
#include <OSUtils.h>
#include <ToolUtils.h>
static void InitToolBox ()
{
GrafPtr wmgrPort;
#if defined(TARGET_API_MAC_CARBON) && (TARGET_API_MAC_CARBON > 0)
/* no init required for the managers below in Carbon */
#else
InitGraf (&qd.thePort);
InitFonts ();
InitWindows ();
InitMenus ();
TEInit ();
InitDialogs (0L);
MaxApplZone ();
#endif
InitCursor ();
#if defined(TARGET_API_MAC_CARBON) && (TARGET_API_MAC_CARBON > 0)
wmgrPort = CreateNewPort();
#else
GetWMgrPort (&wmgrPort);
#endif
SetPort (wmgrPort);
}

View File

@ -465,7 +465,7 @@ struct moo_initv_t
enum moo_pragma_flag_t enum moo_pragma_flag_t
{ {
MOO_PRAGMA_QC = (1 << 0), MOO_PRAGMA_QC = (1 << 0)
}; };
struct moo_compiler_t struct moo_compiler_t

View File

@ -123,7 +123,7 @@ enum moo_trait_t
MOO_NOGC = (1 << 8), MOO_NOGC = (1 << 8),
/* wait for running process when exiting from the main method */ /* wait for running process when exiting from the main method */
MOO_AWAIT_PROCS = (1 << 9), MOO_AWAIT_PROCS = (1 << 9)
}; };
typedef enum moo_trait_t moo_trait_t; typedef enum moo_trait_t moo_trait_t;
@ -1428,7 +1428,7 @@ enum moo_log_mask_t
MOO_LOG_STDOUT = (1 << 14), /* write log messages to stdout without timestamp. MOO_LOG_STDOUT wins over MOO_LOG_STDERR. */ MOO_LOG_STDOUT = (1 << 14), /* write log messages to stdout without timestamp. MOO_LOG_STDOUT wins over MOO_LOG_STDERR. */
MOO_LOG_STDERR = (1 << 15), /* write log messages to stderr without timestamp. */ MOO_LOG_STDERR = (1 << 15) /* write log messages to stderr without timestamp. */
}; };
typedef enum moo_log_mask_t moo_log_mask_t; typedef enum moo_log_mask_t moo_log_mask_t;