diff options
author | Couriersud <couriersud@users.noreply.github.com> | 2013-12-26 00:17:36 +0000 |
---|---|---|
committer | Couriersud <couriersud@users.noreply.github.com> | 2013-12-26 00:17:36 +0000 |
commit | e73ee5e6ed4a13758b2f3d9584969cb97f9dd23e (patch) | |
tree | 93ea0bfb6bfb289b1573f9d088e8a4d870dc5602 /src/tools | |
parent | 1b83a5b72941008f39cf72cf8e88052a3121331e (diff) |
Added a "-u" (for unix) flag to srcclean to produce unix-style endings. [Couriersud]
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/srcclean.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/tools/srcclean.c b/src/tools/srcclean.c index f8930e58eb9..ca2e9eb8fdb 100644 --- a/src/tools/srcclean.c +++ b/src/tools/srcclean.c @@ -38,10 +38,12 @@ static UINT8 modified[MAX_FILE_SIZE]; int main(int argc, char *argv[]) { + bool unix_le = false; int removed_tabs = 0; int added_tabs = 0; int removed_spaces = 0; int removed_continuations = 0; + int fixed_dos_style = 0; int fixed_mac_style = 0; int fixed_nix_style = 0; int added_newline = 0; @@ -64,12 +66,25 @@ int main(int argc, char *argv[]) const int tab_size = 4; /* print usage info */ - if (argc != 2) + if (argc < 2) { - printf("Usage:\nsrcclean <file>\n"); + printf("Usage:\nsrcclean [-u] <file>\n"); return 0; } + if (strcmp(argv[1], "-u") == 0) + { + unix_le = true; + argc--; + argv++; + } + + if (argc < 2) + { + printf("Usage:\nsrcclean [-u] <file>\n"); + return 0; + } + /* read the file */ file = fopen(argv[1], "rb"); if (file == NULL) @@ -202,13 +217,18 @@ int main(int argc, char *argv[]) } /* insert a proper CR/LF */ - modified[dst++] = 0x0d; + if (!unix_le) + modified[dst++] = 0x0d; modified[dst++] = 0x0a; col = 0; /* skip over any LF in the source file */ if (ch == 0x0d && original[src] == 0x0a) - src++; + { + src++; + if (unix_le) + fixed_dos_style = 1; + } else if (ch == 0x0a) fixed_nix_style = 1; else @@ -338,6 +358,7 @@ int main(int argc, char *argv[]) if (hichars) printf(" fixed %d high-ASCII char(s)", hichars); if (fixed_nix_style) printf(" fixed *nix-style line-ends"); if (fixed_mac_style) printf(" fixed Mac-style line-ends"); + if (fixed_dos_style) printf(" fixed Dos-style line-ends"); printf("\n"); /* write the file */ |