diff options
author | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2019-11-06 10:38:28 +0100 |
---|---|---|
committer | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2019-11-06 20:11:38 +0100 |
commit | 80e009c50bc3f76495bd9d6d84e2e5eb23fe0f7d (patch) | |
tree | 0e2f0ede90cab29d216c0329697ba4e2c63abf38 | |
parent | 42c242f5f2f0a3058672dd568de49f72a18f3665 (diff) | |
download | libfo-80e009c50bc3f76495bd9d6d84e2e5eb23fe0f7d.tar.gz libfo-80e009c50bc3f76495bd9d6d84e2e5eb23fe0f7d.tar.bz2 libfo-80e009c50bc3f76495bd9d6d84e2e5eb23fe0f7d.zip |
fogen: add a way to add custom code to onverriden functions
Signed-off-by: Michał Łyszczek <michal.lyszczek@bofc.pl>
-rw-r--r-- | Makefile | 9 | ||||
-rw-r--r-- | custom/fread | 4 | ||||
-rw-r--r-- | custom/fwrite | 4 | ||||
-rwxr-xr-x | fogen | 10 |
4 files changed, 27 insertions, 0 deletions
@@ -4,6 +4,7 @@ GITSHA=$(shell git rev-parse --short HEAD) DIST_DIR=libfo-$(VERSION) DESTDIR?=/usr/local RM ?= rm -f +RMDIR ?= rmdir --ignore-fail-on-non-empty all: libfo.so @@ -64,6 +65,9 @@ install: if [ "$(BASE_VERSION)" = "9999" ]; then \ sed -i 's/^version="9999\(-[[:alnum:]]\+\)\?"$$/version="9999-$(GITSHA)"/' fogen; \ fi + for f in custom/*; do \ + install -m0644 -D $$f $(DESTDIR)/share/fogen/$$f; \ + done install -m0755 -D fogen $(DESTDIR)/bin/fogen install -m0755 -D fo.c.in $(DESTDIR)/share/fogen/fo.c.in install -m0755 -D fo.h.in $(DESTDIR)/share/fogen/fo.h.in @@ -74,6 +78,9 @@ install: install -m0644 -D man/libfo.7 $(DESTDIR)/share/man/man7/libfo.7 uninstall: + for f in custom/*; do \ + $(RM) $(DESTDIR)/share/fogen/$$f; \ + done $(RM) $(DESTDIR)/bin/fogen $(RM) $(DESTDIR)/share/fogen/fo.c.in $(RM) $(DESTDIR)/share/fogen/fo.h.in @@ -82,5 +89,7 @@ uninstall: $(RM) $(DESTDIR)/share/man/man3/fo_init.3 $(RM) $(DESTDIR)/share/man/man3/fo_fail.3 $(RM) $(DESTDIR)/share/man/man7/libfo.7 + $(RMDIR) $(DESTDIR)/share/fogen/custom + $(RMDIR) $(DESTDIR)/share/fogen/ .PHONY: www all check dist distclean clean install uninstall diff --git a/custom/fread b/custom/fread new file mode 100644 index 0000000..8a80d54 --- /dev/null +++ b/custom/fread @@ -0,0 +1,4 @@ +{ + if (fo_info[fo_fread].errn != 0) + arg3->_flags |= _IO_ERR_SEEN; +} diff --git a/custom/fwrite b/custom/fwrite new file mode 100644 index 0000000..02d0ce9 --- /dev/null +++ b/custom/fwrite @@ -0,0 +1,4 @@ +{ + if (fo_info[fo_fwrite].errn != 0) + arg3->_flags |= _IO_ERR_SEEN; +} @@ -388,6 +388,16 @@ for f in db: o += "\t\toriginal = fo_info[fo_{}].original;\n".format(f['fname']) o += "\t\treturn original({});\n".format(args_call) o += "\t}\n" + + try: + with open(resdir + "/custom/" + f['fname']) as c: + o += "\n" + for l in c.read().splitlines(): + o += "\t{}\n".format(l) + o += "\n" + except: + pass + o += "\terrno = fo_info[fo_{}].errn;\n".format(f['fname']) o += "\treturn ({})fo_info[fo_{}].ret;\n".format(f['rtype'], f['fname']) o += "}\n\n\n" |