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 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. */
20 # if !defined (PROC_D)
22 typedef void (*PROC_t
) (void);
23 typedef struct { PROC_t proc
; } PROC
;
30 # include "GDynamicStrings.h"
32 # define MaxFileName 0
33 # define MaxStemName 0
34 # define Directory '/'
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
43 extern "C" DynamicStrings_String
mcFileName_calculateFileName (DynamicStrings_String module
, DynamicStrings_String extension
);
46 calculateStemName - calculates the stem name for given a module.
47 This name length will be operating system and
51 extern "C" DynamicStrings_String
mcFileName_calculateStemName (DynamicStrings_String module
);
54 extractExtension - given a, filename, return the filename without
58 extern "C" DynamicStrings_String
mcFileName_extractExtension (DynamicStrings_String filename
, DynamicStrings_String ext
);
61 extractModule - given a, filename, return the module name including any
62 extension. A new string is returned.
65 extern "C" DynamicStrings_String
mcFileName_extractModule (DynamicStrings_String filename
);
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
75 extern "C" DynamicStrings_String
mcFileName_calculateFileName (DynamicStrings_String module
, DynamicStrings_String extension
)
79 return DynamicStrings_ConCat (DynamicStrings_ConCatChar (DynamicStrings_Slice (module
, 0, MaxFileName
), '.'), extension
);
83 return DynamicStrings_ConCat (DynamicStrings_ConCatChar (DynamicStrings_Slice (module
, 0, (MaxFileName
-(DynamicStrings_Length (extension
)))-1), '.'), extension
);
85 /* static analysis guarentees a RETURN statement will be used before here. */
86 __builtin_unreachable ();
91 calculateStemName - calculates the stem name for given a module.
92 This name length will be operating system and
96 extern "C" DynamicStrings_String
mcFileName_calculateStemName (DynamicStrings_String module
)
98 return DynamicStrings_Slice (module
, 0, MaxStemName
);
99 /* static analysis guarentees a RETURN statement will be used before here. */
100 __builtin_unreachable ();
105 extractExtension - given a, filename, return the filename without
109 extern "C" DynamicStrings_String
mcFileName_extractExtension (DynamicStrings_String filename
, DynamicStrings_String ext
)
111 if (DynamicStrings_Equal (ext
, DynamicStrings_Mark (DynamicStrings_Slice (filename
, static_cast<int> (-(DynamicStrings_Length (ext
))), 0))))
113 return DynamicStrings_Slice (filename
, 0, static_cast<int> (-(DynamicStrings_Length (ext
))));
119 /* static analysis guarentees a RETURN statement will be used before here. */
120 __builtin_unreachable ();
125 extractModule - given a, filename, return the module name including any
126 extension. A new string is returned.
129 extern "C" DynamicStrings_String
mcFileName_extractModule (DynamicStrings_String filename
)
133 i
= DynamicStrings_Index (filename
, Directory
, 0);
136 return DynamicStrings_Dup (filename
);
140 return DynamicStrings_Slice (filename
, i
+1, 0);
142 /* static analysis guarentees a RETURN statement will be used before here. */
143 __builtin_unreachable ();
146 extern "C" void _M2_mcFileName_init (__attribute__((unused
)) int argc
,__attribute__((unused
)) char *argv
[],__attribute__((unused
)) char *envp
[])
150 extern "C" void _M2_mcFileName_finish (__attribute__((unused
)) int argc
,__attribute__((unused
)) char *argv
[],__attribute__((unused
)) char *envp
[])