Previous 199869 Revisions Next

r26755 Thursday 26th December, 2013 at 00:17:36 UTC by Couriersud
Added a "-u" (for unix) flag to srcclean to produce unix-style endings. [Couriersud]
[src/tools]srcclean.c

trunk/src/tools/srcclean.c
r26754r26755
3838
3939int main(int argc, char *argv[])
4040{
41    bool unix_le = false;
4142   int removed_tabs = 0;
4243   int added_tabs = 0;
4344   int removed_spaces = 0;
4445   int removed_continuations = 0;
46    int fixed_dos_style = 0;
4547   int fixed_mac_style = 0;
4648   int fixed_nix_style = 0;
4749   int added_newline = 0;
r26754r26755
6466   const int tab_size = 4;
6567
6668   /* print usage info */
67   if (argc != 2)
69   if (argc < 2)
6870   {
69      printf("Usage:\nsrcclean <file>\n");
71      printf("Usage:\nsrcclean [-u] <file>\n");
7072      return 0;
7173   }
7274
75   if (strcmp(argv[1], "-u") == 0)
76   {
77        unix_le = true;
78        argc--;
79        argv++;
80   }
81
82    if (argc < 2)
83    {
84        printf("Usage:\nsrcclean [-u] <file>\n");
85        return 0;
86    }
87
7388   /* read the file */
7489   file = fopen(argv[1], "rb");
7590   if (file == NULL)
r26754r26755
202217         }
203218
204219         /* insert a proper CR/LF */
205         modified[dst++] = 0x0d;
220         if (!unix_le)
221             modified[dst++] = 0x0d;
206222         modified[dst++] = 0x0a;
207223         col = 0;
208224
209225         /* skip over any LF in the source file */
210226         if (ch == 0x0d && original[src] == 0x0a)
211            src++;
227         {
228                src++;
229                if (unix_le)
230                    fixed_dos_style = 1;
231         }
212232         else if (ch == 0x0a)
213233            fixed_nix_style = 1;
214234         else
r26754r26755
338358      if (hichars) printf(" fixed %d high-ASCII char(s)", hichars);
339359      if (fixed_nix_style) printf(" fixed *nix-style line-ends");
340360      if (fixed_mac_style) printf(" fixed Mac-style line-ends");
361        if (fixed_dos_style) printf(" fixed Dos-style line-ends");
341362      printf("\n");
342363
343364      /* write the file */

Previous 199869 Revisions Next


© 1997-2024 The MAME Team