Commit of the code which was suggested by Georg as a fix for:
[cake.git] / rom / dos / findarg.c
blob6950f731ca2cddfdb6f280fb1a0f053dd70ecb2f
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
8 #include <proto/utility.h>
9 #include "dos_intern.h"
11 /*****************************************************************************
13 NAME */
14 #include <proto/dos.h>
16 AROS_LH2(LONG, FindArg,
18 /* SYNOPSIS */
19 AROS_LHA(CONST_STRPTR, template, D1),
20 AROS_LHA(CONST_STRPTR, keyword, D2),
22 /* LOCATION */
23 struct DosLibrary *, DOSBase, 134, Dos)
25 /* FUNCTION
27 INPUTS
29 RESULT
31 NOTES
33 EXAMPLE
35 BUGS
37 SEE ALSO
39 INTERNALS
41 *****************************************************************************/
43 AROS_LIBFUNC_INIT
45 LONG count=0;
46 CONST_STRPTR key;
48 /* Loop over template */
49 for(;;)
51 /* Compare key to template */
52 key=keyword;
53 for(;;)
55 UBYTE lkey;
57 /* If the keyword has ended check the template */
58 if(!*key)
60 if(!*template||*template=='='||*template=='/'||*template==',')
61 /* The template has ended, too. Return count. */
62 return count;
63 /* The template isn't finished. Stop comparison. */
64 break;
66 /* If the two differ stop comparison. */
67 lkey=ToLower(*key);
68 if(lkey!=ToLower(*template))
69 break;
70 /* Go to next character */
71 key++;
72 template++;
74 /* Find next keyword in template */
75 for(;;)
77 if(!*template)
78 return -1;
79 if(*template=='=')
81 /* Alias found */
82 template++;
83 break;
85 if(*template==',')
87 /* Next item found */
88 template++;
89 count++;
90 break;
92 template++;
95 AROS_LIBFUNC_EXIT
96 } /* FindArg */