commit edae8fd

uint  ·  2026-10-24 18:51:18 +0000 UTC
parent 0496419
Move main() to test.c
2 files changed,  +40, -38
M expl.c
A test.c
M expl.c
+0, -38
 1@@ -573,41 +573,3 @@ expl_run(expl* ctx, const char* source)
 2 	return result;
 3 }
 4 
 5-#if 1
 6-static expl_value
 7-birds_who_hit_my_window(int argc, const expl_value* argv, void* data)
 8-{
 9-	int* count = (int*)data;
10-	expl_value result = { 0 };
11-
12-	if (argc == 1 && argv[0].type == EXPL_VALUE_NUMBER)
13-		*count += (int)argv[0].as.number;
14-
15-	result.type = EXPL_VALUE_NUMBER;
16-	result.as.number = *count;
17-
18-	return result;
19-}
20-
21-#define FIND_THE_BIRDS \
22-"(fn foo (x) (birds_who_hit_my_window x))\n" \
23-"(foo 134)\n"
24-
25-int
26-main(void)
27-{
28-	int birds_who_hit_my_window_c = 0;
29-	expl* ctx = expl_init();
30-
31-	if (!ctx)
32-		return EXIT_FAILURE;
33-
34-	expl_register(ctx, "birds_who_hit_my_window", birds_who_hit_my_window, &birds_who_hit_my_window_c);
35-	expl_run(ctx, FIND_THE_BIRDS);
36-	printf("Stupid birds: %d\n", birds_who_hit_my_window_c);
37-
38-	expl_close(ctx);
39-	return EXIT_SUCCESS;
40-}
41-#endif
42-
A test.c
+40, -0
 1@@ -0,0 +1,40 @@
 2+#include <stdio.h>
 3+#include <stdlib.h>
 4+
 5+#include "expl.h"
 6+
 7+static expl_value
 8+birds_who_hit_my_window(int argc, const expl_value* argv, void* data)
 9+{
10+	int* count = (int*)data;
11+	expl_value result = { 0 };
12+
13+	if (argc == 1 && argv[0].type == EXPL_VALUE_NUMBER)
14+		*count += (int)argv[0].as.number;
15+
16+	result.type = EXPL_VALUE_NUMBER;
17+	result.as.number = *count;
18+
19+	return result;
20+}
21+
22+#define FIND_THE_BIRDS \
23+"(fn foo (x) (birds_who_hit_my_window x))\n" \
24+"(foo 134)\n"
25+
26+int
27+main(void)
28+{
29+	int birds_who_hit_my_window_c = 0;
30+	expl* ctx = expl_init();
31+
32+	if (!ctx)
33+		return EXIT_FAILURE;
34+
35+	expl_register(ctx, "birds_who_hit_my_window", birds_who_hit_my_window, &birds_who_hit_my_window_c);
36+	expl_run(ctx, FIND_THE_BIRDS);
37+	printf("Stupid birds: %d\n", birds_who_hit_my_window_c);
38+
39+	expl_close(ctx);
40+	return EXIT_SUCCESS;
41+}