int main(void)
{
	printf_number(98);
  	printf("\n");
	printf_number(402);
	printf("\n");
 	printf_number(1024);
 	printf("\n");
 	printf_number(0);
 	printf("\n");
 	printf_number(-98);
 	printf("\n");
 	return (0);
}
Exemplo n.º 2
0
Arquivo: assert.c Projeto: quad/voot
void __assert (const char *module, int32 line, const char *expr, const char *func, uint32 extra)
{
    char line_msg[20];

    assert_puts ("*** ASSERTION FAILURE ***");

    /* STAGE: Module name. */

    assert_puts ("Module:");
    assert_puts (module);

    /* STAGE: Function the assertion occured in. */

    assert_puts ("Function:");
    assert_puts (func);

    /* STAGE: The line number of the assertion. */

    memset (line_msg, NULL, sizeof (line_msg));
    printf_number (line_msg, line, 10, sizeof (line_msg), 0, N_LEFT);

    assert_puts ("Line Number:");
    assert_puts (line_msg);

    /* STAGE: The expression asserted. */

    assert_puts ("Expression:");
    assert_puts (expr);

    /* STAGE: The optional extra data passed in assert_x() */

    if (extra)
    {
        /* STAGE: Convert the extra number to ASCII for rendering. */

        memset (line_msg, NULL, sizeof (line_msg));
        printf_number (line_msg, extra, 16, sizeof (line_msg), 0, N_LEFT);

        assert_puts ("Message:");
        assert_puts (line_msg);
    }

    /* STAGE: Lock the system. */

    for (;;);
}
Exemplo n.º 3
0
void	printf_conversion_big_b(t_printf *t)
{
	t->flags.base = 2;
	t->flags.spec = 'b';
	t->flags.is_negative = 0;
	t->flags.showsign = 0;
	t->flags.space = 0;
	t->flags.number.longlong = VA_ARG(t->args, unsigned long int);
	if (t->flags.number.longlong == 0)
		t->flags.alt = false;
	printf_number(t);
}
Exemplo n.º 4
0
void	printf_conversion_big_f(t_printf *t)
{
	t->flags.base = 10;
	t->flags.spec = 'F';
	t->flags.number.longdouble = VA_ARG(t->args, double);
	if (t->flags.number.longdouble < 0)
	{
		t->flags.number.longdouble =
			t->flags.number.longdouble * -1;
		t->flags.is_negative = true;
	}
	printf_number(t);
}
Exemplo n.º 5
0
void	printf_conversion_p(t_printf *t)
{
	const void	*ptr;

	ptr = VA_ARG(t->args, void *);
	if (t->flags.prec == 0 && ptr == NULL)
	{
		t->flags.prec = -1;
		t->flags.pad = ' ';
		printf_string(t, "0x", 2);
		return ;
	}
	t->flags.base = 16;
	t->flags.number.word = (unsigned long int)ptr;
	t->flags.is_negative = false;
	t->flags.alt = true;
	t->flags.spec = 'x';
	printf_number(t);
}
Exemplo n.º 6
0
int vsnprintf (char *buffer, int bufferlen, char *fmt, va_list args)
{
     unsigned long ul;
     unsigned char *str, ch, base, size, lflag;

     printf_bufferp = buffer;
     printf_buffer_endp = buffer + bufferlen;
     while(1) {
	  while ((ch = *fmt++) != '%') {
	       if (ch == '\0')
		    goto return_label;
	       xxputchar(ch);
	       if (ch == '\n')
		    xxputchar('\r');
	  }
	  ch = *fmt++;
	  lflag = 0;
	  if (ch == 'l') {
	       lflag = sizeof(long) - sizeof(int);
	       ch = *fmt++;
	  }
	  base = 10;
	  size = 0;
	  switch (ch) {
	  case 'c':
	       ch = va_arg(args, char);
	       xxputchar(ch);
	       size = sizeof(int);
	       break;
	  case 's':
	       str = va_arg(args, str_t);
	       while ((ch = *str++))
		    xxputchar(ch);
	       size = sizeof(char *);
	       break;
	  case 'x':
	  case 'p':
	       base = 16;
	  case 'd':
	       if (lflag)
		    ul = va_arg(args, long);
	       else
		    ul = va_arg(args, int);
	       if ((long)ul < 0 && base == 10) {
		    xxputchar('-');
		    ul = -(long)ul;
	       }
	       printf_number(ul, base);
	       size = sizeof(int);
	       break;
	  case 'u':
	       if (lflag)
		    ul = va_arg(args, long);
	       else
		    ul = va_arg(args, unsigned);
	       printf_number(ul, base);
	       size = sizeof(int);
	       break;
	  default:
	       xxputchar('%');
	       if (lflag)
		    xxputchar('l');
	       xxputchar(ch);
	  }
int main(void)
{
    printf_number(98);
    printf("\n");
    printf_number(402);
    printf("\n");
    printf_number(1024);
    printf("\n");
    printf_number(0);
    printf("\n");
    printf_number(-98);
    printf("\n");
    printf_number(-2147483648);
    printf("\n");
    printf_number(2147483647);
    printf("\n");
    printf("\n");
    printf_number(21474838);
    printf("\n");
    printf_number(999999999);
    printf("\n");
    printf_number(21475);
    printf("\n");
    printf_number(2144);
    printf("\n");
    printf_number(2);
    printf("\n");
    printf_number(-2);
    printf("\n");
    printf_number(-1);
    printf("\n");
    printf_number(1);
    printf("\n");
    printf_number(0000);
    printf("\n");

    return (0);
}