コード例 #1
0
abstract_css_selector *css_selector_reader::create_selector (const char *data)
{
  CHECK_RET (skip_comments_and_whitespaces (data), nullptr);

  unique_ptr<group_selector> group (new group_selector);

  while (*data)
    {
      string single_selector_string;
      CHECK_RET (extract_chunk (',', data, single_selector_string), nullptr);
      abstract_css_selector *selector = create_single_selector (single_selector_string.c_str ());
      if (!selector)
        return nullptr;

      group->add_selector (selector);
    }

  return group.release ();
}
コード例 #2
0
ファイル: rbh_find_printf.c プロジェクト: cea-hpc/robinhood
/**
 * Split the format string and store the result in an array. Validate
 * each chunk at the same time.
 * Return the array on success, or NULL on error.
 *
 * This function is called only once per format string.
 */
GArray *prepare_printf_format(const char *format)
{
    struct fchunk chunk;
    GArray *chunks;

    chunks = g_array_sized_new(FALSE, FALSE, sizeof(struct fchunk), 10);

    while (*format) {
        chunk.format = g_string_sized_new(50);

        format = extract_chunk(format, &chunk);
        g_array_append_val(chunks, chunk);

        if (format == NULL)
            goto free;
    }

    return chunks;

 free:
    free_printf_formats(chunks);

    return NULL;
}