All pastes #25728 Raw Edit

Someone

public text v1 · immutable
#25728 ·published 2005-10-17 05:50 UTC
rendered paste body
static gchar *
escape_under_score (const gchar *text)
{
  GString *str;
  gint length;
  const gchar *p;
  const gchar *end;

  g_return_val_if_fail (text != NULL, NULL);

  length = strlen (text);

  str = g_string_sized_new (length);

  p = text;
  end = text + length;

  while (p != end)
    {
      const gchar *next;
      next = g_utf8_next_char (p);

      if (*p == '_')
        g_string_append (str, "");
      else
        g_string_append_len (str, p, next - p);

      p = next;
    }

  return g_string_free (str, FALSE);
}