diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1999-07-08 18:47:35 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1999-07-08 18:47:35 +0000 |
commit | 51371543ca1a75ed152020ad0846b5b8cf11c32f (patch) | |
tree | 9bfd9a21697b0769e2681483631c742642dd8c45 /win32 | |
parent | 4d61ec052de5c3a91dc64c80c032c2cbec44d845 (diff) | |
download | perl-51371543ca1a75ed152020ad0846b5b8cf11c32f.tar.gz |
more PERL_OBJECT cleanups (changes still untested on Unix!)
p4raw-id: //depot/perl@3660
Diffstat (limited to 'win32')
-rw-r--r-- | win32/GenCAPI.pl | 254 | ||||
-rw-r--r-- | win32/Makefile | 18 | ||||
-rw-r--r-- | win32/makedef.pl | 169 | ||||
-rw-r--r-- | win32/perllib.c | 2 | ||||
-rw-r--r-- | win32/win32.c | 209 | ||||
-rw-r--r-- | win32/win32.h | 2 |
6 files changed, 325 insertions, 329 deletions
diff --git a/win32/GenCAPI.pl b/win32/GenCAPI.pl index 3cd581de72..703a156795 100644 --- a/win32/GenCAPI.pl +++ b/win32/GenCAPI.pl @@ -511,13 +511,13 @@ statusvalue_vms sublex_info thrsv threadnum -PL_piMem -PL_piENV -PL_piStdIO -PL_piLIO -PL_piDir -PL_piSock -PL_piProc +PL_Mem +PL_Env +PL_StdIO +PL_LIO +PL_Dir +PL_Sock +PL_Proc cshname threadsv_names thread @@ -544,7 +544,7 @@ sub readvars(\%$$) { or die "$0: Can't open $file: $!\n"; while (<FILE>) { s/[ \t]*#.*//; # Delete comments. - if (/PERLVARI?C?\($pre(\w+),\s*([^,)]+)/) { + if (/PERLVARA?I?C?\($pre(\w+),\s*([^,)]+)/) { $$syms{$1} = $2; } } @@ -675,13 +675,13 @@ void Perl_deb(const char pat, ...) { } -#undef PL_piMem -#undef PL_piENV -#undef PL_piStdIO -#undef PL_piLIO -#undef PL_piDir -#undef PL_piSock -#undef PL_piProc +#undef PL_Mem +#undef PL_Env +#undef PL_StdIO +#undef PL_LIO +#undef PL_Dir +#undef PL_Sock +#undef PL_Proc int * _win32_errno(void) { @@ -690,27 +690,27 @@ int * _win32_errno(void) FILE* _win32_stdin(void) { - return (FILE*)pPerl->PL_piStdIO->Stdin(); + return (FILE*)pPerl->PL_StdIO->Stdin(); } FILE* _win32_stdout(void) { - return (FILE*)pPerl->PL_piStdIO->Stdout(); + return (FILE*)pPerl->PL_StdIO->Stdout(); } FILE* _win32_stderr(void) { - return (FILE*)pPerl->PL_piStdIO->Stderr(); + return (FILE*)pPerl->PL_StdIO->Stderr(); } int _win32_ferror(FILE *fp) { - return pPerl->PL_piStdIO->Error((PerlIO*)fp, ErrorNo()); + return pPerl->PL_StdIO->Error((PerlIO*)fp, ErrorNo()); } int _win32_feof(FILE *fp) { - return pPerl->PL_piStdIO->Eof((PerlIO*)fp, ErrorNo()); + return pPerl->PL_StdIO->Eof((PerlIO*)fp, ErrorNo()); } char* _win32_strerror(int e) @@ -725,12 +725,12 @@ void _win32_perror(const char *str) int _win32_vfprintf(FILE *pf, const char *format, va_list arg) { - return pPerl->PL_piStdIO->Vprintf((PerlIO*)pf, ErrorNo(), format, arg); + return pPerl->PL_StdIO->Vprintf((PerlIO*)pf, ErrorNo(), format, arg); } int _win32_vprintf(const char *format, va_list arg) { - return pPerl->PL_piStdIO->Vprintf(pPerl->PL_piStdIO->Stdout(), ErrorNo(), format, arg); + return pPerl->PL_StdIO->Vprintf(pPerl->PL_StdIO->Stdout(), ErrorNo(), format, arg); } int _win32_fprintf(FILE *pf, const char *format, ...) @@ -755,532 +755,532 @@ int _win32_printf(const char *format, ...) size_t _win32_fread(void *buf, size_t size, size_t count, FILE *pf) { - return pPerl->PL_piStdIO->Read((PerlIO*)pf, buf, (size*count), ErrorNo()); + return pPerl->PL_StdIO->Read((PerlIO*)pf, buf, (size*count), ErrorNo()); } size_t _win32_fwrite(const void *buf, size_t size, size_t count, FILE *pf) { - return pPerl->PL_piStdIO->Write((PerlIO*)pf, buf, (size*count), ErrorNo()); + return pPerl->PL_StdIO->Write((PerlIO*)pf, buf, (size*count), ErrorNo()); } FILE* _win32_fopen(const char *path, const char *mode) { - return (FILE*)pPerl->PL_piStdIO->Open(path, mode, ErrorNo()); + return (FILE*)pPerl->PL_StdIO->Open(path, mode, ErrorNo()); } FILE* _win32_fdopen(int fh, const char *mode) { - return (FILE*)pPerl->PL_piStdIO->Fdopen(fh, mode, ErrorNo()); + return (FILE*)pPerl->PL_StdIO->Fdopen(fh, mode, ErrorNo()); } FILE* _win32_freopen(const char *path, const char *mode, FILE *pf) { - return (FILE*)pPerl->PL_piStdIO->Reopen(path, mode, (PerlIO*)pf, ErrorNo()); + return (FILE*)pPerl->PL_StdIO->Reopen(path, mode, (PerlIO*)pf, ErrorNo()); } int _win32_fclose(FILE *pf) { - return pPerl->PL_piStdIO->Close((PerlIO*)pf, ErrorNo()); + return pPerl->PL_StdIO->Close((PerlIO*)pf, ErrorNo()); } int _win32_fputs(const char *s,FILE *pf) { - return pPerl->PL_piStdIO->Puts((PerlIO*)pf, s, ErrorNo()); + return pPerl->PL_StdIO->Puts((PerlIO*)pf, s, ErrorNo()); } int _win32_fputc(int c,FILE *pf) { - return pPerl->PL_piStdIO->Putc((PerlIO*)pf, c, ErrorNo()); + return pPerl->PL_StdIO->Putc((PerlIO*)pf, c, ErrorNo()); } int _win32_ungetc(int c,FILE *pf) { - return pPerl->PL_piStdIO->Ungetc((PerlIO*)pf, c, ErrorNo()); + return pPerl->PL_StdIO->Ungetc((PerlIO*)pf, c, ErrorNo()); } int _win32_getc(FILE *pf) { - return pPerl->PL_piStdIO->Getc((PerlIO*)pf, ErrorNo()); + return pPerl->PL_StdIO->Getc((PerlIO*)pf, ErrorNo()); } int _win32_fileno(FILE *pf) { - return pPerl->PL_piStdIO->Fileno((PerlIO*)pf, ErrorNo()); + return pPerl->PL_StdIO->Fileno((PerlIO*)pf, ErrorNo()); } void _win32_clearerr(FILE *pf) { - pPerl->PL_piStdIO->Clearerr((PerlIO*)pf, ErrorNo()); + pPerl->PL_StdIO->Clearerr((PerlIO*)pf, ErrorNo()); } int _win32_fflush(FILE *pf) { - return pPerl->PL_piStdIO->Flush((PerlIO*)pf, ErrorNo()); + return pPerl->PL_StdIO->Flush((PerlIO*)pf, ErrorNo()); } long _win32_ftell(FILE *pf) { - return pPerl->PL_piStdIO->Tell((PerlIO*)pf, ErrorNo()); + return pPerl->PL_StdIO->Tell((PerlIO*)pf, ErrorNo()); } int _win32_fseek(FILE *pf,long offset,int origin) { - return pPerl->PL_piStdIO->Seek((PerlIO*)pf, offset, origin, ErrorNo()); + return pPerl->PL_StdIO->Seek((PerlIO*)pf, offset, origin, ErrorNo()); } int _win32_fgetpos(FILE *pf,fpos_t *p) { - return pPerl->PL_piStdIO->Getpos((PerlIO*)pf, p, ErrorNo()); + return pPerl->PL_StdIO->Getpos((PerlIO*)pf, p, ErrorNo()); } int _win32_fsetpos(FILE *pf,const fpos_t *p) { - return pPerl->PL_piStdIO->Setpos((PerlIO*)pf, p, ErrorNo()); + return pPerl->PL_StdIO->Setpos((PerlIO*)pf, p, ErrorNo()); } void _win32_rewind(FILE *pf) { - pPerl->PL_piStdIO->Rewind((PerlIO*)pf, ErrorNo()); + pPerl->PL_StdIO->Rewind((PerlIO*)pf, ErrorNo()); } FILE* _win32_tmpfile(void) { - return (FILE*)pPerl->PL_piStdIO->Tmpfile(ErrorNo()); + return (FILE*)pPerl->PL_StdIO->Tmpfile(ErrorNo()); } void _win32_setbuf(FILE *pf, char *buf) { - pPerl->PL_piStdIO->SetBuf((PerlIO*)pf, buf, ErrorNo()); + pPerl->PL_StdIO->SetBuf((PerlIO*)pf, buf, ErrorNo()); } int _win32_setvbuf(FILE *pf, char *buf, int type, size_t size) { - return pPerl->PL_piStdIO->SetVBuf((PerlIO*)pf, buf, type, size, ErrorNo()); + return pPerl->PL_StdIO->SetVBuf((PerlIO*)pf, buf, type, size, ErrorNo()); } char* _win32_fgets(char *s, int n, FILE *pf) { - return pPerl->PL_piStdIO->Gets((PerlIO*)pf, s, n, ErrorNo()); + return pPerl->PL_StdIO->Gets((PerlIO*)pf, s, n, ErrorNo()); } char* _win32_gets(char *s) { - return _win32_fgets(s, 80, (FILE*)pPerl->PL_piStdIO->Stdin()); + return _win32_fgets(s, 80, (FILE*)pPerl->PL_StdIO->Stdin()); } int _win32_fgetc(FILE *pf) { - return pPerl->PL_piStdIO->Getc((PerlIO*)pf, ErrorNo()); + return pPerl->PL_StdIO->Getc((PerlIO*)pf, ErrorNo()); } int _win32_putc(int c, FILE *pf) { - return pPerl->PL_piStdIO->Putc((PerlIO*)pf, c, ErrorNo()); + return pPerl->PL_StdIO->Putc((PerlIO*)pf, c, ErrorNo()); } int _win32_puts(const char *s) { - return pPerl->PL_piStdIO->Puts(pPerl->PL_piStdIO->Stdout(), s, ErrorNo()); + return pPerl->PL_StdIO->Puts(pPerl->PL_StdIO->Stdout(), s, ErrorNo()); } int _win32_getchar(void) { - return pPerl->PL_piStdIO->Getc(pPerl->PL_piStdIO->Stdin(), ErrorNo()); + return pPerl->PL_StdIO->Getc(pPerl->PL_StdIO->Stdin(), ErrorNo()); } int _win32_putchar(int c) { - return pPerl->PL_piStdIO->Putc(pPerl->PL_piStdIO->Stdout(), c, ErrorNo()); + return pPerl->PL_StdIO->Putc(pPerl->PL_StdIO->Stdout(), c, ErrorNo()); } void* _win32_malloc(size_t size) { - return pPerl->PL_piMem->Malloc(size); + return pPerl->PL_Mem->Malloc(size); } void* _win32_calloc(size_t numitems, size_t size) { - return pPerl->PL_piMem->Malloc(numitems*size); + return pPerl->PL_Mem->Malloc(numitems*size); } void* _win32_realloc(void *block, size_t size) { - return pPerl->PL_piMem->Realloc(block, size); + return pPerl->PL_Mem->Realloc(block, size); } void _win32_free(void *block) { - pPerl->PL_piMem->Free(block); + pPerl->PL_Mem->Free(block); } void _win32_abort(void) { - pPerl->PL_piProc->Abort(); + pPerl->PL_Proc->Abort(); } int _win32_pipe(int *phandles, unsigned int psize, int textmode) { - return pPerl->PL_piProc->Pipe(phandles); + return pPerl->PL_Proc->Pipe(phandles); } FILE* _win32_popen(const char *command, const char *mode) { - return (FILE*)pPerl->PL_piProc->Popen(command, mode); + return (FILE*)pPerl->PL_Proc->Popen(command, mode); } int _win32_pclose(FILE *pf) { - return pPerl->PL_piProc->Pclose((PerlIO*)pf); + return pPerl->PL_Proc->Pclose((PerlIO*)pf); } unsigned _win32_sleep(unsigned int t) { - return pPerl->PL_piProc->Sleep(t); + return pPerl->PL_Proc->Sleep(t); } int _win32_spawnvp(int mode, const char *cmdname, const char *const *argv) { - return pPerl->PL_piProc->Spawnvp(mode, cmdname, argv); + return pPerl->PL_Proc->Spawnvp(mode, cmdname, argv); } int _win32_mkdir(const char *dir, int mode) { - return pPerl->PL_piDir->Makedir(dir, mode, ErrorNo()); + return pPerl->PL_Dir->Makedir(dir, mode, ErrorNo()); } int _win32_rmdir(const char *dir) { - return pPerl->PL_piDir->Rmdir(dir, ErrorNo()); + return pPerl->PL_Dir->Rmdir(dir, ErrorNo()); } int _win32_chdir(const char *dir) { - return pPerl->PL_piDir->Chdir(dir, ErrorNo()); + return pPerl->PL_Dir->Chdir(dir, ErrorNo()); } #undef stat int _win32_fstat(int fd,struct stat *sbufptr) { - return pPerl->PL_piLIO->FileStat(fd, sbufptr, ErrorNo()); + return pPerl->PL_LIO->FileStat(fd, sbufptr, ErrorNo()); } int _win32_stat(const char *name,struct stat *sbufptr) { - return pPerl->PL_piLIO->NameStat(name, sbufptr, ErrorNo()); + return pPerl->PL_LIO->NameStat(name, sbufptr, ErrorNo()); } int _win32_rename(const char *oname, const char *newname) { - return pPerl->PL_piLIO->Rename(oname, newname, ErrorNo()); + return pPerl->PL_LIO->Rename(oname, newname, ErrorNo()); } int _win32_setmode(int fd, int mode) { - return pPerl->PL_piLIO->Setmode(fd, mode, ErrorNo()); + return pPerl->PL_LIO->Setmode(fd, mode, ErrorNo()); } long _win32_lseek(int fd, long offset, int origin) { - return pPerl->PL_piLIO->Lseek(fd, offset, origin, ErrorNo()); + return pPerl->PL_LIO->Lseek(fd, offset, origin, ErrorNo()); } long _win32_tell(int fd) { - return pPerl->PL_piStdIO->Tell((PerlIO*)fd, ErrorNo()); + return pPerl->PL_StdIO->Tell((PerlIO*)fd, ErrorNo()); } int _win32_dup(int fd) { - return pPerl->PL_piLIO->Dup(fd, ErrorNo()); + return pPerl->PL_LIO->Dup(fd, ErrorNo()); } int _win32_dup2(int h1, int h2) { - return pPerl->PL_piLIO->Dup2(h1, h2, ErrorNo()); + return pPerl->PL_LIO->Dup2(h1, h2, ErrorNo()); } int _win32_open(const char *path, int oflag,...) { - return pPerl->PL_piLIO->Open(path, oflag, ErrorNo()); + return pPerl->PL_LIO->Open(path, oflag, ErrorNo()); } int _win32_close(int fd) { - return pPerl->PL_piLIO->Close(fd, ErrorNo()); + return pPerl->PL_LIO->Close(fd, ErrorNo()); } int _win32_read(int fd, void *buf, unsigned int cnt) { - return pPerl->PL_piLIO->Read(fd, buf, cnt, ErrorNo()); + return pPerl->PL_LIO->Read(fd, buf, cnt, ErrorNo()); } int _win32_write(int fd, const void *buf, unsigned int cnt) { - return pPerl->PL_piLIO->Write(fd, buf, cnt, ErrorNo()); + return pPerl->PL_LIO->Write(fd, buf, cnt, ErrorNo()); } int _win32_times(struct tms *timebuf) { - return pPerl->PL_piProc->Times(timebuf); + return pPerl->PL_Proc->Times(timebuf); } int _win32_ioctl(int i, unsigned int u, char *data) { - return pPerl->PL_piLIO->IOCtl(i, u, data, ErrorNo()); + return pPerl->PL_LIO->IOCtl(i, u, data, ErrorNo()); } int _win32_utime(const char *f, struct utimbuf *t) { - return pPerl->PL_piLIO->Utime((char*)f, t, ErrorNo()); + return pPerl->PL_LIO->Utime((char*)f, t, ErrorNo()); } int _win32_uname(struct utsname *name) { - return pPerl->PL_piENV->Uname(name, ErrorNo()); + return pPerl->PL_Env->Uname(name, ErrorNo()); } unsigned long _win32_os_id(void) { - return pPerl->PL_piENV->OsID(); + return pPerl->PL_Env->OsID(); } char* _win32_getenv(const char *name) { - return pPerl->PL_piENV->Getenv(name, ErrorNo()); + return pPerl->PL_Env->Getenv(name, ErrorNo()); } int _win32_putenv(const char *name) { - return pPerl->PL_piENV->Putenv(name, ErrorNo()); + return pPerl->PL_Env->Putenv(name, ErrorNo()); } int _win32_open_osfhandle(long handle, int flags) { - return pPerl->PL_piStdIO->OpenOSfhandle(handle, flags); + return pPerl->PL_StdIO->OpenOSfhandle(handle, flags); } long _win32_get_osfhandle(int fd) { - return pPerl->PL_piStdIO->GetOSfhandle(fd); + return pPerl->PL_StdIO->GetOSfhandle(fd); } u_long _win32_htonl (u_long hostlong) { - return pPerl->PL_piSock->Htonl(hostlong); + return pPerl->PL_Sock->Htonl(hostlong); } u_short _win32_htons (u_short hostshort) { - return pPerl->PL_piSock->Htons(hostshort); + return pPerl->PL_Sock->Htons(hostshort); } u_long _win32_ntohl (u_long netlong) { - return pPerl->PL_piSock->Ntohl(netlong); + return pPerl->PL_Sock->Ntohl(netlong); } u_short _win32_ntohs (u_short netshort) { - return pPerl->PL_piSock->Ntohs(netshort); + return pPerl->PL_Sock->Ntohs(netshort); } unsigned long _win32_inet_addr (const char * cp) { - return pPerl->PL_piSock->InetAddr(cp, ErrorNo()); + return pPerl->PL_Sock->InetAddr(cp, ErrorNo()); } char * _win32_inet_ntoa (struct in_addr in) { - return pPerl->PL_piSock->InetNtoa(in, ErrorNo()); + return pPerl->PL_Sock->InetNtoa(in, ErrorNo()); } SOCKET _win32_socket (int af, int type, int protocol) { - return pPerl->PL_piSock->Socket(af, type, protocol, ErrorNo()); + return pPerl->PL_Sock->Socket(af, type, protocol, ErrorNo()); } int _win32_bind (SOCKET s, const struct sockaddr *addr, int namelen) { - return pPerl->PL_piSock->Bind(s, addr, namelen, ErrorNo()); + return pPerl->PL_Sock->Bind(s, addr, namelen, ErrorNo()); } int _win32_listen (SOCKET s, int backlog) { - return pPerl->PL_piSock->Listen(s, backlog, ErrorNo()); + return pPerl->PL_Sock->Listen(s, backlog, ErrorNo()); } SOCKET _win32_accept (SOCKET s, struct sockaddr *addr, int *addrlen) { - return pPerl->PL_piSock->Accept(s, addr, addrlen, ErrorNo()); + return pPerl->PL_Sock->Accept(s, addr, addrlen, ErrorNo()); } int _win32_connect (SOCKET s, const struct sockaddr *name, int namelen) { - return pPerl->PL_piSock->Connect(s, name, namelen, ErrorNo()); + return pPerl->PL_Sock->Connect(s, name, namelen, ErrorNo()); } int _win32_send (SOCKET s, const char * buf, int len, int flags) { - return pPerl->PL_piSock->Send(s, buf, len, flags, ErrorNo()); + return pPerl->PL_Sock->Send(s, buf, len, flags, ErrorNo()); } int _win32_sendto (SOCKET s, const char * buf, int len, int flags, const struct sockaddr *to, int tolen) { - return pPerl->PL_piSock->Sendto(s, buf, len, flags, to, tolen, ErrorNo()); + return pPerl->PL_Sock->Sendto(s, buf, len, flags, to, tolen, ErrorNo()); } int _win32_recv (SOCKET s, char * buf, int len, int flags) { - return pPerl->PL_piSock->Recv(s, buf, len, flags, ErrorNo()); + return pPerl->PL_Sock->Recv(s, buf, len, flags, ErrorNo()); } int _win32_recvfrom (SOCKET s, char * buf, int len, int flags, struct sockaddr *from, int * fromlen) { - return pPerl->PL_piSock->Recvfrom(s, buf, len, flags, from, fromlen, ErrorNo()); + return pPerl->PL_Sock->Recvfrom(s, buf, len, flags, from, fromlen, ErrorNo()); } int _win32_shutdown (SOCKET s, int how) { - return pPerl->PL_piSock->Shutdown(s, how, ErrorNo()); + return pPerl->PL_Sock->Shutdown(s, how, ErrorNo()); } int _win32_closesocket (SOCKET s) { - return pPerl->PL_piSock->Closesocket(s, ErrorNo()); + return pPerl->PL_Sock->Closesocket(s, ErrorNo()); } int _win32_ioctlsocket (SOCKET s, long cmd, u_long *argp) { - return pPerl->PL_piSock->Ioctlsocket(s, cmd, argp, ErrorNo()); + return pPerl->PL_Sock->Ioctlsocket(s, cmd, argp, ErrorNo()); } int _win32_setsockopt (SOCKET s, int level, int optname, const char * optval, int optlen) { - return pPerl->PL_piSock->Setsockopt(s, level, optname, optval, optlen, ErrorNo()); + return pPerl->PL_Sock->Setsockopt(s, level, optname, optval, optlen, ErrorNo()); } int _win32_getsockopt (SOCKET s, int level, int optname, char * optval, int *optlen) { - return pPerl->PL_piSock->Getsockopt(s, level, optname, optval, optlen, ErrorNo()); + return pPerl->PL_Sock->Getsockopt(s, level, optname, optval, optlen, ErrorNo()); } int _win32_getpeername (SOCKET s, struct sockaddr *name, int * namelen) { - return pPerl->PL_piSock->Getpeername(s, name, namelen, ErrorNo()); + return pPerl->PL_Sock->Getpeername(s, name, namelen, ErrorNo()); } int _win32_getsockname (SOCKET s, struct sockaddr *name, int * namelen) { - return pPerl->PL_piSock->Getsockname(s, name, namelen, ErrorNo()); + return pPerl->PL_Sock->Getsockname(s, name, namelen, ErrorNo()); } int _win32_gethostname (char * name, int namelen) { - return pPerl->PL_piSock->Gethostname(name, namelen, ErrorNo()); + return pPerl->PL_Sock->Gethostname(name, namelen, ErrorNo()); } struct hostent * _win32_gethostbyname(const char * name) { - return pPerl->PL_piSock->Gethostbyname(name, ErrorNo()); + return pPerl->PL_Sock->Gethostbyname(name, ErrorNo()); } struct hostent * _win32_gethostbyaddr(const char * addr, int len, int type) { - return pPerl->PL_piSock->Gethostbyaddr(addr, len, type, ErrorNo()); + return pPerl->PL_Sock->Gethostbyaddr(addr, len, type, ErrorNo()); } struct protoent * _win32_getprotobyname(const char * name) { - return pPerl->PL_piSock->Getprotobyname(name, ErrorNo()); + return pPerl->PL_Sock->Getprotobyname(name, ErrorNo()); } struct protoent * _win32_getprotobynumber(int proto) { - return pPerl->PL_piSock->Getprotobynumber(proto, ErrorNo()); + return pPerl->PL_Sock->Getprotobynumber(proto, ErrorNo()); } struct servent * _win32_getservbyname(const char * name, const char * proto) { - return pPerl->PL_piSock->Getservbyname(name, proto, ErrorNo()); + return pPerl->PL_Sock->Getservbyname(name, proto, ErrorNo()); } struct servent * _win32_getservbyport(int port, const char * proto) { - return pPerl->PL_piSock->Getservbyport(port, proto, ErrorNo()); + return pPerl->PL_Sock->Getservbyport(port, proto, ErrorNo()); } int _win32_select (int nfds, Perl_fd_set *rfds, Perl_fd_set *wfds, Perl_fd_set *xfds, const struct timeval *timeout) { - return pPerl->PL_piSock->Select(nfds, (char*)rfds, (char*)wfds, (char*)xfds, timeout, ErrorNo()); + return pPerl->PL_Sock->Select(nfds, (char*)rfds, (char*)wfds, (char*)xfds, timeout, ErrorNo()); } void _win32_endnetent(void) { - pPerl->PL_piSock->Endnetent(ErrorNo()); + pPerl->PL_Sock->Endnetent(ErrorNo()); } void _win32_endhostent(void) { - pPerl->PL_piSock->Endhostent(ErrorNo()); + pPerl->PL_Sock->Endhostent(ErrorNo()); } void _win32_endprotoent(void) { - pPerl->PL_piSock->Endprotoent(ErrorNo()); + pPerl->PL_Sock->Endprotoent(ErrorNo()); } void _win32_endservent(void) { - pPerl->PL_piSock->Endservent(ErrorNo()); + pPerl->PL_Sock->Endservent(ErrorNo()); } struct netent * _win32_getnetent(void) { - return pPerl->PL_piSock->Getnetent(ErrorNo()); + return pPerl->PL_Sock->Getnetent(ErrorNo()); } struct netent * _win32_getnetbyname(char *name) { - return pPerl->PL_piSock->Getnetbyname(name, ErrorNo()); + return pPerl->PL_Sock->Getnetbyname(name, ErrorNo()); } struct netent * _win32_getnetbyaddr(long net, int type) { - return pPerl->PL_piSock->Getnetbyaddr(net, type, ErrorNo()); + return pPerl->PL_Sock->Getnetbyaddr(net, type, ErrorNo()); } struct protoent *_win32_getprotoent(void) { - return pPerl->PL_piSock->Getprotoent(ErrorNo()); + return pPerl->PL_Sock->Getprotoent(ErrorNo()); } struct servent *_win32_getservent(void) { - return pPerl->PL_piSock->Getservent(ErrorNo()); + return pPerl->PL_Sock->Getservent(ErrorNo()); } void _win32_sethostent(int stayopen) { - pPerl->PL_piSock->Sethostent(stayopen, ErrorNo()); + pPerl->PL_Sock->Sethostent(stayopen, ErrorNo()); } void _win32_setnetent(int stayopen) { - pPerl->PL_piSock->Setnetent(stayopen, ErrorNo()); + pPerl->PL_Sock->Setnetent(stayopen, ErrorNo()); } void _win32_setprotoent(int stayopen) { - pPerl->PL_piSock->Setprotoent(stayopen, ErrorNo()); + pPerl->PL_Sock->Setprotoent(stayopen, ErrorNo()); } void _win32_setservent(int stayopen) { - pPerl->PL_piSock->Setservent(stayopen, ErrorNo()); + pPerl->PL_Sock->Setservent(stayopen, ErrorNo()); } } /* extern "C" */ EOCODE diff --git a/win32/Makefile b/win32/Makefile index 51f80c1599..608d37e0bd 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -40,7 +40,7 @@ INST_VER = \5.00557 # the same location. Commenting it out gives you a simpler # installation that is easier to understand for beginners. # -#INST_ARCH = \$(ARCHNAME) +INST_ARCH = \$(ARCHNAME) # # uncomment to enable threads-capabilities @@ -325,7 +325,7 @@ EXTUTILSDIR = $(LIBDIR)\extutils !IF "$(OBJECT)" == "-DPERL_OBJECT" PERLIMPLIB = ..\perlcore.lib PERLDLL = ..\perlcore.dll -#CAPILIB = $(COREDIR)\perlCAPI.lib +#CAPILIB = $(COREDIR)\perlapi.lib !ELSE PERLIMPLIB = ..\perl.lib PERLDLL = ..\perl.dll @@ -400,6 +400,7 @@ MICROCORE_SRC = \ ..\mg.c \ ..\op.c \ ..\perl.c \ + ..\perlapi.c \ ..\perly.c \ ..\pp.c \ ..\pp_ctl.c \ @@ -477,6 +478,7 @@ CORE_NOCFG_H = \ ..\op.h \ ..\opcode.h \ ..\perl.h \ + ..\perlapi.h \ ..\perlsdio.h \ ..\perlsfio.h \ ..\perly.h \ @@ -793,15 +795,12 @@ $(DYNALOADER).c: $(MINIPERL) $(EXTDIR)\DynaLoader\dl_win32.xs $(CONFIGPM) cd ..\..\win32 #!IF "$(OBJECT)" == "-DPERL_OBJECT" -#perlCAPI.cpp : $(MINIPERL) -# $(MINIPERL) GenCAPI.pl $(COREDIR) -# -#perlCAPI$(o) : perlCAPI.cpp +#perlapi$(o) : ..\perlapi.c # $(CC) $(CFLAGS_O) $(RUNTIME) -UPERLDLL -c \ -# $(OBJOUT_FLAG)perlCAPI$(o) perlCAPI.cpp +# $(OBJOUT_FLAG)perlapi$(o) ..\perlapi.c # -#$(CAPILIB) : perlCAPI.cpp perlCAPI$(o) -# lib /OUT:$(CAPILIB) perlCAPI$(o) +#$(CAPILIB) : ..\perlapi.c ..\perlapi$(o) +# lib /OUT:$(CAPILIB) ..\perlapi$(o) #!ENDIF $(EXTDIR)\DynaLoader\dl_win32.xs: dl_win32.xs @@ -993,7 +992,6 @@ clean : -@erase perlmain$(o) -@erase config.w32 -@erase /f config.h - -@erase perlCAPI.cpp -@erase $(GLOBEXE) -@erase $(PERLEXE) -@erase $(PERLDLL) diff --git a/win32/makedef.pl b/win32/makedef.pl index f95d3747ed..dc0869a5c7 100644 --- a/win32/makedef.pl +++ b/win32/makedef.pl @@ -28,51 +28,50 @@ if ($define{PERL_OBJECT}) { print "LIBRARY PerlCore\n"; print "DESCRIPTION 'Perl interpreter'\n"; print "EXPORTS\n"; - output_symbol("perl_alloc"); +# output_symbol("perl_alloc"); output_symbol("perl_get_host_info"); output_symbol("perl_alloc_using"); - output_symbol("perl_construct"); - output_symbol("perl_destruct"); - output_symbol("perl_free"); - output_symbol("perl_parse"); - output_symbol("perl_run"); - output_symbol("RunPerl"); +# output_symbol("perl_construct"); +# output_symbol("perl_destruct"); +# output_symbol("perl_free"); +# output_symbol("perl_parse"); +# output_symbol("perl_run"); +# output_symbol("RunPerl"); output_symbol("GetPerlInterpreter"); - exit(0); +# exit(0); +} +else { + if ($CCTYPE ne 'GCC') { + print "LIBRARY Perl\n"; + print "DESCRIPTION 'Perl interpreter, export autogenerated'\n"; + } + else { + $define{'PERL_GLOBAL_STRUCT'} = 1; + $define{'MULTIPLICITY'} = 1; + } + print "EXPORTS\n"; } - -if ($CCTYPE ne 'GCC') - { - print "LIBRARY Perl\n"; - print "DESCRIPTION 'Perl interpreter, export autogenerated'\n"; - } -else - { - $define{'PERL_GLOBAL_STRUCT'} = 1; - $define{'MULTIPLICITY'} = 1; - } - -print "EXPORTS\n"; my %skip; my %export; -sub skip_symbols -{ - my $list = shift; - foreach my $symbol (@$list) - { - $skip{$symbol} = 1; - } +sub skip_symbols { + my $list = shift; + foreach my $symbol (@$list) { + $skip{$symbol} = 1; + } } -sub emit_symbols -{ - my $list = shift; - foreach my $symbol (@$list) - { - emit_symbol($symbol) unless exists $skip{$symbol}; - } +sub emit_symbols { + my $list = shift; + foreach my $symbol (@$list) { + my $skipsym = $symbol; + # XXX hack + if ($define{PERL_OBJECT}) { + $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/; + } + emit_symbol($symbol) unless exists $skip{$skipsym}; + } } skip_symbols [qw( @@ -120,6 +119,24 @@ PL_cshname PL_opsave )]; +if ($define{'PERL_OBJECT'}) { + skip_symbols [qw( + Perl_getenv_len + Perl_my_popen + Perl_my_pclose + )]; +} +else { + skip_symbols [qw( + PL_Dir + PL_Env + PL_LIO + PL_Mem + PL_Proc + PL_Sock + PL_StdIO + )]; +} if ($define{'MYMALLOC'}) { @@ -194,13 +211,14 @@ unless ($define{'FAKE_THREADS'}) sub readvar { my $file = shift; + my $proc = shift || sub { "PL_$_[2]" }; open(VARS,$file) || die "Cannot open $file:$!"; my @syms; while (<VARS>) { # All symbols have a Perl_ prefix because that's what embed.h # sticks in front of them. - push(@syms,"PL_".$1) if (/\bPERLVARI?C?\([IGT](\w+)/); + push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/); } close(VARS); return \@syms; @@ -267,23 +285,27 @@ for my $syms ('../global.sym','../pp.sym', '../globvar.sym') # variables -unless ($define{'PERL_GLOBAL_STRUCT'}) - { - my $glob = readvar("../perlvars.h"); - emit_symbols $glob; - } - -unless ($define{'MULTIPLICITY'}) - { - my $glob = readvar("../intrpvar.h"); - emit_symbols $glob; - } - -unless ($define{'MULTIPLICITY'} || $define{'USE_THREADS'}) - { - my $glob = readvar("../thrdvar.h"); - emit_symbols $glob; - } +if ($define{'PERL_OBJECT'}) { + for my $f ("../perlvars.h", "../intrpvar.h", "../thrdvar.h") { + my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" }); + emit_symbols $glob; + } +} +else { + unless ($define{'PERL_GLOBAL_STRUCT'}) { + my $glob = readvar("../perlvars.h"); + emit_symbols $glob; + } + unless ($define{'MULTIPLICITY'}) { + my $glob = readvar("../intrpvar.h"); + emit_symbols $glob; + } + + unless ($define{'MULTIPLICITY'} || $define{'USE_THREADS'}) { + my $glob = readvar("../thrdvar.h"); + emit_symbols $glob; + } +} while (<DATA>) { my $symbol; @@ -309,25 +331,28 @@ sub emit_symbol { sub output_symbol { my $symbol = shift; - if ($CCTYPE eq "BORLAND") { - # workaround Borland quirk by exporting both the straight - # name and a name with leading underscore. Note the - # alias *must* come after the symbol itself, if both - # are to be exported. (Linker bug?) - print "\t_$symbol\n"; - print "\t$symbol = _$symbol\n"; - } - elsif ($CCTYPE eq 'GCC') { - # Symbols have leading _ whole process is $%£"% slow - # so skip aliases for now - print "\t$symbol\n"; - } - else { - # for binary coexistence, export both the symbol and - # alias with leading underscore - print "\t$symbol\n"; - print "\t_$symbol = $symbol\n"; - } + print "\t$symbol\n"; +# XXX: binary compatibility between compilers is an exercise +# in frustration :-( +# if ($CCTYPE eq "BORLAND") { +# # workaround Borland quirk by exporting both the straight +# # name and a name with leading underscore. Note the +# # alias *must* come after the symbol itself, if both +# # are to be exported. (Linker bug?) +# print "\t_$symbol\n"; +# print "\t$symbol = _$symbol\n"; +# } +# elsif ($CCTYPE eq 'GCC') { +# # Symbols have leading _ whole process is $%@"% slow +# # so skip aliases for now +# print "\t$symbol\n"; +# } +# else { +# # for binary coexistence, export both the symbol and +# # alias with leading underscore +# print "\t$symbol\n"; +# print "\t_$symbol = $symbol\n"; +# } } 1; diff --git a/win32/perllib.c b/win32/perllib.c index 7cfe60da15..8682f77ab5 100644 --- a/win32/perllib.c +++ b/win32/perllib.c @@ -1473,10 +1473,12 @@ RunPerl(int argc, char **argv, char **env) #ifdef PERL_GLOBAL_STRUCT #define PERLVAR(var,type) /**/ +#define PERLVARA(var,type) /**/ #define PERLVARI(var,type,init) PL_Vars.var = init; #define PERLVARIC(var,type,init) PL_Vars.var = init; #include "perlvars.h" #undef PERLVAR +#undef PERLVARA #undef PERLVARI #undef PERLVARIC #endif diff --git a/win32/win32.c b/win32/win32.c index 1fffbaf66f..cbe50c29f5 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -90,7 +90,7 @@ static long tokenize(char *str, char **dest, char ***destv); static BOOL has_shell_metachars(char *ptr); static long filetime_to_clock(PFILETIME ft); static BOOL filetime_from_time(PFILETIME ft, time_t t); -static char * get_emd_part(char **leading, char *trailing, ...); +static char * get_emd_part(SV *leading, char *trailing, ...); static void remove_dead_process(long deceased); static long find_pid(int pid); static char * qualified_path(const char *cmd); @@ -134,9 +134,9 @@ IsWinNT(void) return (win32_os_id() == VER_PLATFORM_WIN32_NT); } -/* *ptr is expected to point to valid allocated space (can't be NULL) */ -char* -GetRegStrFromKey(HKEY hkey, const char *lpszValueName, char** ptr, DWORD* lpDataLen) +/* sv (if non-NULL) is expected to be POK (valid allocated SvPVX(sv)) */ +static char* +get_regstr_from(HKEY hkey, const char *valuename, SV *sv) { /* Retrieve a REG_SZ or REG_EXPAND_SZ from the registry */ HKEY handle; @@ -147,33 +147,38 @@ GetRegStrFromKey(HKEY hkey, const char *lpszValueName, char** ptr, DWORD* lpData retval = RegOpenKeyEx(hkey, subkey, 0, KEY_READ, &handle); if (retval == ERROR_SUCCESS) { - retval = RegQueryValueEx(handle, lpszValueName, 0, &type, NULL, lpDataLen); + DWORD datalen; + retval = RegQueryValueEx(handle, valuename, 0, &type, NULL, &datalen); if (retval == ERROR_SUCCESS && type == REG_SZ) { dPERLOBJ; - Renew(*ptr, *lpDataLen, char); - retval = RegQueryValueEx(handle, lpszValueName, 0, NULL, - (PBYTE)*ptr, lpDataLen); - if (retval == ERROR_SUCCESS) - str = *ptr; + if (!sv) + sv = sv_2mortal(newSVpvn("",0)); + SvGROW(sv, datalen); + retval = RegQueryValueEx(handle, valuename, 0, NULL, + (PBYTE)SvPVX(sv), &datalen); + if (retval == ERROR_SUCCESS) { + str = SvPVX(sv); + SvCUR_set(sv,datalen-1); + } } RegCloseKey(handle); } return str; } -/* *ptr is expected to point to valid allocated space (can't be NULL) */ -char* -GetRegStr(const char *lpszValueName, char** ptr, DWORD* lpDataLen) +/* sv (if non-NULL) is expected to be POK (valid allocated SvPVX(sv)) */ +static char* +get_regstr(const char *valuename, SV *sv) { - char *str = GetRegStrFromKey(HKEY_CURRENT_USER, lpszValueName, ptr, lpDataLen); + char *str = get_regstr_from(HKEY_CURRENT_USER, valuename, sv); if (!str) - str = GetRegStrFromKey(HKEY_LOCAL_MACHINE, lpszValueName, ptr, lpDataLen); + str = get_regstr_from(HKEY_LOCAL_MACHINE, valuename, sv); return str; } -/* *prev_path is expected to point to valid allocated space (can't be NULL) */ +/* prev_path (if non-NULL) is expected to be POK (valid allocated SvPVX(sv)) */ static char * -get_emd_part(char **prev_path, char *trailing_path, ...) +get_emd_part(SV *prev_path, char *trailing_path, ...) { char base[10]; va_list ap; @@ -242,13 +247,11 @@ get_emd_part(char **prev_path, char *trailing_path, ...) if (GetFileAttributes(mod_name) != (DWORD) -1) { /* directory exists */ dPERLOBJ; - newsize = strlen(mod_name) + 1; - oldsize = strlen(*prev_path) + 1; - newsize += oldsize; /* includes plus 1 for ';' */ - Renew(*prev_path, newsize, char); - (*prev_path)[oldsize-1] = ';'; - strcpy(&(*prev_path)[oldsize], mod_name); - return *prev_path; + if (!prev_path) + prev_path = sv_2mortal(newSVpvn("",0)); + sv_catpvn(prev_path, ";", 1); + sv_catpv(prev_path, mod_name); + return SvPVX(prev_path); } return Nullch; @@ -257,73 +260,60 @@ get_emd_part(char **prev_path, char *trailing_path, ...) char * win32_get_privlib(pTHX_ char *pl) { + dPERLOBJ; char *stdlib = "lib"; char buffer[MAX_PATH+1]; - char **path; - DWORD datalen; - dPERLOBJ; - SV *sv = sv_2mortal(newSVpvn("",127)); + SV *sv = Nullsv; /* $stdlib = $HKCU{"lib-$]"} || $HKLM{"lib-$]"} || $HKCU{"lib"} || $HKLM{"lib"} || ""; */ sprintf(buffer, "%s-%s", stdlib, pl); - path = &SvPVX(sv); - if (!GetRegStr(buffer, path, &datalen)) - (void)GetRegStr(stdlib, path, &datalen); + if (!get_regstr(buffer, sv)) + (void)get_regstr(stdlib, sv); /* $stdlib .= ";$EMD/../../lib" */ - (void)get_emd_part(path, stdlib, ARCHNAME, "bin", Nullch); - SvCUR_set(sv, strlen(*path)); - SvLEN_set(sv, SvCUR(sv)+1); - return SvPVX(sv); + return get_emd_part(sv, stdlib, ARCHNAME, "bin", Nullch); } char * win32_get_sitelib(pTHX_ char *pl) { + dPERLOBJ; char *sitelib = "sitelib"; char regstr[40]; char pathstr[MAX_PATH+1]; DWORD datalen; - char **path1, *str1 = Nullch; - char **path2, *str2 = Nullch; int len, newsize; - dPERLOBJ; - SV *sv1 = sv_2mortal(newSVpvn("",127)); - SV *sv2 = sv_2mortal(newSVpvn("",127)); + SV *sv1 = Nullsv; + SV *sv2 = Nullsv; /* $HKCU{"sitelib-$]"} || $HKLM{"sitelib-$]"} . ---; */ sprintf(regstr, "%s-%s", sitelib, pl); - path1 = &SvPVX(sv1); - (void)GetRegStr(regstr, path1, &datalen); + (void)get_regstr(regstr, sv1); /* $sitelib .= * ";$EMD/" . ((-d $EMD/../../../$]) ? "../../.." : "../.."). "/site/$]/lib"; */ sprintf(pathstr, "site/%s/lib", pl); - str1 = get_emd_part(path1, pathstr, ARCHNAME, "bin", pl, Nullch); - if (!str1 && strlen(pl) == 7) { + (void)get_emd_part(sv1, pathstr, ARCHNAME, "bin", pl, Nullch); + if (!sv1 && strlen(pl) == 7) { /* pl may have been SUBVERSION-specific; try again without * SUBVERSION */ sprintf(pathstr, "site/%.5s/lib", pl); - str1 = get_emd_part(path1, pathstr, ARCHNAME, "bin", pl, Nullch); + (void)get_emd_part(sv1, pathstr, ARCHNAME, "bin", pl, Nullch); } /* $HKCU{'sitelib'} || $HKLM{'sitelib'} . ---; */ - path2 = &SvPVX(sv2); - (void)GetRegStr(sitelib, path2, &datalen); + (void)get_regstr(sitelib, sv2); /* $sitelib .= * ";$EMD/" . ((-d $EMD/../../../$]) ? "../../.." : "../.."). "/site/lib"; */ - str2 = get_emd_part(path2, "site/lib", ARCHNAME, "bin", pl, Nullch); - - SvCUR_set(sv1, strlen(*path1)); - SvLEN_set(sv1, SvCUR(sv1)+1); - SvCUR_set(sv2, strlen(*path2)); - SvLEN_set(sv2, SvCUR(sv2)+1); + (void)get_emd_part(sv2, "site/lib", ARCHNAME, "bin", pl, Nullch); - if (!str1) - return *path2; - if (!str2) - return *path1; + if (!sv1 && !sv2) + return Nullch; + if (!sv1) + return SvPVX(sv2); + if (!sv2) + return SvPVX(sv1); sv_catpvn(sv1, ";", 1); sv_catsv(sv1, sv2); @@ -497,6 +487,7 @@ get_shell(void) int do_aspawn(pTHX_ void *vreally, void **vmark, void **vsp) { + dPERLOBJ; SV *really = (SV*)vreally; SV **mark = (SV**)vmark; SV **sp = (SV**)vsp; @@ -505,7 +496,6 @@ do_aspawn(pTHX_ void *vreally, void **vmark, void **vsp) int status; int flag = P_WAIT; int index = 0; - dPERLOBJ; if (sp <= mark) return -1; @@ -562,13 +552,13 @@ do_aspawn(pTHX_ void *vreally, void **vmark, void **vsp) int do_spawn2(pTHX_ char *cmd, int exectype) { + dPERLOBJ; char **a; char *s; char **argv; int status = -1; BOOL needToTry = TRUE; char *cmd2; - dPERLOBJ; /* Save an extra exec if possible. See if there are shell * metacharacters in it */ @@ -676,6 +666,7 @@ DIR * win32_opendir(char *filename) { dTHX; + dPERLOBJ; DIR *p; long len; long idx; @@ -687,7 +678,6 @@ win32_opendir(char *filename) char buffer[MAX_PATH*2]; WCHAR wbuffer[MAX_PATH]; char* ptr; - dPERLOBJ; len = strlen(filename); if (len > MAX_PATH) @@ -915,8 +905,8 @@ chown(const char *path, uid_t owner, gid_t group) static long find_pid(int pid) { - long child; dPERLOBJ; + long child; for (child = 0 ; child < w32_num_children ; ++child) { if (w32_child_pids[child] == pid) return child; @@ -966,6 +956,7 @@ win32_sleep(unsigned int t) DllExport int win32_stat(const char *path, struct stat *buffer) { + dPERLOBJ; char t[MAX_PATH+1]; int l = strlen(path); int res; @@ -991,7 +982,6 @@ win32_stat(const char *path, struct stat *buffer) break; } } - dPERLOBJ; if (USING_WIDE()) { dTHX; A2WHELPER(path, wbuffer, sizeof(wbuffer)); @@ -1140,80 +1130,61 @@ win32_getenv(const char *name) { dTHX; dPERLOBJ; - static char *curitem = Nullch; /* XXX threadead */ - static WCHAR *wCuritem = (WCHAR*)Nullch; /* XXX threadead */ - static DWORD curlen = 0, wCurlen = 0;/* XXX threadead */ WCHAR wBuffer[MAX_PATH]; DWORD needlen; - - if (USING_WIDE()) { - if (!wCuritem) { - wCurlen = 512; - New(1306,wCuritem,wCurlen,WCHAR); - } - } - if (!curitem) { - curlen = 512; - New(1305,curitem,curlen,char); - } + SV *curitem = Nullsv; if (USING_WIDE()) { A2WHELPER(name, wBuffer, sizeof(wBuffer)); - needlen = GetEnvironmentVariableW(wBuffer,wCuritem,wCurlen); + needlen = GetEnvironmentVariableW(wBuffer, NULL, 0); } else - needlen = GetEnvironmentVariableA(name,curitem,curlen); + needlen = GetEnvironmentVariableA(name,NULL,0); if (needlen != 0) { + curitem = sv_2mortal(newSVpvn("", 0)); if (USING_WIDE()) { - while (needlen > wCurlen) { - Renew(wCuritem,needlen,WCHAR); - wCurlen = needlen; - needlen = GetEnvironmentVariableW(wBuffer,wCuritem,wCurlen); - } - if (needlen > curlen) { - Renew(curitem,needlen,char); - curlen = needlen; - } - W2AHELPER(wCuritem, curitem, curlen); + SV *acuritem; + do { + SvGROW(curitem, (needlen+1)*sizeof(WCHAR)); + needlen = GetEnvironmentVariableW(wBuffer, + (WCHAR*)SvPVX(curitem), + needlen); + } while (needlen >= SvLEN(curitem)/sizeof(WCHAR)); + SvCUR_set(curitem, needlen*sizeof(WCHAR)); + acuritem = sv_2mortal(newSVsv(curitem)); + W2AHELPER((WCHAR*)SvPVX(acuritem), SvPVX(curitem), SvCUR(curitem)); } else { - while (needlen > curlen) { - Renew(curitem,needlen,char); - curlen = needlen; - needlen = GetEnvironmentVariableA(name,curitem,curlen); - } + do { + SvGROW(curitem, needlen+1); + needlen = GetEnvironmentVariableA(name,SvPVX(curitem), + needlen); + } while (needlen >= SvLEN(curitem)); + SvCUR_set(curitem, needlen); } } else { /* allow any environment variables that begin with 'PERL' to be stored in the registry */ - if (curitem) - *curitem = '\0'; - - if (strncmp(name, "PERL", 4) == 0) { - if (curitem) { - Safefree(curitem); - curitem = Nullch; - curlen = 0; - } - curitem = GetRegStr(name, &curitem, &curlen); - } + if (strncmp(name, "PERL", 4) == 0) + (void)get_regstr(name, curitem); } - if (curitem && *curitem == '\0') - return Nullch; + if (curitem && SvCUR(curitem)) + return SvPVX(curitem); - return curitem; + return Nullch; } DllExport int win32_putenv(const char *name) { + dPERLOBJ; char* curitem; char* val; WCHAR* wCuritem; WCHAR* wVal; int length, relval = -1; - dPERLOBJ; + if (name) { if (USING_WIDE()) { dTHX; @@ -1319,13 +1290,13 @@ filetime_from_time(PFILETIME pFileTime, time_t Time) DllExport int win32_utime(const char *filename, struct utimbuf *times) { + dPERLOBJ; HANDLE handle; FILETIME ftCreate; FILETIME ftAccess; FILETIME ftWrite; struct utimbuf TimeBuffer; WCHAR wbuffer[MAX_PATH]; - dPERLOBJ; int rc; if (USING_WIDE()) { @@ -1503,9 +1474,9 @@ win32_wait(int *status) /* XXX this wait emulation only knows about processes * spawned via win32_spawnvp(P_NOWAIT, ...). */ + dPERLOBJ; int i, retval; DWORD exitcode, waitcode; - dPERLOBJ; if (!w32_num_children) { errno = ECHILD; @@ -1899,11 +1870,11 @@ win32_fwrite(const void *buf, size_t size, size_t count, FILE *fp) DllExport FILE * win32_fopen(const char *filename, const char *mode) { + dPERLOBJ; WCHAR wMode[MODE_SIZE], wBuffer[MAX_PATH]; if (stricmp(filename, "/dev/null")==0) filename = "NUL"; - dPERLOBJ; if (USING_WIDE()) { dTHX; A2WHELPER(mode, wMode, sizeof(wMode)); @@ -1921,8 +1892,8 @@ win32_fopen(const char *filename, const char *mode) DllExport FILE * win32_fdopen(int handle, const char *mode) { - WCHAR wMode[MODE_SIZE]; dPERLOBJ; + WCHAR wMode[MODE_SIZE]; if (USING_WIDE()) { dTHX; A2WHELPER(mode, wMode, sizeof(wMode)); @@ -1934,8 +1905,8 @@ win32_fdopen(int handle, const char *mode) DllExport FILE * win32_freopen(const char *path, const char *mode, FILE *stream) { - WCHAR wMode[MODE_SIZE], wBuffer[MAX_PATH]; dPERLOBJ; + WCHAR wMode[MODE_SIZE], wBuffer[MAX_PATH]; if (stricmp(path, "/dev/null")==0) path = "NUL"; @@ -2318,10 +2289,10 @@ win32_tell(int fd) DllExport int win32_open(const char *path, int flag, ...) { + dPERLOBJ; va_list ap; int pmode; WCHAR wBuffer[MAX_PATH]; - dPERLOBJ; va_start(ap, flag); pmode = va_arg(ap, int); @@ -2395,10 +2366,10 @@ win32_chdir(const char *dir) static char * create_command_line(const char* command, const char * const *args) { + dPERLOBJ; int index; char *cmd, *ptr, *arg; STRLEN len = strlen(command) + 1; - dPERLOBJ; for (index = 0; (ptr = (char*)args[index]) != NULL; ++index) len += strlen(ptr) + 1; @@ -2419,11 +2390,11 @@ create_command_line(const char* command, const char * const *args) static char * qualified_path(const char *cmd) { + dPERLOBJ; char *pathstr; char *fullcmd, *curfullcmd; STRLEN cmdlen = 0; int has_slash = 0; - dPERLOBJ; if (!cmd) return Nullch; @@ -2521,11 +2492,11 @@ win32_spawnvp(int mode, const char *cmdname, const char *const *argv) #ifdef USE_RTL_SPAWNVP return spawnvp(mode, cmdname, (char * const *)argv); #else + dPERLOBJ; DWORD ret; STARTUPINFO StartupInfo; PROCESS_INFORMATION ProcessInformation; DWORD create = 0; - dPERLOBJ; char *cmd = create_command_line(cmdname, strcmp(cmdname, argv[0]) == 0 ? &argv[1] : argv); @@ -2819,8 +2790,8 @@ win32_get_osfhandle(int fd) DllExport void* win32_dynaload(aTHX_ const char*filename) { - HMODULE hModule; dPERLOBJ; + HMODULE hModule; if (USING_WIDE()) { WCHAR wfilename[MAX_PATH]; A2WHELPER(filename, wfilename, sizeof(wfilename)); @@ -3247,9 +3218,9 @@ XS(w32_CopyFile) void Perl_init_os_extras(pTHX) { + dPERLOBJ; char *file = __FILE__; dXSUB_SYS; - dPERLOBJ; w32_perlshell_tokens = Nullch; w32_perlshell_items = -1; diff --git a/win32/win32.h b/win32/win32.h index 75e3c61cbb..38d8688cdb 100644 --- a/win32/win32.h +++ b/win32/win32.h @@ -239,7 +239,7 @@ struct mgvtbl { \ } -#define dPERLOBJ +#define dPERLOBJ dNOOP #endif /* PERL_OBJECT */ #endif /* _MSC_VER */ |