changeset 2323:a48a1a3e835a

- fixed /proc/bus/input/devices parser error when there are multiple lines between phys and handlers, thanks to Checkryzhev Vitaly for report and patch
author Giacomo Lozito <james@develia.org>
date Wed, 16 Jan 2008 23:07:15 +0100
parents 4bb86ffd9ddf
children 71950156bff0
files src/evdev-plug/ed_common.h src/evdev-plug/ed_internals.c
diffstat 2 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/evdev-plug/ed_common.h	Wed Jan 16 01:12:24 2008 +0200
+++ b/src/evdev-plug/ed_common.h	Wed Jan 16 23:07:15 2008 +0100
@@ -30,7 +30,7 @@
 
 #include "../../config.h"
 
-#define ED_VERSION_PLUGIN "0.2"
+#define ED_VERSION_PLUGIN "0.2p1"
 #define ED_VERSION_CONFIG "0"
 
 #define PLAYER_LOCALRC_FILE "evdev-plug.conf"
--- a/src/evdev-plug/ed_internals.c	Wed Jan 16 01:12:24 2008 +0200
+++ b/src/evdev-plug/ed_internals.c	Wed Jan 16 23:07:15 2008 +0100
@@ -378,13 +378,13 @@
 
     /* parse content of /proc/bus/input/devices */
     regcomp( &preg,
-      "I:[^\n]*\nN: Name=\"([^\n]*)\"\nP: Phys=([^\n]*)\n[^\n]+\nH: Handlers=[^\n]*(event[0-9]+)[^\n]*\n" ,
+      "I:[^\n]*\nN: Name=\"([^\n]*)\"\nP: Phys=([^\n]*)\n([^\n]+\n)*H: Handlers=[^\n]*(event[0-9]+)[^\n]*\n" ,
       REG_ICASE | REG_EXTENDED );
 
     while ( search_offset > -1 )
     {
-      size_t nmatch = 4;
-      regmatch_t submatch[4];
+      size_t nmatch = 5;
+      regmatch_t submatch[5];
 
       if ( regexec( &preg , &buffer[search_offset] , nmatch , submatch , 0 ) == 0 )
       {
@@ -408,13 +408,13 @@
             submatch[2].rm_eo - submatch[2].rm_so );
         }
 
-        if ( submatch[3].rm_so != -1 ) /* check validity of filename sub-expression */
+        if ( submatch[4].rm_so != -1 ) /* check validity of filename sub-expression */
         {
           device_file = g_string_new( "" );
           GString *device_test = g_string_new( "" );
           g_string_append_len( device_file ,
-            &buffer[(search_offset + submatch[3].rm_so)] ,
-            submatch[3].rm_eo - submatch[3].rm_so );
+            &buffer[(search_offset + submatch[4].rm_so)] ,
+            submatch[4].rm_eo - submatch[4].rm_so );
 
           /* let's check if the filename actually exists in /dev */
           g_string_printf( device_test , "/dev/input/%s" , (char*)device_file->str );