#include <config.h>
+#ifdef __linux__
#define _XOPEN_SOURCE
+#endif
-#include <string.h>
-#include <math.h>
+#include <cmath>
+#include <cstdlib>
+#include <cstring>
#ifdef HAVE_LCMS
/*** color support enabled ***/
if (ratio < 0.5 || ratio > 2.0) return 0.0; /* reasonable ratio */
- size = sqrt(xsize * xsize + ysize * ysize);
+ size = hypot(xsize, ysize);
if (size < 1.0 || size > 100.0) return 0.0; /* reasonable sensor size in mm */
- return sqrt(36*36+24*24) / size;
-
+ return hypot(36, 24) / size;
}
static gboolean remove_suffix(gchar *str, const gchar *suffix, gint suffix_len)
{
/* grr, flash is a bitmask... */
GString *string;
- gchar *text;
gint n;
gint v;
/* red-eye (bit 6) */
if ((n >> 5) & 0x01) string = append_comma_text(string, _("red-eye reduction"));
- text = string->str;
- g_string_free(string, FALSE);
- return text;
+ return g_string_free(string, FALSE);
}
static gchar *exif_build_formatted_Resolution(ExifData *exif)
#ifdef HAVE_LCMS2
profileID[16] = '\0';
cmsGetHeaderProfileID(profile, profileID);
- name = (gchar *) profileID;
+ name = reinterpret_cast<gchar *>(profileID);
#else
name = (gchar *) cmsTakeProductName(profile);
#endif
static gchar *exif_build_formatted_GPSPosition(ExifData *exif)
{
GString *string;
- gchar *text, *ref;
+ gchar *ref;
ExifRational *value;
ExifItem *item;
guint i;
g_string_append_printf(string, ", %0lu° %0lu' %0.2f\" %.1s", p1, p2, p3, ref);
} // if (item && ref)
- text = string->str;
- g_string_free(string, FALSE);
-
- return text;
+ return g_string_free(string, FALSE);
} // static gchar *exif_build_forma...
static gchar *exif_build_formatted_GPSAltitude(ExifData *exif)
if (key_valid) return text;
item = exif_get_item(exif, key);
- if (item) return exif_item_get_data_as_text(item);
+ if (item) return exif_item_get_data_as_text(item, exif);
return nullptr;
}
return g_strdup_printf("%s (%d%d%d%d)", pbuf, mb, mu, mg, mo);
}
-gchar *metadata_file_info(FileData *fd, const gchar *key, MetadataFormat UNUSED(format))
+gchar *metadata_file_info(FileData *fd, const gchar *key, MetadataFormat)
{
gchar *page_n_of_m;
}
#ifdef HAVE_LUA
-gchar *metadata_lua_info(FileData *fd, const gchar *key, MetadataFormat UNUSED(format))
+gchar *metadata_lua_info(FileData *fd, const gchar *key, MetadataFormat)
{
gchar *script_name;
gchar *script_name_utf8;
script_name_utf8 = g_strdup(key + 4);
script_name = path_from_utf8(script_name_utf8);
- raw_data = lua_callvalue(fd, script_name, NULL);
+ raw_data = lua_callvalue(fd, script_name, nullptr);
valid_data = g_utf8_make_valid(raw_data, -1);
data = g_utf8_substring(valid_data, 0, 150);