| 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 |
| 15 |
along with GCC; see the file COPYING3. If not see |
| 16 |
<http://www.gnu.org/licenses/>. */ |
| 17 |
|
| 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 |
| 26 |
|
| 27 |
#define _mcFileName_C |
| 28 |
|
| 29 |
#include "GmcFileName.h" |
| 30 |
# include "GASCII.h" |
| 31 |
# include "GDynamicStrings.h" |
| 32 |
|
| 33 |
# define MaxFileName 0 |
| 34 |
# define MaxStemName 0 |
| 35 |
# define Directory '/' |
| 36 |
|
| 37 |
/* |
| 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. |
| 42 |
*/ |
| 43 |
|
| 44 |
extern "C" DynamicStrings_String mcFileName_calculateFileName (DynamicStrings_String module, DynamicStrings_String extension); |
| 45 |
|
| 46 |
/* |
| 47 |
calculateStemName - calculates the stem name for given a module. |
| 48 |
This name length will be operating system and |
| 49 |
compiler specific. |
| 50 |
*/ |
| 51 |
|
| 52 |
extern "C" DynamicStrings_String mcFileName_calculateStemName (DynamicStrings_String module); |
| 53 |
|
| 54 |
/* |
| 55 |
extractExtension - given a, filename, return the filename without |
| 56 |
the extension, Ext. |
| 57 |
*/ |
| 58 |
|
| 59 |
extern "C" DynamicStrings_String mcFileName_extractExtension (DynamicStrings_String filename, DynamicStrings_String ext); |
| 60 |
|
| 61 |
/* |
| 62 |
extractModule - given a, filename, return the module name including any |
| 63 |
extension. A new string is returned. |
| 64 |
*/ |
| 65 |
|
| 66 |
extern "C" DynamicStrings_String mcFileName_extractModule (DynamicStrings_String filename); |
| 67 |
|
| 68 |
|
| 69 |
/* |
| 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. |
| 74 |
*/ |
| 75 |
|
| 76 |
extern "C" DynamicStrings_String mcFileName_calculateFileName (DynamicStrings_String module, DynamicStrings_String extension) |
| 77 |
{ |
| 78 |
if (MaxFileName == 0) |
| 79 |
{ |
| 80 |
return DynamicStrings_ConCat (DynamicStrings_ConCatChar (DynamicStrings_Slice (module, 0, MaxFileName), '.'), extension); |
| 81 |
} |
| 82 |
else |
| 83 |
{ |
| 84 |
return DynamicStrings_ConCat (DynamicStrings_ConCatChar (DynamicStrings_Slice (module, 0, (MaxFileName-(DynamicStrings_Length (extension)))-1), '.'), extension); |
| 85 |
} |
| 86 |
/* static analysis guarentees a RETURN statement will be used before here. */ |
| 87 |
__builtin_unreachable (); |
| 88 |
} |
| 89 |
|
| 90 |
|
| 91 |
/* |
| 92 |
calculateStemName - calculates the stem name for given a module. |
| 93 |
This name length will be operating system and |
| 94 |
compiler specific. |
| 95 |
*/ |
| 96 |
|
| 97 |
extern "C" DynamicStrings_String mcFileName_calculateStemName (DynamicStrings_String module) |
| 98 |
{ |
| 99 |
return DynamicStrings_Slice (module, 0, MaxStemName); |
| 100 |
/* static analysis guarentees a RETURN statement will be used before here. */ |
| 101 |
__builtin_unreachable (); |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
/* |
| 106 |
extractExtension - given a, filename, return the filename without |
| 107 |
the extension, Ext. |
| 108 |
*/ |
| 109 |
|
| 110 |
extern "C" DynamicStrings_String mcFileName_extractExtension (DynamicStrings_String filename, DynamicStrings_String ext) |
| 111 |
{ |
| 112 |
if (DynamicStrings_Equal (ext, DynamicStrings_Mark (DynamicStrings_Slice (filename, static_cast<int> (-(DynamicStrings_Length (ext))), 0)))) |
| 113 |
{ |
| 114 |
return DynamicStrings_Slice (filename, 0, static_cast<int> (-(DynamicStrings_Length (ext)))); |
| 115 |
} |
| 116 |
else |
| 117 |
{ |
| 118 |
return filename; |
| 119 |
} |
| 120 |
/* static analysis guarentees a RETURN statement will be used before here. */ |
| 121 |
__builtin_unreachable (); |
| 122 |
} |
| 123 |
|
| 124 |
|
| 125 |
/* |
| 126 |
extractModule - given a, filename, return the module name including any |
| 127 |
extension. A new string is returned. |
| 128 |
*/ |
| 129 |
|
| 130 |
extern "C" DynamicStrings_String mcFileName_extractModule (DynamicStrings_String filename) |
| 131 |
{ |
| 132 |
int i; |
| 133 |
|
| 134 |
i = DynamicStrings_Index (filename, Directory, 0); |
| 135 |
if (i == -1) |
| 136 |
{ |
| 137 |
return DynamicStrings_Dup (filename); |
| 138 |
} |
| 139 |
else |
| 140 |
{ |
| 141 |
return DynamicStrings_Slice (filename, i+1, 0); |
| 142 |
} |
| 143 |
/* static analysis guarentees a RETURN statement will be used before here. */ |
| 144 |
__builtin_unreachable (); |
| 145 |
} |
| 146 |
|
| 147 |
extern "C" void _M2_mcFileName_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) |
| 148 |
{ |
| 149 |
} |
| 150 |
|
| 151 |
extern "C" void _M2_mcFileName_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) |
| 152 |
{ |
| 153 |
} |