View | Details | Raw Unified | Return to bug 164674 | Differences between
and this patch

Collapse All | Expand All

(-)lib/libc/stdio/vfwprintf.c (-14 / +24 lines)
Lines 449-468 Link Here
449
449
450
	/* BEWARE, these `goto error' on error. */
450
	/* BEWARE, these `goto error' on error. */
451
#define	PRINT(ptr, len)	do {			\
451
#define	PRINT(ptr, len)	do {			\
452
	if (io_print(&io, (ptr), (len), locale))	\
452
	if (io_print(&io, (ptr), (len), locale)) {	\
453
		goto error; \
453
		ret = EOF;	\
454
		goto error;	\
455
	}	\
454
} while (0)
456
} while (0)
455
#define	PAD(howmany, with) { \
457
#define	PAD(howmany, with) { \
456
	if (io_pad(&io, (howmany), (with), locale)) \
458
	if (io_pad(&io, (howmany), (with), locale)) {	\
457
		goto error; \
459
		ret = EOF;	\
460
		goto error;	\
461
	}	\
458
}
462
}
459
#define	PRINTANDPAD(p, ep, len, with) {	\
463
#define	PRINTANDPAD(p, ep, len, with) {	\
460
	if (io_printandpad(&io, (p), (ep), (len), (with), locale)) \
464
	if (io_printandpad(&io, (p), (ep), (len), (with), locale)) {	\
461
		goto error; \
465
		ret = EOF;	\
466
		goto error;	\
467
	}	\
462
}
468
}
463
#define	FLUSH() { \
469
#define	FLUSH() { \
464
	if (io_flush(&io, locale)) \
470
	if (io_flush(&io, locale)) {	\
465
		goto error; \
471
		ret = EOF;	\
472
		goto error;	\
473
	}	\
466
}
474
}
467
475
468
	/*
476
	/*
Lines 897-902 Link Here
897
					convbuf = __mbsconv(mbp, prec);
905
					convbuf = __mbsconv(mbp, prec);
898
					if (convbuf == NULL) {
906
					if (convbuf == NULL) {
899
						fp->_flags |= __SERR;
907
						fp->_flags |= __SERR;
908
						ret = EOF;
900
						goto error;
909
						goto error;
901
					}
910
					}
902
					cp = convbuf;
911
					cp = convbuf;
Lines 1030-1037 Link Here
1030
			/* leading zeroes from decimal precision */
1039
			/* leading zeroes from decimal precision */
1031
			PAD(dprec - size, zeroes);
1040
			PAD(dprec - size, zeroes);
1032
			if (gs.grouping) {
1041
			if (gs.grouping) {
1033
				if (grouping_print(&gs, &io, cp, buf+BUF, locale) < 0)
1042
				if (grouping_print(&gs, &io, cp, buf+BUF, locale) < 0) {
1043
					ret = EOF;
1034
					goto error;
1044
					goto error;
1045
				}
1035
			} else {
1046
			} else {
1036
				PRINT(cp, size);
1047
				PRINT(cp, size);
1037
			}
1048
			}
Lines 1047-1056 Link Here
1047
					prec += expt;
1058
					prec += expt;
1048
				} else {
1059
				} else {
1049
					if (gs.grouping) {
1060
					if (gs.grouping) {
1050
						n = grouping_print(&gs, &io,
1061
						if ((n = grouping_print(&gs, &io,
1051
						    cp, convbuf + ndig, locale);
1062
						    cp, convbuf + ndig, locale)) < 0) {
1052
						if (n < 0)
1063
							ret = EOF;
1053
							goto error;
1064
							goto error;
1065
						}
1054
						cp += n;
1066
						cp += n;
1055
					} else {
1067
					} else {
1056
						PRINTANDPAD(cp, convbuf + ndig,
1068
						PRINTANDPAD(cp, convbuf + ndig,
Lines 1089-1096 Link Here
1089
	va_end(orgap);
1101
	va_end(orgap);
1090
	if (convbuf != NULL)
1102
	if (convbuf != NULL)
1091
		free(convbuf);
1103
		free(convbuf);
1092
	if (__sferror(fp))
1093
		ret = EOF;
1094
	if ((argtable != NULL) && (argtable != statargtable))
1104
	if ((argtable != NULL) && (argtable != statargtable))
1095
		free (argtable);
1105
		free (argtable);
1096
	return (ret);
1106
	return (ret);
(-)lib/libc/stdio/vfprintf.c (-15 / +26 lines)
Lines 127-133 Link Here
127
	const CHAR *cp0 = cp;
127
	const CHAR *cp0 = cp;
128
128
129
	if (io_printandpad(iop, cp, ep, gs->lead, zeroes, locale))
129
	if (io_printandpad(iop, cp, ep, gs->lead, zeroes, locale))
130
		return (-1);
130
		return (EOF);
131
	cp += gs->lead;
131
	cp += gs->lead;
132
	while (gs->nseps > 0 || gs->nrepeats > 0) {
132
	while (gs->nseps > 0 || gs->nrepeats > 0) {
133
		if (gs->nrepeats > 0)
133
		if (gs->nrepeats > 0)
Lines 137-145 Link Here
137
			gs->nseps--;
137
			gs->nseps--;
138
		}
138
		}
139
		if (io_print(iop, gs->thousands_sep, gs->thousep_len, locale))
139
		if (io_print(iop, gs->thousands_sep, gs->thousep_len, locale))
140
			return (-1);
140
			return (EOF);
141
		if (io_printandpad(iop, cp, ep, *gs->grouping, zeroes, locale))
141
		if (io_printandpad(iop, cp, ep, *gs->grouping, zeroes, locale))
142
			return (-1);
142
			return (EOF);
143
		cp += *gs->grouping;
143
		cp += *gs->grouping;
144
	}
144
	}
145
	if (cp > ep)
145
	if (cp > ep)
Lines 369-388 Link Here
369
369
370
	/* BEWARE, these `goto error' on error. */
370
	/* BEWARE, these `goto error' on error. */
371
#define	PRINT(ptr, len) { \
371
#define	PRINT(ptr, len) { \
372
	if (io_print(&io, (ptr), (len), locale))	\
372
	if (io_print(&io, (ptr), (len), locale)) {	\
373
		goto error; \
373
		ret = EOF;	\
374
		goto error;	\
375
	}	\
374
}
376
}
375
#define	PAD(howmany, with) { \
377
#define	PAD(howmany, with) { \
376
	if (io_pad(&io, (howmany), (with), locale)) \
378
	if (io_pad(&io, (howmany), (with), locale)) {	\
379
		ret = EOF;	\
377
		goto error; \
380
		goto error; \
381
	}	\
378
}
382
}
379
#define	PRINTANDPAD(p, ep, len, with) {	\
383
#define	PRINTANDPAD(p, ep, len, with) {	\
380
	if (io_printandpad(&io, (p), (ep), (len), (with), locale)) \
