Daily bump.
[official-gcc.git] / gcc / m2 / mc-boot / GmcFileName.cc
blob3b516594c595e447de748ae00876a68b32b43364
1 /* do not edit automatically generated by mc from mcFileName. */
2 /* This file is part of GNU Modula-2.
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.
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.
14 You should have received a copy of the GNU General Public License
15 along with GCC; see the file COPYING3. If not see
16 <http://www.gnu.org/licenses/>. */
18 #include "config.h"
19 #include "system.h"
20 #include <stdbool.h>
21 # if !defined (PROC_D)
22 # define PROC_D
23 typedef void (*PROC_t) (void);
24 typedef struct { PROC_t proc; } PROC;
25 # endif
27 #define _mcFileName_C
29 #include "GmcFileName.h"
30 # include "GASCII.h"
31 # include "GDynamicStrings.h"
33 # define MaxFileName 0
34 # define MaxStemName 0
35 # define Directory '/'
38 calculateFileName - calculates and returns a new string filename given a module
39 and an extension. String, Extension, is concatenated onto
40 Module and thus it is safe to `Mark' the extension for garbage
41 collection.
44 extern "C" DynamicStrings_String mcFileName_calculateFileName (DynamicStrings_String module, DynamicStrings_String extension);
47 calculateStemName - calculates the stem name for given a module.
48 This name length will be operating system and
49 compiler specific.
52 extern "C" DynamicStrings_String mcFileName_calculateStemName (DynamicStrings_String module);
55 extractExtension - given a, filename, return the filename without
56 the extension, Ext.
59 extern "C" DynamicStrings_String mcFileName_extractExtension (DynamicStrings_String filename, DynamicStrings_String ext);
62 extractModule - given a, filename, return the module name including any
63 extension. A new string is returned.
66 extern "C" DynamicStrings_String mcFileName_extractModule (DynamicStrings_String filename);
70 calculateFileName - calculates and returns a new string filename given a module
71 and an extension. String, Extension, is concatenated onto
72 Module and thus it is safe to `Mark' the extension for garbage
73 collection.
76 extern "C" DynamicStrings_String mcFileName_calculateFileName (DynamicStrings_String module, DynamicStrings_String extension)
78 if (MaxFileName == 0)
80 return DynamicStrings_ConCat (DynamicStrings_ConCatChar (DynamicStrings_Slice (module, 0, MaxFileName), '.'), extension);
82 else
84 return DynamicStrings_ConCat (DynamicStrings_ConCatChar (DynamicStrings_Slice (module, 0, (MaxFileName-(DynamicStrings_Length (extension)))-1), '.'), extension);
86 /* static analysis guarentees a RETURN statement will be used before here. */
87 __builtin_unreachable ();
92 calculateStemName - calculates the stem name for given a module.
93 This name length will be operating system and
94 compiler specific.
97 extern "C" DynamicStrings_String mcFileName_calculateStemName (DynamicStrings_String module)
99 return DynamicStrings_Slice (module, 0, MaxStemName);
100 /* static analysis guarentees a RETURN statement will be used before here. */
101 __builtin_unreachable ();
106 extractExtension - given a, filename, return the filename without
107 the extension, Ext.
110 extern "C" DynamicStrings_String mcFileName_extractExtension (DynamicStrings_String filename, DynamicStrings_String ext)
112 if (DynamicStrings_Equal (ext, DynamicStrings_Mark (DynamicStrings_Slice (filename, static_cast<int> (-(DynamicStrings_Length (ext))), 0))))
114 return DynamicStrings_Slice (filename, 0, static_cast<int> (-(DynamicStrings_Length (ext))));
116 else
118 return filename;
120 /* static analysis guarentees a RETURN statement will be used before here. */
121 __builtin_unreachable ();
126 extractModule - given a, filename, return the module name including any
127 extension. A new string is returned.
130 extern "C" DynamicStrings_String mcFileName_extractModule (DynamicStrings_String filename)
132 int i;
134 i = DynamicStrings_Index (filename, Directory, 0);
135 if (i == -1)
137 return DynamicStrings_Dup (filename);
139 else
141 return DynamicStrings_Slice (filename, i+1, 0);
143 /* static analysis guarentees a RETURN statement will be used before here. */
144 __builtin_unreachable ();
147 extern "C" void _M2_mcFileName_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
151 extern "C" void _M2_mcFileName_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])