LCOV - code coverage report
Current view: top level - /mnt/build/buildbot/bld/build-lcov/gcc/m2/gm2-compiler-boot - M2Search.c (source / functions) Coverage Total Hit
Test: gcc.info Lines: 83.3 % 36 30
Test Date: 2024-12-21 13:15:12 Functions: 75.0 % 8 6
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 M2Search.  */
       2                 :             : /* M2Search.mod provides a mechanism to search selected directories.
       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                 :             : #   if !defined (TRUE)
      33                 :             : #      define TRUE (1==1)
      34                 :             : #   endif
      35                 :             : 
      36                 :             : #   if !defined (FALSE)
      37                 :             : #      define FALSE (1==0)
      38                 :             : #   endif
      39                 :             : 
      40                 :             : #if defined(__cplusplus)
      41                 :             : #   undef NULL
      42                 :             : #   define NULL 0
      43                 :             : #endif
      44                 :             : #define _M2Search_C
      45                 :             : 
      46                 :             : #include "GM2Search.h"
      47                 :             : #   include "GM2FileName.h"
      48                 :             : #   include "GAssertion.h"
      49                 :             : #   include "GPathName.h"
      50                 :             : #   include "GDynamicStrings.h"
      51                 :             : 
      52                 :             : #   define GarbageDebugging false
      53                 :             : #   define DefaultDefExt ".def"
      54                 :             : #   define DefaultModExt ".mod"
      55                 :             : static DynamicStrings_String Def;
      56                 :             : static DynamicStrings_String Mod;
      57                 :             : 
      58                 :             : /*
      59                 :             :    FindSourceFile - attempts to locate the source file FileName.
      60                 :             :                     If a file is found then TRUE is returned otherwise
      61                 :             :                     FALSE is returned.
      62                 :             :                     The parameter FullPath is set indicating the
      63                 :             :                     absolute location of source FileName.
      64                 :             :                     FullPath will be totally overwritten and should
      65                 :             :                     not be initialized by InitString before this function
      66                 :             :                     is called.
      67                 :             :                     FullPath is set to NIL if this function returns FALSE.
      68                 :             :                     FindSourceFile sets FullPath to a new string if successful.
      69                 :             :                     The string FileName is not altered.
      70                 :             : */
      71                 :             : 
      72                 :             : extern "C" bool M2Search_FindSourceFile (DynamicStrings_String FileName, DynamicStrings_String *FullPath, DynamicStrings_String *named);
      73                 :             : 
      74                 :             : /*
      75                 :             :    FindSourceDefFile - attempts to find the definition module for
      76                 :             :                        a module, Stem. If successful it returns
      77                 :             :                        the full path and returns TRUE. If unsuccessful
      78                 :             :                        then FALSE is returned and FullPath is set to NIL.
      79                 :             : */
      80                 :             : 
      81                 :             : extern "C" bool M2Search_FindSourceDefFile (DynamicStrings_String Stem, DynamicStrings_String *FullPath, DynamicStrings_String *named);
      82                 :             : 
      83                 :             : /*
      84                 :             :    FindSourceModFile - attempts to find the implementation module for
      85                 :             :                        a module, Stem. If successful it returns
      86                 :             :                        the full path and returns TRUE. If unsuccessful
      87                 :             :                        then FALSE is returned and FullPath is set to NIL.
      88                 :             : */
      89                 :             : 
      90                 :             : extern "C" bool M2Search_FindSourceModFile (DynamicStrings_String Stem, DynamicStrings_String *FullPath, DynamicStrings_String *named);
      91                 :             : 
      92                 :             : /*
      93                 :             :    SetDefExtension - sets the default extension for definition modules to, ext.
      94                 :             :                      The string, ext, should be deallocated by the caller at
      95                 :             :                      an appropriate time.
      96                 :             : */
      97                 :             : 
      98                 :             : extern "C" void M2Search_SetDefExtension (DynamicStrings_String ext);
      99                 :             : 
     100                 :             : /*
     101                 :             :    SetModExtension - sets the default extension for implementation and program
     102                 :             :                      modules to, ext. The string, ext, should be deallocated
     103                 :             :                      by the caller at an appropriate time.
     104                 :             : */
     105                 :             : 
     106                 :             : extern "C" void M2Search_SetModExtension (DynamicStrings_String ext);
     107                 :             : 
     108                 :             : /*
     109                 :             :    Init - initializes the def and mod default string names to NIL.
     110                 :             : */
     111                 :             : 
     112                 :             : static void Init (void);
     113                 :             : 
     114                 :             : 
     115                 :             : /*
     116                 :             :    Init - initializes the def and mod default string names to NIL.
     117                 :             : */
     118                 :             : 
     119                 :       14232 : static void Init (void)
     120                 :             : {
     121                 :       14232 :   Def = static_cast<DynamicStrings_String> (NULL);
     122                 :       14232 :   Mod = static_cast<DynamicStrings_String> (NULL);
     123                 :           0 : }
     124                 :             : 
     125                 :             : 
     126                 :             : /*
     127                 :             :    FindSourceFile - attempts to locate the source file FileName.
     128                 :             :                     If a file is found then TRUE is returned otherwise
     129                 :             :                     FALSE is returned.
     130                 :             :                     The parameter FullPath is set indicating the
     131                 :             :                     absolute location of source FileName.
     132                 :             :                     FullPath will be totally overwritten and should
     133                 :             :                     not be initialized by InitString before this function
     134                 :             :                     is called.
     135                 :             :                     FullPath is set to NIL if this function returns FALSE.
     136                 :             :                     FindSourceFile sets FullPath to a new string if successful.
     137                 :             :                     The string FileName is not altered.
     138                 :             : */
     139                 :             : 
     140                 :      176066 : extern "C" bool M2Search_FindSourceFile (DynamicStrings_String FileName, DynamicStrings_String *FullPath, DynamicStrings_String *named)
     141                 :             : {
     142                 :      176066 :   (*FullPath) = PathName_FindNamedPathFile (FileName, named);
     143                 :      176066 :   return (*FullPath) != NULL;
     144                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     145                 :             :   __builtin_unreachable ();
     146                 :             : }
     147                 :             : 
     148                 :             : 
     149                 :             : /*
     150                 :             :    FindSourceDefFile - attempts to find the definition module for
     151                 :             :                        a module, Stem. If successful it returns
     152                 :             :                        the full path and returns TRUE. If unsuccessful
     153                 :             :                        then FALSE is returned and FullPath is set to NIL.
     154                 :             : */
     155                 :             : 
     156                 :      115574 : extern "C" bool M2Search_FindSourceDefFile (DynamicStrings_String Stem, DynamicStrings_String *FullPath, DynamicStrings_String *named)
     157                 :             : {
     158                 :      115574 :   DynamicStrings_String f;
     159                 :             : 
     160                 :      115574 :   if (Def != NULL)
     161                 :             :     {
     162                 :          30 :       f = M2FileName_CalculateFileName (Stem, Def);
     163                 :          30 :       if (M2Search_FindSourceFile (f, FullPath, named))
     164                 :             :         {
     165                 :             :           return true;
     166                 :             :         }
     167                 :          24 :       f = DynamicStrings_KillString (f);
     168                 :             :     }
     169                 :             :   /* Try the GNU Modula-2 default extension.  */
     170                 :      115568 :   f = M2FileName_CalculateFileName (Stem, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) ".def", 4)));
     171                 :      115568 :   return M2Search_FindSourceFile (f, FullPath, named);
     172                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     173                 :             :   __builtin_unreachable ();
     174                 :             : }
     175                 :             : 
     176                 :             : 
     177                 :             : /*
     178                 :             :    FindSourceModFile - attempts to find the implementation module for
     179                 :             :                        a module, Stem. If successful it returns
     180                 :             :                        the full path and returns TRUE. If unsuccessful
     181                 :             :                        then FALSE is returned and FullPath is set to NIL.
     182                 :             : */
     183                 :             : 
     184                 :       60468 : extern "C" bool M2Search_FindSourceModFile (DynamicStrings_String Stem, DynamicStrings_String *FullPath, DynamicStrings_String *named)
     185                 :             : {
     186                 :       60468 :   DynamicStrings_String f;
     187                 :             : 
     188                 :       60468 :   if (Mod != NULL)
     189                 :             :     {
     190                 :           0 :       f = M2FileName_CalculateFileName (Stem, Mod);
     191                 :           0 :       if (M2Search_FindSourceFile (f, FullPath, named))
     192                 :             :         {
     193                 :             :           return true;
     194                 :             :         }
     195                 :           0 :       f = DynamicStrings_KillString (f);
     196                 :             :     }
     197                 :             :   /* Try the GNU Modula-2 default extension.  */
     198                 :       60468 :   f = M2FileName_CalculateFileName (Stem, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) ".mod", 4)));
     199                 :       60468 :   return M2Search_FindSourceFile (f, FullPath, named);
     200                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     201                 :             :   __builtin_unreachable ();
     202                 :             : }
     203                 :             : 
     204                 :             : 
     205                 :             : /*
     206                 :             :    SetDefExtension - sets the default extension for definition modules to, ext.
     207                 :             :                      The string, ext, should be deallocated by the caller at
     208                 :             :                      an appropriate time.
     209                 :             : */
     210                 :             : 
     211                 :           6 : extern "C" void M2Search_SetDefExtension (DynamicStrings_String ext)
     212                 :             : {
     213                 :           6 :   Def = DynamicStrings_KillString (Def);
     214                 :           6 :   Def = DynamicStrings_Dup (ext);
     215                 :           6 : }
     216                 :             : 
     217                 :             : 
     218                 :             : /*
     219                 :             :    SetModExtension - sets the default extension for implementation and program
     220                 :             :                      modules to, ext. The string, ext, should be deallocated
     221                 :             :                      by the caller at an appropriate time.
     222                 :             : */
     223                 :             : 
     224                 :           6 : extern "C" void M2Search_SetModExtension (DynamicStrings_String ext)
     225                 :             : {
     226                 :           6 :   Mod = DynamicStrings_KillString (Mod);
     227                 :           6 :   Mod = DynamicStrings_Dup (ext);
     228                 :           6 : }
     229                 :             : 
     230                 :       14232 : extern "C" void _M2_M2Search_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
     231                 :             : {
     232                 :       14232 :   Init ();
     233                 :       14232 : }
     234                 :             : 
     235                 :           0 : extern "C" void _M2_M2Search_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
     236                 :             : {
     237                 :           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.