Honor `progname:' entries in the user's profile.
Showing
1 changed file
with
33 additions
and
1 deletions
... | @@ -81,6 +81,9 @@ mh_argp_parse (int argc, char **argv, | ... | @@ -81,6 +81,9 @@ mh_argp_parse (int argc, char **argv, |
81 | program_invocation_short_name = p+1; | 81 | program_invocation_short_name = p+1; |
82 | else | 82 | else |
83 | program_invocation_short_name = program_invocation_name; | 83 | program_invocation_short_name = program_invocation_name; |
84 | |||
85 | mh_init (); | ||
86 | |||
84 | memset (&argp, 0, sizeof (argp)); | 87 | memset (&argp, 0, sizeof (argp)); |
85 | argp.options = option; | 88 | argp.options = option; |
86 | argp.parser = parse_opt; | 89 | argp.parser = parse_opt; |
... | @@ -89,7 +92,36 @@ mh_argp_parse (int argc, char **argv, | ... | @@ -89,7 +92,36 @@ mh_argp_parse (int argc, char **argv, |
89 | data.mh_option = mh_option; | 92 | data.mh_option = mh_option; |
90 | data.closure = closure; | 93 | data.closure = closure; |
91 | data.handler = handler; | 94 | data.handler = handler; |
92 | return argp_parse (&argp, argc, argv, 0, 0, &data); | 95 | |
96 | p = mh_profile_value (program_invocation_short_name, NULL); | ||
97 | if (p) | ||
98 | { | ||
99 | int _argc; | ||
100 | char **_argv; | ||
101 | int xargc; | ||
102 | char **xargv; | ||
103 | int i; | ||
104 | |||
105 | argcv_get (p, "", &xargc, &xargv); | ||
106 | |||
107 | _argc = argc + xargc; | ||
108 | _argv = calloc (_argc+1, sizeof *_argv); | ||
109 | if (!_argv) | ||
110 | { | ||
111 | mh_error ("not enough memory"); | ||
112 | abort (); | ||
113 | } | ||
114 | for (i = 0; i < argc; i++) | ||
115 | _argv[i] = argv[i]; | ||
116 | for (; i < _argc; i++) | ||
117 | _argv[i] = xargv[i-argc]; | ||
118 | _argv[i] = NULL; | ||
119 | argp_parse (&argp, _argc, _argv, 0, 0, &data); | ||
120 | free (_argv); | ||
121 | } | ||
122 | else | ||
123 | argp_parse (&argp, argc, argv, 0, 0, &data); | ||
124 | return 0; | ||
93 | } | 125 | } |
94 | 126 | ||
95 | void | 127 | void | ... | ... |
-
Please register or sign in to post a comment