summaryrefslogtreecommitdiff
path: root/src/lib/eina
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2019-05-10 14:37:24 -0700
committerCedric BAIL <cedric.bail@free.fr>2019-05-11 08:52:07 -0700
commit370917751f83bcaf65b56fde8d1a2b0d47b1d676 (patch)
tree326fc5cb90163c06064de2f3e5728a82aa863b90 /src/lib/eina
parent9c992c05d5494764df209faf1a36c04972814628 (diff)
eina: update vpath to also support a more classic syntax for variable.
This enable vpath to recognize also ${} as a variable. It does mimic what Efl.ViewModel provide with Efl.ViewModel.PropertyText and various other language. Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D8883
Diffstat (limited to 'src/lib/eina')
-rw-r--r--src/lib/eina/eina_vpath.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/lib/eina/eina_vpath.c b/src/lib/eina/eina_vpath.c
index 87b8566..0717e92 100644
--- a/src/lib/eina/eina_vpath.c
+++ b/src/lib/eina/eina_vpath.c
@@ -254,37 +254,53 @@ _eina_vpath_resolve(const char *path, char *str, size_t size)
254 } 254 }
255 } 255 }
256 // (:xxx:)/* ... <- meta hash table 256 // (:xxx:)/* ... <- meta hash table
257 else if ((path[0] == '(') && (path[1] == ':')) 257 else if (((path[0] == '(') && (path[1] == ':')) ||
258 ((path[0] == '$') && (path[1] == '{')))
258 { 259 {
259 const char *p, *end, *meta; 260 const char *p, *end, *meta;
261 const char *msg_start, *msg_end;
260 char *name; 262 char *name;
263 int offset;
261 Eina_Bool found = EINA_FALSE; 264 Eina_Bool found = EINA_FALSE;
262 265
263 end = p = strstr(path + 2, ":)"); 266 if (path[0] == '(')
267 {
268 end = p = strstr(path + 2, ":)");
269 offset = 2;
270 msg_start = "(:";
271 msg_end = ":)";
272 }
273 else
274 {
275 end = p = strchr(path + 2, '}');
276 offset = 1;
277 msg_start = "${";
278 msg_end = "}";
279 }
264 if (p) found = EINA_TRUE; 280 if (p) found = EINA_TRUE;
265 p += 2; 281 p += offset;
266 282
267 if (!found) 283 if (!found)
268 { 284 {
269 ERR("(: Needs to have a matching ':)'\nThe string was: %s", path); 285 ERR("'%s' Needs to have a matching '%s'\nThe string was: %s", msg_start, msg_end, path);
270 return 0; 286 return 0;
271 } 287 }
272 288
273 if (*p != '/') 289 if (*p != '/')
274 { 290 {
275 ERR("A / is expected after :)\nThe string was: %s", path); 291 ERR("A / is expected after '%s'\nThe string was: %s", msg_end, path);
276 return 0; 292 return 0;
277 } 293 }
278 294
279 if (found) 295 if (found)
280 { 296 {
281 name = alloca(end - path); 297 name = alloca(end - path);
282 strncpy(name, path + 2, end - path - 2); 298 strncpy(name, path + 2, end - path - offset);
283 name[end - path - 2] = 0; 299 name[end - path - 2] = 0;
284 meta = _eina_vpath_data_get(name); 300 meta = _eina_vpath_data_get(name);
285 if (meta) 301 if (meta)
286 { 302 {
287 return snprintf(str, size, "%s%s", meta, end + 2); 303 return snprintf(str, size, "%s%s", meta, end + offset);
288 } 304 }
289 else 305 else
290 { 306 {