aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>2008-11-23 00:16:59 +0100
committerJunio C Hamano <gitster@pobox.com>2008-11-23 19:56:57 -0800
commit7de1950cb28cee7d6b1e9cdaf22f30ddcdc5bd01 (patch)
tree3b5f07a64f65ad5085537fec3e8f214c1efb0b71
parenta47551c3828f81ec88d5b0b3d05887f1a7a4233a (diff)
downloadgit-7de1950cb28cee7d6b1e9cdaf22f30ddcdc5bd01.tar.gz
git-7de1950cb28cee7d6b1e9cdaf22f30ddcdc5bd01.tar.xz
remove the unused files interpolate.c and interpolate.h
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--Makefile1
-rw-r--r--interpolate.c103
-rw-r--r--interpolate.h26
3 files changed, 0 insertions, 130 deletions
diff --git a/Makefile b/Makefile
index 35adafa01..54e074524 100644
--- a/Makefile
+++ b/Makefile
@@ -437,7 +437,6 @@ LIB_OBJS += grep.o
LIB_OBJS += hash.o
LIB_OBJS += help.o
LIB_OBJS += ident.o
-LIB_OBJS += interpolate.o
LIB_OBJS += levenshtein.o
LIB_OBJS += list-objects.o
LIB_OBJS += ll-merge.o
diff --git a/interpolate.c b/interpolate.c
deleted file mode 100644
index 7f03bd99c..000000000
--- a/interpolate.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2006 Jon Loeliger
- */
-
-#include "git-compat-util.h"
-#include "interpolate.h"
-
-
-void interp_set_entry(struct interp *table, int slot, const char *value)
-{
- char *oldval = table[slot].value;
- char *newval = NULL;
-
- free(oldval);
-
- if (value)
- newval = xstrdup(value);
-
- table[slot].value = newval;
-}
-
-
-void interp_clear_table(struct interp *table, int ninterps)
-{
- int i;
-
- for (i = 0; i < ninterps; i++) {
- interp_set_entry(table, i, NULL);
- }
-}
-
-
-/*
- * Convert a NUL-terminated string in buffer orig
- * into the supplied buffer, result, whose length is reslen,
- * performing substitutions on %-named sub-strings from
- * the table, interps, with ninterps entries.
- *
- * Example interps:
- * {
- * { "%H", "example.org"},
- * { "%port", "123"},
- * { "%%", "%"},
- * }
- *
- * Returns the length of the substituted string (not including the final \0).
- * Like with snprintf, if the result is >= reslen, then it overflowed.
- */
-
-unsigned long interpolate(char *result, unsigned long reslen,
- const char *orig,
- const struct interp *interps, int ninterps)
-{
- const char *src = orig;
- char *dest = result;
- unsigned long newlen = 0;
- const char *name, *value;
- unsigned long namelen, valuelen;
- int i;
- char c;
-
- while ((c = *src)) {
- if (c == '%') {
- /* Try to match an interpolation string. */
- for (i = 0; i < ninterps; i++) {
- name = interps[i].name;
- namelen = strlen(name);
- if (strncmp(src, name, namelen) == 0)
- break;
- }
-
- /* Check for valid interpolation. */
- if (i < ninterps) {
- value = interps[i].value;
- if (!value) {
- src += namelen;
- continue;
- }
-
- valuelen = strlen(value);
- if (newlen + valuelen < reslen) {
- /* Substitute. */
- memcpy(dest, value, valuelen);
- dest += valuelen;
- }
- newlen += valuelen;
- src += namelen;
- continue;
- }
- }
- /* Straight copy one non-interpolation character. */
- if (newlen + 1 < reslen)
- *dest++ = *src;
- src++;
- newlen++;
- }
-
- /* XXX: the previous loop always keep room for the ending NUL,
- we just need to check if there was room for a NUL in the first place */
- if (reslen > 0)
- *dest = '\0';
- return newlen;
-}
diff --git a/interpolate.h b/interpolate.h
deleted file mode 100644
index 77407e67d..000000000
--- a/interpolate.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright 2006 Jon Loeliger
- */
-
-#ifndef INTERPOLATE_H
-#define INTERPOLATE_H
-
-/*
- * Convert a NUL-terminated string in buffer orig,
- * performing substitutions on %-named sub-strings from
- * the interpretation table.
- */
-
-struct interp {
- const char *name;
- char *value;
-};
-
-extern void interp_set_entry(struct interp *table, int slot, const char *value);
-extern void interp_clear_table(struct interp *table, int ninterps);
-
-extern unsigned long interpolate(char *result, unsigned long reslen,
- const char *orig,
- const struct interp *interps, int ninterps);
-
-#endif /* INTERPOLATE_H */