use g_snprintf instead of snprintf

Seems the latter cannot be found on some platforms; perhaps a
c++/namespace thing?

Use g_snprintf instead.
This commit is contained in:
Dirk-Jan C. Binnema 2020-01-07 23:15:22 +02:00
parent 38a91f3696
commit b2014fe93e
7 changed files with 12 additions and 12 deletions

View File

@ -539,7 +539,7 @@ path_to_string (Path *p, const char* frmt)
for (u = 0, str = NULL; p->_data[u] != 0; ++u) { for (u = 0, str = NULL; p->_data[u] != 0; ++u) {
char segm[16]; char segm[16];
snprintf (segm, sizeof(segm), frmt, p->_data[u] - 1); g_snprintf (segm, sizeof(segm), frmt, p->_data[u] - 1);
if (!str) if (!str)
str = g_strdup (segm); str = g_strdup (segm);
@ -645,7 +645,7 @@ thread_segment_format_string (size_t matchnum)
/* get the number of digits needed in a hex-representation of /* get the number of digits needed in a hex-representation of
* matchnum */ * matchnum */
digitnum = (unsigned) (ceil (log(matchnum)/log(16))); digitnum = (unsigned) (ceil (log(matchnum)/log(16)));
snprintf (frmt, sizeof(frmt), "%%0%ux", digitnum); g_snprintf (frmt, sizeof(frmt), "%%0%ux", digitnum);
return frmt; return frmt;
} }

View File

@ -306,7 +306,7 @@ Store::set_path_tstamp (const std::string& path, time_t tstamp)
LOCKED; LOCKED;
std::array<char, 2*sizeof(tstamp)+1> data{}; std::array<char, 2*sizeof(tstamp)+1> data{};
const std::size_t len = snprintf (data.data(), data.size(), "%x", tstamp); const std::size_t len = g_snprintf (data.data(), data.size(), "%x", tstamp);
priv_->writable_db()->set_metadata(path, std::string{data.data(), len}); priv_->writable_db()->set_metadata(path, std::string{data.data(), len});
} }
@ -390,7 +390,7 @@ mutable_self (MuStore *store)
static void static void
hash_str (char *buf, size_t buf_size, const char *data) hash_str (char *buf, size_t buf_size, const char *data)
{ {
snprintf(buf, buf_size, "016%" PRIx64, mu_util_get_hash(data)); g_snprintf(buf, buf_size, "016%" PRIx64, mu_util_get_hash(data));
} }
@ -954,7 +954,7 @@ each_part (MuMsg *msg, MuMsgPart *part, PartData *pdata)
/* save the mime type of any part */ /* save the mime type of any part */
if (part->type) { if (part->type) {
char ctype[MU_STORE_MAX_TERM_LENGTH + 1]; char ctype[MU_STORE_MAX_TERM_LENGTH + 1];
snprintf(ctype, sizeof(ctype), "%s/%s", part->type, part->subtype); g_snprintf(ctype, sizeof(ctype), "%s/%s", part->type, part->subtype);
add_term(pdata->_doc, mime + ctype); add_term(pdata->_doc, mime + ctype);
} }

View File

@ -166,7 +166,7 @@ find_or_create (GHashTable *id_table, MuMsg *msg, guint docid)
msgid = mu_msg_get_path (msg); /* fake it */ msgid = mu_msg_get_path (msg); /* fake it */
if (!msgid) { /* no path either? seems to happen... */ if (!msgid) { /* no path either? seems to happen... */
g_warning ("message without path"); g_warning ("message without path");
snprintf (fake, sizeof(fake), "fake:%p", (gpointer)msg); g_snprintf (fake, sizeof(fake), "fake:%p", (gpointer)msg);
msgid = fake; msgid = fake;
} }

View File

@ -299,7 +299,7 @@ mu_str_fullpath_s (const char* path, const char* name)
g_return_val_if_fail (path, NULL); g_return_val_if_fail (path, NULL);
snprintf (buf, sizeof(buf), "%s%c%s", path, G_DIR_SEPARATOR, g_snprintf (buf, sizeof(buf), "%s%c%s", path, G_DIR_SEPARATOR,
name ? name : ""); name ? name : "");
return buf; return buf;

View File

@ -135,7 +135,7 @@ mu_util_cache_dir (void)
{ {
static char cachedir [PATH_MAX]; static char cachedir [PATH_MAX];
snprintf (cachedir, sizeof(cachedir), "%s%cmu-%u", g_snprintf (cachedir, sizeof(cachedir), "%s%cmu-%u",
g_get_tmp_dir(), G_DIR_SEPARATOR, g_get_tmp_dir(), G_DIR_SEPARATOR,
getuid()); getuid());

View File

@ -220,7 +220,7 @@ std::string
Mu::date_to_time_t_string (int64_t t) Mu::date_to_time_t_string (int64_t t)
{ {
char buf[sizeof(InternalDateMax)]; char buf[sizeof(InternalDateMax)];
snprintf (buf, sizeof(buf), InternalDateFormat, t); g_snprintf (buf, sizeof(buf), InternalDateFormat, t);
return buf; return buf;
} }
@ -398,7 +398,7 @@ std::string
Mu::size_to_string (int64_t size) Mu::size_to_string (int64_t size)
{ {
char buf[sizeof(SizeMax)]; char buf[sizeof(SizeMax)];
snprintf (buf, sizeof(buf), SizeFormat, size); g_snprintf (buf, sizeof(buf), SizeFormat, size);
return buf; return buf;
} }

View File

@ -137,7 +137,7 @@ print_stats (MuIndexStats* stats, gboolean clear, gboolean color)
fputs ("\r", stdout); fputs ("\r", stdout);
if (color) if (color)
snprintf g_snprintf
(output, sizeof(output), (output, sizeof(output),
MU_COLOR_YELLOW "%c " MU_COLOR_DEFAULT MU_COLOR_YELLOW "%c " MU_COLOR_DEFAULT
"processing mail; " "processing mail; "
@ -149,7 +149,7 @@ print_stats (MuIndexStats* stats, gboolean clear, gboolean color)
(unsigned)stats->_updated, (unsigned)stats->_updated,
(unsigned)stats->_cleaned_up); (unsigned)stats->_cleaned_up);
else else
snprintf g_snprintf
(output, sizeof(output), (output, sizeof(output),
"%c processing mail; processed: %u; " "%c processing mail; processed: %u; "
"updated/new: %u, cleaned-up: %u", "updated/new: %u, cleaned-up: %u",