BUG: Token array now terminated by \0
This commit is contained in:
parent
075cfddcaf
commit
5d5b4d93d7
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
* @name analyze
|
||||
|
@ -10,7 +11,8 @@
|
|||
* @brief Analyze the tokens syntax. Return -1 on error and 1 on warning, 0 else.
|
||||
*
|
||||
* @param char* tokens: analyze_tokens
|
||||
* @param char* device: target device
|
||||
*/
|
||||
int analyze (char* tokens);
|
||||
int analyze (char* tokens, char* device);
|
||||
|
||||
#endif//ANALYZER_H
|
||||
|
|
|
@ -6,8 +6,9 @@
|
|||
* @brief Check for errors and warnings.
|
||||
*
|
||||
* @param char* token
|
||||
* @param char* device
|
||||
*/
|
||||
int analyze (char* token) {
|
||||
int analyze (char* token, char* device) {
|
||||
int rv = 0;
|
||||
int position = 0;
|
||||
|
||||
|
@ -28,8 +29,8 @@ int analyze (char* token) {
|
|||
break;
|
||||
}
|
||||
|
||||
/* check for nested loops */
|
||||
if (rv > 1) {
|
||||
/* check for nested loops in case of using the logisim model */
|
||||
if (rv > 1 && !strcmp(device, "logisim")) {
|
||||
(void)printf("Warning on token %d\n", position);
|
||||
(void)printf("WARNING: Nested loops are not supported on all versions of the target device!\n");
|
||||
}
|
||||
|
|
|
@ -38,6 +38,9 @@ int extractTokens (char* buffer, char* tokens) {
|
|||
|
||||
}
|
||||
|
||||
/* Terminate the array using a null character */
|
||||
tokens[tokens_found] = 0; /* same as \0 */
|
||||
|
||||
rv = tokens_found;
|
||||
|
||||
return rv;
|
||||
|
|
Loading…
Reference in New Issue