Deleted Added
full compact
message.c (278433) message.c (291125)
1///////////////////////////////////////////////////////////////////////////////
2//
3/// \file message.c
4/// \brief Printing messages
5//
6// Author: Lasse Collin
7//
8// This file has been put into the public domain.

--- 367 unchanged lines hidden (view full) ---

376 // Use big enough buffer to hold e.g. a multibyte decimal point.
377 static char buf[16];
378 snprintf(buf, sizeof(buf), "%.*f %s",
379 speed > 9.9 ? 0 : 1, speed, unit[unit_index]);
380 return buf;
381}
382
383
1///////////////////////////////////////////////////////////////////////////////
2//
3/// \file message.c
4/// \brief Printing messages
5//
6// Author: Lasse Collin
7//
8// This file has been put into the public domain.

--- 367 unchanged lines hidden (view full) ---

376 // Use big enough buffer to hold e.g. a multibyte decimal point.
377 static char buf[16];
378 snprintf(buf, sizeof(buf), "%.*f %s",
379 speed > 9.9 ? 0 : 1, speed, unit[unit_index]);
380 return buf;
381}
382
383
384/// Make a string indicating elapsed or remaining time. The format is either
384/// Make a string indicating elapsed time. The format is either
385/// M:SS or H:MM:SS depending on if the time is an hour or more.
386static const char *
387progress_time(uint64_t mseconds)
388{
389 // 9999 hours = 416 days
390 static char buf[sizeof("9999:59:59")];
391
385/// M:SS or H:MM:SS depending on if the time is an hour or more.
386static const char *
387progress_time(uint64_t mseconds)
388{
389 // 9999 hours = 416 days
390 static char buf[sizeof("9999:59:59")];
391
392 uint32_t seconds = mseconds / 1000;
392 // 32-bit variable is enough for elapsed time (136 years).
393 uint32_t seconds = (uint32_t)(mseconds / 1000);
393
394 // Don't show anything if the time is zero or ridiculously big.
395 if (seconds == 0 || seconds > ((9999 * 60) + 59) * 60 + 59)
396 return "";
397
398 uint32_t minutes = seconds / 60;
399 seconds %= 60;
400

--- 857 unchanged lines hidden ---
394
395 // Don't show anything if the time is zero or ridiculously big.
396 if (seconds == 0 || seconds > ((9999 * 60) + 59) * 60 + 59)
397 return "";
398
399 uint32_t minutes = seconds / 60;
400 seconds %= 60;
401

--- 857 unchanged lines hidden ---