<commit_before>/*
 * A simple brainfuck interpreter.
 *
 * This file was written by <NAME>, <<EMAIL>>. This is free
 * and unencumbered software released into the public domain. For more
 * information, please refer to the accompanying "UNLICENCE" file.
*/

#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "brainfuck.h"

#define NUMBER_OF_CELLS 30000

int main(int argc, char **argv)
{
  char *commands = NULL;
  unsigned int number_of_commands = 0;
  brainfuck_evaluate_status status;
  brainfuck_tape *tape = brainfuck_createTape(NUMBER_OF_CELLS, malloc);
  FILE *brainfuck_stream = stdin;
  if ((argc != 1) && (strcmp(argv[1], "-") != 0)) {
    if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0)) {
      printf("\"%s\" is a simple brainfuck interpreter.\n\n", argv[0]);
      printf("  - brainfuck programs have access to %d %d-bit cells.\n",
          NUMBER_OF_CELLS, (int)sizeof(tape->data[0]) * 8);
      puts("  - The cell array does not extend dynamically.");
      printf("  - When accepting input, EOF is equal to %d.\n\n", EOF);
      printf("Usage: %s [options] [- | programfile]\n", argv[0]);
      puts("Options:\n  -h, --help    Print this message.");
      exit(EXIT_SUCCESS);
    } else if (argv[1][0] == '-') {
      fprintf(stderr, "Unrecognised option: %s\n", argv[1]);
      fprintf(stderr, "Try \"%s -h\" for more information.\n", argv[0]);
      exit(EXIT_FAILURE);
    } else if ((brainfuck_stream = fopen(argv[1], "r")) == NULL) {
      fprintf(stderr, "Cannot open \"%s\": %s\n", argv[1], strerror(errno));
      exit(EXIT_FAILURE);
    }
  }
  while (1) {
    char character = fgetc(brainfuck_stream);
    char *new_commands = realloc(commands, ++number_of_commands * sizeof(char));
    if (new_commands == NULL) {
      free(commands);
      perror("Unable to create command list");
      exit(EXIT_FAILURE);
    } else {
      commands = new_commands;
    }
    if (character == EOF) {<commit_msg>Fiddle with the interpreter's help message.<commit_after>/*
 * A simple brainfuck interpreter.
 *
 * This file was written by <NAME>, <<EMAIL>>. This is free
 * and unencumbered software released into the public domain. For more
 * information, please refer to the accompanying "UNLICENCE" file.
*/

#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "brainfuck.h"

#define NUMBER_OF_CELLS 30000

int main(int argc, char **argv)
{
  char *commands = NULL;
  unsigned int number_of_commands = 0;
  brainfuck_evaluate_status status;
  brainfuck_tape *tape = brainfuck_createTape(NUMBER_OF_CELLS, malloc);
  FILE *brainfuck_stream = stdin;
  if ((argc != 1) && (strcmp(argv[1], "-") != 0)) {
    if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0)) {
      printf("\"%s\" is a nice brainfuck interpreter.\n\n", argv[0]);
      printf("  - brainfuck programs have access to %d %d-bit cells.\n",
          NUMBER_OF_CELLS, (int)sizeof(tape->data[0]) * 8);
      /* FIXME: Rewrite this poorly worded bullet-point. */
      puts("  - Integer wraparound, yo.");
      printf("  - When accepting input, EOF is equal to %d.\n\n", EOF);
      printf("Usage: %s [options] [- | programfile]\n", argv[0]);
      puts("Options:\n  -h, --help    Print this message.");
      exit(EXIT_SUCCESS);
    } else if (argv[1][0] == '-') {
      fprintf(stderr, "Unrecognised option: %s\n", argv[1]);
      fprintf(stderr, "Try \"%s -h\" for more information.\n", argv[0]);
      exit(EXIT_FAILURE);
    } else if ((brainfuck_stream = fopen(argv[1], "r")) == NULL) {
      fprintf(stderr, "Cannot open \"%s\": %s\n", argv[1], strerror(errno));
      exit(EXIT_FAILURE);
    }
  }
  while (1) {
    char character = fgetc(brainfuck_stream);
    char *new_commands = realloc(commands, ++number_of_commands * sizeof(char));
    if (new_commands == NULL) {
      free(commands);
      perror("Unable to create command list");
      exit(EXIT_FAILURE);
    } else {
      commands = new_commands;
    }
    if (character == EOF) {
{'fraction_non_alphanumeric': 0.17009803921568628, 'fraction_numerical': 0.011764705882352941, 'mean_word_length': 3.327677624602333, 'pattern_counts': {'":': 2, '<': 19, '<?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': '870884', 'n_tokens_mistral': 1438, 'n_tokens_neox': 1421, 'n_words': 383}