<commit_before>// @(#)root/meta:$Name:  $:$Id: TStreamerElement.cxx,v 1.77 2005/03/09 22:40:45 brun Exp $
// Author: <NAME>   12/10/2000

/*************************************************************************
 * Copyright (C) 1995-2000, <NAME> and <NAME>.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//////////////////////////////////////////////////////////////////////////
//                                                                      //
//                                                                      //
//////////////////////////////////////////////////////////////////////////


#include "TROOT.h"
#include "TStreamerElement.h"
#include "TStreamerInfo.h"
#include "TClass.h"
#include "TClassEdit.h"
#include "TBaseClass.h"
#include "TDataMember.h"
#include "TDataType.h"
#include "TMethodCall.h"
#include "TRealData.h"
#include "TFolder.h"
#include "TRef.h"
#include "Api.h"
#include "TInterpreter.h"

const Int_t kMaxLen = 1024;
static char gIncludeName[kMaxLen];


//______________________________________________________________________________
static TStreamerBasicType *InitCounter(const char *countClass, const char *countName) 
{
   // Helper function to initialize the 'index/counter' value of 
   // the Pointer streamerElements.

   TClass *cl = gROOT->GetClass(countClass);
  
   if (cl==0) return 0;

   TStreamerBasicType *counter = TStreamerInfo::GetElementCounter(countName,cl);

   //at this point the counter is may be declared to skip
   if (counter) {
      if (counter->GetType() < TStreamerInfo::kCounter) counter->SetType(TStreamerInfo::kCounter); 
   }
   return counter;
}  


//______________________________________________________________________________
static void GetRange(const char *comments, Double_t &xmin, Double_t &xmax, Double_t &factor) 
{
   // Parse comments to search for a range specifier of the style: 
   //  [xmin,xmax] or [xmin,xmax,nbits]
   //  [0,1]
   //  [-10,100];
   //  [-pi,pi], [-pi/2,pi/4],[-2pi,2*pi]
   //  [-10,100,16]
   // if nbits is not specified, or nbits <2 or nbits>32 it is set to 32
   //
   // Currently the range specifier is used only to stream a Double32_t type
   // see TBuffer::WriteDouble32
         
   factor = xmin = xmax = 0;
   if (!comments) return;
   const char *left = strstr(comments,"[");
   if (!left) return;
   const char *right = strstr(left,"]");
   if (!right) return;
   const char *comma = strstr(left,",");
   if (!comma || comma > right) {
      //may be first bracket was a dimension specifier
      left = strstr(right,"[");
      if (!left) return;
      right = strstr(left,"]");
      if (!right) return;
      comma = strstr(left,",");
      if (!comma || comma >right) return;
   }
   //search if nbits is specified
   const char *comma2 = 0;
   if (comma) comma2 = strstr(comma+1,",");
   if (comma2 > right) comma2 = 0;
   Int_t nbits = 32;
   if (comma2) {
      TString sbits(comma2+1,right-comma2-1);
      sscanf(sbits.Data(),"%d",&nbits);
      if (nbits < 2 || nbits > 32) {
         printf("illegal specification for the number of bits; %d. reset to 32\n",nbits);
         nbits = 32;
      }
      right = comma2;
   }
   TString range(left+1,right-left-1);
   TString sxmin(left+1,comma-left-1);
   sxmin.ToLower(); 
   sxmin.ReplaceAll(" ","");
   if (sxmin.Contains("pi")) {
      if      (sxmin.Contains("2pi"))   xmin = TMath::TwoPi();
      else if (sxmin.Contains("2*pi"))  xmin = TMath::TwoPi();
      else if (sxmin.Contains("twopi")) xmin = TMath::TwoPi();
      else if (sxmin.Contains("pi/2"))  xmin = TMath::PiOver2();
      else if (sxmin.Contains("pi/4"))  xmin = TMath::PiOver4();      
      else if (sxmin.Contains("pi"))    xmin = TMath::Pi();      
      if (sxmin.Contains("-"))          xmin = -xmin;
   } else {
      sscanf(sxmin.Data(),"%lg",&xmin);
   }
   TString sxmax(comma+1,right-comma-1);
   sxmax.ToLower(); 
   sxmax.ReplaceAll(" ","");
   if (sxmax.Contains("pi")) {
      if      (sxmax.Contains("2pi"))   xmax = TMath::TwoPi();
      else if (sxmax.Contains("2*pi"))  xmax = TMath::TwoPi();
      else if (sxmax.Contains("twopi")) xmax = TMath::TwoPi();
      else if (sxmax.Contains("pi/2"))  xmax = TMath::PiOver2();
      else if (sxmax.Contains("pi/4"))  xmax = TMath::PiOver4();      
      else if (sxmax.Contains("pi"))    xmax = TMath::Pi();      
      if (sxmax.Contains("-"))          xmax = -xmax;
   } else {
      sscanf(sxmax.Data(),"%lg",&xmax);
   }
   UInt_t bigint;
   if (nbits < 32) bigint = 1<<nbits;
   else            bigint = 0xffffffff;
   factor = bigint/(xmax-xmin);
}
   
ClassImp(TStreamerElement)

//______________________________________________________________________________
TStreamerElement::TStreamerElement()
{
   // Default ctor.

   fType        = 0;
   fSize        = 0;<commit_msg>Added protection against a range where xmin >= xmax<commit_after>// @(#)root/meta:$Name:  $:$Id: TStreamerElement.cxx,v 1.78 2005/04/18 10:54:58 brun Exp $
// Author: <NAME>   12/10/2000

/*************************************************************************
 * Copyright (C) 1995-2000, <NAME> and <NAME>.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//////////////////////////////////////////////////////////////////////////
//                                                                      //
//                                                                      //
//////////////////////////////////////////////////////////////////////////


#include "TROOT.h"
#include "TStreamerElement.h"
#include "TStreamerInfo.h"
#include "TClass.h"
#include "TClassEdit.h"
#include "TBaseClass.h"
#include "TDataMember.h"
#include "TDataType.h"
#include "TMethodCall.h"
#include "TRealData.h"
#include "TFolder.h"
#include "TRef.h"
#include "Api.h"
#include "TInterpreter.h"

const Int_t kMaxLen = 1024;
static char gIncludeName[kMaxLen];


//______________________________________________________________________________
static TStreamerBasicType *InitCounter(const char *countClass, const char *countName) 
{
   // Helper function to initialize the 'index/counter' value of 
   // the Pointer streamerElements.

   TClass *cl = gROOT->GetClass(countClass);
  
   if (cl==0) return 0;

   TStreamerBasicType *counter = TStreamerInfo::GetElementCounter(countName,cl);

   //at this point the counter is may be declared to skip
   if (counter) {
      if (counter->GetType() < TStreamerInfo::kCounter) counter->SetType(TStreamerInfo::kCounter); 
   }
   return counter;
}  


//______________________________________________________________________________
static void GetRange(const char *comments, Double_t &xmin, Double_t &xmax, Double_t &factor) 
{
   // Parse comments to search for a range specifier of the style: 
   //  [xmin,xmax] or [xmin,xmax,nbits]
   //  [0,1]
   //  [-10,100];
   //  [-pi,pi], [-pi/2,pi/4],[-2pi,2*pi]
   //  [-10,100,16]
   // if nbits is not specified, or nbits <2 or nbits>32 it is set to 32
   //
   // Currently the range specifier is used only to stream a Double32_t type
   // see TBuffer::WriteDouble32
         
   factor = xmin = xmax = 0;
   if (!comments) return;
   const char *left = strstr(comments,"[");
   if (!left) return;
   const char *right = strstr(left,"]");
   if (!right) return;
   const char *comma = strstr(left,",");
   if (!comma || comma > right) {
      //may be first bracket was a dimension specifier
      left = strstr(right,"[");
      if (!left) return;
      right = strstr(left,"]");
      if (!right) return;
      comma = strstr(left,",");
      if (!comma || comma >right) return;
   }
   //search if nbits is specified
   const char *comma2 = 0;
   if (comma) comma2 = strstr(comma+1,",");
   if (comma2 > right) comma2 = 0;
   Int_t nbits = 32;
   if (comma2) {
      TString sbits(comma2+1,right-comma2-1);
      sscanf(sbits.Data(),"%d",&nbits);
      if (nbits < 2 || nbits > 32) {
         printf("illegal specification for the number of bits; %d. reset to 32\n",nbits);
         nbits = 32;
      }
      right = comma2;
   }
   TString range(left+1,right-left-1);
   TString sxmin(left+1,comma-left-1);
   sxmin.ToLower(); 
   sxmin.ReplaceAll(" ","");
   if (sxmin.Contains("pi")) {
      if      (sxmin.Contains("2pi"))   xmin = TMath::TwoPi();
      else if (sxmin.Contains("2*pi"))  xmin = TMath::TwoPi();
      else if (sxmin.Contains("twopi")) xmin = TMath::TwoPi();
      else if (sxmin.Contains("pi/2"))  xmin = TMath::PiOver2();
      else if (sxmin.Contains("pi/4"))  xmin = TMath::PiOver4();      
      else if (sxmin.Contains("pi"))    xmin = TMath::Pi();      
      if (sxmin.Contains("-"))          xmin = -xmin;
   } else {
      sscanf(sxmin.Data(),"%lg",&xmin);
   }
   TString sxmax(comma+1,right-comma-1);
   sxmax.ToLower(); 
   sxmax.ReplaceAll(" ","");
   if (sxmax.Contains("pi")) {
      if      (sxmax.Contains("2pi"))   xmax = TMath::TwoPi();
      else if (sxmax.Contains("2*pi"))  xmax = TMath::TwoPi();
      else if (sxmax.Contains("twopi")) xmax = TMath::TwoPi();
      else if (sxmax.Contains("pi/2"))  xmax = TMath::PiOver2();
      else if (sxmax.Contains("pi/4"))  xmax = TMath::PiOver4();      
      else if (sxmax.Contains("pi"))    xmax = TMath::Pi();      
      if (sxmax.Contains("-"))          xmax = -xmax;
   } else {
      sscanf(sxmax.Data(),"%lg",&xmax);
   }
   UInt_t bigint;
   if (nbits < 32)  bigint = 1<<nbits;
   else             bigint = 0xffffffff;
   if (xmin < xmax) factor = bigint/(xmax-xmin);
}
   
ClassImp(TStreamerElement)

//______________________________________________________________________________
TStreamerElement::TStreamerElement()
{
   // Default ctor.

   fType        = 0;
   fSize        = 0;
{'fraction_non_alphanumeric': 0.1993435659812723, 'fraction_numerical': 0.021816777681243363, 'mean_word_length': 2.262992125984252, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3686714', 'n_tokens_mistral': 3456, 'n_tokens_neox': 3232, 'n_words': 769}