<commit_before>// Copyright (c) 2010 The WebM project authors. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree. An additional intellectual property rights grant can be found
// in the file PATENTS.  All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
//
// This sample application demonstrates how to use the Matroska parser
// library, which allows clients to handle a Matroska format file.
#include <cstdio>
#include <cstdlib>
#include <memory>
#include <new>

#include "mkvparser/mkvparser.h"
#include "mkvparser/mkvreader.h"

namespace {
const wchar_t* utf8towcs(const char* str) {
  if (str == NULL)
    return NULL;

  // TODO: this probably requires that the locale be
  // configured somehow:

  const size_t size = mbstowcs(NULL, str, 0);

  if (size == 0 || size == static_cast<size_t>(-1))
    return NULL;

  wchar_t* const val = new (std::nothrow) wchar_t[size + 1];
  if (val == NULL)
    return NULL;

  mbstowcs(val, str, size);
  val[size] = L'\0';

  return val;
}

bool InputHasCues(const mkvparser::Segment* const segment) {
  const mkvparser::Cues* const cues = segment->GetCues();
  if (cues == NULL)
    return false;

  while (!cues->DoneParsing())
    cues->LoadCuePoint();

  const mkvparser::CuePoint* const cue_point = cues->GetFirst();
  if (cue_point == NULL)
    return false;

  return true;
}

bool MasteringMetadataValuePresent(double value) {
  return value != mkvparser::MasteringMetadata::kValueNotPresent;
}

bool ColourValuePresent(long long value) {
  return value != mkvparser::Colour::kValueNotPresent;
}
}  // namespace

int main(int argc, char* argv[]) {
  if (argc == 1) {
    printf("Mkv Parser Sample Application\n");
    printf("  Usage: %s <input file> \n", argv[0]);
    return EXIT_FAILURE;
  }

  mkvparser::MkvReader reader;

  if (reader.Open(argv[1])) {
    printf("\n Filename is invalid or error while opening.\n");
    return EXIT_FAILURE;
  }

  int maj, min, build, rev;

  mkvparser::GetVersion(maj, min, build, rev);
  printf("\t\t libmkv verison: %d.%d.%d.%d\n", maj, min, build, rev);
<commit_msg>mkvparser_sample: Fix version info string.<commit_after>// Copyright (c) 2010 The WebM project authors. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree. An additional intellectual property rights grant can be found
// in the file PATENTS.  All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
//
// This sample application demonstrates how to use the Matroska parser
// library, which allows clients to handle a Matroska format file.
#include <cstdio>
#include <cstdlib>
#include <memory>
#include <new>

#include "mkvparser/mkvparser.h"
#include "mkvparser/mkvreader.h"

namespace {
const wchar_t* utf8towcs(const char* str) {
  if (str == NULL)
    return NULL;

  // TODO: this probably requires that the locale be
  // configured somehow:

  const size_t size = mbstowcs(NULL, str, 0);

  if (size == 0 || size == static_cast<size_t>(-1))
    return NULL;

  wchar_t* const val = new (std::nothrow) wchar_t[size + 1];
  if (val == NULL)
    return NULL;

  mbstowcs(val, str, size);
  val[size] = L'\0';

  return val;
}

bool InputHasCues(const mkvparser::Segment* const segment) {
  const mkvparser::Cues* const cues = segment->GetCues();
  if (cues == NULL)
    return false;

  while (!cues->DoneParsing())
    cues->LoadCuePoint();

  const mkvparser::CuePoint* const cue_point = cues->GetFirst();
  if (cue_point == NULL)
    return false;

  return true;
}

bool MasteringMetadataValuePresent(double value) {
  return value != mkvparser::MasteringMetadata::kValueNotPresent;
}

bool ColourValuePresent(long long value) {
  return value != mkvparser::Colour::kValueNotPresent;
}
}  // namespace

int main(int argc, char* argv[]) {
  if (argc == 1) {
    printf("Mkv Parser Sample Application\n");
    printf("  Usage: %s <input file> \n", argv[0]);
    return EXIT_FAILURE;
  }

  mkvparser::MkvReader reader;

  if (reader.Open(argv[1])) {
    printf("\n Filename is invalid or error while opening.\n");
    return EXIT_FAILURE;
  }

  int maj, min, build, rev;

  mkvparser::GetVersion(maj, min, build, rev);
  printf("\t\t libwebm version: %d.%d.%d.%d\n", maj, min, build, rev);

{'fraction_non_alphanumeric': 0.1255585344057194, 'fraction_numerical': 0.00580875781948168, 'mean_word_length': 3.783119658119658, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 23, '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': '4290545', 'n_tokens_mistral': 1523, 'n_tokens_neox': 1458, 'n_words': 502}