Add example for exiting mid-program.
authornorly <ny-git@enpas.org>
Sun, 13 Jan 2013 22:15:09 +0000 (22:15 +0000)
committernorly <ny-git@enpas.org>
Sun, 13 Jan 2013 22:20:56 +0000 (22:20 +0000)
.gitignore
Makefile
demo-exitclean.c [new file with mode: 0644]

index 48ab12eee17f4f8af2c32ce19ae2b1a4c75fb551..1c6b74c01a57b520f0c13a331eabf9fca8f6fd35 100644 (file)
@@ -3,3 +3,4 @@ demo-printing
 demo-input-char
 demo-input-int
 demo-exitcode
+demo-exitclean
index 426e6cb9a545a9c99a6f2d098d076ebffc479a6f..49698ee5b799f6acf654ae81ccfbb7771b5e96fe 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,7 @@ LDFLAGS=
 SRCDIR=src
 BINDIR=build
 
-all: libmalice.o demo-printing demo-input-char demo-input-int demo-exitcode
+all: libmalice.o demo-printing demo-input-char demo-input-int demo-exitcode demo-exitclean
 
 libmalice.o: libmalice.asm
        nasm $(NASMFLAGS) -o $@ $<
@@ -27,6 +27,9 @@ demo-input-int: demo-input-int.o libmalice.o
 demo-exitcode: demo-exitcode.o libmalice.o
        ld $(LDFLAGS) -nostdlib -e _lmStart -o $@ $^
 
+demo-exitclean: demo-exitclean.o libmalice.o
+       ld $(LDFLAGS) -nostdlib -e _lmStart -o $@ $^
+
 
 .PHONY : clean
 clean:
@@ -35,3 +38,4 @@ clean:
        rm -f demo-input-char
        rm -f demo-input-int
        rm -f demo-exitcode
+       rm -f demo-exitclean
diff --git a/demo-exitclean.c b/demo-exitclean.c
new file mode 100644 (file)
index 0000000..a87c0f9
--- /dev/null
@@ -0,0 +1,12 @@
+#include "libmalice.h"
+
+int lmMain(void)
+{
+  lmPrintString("This demo exits mid-program via lmExit() with code 23.\n");
+
+  lmExit(23);
+
+  lmPrintString("This line is never printed.\n");
+
+  return 42;
+}