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