Lines Matching refs:spec
766 mpd_validate_lconv(mpd_spec_t *spec)
770 const char *cp = spec->grouping;
777 n = strlen(spec->dot);
781 if (strlen(spec->sep) > 4) {
789 mpd_parse_fmt_str(mpd_spec_t *spec, const char *fmt, int caps)
795 spec->min_width = 0;
796 spec->prec = -1;
797 spec->type = caps ? 'G' : 'g';
798 spec->align = '>';
799 spec->sign = '-';
800 spec->dot = "";
801 spec->sep = "";
802 spec->grouping = "";
806 if ((n = _mpd_copy_utf8(spec->fill, cp)) < 0) {
814 spec->align = *cp++;
819 spec->fill[0] = ' ';
820 spec->fill[1] = '\0';
823 spec->align = *cp++;
830 spec->sign = *cp++;
840 spec->align = 'z';
841 spec->fill[0] = *cp++;
842 spec->fill[1] = '\0';
851 spec->min_width = mpd_strtossize(cp, &cp, 10);
859 spec->dot = ".";
860 spec->sep = ",";
861 spec->grouping = "\003\003";
872 spec->prec = mpd_strtossize(cp, &cp, 10);
881 spec->type = *cp++;
887 if (*spec->sep) {
890 spec->type = *cp++;
891 spec->type = (spec->type == 'N') ? 'G' : 'g';
893 spec->dot = lc->decimal_point;
894 spec->sep = lc->thousands_sep;
895 spec->grouping = lc->grouping;
896 if (mpd_validate_lconv(spec) < 0) {
910 * The following functions assume that spec->min_width <= MPD_MAX_PREC, which
911 * is made sure in mpd_qformat_spec. Then, even with a spec that inserts a
973 * part according to spec->grouping. If leading zero padding is enabled
974 * and the result is smaller than spec->min_width, continue adding zeros
992 const mpd_spec_t *spec)
999 n_sep = (mpd_ssize_t)strlen(spec->sep);
1011 g = spec->grouping;
1030 if (spec->align == 'z' &&
1031 dest->nchars + n_sign < spec->min_width) {
1034 n_src = spec->min_width - (dest->nchars + n_sign);
1056 _mbstr_copy_char(dest, spec->sep, n_sep);
1093 _mpd_apply_lconv(mpd_mbstr_t *result, const mpd_spec_t *spec, uint32_t *status)
1116 dp++; dot = spec->dot;
1122 if (dot == NULL && (*spec->sep == '\0' || *spec->grouping == '\0')) {
1132 rest, n_rest, spec);
1143 rest, n_rest, spec);
1151 _mpd_add_pad(mpd_mbstr_t *result, const mpd_spec_t *spec, uint32_t *status)
1153 if (result->nchars < spec->min_width) {
1157 char align = spec->align;
1161 n_fill = strlen(spec->fill);
1162 add_chars = (spec->min_width - result->nchars);
1199 cp[i*n_fill+j] = spec->fill[j];
1205 cp[i*n_fill+j] = spec->fill[j];
1243 * Return the string representation of an mpd_t, formatted according to 'spec'.
1248 mpd_qformat_spec(const mpd_t *dec, const mpd_spec_t *spec,
1256 char type = spec->type;
1260 if (spec->min_width > MPD_MAX_PREC) {
1269 if (spec->sign == ' ') {
1272 else if (spec->sign == '+') {
1277 if (spec->align == 'z') {
1278 stackspec = *spec;
1282 spec = &stackspec;
1284 assert(strlen(spec->fill) == 1); /* annotation for scan-build */
1307 if (spec->prec >= 0) {
1308 if (spec->prec > MPD_MAX_PREC) {
1315 prec = (spec->prec == 0) ? 1 : spec->prec;
1324 dplace = 1-spec->prec;
1327 _mpd_round(&tmp, dec, spec->prec+1, ctx,
1333 mpd_qrescale(&tmp, dec, -spec->prec, ctx,
1372 if (*spec->dot != '\0' && !mpd_isspecial(dec)) {
1381 if (!_mpd_apply_lconv(&result, spec, status)) {
1386 if (spec->min_width) {
1387 if (!_mpd_add_pad(&result, spec, status)) {
1404 mpd_spec_t spec;
1406 if (!mpd_parse_fmt_str(&spec, fmt, 1)) {
1411 return mpd_qformat_spec(dec, &spec, ctx, status);