diff options
| author | Wayne Davison <wayned@samba.org> | 2006-02-03 19:40:16 +0000 |
|---|---|---|
| committer | Wayne Davison <wayned@samba.org> | 2006-02-03 19:40:16 +0000 |
| commit | afa73c75b531c9a584d4b1b2ccd85defaa92e8f7 (patch) | |
| tree | 30fe0245acb74cb0ca0e061a7cba0bf30e6ed2d6 /util.c | |
| parent | 8261af7422242809bc7f888a715e9775b8c0ebd3 (diff) | |
| download | android_external_rsync-afa73c75b531c9a584d4b1b2ccd85defaa92e8f7.tar.gz android_external_rsync-afa73c75b531c9a584d4b1b2ccd85defaa92e8f7.tar.bz2 android_external_rsync-afa73c75b531c9a584d4b1b2ccd85defaa92e8f7.zip | |
A minor optimization to timestring.
Diffstat (limited to 'util.c')
| -rw-r--r-- | util.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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; } |
