Scripts for preparing guile documentation strings from C sources. The
reason for their presence is that guile-doc-snarf scripts distributed with guile up to version 1.4 do not work. The comment at th beginnig of scripts/guile-doc-snarf describes why. We'll have to use these until next version of guile fixes the bug.
Showing
4 changed files
with
220 additions
and
0 deletions
scripts/Makefile.am
0 → 100644
1 | EXTRA_DIST = guile-doc-snarf guile-func-name-check guile-snarf.awk |
scripts/guile-doc-snarf
0 → 100755
1 | #! /bin/sh | ||
2 | # Extract the initialization actions for builtin things. | ||
3 | # | ||
4 | # Copyright (C) 1999, 2000 Free Software Foundation, Inc. | ||
5 | # | ||
6 | # This program is free software; you can redistribute it and/or modify | ||
7 | # it under the terms of the GNU General Public License as published by | ||
8 | # the Free Software Foundation; either version 2, or (at your option) | ||
9 | # any later version. | ||
10 | # | ||
11 | # This program is distributed in the hope that it will be useful, | ||
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | # GNU General Public License for more details. | ||
15 | # | ||
16 | # You should have received a copy of the GNU General Public License | ||
17 | # along with this software; see the file COPYING. If not, write to | ||
18 | # the Free Software Foundation, Inc., 59 Temple Place, Suite 330, | ||
19 | # Boston, MA 02111-1307 USA | ||
20 | # | ||
21 | ## For some obscure reason, the original guile-doc-snarf distributed | ||
22 | ## with guile up to version 1.4, passes guile-func-name-check | ||
23 | ## to awk without absolute path spec. Consequently the script bails | ||
24 | ## out unless guile-func-name-check is in the current directory. | ||
25 | ## This version assumes that both scripts live in the same directory | ||
26 | ## and deduces the path to guile-func-name-check from the own pathname. | ||
27 | ## --gray | ||
28 | |||
29 | fullfilename=$1; shift | ||
30 | |||
31 | # strip path to source directory | ||
32 | filename=`basename $fullfilename` | ||
33 | |||
34 | # we need to be sure that the .x file exists | ||
35 | # since the .c/.cc file may include it | ||
36 | # (the old guile-snarf did not have this problem | ||
37 | # because the makefile redirects output to the .x file | ||
38 | # which creates the file before the inclusion occurs) | ||
39 | # --12/12/99 gjb | ||
40 | no_ext=`echo $filename | sed 's/\.[^.]*$//g'` | ||
41 | dot_doc=${no_ext}.doc | ||
42 | |||
43 | temp="/tmp/snarf.$$" | ||
44 | trap "rm -f $temp" 0 1 2 15 | ||
45 | |||
46 | ## Let the user override the preprocessor & awk autoconf found. | ||
47 | test -n "${CPP+set}" || CPP="gcc -E" | ||
48 | test -n "${AWK+set}" || AWK="gawk" | ||
49 | |||
50 | ## Must run guile-func-name-check on the unpreprocessed source | ||
51 | ${AWK} -f `dirname $0`/guile-func-name-check "$fullfilename" | ||
52 | |||
53 | ## We must use a temporary file here, instead of a pipe, because we | ||
54 | ## need to know if CPP exits with a non-zero status. | ||
55 | ${CPP} -DSCM_MAGIC_SNARFER "$@" > ${temp} || exit $? | ||
56 | cat ${temp} | sed 's/^\(.\{128\}.\{128\}.\{128\}.\{128\}.\{128\}.\{128\}.\{128\}.\{128\}\).*/\1/g' | \ | ||
57 | ${AWK} -f `dirname $0`/guile-snarf.awk `basename ${dot_doc}` |
scripts/guile-func-name-check
0 → 100755
1 | #! /usr/bin/awk -f | ||
2 | # | ||
3 | # Copyright (C) 2000 Free Software Foundation, Inc. | ||
4 | # | ||
5 | # This program is free software; you can redistribute it and/or modify | ||
6 | # it under the terms of the GNU General Public License as published by | ||
7 | # the Free Software Foundation; either version 2, or (at your option) | ||
8 | # any later version. | ||
9 | # | ||
10 | # This program is distributed in the hope that it will be useful, | ||
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | # GNU General Public License for more details. | ||
14 | # | ||
15 | # You should have received a copy of the GNU General Public License | ||
16 | # along with this software; see the file COPYING. If not, write to | ||
17 | # the Free Software Foundation, Inc., 59 Temple Place, Suite 330, | ||
18 | # Boston, MA 02111-1307 USA | ||
19 | # | ||
20 | # Written by Greg J. Badros, <gjb@cs.washington.edu> | ||
21 | # 11-Jan-2000 | ||
22 | |||
23 | BEGIN { | ||
24 | filename = ARGV[1]; | ||
25 | } | ||
26 | |||
27 | /^SCM_DEFINE/ { | ||
28 | func_name = $0; | ||
29 | sub(/^[^\(\n]*\([ \t]*/,"", func_name); | ||
30 | sub(/[ \t]*,.*/,"", func_name); | ||
31 | # print func_name; # GJB:FIXME:: flag to do this to list primitives? | ||
32 | in_a_func = 1; | ||
33 | } | ||
34 | |||
35 | in_a_func && /^\{/ { | ||
36 | if (!match(last_line,/^#define[ \t]+FUNC_NAME[ \t]+/)) { | ||
37 | printf filename ":" NR ":***" > "/dev/stderr"; | ||
38 | print "Missing or erroneous `#define FUNC_NAME s_" func_name "'" > "/dev/stderr"; | ||
39 | } else { | ||
40 | sub(/^#define[ \t]+FUNC_NAME[ \t]+s_/, "", last_line); | ||
41 | sub(/[ \t]*$/,"",last_line); | ||
42 | if (last_line != func_name) { | ||
43 | printf filename ":" NR ":***" > "/dev/stderr"; | ||
44 | print "Mismatching FUNC_NAME. Should be: `#define FUNC_NAME s_" func_name "'" > "/dev/stderr"; | ||
45 | } | ||
46 | } | ||
47 | } | ||
48 | |||
49 | 1 == next_line_better_be_undef { | ||
50 | if (!match($0,/^#undef FUNC_NAME[ \t]*$/)) { | ||
51 | printf filename ":" NR ":***" > "/dev/stderr"; | ||
52 | print "Missing or erroneous #undef for " func_name ": " | ||
53 | "Got `" $0 "' instead." > "/dev/stderr"; | ||
54 | } | ||
55 | in_a_func = ""; | ||
56 | func_name = ""; | ||
57 | next_line_better_be_undef = 0; | ||
58 | } | ||
59 | |||
60 | in_a_func && /^\}/ { | ||
61 | next_line_better_be_undef = 1; | ||
62 | } | ||
63 | |||
64 | { last_line = $0; } |
scripts/guile-snarf.awk
0 → 100644
1 | # Copyright (C) 1999, 2000 Free Software Foundation, Inc. | ||
2 | # | ||
3 | # This program is free software; you can redistribute it and/or modify | ||
4 | # it under the terms of the GNU General Public License as published by | ||
5 | # the Free Software Foundation; either version 2, or (at your option) | ||
6 | # any later version. | ||
7 | # | ||
8 | # This program is distributed in the hope that it will be useful, | ||
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | # GNU General Public License for more details. | ||
12 | # | ||
13 | # You should have received a copy of the GNU General Public License | ||
14 | # along with this software; see the file COPYING. If not, write to | ||
15 | # the Free Software Foundation, Inc., 59 Temple Place, Suite 330, | ||
16 | # Boston, MA 02111-1307 USA | ||
17 | # | ||
18 | # Written by Greg J. Badros, <gjb@cs.washington.edu> | ||
19 | # 12-Dec-1999 | ||
20 | |||
21 | BEGIN { FS="|"; | ||
22 | dot_doc_file = ARGV[1]; ARGV[1] = "-"; | ||
23 | std_err = "/dev/stderr"; | ||
24 | # be sure to put something in the files to help make out | ||
25 | print ""; | ||
26 | printf "" > dot_doc_file; | ||
27 | } | ||
28 | |||
29 | /^[ \t]*SCM__I/ { copy = $0; | ||
30 | gsub(/[ \t]*SCM__I/, "", copy); | ||
31 | gsub(/SCM__D.*$/, "", copy); | ||
32 | print copy; } | ||
33 | |||
34 | /SCM__D/,/SCM__S/ { copy = $0; | ||
35 | if (match(copy,/SCM__DR/)) { registering = 1; } | ||
36 | else {registering = 0; } | ||
37 | gsub(/.*SCM__D./,"", copy); | ||
38 | gsub(/SCM__S.*/,"",copy); | ||
39 | gsub(/[ \t]+/," ", copy); | ||
40 | sub(/^[ \t]*/,"(", copy); | ||
41 | gsub(/\"/,"",copy); | ||
42 | sub(/\([ \t]*void[ \t]*\)/,"()", copy); | ||
43 | sub(/ \(/," ",copy); | ||
44 | numargs = gsub(/SCM /,"", copy); | ||
45 | numcommas = gsub(/,/,"", copy); | ||
46 | numactuals = $2 + $3 + $4; | ||
47 | location = $5; | ||
48 | gsub(/\"/,"",location); | ||
49 | sub(/^[ \t]*/,"",location); | ||
50 | sub(/[ \t]*$/,"",location); | ||
51 | sub(/: /,":",location); | ||
52 | # Now whittle copy down to just the $1 field | ||
53 | # (but do not use $1, since it hasn't been | ||
54 | # altered by the above regexps) | ||
55 | gsub(/[ \t]*\|.*$/,"",copy); | ||
56 | sub(/ \)/,")",copy); | ||
57 | # Now `copy' contains the nice scheme proc "prototype", e.g. | ||
58 | # (set-car! pair value) | ||
59 | # print copy > "/dev/stderr"; # for debugging | ||
60 | proc_and_args = copy; | ||
61 | curr_function_proto = copy; | ||
62 | sub(/[^ \n]* /,"",proc_and_args); | ||
63 | sub(/\)[ \t]*/,"",proc_and_args); | ||
64 | split(proc_and_args,args," "); | ||
65 | # now args is an array of the arguments | ||
66 | # args[1] is the formal name of the first argument, etc. | ||
67 | if (numargs != numactuals && !registering) | ||
68 | { print location ":*** `" copy "' is improperly registered as having " numactuals " arguments" > std_err; } | ||
69 | print "\n" copy (registering?")":"") > dot_doc_file ; } | ||
70 | |||
71 | /SCM__S/,/SCM__E.*$/ { copy = $0; | ||
72 | gsub(/.*SCM__S/,"",copy); | ||
73 | sub(/^[ \t]*"?/,"", copy); | ||
74 | sub(/\"?[ \t]*SCM__E.*$/,"", copy); | ||
75 | gsub(/\\n\\n"?/,"\n",copy); | ||
76 | gsub(/\\n"?[ \t]*$/,"",copy); | ||
77 | gsub(/\\\"[ \t]*$/,"\"",copy); | ||
78 | gsub(/[ \t]*$/,"", copy); | ||
79 | if (copy != "") { print copy > dot_doc_file } | ||
80 | } | ||
81 | |||
82 | /SCM__E[ \t]/ { print "[" location "]" >> dot_doc_file; } | ||
83 | |||
84 | /\*&\*&\*&\*SCM_ARG_BETTER_BE_IN_POSITION/ { copy = $0; | ||
85 | sub(/.*\*&\*&\*&\*SCM_ARG_BETTER_BE_IN_POSITION\([ \t]*/,"",copy); | ||
86 | if (copy ~ /\"/) { next } | ||
87 | gsub(/[ \t]*,[ \t]*/,":",copy); | ||
88 | sub(/[ \t]*\).*/,"",copy); | ||
89 | split(copy,argpos,":"); | ||
90 | argname = argpos[1]; | ||
91 | pos = argpos[2]; | ||
92 | if (pos ~ /[A-Za-z]/) { next } | ||
93 | if (pos ~ /^[ \t]*$/) { next } | ||
94 | if (argname ~ / /) { next } | ||
95 | line = argpos[3]; | ||
96 | # print pos " " args[pos] " vs. " argname > "/dev/stderr"; | ||
97 | if (args[pos] != argname) { print filename ":" line ":*** Argument name/number mismatch in `" curr_function_proto "' -- " argname " is not formal #" pos > "/dev/stderr"; } | ||
98 | } |
-
Please register or sign in to post a comment