summaryrefslogtreecommitdiff
path: root/os2
diff options
context:
space:
mode:
authorIlya Zakharevich <ilya@math.berkeley.edu>2001-06-25 01:02:36 -0400
committerJarkko Hietaniemi <jhi@iki.fi>2001-06-25 13:44:14 +0000
commit9fed8b87f0e66c26a1acaf42431d99e8f98aed9b (patch)
tree0e2217b9b1b47b8bbe645e1146f1d52ec742c0fb /os2
parent65850d1188a11c32e29d02481824ef0f35fbacee (diff)
downloadperl-9fed8b87f0e66c26a1acaf42431d99e8f98aed9b.tar.gz
Re: [PATCH 5.6.1] $^E on OS/2
Message-ID: <20010625050235.A24046@math.ohio-state.edu> p4raw-id: //depot/perl@10917
Diffstat (limited to 'os2')
-rw-r--r--os2/dl_os2.c30
-rw-r--r--os2/os2.c41
2 files changed, 40 insertions, 31 deletions
diff --git a/os2/dl_os2.c b/os2/dl_os2.c
index 02ca2efd46..aaeeb580f4 100644
--- a/os2/dl_os2.c
+++ b/os2/dl_os2.c
@@ -8,6 +8,8 @@
static ULONG retcode;
static char fail[300];
+char *os2error(int rc);
+
void *
dlopen(char *path, int mode)
{
@@ -62,29 +64,17 @@ dlerror(void)
{
static char buf[700];
ULONG len;
+ char *err;
if (retcode == 0)
return NULL;
- if (DosGetMessage(NULL, 0, buf, sizeof buf - 1, retcode,
- "OSO001.MSG", &len)) {
- if (fail[0])
- sprintf(buf,
-"OS/2 system error code %lu, possible problematic module: '%s'",
- retcode, fail);
- else
- sprintf(buf, "OS/2 system error code %lu", retcode);
- } else {
- buf[len] = '\0';
- if (len && buf[len - 1] == '\n')
- buf[--len] = 0;
- if (len && buf[len - 1] == '\r')
- buf[--len] = 0;
- if (len && buf[len - 1] == '.')
- buf[--len] = 0;
- if (fail[0] && len < 300)
- sprintf(buf + len, ", possible problematic module: '%s'",
- fail);
- }
+ err = os2error(retcode);
+ len = strlen(err);
+ if (len > sizeof(buf) - 1)
+ len = sizeof(buf) - 1;
+ strncpy(buf, err, len+1);
+ if (fail[0] && len < 300)
+ sprintf(buf + len, ", possible problematic module: '%s'", fail);
retcode = 0;
return buf;
}
diff --git a/os2/os2.c b/os2/os2.c
index 1016d9bebb..9cb0dd79c0 100644
--- a/os2/os2.c
+++ b/os2/os2.c
@@ -1356,20 +1356,36 @@ os2error(int rc)
{
static char buf[300];
ULONG len;
+ char *s;
+ int number = SvTRUE(get_sv("OS2::nsyserror", TRUE));
if (!(_emx_env & 0x200)) return ""; /* Nop if not OS/2. */
if (rc == 0)
- return NULL;
- if (DosGetMessage(NULL, 0, buf, sizeof buf - 1, rc, "OSO001.MSG", &len))
- sprintf(buf, "OS/2 system error code %d=0x%x", rc, rc);
- else {
- buf[len] = '\0';
- if (len && buf[len - 1] == '\n')
- buf[--len] = 0;
- if (len && buf[len - 1] == '\r')
- buf[--len] = 0;
- if (len && buf[len - 1] == '.')
- buf[--len] = 0;
+ return "";
+ if (number) {
+ sprintf(buf, "SYS%04d=%#x: ", rc, rc);
+ s = buf + strlen(buf);
+ } else
+ s = buf;
+ if (DosGetMessage(NULL, 0, s, sizeof(buf) - 1 - (s-buf),
+ rc, "OSO001.MSG", &len)) {
+ if (!number) {
+ sprintf(buf, "SYS%04d=%#x: ", rc, rc);
+ s = buf + strlen(buf);
+ }
+ sprintf(s, "[No description found in OSO001.MSG]");
+ } else {
+ s[len] = '\0';
+ if (len && s[len - 1] == '\n')
+ s[--len] = 0;
+ if (len && s[len - 1] == '\r')
+ s[--len] = 0;
+ if (len && s[len - 1] == '.')
+ s[--len] = 0;
+ if (len >= 10 && number && strnEQ(s, buf, 7)
+ && s[7] == ':' && s[8] == ' ')
+ /* Some messages start with SYSdddd:, some not */
+ Move(s + 9, s, (len -= 9) + 1, char);
}
return buf;
}
@@ -2186,6 +2202,9 @@ Xs_OS2_init(pTHX)
gv = gv_fetchpv("OS2::os_ver", TRUE, SVt_PV);
GvMULTI_on(gv);
sv_setnv(GvSV(gv), _osmajor + 0.001 * _osminor);
+ gv = gv_fetchpv("OS2::nsyserror", TRUE, SVt_PV);
+ GvMULTI_on(gv);
+ sv_setiv(GvSV(gv), 1); /* DEFAULT: Show number on syserror */
}
return 0;
}