<commit_before>#include <stdlib.h>

#include "timing.h"
#include "pickopt.h"
#include "sift_anatomy_20141201/lib_sift_anatomy.h"
#include "gdal.h"
#include "cpl_conv.h"


void print_help(char *v[])
{
    fprintf(stderr, "usage:\n\t%s file.tif x y w h [-o file] [--max-nb-pts n]"
    //                          0 1        2 3 4 5
            " [-b] [--verbose] [--thresh-dog t (0.0133)]"
            " [--scale-space-noct n (8)] [--scale-space-nspo n (3)]\n", *v);
}


int main(int c, char *v[]) {
    // process input arguments
    if (c < 2) {
        print_help(v);
        return 1;
    }

    // optional arguments
    const char *output_file = pick_option(&c, &v, "o", "stdout");
    bool binary = (bool) pick_option(&c, &v, "b", NULL);
    bool verbose = (bool) pick_option(&c, &v, "-verbose", NULL);
    int max_nb_pts = atoi(pick_option(&c, &v, "-max-nb-pts", "INT_MAX"));
    float thresh_dog = (float) atof(pick_option(&c, &v, "-thresh-dog", "0.0133"));
    int ss_noct = atoi(pick_option(&c, &v, "-scale-space-noct", "8"));
    int ss_nspo = atoi(pick_option(&c, &v, "-scale-space-nspo", "3"));

    // initialise time
    struct timespec ts;
    portable_gettime(&ts);

    // define the rectangular region of interest (roi)
    int x, y, w, h;
    if (c == 6) {
        x = atoi(v[2]);
        y = atoi(v[3]);
        w = atoi(v[4]);
        h = atoi(v[5]);
    } else {
        print_help(v);
        return 1;
    }

    // open the input image
    GDALAllRegister();
    GDALDatasetH hDataset = GDALOpen(v[1], GA_ReadOnly);
    if (hDataset == NULL) {
        fprintf(stderr, "ERROR: can't open %s\n", v[1]);
        return 1;
    }

    // clip roi to stay inside the image boundaries
    if (x < 0) {
        x = 0;
        w += x;
    }
    if (y < 0) {
        y = 0;
        h += y;
    }
    int size_x = GDALGetRasterXSize(hDataset);
    int size_y = GDALGetRasterYSize(hDataset);
    if (x + w > size_x)
        w = size_x - x;
    if (y + h > size_y)
        h = size_y - y;
    if (w <= 0 || h <= 0) {
        fprintf(stderr, "WARNING: empty roi\n");
        return 0;
    }

    // read roi
    GDALRasterBandH hBand = GDALGetRasterBand(hDataset, 1);
    float *roi = (float *) CPLMalloc(sizeof(float)*w*h);<commit_msg>[sift] fix error pointed out by cpalmann<commit_after>#include <stdlib.h>

#include "timing.h"
#include "pickopt.h"
#include "sift_anatomy_20141201/lib_sift_anatomy.h"
#include "gdal.h"
#include "cpl_conv.h"


void print_help(char *v[])
{
    fprintf(stderr, "usage:\n\t%s file.tif x y w h [-o file] [--max-nb-pts n]"
    //                          0 1        2 3 4 5
            " [-b] [--verbose] [--thresh-dog t (0.0133)]"
            " [--scale-space-noct n (8)] [--scale-space-nspo n (3)]\n", *v);
}


int main(int c, char *v[]) {
    // process input arguments
    if (c < 2) {
        print_help(v);
        return 1;
    }

    // optional arguments
    const char *output_file = pick_option(&c, &v, "o", "/dev/stdout");
    bool binary = (bool) pick_option(&c, &v, "b", NULL);
    bool verbose = (bool) pick_option(&c, &v, "-verbose", NULL);
    int max_nb_pts = atoi(pick_option(&c, &v, "-max-nb-pts", "INT_MAX"));
    float thresh_dog = (float) atof(pick_option(&c, &v, "-thresh-dog", "0.0133"));
    int ss_noct = atoi(pick_option(&c, &v, "-scale-space-noct", "8"));
    int ss_nspo = atoi(pick_option(&c, &v, "-scale-space-nspo", "3"));

    // initialise time
    struct timespec ts;
    portable_gettime(&ts);

    // define the rectangular region of interest (roi)
    int x, y, w, h;
    if (c == 6) {
        x = atoi(v[2]);
        y = atoi(v[3]);
        w = atoi(v[4]);
        h = atoi(v[5]);
    } else {
        print_help(v);
        return 1;
    }

    // open the input image
    GDALAllRegister();
    GDALDatasetH hDataset = GDALOpen(v[1], GA_ReadOnly);
    if (hDataset == NULL) {
        fprintf(stderr, "ERROR: can't open %s\n", v[1]);
        return 1;
    }

    // clip roi to stay inside the image boundaries
    if (x < 0) {
        w += x;
        x = 0;
    }
    if (y < 0) {
        h += y;
        y = 0;
    }
    int size_x = GDALGetRasterXSize(hDataset);
    int size_y = GDALGetRasterYSize(hDataset);
    if (x + w > size_x)
        w = size_x - x;
    if (y + h > size_y)
        h = size_y - y;
    if (w <= 0 || h <= 0) {
        fprintf(stderr, "WARNING: empty roi\n");
        return 0;
    }

    // read roi
    GDALRasterBandH hBand = GDALGetRasterBand(hDataset, 1);
    float *roi = (float *) CPLMalloc(sizeof(float)*w*h);
{'fraction_non_alphanumeric': 0.17543084401237297, 'fraction_numerical': 0.0207688908528502, 'mean_word_length': 2.124223602484472, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3989885', 'n_tokens_mistral': 1828, 'n_tokens_neox': 1770, 'n_words': 449}