2
* test-stubs.c - this file is part of XMLSnippets, a Geany plugin
4
* Copyright 2010 Eugene Arshinov <earshinov(at)gmail(dot)com>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
28
#include "test-stubs.h"
32
GHashTable *completions;
34
void test_stubs_init()
36
completions = g_hash_table_new(g_str_hash, g_str_equal);
39
void test_stubs_finalize()
41
g_hash_table_destroy(completions);
44
const gchar *editor_find_snippet(GeanyEditor *editor, const gchar *snippet_name)
46
return (const gchar *)g_hash_table_lookup(completions, snippet_name);
50
/** Searches backward through @a size bytes looking for a '<'.
53
* @return pointer to '<' of the found opening tag within @a sel, or @c NULL if no opening tag was found.
55
const gchar *utils_find_open_xml_tag_pos(const gchar sel[], gint size)
57
/* stolen from anjuta and modified */
58
const gchar *begin, *cur;
60
if (G_UNLIKELY(size < 3))
61
{ /* Smallest tag is "<p>" which is 3 characters */
67
/* Skip to the character before the closing brace */
76
while (cur > begin && isspace(*cur))
79
return NULL; /* we found a short tag which doesn't need to be closed */
84
/* exit immediately if such non-valid XML/HTML is detected, e.g. "<script>if a >" */
90
/* if the found tag is an opening, not a closing tag or empty <> */
91
if (*cur == '<' && *(cur + 1) != '/' && *(cur + 1) != '>')