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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>FixCRLF Task</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- or space-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- or space-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. <li>mac: convert all EOLs to a single CR</li>
  97. <li>unix: convert all EOLs to a single LF</li>
  98. <li>dos: convert all EOLs to the pair CRLF</li>
  99. </ul>
  100. Default is based on the platform on which you are running
  101. this task. For Unix platforms, the default is &quot;lf&quot;.
  102. For DOS based systems (including Windows), the default is
  103. &quot;crlf&quot;. For Mac OS, the default is &quot;cr&quot;.
  104. <p>
  105. This is the preferred method for specifying EOL. The
  106. &quot;<i><b>cr</b></i>&quot; attribute (see below) is
  107. now deprecated.
  108. </p>
  109. <p>
  110. <i>N.B.</i>: One special case is recognized. The three
  111. characters CR-CR-LF are regarded as a single EOL.
  112. Unless this property is specified as &quot;asis&quot;,
  113. this sequence will be converted into the specified EOL
  114. type.
  115. </p>
  116. </td>
  117. <td valign="top" align="center">No</td>
  118. </tr>
  119. <tr>
  120. <td valign="top">cr</td>
  121. <td valign="top">
  122. <i><b>Deprecated.</b></i> Specifies how CR characters are
  123. to be handled at end-of-line (EOL). Valid values for this
  124. property are:
  125. <ul>
  126. <li>asis: leave EOL characters alone.</li>
  127. <li>
  128. add: add a CR before any single LF characters. The
  129. intent is to convert all EOLs to the pair CRLF.
  130. </li>
  131. <li>
  132. remove: remove all CRs from the file. The intent is
  133. to convert all EOLs to a single LF.
  134. </li>
  135. </ul>
  136. Default is based on the platform on which you are running
  137. this task. For Unix platforms, the default is &quot;remove&quot;.
  138. For DOS based systems (including Windows), the default is
  139. &quot;add&quot;.
  140. <p>
  141. <i>N.B.</i>: One special case is recognized. The three
  142. characters CR-CR-LF are regarded as a single EOL.
  143. Unless this property is specified as &quot;asis&quot;,
  144. this sequence will be converted into the specified EOL
  145. type.
  146. </p>
  147. </td>
  148. <td valign="top" align="center">No</td>
  149. </tr>
  150. <tr>
  151. <td valign="top">javafiles</td>
  152. <td valign="top">
  153. Used only in association with the
  154. &quot;<i><b>tab</b></i>&quot; attribute (see below), this
  155. boolean attribute indicates whether the fileset is a set
  156. of java source files
  157. (&quot;yes&quot;/&quot;no&quot;). Defaults to
  158. &quot;no&quot;. See notes in section on &quot;tab&quot;.
  159. </td>
  160. <td valign="top" align="center">No</td>
  161. </tr>
  162. <tr>
  163. <td valign="top">tab</td>
  164. <td valign="top">Specifies how tab characters are to be handled. Valid
  165. values for this property are:
  166. <ul>
  167. <li>add: convert sequences of spaces which span a tab stop to tabs</li>
  168. <li>asis: leave tab and space characters alone</li>
  169. <li>remove: convert tabs to spaces</li>
  170. </ul>
  171. Default for this parameter is &quot;asis&quot;.
  172. <p>
  173. <i>N.B.</i>: When the attribute
  174. &quot;<i><b>javafiles</b></i>&quot; (see above) is
  175. &quot;true&quot;, literal TAB characters occurring
  176. within Java string or character constants are never
  177. modified. This functionality also requires the
  178. recognition of Java-style comments.
  179. </p>
  180. <p>
  181. <i>N.B.</i>: There is an incompatibility between this
  182. and the previous version in the handling of white
  183. space at the end of lines. This version does
  184. <i><b>not</b></i> remove trailing whitespace on lines.
  185. </p>
  186. </td>
  187. <td valign="top" align="center">No</td>
  188. </tr>
  189. <tr>
  190. <td valign="top">tablength</td>
  191. <td valign="top">TAB character interval. Valid values are between
  192. 2 and 80 inclusive. The default for this parameter is 8.</td>
  193. <td valign="top" align="center">No</td>
  194. </tr>
  195. <tr>
  196. <td valign="top">eof</td>
  197. <td valign="top">Specifies how DOS end of file (control-Z) characters are
  198. to be handled. Valid values for this property are:
  199. <ul>
  200. <li>add: ensure that there is an EOF character at the end of the file</li>
  201. <li>asis: leave EOF characters alone</li>
  202. <li>remove: remove any EOF character found at the end</li>
  203. </ul>
  204. Default is based on the platform on which you are running this task.
  205. For Unix platforms, the default is remove. For DOS based systems
  206. (including Windows), the default is asis.
  207. </td>
  208. <td valign="top" align="center">No</td>
  209. </tr>
  210. <tr>
  211. <td valign="top">encoding</td>
  212. <td valign="top">The encoding of the files</td>
  213. <td align="center">No - defaults to default JVM encoding</td>
  214. </tr>
  215. <tr>
  216. <td valign="top">fixlast</td>
  217. <td valign="top">Whether to add a missing EOL to the last line
  218. of a processed file. (Since ant 1.6.1)</td>
  219. <td align="center">No - default is <i>true</i></td>
  220. </tr>
  221. </table>
  222. <h3>Examples</h3>
  223. <pre> &lt;fixcrlf srcdir=&quot;${src}&quot;
  224. eol=&quot;lf&quot;
  225. eof=&quot;remove&quot;
  226. includes=&quot;**/*.sh&quot;
  227. /&gt;</pre>
  228. <p>Replaces EOLs with LF characters and removes eof characters from
  229. the shell scripts. Tabs and spaces are left as is.</p>
  230. <pre> &lt;fixcrlf srcdir=&quot;${src}&quot;
  231. eol=&quot;crlf&quot;
  232. includes=&quot;**/*.bat&quot;
  233. /&gt;</pre>
  234. <p>Replaces all EOLs with cr-lf pairs in the batch files.
  235. Tabs and spaces are left as is.
  236. EOF characters are left alone if run on
  237. DOS systems, and are removed if run on Unix systems.</p>
  238. <pre> &lt;fixcrlf srcdir=&quot;${src}&quot;
  239. tab=&quot;add&quot;
  240. includes=&quot;**/Makefile&quot;
  241. /&gt;</pre>
  242. <p>Sets EOLs according to local OS conventions, and
  243. converts sequences of spaces and tabs to the minimal set of spaces and
  244. tabs which will maintain spacing within the line. Tabs are
  245. set at 8 character intervals. EOF characters are left alone if
  246. run on DOS systems, and are removed if run on Unix systems.
  247. Many versions of make require tabs prior to commands.</p>
  248. <pre> &lt;fixcrlf srcdir=&quot;${src}&quot;
  249. tab=&quot;remove&quot;
  250. tablength=&quot;3&quot;
  251. eol=&quot;lf&quot;
  252. javafiles=&quot;yes&quot;
  253. includes=&quot;**/*.java&quot;
  254. /&gt;</pre>
  255. <p>
  256. Converts all EOLs in the included java source files to a
  257. single LF. Replace all TAB characters except those in string
  258. or character constants with spaces, assuming a tab width of 3.
  259. If run on a unix system, any CTRL-Z EOF characters at the end
  260. of the file are removed. On DOS/Windows, any such EOF
  261. characters will be left untouched.
  262. </p>
  263. <pre> &lt;fixcrlf srcdir=&quot;${src}&quot;
  264. tab=&quot;remove&quot;
  265. includes=&quot;**/README*&quot;
  266. /&gt;</pre>
  267. <p>Sets EOLs according to local OS conventions, and
  268. converts all tabs to spaces, assuming a tab width of 8.
  269. EOF characters are left alone if run on
  270. DOS systems, and are removed if run on Unix systems.
  271. You never know what editor a user will use to browse README's.</p>
  272. <hr>
  273. <p align="center">Copyright &copy; 2000-2004 The Apache Software Foundation. All rights
  274. Reserved.</p>
  275. </body>
  276. </html>