aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2022-01-01 19:19:47 +0100
committerElias Fleckenstein <eliasfleckenstein@web.de>2022-01-01 19:19:47 +0100
commite56374fa85ab5cac4c9a4b264ea994c750a2bae0 (patch)
tree8fa4e2c1f2ccd482b55b27df6549d09047ad050c
parent6ec67846ffadb5bd1be13d5a7ea3abcf67f1c536 (diff)
downloaduwu-lang-e56374fa85ab5cac4c9a4b264ea994c750a2bae0.tar.xz
Use uwu-common as submodule
-rw-r--r--.gitmodules3
-rw-r--r--README.md2
m---------common0
-rw-r--r--common/dl.h14
-rw-r--r--common/err.h27
-rw-r--r--common/file.h19
-rw-r--r--common/str.h17
-rw-r--r--src/load.c16
8 files changed, 5 insertions, 93 deletions
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..10d1794
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "common"]
+ path = common
+ url = https://github.com/EliasFleckenstein03/uwu-common
diff --git a/README.md b/README.md
index bea6e21..703a9d8 100644
--- a/README.md
+++ b/README.md
@@ -28,7 +28,7 @@ It's turing complete and somewhat useable.
To build:
```
-make
+make all std
```
To run:
diff --git a/common b/common
new file mode 160000
+Subproject a636a960a0866a94719aff01774b9533743ee07
diff --git a/common/dl.h b/common/dl.h
deleted file mode 100644
index 143b422..0000000
--- a/common/dl.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef _COMMON_DL_H_
-#define _COMMON_DL_H_
-
-#include <dlfcn.h>
-#include "err.h"
-
-inline static void check_dlerror()
-{
- char *err = dlerror();
- if (err)
- error("library error: %s\n", err);
-}
-
-#endif
diff --git a/common/err.h b/common/err.h
deleted file mode 100644
index b9faf11..0000000
--- a/common/err.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef _COMMON_ERR_H_
-#define _COMMON_ERR_H_
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-
-static inline void error(const char *format, ...)
-{
- va_list args;
- va_start(args, format);
- vfprintf(stderr, format, args);
- va_end(args);
- exit(1);
-}
-
-static inline void syserror(const char *call, FILE *file)
-{
- perror(call);
-
- if (file)
- fclose(file);
-
- exit(1);
-}
-
-#endif
diff --git a/common/file.h b/common/file.h
deleted file mode 100644
index c5e8036..0000000
--- a/common/file.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef _COMMON_FILE_H_
-#define _COMMON_FILE_H_
-
-#include <stdio.h>
-#include <stdbool.h>
-
-inline static bool file_exists(const char *filename)
-{
- FILE *f = fopen(filename, "r");
-
- if (f) {
- fclose(f);
- return true;
- }
-
- return false;
-}
-
-#endif
diff --git a/common/str.h b/common/str.h
deleted file mode 100644
index fc5f587..0000000
--- a/common/str.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef _COMMON_STR_H_
-#define _COMMON_STR_H_
-
-#include <stdio.h>
-#include <stdarg.h>
-
-static inline char *asprintf_wrapper(const char *format, ...)
-{
- va_list args;
- va_start(args, format);
- char *ptr;
- vasprintf(&ptr, format, args);
- va_end(args);
- return ptr;
-}
-
-#endif
diff --git a/src/load.c b/src/load.c
index 4a05915..4eee717 100644
--- a/src/load.c
+++ b/src/load.c
@@ -2,31 +2,17 @@
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
-#include <libgen.h>
#include <dlfcn.h>
#include "common/err.h"
#include "common/str.h"
#include "common/file.h"
#include "common/dl.h"
+#include "common/dir.h"
#include "load.h"
#include "parse.h"
#define DEBUG 0
-// helper functions
-
-static char *dirname_wrapper(const char *name)
-{
- char *copy = strdup(name);
- char *result = dirname(copy);
- char *result_copy = strdup(result);
-
- free(copy);
- return result_copy;
-}
-
-// type definitions
-
typedef struct
{
char *name;