Mercurial > hg > octave-lyh
comparison scripts/gethelp.cc @ 3575:7576a76f6d7b
[project @ 2000-02-04 11:02:49 by jwe]
author | jwe |
---|---|
date | Fri, 04 Feb 2000 11:02:51 +0000 |
parents | e098ebb77023 |
children | 168277402d7c |
comparison
equal
deleted
inserted
replaced
3574:787bb9d8f60e | 3575:7576a76f6d7b |
---|---|
1 #include <string> | 1 #include <string> |
2 #include <iostream.h> | 2 #include <iostream> |
3 | 3 |
4 #ifndef NPOS | 4 #ifndef NPOS |
5 #define NPOS string::npos | 5 #define NPOS std::string::npos |
6 #endif | 6 #endif |
7 | 7 |
8 static bool | 8 static bool |
9 looks_like_octave_copyright (const string& s) | 9 looks_like_octave_copyright (const std::string& s) |
10 { | 10 { |
11 bool retval = false; | 11 bool retval = false; |
12 | 12 |
13 string t = s.substr (0, 14); | 13 std::string t = s.substr (0, 14); |
14 | 14 |
15 if (t == "Copyright (C) ") | 15 if (t == "Copyright (C) ") |
16 { | 16 { |
17 size_t pos = s.find ('\n'); | 17 size_t pos = s.find ('\n'); |
18 | 18 |
37 } | 37 } |
38 | 38 |
39 // Eat whitespace and comments from FFILE, returning the text of the | 39 // Eat whitespace and comments from FFILE, returning the text of the |
40 // first block of comments that doesn't look like a copyright notice, | 40 // first block of comments that doesn't look like a copyright notice, |
41 | 41 |
42 static string | 42 static std::string |
43 extract_help_text (void) | 43 extract_help_text (void) |
44 { | 44 { |
45 string help_txt; | 45 std::string help_txt; |
46 | 46 |
47 bool first_comments_seen = false; | 47 bool first_comments_seen = false; |
48 bool begin_comment = false; | 48 bool begin_comment = false; |
49 bool have_help_text = false; | 49 bool have_help_text = false; |
50 bool in_comment = false; | 50 bool in_comment = false; |
51 bool discard_space = true; | 51 bool discard_space = true; |
52 int c; | 52 int c; |
53 | 53 |
54 while ((c = cin.get ()) != EOF) | 54 while ((c = std::cin.get ()) != EOF) |
55 { | 55 { |
56 if (begin_comment) | 56 if (begin_comment) |
57 { | 57 { |
58 if (c == '%' || c == '#') | 58 if (c == '%' || c == '#') |
59 continue; | 59 continue; |
77 if (c == '\n') | 77 if (c == '\n') |
78 { | 78 { |
79 in_comment = false; | 79 in_comment = false; |
80 discard_space = true; | 80 discard_space = true; |
81 | 81 |
82 if ((c = cin.get ()) != EOF) | 82 if ((c = std::cin.get ()) != EOF) |
83 { | 83 { |
84 if (c == '\n') | 84 if (c == '\n') |
85 break; | 85 break; |
86 } | 86 } |
87 else | 87 else |
130 } | 130 } |
131 | 131 |
132 int | 132 int |
133 main (int argc, char **argv) | 133 main (int argc, char **argv) |
134 { | 134 { |
135 string name; | 135 std::string name; |
136 | 136 |
137 if (argc != 2) | 137 if (argc != 2) |
138 { | 138 { |
139 cerr << "usage: gethelp name\n"; | 139 std::cerr << "usage: gethelp name\n"; |
140 return 1; | 140 return 1; |
141 } | 141 } |
142 else | 142 else |
143 name = argv[1]; | 143 name = argv[1]; |
144 | 144 |
145 string help_text = extract_help_text (); | 145 std::string help_text = extract_help_text (); |
146 | 146 |
147 if (! help_text.empty ()) | 147 if (! help_text.empty ()) |
148 { | 148 { |
149 cout << "" << name << "\n" << help_text; | 149 cout << "" << name << "\n" << help_text; |
150 | 150 |