Use strrchr() to strip file extension instead of g_strsplit()
This commit is contained in:
parent
13f254cecf
commit
7cc5d522bb
@ -835,7 +835,7 @@ static GHashTable *get_includes(TMSourceFile *source, GPtrArray **header_candida
|
||||
{
|
||||
GHashTable *includes = g_hash_table_new(NULL, NULL);
|
||||
GPtrArray *headers;
|
||||
gchar **src_comps;
|
||||
gchar *src_basename, *ptr;
|
||||
guint i;
|
||||
|
||||
*header_candidates = NULL;
|
||||
@ -844,7 +844,10 @@ static GHashTable *get_includes(TMSourceFile *source, GPtrArray **header_candida
|
||||
(source->lang != TM_PARSER_C && source->lang != TM_PARSER_CPP))
|
||||
return includes;
|
||||
|
||||
src_comps = g_strsplit(source->short_name, ".", 2);
|
||||
src_basename = g_strdup(source->short_name);
|
||||
if (ptr = strrchr(src_basename, '.'))
|
||||
*ptr = '\0';
|
||||
|
||||
headers = tm_tags_extract(source->tags_array, tm_tag_include_t);
|
||||
|
||||
for (i = 0; i < headers->len; i++)
|
||||
@ -859,12 +862,13 @@ static GHashTable *get_includes(TMSourceFile *source, GPtrArray **header_candida
|
||||
|
||||
if (!*header_candidates)
|
||||
{
|
||||
TMSourceFile *hdr = tm_files->pdata[0];
|
||||
gchar **hdr_comps = g_strsplit(hdr->short_name, ".", 2);
|
||||
gchar *hdr_basename = g_strdup(hdr_name);
|
||||
if (ptr = strrchr(hdr_basename, '.'))
|
||||
*ptr = '\0';
|
||||
|
||||
if (g_strcmp0(hdr_comps[0], src_comps[0]) == 0)
|
||||
if (g_strcmp0(hdr_basename, src_basename) == 0)
|
||||
*header_candidates = tm_files;
|
||||
g_strfreev(hdr_comps);
|
||||
g_free(hdr_basename);
|
||||
}
|
||||
|
||||
for (j = 0; j < tm_files->len; j++)
|
||||
@ -875,7 +879,7 @@ static GHashTable *get_includes(TMSourceFile *source, GPtrArray **header_candida
|
||||
}
|
||||
|
||||
g_ptr_array_free(headers, TRUE);
|
||||
g_strfreev(src_comps);
|
||||
g_free(src_basename);
|
||||
return includes;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user