#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 ***/
#endif
#endif
-#include "main.h"
+#include "cache.h"
+#include "debug.h"
#include "exif.h"
-
#include "filecache.h"
#include "glua.h"
-#include "ui-fileops.h"
-#include "cache.h"
+#include "intl.h"
#include "jpeg-parser.h"
+#include "main-defines.h"
#include "misc.h"
+#include "ui-fileops.h"
#include "zonedetect.h"
gdouble xres = exif_get_rational_as_double(exif, "Exif.Photo.FocalPlaneXResolution");
gdouble yres = exif_get_rational_as_double(exif, "Exif.Photo.FocalPlaneYResolution");
gint res_unit;
- gint w, h;
- gdouble xsize, ysize, size, ratio;
+ gint w;
+ gint h;
+ gdouble xsize;
+ gdouble ysize;
+ gdouble size;
+ gdouble ratio;
if (xres == 0.0 || yres == 0.0) return 0.0;
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)
if (software)
{
- gint i, j;
+ gint i;
+ gint j;
g_strstrip(software);
static gchar *exif_build_formatted_FocalLength35mmFilm(ExifData *exif)
{
gint n;
- gdouble f, c;
+ gdouble f;
+ gdouble c;
if (exif_get_integer(exif, "Exif.Photo.FocalLengthIn35mmFilm", &n) && n != 0)
{
{
/* 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)
{
- ExifRational *rx, *ry;
+ ExifRational *rx;
+ ExifRational *ry;
gchar *units;
gchar *text;
static gchar *exif_build_formatted_GPSPosition(ExifData *exif)
{
GString *string;
- gchar *text, *ref;
+ gchar *ref;
ExifRational *value;
ExifItem *item;
guint i;
- gdouble p, p3;
- gulong p1, p2;
+ gdouble p;
+ gdouble p3;
+ gulong p1;
+ gulong p2;
string = g_string_new("");
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;
}
static gchar *mode_number(mode_t m)
{
- gint mb, mu, mg, mo;
+ gint mb;
+ gint mu;
+ gint mg;
+ gint mo;
gchar pbuf[12];
mb = mu = mg = mo = 0;
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;
page_n_of_m = g_strdup_printf("[%d/%d]", fd->page_num + 1, fd->page_total);
return page_n_of_m;
}
- else
- {
- return nullptr;
- }
+
+ return nullptr;
}
return g_strdup("");
}
#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);