<commit_before>// -*- C++ -*-
// Copyright  1996, 1997, 1998, 2004, 2017 <NAME>
//
// All Rights Reserved
//
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#include "calc.h"
#include "parse_scan.h"
#include "parse.hh"  /* Parser definiitons */

#include <cmath>


namespace
{
  struct init
  {
    const char * fname;
    double (*fnct)(double);
  };

  init const arith_fncts[] =
    {
      { "sin", sin },
      { "cos", cos },
      { "tan", tan },
      { "asin", asin },
      { "acos", acos },
      { "atan", atan },
      { "ln", log },
      { "exp", exp },
      { "sqrt", sqrt },
      { 0, 0 }
    };
}

// ---------------------------------------------------------------

MaRC::sym_entry::sym_entry (void)
  // : type (sym_type)
{
  value.var = 0; /* set value to 0 even if fctn.  */
}

// ---------------------------------------------------------------

MaRC::symrec::symrec (void)
  : table_ ()
{
  for (init const * i = arith_fncts; i->fname != 0; ++i)
    {
      sym_entry s;
      s.type = FNCT;
      s.value.fnctptr = i->fnct;

      this->table_[i->fname] = s;
    }
}

void
MaRC::symrec::putsym (char const * name, int type)
{
  sym_entry s;
  s.type = type;

  Table::value_type const d (name, s);

  // Use insert() instead of operator[] to prevent users from
  // overwriting function entries we added.
  (void) this->table_.insert (d);
}

MaRC::sym_entry *
MaRC::symrec::getsym (char const * sym_name)
{
  Table::iterator const i (this->table_.find (sym_name));

  if (i != this->table_.end ())
    return &(*i).second;
  else
    return 0;
}
<commit_msg>calc: Fixed uninitialized member flagged by Coverity.<commit_after>// -*- C++ -*-
// Copyright  1996, 1997, 1998, 2004, 2017 <NAME>
//
// All Rights Reserved
//
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#include "calc.h"
#include "parse_scan.h"
#include "parse.hh"  /* Parser definiitons */

#include <cmath>


namespace
{
  struct init
  {
    const char * fname;
    double (*fnct)(double);
  };

  init const arith_fncts[] =
    {
      { "sin", sin },
      { "cos", cos },
      { "tan", tan },
      { "asin", asin },
      { "acos", acos },
      { "atan", atan },
      { "ln", log },
      { "exp", exp },
      { "sqrt", sqrt },
      { 0, 0 }
    };
}

// ---------------------------------------------------------------

MaRC::sym_entry::sym_entry (void)
   : type()
{
  value.var = 0; /* set value to 0 even if fctn.  */
}

// ---------------------------------------------------------------

MaRC::symrec::symrec (void)
  : table_ ()
{
  for (init const * i = arith_fncts; i->fname != 0; ++i)
    {
      sym_entry s;
      s.type = FNCT;
      s.value.fnctptr = i->fnct;

      this->table_[i->fname] = s;
    }
}

void
MaRC::symrec::putsym (char const * name, int type)
{
  sym_entry s;
  s.type = type;

  Table::value_type const d (name, s);

  // Use insert() instead of operator[] to prevent users from
  // overwriting function entries we added.
  (void) this->table_.insert (d);
}

MaRC::sym_entry *
MaRC::symrec::getsym (char const * sym_name)
{
  Table::iterator const i (this->table_.find (sym_name));

  if (i != this->table_.end ())
    return &(*i).second;
  else
    return 0;
}

{'fraction_non_alphanumeric': 0.19369071255239356, 'fraction_numerical': 0.018089565409221266, 'mean_word_length': 2.1639916259595253, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 21, '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': '5644222', 'n_tokens_mistral': 1521, 'n_tokens_neox': 1430, 'n_words': 503}