<commit_before>/*
 * lsort - re-sort groupinfo files from versions prior to 1.9.3
 *
 * Written by <NAME> <<EMAIL>>
 * (C) Copyright 1999
 *
 * See file COPYING for restrictions on the use of this software.
 */

#include "leafnode.h"
#include "critmem.h"

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

int verbose = 0;
int debug = 0;

static int
comp(const void *a, const void *b)
{
    return strcasecmp(*(const char **)a, *(const char **)b);
}

int
main(void)
{
    char *l;
    char path[PATH_MAX];
    char **act;
    unsigned long acount = 0;
    unsigned long i;
    FILE *f;

    strcpy(path, spooldir);
    strcat(path, "/leaf.node/groupinfo.old");

    f = fopen(path, "r");
    if (f == NULL) {
	fprintf(stderr, "Error: Can't open groupinfo.old!\n");
	exit(1);
    }

    act = (char **)critmalloc(sizeof(char *),
			      "Allocating space for active file");

    while ((l = getaline(f))) {
	act = (char **)realloc(act, (acount + 1) * sizeof(char *));
	if (act == NULL) {
	    fprintf(stderr, "realloc returned NULL\n");
	    exit(1);
	}
	act[acount] = strdup(l);
	acount++;
    }
    fclose(f);

    qsort(act, acount, sizeof(char *), &comp);

    for (i = 0; i < acount; i++)
	printf("%s\n", act[i]);

    return 0;
}<commit_msg>Fixes for type bugs and memory leaks found by Ralf Wildenhues.<commit_after>/*
 * lsort - re-sort groupinfo files from versions prior to 1.9.3
 *
 * Written by <NAME> <<EMAIL>>
 * (C) Copyright 1999
 *
 * See file COPYING for restrictions on the use of this software.
 */

#include "leafnode.h"
#include "critmem.h"

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

int verbose = 0;
int debug = 0;

static int
comp(const void *a, const void *b)
{
    return strcasecmp(*(const char **)a, *(const char **)b);
}

int
main(void)
{
    char *l;
    char path[PATH_MAX];
    char **act;
    size_t acount = 0;
    size_t i;
    FILE *f;

    strcpy(path, spooldir);
    strcat(path, "/leaf.node/groupinfo.old");

    f = fopen(path, "r");
    if (f == NULL) {
	fprintf(stderr, "Error: Can't open groupinfo.old!\n");
	exit(1);
    }

    act = (char **)critmalloc(sizeof(char *),
			      "Allocating space for active file");

    while ((l = getaline(f))) {
	act = (char **)realloc(act, (acount + 1) * sizeof(char *));
	if (act == NULL) {
	    fprintf(stderr, "realloc returned NULL\n");
	    exit(1);
	}
	act[acount] = strdup(l);
	acount++;
    }
    (void)fclose(f);

    qsort(act, acount, sizeof(char *), &comp);

    for (i = 0; i < acount; i++)
	printf("%s\n", act[i]);

    free(act);
    return 0;
}
{'fraction_non_alphanumeric': 0.177431906614786, 'fraction_numerical': 0.011673151750972763, 'mean_word_length': 3.036106750392465, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, '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': '2151405', 'n_tokens_mistral': 1027, 'n_tokens_neox': 970, 'n_words': 279}