[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Autoscan patch
From: |
Pavel Roskin |
Subject: |
Autoscan patch |
Date: |
Tue, 12 Dec 2000 02:02:50 -0500 (EST) |
Hello!
What I thought would be a trivial task (updating acidentifiers) required
some modifications in autoscan to accept spaces in the definitions.
By the way, some day we may even switch to multi-line definitions which
would require a different syntax.
While testing the change I found that many keywords, notably "const" are
not recognized when they stand at the beginning of the line. It turned out
that \W was used where \b or \B (in one case) was meant. I couldn't find
any place where \W were justified.
Finally, it's probably a good idea to use AC_CONFIG_HEADER if any C/C++
sources have been found.
ChangeLog:
* autoscan.pl (init_tables): Allow spaces on the right hand side
in autoscan tables. Die if there are no spaces at all.
(scan_c_file): Use \b instead of \W so that keywords match at
the beginning and the end of the line.
(scan_sh_file): Likewise.
(scan_makefile): Likewise. Use \B to match before `-l'.
(output): Suggest AC_CONFIG_HEADER if any C/C++ sources are
found.
* acidentifiers: Update macros for structure members st_blksize
and st_rdev.
Regards,
Pavel Roskin
_____________________
Index: acidentifiers
--- acidentifiers Tue Aug 1 23:04:16 2000
+++ acidentifiers Tue Dec 12 00:07:54 2000
@@ -29,7 +29,7 @@
S_ISSOCK AC_HEADER_STAT
# Members of structures.
-st_blksize AC_STRUCT_ST_BLKSIZE
+st_blksize AC_CHECK_MEMBERS([struct stat.st_blksize])
st_blocks AC_STRUCT_ST_BLOCKS
-st_rdev AC_STRUCT_ST_RDEV
+st_rdev AC_CHECK_MEMBERS([struct stat.st_rdev])
tm_zone AC_STRUCT_TIMEZONE
Index: autoscan.pl
--- autoscan.pl Fri Nov 10 20:29:31 2000
+++ autoscan.pl Tue Dec 12 01:54:51 2000
@@ -125,7 +125,10 @@
die "$me: cannot open $datadir/ac$kind: $!\n";
while (<TABLE>) {
next if /^\s*$/ || /^\s*#/; # Ignore blank lines and comments.
- ($word, $macro) = split;
+ unless (/^(\S+)\s+(\S.*)$/) {
+ die "$me: cannot parse definition in $datadir/ac$kind:\n$_\n";
+ }
+ ($word, $macro) = ($1, $2);
eval "\$$kind" . "_macros{\$word} = \$macro";
}
close(TABLE);
@@ -210,10 +213,10 @@
# Tokens in the code.
# Maybe we should ignore function definitions (in column 0)?
- while (s/\W([a-zA-Z_]\w*)\s*\(/ /) {
+ while (s/\b([a-zA-Z_]\w*)\s*\(/ /) {
$functions{$1}++ if !defined($c_keywords{$1});
}
- while (s/\W([a-zA-Z_]\w*)\W/ /) {
+ while (s/\b([a-zA-Z_]\w*)\b/ /) {
$identifiers{$1}++ if !defined($c_keywords{$1});
}
}
@@ -252,15 +255,15 @@
s/@address@hidden@//g;
# Variable assignments.
- while (s/\W([a-zA-Z_]\w*)\s*=/ /) {
+ while (s/\b([a-zA-Z_]\w*)\s*=/ /) {
$makevars{$1}++;
}
# Libraries.
- while (s/\W-l([a-zA-Z_]\w*)\W/ /) {
+ while (s/\B-l([a-zA-Z_]\w*)\b/ /) {
$libraries{$1}++;
}
# Tokens in the code.
- while (s/\W([a-zA-Z_]\w*)\W/ /) {
+ while (s/\b([a-zA-Z_]\w*)\b/ /) {
$programs{$1}++;
}
}
@@ -298,7 +301,7 @@
s/@address@hidden@//g;
# Tokens in the code.
- while (s/\W([a-zA-Z_]\w*)\W/ /) {
+ while (s/\b([a-zA-Z_]\w*)\b/ /) {
$programs{$1}++;
}
}
@@ -323,6 +326,9 @@
print CONF "AC_INIT\n";
if (defined $initfile) {
print CONF "AC_CONFIG_SRCDIR([$initfile])\n";
+ }
+ if (defined $cfiles[0]) {
+ print CONF "AC_CONFIG_HEADER([config.h])\n";
}
&output_programs;
_____________________
- Autoscan patch,
Pavel Roskin <=