1*10d63b7dSRichard Lowe /* 2*10d63b7dSRichard Lowe * CDDL HEADER START 3*10d63b7dSRichard Lowe * 4*10d63b7dSRichard Lowe * The contents of this file are subject to the terms of the 5*10d63b7dSRichard Lowe * Common Development and Distribution License (the "License"). 6*10d63b7dSRichard Lowe * You may not use this file except in compliance with the License. 7*10d63b7dSRichard Lowe * 8*10d63b7dSRichard Lowe * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*10d63b7dSRichard Lowe * or http://www.opensolaris.org/os/licensing. 10*10d63b7dSRichard Lowe * See the License for the specific language governing permissions 11*10d63b7dSRichard Lowe * and limitations under the License. 12*10d63b7dSRichard Lowe * 13*10d63b7dSRichard Lowe * When distributing Covered Code, include this CDDL HEADER in each 14*10d63b7dSRichard Lowe * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*10d63b7dSRichard Lowe * If applicable, add the following below this CDDL HEADER, with the 16*10d63b7dSRichard Lowe * fields enclosed by brackets "[]" replaced with your own identifying 17*10d63b7dSRichard Lowe * information: Portions Copyright [yyyy] [name of copyright owner] 18*10d63b7dSRichard Lowe * 19*10d63b7dSRichard Lowe * CDDL HEADER END 20*10d63b7dSRichard Lowe */ 21*10d63b7dSRichard Lowe /* 22*10d63b7dSRichard Lowe * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 23*10d63b7dSRichard Lowe * Use is subject to license terms. 24*10d63b7dSRichard Lowe */ 25*10d63b7dSRichard Lowe 26*10d63b7dSRichard Lowe 27*10d63b7dSRichard Lowe /* 28*10d63b7dSRichard Lowe * i18n.cc 29*10d63b7dSRichard Lowe * 30*10d63b7dSRichard Lowe * Deal with internationalization conversions 31*10d63b7dSRichard Lowe */ 32*10d63b7dSRichard Lowe 33*10d63b7dSRichard Lowe /* 34*10d63b7dSRichard Lowe * Included files 35*10d63b7dSRichard Lowe */ 36*10d63b7dSRichard Lowe #include <mksh/i18n.h> 37*10d63b7dSRichard Lowe #include <mksh/misc.h> /* setup_char_semantics() */ 38*10d63b7dSRichard Lowe 39*10d63b7dSRichard Lowe /* 40*10d63b7dSRichard Lowe * get_char_semantics_value(ch) 41*10d63b7dSRichard Lowe * 42*10d63b7dSRichard Lowe * Return value: 43*10d63b7dSRichard Lowe * The character semantics of ch. 44*10d63b7dSRichard Lowe * 45*10d63b7dSRichard Lowe * Parameters: 46*10d63b7dSRichard Lowe * ch character we want semantics for. 47*10d63b7dSRichard Lowe * 48*10d63b7dSRichard Lowe */ 49*10d63b7dSRichard Lowe char get_char_semantics_value(wchar_t ch)50*10d63b7dSRichard Loweget_char_semantics_value(wchar_t ch) 51*10d63b7dSRichard Lowe { 52*10d63b7dSRichard Lowe static Boolean char_semantics_setup; 53*10d63b7dSRichard Lowe 54*10d63b7dSRichard Lowe if (!char_semantics_setup) { 55*10d63b7dSRichard Lowe setup_char_semantics(); 56*10d63b7dSRichard Lowe char_semantics_setup = true; 57*10d63b7dSRichard Lowe } 58*10d63b7dSRichard Lowe return char_semantics[get_char_semantics_entry(ch)]; 59*10d63b7dSRichard Lowe } 60*10d63b7dSRichard Lowe 61*10d63b7dSRichard Lowe /* 62*10d63b7dSRichard Lowe * get_char_semantics_entry(ch) 63*10d63b7dSRichard Lowe * 64*10d63b7dSRichard Lowe * Return value: 65*10d63b7dSRichard Lowe * The slot number in the array for special make chars, 66*10d63b7dSRichard Lowe * else the slot number of the last array entry. 67*10d63b7dSRichard Lowe * 68*10d63b7dSRichard Lowe * Parameters: 69*10d63b7dSRichard Lowe * ch The wide character 70*10d63b7dSRichard Lowe * 71*10d63b7dSRichard Lowe * Global variables used: 72*10d63b7dSRichard Lowe * char_semantics_char[] array of special wchar_t chars 73*10d63b7dSRichard Lowe * "&*@`\\|[]:$=!>-\n#()%?;^<'\"" 74*10d63b7dSRichard Lowe */ 75*10d63b7dSRichard Lowe int get_char_semantics_entry(wchar_t ch)76*10d63b7dSRichard Loweget_char_semantics_entry(wchar_t ch) 77*10d63b7dSRichard Lowe { 78*10d63b7dSRichard Lowe wchar_t *char_sem_char; 79*10d63b7dSRichard Lowe 80*10d63b7dSRichard Lowe char_sem_char = (wchar_t *) wcschr(char_semantics_char, ch); 81*10d63b7dSRichard Lowe if (char_sem_char == NULL) { 82*10d63b7dSRichard Lowe /* 83*10d63b7dSRichard Lowe * Return the integer entry for the last slot, 84*10d63b7dSRichard Lowe * whose content is empty. 85*10d63b7dSRichard Lowe */ 86*10d63b7dSRichard Lowe return (CHAR_SEMANTICS_ENTRIES - 1); 87*10d63b7dSRichard Lowe } else { 88*10d63b7dSRichard Lowe return (char_sem_char - char_semantics_char); 89*10d63b7dSRichard Lowe } 90*10d63b7dSRichard Lowe } 91*10d63b7dSRichard Lowe 92