Example #1
0
File: r3.c Project: 0day-ci/gcc
int main (void)
{
  struct R1 A1 = My_R1;
  struct R2 A2 = My_R2;

  put ("A1 :");
  dump (&A1, sizeof (struct R1));
  new_line ();
  /* { dg-output "A1 : c2 7b f3 2a 5e 12 9a 95.*\n" } */

  put ("A2 :");
  dump (&A2, sizeof (struct R2));
  new_line ();
  /* { dg-output "A2 : 09 e2 af 37 bd 24 d2 b4.*\n" } */

  if (Get_Elem1 (A1) != 0x78ABCDEF) abort ();

  Set_Elem1 (&A1, 0xCD0034);
  if (Get_Elem1 (A1) != 0xCD0034) abort ();

  if (Get_Elem2 (A2) != 0x78ABCDEF) abort ();

  Set_Elem2 (&A2, 0xCD0034);
  if (Get_Elem2 (A2) != 0xCD0034) abort ();

  new_line ();
  return 0;
}
Example #2
0
/* REAL: real console, which ignores non-printing charasters */
ssize_t console_write(const void *buf, size_t nbyte){
	if(nbyte > (SIZE_MAX - 1) / 2){
		nbyte = (SIZE_MAX - 1) / 2;
	}

	const char *cbuf = static_cast<const char *>(buf);

	for(size_t i = 0; i != nbyte; ++i){
		switch(cbuf[i]){
			case '\n':
				new_line();
				break;
			case '\b':
				if(col != 0){
					--col;
					screen[2 * (row * cols + col)] = ' ';
				}
				break;
			default:
				screen[2 * (row * cols + col)] = uint8_t(cbuf[i]);
				++col;

				if(col == cols){
					new_line();
				}

				break;
		}
	}

	set_cursor();

	return ssize_t(nbyte);
}
Example #3
0
File: q5.c Project: pjump/gcc
int main (void)
{
  struct R1 A1 = My_R1;
  struct R1 B1 = My_R1;

  struct R2 A2 = My_R2;
  struct R2 B2 = My_R2;

  put ("A1 :");
  dump (&A1, sizeof (struct R1));
  new_line ();
  /* { dg-output "A1 : 78 56 34 12 12 00 ab 00 34 00 cd 00 56 00 ef 00.*\n" } */

  put ("B1 :");
  dump (&B1, sizeof (struct R1));
  new_line ();
  /* { dg-output "B1 : 78 56 34 12 12 00 ab 00 34 00 cd 00 56 00 ef 00.*\n" } */

  put ("A2 :");
  dump (&A2, sizeof (struct R2));
  new_line ();
  /* { dg-output "A2 : 12 34 56 78 00 ab 00 12 00 cd 00 34 00 ef 00 56.*\n" } */

  put ("B2 :");
  dump (&B2, sizeof (struct R2));
  new_line ();
  /* { dg-output "B2 : 12 34 56 78 00 ab 00 12 00 cd 00 34 00 ef 00 56.*\n" } */

  if (A1.I != B1.I || A1.A[0] != B1.A[0]) abort();

  if (A2.I != B2.I || A2.A[0] != B2.A[0]) abort ();

  return 0;
}
Example #4
0
File: line.c Project: 8l/FUZIX
int main( int argc, char *argv[] )
{

  FILE *f;
  char buf[256];
  line *head, *curr;
  int linenum = 0;

  if( argc < 2 ) {
    puts( "line: Usage line filename" );
    return 0;
  }

  f = fopen( argv[1], "r" );

  head = new_line("", ' ', 0 );
  curr = head;

  do {
    strset( buf, 0 );
    fgets( buf, 255, f );
    chop( buf );
    trim( buf );
puts( buf );
    if( strcmp(buf, "") ) {
      curr->next = (struct line *)new_line( buf, 'Q', ++linenum );
      curr = (line *)curr->next;
    }
  } while( !feof(f) );

  
  print_line_list( head );

  return 0;
}
Example #5
0
File: r5.c Project: 0day-ci/gcc
int main (void)
{
  struct R1 A1 = My_R1;
  struct R2 A2 = My_R2;

  put ("A1 :");
  dump (&A1, sizeof (struct R1));
  new_line ();
  /* { dg-output "A1 : 78 56 34 12 12 00 ab 00 34 00 cd 00 56 00 ef 00.*\n" } */

  put ("A2 :");
  dump (&A2, sizeof (struct R2));
  new_line ();
  /* { dg-output "A2 : 12 34 56 78 00 ab 00 12 00 cd 00 34 00 ef 00 56.*\n" } */

  if (Get_Elem1 (A1) != 0xAB0012) abort ();

  Set_Elem1 (&A1, 0xCD0034);
  if (Get_Elem1 (A1) != 0xCD0034) abort ();

  if (Get_Elem2 (A2) != 0xAB0012) abort ();

  Set_Elem2 (&A2, 0xCD0034);
  if (Get_Elem2 (A2) != 0xCD0034) abort ();

  new_line ();
  return 0;
}
Example #6
0
/**
 * Given a certain width, split a textblock into wrapped lines of text.
 *
 * \returns Number of lines in output.
 */
