- The common error reporting function __show_error() could throw Enforcer

hits if the program was not launched from Shell. Fixed.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14783 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
Olaf Barthel
2004-12-24 10:52:02 +00:00
parent 76c68da3a5
commit 3c9f119046
2 changed files with 39 additions and 28 deletions
+3
View File
@@ -2,6 +2,9 @@
- Fixed a typo in the hstrerror() function.
- The common error reporting function __show_error() could throw Enforcer
hits if the program was not launched from Shell. Fixed.
c.lib 1.184 (28.11.2004)
+36 -28
View File
@@ -1,5 +1,5 @@
/*
* $Id: stdlib_showerror.c,v 1.2 2004-12-13 11:11:57 obarthel Exp $
* $Id: stdlib_showerror.c,v 1.3 2004-12-24 10:52:02 obarthel Exp $
*
* :ts=4
*
@@ -76,33 +76,53 @@ __show_error(const char * message)
struct DOSIFace * IDOS = NULL;
#endif /* __amigaos4__ */
struct Library * IntuitionBase = NULL;
struct Library * DOSBase = NULL;
struct Library * IntuitionBase;
struct Library * DOSBase;
PROFILE_OFF();
if(__detach || __WBenchMsg != NULL || __no_standard_io)
DOSBase = OpenLibrary("dos.library",0);
IntuitionBase = OpenLibrary("intuition.library",0);
if(DOSBase == NULL || IntuitionBase == NULL)
goto out;
#if defined(__amigaos4__)
{
IntuitionBase = OpenLibrary("intuition.library",0);
if(IntuitionBase == NULL)
IDOS = (struct DOSIFace *)GetInterface((struct Library *)DOSBase, "main", 1, 0);
if (IDOS == NULL)
goto out;
#if defined(__amigaos4__)
{
IIntuition = (struct IntuitionIFace *)GetInterface((struct Library *)IntuitionBase, "main", 1, 0);
if (IIntuition == NULL)
goto out;
}
#endif /* __amigaos4__ */
IIntuition = (struct IntuitionIFace *)GetInterface((struct Library *)IntuitionBase, "main", 1, 0);
if (IIntuition == NULL)
goto out;
}
#endif /* __amigaos4__ */
if(__detach || __no_standard_io || __WBenchMsg != NULL)
{
if(IntuitionBase->lib_Version >= 37)
{
UBYTE program_name[256];
struct EasyStruct es;
STRPTR title_string;
if(__WBenchMsg != NULL)
{
title_string = (STRPTR)FilePart(__WBenchMsg->sm_ArgList[0].wa_Name);
}
else
{
if(GetProgramName(program_name,sizeof(program_name)))
title_string = FilePart((STRPTR)program_name);
else
title_string = (STRPTR)"Error";
}
memset(&es,0,sizeof(es));
es.es_StructSize = sizeof(es);
es.es_Title = (STRPTR)__WBenchMsg->sm_ArgList[0].wa_Name;
es.es_Title = title_string;
es.es_TextFormat = (STRPTR)message;
es.es_GadgetFormat = (STRPTR)"Sorry";
@@ -114,8 +134,8 @@ __show_error(const char * message)
#if NOT defined(__amigaos4__)
{
static struct TextAttr default_font = { (STRPTR)"topaz.font",8,FS_NORMAL,FPF_ROMFONT|FPF_DESIGNED };
static struct IntuiText sorry_text = {0,1,JAM1,6,3,(struct IText *)NULL,(STRPTR)"Sorry",NULL};
static struct IntuiText body_text = {0,1,JAM1,5,3,(struct IText *)NULL,(STRPTR)NULL,NULL};
static struct IntuiText sorry_text = {0,1,JAM1,6,3,(struct TextAttr *)NULL,(STRPTR)"Sorry",(struct IntuiText *)NULL};
static struct IntuiText body_text = {0,1,JAM1,5,3,(struct TextAttr *)NULL,(STRPTR)NULL,(struct IntuiText *)NULL};
sorry_text.ITextFont = &default_font;
body_text.ITextFont = &default_font;
@@ -131,18 +151,6 @@ __show_error(const char * message)
{
BPTR output;
DOSBase = OpenLibrary("dos.library",0);
if(DOSBase == NULL)
goto out;
#if defined(__amigaos4__)
{
IDOS = (struct DOSIFace *)GetInterface((struct Library *)DOSBase, "main", 1, 0);
if (IDOS == NULL)
goto out;
}
#endif /* __amigaos4__ */
output = Output();
Write(output,(STRPTR)message,(LONG)strlen(message));