2006-04-17 00:05:42 +00:00
# Copyright (C) 1999, 2000, 2001, 2006 Free Software Foundation, Inc.
2001-02-21 20:15:15 +00:00
#
# This program is free software; you can redistribute it and/or modify
2009-06-17 00:22:09 +01:00
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 3, or (at
# your option) any later version.
2001-02-21 20:15:15 +00:00
#
2009-06-17 00:22:09 +01:00
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
2001-02-21 20:15:15 +00:00
#
2009-06-17 00:22:09 +01:00
# You should have received a copy of the GNU Lesser General Public
# License along with this software; see the file COPYING.LESSER. If
# not, write to the Free Software Foundation, Inc., 51 Franklin
# Street, Fifth Floor, Boston, MA 02110-1301 USA
2001-02-21 20:15:15 +00:00
#
1999-12-14 17:41:59 +00:00
# Written by Greg J. Badros, <gjb@cs.washington.edu>
# 12-Dec-1999
BEGIN { FS = "|" ;
2000-06-14 00:59:42 +00:00
dot_doc_file = ARGV [ 1 ] ; ARGV [ 1 ] = "-" ;
2000-02-10 19:45:10 +00:00
std_err = "/dev/stderr" ;
1999-12-14 17:41:59 +00:00
# be sure to put something in the files to help make out
print "" ;
printf "" > dot_doc_file ;
}
2000-06-21 08:43:12 +00:00
/^[ \t]*SCM_SNARF_INIT_START/ { copy = $ 0 ;
gsub ( /[ \t]*SCM_SNARF_INIT_START/ , "" , copy ) ;
gsub ( /SCM_SNARF_DOC_START.*$/ , "" , copy ) ;
1999-12-14 17:41:59 +00:00
print copy ; }
2000-06-21 08:43:12 +00:00
/SCM_SNARF_DOC_START/ , /SCM_SNARF_DOCSTRING_START/ { copy = $ 0 ;
if ( match ( copy , /SCM_SNARF_DOC_STARTR/ ) ) { registering = 1 ; }
1999-12-14 17:41:59 +00:00
else { registering = 0 ; }
2000-06-21 08:43:12 +00:00
gsub ( /.*SCM_SNARF_DOC_START./ , "" , copy ) ;
gsub ( /SCM_SNARF_DOCSTRING_START.*/ , "" , copy ) ;
1999-12-14 17:41:59 +00:00
gsub ( /[ \t]+/ , " " , copy ) ;
sub ( /^[ \t]*/ , "(" , copy ) ;
gsub ( /\"/ , "" , copy ) ;
2000-01-05 18:48:07 +00:00
sub ( /\([ \t]*void[ \t]*\)/ , "()" , copy ) ;
1999-12-14 17:41:59 +00:00
sub ( / \(/ , " " , copy ) ;
numargs = gsub ( /SCM / , "" , copy ) ;
numcommas = gsub ( /,/ , "" , copy ) ;
numactuals = $ 2 + $ 3 + $ 4 ;
location = $ 5 ;
gsub ( /\"/ , "" , location ) ;
sub ( /^[ \t]*/ , "" , location ) ;
sub ( /[ \t]*$/ , "" , location ) ;
sub ( /: / , ":" , location ) ;
2000-09-29 20:33:13 +00:00
sub ( /^\.\// , "" , location ) ;
2000-01-05 18:48:07 +00:00
# Now whittle copy down to just the $1 field
# (but do not use $1, since it hasn't been
# altered by the above regexps)
1999-12-14 17:41:59 +00:00
gsub ( /[ \t]*\|.*$/ , "" , copy ) ;
sub ( / \)/ , ")" , copy ) ;
2000-01-05 18:48:07 +00:00
# Now `copy' contains the nice scheme proc "prototype", e.g.
# (set-car! pair value)
2001-02-16 18:57:11 +00:00
# Since this is destined to become Texinfo source,
# quote any `@'s that occur in the prototype.
gsub ( /\@/ , "@@" , copy ) ;
2000-01-05 18:48:07 +00:00
# print copy > "/dev/stderr"; # for debugging
2000-09-29 20:33:13 +00:00
sub ( /^\(/ , "" , copy ) ;
sub ( /\)[ \t]*$/ , "" , copy ) ;
2000-01-05 18:48:07 +00:00
proc_and_args = copy ;
curr_function_proto = copy ;
2000-09-29 20:33:13 +00:00
proc_name = copy ;
sub ( / .*$/ , "" , proc_name ) ;
2000-01-05 18:48:07 +00:00
sub ( /[^ \n]* / , "" , proc_and_args ) ;
split ( proc_and_args , args , " " ) ;
# now args is an array of the arguments
# args[1] is the formal name of the first argument, etc.
1999-12-14 17:41:59 +00:00
if ( numargs != numactuals && ! registering )
2000-09-29 20:33:13 +00:00
{ print location ":*** `" curr_function_proto "' is improperly registered as having " numactuals " arguments" > std_err ; }
# Build a nicer function prototype than curr_function_proto
# that shows optional and rest arguments.
nicer_function_proto = proc_name ;
if ( ! registering ) {
optional_args_tail = "" ;
for ( i = 1 ; i <= $ 2 ; i ++ ) {
nicer_function_proto = nicer_function_proto " " args [ i ] ;
}
for ( ; i <= $ 2 + $ 3 ; i ++ ) {
nicer_function_proto = nicer_function_proto " [" args [ i ] ;
optional_args_tail = optional_args_tail "]" ;
}
nicer_function_proto = nicer_function_proto optional_args_tail ;
if ( $ 4 != 0 ) {
nicer_function_proto = nicer_function_proto " . " args [ i ] ;
}
}
# Now produce Texinfo format output.
print "\n " proc_name > dot_doc_file ;
print "@c snarfed from " location > dot_doc_file ;
print "@deffn primitive " nicer_function_proto > dot_doc_file ;
}
1999-12-14 17:41:59 +00:00
* eval.c (scm_promise_p), list.c (scm_append_x, scm_reverse_x),
symbols.c (scm_symbol_to_string), vports.c (scm_make_soft_port):
Change R4RS references to R5RS.
* guile-snarf.awk.in: Fixes so that (i) blank lines in the
docstring source are correctly reproduced in the output (ii)
we don't anymore get occasional trailing quotes. Also reorganized
and commented the code a little.
* scmsigs.c (scm_raise), throw.c (scm_throw): Docstring format
fixes.
* new-docstrings.texi, posix.texi, scheme-control.texi,
scheme-data.texi, scheme-debug.texi, scheme-evaluation.texi,
scheme-io.texi, scheme-memory.texi, scheme-procedures.texi:
Automatic docstring updates (mostly argument name updates and
blank lines).
* scheme-modules.texi: Change double hyphens to single.
* scheme-control.texi (Lazy Catch): Completed.
* posix.texi (Network Databases and Address Conversion): New
subsubsection `IPv6 Address Conversion'.
2001-05-04 21:54:00 +00:00
/SCM_SNARF_DOCSTRING_START/ , /SCM_SNARF_DOCSTRING_END.*$/ { copy = $ 0 ;
# Trim everything up to and including
# SCM_SNARF_DOCSTRING_START marker.
gsub ( /.*SCM_SNARF_DOCSTRING_START/ , "" , copy ) ;
# Trim leading whitespace and opening quote.
sub ( /^[ \t]*\"?/ , "" , copy ) ;
# Trim closing quote and trailing whitespace, or
# closing quote and whitespace followed by the
# SCM_SNARF_DOCSTRING_END marker.
sub ( /[ \t]*\"?[ \t]*$/ , "" , copy ) ;
sub ( /[ \t]*\"?[ \t]*SCM_SNARF_DOCSTRING_END.*$/ , "" , copy ) ;
# Replace escaped characters.
gsub ( /\\n/ , "\n" , copy ) ;
gsub ( /\\\"/ , "\"" , copy ) ;
gsub ( /\\\\/ , "\\" , copy ) ;
# Some docstrings end each line with "\n", while
# others don't. Therefore we always strip off one "\n"
# if present at the end of the line. Docstrings must
# therefore always use "\n\n" to indicate a blank line.
if ( copy != "" )
{
sub ( /[ \t]*\n$/ , "" , copy ) ;
print copy > dot_doc_file ;
}
2000-01-05 18:48:07 +00:00
}
2001-03-07 06:06:16 +00:00
/SCM_SNARF_DOCSTRING_END[ \t]*/ { print "@end deffn" > > dot_doc_file ; }
1999-12-14 17:41:59 +00:00
2000-01-05 18:48:07 +00:00
/\*&\*&\*&\*SCM_ARG_BETTER_BE_IN_POSITION/ { copy = $ 0 ;
sub ( /.*\*&\*&\*&\*SCM_ARG_BETTER_BE_IN_POSITION\([ \t]*/ , "" , copy ) ;
if ( copy ~ /\"/ ) { next }
gsub ( /[ \t]*,[ \t]*/ , ":" , copy ) ;
sub ( /[ \t]*\).*/ , "" , copy ) ;
split ( copy , argpos , ":" ) ;
argname = argpos [ 1 ] ;
pos = argpos [ 2 ] ;
if ( pos ~ /[A-Za-z]/ ) { next }
if ( pos ~ /^[ \t]*$/ ) { next }
if ( argname ~ / / ) { next }
line = argpos [ 3 ] ;
# print pos " " args[pos] " vs. " argname > "/dev/stderr";
if ( args [ pos ] != argname ) { print filename ":" line ":*** Argument name/number mismatch in `" curr_function_proto "' -- " argname " is not formal #" pos > "/dev/stderr" ; }
}