summaryrefslogtreecommitdiff
path: root/src/operetta.c
diff options
context:
space:
mode:
authorKai Stevenson <kai@kaistevenson.com>2023-06-17 20:11:37 -0700
committerKai Stevenson <kai@kaistevenson.com>2023-06-17 20:11:37 -0700
commita7d426c3d5b72b57131c5ca2e6efbf0a7c2b8df9 (patch)
tree2ef270417daae91ed3ed7ccb5074b6b7fb0f7097 /src/operetta.c
parentd201bf2bf253c80a8629f11e44da9daca67470aa (diff)
added contradiction introduction rule
Diffstat (limited to 'src/operetta.c')
-rw-r--r--src/operetta.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/operetta.c b/src/operetta.c
index 7e257f0..9b7fea3 100644
--- a/src/operetta.c
+++ b/src/operetta.c
@@ -28,7 +28,8 @@ int main(int argc, char** argv) {
s[0] = '\0';
char* propString = write_prop(line.proposition);
char* justString = write_just(line.justification);
- snprintf(s, 100, "%d. %s BECAUSE: %s", i + 1, propString, justString);
+ char isValid = just_is_sound(line, lines);
+ snprintf(s, 100, "%d. %s BECAUSE: %s <%s>", i + 1, propString, justString, isValid ? "SOUND" : "UNSOUND");
free(propString);
free(justString);
consoleLines[i] = init_simple_consoleline(CWHITE, s);
@@ -48,6 +49,12 @@ int main(int argc, char** argv) {
free(content);
}
char* write_prop(prop_t prop) {
+ if (prop.isContradiction) {
+ char* s = tttos(CONTRADICTION);
+ char* sp = malloc(sizeof(char) * strlen(s) + 1);
+ strcpy(sp, s);
+ return sp;
+ }
char* out = calloc(sizeof(char), 100);
out[0] = '\0';
if (prop.isNegative) {
@@ -69,7 +76,7 @@ char* write_prop(prop_t prop) {
free(c2);
strcat(out, ")");
}
- return out;
+ return realloc(out, sizeof(char) * strlen(out) + 1);
}
char* write_just(just_t just) {
char* out = calloc(sizeof(char), 50);
@@ -81,7 +88,7 @@ char* write_just(just_t just) {
strcat(out, n);
free(n);
}
- return out;
+ return realloc(out, sizeof(char) * strlen(out) + 1);
}
char* read_file(char* path) {
FILE* file = fopen(path, "r");