summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cfile.c12
-rw-r--r--cfile8.c14
2 files changed, 15 insertions, 11 deletions
diff --git a/cfile.c b/cfile.c
index b06c1d8..72e0ebd 100644
--- a/cfile.c
+++ b/cfile.c
@@ -21,7 +21,7 @@ int main(int argc, char *argv[])
{
if (!(in=fopen(argv[1],"rb")))
{
- perror(argv[0]);
+ perror(argv[1]);
}
}
@@ -29,7 +29,7 @@ int main(int argc, char *argv[])
{
if (!(out=fopen(argv[2],"w")))
{
- perror(argv[0]);
+ perror(argv[2]);
}
}
@@ -54,10 +54,10 @@ int main(int argc, char *argv[])
first=1;
len=0;
+ fread(&num,sizeof(unsigned long),1,in);
+
while(!feof(in))
{
- fread(&num,sizeof(unsigned long),1,in);
-
if (col==0)
{
if (first)
@@ -75,11 +75,13 @@ int main(int argc, char *argv[])
fprintf(out,",");
}
- fprintf(out,"0x%.8x",num);
+ fprintf(out,"0x%.8lx",num);
col=(col+1)%4;
num=0;
len++;
+
+ fread(&num,sizeof(unsigned long),1,in);
}
fprintf(out,"\n\t\t\t};\n#define %s_LEN %d\n", name, len);
diff --git a/cfile8.c b/cfile8.c
index 647e1d5..c41878a 100644
--- a/cfile8.c
+++ b/cfile8.c
@@ -21,7 +21,7 @@ int main(int argc, char *argv[])
{
if (!(in=fopen(argv[1],"rb")))
{
- perror(argv[0]);
+ perror(argv[1]);
}
}
@@ -29,7 +29,7 @@ int main(int argc, char *argv[])
{
if (!(out=fopen(argv[2],"w")))
{
- perror(argv[0]);
+ perror(argv[2]);
}
}
@@ -54,10 +54,10 @@ int main(int argc, char *argv[])
first=1;
len=0;
- while(!feof(in))
- {
- fread(&num,sizeof num,1,in);
+ fread(&num,sizeof num,1,in);
+ while(!feof(in))
+ {
if (col==0)
{
if (first)
@@ -80,7 +80,9 @@ int main(int argc, char *argv[])
col=(col+1)%8;
num=0;
len++;
- }
+
+ fread(&num,sizeof num,1,in);
+ }
fprintf(out,"\n\t};\n#define %s_LEN %d\n", name, len);