<commit_before>
/*
 * termsbr.c -- termcap support
 *
 * This code is Copyright (c) 2002, by the authors of nmh.  See the
 * COPYRIGHT file in the root directory of the nmh distribution for
 * complete copyright information.
 */

#include <h/mh.h>
#include <h/utils.h>

#include <termios.h>
#include <sys/ioctl.h>

#include <curses.h>
#include <term.h>

#ifdef WINSIZE_IN_PTEM
# include <sys/stream.h>
# include <sys/ptem.h>
#endif

static int initLI = 0;
static int initCO = 0;

static int LI = 40;                /* number of lines                        */
static int CO = 80;                /* number of colums                       */
static char *ti_clear = NULL;      /* terminfo string to clear screen        */
static char *ti_standend = NULL;   /* terminfo string to end standout mode   */
static char *ti_standbegin = NULL; /* terminfo string to begin standout mode */
static int termstatus = 0;	   /* terminfo initialization status         */
static char *termcbuf = NULL;	   /* tputs() output buffer                  */
static char *termcbufp = NULL;	   /* tputs() output buffer pointer          */
static size_t termcbufsz = 0;	   /* Size of termcbuf                       */

static void initialize_terminfo(void);
static int termbytes(int);

/*
 * Initialize the terminfo library.
 */

static void
initialize_terminfo(void)
{
    int errret, rc;

    if (termstatus)
    	return;

    rc = setupterm(NULL, fileno(stdout), &errret);

    if (rc != 0 || errret != 1) {
    	termstatus = -1;
	return;
    } else {
    	termstatus = 1;
    }

    if (!initCO && (CO = tigetnum ("cols")) <= 0)
	CO = 80;
    if (!initLI && (LI = tigetnum ("lines")) <= 0)
	LI = 24;

    ti_clear = tigetstr ("clear");
    ti_standbegin = tigetstr ("smso");
    ti_standend = tigetstr ("rmso");
}


int
sc_width (void)
{
#ifdef TIOCGWINSZ
    struct winsize win;
    int width;

    if (ioctl (fileno (stderr), TIOCGWINSZ, &win) != NOTOK
	    && (width = win.ws_col) > 0) {
	CO = width;
	initCO++;
    } else
#endif /* TIOCGWINSZ */
	initialize_terminfo();

    return CO;
}


int
sc_length (void)
{
#ifdef TIOCGWINSZ
    struct winsize win;

    if (ioctl (fileno (stderr), TIOCGWINSZ, &win) != NOTOK
	    && (LI = win.ws_row) > 0)
	initLI++;
    else
#endif /* TIOCGWINSZ */
	initialize_terminfo();

    return LI;
}


static int
outc (int c)
{
    return putchar(c);
}


void
nmh_clear_screen (void)
{
    initialize_terminfo ();

    if (clear)
	tputs (ti_clear, LI, outc);
    else {
	printf ("\f");
    }

    fflush (stdout);
}

<commit_msg>Sigh.  Fix up missing conversion from clear->ti_clear.<commit_after>
/*
 * termsbr.c -- termcap support
 *
 * This code is Copyright (c) 2002, by the authors of nmh.  See the
 * COPYRIGHT file in the root directory of the nmh distribution for
 * complete copyright information.
 */

#include <h/mh.h>
#include <h/utils.h>

#include <termios.h>
#include <sys/ioctl.h>

#include <curses.h>
#include <term.h>

#ifdef WINSIZE_IN_PTEM
# include <sys/stream.h>
# include <sys/ptem.h>
#endif

static int initLI = 0;
static int initCO = 0;

static int LI = 40;                /* number of lines                        */
static int CO = 80;                /* number of colums                       */
static char *ti_clear = NULL;      /* terminfo string to clear screen        */
static char *ti_standend = NULL;   /* terminfo string to end standout mode   */
static char *ti_standbegin = NULL; /* terminfo string to begin standout mode */
static int termstatus = 0;	   /* terminfo initialization status         */
static char *termcbuf = NULL;	   /* tputs() output buffer                  */
static char *termcbufp = NULL;	   /* tputs() output buffer pointer          */
static size_t termcbufsz = 0;	   /* Size of termcbuf                       */

static void initialize_terminfo(void);
static int termbytes(int);

/*
 * Initialize the terminfo library.
 */

static void
initialize_terminfo(void)
{
    int errret, rc;

    if (termstatus)
    	return;

    rc = setupterm(NULL, fileno(stdout), &errret);

    if (rc != 0 || errret != 1) {
    	termstatus = -1;
	return;
    } else {
    	termstatus = 1;
    }

    if (!initCO && (CO = tigetnum ("cols")) <= 0)
	CO = 80;
    if (!initLI && (LI = tigetnum ("lines")) <= 0)
	LI = 24;

    ti_clear = tigetstr ("clear");
    ti_standbegin = tigetstr ("smso");
    ti_standend = tigetstr ("rmso");
}


int
sc_width (void)
{
#ifdef TIOCGWINSZ
    struct winsize win;
    int width;

    if (ioctl (fileno (stderr), TIOCGWINSZ, &win) != NOTOK
	    && (width = win.ws_col) > 0) {
	CO = width;
	initCO++;
    } else
#endif /* TIOCGWINSZ */
	initialize_terminfo();

    return CO;
}


int
sc_length (void)
{
#ifdef TIOCGWINSZ
    struct winsize win;

    if (ioctl (fileno (stderr), TIOCGWINSZ, &win) != NOTOK
	    && (LI = win.ws_row) > 0)
	initLI++;
    else
#endif /* TIOCGWINSZ */
	initialize_terminfo();

    return LI;
}


static int
outc (int c)
{
    return putchar(c);
}


void
nmh_clear_screen (void)
{
    initialize_terminfo ();

    if (ti_clear)
	tputs (ti_clear, LI, outc);
    else {
	printf ("\f");
    }

    fflush (stdout);
}


{'fraction_non_alphanumeric': 0.13070620366757707, 'fraction_numerical': 0.009364026531408505, 'mean_word_length': 2.434025452109846, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 24, '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': '3985306', 'n_tokens_mistral': 1878, 'n_tokens_neox': 1772, 'n_words': 536}