Malloc_t Perl_malloc (MEM_SIZE nbytes)
{
dTHXs;
- return PerlMem_malloc(nbytes);
+ return (Malloc_t)PerlMem_malloc(nbytes);
}
Malloc_t Perl_calloc (MEM_SIZE elements, MEM_SIZE size)
{
dTHXs;
- return PerlMem_calloc(elements, size);
+ return (Malloc_t)PerlMem_calloc(elements, size);
}
Malloc_t Perl_realloc (Malloc_t where, MEM_SIZE nbytes)
{
dTHXs;
- return PerlMem_realloc(where, nbytes);
+ return (Malloc_t)PerlMem_realloc(where, nbytes);
}
Free_t Perl_mfree (Malloc_t where)
}
}
BmRARE(sv) = s[rarest];
- BmPREVIOUS(sv) = rarest;
+ BmPREVIOUS(sv) = (U16)rarest;
BmUSEFUL(sv) = 100; /* Initial value */
if (flags & FBMcf_TAIL)
SvTAIL_on(sv);
register STRLEN littlelen = l;
register I32 multiline = flags & FBMrf_MULTILINE;
- if (bigend - big < littlelen) {
+ if ((STRLEN)(bigend - big) < littlelen) {
if ( SvTAIL(littlestr)
- && (bigend - big == littlelen - 1)
+ && ((STRLEN)(bigend - big) == littlelen - 1)
&& (littlelen == 1
|| (*big == *little &&
memEQ((char *)big, (char *)little, littlelen - 1))))
register unsigned char *table = little + littlelen + FBM_TABLE_OFFSET;
register unsigned char *oldlittle;
- if (littlelen > bigend - big)
+ if (littlelen > (STRLEN)(bigend - big))
return Nullch;
--littlelen; /* Last char found by table lookup */
=for apidoc savepv
-Copy a string to a safe spot. This does not use an SV.
+Perl's version of C<strdup()>. Returns a pointer to a newly allocated
+string which is a duplicate of C<pv>. The size of the string is
+determined by C<strlen()>. The memory allocated for the new string can
+be freed with the C<Safefree()> function.
=cut
*/
char *
-Perl_savepv(pTHX_ const char *sv)
+Perl_savepv(pTHX_ const char *pv)
{
register char *newaddr = Nullch;
- if (sv) {
- New(902,newaddr,strlen(sv)+1,char);
- (void)strcpy(newaddr,sv);
+ if (pv) {
+ New(902,newaddr,strlen(pv)+1,char);
+ (void)strcpy(newaddr,pv);
}
return newaddr;
}
/*
=for apidoc savepvn
-Copy a string to a safe spot. The C<len> indicates number of bytes to
-copy. If pointer is NULL allocate space for a string of size specified.
-This does not use an SV.
+Perl's version of what C<strndup()> would be if it existed. Returns a
+pointer to a newly allocated string which is a duplicate of the first
+C<len> bytes from C<pv>. The memory allocated for the new string can be
+freed with the C<Safefree()> function.
=cut
*/
char *
-Perl_savepvn(pTHX_ const char *sv, register I32 len)
+Perl_savepvn(pTHX_ const char *pv, register I32 len)
{
register char *newaddr;
New(903,newaddr,len+1,char);
/* Give a meaning to NULL pointer mainly for the use in sv_magic() */
- if (sv) {
- Copy(sv,newaddr,len,char); /* might not be null terminated */
+ if (pv) {
+ Copy(pv,newaddr,len,char); /* might not be null terminated */
newaddr[len] = '\0'; /* is now */
}
else {
/*
=for apidoc savesharedpv
-Copy a string to a safe spot in memory shared between threads.
-This does not use an SV.
+A version of C<savepv()> which allocates the duplicate string in memory
+which is shared between threads.
=cut
*/
char *
-Perl_savesharedpv(pTHX_ const char *sv)
+Perl_savesharedpv(pTHX_ const char *pv)
{
register char *newaddr = Nullch;
- if (sv) {
- newaddr = PerlMemShared_malloc(strlen(sv)+1);
- (void)strcpy(newaddr,sv);
+ if (pv) {
+ newaddr = (char*)PerlMemShared_malloc(strlen(pv)+1);
+ (void)strcpy(newaddr,pv);
}
return newaddr;
}
*(s+(nlen+1+vlen)) = '\0'
#ifdef USE_ENVIRON_ARRAY
- /* VMS' and EPOC's my_setenv() is in vms.c and epoc.c */
+ /* VMS' my_setenv() is in vms.c */
#if !defined(WIN32) && !defined(NETWARE)
void
Perl_my_setenv(pTHX_ char *nam, char *val)
my_setenv_format(environ[i], nam, nlen, val, vlen);
#else /* PERL_USE_SAFE_PUTENV */
-# if defined(__CYGWIN__)
+# if defined(__CYGWIN__) || defined( EPOC)
setenv(nam, val, 1);
# else
char *new_env;
return PerlIO_fdopen(p[This], mode);
}
#else
-#if defined(atarist)
+#if defined(atarist) || defined(EPOC)
FILE *popen();
PerlIO *
Perl_my_popen(pTHX_ char *cmd, char *mode)
Perl_dump_fds(pTHX_ char *s)
{
int fd;
- struct stat tmpstatbuf;
+ Stat_t tmpstatbuf;
PerlIO_printf(Perl_debug_log,"%s", s);
for (fd = 0; fd < 32; fd++) {
hv_iterinit(PL_pidstatus);
if ((entry = hv_iternext(PL_pidstatus))) {
+ SV *sv;
+ char spid[TYPE_CHARS(int)];
+
pid = atoi(hv_iterkey(entry,(I32*)statusp));
sv = hv_iterval(PL_pidstatus,entry);
*statusp = SvIVX(sv);
return;
}
-#if defined(atarist) || defined(OS2)
+#if defined(atarist) || defined(OS2) || defined(EPOC)
int pclose();
#ifdef HAS_FORK
int /* Cannot prototype with I32
{
char *fa = strrchr(a,'/');
char *fb = strrchr(b,'/');
- struct stat tmpstatbuf1;
- struct stat tmpstatbuf2;
+ Stat_t tmpstatbuf1;
+ Stat_t tmpstatbuf2;
SV *tmpsv = sv_newmortal();
if (fa)
if (gv && isGV(gv)) {
SV *sv = sv_newmortal();
gv_efullname4(sv, gv, Nullch, FALSE);
- name = SvPVX(sv);
+ if (SvOK(sv))
+ name = SvPVX(sv);
}
if (op == OP_phoney_OUTPUT_ONLY || op == OP_phoney_INPUT_ONLY) {
#else
- struct stat statbuf;
+ Stat_t statbuf;
int orig_cdev, orig_cino, cdev, cino, odev, oino, tdev, tino;
int namelen, pathlen=0;
DIR *dir;
/* this is atoi() that tolerates underscores */
char *end = pos;
UV mult = 1;
- if ( *(s-1) == '_') {
+ if ( s > pos && *(s-1) == '_') {
mult = 10;
}
while (--end >= s) {
return s;
}
-#if !defined(HAS_SOCKETPAIR) && defined(HAS_SOCKET) && defined(AF_INET) && defined(PF_INET) && defined(SOCK_DGRAM)
+#if !defined(HAS_SOCKETPAIR) && defined(HAS_SOCKET) && defined(AF_INET) && defined(PF_INET) && defined(SOCK_DGRAM) && defined(HAS_SELECT)
# define EMULATE_SOCKETPAIR_UDP
#endif
return -1;
}
}
+#endif /* EMULATE_SOCKETPAIR_UDP */
+#if !defined(HAS_SOCKETPAIR) && defined(HAS_SOCKET) && defined(AF_INET) && defined(PF_INET)
int
Perl_my_socketpair (int family, int type, int protocol, int fd[2]) {
/* Stevens says that family must be AF_LOCAL, protocol 0.
return 0;
abort_tidy_up_and_fail:
- errno = ECONNABORTED; /* I hope this is portable and appropriate. */
+ errno = ECONNABORTED; /* I hope this is portable and appropriate. */
tidy_up_and_fail:
{
int save_errno = errno;
return -1;
}
}
-#endif /* !defined(HAS_SOCKETPAIR) && defined(HAS_SOCKET) */
-#ifdef HAS_SOCKETPAIR
+#else
/* In any case have a stub so that there's code corresponding
* to the my_socketpair in global.sym. */
int
Perl_my_socketpair (int family, int type, int protocol, int fd[2]) {
+#ifdef HAS_SOCKETPAIR
return socketpair(family, type, protocol, fd);
+#else
+ return -1;
+#endif
}
#endif