GithubHelp home page GithubHelp logo

html's People

Contributors

h4xxel avatar ralfherzog avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

html's Issues

Segmentation Fault

Dear Friend
thank you for your grate effort. I wrote the "main()" into thread and I created that thread 1000 times.
it gets segmentation fault randomly.
the problem is html_parse_stream() function. But because the seg fault is random I can not follow the problem. would you please help me.

Checking for NULL pointer (attrib.c)

My compiler:
Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin15.3.0
Thread model: posix

When i run program, return output is this:
Segmentation fault: 11

My solution is to change two lines into attrib.c C file ( attrib_append() function ):
if ((attrib) != NULL) {
attrib = (struct HtmlAttrib)malloc(sizeof(HtmlAttrib));

Great job,
Emilio

TODO: dynamic buffer handling to never overflow

My solution works with small BUFFERSIZE value... but now i lose lastest bytes

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "html.h"

#define BUFFSIZE 2

int main(int argc, char **argv) {
    //TODO: dynamic buffer handling to never overflow
    FILE *f;
    HtmlDocument *doc;
    HtmlParseState *parse_state;

    char *buf = NULL; 
    buf = (char*) realloc (buf, (BUFFSIZE+1) * sizeof(char));
    buf[BUFFSIZE] = 0;

    const char *token = buf;


    if(argc != 2) {
        fprintf(stderr, "usage: html <file.html>\n");
        return 1;
    }

    size_t len = 0;
    size_t buffsize = BUFFSIZE;

    parse_state = html_parse_begin();
    if(!(f = fopen(argv[1], "r"))) {
        fprintf(stderr, "error: cannot open file %s\n", argv[1]);
        return 1;
    }

    int gain=0;
    int aftergain=0;
    int add=0;

    while(!feof(f)) {
        if (buffsize==0) {
                gain++;
                add=1;
                buf = (char*) realloc (buf, (gain+BUFFSIZE + 1) * sizeof(char));
                buf[gain+BUFFSIZE] = 0;
        } else {
            add = 0;
        }
        len = fread(buf+(BUFFSIZE+aftergain-buffsize), 1, add+buffsize, f);
        token = html_parse_stream(parse_state, buf + (BUFFSIZE+aftergain-buffsize), buf, len);
        buffsize = (token - buf);
        memmove(buf, token, BUFFSIZE+gain-buffsize);
        aftergain=gain;

    }

    doc = html_parse_end(parse_state);
    fclose(f);

    html_print_dom(doc);

    html_free_document(doc);

    free(buf);
    return 0;
}

Check this pls

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.