strfmon.c (104946) | strfmon.c (104963) |
---|---|
1/*- 2 * Copyright (c) 2001 Alexey Zelkin <phantom@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 12 unchanged lines hidden (view full) --- 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 */ 27 28#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2001 Alexey Zelkin <phantom@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 12 unchanged lines hidden (view full) --- 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 */ 27 28#include <sys/cdefs.h> |
29__FBSDID("$FreeBSD: head/lib/libc/stdlib/strfmon.c 104946 2002-10-11 23:31:50Z tjr $"); | 29__FBSDID("$FreeBSD: head/lib/libc/stdlib/strfmon.c 104963 2002-10-12 04:38:35Z tjr $"); |
30 31#include <sys/types.h> 32#include <ctype.h> 33#include <errno.h> 34#include <limits.h> 35#include <locale.h> 36#include <stdarg.h> 37#include <stdio.h> --- 286 unchanged lines hidden (view full) --- 324 if (sep_by_space == 1) 325 PRINT(' '); 326 PRINTS(signstr); 327 } 328 329 if (!(flags & SUPRESS_CURR_SYMBOL)) { 330 if ((sign_posn == 3 && sep_by_space == 2) 331 || (sep_by_space == 1 | 30 31#include <sys/types.h> 32#include <ctype.h> 33#include <errno.h> 34#include <limits.h> 35#include <locale.h> 36#include <stdarg.h> 37#include <stdio.h> --- 286 unchanged lines hidden (view full) --- 324 if (sep_by_space == 1) 325 PRINT(' '); 326 PRINTS(signstr); 327 } 328 329 if (!(flags & SUPRESS_CURR_SYMBOL)) { 330 if ((sign_posn == 3 && sep_by_space == 2) 331 || (sep_by_space == 1 |
332 && (sign_posn = 0 | 332 && (sign_posn == 0 |
333 || sign_posn == 1 334 || sign_posn == 2 335 || sign_posn == 4))) 336 PRINT(space_char); 337 PRINTS(currency_symbol); /* XXX: len */ 338 if (sign_posn == 4) { 339 if (sep_by_space == 2) 340 PRINT(' '); --- 8 unchanged lines hidden (view full) --- 349 PRINTS(signstr); 350 } 351 352 if (sign_posn == 0 && (flags & IS_NEGATIVE)) 353 PRINT(')'); 354 355 if (dst - tmpptr < width) { 356 if (flags & LEFT_JUSTIFY) { | 333 || sign_posn == 1 334 || sign_posn == 2 335 || sign_posn == 4))) 336 PRINT(space_char); 337 PRINTS(currency_symbol); /* XXX: len */ 338 if (sign_posn == 4) { 339 if (sep_by_space == 2) 340 PRINT(' '); --- 8 unchanged lines hidden (view full) --- 349 PRINTS(signstr); 350 } 351 352 if (sign_posn == 0 && (flags & IS_NEGATIVE)) 353 PRINT(')'); 354 355 if (dst - tmpptr < width) { 356 if (flags & LEFT_JUSTIFY) { |
357 while (dst - tmpptr <= width) | 357 while (dst - tmpptr < width) |
358 PRINT(' '); 359 } else { 360 pad_size = dst-tmpptr; 361 memmove(tmpptr + width-pad_size, tmpptr, 362 pad_size); 363 memset(tmpptr, ' ', width-pad_size); 364 dst += width-pad_size; 365 } 366 } 367 } 368 369 PRINT('\0'); 370 va_end(ap); | 358 PRINT(' '); 359 } else { 360 pad_size = dst-tmpptr; 361 memmove(tmpptr + width-pad_size, tmpptr, 362 pad_size); 363 memset(tmpptr, ' ', width-pad_size); 364 dst += width-pad_size; 365 } 366 } 367 } 368 369 PRINT('\0'); 370 va_end(ap); |
371 free(asciivalue); 372 free(currency_symbol); |
|
371 return (dst - s - 1); /* return size of put data except trailing '\0' */ 372 373e2big_error: 374 errno = E2BIG; 375 goto end_error; 376 377format_error: 378 errno = EINVAL; --- 214 unchanged lines hidden (view full) --- 593 } 594 595 /* do padding with pad_char */ 596 if (padded > 0) { 597 bufend -= padded; 598 memset(bufend, pad_char, padded); 599 } 600 | 373 return (dst - s - 1); /* return size of put data except trailing '\0' */ 374 375e2big_error: 376 errno = E2BIG; 377 goto end_error; 378 379format_error: 380 errno = EINVAL; --- 214 unchanged lines hidden (view full) --- 595 } 596 597 /* do padding with pad_char */ 598 if (padded > 0) { 599 bufend -= padded; 600 memset(bufend, pad_char, padded); 601 } 602 |
601 bufsize = bufsize - (rslt - bufend); | 603 bufsize = bufsize - (bufend - rslt) + 1; |
602 memmove(rslt, bufend, bufsize); 603 free(avalue); 604 return (rslt); 605} | 604 memmove(rslt, bufend, bufsize); 605 free(avalue); 606 return (rslt); 607} |