LCOV - code coverage report
Current view: top level - /mnt/build/buildbot/bld/build-lcov/gcc/m2/gm2-compiler-boot - M2FileName.c (source / functions) Coverage Total Hit
Test: gcc.info Lines: 27.8 % 18 5
Test Date: 2024-04-13 14:00:49 Functions: 33.3 % 6 2
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* do not edit automatically generated by mc from M2FileName.  */
       2                 :             : /* M2FileName.mod construct file names.
       3                 :             : 
       4                 :             : Copyright (C) 2001-2024 Free Software Foundation, Inc.
       5                 :             : Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
       6                 :             : 
       7                 :             : This file is part of GNU Modula-2.
       8                 :             : 
       9                 :             : GNU Modula-2 is free software; you can redistribute it and/or modify
      10                 :             : it under the terms of the GNU General Public License as published by
      11                 :             : the Free Software Foundation; either version 3, or (at your option)
      12                 :             : any later version.
      13                 :             : 
      14                 :             : GNU Modula-2 is distributed in the hope that it will be useful, but
      15                 :             : WITHOUT ANY WARRANTY; without even the implied warranty of
      16                 :             : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      17                 :             : General Public License for more details.
      18                 :             : 
      19                 :             : You should have received a copy of the GNU General Public License
      20                 :             : along with GNU Modula-2; see the file COPYING3.  If not see
      21                 :             : <http://www.gnu.org/licenses/>.  */
      22                 :             : 
      23                 :             : #include "config.h"
      24                 :             : #include "system.h"
      25                 :             : #include <stdbool.h>
      26                 :             : #   if !defined (PROC_D)
      27                 :             : #      define PROC_D
      28                 :             :        typedef void (*PROC_t) (void);
      29                 :             :        typedef struct { PROC_t proc; } PROC;
      30                 :             : #   endif
      31                 :             : 
      32                 :             : #define _M2FileName_H
      33                 :             : #define _M2FileName_C
      34                 :             : 
      35                 :             : #   include "GASCII.h"
      36                 :             : #   include "GDynamicStrings.h"
      37                 :             : 
      38                 :             : #   define MaxFileName 0
      39                 :             : #   define MaxStemName 0
      40                 :             : #   define Directory '/'
      41                 :             : 
      42                 :             : /*
      43                 :             :    CalculateFileName - calculates and returns a new string filename given a module
      44                 :             :                        and an extension. String, Extension, is concatenated onto
      45                 :             :                        Module and thus it is safe to `Mark' the extension for garbage
      46                 :             :                        collection.
      47                 :             : */
      48                 :             : 
      49                 :             : extern "C" DynamicStrings_String M2FileName_CalculateFileName (DynamicStrings_String Module, DynamicStrings_String Extension);
      50                 :             : 
      51                 :             : /*
      52                 :             :    CalculateStemName - calculates the stem name for given a module.
      53                 :             :                        This name length will be operating system and
      54                 :             :                        compiler specific.
      55                 :             : */
      56                 :             : 
      57                 :             : extern "C" DynamicStrings_String M2FileName_CalculateStemName (DynamicStrings_String Module);
      58                 :             : 
      59                 :             : /*
      60                 :             :    ExtractExtension - given a, filename, return the filename without
      61                 :             :                       the extension, Ext.
      62                 :             : */
      63                 :             : 
      64                 :             : extern "C" DynamicStrings_String M2FileName_ExtractExtension (DynamicStrings_String filename, DynamicStrings_String ext);
      65                 :             : 
      66                 :             : /*
      67                 :             :    ExtractModule - given a, filename, return the module name including any
      68                 :             :                    extension. A new string is returned.
      69                 :             : */
      70                 :             : 
      71                 :             : extern "C" DynamicStrings_String M2FileName_ExtractModule (DynamicStrings_String filename);
      72                 :             : 
      73                 :             : 
      74                 :             : /*
      75                 :             :    CalculateFileName - calculates and returns a new string filename given a module
      76                 :             :                        and an extension. String, Extension, is concatenated onto
      77                 :             :                        Module and thus it is safe to `Mark' the extension for garbage
      78                 :             :                        collection.
      79                 :             : */
      80                 :             : 
      81                 :      164517 : extern "C" DynamicStrings_String M2FileName_CalculateFileName (DynamicStrings_String Module, DynamicStrings_String Extension)
      82                 :             : {
      83                 :      164517 :   if (MaxFileName == 0)
      84                 :             :     {
      85                 :      164517 :       return DynamicStrings_ConCat (DynamicStrings_Slice (Module, 0, MaxFileName), Extension);
      86                 :             :     }
      87                 :             :   else
      88                 :             :     {
      89                 :             :       return DynamicStrings_ConCat (DynamicStrings_Slice (Module, 0, MaxFileName-(DynamicStrings_Length (Extension))), Extension);
      90                 :             :     }
      91                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
      92                 :             :   __builtin_unreachable ();
      93                 :             : }
      94                 :             : 
      95                 :             : 
      96                 :             : /*
      97                 :             :    CalculateStemName - calculates the stem name for given a module.
      98                 :             :                        This name length will be operating system and
      99                 :             :                        compiler specific.
     100                 :             : */
     101                 :             : 
     102                 :           0 : extern "C" DynamicStrings_String M2FileName_CalculateStemName (DynamicStrings_String Module)
     103                 :             : {
     104                 :           0 :   return DynamicStrings_Slice (Module, 0, MaxStemName);
     105                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     106                 :             :   __builtin_unreachable ();
     107                 :             : }
     108                 :             : 
     109                 :             : 
     110                 :             : /*
     111                 :             :    ExtractExtension - given a, filename, return the filename without
     112                 :             :                       the extension, Ext.
     113                 :             : */
     114                 :             : 
     115                 :           0 : extern "C" DynamicStrings_String M2FileName_ExtractExtension (DynamicStrings_String filename, DynamicStrings_String ext)
     116                 :             : {
     117                 :           0 :   if (DynamicStrings_Equal (ext, DynamicStrings_Mark (DynamicStrings_Slice (filename, static_cast<int> (-(DynamicStrings_Length (ext))), 0))))
     118                 :             :     {
     119                 :           0 :       return DynamicStrings_Slice (filename, 0, static_cast<int> (-(DynamicStrings_Length (ext))));
     120                 :             :     }
     121                 :             :   else
     122                 :             :     {
     123                 :             :       return filename;
     124                 :             :     }
     125                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     126                 :             :   __builtin_unreachable ();
     127                 :             : }
     128                 :             : 
     129                 :             : 
     130                 :             : /*
     131                 :             :    ExtractModule - given a, filename, return the module name including any
     132                 :             :                    extension. A new string is returned.
     133                 :             : */
     134                 :             : 
     135                 :           0 : extern "C" DynamicStrings_String M2FileName_ExtractModule (DynamicStrings_String filename)
     136                 :             : {
     137                 :           0 :   int i;
     138                 :             : 
     139                 :           0 :   i = DynamicStrings_Index (filename, Directory, 0);
     140                 :           0 :   if (i == -1)
     141                 :             :     {
     142                 :           0 :       return DynamicStrings_Dup (filename);
     143                 :             :     }
     144                 :             :   else
     145                 :             :     {
     146                 :           0 :       return DynamicStrings_Slice (filename, i+1, 0);
     147                 :             :     }
     148                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     149                 :             :   __builtin_unreachable ();
     150                 :             : }
     151                 :             : 
     152                 :       12963 : extern "C" void _M2_M2FileName_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
     153                 :             : {
     154                 :       12963 : }
     155                 :             : 
     156                 :           0 : extern "C" void _M2_M2FileName_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
     157                 :             : {
     158                 :           0 : }
        

Generated by: LCOV version 2.1-beta

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.