[LIB]: Allow passing a NULL argp to cus__loadfl

For tools such as pdwtags, that don't have any further options.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
This commit is contained in:
Arnaldo Carvalho de Melo 2007-03-30 13:54:14 -03:00
parent cd07fdbaf0
commit df2a515d4f
2 changed files with 14 additions and 6 deletions

View File

@ -3314,13 +3314,17 @@ int cus__loadfl(struct cus *self, struct argp *argp, int argc, char *argv[],
Dwfl *dwfl = NULL;
Dwarf_Die *cu_die = NULL;
Dwarf_Addr dwbias;
const struct argp_child argp_children[] = {
{ .argp = dwfl_standard_argp(), },
{ .argp = NULL }
};
argp->children = argp_children;
argp_parse(argp, argc, argv, 0, remaining, &dwfl);
if (argp != NULL) {
const struct argp_child argp_children[] = {
{ .argp = dwfl_standard_argp(), },
{ .argp = NULL }
};
argp->children = argp_children;
argp_parse(argp, argc, argv, 0, remaining, &dwfl);
} else
argp_parse(dwfl_standard_argp(), argc, argv, 0, remaining, &dwfl);
if (dwfl == NULL)
return -1;

View File

@ -17,6 +17,8 @@
#include "list.h"
struct argp;
#ifndef __unused
#define __unused __attribute__ ((unused))
#endif
@ -285,6 +287,8 @@ extern size_t lexblock__fprintf(const struct lexblock *self,
extern struct cus *cus__new(struct list_head *definitions,
struct list_head *fwd_decls);
extern int cus__loadfl(struct cus *self, struct argp *argp,
int argc, char *argv[], int *remaining);
extern int cus__load(struct cus *self, const char *filename);
extern int cus__load_dir(struct cus *self, const char *dirname,
const char *filename_mask, const int recursive);