<commit_before>/* $Id$
 * $Log$
 * Revision 1.17  1994/07/26 09:00:46  mjl
 * Added a quick fix so that hitting a carriage return when prompted for
 * a filename no longer aborts the program.  Contributed by <NAME>.
 *
 * Revision 1.16  1994/06/30  18:22:17  mjl
 * All core source files: made another pass to eliminate warnings when using
 * gcc -Wall.  Lots of cleaning up: got rid of includes of math.h or string.h
 * (now included by plplot.h), and other minor changes.  Now each file has
 * global access to the plstream pointer via extern; many accessor functions
 * eliminated as a result.
 *
 * Revision 1.15  1994/05/10  21:52:45  mjl
 * Put in a slight optimization in cmap1 color interpolation.
 *
 * Revision 1.14  1994/04/30  16:15:13  mjl
 * Fixed format field (%ld instead of %d) or introduced casts where
 * appropriate to eliminate warnings given by gcc -Wall.
 *
 * Revision 1.13  1994/03/23  08:32:34  mjl
 * Moved color and color map handling functions into plctrl.c.
 * Changed file open routine to support new options for sequencing family
 * member files.
 *
 * Revision 1.12  1994/01/15  17:28:59  mjl
 * Added include of pdf.h.
*/

/*	plstream.c

	Stream & device support functions.
*/

#include "plplotP.h"

/*----------------------------------------------------------------------*\
 * plcol_interp()
 *
 * Initializes device cmap 1 entry by interpolation from pls->cmap1
 * entries.  Returned PLColor is supposed to represent the i_th color
 * out of a total of ncol colors in the current color scheme.
\*----------------------------------------------------------------------*/

void
plcol_interp(PLStream *pls, PLColor *newcolor, int i, int ncol)
{
    float x, delta;
    int il, ir;

    x = (double) (i * (pls->ncol1-1)) / (double) (ncol-1);
    il = x;
    ir = il + 1;
    delta = x - il;

    if (ir > pls->ncol1 || il < 0)
	fprintf(stderr, "Invalid color\n");

    else if (ir == pls->ncol1 || (delta == 0.)) {
	newcolor->r = pls->cmap1[il].r;
	newcolor->g = pls->cmap1[il].g;
	newcolor->b = pls->cmap1[il].b;
    }
    else {
	newcolor->r = (1.-delta) * pls->cmap1[il].r + delta * pls->cmap1[ir].r;
	newcolor->g = (1.-delta) * pls->cmap1[il].g + delta * pls->cmap1[ir].g;
	newcolor->b = (1.-delta) * pls->cmap1[il].b + delta * pls->cmap1[ir].b;
    }
}

/*----------------------------------------------------------------------*\
 * plOpenFile()
 *
 * Opens file for output, prompting if not set.
 * Prints extra newline at end to make output look better in batch runs.
 * A file name of "-" indicates output to stdout.
\*----------------------------------------------------------------------*/

#define MAX_NUM_TRIES	10
void
plOpenFile(PLStream *pls)
{
    int count = 0;
    size_t len;
    char line[256];

    while (pls->OutFile == NULL) {<commit_msg>Added missing variable declaration and initializer.<commit_after>/* $Id$
 * $Log$
 * Revision 1.18  1994/07/26 18:17:24  mjl
 * Added missing variable declaration and initializer.
 *
 * Revision 1.17  1994/07/26  09:00:46  mjl
 * Added a quick fix so that hitting a carriage return when prompted for
 * a filename no longer aborts the program.  Contributed by <NAME>.
 *
 * Revision 1.16  1994/06/30  18:22:17  mjl
 * All core source files: made another pass to eliminate warnings when using
 * gcc -Wall.  Lots of cleaning up: got rid of includes of math.h or string.h
 * (now included by plplot.h), and other minor changes.  Now each file has
 * global access to the plstream pointer via extern; many accessor functions
 * eliminated as a result.
 *
 * Revision 1.15  1994/05/10  21:52:45  mjl
 * Put in a slight optimization in cmap1 color interpolation.
 *
 * Revision 1.14  1994/04/30  16:15:13  mjl
 * Fixed format field (%ld instead of %d) or introduced casts where
 * appropriate to eliminate warnings given by gcc -Wall.
 *
 * Revision 1.13  1994/03/23  08:32:34  mjl
 * Moved color and color map handling functions into plctrl.c.
 * Changed file open routine to support new options for sequencing family
 * member files.
 *
 * Revision 1.12  1994/01/15  17:28:59  mjl
 * Added include of pdf.h.
*/

/*	plstream.c

	Stream & device support functions.
*/

#include "plplotP.h"

/*----------------------------------------------------------------------*\
 * plcol_interp()
 *
 * Initializes device cmap 1 entry by interpolation from pls->cmap1
 * entries.  Returned PLColor is supposed to represent the i_th color
 * out of a total of ncol colors in the current color scheme.
\*----------------------------------------------------------------------*/

void
plcol_interp(PLStream *pls, PLColor *newcolor, int i, int ncol)
{
    float x, delta;
    int il, ir;

    x = (double) (i * (pls->ncol1-1)) / (double) (ncol-1);
    il = x;
    ir = il + 1;
    delta = x - il;

    if (ir > pls->ncol1 || il < 0)
	fprintf(stderr, "Invalid color\n");

    else if (ir == pls->ncol1 || (delta == 0.)) {
	newcolor->r = pls->cmap1[il].r;
	newcolor->g = pls->cmap1[il].g;
	newcolor->b = pls->cmap1[il].b;
    }
    else {
	newcolor->r = (1.-delta) * pls->cmap1[il].r + delta * pls->cmap1[ir].r;
	newcolor->g = (1.-delta) * pls->cmap1[il].g + delta * pls->cmap1[ir].g;
	newcolor->b = (1.-delta) * pls->cmap1[il].b + delta * pls->cmap1[ir].b;
    }
}

/*----------------------------------------------------------------------*\
 * plOpenFile()
 *
 * Opens file for output, prompting if not set.
 * Prints extra newline at end to make output look better in batch runs.
 * A file name of "-" indicates output to stdout.
\*----------------------------------------------------------------------*/

#define MAX_NUM_TRIES	10
void
plOpenFile(PLStream *pls)
{
    int i = 0, count = 0;
    size_t len;
    char line[256];

    while (pls->OutFile == NULL) {
{'fraction_non_alphanumeric': 0.21399895269680572, 'fraction_numerical': 0.04887414906615465, 'mean_word_length': 2.0939524838012957, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 47, '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': '177248', 'n_tokens_mistral': 2060, 'n_tokens_neox': 1866, 'n_words': 644}