Previous 199869 Revisions Next

r26766 Thursday 26th December, 2013 at 20:13:05 UTC by Couriersud
Added a dry-run option (-d) to srcclean. Know what you are doing :-) [Couriersud]
[src/tools]srcclean.c

trunk/src/tools/srcclean.c
r26765r26766
8181   int escape = 0;
8282   int consume = 0;
8383   const int tab_size = 4;
84   bool arg_found = true;
85   bool dry_run = false;
8486
85   /* print usage info */
86   if (argc < 2)
87   {
88      printf("Usage:\nsrcclean [-u] <file>\n");
89      return 0;
90   }
87   while (arg_found && argc > 1) {
88       if (strcmp(argv[1], "-u") == 0)
89       {
90           unix_le = true;
91           argc--;
92           argv++;
93       }
94       else if (strcmp(argv[1], "-d") == 0)
95        {
96            dry_run = true;
97            argc--;
98            argv++;
99        }
100       else
101           arg_found = false;
91102
92   if (strcmp(argv[1], "-u") == 0)
93   {
94        unix_le = true;
95        argc--;
96        argv++;
97103   }
98104
105    /* print usage info */
99106    if (argc < 2)
100107    {
101        printf("Usage:\nsrcclean [-u] <file>\n");
108        printf("Usage:\nsrcclean [-u] [-d] <file>\n");
102109        return 0;
103110    }
104111
r26765r26766
382389        if (fixed_dos_style) printf(" fixed Dos-style line-ends");
383390      printf("\n");
384391
385      /* write the file */
386      file = fopen(argv[1], "wb");
387        fwrite(modified, 1, dst, file);
388      fclose(file);
392      if (!dry_run)
393      {
394           /* write the file */
395           file = fopen(argv[1], "wb");
396           fwrite(modified, 1, dst, file);
397           fclose(file);
398      }
389399   }
390400
391401   return 0;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team