Révision 127 pobysoC-4.0/src/pobyso.c
pobyso.c (revision 127) | ||
---|---|---|
28 | 28 |
/* Global variables */ |
29 | 29 |
|
30 | 30 |
/* Functions */ |
31 |
|
|
32 |
/* @see pobyso.h#pobyso_autprint */ |
|
31 | 33 |
void |
32 | 34 |
pobyso_autoprint(sollya_obj_t solObj, ...) |
33 | 35 |
{ |
... | ... | |
37 | 39 |
va_end(va); |
38 | 40 |
} /* End pobyso_autoprint. */ |
39 | 41 |
|
42 |
/* @see pobyso.h#pobyso_parse_string*/ |
|
40 | 43 |
sollya_obj_t |
41 | 44 |
pobyso_parse_string(const char* expression) |
42 | 45 |
{ |
46 |
int expressionLength; |
|
47 |
char *expressionWithSemiCo; |
|
48 |
sollya_obj_t expressionSa; |
|
49 |
/* Arguments check. */ |
|
43 | 50 |
if (expression == NULL) |
44 | 51 |
{ |
45 | 52 |
pobyso_error_message("pobyso_parse_string", |
46 | 53 |
"NULL_POINTER_ARGUMENT", |
47 | 54 |
"The expression is a NULL pointer"); |
48 |
return(NULL);
|
|
55 |
return(sollya_lib_error());
|
|
49 | 56 |
} |
50 |
return(sollya_lib_parse_string(expression)); |
|
57 |
expressionLength = strlen(expression); |
|
58 |
if (expressionLength == 0) |
|
59 |
{ |
|
60 |
pobyso_error_message("pobyso_parse_string", |
|
61 |
"EMPTY_STRING_ARGUMENT", |
|
62 |
"The expression is an empty string"); |
|
63 |
} |
|
64 |
/* If the final ";" has been forgotten. */ |
|
65 |
if (expression[expressionLength-1] != ';') |
|
66 |
{ |
|
67 |
expressionWithSemiCo = calloc(expressionLength + 2, sizeof(char)); |
|
68 |
if (expressionWithSemiCo == NULL) |
|
69 |
{ |
|
70 |
pobyso_error_message("pobyso_parse_string", |
|
71 |
"MEMORY_ALLOCATION_ERROR", |
|
72 |
"Could not allocate the expression string"); |
|
73 |
return(sollya_lib_error()); |
|
74 |
} |
|
75 |
expressionWithSemiCo = strcat(expressionWithSemiCo, expression); |
|
76 |
expressionWithSemiCo = strcat(expressionWithSemiCo, ";"); |
|
77 |
expressionSa = sollya_lib_parse_string(expressionWithSemiCo); |
|
78 |
free(expressionWithSemiCo); |
|
79 |
return(expressionSa); |
|
80 |
} /* End ";" forgotten */ |
|
81 |
else |
|
82 |
{ |
|
83 |
return(sollya_lib_parse_string(expression)); |
|
84 |
} |
|
51 | 85 |
} /* pobyso_parse_string */ |
52 | 86 |
|
53 | 87 |
void |
Formats disponibles : Unified diff