printf.c (219153) | printf.c (222418) |
---|---|
1/*- 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. 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 --- 30 unchanged lines hidden (view full) --- 39#endif /* not lint */ 40#endif 41 42#ifndef lint 43#if 0 44static char const sccsid[] = "@(#)printf.c 8.1 (Berkeley) 7/20/93"; 45#endif 46static const char rcsid[] = | 1/*- 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. 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 --- 30 unchanged lines hidden (view full) --- 39#endif /* not lint */ 40#endif 41 42#ifndef lint 43#if 0 44static char const sccsid[] = "@(#)printf.c 8.1 (Berkeley) 7/20/93"; 45#endif 46static const char rcsid[] = |
47 "$FreeBSD: head/usr.bin/printf/printf.c 219153 2011-03-01 21:47:06Z jilles $"; | 47 "$FreeBSD: head/usr.bin/printf/printf.c 222418 2011-05-28 11:37:47Z jilles $"; |
48#endif /* not lint */ 49 50#include <sys/types.h> 51 52#include <err.h> 53#include <errno.h> 54#include <inttypes.h> 55#include <limits.h> 56#include <locale.h> 57#include <stdio.h> 58#include <stdlib.h> 59#include <string.h> 60#include <unistd.h> | 48#endif /* not lint */ 49 50#include <sys/types.h> 51 52#include <err.h> 53#include <errno.h> 54#include <inttypes.h> 55#include <limits.h> 56#include <locale.h> 57#include <stdio.h> 58#include <stdlib.h> 59#include <string.h> 60#include <unistd.h> |
61#include <wchar.h> |
|
61 62#ifdef SHELL 63#define main printfcmd 64#include "bltin/bltin.h" 65#include "error.h" 66#endif 67 68#define PF(f, func) do { \ --- 463 unchanged lines hidden (view full) --- 532 ++gargv; 533 return (rval); 534} 535 536static int 537asciicode(void) 538{ 539 int ch; | 62 63#ifdef SHELL 64#define main printfcmd 65#include "bltin/bltin.h" 66#include "error.h" 67#endif 68 69#define PF(f, func) do { \ --- 463 unchanged lines hidden (view full) --- 533 ++gargv; 534 return (rval); 535} 536 537static int 538asciicode(void) 539{ 540 int ch; |
541 wchar_t wch; 542 mbstate_t mbs; |
|
540 | 543 |
541 ch = **gargv; 542 if (ch == '\'' || ch == '"') 543 ch = (*gargv)[1]; | 544 ch = (unsigned char)**gargv; 545 if (ch == '\'' || ch == '"') { 546 memset(&mbs, 0, sizeof(mbs)); 547 switch (mbrtowc(&wch, *gargv + 1, MB_LEN_MAX, &mbs)) { 548 case (size_t)-2: 549 case (size_t)-1: 550 wch = (unsigned char)gargv[0][1]; 551 break; 552 case 0: 553 wch = 0; 554 break; 555 } 556 ch = wch; 557 } |
544 ++gargv; 545 return (ch); 546} 547 548static void 549usage(void) 550{ 551 (void)fprintf(stderr, "usage: printf format [arguments ...]\n"); 552} | 558 ++gargv; 559 return (ch); 560} 561 562static void 563usage(void) 564{ 565 (void)fprintf(stderr, "usage: printf format [arguments ...]\n"); 566} |