mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-01-06 12:09:26 +08:00
d5d6fca504
* ada-lang.c (find_struct_field): Initialize *byte_offset_p. * breakpoint.c (do_enable_breakpoint): Ignore both mem_cnt and i. * c-typeprint.c (c_type_print_varspec_suffix): Don't test length greater than or equal to zero. * m2-typeprint.c (m2_array): Likewise. * p-typeprint.c (pascal_type_print_varspec_prefix): Likewise. * gdbtypes.c (copy_type_recursive): Correct == typo. * i386-tdep.c (i386_skip_prologue): Remove stray semicolon. * linux-nat.c (linux_nat_info_proc_cmd): Don't compare a pointer greater than zero. * macroscope.c (sal_macro_scope): Don't name a local variable "main". (default_macro_scope): Remove unused variable. * prologue-value.h (pv_area_find_reg): Don't name an argument "register". * remote-fileio.c (remote_fio_func_map): Add missing braces. * remote.c (sigint_remote_twice_token, sigint_remote_token): Change type. (cleanup_sigint_signal_handler): Remove casts. * valprint.c (val_print): Use a volatile local for the modified argument. * varobj.c (languages): Remove extra array dimension. (varobj_create): Correct access to languages array. * mi/mi-cmd-break.c (mi_cmd_break_insert, mi_cmd_break_watch): Add missing braces. * mi/mi-cmd-disas.c (mi_cmd_disassemble): Likewise. * mi/mi-cmd-env.c (mi_cmd_env_path, mi_cmd_env_dir): Likewise. * mi/mi-getopt.c (mi_valid_noargs): Likewise. * mi/mi-main.c (mi_cmd_data_read_memory): Likewise. (mi_cmd_data_write_memory): Likewise. * signals/signals.c (target_signal_to_string): Cast to int before comparing. * tui/tui-layout.c (init_and_make_win): Take and return a void *. Update all callers.
93 lines
2.3 KiB
C
93 lines
2.3 KiB
C
/* MI Command Set - MI Option Parser.
|
|
Copyright (C) 2000, 2001 Free Software Foundation, Inc.
|
|
Contributed by Cygnus Solutions (a Red Hat company).
|
|
|
|
This file is part of GDB.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
Boston, MA 02110-1301, USA. */
|
|
|
|
#include "defs.h"
|
|
#include "mi-getopt.h"
|
|
#include "gdb_string.h"
|
|
|
|
int
|
|
mi_getopt (const char *prefix,
|
|
int argc, char **argv,
|
|
struct mi_opt *opts,
|
|
int *optind, char **optarg)
|
|
{
|
|
char *arg;
|
|
struct mi_opt *opt;
|
|
/* We assume that argv/argc are ok. */
|
|
if (*optind > argc || *optind < 0)
|
|
internal_error (__FILE__, __LINE__,
|
|
_("mi_getopt_long: optind out of bounds"));
|
|
if (*optind == argc)
|
|
return -1;
|
|
arg = argv[*optind];
|
|
/* ``--''? */
|
|
if (strcmp (arg, "--") == 0)
|
|
{
|
|
*optind += 1;
|
|
*optarg = NULL;
|
|
return -1;
|
|
}
|
|
/* End of option list. */
|
|
if (arg[0] != '-')
|
|
{
|
|
*optarg = NULL;
|
|
return -1;
|
|
}
|
|
/* Look the option up. */
|
|
for (opt = opts; opt->name != NULL; opt++)
|
|
{
|
|
if (strcmp (opt->name, arg + 1) != 0)
|
|
continue;
|
|
if (opt->arg_p)
|
|
{
|
|
/* A non-simple optarg option. */
|
|
if (argc < *optind + 2)
|
|
error (_("%s: Option %s requires an argument"), prefix, arg);
|
|
*optarg = argv[(*optind) + 1];
|
|
*optind = (*optind) + 2;
|
|
return opt->index;
|
|
}
|
|
else
|
|
{
|
|
*optarg = NULL;
|
|
*optind = (*optind) + 1;
|
|
return opt->index;
|
|
}
|
|
}
|
|
error (_("%s: Unknown option ``%s''"), prefix, arg + 1);
|
|
}
|
|
|
|
int
|
|
mi_valid_noargs (const char *prefix, int argc, char **argv)
|
|
{
|
|
int optind = 0;
|
|
char *optarg;
|
|
static struct mi_opt opts[] =
|
|
{
|
|
{ 0, 0, 0 }
|
|
};
|
|
|
|
if (mi_getopt (prefix, argc, argv, opts, &optind, &optarg) == -1)
|
|
return 1;
|
|
else
|
|
return 0;
|
|
}
|