summaryrefslogtreecommitdiff
path: root/src/lib/eolian
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2019-09-06 16:58:08 +0200
committerDaniel Kolesa <d.kolesa@samsung.com>2019-09-06 16:58:49 +0200
commit67c2a4f5f10595d4e47484d887298b87ab26a506 (patch)
tree270c3389d3ed536b9a9f110a30dba24c31f585ab /src/lib/eolian
parentd1c5e201be98875ce9a7a574719591bc7e7200f0 (diff)
eolian: disallow duplicate entries in requires/composite sections
Diffstat (limited to 'src/lib/eolian')
-rw-r--r--src/lib/eolian/eo_parser.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index 975c2a880b..e010a3fc30 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -2157,14 +2157,28 @@ _requires_add(Eo_Lexer *ls, Eina_Strbuf *buf)
2157{ 2157{
2158 const char *required; 2158 const char *required;
2159 char *fnm; 2159 char *fnm;
2160 Eina_List *l;
2161 const char *oname;
2162 char ebuf[PATH_MAX];
2160 2163
2161 eina_strbuf_reset(buf); 2164 eina_strbuf_reset(buf);
2162 eo_lexer_context_push(ls); 2165 eo_lexer_context_push(ls);
2163 parse_name(ls, buf); 2166 parse_name(ls, buf);
2164 required = eina_strbuf_string_get(buf); 2167 required = eina_stringshare_add(eina_strbuf_string_get(buf));
2168
2169 EINA_LIST_FOREACH(ls->klass->requires, l, oname)
2170 if (required == oname)
2171 {
2172 eo_lexer_context_restore(ls);
2173 eina_stringshare_del(required);
2174 snprintf(ebuf, sizeof(ebuf), "duplicate entry '%s'", oname);
2175 eo_lexer_syntax_error(ls, ebuf);
2176 return;
2177 }
2178
2165 fnm = database_class_to_filename(required); 2179 fnm = database_class_to_filename(required);
2166 2180
2167 ls->klass->requires = eina_list_append(ls->klass->requires, eina_stringshare_add(required)); 2181 ls->klass->requires = eina_list_append(ls->klass->requires, required);
2168 database_defer(ls->state, fnm, EINA_TRUE); 2182 database_defer(ls->state, fnm, EINA_TRUE);
2169 eo_lexer_context_pop(ls); 2183 eo_lexer_context_pop(ls);
2170 2184
@@ -2174,25 +2188,39 @@ _requires_add(Eo_Lexer *ls, Eina_Strbuf *buf)
2174static void 2188static void
2175_composite_add(Eo_Lexer *ls, Eina_Strbuf *buf) 2189_composite_add(Eo_Lexer *ls, Eina_Strbuf *buf)
2176{ 2190{
2191 const char *oname;
2192 char ebuf[PATH_MAX];
2193 Eina_List *l;
2194
2177 eina_strbuf_reset(buf); 2195 eina_strbuf_reset(buf);
2178 eo_lexer_context_push(ls); 2196 eo_lexer_context_push(ls);
2179 parse_name(ls, buf); 2197 parse_name(ls, buf);
2180 const char *nm = eina_strbuf_string_get(buf); 2198 const char *nm = eina_stringshare_add(eina_strbuf_string_get(buf));
2199
2200 EINA_LIST_FOREACH(ls->klass->composite, l, oname)
2201 if (nm == oname)
2202 {
2203 eo_lexer_context_restore(ls);
2204 snprintf(ebuf, sizeof(ebuf), "duplicate entry '%s'", nm);
2205 eina_stringshare_del(nm);
2206 eo_lexer_syntax_error(ls, ebuf);
2207 return;
2208 }
2209
2181 char *fnm = database_class_to_filename(nm); 2210 char *fnm = database_class_to_filename(nm);
2182 if (!eina_hash_find(ls->state->filenames_eo, fnm)) 2211 if (!eina_hash_find(ls->state->filenames_eo, fnm))
2183 { 2212 {
2184 free(fnm); 2213 free(fnm);
2185 char ebuf[PATH_MAX];
2186 eo_lexer_context_restore(ls); 2214 eo_lexer_context_restore(ls);
2187 snprintf(ebuf, sizeof(ebuf), "unknown interface '%s'", nm); 2215 snprintf(ebuf, sizeof(ebuf), "unknown interface '%s'", nm);
2216 eina_stringshare_del(nm);
2188 eo_lexer_syntax_error(ls, ebuf); 2217 eo_lexer_syntax_error(ls, ebuf);
2189 return; 2218 return;
2190 } 2219 }
2191 /* do not introduce a dependency */ 2220 /* do not introduce a dependency */
2192 database_defer(ls->state, fnm, EINA_FALSE); 2221 database_defer(ls->state, fnm, EINA_FALSE);
2193 free(fnm); 2222 free(fnm);
2194 ls->klass->composite = eina_list_append(ls->klass->composite, 2223 ls->klass->composite = eina_list_append(ls->klass->composite, nm);
2195 eina_stringshare_add(nm));
2196 eo_lexer_context_pop(ls); 2224 eo_lexer_context_pop(ls);
2197} 2225}
2198 2226