LCOV - code coverage report
Current view: top level - /mnt/build/buildbot/bld/build-lcov/gcc/m2/gm2-compiler-boot - M2ColorString.c (source / functions) Coverage Total Hit
Test: gcc.info Lines: 65.5 % 55 36
Test Date: 2024-03-23 14:05:01 Functions: 50.0 % 18 9
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 M2ColorString.  */
       2                 :             : /* M2ColorString.mod provides procedures for obtaining GCC color strings.
       3                 :             : 
       4                 :             : Copyright (C) 2019-2024 Free Software Foundation, Inc.
       5                 :             : Contributed by Gaius Mulley <gaius@glam.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                 :             : #define _M2ColorString_H
      37                 :             : #define _M2ColorString_C
      38                 :             : 
      39                 :             : #   include "Gm2color.h"
      40                 :             : #   include "GDynamicStrings.h"
      41                 :             : #   include "GStrLib.h"
      42                 :             : #   include "Glibc.h"
      43                 :             : #   include "GSYSTEM.h"
      44                 :             : 
      45                 :             : static bool EnableColor;
      46                 :             : 
      47                 :             : /*
      48                 :             :    SetEnableColor - sets the global variable to, b, and returns
      49                 :             :                     the previous value.
      50                 :             : */
      51                 :             : 
      52                 :             : extern "C" bool M2ColorString_SetEnableColor (bool b);
      53                 :             : 
      54                 :             : /*
      55                 :             :    quoteOpen - adds an open quote to string, s.
      56                 :             : */
      57                 :             : 
      58                 :             : extern "C" DynamicStrings_String M2ColorString_quoteOpen (DynamicStrings_String s);
      59                 :             : 
      60                 :             : /*
      61                 :             :    quoteClose - adds a close quote to string, s.
      62                 :             : */
      63                 :             : 
      64                 :             : extern "C" DynamicStrings_String M2ColorString_quoteClose (DynamicStrings_String s);
      65                 :             : 
      66                 :             : /*
      67                 :             :    endColor - stops using color.
      68                 :             : */
      69                 :             : 
      70                 :             : extern "C" DynamicStrings_String M2ColorString_endColor (DynamicStrings_String s);
      71                 :             : 
      72                 :             : /*
      73                 :             :    quoteColor - adds quote color to string, s.
      74                 :             : */
      75                 :             : 
      76                 :             : extern "C" DynamicStrings_String M2ColorString_quoteColor (DynamicStrings_String s);
      77                 :             : 
      78                 :             : /*
      79                 :             :    errorColor - adds error color to string, s.
      80                 :             : */
      81                 :             : 
      82                 :             : extern "C" DynamicStrings_String M2ColorString_errorColor (DynamicStrings_String s);
      83                 :             : 
      84                 :             : /*
      85                 :             :    warningColor - adds warning color to string, s.
      86                 :             : */
      87                 :             : 
      88                 :             : extern "C" DynamicStrings_String M2ColorString_warningColor (DynamicStrings_String s);
      89                 :             : 
      90                 :             : /*
      91                 :             :    noteColor - adds note color to string, s.
      92                 :             : */
      93                 :             : 
      94                 :             : extern "C" DynamicStrings_String M2ColorString_noteColor (DynamicStrings_String s);
      95                 :             : 
      96                 :             : /*
      97                 :             :    locusColor - adds locus color to string, s.
      98                 :             : */
      99                 :             : 
     100                 :             : extern "C" DynamicStrings_String M2ColorString_locusColor (DynamicStrings_String s);
     101                 :             : 
     102                 :             : /*
     103                 :             :    insertColor - adds fixit-insert color to string, s.
     104                 :             : */
     105                 :             : 
     106                 :             : extern "C" DynamicStrings_String M2ColorString_insertColor (DynamicStrings_String s);
     107                 :             : 
     108                 :             : /*
     109                 :             :    deleteColor - adds fixit-insert color to string, s.
     110                 :             : */
     111                 :             : 
     112                 :             : extern "C" DynamicStrings_String M2ColorString_deleteColor (DynamicStrings_String s);
     113                 :             : 
     114                 :             : /*
     115                 :             :    filenameColor - adds filename color to string, s.
     116                 :             : */
     117                 :             : 
     118                 :             : extern "C" DynamicStrings_String M2ColorString_filenameColor (DynamicStrings_String s);
     119                 :             : 
     120                 :             : /*
     121                 :             :    typeColor - adds type color to string, s.
     122                 :             : */
     123                 :             : 
     124                 :             : extern "C" DynamicStrings_String M2ColorString_typeColor (DynamicStrings_String s);
     125                 :             : 
     126                 :             : /*
     127                 :             :    range1Color - adds type color to string, s.
     128                 :             : */
     129                 :             : 
     130                 :             : extern "C" DynamicStrings_String M2ColorString_range1Color (DynamicStrings_String s);
     131                 :             : 
     132                 :             : /*
     133                 :             :    range2Color - adds type color to string, s.
     134                 :             : */
     135                 :             : 
     136                 :             : extern "C" DynamicStrings_String M2ColorString_range2Color (DynamicStrings_String s);
     137                 :             : 
     138                 :             : /*
     139                 :             :    append - appends color string, name, to the end of string, s,
     140                 :             :             and returns, s.
     141                 :             : */
     142                 :             : 
     143                 :             : static DynamicStrings_String append (DynamicStrings_String s, const char *name_, unsigned int _name_high);
     144                 :             : 
     145                 :             : 
     146                 :             : /*
     147                 :             :    append - appends color string, name, to the end of string, s,
     148                 :             :             and returns, s.
     149                 :             : */
     150                 :             : 
     151                 :       92768 : static DynamicStrings_String append (DynamicStrings_String s, const char *name_, unsigned int _name_high)
     152                 :             : {
     153                 :       92768 :   DynamicStrings_String c;
     154                 :       92768 :   char name[_name_high+1];
     155                 :             : 
     156                 :             :   /* make a local copy of each unbounded array.  */
     157                 :       92768 :   memcpy (name, name_, _name_high+1);
     158                 :             : 
     159                 :       92768 :   c = DynamicStrings_InitStringCharStar (reinterpret_cast<void *> (m2color_colorize_start (EnableColor, &name, StrLib_StrLen ((const char *) name, _name_high))));
     160                 :       92768 :   s = DynamicStrings_ConCat (s, c);
     161                 :       92768 :   c = DynamicStrings_KillString (c);
     162                 :       92768 :   return s;
     163                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     164                 :             :   __builtin_unreachable ();
     165                 :       92768 : }
     166                 :             : 
     167                 :             : 
     168                 :             : /*
     169                 :             :    SetEnableColor - sets the global variable to, b, and returns
     170                 :             :                     the previous value.
     171                 :             : */
     172                 :             : 
     173                 :       24456 : extern "C" bool M2ColorString_SetEnableColor (bool b)
     174                 :             : {
     175                 :       24456 :   bool previous;
     176                 :             : 
     177                 :       24456 :   previous = EnableColor;
     178                 :       24456 :   EnableColor = b;
     179                 :       24456 :   return previous;
     180                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     181                 :             :   __builtin_unreachable ();
     182                 :             : }
     183                 :             : 
     184                 :             : 
     185                 :             : /*
     186                 :             :    quoteOpen - adds an open quote to string, s.
     187                 :             : */
     188                 :             : 
     189                 :       30249 : extern "C" DynamicStrings_String M2ColorString_quoteOpen (DynamicStrings_String s)
     190                 :             : {
     191                 :       30249 :   return DynamicStrings_ConCat (append (s, (const char *) "quote", 5), DynamicStrings_Mark (DynamicStrings_InitStringCharStar (reinterpret_cast<void *> (m2color_open_quote ()))));
     192                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     193                 :             :   __builtin_unreachable ();
     194                 :             : }
     195                 :             : 
     196                 :             : 
     197                 :             : /*
     198                 :             :    quoteClose - adds a close quote to string, s.
     199                 :             : */
     200                 :             : 
     201                 :       30249 : extern "C" DynamicStrings_String M2ColorString_quoteClose (DynamicStrings_String s)
     202                 :             : {
     203                 :       30249 :   s = M2ColorString_endColor (s);
     204                 :       30249 :   s = append (s, (const char *) "quote", 5);
     205                 :       30249 :   s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitStringCharStar (reinterpret_cast<void *> (m2color_close_quote ()))));
     206                 :       30249 :   s = M2ColorString_endColor (s);
     207                 :       30249 :   return s;
     208                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     209                 :             :   __builtin_unreachable ();
     210                 :             : }
     211                 :             : 
     212                 :             : 
     213                 :             : /*
     214                 :             :    endColor - stops using color.
     215                 :             : */
     216                 :             : 
     217                 :      118468 : extern "C" DynamicStrings_String M2ColorString_endColor (DynamicStrings_String s)
     218                 :             : {
     219                 :      118468 :   DynamicStrings_String c;
     220                 :             : 
     221                 :      118468 :   c = DynamicStrings_InitStringCharStar (reinterpret_cast<void *> (m2color_colorize_stop (EnableColor)));
     222                 :      118468 :   s = DynamicStrings_ConCat (s, c);
     223                 :      118468 :   c = DynamicStrings_KillString (c);
     224                 :      118468 :   return s;
     225                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     226                 :             :   __builtin_unreachable ();
     227                 :             : }
     228                 :             : 
     229                 :             : 
     230                 :             : /*
     231                 :             :    quoteColor - adds quote color to string, s.
     232                 :             : */
     233                 :             : 
     234                 :           0 : extern "C" DynamicStrings_String M2ColorString_quoteColor (DynamicStrings_String s)
     235                 :             : {
     236                 :           0 :   return append (s, (const char *) "quote", 5);
     237                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     238                 :             :   __builtin_unreachable ();
     239                 :             : }
     240                 :             : 
     241                 :             : 
     242                 :             : /*
     243                 :             :    errorColor - adds error color to string, s.
     244                 :             : */
     245                 :             : 
     246                 :        6888 : extern "C" DynamicStrings_String M2ColorString_errorColor (DynamicStrings_String s)
     247                 :             : {
     248                 :        6888 :   return append (s, (const char *) "error", 5);
     249                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     250                 :             :   __builtin_unreachable ();
     251                 :             : }
     252                 :             : 
     253                 :             : 
     254                 :             : /*
     255                 :             :    warningColor - adds warning color to string, s.
     256                 :             : */
     257                 :             : 
     258                 :       24738 : extern "C" DynamicStrings_String M2ColorString_warningColor (DynamicStrings_String s)
     259                 :             : {
     260                 :       24738 :   return append (s, (const char *) "warning", 7);
     261                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     262                 :             :   __builtin_unreachable ();
     263                 :             : }
     264                 :             : 
     265                 :             : 
     266                 :             : /*
     267                 :             :    noteColor - adds note color to string, s.
     268                 :             : */
     269                 :             : 
     270                 :          78 : extern "C" DynamicStrings_String M2ColorString_noteColor (DynamicStrings_String s)
     271                 :             : {
     272                 :          78 :   return append (s, (const char *) "note", 4);
     273                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     274                 :             :   __builtin_unreachable ();
     275                 :             : }
     276                 :             : 
     277                 :             : 
     278                 :             : /*
     279                 :             :    locusColor - adds locus color to string, s.
     280                 :             : */
     281                 :             : 
     282                 :         566 : extern "C" DynamicStrings_String M2ColorString_locusColor (DynamicStrings_String s)
     283                 :             : {
     284                 :         566 :   return append (s, (const char *) "locus", 5);
     285                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     286                 :             :   __builtin_unreachable ();
     287                 :             : }
     288                 :             : 
     289                 :             : 
     290                 :             : /*
     291                 :             :    insertColor - adds fixit-insert color to string, s.
     292                 :             : */
     293                 :             : 
     294                 :           0 : extern "C" DynamicStrings_String M2ColorString_insertColor (DynamicStrings_String s)
     295                 :             : {
     296                 :           0 :   return append (s, (const char *) "fixit-insert", 12);
     297                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     298                 :             :   __builtin_unreachable ();
     299                 :             : }
     300                 :             : 
     301                 :             : 
     302                 :             : /*
     303                 :             :    deleteColor - adds fixit-insert color to string, s.
     304                 :             : */
     305                 :             : 
     306                 :           0 : extern "C" DynamicStrings_String M2ColorString_deleteColor (DynamicStrings_String s)
     307                 :             : {
     308                 :           0 :   return append (s, (const char *) "fixit-delete", 12);
     309                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     310                 :             :   __builtin_unreachable ();
     311                 :             : }
     312                 :             : 
     313                 :             : 
     314                 :             : /*
     315                 :             :    filenameColor - adds filename color to string, s.
     316                 :             : */
     317                 :             : 
     318                 :           0 : extern "C" DynamicStrings_String M2ColorString_filenameColor (DynamicStrings_String s)
     319                 :             : {
     320                 :           0 :   return append (s, (const char *) "diff-filename", 13);
     321                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     322                 :             :   __builtin_unreachable ();
     323                 :             : }
     324                 :             : 
     325                 :             : 
     326                 :             : /*
     327                 :             :    typeColor - adds type color to string, s.
     328                 :             : */
     329                 :             : 
     330                 :           0 : extern "C" DynamicStrings_String M2ColorString_typeColor (DynamicStrings_String s)
     331                 :             : {
     332                 :           0 :   return append (s, (const char *) "type", 4);
     333                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     334                 :             :   __builtin_unreachable ();
     335                 :             : }
     336                 :             : 
     337                 :             : 
     338                 :             : /*
     339                 :             :    range1Color - adds type color to string, s.
     340                 :             : */
     341                 :             : 
     342                 :           0 : extern "C" DynamicStrings_String M2ColorString_range1Color (DynamicStrings_String s)
     343                 :             : {
     344                 :           0 :   return append (s, (const char *) "range1", 6);
     345                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     346                 :             :   __builtin_unreachable ();
     347                 :             : }
     348                 :             : 
     349                 :             : 
     350                 :             : /*
     351                 :             :    range2Color - adds type color to string, s.
     352                 :             : */
     353                 :             : 
     354                 :           0 : extern "C" DynamicStrings_String M2ColorString_range2Color (DynamicStrings_String s)
     355                 :             : {
     356                 :           0 :   return append (s, (const char *) "range2", 6);
     357                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     358                 :             :   __builtin_unreachable ();
     359                 :             : }
     360                 :             : 
     361                 :           0 : extern "C" void _M2_M2ColorString_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
     362                 :             : {
     363                 :           0 :   EnableColor = true;
     364                 :           0 : }
     365                 :             : 
     366                 :           0 : extern "C" void _M2_M2ColorString_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
     367                 :             : {
     368                 :           0 : }
        

Generated by: LCOV version 2.0-1

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.