projects
/
git.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Document git-clone --use-separate-remote
[git.git]
/
xdiff
/
xutils.c
diff --git
a/xdiff/xutils.c
b/xdiff/xutils.c
index
8221806
..
21ab8e7
100644
(file)
--- a/
xdiff/xutils.c
+++ b/
xdiff/xutils.c
@@
-29,6
+29,19
@@
+long xdl_bogosqrt(long n) {
+ long i;
+
+ /*
+ * Classical integer square root approximation using shifts.
+ */
+ for (i = 1; n > 0; n >>= 2)
+ i <<= 1;
+
+ return i;
+}
+
+
int xdl_emit_diffrec(char const *rec, long size, char const *pre, long psize,
xdemitcb_t *ecb) {
mmbuffer_t mb[3];
int xdl_emit_diffrec(char const *rec, long size, char const *pre, long psize,
xdemitcb_t *ecb) {
mmbuffer_t mb[3];
@@
-235,7
+248,8
@@
long xdl_atol(char const *str, char const **next) {
}
}
-int xdl_emit_hunk_hdr(long s1, long c1, long s2, long c2, xdemitcb_t *ecb) {
+int xdl_emit_hunk_hdr(long s1, long c1, long s2, long c2,
+ const char *func, long funclen, xdemitcb_t *ecb) {
int nb = 0;
mmbuffer_t mb;
char buf[128];
int nb = 0;
mmbuffer_t mb;
char buf[128];
@@
-243,7
+257,7
@@
int xdl_emit_hunk_hdr(long s1, long c1, long s2, long c2, xdemitcb_t *ecb) {
memcpy(buf, "@@ -", 4);
nb += 4;
memcpy(buf, "@@ -", 4);
nb += 4;
- nb += xdl_num_out(buf + nb, c1 ? s1:
0
);
+ nb += xdl_num_out(buf + nb, c1 ? s1:
s1 - 1
);
if (c1 != 1) {
memcpy(buf + nb, ",", 1);
if (c1 != 1) {
memcpy(buf + nb, ",", 1);
@@
-255,7
+269,7
@@
int xdl_emit_hunk_hdr(long s1, long c1, long s2, long c2, xdemitcb_t *ecb) {
memcpy(buf + nb, " +", 2);
nb += 2;
memcpy(buf + nb, " +", 2);
nb += 2;
- nb += xdl_num_out(buf + nb, c2 ? s2:
0
);
+ nb += xdl_num_out(buf + nb, c2 ? s2:
s2 - 1
);
if (c2 != 1) {
memcpy(buf + nb, ",", 1);
if (c2 != 1) {
memcpy(buf + nb, ",", 1);
@@
-264,8
+278,16
@@
int xdl_emit_hunk_hdr(long s1, long c1, long s2, long c2, xdemitcb_t *ecb) {
nb += xdl_num_out(buf + nb, c2);
}
nb += xdl_num_out(buf + nb, c2);
}
- memcpy(buf + nb, " @@\n", 4);
- nb += 4;
+ memcpy(buf + nb, " @@", 3);
+ nb += 3;
+ if (func && funclen) {
+ buf[nb++] = ' ';
+ if (funclen > sizeof(buf) - nb - 1)
+ funclen = sizeof(buf) - nb - 1;
+ memcpy(buf + nb, func, funclen);
+ nb += funclen;
+ }
+ buf[nb++] = '\n';
mb.ptr = buf;
mb.size = nb;
mb.ptr = buf;
mb.size = nb;