libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / m2 / mc-boot / GStrCase.cc
blob9492774596ba47c43d95072d7b25b6c9d4ae8024
1 /* do not edit automatically generated by mc from StrCase. */
2 /* StrCase.mod provides procedure to convert between text case.
4 Copyright (C) 2001-2024 Free Software Foundation, Inc.
5 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
7 This file is part of GNU Modula-2.
9 GNU Modula-2 is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3, or (at your option)
12 any later version.
14 GNU Modula-2 is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
19 Under Section 7 of GPL version 3, you are granted additional
20 permissions described in the GCC Runtime Library Exception, version
21 3.1, as published by the Free Software Foundation.
23 You should have received a copy of the GNU General Public License and
24 a copy of the GCC Runtime Library Exception along with this program;
25 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
26 <http://www.gnu.org/licenses/>. */
28 #include "config.h"
29 #include "system.h"
30 #include <stdbool.h>
31 # if !defined (PROC_D)
32 # define PROC_D
33 typedef void (*PROC_t) (void);
34 typedef struct { PROC_t proc; } PROC;
35 # endif
37 #define _StrCase_C
39 #include "GStrCase.h"
40 # include "GASCII.h"
41 # include "GStrLib.h"
45 StrToUpperCase - converts string, a, to uppercase returning the
46 result in, b.
49 extern "C" void StrCase_StrToUpperCase (const char *a_, unsigned int _a_high, char *b, unsigned int _b_high);
52 StrToLowerCase - converts string, a, to lowercase returning the
53 result in, b.
56 extern "C" void StrCase_StrToLowerCase (const char *a_, unsigned int _a_high, char *b, unsigned int _b_high);
59 Cap - converts a lower case character into a capital character.
60 If the character is not a lower case character 'a'..'z'
61 then the character is simply returned unaltered.
64 extern "C" char StrCase_Cap (char ch);
67 Lower - converts an upper case character into a lower case character.
68 If the character is not an upper case character 'A'..'Z'
69 then the character is simply returned unaltered.
72 extern "C" char StrCase_Lower (char ch);
76 StrToUpperCase - converts string, a, to uppercase returning the
77 result in, b.
80 extern "C" void StrCase_StrToUpperCase (const char *a_, unsigned int _a_high, char *b, unsigned int _b_high)
82 unsigned int higha;
83 unsigned int highb;
84 unsigned int i;
85 char a[_a_high+1];
87 /* make a local copy of each unbounded array. */
88 memcpy (a, a_, _a_high+1);
90 higha = StrLib_StrLen ((const char *) a, _a_high);
91 highb = _b_high;
92 i = 0;
93 while (((i < higha) && (a[i] != ASCII_nul)) && (i < highb))
95 const_cast<char *>(b)[i] = StrCase_Cap (a[i]);
96 i += 1;
98 if (i < highb)
100 const_cast<char *>(b)[i] = ASCII_nul;
106 StrToLowerCase - converts string, a, to lowercase returning the
107 result in, b.
110 extern "C" void StrCase_StrToLowerCase (const char *a_, unsigned int _a_high, char *b, unsigned int _b_high)
112 unsigned int higha;
113 unsigned int highb;
114 unsigned int i;
115 char a[_a_high+1];
117 /* make a local copy of each unbounded array. */
118 memcpy (a, a_, _a_high+1);
120 higha = StrLib_StrLen ((const char *) a, _a_high);
121 highb = _b_high;
122 i = 0;
123 while (((i < higha) && (a[i] != ASCII_nul)) && (i < highb))
125 const_cast<char *>(b)[i] = StrCase_Lower (a[i]);
126 i += 1;
128 if (i < highb)
130 const_cast<char *>(b)[i] = ASCII_nul;
136 Cap - converts a lower case character into a capital character.
137 If the character is not a lower case character 'a'..'z'
138 then the character is simply returned unaltered.
141 extern "C" char StrCase_Cap (char ch)
143 if ((ch >= 'a') && (ch <= 'z'))
145 ch = ((char) (( ((unsigned int) (ch))- ((unsigned int) ('a')))+ ((unsigned int) ('A'))));
147 return ch;
148 /* static analysis guarentees a RETURN statement will be used before here. */
149 __builtin_unreachable ();
154 Lower - converts an upper case character into a lower case character.
155 If the character is not an upper case character 'A'..'Z'
156 then the character is simply returned unaltered.
159 extern "C" char StrCase_Lower (char ch)
161 if ((ch >= 'A') && (ch <= 'Z'))
163 ch = ((char) (( ((unsigned int) (ch))- ((unsigned int) ('A')))+ ((unsigned int) ('a'))));
165 return ch;
166 /* static analysis guarentees a RETURN statement will be used before here. */
167 __builtin_unreachable ();
170 extern "C" void _M2_StrCase_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
174 extern "C" void _M2_StrCase_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])