<commit_before>// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

#include "platform/assert.h"

#include <sstream>
#include <string>

#include "platform/globals.h"

namespace dart {

// Exit with a failure code when we miss an EXPECT check.
static void failed_exit(void) {
  exit(255);
}

void DynamicAssertionHelper::Fail(const char* format, ...) {
  std::ostringstream stream;
  stream << file_ << ":" << line_ << ": error: ";

  va_list arguments;
  va_start(arguments, format);
  char buffer[2 * KB];
  vsnprintf(buffer, sizeof(buffer), format, arguments);
  va_end(arguments);
  stream << buffer << std::endl;

  // Get the message from the string stream and dump it on stderr.
  std::string message = stream.str();
  fprintf(stderr, "%s", message.c_str());

  // In case of failed assertions, abort right away. Otherwise, wait
  // until the program is exiting before producing a non-zero exit
  // code through abort.
  // TODO(5411324): replace std::abort with OS::Abort so that we can handle
  // restoring of signal handlers before aborting.
  if (kind_ == ASSERT) {
    abort();
  }
  static bool failed = false;
  if (!failed) {
    atexit(&failed_exit);
  }
  failed = true;
}

}  // namespace dart<commit_msg>Flush stderr when printing ASSERT message.<commit_after>// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

#include "platform/assert.h"

#include <sstream>
#include <string>

#include "platform/globals.h"

namespace dart {

// Exit with a failure code when we miss an EXPECT check.
static void failed_exit(void) {
  exit(255);
}

void DynamicAssertionHelper::Fail(const char* format, ...) {
  std::ostringstream stream;
  stream << file_ << ":" << line_ << ": error: ";

  va_list arguments;
  va_start(arguments, format);
  char buffer[2 * KB];
  vsnprintf(buffer, sizeof(buffer), format, arguments);
  va_end(arguments);
  stream << buffer << std::endl;

  // Get the message from the string stream and dump it on stderr.
  std::string message = stream.str();
  fprintf(stderr, "%s", message.c_str());
  fflush(stderr);

  // In case of failed assertions, abort right away. Otherwise, wait
  // until the program is exiting before producing a non-zero exit
  // code through abort.
  // TODO(5411324): replace std::abort with OS::Abort so that we can handle
  // restoring of signal handlers before aborting.
  if (kind_ == ASSERT) {
    abort();
  }
  static bool failed = false;
  if (!failed) {
    atexit(&failed_exit);
  }
  failed = true;
}

}  // namespace dart
{'fraction_non_alphanumeric': 0.12176991150442477, 'fraction_numerical': 0.010619469026548672, 'mean_word_length': 3.6176470588235294, 'pattern_counts': {'":': 4, '<': 31, '<?xml version=': 0, '>': 7, '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': '3596359', 'n_tokens_mistral': 889, 'n_tokens_neox': 845, 'n_words': 323}