Skip to content

Commit 07137ab

Browse files
author
Erik Williamson
committed
tesint MB_CUR
1 parent 5249596 commit 07137ab

File tree

2 files changed

+4
-19
lines changed

2 files changed

+4
-19
lines changed

ft_printf.c

+2-17
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ int ft_wctomb(char *s, wchar_t wchar)
55
char *tmp;
66

77
tmp = s;
8-
if (wchar <= 0x00FF)
8+
if (wchar <= 0x007F)
99
{
1010
*tmp = wchar;
1111
return (1);
@@ -348,11 +348,6 @@ t_print *fmt_ptr(t_print *p)
348348
char *hexn;
349349
char *alt;
350350
hexn = cast_uint(p, 0, 16);
351-
// if (!*hexn && p->precision == 0 && p->width < 1)
352-
// {
353-
// ft_strwjoin(p, " ", 1);
354-
// return (p);
355-
// }
356351
alt = ft_strdup("0x");
357352
ft_strnjoin(&alt, hexn, ft_strlen(hexn));
358353
justify_hex(p, alt, 0);
@@ -594,7 +589,6 @@ void justify_dec(t_print *p, char *digits)
594589

595590
uintmax_t castify(intmax_t n, t_print *p)
596591
{
597-
// char lengths[][3] = {"hh","h","ll","l","j","z","\0"};
598592
if (p->length == 0)
599593
{
600594
p->is_signed = ((signed char)n < 0 ? 1 : 0);
@@ -692,10 +686,7 @@ t_print *parse_conversion(t_print *p)
692686
fmt_str(p);
693687
else if (p->buf[p->i] == 'S')
694688
{
695-
if (MB_CUR_MAX > 1)
696-
fmt_wstr(p);
697-
else
698-
fmt_str(p);
689+
fmt_wstr(p);
699690
}
700691
else if (p->buf[p->i] == 'd' || p->buf[p->i] == 'i'|| p->buf[p->i] == 'D')
701692
{
@@ -706,7 +697,6 @@ t_print *parse_conversion(t_print *p)
706697
fmt_hex(p, 0);
707698
else if (p->buf[p->i] == 'p')
708699
{
709-
// p->f_alt = 1;
710700
p->length = 3;
711701
fmt_ptr(p);
712702
}
@@ -780,13 +770,8 @@ int ft_printf(const char *format, ...)
780770
parse_conversion(parse_length(parse_precision(parse_width(parse_flags(parse_percent(p))))));
781771
}
782772
va_end(p->ap);
783-
// ft_putstrc(p->out, 200, 20, 20);
784773
len = p->r;
785774
write(1, p->out, len);
786-
// print_struct(p);
787-
// ft_putstr("ret: ");
788-
// ft_putnbr(len);
789-
// ft_putchar('\n');
790775
ft_strdel(&p->buf);
791776
ft_strdel(&p->out);
792777
free(p);

testing/main.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ int main(void)
3333
// my_str = ft_strnew(wstrbytelen(my_wstr));
3434
// wstrtombstr(my_str, my_wstr);
3535
// printf("%s\n", my_str);
36-
o1 = ft_printf("%C\n", L'≥');
37-
o2 = printf("%C\n", L'≥');
36+
o1 = ft_printf("%S\n", L"❀ ≥ ☭ test text Æ");
37+
o2 = printf("%S\n", L"❀ ≥ ☭ test text Æ");
3838
// printf("%d\n", wstrbytelen(L"≥"));
3939
// ft_putnbr(write(1, &my_str, 2));
4040
// write(1, my_str, sizeof(my_str) / sizeof(my_wchar));

0 commit comments

Comments
 (0)