<commit_before>/***************************************************************************
*
*     Copyright (c) 2002 by <NAME>
*           All Rights Reserved
*
*	Permission is granted to any individual or institution to use, copy, 
*  modify, or redistribute this file so long as it is not sold for profit, 
*  and that this copyright notice is retained.
*
***************************************************************************
*
*  This program translates all line-endings (DOS, UNIX or Mac) into DOS
*  style line endings.
*
*  Usage:   2dos file ...
*
*  Currently it does not accept wildcards (I use bash which does the 
*  wildcard expansion for me).
*
***************************************************************************/

#include <stdio.h>
#include <stdlib.h>

#define	TRUE	1
#define	FALSE	0

int main( int argc, char **argv )
{
	int		i;
	FILE	*src_fs;
	int		ch;
	int		foundCr;
    int     lfCount;
    int     crCount;
    int     crLfCount;
    int     crcrLfCount;
    int     otherCount;

	if ( argc < 2 )
	{
		fprintf( stderr, "Usage: CountLineEndings file ...\n" );
		exit( 1 );
	}

    printf( "    LF     CR   CRLF CRCRLF  Other FileName\n" );
    printf( "------ ------ ------ ------ ------ ---------------------------\n" );

    for ( i = 1; i < argc; i++ )
	{
		if (( src_fs = fopen( argv[ i ], "rb" )) == NULL )
		{
			fprintf( stderr, "Unable to open file %s\n", argv[ i ] );
			exit( 1 );
		}

        foundCr = 0;
        lfCount = 0;
        crCount = 0;
        crLfCount = 0;
        crcrLfCount = 0;
        otherCount = 0;

		while (( ch = fgetc( src_fs )) != EOF )
		{
            if ( ch == 0x0D )
            {
                foundCr++;
                continue;
            }

            if ( ch == 0x0A )
            {
                switch ( foundCr )
                {
                    case 0:     lfCount++;      break;
                    case 1:     crLfCount++;    break;
                    case 2:     crcrLfCount++;  break;
                    default:    otherCount++;   break;
                }

                foundCr = 0;
                continue;
            }

            if ( foundCr > 0 )
            {
                if ( foundCr == 1 )
                {
                    crCount++;
                }
                else
                {
                    otherCount++;
                }
            }
		}

		fclose(src_fs);

        printf( "%6d %6d %6d %6d %6d %s\n", lfCount, crCount, crLfCount, crcrLfCount, otherCount, argv[ i ] );
	}

	exit( 0 );
	return 0;
}

<commit_msg>Fixed a minor bug in the counting of CR terminated lines<commit_after>/***************************************************************************
*
*     Copyright (c) 2002 by <NAME>
*           All Rights Reserved
*
*	Permission is granted to any individual or institution to use, copy, 
*  modify, or redistribute this file so long as it is not sold for profit, 
*  and that this copyright notice is retained.
*
***************************************************************************
*
*  This program translates all line-endings (DOS, UNIX or Mac) into DOS
*  style line endings.
*
*  Usage:   2dos file ...
*
*  Currently it does not accept wildcards (I use bash which does the 
*  wildcard expansion for me).
*
***************************************************************************/

#include <stdio.h>
#include <stdlib.h>

#define	TRUE	1
#define	FALSE	0

int main( int argc, char **argv )
{
	int		i;
	FILE	*src_fs;
	int		ch;
	int		foundCr;
	int     lfCount;
	int     crCount;
	int     crLfCount;
	int     crcrLfCount;
	int     otherCount;

	if ( argc < 2 )
	{
		fprintf( stderr, "Usage: CountLineEndings file ...\n" );
		exit( 1 );
	}

	printf( "    LF     CR   CRLF CRCRLF  Other FileName\n" );
	printf( "------ ------ ------ ------ ------ ---------------------------\n" );

	for ( i = 1; i < argc; i++ )
	{
		if (( src_fs = fopen( argv[ i ], "rb" )) == NULL )
		{
			fprintf( stderr, "Unable to open file %s\n", argv[ i ] );
			exit( 1 );
		}

		foundCr = 0;
		lfCount = 0;
		crCount = 0;
		crLfCount = 0;
		crcrLfCount = 0;
		otherCount = 0;

		while (( ch = fgetc( src_fs )) != EOF )
		{
			if ( ch == 0x0D )
			{
				foundCr++;
				continue;
			}

			if ( ch == 0x0A )
			{
				switch ( foundCr )
				{
					case 0:     lfCount++;      break;
					case 1:     crLfCount++;    break;
					case 2:     crcrLfCount++;  break;
					default:    otherCount++;   break;
				}

				foundCr = 0;
				continue;
			}

			if ( foundCr > 0 )
			{
                crCount += foundCr;
                foundCr = 0;
			}
		}

		fclose(src_fs);

		printf( "%6d %6d %6d %6d %6d %s\n", lfCount, crCount, crLfCount, crcrLfCount, otherCount, argv[ i ] );
	}

	exit( 0 );
	return 0;
}


{'fraction_non_alphanumeric': 0.2142136079143953, 'fraction_numerical': 0.01372905309913184, 'mean_word_length': 1.562855664769788, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, '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': '816403', 'n_tokens_mistral': 1776, 'n_tokens_neox': 1539, 'n_words': 458}