ungetwc.c (87275e436a0fb31fea2757532860a3ec993d2cd6) | ungetwc.c (f9ceea9bf17bc8d7b0020c409743f162c3c5eebd) |
---|---|
1/*- 2 * Copyright (c) 2002-2004 Tim J. Robbins. 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 --- 21 unchanged lines hidden (view full) --- 30#include "namespace.h" 31#include <errno.h> 32#include <stdio.h> 33#include <stdlib.h> 34#include <wchar.h> 35#include "un-namespace.h" 36#include "libc_private.h" 37#include "local.h" | 1/*- 2 * Copyright (c) 2002-2004 Tim J. Robbins. 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 --- 21 unchanged lines hidden (view full) --- 30#include "namespace.h" 31#include <errno.h> 32#include <stdio.h> 33#include <stdlib.h> 34#include <wchar.h> 35#include "un-namespace.h" 36#include "libc_private.h" 37#include "local.h" |
38#include "mblocal.h" |
|
38 39/* 40 * Non-MT-safe version. 41 */ 42wint_t 43__ungetwc(wint_t wc, FILE *fp) 44{ 45 char buf[MB_LEN_MAX]; 46 size_t len; 47 48 if (wc == WEOF) 49 return (WEOF); | 39 40/* 41 * Non-MT-safe version. 42 */ 43wint_t 44__ungetwc(wint_t wc, FILE *fp) 45{ 46 char buf[MB_LEN_MAX]; 47 size_t len; 48 49 if (wc == WEOF) 50 return (WEOF); |
50 if ((len = wcrtomb(buf, wc, &fp->_extra->mbstate)) == (size_t)-1) { | 51 if ((len = __wcrtomb(buf, wc, &fp->_extra->mbstate)) == (size_t)-1) { |
51 fp->_flags |= __SERR; 52 return (WEOF); 53 } 54 while (len-- != 0) 55 if (__ungetc((unsigned char)buf[len], fp) == EOF) 56 return (WEOF); 57 58 return (wc); --- 17 unchanged lines hidden --- | 52 fp->_flags |= __SERR; 53 return (WEOF); 54 } 55 while (len-- != 0) 56 if (__ungetc((unsigned char)buf[len], fp) == EOF) 57 return (WEOF); 58 59 return (wc); --- 17 unchanged lines hidden --- |