Re: Escaping in (#51382)



On 16 Mar 2001, Owen Taylor wrote:

> > > We don't really have an escaping standard in GTK+:
> > 
> > that's not completely true, the item factory already does
> > C string like escapes for i think \", 
> 
> I don't see that anywhere. So, add another to list to the 
> characters that are going to cause problems ;-)
> 
> > and besides that, i'd count the rc-file parsing behaviour the
> > "official" standard... well, as official as you can get basically.
> 
> > >  * GScanner and hence RC files support C-string like
> > >    escaping with \n \r \t \b \f and octal escapes.
> > > 
> > >    This would imply:
> > > 
> > >    "/_File/\\/var\\/log\\/messages"
> > 
> > we don't actually have an option here, the item factory
> > dumps are supposed to be GScanner parsable, so we'll have
> > to use this style.
> 
> OK, I'll do that then.

that's not much, i.e. it shouldn't be more than just:

static void
gtk_item_factory_foreach (gpointer hash_key,
                          gpointer value,
                          gpointer user_data)
{
  GtkItemFactoryItem *item;
  GtkIFDumpData *data;
  gchar *string;
  gchar *name;
  gchar comment_prefix[2] = "\000\000";

  item = value;
  data = user_data;

  if (data->pspec && !gtk_pattern_match_string (data->pspec, item->path))
    return;

  comment_prefix[0] = gtk_item_factory_class->cpair_comment_single[0];

  name = gtk_accelerator_name (item->accelerator_key, item->accelerator_mods);
  string = g_strconcat (item->modified ? "" : comment_prefix,
                        "(menu-path \"",
                        hash_key,
                        "\" \"",
                        name,
                        "\")",
                        NULL);
  g_free (name);

+ name = g_strescape (string, NULL);
+ g_free (string);
+ string = name;
  data->print_func (data->func_data, string);

  g_free (string);
}


> 
>                                         Owen
> 

---
ciaoTJ





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