[aravis] gv_device: fix parsing of hexadecimal address/length with 0x prefix.



commit 0f9de382fa2603513e0088d65d3c4d42a3a02923
Author: Emmanuel Pacaud <emmanuel gnome org>
Date:   Wed Sep 26 23:03:42 2012 +0200

    gv_device: fix parsing of hexadecimal address/length with 0x prefix.
    
    AT-Automation Technology cameras use 0x prefix for address and lenth
    in the genicam location string. For example:
    
    Local:C4_2040_GigE_1.0.0.zip;0x8C400904;0x4D30
    
    This commit makes the regular expression ignore 0x prefix.

 src/arvgvdevice.c |    2 +-
 tests/genicam.c   |   13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/src/arvgvdevice.c b/src/arvgvdevice.c
index 1ca8093..81af740 100644
--- a/src/arvgvdevice.c
+++ b/src/arvgvdevice.c
@@ -77,7 +77,7 @@ arv_gv_device_get_url_regex (void)
 static GRegex *arv_gv_device_url_regex = NULL;
 
 	if (arv_gv_device_url_regex == NULL)
-		arv_gv_device_url_regex = g_regex_new ("^(local:|file:|http:)(.+\\.[^;]+);?([0-9:a-f]*)?;?([0-9:a-f]*)?$",
+		arv_gv_device_url_regex = g_regex_new ("^(local:|file:|http:)(.+\\.[^;]+);?(?:0x)?([0-9:a-f]*)?;?(?:0x)?([0-9:a-f]*)?$",
 						       G_REGEX_CASELESS, 0, NULL);
 
 	return arv_gv_device_url_regex;
diff --git a/tests/genicam.c b/tests/genicam.c
index bd9d3c1..3180b0b 100644
--- a/tests/genicam.c
+++ b/tests/genicam.c
@@ -301,6 +301,19 @@ url_test (void)
 	g_assert_cmpstr (tokens[4], ==, "10cca");
 
 	g_strfreev (tokens);
+
+	tokens = g_regex_split (arv_gv_device_get_url_regex (), "Local:C4_2040_GigE_1.0.0.zip;0x8C400904;0x4D30", 0);
+
+	g_assert_cmpint (g_strv_length (tokens), ==, 6);
+
+	g_assert_cmpstr (tokens[0], ==, "");
+	g_assert_cmpstr (tokens[1], ==, "Local:");
+	g_assert_cmpstr (tokens[2], ==, "C4_2040_GigE_1.0.0.zip");
+	g_assert_cmpstr (tokens[3], ==, "8C400904");
+	g_assert_cmpstr (tokens[4], ==, "4D30");
+
+	g_strfreev (tokens);
+
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]