This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:

Subject: v4l-utils: Ignore comma in bracket when getting subopt
Author:  Ming Qian <ming.q...@oss.nxp.com>
Date:    Wed Nov 6 15:15:35 2024 +0900

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.q...@oss.nxp.com>
Signed-off-by: Hans Verkuil <hverk...@xs4all.nl>

 include/v4l-getsubopt.h | 35 +++++++++++++++++++++++++++++++----
 meson.build             |  1 +
 2 files changed, 32 insertions(+), 4 deletions(-)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=7d0b8f3053bce969b3e121c376d5e16014f27493
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 aad8a794f7da..cd74cc8adee1 100644
--- a/meson.build
+++ b/meson.build
@@ -45,6 +45,7 @@ common_arguments = [
     '-D_GNU_SOURCE',
     '-DPROMOTED_MODE_T=int',
     '-DENABLE_NLS',
+    '-DGETSUBOPT_IGNORE_COMMA_IN_BRACKET',
     '-include', meson.current_build_dir() / 'config.h',
 ]
 

Reply via email to