All of lore.kernel.org
 help / color / mirror / Atom feed
From: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
To: Git Mailing List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>, Jon Loeliger <jdl@freescale.com>
Subject: [PATCH 4/4] remove the unused files interpolate.c and interpolate.h
Date: Sun, 23 Nov 2008 00:16:59 +0100	[thread overview]
Message-ID: <492892EB.4040102@lsrfire.ath.cx> (raw)
In-Reply-To: <49289275.7090003@lsrfire.ath.cx>

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
 Makefile      |    1 -
 interpolate.c |  103 ---------------------------------------------------------
 interpolate.h |   26 --------------
 3 files changed, 0 insertions(+), 130 deletions(-)
 delete mode 100644 interpolate.c
 delete mode 100644 interpolate.h

diff --git a/Makefile b/Makefile
index 35adafa..54e0745 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 7f03bd9..0000000
--- 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 77407e6..0000000
--- 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 */
-- 
1.6.0.4.755.g6e139

  reply	other threads:[~2008-11-22 23:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-22 23:09 [PATCH 1/4] add strbuf_expand_dict_cb(), a helper for simple cases René Scharfe
2008-11-22 23:13 ` [PATCH 2/4] merge-recursive: use strbuf_expand() instead of interpolate() René Scharfe
2008-11-22 23:15   ` [PATCH 3/4] daemon: " René Scharfe
2008-11-22 23:16     ` René Scharfe [this message]
2008-11-22 23:19     ` [PATCH 3.1/4] daemon: inline fill_in_extra_table_entries() René Scharfe
2008-11-22 23:21       ` [PATCH 3.2/4] daemon: deglobalize variable 'directory' René Scharfe
2008-12-04 20:30 ` [PATCH 1/4] add strbuf_expand_dict_cb(), a helper for simple cases Jon Loeliger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=492892EB.4040102@lsrfire.ath.cx \
    --to=rene.scharfe@lsrfire.ath.cx \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jdl@freescale.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.