384
	if (io_printandpad(&io, (p), (ep), (len), (with), locale)) {	\
381
		goto error; \
385
		ret = EOF;	\
386
		goto error;	\
387
	}	\
382
}
388
}
383
#define	FLUSH() { \
389
#define	FLUSH() { \
384
	if (io_flush(&io, locale)) \
390
	if (io_flush(&io, locale)) {	\
391
		ret = EOF;	\
385
		goto error; \
392
		goto error; \
393
	}	\
386
}
394
}
387
395
388
	/*
396
	/*
Lines 617-622 Link Here
617
				    (wchar_t)GETARG(wint_t), &mbs);
625
				    (wchar_t)GETARG(wint_t), &mbs);
618
				if (mbseqlen == (size_t)-1) {
626
				if (mbseqlen == (size_t)-1) {
619
					fp->_flags |= __SERR;
627
					fp->_flags |= __SERR;
628
					ret = EOF;
620
					goto error;
629
					goto error;
621
				}
630
				}
622
				size = (int)mbseqlen;
631
				size = (int)mbseqlen;
Lines 828-833 Link Here
828
					convbuf = __wcsconv(wcp, prec);
837
					convbuf = __wcsconv(wcp, prec);
829
					if (convbuf == NULL) {
838
					if (convbuf == NULL) {
830
						fp->_flags |= __SERR;
839
						fp->_flags |= __SERR;
840
						ret = EOF;
831
						goto error;
841
						goto error;
832
					}
842
					}
833
					cp = convbuf;
843
					cp = convbuf;
Lines 962-969 Link Here
962
			/* leading zeroes from decimal precision */
972
			/* leading zeroes from decimal precision */
963
			PAD(dprec - size, zeroes);
973
			PAD(dprec - size, zeroes);
964
			if (gs.grouping) {
974
			if (gs.grouping) {
965
				if (grouping_print(&gs, &io, cp, buf+BUF, locale) < 0)
975
				if (grouping_print(&gs, &io, cp, buf+BUF, locale) < 0) {
976
					ret = EOF;
966
					goto error;
977
					goto error;
978
				}
967
			} else {
979
			} else {
968
				PRINT(cp, size);
980
				PRINT(cp, size);
969
			}
981
			}
Lines 979-988 Link Here
979
					prec += expt;
991
					prec += expt;
980
				} else {
992
				} else {
981
					if (gs.grouping) {
993
					if (gs.grouping) {
982
						n = grouping_print(&gs, &io,
994
						if ((n = grouping_print(&gs, &io,
983
						    cp, dtoaend, locale);
995
						    cp, dtoaend, locale)) < 0) {
984
						if (n < 0)
996
							ret = EOF;
985
							goto error;
997
							goto error;
998
						}
986
						cp += n;
999
						cp += n;
987
					} else {
1000
					} else {
988
						PRINTANDPAD(cp, dtoaend,
1001
						PRINTANDPAD(cp, dtoaend,
Lines 1024-1031 Link Here
1024
#endif
1037
#endif
1025
	if (convbuf != NULL)
1038
	if (convbuf != NULL)
1026
		free(convbuf);
1039
		free(convbuf);
1027
	if (__sferror(fp))
1028
		ret = EOF;
1029
	if ((argtable != NULL) && (argtable != statargtable))
1040
	if ((argtable != NULL) && (argtable != statargtable))
1030
		free (argtable);
1041
		free (argtable);
1031
	return (ret);
1042
	return (ret);

Return to bug 164674