size_t textblock_calculate_lines(textblock *tb,
		size_t **line_starts, size_t **line_lengths, size_t width)
{
	const char *text = tb->text;

	size_t cur_line = 0, n_lines = 0;

	size_t len = strlen(text);
	size_t text_offset;

	size_t line_start = 0, line_length = 0;
	size_t word_start = 0, word_length = 0;

	assert(width > 0);

	for (text_offset = 0; text_offset < len; text_offset++) {
		if (text[text_offset] == '\n') {
			new_line(line_starts, line_lengths, &n_lines, &cur_line,
					line_start, line_length);

			line_start = text_offset + 1;
			line_length = 0;
		} else if (text[text_offset] == ' ') {
			line_length++;

			word_start = line_length;
			word_length = 0;
		} else {
			line_length++;
			word_length++;
		}

		/* special case: if we have a very long word, just slice it */
		if (word_length == width) {
			new_line(line_starts, line_lengths, &n_lines, &cur_line,
					line_start, line_length);

			line_start += line_length;
			line_length = 0;
		}

		/* normal wrapping: wrap text at last word */
		if (line_length == width) {
			size_t last_word_offset = word_start;
			while (text[line_start + last_word_offset] != ' ')
				last_word_offset--;

			new_line(line_starts, line_lengths, &n_lines, &cur_line,
					line_start, last_word_offset);

			line_start += word_start;
			line_length = word_length;
		}
	}

	return cur_line;
}
Example #7
0
File: p4.c Project: 0day-ci/gcc
int main (void)
{
  struct R1 Local_R1;
  struct R2 Local_R2;

  put ("My_R1    :");
  dump (&My_R1, sizeof (struct R1));
  new_line ();
  /* { dg-output "My_R1    : db 0f 49 40.*\n" } */

  put ("My_R2    :");
  dump (&My_R2, sizeof (struct R2));
  new_line ();
  /* { dg-output "My_R2    : 40 49 0f db.*\n" } */

  Local_R1 = My_R1;
  put ("Local_R1 :");
  dump (&Local_R1, sizeof (struct R1));
  new_line ();
  /* { dg-output "Local_R1 : db 0f 49 40.*\n" } */

  Local_R2 = My_R2;
  put ("Local_R2 :");
  dump (&Local_R2, sizeof (struct R2));
  new_line ();
  /* { dg-output "Local_R2 : 40 49 0f db.*\n" } */

  Local_R1.F = Pi;

  put ("Local_R1 :");
  dump (&Local_R1, sizeof (struct R1));
  new_line ();
  /* { dg-output "Local_R1 : db 0f 49 40.*\n" } */

  Local_R2.F = Pi;

  put ("Local_R2 :");
  dump (&Local_R2, sizeof (struct R2));
  new_line ();
  /* { dg-output "Local_R2 : 40 49 0f db.*\n" } */

  Local_R1.F = Local_R2.F;

  put ("Local_R1 :");
  dump (&Local_R1, sizeof (struct R1));
  new_line ();
  /* { dg-output "Local_R1 : db 0f 49 40.*\n" } */

  Local_R2.F = Local_R1.F;

  put ("Local_R2 :");
  dump (&Local_R2, sizeof (struct R2));
  new_line ();
  /* { dg-output "Local_R2 : 40 49 0f db.*\n" } */

  new_line ();
  return 0;
}
Example #8
0
static void
MakeTrafficLines(
    struct traffic_info *pti)
{
    char *portname;
    static int nextcolor = 0;

