summaryrefslogtreecommitdiffstatshomepage
path: root/src/tools
diff options
context:
space:
mode:
author Couriersud <couriersud@users.noreply.github.com>2013-12-26 20:13:05 +0000
committer Couriersud <couriersud@users.noreply.github.com>2013-12-26 20:13:05 +0000
commit93a381dd418996ca6a9fc8465db8b88b863d7cdf (patch)
treed8610fe2b6de78d72a49a920f02cea0a21cf53e8 /src/tools
parentbb022a9daefecea9a6dd3045eff682f2b44d8e90 (diff)
Added a dry-run option (-d) to srcclean. Know what you are doing :-) [Couriersud]
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/srcclean.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/src/tools/srcclean.c b/src/tools/srcclean.c
index ccdba13edda..5ac248e330d 100644
--- a/src/tools/srcclean.c
+++ b/src/tools/srcclean.c
@@ -81,24 +81,31 @@ int main(int argc, char *argv[])
int escape = 0;
int consume = 0;
const int tab_size = 4;
+ bool arg_found = true;
+ bool dry_run = false;
+
+ while (arg_found && argc > 1) {
+ if (strcmp(argv[1], "-u") == 0)
+ {
+ unix_le = true;
+ argc--;
+ argv++;
+ }
+ else if (strcmp(argv[1], "-d") == 0)
+ {
+ dry_run = true;
+ argc--;
+ argv++;
+ }
+ else
+ arg_found = false;
- /* print usage info */
- if (argc < 2)
- {
- printf("Usage:\nsrcclean [-u] <file>\n");
- return 0;
- }
-
- if (strcmp(argv[1], "-u") == 0)
- {
- unix_le = true;
- argc--;
- argv++;
}
+ /* print usage info */
if (argc < 2)
{
- printf("Usage:\nsrcclean [-u] <file>\n");
+ printf("Usage:\nsrcclean [-u] [-d] <file>\n");
return 0;
}
@@ -382,10 +389,13 @@ int main(int argc, char *argv[])
if (fixed_dos_style) printf(" fixed Dos-style line-ends");
printf("\n");
- /* write the file */
- file = fopen(argv[1], "wb");
- fwrite(modified, 1, dst, file);
- fclose(file);
+ if (!dry_run)
+ {
+ /* write the file */
+ file = fopen(argv[1], "wb");
+ fwrite(modified, 1, dst, file);
+ fclose(file);
+ }
}
return 0;