perl 4.0 patch 14: patch #11, continued
[p5sagit/p5-mst-13.2.git] / msdos / README.msdos
CommitLineData
0f85fab0 1 Notes on the MS-DOS Perl port
2
3 Diomidis Spinellis
4 (dds@cc.ic.ac.uk)
5
6[0. First copy the files in the msdos directory into the parent
7directory--law]
8
91. Compiling.
10
11 Perl has been compiled under MS-DOS using the Microsoft
12C compiler version 5.1. Before compiling install dir.h as
13<sys/dir.h>. You will need a Unix-like make program (e.g.
14pdmake) and something like yacc (e.g. bison). You could get
15away by running yacc and dry running make on a Unix host,
16but I haven't tried it. Compilation takes 12 minutes on a
1720MHz 386 machine (together with formating the manual), so
18you will probably need something to do in the meantime. The
19executable is 272k and the top level directory needs 1M for
20sources and about the same ammount for the object code and
21the executables.
22
23 The makefile will compile glob for you which you will
24need to place somewhere in your path so that perl globbing
25will work correctly. I have not tried all the tests or the
26examples, nor the awk and sed to Perl translators. You are
27on your own with them. In the eg directory I have included
28an example program that uses ioctl to display the charac-
29teristics of the storage devices of the system.
30
312. Using MS-DOS Perl
32
33 The MS-DOS version of perl has most of the functional-
34ity of the Unix version. Functions that can not be provided
35under MS-DOS like sockets, password and host database
36access, fork and wait have been ommited and will terminate
37with a fatal error. Care has been taken to implement the
38rest. In particular directory access, redirection (includ-
39ing pipes, but excluding the pipe function), system, ioctl
40and sleep have been provided.
41
87250799 42[Files currently can be edited in-place provided you are cre-
43ating a backup. However, if the backup coincidentally has
44the same name as the original, or if the resulting backup
45filename is invalid, then the file will probably be trashed.
46For example, don't do
47
48 perl -i~ script makefile
49 perl -i.bak script file.dat
50
51because (1) MS-DOS treats "makefile~" and "makefile" as the
52same filename, and (2) "file.dat.bak" is an invalid filename.
53The files "makefile" and "file.dat" will probably be lost
54forever. Moral of the story: Don't use in-place editing
55under MS-DOS. --rjc]
56
0f85fab0 572.1. Interface to the MS-DOS ioctl system call.
58
59 The function code of the ioctl function (the second
60argument) is encoded as follows:
61
62- The lowest nibble of the function code goes to AL.
63- The two middle nibbles go to CL.
64- The high nibble goes to CH.
65
66 The return code is -1 in the case of an error and if
67successful:
68
69- for functions AL = 00, 09, 0a the value of the register DX
70- for functions AL = 02 - 08, 0e the value of the register AX
71- for functions AL = 01, 0b - 0f the number 0.
72
73 See the perl manual for instruction on how to distin-
74guish between the return value and the success of ioctl.
75
76 Some ioctl functions need a number as the first argu-
77ment. Provided that no other files have been opened the
78number can be obtained if ioctl is called with
79@fdnum[number] as the first argument after executing the
80following code:
81
82 @fdnum = ("STDIN", "STDOUT", "STDERR");
83 $maxdrives = 15;
84 for ($i = 3; $i < $maxdrives; $i++) {
85 open("FD$i", "nul");
86 @fdnum[$i - 1] = "FD$i";
87 }
88
892.2. Binary file access
90
91 Files are opened in text mode by default. This means
92that CR LF pairs are translated to LF. If binary access is
93needed the `binary' function should be used. There is
94currently no way to reverse the effect of the binary func-
95tion. If that is needed close and reopen the file.
96
972.3. Interpreter startup.
98
99 The effect of the Unix #!/bin/perl interpreter startup
100can be obtained under MS-DOS by giving the script a .bat
101extension and using the following lines on its begining:
102
103 @REM=("
104 @perl %0.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
105 @end ") if 0 ;
106
107(Note that you will probably want an absolute path name in
108front of %0.bat).
109
110 March 1990
111
112 Diomidis Spinellis <dds@cc.ic.ac.uk>
113 Myrsinis 1
114 GR-145 62 Kifissia
115 Greece
fe14fcc3 116
117--------------------------------------------------------------------------
118
119 Revisions to the MS-DOS support in Perl 4.0
120 Tom Dinger, 18 March 1991
121
122The DOS compatibility added to Perl sometime in release 3.x was not
123maintained, and Perl as distributed could not be built without changes.
124
125Both myself and Len Reed more or less "rediscovered" how to get Perl built
126and running reliably for MS-DOS, using the Microsoft C compiler. He and I
127have communicated, and will be putting together additional patches for the
128DOS version of Perl.
129
1301. Compiling Perl
131
132 For now, I have not supplied a makefile, as there is no standard for
133 make utilities under DOS. All the files can be compiled with Microsoft
134 C 5.1, using the switches "-AL -Ox" for Large memory model, maximum
135 optimization (this turned out a few code generation bugs in MSC 5.1).
136 The code will also compile with MSC 6.00A, with the optimization
137 "-Oacegils /Gs" for all files (regcomp.c has special case code to change
138 the aliasing optimizations).
139
140 Generally, you follow the instructions given above to compile and build
141 Perl 4.0 for DOS. I used the output of SunOS yacc run on perly.y,
142 without modification, but I expect both Bison and Berkeley-YACC will work
143 also. From inspection of the generated code, however, I believe AT&T
144 derived YACC produces the smallest tables, i.e. uses the least memory.
145 This is important for a 300K executable file.
146
1472. Editing in-place.
148
149 You will need the file suffix.c from the os2 subdirectory -- it will
150 create a backup file with much less danger for DOS.
151
1523. A "Smarter" chdir() function.
153
154 I have added to the DOS version of Perl 4.0 a replacement chdir()
155 function. Unlike the "normal" behavior, it is aware of drive letters
156 at the start of paths for DOS. So for example:
157
158 perl_chdir( "B:" ) changes to the default directory, on drive B:
159 perl_chdir( "C:\FOO" ) changes to the specified directory, on drive C:
160 perl_chdir( "\BAR" ) changes to the specified directory on the
161 current drive.
162
1634. *.BAT Scripts as Perl scripts
164
165 The strategy described above for turning a Perl script into a *.BAT
166 script do not work. I have been using the following lines at the
167 beginning of a Perl *.BAT script:
168
169 @REM=(qq!
170 @perl -S %0.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
171 @goto end !) if 0 ;
172
173 and the following at the end of the *.BAT script:
174
175 @REM=(qq!
176 :end !) if 0 ;
177
178 If you like, with the proper editor you can replace the four '!'
179 characters with some untypeable character, such as Ctrl-A. This will
180 allow you to pass any characters, including ".." strings as arguments.
181
1824. Things to Come
183
184 * Better temporary file handling.
185 * A real Makefile -- Len Reed has one for Dmake 3.6
186 * Swapping code -- swaps most of Perl out of memory (to EMS, XMS or
187 disk) before running a sub-program or pipe.
188 * MKS command line support, both into Perl, and to other programs
189 spawned by Perl.
190 * Smarter pipe functions, not using COMMAND.COM.
191
192
193 Tom Dinger
194 tdinger@East.Sun.COM
195 Martch 18, 1991