]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/m2/mc-boot/GmcFileName.c
Merge modula-2 front end onto gcc.
[thirdparty/gcc.git] / gcc / m2 / mc-boot / GmcFileName.c
1 /* do not edit automatically generated by mc from mcFileName. */
2 /* This file is part of GNU Modula-2.
3
4 GNU Modula-2 is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 3, or (at your option) any later
7 version.
8
9 GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License along
15 with gm2; see the file COPYING. If not, write to the Free Software
16 Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
17
18 #include "config.h"
19 #include "system.h"
20 # if !defined (PROC_D)
21 # define PROC_D
22 typedef void (*PROC_t) (void);
23 typedef struct { PROC_t proc; } PROC;
24 # endif
25
26 #define _mcFileName_H
27 #define _mcFileName_C
28
29 # include "GASCII.h"
30 # include "GDynamicStrings.h"
31
32 # define MaxFileName 0
33 # define MaxStemName 0
34 # define Directory '/'
35
36 /*
37 calculateFileName - calculates and returns a new string filename given a module
38 and an extension. String, Extension, is concatenated onto
39 Module and thus it is safe to `Mark' the extension for garbage
40 collection.
41 */
42
43 extern "C" DynamicStrings_String mcFileName_calculateFileName (DynamicStrings_String module, DynamicStrings_String extension);
44
45 /*
46 calculateStemName - calculates the stem name for given a module.
47 This name length will be operating system and
48 compiler specific.
49 */
50
51 extern "C" DynamicStrings_String mcFileName_calculateStemName (DynamicStrings_String module);
52
53 /*
54 extractExtension - given a, filename, return the filename without
55 the extension, Ext.
56 */
57
58 extern "C" DynamicStrings_String mcFileName_extractExtension (DynamicStrings_String filename, DynamicStrings_String ext);
59
60 /*
61 extractModule - given a, filename, return the module name including any
62 extension. A new string is returned.
63 */
64
65 extern "C" DynamicStrings_String mcFileName_extractModule (DynamicStrings_String filename);
66
67
68 /*
69 calculateFileName - calculates and returns a new string filename given a module
70 and an extension. String, Extension, is concatenated onto
71 Module and thus it is safe to `Mark' the extension for garbage
72 collection.
73 */
74
75 extern "C" DynamicStrings_String mcFileName_calculateFileName (DynamicStrings_String module, DynamicStrings_String extension)
76 {
77 if (MaxFileName == 0)
78 {
79 return DynamicStrings_ConCat (DynamicStrings_ConCatChar (DynamicStrings_Slice (module, 0, MaxFileName), '.'), extension);
80 }
81 else
82 {
83 return DynamicStrings_ConCat (DynamicStrings_ConCatChar (DynamicStrings_Slice (module, 0, (MaxFileName-(DynamicStrings_Length (extension)))-1), '.'), extension);
84 }
85 /* static analysis guarentees a RETURN statement will be used before here. */
86 __builtin_unreachable ();
87 }
88
89
90 /*
91 calculateStemName - calculates the stem name for given a module.
92 This name length will be operating system and
93 compiler specific.
94 */
95
96 extern "C" DynamicStrings_String mcFileName_calculateStemName (DynamicStrings_String module)
97 {
98 return DynamicStrings_Slice (module, 0, MaxStemName);
99 /* static analysis guarentees a RETURN statement will be used before here. */
100 __builtin_unreachable ();
101 }
102
103
104 /*
105 extractExtension - given a, filename, return the filename without
106 the extension, Ext.
107 */
108
109 extern "C" DynamicStrings_String mcFileName_extractExtension (DynamicStrings_String filename, DynamicStrings_String ext)
110 {
111 if (DynamicStrings_Equal (ext, DynamicStrings_Mark (DynamicStrings_Slice (filename, static_cast<int> (-(DynamicStrings_Length (ext))), 0))))
112 {
113 return DynamicStrings_Slice (filename, 0, static_cast<int> (-(DynamicStrings_Length (ext))));
114 }
115 else
116 {
117 return filename;
118 }
119 /* static analysis guarentees a RETURN statement will be used before here. */
120 __builtin_unreachable ();
121 }
122
123
124 /*
125 extractModule - given a, filename, return the module name including any
126 extension. A new string is returned.
127 */
128
129 extern "C" DynamicStrings_String mcFileName_extractModule (DynamicStrings_String filename)
130 {
131 int i;
132
133 i = DynamicStrings_Index (filename, Directory, 0);
134 if (i == -1)
135 {
136 return DynamicStrings_Dup (filename);
137 }
138 else
139 {
140 return DynamicStrings_Slice (filename, i+1, 0);
141 }
142 /* static analysis guarentees a RETURN statement will be used before here. */
143 __builtin_unreachable ();
144 }
145
146 extern "C" void _M2_mcFileName_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
147 {
148 }
149
150 extern "C" void _M2_mcFileName_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
151 {
152 }