huffman progress, scripting

This commit is contained in:
Christoph J. Scherr 2022-11-25 00:14:31 +01:00
parent baea9ae9be
commit 96d374eeb7
5 changed files with 182 additions and 184 deletions

View File

@ -3,7 +3,9 @@ returnCode=0
echo -e "compiling all files in working directory $(pwd)\n" echo -e "compiling all files in working directory $(pwd)\n"
for file in $(/bin/ls *.c); for file in $(/bin/ls *.c);
do do
./compile.sh $file; echo "compiling $file ..."
noext=$(echo "$file" | cut -f 1 -d '.')
gcc $file -o bin/$noext -lm
if [ "$?" -ne 0 ] if [ "$?" -ne 0 ]
then then
echo -e "\nERROR: could not compile $file !\n"; echo -e "\nERROR: could not compile $file !\n";

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
noext=$(echo "$1" | cut -f 1 -d '.') noext=$(echo "$1" | cut -f 1 -d '.')
./compile.sh $1 echo "compiling $1 ..."
noext=$(echo "$1" | cut -f 1 -d '.')
gcc $1 -o bin/$noext -lm
./bin/$noext $2 $3 $4 $5 $6 $7 $8 $9 ./bin/$noext $2 $3 $4 $5 $6 $7 $8 $9

View File

@ -1,8 +1,4 @@
#!/bin/bash #!/bin/bash
echo "compiling $1 ..." echo "compiling $1 ..."
noext=$(echo "$1" | cut -f 1 -d '.') noext=$(echo "$1" | cut -f 1 -d '.')
# to treat warnings as errors, use the following line
#gcc $1 -o bin/$noext -lm -Werror=format
#
gcc $1 -o bin/$noext -lm gcc $1 -o bin/$noext -lm

Binary file not shown.

View File

@ -151,7 +151,6 @@ int main(int argc, char *argv[]) {
} }
*/ */
// backup // backup
/*
while(1){ while(1){
fseek(fptrR, 512, SEEK_CUR); // this line seems the be making the most problems fseek(fptrR, 512, SEEK_CUR); // this line seems the be making the most problems
@ -163,9 +162,9 @@ int main(int argc, char *argv[]) {
// FIXME )This is a buggy mess // FIXME )This is a buggy mess
if(512 == fread(buf, 1, 512, fptrR)){ if(512 == fread(buf, 1, 512, fptrR)){
for(int i=0;i<512;i++){ for(int i=0;i<512;i++){
occurences[buf[i]]++;) occurences[buf[i]]++;
}
} }
})
else if(0 == fread(buf, 1, 512, fptrR)){ else if(0 == fread(buf, 1, 512, fptrR)){
if(debug) if(debug)
printf("[DEBUG]fread returned 0! ftell for current position is %lu\n", ftell(fptrR)); printf("[DEBUG]fread returned 0! ftell for current position is %lu\n", ftell(fptrR));
@ -181,28 +180,27 @@ int main(int argc, char *argv[]) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
*/
// ALMOST WORKS! ~200 bytes lost for a 10M file!!! // ALMOST WORKS! ~200 bytes lost for a 10M file!!!
uint8_t bufMini[1]; uint8_t bufMini[1];
while(1){ // while(1){
if(fread(bufMini, 1, 1, fptrR)){ // if(fread(bufMini, 1, 1, fptrR)){
occurences[buf[0]]++; // occurences[buf[0]]++;
} // }
else{ // else{
if(ferror(fptrR)){ // if(ferror(fptrR)){
fprintf(stderr, "encountered error when reading file.\n"); // fprintf(stderr, "encountered error when reading file.\n");
exit(EXIT_FAILURE); // exit(EXIT_FAILURE);
} // }
} // }
fseek(fptrR, 1, SEEK_SET); // fseek(fptrR, 1, SEEK_SET);
if(ferror(fptrR)){ // if(ferror(fptrR)){
fprintf(stderr, "encountered error when reading file.\n"); // fprintf(stderr, "encountered error when reading file.\n");
exit(EXIT_FAILURE); // exit(EXIT_FAILURE);
} // }
else if(feof(fptrR)){ // else if(feof(fptrR)){
continue; // break;
} // }
} // }
if(debug){ if(debug){
printf("Occurences (Hex):\n"); printf("Occurences (Hex):\n");
for(int i=0;i<256;i++){ for(int i=0;i<256;i++){