fixincl.tpl 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. [= AutoGen5 Template -*- Mode: C -*-
  2. x=fixincl.x =]
  3. [=
  4. (if (version-compare >= autogen-version "5.18.1")
  5. (dne "-D" " * " "/* ")
  6. (dne " * " "/* ") ) =]
  7. */
  8. /* DO NOT SVN-MERGE THIS FILE, EITHER [=
  9. (define re-ct 0) (define max-mach 0) (define ct 0)
  10. (define HACK "") (define Hack "") (define tmp "")
  11. (shell "date") =]
  12. *
  13. * You must regenerate it. Use the ./genfixes script.
  14. *
  15. *
  16. * This is part of the fixincl program used to install modified versions of
  17. * certain ANSI-incompatible system header files which are fixed to work
  18. * correctly with ANSI C and placed in a directory that GNU C will search.
  19. *
  20. * This file contains [=(count "fix")=] fixup descriptions.
  21. *
  22. * See README for more information.
  23. *
  24. * inclhack copyright (c) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
  25. * 2006, 2007, 2008
  26. * The Free Software Foundation, Inc.
  27. *
  28. * inclhack is free software: you can redistribute it and/or modify it
  29. * under the terms of the GNU General Public License as published by the
  30. * Free Software Foundation, either version 3 of the License, or
  31. * (at your option) any later version.
  32. *
  33. * inclhack is distributed in the hope that it will be useful, but
  34. * WITHOUT ANY WARRANTY; without even the implied warranty of
  35. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  36. * See the GNU General Public License for more details.
  37. *
  38. * You should have received a copy of the GNU General Public License along
  39. * with this program. If not, see <http://www.gnu.org/licenses/>.
  40. */
  41. #ifndef SED_PROGRAM
  42. #define SED_PROGRAM "/usr/bin/sed"
  43. #endif
  44. static char const sed_cmd_z[] = SED_PROGRAM;
  45. [=
  46. FOR fix =]
  47. /* * * * * * * * * * * * * * * * * * * * * * * * * *
  48. *
  49. * Description of [=
  50. (set! Hack (string-capitalize! (get "hackname")))
  51. (set! HACK (string-upcase! (get "hackname")))
  52. (if (and (not (exist? "test_text")) (not (exist? "replace")))
  53. (error (sprintf "include fix '%s' has no test text" Hack )) )
  54. (. Hack)=] fix
  55. */[=
  56. # Note that this is not just for debugging purposes, but in case
  57. some C fix wishes to refer to the regexps it is paired with.
  58. See commentary at the top of fixfixes.c.
  59. =]
  60. tSCC z[=(. Hack)=]Name[] =
  61. "[=hackname=]";
  62. /*
  63. * File name selection pattern
  64. */[=
  65. IF (exist? "files") =]
  66. tSCC z[=(. Hack)=]List[] =
  67. "[= (join "\\0" (stack "files")) =]\0";[=
  68. ELSE =]
  69. #define z[=(. Hack)=]List (char*)NULL[=
  70. ENDIF (exist? "files") =]
  71. /*
  72. * Machine/OS name selection pattern
  73. */[=
  74. IF (exist? "mach") =]
  75. tSCC* apz[=(. Hack)=]Machs[] = {[=
  76. (set! ct 0) =][=
  77. FOR mach =]
  78. [=
  79. (set! tmp (get "mach"))
  80. (set! ct (+ ct (string-length tmp) 5))
  81. (kr-string tmp)=],[=
  82. ENDFOR =]
  83. (const char*)NULL };[=
  84. (if (> ct max-mach) (set! max-mach ct)) =][=
  85. ELSE =]
  86. #define apz[=(. Hack)=]Machs (const char**)NULL[=
  87. ENDIF (exist? "mach") =][=
  88. IF (exist? "select")=]
  89. /*
  90. * content selection pattern - do fix if pattern found
  91. */[=
  92. FOR select =]
  93. tSCC z[=(. Hack)=]Select[=(for-index)=][] =
  94. [=(kr-string (get "select"))=];[=
  95. ENDFOR select =][=
  96. ENDIF =][=
  97. IF (exist? "bypass") =]
  98. /*
  99. * content bypass pattern - skip fix if pattern found
  100. */[=
  101. FOR bypass =]
  102. tSCC z[=(. Hack)=]Bypass[=(for-index)=][] =
  103. [=(kr-string (get "bypass"))=];[=
  104. ENDFOR bypass =][=
  105. ENDIF =][=
  106. IF (exist? "sum")=][=
  107. (if (not (exist? "files"))
  108. (error "specifying a 'sum' requires specifying 'files'"))
  109. =]
  110. /*
  111. * file selection - do fix if checksum matches
  112. */[=
  113. FOR sum =]
  114. tSCC z[=(. Hack)=]Sum[=(for-index)=][] =
  115. [=(kr-string (get "sum"))=];[=
  116. ENDFOR sum =][=
  117. ENDIF =][=
  118. IF (exist? "test") =]
  119. /*
  120. * perform the 'test' shell command - do fix on success
  121. */[=
  122. FOR test =]
  123. tSCC z[=(. Hack)=]Test[=(for-index)=][] =
  124. [=(kr-string (get "test"))=];[=
  125. ENDFOR =][=
  126. ENDIF =][=
  127. IF (exist? "c_test") =]
  128. /*
  129. * perform the C function call test
  130. */[=
  131. FOR c_test =]
  132. tSCC z[=(. Hack)=]FTst[=(for-index)=][] = "[=c_test=]";[=
  133. ENDFOR c_test =][=
  134. ENDIF =][=
  135. IF (set! ct (+ (count "select") (count "bypass")
  136. (count "test") (count "c_test")))
  137. (= ct 0)
  138. =]
  139. #define [=(. HACK)=]_TEST_CT 0
  140. #define a[=(. Hack)=]Tests (tTestDesc*)NULL[=
  141. ELSE =]
  142. #define [=(. HACK)=]_TEST_CT [=(. ct)=][=
  143. (set! re-ct (+ re-ct (count "select") (count "bypass"))) =]
  144. static tTestDesc a[=(. Hack)=]Tests[] = {[=
  145. FOR test =]
  146. { TT_TEST, z[=(. Hack)=]Test[=(for-index)=], 0 /* unused */ },[=
  147. ENDFOR test =][=
  148. FOR c_test =]
  149. { TT_FUNCTION, z[=(. Hack)=]FTst[=(for-index)=], 0 /* unused */ },[=
  150. ENDFOR c_test =][=
  151. FOR bypass =]
  152. { TT_NEGREP, z[=(. Hack)=]Bypass[=(for-index)=], (regex_t*)NULL },[=
  153. ENDFOR bypass =][=
  154. FOR select =]
  155. { TT_EGREP, z[=(. Hack)=]Select[=(for-index)=], (regex_t*)NULL },[=
  156. ENDFOR select =][=
  157. FOR sum =]
  158. { TT_CKSUM, z[=(. Hack)=]Sum[=(for-index)=], 0 /* unused */ },[=
  159. ENDFOR sum =] };[=
  160. ENDIF =]
  161. /*
  162. * Fix Command Arguments for [=(. Hack)=]
  163. */
  164. static const char* apz[=(. Hack)=]Patch[] = {[=
  165. IF (exist? "sed")=] sed_cmd_z[=
  166. FOR sed=],
  167. "-e", [=(kr-string (get "sed"))=][=
  168. ENDFOR sed=],[=
  169. ELIF (exist? "shell")=] "sh", "-c",
  170. [=(kr-string (get "shell"))=],[=
  171. ELIF (exist? "c_fix")=]
  172. [=(kr-string (get "c_fix"))=],[=
  173. FOR c_fix_arg =]
  174. [=(kr-string (get "c_fix_arg"))=],[=
  175. ENDFOR c_fix_arg =][=
  176. ELIF (> (len "replace") 0) =]
  177. [=(kr-string (get "replace"))=],[=
  178. ENDIF=]
  179. (char*)NULL };
  180. [=ENDFOR fix=]
  181. /* * * * * * * * * * * * * * * * * * * * * * * * * *
  182. *
  183. * List of all fixes
  184. */[=
  185. # as of this writing, 49 bytes are needed by the case statement format.
  186. We also must allow for the size of the target machine machine name.
  187. This allows for a 79 byte machine name. Better be enough.
  188. =]
  189. #define REGEX_COUNT [= (. re-ct) =]
  190. #define MACH_LIST_SIZE_LIMIT [= (+ 128 max-mach) =]
  191. #define FIX_COUNT [= (count "fix") =]
  192. /*
  193. * Enumerate the fixes[= # in a way that minimizes diffs :-) =]
  194. */
  195. typedef enum {[=
  196. FOR fix "," =]
  197. [=(string-upcase! (get "hackname"))=]_FIXIDX[=
  198. ENDFOR
  199. =]
  200. } t_fixinc_idx;
  201. tFixDesc fixDescList[ FIX_COUNT ] = {[=
  202. FOR fix ",\n" =][=
  203. (set! Hack (string-capitalize! (get "hackname")))
  204. (set! HACK (string-upcase! (get "hackname"))) =]
  205. { z[=(. Hack)=]Name, z[=(. Hack)=]List,
  206. apz[=(. Hack)=]Machs,
  207. [=(. HACK)=]_TEST_CT, [=
  208. IF (exist? "not_machine") =]FD_MACH_IFNOT[=
  209. ELSE =]FD_MACH_ONLY[=
  210. ENDIF =][=
  211. IF (exist? "shell") =] | FD_SHELL_SCRIPT[=
  212. ELIF (exist? "c_fix") =] | FD_SUBROUTINE[=
  213. ELIF (exist? "replace") =] | FD_REPLACEMENT[=
  214. ENDIF =],
  215. a[=(. Hack)=]Tests, apz[=(. Hack)=]Patch, 0 }[=
  216. ENDFOR =]
  217. };