aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2012-08-01 21:12:09 +0200
committerGravatar Tom Willemsen2012-08-01 21:12:09 +0200
commit2f0fd8d03e032ae21922fe34f68f3f4846045f8c (patch)
tree6bcc05c861a760701959d36605580bcc53fb98f3
parentf7016aea189d18f4dbeb109f498590c2eeb2bf6c (diff)
downloadgitto-2f0fd8d03e032ae21922fe34f68f3f4846045f8c.tar.gz
gitto-2f0fd8d03e032ae21922fe34f68f3f4846045f8c.zip
Use guile-snarf
Because it looks cooler. This way its easy to keep all the information about the function in one place, and it makes it easier/more interesting to add new functions later.
-rw-r--r--src/.gitignore1
-rw-r--r--src/Makefile4
-rw-r--r--src/gitto-path.c13
3 files changed, 12 insertions, 6 deletions
diff --git a/src/.gitignore b/src/.gitignore
index 9d22eb4..042d47a 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -1,2 +1,3 @@
*.o
*.so
+*.x
diff --git a/src/Makefile b/src/Makefile
index 584374e..30ba106 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -8,6 +8,10 @@ all: libguile-gitto-path.so
.PHONY: install uninstall
+%.x: %.c
+ guile-snarf -o $@ $< $(CFLAGS)
+
+gitto-path.o: gitto-path.x
libguile-gitto-path.so: gitto-path.o
$(CC) $(CFLAGS) -shared -o libguile-gitto-path.so $^
diff --git a/src/gitto-path.c b/src/gitto-path.c
index 5dabaea..4fdd6ab 100644
--- a/src/gitto-path.c
+++ b/src/gitto-path.c
@@ -20,14 +20,15 @@
#include <stdlib.h>
#include <libguile.h>
-SCM
-realpath_wrapper(SCM str)
+SCM_DEFINE(realpath_wrapper, "realpath", 1, 0, 0,
+ (SCM path),
+ "Transform PATH into an absolute path.")
{
- char *path = scm_to_locale_string(str);
- char *resolved_path = realpath(path, NULL);
+ char *relative_path = scm_to_locale_string(path);
+ char *resolved_path = realpath(relative_path, NULL);
SCM scm_resolved_path = scm_from_locale_string(resolved_path);
- free(path);
+ free(relative_path);
free(resolved_path);
return scm_resolved_path;
@@ -36,5 +37,5 @@ realpath_wrapper(SCM str)
void
init_gitto()
{
- scm_c_define_gsubr("realpath", 1, 0, 0, realpath_wrapper);
+#include "gitto-path.x"
}