tcc 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +35 -0
  3. data/README.md +196 -0
  4. data/ext/tcc/extconf.rb +25 -0
  5. data/ext/tcc/tcc-0.9.26.patch +30 -0
  6. data/ext/tcc/tcc-0.9.26/COPYING +504 -0
  7. data/ext/tcc/tcc-0.9.26/Changelog +396 -0
  8. data/ext/tcc/tcc-0.9.26/Makefile +349 -0
  9. data/ext/tcc/tcc-0.9.26/README +101 -0
  10. data/ext/tcc/tcc-0.9.26/TODO +93 -0
  11. data/ext/tcc/tcc-0.9.26/VERSION +1 -0
  12. data/ext/tcc/tcc-0.9.26/arm-gen.c +2005 -0
  13. data/ext/tcc/tcc-0.9.26/c67-gen.c +2560 -0
  14. data/ext/tcc/tcc-0.9.26/coff.h +446 -0
  15. data/ext/tcc/tcc-0.9.26/config.h +8 -0
  16. data/ext/tcc/tcc-0.9.26/config.mak +28 -0
  17. data/ext/tcc/tcc-0.9.26/config.texi +1 -0
  18. data/ext/tcc/tcc-0.9.26/configure +540 -0
  19. data/ext/tcc/tcc-0.9.26/conftest.c +71 -0
  20. data/ext/tcc/tcc-0.9.26/elf.h +1731 -0
  21. data/ext/tcc/tcc-0.9.26/examples/ex1.c +8 -0
  22. data/ext/tcc/tcc-0.9.26/examples/ex2.c +98 -0
  23. data/ext/tcc/tcc-0.9.26/examples/ex3.c +24 -0
  24. data/ext/tcc/tcc-0.9.26/examples/ex4.c +26 -0
  25. data/ext/tcc/tcc-0.9.26/examples/ex5.c +8 -0
  26. data/ext/tcc/tcc-0.9.26/i386-asm.c +1498 -0
  27. data/ext/tcc/tcc-0.9.26/i386-asm.h +473 -0
  28. data/ext/tcc/tcc-0.9.26/i386-gen.c +1096 -0
  29. data/ext/tcc/tcc-0.9.26/i386-tok.h +243 -0
  30. data/ext/tcc/tcc-0.9.26/il-gen.c +667 -0
  31. data/ext/tcc/tcc-0.9.26/il-opcodes.h +251 -0
  32. data/ext/tcc/tcc-0.9.26/include/float.h +57 -0
  33. data/ext/tcc/tcc-0.9.26/include/stdarg.h +41 -0
  34. data/ext/tcc/tcc-0.9.26/include/stdbool.h +10 -0
  35. data/ext/tcc/tcc-0.9.26/include/stddef.h +28 -0
  36. data/ext/tcc/tcc-0.9.26/include/tcclib.h +78 -0
  37. data/ext/tcc/tcc-0.9.26/include/varargs.h +12 -0
  38. data/ext/tcc/tcc-0.9.26/lib/Makefile +102 -0
  39. data/ext/tcc/tcc-0.9.26/lib/alloca86-bt.S +47 -0
  40. data/ext/tcc/tcc-0.9.26/lib/alloca86.S +35 -0
  41. data/ext/tcc/tcc-0.9.26/lib/alloca86_64.S +42 -0
  42. data/ext/tcc/tcc-0.9.26/lib/bcheck.c +875 -0
  43. data/ext/tcc/tcc-0.9.26/lib/libtcc1.c +691 -0
  44. data/ext/tcc/tcc-0.9.26/libtcc.c +1941 -0
  45. data/ext/tcc/tcc-0.9.26/libtcc.h +103 -0
  46. data/ext/tcc/tcc-0.9.26/stab.def +234 -0
  47. data/ext/tcc/tcc-0.9.26/stab.h +17 -0
  48. data/ext/tcc/tcc-0.9.26/tcc-doc.html +2332 -0
  49. data/ext/tcc/tcc-0.9.26/tcc-doc.info +1151 -0
  50. data/ext/tcc/tcc-0.9.26/tcc-doc.texi +1268 -0
  51. data/ext/tcc/tcc-0.9.26/tcc.1 +415 -0
  52. data/ext/tcc/tcc-0.9.26/tcc.c +352 -0
  53. data/ext/tcc/tcc-0.9.26/tcc.h +1379 -0
  54. data/ext/tcc/tcc-0.9.26/tccasm.c +1118 -0
  55. data/ext/tcc/tcc-0.9.26/tcccoff.c +948 -0
  56. data/ext/tcc/tcc-0.9.26/tccelf.c +3129 -0
  57. data/ext/tcc/tcc-0.9.26/tccgen.c +5841 -0
  58. data/ext/tcc/tcc-0.9.26/tccpe.c +1887 -0
  59. data/ext/tcc/tcc-0.9.26/tccpp.c +3128 -0
  60. data/ext/tcc/tcc-0.9.26/tccrun.c +737 -0
  61. data/ext/tcc/tcc-0.9.26/tcctok.h +278 -0
  62. data/ext/tcc/tcc-0.9.26/tests/Makefile +199 -0
  63. data/ext/tcc/tcc-0.9.26/tests/asmtest.S +609 -0
  64. data/ext/tcc/tcc-0.9.26/tests/boundtest.c +233 -0
  65. data/ext/tcc/tcc-0.9.26/tests/gcctestsuite.sh +33 -0
  66. data/ext/tcc/tcc-0.9.26/tests/libtcc_test.c +76 -0
  67. data/ext/tcc/tcc-0.9.26/tests/tcctest.c +2713 -0
  68. data/ext/tcc/tcc-0.9.26/tests/tests2/00_assignment.c +18 -0
  69. data/ext/tcc/tcc-0.9.26/tests/tests2/00_assignment.expect +3 -0
  70. data/ext/tcc/tcc-0.9.26/tests/tests2/01_comment.c +14 -0
  71. data/ext/tcc/tcc-0.9.26/tests/tests2/01_comment.expect +5 -0
  72. data/ext/tcc/tcc-0.9.26/tests/tests2/02_printf.c +18 -0
  73. data/ext/tcc/tcc-0.9.26/tests/tests2/02_printf.expect +15 -0
  74. data/ext/tcc/tcc-0.9.26/tests/tests2/03_struct.c +31 -0
  75. data/ext/tcc/tcc-0.9.26/tests/tests2/03_struct.expect +6 -0
  76. data/ext/tcc/tcc-0.9.26/tests/tests2/04_for.c +15 -0
  77. data/ext/tcc/tcc-0.9.26/tests/tests2/04_for.expect +10 -0
  78. data/ext/tcc/tcc-0.9.26/tests/tests2/05_array.c +21 -0
  79. data/ext/tcc/tcc-0.9.26/tests/tests2/05_array.expect +10 -0
  80. data/ext/tcc/tcc-0.9.26/tests/tests2/06_case.c +29 -0
  81. data/ext/tcc/tcc-0.9.26/tests/tests2/06_case.expect +8 -0
  82. data/ext/tcc/tcc-0.9.26/tests/tests2/07_function.c +30 -0
  83. data/ext/tcc/tcc-0.9.26/tests/tests2/07_function.expect +4 -0
  84. data/ext/tcc/tcc-0.9.26/tests/tests2/08_while.c +24 -0
  85. data/ext/tcc/tcc-0.9.26/tests/tests2/08_while.expect +11 -0
  86. data/ext/tcc/tcc-0.9.26/tests/tests2/09_do_while.c +24 -0
  87. data/ext/tcc/tcc-0.9.26/tests/tests2/09_do_while.expect +11 -0
  88. data/ext/tcc/tcc-0.9.26/tests/tests2/10_pointer.c +40 -0
  89. data/ext/tcc/tcc-0.9.26/tests/tests2/10_pointer.expect +8 -0
  90. data/ext/tcc/tcc-0.9.26/tests/tests2/11_precedence.c +40 -0
  91. data/ext/tcc/tcc-0.9.26/tests/tests2/11_precedence.expect +15 -0
  92. data/ext/tcc/tcc-0.9.26/tests/tests2/12_hashdefine.c +14 -0
  93. data/ext/tcc/tcc-0.9.26/tests/tests2/12_hashdefine.expect +2 -0
  94. data/ext/tcc/tcc-0.9.26/tests/tests2/13_integer_literals.c +20 -0
  95. data/ext/tcc/tcc-0.9.26/tests/tests2/13_integer_literals.expect +5 -0
  96. data/ext/tcc/tcc-0.9.26/tests/tests2/14_if.c +21 -0
  97. data/ext/tcc/tcc-0.9.26/tests/tests2/14_if.expect +2 -0
  98. data/ext/tcc/tcc-0.9.26/tests/tests2/15_recursion.c +21 -0
  99. data/ext/tcc/tcc-0.9.26/tests/tests2/15_recursion.expect +10 -0
  100. data/ext/tcc/tcc-0.9.26/tests/tests2/16_nesting.c +21 -0
  101. data/ext/tcc/tcc-0.9.26/tests/tests2/16_nesting.expect +18 -0
  102. data/ext/tcc/tcc-0.9.26/tests/tests2/17_enum.c +29 -0
  103. data/ext/tcc/tcc-0.9.26/tests/tests2/17_enum.expect +3 -0
  104. data/ext/tcc/tcc-0.9.26/tests/tests2/18_include.c +12 -0
  105. data/ext/tcc/tcc-0.9.26/tests/tests2/18_include.expect +3 -0
  106. data/ext/tcc/tcc-0.9.26/tests/tests2/18_include.h +1 -0
  107. data/ext/tcc/tcc-0.9.26/tests/tests2/19_pointer_arithmetic.c +28 -0
  108. data/ext/tcc/tcc-0.9.26/tests/tests2/19_pointer_arithmetic.expect +3 -0
  109. data/ext/tcc/tcc-0.9.26/tests/tests2/20_pointer_comparison.c +24 -0
  110. data/ext/tcc/tcc-0.9.26/tests/tests2/20_pointer_comparison.expect +6 -0
  111. data/ext/tcc/tcc-0.9.26/tests/tests2/21_char_array.c +33 -0
  112. data/ext/tcc/tcc-0.9.26/tests/tests2/21_char_array.expect +7 -0
  113. data/ext/tcc/tcc-0.9.26/tests/tests2/22_floating_point.c +50 -0
  114. data/ext/tcc/tcc-0.9.26/tests/tests2/22_floating_point.expect +16 -0
  115. data/ext/tcc/tcc-0.9.26/tests/tests2/23_type_coercion.c +54 -0
  116. data/ext/tcc/tcc-0.9.26/tests/tests2/23_type_coercion.expect +12 -0
  117. data/ext/tcc/tcc-0.9.26/tests/tests2/24_math_library.c +28 -0
  118. data/ext/tcc/tcc-0.9.26/tests/tests2/24_math_library.expect +18 -0
  119. data/ext/tcc/tcc-0.9.26/tests/tests2/25_quicksort.c +83 -0
  120. data/ext/tcc/tcc-0.9.26/tests/tests2/25_quicksort.expect +2 -0
  121. data/ext/tcc/tcc-0.9.26/tests/tests2/26_character_constants.c +17 -0
  122. data/ext/tcc/tcc-0.9.26/tests/tests2/26_character_constants.expect +8 -0
  123. data/ext/tcc/tcc-0.9.26/tests/tests2/27_sizeof.c +16 -0
  124. data/ext/tcc/tcc-0.9.26/tests/tests2/27_sizeof.expect +3 -0
  125. data/ext/tcc/tcc-0.9.26/tests/tests2/28_strings.c +46 -0
  126. data/ext/tcc/tcc-0.9.26/tests/tests2/28_strings.expect +19 -0
  127. data/ext/tcc/tcc-0.9.26/tests/tests2/29_array_address.c +13 -0
  128. data/ext/tcc/tcc-0.9.26/tests/tests2/29_array_address.expect +1 -0
  129. data/ext/tcc/tcc-0.9.26/tests/tests2/30_hanoi.c +122 -0
  130. data/ext/tcc/tcc-0.9.26/tests/tests2/30_hanoi.expect +71 -0
  131. data/ext/tcc/tcc-0.9.26/tests/tests2/31_args.c +14 -0
  132. data/ext/tcc/tcc-0.9.26/tests/tests2/31_args.expect +7 -0
  133. data/ext/tcc/tcc-0.9.26/tests/tests2/32_led.c +266 -0
  134. data/ext/tcc/tcc-0.9.26/tests/tests2/32_led.expect +4 -0
  135. data/ext/tcc/tcc-0.9.26/tests/tests2/33_ternary_op.c +15 -0
  136. data/ext/tcc/tcc-0.9.26/tests/tests2/33_ternary_op.expect +10 -0
  137. data/ext/tcc/tcc-0.9.26/tests/tests2/34_array_assignment.c +23 -0
  138. data/ext/tcc/tcc-0.9.26/tests/tests2/34_array_assignment.expect +2 -0
  139. data/ext/tcc/tcc-0.9.26/tests/tests2/35_sizeof.c +14 -0
  140. data/ext/tcc/tcc-0.9.26/tests/tests2/35_sizeof.expect +2 -0
  141. data/ext/tcc/tcc-0.9.26/tests/tests2/36_array_initialisers.c +21 -0
  142. data/ext/tcc/tcc-0.9.26/tests/tests2/36_array_initialisers.expect +20 -0
  143. data/ext/tcc/tcc-0.9.26/tests/tests2/37_sprintf.c +17 -0
  144. data/ext/tcc/tcc-0.9.26/tests/tests2/37_sprintf.expect +20 -0
  145. data/ext/tcc/tcc-0.9.26/tests/tests2/38_multiple_array_index.c +32 -0
  146. data/ext/tcc/tcc-0.9.26/tests/tests2/38_multiple_array_index.expect +4 -0
  147. data/ext/tcc/tcc-0.9.26/tests/tests2/39_typedef.c +31 -0
  148. data/ext/tcc/tcc-0.9.26/tests/tests2/39_typedef.expect +3 -0
  149. data/ext/tcc/tcc-0.9.26/tests/tests2/40_stdio.c +52 -0
  150. data/ext/tcc/tcc-0.9.26/tests/tests2/40_stdio.expect +27 -0
  151. data/ext/tcc/tcc-0.9.26/tests/tests2/41_hashif.c +85 -0
  152. data/ext/tcc/tcc-0.9.26/tests/tests2/41_hashif.expect +6 -0
  153. data/ext/tcc/tcc-0.9.26/tests/tests2/42_function_pointer.c +18 -0
  154. data/ext/tcc/tcc-0.9.26/tests/tests2/42_function_pointer.expect +2 -0
  155. data/ext/tcc/tcc-0.9.26/tests/tests2/43_void_param.c +15 -0
  156. data/ext/tcc/tcc-0.9.26/tests/tests2/43_void_param.expect +1 -0
  157. data/ext/tcc/tcc-0.9.26/tests/tests2/44_scoped_declarations.c +17 -0
  158. data/ext/tcc/tcc-0.9.26/tests/tests2/44_scoped_declarations.expect +1 -0
  159. data/ext/tcc/tcc-0.9.26/tests/tests2/45_empty_for.c +18 -0
  160. data/ext/tcc/tcc-0.9.26/tests/tests2/45_empty_for.expect +10 -0
  161. data/ext/tcc/tcc-0.9.26/tests/tests2/46_grep.c +564 -0
  162. data/ext/tcc/tcc-0.9.26/tests/tests2/47_switch_return.c +24 -0
  163. data/ext/tcc/tcc-0.9.26/tests/tests2/47_switch_return.expect +4 -0
  164. data/ext/tcc/tcc-0.9.26/tests/tests2/48_nested_break.c +26 -0
  165. data/ext/tcc/tcc-0.9.26/tests/tests2/48_nested_break.expect +1 -0
  166. data/ext/tcc/tcc-0.9.26/tests/tests2/49_bracket_evaluation.c +23 -0
  167. data/ext/tcc/tcc-0.9.26/tests/tests2/49_bracket_evaluation.expect +1 -0
  168. data/ext/tcc/tcc-0.9.26/tests/tests2/50_logical_second_arg.c +29 -0
  169. data/ext/tcc/tcc-0.9.26/tests/tests2/50_logical_second_arg.expect +20 -0
  170. data/ext/tcc/tcc-0.9.26/tests/tests2/51_static.c +30 -0
  171. data/ext/tcc/tcc-0.9.26/tests/tests2/51_static.expect +8 -0
  172. data/ext/tcc/tcc-0.9.26/tests/tests2/52_unnamed_enum.c +27 -0
  173. data/ext/tcc/tcc-0.9.26/tests/tests2/52_unnamed_enum.expect +9 -0
  174. data/ext/tcc/tcc-0.9.26/tests/tests2/54_goto.c +56 -0
  175. data/ext/tcc/tcc-0.9.26/tests/tests2/54_goto.expect +8 -0
  176. data/ext/tcc/tcc-0.9.26/tests/tests2/55_lshift_type.c +52 -0
  177. data/ext/tcc/tcc-0.9.26/tests/tests2/55_lshift_type.expect +1 -0
  178. data/ext/tcc/tcc-0.9.26/tests/tests2/LICENSE +37 -0
  179. data/ext/tcc/tcc-0.9.26/tests/tests2/Makefile +98 -0
  180. data/ext/tcc/tcc-0.9.26/texi2pod.pl +427 -0
  181. data/ext/tcc/tcc-0.9.26/win32/build-tcc.bat +60 -0
  182. data/ext/tcc/tcc-0.9.26/win32/examples/dll.c +12 -0
  183. data/ext/tcc/tcc-0.9.26/win32/examples/fib.c +23 -0
  184. data/ext/tcc/tcc-0.9.26/win32/examples/hello_dll.c +19 -0
  185. data/ext/tcc/tcc-0.9.26/win32/examples/hello_win.c +163 -0
  186. data/ext/tcc/tcc-0.9.26/win32/include/_mingw.h +139 -0
  187. data/ext/tcc/tcc-0.9.26/win32/include/assert.h +54 -0
  188. data/ext/tcc/tcc-0.9.26/win32/include/conio.h +409 -0
  189. data/ext/tcc/tcc-0.9.26/win32/include/ctype.h +281 -0
  190. data/ext/tcc/tcc-0.9.26/win32/include/dir.h +31 -0
  191. data/ext/tcc/tcc-0.9.26/win32/include/direct.h +68 -0
  192. data/ext/tcc/tcc-0.9.26/win32/include/dirent.h +135 -0
  193. data/ext/tcc/tcc-0.9.26/win32/include/dos.h +55 -0
  194. data/ext/tcc/tcc-0.9.26/win32/include/errno.h +75 -0
  195. data/ext/tcc/tcc-0.9.26/win32/include/excpt.h +123 -0
  196. data/ext/tcc/tcc-0.9.26/win32/include/fcntl.h +52 -0
  197. data/ext/tcc/tcc-0.9.26/win32/include/fenv.h +108 -0
  198. data/ext/tcc/tcc-0.9.26/win32/include/inttypes.h +297 -0
  199. data/ext/tcc/tcc-0.9.26/win32/include/io.h +418 -0
  200. data/ext/tcc/tcc-0.9.26/win32/include/limits.h +111 -0
  201. data/ext/tcc/tcc-0.9.26/win32/include/locale.h +91 -0
  202. data/ext/tcc/tcc-0.9.26/win32/include/malloc.h +175 -0
  203. data/ext/tcc/tcc-0.9.26/win32/include/math.h +777 -0
  204. data/ext/tcc/tcc-0.9.26/win32/include/mem.h +13 -0
  205. data/ext/tcc/tcc-0.9.26/win32/include/memory.h +40 -0
  206. data/ext/tcc/tcc-0.9.26/win32/include/process.h +176 -0
  207. data/ext/tcc/tcc-0.9.26/win32/include/sec_api/conio_s.h +42 -0
  208. data/ext/tcc/tcc-0.9.26/win32/include/sec_api/crtdbg_s.h +19 -0
  209. data/ext/tcc/tcc-0.9.26/win32/include/sec_api/io_s.h +33 -0
  210. data/ext/tcc/tcc-0.9.26/win32/include/sec_api/mbstring_s.h +52 -0
  211. data/ext/tcc/tcc-0.9.26/win32/include/sec_api/search_s.h +25 -0
  212. data/ext/tcc/tcc-0.9.26/win32/include/sec_api/stdio_s.h +145 -0
  213. data/ext/tcc/tcc-0.9.26/win32/include/sec_api/stdlib_s.h +67 -0
  214. data/ext/tcc/tcc-0.9.26/win32/include/sec_api/stralign_s.h +30 -0
  215. data/ext/tcc/tcc-0.9.26/win32/include/sec_api/string_s.h +41 -0
  216. data/ext/tcc/tcc-0.9.26/win32/include/sec_api/sys/timeb_s.h +34 -0
  217. data/ext/tcc/tcc-0.9.26/win32/include/sec_api/tchar_s.h +266 -0
  218. data/ext/tcc/tcc-0.9.26/win32/include/sec_api/time_s.h +61 -0
  219. data/ext/tcc/tcc-0.9.26/win32/include/sec_api/wchar_s.h +128 -0
  220. data/ext/tcc/tcc-0.9.26/win32/include/setjmp.h +160 -0
  221. data/ext/tcc/tcc-0.9.26/win32/include/share.h +28 -0
  222. data/ext/tcc/tcc-0.9.26/win32/include/signal.h +63 -0
  223. data/ext/tcc/tcc-0.9.26/win32/include/stdint.h +209 -0
  224. data/ext/tcc/tcc-0.9.26/win32/include/stdio.h +429 -0
  225. data/ext/tcc/tcc-0.9.26/win32/include/stdlib.h +580 -0
  226. data/ext/tcc/tcc-0.9.26/win32/include/string.h +164 -0
  227. data/ext/tcc/tcc-0.9.26/win32/include/sys/fcntl.h +13 -0
  228. data/ext/tcc/tcc-0.9.26/win32/include/sys/file.h +14 -0
  229. data/ext/tcc/tcc-0.9.26/win32/include/sys/locking.h +30 -0
  230. data/ext/tcc/tcc-0.9.26/win32/include/sys/stat.h +290 -0
  231. data/ext/tcc/tcc-0.9.26/win32/include/sys/time.h +69 -0
  232. data/ext/tcc/tcc-0.9.26/win32/include/sys/timeb.h +133 -0
  233. data/ext/tcc/tcc-0.9.26/win32/include/sys/types.h +118 -0
  234. data/ext/tcc/tcc-0.9.26/win32/include/sys/unistd.h +14 -0
  235. data/ext/tcc/tcc-0.9.26/win32/include/sys/utime.h +146 -0
  236. data/ext/tcc/tcc-0.9.26/win32/include/tchar.h +1102 -0
  237. data/ext/tcc/tcc-0.9.26/win32/include/time.h +287 -0
  238. data/ext/tcc/tcc-0.9.26/win32/include/vadefs.h +11 -0
  239. data/ext/tcc/tcc-0.9.26/win32/include/values.h +4 -0
  240. data/ext/tcc/tcc-0.9.26/win32/include/wchar.h +871 -0
  241. data/ext/tcc/tcc-0.9.26/win32/include/wctype.h +172 -0
  242. data/ext/tcc/tcc-0.9.26/win32/include/winapi/basetsd.h +149 -0
  243. data/ext/tcc/tcc-0.9.26/win32/include/winapi/basetyps.h +85 -0
  244. data/ext/tcc/tcc-0.9.26/win32/include/winapi/guiddef.h +151 -0
  245. data/ext/tcc/tcc-0.9.26/win32/include/winapi/intrin.h +11 -0
  246. data/ext/tcc/tcc-0.9.26/win32/include/winapi/poppack.h +8 -0
  247. data/ext/tcc/tcc-0.9.26/win32/include/winapi/pshpack1.h +8 -0
  248. data/ext/tcc/tcc-0.9.26/win32/include/winapi/pshpack2.h +8 -0
  249. data/ext/tcc/tcc-0.9.26/win32/include/winapi/pshpack4.h +8 -0
  250. data/ext/tcc/tcc-0.9.26/win32/include/winapi/pshpack8.h +8 -0
  251. data/ext/tcc/tcc-0.9.26/win32/include/winapi/reason.h +80 -0
  252. data/ext/tcc/tcc-0.9.26/win32/include/winapi/specstrings.h +7 -0
  253. data/ext/tcc/tcc-0.9.26/win32/include/winapi/stralign.h +154 -0
  254. data/ext/tcc/tcc-0.9.26/win32/include/winapi/tvout.h +79 -0
  255. data/ext/tcc/tcc-0.9.26/win32/include/winapi/winbase.h +2951 -0
  256. data/ext/tcc/tcc-0.9.26/win32/include/winapi/wincon.h +301 -0
  257. data/ext/tcc/tcc-0.9.26/win32/include/winapi/windef.h +293 -0
  258. data/ext/tcc/tcc-0.9.26/win32/include/winapi/windows.h +123 -0
  259. data/ext/tcc/tcc-0.9.26/win32/include/winapi/winerror.h +3166 -0
  260. data/ext/tcc/tcc-0.9.26/win32/include/winapi/wingdi.h +4080 -0
  261. data/ext/tcc/tcc-0.9.26/win32/include/winapi/winnetwk.h +476 -0
  262. data/ext/tcc/tcc-0.9.26/win32/include/winapi/winnls.h +765 -0
  263. data/ext/tcc/tcc-0.9.26/win32/include/winapi/winnt.h +5770 -0
  264. data/ext/tcc/tcc-0.9.26/win32/include/winapi/winreg.h +272 -0
  265. data/ext/tcc/tcc-0.9.26/win32/include/winapi/winuser.h +5651 -0
  266. data/ext/tcc/tcc-0.9.26/win32/include/winapi/winver.h +160 -0
  267. data/ext/tcc/tcc-0.9.26/win32/lib/chkstk.S +191 -0
  268. data/ext/tcc/tcc-0.9.26/win32/lib/crt1.c +34 -0
  269. data/ext/tcc/tcc-0.9.26/win32/lib/dllcrt1.c +13 -0
  270. data/ext/tcc/tcc-0.9.26/win32/lib/dllmain.c +9 -0
  271. data/ext/tcc/tcc-0.9.26/win32/lib/gdi32.def +337 -0
  272. data/ext/tcc/tcc-0.9.26/win32/lib/kernel32.def +765 -0
  273. data/ext/tcc/tcc-0.9.26/win32/lib/msvcrt.def +1399 -0
  274. data/ext/tcc/tcc-0.9.26/win32/lib/user32.def +654 -0
  275. data/ext/tcc/tcc-0.9.26/win32/lib/wincrt1.c +64 -0
  276. data/ext/tcc/tcc-0.9.26/win32/tcc-win32.txt +156 -0
  277. data/ext/tcc/tcc-0.9.26/win32/tools/tiny_impdef.c +243 -0
  278. data/ext/tcc/tcc-0.9.26/win32/tools/tiny_libmaker.c +258 -0
  279. data/ext/tcc/tcc-0.9.26/x86_64-asm.h +448 -0
  280. data/ext/tcc/tcc-0.9.26/x86_64-gen.c +1701 -0
  281. data/lib/tcc.rb +291 -0
  282. data/tcc.gemspec +15 -0
  283. metadata +343 -0
