static void get_options(t_dt *data) { while (*(++data->tail)) { if (*data->tail == '#') data->flag.hash = 1; else if (*data->tail == '-') data->flag.minus = 1; else if (*data->tail == '+') data->flag.plus = 1; else if (*data->tail == ' ') data->flag.space = 1; else if (*data->tail == '0') data->flag.zero = 1; else if (ft_isdigit(*data->tail)) data->flag.min_width = pf_atoi(data); else if (*data->tail == '.') { data->flag.point = data->tail++; data->flag.precision = pf_atoi(data); } else if (get_more_options(data)) break ; } }
/* **Returns the argument precision */ int get_precision(char *s) { char *backup; char *num; int i; backup = s; if (*s == '.' && pf_char_isnum(*(s + 1))) { num = pf_xmalloc(sizeof(*num) * 10); ++s; i = 0; while (pf_char_isnum(*s)) { num[i++] = *s; s++; } num[i] = 0; pf_shift_left(backup, i + 1); i = pf_atoi(num); free(num); return (i); } return (-1); }
/* **Returns the field width */ int get_field_width(char *s) { char *backup; char *num; int i; backup = s; if (pf_char_isnum(*s)) { num = pf_xmalloc(sizeof(*num) * 10); i = 0; while (pf_char_isnum(*s)) { num[i++] = *s; s++; } num[i] = 0; pf_shift_left(backup, i); i = pf_atoi(num); free(num); return (i); } return (0); }