mirror of
https://github.com/RsyncProject/rsync.git
synced 2026-10-22 05:44:17 -04:00
A minor optimization to timestring.
This commit is contained in:
1 parent
8261af7422
commit
afa73c75b5
1 file changed
+4
-4
@@ -1138,6 +1138,7 @@ char *timestring(time_t t)
|
||||
{
|
||||
static char TimeBuf[200];
|
||||
struct tm *tm = localtime(&t);
|
||||
char *p;
|
||||
|
||||
#ifdef HAVE_STRFTIME
|
||||
strftime(TimeBuf, sizeof TimeBuf - 1, "%Y/%m/%d %H:%M:%S", tm);
|
||||
@@ -1145,11 +1146,10 @@ char *timestring(time_t t)
|
||||
strlcpy(TimeBuf, asctime(tm), sizeof TimeBuf);
|
||||
#endif
|
||||
|
||||
if (TimeBuf[strlen(TimeBuf)-1] == '\n') {
|
||||
TimeBuf[strlen(TimeBuf)-1] = 0;
|
||||
}
|
||||
if ((p = strchr(TimeBuf, '\n')) != NULL)
|
||||
*p = '\0';
|
||||
|
||||
return(TimeBuf);
|
||||
return TimeBuf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user