"Fossies" - the Fresh Open Source Software Archive

Member "schily-2021-09-18/sunpro/Make/lib/mksh/src/i18n.cc" (15 Aug 2021, 2594 Bytes) of package /linux/privat/schily-2021-09-18.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "i18n.cc" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes reports: 2021-08-14_vs_2021-09-18 or 2021-07-29_vs_2021-09-18.

    1 /*
    2  * CDDL HEADER START
    3  *
    4  * This file and its contents are supplied under the terms of the
    5  * Common Development and Distribution License ("CDDL"), version 1.0.
    6  * You may use this file only in accordance with the terms of version
    7  * 1.0 of the CDDL.
    8  *
    9  * A full copy of the text of the CDDL should have accompanied this
   10  * source.  A copy of the CDDL is also available via the Internet at
   11  * http://www.opensource.org/licenses/cddl1.txt
   12  * See the License for the specific language governing permissions
   13  * and limitations under the License.
   14  *
   15  * When distributing Covered Code, include this CDDL HEADER in each
   16  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
   17  * If applicable, add the following below this CDDL HEADER, with the
   18  * fields enclosed by brackets "[]" replaced with your own identifying
   19  * information: Portions Copyright [yyyy] [name of copyright owner]
   20  *
   21  * CDDL HEADER END
   22  */
   23 /*
   24  * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
   25  * Use is subject to license terms.
   26  */
   27 /*
   28  * @(#)i18n.cc 1.3 06/12/12
   29  */
   30 
   31 #pragma ident   "@(#)i18n.cc    1.3 06/12/12"
   32 
   33 /*
   34  * Copyright 2017 J. Schilling
   35  *
   36  * @(#)i18n.cc  1.4 21/08/16 2017 J. Schilling
   37  */
   38 #include <schily/mconfig.h>
   39 #ifndef lint
   40 static  UConst char sccsid[] =
   41     "@(#)i18n.cc    1.4 21/08/16 2017 J. Schilling";
   42 #endif
   43 
   44 /*
   45  *      i18n.cc
   46  *
   47  *      Deal with internationalization conversions
   48  */
   49 
   50 /*
   51  * Included files
   52  */
   53 #include <mksh/defs.h>
   54 #include <mksh/i18n.h>
   55 #include <mksh/misc.h>      /* setup_char_semantics() */
   56 
   57 /*
   58  *  get_char_semantics_value(ch)
   59  *
   60  *  Return value:
   61  *      The character semantics of ch.
   62  *
   63  *  Parameters:
   64  *      ch      character we want semantics for.
   65  *
   66  */
   67 char
   68 get_char_semantics_value(wchar_t ch)
   69 {
   70     static Boolean  char_semantics_setup;
   71 
   72     if (!char_semantics_setup) {
   73         setup_char_semantics();
   74         char_semantics_setup = true;
   75     }
   76     return char_semantics[get_char_semantics_entry(ch)];
   77 }
   78 
   79 /*
   80  *  get_char_semantics_entry(ch)
   81  *
   82  *  Return value:
   83  *      The slot number in the array for special make chars,
   84  *      else the slot number of the last array entry.
   85  *
   86  *  Parameters:
   87  *      ch      The wide character
   88  *
   89  *  Global variables used:
   90  *      char_semantics_char[]   array of special wchar_t chars
   91  *                  "&*@`\\|[]:$=!>-\n#()%?;^<'\""
   92  */
   93 int
   94 get_char_semantics_entry(wchar_t ch)
   95 {
   96     wchar_t     *char_sem_char;
   97 
   98     char_sem_char = (wchar_t *) wcschr(char_semantics_char, ch);
   99     if (char_sem_char == NULL) {
  100         /*
  101          * Return the integer entry for the last slot,
  102          * whose content is empty.
  103          */
  104         return (CHAR_SEMANTICS_ENTRIES - 1);
  105     } else {
  106         return (char_sem_char - char_semantics_char);
  107     }
  108 }
  109