Staging
v0.5.2
v0.5.2
https://github.com/git/git
Revision 1dc71a9155e209ed4da866eeb7c3064e4568532e authored by J. Bruce Fields on 11 March 2007, 03:38:13 UTC, committed by J. Bruce Fields on 11 March 2007, 04:05:01 UTC
Asciidoc appears to interpret a backslash at the end of a line as escaping the end-of-line character, which screws up the display of history diagrams like o--o--o \ o--... The obvious fix (replacing "\" by "\\") doesn't work. The only workaround I've found is to include all such diagrams in a LiteralBlock. Asciidoc claims that should be equivalent to a literal paragraph, so I don't understand why the difference--perhaps it's an asciidoc bug. Cc: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: "J. Bruce Fields" <bfields@citi.umich.edu>
1 parent ed4eb0d
Tip revision: 1dc71a9155e209ed4da866eeb7c3064e4568532e authored by J. Bruce Fields on 11 March 2007, 03:38:13 UTC
user-manual: fix rendering of history diagrams
user-manual: fix rendering of history diagrams
Tip revision: 1dc71a9
interpolate.c
/*
* 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;
if (oldval)
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 1 on a successful substitution pass that fits in result,
* Returns 0 on a failed or overflowing substitution pass.
*/
int interpolate(char *result, int reslen,
const char *orig,
const struct interp *interps, int ninterps)
{
const char *src = orig;
char *dest = result;
int newlen = 0;
char *name, *value;
int namelen, valuelen;
int i;
char c;
memset(result, 0, reslen);
while ((c = *src) && newlen < reslen - 1) {
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;
valuelen = strlen(value);
if (newlen + valuelen < reslen - 1) {
/* Substitute. */
strncpy(dest, value, valuelen);
newlen += valuelen;
dest += valuelen;
src += namelen;
} else {
/* Something's not fitting. */
return 0;
}
} else {
/* Skip bogus interpolation. */
*dest++ = *src++;
newlen++;
}
} else {
/* Straight copy one non-interpolation character. */
*dest++ = *src++;
newlen++;
}
}
return newlen < reslen - 1;
}
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...