Skip to contentSkip to conversation

Use light stacking for non-option arguments.

PATCH In review Andreas Ericsson 1 participant 1 message Jun 15, 2016 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Use light stacking for non-option arguments.

This patch adds some simple library code that can help C-programs in the git suite ignore argument ordering without interfering with the current argument parsing code too much.

---

 Makefile |    4 ++--
 stack.c  |   42 ++++++++++++++++++++++++++++++++++++++++++
 stack.h  |    9 +++++++++
 3 files changed, 53 insertions(+), 2 deletions(-)
 create mode 100644 stack.c
 create mode 100644 stack.h

5ebd4cbfef1a2c369f763eb3a98f079ffb4f6b5d

Makefile +2 -2
index c9c15b5..ba861fb 100644
@@ -165,7 +165,7 @@ LIB_FILE=libgit.a
 LIB_H = \
 	blob.h cache.h commit.h count-delta.h csum-file.h delta.h \
 	diff.h epoch.h object.h pack.h pkt-line.h quote.h refs.h \
-	run-command.h strbuf.h tag.h tree.h git-compat-util.h
+	run-command.h stack.h strbuf.h tag.h tree.h git-compat-util.h
 
 DIFF_OBJS = \
 	diff.o diffcore-break.o diffcore-order.o diffcore-pathspec.o \
@@ -176,7 +176,7 @@ LIB_OBJS = \
 	date.o diff-delta.o entry.o ident.o index.o \
 	object.o pack-check.o patch-delta.o path.o pkt-line.o \
 	quote.o read-cache.o refs.o run-command.o \
-	server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
+	server-info.o setup.o sha1_file.o sha1_name.o stack.o strbuf.o \
 	tag.o tree.o usage.o config.o environment.o ctype.o copy.o \
 	fetch-clone.o \
 	$(DIFF_OBJS)
stack.c new file +42 -0

42 lines not on this page · raw message

stack.h new file +9 -0
new file mode 100644
index 0000000..5682559
@@ -0,0 +1,9 @@
+struct stack {
+	void **stack;
+	unsigned ents, next;
+};
+
+struct stack *stack_push(struct stack *s, const void *ptr);
+void *stack_pull(struct stack *s);
+void *stack_pop(struct stack *s);
+void stack_destroy(struct stack *s);
Signature · 1 line
1.1.0