commit 496dbd7ffc3006e2ff52a9f3a2841cc6c7e985f8
parent 24052ac4c0ccf0c9b493ff35172f4dfc64580c43
Author: Remy Noulin <loader2x@gmail.com>
Date: Thu, 17 Oct 2019 07:23:16 +0200
add unless (if not), until (while not) and generate buildMemcheck.sh in genMake
completion.txt | 2 ++
documentation.md | 22 ++++++++++++++++++++++
genMake.c | 20 +++++++++++++++++---
release/libsheepy.h | 23 +++++++++++++++++++++++
src/libsheepy.h | 23 +++++++++++++++++++++++
5 files changed, 87 insertions(+), 3 deletions(-)
Diffstat:
5 files changed, 87 insertions(+), 3 deletions(-)
diff --git a/completion.txt b/completion.txt
@@ -97,6 +97,8 @@ isIntEven(value)
typ
ret
elif
+unless(cond)
+until(cond)
cast(type, casted, toCast)
freen(ptr)
EVA(var, func)
diff --git a/documentation.md b/documentation.md
@@ -128,6 +128,8 @@ isIntEven(value)
typ
ret
elif
+unless(cond)
+until(cond)
cast(type, casted, toCast)
freen(ptr)
EVA(var, func)
@@ -1691,6 +1693,26 @@ extern jmp_buf tryJumpBuffers[maxTryThrowCount];
*/
#define elif else if
/*
+ * unless executes the statement unless the condition is true (that is, if the condition is false).
+ *
+ * Example:
+ * unless(isPath("/void")) {
+ * put("the '/void' directory doesn't exist.");
+ * }
+ */
+#define unless(cond) if(not(cond))
+/*
+ * until repeats the statement until the condition is true (or while the condition is false)
+ *
+ * Example:
+ * i16 i = 0;
+ * do {
+ * i++;
+ * logVarG(i);
+ * } until(i == 3);
+ */
+#define until(cond) while(not(cond))
+/*
* define variable and cast pointer
*/
#define cast(type, casted, toCast) type casted = (type) (toCast);
diff --git a/genMake.c b/genMake.c
@@ -157,18 +157,22 @@ int main(int ARGC, char** ARGV) {
// remove -mrdrnd cflag in Makefile on ARM platforms
// because there is no HW random number generator
char *m = readFileToS("Makefile");
- char *b = readFileToS("build.sh");
+ char *b = readfiletos("build.sh");
+ char *B = readfiletos("buildMemcheck.sh");
#if !TERMUX
puts("ARM cpu");
iReplaceS(&m, " -mrdrnd", "", 1);
iReplaceS(&b, " -mrdrnd", "", 1);
+ iReplaceS(&B, " -mrdrnd", "", 1);
#else // #if !TERMUX
puts("ARM cpu Termux");
char *i = readFileToS("install.sh");
iReplaceS(&m, "gnu99", "gnu11", 2);
iReplaceS(&b, "gnu99", "gnu11", 2);
+ iReplaceS(&B, "gnu99", "gnu11", 2);
iReplaceS(&m, " -mrdrnd", " -D__TERMUX__=1 -D__arm__=1", 1);
iReplaceS(&b, " -mrdrnd", " -D__TERMUX__=1 -D__arm__=1", 1);
+ iReplaceS(&B, " -mrdrnd", " -D__TERMUX__=1 -D__arm__=1", 1);
iReplaceS(&m, "/usr/local/include/", "/data/data/com.termux/files/usr/include/", 0);
iReplaceS(&i, "/usr/local/include/", "/data/data/com.termux/files/usr/include/", 0);
iReplaceS(&m, "/usr/local/lib/", "/data/data/com.termux/files/usr/lib/", 0);
@@ -178,8 +182,10 @@ int main(int ARGC, char** ARGV) {
#endif // #if !TERMUX
writeFileS("Makefile", m);
writeFileS("build.sh", b);
+ writeFileS("buildMemcheck.sh", B);
free(m);
free(b);
+ free(B);
#endif // #if __arm__
@@ -198,12 +204,16 @@ int main(int ARGC, char** ARGV) {
puts("alpine linux detected, add define MUSL_LIBC=1 in Makefile and build.sh");
char *M = readFileToS("Makefile");
- char *B = readFileToS("build.sh");
+ char *b = readFileToS("build.sh");
+ char *B = readFileToS("buildMemcheck.sh");
iReplaceS(&M, "-pipe", "-pipe -DMUSL_LIBC=1", 1);
+ iReplaceS(&b, "-pipe", "-pipe -DMUSL_LIBC=1", 1);
iReplaceS(&B, "-pipe", "-pipe -DMUSL_LIBC=1", 1);
writeFileS("Makefile", M);
- writeFileS("build.sh", B);
+ writeFileS("build.sh", b);
+ writeFileS("buildMemcheck.sh", B);
free(M);
+ free(b);
free(B);
}
#endif // #if __APPLE__
@@ -214,12 +224,16 @@ int main(int ARGC, char** ARGV) {
// because pthread is linked by default
char *m = readFileToS("Makefile");
char *b = readFileToS("build.sh");
+ char *B = readFileToS("buildMemcheck.sh");
iReplaceS(&m, " -pthread", "", 1);
iReplaceS(&b, " -pthread", "", 1);
+ iReplaceS(&B, " -pthread", "", 1);
writeFileS("Makefile", m);
writeFileS("build.sh", b);
+ writeFileS("buildMemcheck.sh", B);
free(m);
free(b);
+ free(B);
#endif // #if __HAIKU__
}
diff --git a/release/libsheepy.h b/release/libsheepy.h
@@ -511,6 +511,29 @@ extern jmp_buf tryJumpBuffers[maxTryThrowCount];
#define elif else if
/**
+ * unless executes the statement unless the condition is true (that is, if the condition is false).
+ *
+ * Example:
+ * unless(isPath("/void")) {
+ * put("the '/void' directory doesn't exist.");
+ * }
+ */
+#define unless(cond) if(not(cond))
+
+/**
+ * until repeats the statement until the condition is true (or while the condition is false)
+ *
+ * Example:
+ * i16 i = 0;
+ * do {
+ * i++;
+ * logVarG(i);
+ * } until(i == 3);
+ */
+#define until(cond) while(not(cond))
+
+
+/**
* define variable and cast pointer
*/
#define cast(type, casted, toCast) type casted = (type) (toCast);
diff --git a/src/libsheepy.h b/src/libsheepy.h
@@ -511,6 +511,29 @@ extern jmp_buf tryJumpBuffers[maxTryThrowCount];
#define elif else if
/**
+ * unless executes the statement unless the condition is true (that is, if the condition is false).
+ *
+ * Example:
+ * unless(isPath("/void")) {
+ * put("the '/void' directory doesn't exist.");
+ * }
+ */
+#define unless(cond) if(not(cond))
+
+/**
+ * until repeats the statement until the condition is true (or while the condition is false)
+ *
+ * Example:
+ * i16 i = 0;
+ * do {
+ * i++;
+ * logVarG(i);
+ * } until(i == 3);
+ */
+#define until(cond) while(not(cond))
+
+
+/**
* define variable and cast pointer
*/
#define cast(type, casted, toCast) type casted = (type) (toCast);