1
# sed script specifically designed to parse the #define statements in
2
# bindings/swig-support/plplotcapi.i into a file that can be used for
3
# global variable definitions for f77.
5
# Insert text at the start:
7
c Do not edit this generated file. Instead, check its consistency\
8
c with the #defines in bindings/swig-support/plplotcapi.i using the\
9
c (Unix) target "check_f77_parameters". If that target reports an\
10
c inconsistency (via a cmp message) between the generated\
11
c plplot_parameters.fm4_compare file in the build tree and\
12
c plplot_parameters.fm4 in the source tree, then copy\
13
c plplot_parameters.fm4_compare on top of plplot_parameters.fm4 and\
14
c check in that result.\
16
# Drop every line that is not a #define
19
# Drop specific #defines from the file that are not available
20
# because of specific #if statements.
26
# Translate trailing comment identifier into fortran 95 trailing comment.
28
# Transform octal constants to Fortran (BOZ) form.
29
/^#define/ s? 0\([0-9][0-9]*\)? o'\1'?
30
# Transform hexadecimal constants to Fortran (BOZ) form.
31
/^#define/ s? 0[xX]\([0-9a-fA-F][0-9a-fA-F]*\)? z'\1'?
32
# Handle special case of z'80000000' which generates integer overflow
33
# for gfortran (and probably other Fortran 95 compilers).
34
/^#define/ s? z'80000000'? ishft(1,31)?
36
# Parse what is left while preserving trailing comments. Watch out
37
# for parentheses around value as well.
38
# Treat PL_NOTSET as a floating value and append special parameter lines for
39
# PI and TWOPI in this case as well.
41
# N.B. These double-precision results are transformed later to single precision
42
# for the (uncommon) case where PLplot is a single-precision library.
43
/^#define/ s?^#define *\(PL_NOTSET\)[ (]*\([^ ]*\)[ )]*\(.*\)$? real*8 \1 \3\n parameter (\1 = \2.0d0)\n real*8 PI\n parameter (PI = 3.1415926535897932384d0)\n real*8 TWOPI\n parameter (TWOPI = 2.0d0*PI)?
45
/^#define/ s?^#define *\([^ ]*\)[ (]*\([^ ]*\)[ )]*\(.*\)$? integer*4 \1 \3\n parameter (\1 = \2)?