]> sjero.net Git - wget/blob - vms/CONFIG_EXTRACT.COM
imported patch vms-overlay
[wget] / vms / CONFIG_EXTRACT.COM
1 $!                                              22 September 2009.  SMS.
2 $!
3 $!    Extract the AC_INIT strings from the "configure.ac" file.
4 $!
5 $!    P1 = input file spec.
6 $!    P2, P3, P4 = logical names to be defined with the extracted text.
7 $!
8 $! We're expecting to extract the bracketed text from the "[text]"
9 $! tokens from a block of text like:
10 $!
11 $!       AC_INIT([wget],
12 $!               [1.12-devel],
13 $!               [bug-wget@gnu.org])
14 $!
15 $! That is, starting with "AC_INIT", and ending with ")".
16 $!
17 $ file_in_open = 0
18 $ ac_init = ""
19 $!
20 $ on error then goto tidy
21 $!
22 $ open /error = tidy /read file_in 'p1'
23 $ file_in_open = 1
24 $ state = 0                     ! Looking for "AC_INIT".
25 $!
26 $ loop_read:
27 $!
28 $    read /error = tidy file_in line
29 $    line_len = f$length( line)
30 $    if (state .eq. 0)
31 $    then
32 $        if (f$locate( "AC_INIT", line) .lt line_len)
33 $        then
34 $           ac_init = line
35 $           state = 1           ! Looking for ")".
36 $        endif
37 $    else
38 $        if (f$locate( ")", line) .lt line_len)
39 $        then
40 $           state = 2           ! Found ")".  (Done.)
41 $        endif
42 $        ac_init = ac_init+ line
43 $    endif
44 $!
45 $ if (state .ne. 2) then goto loop_read
46 $!
47 $ t1 = f$element( 0, "]", f$element( 1, "[", ac_init))
48 $ t2 = f$element( 0, "]", f$element( 2, "[", ac_init))
49 $ t3 = f$element( 0, "]", f$element( 3, "[", ac_init))
50 $!
51 $ if (p2 .nes. "")
52 $ then
53 $    define 'p2' "''t1'"
54 $ else
55 $    write sys$output " 1: >''t1'<"
56 $ endif
57 $!
58 $ if (p3 .nes. "")
59 $ then
60 $    define 'p3' "''t2'"
61 $ else
62 $    write sys$output " 2: >''t2'<"
63 $ endif
64 $!
65 $ if (p4 .nes. "")
66 $ then
67 $    define 'p4' "''t3'"
68 $ else
69 $    write sys$output " 3: >''t3'<"
70 $ endif
71 $!
72 $ tidy:
73 $ if (file_in_open)
74 $ then
75 $    close file_in
76 $ endif