2 * Copyright (C) 2009 Dan Carpenter.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
19 * Idea from Michael Stefaniuc and Vincent BĂ©ron's earlier WtoA
22 * Apparently when you are coding WINE, you are not allowed to call
23 * functions that end in capital 'A' from functions that end in
34 static void match_function_def(struct symbol
*sym
)
36 char *func
= get_function();
44 if (func
[len
- 1] == 'W' && len
> 2 && func
[len
- 2] != 'A' )
50 static int allowed_func(const char *fn
)
52 if (!strcmp("lstrcatA", fn
))
54 if (!strcmp("lstrcpyA", fn
))
56 if (!strcmp("lstrcpynA", fn
))
58 if (!strcmp("lstrlenA", fn
))
63 static void match_call(struct expression
*expr
)
71 fn_name
= expr_to_var(expr
->fn
);
74 len
= strlen(fn_name
);
75 if (fn_name
[len
- 1] == 'A' && !allowed_func(fn_name
)) {
76 sm_msg("warn: WtoA call %s()", fn_name
);
82 void check_wine_WtoA(int id
)
84 if (option_project
!= PROJ_WINE
)
88 add_hook(&match_function_def
, FUNC_DEF_HOOK
);
89 add_hook(&match_call
, FUNCTION_CALL_HOOK
);