<commit_before>// $Header$

#include "RMacro.h"

#include <TSystem.h>
#include <TROOT.h>
#include <G__ci.h>

using namespace Reve;

//______________________________________________________________________
// RMacro
//
// Sub-class of TMacro, overriding Exec to unload the previous verison
// and cleanup after the execution.

ClassImp(RMacro)

RMacro::RMacro() : TMacro() {}

RMacro::RMacro(const RMacro& m) : TMacro(m) {}

RMacro::RMacro(const char* name, const char* /*title*/) : TMacro(name, "") {}

/**************************************************************************/

void RMacro::Exec(const char* params)
{
  if(Reve::CheckMacro(fName))
    G__unloadfile(fTitle.Data());

  // Copy from TMacro::Exec. Difference is that the file is really placed
  // into the /tmp.
  TString fname = "/tmp/";
  {
    //the current implementation uses a file in the current directory.
    //should be replaced by a direct execution from memory by CINT
    fname += GetName();
    fname += ".Cexec";
    SaveSource(fname);
    //disable a possible call to gROOT->Reset from the executed script
    gROOT->SetExecutingMacro(kTRUE);
    //execute script in /tmp
    TString exec = ".x " + fname;
    TString p = params;
    if (p == "") p = fParams;
    if (p != "")
      exec += "(" + p + ")";
    gROOT->ProcessLine(exec);<commit_msg>Check for macro via full-path (fTitle); save macro as '.C' not '.Cexec'.<commit_after>// $Header$

#include "RMacro.h"

#include <TSystem.h>
#include <TROOT.h>
#include <G__ci.h>

using namespace Reve;

//______________________________________________________________________
// RMacro
//
// Sub-class of TMacro, overriding Exec to unload the previous verison
// and cleanup after the execution.

ClassImp(RMacro)

RMacro::RMacro() : TMacro() {}

RMacro::RMacro(const RMacro& m) : TMacro(m) {}

RMacro::RMacro(const char* name, const char* /*title*/) : TMacro(name, "") {}

/**************************************************************************/

void RMacro::Exec(const char* params)
{
  if(Reve::CheckMacro(fTitle.Data()))
    G__unloadfile(fTitle.Data());

  // Copy from TMacro::Exec. Difference is that the file is really placed
  // into the /tmp.
  TString fname = "/tmp/";
  {
    //the current implementation uses a file in the current directory.
    //should be replaced by a direct execution from memory by CINT
    fname += GetName();
    fname += ".C";
    SaveSource(fname);
    //disable a possible call to gROOT->Reset from the executed script
    gROOT->SetExecutingMacro(kTRUE);
    //execute script in /tmp
    TString exec = ".x " + fname;
    TString p = params;
    if (p == "") p = fParams;
    if (p != "")
      exec += "(" + p + ")";
    gROOT->ProcessLine(exec);
{'fraction_non_alphanumeric': 0.19302752293577982, 'fraction_numerical': 0.0, 'mean_word_length': 3.628183361629881, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '466298', 'n_tokens_mistral': 881, 'n_tokens_neox': 866, 'n_words': 256}