Ejemplo n.º 1
0
int
main (int argc, const char *const *argv)
{
    const char *cp;
    enum backup_type backup_type = no_backups;

    program_name = (char *) argv[0];

    if (argc > 2)
    {
        fprintf (stderr, "Usage: %s [VERSION_CONTROL]\n", program_name);
        exit (1);
    }

    if ((cp = getenv ("VERSION_CONTROL")))
        backup_type = XARGMATCH ("$VERSION_CONTROL", cp,
                                 backup_args, backup_vals);

    if (argc == 2)
        backup_type = XARGMATCH (program_name, argv[1],
                                 backup_args, backup_vals);

    printf ("The version control is '%s'\n",
            ARGMATCH_TO_ARGUMENT (backup_type, backup_args, backup_vals));

    return 0;
}
Ejemplo n.º 2
0
void
warning_argmatch (char const *arg, size_t no, size_t err)
{
  int value = XARGMATCH ("--warning", arg + no + err,
                         warnings_args, warnings_types);

  /* -Wnone == -Wno-everything, and -Wno-none == -Weverything.  */
  if (!value)
    {
      value = Weverything;
      no = !no;
    }

  size_t b;
  for (b = 0; b < warnings_size; ++b)
    if (value & 1 << b)
      {
        if (err && no)
          /* -Wno-error=foo.  */
          errority_flag[b] = errority_disabled;
        else if (err && !no)
          {
            /* -Werror=foo: enables -Wfoo. */
            errority_flag[b] = errority_enabled;
            warnings_flag[b] = severity_warning;
          }
        else if (no)
          /* -Wno-foo.  */
          warnings_flag[b] = severity_disabled;
        else
          /* -Wfoo. */
          warnings_flag[b] = severity_warning;
      }
}
Ejemplo n.º 3
0
enum backup_type
get_version (char const *context, char const *version)
{
  if (version == 0 || *version == 0)
    return numbered_existing_backups;
  else
    return XARGMATCH (context, version, backup_args, backup_types);
}
Ejemplo n.º 4
0
int
main (int argc, char **argv)
{
  int exclude_options = 0;
  struct exclude *exclude = new_exclude ();

  set_program_name (argv[0]);

  if (argc == 1)
    error (1, 0, "usage: %s file -- words...", argv[0]);

  while (--argc)
    {
      char *opt = *++argv;
      if (opt[0] == '-')
        {
          int neg = 0;
          int flag;
          char *s = opt + 1;

          if (opt[1] == '-' && opt[2] == 0)
            {
              argc--;
              break;
            }
          if (strlen (s) > 3 && memcmp (s, "no-", 3) == 0)
            {
              neg = 1;
              s += 3;
            }
          flag = XARGMATCH (opt, s, exclude_keywords, exclude_flags);
          if (neg)
            exclude_options &= ~flag;
          else
            exclude_options |= flag;
        }
      else if (add_exclude_file (add_exclude, exclude, opt,
                                 exclude_options, '\n') != 0)
        error (1, errno, "error loading %s", opt);
    }

  for (; argc; --argc)
    {
      char *word = *++argv;

      printf ("%s: %d\n", word, excluded_file_name (exclude, word));
    }
  return 0;
}
Ejemplo n.º 5
0
void
set_warning_option (const char *arg)
{
  int negate = 0;
  int option;

  if (strcmp (arg, "none") == 0)
    {
      warning_option = 0;
      return;
    }
  if (strlen (arg) > 2 && memcmp (arg, "no-", 3) == 0)
    {
      negate = 1;
      arg += 3;
    }

  option = XARGMATCH ("--warning", arg,
		      warning_args, warning_types);
  if (negate)
    warning_option &= ~option;
  else
    warning_option |= option;
}