Esempio n. 1
0
/*******************************************************************
 *         parse_file
 */
static void parse_file( INCL_FILE *pFile, int src )
{
    char buffer[1024];
    char *include;
    int line = 0;
    FILE *file;

    if (is_generated( pFile->name ))
    {
        /* file is generated during make, don't try to open it */
        pFile->filename = xstrdup( pFile->name );
        return;
    }

    file = src ? open_src_file( pFile ) : open_include_file( pFile );
    if (!file) return;

    while (fgets( buffer, sizeof(buffer)-1, file ))
    {
        char quote;
        char *p = buffer;
        line++;
        while (*p && isspace(*p)) p++;
        if (*p++ != '#') continue;
        while (*p && isspace(*p)) p++;
        if (strncmp( p, "include", 7 )) continue;
        p += 7;
        while (*p && isspace(*p)) p++;
        if (*p != '\"' && *p != '<' ) continue;
        quote = *p++;
        if (quote == '<') quote = '>';
        include = p;
        while (*p && (*p != quote)) p++;
        if (!*p)
        {
            fprintf( stderr, "%s:%d: Malformed #include directive\n",
                     pFile->filename, line );
            exit(1);
        }
        *p = 0;
        add_include( pFile, include, line, (quote == '>') );
    }
    fclose(file);
}
Esempio n. 2
0
void grapher::require_generated() const {
    if (!is_generated()) {
        BOOST_LOG_SEV(lg, error) << graph_not_yet_generated;
        BOOST_THROW_EXCEPTION(graphing_error(graph_not_yet_generated));
    }
}