]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/m2/pge-boot/GStrCase.c
Update copyright years.
[thirdparty/gcc.git] / gcc / m2 / pge-boot / GStrCase.c
CommitLineData
1eee94d3
GM
1/* do not edit automatically generated by mc from StrCase. */
2/* StrCase.mod provides procedure to convert between text case.
3
83ffe9cd 4Copyright (C) 2001-2023 Free Software Foundation, Inc.
1eee94d3
GM
5Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6
7This file is part of GNU Modula-2.
8
9GNU Modula-2 is free software; you can redistribute it and/or modify
10it under the terms of the GNU General Public License as published by
11the Free Software Foundation; either version 3, or (at your option)
12any later version.
13
14GNU Modula-2 is distributed in the hope that it will be useful, but
15WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17General Public License for more details.
18
19Under Section 7 of GPL version 3, you are granted additional
20permissions described in the GCC Runtime Library Exception, version
213.1, as published by the Free Software Foundation.
22
23You should have received a copy of the GNU General Public License and
24a copy of the GCC Runtime Library Exception along with this program;
25see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
26<http://www.gnu.org/licenses/>. */
27
28# if !defined (PROC_D)
29# define PROC_D
30 typedef void (*PROC_t) (void);
31 typedef struct { PROC_t proc; } PROC;
32# endif
33
34#include <string.h>
35#include <limits.h>
36#define _StrCase_H
37#define _StrCase_C
38
39# include "GASCII.h"
40# include "GStrLib.h"
41
42
43/*
44 StrToUpperCase - converts string, a, to uppercase returning the
45 result in, b.
46*/
47
48extern "C" void StrCase_StrToUpperCase (const char *a_, unsigned int _a_high, char *b, unsigned int _b_high);
49
50/*
51 StrToLowerCase - converts string, a, to lowercase returning the
52 result in, b.
53*/
54
55extern "C" void StrCase_StrToLowerCase (const char *a_, unsigned int _a_high, char *b, unsigned int _b_high);
56
57/*
58 Cap - converts a lower case character into a capital character.
59 If the character is not a lower case character 'a'..'z'
60 then the character is simply returned unaltered.
61*/
62
63extern "C" char StrCase_Cap (char ch);
64
65/*
66 Lower - converts an upper case character into a lower case character.
67 If the character is not an upper case character 'A'..'Z'
68 then the character is simply returned unaltered.
69*/
70
71extern "C" char StrCase_Lower (char ch);
72
73
74/*
75 StrToUpperCase - converts string, a, to uppercase returning the
76 result in, b.
77*/
78
79extern "C" void StrCase_StrToUpperCase (const char *a_, unsigned int _a_high, char *b, unsigned int _b_high)
80{
81 unsigned int higha;
82 unsigned int highb;
83 unsigned int i;
84 char a[_a_high+1];
85
86 /* make a local copy of each unbounded array. */
87 memcpy (a, a_, _a_high+1);
88
89 higha = StrLib_StrLen ((const char *) a, _a_high);
90 highb = _b_high;
91 i = 0;
92 while (((i < higha) && (a[i] != ASCII_nul)) && (i < highb))
93 {
94 b[i] = StrCase_Cap (a[i]);
95 i += 1;
96 }
97 if (i < highb)
98 {
99 b[i] = ASCII_nul;
100 }
101}
102
103
104/*
105 StrToLowerCase - converts string, a, to lowercase returning the
106 result in, b.
107*/
108
109extern "C" void StrCase_StrToLowerCase (const char *a_, unsigned int _a_high, char *b, unsigned int _b_high)
110{
111 unsigned int higha;
112 unsigned int highb;
113 unsigned int i;
114 char a[_a_high+1];
115
116 /* make a local copy of each unbounded array. */
117 memcpy (a, a_, _a_high+1);
118
119 higha = StrLib_StrLen ((const char *) a, _a_high);
120 highb = _b_high;
121 i = 0;
122 while (((i < higha) && (a[i] != ASCII_nul)) && (i < highb))
123 {
124 b[i] = StrCase_Lower (a[i]);
125 i += 1;
126 }
127 if (i < highb)
128 {
129 b[i] = ASCII_nul;
130 }
131}
132
133
134/*
135 Cap - converts a lower case character into a capital character.
136 If the character is not a lower case character 'a'..'z'
137 then the character is simply returned unaltered.
138*/
139
140extern "C" char StrCase_Cap (char ch)
141{
142 if ((ch >= 'a') && (ch <= 'z'))
143 {
144 ch = ((char) (( ((unsigned int) (ch))- ((unsigned int) ('a')))+ ((unsigned int) ('A'))));
145 }
146 return ch;
147 /* static analysis guarentees a RETURN statement will be used before here. */
148 __builtin_unreachable ();
149}
150
151
152/*
153 Lower - converts an upper case character into a lower case character.
154 If the character is not an upper case character 'A'..'Z'
155 then the character is simply returned unaltered.
156*/
157
158extern "C" char StrCase_Lower (char ch)
159{
160 if ((ch >= 'A') && (ch <= 'Z'))
161 {
162 ch = ((char) (( ((unsigned int) (ch))- ((unsigned int) ('A')))+ ((unsigned int) ('a'))));
163 }
164 return ch;
165 /* static analysis guarentees a RETURN statement will be used before here. */
166 __builtin_unreachable ();
167}
168
169extern "C" void _M2_StrCase_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
170{
171}
172
173extern "C" void _M2_StrCase_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
174{
175}