You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

fixcrlf.html 10 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>Apache Ant User Manual</title>
  5. </head>
  6. <body>
  7. <h2><a name="fixcrlf">FixCRLF</a></h2>
  8. <h3>Description</h3>
  9. <p>
  10. Adjusts a text file to local conventions.
  11. </p>
  12. <p>
  13. The set of files to be adjusted can be refined with the
  14. <i>includes</i>, <i>includesfile</i>, <i>excludes</i>,
  15. <i>excludesfile</i> and <i>defaultexcludes</i>
  16. attributes. Patterns provided through the <i>includes</i> or
  17. <i>includesfile</i> attributes specify files to be
  18. included. Patterns provided through the <i>exclude</i> or
  19. <i>excludesfile</i> attribute specify files to be
  20. excluded. Additionally, default exclusions can be specified with
  21. the <i>defaultexcludes</i> attribute. See the section on <a
  22. href="../dirtasks.html#directorybasedtasks">directory based
  23. tasks</a>, for details of file inclusion/exclusion patterns
  24. and their usage.
  25. </p>
  26. <p>This task forms an implicit <a href="../CoreTypes/fileset.html">FileSet</a> and
  27. supports all attributes of <code>&lt;fileset&gt;</code>
  28. (<code>dir</code> becomes <code>srcdir</code>) as well as the nested
  29. <code>&lt;include&gt;</code>, <code>&lt;exclude&gt;</code> and
  30. <code>&lt;patternset&gt;</code> elements.</p>
  31. <p>
  32. The output file is only written if it is a new file, or if it
  33. differs from the existing file. This prevents spurious
  34. rebuilds based on unchanged files which have been regenerated
  35. by this task.
  36. </p>
  37. <h3>Parameters</h3>
  38. <table border="1" cellpadding="2" cellspacing="0">
  39. <tr>
  40. <td valign="top"><b>Attribute</b></td>
  41. <td valign="top"><b>Description</b></td>
  42. <td align="center" valign="top"><b>Required</b></td>
  43. </tr>
  44. <tr>
  45. <td valign="top">srcDir</td>
  46. <td valign="top">Where to find the files to be fixed up.</td>
  47. <td valign="top" align="center">Yes</td>
  48. </tr>
  49. <tr>
  50. <td valign="top">destDir</td>
  51. <td valign="top">Where to place the corrected files. Defaults to
  52. srcDir (replacing the original file)</td>
  53. <td valign="top" align="center">No</td>
  54. </tr>
  55. <tr>
  56. <td valign="top">includes</td>
  57. <td valign="top">comma separated list of patterns of files that must be
  58. included. All files are included when omitted.</td>
  59. <td valign="top" align="center">No</td>
  60. </tr>
  61. <tr>
  62. <td valign="top">includesfile</td>
  63. <td valign="top">the name of a file. Each line of this file is
  64. taken to be an include pattern</td>
  65. <td valign="top" align="center">No</td>
  66. </tr>
  67. <tr>
  68. <td valign="top">excludes</td>
  69. <td valign="top">comma separated list of patterns of files that must be
  70. excluded. No files (except default excludes) are excluded when omitted.</td>
  71. <td valign="top" align="center">No</td>
  72. </tr>
  73. <tr>
  74. <td valign="top">excludesfile</td>
  75. <td valign="top">the name of a file. Each line of this file is
  76. taken to be an exclude pattern</td>
  77. <td valign="top" align="center">No</td>
  78. </tr>
  79. <tr>
  80. <td valign="top">defaultexcludes</td>
  81. <td valign="top">indicates whether default excludes should be used or not
  82. (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when omitted.</td>
  83. <td valign="top" align="center">No</td>
  84. </tr>
  85. <tr>
  86. <td valign="top">eol</td>
  87. <td valign="top">
  88. Specifies how end-of-line (EOL) characters are to be
  89. handled. The EOL characters are CR, LF and the pair CRLF.
  90. Valid values for this property are:
  91. <ul>
  92. <li>asis: leave EOL characters alone</li>
  93. <li>cr: convert all EOLs to a single CR</li>
  94. <li>lf: convert all EOLs to a single LF</li>
  95. <li>crlf: convert all EOLs to the pair CRLF</li>
  96. </ul>
  97. Default is based on the platform on which you are running
  98. this task. For Unix platforms, the default is &quot;lf&quot;.
  99. For DOS based systems (including Windows), the default is
  100. &quot;crlf&quot;. For Mac OS, the default is &quot;cr&quot;.
  101. <p>
  102. This is the preferred method for specifying EOL. The
  103. &quot;<i><b>cr</b></i>&quot; attribute (see below) is
  104. now deprecated.
  105. </p>
  106. <p>
  107. <i>N.B.</i>: One special case is recognized. The three
  108. characters CR-CR-LF are regarded as a single EOL.
  109. Unless this property is specified as &quot;asis&quot;,
  110. this sequence will be converted into the specified EOL
  111. type.
  112. </p>
  113. </td>
  114. <td valign="top" align="center">No</td>
  115. </tr>
  116. <tr>
  117. <td valign="top">cr</td>
  118. <td valign="top">
  119. <i><b>Deprecated.</b></i> Specifies how CR characters are
  120. to be handled at end-of-line (EOL). Valid values for this
  121. property are:
  122. <ul>
  123. <li>asis: leave EOL characters alone.</li>
  124. <li>
  125. add: add a CR before any single LF characters. The
  126. intent is to convert all EOLs to the pair CRLF.
  127. </li>
  128. <li>
  129. remove: remove all CRs from the file. The intent is
  130. to convert all EOLs to a single LF.
  131. </li>
  132. </ul>
  133. Default is based on the platform on which you are running
  134. this task. For Unix platforms, the default is &quot;remove&quot;.
  135. For DOS based systems (including Windows), the default is
  136. &quot;add&quot;.
  137. <p>
  138. <i>N.B.</i>: One special case is recognized. The three
  139. characters CR-CR-LF are regarded as a single EOL.
  140. Unless this property is specified as &quot;asis&quot;,
  141. this sequence will be converted into the specified EOL
  142. type.
  143. </p>
  144. </td>
  145. <td valign="top" align="center">No</td>
  146. </tr>
  147. <tr>
  148. <td valign="top">javafiles</td>
  149. <td valign="top">
  150. Used only in association with the
  151. &quot;<i><b>tab</b></i>&quot; attribute (see below), this
  152. boolean attribute indicates whether the fileset is a set
  153. of java source files
  154. (&quot;yes&quot;/&quot;no&quot;). Defaults to
  155. &quot;no&quot;. See notes in section on &quot;tab&quot;.
  156. </td>
  157. <td valign="top" align="center">No</td>
  158. </tr>
  159. <tr>
  160. <td valign="top">tab</td>
  161. <td valign="top">Specifies how tab characters are to be handled. Valid
  162. values for this property are:
  163. <ul>
  164. <li>add: convert sequences of spaces which span a tab stop to tabs</li>
  165. <li>asis: leave tab and space characters alone</li>
  166. <li>remove: convert tabs to spaces</li>
  167. </ul>
  168. Default for this parameter is &quot;asis&quot;.
  169. <p>
  170. <i>N.B.</i>: When the attribute
  171. &quot;<i><b>javafiles</b></i>&quot; (see above) is
  172. &quot;true&quot;, literal TAB characters occurring
  173. within Java string or character constants are never
  174. modified. This functionality also requires the
  175. recognition of Java-style comments.
  176. </p>
  177. <p>
  178. <i>N.B.</i>: There is an incompatibility between this
  179. and the previous version in the handling of white
  180. space at the end of lines. This version does
  181. <i><b>not</b></i> remove trailing whitespace on lines.
  182. </p>
  183. </td>
  184. <td valign="top" align="center">No</td>
  185. </tr>
  186. <tr>
  187. <td valign="top">tablength</td>
  188. <td valign="top">TAB character interval. Valid values are between
  189. 2 and 80 inclusive. The default for this parameter is 8.</td>
  190. <td valign="top" align="center">No</td>
  191. </tr>
  192. <tr>
  193. <td valign="top">eof</td>
  194. <td valign="top">Specifies how DOS end of file (control-Z) characters are
  195. to be handled. Valid values for this property are:
  196. <ul>
  197. <li>add: ensure that there is an EOF character at the end of the file</li>
  198. <li>asis: leave EOF characters alone</li>
  199. <li>remove: remove any EOF character found at the end</li>
  200. </ul>
  201. Default is based on the platform on which you are running this task.
  202. For Unix platforms, the default is remove. For DOS based systems
  203. (including Windows), the default is asis.
  204. </td>
  205. <td valign="top" align="center">No</td>
  206. </tr>
  207. <tr>
  208. <td valign="top">encoding</td>
  209. <td valign="top">The encoding of the files</td>
  210. <td align="center">No - defaults to default JVM encoding</td>
  211. </tr>
  212. </table>
  213. <h3>Examples</h3>
  214. <pre> &lt;fixcrlf srcdir=&quot;${src}&quot;
  215. eol=&quot;lf&quot; eof=&quot;remove&quot;
  216. includes=&quot;**/*.sh&quot;
  217. /&gt;</pre>
  218. <p>Replaces EOLs with LF characters and removes eof characters from
  219. the shell scripts. Tabs and spaces are left as is.</p>
  220. <pre> &lt;fixcrlf srcdir=&quot;${src}&quot;
  221. eol=&quot;crlf&quot;
  222. includes=&quot;**/*.bat&quot;
  223. /&gt;</pre>
  224. <p>Replaces all EOLs with cr-lf pairs in the batch files.
  225. Tabs and spaces are left as is.
  226. EOF characters are left alone if run on
  227. DOS systems, and are removed if run on Unix systems.</p>
  228. <pre> &lt;fixcrlf srcdir=&quot;${src}&quot;
  229. tabs=&quot;add&quot;
  230. includes=&quot;**/Makefile&quot;
  231. /&gt;</pre>
  232. <p>Sets EOLs according to local OS conventions, and
  233. converts sequences of spaces and tabs to the minimal set of spaces and
  234. tabs which will maintain spacing within the line. Tabs are
  235. set at 8 character intervals. EOF characters are left alone if
  236. run on DOS systems, and are removed if run on Unix systems.
  237. Many versions of make require tabs prior to commands.</p>
  238. <pre> &lt;fixcrlf srcdir=&quot;${src}&quot;
  239. tabs=&quot;remove&quot;
  240. tablength=&quot;3&quot;
  241. eol=&quot;lf&quot;
  242. javafiles=&quot;yes&quot;
  243. includes=&quot;**/*.java&quot;
  244. /&gt;</pre>
  245. <p>
  246. Converts all EOLs in the included java source files to a
  247. single LF. Replace all TAB characters except those in string
  248. or character constants with spaces, assuming a tab width of 3.
  249. If run on a unix system, any CTRL-Z EOF characters at the end
  250. of the file are removed. On DOS/Windows, any such EOF
  251. characters will be left untouched.
  252. </p>
  253. <pre> &lt;fixcrlf srcdir=&quot;${src}&quot;
  254. tabs=&quot;remove&quot;
  255. includes=&quot;**/README*&quot;
  256. /&gt;</pre>
  257. <p>Sets EOLs according to local OS conventions, and
  258. converts all tabs to spaces, assuming a tab width of 8.
  259. EOF characters are left alone if run on
  260. DOS systems, and are removed if run on Unix systems.
  261. You never know what editor a user will use to browse README's.</p>
  262. <hr>
  263. <p align="center">Copyright &copy; 2000,2001 Apache Software Foundation. All rights
  264. Reserved.</p>
  265. </body>
  266. </html>