eolian: use libgen.h basename

This commit is contained in:
Daniel Kolesa 2014-07-23 19:37:03 +01:00
parent 5a67cc997d
commit a3182948ad
4 changed files with 22 additions and 12 deletions

View File

@ -1,4 +1,5 @@
#include <getopt.h> #include <getopt.h>
#include <libgen.h>
#include <Eina.h> #include <Eina.h>
@ -327,9 +328,10 @@ int main(int argc, char **argv)
{ {
EINA_LIST_FOREACH(files4gen, itr, filename) EINA_LIST_FOREACH(files4gen, itr, filename)
{ {
char *bn = eina_file_path_basename(filename, NULL); char *dup = strdup(filename);
char *bn = basename(dup);
class = eolian_class_get_by_file(bn); class = eolian_class_get_by_file(bn);
free(bn); free(dup);
if (class) eolian_show_class(class); if (class) eolian_show_class(class);
} }
} }
@ -340,9 +342,10 @@ int main(int argc, char **argv)
goto end; goto end;
} }
char *bn = eina_file_path_basename(eina_list_data_get(files4gen), NULL); char *dup = strdup(eina_list_data_get(files4gen));
char *bn = basename(dup);
class = eolian_class_get_by_file(bn); class = eolian_class_get_by_file(bn);
free(bn); free(dup);
if (gen_opt) if (gen_opt)
{ {

View File

@ -2,6 +2,7 @@
#define EOLIAN_CXX_EOLIAN_WRAPPERS_HH #define EOLIAN_CXX_EOLIAN_WRAPPERS_HH
#include <cassert> #include <cassert>
#include <libgen.h>
#include <Eolian.h> #include <Eolian.h>
@ -30,9 +31,10 @@ ctor_t const ctor = {};
inline const Eolian_Class* inline const Eolian_Class*
class_from_file(std::string const& file) class_from_file(std::string const& file)
{ {
char *bn = eina_file_path_basename(file.c_str(), NULL); char *dup = strdup(file.c_str());
char *bn = basename(dup);
const Eolian_Class *cl = ::eolian_class_get_by_file(bn); const Eolian_Class *cl = ::eolian_class_get_by_file(bn);
free(bn); free(dup);
return cl; return cl;
} }

View File

@ -1,3 +1,5 @@
#include <libgen.h>
#include "eo_parser.h" #include "eo_parser.h"
#define CASE_LOCK(ls, var, msg) \ #define CASE_LOCK(ls, var, msg) \
@ -126,9 +128,10 @@ append_node(Eo_Lexer *ls, int type, void *def)
static const char * static const char *
get_filename(Eo_Lexer *ls) get_filename(Eo_Lexer *ls)
{ {
char *s = eina_file_path_basename(ls->source, NULL); char *dup = strdup(ls->source);
char *s = basename(dup);
const char *file = eina_stringshare_add(s); const char *file = eina_stringshare_add(s);
free(s); free(dup);
return file; return file;
} }

View File

@ -1,3 +1,4 @@
#include <libgen.h>
#include <Eina.h> #include <Eina.h>
#include "eo_parser.h" #include "eo_parser.h"
#include "eolian_database.h" #include "eolian_database.h"
@ -133,7 +134,8 @@ EAPI Eina_Bool
eolian_eo_file_parse(const char *filepath) eolian_eo_file_parse(const char *filepath)
{ {
Eina_Iterator *itr; Eina_Iterator *itr;
char *bfilename = eina_file_path_basename(filepath, NULL); char *bfiledup = strdup(filepath);
char *bfilename = basename(bfiledup);
const Eolian_Class *class = eolian_class_get_by_file(bfilename); const Eolian_Class *class = eolian_class_get_by_file(bfilename);
const char *inherit_name; const char *inherit_name;
Eolian_Implement *impl; Eolian_Implement *impl;
@ -141,18 +143,18 @@ eolian_eo_file_parse(const char *filepath)
{ {
if (!eo_parser_database_fill(filepath, EINA_FALSE)) if (!eo_parser_database_fill(filepath, EINA_FALSE))
{ {
free(bfilename); free(bfiledup);
return EINA_FALSE; return EINA_FALSE;
} }
class = eolian_class_get_by_file(bfilename); class = eolian_class_get_by_file(bfilename);
if (!class) if (!class)
{ {
ERR("No class for file %s", bfilename); ERR("No class for file %s", bfilename);
free(bfilename); free(bfiledup);
return EINA_FALSE; return EINA_FALSE;
} }
} }
free(bfilename); free(bfiledup);
itr = eolian_class_inherits_get(class); itr = eolian_class_inherits_get(class);
EINA_ITERATOR_FOREACH(itr, inherit_name) EINA_ITERATOR_FOREACH(itr, inherit_name)
{ {