Example #1
0
static void end_tag(void)
{
    bool can_force_newline;
    char * tmp;
    /*
     * Save text because force_newline_before_tag can trash it.
     */
    tmp = strdup(yytext);

    if (using_primary_buf()) {
        can_force_newline = true;
    } else {
        /* The element didn't have any children - force newline only if user
           explicity requested that.  */
	merge_buffers();
	can_force_newline = force_always;
    }
    if (force_newline_before_end_tag && can_force_newline) {
        force_newline_before_tag(current_buf);
    }
    buffer_push_str(current_buf, tmp);
    indent_delta--;

    if (force_newline_after_end_tag && can_force_newline) {
        force_newline_after_tag(current_buf);
    }
    free(tmp);
}
Example #2
0
static void newline(void)
{
    /*
     * Flush all pending stuff before doing the newline.
     */
    if (!using_primary_buf()) {
	merge_buffers();
    }
    do_newline(current_buf, "\n");
    eat_whitespace();
}
Example #3
0
/* Force newline for wrapping line. Use lexer to get current character and
   do not eat whitespace from next line.  */
static void force_newline_for_wrap(struct buffer * buffer)
{
    int current = input();

    /*
     * Flush all pending stuff before doing the newline.
     */
    if (!using_primary_buf()) {
	merge_buffers();
    }
    do_newline(current_buf, "\n");

    if (!is_newline(current))
	do_unput(current);
}
int main(int argc, char *argv[])
{
  if (argc != 4)
    invocation_error(argv[0], "[input file 1] [input file 2] [output file]"); 

  char *output_filename = argv[3];
  struct stat file1_stat, file2_stat;
  FileInfo larger, smaller;
  off_t record_size = (off_t)get_part_record_size();

  validate_input_file(argv[1], &file1_stat, record_size);
  validate_input_file(argv[2], &file2_stat, record_size);

  sort_input_files(argv[1], &file1_stat, argv[2], &file2_stat, &larger, &smaller, record_size);

  Part out_buffer = (Part)malloc(larger.size + smaller.size);
  if (!out_buffer)
    memory_error(__FILE__, __LINE__, __func__);

  if (read_input(&larger, out_buffer, record_size) != 0) {
    free(out_buffer);
    exit(EXIT_FAILURE);
  }

  Part in_buffer = malloc(smaller.size);
  if (!in_buffer) {
    free(out_buffer);
    memory_error(__FILE__, __LINE__, __func__);
  }

  if (read_input(&smaller, in_buffer, record_size) != 0) {
    free(in_buffer);
    free(out_buffer);
    exit(EXIT_FAILURE);
  }

  size_t out_count = merge_buffers(in_buffer, smaller.count, out_buffer, larger.count);
  free(in_buffer);

  if (write_output(output_filename, out_buffer, out_count, record_size) != 0) {
    free(out_buffer);
    exit(EXIT_FAILURE);
  }

  free(out_buffer);
  return 0;
}
Example #5
0
static void drop_down_menu_callback(gpointer data)
{
  if(strcmp("drop_down_menu.remove", (char *)data) == 0)
    {
      remove_buffer(drop_down_menu_id);
    }
  else if(strcmp("drop_down_menu.merge_down", (char *)data) == 0)
    {
      if(drop_down_menu_id < get_buffer_count() - 1)
	{
	  merge_buffers(mdata[drop_down_menu_id], mdata[drop_down_menu_id + 1]);
	  remove_buffer(drop_down_menu_id + 1);
	  set_image();
	}
    }
  else if(strcmp("drop_down_menu.move_up", (char *)data) == 0)
    {
      if(drop_down_menu_id > 0)
	{
	  unsigned char * tmpdata = mdata[drop_down_menu_id];
	  mdata[drop_down_menu_id] = mdata[drop_down_menu_id - 1];
	  mdata[drop_down_menu_id - 1] = tmpdata;

	  set_image();
	}
    }
  else if(strcmp("drop_down_menu.move_down", (char *)data) == 0)
    {
      if(drop_down_menu_id < get_buffer_count() - 1)
	{
	  unsigned char * tmpdata = mdata[drop_down_menu_id];
	  mdata[drop_down_menu_id] = mdata[drop_down_menu_id + 1];
	  mdata[drop_down_menu_id + 1] = tmpdata;

	  set_image();
	}
    }
}
Example #6
0
//	-----------------------------------------------------------------------------
void dump_used_textures_all(void)
{
	int	i;
	int	temp_tmap_buf[MAX_BITMAP_FILES];
	int	perm_tmap_buf[MAX_BITMAP_FILES];
	byte	level_tmap_buf[MAX_BITMAP_FILES];
	int	temp_wall_buf[MAX_BITMAP_FILES];
	int	perm_wall_buf[MAX_BITMAP_FILES];

say_totals_all();

	my_file = fopen( "textures.dmp", "wt" );
	// -- mprintf((1, "Fileno = %i\n", fileno(my_file)));

	if (!my_file)	{
		char  ErrorMessage[200];

		sprintf( ErrorMessage, "ERROR: Can't open textures.dmp\nErrno=%i", errno);
		stop_time();
		gr_palette_load(gr_palette);
		nm_messagebox( NULL, 1, "Ok", ErrorMessage );
		start_time();

		return;
	}

	for (i=0; i<MAX_BITMAP_FILES; i++) {
		perm_tmap_buf[i] = 0;
		level_tmap_buf[i] = -1;
	}

	for (i=0; i<MAX_BITMAP_FILES; i++) {
		perm_wall_buf[i] = 0;
	}

// --05/17/95--	for (i=0; i<NUM_SHAREWARE_LEVELS; i++) {
// --05/17/95--		determine_used_textures_level(1, 1, i, temp_tmap_buf, temp_wall_buf, level_tmap_buf, MAX_BITMAP_FILES);
// --05/17/95--		fprintf(my_file, "\nTextures used in [%s]\n", Shareware_level_names[i]);
// --05/17/95--		say_used_tmaps(my_file, temp_tmap_buf);
// --05/17/95--		merge_buffers(perm_tmap_buf, temp_tmap_buf, MAX_BITMAP_FILES);
// --05/17/95--		merge_buffers(perm_wall_buf, temp_wall_buf, MAX_BITMAP_FILES);
// --05/17/95--	}
// --05/17/95--
// --05/17/95--	fprintf(my_file, "\n\nUsed textures in all shareware mines:\n");
// --05/17/95--	say_used_tmaps(my_file, perm_tmap_buf);
// --05/17/95--
// --05/17/95--	fprintf(my_file, "\nUnused textures in all shareware mines:\n");
// --05/17/95--	say_unused_tmaps(my_file, perm_tmap_buf);
// --05/17/95--
// --05/17/95--	fprintf(my_file, "\nTextures used exactly once in all shareware mines:\n");
// --05/17/95--	say_used_once_tmaps(my_file, perm_tmap_buf, level_tmap_buf);
// --05/17/95--
// --05/17/95--	fprintf(my_file, "\nWall anims (eg, doors) unused in all shareware mines:\n");
// --05/17/95--	say_unused_walls(my_file, perm_wall_buf);

// --05/17/95--	for (i=0; i<NUM_REGISTERED_LEVELS; i++) {
// --05/17/95--		determine_used_textures_level(1, 0, i, temp_tmap_buf, temp_wall_buf, level_tmap_buf, MAX_BITMAP_FILES);
// --05/17/95--		fprintf(my_file, "\nTextures used in [%s]\n", Registered_level_names[i]);
// --05/17/95--		say_used_tmaps(my_file, temp_tmap_buf);
// --05/17/95--		merge_buffers(perm_tmap_buf, temp_tmap_buf, MAX_BITMAP_FILES);
// --05/17/95--	}
// --05/17/95--
// --05/17/95--	fprintf(my_file, "\n\nUsed textures in all (including registered) mines:\n");
// --05/17/95--	say_used_tmaps(my_file, perm_tmap_buf);
// --05/17/95--
// --05/17/95--	fprintf(my_file, "\nUnused textures in all (including registered) mines:\n");
// --05/17/95--	say_unused_tmaps(my_file, perm_tmap_buf);

	for (i=First_dump_level; i<=Last_dump_level; i++) {
		determine_used_textures_level(1, 0, i, temp_tmap_buf, temp_wall_buf, level_tmap_buf, MAX_BITMAP_FILES);
		fprintf(my_file, "\nTextures used in [%s]\n", Adam_level_names[i]);
		say_used_tmaps(my_file, temp_tmap_buf);
		merge_buffers(perm_tmap_buf, temp_tmap_buf, MAX_BITMAP_FILES);
	}

	fprintf(my_file, "\n\nUsed textures in all (including registered) mines:\n");
	say_used_tmaps(my_file, perm_tmap_buf);

	fprintf(my_file, "\nUnused textures in all (including registered) mines:\n");
	say_unused_tmaps(my_file, perm_tmap_buf);

	fclose(my_file);
}
Example #7
0
static void drop_down_menu_callback(gpointer data)
{
  if(strcmp("drop_down_menu.remove", (char *)data) == 0)
    {
      remove_buffer(drop_down_menu_id);
    }
  else if(strcmp("drop_down_menu.merge_down", (char *)data) == 0)
    {
      if(drop_down_menu_id < get_buffer_count() - 1)
	{
	  merge_buffers(mdata[drop_down_menu_id], mdata[drop_down_menu_id + 1]);
	  remove_buffer(drop_down_menu_id + 1);
	  set_image();
	}
    }
  else if(strcmp("drop_down_menu.move_up", (char *)data) == 0)
    {
      if(drop_down_menu_id > 0)
	{
	  unsigned char * tmpdata = mdata[drop_down_menu_id];
	  mdata[drop_down_menu_id] = mdata[drop_down_menu_id - 1];
	  mdata[drop_down_menu_id - 1] = tmpdata;

	  set_image();
	}
    }
  else if(strcmp("drop_down_menu.move_down", (char *)data) == 0)
    {
      if(drop_down_menu_id < get_buffer_count() - 1)
	{
	  unsigned char * tmpdata = mdata[drop_down_menu_id];
	  mdata[drop_down_menu_id] = mdata[drop_down_menu_id + 1];
	  mdata[drop_down_menu_id + 1] = tmpdata;

	  set_image();
	}
    }
  else if(strcmp("drop_down_menu.edit_map_data", (char *)data) == 0)
    {
      char buffer[256];
      GtkWidget * dialog = gtk_dialog_new_with_buttons("Edit Map Data",
						       GTK_WINDOW(window),
						       GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
						       _("_OK"),
						       GTK_RESPONSE_ACCEPT,
						       _("_Cancel"),
						       GTK_RESPONSE_REJECT, NULL);


      GtkWidget * content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
      
      sprintf(buffer, "%i", mdata_info[drop_down_menu_id].scale);
      GtkWidget * scale_entry = gtk_entry_new();
      gtk_entry_set_text(GTK_ENTRY(scale_entry), buffer);
      gtk_container_add(GTK_CONTAINER(content_area), scale_entry);

      sprintf(buffer, "%i", mdata_info[drop_down_menu_id].xpos);
      GtkWidget * xpos_entry = gtk_entry_new();
      gtk_entry_set_text(GTK_ENTRY(xpos_entry), buffer);
      gtk_container_add(GTK_CONTAINER(content_area), xpos_entry);

      sprintf(buffer, "%i", mdata_info[drop_down_menu_id].zpos);
      GtkWidget * zpos_entry = gtk_entry_new();
      gtk_entry_set_text(GTK_ENTRY(zpos_entry), buffer);
      gtk_container_add(GTK_CONTAINER(content_area), zpos_entry);

      sprintf(buffer, "%i", mdata_info[drop_down_menu_id].dimension);
      GtkWidget * dimension_entry = gtk_entry_new();
      gtk_entry_set_text(GTK_ENTRY(dimension_entry), buffer);
      gtk_container_add(GTK_CONTAINER(content_area), dimension_entry);

      gtk_widget_show_all(dialog);

      if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
	{
	  mdata_info[drop_down_menu_id].scale = atoi((char *)gtk_entry_get_text(GTK_ENTRY(scale_entry)));
	  mdata_info[drop_down_menu_id].xpos = atoi((char *)gtk_entry_get_text(GTK_ENTRY(xpos_entry)));
	  mdata_info[drop_down_menu_id].zpos = atoi((char *)gtk_entry_get_text(GTK_ENTRY(zpos_entry)));
	  mdata_info[drop_down_menu_id].dimension = atoi((char *)gtk_entry_get_text(GTK_ENTRY(dimension_entry)));
	}
      gtk_widget_destroy(dialog);
    }
}
Example #8
0
int main(unsigned long long spe_id,
	 unsigned long long argp,
	 unsigned long long envp)
{
  #ifdef TRACE_TIME
  spu_write_decrementer(0);
  #endif
  setup_spu(argp);

  //unsigned int prod_ticks = 0;

  // Merge
  num_active_mergers = spu_ctrlblock.num_mergers;

  while(num_active_mergers > 0){
    if(md[am].done){
      am = (am+1) % spu_ctrlblock.num_mergers;
      continue;
    }

    // Check DMA completion if leaf node or extern parent    
    if(mcb[am].leaf_node){
      check_pull_dma(LEFT);
      check_pull_dma(RIGHT);

      if(md[am].num_waiting[LEFT] + md[am].num_waiting[RIGHT]){
	am = (am+1) % spu_ctrlblock.num_mergers;
	continue;
      }
    }

    if(mcb[am].local[OUT] == 255){
      check_push_dma();
      if(md[am].held_tag[OUT] < 32){
	am = (am+1) % spu_ctrlblock.num_mergers;
	continue;
      }
    }

    if(md[am].done){
      am = (am+1) % spu_ctrlblock.num_mergers;
      continue;
    }

    // Produce    
    #ifdef TRACE_TIME
    dec_val = spu_read_decrementer();
    #endif
    if(md[am].depleted[LEFT] && !md[am].depleted[RIGHT]){      
      cp_buffer(RIGHT);
    } else if(md[am].depleted[RIGHT] && !md[am].depleted[LEFT]){
      cp_buffer(LEFT);
    } else {
      merge_buffers();
    }
    #ifdef TRACE_TIME
    merge_ticks += -(spu_read_decrementer() - dec_val);
    #endif

    // Push, if parent not local
    if(mcb[am].local[OUT] == 255)
      push();

    // Pull if leaf node
    if(mcb[am].leaf_node){
      pull(LEFT);
      pull(RIGHT);
    }

    am = (am+1) % spu_ctrlblock.num_mergers;
  }

  #ifdef TRACE_TIME
  float tot = -spu_read_decrementer() / (79.8*1000);
  float sort = sort_v_ticks / (79.8*1000);
  float merge = merge_ticks / (79.8*1000);
  float merge_loop = merge_loop_ticks / (79.8*1000);

  printf("SPU%d: Total %fms, merge %fms, inner loop %fms, sort %fms\n", spu_ctrlblock.spu_id,tot, merge, merge_loop, sort);
  #endif

  return 0;
}