<commit_before>#include "posix_config.h"

#include <sys/types.h>
#include <sys/stat.h>

#include <err.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

/*
 * Print compile time value of named constants.
 */

static const struct {
  enum number_type_t {
    SIGNED_LONG,
    UNSIGNED_LONG
  } number_type;
  union number_t {
    long lo;
    unsigned long ulo;
  } number;
  const char *name;
} constants[] = {
  { SIGNED_LONG,   { PATH_MAX           }, "PATH_MAX" },
  { SIGNED_LONG,   { _SC_LOGIN_NAME_MAX }, "LOGIN_NAME_MAX" },

  { UNSIGNED_LONG, { S_IRUSR }, "S_IRUSR" },
  { UNSIGNED_LONG, { S_IWUSR }, "S_IWUSR" },
  { UNSIGNED_LONG, { S_IXUSR }, "S_IXUSR" },
  { UNSIGNED_LONG, { S_IRGRP }, "S_IRGRP" },
  { UNSIGNED_LONG, { S_IWGRP }, "S_IWGRP" },
  { UNSIGNED_LONG, { S_IXGRP }, "S_IXGRP" },
  { UNSIGNED_LONG, { S_IROTH }, "S_IROTH" },
  { UNSIGNED_LONG, { S_IWOTH }, "S_IWOTH" },
  { UNSIGNED_LONG, { S_IXOTH }, "S_IXOTH" },
  { UNSIGNED_LONG, { S_ISUID }, "S_ISUID" },
  { UNSIGNED_LONG, { S_ISGID }, "S_ISGID" },
};
const unsigned int constants_size = sizeof (constants) / sizeof (constants [0]);

int
main (int argc, char *argv[])
{
  unsigned int index;
  unsigned int exit_code = EXIT_FAILURE;

  if (argc < 2) return EXIT_FAILURE;

  for (index = 0; index < constants_size; ++index) {
    if (strcmp (constants [index].name, argv [1]) == 0) {
      switch (constants [index].number_type) {
        case SIGNED_LONG: (void) printf ("%ld", constants [index].number.lo); break;
        case UNSIGNED_LONG: (void) printf ("%lu", constants [index].number.ulo); break;
      }
      exit_code = EXIT_SUCCESS;
    }
  }

  (void) fflush (NULL);

  if (exit_code != EXIT_SUCCESS) {
    errx (EXIT_FAILURE, "could not determine value of %s", argv[1]);
  } else {
    exit (EXIT_SUCCESS);
  }

  /*@notreached@*/
  return 0;
}
<commit_msg>Add note about strange use of LINE_MAX.<commit_after>#include "posix_config.h"

#include <sys/types.h>
#include <sys/stat.h>

#include <err.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

/*
 * Print compile time value of named constants.
 */

static const struct {
  enum number_type_t {
    SIGNED_LONG,
    UNSIGNED_LONG
  } number_type;
  union number_t {
    long lo;
    unsigned long ulo;
  } number;
  const char *name;
} constants[] = {
  { SIGNED_LONG,   { PATH_MAX }, "PATH_MAX" },

  /* XXX: Platforms rarely provide a compile-time constant for this.
   *      However, the constant is used in these bindings to specify
   *      a buffer size for getpwnam_r which corresponds directly to
   *      the length of a single line in /etc/passwd.
   */

  { SIGNED_LONG,   { LINE_MAX }, "LOGIN_NAME_MAX" },

  { UNSIGNED_LONG, { S_IRUSR }, "S_IRUSR" },
  { UNSIGNED_LONG, { S_IWUSR }, "S_IWUSR" },
  { UNSIGNED_LONG, { S_IXUSR }, "S_IXUSR" },
  { UNSIGNED_LONG, { S_IRGRP }, "S_IRGRP" },
  { UNSIGNED_LONG, { S_IWGRP }, "S_IWGRP" },
  { UNSIGNED_LONG, { S_IXGRP }, "S_IXGRP" },
  { UNSIGNED_LONG, { S_IROTH }, "S_IROTH" },
  { UNSIGNED_LONG, { S_IWOTH }, "S_IWOTH" },
  { UNSIGNED_LONG, { S_IXOTH }, "S_IXOTH" },
  { UNSIGNED_LONG, { S_ISUID }, "S_ISUID" },
  { UNSIGNED_LONG, { S_ISGID }, "S_ISGID" },
};
const unsigned int constants_size = sizeof (constants) / sizeof (constants [0]);

int
main (int argc, char *argv[])
{
  unsigned int index;
  unsigned int exit_code = EXIT_FAILURE;

  if (argc < 2) return EXIT_FAILURE;

  for (index = 0; index < constants_size; ++index) {
    if (strcmp (constants [index].name, argv [1]) == 0) {
      switch (constants [index].number_type) {
        case SIGNED_LONG: (void) printf ("%ld", constants [index].number.lo); break;
        case UNSIGNED_LONG: (void) printf ("%lu", constants [index].number.ulo); break;
      }
      exit_code = EXIT_SUCCESS;
    }
  }

  (void) fflush (NULL);

  if (exit_code != EXIT_SUCCESS) {
    errx (EXIT_FAILURE, "could not determine value of %s", argv[1]);
  } else {
    exit (EXIT_SUCCESS);
  }

  /*@notreached@*/
  return 0;
}

{'fraction_non_alphanumeric': 0.15246746869629266, 'fraction_numerical': 0.003437269825681316, 'mean_word_length': 3.394822006472492, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 19, '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': '7002363', 'n_tokens_mistral': 1673, 'n_tokens_neox': 1605, 'n_words': 374}