<commit_before>/* cmd_buffer.c -- buffer manipulation commands */
#include <string.h>

#include "edna.h"
#include "buffer.h"
#include "cmd.h"
#include "state.h"

int
cmd_switchbuf(State *st, Buffer buf, Arg *arg, char *error)
{
	if (!arg->mode) {
		strcpy(error, "no option specified");
		return FAIL;

	} else if (!strcmp(arg->mode, "next")) {
		returnbuf(st, buf);
		checkoutbuf(buf, st, 0);

		return SUCC;

	} else if (!strcmp(arg->mode, "prev")) {
		returnbuf(st, buf);
		checkoutbuf(buf, st, (st->buffers.c != 1) ? st->buffers.c - 2 : 0 );

		return SUCC;
	}

	strcpy (error, "unknown option");
	return FAIL;
}

int
cmd_openbuf(State *st, Buffer buf, Arg *arg, char *error)
{
	Buffer tmp;
	size_t i;

	if (!arg->param.c) {
		strcpy(error, "no filenames provided");
		return FAIL;
	}

	i = 0;
	do {
		tmp = makebuf();
		initbuf(tmp, arg->param.v[i]);
		readbuf(tmp, error);
		bufclean(buf);
		addbuf(st, tmp);
	} while (++i < arg->param.c);

	return SUCC;
}<commit_msg>small re-order<commit_after>/* cmd_buffer.c -- buffer manipulation commands */
#include <string.h>

#include "edna.h"
#include "buffer.h"
#include "cmd.h"
#include "state.h"

int
cmd_openbuf(State *st, Buffer buf, Arg *arg, char *error)
{
	Buffer tmp;
	size_t i;

	if (!arg->param.c) {
		strcpy(error, "no filenames provided");
		return FAIL;
	}

	i = 0;
	do {
		tmp = makebuf();
		initbuf(tmp, arg->param.v[i]);
		readbuf(tmp, error);
		bufclean(buf);
		addbuf(st, tmp);
	} while (++i < arg->param.c);

	return SUCC;
}

int
cmd_switchbuf(State *st, Buffer buf, Arg *arg, char *error)
{
	if (!arg->mode) {
		strcpy(error, "no option specified");
		return FAIL;

	} else if (!strcmp(arg->mode, "next")) {
		returnbuf(st, buf);
		checkoutbuf(buf, st, 0);

		return SUCC;

	} else if (!strcmp(arg->mode, "prev")) {
		returnbuf(st, buf);
		checkoutbuf(buf, st, (st->buffers.c != 1) ? st->buffers.c - 2 : 0 );

		return SUCC;
	}

	strcpy (error, "unknown option");
	return FAIL;
}
{'fraction_non_alphanumeric': 0.1883016931759877, 'fraction_numerical': 0.00513083632632119, 'mean_word_length': 3.7445255474452557, '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': '1717361', 'n_tokens_mistral': 848, 'n_tokens_neox': 786, 'n_words': 205}