Currently comments in bindings.cfg are parsed dumbly (but efficiently)
as the first occurrence of '#', even if it occurs in a pair of quotes.
Attached is a more intelligent way that handles such quotes.

"eesh exec" in a terminal, and the exec commands in the .menu files are
both able to handle this, I guess because the shell is doing that
parsing.

Eg.
        eesh exec logger http://hello#world
        eesh exec logger 'http://hello #world'
--- a/src/aclass.c      2023-06-25 12:32:51.000000000 -0400
+++ b/src/aclass.c      2023-06-25 12:47:03.000000000 -0400
@@ -692,12 +692,34 @@
    ActionClass        *ac = *pac;
    Action             *aa = *paa;
    int                 len, len2;
-
-   len = strcspn(s, "#\r\n");
+   char               *s2, *s3;
+   int                quoteclosed;
+  
+   len = strcspn(s, "\r\n");
    if (len <= 0)
       return;
    s[len] = '\0';
 
+       s2 = s - 1;
+       quoteclosed = 0;
+       while (!quoteclosed && (s2 = strchr(s2+1, '#'))) {
+               quoteclosed = 1;
+               for (s3=s; s3<s2; s3++)
+                       if (*s3 == '\'') {
+                               while (++s3<s2 && *s3 != '\'' && *(s3 - 1) != 
'\\' ) ;
+                               if (s3 == s2)
+                                       quoteclosed = 0;
+                       }
+                       else if (*s3 == '\"') {
+                               while (++s3<s2 && *s3 != '\"' && *(s3 - 1) != 
'\\' ) ;
+                               if (s3 == s2)
+                                       quoteclosed = 0;
+                       }
+       }
+       if (s2)
+               s[s2-s] = '\0'; 
+
+
    prm2[0] = prm3[0] = '\0';
    len2 = 0;
    len = sscanf(s, "%16s %n%127s %16s", prm1, &len2, prm2, prm3);
_______________________________________________
enlightenment-users mailing list
enlightenment-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-users

Reply via email to