better compile scripts, fixed some code

This commit is contained in:
Christoph J. Scherr 2022-11-24 22:20:17 +01:00
parent fb0938d2c3
commit dbe1895350
40 changed files with 25 additions and 7 deletions

View File

@ -21,7 +21,6 @@ int main(){
bin[i] = b; bin[i] = b;
} }
for(int j = 0; j < 16; j++){ for(int j = 0; j < 16; j++){
if(
printf("%d", bin[j]); printf("%d", bin[j]);
} }
printf("\n"); printf("\n");

Binary file not shown.

Binary file not shown.

BIN
bin/abc Executable file

Binary file not shown.

BIN
bin/adder

Binary file not shown.

BIN
bin/args

Binary file not shown.

BIN
bin/arrToBin Executable file

Binary file not shown.

BIN
bin/ascii

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
bin/echo

Binary file not shown.

Binary file not shown.

BIN
bin/euler

Binary file not shown.

Binary file not shown.

BIN
bin/fail

Binary file not shown.

BIN
bin/fread

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
bin/sum

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,3 +1,13 @@
#!/bin/bash #!/bin/bash
echo "compiling all files in working directory $(pwd)" returnCode=0
for file in $(/bin/ls); do ./compile.sh $file; done echo -e "compiling all files in working directory $(pwd)\n"
for file in $(/bin/ls *.c);
do
./compile.sh $file;
if [ "$?" -ne 0 ]
then
echo -e "\nERROR: could not compile $file !\n";
returnCode=1;
fi
done
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 '.')
gcc $1 -o bin/$noext ./compile $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,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 '.')
gcc $1 -o bin/$noext gcc $1 -o bin/$noext -lm

11
echo.c
View File

@ -2,7 +2,16 @@
int main() { int main() {
char s[100]; char s[100];
gets(s); //gets(s);
/*
* Never use gets(). Because it is impossible to tell without knowing the data in advance how many characters gets() will read, and be
* cause gets() will continue to store characters past the end of the buffer, it is extremely dangerous to use. It has been used to break
* computer security. Use fgets() instead.
*
* For more information, see CWE-242 (aka "Use of Inherently Dangerous Function") at http://cwe.mitre.org/data/definitions/242.html
*
*/
fgets(s, sizeof(s), stdin);
printf("%s\n", s); printf("%s\n", s);
return 0; return 0;
} }