X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=epoc%2Fepoc.c;h=d580552ae99a4778a45033bb527eb2b76a324727;hb=e9d185f8391f09209c11be82e97358d853f1ba30;hp=a2691f3d3877fe20e5793f44ea34bfe0a7ee16d0;hpb=22d4bb9ccb8701e68f9243547d7e3a3c55f70908;p=p5sagit%2Fp5-mst-13.2.git diff --git a/epoc/epoc.c b/epoc/epoc.c index a2691f3..d580552 100644 --- a/epoc/epoc.c +++ b/epoc/epoc.c @@ -10,139 +10,56 @@ #include #include #include - -void -Perl_epoc_init(int *argcp, char ***argvp) { - int i; - int truecount=0; - char **lastcp = (*argvp); - char *ptr; - for (i=0; i< *argcp; i++) { - if ((*argvp)[i]) { - if (*((*argvp)[i]) == '<') { - if (strlen((*argvp)[i]) > 1) { - ptr =((*argvp)[i])+1; - } else { - i++; - ptr = ((*argvp)[i]); - } - freopen( ptr, "r", stdin); - } else if (*((*argvp)[i]) == '>') { - if (strlen((*argvp)[i]) > 1) { - ptr =((*argvp)[i])+1; - } else { - i++; - ptr = ((*argvp)[i]); - } - freopen( ptr, "w", stdout); - } else if ((*((*argvp)[i]) == '2') && (*(((*argvp)[i])+1) == '>')) { - if (strcmp( (*argvp)[i], "2>&1") == 0) { - dup2( fileno( stdout), fileno( stderr)); - } else { - if (strlen((*argvp)[i]) > 2) { - ptr =((*argvp)[i])+2; - } else { - i++; - ptr = ((*argvp)[i]); - } - freopen( ptr, "w", stderr); - } - } else { - *lastcp++ = (*argvp)[i]; - truecount++; - } - } - } - *argcp=truecount; - - -} +#include -#ifdef __MARM__ -/* Symbian forgot to include __fixunsdfi into the MARM euser.lib */ -/* This is from libgcc2.c , gcc-2.7.2.3 */ - -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); - -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); - - - -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); - - -USItype -__fixunsdfsi (a) - DFtype a; -{ - if (a >= - (DFtype) (- 2147483647L -1) ) - return (SItype) (a + (- 2147483647L -1) ) - (- 2147483647L -1) ; - return (SItype) a; -} - -#endif - #include "EXTERN.h" #include "perl.h" #include "XSUB.h" int -do_aspawn( pTHX_ SV *really,SV **mark,SV **sp) { - return do_spawn( really, mark, sp); +do_spawn( char *cmd) { + dTHX; + return system( cmd); } int -do_spawn (pTHX_ SV *really,SV **mark,SV **sp) -{ - dTHR; +do_aspawn ( void *vreally, void **vmark, void **vsp) { + + dTHX; + + SV *really = (SV*)vreally; + SV **mark = (SV**)vmark; + SV **sp = (SV**)vsp; + + char **argv; + char *str; + char *p2, **ptr; + char *cmd; + + int rc; - char **a,*cmd,**ptr, *cmdline, **argv, *p2; - STRLEN n_a; - size_t len = 0; + int index = 0; if (sp<=mark) return -1; - a=argv=ptr=(char**) malloc ((sp-mark+3)*sizeof (char*)); + ptr = argv =(char**) malloc ((sp-mark+3)*sizeof (char*)); while (++mark <= sp) { - if (*mark) - *a = SvPVx(*mark, n_a); + if (*mark && (str = SvPV_nolen(*mark))) + argv[index] = str; else - *a = ""; - len += strlen( *a) + 1; - a++; + argv[index] = ""; } - *a = Nullch; + argv[index++] = 0; - if (!(really && *(cmd = SvPV(really, n_a)))) { - cmd = argv[0]; - argv++; - } - - cmdline = (char * ) malloc( len + 1); - cmdline[ 0] = '\0'; - while (*argv != NULL) { - strcat( cmdline, *argv++); - strcat( cmdline, " "); - } + cmd = strdup((const char*)(really ? SvPV_nolen(really) : argv[0])); + + rc = spawnvp( P_WAIT, cmd, argv); + free( argv); + free( cmd); - for (p2=cmd; *p2 != '\0'; p2++) { - /* Change / to \ */ - if ( *p2 == '/') - *p2 = '\\'; - } - rc = epoc_spawn( cmd, cmdline); - free( ptr); - free( cmdline); - return rc; } @@ -188,6 +105,9 @@ XS(epoc_getcwd) /* more or less stolen from win32.c */ EXTEND(SP,1); SvPOK_on(sv); ST(0) = sv; +#ifndef INCOMPLETE_TAINTS + SvTAINTED_on(ST(0)); +#endif XSRETURN(1); } free( buffer); @@ -198,12 +118,8 @@ XS(epoc_getcwd) /* more or less stolen from win32.c */ void Perl_init_os_extras(void) { - dTHXo; + dTHX; char *file = __FILE__; newXS("EPOC::getcwd", epoc_getcwd, file); } -void -Perl_my_setenv(pTHX_ char *nam,char *val) { - setenv( nam, val, 1); -}