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)
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/>. */
31 # if !defined (PROC_D)
33 typedef void (*PROC_t
) (void);
34 typedef struct { PROC_t proc
; } PROC
;
45 StrToUpperCase - converts string, a, to uppercase returning the
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
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
80 extern "C" void StrCase_StrToUpperCase (const char *a_
, unsigned int _a_high
, char *b
, unsigned int _b_high
)
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
);
93 while (((i
< higha
) && (a
[i
] != ASCII_nul
)) && (i
< highb
))
95 const_cast<char *>(b
)[i
] = StrCase_Cap (a
[i
]);
100 const_cast<char *>(b
)[i
] = ASCII_nul
;
106 StrToLowerCase - converts string, a, to lowercase returning the
110 extern "C" void StrCase_StrToLowerCase (const char *a_
, unsigned int _a_high
, char *b
, unsigned int _b_high
)
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
);
123 while (((i
< higha
) && (a
[i
] != ASCII_nul
)) && (i
< highb
))
125 const_cast<char *>(b
)[i
] = StrCase_Lower (a
[i
]);
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'))));
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'))));
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
[])