@@ -0,0 +1,32 @@
1
+ #include <stdio.h>
2
+
3
+ int main()
4
+ {
5
+ int a[4][4];
6
+ int b = 0;
7
+ int x;
8
+ int y;
9
+
10
+ for (x = 0; x < 4; x++)
11
+ {
12
+ for (y = 0; y < 4; y++)
13
+ {
14
+ b++;
15
+ a[x][y] = b;
16
+ }
17
+ }
18
+
19
+ for (x = 0; x < 4; x++)
20
+ {
21
+ printf("x=%d: ", x);
22
+ for (y = 0; y < 4; y++)
23
+ {
24
+ printf("%d ", a[x][y]);
25
+ }
26
+ printf("\n");
27
+ }
28
+
29
+ return 0;
30
+ }
31
+
32
+ /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
@@ -0,0 +1,4 @@
1
+ x=0: 1 2 3 4
2
+ x=1: 5 6 7 8
3
+ x=2: 9 10 11 12
4
+ x=3: 13 14 15 16
@@ -0,0 +1,31 @@
1
+ #include <stdio.h>
2
+
3
+ typedef int MyInt;
4
+
5
+ struct FunStruct
6
+ {
7
+ int i;
8
+ int j;
9
+ };
10
+
11
+ typedef struct FunStruct MyFunStruct;
12
+
13
+ typedef MyFunStruct *MoreFunThanEver;
14
+
15
+ int main()
16
+ {
17
+ MyInt a = 1;
18
+ printf("%d\n", a);
19
+
20
+ MyFunStruct b;
21
+ b.i = 12;
22
+ b.j = 34;
23
+ printf("%d,%d\n", b.i, b.j);
24
+
25
+ MoreFunThanEver c = &b;
26
+ printf("%d,%d\n", c->i, c->j);
27
+
28
+ return 0;
29
+ }
30
+
31
+ /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
@@ -0,0 +1,3 @@
1
+ 1
2
+ 12,34
3
+ 12,34
@@ -0,0 +1,52 @@
1
+ #include <stdio.h>
2
+
3
+ int main()
4
+ {
5
+ FILE *f = fopen("fred.txt", "w");
6
+ fwrite("hello\nhello\n", 1, 12, f);
7
+ fclose(f);
8
+
9
+ char freddy[7];
10
+ f = fopen("fred.txt", "r");
11
+ if (fread(freddy, 1, 6, f) != 6)
12
+ printf("couldn't read fred.txt\n");
13
+
14
+ freddy[6] = '\0';
15
+ fclose(f);
16
+
17
+ printf("%s", freddy);
18
+
19
+ int InChar;
20
+ char ShowChar;
21
+ f = fopen("fred.txt", "r");
22
+ while ( (InChar = fgetc(f)) != EOF)
23
+ {
24
+ ShowChar = InChar;
25
+ if (ShowChar < ' ')
26
+ ShowChar = '.';
27
+
28
+ printf("ch: %d '%c'\n", InChar, ShowChar);
29
+ }
30
+ fclose(f);
31
+
32
+ f = fopen("fred.txt", "r");
33
+ while ( (InChar = getc(f)) != EOF)
34
+ {
35
+ ShowChar = InChar;
36
+ if (ShowChar < ' ')
37
+ ShowChar = '.';
38
+
39
+ printf("ch: %d '%c'\n", InChar, ShowChar);
40
+ }
41
+ fclose(f);
42
+
43
+ f = fopen("fred.txt", "r");
44
+ while (fgets(freddy, sizeof(freddy), f) != NULL)
45
+ printf("x: %s", freddy);
46
+
47
+ fclose(f);
48
+
49
+ return 0;
50
+ }
51
+
52
+ /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
@@ -0,0 +1,27 @@
1
+ hello
2
+ ch: 104 'h'
3
+ ch: 101 'e'
4
+ ch: 108 'l'
5
+ ch: 108 'l'
6
+ ch: 111 'o'
7
+ ch: 10 '.'
8
+ ch: 104 'h'
9
+ ch: 101 'e'
10
+ ch: 108 'l'
11
+ ch: 108 'l'
12
+ ch: 111 'o'
13
+ ch: 10 '.'
14
+ ch: 104 'h'
15
+ ch: 101 'e'
16
+ ch: 108 'l'
17
+ ch: 108 'l'
18
+ ch: 111 'o'
19
+ ch: 10 '.'
20
+ ch: 104 'h'
21
+ ch: 101 'e'
22
+ ch: 108 'l'
23
+ ch: 108 'l'
24
+ ch: 111 'o'
25
+ ch: 10 '.'
26
+ x: hello
27
+ x: hello
@@ -0,0 +1,85 @@
1
+ #include <stdio.h>
2
+
3
+ int main()
4
+ {
5
+ printf("#include test\n");
6
+
7
+ #if 1
8
+ #if 0
9
+ printf("a\n");
10
+ #else
11
+ printf("b\n");
12
+ #endif
13
+ #else
14
+ #if 0
15
+ printf("c\n");
16
+ #else
17
+ printf("d\n");
18
+ #endif
19
+ #endif
20
+
21
+ #if 0
22
+ #if 1
23
+ printf("e\n");
24
+ #else
25
+ printf("f\n");
26
+ #endif
27
+ #else
28
+ #if 1
29
+ printf("g\n");
30
+ #else
31
+ printf("h\n");
32
+ #endif
33
+ #endif
34
+
35
+ #define DEF
36
+
37
+ #ifdef DEF
38
+ #ifdef DEF
39
+ printf("i\n");
40
+ #else
41
+ printf("j\n");
42
+ #endif
43
+ #else
44
+ #ifdef DEF
45
+ printf("k\n");
46
+ #else
47
+ printf("l\n");
48
+ #endif
49
+ #endif
50
+
51
+ #ifndef DEF
52
+ #ifndef DEF
53
+ printf("m\n");
54
+ #else
55
+ printf("n\n");
56
+ #endif
57
+ #else
58
+ #ifndef DEF
59
+ printf("o\n");
60
+ #else
61
+ printf("p\n");
62
+ #endif
63
+ #endif
64
+
65
+ #define ONE 1
66
+ #define ZERO 0
67
+
68
+ #if ONE
69
+ #if ZERO
70
+ printf("q\n");
71
+ #else
72
+ printf("r\n");
73
+ #endif
74
+ #else
75
+ #if ZERO
76
+ printf("s\n");
77
+ #else
78
+ printf("t\n");
79
+ #endif
80
+ #endif
81
+
82
+ return 0;
83
+ }
84
+
85
+ /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
@@ -0,0 +1,6 @@
1
+ #include test
2
+ b
3
+ g
4
+ i
5
+ p
6
+ r
@@ -0,0 +1,18 @@
1
+ #include <stdio.h>
2
+
3
+ int fred(int p)
4
+ {
5
+ printf("yo %d\n", p);
6
+ return 42;
7
+ }
8
+
9
+ int (*f)(int) = &fred;
10
+
11
+ int main()
12
+ {
13
+ printf("%d\n", (*f)(24));
14
+
15
+ return 0;
16
+ }
17
+
18
+ /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
@@ -0,0 +1,15 @@
1
+ #include <stdio.h>
2
+
3
+ void fred(void)
4
+ {
5
+ printf("yo\n");
6
+ }
7
+
8
+ int main()
9
+ {
10
+ fred();
11
+
12
+ return 0;
13
+ }
14
+
15
+ /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
@@ -0,0 +1,17 @@
1
+ #include <stdio.h>
2
+
3
+ int main()
4
+ {
5
+ int a;
6
+
7
+ for (a = 0; a < 2; a++)
8
+ {
9
+ int b = a;
10
+ }
11
+
12
+ printf("it's all good\n");
13
+
14
+ return 0;
15
+ }
16
+
17
+ /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
@@ -0,0 +1,18 @@
1
+ #include <stdio.h>
2
+
3
+ int main()
4
+ {
5
+ int Count = 0;
6
+
7
+ for (;;)
8
+ {
9
+ Count++;
10
+ printf("%d\n", Count);
11
+ if (Count >= 10)
12
+ break;
13
+ }
14
+
15
+ return 0;
16
+ }
17
+
18
+ /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
@@ -0,0 +1,10 @@
1
+ 1
2
+ 2
3
+ 3
4
+ 4
5
+ 5
6
+ 6
7
+ 7
8
+ 8
9
+ 9
10
+ 10
@@ -0,0 +1,564 @@
1
+ /*
2
+ * The information in this document is subject to change
3
+ * without notice and should not be construed as a commitment
4
+ * by Digital Equipment Corporation or by DECUS.
5
+ *
6
+ * Neither Digital Equipment Corporation, DECUS, nor the authors
7
+ * assume any responsibility for the use or reliability of this
8
+ * document or the described software.
9
+ *
10
+ * Copyright (C) 1980, DECUS
11
+ *
12
+ * General permission to copy or modify, but not for profit, is
13
+ * hereby granted, provided that the above copyright notice is
14
+ * included and reference made to the fact that reproduction
15
+ * privileges were granted by DECUS.
16
+ */
17
+ #include <stdio.h>
18
+
19
+ /*
20
+ * grep
21
+ *
22
+ * Runs on the Decus compiler or on vms, On vms, define as:
23
+ * grep :== "$disk:[account]grep" (native)
24
+ * grep :== "$disk:[account]grep grep" (Decus)
25
+ * See below for more information.
26
+ */
27
+
28
+ #if 0
29
+ char *documentation[] = {
30
+ "grep searches a file for a given pattern. Execute by",
31
+ " grep [flags] regular_expression file_list\n",
32
+ "Flags are single characters preceeded by '-':",
33
+ " -c Only a count of matching lines is printed",
34
+ " -f Print file name for matching lines switch, see below",
35
+ " -n Each line is preceeded by its line number",
36
+ " -v Only print non-matching lines\n",
37
+ "The file_list is a list of files (wildcards are acceptable on RSX modes).",
38
+ "\nThe file name is normally printed if there is a file given.",
39
+ "The -f flag reverses this action (print name no file, not if more).\n",
40
+ 0 };
41
+
42
+ char *patdoc[] = {
43
+ "The regular_expression defines the pattern to search for. Upper- and",
44
+ "lower-case are always ignored. Blank lines never match. The expression",
45
+ "should be quoted to prevent file-name translation.",
46
+ "x An ordinary character (not mentioned below) matches that character.",
47
+ "'\\' The backslash quotes any character. \"\\$\" matches a dollar-sign.",
48
+ "'^' A circumflex at the beginning of an expression matches the",
49
+ " beginning of a line.",
50
+ "'$' A dollar-sign at the end of an expression matches the end of a line.",
51
+ "'.' A period matches any character except \"new-line\".",
52
+ "':a' A colon matches a class of characters described by the following",
53
+ "':d' character. \":a\" matches any alphabetic, \":d\" matches digits,",
54
+ "':n' \":n\" matches alphanumerics, \": \" matches spaces, tabs, and",
55
+ "': ' other control characters, such as new-line.",
56
+ "'*' An expression followed by an asterisk matches zero or more",
57
+ " occurrances of that expression: \"fo*\" matches \"f\", \"fo\"",
58
+ " \"foo\", etc.",
59
+ "'+' An expression followed by a plus sign matches one or more",
60
+ " occurrances of that expression: \"fo+\" matches \"fo\", etc.",
61
+ "'-' An expression followed by a minus sign optionally matches",
62
+ " the expression.",
63
+ "'[]' A string enclosed in square brackets matches any character in",
64
+ " that string, but no others. If the first character in the",
65
+ " string is a circumflex, the expression matches any character",
66
+ " except \"new-line\" and the characters in the string. For",
67
+ " example, \"[xyz]\" matches \"xx\" and \"zyx\", while \"[^xyz]\"",
68
+ " matches \"abc\" but not \"axb\". A range of characters may be",
69
+ " specified by two characters separated by \"-\". Note that,",
70
+ " [a-z] matches alphabetics, while [z-a] never matches.",
71
+ "The concatenation of regular expressions is a regular expression.",
72
+ 0};
73
+ #endif
74
+
75
+ #define LMAX 512
76
+ #define PMAX 256
77
+
78
+ #define CHAR 1
79
+ #define BOL 2
80
+ #define EOL 3
81
+ #define ANY 4
82
+ #define CLASS 5
83
+ #define NCLASS 6
84
+ #define STAR 7
85
+ #define PLUS 8
86
+ #define MINUS 9
87
+ #define ALPHA 10
88
+ #define DIGIT 11
89
+ #define NALPHA 12
90
+ #define PUNCT 13
91
+ #define RANGE 14
92
+ #define ENDPAT 15
93
+
94
+ int cflag=0, fflag=0, nflag=0, vflag=0, nfile=0, debug=0;
95
+
96
+ char *pp, lbuf[LMAX], pbuf[PMAX];
97
+
98
+ char *cclass();
99
+ char *pmatch();
100
+
101
+
102
+ /*** Display a file name *******************************/
103
+ void file(char *s)
104
+ {
105
+ printf("File %s:\n", s);
106
+ }
107
+
108
+ /*** Report unopenable file ****************************/
109
+ void cant(char *s)
110
+ {
111
+ fprintf(stderr, "%s: cannot open\n", s);
112
+ }
113
+
114
+ /*** Give good help ************************************/
115
+ void help(char **hp)
116
+ {
117
+ char **dp;
118
+
119
+ for (dp = hp; *dp; ++dp)
120
+ printf("%s\n", *dp);
121
+ }
122
+
123
+ /*** Display usage summary *****************************/
124
+ void usage(char *s)
125
+ {
126
+ fprintf(stderr, "?GREP-E-%s\n", s);
127
+ fprintf(stderr,
128
+ "Usage: grep [-cfnv] pattern [file ...]. grep ? for help\n");
129
+ exit(1);
130
+ }
131
+
132
+ /*** Compile the pattern into global pbuf[] ************/
133
+ void compile(char *source)
134
+ {
135
+ char *s; /* Source string pointer */
136
+ char *lp; /* Last pattern pointer */
137
+ int c; /* Current character */
138
+ int o; /* Temp */
139
+ char *spp; /* Save beginning of pattern */
140
+
141
+ s = source;
142
+ if (debug)
143
+ printf("Pattern = \"%s\"\n", s);
144
+ pp = pbuf;
145
+ while (c = *s++) {
146
+ /*
147
+ * STAR, PLUS and MINUS are special.
148
+ */
149
+ if (c == '*' || c == '+' || c == '-') {
150
+ if (pp == pbuf ||
151
+ (o=pp[-1]) == BOL ||
152
+ o == EOL ||
153
+ o == STAR ||
154
+ o == PLUS ||
155
+ o == MINUS)
156
+ badpat("Illegal occurrance op.", source, s);
157
+ store(ENDPAT);
158
+ store(ENDPAT);
159
+ spp = pp; /* Save pattern end */
160
+ while (--pp > lp) /* Move pattern down */
161
+ *pp = pp[-1]; /* one byte */
162
+ *pp = (c == '*') ? STAR :
163
+ (c == '-') ? MINUS : PLUS;
164
+ pp = spp; /* Restore pattern end */
165
+ continue;
166
+ }
167
+ /*
168
+ * All the rest.
169
+ */
170
+ lp = pp; /* Remember start */
171
+ switch(c) {
172
+
173
+ case '^':
174
+ store(BOL);
175
+ break;
176
+
177
+ case '$':
178
+ store(EOL);
179
+ break;
180
+
181
+ case '.':
182
+ store(ANY);
183
+ break;
184
+
185
+ case '[':
186
+ s = cclass(source, s);
187
+ break;
188
+
189
+ case ':':
190
+ if (*s) {
191
+ switch(tolower(c = *s++)) {
192
+
193
+ case 'a':
194
+ case 'A':
195
+ store(ALPHA);
196
+ break;
197
+
198
+ case 'd':
199
+ case 'D':
200
+ store(DIGIT);
201
+ break;
202
+
203
+ case 'n':
204
+ case 'N':
205
+ store(NALPHA);
206
+ break;
207
+
208
+ case ' ':
209
+ store(PUNCT);
210
+ break;
211
+
212
+ default:
213
+ badpat("Unknown : type", source, s);
214
+
215
+ }
216
+ break;
217
+ }
218
+ else badpat("No : type", source, s);
219
+
220
+ case '\\':
221
+ if (*s)
222
+ c = *s++;
223
+
224
+ default:
225
+ store(CHAR);
226
+ store(tolower(c));
227
+ }
228
+ }
229
+ store(ENDPAT);
230
+ store(0); /* Terminate string */
231
+ if (debug) {
232
+ for (lp = pbuf; lp < pp;) {
233
+ if ((c = (*lp++ & 0377)) < ' ')
234
+ printf("\\%o ", c);
235
+ else printf("%c ", c);
236
+ }
237
+ printf("\n");
238
+ }
239
+ }
240
+
241
+ /*** Compile a class (within []) ***********************/
242
+ char *cclass(char *source, char *src)
243
+ /* char *source; // Pattern start -- for error msg. */
244
+ /* char *src; // Class start */
245
+ {
246
+ char *s; /* Source pointer */
247
+ char *cp; /* Pattern start */
248
+ int c; /* Current character */
249
+ int o; /* Temp */
250
+
251
+ s = src;
252
+ o = CLASS;
253
+ if (*s == '^') {
254
+ ++s;
255
+ o = NCLASS;
256
+ }
257
+ store(o);
258
+ cp = pp;
259
+ store(0); /* Byte count */
260
+ while ((c = *s++) && c!=']') {
261
+ if (c == '\\') { /* Store quoted char */
262
+ if ((c = *s++) == '\0') /* Gotta get something */
263
+ badpat("Class terminates badly", source, s);
264
+ else store(tolower(c));
265
+ }
266
+ else if (c == '-' &&
267
+ (pp - cp) > 1 && *s != ']' && *s != '\0') {
268
+ c = pp[-1]; /* Range start */
269
+ pp[-1] = RANGE; /* Range signal */
270
+ store(c); /* Re-store start */
271
+ c = *s++; /* Get end char and*/
272
+ store(tolower(c)); /* Store it */
273
+ }
274
+ else {
275
+ store(tolower(c)); /* Store normal char */
276
+ }
277
+ }
278
+ if (c != ']')
279
+ badpat("Unterminated class", source, s);
280
+ if ((c = (pp - cp)) >= 256)
281
+ badpat("Class too large", source, s);
282
+ if (c == 0)
283
+ badpat("Empty class", source, s);
284
+ *cp = c;
285
+ return(s);
286
+ }
287
+
288
+ /*** Store an entry in the pattern buffer **************/
289
+ void store(int op)
290
+ {
291
+ if (pp >= &pbuf[PMAX])
292
+ error("Pattern too complex\n");
293
+ *pp++ = op;
294
+ }
295
+
296
+ /*** Report a bad pattern specification ****************/
297
+ void badpat(char *message, char *source, char *stop)
298
+ /* char *message; // Error message */
299
+ /* char *source; // Pattern start */
300
+ /* char *stop; // Pattern end */
301
+ {
302
+ fprintf(stderr, "-GREP-E-%s, pattern is\"%s\"\n", message, source);
303
+ fprintf(stderr, "-GREP-E-Stopped at byte %d, '%c'\n",
304
+ stop-source, stop[-1]);
305
+ error("?GREP-E-Bad pattern\n");
306
+ }
307
+
308
+ /*** Scan the file for the pattern in pbuf[] ***********/
309
+ void grep(FILE *fp, char *fn)
310
+ /* FILE *fp; // File to process */
311
+ /* char *fn; // File name (for -f option) */
312
+ {
313
+ int lno, count, m;
314
+
315
+ lno = 0;
316
+ count = 0;
317
+ while (fgets(lbuf, LMAX, fp)) {
318
+ ++lno;
319
+ m = match();
320
+ if ((m && !vflag) || (!m && vflag)) {
321
+ ++count;
322
+ if (!cflag) {
323
+ if (fflag && fn) {
324
+ file(fn);
325
+ fn = 0;
326
+ }
327
+ if (nflag)
328
+ printf("%d\t", lno);
329
+ printf("%s\n", lbuf);
330
+ }
331
+ }
332
+ }
333
+ if (cflag) {
334
+ if (fflag && fn)
335
+ file(fn);
336
+ printf("%d\n", count);
337
+ }
338
+ }
339
+
340
+ /*** Match line (lbuf) with pattern (pbuf) return 1 if match ***/
341
+ void match()
342
+ {
343
+ char *l; /* Line pointer */
344
+
345
+ for (l = lbuf; *l; ++l) {
346
+ if (pmatch(l, pbuf))
347
+ return(1);
348
+ }
349
+ return(0);
350
+ }
351
+
352
+ /*** Match partial line with pattern *******************/
353
+ char *pmatch(char *line, char *pattern)
354
+ /* char *line; // (partial) line to match */
355
+ /* char *pattern; // (partial) pattern to match */
356
+ {
357
+ char *l; /* Current line pointer */
358
+ char *p; /* Current pattern pointer */
359
+ char c; /* Current character */
360
+ char *e; /* End for STAR and PLUS match */
361
+ int op; /* Pattern operation */
362
+ int n; /* Class counter */
363
+ char *are; /* Start of STAR match */
364
+
365
+ l = line;
366
+ if (debug > 1)
367
+ printf("pmatch(\"%s\")\n", line);
368
+ p = pattern;
369
+ while ((op = *p++) != ENDPAT) {
370
+ if (debug > 1)
371
+ printf("byte[%d] = 0%o, '%c', op = 0%o\n",
372
+ l-line, *l, *l, op);
373
+ switch(op) {
374
+
375
+ case CHAR:
376
+ if (tolower(*l++) != *p++)
377
+ return(0);
378
+ break;
379
+
380
+ case BOL:
381
+ if (l != lbuf)
382
+ return(0);
383
+ break;
384
+
385
+ case EOL:
386
+ if (*l != '\0')
387
+ return(0);
388
+ break;
389
+
390
+ case ANY:
391
+ if (*l++ == '\0')
392
+ return(0);
393
+ break;
394
+
395
+ case DIGIT:
396
+ if ((c = *l++) < '0' || (c > '9'))
397
+ return(0);
398
+ break;
399
+
400
+ case ALPHA:
401
+ c = tolower(*l++);
402
+ if (c < 'a' || c > 'z')
403
+ return(0);
404
+ break;
405
+
406
+ case NALPHA:
407
+ c = tolower(*l++);
408
+ if (c >= 'a' && c <= 'z')
409
+ break;
410
+ else if (c < '0' || c > '9')
411
+ return(0);
412
+ break;
413
+
414
+ case PUNCT:
415
+ c = *l++;
416
+ if (c == 0 || c > ' ')
417
+ return(0);
418
+ break;
419
+
420
+ case CLASS:
421
+ case NCLASS:
422
+ c = tolower(*l++);
423
+ n = *p++ & 0377;
424
+ do {
425
+ if (*p == RANGE) {
426
+ p += 3;
427
+ n -= 2;
428
+ if (c >= p[-2] && c <= p[-1])
429
+ break;
430
+ }
431
+ else if (c == *p++)
432
+ break;
433
+ } while (--n > 1);
434
+ if ((op == CLASS) == (n <= 1))
435
+ return(0);
436
+ if (op == CLASS)
437
+ p += n - 2;
438
+ break;
439
+
440
+ case MINUS:
441
+ e = pmatch(l, p); /* Look for a match */
442
+ while (*p++ != ENDPAT); /* Skip over pattern */
443
+ if (e) /* Got a match? */
444
+ l = e; /* Yes, update string */
445
+ break; /* Always succeeds */
446
+
447
+ case PLUS: /* One or more ... */
448
+ if ((l = pmatch(l, p)) == 0)
449
+ return(0); /* Gotta have a match */
450
+ case STAR: /* Zero or more ... */
451
+ are = l; /* Remember line start */
452
+ while (*l && (e = pmatch(l, p)))
453
+ l = e; /* Get longest match */
454
+ while (*p++ != ENDPAT); /* Skip over pattern */
455
+ while (l >= are) { /* Try to match rest */
456
+ if (e = pmatch(l, p))
457
+ return(e);
458
+ --l; /* Nope, try earlier */
459
+ }
460
+ return(0); /* Nothing else worked */
461
+
462
+ default:
463
+ printf("Bad op code %d\n", op);
464
+ error("Cannot happen -- match\n");
465
+ }
466
+ }
467
+ return(l);
468
+ }
469
+
470
+ /*** Report an error ***********************************/
471
+ void error(char *s)
472
+ {
473
+ fprintf(stderr, "%s", s);
474
+ exit(1);
475
+ }
476
+
477
+ /*** Main program - parse arguments & grep *************/
478
+ int main(int argc, char **argv)
479
+ {
480
+ char *p;
481
+ int c, i;
482
+ int gotpattern;
483
+
484
+ FILE *f;
485
+
486
+ if (argc <= 1)
487
+ usage("No arguments");
488
+ if (argc == 2 && argv[1][0] == '?' && argv[1][1] == 0) {
489
+ help(documentation);
490
+ help(patdoc);
491
+ return 0;
492
+ }
493
+ nfile = argc-1;
494
+ gotpattern = 0;
495
+ for (i=1; i < argc; ++i) {
496
+ p = argv[i];
497
+ if (*p == '-') {
498
+ ++p;
499
+ while (c = *p++) {
500
+ switch(tolower(c)) {
501
+
502
+ case '?':
503
+ help(documentation);
504
+ break;
505
+
506
+ case 'C':
507
+ case 'c':
508
+ ++cflag;
509
+ break;
510
+
511
+ case 'D':
512
+ case 'd':
513
+ ++debug;
514
+ break;
515
+
516
+ case 'F':
517
+ case 'f':
518
+ ++fflag;
519
+ break;
520
+
521
+ case 'n':
522
+ case 'N':
523
+ ++nflag;
524
+ break;
525
+
526
+ case 'v':
527
+ case 'V':
528
+ ++vflag;
529
+ break;
530
+
531
+ default:
532
+ usage("Unknown flag");
533
+ }
534
+ }
535
+ argv[i] = 0;
536
+ --nfile;
537
+ } else if (!gotpattern) {
538
+ compile(p);
539
+ argv[i] = 0;
540
+ ++gotpattern;
541
+ --nfile;
542
+ }
543
+ }
544
+ if (!gotpattern)
545
+ usage("No pattern");
546
+ if (nfile == 0)
547
+ grep(stdin, 0);
548
+ else {
549
+ fflag = fflag ^ (nfile > 0);
550
+ for (i=1; i < argc; ++i) {
551
+ if (p = argv[i]) {
552
+ if ((f=fopen(p, "r")) == NULL)
553
+ cant(p);
554
+ else {
555
+ grep(f, p);
556
+ fclose(f);
557
+ }
558
+ }
559
+ }
560
+ }
561
+ return 0;
562
+ }
563
+
564
+ /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/