
I'm taking a page from Dolphin's book, and including copies of each dependency's source code. This combines the ease of use of including pre-built libraries instead of needing to navigate a package manager - as is (or was) the case for MSVC - with the portability of using packages. Granted, this method's more of a jack of all trades, master of none, since it's *less* user-friendly than prebuilt packages (compilation times), and you don't get the per-distro compatibility fixes you'd get from a package manager. You can still use system libs if you want. In fact, it's still the default behaviour: compiling the libs manually is just a fallback. I'll add an option to force-enable this soon, however, since it's a nicer way to produce static MSYS2 builds than the hackish nightmare that I was using before. Not to mention, having my own copy of the sources means I can provide my own fixes and tweaks your package manager may not. For example, I can combine MSYS2's FreeType subpixel rendering with vcpkg's fix for SDL2 exporting its symbols in static builds.
65 lines
1.5 KiB
C
65 lines
1.5 KiB
C
/* fromdos.c : strip the stupid ^M characters without mistakes! */
|
|
|
|
/* this can do in-place conversion or be used as a pipe... */
|
|
|
|
#include <stdio.h>
|
|
#include <errno.h>
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
|
|
int main(int argc, char** argv) {
|
|
int f,c;
|
|
if (argc <= 1) {
|
|
if (isatty(0)) {
|
|
fprintf(stderr,"usage : %s <files>\nStrips ^M characters.\nCan do in-place conversion of many files or can be used in a pipe\n",argv[0]);
|
|
return 1;
|
|
}
|
|
for (;;) {
|
|
c = getchar();
|
|
while (c == '\r') {
|
|
c = getchar();
|
|
if (c != '\n') putchar(c);
|
|
}
|
|
if (c < 0) break;
|
|
putchar(c);
|
|
}
|
|
return 0;
|
|
}
|
|
for (f = 1; f < argc; f++) {
|
|
char* fname = argv[f];
|
|
char tempname[1024];
|
|
FILE* in = fopen(fname,"rb");
|
|
FILE* out;
|
|
int mod = 0;
|
|
if (!in) {
|
|
fprintf(stderr,"%s : %s\n", fname, strerror(errno));
|
|
return 1;
|
|
}
|
|
strcpy(tempname, fname);
|
|
strcat(tempname, ".temp");
|
|
out = fopen(tempname, "wb");
|
|
if (!out) {
|
|
fprintf(stderr,"%s : %s\n", fname, strerror(errno));
|
|
return 1;
|
|
}
|
|
for (;;) {
|
|
c = getc(in);
|
|
while (c == '\r') {
|
|
c = getc(in);
|
|
if (c == '\n') mod=1; else putc(c,out);
|
|
}
|
|
if (c < 0) break;
|
|
putc(c,out);
|
|
}
|
|
fclose(in);
|
|
fclose(out);
|
|
if (!mod) {
|
|
fprintf(stderr,"%s : no change\n", fname);
|
|
unlink(tempname);
|
|
} else if (rename(tempname, fname)) {
|
|
fprintf(stderr,"Can't mv %s %s : %s\n",tempname,fname,strerror(errno));
|
|
return 1;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|