Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Commit

Permalink
flow: options parser shouldn't be looking for a substring
Browse files Browse the repository at this point in the history
The field name of options must match exactly with expected
keys.

The added test explores the issue this commit fixes.

Signed-off-by: Bruno Dilly <bruno.dilly@intel.com>
  • Loading branch information
bdilly committed Sep 4, 2015
1 parent 4e6e900 commit c2c1bf7
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/lib/flow/sol-flow-node-options.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,27 @@ get_member_memory(const struct sol_flow_node_options_member_description *member,
_max_val, _max_str, _max_str_len, \
_min_val, _min_str, _min_str_len) \
do { \
bool is_max = false, is_min = false; \
_key = strstr(buf, #_key); \
if (_key) { \
keys_schema = true; \
_key = strchr(_key, ':'); \
} else break; \
bool is_max = false, is_min = false; \
char *key_name, *remaining, *i; \
remaining = buf; \
while ((key_name = strstr(remaining, #_key))) { \
keys_schema = true; \
_key = strchr(key_name, ':'); \
if (!_key) { \
key_name = NULL; \
break; \
} \
i = key_name + strlen(#_key); \
for (; i < _key; i++) \
if (!isspace(*i)) { \
remaining = _key; \
break; \
} \
if (remaining != _key) \
break; \
} \
if (!key_name) \
break; \
if (_key && _key[0] && _key[1]) { \
_key++; \
while (_key && isspace(*_key)) _key++; \
Expand Down
42 changes: 42 additions & 0 deletions src/test-fbp/parser-rgb.fbp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This file is part of the Soletta Project
#
# Copyright (C) 2015 Intel Corporation. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Intel Corporation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Check if parser isn't getting a substring from option fields key.
# It shouldn't match 'red' on 'red_max'
Color(constant/rgb:value=red_max:80|red:20)
Converter(converter/rgb-to-int)
Red(constant/int:value=20)
Equal(int/equal)

Color OUT -> IN Converter
Converter RED -> IN[0] Equal
Red OUT -> IN[1] Equal

Equal OUT -> RESULT test_parser_suboptions(test/result)

0 comments on commit c2c1bf7

Please sign in to comment.