<commit_before>#include "istream.h"
#include "widget.h"
#include "processor.h"
#include "uri-parser.h"
#include "session.h"
#include "widget-stream.h"
#include "embed.h"
#include "widget-registry.h"
#include "uri-address.h"

#include <stdlib.h>
#include <stdio.h>

#define EXPECTED_RESULT "foo &c:url; "

void
widget_class_lookup(pool_t pool __attr_unused, pool_t widget_pool __attr_unused,
                    struct tcache *translate_cache __attr_unused,
                    const char *widget_type __attr_unused,
                    widget_class_callback_t callback,
                    void *ctx,
                    struct async_operation_ref *async_ref __attr_unused)
{
    callback(NULL, ctx);
}

istream_t
embed_inline_widget(pool_t pool, struct processor_env *env __attr_unused,
                    struct widget *widget)
{
    return istream_string_new(pool,
                              widget->class->address.type == RESOURCE_ADDRESS_HTTP
                              ? widget->class->address.u.http->uri : "bar");
}

void
embed_frame_widget(pool_t pool __attr_unused,
                   struct processor_env *env __attr_unused,
                   struct widget *widget __attr_unused,
                   const struct http_response_handler *handler,
                   void *handler_ctx,
                   struct async_operation_ref *async_ref __attr_unused)
{
    http_response_handler_direct_abort(handler, handler_ctx);
}

static istream_t
create_input(pool_t pool)
{
    return istream_string_new(pool, "foo &c:url; <c:widget id=\"foo\" href=\"http://localhost:8080/foo\"/>");
}

static istream_t
create_test(pool_t pool, istream_t input)
{
    int ret;
    const char *uri;
    static struct parsed_uri parsed_uri;
    static struct widget widget;
    static struct processor_env env;
    struct widget_stream *ws;
    istream_t delayed;

    uri = "/beng.html";
    ret = uri_parse(pool, &parsed_uri, uri);
    if (ret != 0)
        abort();

    widget_init(&widget, &root_widget_class);<commit_msg>set global_translate_cache to 0x1, fake<commit_after>#include "istream.h"
#include "widget.h"
#include "processor.h"
#include "uri-parser.h"
#include "session.h"
#include "widget-stream.h"
#include "embed.h"
#include "widget-registry.h"
#include "uri-address.h"
#include "global.h"

#include <stdlib.h>
#include <stdio.h>

#define EXPECTED_RESULT "foo &c:url; "

void
widget_class_lookup(pool_t pool __attr_unused, pool_t widget_pool __attr_unused,
                    struct tcache *translate_cache __attr_unused,
                    const char *widget_type __attr_unused,
                    widget_class_callback_t callback,
                    void *ctx,
                    struct async_operation_ref *async_ref __attr_unused)
{
    callback(NULL, ctx);
}

istream_t
embed_inline_widget(pool_t pool, struct processor_env *env __attr_unused,
                    struct widget *widget)
{
    return istream_string_new(pool,
                              widget->class->address.type == RESOURCE_ADDRESS_HTTP
                              ? widget->class->address.u.http->uri : "bar");
}

void
embed_frame_widget(pool_t pool __attr_unused,
                   struct processor_env *env __attr_unused,
                   struct widget *widget __attr_unused,
                   const struct http_response_handler *handler,
                   void *handler_ctx,
                   struct async_operation_ref *async_ref __attr_unused)
{
    http_response_handler_direct_abort(handler, handler_ctx);
}

static istream_t
create_input(pool_t pool)
{
    return istream_string_new(pool, "foo &c:url; <c:widget id=\"foo\" href=\"http://localhost:8080/foo\"/>");
}

static istream_t
create_test(pool_t pool, istream_t input)
{
    int ret;
    const char *uri;
    static struct parsed_uri parsed_uri;
    static struct widget widget;
    static struct processor_env env;
    struct widget_stream *ws;
    istream_t delayed;

    /* HACK, processor.c will ignore c:widget otherwise */
    global_translate_cache = (struct tcache *)(size_t)1;

    uri = "/beng.html";
    ret = uri_parse(pool, &parsed_uri, uri);
    if (ret != 0)
        abort();

    widget_init(&widget, &root_widget_class);
{'fraction_non_alphanumeric': 0.09731144420651916, 'fraction_numerical': 0.0030930287889602663, 'mean_word_length': 2.7636526410026856, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '487780', 'n_tokens_mistral': 1316, 'n_tokens_neox': 1299, 'n_words': 299}