# HG changeset patch # User jwe # Date 940327986 0 # Node ID 35a6d027772c9d49163169a93b21a54fb9eb13e0 # Parent bfe1573bd2ae4f3bb5ca07a02a0c6046e290bd6c [project @ 1999-10-19 10:13:02 by jwe] diff --git a/examples/make_int.cc b/examples/make_int.cc --- a/examples/make_int.cc +++ b/examples/make_int.cc @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/scripts/Makefile.in b/scripts/Makefile.in --- a/scripts/Makefile.in +++ b/scripts/Makefile.in @@ -36,7 +36,7 @@ FCN_FILES = # $(wildcard $(srcdir)/*.m) FCN_FILES_NO_DIR = # $(notdir $(FCN_FILES)) -all: $(SUBDIRS) +all: $(SUBDIRS) DOCSTRINGS .PHONY: all $(SUBDIRS): @@ -44,6 +44,11 @@ cd $@; $(MAKE) all .PHONY: $(SUBDIRS) +DOCSTRINGS: gethelp mkdoc + $(srcdir)/mkdoc $(srcdir) > $@.t + @$(top_srcdir)/move-if-change $@.t $@ +.PHONY: DOCSTRINGS + install install-strip uninstall clean mostlyclean distclean maintainer-clean:: @$(subdir-for-command) .PHONY: install install-strip uninstall diff --git a/scripts/gethelp.cc b/scripts/gethelp.cc new file mode 100644 --- /dev/null +++ b/scripts/gethelp.cc @@ -0,0 +1,149 @@ +#include +#include + +#ifndef NPOS +#define NPOS string::npos +#endif + +static bool +looks_like_octave_copyright (const string& s) +{ + bool retval = false; + + string t = s.substr (0, 15); + + if (t == " Copyright (C) ") + { + size_t pos = s.find ('\n'); + + if (pos != NPOS) + { + pos = s.find ('\n', pos + 1); + + if (pos != NPOS) + { + pos++; + + t = s.substr (pos, 29); + + if (t == " This file is part of Octave." + || t == " This program is free softwar") + retval = true; + } + } + } + + return retval; +} + +// Eat whitespace and comments from FFILE, returning the text of the +// first block of comments that doesn't look like a copyright notice, + +static string +extract_help_text (void) +{ + string help_txt; + + bool first_comments_seen = false; + bool begin_comment = false; + bool have_help_text = false; + bool in_comment = false; + int c; + + while ((c = cin.get ()) != EOF) + { + if (begin_comment) + { + if (c == '%' || c == '#') + continue; + else + begin_comment = false; + } + + if (in_comment) + { + if (! have_help_text) + { + first_comments_seen = true; + help_txt += (char) c; + } + + if (c == '\n') + { + in_comment = false; + + if ((c = cin.get ()) != EOF) + { + if (c == '\n') + break; + } + else + break; + } + } + else + { + switch (c) + { + case ' ': + case '\t': + if (first_comments_seen) + have_help_text = true; + break; + + case '\n': + if (first_comments_seen) + have_help_text = true; + continue; + + case '%': + case '#': + begin_comment = true; + in_comment = true; + break; + + default: + goto done; + } + } + } + + done: + + if (! help_txt.empty ()) + { + if (looks_like_octave_copyright (help_txt)) + help_txt.resize (0); + + if (help_txt.empty ()) + help_txt = extract_help_text (); + } + + return help_txt; +} + +int +main (int argc, char **argv) +{ + string name; + + if (argc != 2) + { + cerr << "usage: gethelp name\n"; + return 1; + } + else + name = argv[1]; + + string help_text = extract_help_text (); + + if (! help_text.empty ()) + { + cout << "" << name << "\n" << help_text; + + if (help_text[help_text.length () - 1] != '\n') + cout << "\n"; + } + + return 0; +} diff --git a/scripts/mkdoc b/scripts/mkdoc new file mode 100755 --- /dev/null +++ b/scripts/mkdoc @@ -0,0 +1,9 @@ +#! /bin/sh + +if test $# != 1; then + d=. +else + d=$1 +fi + +find $d -name '*.m' | sed "s,\(.*\)/\(.*\)\.m,./gethelp \2 < &," | /bin/sh diff --git a/scripts/time/ctime.m b/scripts/time/ctime.m --- a/scripts/time/ctime.m +++ b/scripts/time/ctime.m @@ -17,7 +17,20 @@ ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA. -## usage: ctime (TIME) +## -*- texinfo -*- +## @deftypefn {Function File} {} ctime (@var{t}) +## Convert a value returned from @code{time} (or any other nonnegative +## integer), to the local time and return a string of the same form as +## @code{asctime}. The function @code{ctime (time)} is equivalent to +## @code{asctime (localtime (time))}. For example, +## +## @example +## @group +## ctime (time ()) +## @result{} "Mon Feb 17 01:15:06 1997" +## @end group +## @end example +## @end deftypefn ## Author: jwe diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +1999-10-18 John W. Eaton + + * help.cc (help_from_info): Print `unable to find info' message if + try_info returns 127; otherwise, print `not indexed' message. + Don't sleep after printing `not indexed' message. + 1999-10-14 John W. Eaton * parse.y (fold (tree_unary_expression *)): New function. diff --git a/src/DLD-FUNCTIONS/time.cc b/src/DLD-FUNCTIONS/time.cc --- a/src/DLD-FUNCTIONS/time.cc +++ b/src/DLD-FUNCTIONS/time.cc @@ -174,66 +174,155 @@ } DEFUN_DLD (strftime, args, , - "strftime (FMT, TMSTRUCT)\n\ + "-*- texinfo -*-\n\ +@deftypefn {Loadable Function} {} strftime (@var{tm_struct})\n\ +Format a time structure in a flexible way using @samp{%} substitutions\n\ +similar to those in @code{printf}. Except where noted, substituted\n\ +fields have a fixed size; numeric fields are padded if necessary.\n\ +Padding is with zeros by default; for fields that display a single\n\ +number, padding can be changed or inhibited by following the @samp{%}\n\ +with one of the modifiers described below. Unknown field specifiers are\n\ +copied as normal characters. All other characters are copied to the\n\ +output without change. For example,\n\ \n\ -Performs `%' substitutions similar to those in printf. Except where\n\ -noted, substituted fields have a fixed size; numeric fields are\n\ -padded if necessary. Padding is with zeros by default; for fields\n\ -that display a single number, padding can be changed or inhibited by\n\ -following the `%' with one of the modifiers described below.\n\ -Unknown field specifiers are copied as normal characters. All other\n\ -characters are copied to the output without change.\n\ +@example\n\ +@group\n\ +strftime (\"%r (%Z) %A %e %B %Y\", localtime (time ())\n\ + @result{} \"01:15:06 AM (CST) Monday 17 February 1997\"\n\ +@end group\n\ +@end example\n\ \n\ -Supports a superset of the ANSI C field specifiers.\n\ +Octave's @code{strftime} function supports a superset of the ANSI C\n\ +field specifiers.\n\ \n\ +@noindent\n\ Literal character fields:\n\ \n\ - % %\n\ - n newline\n\ - t tab\n\ +@table @code\n\ +@item %\n\ +% character.\n\ \n\ +@item n\n\ +Newline character.\n\ +\n\ +@item t\n\ +Tab character.\n\ +@end table\n\ +\n\ +@noindent\n\ Numeric modifiers (a nonstandard extension):\n\ \n\ - - do not pad the field\n\ - _ pad the field with spaces\n\ +@table @code\n\ +@item - (dash)\n\ +Do not pad the field.\n\ \n\ +@item _ (underscore)\n\ +Pad the field with spaces.\n\ +@end table\n\ +\n\ +@noindent\n\ Time fields:\n\ \n\ - %H hour (00..23)\n\ - %I hour (01..12)\n\ - %k hour ( 0..23)\n\ - %l hour ( 1..12)\n\ - %M minute (00..59)\n\ - %p locale's AM or PM\n\ - %r time, 12-hour (hh:mm:ss [AP]M)\n\ - %R time, 24-hour (hh:mm)\n\ - %s time in seconds since 00:00:00, Jan 1, 1970 (a nonstandard extension)\n\ - %S second (00..61)\n\ - %T time, 24-hour (hh:mm:ss)\n\ - %X locale's time representation (%H:%M:%S)\n\ - %Z time zone (EDT), or nothing if no time zone is determinable\n\ - %z offset from GMT\n\ +@table @code\n\ +@item %H\n\ +Hour (00-23).\n\ +\n\ +@item %I\n\ +Hour (01-12).\n\ +\n\ +@item %k\n\ +Hour (0-23).\n\ +\n\ +@item %l\n\ +Hour (1-12).\n\ +\n\ +@item %M\n\ +Minute (00-59).\n\ +\n\ +@item %p\n\ +Locale's AM or PM.\n\ \n\ +@item %r\n\ +Time, 12-hour (hh:mm:ss [AP]M).\n\ +\n\ +@item %R\n\ +Time, 24-hour (hh:mm).\n\ +\n\ +@item %s\n\ +Time in seconds since 00:00:00, Jan 1, 1970 (a nonstandard extension).\n\ +\n\ +@item %S\n\ +Second (00-61).\n\ +\n\ +@item %T\n\ +Time, 24-hour (hh:mm:ss).\n\ +\n\ +@item %X\n\ +Locale's time representation (%H:%M:%S).\n\ +\n\ +@item %Z\n\ +Time zone (EDT), or nothing if no time zone is determinable.\n\ +@end table\n\ +\n\ +@noindent\n\ Date fields:\n\ \n\ - %a locale's abbreviated weekday name (Sun..Sat)\n\ - %A locale's full weekday name, variable length (Sunday..Saturday)\n\ - %b locale's abbreviated month name (Jan..Dec)\n\ - %B locale's full month name, variable length (January..December)\n\ - %c locale's date and time (Sat Nov 04 12:02:33 EST 1989)\n\ - %C century (00..99)\n\ - %d day of month (01..31)\n\ - %e day of month ( 1..31)\n\ - %D date (mm/dd/yy)\n\ - %h same as %b\n\ - %j day of year (001..366)\n\ - %m month (01..12)\n\ - %U week number of year with Sunday as first day of week (00..53)\n\ - %w day of week (0..6)\n\ - %W week number of year with Monday as first day of week (00..53)\n\ - %x locale's date representation (mm/dd/yy)\n\ - %y last two digits of year (00..99)\n\ - %Y year (1970...)") +@table @code\n\ +@item %a\n\ +Locale's abbreviated weekday name (Sun-Sat).\n\ +\n\ +@item %A\n\ +Locale's full weekday name, variable length (Sunday-Saturday).\n\ +\n\ +@item %b\n\ +Locale's abbreviated month name (Jan-Dec).\n\ +\n\ +@item %B\n\ +Locale's full month name, variable length (January-December).\n\ +\n\ +@item %c\n\ +Locale's date and time (Sat Nov 04 12:02:33 EST 1989).\n\ +\n\ +@item %C\n\ +Century (00-99).\n\ +\n\ +@item %d\n\ +Day of month (01-31).\n\ +\n\ +@item %e\n\ +Day of month ( 1-31).\n\ +\n\ +@item %D\n\ +Date (mm/dd/yy).\n\ +\n\ +@item %h\n\ +Same as %b.\n\ +\n\ +@item %j\n\ +Day of year (001-366).\n\ +\n\ +@item %m\n\ +Month (01-12).\n\ +\n\ +@item %U\n\ +Week number of year with Sunday as first day of week (00-53).\n\ +\n\ +@item %w\n\ +Day of week (0-6).\n\ +\n\ +@item %W\n\ +Week number of year with Monday as first day of week (00-53).\n\ +\n\ +@item %x\n\ +Locale's date representation (mm/dd/yy).\n\ +\n\ +@item %y\n\ +Last two digits of year (00-99).\n\ +\n\ +@item %Y\n\ +Year (1970-).\n\ +@end table\n\ +@end deftypefn\n") { octave_value_list retval; diff --git a/src/Makefile.in b/src/Makefile.in --- a/src/Makefile.in +++ b/src/Makefile.in @@ -27,6 +27,12 @@ | $(srcdir)/mkdefs > $@.t @mv $@.t $@ +%.dc : %.cc + @echo making $@ from $< + @$(CXXCPP) -c $(CPPFLAGS) $(CXXFLAGS_NO_PT_FLAGS) -DMAKE_DOC $< \ + | $(srcdir)/mkdocs > $@.t + @mv $@.t $@ + # How to make a .oct file from a .o file: ifeq ($(OCTAVE_LITE), true) @@ -175,6 +181,8 @@ VAR_1 := $(patsubst %.l, %, $(VAR_2)) VAR_FILES := $(patsubst %.cc, %, $(VAR_1)) +DOC_FILES := $(sort $(DEF_FILES) $(patsubst %, %.df, $(VAR_FILES))) + OCTAVE_LFLAGS = -L$(TOPDIR)/liboctave -L$(TOPDIR)/libcruft \ -L$(TOPDIR)/src $(RLD_FLAG) @@ -195,7 +203,7 @@ BINDISTFILES = octave $(OCT_FILES) endif -all: stamp-prereq libraries stamp-oct-links octave +all: stamp-prereq libraries stamp-oct-links octave DOCSTRINGS .PHONY: all stamp-oct-links: $(OCT_FILES) @@ -260,6 +268,17 @@ @$(srcdir)/mkbuiltins def-files var-files > $@.t @$(top_srcdir)/move-if-change $@.t $@ +DOCSTRINGS: gendoc + ./gendoc > $@.t + mv $@.t $@ + +gendoc.cc: $(DOC_FILES) mkgendoc + @echo making $@ + @echo DOC_FILES = $(DOC_FILES) + @echo $(DOC_FILES) > doc-files + @$(srcdir)/mkgendoc doc-files > $@-t + @$(top_srcdir)/move-if-change $@-t $@ + ops.cc: $(OP_SRC) mkops @echo making $@ from $(OP_SRC) @$(srcdir)/mkops $(OP_SRC) > $@.t diff --git a/src/defun-dld.h b/src/defun-dld.h --- a/src/defun-dld.h +++ b/src/defun-dld.h @@ -40,15 +40,21 @@ // and the second is for the definition of the function. #if defined (MAKE_BUILTINS) + #if ! (defined (OCTAVE_LITE) && defined (WITH_DYNAMIC_LINKING)) + #define DEFUN_DLD(name, args_name, nargout_name, doc) \ DEFUN_INTERNAL (name, args_name, nargout_name, 0, doc) + #endif + #else + #define DEFUN_DLD(name, args_name, nargout_name, doc) \ DECLARE_FUN (name, args_name, nargout_name); \ DEFINE_FUN_INSTALLER_FUN (name, doc) \ DECLARE_FUN (name, args_name, nargout_name) + #endif #endif diff --git a/src/defun-int.h b/src/defun-int.h --- a/src/defun-int.h +++ b/src/defun-int.h @@ -56,43 +56,6 @@ extern void alias_builtin (const string& alias, const string& name); -// MAKE_BUILTINS is defined to extract function names and related -// information and create the *.def files that are eventually used to -// create the buitlins.cc file. - -#ifdef MAKE_BUILTINS - -// Generate code to install name in the symbol table. The script -// mkdefs will create a .def file for every .cc file that uses DEFUN, -// DEFUN_TEXT, or DEFUN_DLD. - -#define DEFUN_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) \ - BEGIN_INSTALL_BUILTIN \ - extern DECLARE_FUN (name, args_name, nargout_name); \ - install_builtin_function (F ## name, #name, doc, is_text_fcn); \ - END_INSTALL_BUILTIN - -// Generate code for making another name for an existing function. - -#define DEFALIAS_INTERNAL(alias, name) \ - BEGIN_INSTALL_BUILTIN \ - alias_builtin (#alias, #name); \ - END_INSTALL_BUILTIN - -#else /* ! MAKE_BUILTINS */ - -// Generate the first line of the function definition. This ensures -// that the internal functions all have the same signature. - -#define DEFUN_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) \ - DECLARE_FUN (name, args_name, nargout_name) - -// No definition is required for an alias. - -#define DEFALIAS_INTERNAL(name, alias) - -#endif /* ! MAKE_BUILTINS */ - // Define the code that will be used to insert the new function into // the symbol table. @@ -114,6 +77,59 @@ octave_value_list \ F ## name (const octave_value_list& args_name, int nargout_name) +// MAKE_BUILTINS is defined to extract function names and related +// information and create the *.df files that are eventually used to +// create the builtins.cc file. + +#if defined (MAKE_BUILTINS) + +// Generate code to install name in the symbol table. The script +// mkdefs will create a .def file for every .cc file that uses DEFUN, +// DEFUN_TEXT, or DEFUN_DLD. + +#define DEFUN_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) \ + BEGIN_INSTALL_BUILTIN \ + XDEFUN_INTERNAL (name, args_name, nargout_name, is_text_fcn, doc) \ + END_INSTALL_BUILTIN + +// Generate code for making another name for an existing function. + +#define DEFALIAS_INTERNAL(alias, name) \ + BEGIN_INSTALL_BUILTIN \ + XDEFALIAS_INTERNAL(alias, name) \ + END_INSTALL_BUILTIN + +#define DEFVAR_INTERNAL(name, sname, defn, protect, chg_fcn, doc) \ + BEGIN_INSTALL_BUILTIN \ + XDEFVAR_INTERNAL(name, sname, defn, protect, chg_fcn, doc) \ + END_INSTALL_BUILTIN + +#define DEFCONST_INTERNAL(name, sname, defn, protect, doc) \ + BEGIN_INSTALL_BUILTIN \ + XDEFCONST_INTERNAL(name, sname, defn, protect, doc) \ + END_INSTALL_BUILTIN + +#define DEFUN_MAPPER_INTERNAL(name, ch_map, d_b_map, c_b_map, d_d_map, \ + d_c_map, c_c_map, lo, hi, \ + can_ret_cmplx_for_real, doc) \ + BEGIN_INSTALL_BUILTIN \ + XDEFUN_MAPPER_INTERNAL(name, ch_map, d_b_map, c_b_map, d_d_map, \ + d_c_map, c_c_map, lo, hi, \ + can_ret_cmplx_for_real, doc) \ + END_INSTALL_BUILTIN + +#else /* ! MAKE_BUILTINS */ + +// Generate the first line of the function definition. This ensures +// that the internal functions all have the same signature. + +#define DEFUN_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) \ + DECLARE_FUN (name, args_name, nargout_name) + +// No definition is required for an alias. + +#define DEFALIAS_INTERNAL(name, alias) + // How builtin variables are actually installed. #define DEFVAR_INTERNAL(name, sname, defn, protect, chg_fcn, doc) \ @@ -135,6 +151,8 @@ c_c_map, lo, hi, \ can_ret_cmplx_for_real, #name)) +#endif /* ! MAKE_BUILTINS */ + #endif /* diff --git a/src/help.cc b/src/help.cc --- a/src/help.cc +++ b/src/help.cc @@ -41,6 +41,8 @@ #include #endif +#include "cmd-edit.h" +#include "file-ops.h" #include "oct-env.h" #include "str-vec.h" @@ -57,6 +59,7 @@ #include "pager.h" #include "parse.h" #include "pathsearch.h" +#include "procstream.h" #include "pt-pr-code.h" #include "sighandlers.h" #include "symtab.h" @@ -400,14 +403,11 @@ os << "\n\ Additional help for built-in functions, operators, and variables\n\ is available in the on-line version of the manual. Use the command\n\ -`help -i ' to search the manual index.\n"; - - if (! Vsuppress_verbose_help_message) - os << "\n\ +`help -i ' to search the manual index.\n\ +\n\ Help and information about Octave is also available on the WWW\n\ at http://www.che.wisc.edu/octave/octave.html and via the\n\ help-octave@bevo.che.wisc.edu mailing list.\n"; - } // XXX FIXME XXX -- this needs a major overhaul to cope with new @@ -647,24 +647,99 @@ if (status) { - if (status < 0) - { - message ("help", "sorry, `%s' is not indexed in the manual", - argv[i].c_str ()); - sleep (2); - } - else + if (status == 127) { error ("help: unable to find info"); error ("help: you need info 2.18 or later (texinfo 3.12)"); break; } + else + { + message ("help", "sorry, `%s' is not indexed in the manual", + argv[i].c_str ()); + } } } } } static bool +looks_like_texinfo (const string& msg, size_t& p1) +{ + p1 = msg.find ('\n'); + + string t = msg.substr (0, p1); + + if (p1 == NPOS) + p1 = 0; + + size_t p2 = t.find ("-*- texinfo -*-"); + + return (p2 != NPOS); +} + +static void +display_help_text (ostream& os, const string& msg) +{ + // Look for "-*- texinfo -*-" in first line of help message. If it + // is present, use makeinfo to format the rest of the message before + // sending it to the output stream. Otherwise, just print the + // message. + + size_t pos; + + if (looks_like_texinfo (msg, pos)) + { + string tmp_file_name = file_ops::tempnam ("", ""); + + int cols = command_editor::terminal_cols (); + + if (cols > 16) + cols--; + + if (cols > 64) + cols -= 7; + + if (cols > 80) + cols = 72; + + ostrstream buf; + buf << "sed 's/^[#%]+ *//'" + << " | makeinfo --fill-column " << cols + << " --no-warn --no-validate --no-headers --force > " + << tmp_file_name + << ends; + + char *cmd = buf.str (); + + oprocstream filter (cmd); + + delete [] cmd; + + if (filter) + { + filter << msg.substr (pos+1); + + filter.close (); + + ifstream tmp_file (tmp_file_name.c_str ()); + + int c; + while ((c = tmp_file.get ()) != EOF) + os << (char) c; + + tmp_file.close (); + + file_ops::unlink (tmp_file_name); + } + else + os << msg; + } + else + os << msg; +} + +static bool help_from_list (ostream& os, const help_list *list, const string& nm, int usage) { @@ -681,7 +756,9 @@ os << "\n*** " << nm << ":\n\n"; } - os << list->help << "\n"; + display_help_text (os, list->help); + + os << "\n"; return true; } @@ -714,7 +791,9 @@ if (h.length () > 0) { print_symbol_type (octave_stdout, sym_rec, argv[i], 1); - octave_stdout << "\n" << h << "\n"; + octave_stdout << "\n"; + display_help_text (octave_stdout, h); + octave_stdout << "\n"; continue; } } @@ -726,8 +805,9 @@ if (! h.empty ()) { octave_stdout << argv[i] << " is the file: " - << path << "\n\n" << h << "\n"; - + << path << "\n\n"; + display_help_text (octave_stdout, h); + octave_stdout << "\n"; continue; } diff --git a/src/mkbuiltins b/src/mkbuiltins --- a/src/mkbuiltins +++ b/src/mkbuiltins @@ -29,6 +29,21 @@ #include "oct-obj.h" #include "variables.h" +#define XDEFUN_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) \ + extern DECLARE_FUN (name, args_name, nargout_name); \ + install_builtin_function (F ## name, #name, doc, is_text_fcn); \ + +#define XDEFALIAS_INTERNAL(alias, name) \ + alias_builtin (#alias, #name); + +#define XDEFVAR_INTERNAL(name, sname, defn, protect, chg_fcn, doc) + +#define XDEFCONST_INTERNAL(name, sname, defn, protect, doc) + +#define XDEFUN_MAPPER_INTERNAL(name, ch_map, d_b_map, c_b_map, d_d_map, \ + d_c_map, c_c_map, lo, hi, \ + can_ret_cmplx_for_real, doc) + EOF for file in $DEF_FILES; do diff --git a/src/mkdefs b/src/mkdefs --- a/src/mkdefs +++ b/src/mkdefs @@ -9,4 +9,4 @@ s/BEGIN_INSTALL_BUILTIN// s/END_INSTALL_BUILTIN// p -}' +}' \ No newline at end of file diff --git a/src/mkdocs b/src/mkdocs new file mode 100755 --- /dev/null +++ b/src/mkdocs @@ -0,0 +1,12 @@ +#!/bin/sh + +sed -n -e '/^BEGIN_DOC_STRING/{ + : loop + N + /END_DOC_STRING/b done + b loop + : done + s/BEGIN_DOC_STRING// + s/END_DOC_STRING// + p +}' diff --git a/src/mkgendoc b/src/mkgendoc new file mode 100755 --- /dev/null +++ b/src/mkgendoc @@ -0,0 +1,74 @@ +#! /bin/sh + +if test $# -ne 1; then + echo "usage: mkgendoc f1" 1>&2 + exit 1 +fi + +DOC_FILES=`cat $1` + +if test -z "$DOC_FILES"; then + echo "mkgendoc: DOC_FILES is empty!" 1>&2 + exit 1 +fi + +cat << \EOF +// DO NOT EDIT! Generated automatically by mkbuiltins. + +#include +#include + +#define XDEFUN_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) \ + print_doc_string (#name, doc); + +#define XDEFALIAS_INTERNAL(alias, name) + +#define XDEFVAR_INTERNAL(name, sname, defn, protect, chg_fcn, doc) \ + print_doc_string (#name, doc); + +#define XDEFCONST_INTERNAL(name, sname, defn, protect, doc) \ + print_doc_string (#name, doc); + +#define XDEFUN_MAPPER_INTERNAL(name, ch_map, d_b_map, c_b_map, d_d_map, \ + d_c_map, c_c_map, lo, hi, \ + can_ret_cmplx_for_real, doc) \ + print_doc_string (#name, doc); + +static void +print_doc_string (const string& name, const string& doc) +{ + cout << "" << name << "\n"; + cout << doc << "\n"; +} + +EOF + +for file in $DOC_FILES; do + fcn=`echo $file | sed 's,^\./,,; s/\.df//; s/-/_/g'` + echo "static void" + echo "print_${fcn}_doc_strings (void)" + echo "{" + cat $file + echo "}" + echo "" +done + +cat << \EOF + +int +main (void) +{ +EOF + +for file in $DOC_FILES; do + fcn=`echo $file | sed 's,^\./,,; s/\.df//; s/-/_/g'` + echo " print_${fcn}_doc_strings ();" +done + +cat << \EOF + + return 0; +} +EOF + +exit 0