Previous 199869 Revisions Next

r20205 Friday 11th January, 2013 at 19:41:08 UTC by smf
remove extraneous line continuation characters followed by a blank line and blank lines that follow an opening brace in c files. [smf]
[src/tools]srcclean.c

trunk/src/tools/srcclean.c
r20204r20205
7070   int removed_tabs = 0;
7171   int added_tabs = 0;
7272   int removed_spaces = 0;
73   int removed_continuations = 0;
7374   int fixed_mac_style = 0;
7475   int fixed_nix_style = 0;
7576   int added_newline = 0;
r20204r20205
203204      /* if we hit a CR or LF, clean up from there */
204205      else if (ch == 0x0d || ch == 0x0a)
205206      {
206         /* remove all extra spaces/tabs at the end */
207         while (dst > 0 && (modified[dst-1] == ' ' || modified[dst-1] == 0x09))
207         while (true)
208208         {
209            removed_spaces++;
210            dst--;
209            /* remove all extra spaces/tabs at the end */
210            if (dst > 0 && (modified[dst-1] == ' ' || modified[dst-1] == 0x09))
211            {
212               removed_spaces++;
213               dst--;
214            }
215            /* remove extraneous line continuation followed by a blank line */
216            else if (is_c_file && dst > 2 && modified[dst-3] == '\\' && modified[dst-2] == 0x0d && modified[dst-1]==0x0a)
217            {
218               removed_continuations++;
219               dst -= 3;
220            }
221            /* remove blank lines following an opening brace */
222            else if (is_c_file && !in_multiline_comment && dst > 2 && modified[dst-3] == '{' && modified[dst-2] == 0x0d && modified[dst-1]==0x0a)
223            {
224               removed_newlines++;
225               dst -= 2;
226            }
227            else
228            {
229               break;
230            }
211231         }
212232
213233         /* insert a proper CR/LF */
r20204r20205
339359      /* explain what we did */
340360      printf("Cleaned up %s:", argv[1]);
341361      if (added_newline) printf(" added newline at end of file");
342      if (removed_newlines) printf(" removed %d newline(s) at end of file", removed_newlines);
362      if (removed_newlines) printf(" removed %d newline(s)", removed_newlines);
343363      if (removed_spaces) printf(" removed %d space(s)", removed_spaces);
364      if (removed_continuations) printf(" removed %d continuation(s)", removed_continuations);
344365      if (removed_tabs) printf(" removed %d tab(s)", removed_tabs);
345366      if (added_tabs) printf(" added %d tab(s)", added_tabs);
346367      if (hichars) printf(" fixed %d high-ASCII char(s)", hichars);

Previous 199869 Revisions Next


© 1997-2024 The MAME Team