home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / qtawk / ansicstd.exp < prev    next >
Text File  |  1990-04-23  |  4KB  |  167 lines

  1. # QTAwk program to scan C source files for keywords defined in the ANSI C
  2. # standard keywords:
  3. # macro or function names defined in the standard
  4. # types or constants defined in the standard
  5. #
  6. # program to illustrate GROUP pattern keyword
  7. #
  8. # input: C source file
  9. # output: all lines containing ANSI C standard defined keywords
  10. #
  11. # use 'GROUP' pattern keyword to form one large GROUP of patterns to speed
  12. # search. Only two actions defined:
  13. #   1) action to print macro or function names
  14. #   2) action to print types or constants
  15. #
  16. #
  17. BEGIN {
  18.     #
  19.     # ANSI C key words
  20.     #
  21.     # expression for leader
  22.     ldr = /(^|{_w})/;
  23.     # opening function parenthesis - look-ahead to find
  24.     o_p = /@{_w}*\(/;
  25. }
  26.     #
  27.     #
  28.     # Following are macro or functions names as defined by ANSI C standard
  29.     #
  30.     # 1
  31. GROUP /{ldr}assert{o_p}/
  32.     # 2
  33. GROUP /{ldr}is(al(num|pha)|cntrl|x?digit|graph|lower|p(rint|unct)|space|upper){o_p}/
  34.     # 3
  35. GROUP /{ldr}to(lower|upper){o_p}/
  36.     # 4
  37. GROUP /{ldr}set(locale|v?buf){o_p}/
  38.     # 5
  39. GROUP /{ldr}a(cos|sin|tan2?|bort){o_p}/
  40.     # 6
  41. GROUP /{ldr}(cos|sin|tan)h?{o_p}/
  42.     # 7
  43. GROUP /{ldr}(fr|ld)?exp{o_p}/
  44.     # 8
  45. GROUP /{ldr}log(10)?{o_p}/
  46.     # 9
  47. GROUP /{ldr}modf{o_p}/
  48.     # 10
  49. GROUP /{ldr}pow{o_p}/
  50.     # 11
  51. GROUP /{ldr}sqrt{o_p}/
  52.     # 12
  53. GROUP /{ldr}ceil{o_p}/
  54.     # 13
  55. GROUP /{ldr}(f|l)?abs{o_p}/
  56.     # 14
  57. GROUP /{ldr}f(loor|mod){o_p}/
  58.     # 15
  59. GROUP /{ldr}jmp_buf{o_p}/
  60.     # 16
  61. GROUP /{ldr}(set|long)jmp{o_p}/
  62.     # 17
  63. GROUP /{ldr}signal{o_p}/
  64.     # 18
  65. GROUP /{ldr}raise{o_p}/
  66.     # 19
  67. GROUP /{ldr}va_(arg|end|list|start){o_p}/
  68.     # 20
  69. GROUP /{ldr}re(move|name|wind){o_p}/
  70.     # 21
  71. GROUP /{ldr}tmp(file|nam){o_p}/
  72.     # 22
  73. GROUP /{ldr}(v?[fs])?printf{o_p}/
  74.     # 23
  75. GROUP /{ldr}[fs]?scanf{o_p}/
  76.     # 24
  77. GROUP /{ldr}f?get(c(har)?|s|env){o_p}/
  78.     # 25
  79. GROUP /{ldr}f?put(c(har)?|s){o_p}/
  80.     # 26
  81. GROUP /{ldr}ungetc{o_p}/
  82.     # 27
  83. GROUP /{ldr}f(close|flush|(re)?open|read|write|[gs]etpos|seek|tell|eof|ree|pos_t){o_p}/
  84.     # 28
  85. GROUP /{ldr}clearerr{o_p}/
  86.     # 29
  87. GROUP /{ldr}[fp]error{o_p}/
  88.     # 30
  89. GROUP /{ldr}ato[fil]{o_p}/
  90.     # 31
  91. GROUP /{ldr}str(to(d|k|u?l)|n?c(py|at|mp)|coll|r?chr|c?spn|pbrk|str|error|len){o_p}/
  92.     # 32
  93. GROUP /{ldr}nd{o_p}/
  94.     # 33
  95. GROUP /{ldr}(c|m|re)?alloc{o_p}/
  96.     # 34
  97. GROUP /{ldr}?exit{o_p}/
  98.     # 35
  99. GROUP /{ldr}(f|mk|asc|c|gm|local|strf)?time{o_p}/ {
  100.     printf("Macro/function\n%uE - %luR: %s\n%s\n",NG,FNR,$0,$$0);
  101.     mf_count++;
  102. }
  103.     #
  104.     # following are types or constants
  105.     #
  106.     # 36
  107. GROUP /errno/
  108.     # 37
  109. GROUP /NULL/
  110.     # 38
  111. GROUP /offsetof/
  112.     # 39
  113. GROUP /ptrdiff_t/
  114.     # 40
  115. GROUP /size_t/
  116.     # 41
  117. GROUP /NDEBUG/
  118.     # 42
  119. GROUP /LC_(ALL|COLLATE|CTYPE|NUMERIC|TIME)/
  120.     # 43
  121. GROUP /E(DOM|RANGE|OF)/
  122.     # 44
  123. GROUP /HUGE_VAL/
  124.     # 45
  125. GROUP /sig_atomic_t/
  126.     # 46
  127. GROUP /SIG(_(DFL|ERR|IGN)|ABRT|FPE|ILL|INT|SEGV|TERM)/
  128.     # 47
  129. GROUP /FILE/
  130.     # 48
  131. GROUP /_IO[FLN]BF/
  132.     # 49
  133. GROUP /BUFSIZ/
  134.     # 50
  135. GROUP /L_tmpnam/
  136.     # 51
  137. GROUP /(OPEN|RAND|TMP|U(CHAR|INT|LONG|SHRT))_MAX/
  138.     # 52
  139. GROUP /SEEK_(CUR|END|SET)/
  140.     # 53
  141. GROUP /std(err|in|out)/
  142.     # 54
  143. GROUP /l?div_t/
  144.     # 55
  145. GROUP /CLK_TCK/
  146.     # 56
  147. GROUP /(clock|time)_t/
  148.     # 57
  149. GROUP /tm_(sec|min|hour|[mwy]day|mon|year|isdst)/
  150.     # 58
  151. GROUP /CHAR_(BIT|M(AX|IN))/
  152.     # 59
  153. GROUP /(INT|LONG|S(CHAR|HRT))_(M(IN|AX))/
  154.     # 60
  155. GROUP /(L?DBL|FLT)_((MANT_)?DIG|EPSILON|M(AX|IN)(_(10_)?EXP)?)/
  156.     # 61
  157. GROUP /FLT_R(ADIX|OUNDS)/ {
  158.     printf("type/constant\n%uE - %luR: %s\n%s\n",NG,FNR,$0,$$0);
  159.     tc_count++;
  160. }
  161.  
  162. FINAL {
  163.     printf("Total Lines Scanned: %lu\n",FNR);
  164.     printf("Total Line containing macro/function names: %lu\n",mf_count);
  165.     printf("Total Line containing type/constant  names: %lu\n",tc_count);
  166. }
  167.