diff options
author | Olaf Flebbe <o.flebbe@science-computing.de> | 2001-02-27 00:34:36 +0100 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-02-27 06:12:11 +0000 |
commit | d5ff79b3161a608c49c52fd6aa22cff1af6f6b82 (patch) | |
tree | 020e9213536d2108b5cf5da6059511b1d3b53ebb /epoc/epoc.c | |
parent | e4f0d88dd7061f3d9b4bbe01e378d668273f5363 (diff) | |
download | perl-d5ff79b3161a608c49c52fd6aa22cff1af6f6b82.tar.gz |
[perl-current] EPOC
Message-ID: <Pine.LNX.4.02.10102262333490.3781-100000@milkyway.science-computing.de>
p4raw-id: //depot/perl@8956
Diffstat (limited to 'epoc/epoc.c')
-rw-r--r-- | epoc/epoc.c | 85 |
1 files changed, 60 insertions, 25 deletions
diff --git a/epoc/epoc.c b/epoc/epoc.c index b9bc652c22..6652ef0ce1 100644 --- a/epoc/epoc.c +++ b/epoc/epoc.c @@ -17,6 +17,10 @@ Perl_epoc_init(int *argcp, char ***argvp) { int truecount=0; char **lastcp = (*argvp); char *ptr; + +#if 0 + epoc_spawn_posix_server(); +#endif for (i=0; i< *argcp; i++) { if ((*argvp)[i]) { if (*((*argvp)[i]) == '<') { @@ -94,54 +98,85 @@ __fixunsdfsi (a) #include "XSUB.h" int -do_aspawn( pTHX_ SV *really,SV **mark,SV **sp) { - return do_spawn( really, mark, sp); +do_spawn( char *cmd) { + dTHXo; + char *argv0, *ptr; + char *cmdptr = cmd; + int ret; + + argv0 = ptr = malloc( strlen(cmd) + 1); + + while (*cmdptr && !isSPACE( *cmdptr)) { + *ptr = *cmdptr; + if (*ptr == '/') { + *ptr = '\\'; + } + ptr++; cmdptr++; + } + while (*cmdptr && isSPACE( *cmdptr)) { + cmdptr++; + } + *ptr = '\0'; + ret = epoc_spawn( argv0, cmdptr); + free( argv0); + return ret; } int -do_spawn (pTHX_ SV *really,SV **mark,SV **sp) -{ +do_aspawn ( void *vreally, void **vmark, void **vsp) { + + dTHXo; + + SV *really = (SV*)vreally; + SV **mark = (SV**)vmark; + SV **sp = (SV**)vsp; + + char **argv; + char *str; + char *p2, **ptr; + char *cmd, *cmdline; + + int rc; - char **a,*cmd,**ptr, *cmdline, **argv, *p2; - STRLEN n_a; - size_t len = 0; + int index = 0; + int len = 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] = ""; + + len += strlen(argv[ index++]) + 1; } - *a = Nullch; + argv[index++] = 0; - if (!(really && *(cmd = SvPV(really, n_a)))) { - cmd = argv[0]; - argv++; + cmd = strdup((const char*)(really ? SvPV_nolen(really) : argv[0])); + + for (p2=cmd; *p2 != '\0'; p2++) { + /* Change / to \ */ + if ( *p2 == '/') + *p2 = '\\'; } cmdline = (char * ) malloc( len + 1); cmdline[ 0] = '\0'; while (*argv != NULL) { - strcat( cmdline, *argv++); + strcat( cmdline, *ptr++); strcat( cmdline, " "); } + + free( argv); - for (p2=cmd; *p2 != '\0'; p2++) { - /* Change / to \ */ - if ( *p2 == '/') - *p2 = '\\'; - } rc = epoc_spawn( cmd, cmdline); - free( ptr); free( cmdline); - + free( cmd); + return rc; } |