1 // This is a slow larval-stage kludge to help massage the generated man
2 // pages. It's used like this:
3 const char* const usage
=
4 "\nTakes on stdin, whitespace-separated words of the form\n"
9 "and writes on stdout the nearest matching standard header name.\n"
11 "Takes no command-line arguments.\n"
18 typedef std::map
<std::string
, std::string
> Map
;
24 // Enter the glamourous world of data entry!! Maintain these!
25 headers
["algo.h"] = "algorithm";
26 headers
["algobase.h"] = "algorithm";
27 headers
["algorithm.h"] = "algorithm";
28 headers
["alloc.h"] = "memory";
29 headers
["basic_ios.h"] = "ios";
30 headers
["basic_ios.tcc"] = "ios";
31 headers
["basic_string.h"] = "string";
32 headers
["basic_string.tcc"] = "string";
33 headers
["bitset.h"] = "bitset";
34 headers
["bvector.h"] = "vector";
35 //headers["char_traits.h"] uhhhhhh
36 headers
["complex.h"] = "complex";
37 //headers["construct.h"] stl_construct.h entirely internal
38 headers
["deque.h"] = "deque";
39 headers
["fstream.h"] = "fstream";
40 headers
["fstream.tcc"] = "fstream";
41 headers
["function.h"] = "functional";
42 headers
["functional.h"] = "functional";
43 headers
["heap.h"] = "algorithm";
44 headers
["iomanip.h"] = "iomanip";
45 headers
["ios.h"] = "ios";
46 headers
["iosfwd.h"] = "iosfwd";
47 headers
["iostream.h"] = "iostream";
48 headers
["istream.h"] = "istream";
49 headers
["istream.tcc"] = "istream";
50 headers
["iterator.h"] = "iterator";
51 headers
["iterator_base_funcs.h"] = "iterator";
52 headers
["iterator_base_types.h"] = "iterator";
53 headers
["limits.h"] = "limits";
54 headers
["list.h"] = "list";
55 headers
["locale.h"] = "locale";
56 headers
["locale_facets.h"] = "locale";
57 headers
["locale_facets.tcc"] = "locale";
58 headers
["map.h"] = "map";
59 headers
["memory.h"] = "memory";
60 headers
["multimap.h"] = "map";
61 headers
["multiset.h"] = "set";
62 headers
["numeric.h"] = "numeric";
63 headers
["ostream.h"] = "ostream";
64 headers
["ostream.tcc"] = "ostream";
65 headers
["pair.h"] = "utility";
66 //headers["pthread_alloc.h"] who knows
67 headers
["queue.h"] = "queue";
68 headers
["raw_storage_iter.h"] = "memory";
69 headers
["relops.h"] = "utility";
70 headers
["set.h"] = "set";
71 headers
["sstream.h"] = "sstream";
72 headers
["sstream.tcc"] = "sstream";
73 headers
["stack.h"] = "stack";
74 headers
["stdexcept.h"] = "stdexcept";
75 headers
["streambuf.h"] = "streambuf";
76 headers
["streambuf.tcc"] = "streambuf";
77 headers
["string.h"] = "string";
78 headers
["tempbuf.h"] = "memory";
79 //headers["threads.h"] who knows
80 headers
["tree.h"] = "backward/tree.h";
81 headers
["uninitialized.h"] = "memory";
82 headers
["utility.h"] = "utility";
83 headers
["valarray.h"] = "valarray";
84 headers
["valarray_array.h"] = "valarray";
85 headers
["valarray_array.tcc"] = "valarray";
86 headers
["valarray_meta.h"] = "valarray";
87 headers
["vector.h"] = "vector";
89 // C wrappers -- probably was an easier way to do these, but oh well
90 headers
["cassert.h"] = "cassert";
91 headers
["cctype.h"] = "cctype";
92 headers
["cerrno.h"] = "cerrno";
93 headers
["cfloat.h"] = "cfloat";
94 headers
["climits.h"] = "climits";
95 headers
["clocale.h"] = "clocale";
96 headers
["cmath.h"] = "cmath";
97 headers
["csetjmp.h"] = "csetjmp";
98 headers
["csignal.h"] = "csignal";
99 headers
["cstdarg.h"] = "cstdarg";
100 headers
["cstddef.h"] = "cstddef";
101 headers
["cstdio.h"] = "cstdio";
102 headers
["cstdlib.h"] = "cstdlib";
103 headers
["cstring.h"] = "cstring";
104 headers
["ctime.h"] = "ctime";
105 headers
["cwchar.h"] = "cwchar";
106 headers
["cwctype.h"] = "cwctype";
110 void do_word (std::string
const& longheader
)
112 std::string::size_type start
= 0;
114 // if it doesn't contain a "." then it's already a std header
115 if (longheader
.find(".") == std::string::npos
)
117 std::cout
<< longheader
<< '\n';
121 if (longheader
.substr(start
,5) == "bits/") start
+= 5;
122 if ((longheader
.substr(start
,4) == "stl_") ||
123 (longheader
.substr(start
,4) == "std_"))
128 // come on, gdb, find `p' already...
129 const char* p
= longheader
.substr(start
).c_str();
130 Map::iterator word
= headers
.find(p
);
131 if (word
!= headers
.end())
132 std::cout
<< word
->second
<< '\n';
133 else std::cout
<< "MAYBE_AN_ERROR_MESSAGE_HERE\n";
137 int main (int argc
, char**)
148 while (std::cin
>> w
)