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