Example #1
0
static void
brute_force( int line, const char *file ) {
  SV *sva;
  hash *baby;
  const where *w;
  int err;

  fprintf( stderr, "brute_force(%d, \"%s\")\n", line, file );

  w = get_where( line, file );

  if ( err = hash_new( PL_sv_count, &baby ), ERR_None != err ) {
    nomem(  );
  }

  for ( sva = PL_sv_arenaroot; sva; sva = ( SV * ) SvANY( sva ) ) {
    SV *sv = sva + 1;
    SV *svend = &sva[SvREFCNT( sva )];

    while ( sv < svend ) {
      if ( live_sv( sv ) ) {
        const where *nw = w;

        if ( brute ) {
          const where *ow;
          if ( ( ow = hash_get( brute, &sv, sizeof( sv ) ) ) ) {
            nw = hash_GETNULL( ow );
          }
          else {
            if ( w ) {
              fprintf( stderr,
                       "%s, line %d: New var (bf): %p\n",
                       ( const char * ) ( w + 1 ), w->line, sv );
            }
          }
        }

        if ( err = hash_put( baby, &sv, sizeof( sv ),
                             hash_PUTNULL( ( void * ) nw ) ),
             ERR_None != err ) {
          nomem(  );
        }
      }
      ++sv;
    }
  }

  hash_delete( brute );
  brute = baby;
}
Example #2
0
static void
note_new_vars( int line, const char *file ) {
  list new_arenas;
  list new_free;
  int err;
  const where *w;

  if ( !file ) {
    return;
  }
#ifdef SANITY
  free_list_sane(  );
#endif

  w = get_where( line, file );

  /*fprintf(stderr, "note_new_vars(%d, \"%s\")\n", line, file); */

  if ( err =
       list_build( &new_arenas, PL_sv_arenaroot,
                   list_hint( &current_arenas ) ), ERR_None != err ) {
    nomem(  );
  }

  if ( err =
       list_build( &new_free, PL_sv_root, list_hint( &current_free ) ),
       ERR_None != err ) {
    nomem(  );
  }

  if ( note_init_done ) {
    /* Scan the lists looking for new arenas and deleted
     * free slots. A deleted free slot implies the creation of a new
     * variable.
     */

    list_true_diff( &current_arenas, &new_arenas, w, new_arena,
                    free_arena );
    list_true_diff( &new_free, &current_free, w, new_var, free_var );

    list_delete( &current_arenas );
    list_delete( &current_free );
  }

  /* Roll round to new versions of lists */
  current_arenas = new_arenas;
  current_free = new_free;
  note_init_done = 1;
}
Example #3
0
void
parse_paste(void)
{
    TextNode *pn = curr_node;
    PasteNode *paste;
    int where;

    if (gParserRegion != Scrolling) {
        fprintf(stderr, "(HyperDoc) Paste areas are only allowed in the scrolling area:");
        print_page_and_filename();
        jump();
    }
    gInPaste++;

    /* now I need to get the name */
    get_token();
    if (token.type != openaxiom_Lbrace_token) {
        fprintf(stderr, "(HyperDoc) A paste area needs a name:\n");
        print_next_ten_tokens();
        print_page_and_filename();
        jump();
    }
    pn->data.text = alloc_string(get_input_string());
    pn->type = openaxiom_Paste_token;

    /*
     * now see if there is already an entry in the hash_table for this thing,
     * if not create it and put it there.
     */
    paste = (PasteNode *) hash_find(gWindow->fPasteHashTable, pn->data.text);
    if (paste == 0) {
        paste = alloc_paste_node(pn->data.text);
        hash_insert(gWindow->fPasteHashTable, (char *)paste, paste->name);
    }
    else if (paste->haspaste) {
        fprintf(stderr, "(HyperDoc) Tried to redefine paste area %s\n", paste->name);
        print_page_and_filename();
        /* jump(); */
    }
    paste->haspaste = 1;
    paste->paste_item = current_item();
    get_token();
    if (token.type == openaxiom_Lsquarebrace_token) {
        /* user wishes to specify a where to send the command */
        where = get_where();
        if (where == -1) {
            paste->where = -1;
            fprintf(stderr, "(HyperDoc) \\begin{paste} was expecting [lisp|unix|ht]\n");
            print_next_ten_tokens();
            print_page_and_filename();
            jump();
        }
        else
            paste->where = where;
        get_token();
    }
    else
        paste->where = openaxiom_FromFile_input;

    /* now try to get the command argument or page name */
    if (token.type != openaxiom_Lbrace_token) {
        paste->where = 0;
        fprintf(stderr, "(HyperDoc) \\begin{paste} was expecting an argument\n");
        print_next_ten_tokens();
        print_page_and_filename();
        jump();
    }
    paste->arg_node = alloc_node();
    curr_node = paste->arg_node;
    parse_HyperDoc();
    curr_node->type = openaxiom_Endarg_token;

    gWindow->fDisplayedWindow = gWindow->fScrollWindow;

    /* Now try to find the displaying text */
    pn->next = alloc_node();
    curr_node = pn->next;
    parse_HyperDoc();
    curr_node->type = openaxiom_Endpaste_token;
    paste->end_node = curr_node;

    paste->begin_node = pn;
    gInPaste--;
}