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"
19 typedef std::map
<std::string
, std::string
> Map
;
25 // Enter the glamourous world of data entry!! Maintain these!
26 headers
["algo.h"] = "algorithm";
27 headers
["algobase.h"] = "algorithm";
28 headers
["algorithm.h"] = "algorithm";
29 headers
["heap.h"] = "algorithm";
30 headers
["bitset.h"] = "bitset";
31 headers
["complex.h"] = "complex";
32 //headers["construct.h"] stl_construct.h entirely internal
33 headers
["deque.h"] = "deque";
34 headers
["deque.tcc"] = "deque";
35 headers
["fstream.h"] = "fstream";
36 headers
["fstream.tcc"] = "fstream";
37 headers
["function.h"] = "functional";
38 headers
["functional.h"] = "functional";
39 headers
["iomanip.h"] = "iomanip";
40 headers
["basic_ios.h"] = "ios";
41 headers
["basic_ios.tcc"] = "ios";
42 headers
["ios.h"] = "ios";
43 headers
["iosfwd.h"] = "iosfwd";
44 headers
["iostream.h"] = "iostream";
45 headers
["istream.h"] = "istream";
46 headers
["istream.tcc"] = "istream";
47 headers
["iterator.h"] = "iterator";
48 headers
["iterator_base_funcs.h"] = "iterator";
49 headers
["iterator_base_types.h"] = "iterator";
50 headers
["stream_iterator.h"] = "iterator";
51 headers
["streambuf_iterator.h"] = "iterator";
52 headers
["limits.h"] = "limits";
53 headers
["list.h"] = "list";
54 headers
["list.tcc"] = "list";
55 headers
["codecvt.h"] = "locale";
56 headers
["locale.h"] = "locale";
57 headers
["localefwd.h"] = "locale";
58 headers
["locale_classes.h"] = "locale";
59 headers
["locale_facets.h"] = "locale";
60 headers
["locale_facets.tcc"] = "locale";
61 headers
["map.h"] = "map";
62 headers
["multimap.h"] = "map";
63 headers
["memory.h"] = "memory";
64 headers
["allocator.h"] = "memory";
65 headers
["raw_storage_iter.h"] = "memory";
66 headers
["tempbuf.h"] = "memory";
67 headers
["uninitialized.h"] = "memory";
68 headers
["numeric.h"] = "numeric";
69 headers
["ostream.h"] = "ostream";
70 headers
["ostream.tcc"] = "ostream";
71 headers
["queue.h"] = "queue";
72 headers
["set.h"] = "set";
73 headers
["multiset.h"] = "set";
74 headers
["sstream.h"] = "sstream";
75 headers
["sstream.tcc"] = "sstream";
76 headers
["stack.h"] = "stack";
77 headers
["functexcept.h"] = "stdexcept";
78 headers
["stdexcept.h"] = "stdexcept";
79 headers
["streambuf.h"] = "streambuf";
80 headers
["streambuf.tcc"] = "streambuf";
81 headers
["string.h"] = "string";
82 headers
["char_traits.h"] = "string";
83 headers
["postypes.h"] = "string";
84 headers
["basic_string.h"] = "string";
85 headers
["basic_string.tcc"] = "string";
86 headers
["tree.h"] = "backward/tree.h";
87 headers
["pair.h"] = "utility";
88 headers
["utility.h"] = "utility";
89 headers
["relops.h"] = "utility";
90 headers
["gslice.h"] = "valarray";
91 headers
["gslice_array.h"] = "valarray";
92 headers
["indirect_array.h"] = "valarray";
93 headers
["mask_array.h"] = "valarray";
94 headers
["slice_array.h"] = "valarray";
95 headers
["valarray.h"] = "valarray";
96 headers
["valarray_after.h"] = "valarray";
97 headers
["valarray_before.h"] = "valarray";
98 headers
["valarray_array.h"] = "valarray";
99 headers
["valarray_array.tcc"] = "valarray";
100 headers
["valarray_meta.h"] = "valarray";
101 headers
["bvector.h"] = "vector";
102 headers
["vector.h"] = "vector";
103 headers
["vector.tcc"] = "vector";
105 //headers["concurrence.h"] who knows
106 //headers["atomicity.h"] who knows
108 // C wrappers -- probably was an easier way to do these, but oh well
109 headers
["cassert.h"] = "cassert";
110 headers
["cctype.h"] = "cctype";
111 headers
["cerrno.h"] = "cerrno";
112 headers
["cfloat.h"] = "cfloat";
113 headers
["climits.h"] = "climits";
114 headers
["clocale.h"] = "clocale";
115 headers
["cmath.h"] = "cmath";
116 headers
["csetjmp.h"] = "csetjmp";
117 headers
["csignal.h"] = "csignal";
118 headers
["cstdarg.h"] = "cstdarg";
119 headers
["cstddef.h"] = "cstddef";
120 headers
["cstdio.h"] = "cstdio";
121 headers
["cstdlib.h"] = "cstdlib";
122 headers
["cstring.h"] = "cstring";
123 headers
["ctime.h"] = "ctime";
124 headers
["cwchar.h"] = "cwchar";
125 headers
["cwctype.h"] = "cwctype";
129 void do_word (std::string
const& longheader
)
131 std::string::size_type start
= 0;
133 // if it doesn't contain a "." then it's already a std header
134 if (longheader
.find(".") == std::string::npos
)
136 std::cout
<< longheader
<< '\n';
140 if (longheader
.substr(start
,5) == "bits/") start
+= 5;
141 if ((longheader
.substr(start
,4) == "stl_") ||
142 (longheader
.substr(start
,4) == "std_"))
147 // come on, gdb, find `p' already...
148 const char* p
= longheader
.substr(start
).c_str();
149 Map::iterator word
= headers
.find(p
);
150 if (word
!= headers
.end())
151 std::cout
<< word
->second
<< '\n';
152 else std::cout
<< "MAYBE_AN_ERROR_MESSAGE_HERE\n";
156 int main (int argc
, char**)
167 while (std::cin
>> w
)