    /* map port number to name for printing */
    portname = (pti->port==0)?"total":strdup(PortName(pti->port));

    /* pick color */
    pti->color = ColorNames[nextcolor % NCOLORS];
    ++nextcolor;

    /* create the lines that we sometimes use */
    if (doplot_bytes)
	pti->line_nbytes = new_line(plotter_bytes, portname, pti->color);
    if (doplot_packets) 
	pti->line_npackets = new_line(plotter_packets, portname, pti->color);
    if (doplot_active)
	pti->line_nactive = new_line(plotter_active, portname, pti->color);
    if (doplot_idle)
	pti->line_nidle = new_line(plotter_idle, portname, pti->color);
    if (doplot_open)
	pti->line_nopen = new_line(plotter_open, portname, pti->color);
    if (doplot_long)
	pti->line_nlong = new_line(plotter_long, portname, pti->color);
    if (doplot_i_open)
	pti->line_niopen = new_line(plotter_i_open, portname, pti->color);
    if (doplot_pureacks)
	pti->line_pureacks = new_line(plotter_pureacks, portname, pti->color);
}
Example #9
0
void print_ignition_indexes()
{
	print_char('S');print_char(' ');
	print_byte(lowRPMindexIgn);print_char(' ');
	print_byte(highRPMindexIgn);
	new_line();
}
Example #10
0
/* 
 * terminal_read()
 *
 * Description:
 * Implements read syscall specific to the terminal. 
 *
 * Inputs:
 * buf: buf to read the command buffer into
 * nbytes: number of bytes to read
 *
 * Outputs:
 * countread: the number of bytes read
 */
int32_t terminal_read(unsigned char * buf, int32_t nbytes) {
	int i;
	int countread = 0;
	
	set_command_location(get_tty_number());

	/* Spin until allow_terminal_read = 1 (we allow it to be read). */
	while(!allow_terminal_read[get_tty_number()]);

	/* We can only get here if we are the active terminal and the user
	 * presses ENTER.
	 */
	new_line();

	/* Iterate through nbytes reading (putting) the command buffer into buf. */
	for (i = 0; i < nbytes; i++) {
		buf[i] = command_buffer[active_terminal][i];
		command_buffer[active_terminal][i] = NULL;
		countread++;
	}

	/* Reset command_length, cursor, and the allow_terminal_read lock. */
	command_length[active_terminal] = 0;
	cursor_x[active_terminal] = 0;
	allow_terminal_read[active_terminal] = 0;

	return countread;
}
Example #11
0
// Write a char, handles newlines.
void DisplaySmall::write(uint8_t c) {
	if (c == '\n') {
		new_line();
	} else {
		_disp.write(c);
	}
}
Example #12
0
NODE *lpprop(NODE *args)
   {
   NODE *plname, *pname, *newval, *plist, *val = NIL;

   plname = string_arg(args);
   pname = string_arg(cdr(args));
   newval = car(cddr(args));
   if (NOT_THROWING)
      {
      plname = intern(plname);
      if (flag__caseobj(plname, PLIST_TRACED))
         {
         ndprintf(writestream, "Pprop %s %s %s", maybe_quote(plname),
            maybe_quote(pname), maybe_quote(newval));
         if (ufun != NIL)
            ndprintf(writestream, " in %s\n%s", ufun, this_line);
         new_line(writestream);
         }
      plist = plist__caseobj(plname);
      if (plist != NIL)
         val = getprop(plist, pname, FALSE);
      if (val != NIL)
         setcar(cdr(val), newval);
      else
         setplist__caseobj(plname, cons(pname, cons(newval, plist)));
      }
   return (UNBOUND);
   }
