summaryrefslogtreecommitdiff
path: root/ext/DynaLoader
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>1997-11-29 00:35:30 -0800
committerMalcolm Beattie <mbeattie@sable.ox.ac.uk>1997-12-10 10:41:25 +0000
commitce637636a41b2fef0be4daa6d9d27b84e0907a74 (patch)
tree9042d85dec63727158133a0f99357eb7ed498d53 /ext/DynaLoader
parentc4826df72d2d8ad93e7363e4709fc5003146a3cb (diff)
downloadperl-ce637636a41b2fef0be4daa6d9d27b84e0907a74.tar.gz
Patches for IRIX, AIX and some generic stuff:
Subject: [PATCH] _55: Mostly AIX stuff but also IRIX and generic (checked/ignored a few rejects; tweaked wording). p4raw-id: //depot/perl@354
Diffstat (limited to 'ext/DynaLoader')
-rw-r--r--ext/DynaLoader/dl_aix.xs59
1 files changed, 53 insertions, 6 deletions
diff --git a/ext/DynaLoader/dl_aix.xs b/ext/DynaLoader/dl_aix.xs
index 548fe41a9c..4e865edd3b 100644
--- a/ext/DynaLoader/dl_aix.xs
+++ b/ext/DynaLoader/dl_aix.xs
@@ -77,16 +77,63 @@ static int readExports(ModulePtr);
static void terminate(void);
static void *findMain(void);
+static char *strerror_failed = "(strerror failed)";
+static char *strerror_r_failed = "(strerror_r failed)";
+
char *strerrorcat(char *str, int err) {
- char buf[8192];
- strerror_r(err, buf, sizeof(buf));
- strcat(str,buf);
+ int strsiz = strlen(str);
+ int msgsiz;
+ char *msg;
+
+#ifdef USE_THREADS
+ char *buf = malloc(BUFSIZ);
+
+ if (buf == 0)
+ return 0;
+ if (strerror_r(err, buf, sizeof(buf)) == 0)
+ msg = buf;
+ else
+ msg = strerror_r_failed;
+ msgsiz = strlen(msg);
+ if (strsiz + msgsiz < BUFSIZ)
+ strcat(str, msg);
+ free(buf);
+#else
+ if ((msg = strerror(err)) == 0)
+ msg = strerror_failed;
+ msgsiz = strlen(msg); /* Note msg = buf and free() above. */
+ if (strsiz + msgsiz < BUFSIZ) /* Do not move this after #endif. */
+ strcat(str, msg);
+#endif
+
return str;
}
+
char *strerrorcpy(char *str, int err) {
- char buf[8192];
- strerror_r(err, buf, sizeof(buf));
- strcpy(str,buf);
+ int msgsiz;
+ char *msg;
+
+#ifdef USE_THREADS
+ char *buf = malloc(BUFSIZ);
+
+ if (buf == 0)
+ return 0;
+ if (strerror_r(err, buf, sizeof(buf)) == 0)
+ msg = buf;
+ else
+ msg = strerror_r_failed;
+ msgsiz = strlen(msg);
+ if (msgsiz < BUFSIZ)
+ strcpy(str, msg);
+ free(buf);
+#else
+ if ((msg = strerror(err)) == 0)
+ msg = strerror_failed;
+ msgsiz = strlen(msg); /* Note msg = buf and free() above. */
+ if (msgsiz < BUFSIZ) /* Do not move this after #endif. */
+ strcpy(str, msg);
+#endif
+
return str;
}