scripting improvements, warning.c

This commit is contained in:
Christoph J. Scherr 2022-11-24 23:00:34 +01:00
parent 47c22c84d2
commit baea9ae9be
6 changed files with 23 additions and 4 deletions

BIN
bin/warning Executable file

Binary file not shown.

View File

@ -10,4 +10,12 @@ do
returnCode=1; returnCode=1;
fi fi
done done
echo -ne "\nfinished compiling all source files. ";
if [ "$returnCode" -eq 0 ]
then
echo -ne "No errors occured.";
else
echo -ne "Some errors occured.";
fi
echo "";
exit $returnCode exit $returnCode

View File

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

View File

@ -1,4 +1,8 @@
#!/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

View File

@ -1,11 +1,9 @@
# Huffman # Huffman
the testfiles folder is unpopulated and not staged through gitignore, as it might contain large files. the testfiles folder is unpopulated and not staged through gitignore, as it might contain large files.
use the following command to populate it or create your own testfiles. Use the following command to populate it or create your own testfiles.
``dd if=/dev/urandom of=10K-random.img count=1K`` ``dd if=/dev/urandom of=10K-random.img count=1K``
``dd if=/dev/urandom of=10K-random.img count=1M`` ``dd if=/dev/urandom of=10K-random.img count=1M``
... ...
files with random bytes wont be able to be compressed byy much, that is normal. files with random bytes wont be able to be compressed byy much, that is normal.

9
warning.c Normal file
View File

@ -0,0 +1,9 @@
#include <stdio.h>
int main(){
char s[2];
// produce warning, char* s is too small for the following fgets instruction
fgets(s, 10, stdin);
printf("%s\n",s);
return 0;
}