コード例 #1
0
ファイル: dnp_sim2.c プロジェクト: Firstyear/ds
void set_default_sim_params ()
{
	memset (&sim, 0, sizeof (sim));
	sim.runs = 1;
	sim.fout = stdout;
	sim.value_count = count_values ();
}
コード例 #2
0
ファイル: css-apply.c プロジェクト: Enzime/mupdf
static void
add_shorthand_trbl(fz_css_match *match, fz_css_value *value, int spec,
	const char *name_t, const char *name_r, const char *name_b, const char *name_l)
{
	int n = count_values(value);

	if (n == 1)
	{
		add_property(match, name_t, value, spec);
		add_property(match, name_r, value, spec);
		add_property(match, name_b, value, spec);
		add_property(match, name_l, value, spec);
	}

	if (n == 2)
	{
		fz_css_value *a = value;
		fz_css_value *b = value->next;

		add_property(match, name_t, a, spec);
		add_property(match, name_r, b, spec);
		add_property(match, name_b, a, spec);
		add_property(match, name_l, b, spec);
	}

	if (n == 3)
	{
		fz_css_value *a = value;
		fz_css_value *b = value->next;
		fz_css_value *c = value->next->next;

		add_property(match, name_t, a, spec);
		add_property(match, name_r, b, spec);
		add_property(match, name_b, c, spec);
		add_property(match, name_l, b, spec);
	}

	if (n == 4)
	{
		fz_css_value *a = value;
		fz_css_value *b = value->next;
		fz_css_value *c = value->next->next;
		fz_css_value *d = value->next->next->next;

		add_property(match, name_t, a, spec);
		add_property(match, name_r, b, spec);
		add_property(match, name_b, c, spec);
		add_property(match, name_l, d, spec);
	}
}
コード例 #3
0
void print_tree(IndexTreeNode *root_node, unsigned depth)
{
   char *value_str;
   int i;
   char buffer[256];

   if (!root_node)
      return;
   print_tree(root_node->left_node, depth+1);
   for (i = 0; i < depth; i++)
      SLPDLog("   ");
   value_str = get_value_string(root_node);
   sprintf(buffer, "%03d %3d %s\n", tree_depth(root_node), count_values(root_node), value_str);
   SLPDLog(buffer);
   free(value_str);
   print_tree(root_node->right_node, depth+1);
}
コード例 #4
0
ファイル: repeat.c プロジェクト: RobertDash/pspp
static bool
parse_commands (struct lexer *lexer, struct hmap *dummies)
{
  enum lex_syntax_mode syntax_mode;
  enum segmenter_mode mode;
  struct string *outputs;
  struct string input;
  size_t input_len;
  size_t n_values;
  char *file_name;
  int line_number;
  bool ok;
  size_t i;

  if (lex_get_file_name (lexer) != NULL)
    file_name = xstrdup (lex_get_file_name (lexer));
  else
    file_name = NULL;
  line_number = lex_get_first_line_number (lexer, 0);

  ds_init_empty (&input);
  while (lex_is_string (lexer))
    {
      ds_put_substring (&input, lex_tokss (lexer));
      ds_put_byte (&input, '\n');
      lex_get (lexer);
    }
  if (ds_is_empty (&input))
    ds_put_byte (&input, '\n');
  ds_put_byte (&input, '\0');
  input_len = ds_length (&input);

  n_values = count_values (dummies);
  outputs = xmalloc (n_values * sizeof *outputs);
  for (i = 0; i < n_values; i++)
    ds_init_empty (&outputs[i]);

  syntax_mode = lex_get_syntax_mode (lexer);
  if (syntax_mode == LEX_SYNTAX_AUTO)
    mode = SEG_MODE_AUTO;
  else if (syntax_mode == LEX_SYNTAX_INTERACTIVE)
    mode = SEG_MODE_INTERACTIVE;
  else if (syntax_mode == LEX_SYNTAX_BATCH)
    mode = SEG_MODE_BATCH;
  else
    NOT_REACHED ();
  do_parse_commands (ds_ss (&input), mode, dummies, outputs, n_values);

  ds_destroy (&input);

  while (lex_match (lexer, T_ENDCMD))
    continue;

  ok = (lex_force_match_id (lexer, "END")
        && lex_force_match_id (lexer, "REPEAT"));
  if (ok)
    lex_match_id (lexer, "PRINT"); /* XXX */

  lex_discard_rest_of_command (lexer);

  for (i = 0; i < n_values; i++)
    {
      struct string *output = &outputs[n_values - i - 1];
      struct lex_reader *reader;

      reader = lex_reader_for_substring_nocopy (ds_ss (output));
      lex_reader_set_file_name (reader, file_name);
      reader->line_number = line_number;
      lex_include (lexer, reader);
    }
  free (file_name);

  return ok;
}