void ft_deal_with_uint_conversion_part1(t_op *op, t_arg *lnk) { if (ft_strncmp(op->mod, "hh", 2) == 0) { ft_putchar((unsigned char)lnk->ull); lnk->ps += 1; } else if (ft_strncmp(op->mod, "h", 1) == 0) { ft_putunbr((unsigned short)lnk->ull); lnk->ps += ft_strlen((char*)ft_uitoa((unsigned short)lnk->ull)); } else if (ft_strncmp(op->mod, "ll", 2) == 0 || ft_strncmp(op->mod, "l", 1) == 0 || ft_strncmp(op->mod, "q", 1) == 0) { ft_putunbr((unsigned long)lnk->ull); lnk->ps += ft_strlen((char*)ft_uitoa((unsigned long)lnk->ull)); } else { ft_putunbr((unsigned int)lnk->ull); lnk->ps += ft_strlen((char*)ft_uitoa((unsigned int)lnk->ull)); } }
void ft_printf_dis_lint(long int number, t_printf *st) { size_t len_dis; int n; if (st->precision == 0 && number == 0) return ; len_dis = ft_itoa_ccount((number < 0) ? number * -1 : number); if (number < 0) ++len_dis; ft_printf_dis_int2(number, st, len_dis); if ((int)len_dis < st->precision && st->right_align) { n = st->precision - len_dis; while (n--) ft_putchar('0'); } if (number < 0) ft_putunbr(number * -1); else ft_putunbr(number); if ((int)len_dis < st->precision && !st->right_align) { n = st->precision - len_dis; while (n--) ft_putchar('0'); } }
void ft_putnbr(int n) { if (n < 0) { ft_putchar('-'); ft_putunbr(-n); } else ft_putunbr(n); }
void ft_putunbr(uintmax_t n) { if (n >= 10) { ft_putunbr(n / 10); ft_putunbr(n % 10); } else ft_putchar(n + '0'); }
void ft_putnbr_color(char *color, int n) { if (n < 0) { ft_putchar('-'); ft_putunbr(color, -n); } else ft_putunbr(color, n); }
void ft_putunbr(unsigned long n) { if (n > 9) { ft_putunbr(n / 10); ft_putunbr(n % 10); } else if (n <= 9) { ft_putchar(n + 48); } }
int ft_noullflag(va_list ap, t_print *gl) { unsigned long long int u; int space; int temp; gl->i = 0; u = va_arg(ap, unsigned long long int); space = ft_char_uns(u); temp = space; ft_putstr(gl->s); if (gl->p > space) { while (gl->larg-- > gl->p && gl->i++ < 2147483647) ft_putchar(gl->c); temp = gl->p; } else while (gl->larg-- > space && gl->i++ < 2147483647) ft_putchar(gl->c); while (gl->p-- > space) ft_putchar('0'); space = temp; ft_putunbr(u); return (space + ft_strlen(gl->s) + gl->i); }
int flag_u(void *donne, const char *format, int i, int count) { if (format[i] == 'u') { ft_putunbr((unsigned int)donne); count += ft_strlen(ft_uitoa((unsigned int)donne)); } return (count); }
void ft_putunbr(unsigned int n) { char a; if (n / 10) ft_putunbr(n / 10); a = '0' + n % 10; write(1, &a, 1); }
void ft_putunbr(unsigned int d) { if (d > 9) { ft_putunbr(d / 10); ft_putnbr(d % 10); } else ft_putnbr(d); }
int unload7(t_print *gl, char t, long long int i) { if (i == 0 && gl->p == 0) ft_putchar(' '); else { if (t == 'i') ft_putunbr((unsigned int)i); if (t == 'l') ft_putunbr((unsigned long int)i); if (t == 'L') ft_putunbr((unsigned long long int)i); if (t == 's') ft_putunbr((unsigned short)i); if (t == 'c') ft_putunbr((unsigned char)i); } while (gl->larg-- > gl->space && gl->i++ < 2147483647) ft_putchar(' '); return (gl->space + ft_strlen(gl->s) + gl->i + gl->neg); }
int unload4(t_print *gl, char t, long long int i) { if (i == 0 && gl->p == 0) { if (gl->temp > 0) ft_putchar(' '); else gl->space--; } else { if (t == 'i') ft_putunbr((unsigned int)i); if (t == 'l') ft_putunbr((unsigned long int)i); if (t == 'L') ft_putunbr((unsigned long long int)i); if (t == 's') ft_putunbr((unsigned short)i); if (t == 'c') ft_putunbr((unsigned char)i); } return (gl->space + ft_strlen(gl->s) + gl->i + gl->neg); }
void write_uint(t_env *e, va_list ap) { void *d; int lng; d = va_arg(ap, void *); d = caste_normal_type(e, d); if (e->precision.p == 0 && (int)d == 0) return ; if (d == UINT_MAX + 1 && d != 0) { ft_putchar('0'); e->written++; } lng = ft_lenuint((unsigned long long int)d) - 1; if (e->precision.p > 0 && e->convert.flags[BASE] != 1) wr_prec(e, lng); if (e->convert.flags[BASE] == 1) wr_justify(e, lng); ft_putunbr((unsigned long long int)d); e->written += ft_lenuint((unsigned long long int)d); if (e->convert.flags[LEFT_JUSTIFY] == 1 && e->width.w > lng) wl_justify(e, lng); }
static void ft_putunbr(unsigned int n) { if (n >= 10) ft_putunbr(n / 10); ft_putchar((n % 10) + '0'); }
static void ft_putunbr(char *color, unsigned int n) { if (n >= 10) ft_putunbr(color, n / 10); ft_putchar_color(color, (n % 10) + '0'); }