Example #13
0
const Pack_Of_Pts * Flux_To_Surf_Computed::next(void)
{
     if (_last)
        return 0;

     _rle_pack->set_pt0(Pt2di(_x0,_y_cur));
     _rle_pack->set_nb(_x1-_x0);
     
     if (_x1 == _x_max +1)
     {
         if (_y_cur == _b._p1.y-1)
            _last = true;
         else
         {
             for (INT x=_x_min ; x<=_x_max ; x++)
                 _l_cur[x]  = 0;
             new_line(_y_cur+1);
         }
     }
     else
     {
         while (! _l_cur[_x1]) _x1++;
         _x0 = _x1;
         while (_l_cur[_x1]) _x1++;
     }

     return _rle_pack;
}
Example #14
0
void terminal_putchar(char character)
{
	switch(character)
	{
		case '\n':
			new_line();
		break;

		case '\b':
			if(cursor_x > 0)
			{
				cursor_x--;
				terminal_putentryat(' ', terminal_color,cursor_x,cursor_y);
			}
		break;

		case '\r':
			cursor_x = 0;
		break;

		case '\t':
			cursor_x = (cursor_x + tab_size) & ~(tab_size - 1);
		break;

		default:
			terminal_putentryat(character, terminal_color, cursor_x, cursor_y);
			cursor_x++;
		break;
	}

	new_line_check();
	update_cursor();
}
Example #15
0
void new_line_check(void)
{
	if (cursor_x >= VGA_TERMINAL_WIDTH )
	{
		new_line();
	}
}
Example #16
0
void	make_line_6(t_function **file, t_tempo *vars)
{
	t_function	*tmp;
	t_line		*tmp2;
	t_instruct	*tmp3;

	tmp = *file;
	while (tmp->next)
		tmp = tmp->next;
	tmp2 = new_line(g_nb_line);
	ft_lstaddend_line(&tmp->lines, tmp2);
	tmp3 = new_instruct(vars->name, LABEL, recup_opcode(vars->name));
	ft_lstaddend_instruct(&tmp->lines, tmp3);
	tmp3 = new_instruct(vars->param1, check_param(vars->param1), 0);
	ft_lstaddend_instruct(&tmp->lines, tmp3);
	tmp3 = new_instruct(vars->param2, check_param(vars->param2), 0);
	ft_lstaddend_instruct(&tmp->lines, tmp3);
	tmp3 = new_instruct(vars->param3, check_param(vars->param3), 0);
	ft_lstaddend_instruct(&tmp->lines, tmp3);
	tmp3 = new_instruct(vars->param4, check_param(vars->param4), 0);
	ft_lstaddend_instruct(&tmp->lines, tmp3);
	tmp3 = new_instruct(vars->param5, check_param(vars->param5), 0);
	ft_lstaddend_instruct(&tmp->lines, tmp3);
	tmp3 = new_instruct(vars->param6, check_param(vars->param6), 0);
	ft_lstaddend_instruct(&tmp->lines, tmp3);
}
Example #17
0
void print_injection_indexes()
{
	print_char('I');print_char(' ');
	print_byte(lowRPMindexInj);print_char(' ');
	print_byte(highRPMindexInj);
	new_line();
}
Example #18
0
char					*get_line(t_shell *shell)
{
	struct termios		term;
	t_line				*tmp;

	new_line(shell, &tmp);
	if (shell && shell->env && !ft_init(&term))
	{
		if (!ft_config(&term))
		{
			ft_term(&tmp->str, shell, 0);
			if (!tmp->str || !tmp->str[0])
			{
				shell->hist = shell->hist->next;
				if (shell->hist)
					shell->hist->prev = NULL;
			}
			if (ft_defconfig(&term))
				exit (0);
			return (ft_strdup(tmp->str));
		}
	}
	get_next_line(1, &tmp->str);
	return (ft_strdup(tmp->str));
}
Example #19
0
void
my_output (const_string s)
{
  int len = strlen (s);
  int less_indent = 0;

  if (!out)
    return;

  if (line_pos + len > max_line_length)
    new_line ();

  if (indent > 1 && (strcmp (s, "case") == 0 || strcmp (s, "default") == 0))
    less_indent = 2;

  while (line_pos < indent * 2 - less_indent) {
    fputs ("  ", out);
    line_pos += 2;
  }

  /* Output the token.  */
  fputs (s, out);

  /* Omitting the space for parentheses makes fixwrites lose.  Sigh.
     What a kludge.  */
  if (!(len == 1 && (*s == ';' || *s == '[' || *s == ']')))
    putc (' ', out);
  line_pos += len + 1;

  last_brace = (s[0] == '}');
}
Example #20
0
void print_load_indexes()
{
	print_char('L');print_char(' ');
	print_byte(lowMAPindex);print_char(' ');
	print_byte(highMAPindex);
	new_line();
}
Example #21
0
int main(int argc, char const *argv[]) {
	//TODO 1. checar se a entrada tem o número correto de argumentos. (FEITO)
	//	   2. checar se a entrada é alfanumérica
	//	   3. checar se a entrada contém números inteiros.
	//	   3. tratar o 0.
	
	if (argc != 2) {
		printf("ERRO: número de argumentos inválido. Chamar como ./test_concat size, onde size é um inteiro.");
		exit(EXIT_FAILURE);
	}
	
	int x = atoi(argv[1]), i = 0;

	line_t line = new_line(x);
	node_t *aux = line.first;
	point_t current_point;

	if (x > 1) {
		while (aux != NULL) {
			current_point = aux->point;
			printf("Ponto %d - Valor de X: %d, Valor de Y: %d\n", i, current_point.x, current_point.y);
			i++;
			aux = aux->right;
		}
	}
	else {
		current_point = aux->point;
		printf("Ponto %d - Valor de X: %d, Valor de Y: %d\n", i, current_point.x, current_point.y);
	}
	
	printf("\n");		

	return 0;
}
Example #22
0
void read_pargh()
  {
  int s,i;
  long *d;
  char c;
  if (odstavce!=NULL) free(odstavce);
  odstavce=NULL;
  s=(pocet=i=count_pargh())*sizeof(long)*2;
  if (s==0) return;
  odstavce=getmem(s);
  d=odstavce;
  fseek(dlg,0,SEEK_SET);
  c=get_article();
  while (c!=0xff && i)
     {
     if (c==':')
        {
        fscanf(dlg,"%d",&s);
        *d++=s;
        *d++=ftell(dlg);
        i--;
        }
     if (c!='\n') new_line();
     c=get_article();
     }
  }
