/* cflags: */
/* linker: debug.o */
-#include <assert.h>
+#include <errno.h>
#include <getopt.h>
#include <malloc.h>
#include <stdio.h>
fid = fopen (output, "w");
if (fid == NULL) {
VERBOSE (ERROR, fprintf (stderr, "%s: can't open file '%s' for writing\n", progname, output));
+ if (buffer) free (buffer);
return 1;
}
} else {
fclose (fid);
}
+ /* free buffer */
+ if (buffer) {
+ free (buffer);
+ }
+
VERBOSE (INFO, fprintf (stdout, "\nmemory:"); int _i; for (_i = 0; _i < MEMSIZE; _i++) fprintf (stdout," %d", mem[_i]); fprintf (stdout,"\n"));
return rc;
// test: bf.exe -e '+++' -e '+++>++>>-<--' -v2 | grep -q "memory: 3 2 -2 -1 0"
// test: bf.exe -e '+++>++>>-<--' -v2 | grep -q "memory: 3 2 -2 -1 0"
// test: bf.exe -m "51 50 49" -e '.>.>.' |grep -q "321"
-// test: bf.exe -m "51 50 49" -e '.>.>.' -o test.log | grep -q "321" test.log; rc=$?; rm test.log; test $rc -eq 0
+// test: bf.exe -m "51 50 49" -e '.>.>.' -o test.log && grep -q "321" test.log; rc=$?; rm test.log; test $rc -eq 0
// test: echo '+++>++>>-<--' > test.b | bf.exe -i test.b | grep -q "memory: 3 2 -2 -1 0"; rc=$?; rm test.b; test $rc -eq 0
// test: echo '++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.' | bf.exe -v1 | grep -q "Hello World!"