Commit code, circa 2010

This commit is contained in:
2026-05-18 12:31:43 -04:00
commit e58e308366
5 changed files with 1163 additions and 0 deletions

41
wrap.c Executable file
View File

@@ -0,0 +1,41 @@
#include <stdio.h>
const char *usage = "\
wrap - wrap a text file.\n\
Usage: wrap <infile> <outfile>\n";
int main(int argc, char **argv)
{
if ( argc < 3 ) {
printf("%s", usage);
return 1;
}
FILE *in = fopen(argv[1], "r");
FILE *out = fopen(argv[2], "w");
int cn = 0;
char c = 0x00;
if ( !in || !out ) {
printf("Failed to open input/output file.\n");
in ? fclose(in) : 0 ;
out ? fclose(out) : 0 ;
return 1;
}
while ( !feof(in) ) {
c = fgetc(in);
if ( cn > 60 &&
( c == ' ' || c == '\n' || c == '\t' )) {
fputc('\n', out);
cn = 0;
if ( c != '\t' ) continue;
}
fputc(c, out);
cn++;
}
fclose(in);
fclose(out);
return 0;
}