annotate doc/interpreter/munge-texi.cc @ 12254:23385f2c90b7 release-3-4-x

whitespace fixes
author John W. Eaton <jwe@octave.org>
date Wed, 26 Jan 2011 23:49:42 -0500
parents fd0a3ac60b0e
children 72c96de7a403
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3313
27502f8b3ba7 [project @ 1999-10-21 23:24:38 by jwe]
jwe
parents: 3301
diff changeset
1 /*
27502f8b3ba7 [project @ 1999-10-21 23:24:38 by jwe]
jwe
parents: 3301
diff changeset
2
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 11233
diff changeset
3 Copyright (C) 1999-2011 John W. Eaton
3313
27502f8b3ba7 [project @ 1999-10-21 23:24:38 by jwe]
jwe
parents: 3301
diff changeset
4
27502f8b3ba7 [project @ 1999-10-21 23:24:38 by jwe]
jwe
parents: 3301
diff changeset
5 This file is part of Octave.
27502f8b3ba7 [project @ 1999-10-21 23:24:38 by jwe]
jwe
parents: 3301
diff changeset
6
27502f8b3ba7 [project @ 1999-10-21 23:24:38 by jwe]
jwe
parents: 3301
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
27502f8b3ba7 [project @ 1999-10-21 23:24:38 by jwe]
jwe
parents: 3301
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5334
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5334
diff changeset
10 option) any later version.
3313
27502f8b3ba7 [project @ 1999-10-21 23:24:38 by jwe]
jwe
parents: 3301
diff changeset
11
27502f8b3ba7 [project @ 1999-10-21 23:24:38 by jwe]
jwe
parents: 3301
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
27502f8b3ba7 [project @ 1999-10-21 23:24:38 by jwe]
jwe
parents: 3301
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
27502f8b3ba7 [project @ 1999-10-21 23:24:38 by jwe]
jwe
parents: 3301
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
27502f8b3ba7 [project @ 1999-10-21 23:24:38 by jwe]
jwe
parents: 3301
diff changeset
15 for more details.
27502f8b3ba7 [project @ 1999-10-21 23:24:38 by jwe]
jwe
parents: 3301
diff changeset
16
27502f8b3ba7 [project @ 1999-10-21 23:24:38 by jwe]
jwe
parents: 3301
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5334
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5334
diff changeset
19 <http://www.gnu.org/licenses/>.
3313
27502f8b3ba7 [project @ 1999-10-21 23:24:38 by jwe]
jwe
parents: 3301
diff changeset
20
27502f8b3ba7 [project @ 1999-10-21 23:24:38 by jwe]
jwe
parents: 3301
diff changeset
21 */
27502f8b3ba7 [project @ 1999-10-21 23:24:38 by jwe]
jwe
parents: 3301
diff changeset
22
4177
34ef135b29fa [project @ 2002-11-13 04:09:53 by jwe]
jwe
parents: 3576
diff changeset
23 #include <cctype>
3575
7576a76f6d7b [project @ 2000-02-04 11:02:49 by jwe]
jwe
parents: 3404
diff changeset
24 #include <iostream>
7576a76f6d7b [project @ 2000-02-04 11:02:49 by jwe]
jwe
parents: 3404
diff changeset
25 #include <fstream>
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
26 #include <string>
4215
bc6059c5ddc7 [project @ 2002-12-04 05:21:08 by jwe]
jwe
parents: 4178
diff changeset
27 #include <map>
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
28
7048
845ca0affec0 [project @ 2007-10-22 16:55:41 by jwe]
jwe
parents: 7017
diff changeset
29 #include <cstdlib>
845ca0affec0 [project @ 2007-10-22 16:55:41 by jwe]
jwe
parents: 7017
diff changeset
30 #include <cstring>
845ca0affec0 [project @ 2007-10-22 16:55:41 by jwe]
jwe
parents: 7017
diff changeset
31
9906
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
32 static std::string top_srcdir;
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
33
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
34 static const char doc_delim = '';
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
35
4178
b75f74a76941 [project @ 2002-11-13 15:43:35 by jwe]
jwe
parents: 4177
diff changeset
36 static std::map<std::string, std::string> help_text;
4177
34ef135b29fa [project @ 2002-11-13 04:09:53 by jwe]
jwe
parents: 3576
diff changeset
37
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
38 static void
3575
7576a76f6d7b [project @ 2000-02-04 11:02:49 by jwe]
jwe
parents: 3404
diff changeset
39 fatal (const std::string& msg)
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
40 {
3575
7576a76f6d7b [project @ 2000-02-04 11:02:49 by jwe]
jwe
parents: 3404
diff changeset
41 std::cerr << msg << "\n";
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
42 exit (1);
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
43 }
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
44
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
45 static void
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
46 usage (void)
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
47 {
9906
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
48 std::cerr << "usage: munge-texi TOP-SRCDIR DOCSTRING-FILE < file\n";
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
49 exit (1);
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
50 }
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
51
3575
7576a76f6d7b [project @ 2000-02-04 11:02:49 by jwe]
jwe
parents: 3404
diff changeset
52 static std::string
3576
168277402d7c [project @ 2000-02-04 11:09:38 by jwe]
jwe
parents: 3575
diff changeset
53 extract_symbol_name (std::istream& is)
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
54 {
3575
7576a76f6d7b [project @ 2000-02-04 11:02:49 by jwe]
jwe
parents: 3404
diff changeset
55 std::string symbol_name;
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
56
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
57 int c;
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
58 while ((c = is.get ()) != EOF && c != '\n')
10076
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
59 symbol_name += static_cast<char> (c);
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
60
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
61 return symbol_name;
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
62 }
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
63
3575
7576a76f6d7b [project @ 2000-02-04 11:02:49 by jwe]
jwe
parents: 3404
diff changeset
64 static std::string
7576a76f6d7b [project @ 2000-02-04 11:02:49 by jwe]
jwe
parents: 3404
diff changeset
65 extract_docstring (std::istream& is)
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
66 {
3575
7576a76f6d7b [project @ 2000-02-04 11:02:49 by jwe]
jwe
parents: 3404
diff changeset
67 std::string doc;
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
68
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
69 int c;
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
70 while ((c = is.get ()) != EOF && c != doc_delim)
8287
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
71 {
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
72 // Expand @seealso commands to Texinfo references.
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
73 if (c == '@')
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
74 {
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
75 char buf[16];
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
76 int i = 0;
10076
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
77 buf[i++] = static_cast<char> (c);
12254
23385f2c90b7 whitespace fixes
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
78
23385f2c90b7 whitespace fixes
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
79 if (( buf[i++] = static_cast<char> (is.get ())) == 's'
10076
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
80 && (buf[i++] = static_cast<char> (is.get ())) == 'e'
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
81 && (buf[i++] = static_cast<char> (is.get ())) == 'e'
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
82 && (buf[i++] = static_cast<char> (is.get ())) == 'a'
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
83 && (buf[i++] = static_cast<char> (is.get ())) == 'l'
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
84 && (buf[i++] = static_cast<char> (is.get ())) == 's'
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
85 && (buf[i++] = static_cast<char> (is.get ())) == 'o'
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
86 && (buf[i++] = static_cast<char> (is.get ())) == '{')
8287
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
87 {
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
88 doc += "@seealso{";
12254
23385f2c90b7 whitespace fixes
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
89
8287
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
90 bool first = true;
12254
23385f2c90b7 whitespace fixes
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
91
8287
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
92 // process @seealso parameters
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
93 while ((c = is.get ()) != EOF
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
94 && c != doc_delim
12254
23385f2c90b7 whitespace fixes
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
95 && c != '}')
8287
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
96 {
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
97 // ignore whitespace and delimiters
12254
23385f2c90b7 whitespace fixes
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
98 while ( c == ' '
8287
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
99 || c == '\t'
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
100 || c == '\r'
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
101 || c == '\n'
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
102 || c == ',')
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
103 {
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
104 c = is.get ();
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
105 }
12254
23385f2c90b7 whitespace fixes
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
106
8287
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
107 // test for end of @seealso
12254
23385f2c90b7 whitespace fixes
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
108 if (c == '}')
8287
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
109 break;
12254
23385f2c90b7 whitespace fixes
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
110
8287
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
111 // get function name
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
112 std::string function_name;
12254
23385f2c90b7 whitespace fixes
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
113 do
10076
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
114 function_name += static_cast<char> (c);
8287
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
115 while ((c = is.get ()) != EOF
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
116 && c != doc_delim
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
117 && c != ' '
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
118 && c != '\t'
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
119 && c != '\r'
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
120 && c != '\n'
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
121 && c != ','
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
122 && c != '}');
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
123 if (first)
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
124 first = false;
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
125 else
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
126 doc += ", ";
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
127
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
128 if (function_name[0] == '@')
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
129 function_name = "@" + function_name;
9891
1506a17832c9 doc building fixes for class methods
John W. Eaton <jwe@octave.org>
parents: 9794
diff changeset
130
8287
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
131 doc += "@ref{doc-" + function_name + ",,"
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
132 + function_name + "}";
8287
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
133
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
134 // test for end of @seealso
12254
23385f2c90b7 whitespace fixes
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
135 if (c == '}')
8287
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
136 break;
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
137 }
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
138 if (c == '}')
10076
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
139 doc += static_cast<char> (c);
8287
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
140 }
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
141 else
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
142 {
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
143 for (int j = 0; j < i; j++)
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
144 doc += buf[j];
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
145 }
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
146 }
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
147 else
10076
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
148 doc += static_cast<char> (c);
8287
f3dbea0e8a1d Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7048
diff changeset
149 }
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
150 return doc;
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
151 }
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
152
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
153 static void
5334
f9afe97d6d14 [project @ 2005-05-02 18:56:32 by jwe]
jwe
parents: 5307
diff changeset
154 skip_comments (std::ifstream& is)
f9afe97d6d14 [project @ 2005-05-02 18:56:32 by jwe]
jwe
parents: 5307
diff changeset
155 {
f9afe97d6d14 [project @ 2005-05-02 18:56:32 by jwe]
jwe
parents: 5307
diff changeset
156 int c;
f9afe97d6d14 [project @ 2005-05-02 18:56:32 by jwe]
jwe
parents: 5307
diff changeset
157
f9afe97d6d14 [project @ 2005-05-02 18:56:32 by jwe]
jwe
parents: 5307
diff changeset
158 bool in_comment = false;
f9afe97d6d14 [project @ 2005-05-02 18:56:32 by jwe]
jwe
parents: 5307
diff changeset
159
f9afe97d6d14 [project @ 2005-05-02 18:56:32 by jwe]
jwe
parents: 5307
diff changeset
160 while ((c = is.get ()) != EOF)
f9afe97d6d14 [project @ 2005-05-02 18:56:32 by jwe]
jwe
parents: 5307
diff changeset
161 {
f9afe97d6d14 [project @ 2005-05-02 18:56:32 by jwe]
jwe
parents: 5307
diff changeset
162 if (c == '#')
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
163 in_comment = true;
5334
f9afe97d6d14 [project @ 2005-05-02 18:56:32 by jwe]
jwe
parents: 5307
diff changeset
164 else if (c == '\n')
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
165 in_comment = false;
5334
f9afe97d6d14 [project @ 2005-05-02 18:56:32 by jwe]
jwe
parents: 5307
diff changeset
166 else if (! (in_comment || ::isspace (c)))
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
167 {
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
168 is.putback (c);
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
169 break;
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
170 }
5334
f9afe97d6d14 [project @ 2005-05-02 18:56:32 by jwe]
jwe
parents: 5307
diff changeset
171 }
f9afe97d6d14 [project @ 2005-05-02 18:56:32 by jwe]
jwe
parents: 5307
diff changeset
172 }
f9afe97d6d14 [project @ 2005-05-02 18:56:32 by jwe]
jwe
parents: 5307
diff changeset
173
f9afe97d6d14 [project @ 2005-05-02 18:56:32 by jwe]
jwe
parents: 5307
diff changeset
174 static void
3575
7576a76f6d7b [project @ 2000-02-04 11:02:49 by jwe]
jwe
parents: 3404
diff changeset
175 process_doc_file (const std::string& fname)
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
176 {
3575
7576a76f6d7b [project @ 2000-02-04 11:02:49 by jwe]
jwe
parents: 3404
diff changeset
177 std::ifstream infile (fname.c_str ());
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
178
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
179 if (infile)
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
180 {
5334
f9afe97d6d14 [project @ 2005-05-02 18:56:32 by jwe]
jwe
parents: 5307
diff changeset
181 skip_comments (infile);
f9afe97d6d14 [project @ 2005-05-02 18:56:32 by jwe]
jwe
parents: 5307
diff changeset
182
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
183 if (infile.get () != doc_delim)
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
184 fatal ("invalid doc file format");
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
185
3575
7576a76f6d7b [project @ 2000-02-04 11:02:49 by jwe]
jwe
parents: 3404
diff changeset
186 std::string symbol_name;
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
187
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
188 do
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
189 {
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
190 symbol_name = extract_symbol_name (infile);
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
191
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
192 if (! symbol_name.empty ())
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
193 {
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
194 std::string doc_string = extract_docstring (infile);
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
195
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
196 if (help_text.find (symbol_name) != help_text.end ())
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
197 std::cerr << "ignoring duplicate entry for "
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
198 << symbol_name << "\n";
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
199 else
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
200 help_text[symbol_name] = doc_string;
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
201 }
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
202 }
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
203 while (! symbol_name.empty ());
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
204 }
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
205 else
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
206 fatal ("unable to open docfile");
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
207 }
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
208
9906
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
209 static bool
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
210 recover_from_macro (std::ostream& os, char *buf, int i)
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
211 {
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
212 bool bol = false;
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
213
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
214 buf[i] = '\0';
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
215 os << buf;
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
216
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
217 if (buf[i - 1] == '\n')
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
218 bol = true;
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
219
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
220 return bol;
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
221 }
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
222
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
223 static void
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
224 process_example_file (const std::string& file_name, std::ostream& os)
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
225 {
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
226 std::ifstream infile (file_name.c_str ());
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
227
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
228 if (infile)
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
229 {
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
230 os << "@verbatim\n";
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
231
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
232 int c;
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
233 int clast = 0;
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
234
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
235 while ((c = infile.get ()) != EOF)
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
236 {
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
237 os << static_cast<char> (c);
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
238 clast = c;
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
239 }
9906
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
240
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
241 if (clast != '\n')
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
242 os << "\n";
9906
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
243
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
244 os << "@end verbatim\n";
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
245 }
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
246 else
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
247 fatal ("unable to open example file " + file_name);
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
248 }
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
249
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
250 static void
3575
7576a76f6d7b [project @ 2000-02-04 11:02:49 by jwe]
jwe
parents: 3404
diff changeset
251 process_texi_input_file (std::istream& is, std::ostream& os)
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
252 {
3404
c4ba3cada9cb [project @ 2000-01-05 06:45:00 by jwe]
jwe
parents: 3401
diff changeset
253 os << "@c DO NOT EDIT! Generated automatically by munge-texi.\n\n";
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
254
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
255 bool bol = true;
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
256
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
257 int c;
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
258 while ((c = is.get ()) != EOF)
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
259 {
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
260 if (bol)
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
261 {
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
262 if (c == '@')
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
263 {
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
264 char buf[16];
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
265 int i = 0;
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
266 buf[i++] = static_cast<char> (c);
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
267
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
268 buf[i++] = c = static_cast<char> (is.get ());
9906
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
269
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
270 if (c == 'D')
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
271 {
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
272 std::string symbol_name;
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
273
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
274 if ( (buf[i++] = static_cast<char> (is.get ())) == 'O'
10076
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
275 && (buf[i++] = static_cast<char> (is.get ())) == 'C'
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
276 && (buf[i++] = static_cast<char> (is.get ())) == 'S'
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
277 && (buf[i++] = static_cast<char> (is.get ())) == 'T'
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
278 && (buf[i++] = static_cast<char> (is.get ())) == 'R'
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
279 && (buf[i++] = static_cast<char> (is.get ())) == 'I'
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
280 && (buf[i++] = static_cast<char> (is.get ())) == 'N'
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
281 && (buf[i++] = static_cast<char> (is.get ())) == 'G'
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
282 && (buf[i++] = static_cast<char> (is.get ())) == '(')
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
283 {
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
284 while ((c = is.get ()) != EOF && c != ')')
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
285 symbol_name += static_cast<char> (c);
9014
71fca0fc2436 save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
286
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
287 if (is.eof ())
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
288 fatal ("end of file while reading @DOCSTRING command");
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
289 else
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
290 {
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
291 std::string doc_string = help_text[symbol_name];
9014
71fca0fc2436 save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
292
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
293 size_t len = doc_string.length ();
9906
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
294
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
295 int j = 0;
9014
71fca0fc2436 save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
296
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
297 // If there is a leading comment with the file
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
298 // name, copy it to the output.
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
299 if (len > 1
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
300 && doc_string[j] == '@'
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
301 && doc_string[j+1] == 'c')
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
302 {
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
303 j = 2;
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
304 while (doc_string[j++] != '\n')
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
305 /* find eol */;
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3294
diff changeset
306
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
307 os << doc_string.substr (0, j);
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
308 }
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3294
diff changeset
309
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
310 while (doc_string[j] == ' ')
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
311 j++;
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3294
diff changeset
312
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
313 if (doc_string.substr (j, 15) == "-*- texinfo -*-")
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
314 {
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
315 j += 15;
9906
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
316
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
317 while (isspace (doc_string[j]))
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
318 j++;
3401
1b782f9cecfe [project @ 2000-01-05 02:54:11 by jwe]
jwe
parents: 3376
diff changeset
319
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
320 // Make `see also' references in functions
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
321 // possible using @anchor{TAG} (new with
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
322 // Texinfo 4.0).
9906
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
323
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
324 if (symbol_name[0] == '@')
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
325 symbol_name = "@" + symbol_name;
9906
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
326
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
327 os << "@anchor{doc-" << symbol_name << "}\n";
9891
1506a17832c9 doc building fixes for class methods
John W. Eaton <jwe@octave.org>
parents: 9794
diff changeset
328
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
329 os << doc_string.substr (j);
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
330 }
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
331 else
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
332 os << doc_string;
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
333 }
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
334 }
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
335 else
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
336 bol = recover_from_macro (os, buf, i);
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
337 }
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
338 else if (c == 'E')
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
339 {
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
340 std::string file_name;
9906
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
341
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
342 if ( (buf[i++] = static_cast<char> (is.get ())) == 'X'
10076
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
343 && (buf[i++] = static_cast<char> (is.get ())) == 'A'
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
344 && (buf[i++] = static_cast<char> (is.get ())) == 'M'
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
345 && (buf[i++] = static_cast<char> (is.get ())) == 'P'
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
346 && (buf[i++] = static_cast<char> (is.get ())) == 'L'
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
347 && (buf[i++] = static_cast<char> (is.get ())) == 'E'
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
348 && (buf[i++] = static_cast<char> (is.get ())) == 'F'
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
349 && (buf[i++] = static_cast<char> (is.get ())) == 'I'
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
350 && (buf[i++] = static_cast<char> (is.get ())) == 'L'
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
351 && (buf[i++] = static_cast<char> (is.get ())) == 'E'
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
352 && (buf[i++] = static_cast<char> (is.get ())) == '(')
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
353 {
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
354 while ((c = is.get ()) != EOF && c != ')')
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
355 file_name += static_cast<char> (c);
9906
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
356
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
357 file_name = top_srcdir + "/examples/" + file_name;
9906
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
358
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
359 process_example_file (file_name, os);
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
360 }
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
361 else
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
362 bol = recover_from_macro (os, buf, i);
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
363 }
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
364 else
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
365 bol = recover_from_macro (os, buf, i);
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
366 }
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
367 else
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
368 os.put (static_cast<char> (c));
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
369 }
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
370 else
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
371 {
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
372 if (c == '\n')
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
373 bol = true;
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
374
10162
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
375 os.put (static_cast<char> (c));
9f9eb9d2eefd doc/interpreter/munge-texi.cc: untabify and delete emacs local variable settings
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
376 }
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
377 }
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
378 }
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
379
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
380 int
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
381 main (int argc, char **argv)
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
382 {
10076
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
383 int retval = 0;
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
384
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
385 if (argc > 1)
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
386 {
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
387 top_srcdir = *++argv;
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
388
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
389 while (*++argv)
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
390 process_doc_file (*argv);
9906
8d20fb66a0dc more automake fixes
John W. Eaton <jwe@octave.org>
parents: 9891
diff changeset
391
10076
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
392 process_texi_input_file (std::cin, std::cout);
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
393 }
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
394 else
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
395 {
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
396 usage ();
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
397
10076
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
398 retval = 1;
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
399 }
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
400
10076
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
401 return retval;
4b270d1540f7 avoid various GCC warnings
John W. Eaton <jwe@octave.org>
parents: 9906
diff changeset
402
3294
bfe1573bd2ae [project @ 1999-10-19 10:06:07 by jwe]
jwe
parents:
diff changeset
403 }