#!/usr/bin/perl
use strict ;
use warnings ;
use Term::ANSIColor ;

# ***********************************************#
# Report AnsiCmd Conditional Compile Directives. #
# Invoked from the Makefile: gmake buildlib      #
# or may be invoked directly: ./report.pl        #
# ********************************************** #
# Updated: 19-Mar-2026
# Author : Mahlon R. Smith
#          Copyright (c) 2022-2026 Mahlon R. Smith, The Software Samurai
#              GNU GPL copyright notice located in AnsiCmd.cpp
# Developed under: Perl 5.40.3 (x86_64)

   # Source file containing the directives.
   my $SourceFile = "AnsiCmd.hpp" ;

   # List of directives to scan.
   my @DirectiveList = 
      (
       "#define INCLUDE_API",
       "#define DEBUG_ANSICMD",
       "#define DEBUG_LOG",
       "#define DEBUG_ANSICMD_TEST",
      ) ;

   my $NoBump = "nobump" ; # suppress newline when called from within Makefile
   my $SearchString ;      # string to search for
   my $DebugString ;       # results of search
   my $strLength ;         # length of captured string
   my $itemCount = 0 ;     # number of items printed

   print colored ( "Conditional Compilation Directives:", 'blue reverse' ) ;
   print "  " ;
   foreach my $i ( 0 .. $#DirectiveList )
   {
      $SearchString = $DirectiveList[$i] ;
      $DebugString = qx ( grep -hm 1 '$SearchString' '$SourceFile' 2>&1 ) ;
      chomp $DebugString ;
      $strLength = length($DebugString) ;
      if ( $strLength > 0 )
      {
         $itemCount += 1 ;
         if ( ($itemCount) == 4 )
         { print "\n-----------------------------------  " ; $itemCount = 0 ; }
         print colored ( "'$DebugString'  ", 'blue' ) ;
      }
   }
   print "\n" ;

   # If invoked from the command line, append a blank line.
   if ( (not defined $ARGV[0]) || ($ARGV[0] ne $NoBump) )
   { print "\n" ; }
