<commit_before>#include <stdio.h>
#include "duktape.h"
#include "mininode.h"

/*
 *  Duktape/C functions providing Node.js 'repl' module functionality.
 *  See https://nodejs.org/dist/v6.9.2/docs/api/repl.html
 */

/* Implementation TBD */

/*
 *  Module initialization
 */

char *mn_repl_read_line(void)
{
  char *line = NULL;
  ssize_t bufsize = 0; // have getline allocate a buffer for us
  getline(&line, &bufsize, stdin);
  return line;
}


void mn_repl_loop(duk_context *ctx) {
  char *line;
  int status;

  do {
    printf("> ");
    line = mn_repl_read_line();
    duk_eval_string(ctx, line);
    //duk_call(ctx, 0);
    //status = duk_eval(line);

    free(line);
  } while (true); // while(status)
}


const duk_function_list_entry mn_bi_repl_funcs[] = {
	{ NULL, NULL, 0 }
};

const duk_number_list_entry mn_bi_repl_consts[] = {
	{ NULL, 0.0 }
};

duk_ret_t<commit_msg>use fflush() so repl works on musl-libc<commit_after>#include <stdio.h>
#include "duktape.h"
#include "mininode.h"

/*
 *  Duktape/C functions providing Node.js 'repl' module functionality.
 *  See https://nodejs.org/dist/v6.9.2/docs/api/repl.html
 */

/*
 *  Module initialization
 */

char *mn_repl_read_line(void)
{
  char *line = NULL;
  ssize_t bufsize = 0;
  getline(&line, &bufsize, stdin);
  return line;
}


void mn_repl_loop(duk_context *ctx) {
  char *line;

  do {
    fprintf(stdout, "> ");
    fflush(stdout);
    line = mn_repl_read_line();
    duk_eval_string(ctx, line);
    free(line);
  } while (true); 
}


const duk_function_list_entry mn_bi_repl_funcs[] = {
	{ NULL, NULL, 0 }
};

const duk_number_list_entry mn_bi_repl_consts[] = {
	{ NULL, 0.0 }
};

duk_ret_t
{'fraction_non_alphanumeric': 0.1502403846153846, 'fraction_numerical': 0.009014423076923076, 'mean_word_length': 3.5491803278688523, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '3793040', 'n_tokens_mistral': 709, 'n_tokens_neox': 695, 'n_words': 134}