Example #23
0
static void
console_putc(char c)
{

	if (check_escape(c))
		return;

	switch (c) {
	case '\n':
		new_line();
		return;
	case '\r':
		pos_x = 0;
		return;
	case '\b':
		if (pos_x == 0)
			return;
		pos_x--;
		return;
	}

	vram[pos_y * cols + pos_x] = c | (attrib << 8);
	pos_x++;
	if (pos_x >= cols) {
		pos_x = 0;
		pos_y++;
		if (pos_y >= rows) {
			pos_y = rows - 1;
			scroll_up();
		}
	}
}
Example #24
0
void print_interpolation()
{
	print_char('P');print_char(' ');
	print_byte(p_inj);print_char(' ');
	print_byte(p_ign);print_char(' ');
	print_byte(q);
	new_line();
}
Example #25
0
File: kmain.c Project: inkv/ACSO
//welcome message
void cmd_welcome(char ret_name[])
{
    char name[20];
    clrscr(); //clear the screen
    putsn("================================================");
    putsn("Welcome to the alpha version of Micro-Mini OS :)");
    putsn("================================================");
    getchar();
    new_line();
    putsn("What is your name Mr. Stranger ?");
    puts("Name: ");
    gets(name); new_line(); new_line();
    if(strcpy(ret_name,name)==0) putsn("Error: invalid name(ret_name is not equal with name) ");
    puts("OK, i will call you "); putsn(name);
    cmd_hello(name); //greets the user
    return;
}
Example #26
0
File: u5.c Project: shabesoglu/gcc
int main (void)
{
    struct R1 Local_R1;
    struct R2 Local_R2;
    int C1;
    int C2;

    Local_R1.I    = 1;
    Local_R1.A[0] = 0xAB0012;
    Local_R1.A[1] = 0xCD0034;
    Local_R1.A[2] = 0xEF0056;
    put ("Local_R1 :");
    dump (&Local_R1, sizeof (struct R1));
    new_line ();
    /* { dg-output "Local_R1 : 01 00 00 00 12 00 ab 00 34 00 cd 00 56 00 ef 00\n" } */

    Local_R2.I    = 1;
    Local_R2.A[0] = 0xAB0012;
    Local_R2.A[1] = 0xCD0034;
    Local_R2.A[2] = 0xEF0056;
    put ("Local_R2 :");
    dump (&Local_R2, sizeof (struct R2));
    new_line ();
    /* { dg-output "Local_R2 : 00 00 00 01 00 ab 00 12 00 cd 00 34 00 ef 00 56\n" } */

    C1 = Local_R1.A[Local_R1.I];
    printf ("C1 : %d\n", C1);
    /* { dg-output "C1 : 13434932\n" } */

    Local_R1.I++;
    C1 = Local_R1.A[Local_R1.I];
    printf ("C1 : %d\n", C1);
    /* { dg-output "C1 : 15663190\n" } */

    C2 = Local_R2.A[Local_R2.I];
    printf ("C2 : %d\n", C2);
    /* { dg-output "C2 : 13434932\n" } */

    Local_R2.I++;
    C2 = Local_R2.A[Local_R2.I];
    printf ("C2 : %d\n", C2);
    /* { dg-output "C2 : 15663190\n" } */

    return 0;
}
Example #27
0
static void
cut_mark_point(char out, char *filename, int lineNumber )
{
  if ((count % 10) == 0) {
    if ((count % 50) == 0) new_line();
    print_integer_in_field( count, 5 );
  }

  print_character(out);
  count++;

  if( count == breakpoint )
  {
    print_string_as_error( filename, lineNumber, "Breakpoint hit" );
    new_line();
    cut_exit();
  }
}
Example #28
0
void
semicolon (void)
{
  if (!last_brace) {
    my_output (";");
    new_line ();
    last_brace = 1;
  }
}
Example #29
0
void print_Analog_1()
{
	print_char('A');print_char(' ');
	print_byte(sensor_reading[WB_PIN]);print_char(' ');
	//print_byte(sensor_reading[IAT_PIN]);print_char(' ');
	print_byte(engine_iat);print_char(' ');
	print_byte(sensor_reading[TPS_PIN]);
	new_line();
}
Example #30
0
void print_Analog_2()
{
	print_char('a');print_char(' ');
	print_byte(sensor_reading[CLT_PIN]);print_char(' ');
	print_byte(sensor_reading[MAP2_PIN]);print_char(' ');
	//print_byte(sensor_reading[OT_PIN]);print_char(' ');
	print_byte(engine_MAP);
	new_line();
}