1*837f574eSEli Friedman#!/usr/bin/env python 2a545f466SDaniel Dunbar 3a545f466SDaniel Dunbarimport os 4a545f466SDaniel Dunbarimport re 5a545f466SDaniel Dunbarimport time 6a545f466SDaniel Dunbarfrom pprint import pprint 7a545f466SDaniel Dunbar 8a545f466SDaniel Dunbar### 9a545f466SDaniel Dunbar 10a545f466SDaniel Dunbarc99URL = 'http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf' 11a545f466SDaniel Dunbarc99TOC = [('Foreword', 'xi'), 12a545f466SDaniel Dunbar('Introduction', 'xiv'), 13a545f466SDaniel Dunbar('1. Scope', '1'), 14a545f466SDaniel Dunbar('2. Normative references', '2'), 15a545f466SDaniel Dunbar('3. Terms, definitions, and symbols', '3'), 16a545f466SDaniel Dunbar('4. Conformance', '7'), 17a545f466SDaniel Dunbar('5. Environment', '9'), 18a545f466SDaniel Dunbar('5.1 Conceptual models', '9'), 19a545f466SDaniel Dunbar('5.1.1 Translation environment', '9'), 20a545f466SDaniel Dunbar('5.1.2 Execution environments', '11'), 21a545f466SDaniel Dunbar('5.2 Environmental considerations', '17'), 22a545f466SDaniel Dunbar('5.2.1 Character sets', '17'), 23a545f466SDaniel Dunbar('5.2.2 Character display semantics', '19'), 24a545f466SDaniel Dunbar('5.2.3 Signals and interrupts', '20'), 25a545f466SDaniel Dunbar('5.2.4 Environmental limits', '20'), 26a545f466SDaniel Dunbar('6. Language', '29'), 27a545f466SDaniel Dunbar('6.1 Notation', '29'), 28a545f466SDaniel Dunbar('6.2 Concepts', '29'), 29a545f466SDaniel Dunbar('6.2.1 Scopes of identifiers', '29'), 30a545f466SDaniel Dunbar('6.2.2 Linkages of identifiers', '30'), 31a545f466SDaniel Dunbar('6.2.3 Name spaces of identifiers', '31'), 32a545f466SDaniel Dunbar('6.2.4 Storage durations of objects', '32'), 33a545f466SDaniel Dunbar('6.2.5 Types', '33'), 34a545f466SDaniel Dunbar('6.2.6 Representations of types', '37'), 35a545f466SDaniel Dunbar('6.2.7 Compatible type and composite type', '40'), 36a545f466SDaniel Dunbar('6.3 Conversions', '42'), 37a545f466SDaniel Dunbar('6.3.1 Arithmetic operands', '42'), 38a545f466SDaniel Dunbar('6.3.2 Other operands', '46'), 39a545f466SDaniel Dunbar('6.4 Lexical elements', '49'), 40a545f466SDaniel Dunbar('6.4.1 Keywords', '50'), 41a545f466SDaniel Dunbar('6.4.2 Identifiers', '51'), 42a545f466SDaniel Dunbar('6.4.3 Universal character names', '53'), 43a545f466SDaniel Dunbar('6.4.4 Constants', '54'), 44a545f466SDaniel Dunbar('6.4.5 String literals', '62'), 45a545f466SDaniel Dunbar('6.4.6 Punctuators', '63'), 46a545f466SDaniel Dunbar('6.4.7 Header names', '64'), 47a545f466SDaniel Dunbar('6.4.8 Preprocessing numbers', '65'), 48a545f466SDaniel Dunbar('6.4.9 Comments', '66'), 49a545f466SDaniel Dunbar('6.5 Expressions', '67'), 50a545f466SDaniel Dunbar('6.5.1 Primary expressions', '69'), 51a545f466SDaniel Dunbar('6.5.2 Postfix operators', '69'), 52a545f466SDaniel Dunbar('6.5.3 Unary operators', '78'), 53a545f466SDaniel Dunbar('6.5.4 Cast operators', '81'), 54a545f466SDaniel Dunbar('6.5.5 Multiplicative operators', '82'), 55a545f466SDaniel Dunbar('6.5.6 Additive operators', '82'), 56a545f466SDaniel Dunbar('6.5.7 Bitwise shift operators', '84'), 57a545f466SDaniel Dunbar('6.5.8 Relational operators', '85'), 58a545f466SDaniel Dunbar('6.5.9 Equality operators', '86'), 59a545f466SDaniel Dunbar('6.5.10 Bitwise AND operator', '87'), 60a545f466SDaniel Dunbar('6.5.11 Bitwise exclusive OR operator', '88'), 61a545f466SDaniel Dunbar('6.5.12 Bitwise inclusive OR operator', '88'), 62a545f466SDaniel Dunbar('6.5.13 Logical AND operator', '89'), 63a545f466SDaniel Dunbar('6.5.14 Logical OR operator', '89'), 64a545f466SDaniel Dunbar('6.5.15 Conditional operator', '90'), 65a545f466SDaniel Dunbar('6.5.16 Assignment operators', '91'), 66a545f466SDaniel Dunbar('6.5.17 Comma operator', '94'), 67a545f466SDaniel Dunbar('6.6 Constant expressions', '95'), 68a545f466SDaniel Dunbar('6.7 Declarations', '97'), 69a545f466SDaniel Dunbar('6.7.1 Storage-class specifiers', '98'), 70a545f466SDaniel Dunbar('6.7.2 Type specifiers', '99'), 71a545f466SDaniel Dunbar('6.7.3 Type qualifiers', '108'), 72a545f466SDaniel Dunbar('6.7.4 Function specifiers', '112'), 73a545f466SDaniel Dunbar('6.7.5 Declarators', '114'), 74a545f466SDaniel Dunbar('6.7.6 Type names', '122'), 75a545f466SDaniel Dunbar('6.7.7 Type definitions', '123'), 76a545f466SDaniel Dunbar('6.7.8 Initialization', '125'), 77a545f466SDaniel Dunbar('6.8 Statements and blocks', '131'), 78a545f466SDaniel Dunbar('6.8.1 Labeled statements', '131'), 79a545f466SDaniel Dunbar('6.8.2 Compound statement', '132'), 80a545f466SDaniel Dunbar('6.8.3 Expression and null statements', '132'), 81a545f466SDaniel Dunbar('6.8.4 Selection statements', '133'), 82a545f466SDaniel Dunbar('6.8.5 Iteration statements', '135'), 83a545f466SDaniel Dunbar('6.8.6 Jump statements', '136'), 84a545f466SDaniel Dunbar('6.9 External definitions', '140'), 85a545f466SDaniel Dunbar('6.9.1 Function definitions', '141'), 86a545f466SDaniel Dunbar('6.9.2 External object definitions', '143'), 87a545f466SDaniel Dunbar('6.10 Preprocessing directives', '145'), 88a545f466SDaniel Dunbar('6.10.1 Conditional inclusion', '147'), 89a545f466SDaniel Dunbar('6.10.2 Source file inclusion', '149'), 90a545f466SDaniel Dunbar('6.10.3 Macro replacement', '151'), 91a545f466SDaniel Dunbar('6.10.4 Line control', '158'), 92a545f466SDaniel Dunbar('6.10.5 Error directive', '159'), 93a545f466SDaniel Dunbar('6.10.6 Pragma directive', '159'), 94a545f466SDaniel Dunbar('6.10.7 Null directive', '160'), 95a545f466SDaniel Dunbar('6.10.8 Predefined macro names', '160'), 96a545f466SDaniel Dunbar('6.10.9 Pragma operator', '161'), 97a545f466SDaniel Dunbar('6.11 Future language directions', '163'), 98a545f466SDaniel Dunbar('6.11.1 Floating types', '163'), 99a545f466SDaniel Dunbar('6.11.2 Linkages of identifiers', '163'), 100a545f466SDaniel Dunbar('6.11.3 External names', '163'), 101a545f466SDaniel Dunbar('6.11.4 Character escape sequences', '163'), 102a545f466SDaniel Dunbar('6.11.5 Storage-class specifiers', '163'), 103a545f466SDaniel Dunbar('6.11.6 Function declarators', '163'), 104a545f466SDaniel Dunbar('6.11.7 Function definitions', '163'), 105a545f466SDaniel Dunbar('6.11.8 Pragma directives', '163'), 106a545f466SDaniel Dunbar('6.11.9 Predefined macro names', '163'), 107a545f466SDaniel Dunbar('7. Library', '164'), 108a545f466SDaniel Dunbar('7.1 Introduction', '164'), 109a545f466SDaniel Dunbar('7.1.1 Definitions of terms', '164'), 110a545f466SDaniel Dunbar('7.1.2 Standard headers', '165'), 111a545f466SDaniel Dunbar('7.1.3 Reserved identifiers', '166'), 112a545f466SDaniel Dunbar('7.1.4 Use of library functions', '166'), 113a545f466SDaniel Dunbar('7.2 Diagnostics <assert.h>', '169'), 114a545f466SDaniel Dunbar('7.2.1 Program diagnostics', '169'), 115a545f466SDaniel Dunbar('7.3 Complex arithmetic <complex.h>', '170'), 116a545f466SDaniel Dunbar('7.3.1 Introduction', '170'), 117a545f466SDaniel Dunbar('7.3.2 Conventions', '170'), 118a545f466SDaniel Dunbar('7.3.3 Branch cuts', '171'), 119a545f466SDaniel Dunbar('7.3.4 The CX_LIMITED_RANGE pragma', '171'), 120a545f466SDaniel Dunbar('7.3.5 Trigonometric functions', '172'), 121a545f466SDaniel Dunbar('7.3.6 Hyperbolic functions', '174'), 122a545f466SDaniel Dunbar('7.3.7 Exponential and logarithmic functions', '176'), 123a545f466SDaniel Dunbar('7.3.8 Power and absolute-value functions', '177'), 124a545f466SDaniel Dunbar('7.3.9 Manipulation functions', '178'), 125a545f466SDaniel Dunbar('7.4 Character handling <ctype.h>', '181'), 126a545f466SDaniel Dunbar('7.4.1 Character classification functions', '181'), 127a545f466SDaniel Dunbar('7.4.2 Character case mapping functions', '184'), 128a545f466SDaniel Dunbar('7.5 Errors <errno.h>', '186'), 129a545f466SDaniel Dunbar('7.6 Floating-point environment <fenv.h>', '187'), 130a545f466SDaniel Dunbar('7.6.1 The FENV_ACCESS pragma', '189'), 131a545f466SDaniel Dunbar('7.6.2 Floating-point exceptions', '190'), 132a545f466SDaniel Dunbar('7.6.3 Rounding', '193'), 133a545f466SDaniel Dunbar('7.6.4 Environment', '194'), 134a545f466SDaniel Dunbar('7.7 Characteristics of floating types <float.h>', '197'), 135a545f466SDaniel Dunbar('7.8 Format conversion of integer types <inttypes.h>', '198'), 136a545f466SDaniel Dunbar('7.8.1 Macros for format specifiers', '198'), 137a545f466SDaniel Dunbar('7.8.2 Functions for greatest-width integer types', '199'), 138a545f466SDaniel Dunbar('7.9 Alternative spellings <iso646.h>', '202'), 139a545f466SDaniel Dunbar('7.10 Sizes of integer types <limits.h>', '203'), 140a545f466SDaniel Dunbar('7.11 Localization <locale.h>', '204'), 141a545f466SDaniel Dunbar('7.11.1 Locale control', '205'), 142a545f466SDaniel Dunbar('7.11.2 Numeric formatting convention inquiry', '206'), 143a545f466SDaniel Dunbar('7.12 Mathematics <math.h>', '212'), 144a545f466SDaniel Dunbar('7.12.1 Treatment of error conditions', '214'), 145a545f466SDaniel Dunbar('7.12.2 The FP_CONTRACT pragma', '215'), 146a545f466SDaniel Dunbar('7.12.3 Classification macros', '216'), 147a545f466SDaniel Dunbar('7.12.4 Trigonometric functions', '218'), 148a545f466SDaniel Dunbar('7.12.5 Hyperbolic functions', '221'), 149a545f466SDaniel Dunbar('7.12.6 Exponential and logarithmic functions', '223'), 150a545f466SDaniel Dunbar('7.12.7 Power and absolute-value functions', '228'), 151a545f466SDaniel Dunbar('7.12.8 Error and gamma functions', '230'), 152a545f466SDaniel Dunbar('7.12.9 Nearest integer functions', '231'), 153a545f466SDaniel Dunbar('7.12.10 Remainder functions', '235'), 154a545f466SDaniel Dunbar('7.12.11 Manipulation functions', '236'), 155a545f466SDaniel Dunbar('7.12.12 Maximum, minimum, and positive difference functions', '238'), 156a545f466SDaniel Dunbar('7.12.13 Floating multiply-add', '239'), 157a545f466SDaniel Dunbar('7.12.14 Comparison macros', '240'), 158a545f466SDaniel Dunbar('7.13 Nonlocal jumps <setjmp.h>', '243'), 159a545f466SDaniel Dunbar('7.13.1 Save calling environment', '243'), 160a545f466SDaniel Dunbar('7.13.2 Restore calling environment', '244'), 161a545f466SDaniel Dunbar('7.14 Signal handling <signal.h>', '246'), 162a545f466SDaniel Dunbar('7.14.1 Specify signal handling', '247'), 163a545f466SDaniel Dunbar('7.14.2 Send signal', '248'), 164a545f466SDaniel Dunbar('7.15 Variable arguments <stdarg.h>', '249'), 165a545f466SDaniel Dunbar('7.15.1 Variable argument list access macros', '249'), 166a545f466SDaniel Dunbar('7.16 Boolean type and values <stdbool.h>', '253'), 167a545f466SDaniel Dunbar('7.17 Common definitions <stddef.h>', '254'), 168a545f466SDaniel Dunbar('7.18 Integer types <stdint.h>', '255'), 169a545f466SDaniel Dunbar('7.18.1 Integer types', '255'), 170a545f466SDaniel Dunbar('7.18.2 Limits of specified-width integer types', '257'), 171a545f466SDaniel Dunbar('7.18.3 Limits of other integer types', '259'), 172a545f466SDaniel Dunbar('7.18.4 Macros for integer constants', '260'), 173a545f466SDaniel Dunbar('7.19 Input/output <stdio.h>', '262'), 174a545f466SDaniel Dunbar('7.19.1 Introduction', '262'), 175a545f466SDaniel Dunbar('7.19.2 Streams', '264'), 176a545f466SDaniel Dunbar('7.19.3 Files', '266'), 177a545f466SDaniel Dunbar('7.19.4 Operations on files', '268'), 178a545f466SDaniel Dunbar('7.19.5 File access functions', '270'), 179a545f466SDaniel Dunbar('7.19.6 Formatted input/output functions', '274'), 180a545f466SDaniel Dunbar('7.19.7 Character input/output functions', '296'), 181a545f466SDaniel Dunbar('7.19.8 Direct input/output functions', '301'), 182a545f466SDaniel Dunbar('7.19.9 File positioning functions', '302'), 183a545f466SDaniel Dunbar('7.19.10 Error-handling functions', '304'), 184a545f466SDaniel Dunbar('7.20 General utilities <stdlib.h>', '306'), 185a545f466SDaniel Dunbar('7.20.1 Numeric conversion functions', '307'), 186a545f466SDaniel Dunbar('7.20.2 Pseudo-random sequence generation functions', '312'), 187a545f466SDaniel Dunbar('7.20.3 Memory management functions', '313'), 188a545f466SDaniel Dunbar('7.20.4 Communication with the environment', '315'), 189a545f466SDaniel Dunbar('7.20.5 Searching and sorting utilities', '318'), 190a545f466SDaniel Dunbar('7.20.6 Integer arithmetic functions', '320'), 191a545f466SDaniel Dunbar('7.20.7 Multibyte/wide character conversion functions', '321'), 192a545f466SDaniel Dunbar('7.20.8 Multibyte/wide string conversion functions', '323'), 193a545f466SDaniel Dunbar('7.21 String handling <string.h>', '325'), 194a545f466SDaniel Dunbar('7.21.1 String function conventions', '325'), 195a545f466SDaniel Dunbar('7.21.2 Copying functions', '325'), 196a545f466SDaniel Dunbar('7.21.3 Concatenation functions', '327'), 197a545f466SDaniel Dunbar('7.21.4 Comparison functions', '328'), 198a545f466SDaniel Dunbar('7.21.5 Search functions', '330'), 199a545f466SDaniel Dunbar('7.21.6 Miscellaneous functions', '333'), 200a545f466SDaniel Dunbar('7.22 Type-generic math <tgmath.h>', '335'), 201a545f466SDaniel Dunbar('7.23 Date and time <time.h>', '338'), 202a545f466SDaniel Dunbar('7.23.1 Components of time', '338'), 203a545f466SDaniel Dunbar('7.23.2 Time manipulation functions', '339'), 204a545f466SDaniel Dunbar('7.23.3 Time conversion functions', '341'), 205a545f466SDaniel Dunbar('7.24 Extended multibyte and wide character utilities <wchar.h>', '348'), 206a545f466SDaniel Dunbar('7.24.1 Introduction', '348'), 207a545f466SDaniel Dunbar('7.24.2 Formatted wide character input/output functions', '349'), 208a545f466SDaniel Dunbar('7.24.3 Wide character input/output functions', '367'), 209a545f466SDaniel Dunbar('7.24.4 General wide string utilities', '371'), 210a545f466SDaniel Dunbar('7.24.5 Wide character time conversion functions', '385'), 211a545f466SDaniel Dunbar('7.24.6 Extended multibyte/wide character conversion utilities', '386'), 212a545f466SDaniel Dunbar('7.25 Wide character classification and mapping utilities <wctype.h>', 213a545f466SDaniel Dunbar '393'), 214a545f466SDaniel Dunbar('7.25.1 Introduction', '393'), 215a545f466SDaniel Dunbar('7.25.2 Wide character classification utilities', '394'), 216a545f466SDaniel Dunbar('7.25.3 Wide character case mapping utilities', '399'), 217a545f466SDaniel Dunbar('7.26 Future library directions', '401'), 218a545f466SDaniel Dunbar('7.26.1 Complex arithmetic <complex.h>', '401'), 219a545f466SDaniel Dunbar('7.26.2 Character handling <ctype.h>', '401'), 220a545f466SDaniel Dunbar('7.26.3 Errors <errno.h>', '401'), 221a545f466SDaniel Dunbar('7.26.4 Format conversion of integer types <inttypes.h>', '401'), 222a545f466SDaniel Dunbar('7.26.5 Localization <locale.h>', '401'), 223a545f466SDaniel Dunbar('7.26.6 Signal handling <signal.h>', '401'), 224a545f466SDaniel Dunbar('7.26.7 Boolean type and values <stdbool.h>', '401'), 225a545f466SDaniel Dunbar('7.26.8 Integer types <stdint.h>', '401'), 226a545f466SDaniel Dunbar('7.26.9 Input/output <stdio.h>', '402'), 227a545f466SDaniel Dunbar('7.26.10 General utilities <stdlib.h>', '402'), 228a545f466SDaniel Dunbar('7.26.11 String handling <string.h>', '402'), 229a545f466SDaniel Dunbar('<wchar.h>', '402'), 230a545f466SDaniel Dunbar('<wctype.h>', '402'), 231a545f466SDaniel Dunbar('Annex A (informative) Language syntax summary', '403'), 232a545f466SDaniel Dunbar('A.1 Lexical grammar', '403'), 233a545f466SDaniel Dunbar('A.2 Phrase structure grammar', '409'), 234a545f466SDaniel Dunbar('A.3 Preprocessing directives', '416'), 235a545f466SDaniel Dunbar('Annex B (informative) Library summary', '418'), 236a545f466SDaniel Dunbar('B.1 Diagnostics <assert.h>', '418'), 237a545f466SDaniel Dunbar('B.2 Complex <complex.h>', '418'), 238a545f466SDaniel Dunbar('B.3 Character handling <ctype.h>', '420'), 239a545f466SDaniel Dunbar('B.4 Errors <errno.h>', '420'), 240a545f466SDaniel Dunbar('B.5 Floating-point environment <fenv.h>', '420'), 241a545f466SDaniel Dunbar('B.6 Characteristics of floating types <float.h>', '421'), 242a545f466SDaniel Dunbar('B.7 Format conversion of integer types <inttypes.h>', '421'), 243a545f466SDaniel Dunbar('B.8 Alternative spellings <iso646.h>', '422'), 244a545f466SDaniel Dunbar('B.9 Sizes of integer types <limits.h>', '422'), 245a545f466SDaniel Dunbar('B.10 Localization <locale.h>', '422'), 246a545f466SDaniel Dunbar('B.11 Mathematics <math.h>', '422'), 247a545f466SDaniel Dunbar('B.12 Nonlocal jumps <setjmp.h>', '427'), 248a545f466SDaniel Dunbar('B.13 Signal handling <signal.h>', '427'), 249a545f466SDaniel Dunbar('B.14 Variable arguments <stdarg.h>', '427'), 250a545f466SDaniel Dunbar('B.15 Boolean type and values <stdbool.h>', '427'), 251a545f466SDaniel Dunbar('B.16 Common definitions <stddef.h>', '428'), 252a545f466SDaniel Dunbar('B.17 Integer types <stdint.h>', '428'), 253a545f466SDaniel Dunbar('B.18 Input/output <stdio.h>', '428'), 254a545f466SDaniel Dunbar('B.19 General utilities <stdlib.h>', '430'), 255a545f466SDaniel Dunbar('B.20 String handling <string.h>', '432'), 256a545f466SDaniel Dunbar('B.21 Type-generic math <tgmath.h>', '433'), 257a545f466SDaniel Dunbar('B.22 Date and time <time.h>', '433'), 258a545f466SDaniel Dunbar('B.23 Extended multibyte/wide character utilities <wchar.h>', '434'), 259a545f466SDaniel Dunbar('B.24 Wide character classification and mapping utilities <wctype.h>', 260a545f466SDaniel Dunbar '436'), 261a545f466SDaniel Dunbar('Annex C (informative) Sequence points', '438'), 262a545f466SDaniel Dunbar('Annex D (normative) Universal character names for identifiers', '439'), 263a545f466SDaniel Dunbar('Annex E (informative) Implementation limits', '441'), 264a545f466SDaniel Dunbar('Annex F (normative) IEC 60559 floating-point arithmetic', '443'), 265a545f466SDaniel Dunbar('F.1 Introduction', '443'), 266a545f466SDaniel Dunbar('F.2 Types', '443'), 267a545f466SDaniel Dunbar('F.3 Operators and functions', '444'), 268a545f466SDaniel Dunbar('F.4 Floating to integer conversion', '446'), 269a545f466SDaniel Dunbar('F.5 Binary-decimal conversion', '446'), 270a545f466SDaniel Dunbar('F.6 Contracted expressions', '447'), 271a545f466SDaniel Dunbar('F.7 Floating-point environment', '447'), 272a545f466SDaniel Dunbar('F.8 Optimization', '450'), 273a545f466SDaniel Dunbar('F.9 Mathematics <math.h>', '453'), 274a545f466SDaniel Dunbar('Annex G (informative) IEC 60559-compatible complex arithmetic', '466'), 275a545f466SDaniel Dunbar('G.1 Introduction', '466'), 276a545f466SDaniel Dunbar('G.2 Types', '466'), 277a545f466SDaniel Dunbar('G.3 Conventions', '466'), 278a545f466SDaniel Dunbar('G.4 Conversions', '467'), 279a545f466SDaniel Dunbar('G.5 Binary operators', '467'), 280a545f466SDaniel Dunbar('G.6 Complex arithmetic <complex.h>', '471'), 281a545f466SDaniel Dunbar('G.7 Type-generic math <tgmath.h>', '479'), 282a545f466SDaniel Dunbar('Annex H (informative) Language independent arithmetic', '480'), 283a545f466SDaniel Dunbar('H.1 Introduction', '480'), 284a545f466SDaniel Dunbar('H.2 Types', '480'), 285a545f466SDaniel Dunbar('H.3 Notification', '484'), 286a545f466SDaniel Dunbar('Annex I (informative) Common warnings', '486'), 287a545f466SDaniel Dunbar('Annex J (informative) Portability issues', '488'), 288a545f466SDaniel Dunbar('J.1 Unspecified behavior', '488'), 289a545f466SDaniel Dunbar('J.2 Undefined behavior', '491'), 290a545f466SDaniel Dunbar('J.3 Implementation-defined behavior', '504'), 291a545f466SDaniel Dunbar('J.4 Locale-specific behavior', '511'), 292a545f466SDaniel Dunbar('J.5 Common extensions', '512'), 293a545f466SDaniel Dunbar('Bibliography', '515'), 294a545f466SDaniel Dunbar('Index', '517')] 295a545f466SDaniel Dunbar 296be12fd1fSDaniel DunbarcXXURL = 'http://open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2723.pdf' 297be12fd1fSDaniel DunbarcXXTOC = [('Contents', 'ii'), 298be12fd1fSDaniel Dunbar('List of Tables', 'ix'), 299be12fd1fSDaniel Dunbar('1 General', '1'), 300be12fd1fSDaniel Dunbar('1.1 Scope', '1'), 301be12fd1fSDaniel Dunbar('1.2 Normative references', '1'), 302be12fd1fSDaniel Dunbar('1.3 Definitions', '2'), 303be12fd1fSDaniel Dunbar('1.4 Implementation compliance', '4'), 304be12fd1fSDaniel Dunbar('1.5 Structure of this International Standard', '5'), 305be12fd1fSDaniel Dunbar('1.6 Syntax notation', '5'), 306be12fd1fSDaniel Dunbar('1.7 The C++ memory model', '6'), 307be12fd1fSDaniel Dunbar('1.8 The C++ object model', '6'), 308be12fd1fSDaniel Dunbar('1.9 Program execution', '7'), 309be12fd1fSDaniel Dunbar('1.10 Multi-threaded executions and data races', '10'), 310be12fd1fSDaniel Dunbar('1.11 Acknowledgments', '13'), 311be12fd1fSDaniel Dunbar('2 Lexical conventions', '15'), 312be12fd1fSDaniel Dunbar('2.1 Phases of translation', '15'), 313be12fd1fSDaniel Dunbar('2.2 Character sets', '16'), 314be12fd1fSDaniel Dunbar('2.3 Trigraph sequences', '17'), 315be12fd1fSDaniel Dunbar('2.4 Preprocessing tokens', '17'), 316be12fd1fSDaniel Dunbar('2.5 Alternative tokens', '18'), 317be12fd1fSDaniel Dunbar('2.6 Tokens', '19'), 318be12fd1fSDaniel Dunbar('2.7 Comments', '19'), 319be12fd1fSDaniel Dunbar('2.8 Header names', '19'), 320be12fd1fSDaniel Dunbar('2.9 Preprocessing numbers', '20'), 321be12fd1fSDaniel Dunbar('2.10 Identifiers', '20'), 322be12fd1fSDaniel Dunbar('2.11 Keywords', '20'), 323be12fd1fSDaniel Dunbar('2.12 Operators and punctuators', '21'), 324be12fd1fSDaniel Dunbar('2.13 Literals', '21'), 325be12fd1fSDaniel Dunbar('3 Basic concepts', '29'), 326be12fd1fSDaniel Dunbar('3.1 Declarations and definitions', '29'), 327be12fd1fSDaniel Dunbar('3.2 One definition rule', '31'), 328be12fd1fSDaniel Dunbar('3.3 Declarative regions and scopes', '33'), 329be12fd1fSDaniel Dunbar('3.4 Name lookup', '38'), 330be12fd1fSDaniel Dunbar('3.5 Program and linkage', '51'), 331be12fd1fSDaniel Dunbar('3.6 Start and termination', '54'), 332be12fd1fSDaniel Dunbar('3.7 Storage duration', '58'), 333be12fd1fSDaniel Dunbar('3.8 Object Lifetime', '62'), 334be12fd1fSDaniel Dunbar('3.9 Types', '65'), 335be12fd1fSDaniel Dunbar('3.10 Lvalues and rvalues', '70'), 336be12fd1fSDaniel Dunbar('3.11 Alignment', '72'), 337be12fd1fSDaniel Dunbar('4 Standard conversions', '73'), 338be12fd1fSDaniel Dunbar('4.1 Lvalue-to-rvalue conversion', '74'), 339be12fd1fSDaniel Dunbar('4.2 Array-to-pointer conversion', '74'), 340be12fd1fSDaniel Dunbar('4.3 Function-to-pointer conversion', '74'), 341be12fd1fSDaniel Dunbar('4.4 Qualification conversions', '74'), 342be12fd1fSDaniel Dunbar('4.5 Integral promotions', '75'), 343be12fd1fSDaniel Dunbar('4.6 Floating point promotion', '76'), 344be12fd1fSDaniel Dunbar('4.7 Integral conversions', '76'), 345be12fd1fSDaniel Dunbar('4.8 Floating point conversions', '76'), 346be12fd1fSDaniel Dunbar('4.9 Floating-integral conversions', '77'), 347be12fd1fSDaniel Dunbar('4.10 Pointer conversions', '77'), 348be12fd1fSDaniel Dunbar('4.11 Pointer to member conversions', '77'), 349be12fd1fSDaniel Dunbar('4.12 Boolean conversions', '78'), 350be12fd1fSDaniel Dunbar('4.13 Integer conversion rank', '78'), 351be12fd1fSDaniel Dunbar('5 Expressions', '79'), 352be12fd1fSDaniel Dunbar('5.1 Primary expressions', '80'), 353be12fd1fSDaniel Dunbar('5.2 Postfix expressions', '85'), 354be12fd1fSDaniel Dunbar('5.3 Unary expressions', '96'), 355be12fd1fSDaniel Dunbar('5.4 Explicit type conversion (cast notation)', '104'), 356be12fd1fSDaniel Dunbar('5.5 Pointer-to-member operators', '105'), 357be12fd1fSDaniel Dunbar('5.6 Multiplicative operators', '106'), 358be12fd1fSDaniel Dunbar('5.7 Additive operators', '106'), 359be12fd1fSDaniel Dunbar('5.8 Shift operators', '107'), 360be12fd1fSDaniel Dunbar('5.9 Relational operators', '108'), 361be12fd1fSDaniel Dunbar('5.10 Equality operators', '109'), 362be12fd1fSDaniel Dunbar('5.11 Bitwise AND operator', '110'), 363be12fd1fSDaniel Dunbar('5.12 Bitwise exclusive OR operator', '110'), 364be12fd1fSDaniel Dunbar('5.13 Bitwise inclusive OR operator', '110'), 365be12fd1fSDaniel Dunbar('5.14 Logical AND operator', '110'), 366be12fd1fSDaniel Dunbar('5.15 Logical OR operator', '110'), 367be12fd1fSDaniel Dunbar('5.16 Conditional operator', '111'), 368be12fd1fSDaniel Dunbar('5.17 Assignment and compound assignment operators', '112'), 369be12fd1fSDaniel Dunbar('5.18 Comma operator', '113'), 370be12fd1fSDaniel Dunbar('5.19 Constant expressions', '113'), 371be12fd1fSDaniel Dunbar('6 Statements', '116'), 372be12fd1fSDaniel Dunbar('6.1 Labeled statement', '116'), 373be12fd1fSDaniel Dunbar('6.2 Expression statement', '116'), 374be12fd1fSDaniel Dunbar('6.3 Compound statement or block', '116'), 375be12fd1fSDaniel Dunbar('6.4 Selection statements', '117'), 376be12fd1fSDaniel Dunbar('6.5 Iteration statements', '118'), 377be12fd1fSDaniel Dunbar('6.6 Jump statements', '121'), 378be12fd1fSDaniel Dunbar('6.7 Declaration statement', '122'), 379be12fd1fSDaniel Dunbar('6.8 Ambiguity resolution', '123'), 380be12fd1fSDaniel Dunbar('7 Declarations', '125'), 381be12fd1fSDaniel Dunbar('7.1 Specifiers', '126'), 382be12fd1fSDaniel Dunbar('7.2 Enumeration declarations', '140'), 383be12fd1fSDaniel Dunbar('7.3 Namespaces', '143'), 384be12fd1fSDaniel Dunbar('7.4 The asm declaration', '156'), 385be12fd1fSDaniel Dunbar('7.5 Linkage specifications', '156'), 386be12fd1fSDaniel Dunbar('8 Declarators', '160'), 387be12fd1fSDaniel Dunbar('8.1 Type names', '161'), 388be12fd1fSDaniel Dunbar('8.2 Ambiguity resolution', '161'), 389be12fd1fSDaniel Dunbar('8.3 Meaning of declarators', '163'), 390be12fd1fSDaniel Dunbar('8.4 Function definitions', '175'), 391be12fd1fSDaniel Dunbar('8.5 Initializers', '177'), 392be12fd1fSDaniel Dunbar('9 Classes', '191'), 393be12fd1fSDaniel Dunbar('9.1 Class names', '193'), 394be12fd1fSDaniel Dunbar('9.2 Class members', '194'), 395be12fd1fSDaniel Dunbar('9.3 Member functions', '197'), 396be12fd1fSDaniel Dunbar('9.4 Static members', '200'), 397be12fd1fSDaniel Dunbar('9.5 Unions', '202'), 398be12fd1fSDaniel Dunbar('9.6 Bit-fields', '203'), 399be12fd1fSDaniel Dunbar('9.7 Nested class declarations', '204'), 400be12fd1fSDaniel Dunbar('9.8 Local class declarations', '205'), 401be12fd1fSDaniel Dunbar('9.9 Nested type names', '206'), 402be12fd1fSDaniel Dunbar('10 Derived classes', '207'), 403be12fd1fSDaniel Dunbar('10.1 Multiple base classes', '208'), 404be12fd1fSDaniel Dunbar('10.2 Member name lookup', '210'), 405be12fd1fSDaniel Dunbar('10.3 Virtual functions', '213'), 406be12fd1fSDaniel Dunbar('10.4 Abstract classes', '217'), 407be12fd1fSDaniel Dunbar('11 Member access control', '219'), 408be12fd1fSDaniel Dunbar('11.1 Access specifiers', '221'), 409be12fd1fSDaniel Dunbar('11.2 Accessibility of base classes and base class members', '222'), 410be12fd1fSDaniel Dunbar('11.3 Access declarations', '224'), 411be12fd1fSDaniel Dunbar('11.4 Friends', '225'), 412be12fd1fSDaniel Dunbar('11.5 Protected member access', '228'), 413be12fd1fSDaniel Dunbar('11.6 Access to virtual functions', '229'), 414be12fd1fSDaniel Dunbar('11.7 Multiple access', '230'), 415be12fd1fSDaniel Dunbar('11.8 Nested classes', '230'), 416be12fd1fSDaniel Dunbar('12 Special member functions', '231'), 417be12fd1fSDaniel Dunbar('12.1 Constructors', '231'), 418be12fd1fSDaniel Dunbar('12.2 Temporary objects', '233'), 419be12fd1fSDaniel Dunbar('12.3 Conversions', '235'), 420be12fd1fSDaniel Dunbar('12.4 Destructors', '238'), 421be12fd1fSDaniel Dunbar('12.5 Free store', '240'), 422be12fd1fSDaniel Dunbar('12.6 Initialization', '242'), 423be12fd1fSDaniel Dunbar('12.7 Construction and destruction', '247'), 424be12fd1fSDaniel Dunbar('12.8 Copying class objects', '250'), 425be12fd1fSDaniel Dunbar('12.9 Inheriting Constructors', '255'), 426be12fd1fSDaniel Dunbar('13 Overloading', '259'), 427be12fd1fSDaniel Dunbar('13.1 Overloadable declarations', '259'), 428be12fd1fSDaniel Dunbar('13.2 Declaration matching', '261'), 429be12fd1fSDaniel Dunbar('13.3 Overload resolution', '262'), 430be12fd1fSDaniel Dunbar('13.4 Address of overloaded function', '281'), 431be12fd1fSDaniel Dunbar('13.5 Overloaded operators', '282'), 432be12fd1fSDaniel Dunbar('13.6 Built-in operators', '286'), 433be12fd1fSDaniel Dunbar('14 Templates', '290'), 434be12fd1fSDaniel Dunbar('14.1 Template parameters', '291'), 435be12fd1fSDaniel Dunbar('14.2 Names of template specializations', '294'), 436be12fd1fSDaniel Dunbar('14.3 Template arguments', '296'), 437be12fd1fSDaniel Dunbar('14.4 Type equivalence', '302'), 438be12fd1fSDaniel Dunbar('14.5 Template declarations', '303'), 439be12fd1fSDaniel Dunbar('14.6 Name resolution', '318'), 440be12fd1fSDaniel Dunbar('14.7 Template instantiation and specialization', '331'), 441be12fd1fSDaniel Dunbar('14.8 Function template specializations', '343'), 442be12fd1fSDaniel Dunbar('15 Exception handling', '363'), 443be12fd1fSDaniel Dunbar('15.1 Throwing an exception', '364'), 444be12fd1fSDaniel Dunbar('15.2 Constructors and destructors', '366'), 445be12fd1fSDaniel Dunbar('15.3 Handling an exception', '366'), 446be12fd1fSDaniel Dunbar('15.4 Exception specifications', '368'), 447be12fd1fSDaniel Dunbar('15.5 Special functions', '371'), 448be12fd1fSDaniel Dunbar('15.6 Exceptions and access', '372'), 449be12fd1fSDaniel Dunbar('16 Preprocessing directives', '373'), 450be12fd1fSDaniel Dunbar('16.1 Conditional inclusion', '375'), 451be12fd1fSDaniel Dunbar('16.2 Source file inclusion', '376'), 452be12fd1fSDaniel Dunbar('16.3 Macro replacement', '377'), 453be12fd1fSDaniel Dunbar('16.4 Line control', '382'), 454be12fd1fSDaniel Dunbar('16.5 Error directive', '383'), 455be12fd1fSDaniel Dunbar('16.6 Pragma directive', '383'), 456be12fd1fSDaniel Dunbar('16.7 Null directive', '383'), 457be12fd1fSDaniel Dunbar('16.8 Predefined macro names', '383'), 458be12fd1fSDaniel Dunbar('16.9 Pragma operator', '384'), 459be12fd1fSDaniel Dunbar('17 Library introduction', '386'), 460be12fd1fSDaniel Dunbar('17.1 General', '386'), 461be12fd1fSDaniel Dunbar('17.2 Overview', '386'), 462be12fd1fSDaniel Dunbar('17.3 Definitions', '386'), 463be12fd1fSDaniel Dunbar('17.4 Additional definitions', '390'), 464be12fd1fSDaniel Dunbar('17.5 Method of description (Informative)', '390'), 465be12fd1fSDaniel Dunbar('17.6 Library-wide requirements', '396'), 466be12fd1fSDaniel Dunbar('18 Language support library', '407'), 467be12fd1fSDaniel Dunbar('18.1 Types', '407'), 468be12fd1fSDaniel Dunbar('18.2 Implementation properties', '408'), 469be12fd1fSDaniel Dunbar('18.3 Integer types', '417'), 470be12fd1fSDaniel Dunbar('18.4 Start and termination', '418'), 471be12fd1fSDaniel Dunbar('18.5 Dynamic memory management', '420'), 472be12fd1fSDaniel Dunbar('18.6 Type identification', '424'), 473be12fd1fSDaniel Dunbar('18.7 Exception handling', '427'), 474be12fd1fSDaniel Dunbar('18.8 Initializer lists', '432'), 475be12fd1fSDaniel Dunbar('18.9 Other runtime support', '434'), 476be12fd1fSDaniel Dunbar('19 Diagnostics library', '435'), 477be12fd1fSDaniel Dunbar('19.1 Exception classes', '435'), 478be12fd1fSDaniel Dunbar('19.2 Assertions', '439'), 479be12fd1fSDaniel Dunbar('19.3 Error numbers', '440'), 480be12fd1fSDaniel Dunbar('19.4 System error support', '440'), 481be12fd1fSDaniel Dunbar('20 General utilities library', '452'), 482be12fd1fSDaniel Dunbar('20.1 Requirements', '452'), 483be12fd1fSDaniel Dunbar('20.2 Utility components', '457'), 484be12fd1fSDaniel Dunbar('20.3 Compile-time rational arithmetic', '463'), 485be12fd1fSDaniel Dunbar('20.4 Tuples', '465'), 486be12fd1fSDaniel Dunbar('20.5 Metaprogramming and type traits', '473'), 487be12fd1fSDaniel Dunbar('20.6 Function objects', '486'), 488be12fd1fSDaniel Dunbar('20.7 Memory', '509'), 489be12fd1fSDaniel Dunbar('20.8 Time utilities', '548'), 490be12fd1fSDaniel Dunbar('20.9 Date and time functions', '562'), 491be12fd1fSDaniel Dunbar('21 Strings library', '563'), 492be12fd1fSDaniel Dunbar('21.1 Character traits', '563'), 493be12fd1fSDaniel Dunbar('21.2 String classes', '569'), 494be12fd1fSDaniel Dunbar('21.3 Class template basic_string', '572'), 495be12fd1fSDaniel Dunbar('21.4 Numeric Conversions', '599'), 496be12fd1fSDaniel Dunbar('21.5 Null-terminated sequence utilities', '600'), 497be12fd1fSDaniel Dunbar('22 Localization library', '604'), 498be12fd1fSDaniel Dunbar('22.1 Locales', '604'), 499be12fd1fSDaniel Dunbar('22.2 Standard locale categories', '617'), 500be12fd1fSDaniel Dunbar('22.3 Standard code conversion facets', '657'), 501be12fd1fSDaniel Dunbar('22.4 C Library Locales', '659'), 502be12fd1fSDaniel Dunbar('23 Containers library', '660'), 503be12fd1fSDaniel Dunbar('23.1 Container requirements', '660'), 504be12fd1fSDaniel Dunbar('23.2 Sequence containers', '681'), 505be12fd1fSDaniel Dunbar('23.3 Associative containers', '719'), 506be12fd1fSDaniel Dunbar('23.4 Unordered associative containers', '744'), 507be12fd1fSDaniel Dunbar('24 Iterators library', '759'), 508be12fd1fSDaniel Dunbar('24.1 Iterator requirements', '759'), 509be12fd1fSDaniel Dunbar('24.2 Header <iterator> synopsis', '764'), 510be12fd1fSDaniel Dunbar('24.3 Iterator primitives', '767'), 511be12fd1fSDaniel Dunbar('24.4 Predefined iterators', '770'), 512be12fd1fSDaniel Dunbar('24.5 Stream iterators', '784'), 513be12fd1fSDaniel Dunbar('25 Algorithms library', '792'), 514be12fd1fSDaniel Dunbar('25.1 Non-modifying sequence operations', '802'), 515be12fd1fSDaniel Dunbar('25.2 Mutating sequence operations', '806'), 516be12fd1fSDaniel Dunbar('25.3 Sorting and related operations', '815'), 517be12fd1fSDaniel Dunbar('25.4 C library algorithms', '829'), 518be12fd1fSDaniel Dunbar('26 Numerics library', '831'), 519be12fd1fSDaniel Dunbar('26.1 Numeric type requirements', '831'), 520be12fd1fSDaniel Dunbar('26.2 The floating-point environment', '832'), 521be12fd1fSDaniel Dunbar('26.3 Complex numbers', '833'), 522be12fd1fSDaniel Dunbar('26.4 Random number generation', '842'), 523be12fd1fSDaniel Dunbar('26.5 Numeric arrays', '884'), 524be12fd1fSDaniel Dunbar('26.6 Generalized numeric operations', '904'), 525be12fd1fSDaniel Dunbar('26.7 C Library', '907'), 526be12fd1fSDaniel Dunbar('27 Input/output library', '912'), 527be12fd1fSDaniel Dunbar('27.1 Iostreams requirements', '912'), 528be12fd1fSDaniel Dunbar('27.2 Forward declarations', '912'), 529be12fd1fSDaniel Dunbar('27.3 Standard iostream objects', '915'), 530be12fd1fSDaniel Dunbar('27.4 Iostreams base classes', '916'), 531be12fd1fSDaniel Dunbar('27.5 Stream buffers', '934'), 532be12fd1fSDaniel Dunbar('27.6 Formatting and manipulators', '944'), 533be12fd1fSDaniel Dunbar('27.7 String-based streams', '972'), 534be12fd1fSDaniel Dunbar('27.8 File-based streams', '984'), 535be12fd1fSDaniel Dunbar('28 Regular expressions library', '1000'), 536be12fd1fSDaniel Dunbar('28.1 Definitions', '1000'), 537be12fd1fSDaniel Dunbar('28.2 Requirements', '1000'), 538be12fd1fSDaniel Dunbar('28.3 Regular expressions summary', '1002'), 539be12fd1fSDaniel Dunbar('28.4 Header <regex> synopsis', '1003'), 540be12fd1fSDaniel Dunbar('28.5 Namespace std::regex_constants', '1009'), 541be12fd1fSDaniel Dunbar('28.6 Class regex_error', '1012'), 542be12fd1fSDaniel Dunbar('28.7 Class template regex_traits', '1012'), 543be12fd1fSDaniel Dunbar('28.8 Class template basic_regex', '1015'), 544be12fd1fSDaniel Dunbar('28.9 Class template sub_match', '1020'), 545be12fd1fSDaniel Dunbar('28.10Class template match_results', '1025'), 546be12fd1fSDaniel Dunbar('28.11Regular expression algorithms', '1029'), 547be12fd1fSDaniel Dunbar('28.12Regular expression Iterators', '1033'), 548be12fd1fSDaniel Dunbar('28.13Modified ECMAScript regular expression grammar', '1039'), 549be12fd1fSDaniel Dunbar('29 Atomic operations library', '1042'), 550be12fd1fSDaniel Dunbar('29.1 Order and Consistency', '1044'), 551be12fd1fSDaniel Dunbar('29.2 Lock-free Property', '1046'), 552be12fd1fSDaniel Dunbar('29.3 Atomic Types', '1046'), 553be12fd1fSDaniel Dunbar('29.4 Operations on Atomic Types', '1051'), 554be12fd1fSDaniel Dunbar('29.5 Flag Type and Operations', '1054'), 555be12fd1fSDaniel Dunbar('30 Thread support library', '1057'), 556be12fd1fSDaniel Dunbar('30.1 Requirements', '1057'), 557be12fd1fSDaniel Dunbar('30.2 Threads', '1058'), 558be12fd1fSDaniel Dunbar('30.3 Mutual exclusion', '1063'), 559be12fd1fSDaniel Dunbar('30.4 Condition variables', '1077'), 560be12fd1fSDaniel Dunbar('A Grammar summary', '1085'), 561be12fd1fSDaniel Dunbar('A.1 Keywords', '1085'), 562be12fd1fSDaniel Dunbar('A.2 Lexical conventions', '1085'), 563be12fd1fSDaniel Dunbar('A.3 Basic concepts', '1089'), 564be12fd1fSDaniel Dunbar('A.4 Expressions', '1090'), 565be12fd1fSDaniel Dunbar('A.5 Statements', '1093'), 566be12fd1fSDaniel Dunbar('A.6 Declarations', '1094'), 567be12fd1fSDaniel Dunbar('A.7 Declarators', '1097'), 568be12fd1fSDaniel Dunbar('A.8 Classes', '1098'), 569be12fd1fSDaniel Dunbar('A.9 Derived classes', '1099'), 570be12fd1fSDaniel Dunbar('A.10 Special member functions', '1099'), 571be12fd1fSDaniel Dunbar('A.11 Overloading', '1100'), 572be12fd1fSDaniel Dunbar('A.12 Templates', '1100'), 573be12fd1fSDaniel Dunbar('A.13 Exception handling', '1101'), 574be12fd1fSDaniel Dunbar('A.14 Preprocessing directives', '1101'), 575be12fd1fSDaniel Dunbar('B Implementation quantities', '1103'), 576be12fd1fSDaniel Dunbar('C Compatibility', '1105'), 577be12fd1fSDaniel Dunbar('C.1 C++ and ISO C', '1105'), 578be12fd1fSDaniel Dunbar('C.2 Standard C library', '1114'), 579be12fd1fSDaniel Dunbar('D Compatibility features', '1119'), 580be12fd1fSDaniel Dunbar('D.1 Increment operator with bool operand', '1119'), 581be12fd1fSDaniel Dunbar('D.2 static keyword', '1119'), 582be12fd1fSDaniel Dunbar('D.3 Access declarations', '1119'), 583be12fd1fSDaniel Dunbar('D.4 Implicit conversion from const strings', '1119'), 584be12fd1fSDaniel Dunbar('D.5 C standard library headers', '1119'), 585be12fd1fSDaniel Dunbar('D.6 Old iostreams members', '1120'), 586be12fd1fSDaniel Dunbar('D.7 char* streams', '1121'), 587be12fd1fSDaniel Dunbar('D.8 Binders', '1130'), 588be12fd1fSDaniel Dunbar('D.9 auto_ptr', '1132'), 589be12fd1fSDaniel Dunbar('E Universal-character-names', '1135'), 590be12fd1fSDaniel Dunbar('F Cross references', '1137'), 591be12fd1fSDaniel Dunbar('Index', '1153')] 592be12fd1fSDaniel Dunbar 593a545f466SDaniel DunbarkDocuments = { 594be12fd1fSDaniel Dunbar 'C99' : (c99URL, c99TOC, 12), 595be12fd1fSDaniel Dunbar 'C++' : (cXXURL, cXXTOC, 12), 596a545f466SDaniel Dunbar} 597a545f466SDaniel Dunbar 598a545f466SDaniel Dunbardef findClosestTOCEntry(data, target): 59971978163SDaniel Dunbar # FIXME: Fix for named spec references 60071978163SDaniel Dunbar if isinstance(target[0],str): 60171978163SDaniel Dunbar return ('.'.join(target),'<named>',1) 60271978163SDaniel Dunbar 603a545f466SDaniel Dunbar offset = data[2] 604a545f466SDaniel Dunbar best = None 605a545f466SDaniel Dunbar for (name,page) in data[1]: 606a545f466SDaniel Dunbar if ' ' in name: 607a545f466SDaniel Dunbar section,name = name.split(' ',1) 608a545f466SDaniel Dunbar if section == 'Annex': 609a545f466SDaniel Dunbar section,name = name.split(' ',1) 610a545f466SDaniel Dunbar section = 'Annex '+section 611a545f466SDaniel Dunbar else: 612a545f466SDaniel Dunbar section = None 613a545f466SDaniel Dunbar try: 614a545f466SDaniel Dunbar page = int(page) + offset 615a545f466SDaniel Dunbar except: 616a545f466SDaniel Dunbar page = 1 617a545f466SDaniel Dunbar try: 618a545f466SDaniel Dunbar spec = SpecIndex.fromstring(section) 619a545f466SDaniel Dunbar except: 620a545f466SDaniel Dunbar spec = None 621a545f466SDaniel Dunbar 622a545f466SDaniel Dunbar # Meh, could be better... 623a545f466SDaniel Dunbar if spec is not None: 624a545f466SDaniel Dunbar dist = spec - target 625a545f466SDaniel Dunbar if best is None or dist < best[0]: 626a545f466SDaniel Dunbar best = (dist, (section, name, page)) 627a545f466SDaniel Dunbar return best[1] 628a545f466SDaniel Dunbar 629a545f466SDaniel Dunbar# What a hack. Slow to boot. 630a545f466SDaniel DunbardoxyLineRefRE = re.compile(r"<a name=\"l([0-9]+)\"></a>") 631a545f466SDaniel Dunbardef findClosestLineReference(clangRoot, doxyName, target): 632a545f466SDaniel Dunbar try: 633a545f466SDaniel Dunbar f = open(os.path.join(clangRoot, 'docs', 'doxygen', 'html', doxyName)) 634a545f466SDaniel Dunbar except: 635a545f466SDaniel Dunbar return None 636a545f466SDaniel Dunbar 637a545f466SDaniel Dunbar best = None 638a545f466SDaniel Dunbar for m in doxyLineRefRE.finditer(f.read()): 639a545f466SDaniel Dunbar line = int(m.group(1), 10) 640a545f466SDaniel Dunbar dist = abs(line - target) 641a545f466SDaniel Dunbar if best is None or dist < best[0]: 642a545f466SDaniel Dunbar best = (dist,'l'+m.group(1)) 643a545f466SDaniel Dunbar f.close() 644a545f466SDaniel Dunbar if best is not None: 645a545f466SDaniel Dunbar return best[1] 646a545f466SDaniel Dunbar return None 647a545f466SDaniel Dunbar 648a545f466SDaniel Dunbar### 649a545f466SDaniel Dunbar 65071978163SDaniel DunbarnameAndSpecRefRE = re.compile(r"(C99|C90|C\+\+|H\&S) ((([0-9]+)(\.[0-9]+)*|\[[^]]+\])(p[0-9]+)?)") 651a545f466SDaniel DunbarloneSpecRefRE = re.compile(r" (([0-9]+)(\.[0-9]+){2,100}(p[0-9]+)?)") 652a545f466SDaniel Dunbardef scanFile(path, filename): 653a545f466SDaniel Dunbar try: 654a545f466SDaniel Dunbar f = open(path) 655a545f466SDaniel Dunbar except IOError: 656a545f466SDaniel Dunbar print >>sys.stderr,'WARNING: Unable to open:',path 657a545f466SDaniel Dunbar return 658a545f466SDaniel Dunbar 659a545f466SDaniel Dunbar for i,ln in enumerate(f): 660a545f466SDaniel Dunbar ignore = set() 661a545f466SDaniel Dunbar for m in nameAndSpecRefRE.finditer(ln): 662a545f466SDaniel Dunbar section = m.group(2) 663a545f466SDaniel Dunbar name = m.group(1) 664a545f466SDaniel Dunbar if section.endswith('.'): 665a545f466SDaniel Dunbar section = section[:-1] 666a545f466SDaniel Dunbar yield RefItem(name, section, filename, path, i+1) 667a545f466SDaniel Dunbar ignore.add(section) 668a545f466SDaniel Dunbar for m in loneSpecRefRE.finditer(ln): 669a545f466SDaniel Dunbar section = m.group(1) 670a545f466SDaniel Dunbar if section.endswith('.'): 671a545f466SDaniel Dunbar section = section[:-1] 672a545f466SDaniel Dunbar if section not in ignore: 673a545f466SDaniel Dunbar yield RefItem(None, section, filename, path, i+1) 674a545f466SDaniel Dunbar 675a545f466SDaniel Dunbar### 676a545f466SDaniel Dunbar 677a545f466SDaniel Dunbarclass SpecIndex: 678a545f466SDaniel Dunbar @staticmethod 679a545f466SDaniel Dunbar def fromstring(str): 68071978163SDaniel Dunbar # Check for named sections 68171978163SDaniel Dunbar if str[0] == '[': 68271978163SDaniel Dunbar assert ']' in str 68371978163SDaniel Dunbar secs = str[1:str.index(']')].split('.') 68471978163SDaniel Dunbar tail = str[str.index(']')+1:] 68571978163SDaniel Dunbar if tail: 68671978163SDaniel Dunbar assert tail[0] == 'p' 68771978163SDaniel Dunbar paragraph = int(tail[1:]) 68871978163SDaniel Dunbar else: 68971978163SDaniel Dunbar paragraph = None 69071978163SDaniel Dunbar indices = secs 69171978163SDaniel Dunbar else: 692a545f466SDaniel Dunbar secs = str.split('.') 693a545f466SDaniel Dunbar paragraph = None 694a545f466SDaniel Dunbar if 'p' in secs[-1]: 695a545f466SDaniel Dunbar secs[-1],p = secs[-1].split('p',1) 696a545f466SDaniel Dunbar paragraph = int(p) 697a545f466SDaniel Dunbar indices = map(int, secs) 698a545f466SDaniel Dunbar return SpecIndex(indices, paragraph) 699a545f466SDaniel Dunbar 700a545f466SDaniel Dunbar def __init__(self, indices, paragraph=None): 701a545f466SDaniel Dunbar assert len(indices)>0 702a545f466SDaniel Dunbar self.indices = tuple(indices) 703a545f466SDaniel Dunbar self.paragraph = paragraph 704a545f466SDaniel Dunbar 705a545f466SDaniel Dunbar def __str__(self): 706a545f466SDaniel Dunbar s = '.'.join(map(str,self.indices)) 707a545f466SDaniel Dunbar if self.paragraph is not None: 708a545f466SDaniel Dunbar s += '.p%d'%(self.paragraph,) 709a545f466SDaniel Dunbar return s 710a545f466SDaniel Dunbar 711a545f466SDaniel Dunbar def __repr__(self): 712a545f466SDaniel Dunbar return 'SpecIndex(%s, %s)'%(self.indices, self.paragraph) 713a545f466SDaniel Dunbar 714a545f466SDaniel Dunbar def __cmp__(self, b): 715a545f466SDaniel Dunbar return cmp((self.indices,self.paragraph), 716a545f466SDaniel Dunbar (b.indices,b.paragraph)) 717a545f466SDaniel Dunbar 718a545f466SDaniel Dunbar def __hash__(self): 719a545f466SDaniel Dunbar return hash((self.indices,self.paragraph)) 720a545f466SDaniel Dunbar 721a545f466SDaniel Dunbar def __sub__(self, indices): 722a545f466SDaniel Dunbar def sub(a,b): 723a545f466SDaniel Dunbar a = a or 0 724a545f466SDaniel Dunbar b = b or 0 725a545f466SDaniel Dunbar return abs(a-b) 726a545f466SDaniel Dunbar return map(sub,self.indices,indices) 727a545f466SDaniel Dunbar 728a545f466SDaniel Dunbarclass RefItem: 729a545f466SDaniel Dunbar def __init__(self, name, section, filename, path, line): 730a545f466SDaniel Dunbar self.name = name 731a545f466SDaniel Dunbar self.section = SpecIndex.fromstring(section) 732a545f466SDaniel Dunbar self.filename = filename 733a545f466SDaniel Dunbar self.path = path 734a545f466SDaniel Dunbar self.line = line 735a545f466SDaniel Dunbar 736a545f466SDaniel Dunbar def __str__(self): 737a545f466SDaniel Dunbar if self.name is not None: 738a545f466SDaniel Dunbar return '%s %s'%(self.name, self.section) 739a545f466SDaniel Dunbar else: 740a545f466SDaniel Dunbar return '--- %s'%(self.section,) 741a545f466SDaniel Dunbar 742a545f466SDaniel Dunbar def __repr__(self): 743a545f466SDaniel Dunbar return 'RefItem(%s, %r, "%s", "%s", %d)'%(self.name, 744a545f466SDaniel Dunbar self.section, 745a545f466SDaniel Dunbar self.filename, 746a545f466SDaniel Dunbar self.path, 747a545f466SDaniel Dunbar self.line) 748a545f466SDaniel Dunbar 749a545f466SDaniel Dunbar def __cmp__(self, b): 750a545f466SDaniel Dunbar return cmp((self.name,self.section,self.filename,self.path,self.line), 751a545f466SDaniel Dunbar (b.name,b.section,self.filename,self.path,self.line)) 752a545f466SDaniel Dunbar 753a545f466SDaniel Dunbar def __hash__(self): 754a545f466SDaniel Dunbar return hash((self.name,self.section,self.filename,self.path,self.line)) 755a545f466SDaniel Dunbar 756a545f466SDaniel Dunbar### 757a545f466SDaniel Dunbar 758a545f466SDaniel Dunbardef sorted(l): 759a545f466SDaniel Dunbar l = list(l) 760a545f466SDaniel Dunbar l.sort() 761a545f466SDaniel Dunbar return l 762a545f466SDaniel Dunbar 763a545f466SDaniel Dunbardef getRevision(path): 76421783652SDaniel Dunbar import subprocess 76521783652SDaniel Dunbar p = subprocess.Popen(['svn', 'info', path], 76621783652SDaniel Dunbar stdin=open('/dev/null','r'), 76721783652SDaniel Dunbar stdout=subprocess.PIPE) 76821783652SDaniel Dunbar for ln in p.stdout.read(1024).split('\n'): 76921783652SDaniel Dunbar if ln.startswith('Revision:'): 77021783652SDaniel Dunbar return ln.split(':',1)[1].strip() 77121783652SDaniel Dunbar return None 772a545f466SDaniel Dunbar 773a545f466SDaniel Dunbardef buildRefTree(references): 774a545f466SDaniel Dunbar root = (None, {}, []) 775a545f466SDaniel Dunbar 776a545f466SDaniel Dunbar def getNode(keys): 777a545f466SDaniel Dunbar if not keys: 778a545f466SDaniel Dunbar return root 779a545f466SDaniel Dunbar key,parent = keys[-1],getNode(keys[:-1]) 780a545f466SDaniel Dunbar node = parent[1].get(key) 781a545f466SDaniel Dunbar if node is None: 782a545f466SDaniel Dunbar parent[1][key] = node = (key, {}, []) 783a545f466SDaniel Dunbar return node 784a545f466SDaniel Dunbar 785a545f466SDaniel Dunbar for ref in references: 786a545f466SDaniel Dunbar n = getNode((ref.name,) + ref.section.indices) 787a545f466SDaniel Dunbar n[2].append(ref) 788a545f466SDaniel Dunbar 789a545f466SDaniel Dunbar def flatten((key, children, data)): 790a545f466SDaniel Dunbar children = sorted(map(flatten,children.values())) 791a545f466SDaniel Dunbar return (key, children, sorted(data)) 792a545f466SDaniel Dunbar 793a545f466SDaniel Dunbar return flatten(root) 794a545f466SDaniel Dunbar 795a545f466SDaniel Dunbardef preorder(node,parents=(),first=True): 796a545f466SDaniel Dunbar (key,children,data) = node 797a545f466SDaniel Dunbar if first: 798a545f466SDaniel Dunbar yield parents+(node,) 799a545f466SDaniel Dunbar for c in children: 800a545f466SDaniel Dunbar for item in preorder(c, parents+(node,)): 801a545f466SDaniel Dunbar yield item 802a545f466SDaniel Dunbar 803a545f466SDaniel Dunbardef main(): 804a545f466SDaniel Dunbar global options 805a545f466SDaniel Dunbar from optparse import OptionParser 806a545f466SDaniel Dunbar parser = OptionParser("usage: %prog [options] CLANG_ROOT <output-dir>") 80771978163SDaniel Dunbar parser.add_option("", "--debug", dest="debug", 80871978163SDaniel Dunbar help="Print extra debugging output", 80971978163SDaniel Dunbar action="store_true", 81071978163SDaniel Dunbar default=False) 81171978163SDaniel Dunbar (opts, args) = parser.parse_args() 812a545f466SDaniel Dunbar 813a545f466SDaniel Dunbar if len(args) != 2: 814a545f466SDaniel Dunbar parser.error("incorrect number of arguments") 815a545f466SDaniel Dunbar 816a545f466SDaniel Dunbar references = [] 817a545f466SDaniel Dunbar root,outputDir = args 81871978163SDaniel Dunbar if os.path.isdir(root): 819a545f466SDaniel Dunbar for (dirpath, dirnames, filenames) in os.walk(root): 820a545f466SDaniel Dunbar for filename in filenames: 821a545f466SDaniel Dunbar name,ext = os.path.splitext(filename) 822a545f466SDaniel Dunbar if ext in ('.c', '.cpp', '.h', '.def'): 823a545f466SDaniel Dunbar fullpath = os.path.join(dirpath, filename) 824a545f466SDaniel Dunbar references.extend(list(scanFile(fullpath, filename))) 82571978163SDaniel Dunbar else: 82671978163SDaniel Dunbar references.extend(list(scanFile(root, root))) 827a545f466SDaniel Dunbar 828a545f466SDaniel Dunbar refTree = buildRefTree(references) 829a545f466SDaniel Dunbar 830a545f466SDaniel Dunbar specs = {} 831a545f466SDaniel Dunbar for ref in references: 832a545f466SDaniel Dunbar spec = specs[ref.name] = specs.get(ref.name,{}) 833a545f466SDaniel Dunbar items = spec[ref.section] = spec.get(ref.section,[]) 834a545f466SDaniel Dunbar items.append(ref) 835a545f466SDaniel Dunbar 836a545f466SDaniel Dunbar print 'Found %d references.'%(len(references),) 837a545f466SDaniel Dunbar 83871978163SDaniel Dunbar if opts.debug: 83971978163SDaniel Dunbar pprint(refTree) 84071978163SDaniel Dunbar 841a545f466SDaniel Dunbar referencesPath = os.path.join(outputDir,'references.html') 842a545f466SDaniel Dunbar print 'Writing: %s'%(referencesPath,) 843a545f466SDaniel Dunbar f = open(referencesPath,'w') 844a545f466SDaniel Dunbar print >>f, '<html><head><title>clang: Specification References</title></head>' 845a545f466SDaniel Dunbar print >>f, '<body>' 846a545f466SDaniel Dunbar print >>f, '\t<h2>Specification References</h2>' 847a545f466SDaniel Dunbar for i,node in enumerate(refTree[1]): 848a545f466SDaniel Dunbar specName = node[0] or 'Unknown' 849a545f466SDaniel Dunbar print >>f, '<a href="#spec%d">%s</a><br>'%(i,specName) 850a545f466SDaniel Dunbar for i,node in enumerate(refTree[1]): 851a545f466SDaniel Dunbar specName = node[0] or 'Unknown' 852a545f466SDaniel Dunbar print >>f, '<hr>' 853a545f466SDaniel Dunbar print >>f, '<a name="spec%d">'%(i,) 854a545f466SDaniel Dunbar print >>f, '<h3>Document: %s</h3>'%(specName or 'Unknown',) 855a545f466SDaniel Dunbar print >>f, '<table border="1" cellspacing="2" width="80%">' 856a545f466SDaniel Dunbar print >>f, '<tr><th width="20%">Name</th><th>References</th></tr>' 857a545f466SDaniel Dunbar docData = kDocuments.get(specName) 858a545f466SDaniel Dunbar for path in preorder(node,first=False): 859a545f466SDaniel Dunbar if not path[-1][2]: 860a545f466SDaniel Dunbar continue 861a545f466SDaniel Dunbar components = '.'.join([str(p[0]) for p in path[1:]]) 862a545f466SDaniel Dunbar print >>f, '\t<tr>' 863a545f466SDaniel Dunbar tocEntry = None 864a545f466SDaniel Dunbar if docData is not None: 865a545f466SDaniel Dunbar tocEntry = findClosestTOCEntry(docData, [p[0] for p in path[1:]]) 866a545f466SDaniel Dunbar if tocEntry is not None: 867a545f466SDaniel Dunbar section,name,page = tocEntry 868a545f466SDaniel Dunbar # If section is exact print the TOC name 869a545f466SDaniel Dunbar if page is not None: 870a545f466SDaniel Dunbar linkStr = '<a href="%s#page=%d">%s</a> (pg.%d)'%(docData[0],page,components,page) 871a545f466SDaniel Dunbar else: 872a545f466SDaniel Dunbar linkStr = components 873a545f466SDaniel Dunbar if section == components: 874a545f466SDaniel Dunbar print >>f, '\t\t<td valign=top>%s<br>%s</td>'%(linkStr,name) 875a545f466SDaniel Dunbar else: 876a545f466SDaniel Dunbar print >>f, '\t\t<td valign=top>%s</td>'%(linkStr,) 877a545f466SDaniel Dunbar else: 878a545f466SDaniel Dunbar print >>f, '\t\t<td valign=top>%s</td>'%(components,) 879a545f466SDaniel Dunbar print >>f, '\t\t<td valign=top>' 880a545f466SDaniel Dunbar for item in path[-1][2]: 881a545f466SDaniel Dunbar # XXX total hack 882a545f466SDaniel Dunbar relativePath = item.path[len(root):] 883a545f466SDaniel Dunbar if relativePath.startswith('/'): 884a545f466SDaniel Dunbar relativePath = relativePath[1:] 885a545f466SDaniel Dunbar # XXX this is broken, how does doxygen mangle w/ multiple 886a545f466SDaniel Dunbar # refs? Can we just read its map? 887a545f466SDaniel Dunbar filename = os.path.basename(relativePath) 888a545f466SDaniel Dunbar doxyName = '%s-source.html'%(filename.replace('.','_8'),) 889a545f466SDaniel Dunbar # Grrr, why can't doxygen write line number references. 890a545f466SDaniel Dunbar lineReference = findClosestLineReference(root,doxyName,item.line) 891a545f466SDaniel Dunbar if lineReference is not None: 892a545f466SDaniel Dunbar linkStr = 'http://clang.llvm.org/doxygen/%s#%s'%(doxyName,lineReference) 893a545f466SDaniel Dunbar else: 894a545f466SDaniel Dunbar linkStr = 'http://clang.llvm.org/doxygen/%s'%(doxyName,) 895a545f466SDaniel Dunbar if item.section.paragraph is not None: 896a545f466SDaniel Dunbar paraText = ' (p%d)'%(item.section.paragraph,) 897a545f466SDaniel Dunbar else: 898a545f466SDaniel Dunbar paraText = '' 899a545f466SDaniel Dunbar print >>f,'<a href="%s">%s:%d</a>%s<br>'%(linkStr,relativePath,item.line,paraText) 900a545f466SDaniel Dunbar print >>f, '\t\t</td>' 901a545f466SDaniel Dunbar print >>f, '\t</tr>' 902a545f466SDaniel Dunbar print >>f, '</table>' 903a545f466SDaniel Dunbar print >>f, '<hr>' 904a545f466SDaniel Dunbar print >>f, 'Generated: %s<br>'%(time.strftime('%Y-%m-%d %H:%M'),) 905a545f466SDaniel Dunbar print >>f, 'SVN Revision: %s'%(getRevision(root),) 906a545f466SDaniel Dunbar print >>f, '</body>' 907a545f466SDaniel Dunbar f.close() 908a545f466SDaniel Dunbar 909a545f466SDaniel Dunbarif __name__=='__main__': 910a545f466SDaniel Dunbar main() 911