mirror of
git://projects.qi-hardware.com/wernermisc.git
synced 2024-11-15 16:47:10 +02:00
61 lines
784 B
C
61 lines
784 B
C
|
#include <stdlib.h>
|
||
|
#include <stdio.h>
|
||
|
|
||
|
#include "compiler.h"
|
||
|
|
||
|
|
||
|
#define BUF_SIZE 1000000
|
||
|
|
||
|
|
||
|
static void report(const char *s)
|
||
|
{
|
||
|
fprintf(stderr, "%s\n", s);
|
||
|
}
|
||
|
|
||
|
|
||
|
static void usage(const char *name)
|
||
|
{
|
||
|
fprintf(stderr, "usage: %s patch-file [loops]\n", name);
|
||
|
exit(1);
|
||
|
}
|
||
|
|
||
|
|
||
|
int main(int argc, char **argv)
|
||
|
{
|
||
|
char buf[BUF_SIZE];
|
||
|
const char *name;
|
||
|
FILE *file;
|
||
|
size_t got;
|
||
|
int loops = 1;
|
||
|
int i;
|
||
|
|
||
|
switch (argc) {
|
||
|
case 2:
|
||
|
break;
|
||
|
case 3:
|
||
|
loops = atoi(argv[2]);
|
||
|
break;
|
||
|
default:
|
||
|
usage(*argv);
|
||
|
}
|
||
|
|
||
|
name = argv[1];
|
||
|
file = fopen(name, "r");
|
||
|
if (!file) {
|
||
|
perror(name);
|
||
|
exit(1);
|
||
|
}
|
||
|
got = fread(buf, sizeof(buf)-1, 1, file);
|
||
|
if (got < 0) {
|
||
|
perror(name);
|
||
|
exit(1);
|
||
|
}
|
||
|
buf[got] = 0;
|
||
|
fclose(file);
|
||
|
|
||
|
for (i = 0; i != loops; i++)
|
||
|
patch_compile(buf, report);
|
||
|
|
||
|
return 0;
|
||
|
}
|