14297a3b0SGarrett D'Amore /* 26b5e5868SGarrett D'Amore * This file and its contents are supplied under the terms of the 36b5e5868SGarrett D'Amore * Common Development and Distribution License ("CDDL"), version 1.0. 45aec55ebSGarrett D'Amore * You may only use this file in accordance with the terms of version 56b5e5868SGarrett D'Amore * 1.0 of the CDDL. 64297a3b0SGarrett D'Amore * 76b5e5868SGarrett D'Amore * A full copy of the text of the CDDL should have accompanied this 85aec55ebSGarrett D'Amore * source. A copy of the CDDL is also available via the Internet at 95aec55ebSGarrett D'Amore * http://www.illumos.org/license/CDDL. 104297a3b0SGarrett D'Amore */ 114297a3b0SGarrett D'Amore 124297a3b0SGarrett D'Amore /* 13*2d08521bSGarrett D'Amore * Copyright 2013 Garrett D'Amore <garrett@damore.org> 144297a3b0SGarrett D'Amore * Copyright 2010 Nexenta Systems, Inc. All rights reserved. 154297a3b0SGarrett D'Amore */ 164297a3b0SGarrett D'Amore #include "lint.h" 174297a3b0SGarrett D'Amore #include <ctype.h> 18*2d08521bSGarrett D'Amore #include <locale.h> 19*2d08521bSGarrett D'Amore #include "localeimpl.h" 20*2d08521bSGarrett D'Amore #include "lctype.h" 214297a3b0SGarrett D'Amore 224297a3b0SGarrett D'Amore #pragma weak _tolower = tolower 234297a3b0SGarrett D'Amore #pragma weak _toupper = toupper 244297a3b0SGarrett D'Amore 25*2d08521bSGarrett D'Amore int tolower_l(int c,locale_t loc)26*2d08521bSGarrett D'Amoretolower_l(int c, locale_t loc) 27*2d08521bSGarrett D'Amore { 28*2d08521bSGarrett D'Amore return (((unsigned)c > 255) ? c : loc->ctype->lc_trans_lower[c]); 29*2d08521bSGarrett D'Amore } 30*2d08521bSGarrett D'Amore 31*2d08521bSGarrett D'Amore int toupper_l(int c,locale_t loc)32*2d08521bSGarrett D'Amoretoupper_l(int c, locale_t loc) 33*2d08521bSGarrett D'Amore { 34*2d08521bSGarrett D'Amore return (((unsigned)c > 255) ? c : loc->ctype->lc_trans_upper[c]); 35*2d08521bSGarrett D'Amore } 36*2d08521bSGarrett D'Amore 37*2d08521bSGarrett D'Amore #undef tolower 384297a3b0SGarrett D'Amore int tolower(int c)394297a3b0SGarrett D'Amoretolower(int c) 404297a3b0SGarrett D'Amore { 41*2d08521bSGarrett D'Amore return (isascii(c) ? __trans_lower[c] : tolower_l(c, uselocale(NULL))); 424297a3b0SGarrett D'Amore } 434297a3b0SGarrett D'Amore 44*2d08521bSGarrett D'Amore #undef toupper 454297a3b0SGarrett D'Amore int toupper(int c)464297a3b0SGarrett D'Amoretoupper(int c) 474297a3b0SGarrett D'Amore { 48*2d08521bSGarrett D'Amore return (isascii(c) ? __trans_upper[c] : toupper_l(c, uselocale(NULL))); 494297a3b0SGarrett D'Amore } 50