6 |
if 0; |
if 0; |
7 |
|
|
8 |
# autom4te - Wrapper around M4 libraries. |
# autom4te - Wrapper around M4 libraries. |
9 |
# Copyright (C) 2001, 2002 Free Software Foundation, Inc. |
# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. |
10 |
|
|
11 |
# This program is free software; you can redistribute it and/or modify |
# This program is free software; you can redistribute it and/or modify |
12 |
# it under the terms of the GNU General Public License as published by |
# it under the terms of the GNU General Public License as published by |
189 |
} |
} |
190 |
|
|
191 |
|
|
192 |
# SAVE ($FILENAME) |
# SAVE ($FILE) |
193 |
# ---------------- |
# ------------ |
194 |
|
# Save the cache in the $FILE Autom4te::XFile object. |
195 |
sub save |
sub save |
196 |
{ |
{ |
197 |
my ($self, $filename) = @_; |
my ($self, $file) = @_; |
198 |
|
|
199 |
croak "$me: cannot save a single request\n" |
croak "$me: cannot save a single request\n" |
200 |
if ref ($self); |
if ref ($self); |
201 |
|
|
202 |
my $requests = new Autom4te::XFile ("> $filename"); |
$file->seek (0, 0); |
203 |
print $requests |
$file->truncate (0); |
204 |
|
print $file |
205 |
"# This file was created by $me.\n", |
"# This file was created by $me.\n", |
206 |
"# It contains the lists of macros which have been traced.\n", |
"# It contains the lists of macros which have been traced.\n", |
207 |
"# It can be safely removed.\n", |
"# It can be safely removed.\n", |
212 |
|
|
213 |
# LOAD ($FILE) |
# LOAD ($FILE) |
214 |
# ------------ |
# ------------ |
215 |
|
# "eval" the content of the $FILE Autom4te::XFile object. |
216 |
sub load |
sub load |
217 |
{ |
{ |
218 |
my ($self, $file) = @_; |
my ($self, $file) = @_; |
219 |
|
my $fname = $file->name; |
220 |
|
|
221 |
croak "$me: cannot load a single request\n" |
croak "$me: cannot load a single request\n" |
222 |
if ref ($self); |
if ref ($self); |
223 |
|
|
224 |
(my $return) = do "$file"; |
my $contents = join "", $file->getlines; |
225 |
|
|
226 |
croak "$me: cannot parse $file: $@\n" if $@; |
eval $contents; |
227 |
croak "$me: cannot do $file: $!\n" unless defined $return; |
|
228 |
croak "$me: cannot run $file\n" unless $return; |
croak "$me: cannot eval $fname: $@\n" if $@; |
229 |
} |
} |
230 |
|
|
231 |
|
|
255 |
my $melt = 0; |
my $melt = 0; |
256 |
|
|
257 |
# Names of the cache directory, cache directory index, trace cache |
# Names of the cache directory, cache directory index, trace cache |
258 |
# prefix, and output cache prefix. |
# prefix, and output cache prefix. And the IO objet for the index. |
259 |
my $cache; |
my $cache; |
260 |
my $icache; |
my $icache; |
261 |
my $tcache; |
my $tcache; |
262 |
my $ocache; |
my $ocache; |
263 |
|
my $icache_file; |
264 |
|
|
265 |
# The macros to trace mapped to their format, as specified by the |
# The macros to trace mapped to their format, as specified by the |
266 |
# user. |
# user. |
420 |
autom4te (@PACKAGE_NAME@) @VERSION@ |
autom4te (@PACKAGE_NAME@) @VERSION@ |
421 |
Written by Akim Demaille. |
Written by Akim Demaille. |
422 |
|
|
423 |
Copyright 2002 Free Software Foundation, Inc. |
Copyright (C) 2003 Free Software Foundation, Inc. |
424 |
This is free software; see the source for copying conditions. There is NO |
This is free software; see the source for copying conditions. There is NO |
425 |
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
426 |
EOF |
EOF |
1175 |
or error "cannot create $cache: $!"; |
or error "cannot create $cache: $!"; |
1176 |
} |
} |
1177 |
|
|
1178 |
|
# Open the index for update, and lock it. autom4te handles several |
1179 |
|
# files, but the index is the first and last file to be update, so |
1180 |
|
# locking it is sufficient. |
1181 |
|
$icache_file = new Autom4te::XFile $icache, O_RDWR|O_CREAT; |
1182 |
|
$icache_file->lock (LOCK_EX); |
1183 |
|
|
1184 |
# Read the cache index if available and older than autom4te itself. |
# Read the cache index if available and older than autom4te itself. |
1185 |
# If autom4te is younger, then some structures such as Request, might |
# If autom4te is younger, then some structures such as Request, might |
1186 |
# have changed, which would corrupt its processing. |
# have changed, which would corrupt its processing. |
1187 |
Request->load ($icache) |
Request->load ($icache_file) |
1188 |
if -f $icache && mtime ($icache) > mtime ($0); |
if -f $icache && mtime ($icache) > mtime ($0); |
1189 |
|
|
1190 |
# Add the new trace requests. |
# Add the new trace requests. |
1227 |
$req->valid (1) |
$req->valid (1) |
1228 |
if $exit_status == 0; |
if $exit_status == 0; |
1229 |
|
|
1230 |
Request->save ($icache); |
Request->save ($icache_file); |
1231 |
|
|
1232 |
exit $exit_status; |
exit $exit_status; |
1233 |
|
|