Page MenuHomeFreeBSD

D36814.diff
No OneTemporary

D36814.diff

diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c
--- a/usr.bin/diff/diffreg.c
+++ b/usr.bin/diff/diffreg.c
@@ -1624,10 +1624,7 @@
print_header(const char *file1, const char *file2)
{
const char *time_format;
- char buf1[256];
- char buf2[256];
- char end1[10];
- char end2[10];
+ char buf[256];
struct tm tm1, tm2, *tm_ptr1, *tm_ptr2;
int nsec1 = stb1.st_mtim.tv_nsec;
int nsec2 = stb2.st_mtim.tv_nsec;
@@ -1638,26 +1635,32 @@
time_format = "%c";
tm_ptr1 = localtime_r(&stb1.st_mtime, &tm1);
tm_ptr2 = localtime_r(&stb2.st_mtime, &tm2);
- strftime(buf1, 256, time_format, tm_ptr1);
- strftime(buf2, 256, time_format, tm_ptr2);
- if (!cflag) {
- strftime(end1, 10, "%z", tm_ptr1);
- strftime(end2, 10, "%z", tm_ptr2);
- sprintf(buf1, "%s.%.9d %s", buf1, nsec1, end1);
- sprintf(buf2, "%s.%.9d %s", buf2, nsec2, end2);
- }
if (label[0] != NULL)
printf("%s %s\n", diff_format == D_CONTEXT ? "***" : "---",
label[0]);
- else
- printf("%s %s\t%s\n", diff_format == D_CONTEXT ? "***" : "---",
- file1, buf1);
+ else {
+ strftime(buf, sizeof(buf), time_format, tm_ptr1);
+ printf("%s %s\t%s", diff_format == D_CONTEXT ? "***" : "---",
+ file1, buf);
+ if (!cflag) {
+ strftime(buf, sizeof(buf), "%z", tm_ptr1);
+ printf(".%.9d %s", nsec1, buf);
+ }
+ printf("\n");
+ }
if (label[1] != NULL)
printf("%s %s\n", diff_format == D_CONTEXT ? "---" : "+++",
label[1]);
- else
- printf("%s %s\t%s\n", diff_format == D_CONTEXT ? "---" : "+++",
- file2, buf2);
+ else {
+ strftime(buf, sizeof(buf), time_format, tm_ptr2);
+ printf("%s %s\t%s", diff_format == D_CONTEXT ? "---" : "+++",
+ file2, buf);
+ if (!cflag) {
+ strftime(buf, sizeof(buf), "%z", tm_ptr2);
+ printf(".%.9d %s", nsec2, buf);
+ }
+ printf("\n");
+ }
}
/*

File Metadata

Mime Type
text/plain
Expires
Mon, Apr 28, 4:11 AM (1 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17825541
Default Alt Text
D36814.diff (1 KB)

Event Timeline