Fix errors and warnings with clang / llvm
[scilab.git] / scilab / modules / string / src / c / isletter.c
1 /*
2  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3  * Copyright (C) INRIA - Allan CORNET
4  * 
5  * This file must be used under the terms of the CeCILL.
6  * This source file is licensed as described in the file COPYING, which
7  * you should have received as part of this distribution.  The terms
8  * are also available at    
9  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10  *
11  */
12
13 /*--------------------------------------------------------------------------*/
14 #include <string.h>
15 #include <ctype.h>
16 #include <wchar.h>
17 #include <wctype.h> /* iswalpha */
18 #include "isletter.h"
19 #include "MALLOC.h"
20
21 /*--------------------------------------------------------------------------*/
22 BOOL *isletter(char *input_string, int *sizeArray)
23 {
24         BOOL *returnedValues = NULL;
25         if (input_string)
26         {
27                 int i = 0;
28                 int length_input_string = (int)strlen(input_string);
29                 *sizeArray = length_input_string;
30
31                 if (length_input_string > 0)
32                 {
33                         returnedValues = (BOOL*)MALLOC(sizeof(BOOL)*length_input_string);
34                         if (returnedValues)
35                         {
36                                 for (i = 0;i < length_input_string; i++)
37                                 {
38                                         if ( isalpha(input_string[i]) ) returnedValues[i] = TRUE;
39                                         else returnedValues[i] = FALSE;
40                                 }
41                         }
42                 }
43         }
44         return returnedValues;
45 }
46 /*--------------------------------------------------------------------------*/
47 BOOL *isletterW(wchar_t *wcInput_string, int *sizeArray)
48 {
49         BOOL *returnedValues = NULL;
50         if (wcInput_string)
51         {
52                 int i = 0;
53                 int length_input_string = (int)wcslen(wcInput_string);
54
55                 *sizeArray = length_input_string;
56
57                 if (length_input_string > 0)
58                 {
59                         returnedValues = (BOOL*)MALLOC(sizeof(BOOL)*length_input_string);
60                         if (returnedValues)
61                         {
62                                 for (i = 0;i < length_input_string; i++)
63                                 {
64                                         if ( iswalpha(wcInput_string[i]) ) returnedValues[i] = TRUE;
65                                         else returnedValues[i] = FALSE;
66                                 }
67                         }
68                 }
69         }
70         return returnedValues;
71 }
72 /*--------------------------------------------------------------------------*/