2 * winutils.c: miscellaneous Windows utilities for GUI apps
13 /* Definitions to allow this module to be compiled standalone for testing
14 * split_into_argv(). */
15 #define smalloc malloc
16 #define srealloc realloc
21 * GetOpenFileName/GetSaveFileName tend to muck around with the process'
22 * working directory on at least some versions of Windows.
23 * Here's a wrapper that gives more control over this, and hides a little
24 * bit of other grottiness.
32 * `of' is expected to be initialised with most interesting fields, but
33 * this function does some administrivia. (assume `of' was memset to 0)
34 * save==1 -> GetSaveFileName; save==0 -> GetOpenFileName
35 * `state' is optional.
37 BOOL
request_file(filereq
*state
, OPENFILENAME
*of
, int preserve
, int save
)
39 TCHAR cwd
[MAX_PATH
]; /* process CWD */
44 DWORD r
= GetCurrentDirectory(lenof(cwd
), cwd
);
45 if (r
== 0 || r
>= lenof(cwd
))
46 /* Didn't work, oh well. Stop trying to be clever. */
50 /* Open the file requester, maybe setting lpstrInitialDir */
52 #ifdef OPENFILENAME_SIZE_VERSION_400
53 of
->lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
55 of
->lStructSize
= sizeof(*of
);
57 of
->lpstrInitialDir
= (state
&& state
->cwd
[0]) ? state
->cwd
: NULL
;
58 /* Actually put up the requester. */
59 ret
= save ?
GetSaveFileName(of
) : GetOpenFileName(of
);
62 /* Get CWD left by requester */
64 DWORD r
= GetCurrentDirectory(lenof(state
->cwd
), state
->cwd
);
65 if (r
== 0 || r
>= lenof(state
->cwd
))
66 /* Didn't work, oh well. */
70 /* Restore process CWD */
72 /* If it fails, there's not much we can do. */
73 (void) SetCurrentDirectory(cwd
);
78 filereq
*filereq_new(void)
80 filereq
*ret
= snew(filereq
);
85 void filereq_free(filereq
*state
)
91 * Message box with optional context help.
94 /* Callback function to launch context help. */
95 static VOID CALLBACK
message_box_help_callback(LPHELPINFO lpHelpInfo
)
98 #define CHECK_CTX(name) \
100 if (lpHelpInfo->dwContextId == WINHELP_CTXID_ ## name) \
101 context = WINHELP_CTX_ ## name; \
103 CHECK_CTX(errors_hostkey_absent
);
104 CHECK_CTX(errors_hostkey_changed
);
105 CHECK_CTX(errors_cantloadkey
);
106 CHECK_CTX(option_cleanup
);
107 CHECK_CTX(pgp_fingerprints
);
110 launch_help(hwnd
, context
);
113 int message_box(LPCTSTR text
, LPCTSTR caption
, DWORD style
, DWORD helpctxid
)
118 * We use MessageBoxIndirect() because it allows us to specify a
119 * callback function for the Help button.
121 mbox
.cbSize
= sizeof(mbox
);
122 /* Assumes the globals `hinst' and `hwnd' have sensible values. */
123 mbox
.hInstance
= hinst
;
124 mbox
.hwndOwner
= hwnd
;
125 mbox
.lpfnMsgBoxCallback
= &message_box_help_callback
;
126 mbox
.dwLanguageId
= LANG_NEUTRAL
;
127 mbox
.lpszText
= text
;
128 mbox
.lpszCaption
= caption
;
129 mbox
.dwContextHelpId
= helpctxid
;
130 mbox
.dwStyle
= style
;
131 if (helpctxid
!= 0 && has_help()) mbox
.dwStyle
|= MB_HELP
;
132 return MessageBoxIndirect(&mbox
);
136 * Display the fingerprints of the PGP Master Keys to the user.
138 void pgp_fingerprints(void)
140 message_box("These are the fingerprints of the PuTTY PGP Master Keys. They can\n"
141 "be used to establish a trust path from this executable to another\n"
142 "one. See the manual for more information.\n"
143 "(Note: these fingerprints have nothing to do with SSH!)\n"
145 "PuTTY Master Key (RSA), 1024-bit:\n"
146 " " PGP_RSA_MASTER_KEY_FP
"\n"
147 "PuTTY Master Key (DSA), 1024-bit:\n"
148 " " PGP_DSA_MASTER_KEY_FP
,
149 "PGP fingerprints", MB_ICONINFORMATION
| MB_OK
,
150 HELPCTXID(pgp_fingerprints
));
154 * Handy wrapper around GetDlgItemText which doesn't make you invent
155 * an arbitrary length limit on the output string. Returned string is
156 * dynamically allocated; caller must free.
158 char *GetDlgItemText_alloc(HWND hwnd
, int id
)
164 size
= size
* 4 / 3 + 512;
165 ret
= sresize(ret
, size
, char);
166 GetDlgItemText(hwnd
, id
, ret
, size
);
167 } while (!memchr(ret
, '\0', size
-1));
173 * Split a complete command line into argc/argv, attempting to do
174 * it exactly the same way Windows itself would do it (so that
175 * console utilities, which receive argc and argv from Windows,
176 * will have their command lines processed in the same way as GUI
177 * utilities which get a whole command line and must break it
180 * Does not modify the input command line.
182 * The final parameter (argstart) is used to return a second array
183 * of char * pointers, the same length as argv, each one pointing
184 * at the start of the corresponding element of argv in the
185 * original command line. So if you get half way through processing
186 * your command line in argc/argv form and then decide you want to
187 * treat the rest as a raw string, you can. If you don't want to,
188 * `argstart' can be safely left NULL.
190 void split_into_argv(char *cmdline
, int *argc
, char ***argv
,
194 char *outputline
, *q
;
195 char **outputargv
, **outputargstart
;
199 * At first glance the rules appeared to be:
201 * - Single quotes are not special characters.
203 * - Double quotes are removed, but within them spaces cease
206 * - Backslashes are _only_ special when a sequence of them
207 * appear just before a double quote. In this situation,
208 * they are treated like C backslashes: so \" just gives a
209 * literal quote, \\" gives a literal backslash and then
210 * opens or closes a double-quoted segment, \\\" gives a
211 * literal backslash and then a literal quote, \\\\" gives
212 * two literal backslashes and then opens/closes a
213 * double-quoted segment, and so forth. Note that this
214 * behaviour is identical inside and outside double quotes.
216 * - Two successive double quotes become one literal double
217 * quote, but only _inside_ a double-quoted segment.
218 * Outside, they just form an empty double-quoted segment
219 * (which may cause an empty argument word).
221 * - That only leaves the interesting question of what happens
222 * when one or more backslashes precedes two or more double
223 * quotes, starting inside a double-quoted string. And the
224 * answer to that appears somewhat bizarre. Here I tabulate
225 * number of backslashes (across the top) against number of
226 * quotes (down the left), and indicate how many backslashes
227 * are output, how many quotes are output, and whether a
228 * quoted segment is open at the end of the sequence:
234 * 0 0,0,y | 1,0,y 2,0,y 3,0,y 4,0,y
235 * --------+-----------------------------
236 * 1 0,0,n | 0,1,y 1,0,n 1,1,y 2,0,n
237 * q 2 0,1,n | 0,1,n 1,1,n 1,1,n 2,1,n
238 * u 3 0,1,y | 0,2,n 1,1,y 1,2,n 2,1,y
239 * o 4 0,1,n | 0,2,y 1,1,n 1,2,y 2,1,n
240 * t 5 0,2,n | 0,2,n 1,2,n 1,2,n 2,2,n
241 * e 6 0,2,y | 0,3,n 1,2,y 1,3,n 2,2,y
242 * s 7 0,2,n | 0,3,y 1,2,n 1,3,y 2,2,n
243 * 8 0,3,n | 0,3,n 1,3,n 1,3,n 2,3,n
244 * 9 0,3,y | 0,4,n 1,3,y 1,4,n 2,3,y
245 * 10 0,3,n | 0,4,y 1,3,n 1,4,y 2,3,n
246 * 11 0,4,n | 0,4,n 1,4,n 1,4,n 2,4,n
249 * [Test fragment was of the form "a\\\"""b c" d.]
251 * There is very weird mod-3 behaviour going on here in the
252 * number of quotes, and it even applies when there aren't any
253 * backslashes! How ghastly.
255 * With a bit of thought, this extremely odd diagram suddenly
256 * coalesced itself into a coherent, if still ghastly, model of
259 * - As before, backslashes are only special when one or more
260 * of them appear contiguously before at least one double
261 * quote. In this situation the backslashes do exactly what
262 * you'd expect: each one quotes the next thing in front of
263 * it, so you end up with n/2 literal backslashes (if n is
264 * even) or (n-1)/2 literal backslashes and a literal quote
265 * (if n is odd). In the latter case the double quote
266 * character right after the backslashes is used up.
268 * - After that, any remaining double quotes are processed. A
269 * string of contiguous unescaped double quotes has a mod-3
272 * * inside a quoted segment, a quote ends the segment.
273 * * _immediately_ after ending a quoted segment, a quote
274 * simply produces a literal quote.
275 * * otherwise, outside a quoted segment, a quote begins a
278 * So, for example, if we started inside a quoted segment
279 * then two contiguous quotes would close the segment and
280 * produce a literal quote; three would close the segment,
281 * produce a literal quote, and open a new segment. If we
282 * started outside a quoted segment, then two contiguous
283 * quotes would open and then close a segment, producing no
284 * output (but potentially creating a zero-length argument);
285 * but three quotes would open and close a segment and then
286 * produce a literal quote.
290 * First deal with the simplest of all special cases: if there
291 * aren't any arguments, return 0,NULL,NULL.
293 while (*cmdline
&& isspace(*cmdline
)) cmdline
++;
296 if (argv
) *argv
= NULL
;
297 if (argstart
) *argstart
= NULL
;
302 * This will guaranteeably be big enough; we can realloc it
305 outputline
= snewn(1+strlen(cmdline
), char);
306 outputargv
= snewn(strlen(cmdline
)+1 / 2, char *);
307 outputargstart
= snewn(strlen(cmdline
)+1 / 2, char *);
309 p
= cmdline
; q
= outputline
; outputargc
= 0;
314 /* Skip whitespace searching for start of argument. */
315 while (*p
&& isspace(*p
)) p
++;
318 /* We have an argument; start it. */
319 outputargv
[outputargc
] = q
;
320 outputargstart
[outputargc
] = p
;
324 /* Copy data into the argument until it's finished. */
326 if (!quote
&& isspace(*p
))
327 break; /* argument is finished */
329 if (*p
== '"' || *p
== '\\') {
331 * We have a sequence of zero or more backslashes
332 * followed by a sequence of zero or more quotes.
333 * Count up how many of each, and then deal with
334 * them as appropriate.
336 int i
, slashes
= 0, quotes
= 0;
337 while (*p
== '\\') slashes
++, p
++;
338 while (*p
== '"') quotes
++, p
++;
342 * Special case: if there are no quotes,
343 * slashes are not special at all, so just copy
344 * n slashes to the output string.
346 while (slashes
--) *q
++ = '\\';
348 /* Slashes annihilate in pairs. */
349 while (slashes
>= 2) slashes
-= 2, *q
++ = '\\';
351 /* One remaining slash takes out the first quote. */
352 if (slashes
) quotes
--, *q
++ = '"';
355 /* Outside a quote segment, a quote starts one. */
356 if (!quote
) quotes
--, quote
= 1;
358 /* Now we produce (n+1)/3 literal quotes... */
359 for (i
= 3; i
<= quotes
+1; i
+= 3) *q
++ = '"';
361 /* ... and end in a quote segment iff 3 divides n. */
362 quote
= (quotes
% 3 == 0);
370 /* At the end of an argument, just append a trailing NUL. */
374 outputargv
= sresize(outputargv
, outputargc
, char *);
375 outputargstart
= sresize(outputargstart
, outputargc
, char *);
377 if (argc
) *argc
= outputargc
;
378 if (argv
) *argv
= outputargv
; else sfree(outputargv
);
379 if (argstart
) *argstart
= outputargstart
; else sfree(outputargstart
);
384 const struct argv_test
{
386 const char *argv
[10];
389 * We generate this set of tests by invoking ourself with
392 {"ab c\" d", {"ab", "c d", NULL
}},
393 {"a\"b c\" d", {"ab c", "d", NULL
}},
394 {"a\"\"b c\" d", {"ab", "c d", NULL
}},
395 {"a\"\"\"b c\" d", {"a\"b", "c d", NULL
}},
396 {"a\"\"\"\"b c\" d", {"a\"b c", "d", NULL
}},
397 {"a\"\"\"\"\"b c\" d", {"a\"b", "c d", NULL
}},
398 {"a\"\"\"\"\"\"b c\" d", {"a\"\"b", "c d", NULL
}},
399 {"a\"\"\"\"\"\"\"b c\" d", {"a\"\"b c", "d", NULL
}},
400 {"a\"\"\"\"\"\"\"\"b c\" d", {"a\"\"b", "c d", NULL
}},
401 {"a\\b c\" d", {"a\\b", "c d", NULL
}},
402 {"a\\\"b c\" d", {"a\"b", "c d", NULL
}},
403 {"a\\\"\"b c\" d", {"a\"b c", "d", NULL
}},
404 {"a\\\"\"\"b c\" d", {"a\"b", "c d", NULL
}},
405 {"a\\\"\"\"\"b c\" d", {"a\"\"b", "c d", NULL
}},
406 {"a\\\"\"\"\"\"b c\" d", {"a\"\"b c", "d", NULL
}},
407 {"a\\\"\"\"\"\"\"b c\" d", {"a\"\"b", "c d", NULL
}},
408 {"a\\\"\"\"\"\"\"\"b c\" d", {"a\"\"\"b", "c d", NULL
}},
409 {"a\\\"\"\"\"\"\"\"\"b c\" d", {"a\"\"\"b c", "d", NULL
}},
410 {"a\\\\b c\" d", {"a\\\\b", "c d", NULL
}},
411 {"a\\\\\"b c\" d", {"a\\b c", "d", NULL
}},
412 {"a\\\\\"\"b c\" d", {"a\\b", "c d", NULL
}},
413 {"a\\\\\"\"\"b c\" d", {"a\\\"b", "c d", NULL
}},
414 {"a\\\\\"\"\"\"b c\" d", {"a\\\"b c", "d", NULL
}},
415 {"a\\\\\"\"\"\"\"b c\" d", {"a\\\"b", "c d", NULL
}},
416 {"a\\\\\"\"\"\"\"\"b c\" d", {"a\\\"\"b", "c d", NULL
}},
417 {"a\\\\\"\"\"\"\"\"\"b c\" d", {"a\\\"\"b c", "d", NULL
}},
418 {"a\\\\\"\"\"\"\"\"\"\"b c\" d", {"a\\\"\"b", "c d", NULL
}},
419 {"a\\\\\\b c\" d", {"a\\\\\\b", "c d", NULL
}},
420 {"a\\\\\\\"b c\" d", {"a\\\"b", "c d", NULL
}},
421 {"a\\\\\\\"\"b c\" d", {"a\\\"b c", "d", NULL
}},
422 {"a\\\\\\\"\"\"b c\" d", {"a\\\"b", "c d", NULL
}},
423 {"a\\\\\\\"\"\"\"b c\" d", {"a\\\"\"b", "c d", NULL
}},
424 {"a\\\\\\\"\"\"\"\"b c\" d", {"a\\\"\"b c", "d", NULL
}},
425 {"a\\\\\\\"\"\"\"\"\"b c\" d", {"a\\\"\"b", "c d", NULL
}},
426 {"a\\\\\\\"\"\"\"\"\"\"b c\" d", {"a\\\"\"\"b", "c d", NULL
}},
427 {"a\\\\\\\"\"\"\"\"\"\"\"b c\" d", {"a\\\"\"\"b c", "d", NULL
}},
428 {"a\\\\\\\\b c\" d", {"a\\\\\\\\b", "c d", NULL
}},
429 {"a\\\\\\\\\"b c\" d", {"a\\\\b c", "d", NULL
}},
430 {"a\\\\\\\\\"\"b c\" d", {"a\\\\b", "c d", NULL
}},
431 {"a\\\\\\\\\"\"\"b c\" d", {"a\\\\\"b", "c d", NULL
}},
432 {"a\\\\\\\\\"\"\"\"b c\" d", {"a\\\\\"b c", "d", NULL
}},
433 {"a\\\\\\\\\"\"\"\"\"b c\" d", {"a\\\\\"b", "c d", NULL
}},
434 {"a\\\\\\\\\"\"\"\"\"\"b c\" d", {"a\\\\\"\"b", "c d", NULL
}},
435 {"a\\\\\\\\\"\"\"\"\"\"\"b c\" d", {"a\\\\\"\"b c", "d", NULL
}},
436 {"a\\\\\\\\\"\"\"\"\"\"\"\"b c\" d", {"a\\\\\"\"b", "c d", NULL
}},
437 {"\"ab c\" d", {"ab c", "d", NULL
}},
438 {"\"a\"b c\" d", {"ab", "c d", NULL
}},
439 {"\"a\"\"b c\" d", {"a\"b", "c d", NULL
}},
440 {"\"a\"\"\"b c\" d", {"a\"b c", "d", NULL
}},
441 {"\"a\"\"\"\"b c\" d", {"a\"b", "c d", NULL
}},
442 {"\"a\"\"\"\"\"b c\" d", {"a\"\"b", "c d", NULL
}},
443 {"\"a\"\"\"\"\"\"b c\" d", {"a\"\"b c", "d", NULL
}},
444 {"\"a\"\"\"\"\"\"\"b c\" d", {"a\"\"b", "c d", NULL
}},
445 {"\"a\"\"\"\"\"\"\"\"b c\" d", {"a\"\"\"b", "c d", NULL
}},
446 {"\"a\\b c\" d", {"a\\b c", "d", NULL
}},
447 {"\"a\\\"b c\" d", {"a\"b c", "d", NULL
}},
448 {"\"a\\\"\"b c\" d", {"a\"b", "c d", NULL
}},
449 {"\"a\\\"\"\"b c\" d", {"a\"\"b", "c d", NULL
}},
450 {"\"a\\\"\"\"\"b c\" d", {"a\"\"b c", "d", NULL
}},
451 {"\"a\\\"\"\"\"\"b c\" d", {"a\"\"b", "c d", NULL
}},
452 {"\"a\\\"\"\"\"\"\"b c\" d", {"a\"\"\"b", "c d", NULL
}},
453 {"\"a\\\"\"\"\"\"\"\"b c\" d", {"a\"\"\"b c", "d", NULL
}},
454 {"\"a\\\"\"\"\"\"\"\"\"b c\" d", {"a\"\"\"b", "c d", NULL
}},
455 {"\"a\\\\b c\" d", {"a\\\\b c", "d", NULL
}},
456 {"\"a\\\\\"b c\" d", {"a\\b", "c d", NULL
}},
457 {"\"a\\\\\"\"b c\" d", {"a\\\"b", "c d", NULL
}},
458 {"\"a\\\\\"\"\"b c\" d", {"a\\\"b c", "d", NULL
}},
459 {"\"a\\\\\"\"\"\"b c\" d", {"a\\\"b", "c d", NULL
}},
460 {"\"a\\\\\"\"\"\"\"b c\" d", {"a\\\"\"b", "c d", NULL
}},
461 {"\"a\\\\\"\"\"\"\"\"b c\" d", {"a\\\"\"b c", "d", NULL
}},
462 {"\"a\\\\\"\"\"\"\"\"\"b c\" d", {"a\\\"\"b", "c d", NULL
}},
463 {"\"a\\\\\"\"\"\"\"\"\"\"b c\" d", {"a\\\"\"\"b", "c d", NULL
}},
464 {"\"a\\\\\\b c\" d", {"a\\\\\\b c", "d", NULL
}},
465 {"\"a\\\\\\\"b c\" d", {"a\\\"b c", "d", NULL
}},
466 {"\"a\\\\\\\"\"b c\" d", {"a\\\"b", "c d", NULL
}},
467 {"\"a\\\\\\\"\"\"b c\" d", {"a\\\"\"b", "c d", NULL
}},
468 {"\"a\\\\\\\"\"\"\"b c\" d", {"a\\\"\"b c", "d", NULL
}},
469 {"\"a\\\\\\\"\"\"\"\"b c\" d", {"a\\\"\"b", "c d", NULL
}},
470 {"\"a\\\\\\\"\"\"\"\"\"b c\" d", {"a\\\"\"\"b", "c d", NULL
}},
471 {"\"a\\\\\\\"\"\"\"\"\"\"b c\" d", {"a\\\"\"\"b c", "d", NULL
}},
472 {"\"a\\\\\\\"\"\"\"\"\"\"\"b c\" d", {"a\\\"\"\"b", "c d", NULL
}},
473 {"\"a\\\\\\\\b c\" d", {"a\\\\\\\\b c", "d", NULL
}},
474 {"\"a\\\\\\\\\"b c\" d", {"a\\\\b", "c d", NULL
}},
475 {"\"a\\\\\\\\\"\"b c\" d", {"a\\\\\"b", "c d", NULL
}},
476 {"\"a\\\\\\\\\"\"\"b c\" d", {"a\\\\\"b c", "d", NULL
}},
477 {"\"a\\\\\\\\\"\"\"\"b c\" d", {"a\\\\\"b", "c d", NULL
}},
478 {"\"a\\\\\\\\\"\"\"\"\"b c\" d", {"a\\\\\"\"b", "c d", NULL
}},
479 {"\"a\\\\\\\\\"\"\"\"\"\"b c\" d", {"a\\\\\"\"b c", "d", NULL
}},
480 {"\"a\\\\\\\\\"\"\"\"\"\"\"b c\" d", {"a\\\\\"\"b", "c d", NULL
}},
481 {"\"a\\\\\\\\\"\"\"\"\"\"\"\"b c\" d", {"a\\\\\"\"\"b", "c d", NULL
}},
484 int main(int argc
, char **argv
)
490 * Generation of tests.
492 * Given `-splat <args>', we print out a C-style
493 * representation of each argument (in the form "a", "b",
494 * NULL), backslash-escaping each backslash and double
497 * Given `-split <string>', we first doctor `string' by
498 * turning forward slashes into backslashes, single quotes
499 * into double quotes and underscores into spaces; and then
500 * we feed the resulting string to ourself with `-splat'.
502 * Given `-generate', we concoct a variety of fun test
503 * cases, encode them in quote-safe form (mapping \, " and
504 * space to /, ' and _ respectively) and feed each one to
507 if (!strcmp(argv
[1], "-splat")) {
510 for (i
= 2; i
< argc
; i
++) {
512 for (p
= argv
[i
]; *p
; p
++) {
513 if (*p
== '\\' || *p
== '"')
523 if (!strcmp(argv
[1], "-split") && argc
> 2) {
524 char *str
= malloc(20 + strlen(argv
[0]) + strlen(argv
[2]));
527 q
= str
+ sprintf(str
, "%s -splat ", argv
[0]);
529 for (p
= argv
[2]; *p
; p
++, q
++) {
531 case '/': printf("\\\\"); *q
= '\\'; break;
532 case '\'': printf("\\\""); *q
= '"'; break;
533 case '_': printf(" "); *q
= ' '; break;
534 default: putchar(*p
); *q
= *p
; break;
548 if (!strcmp(argv
[1], "-generate")) {
550 int i
, initialquote
, backslashes
, quotes
;
552 teststr
= malloc(200 + strlen(argv
[0]));
554 for (initialquote
= 0; initialquote
<= 1; initialquote
++) {
555 for (backslashes
= 0; backslashes
< 5; backslashes
++) {
556 for (quotes
= 0; quotes
< 9; quotes
++) {
557 p
= teststr
+ sprintf(teststr
, "%s -split ", argv
[0]);
558 if (initialquote
) *p
++ = '\'';
560 for (i
= 0; i
< backslashes
; i
++) *p
++ = '/';
561 for (i
= 0; i
< quotes
; i
++) *p
++ = '\'';
577 fprintf(stderr
, "unrecognised option: \"%s\"\n", argv
[1]);
582 * If we get here, we were invoked with no arguments, so just
586 for (i
= 0; i
< lenof(argv_tests
); i
++) {
590 split_into_argv(argv_tests
[i
].cmdline
, &ac
, &av
);
592 for (j
= 0; j
< ac
&& argv_tests
[i
].argv
[j
]; j
++) {
593 if (strcmp(av
[j
], argv_tests
[i
].argv
[j
])) {
594 printf("failed test %d (|%s|) arg %d: |%s| should be |%s|\n",
595 i
, argv_tests
[i
].cmdline
,
596 j
, av
[j
], argv_tests
[i
].argv
[j
]);
600 printf("test %d (|%s|) arg %d: |%s| == |%s|\n",
601 i
, argv_tests
[i
].cmdline
,
602 j
, av
[j
], argv_tests
[i
].argv
[j
]);
607 printf("failed test %d (|%s|): %d args returned, should be %d\n",
608 i
, argv_tests
[i
].cmdline
, ac
, j
);
609 if (argv_tests
[i
].argv
[j
])
610 printf("failed test %d (|%s|): %d args returned, should be more\n",
611 i
, argv_tests
[i
].cmdline
, ac
);