version 1.27, 2009/06/06 14:17:27 |
version 1.28, 2009/06/07 08:39:13 |
|
|
}; |
}; |
|
|
int |
int |
cvs_diffreg(const char *file1, const char *file2, int _fd1, int _fd2, |
diffreg(const char *file1, const char *file2, int _fd1, int _fd2, |
BUF *out, int flags) |
BUF *out, int flags) |
{ |
{ |
FILE *f1, *f2; |
FILE *f1, *f2; |
|
|
|
|
fd1 = dup(_fd1); |
fd1 = dup(_fd1); |
if (fd1 == -1) |
if (fd1 == -1) |
fatal("cvs_diffreg: dup: %s", strerror(errno)); |
fatal("diffreg: dup: %s", strerror(errno)); |
|
|
fd2 = dup(_fd2); |
fd2 = dup(_fd2); |
if (fd2 == -1) |
if (fd2 == -1) |
fatal("cvs_diffreg: dup: %s", strerror(errno)); |
fatal("diffreg: dup: %s", strerror(errno)); |
|
|
if (lseek(fd1, 0, SEEK_SET) < 0) |
if (lseek(fd1, 0, SEEK_SET) < 0) |
fatal("cvs_diffreg: lseek: %s", strerror(errno)); |
fatal("diffreg: lseek: %s", strerror(errno)); |
|
|
f1 = fdopen(fd1, "r"); |
f1 = fdopen(fd1, "r"); |
if (f1 == NULL) { |
if (f1 == NULL) { |
|
|
} |
} |
|
|
if (lseek(fd2, 0, SEEK_SET) < 0) |
if (lseek(fd2, 0, SEEK_SET) < 0) |
fatal("cvs_diffreg: lseek: %s", strerror(errno)); |
fatal("diffreg: lseek: %s", strerror(errno)); |
|
|
f2 = fdopen(fd2, "r"); |
f2 = fdopen(fd2, "r"); |
if (f2 == NULL) { |
if (f2 == NULL) { |
|
|
|
|
/* XXX move the isqrt() out of the macro to avoid multiple calls */ |
/* XXX move the isqrt() out of the macro to avoid multiple calls */ |
const u_int bound = (flags & D_MINIMAL) ? UINT_MAX : |
const u_int bound = (flags & D_MINIMAL) ? UINT_MAX : |
MAX(256, (u_int)isqrt(n)); |
MAX(256, isqrt(n)); |
|
|
k = 0; |
k = 0; |
c[0] = newcand(0, 0, 0); |
c[0] = newcand(0, 0, 0); |
|
|
unsigned char buf[FUNCTION_CONTEXT_SIZE]; |
unsigned char buf[FUNCTION_CONTEXT_SIZE]; |
size_t nc; |
size_t nc; |
int last = lastline; |
int last = lastline; |
char *p; |
|
char *state = NULL; |
char *state = NULL; |
|
|
lastline = pos; |
lastline = pos; |
|
|
nc = fread(buf, 1, nc, fp); |
nc = fread(buf, 1, nc, fp); |
if (nc > 0) { |
if (nc > 0) { |
buf[nc] = '\0'; |
buf[nc] = '\0'; |
p = strchr((const char *)buf, '\n'); |
buf[strcspn(buf, "\n")] = '\0'; |
if (p != NULL) |
|
*p = '\0'; |
|
if (isalpha(buf[0]) || buf[0] == '_' || buf[0] == '$') { |
if (isalpha(buf[0]) || buf[0] == '_' || buf[0] == '$') { |
if (begins_with(buf, "private:")) { |
if (begins_with(buf, "private:")) { |
if (!state) |
if (!state) |
|
|
if (!state) |
if (!state) |
state = " (public)"; |
state = " (public)"; |
} else { |
} else { |
strlcpy(lastbuf, buf, |
strlcpy(lastbuf, buf, sizeof lastbuf); |
sizeof lastbuf); |
|
if (state) |
if (state) |
strlcat(lastbuf, state, |
strlcat(lastbuf, state, |
sizeof lastbuf); |
sizeof lastbuf); |