summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2021-07-14 17:35:47 +0100
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2021-07-14 17:35:47 +0100
commitce933dd5c17e0ed0c4c34e1ac7d37af51d4cd082 (patch)
treefdcdd32b7c6c1aecd9c552ac82b0e95aa6c0d72f
parent571a188eb0da3cb396c371c5bbe1a05aaa520280 (diff)
downloadenlightenment-ce933dd5c17e0ed0c4c34e1ac7d37af51d4cd082.tar.gz
efm - fix exif data parse - do by hand because sscanf is stupid
:)
-rw-r--r--src/bin/e_fm_prop.c62
1 files changed, 59 insertions, 3 deletions
diff --git a/src/bin/e_fm_prop.c b/src/bin/e_fm_prop.c
index 14347647d4..de52ecdb84 100644
--- a/src/bin/e_fm_prop.c
+++ b/src/bin/e_fm_prop.c
@@ -138,6 +138,64 @@ _exif_entry_find(ExifData *ed, ExifTag tag)
#endif
/**--CREATE--**/
+#ifdef HAVE_LIBEXIF
+static inline int
+_parse_exif_digit(char c)
+{
+ if ((c >= '0') && (c <= '9')) return (c - '0');
+ return -1;
+}
+
+static inline int
+_parse_digits(const char **s, char end)
+{
+ int vnow = 0, v;
+
+ for (;;)
+ {
+ v = _parse_exif_digit(**s);
+ if (v < 0)
+ {
+ if (**s != end) return -1;
+ (*s)++;
+ return vnow;
+ }
+ else vnow = (vnow * 10) + v;
+ if (!(**s)) return -1;
+ (*s)++;
+ }
+ return vnow;
+}
+
+static int
+_parse_exif_time(const char *str, struct tm *tm)
+{
+ const char *s;
+ int v;
+
+ s = str;
+ v = _parse_digits(&s, ':');
+ if (v < 0) return -1;
+ tm->tm_year = v;
+ v = _parse_digits(&s, ':');
+ if (v < 0) return -1;
+ tm->tm_mon = v;
+ v = _parse_digits(&s, ' ');
+ if (v < 0) return -1;
+ tm->tm_mday = v;
+ v = _parse_digits(&s, ':');
+ if (v < 0) return -1;
+ tm->tm_hour = v;
+ v = _parse_digits(&s, ':');
+ if (v < 0) return -1;
+ tm->tm_min = v;
+ v = _parse_digits(&s, 0);
+ if (v < 0) return -1;
+ tm->tm_sec = v;
+ return 0;
+}
+#endif
+
static void
_fill_data(E_Config_Dialog_Data *cfdata, E_Fm2_Icon *ic)
{
@@ -171,9 +229,7 @@ _fill_data(E_Config_Dialog_Data *cfdata, E_Fm2_Icon *ic)
memset(&tm, 0, sizeof(tm));
tm.tm_isdst = -1;
// "YYYY:MM:DD HH:MM:SS"
- if (sscanf(tbuf, "%i:%i:%i %i:%i:%i",
- &tm.tm_year, &tm.tm_mon, &tm.tm_mday,
- &tm.tm_hour, &tm.tm_min, &tm.tm_sec) == 6)
+ if (_parse_exif_time(tbuf, &tm) == 0)
{
tm.tm_year -= 1900;
tm.tm_mon -= 1;