| 335 | | while (a) |
| 336 | | { |
| 337 | | if (a->name && strstr (a->name, s) == a->name) |
| 338 | | { |
| 339 | | if (!bestname[0]) /* init */ |
| 340 | | strfcpy (bestname, a->name, min (mutt_strlen (a->name) + 1, sizeof (bestname))); |
| 341 | | else |
| | 334 | if (s[0] != 0) /* avoid empty string as strstr argument */ |
| | 335 | { |
| | 336 | memset (bestname, 0, sizeof (bestname)); |
| | 337 | |
| | 338 | while (a) |
| | 339 | { |
| | 340 | if (a->name && strstr (a->name, s) == a->name) |
| 347 | | } |
| 348 | | a = a->next; |
| 349 | | } |
| 350 | | |
| 351 | | if ((bestname[0] == 0) || /* if we didn't find anything */ |
| 352 | | (s[0] == 0)) /* or we weren't given anything */ |
| 353 | | { |
| 354 | | mutt_alias_menu (s, buflen, Aliases); |
| 355 | | return 0; |
| 356 | | } |
| 357 | | else |
| 358 | | { |
| 359 | | if (mutt_strcmp (bestname, s) == 0) /* add anything to the completion? */ |
| 360 | | { |
| | 352 | a = a->next; |
| | 353 | } |
| | 354 | |
| | 355 | if (bestname[0] != 0) |
| | 356 | { |
| | 357 | if (mutt_strcmp (bestname, s) != 0) |
| | 358 | { |
| | 359 | /* we are adding something to the completion */ |
| | 360 | strfcpy (s, bestname, mutt_strlen (bestname) + 1); |
| | 361 | return 1; |
| | 362 | } |
| | 363 | |
| 379 | | |
| 380 | | s[0] = 0; /* reset string before passing to alias_menu */ |
| 381 | | mutt_alias_menu (s, buflen, a_list); |
| 382 | | |
| 383 | | /* free the alias list */ |
| 384 | | while (a_list) |
| 385 | | { |
| 386 | | a_cur = a_list; |
| 387 | | a_list = a_list->next; |
| 388 | | safe_free ((void **) &a_cur); |
| 389 | | } |
| 390 | | |
| 391 | | return 0; |
| 392 | | } |
| 393 | | else /* we are adding something to the completion */ |
| 394 | | strfcpy (s, bestname, mutt_strlen (bestname) + 1); |
| 395 | | } |
| 396 | | |
| 397 | | return 1; |
| | 382 | } |
| | 383 | } |
| | 384 | |
| | 385 | bestname[0] = 0; |
| | 386 | mutt_alias_menu (bestname, sizeof(bestname), a_list ? a_list : Aliases); |
| | 387 | if (bestname[0] != 0) |
| | 388 | strfcpy (s, bestname, buflen); |
| | 389 | |
| | 390 | /* free the alias list */ |
| | 391 | while (a_list) |
| | 392 | { |
| | 393 | a_cur = a_list; |
| | 394 | a_list = a_list->next; |
| | 395 | safe_free ((void **) &a_cur); |
| | 396 | } |
| | 397 | |
| | 398 | return 0; |