mmenu: Fixing bug in custom category management
authorskeezix <skeezix@flotsam-vm.(none)>
Tue, 31 Jan 2012 20:31:27 +0000 (15:31 -0500)
committerskeezix <skeezix@flotsam-vm.(none)>
Tue, 31 Jan 2012 20:31:27 +0000 (15:31 -0500)
minimenu/mmcat.c
minimenu/mmui.c

index 9600d33..f8a21a5 100644 (file)
@@ -786,10 +786,13 @@ void category_publish ( unsigned int filter_mask, char *param ) {
     if ( filter_mask == CFALL ) {
       interested = 1;
     } else if ( filter_mask == CFBYNAME ) {
-      char *foo = strchr ( param, '*' ) + 1;
-      if ( strncasecmp ( iter -> catname, param, strlen ( iter -> catname ) ) == 0 &&
-          iter -> parent_catname &&
-          strcasecmp ( iter -> parent_catname, foo ) == 0 )
+      char *foo = strchr ( param, '*' ) + 1;          // where is parent folder in this? ("Game")
+      char catname [ 256 ];
+      memset ( catname, '\0', 256 );
+      strncpy ( catname, param, foo - param - 1 );    // figure out the subfolder name ("Emulator")
+      if ( strcasecmp ( iter -> catname, catname ) == 0 &&     // if the iter cat is same as the desired subfolder cat
+          iter -> parent_catname &&                           // and we have a parent (since its a subfolder...)
+          strcasecmp ( iter -> parent_catname, foo ) == 0 )   // and sed parent is the right one (in case of subfolder name reuse in other cats!)
       {
        interested = 1;
       }
index 89110b8..7a31c83 100644 (file)
@@ -4158,6 +4158,14 @@ void ui_manage_categories ( void ) {
        // did the user enter something?
        if ( changed ) {
 
+         // for now, force use of '*' into something else as we use * internally :/ (FIXME)
+         {
+           char *fixme;
+           while ( fixme = strchr ( namebuf, '*' ) ) {
+             *fixme = '_';
+           }
+         }
+
          // and if so, is it existant already or not?
          if ( mmcustom_query ( namebuf, NULL ) ) {
            ui_menu_oneby ( "Warning", "B/Enter to accept", "Already a registered category." );
@@ -4201,6 +4209,14 @@ void ui_manage_categories ( void ) {
          // did the user enter something?
          if ( changed ) {
 
+           // for now, force use of '*' into something else as we use * internally :/ (FIXME)
+           {
+             char *fixme;
+             while ( fixme = strchr ( namebuf, '*' ) ) {
+               *fixme = '_';
+             }
+           }
+
            // and if so, is it existant already or not?
            if ( mmcustom_query ( namebuf, maincat ) ) {
              ui_menu_oneby ( "Warning", "B/Enter to accept", "Already a subcategory." );