@matheusbsbs / matheus-bagliano / commits / 7de1950cb2
Fork 0

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>

René Scharfe committed Nov 23, 2008 at 00:16 UTC 7de1950cb28cee7d6b1e9cdaf22f30ddcdc5bd01
3 files changed -130
Makefile
-1
@@ -437,7 +437,6 @@ LIB_OBJS += grep.o
437 LIB_OBJS += hash.o
438 LIB_OBJS += help.o
439 LIB_OBJS += ident.o
440 -LIB_OBJS += interpolate.o
440 LIB_OBJS += levenshtein.o
441 LIB_OBJS += list-objects.o
442 LIB_OBJS += ll-merge.o
interpolate.c deleted
-103
@@ -1,103 +0,0 @@
1 -/*
2 - * Copyright 2006 Jon Loeliger
3 - */
4 -
5 -#include "git-compat-util.h"
6 -#include "interpolate.h"
7 -
8 -
9 -void interp_set_entry(struct interp *table, int slot, const char *value)
10 -{
11 - char *oldval = table[slot].value;
12 - char *newval = NULL;
13 -
14 - free(oldval);
15 -
16 - if (value)
17 - newval = xstrdup(value);
18 -
19 - table[slot].value = newval;
20 -}
21 -
22 -
23 -void interp_clear_table(struct interp *table, int ninterps)
24 -{
25 - int i;
26 -
27 - for (i = 0; i < ninterps; i++) {
28 - interp_set_entry(table, i, NULL);
29 - }
30 -}
31 -
32 -
33 -/*
34 - * Convert a NUL-terminated string in buffer orig
35 - * into the supplied buffer, result, whose length is reslen,
36 - * performing substitutions on %-named sub-strings from
37 - * the table, interps, with ninterps entries.
38 - *
39 - * Example interps:
40 - * {
41 - * { "%H", "example.org"},
42 - * { "%port", "123"},
43 - * { "%%", "%"},
44 - * }
45 - *
46 - * Returns the length of the substituted string (not including the final \0).
47 - * Like with snprintf, if the result is >= reslen, then it overflowed.
48 - */
49 -
50 -unsigned long interpolate(char *result, unsigned long reslen,
51 - const char *orig,
52 - const struct interp *interps, int ninterps)
53 -{
54 - const char *src = orig;
55 - char *dest = result;
56 - unsigned long newlen = 0;
57 - const char *name, *value;
58 - unsigned long namelen, valuelen;
59 - int i;
60 - char c;
61 -
62 - while ((c = *src)) {
63 - if (c == '%') {
64 - /* Try to match an interpolation string. */
65 - for (i = 0; i < ninterps; i++) {
66 - name = interps[i].name;
67 - namelen = strlen(name);
68 - if (strncmp(src, name, namelen) == 0)
69 - break;
70 - }
71 -
72 - /* Check for valid interpolation. */
73 - if (i < ninterps) {
74 - value = interps[i].value;
75 - if (!value) {
76 - src += namelen;
77 - continue;
78 - }
79 -
80 - valuelen = strlen(value);
81 - if (newlen + valuelen < reslen) {
82 - /* Substitute. */
83 - memcpy(dest, value, valuelen);
84 - dest += valuelen;
85 - }
86 - newlen += valuelen;
87 - src += namelen;
88 - continue;
89 - }
90 - }
91 - /* Straight copy one non-interpolation character. */
92 - if (newlen + 1 < reslen)
93 - *dest++ = *src;
94 - src++;
95 - newlen++;
96 - }
97 -
98 - /* XXX: the previous loop always keep room for the ending NUL,
99 - we just need to check if there was room for a NUL in the first place */
100 - if (reslen > 0)
101 - *dest = '\0';
102 - return newlen;
103 -}
interpolate.h deleted
-26
@@ -1,26 +0,0 @@
1 -/*
2 - * Copyright 2006 Jon Loeliger
3 - */
4 -
5 -#ifndef INTERPOLATE_H
6 -#define INTERPOLATE_H
7 -
8 -/*
9 - * Convert a NUL-terminated string in buffer orig,
10 - * performing substitutions on %-named sub-strings from
11 - * the interpretation table.
12 - */
13 -
14 -struct interp {
15 - const char *name;
16 - char *value;
17 -};
18 -
19 -extern void interp_set_entry(struct interp *table, int slot, const char *value);
20 -extern void interp_clear_table(struct interp *table, int ninterps);
21 -
22 -extern unsigned long interpolate(char *result, unsigned long reslen,
23 - const char *orig,
24 - const struct interp *interps, int ninterps);
25 -
26 -#endif /* INTERPOLATE_H */