diff --git a/Make/ConvertLineEndings b/Make/ConvertLineEndings new file mode 100644 index 0000000..69edee1 --- /dev/null +++ b/Make/ConvertLineEndings @@ -0,0 +1,134 @@ +#if 0 + +# ---------- START OF MPW SHELL SCRIPT ---------- + +# Get the root to work on. + +Set ToolPath "{0}Tool" +Set Repo "`Files -f "{0}" | StreamEdit -e '1 Replace /[Â:]*:[Â:]*°/ -n'`" +Set ObjFile "{TempFolder}ConvertLineEndingsTool.o" + + +# Make sure the fast C newline-replacer is available! + + +If "`Exists "{ToolPath}"`" == "" + SC -w off -o "{ObjFile}" "{0}" + ILink -d -t MPST -c 'MPS ' -o "{ToolPath}" "{Libraries}Stubs.o" "{CLibraries}StdCLib.o" "{Libraries}MacRuntime.o" "{Libraries}IntEnv.o" "{Libraries}Interface.o" "{ObjFile}" +End + + +# Run it! + +Echo "# Suggested command to convert TEXT file line-endings:" +Echo "{ToolPath} ¶¶" + +Files -f -r -o -s -t TEXT "{Repo}" | StreamEdit -e '1,° Change " " . " ¶¶"' +Echo " Dev:Null" + +Exit + +# ---------- END OF MPW SHELL SCRIPT ---------- + +#endif + +// ---------- START OF C PROGRAM ---------- + +#include + +int main(int argc, char **argv) +{ + long buflen = 0x1000000; + char *buf; + FILE *f; + int i; + int first_i = 1; + size_t didread; + char fromc = 10; + char toc = 13; + int didctr = 0, didntctr = 0; + + if(argc < 2) + { + printf("# USAGE: %s [-unix] FILE ...\n", argv[0]); + return 1; + } + + if(!strcmp(argv[first_i], "-unix")) + { + fromc = 13; + toc = 10; + first_i++; + } + + // Get the largest possible buffer + buf = (char *)malloc(buflen); + while(buflen && !buf) + { + buflen >>= 1; + buf = (char *)malloc(buflen); + } + + if(!buf) return 1; + + //printf("# %db buffer\n", buflen); + + for(i=first_i; iX "); + else + printf("# X> "); + didctr ++; + } + else + { + printf("# --- "); + didntctr++; + } + + printf("%s\n", argv[i]); + } + + printf("# Files changed: %d. Files unchanged: %d.\n", didctr, didntctr); + + return 0; +} + +// ---------- END OF C PROGRAM ---------- diff --git a/Make/SuggestFileTypes b/Make/SuggestFileTypes new file mode 100644 index 0000000..27233f2 --- /dev/null +++ b/Make/SuggestFileTypes @@ -0,0 +1,46 @@ +# Takes no arguments -- expects to be inside the Make directory, +# or run in place (select all, then cmd-return) + +If "{0}" == "" + Set 0 "{Active}" +End + +Set Tree "`Files -f "{0}" | StreamEdit -e '1 Replace /[Â:]*:[Â:]*°/ -n'`" + +If {#} == 1 + Set Tree "{1}" +Else If {#} == 0 + Set MyPath "`Files -f "{0}"`" + Set Tree "`Echo "{MyPath}" | StreamEdit -e '1 Replace /[Â:]*:[Â:]*°/ -n'`" +Else + Echo "# USAGE: {0} [PATH]" + Exit 1 +End + +Set Count 0 + +Echo "# Suggested commands:" + +For RootFolder in `Files -f "{Tree}" | StreamEdit -e '¥,° Replace /Å:.Å/ -n'` + For UntypedFile in `Files -f -r -o -s -t '' {RootFolder}` + Set NewT "TEXT" + Set NewC "MPS " + + If "{UntypedFile}" =~ /Å.x/ + Set NewT "XCOF" + Else If "{UntypedFile}" =~ /Å.o/ + Set NewT "OBJ " + Else If "{UntypedFile}" =~ /Å.lib/ + Set NewT "OBJ " + Else If "{UntypedFile}" =~ /Å.rsrc/ + Set NewT "rsrc" + Set NewC "RSED" + End + + Echo " SetFile -t ¶"{NewT}¶" -c ¶"{NewC}¶" ¶"{UntypedFile}¶"" + + Set Count `Evaluate {Count} + 1` + End +End + +Echo "# Total: {Count}"