]> vcs.slashdirt.org Git - sw/tic2json.git/commitdiff

vcs.slashdirt.org Git - sw/tic2json.git/commitdiff

git git / sw / tic2json.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 14d6f1b)
Simplify building BAREBUILD
Thu, 2 Sep 2021 09:58:50 +0000 (11:58 +0200)
Thu, 2 Sep 2021 10:16:30 +0000 (12:16 +0200)
This simplifies building for a barebone MCU: a separate 'ticmain()' is
provided instead of main(), all unnecessary bits are disabled and only
one TIC version is supported at a time.


diff --git a/tic2json.c b/tic2json.c
index ab261a76188dc49128174893ba07959f60d21fb3..d41e03ff3e172f7eed5d55a28b7960a2ebb662a1 100644 (file)
--- a/tic2json.c
+++ b/tic2json.c
@@ -27,7 +27,9 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <err.h>
+#ifndef BAREBUILD
+ #include <err.h>
+#endif
#include "tic.h"
#ifdef TICV01
@@ -40,7 +42,7 @@
#endif
#ifdef BAREBUILD
- #warning BAREBUILD currently requires editing the code by hand
+ #warning BAREBUILD currently requires defining only one version of supported TIC and does not provide main()
#endif
#define TIC2JSON_VER "2.0"
@@ -263,6 +265,16 @@ void frame_err(void)
tp.ferr = 1;
}
+static inline void ticinit(void)
+{
+ filter_mode = false;
+ etiq_en = NULL;
+
+ memset(&tp, 0, sizeof(tp));
+ tp.framedelims[0] = '['; tp.framedelims[1] = ']';
+ tp.fdelim = ' ';
+}
+
#ifndef BAREBUILD
static void usage(void)
{
@@ -301,8 +313,6 @@ void parse_config_v01(const char *filename);
void parse_config_v02(const char *filename);
#endif
-#endif /* !BAREBUILD */
-
int main(int argc, char **argv)
{
void (*parse_config)(const char *);
@@ -312,14 +322,8 @@ int main(int argc, char **argv)
const char *fconfig = NULL;
int ch;
- filter_mode = false;
- etiq_en = NULL;
-
- memset(&tp, 0, sizeof(tp));
- tp.framedelims[0] = '['; tp.framedelims[1] = ']';
- tp.fdelim = ' ';
+ ticinit();
-#ifndef BAREBUILD
while ((ch = getopt(argc, argv, "12de:hi:lnrs:uz")) != -1) {
switch (ch) {
#ifdef TICV01
@@ -378,7 +382,6 @@ int main(int argc, char **argv)
}
argc -= optind;
argv += optind;
-#endif /* !BAREBUILD */
if (!yyparse)
errx(-1, "ERREUR: version TIC non spécifiée");
@@ -394,3 +397,25 @@ int main(int argc, char **argv)
free(etiq_en);
return 0;
}
+
+#else /* BAREBUILD */
+
+void ticmain(void)
+{
+ ticinit();
+ putchar(tp.framedelims[0]);
+
+#if defined(TICV01)
+ ticv01yyparse();
+ ticv01yylex_destroy();
+#elif defined(TICV02)
+ ticv02yyparse();
+ ticv02yylex_destroy();
+#else
+ printf("NO TIC VERSION DEFINED!\n");
+#endif
+
+ printf("%c\n", tp.framedelims[1]);
+}
+
+#endif /* !BAREBUILD */
tic2json TIC parser/converter
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /