📄 readme.os2
字号:
Notes on the OS/2 Perl port Raymond Chen (rjc@math.princeton.edu) Kai Uwe Rommel (rommel@lan.informatik.tu-muenchen.dbp.de)-1. Background.This port was based on the MS-DOS port by Diomidis Spinellis.0. Set-up.First copy the files in the os2 directory into the parentdirectory. Also install the file msdos/dir.h in your includedirectory.1. Compiling.Perl has been compiled under MS-DOS using the Microsoft C compilerversion 6.0. Before compiling install dir.h as <sys/dir.h>. You willneed a Unix-like make program and something like yacc (e.g. bison). Ijust ran yacc on my UNIX box and downloaded the resulting y.tab.[ch]files. Compilation takes 45 minutes on a 16MHz 386 machine runningno jobs other than the compiler, so you will probably need something todo in the meantime. Like, say, lunch. (Compilation time does notinclude formatting the manual.) If you compile with optimizationturned off, it takes about half as long.The executable is 270k (perlsym.exe is 473k; if you compilewithout optimization, the sizes are 329K/531K), and the top leveldirectory needs 800K for sources, 550K for object code, and 800K for theexecutables, assuming you want to build both perl.exe and perlsym.exewith full optimization.The makefile will compile glob for you which you will need to placesomewhere in your path so that perl globbing will work correctly. Allthe tests were run, although some modifications were necessary becauseOS/2 isn't UNIX. The tests that failed failed because of limitations ofthe operating system and aren't the fault of the compiler. a2p and s2pwere not tested.In the eg directory you will find the syscalls.pl header file,and a sample program that demonstrates some of the improvementsof the OS/2 version over the MS-DOS version and some of thesystem calls.2. Using OS/2 PerlThe OS/2 version of perl has much of the functionality of the Unixversion. Here are some things that don't work: sockets, passwordfunctions, [gs]et[eug]id, dbm functions, fork.One thing that doesn't work is "split" with no arguments. Somehow,yylval.arg is empty ... [[ Wait, sorry, I fixed that. --rjc ]]Care has been taken to implement the rest, although the implementationmight not be the best possible. Here are short notes on the trickybits:2.1. In-place editing.Files currently can be edited in-place provided you are creating abackup. Considerable effort is made to ensure that a reasonablename for the backup is selected, while still remaining withinthe 8.3 contraints of the FAT filesystem. (HPFS users have nothingto worry about, since HPFS doesn't have the stupid 8.3 rule.)The rules for how OS/2 perl combines your filename with the suffix(the thing passed to "-i") are rather complicated, but the basicidea is that the "obvious" name is chosen.Here are the rules:Style 0: Append the suffix exactly as UNIX perl would do it. If the filesystem likes it, use it. (HPFS will always swallow it. FAT will rarely accept it.)Style 1: If the suffix begins with a '.', change the file extension to whatever you supplied. If the name matches the original name, use the fallback method.Style 2: If the suffix is a single character, not a '.', try to add the suffix to the following places, using the first one that works. [1] Append to extension. [2] Append to filename, [3] Replace end of extension, [4] Replace end of filename. If the name matches the original name, use the fallback method.Style 3: Any other case: Ignore the suffix completely and use the fallback method.Fallback method: Change the extension to ".$$$". If that matches the original name, then change the extension to ".~~~".If filename is more than 1000 characters long, we die a horribledeath. Sorry.Examples, assuming style 0 failed.suffix = ".bak" (style 1) foo.bar => foo.bak foo.bak => foo.$$$ (fallback) foo.$$$ => foo.~~~ (fallback) makefile => makefile.baksuffix = "~" (style 2) foo.c => foo.c~ foo.c~ => foo.c~~ foo.c~~ => foo~.c~~ foo~.c~~ => foo~~.c~~ foo~~~~~.c~~ => foo~~~~~.$$$ (fallback) foo.pas => foo~.pas makefile => makefile.~ longname.fil => longname.fi~ longname.fi~ => longnam~.fi~ longnam~.fi~ => longnam~.$$$2.2. Directory access.Are implemented, but in order to support telldir() and seekdir(),they operate by reading in the entire directory at opendir(),then handing out pieces of it each time you do a readdir().2.3. Pipes and redirection.Pipes and redirection are supported. Although OS/2 does notterminate programs which try to write to closed pipes, perl willkill them for you if you do it like this: open(I, "long-running-program|"); ... process a few lines ... close(I); # discard the rest ...The killing works like this: We wait until the child program eithercloses its stdout or tries to write to it. If it writes to its stdout,we kill it. Otherwise, we cwait for it. This is pretty much what UNIXdoes by default.All pipe commands are given to cmd.exe (or your COMSPEC) for execution as CMD /c your-command-lineso you can go ahead and load it up with any goofy things you want,like 2>1 redirection, more pipes, && || etc.The pipe() function is also supported, so you can go ahead andmake your own funky file descriptor connections before piping offa process. However, you have to mark the descriptor you areretaining as NOINHERIT before spawning, else you are in deadlock city.Unfortunately, there's no way to mark the handle as NOINHERIT yet.It's on my wish list.2.4. Syscall and IoctlIOCtl is not supported because the API is very different from theUNIX API. Instead, IOCtl is supported as a syscall. Here arethe syscalls I've written so far: $OS2_GetVersion = 0; $OS2_Shutdown = 1; $OS2_Beep = 2; $OS2_PhysicalDisk = 3; $OS2_Config = 4; $OS2_IOCtl = 5; $OS2_QCurDisk = 6; $OS2_SelectDisk = 7; $OS2_SetMaxFH = 8; $OS2_Sleep = 9; $OS2_StartSession = 10; $OS2_StopSession = 11; $OS2_SelectSession = 12;The arguments you pass are handed off to OS/2 without interpretation,and the return value is returned straight to you. However, you don'thave to supply arguments for the ones whose descriptions are "must bezero"; perl will supply the mandatory zeros for you.2.5. Binary file accessFiles are opened in text mode by default. This means that CR LF pairsare translated to LF. If binary access is needed the `binarymode'function should be used. There is currently no way to reverse theeffect of the binary function. If that is needed close and reopen thefile.2.6. PriorityThe getpriority and setpriority functions are implemented, but sinceOS/2 priorities are different from UNIX priorities, the arguments aren'tthe same. Basically, the arguments you pass are handed directly toOS/2. The only exception is the last argument to setpriority. To makeit easier to make delta priorities, if the priority class is 0xff, itis changed to 0. That way, you can write setpriority(0,0,-2)instead of setpriority(0,0,0xfe)to decrease the delta by 2.2.7. Interpreter startup.The effect of the Unix #!/bin/perl interpreter startup can be obtainedunder OS/2 by giving the script a .cmd extension and beginning the scriptwith the line extproc C:\binp\perl.exe -SYou should provide the appropriate path to your executable, andthe -S option is necessary so that perl can find your script.2.8. The kill function.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -