jed-users mailing list

[2005 Date Index] [2005 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Jed menus


Hello.

Working on menus for fljed, I came accross a minor error
in jed text menus:

   menu_append_item (menu, "test.txt", "foo");

   menu_delete_item (menu + ".test.txt");    % does not work
   % Error: Unable to find menu node Global.M&ode.test.txt

   menu_delete_item (menu + ".test\\.txt");  % does not work either
   % Error: Unable to find menu node Global.M&ode.test\.txt

jed-B0.99-17.70

If an item contains a period, it should be escaped.
In menu.c all calls like
   name_end = strchr (name, '.')

should be changed to
   name_end = find_name_end(name)

static char* find_name_end(char *name)
{
   int besc = 0;
   if (! name) return NULL;

   while (*name)
   {
      if (*name == '\\') besc = ~besc;
      else {
        if (*name == '.' && ! besc) break;
        besc = 0;
      }
      name++;
   }
   return name;
}

menu_name_eqs() should be changed to:

static int menu_name_eqs (char *a, char *b, char *bmax)
{
   if (*a == '\\') a++;
   if (*b == '\\') b++;
   while (*a && b <= bmax)
     {
	if ((b == bmax)
	    || (*a != *b))
	  return 0;
	
	a++; if (*a == '\\') a++;
	b++; if (*b == '\\') b++;
     }

   return (b == bmax);
}

This code has not been tested. There might be other places in menu.c
where changes should be made. Also a decision should be made if
the '\' character is stored in Menu_Node_Type.name.

Marko


--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2005 date index] [2005 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]