21.07.2015 Views

GAWK: Effective AWK Programming

GAWK: Effective AWK Programming

GAWK: Effective AWK Programming

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

278 <strong>G<strong>AWK</strong></strong>: <strong>Effective</strong> <strong>AWK</strong> <strong>Programming</strong>In order to use gawk, you need to have a shell, either text or graphics, that does not mapall the characters of a command line to uppercase. Maintaining case distinction in optionflags is very important (see Section 11.2 [Command-Line Options], page 177). These daysthis is the default and it may only be a problem for some very old machines. If your systemdoes not preserve the case of option flags, you need to upgrade your tools. Support for I/Oredirection is necessary to make it easy to import awk programs from other environments.Pipes are nice to have but not vital.B.4.1.1 Compiling gawk on the Atari STA proper compilation of gawk sources when sizeof(int) differs from sizeof(void *)requires an ISO C compiler. An initial port was done with gcc. You may actually preferexecutables where ints are four bytes wide but the other variant works as well.You may need quite a bit of memory when trying to recompile the gawk sources, as somesource files (‘regex.c’ in particular) are quite big. If you run out of memory compiling sucha file, try reducing the optimization level for this particular file, which may help.With a reasonable shell (bash will do), you have a pretty good chance that the configureutility will succeed, and in particular if you run GNU/Linux, MiNT or a similar operatingsystem. Otherwise sample versions of ‘config.h’ and ‘Makefile.st’ are given in the ‘atari’subdirectory and can be edited and copied to the corresponding files in the main sourcedirectory. Even if configure produces something, it might be advisable to compare itsresults with the sample versions and possibly make adjustments.Some gawk source code fragments depend on a preprocessor define ‘atarist’. Thisbasically assumes the TOS environment with gcc. Modify these sections as appropriate ifthey are not right for your environment. Also see the remarks about <strong>AWK</strong>PATH and envsepin Section B.4.1.2 [Running gawk on the Atari ST], page 278.As shipped, the sample ‘config.h’ claims that the system function is missing from thelibraries, which is not true, and an alternative implementation of this function is providedin ‘unsupported/atari/system.c’. Depending upon your particular combination of shelland operating system, you might want to change the file to indicate that system is available.B.4.1.2 Running gawk on the Atari STAn executable version of gawk should be placed, as usual, anywhere in your PATH whereyour shell can find it.While executing, the Atari version of gawk creates a number of temporary files. Whenusing gcc libraries for TOS, gawk looks for either of the environment variables, TEMP orTMPDIR, in that order. If either one is found, its value is assumed to be a directory fortemporary files. This directory must exist, and if you can spare the memory, it is a goodidea to put it on a RAM drive. If neither TEMP nor TMPDIR are found, then gawk uses thecurrent directory for its temporary files.The ST version of gawk searches for its program files, as described in Section 11.4 [The<strong>AWK</strong>PATH Environment Variable], page 183. The default value for the <strong>AWK</strong>PATH variable istaken from DEFPATH defined in ‘Makefile’. The sample gcc/TOS ‘Makefile’ for the ST inthe distribution sets DEFPATH to ".,c:\lib\awk,c:\gnu\lib\awk". The search path canbe modified by explicitly setting <strong>AWK</strong>PATH to whatever you want. Note that colons cannotbe used on the ST to separate elements in the <strong>AWK</strong>PATH variable, since they have another

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!