FreeBSD/contrib/diff/src/context.c
/* Print a label for a context diff, with a file name and date or a label.  */
Print a label for a context diff, with a file name and date or a label.
Print a label for a context diff with a file name and date or a label .
static void
print_context_label (char const *mark,
		     struct file_data *inf,
		     char const *label)
{
  if (label)
    fprintf (outfile, "%s %s\n", mark, label);
  else
    {
      char buf[MAX (INT_STRLEN_BOUND (int) + 32,
		    INT_STRLEN_BOUND (time_t) + 11)];
      struct tm const *tm = localtime (&inf->stat.st_mtime);
      long nsec = TIMESPEC_NS (inf->stat.st_mtim);
      if (! (tm && nstrftime (buf, sizeof buf, time_format, tm, 0, nsec)))
	{
	  time_t sec = inf->stat.st_mtime;
	  verify (info_preserved, sizeof inf->stat.st_mtime <= sizeof sec);
	  sprintf (buf, "%jd.%.9ld", (intmax_t)sec, nsec);
	}
      fprintf (outfile, "%s %s\t%s\n", mark, inf->name, buf);
    }
}
static void print_context_label ( char const * mark , struct file_data * inf , char const * label ) { if ( label ) fprintf ( outfile , " \n " , mark , label ) ; else { char buf [ MAX ( INT_STRLEN_BOUND ( int ) + 32 , INT_STRLEN_BOUND ( time_t ) + 11 ) ] ; struct tm const * tm = localtime ( & inf -> stat . st_mtime ) ; long nsec = TIMESPEC_NS ( inf -> stat . st_mtim ) ; if ( ! ( tm && nstrftime ( buf , sizeof buf , time_format , tm , 0 , nsec ) ) ) { time_t sec = inf -> stat . st_mtime ; verify ( info_preserved , sizeof inf -> stat . st_mtime <= sizeof sec ) ; sprintf ( buf , " " , ( intmax_t ) sec , nsec ) ; } fprintf ( outfile , " \t \n " , mark , inf -> name , buf ) ; } }
Print a label for a context diff, with a file name and date or a label.
Print a label for a context diff with a file name and date or a label .