-EV_BACKEND_REGISTER_WITH_CODE (ComicsDocument, comics_document,
- {
- EV_BACKEND_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_THUMBNAILS,
- comics_document_document_thumbnails_iface_init);
- } );
+EV_BACKEND_REGISTER (ComicsDocument, comics_document)
+
+/**
+ * comics_regex_quote:
+ * @unquoted_string: a literal string
+ *
+ * Quotes a string so unzip will not interpret the regex expressions of
+ * @unquoted_string. Basically, this functions uses [] to disable regex
+ * expressions. The return value must be freed with * g_free()
+ *
+ * Return value: quoted and disabled-regex string
+ **/
+static gchar *
+comics_regex_quote (const gchar *unquoted_string)
+{
+ const gchar *p;
+ GString *dest;
+
+ dest = g_string_new ("'");
+
+ p = unquoted_string;
+
+ while (*p) {
+ switch (*p) {
+ /* * matches a sequence of 0 or more characters */
+ case ('*'):
+ /* ? matches exactly 1 charactere */
+ case ('?'):
+ /* [...] matches any single character found inside
+ * the brackets. Disabling the first bracket is enough.
+ */
+ case ('['):
+ g_string_append (dest, "[");
+ g_string_append_c (dest, *p);
+ g_string_append (dest, "]");
+ break;
+ /* Because \ escapes regex expressions that we are
+ * disabling for unzip, we need to disable \ too */
+ case ('\\'):
+ g_string_append (dest, "[\\\\]");
+ break;
+ /* Escape single quote inside the string */
+ case ('\''):
+ g_string_append (dest, "'\\''");
+ break;
+ default:
+ g_string_append_c (dest, *p);
+ break;
+ }
+ ++p;
+ }
+ g_string_append_c (dest, '\'');
+ return g_string_free (dest, FALSE);
+}