From: Olaf Flebbe Date: Mon, 26 Feb 2001 23:34:36 +0000 (+0100) Subject: [perl-current] EPOC X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d5ff79b3161a608c49c52fd6aa22cff1af6f6b82;p=p5sagit%2Fp5-mst-13.2.git [perl-current] EPOC Message-ID: p4raw-id: //depot/perl@8956 --- diff --git a/AUTHORS b/AUTHORS index 89a6b88..5936d57 100644 --- a/AUTHORS +++ b/AUTHORS @@ -391,7 +391,7 @@ Nick Gianniotis Nick Ing-Simmons Norbert Pueschel Norton T. Allen -Olaf Flebbe +Olaf Flebbe Olaf Titz Ollivier Robert Owen Taylor diff --git a/README.epoc b/README.epoc index 6c62565..f688b46 100644 --- a/README.epoc +++ b/README.epoc @@ -15,34 +15,65 @@ Perl 5 README file for the EPOC operating system. EPOC is a OS for palmtops and mobile phones. For more informations look at: http://www.symbian.com/ -This is a port of perl to EPOC. It runs on the Psion Series 5, 5mx, +This is a port of perl to EPOC. It runs on ER5 machines: Psion 5mx, 5mx Pro, Psion Revo and on the Ericson M128. I have no report about -the Psion Netbook or the S7. For information about this hardware -please refer to http://www.psion.com. +the Psion Netbook or the S7. It runs on ER3 Hardware (Series 5 +classic), too. For more information about this hardware please refer +to http://www.psion.com. + +Vendors which like to have support for their devices are free to send +me a sample. =head1 INSTALLING PERL ON EPOC -You will need ~4MB free space in order to install and run perl. +You can download a ready-to-install version from +http://www.science-computing.de/o.flebbe/perl. You may find other +versions with some CPAN modules included at this location. + +You will need at least ~4MB free space in order to install and run +perl. + +Install perl.sis on the EPOC machine. If you do not know how to do +that, consult your PsiWin documentation. + +Perl itself and its standard library is using 2.5 MB disk space. +Unicode support and some other modules are left out. (For details, +please look into epoc/createpkg.pl). If you like to use these modules, +you are free to copy them from a current perl release. -Install perl.sis on the EPOC machine (most likely a PSION Series 5, -5mx). If you do not know how to do that, you are on your own. +=head1 STARTING PERL ON EPOC -Perl itself and its standard library are using 2.5 MB disk space. I -left out unicode support modules and modules which will not work with -this version. (For details look into epoc/createpkg.pl). If you like -to use them, you are free to copy them from a current perl release. +For ER5 machines, you can get the software Perlstart +http://www.science-computing.de/o.flebbe/perl. It contains file +recognizers for files with the extension .pl and .pm. With it you can +start perl with a double click on the camel icon. Be sure to configure +the perl installation drive first. You can even provide a script with +a special commandline, if needed. -Get ESHELL from symbian: +Alternativly you can get ESHELL from symbian: http://developer.epocworld.com/downloads/progs/Eshell.zip -Now you can enter: perl -de 0 in order to run the perl debugger. If -you are leaving perl, you get into the system screen. You have to -switch back manually to ESHELL. When perl is running, you will see -a task with the name STDOUT in the task list. +Running ESHELL you can enter: perl -de 0 in order to run the perl +debugger. If you are leaving perl, you get into the system screen. You +have to switch back manually to ESHELL. When perl is running, you will +see a task with the name STDOUT in the task list. + +If you have a ER3 machine (i.e. a PSION 5), you may have to supply the +full path to the perl executable C:\system\programs\perl.exe. + +If you need to set the current directory of perl, please use the +command line switch '-x'. See L for details. + +=head1 STOPPING PERL ON EPOC + +You can stop a running perl process in the task list by closing the +application `STDOUT'. You cannot stop a running perl process if it has +not written anyting to stdout or stderr! Be very cautious with I/O +redirection. You will have to reboot the PDA! =head1 USING PERL ON EPOC -=head2 IO Redirection +=head2 I/O Redirection You can redirect the output with the UNIX bourne shell syntax (this is built into perl rather then eshell) For instance the following command @@ -61,12 +92,14 @@ installs perl in this special folder directory. The default drive and path are the same as folder the executable resides. The EPOC filesystem is case-preserving, not case-sensitive. -EPOC uses the ?: syntax for establishing a search order: First in C: (RAM), -then on D: (CF Card) and last in Z: (ROM). +The EPOC estdlib uses the ?: syntax for establishing a search order: +First in C: (RAM), then on D: (CF Card, if present) and last in Z: +(ROM). For instance ?:\a.txt searches for C:\a.txt, D:\a.txt (and +Z:\a.txt) -The perl @INC search path is now implemented with '?:'. Your perl -executable can now live on a different drive than the perl library or -even your scripts. +The perl @INC search path is implemented with '?:'. Your perl +executable can live on a different drive than the perl library or even +your scripts. ESHELL paths have to be written with backslashes '\', file arguments to perl with slashes '/'. Remember that I/O redirection is done @@ -74,14 +107,10 @@ internally in perl, so please use slashes for redirects. perl.exe C:/test.pl >C:/output.txt -You can automatically search for file on all EPOC drives with a ? as -the driver letter. For instance ?:\a.txt searches for C:\a.txt, -D:\b.txt (and Z:\a.txt). - =head2 Editors -A suitable text-editor can be downloaded -from symbian http://developer.epocworld.com/downloads/progs/Editor.zip +A suitable text editor can be downloaded from symbian + http://developer.epocworld.com/downloads/progs/Editor.zip =head2 Features @@ -124,12 +153,11 @@ one) See PATH. =item * -You need the shell eshell.exe in order to run perl.exe and supply -it with arguments. +Heap is limited to 4MB. =item * -Heap is limited to 4MB. +Dynamic loading is not implemented. =back @@ -150,12 +178,8 @@ http://www.science-computing.de/o.flebbe/sdk =item * -You may have to adjust config.sh (cc, cppflags) for your epoc -install location. - -=item * - -You may have to adjust config.sh for your cross SDK location +You may have to adjust config.sh (cc, cppflags) to reflect your epoc +and SDK location. =item * @@ -167,13 +191,16 @@ Unpack the sources. =item * -Build a native perl from this sources... +Build a native perl from this sources... Make sure to save the +miniperl executable as miniperl.native. + +Start again from scratch cp epoc/* . ./Configure -S - make perl.a + make cp miniperl.native miniperl - make perl + make make ext/Errno/pm_to_blib perl link.pl perlmain.o lib/auto/DynaLoader/DynaLoader.a \ lib/auto/Data/Dumper/Dumper.a \ @@ -194,11 +221,11 @@ guarantee I'll be able to answer them. =head1 AUTHOR -Olaf Flebbe -http://members.linuxstart.com/~oflebbe/perl/perl5.html +Olaf Flebbe +http://www.science-computing.de/o.flebbe/perl/ =head1 LAST UPDATE -2000-09-18 +2001-02-26 =cut diff --git a/epoc/createpkg.pl b/epoc/createpkg.pl index 65a881f..5ce70fc 100644 --- a/epoc/createpkg.pl +++ b/epoc/createpkg.pl @@ -4,8 +4,8 @@ use File::Find; use Cwd; $VERSION="5.7"; -$PATCH="0"; -$EPOC_VERSION=24; +$PATCH="1"; +$EPOC_VERSION=27; $CROSSCOMPILEPATH=cwd; $CROSSREPLACEPATH="H:\\perl"; @@ -13,7 +13,7 @@ $CROSSREPLACEPATH="H:\\perl"; sub filefound { my $f = $File::Find::name; - return if ( $f =~ /CVS|unicode|CPAN|ExtUtils|IPC|User|DB.pm|\.a$|\.ld$|\.exists$/i); + return if ( $f =~ /CVS|unicode|CPAN|ExtUtils|IPC|User|DB.pm|\.a$|\.ld$|\.exists$|\.pod$/i); my $back = $f; $back =~ s|$CROSSCOMPILEPATH||; @@ -31,7 +31,7 @@ sub filefound { open OUT,">perl.pkg"; print OUT "#{\"perl$VERSION\"},(0x100051d8),$PATCH,$EPOC_VERSION,0\n"; - +print OUT "\"$CROSSREPLACEPATH\\Artistic\"-\"\",FT,TA\n"; print OUT "\"$CROSSREPLACEPATH\\perlmain.exe\"-\"!:\\system\\programs\\perl.exe\"\n"; find(\&filefound, cwd.'/lib'); diff --git a/epoc/epoc.c b/epoc/epoc.c index b9bc652..6652ef0 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; } diff --git a/epoc/epocish.c b/epoc/epocish.c index a0557cc..a8b9597 100644 --- a/epoc/epocish.c +++ b/epoc/epocish.c @@ -9,31 +9,60 @@ /* This is C++ Code !! */ #include +#include +#include +#include extern "C" { +#if 1 +int epoc_spawn( char *cmd, char *cmdline) { RProcess p; TRequestStatus status; TInt rc; rc = p.Create( _L( cmd), _L( cmdline)); - if (rc != KErrNone) + if (rc != KErrNone) { return -1; + } p.Resume(); p.Logon( status); User::WaitForRequest( status); + p.Kill( 0); if (status!=KErrNone) { return -1; } return 0; } +#else +int +epoc_spawn( char *cmd, char *cmdline) { + int len = strlen(cmd) + strlen(cmdline) + 4; + char *n = (char *) malloc( len); + int r; + strcpy( n, cmd); + strcat( n, " "); + strcat( n, cmdline); + r = system( n); + free( n); + return r; +} +#endif +/* Workaround for defect strtoul(). Values with leading + are zero */ + +unsigned long int epoc_strtoul(const char *nptr, char **endptr, + int base) { + if (nptr && *nptr == '+') + nptr++; + return strtoul( nptr, endptr, base); +} - /* Workaround for defect atof(), see java defect list for epoc */ - double epoc_atof( char* str) { +/* Workaround for defect atof(), see java defect list for epoc */ +double epoc_atof( char* str) { TReal64 aRes; while (TChar( *str).IsSpace()) { @@ -43,9 +72,9 @@ epoc_spawn( char *cmd, char *cmdline) { TLex lex( _L( str)); TInt err = lex.Val( aRes, TChar( '.')); return aRes; - } +} - void epoc_gcvt( double x, int digits, unsigned char *buf) { +void epoc_gcvt( double x, int digits, unsigned char *buf) { TRealFormat trel; trel.iPlaces = digits; @@ -57,3 +86,9 @@ epoc_spawn( char *cmd, char *cmdline) { result.Append( TChar( 0)); } } + +#if 0 +void epoc_spawn_posix_server() { + SpawnPosixServerThread(); +} +#endif diff --git a/epoc/epocish.h b/epoc/epocish.h index 551d1f5..e365fa2 100644 --- a/epoc/epocish.h +++ b/epoc/epocish.h @@ -138,6 +138,7 @@ double epoc_atof( const char *ptr); #define atof(a) epoc_atof(a) +#define strtoul(a,b,c) epoc_strtoul(a,b,c) #define init_os_extras Perl_init_os_extras diff --git a/pp_sys.c b/pp_sys.c index c949cd3..8703a09 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -2210,6 +2210,10 @@ PP(pp_socket) fcntl(fd, F_SETFD, fd > PL_maxsysfd); /* ensure close-on-exec */ #endif +#ifdef EPOC + setbuf( IoIFP(io), NULL); /* EPOC gets confused about sockets */ +#endif + RETPUSHYES; #else DIE(aTHX_ PL_no_sock_func, "socket");