From: Ming Qian <ming.qian@xxxxxxxxxxx> v4l_getsubopt() ignore comma in bracket, then we can set rect value in the format of (x,y)/WxH. Add macro GETSUBOPT_IGNORE_COMMA_IN_BRACKET to enable or disable this feature. Signed-off-by: Ming Qian <ming.qian@xxxxxxxxxxx> --- include/v4l-getsubopt.h | 35 +++++++++++++++++++++++++++++++---- meson.build | 1 + 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/include/v4l-getsubopt.h b/include/v4l-getsubopt.h index 60e7b9767ab8..4c9cf509fc0f 100644 --- a/include/v4l-getsubopt.h +++ b/include/v4l-getsubopt.h @@ -7,12 +7,41 @@ * So add support for it here, if needed. */ -#if defined(__GLIBC__) +#if defined(__GLIBC__) && !defined(GETSUBOPT_IGNORE_COMMA_IN_BRACKET) #define v4l_getsubopt getsubopt #else +#include <string.h> +#include <stdlib.h> + +#if defined (GETSUBOPT_IGNORE_COMMA_IN_BRACKET) +/* + * Find the first occurrence of C in S or the final NUL byte. + * But ignore the C in brackets + */ +static inline char *v4l_strchrnul (const char *s, int c_in) +{ + const unsigned char *char_ptr; + unsigned char c; + int in_brackets = 0; + + c = (unsigned char) c_in; + + char_ptr = (const unsigned char *) s; + while (*char_ptr) { + if (*char_ptr == '(') + in_brackets++; + else if (*char_ptr == ')') + in_brackets--; + else if (*char_ptr == c && in_brackets == 0) + break; + ++char_ptr; + } + return (char *) char_ptr; +} +#else /* * Import strchrnul(...) from uClibc version 0.9.33.2 since this feature is * missing in the Android C library. @@ -41,9 +70,6 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include <string.h> -#include <stdlib.h> - /* Find the first occurrence of C in S or the final NUL byte. */ static inline char *v4l_strchrnul (const char *s, int c_in) { @@ -179,6 +205,7 @@ static inline char *v4l_strchrnul (const char *s, int c_in) /* This should never happen. */ return NULL; } +#endif /* * Import getsubopt(...) from uClibc version 0.9.33.2 since this feature is diff --git a/meson.build b/meson.build index ce6db73c7014..84a863f3ca65 100644 --- a/meson.build +++ b/meson.build @@ -46,6 +46,7 @@ common_arguments = [ '-D_GNU_SOURCE', '-DPROMOTED_MODE_T=int', '-DENABLE_NLS', + '-DGETSUBOPT_IGNORE_COMMA_IN_BRACKET', '-include', meson.current_build_dir() / 'config.h', ] -- 2.43.0-rc1