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
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
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/>. */
21 # if !defined (PROC_D)
23 typedef void (*PROC_t
) (void);
24 typedef struct { PROC_t proc
; } PROC
;
29 #include "GmcFileName.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
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
52 extern "C" DynamicStrings_String
mcFileName_calculateStemName (DynamicStrings_String module
);
55 extractExtension - given a, filename, return the filename without
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
76 extern "C" DynamicStrings_String
mcFileName_calculateFileName (DynamicStrings_String module
, DynamicStrings_String extension
)
80 return DynamicStrings_ConCat (DynamicStrings_ConCatChar (DynamicStrings_Slice (module
, 0, MaxFileName
), '.'), extension
);
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
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
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
))));
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
)
134 i
= DynamicStrings_Index (filename
, Directory
, 0);
137 return DynamicStrings_Dup (filename
);
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
[])