Commits

PioneerAxon committed b2cdc1c

Fix coding style issues Phase: 2

Comments (0)

Files changed (5)

 #include "parserfunc.h"
 #include "mp-equation.h"
 
-static gint
+static gboolean
 l_check_if_function(LexerState* state)
 {
 	gchar* name = pl_get_marked_substring(state->prelexer);
 	if(!state->parent->function_is_defined)
 	{
 		free(name);
-		return 0;
+		return FALSE;
 	}
 	if ((*(state->parent->function_is_defined))(state->parent, name))
 	{
 		free(name);
-		return 1;
+		return TRUE;
 	}
 	else
 	{
 		free(name);
-		return 0;
+		return FALSE;
 	}
 }
 
-static gint
+static gboolean
 l_check_if_number(LexerState* state)
 {
 	MPNumber tmp;
 	if(mp_set_from_string(text, state->parent->options->base, &tmp) == 0)
 	{
 		free(text);
-		return 1;
+		return TRUE;
 	}
 	else
 	{
 			if(mp_set_from_string(text, state->parent->options->base, &tmp) == 0)
 			{
 				free(text);
-				return 1;
+				return TRUE;
 			}
 			free(text);
 			count++;
 		while(count--) 
 			pl_get_next_token (state->prelexer);
 		free(text);
-		return 0;
+		return FALSE;
 	}
 }
 
 } LexerState;
 
 /* Create a new LexerState object and fill the dynamic array with tokens. */
-LexerState *l_create_lexer(const gchar *, struct parser_state *);
+LexerState* l_create_lexer(const gchar*, struct parser_state*);
 
 /* Destroy LexerState object and free up space. */
-void l_destroy_lexer(LexerState *);
+void l_destroy_lexer(LexerState*);
 
 /* Tokanize complete string. */
-void l_insert_all_tokens(LexerState *);
+void l_insert_all_tokens(LexerState*);
 
 /* Return next, to be sent, token. */
-LexerToken *l_get_next_token(LexerState *);
+LexerToken* l_get_next_token(LexerState*);
 
 /* Roll back one token. */
-void l_roll_back(LexerState *);
+void l_roll_back(LexerState*);
 
 #endif /* LEXER_H */
 }
 
 /* Check if string "name" is a valid variable for given ParserState. It is the same code, used to get the value of variable in parserfunc.c. */
-static gint
+static gboolean
 p_check_variable(ParserState* state, gchar* name)
 {
 	gint result = 0;
 
 	if(!(state->get_variable))
 	{
-		return 0;
+		return FALSE;
 	}
 
 	/* If defined, then get the variable */
 	if((*(state->get_variable))(state, name, &temp))
 	{
-		return 1;
+		return TRUE;
 	}
 
 	/* If has more than one character then assume a multiplication of variables */
 	}
 	if(!result)
 	{
-		return 0;
+		return FALSE;
 	}
-	return 1;
+	return TRUE;
 }
 
 static guint
 #include "prelexer.h"
 
 /* Creates a scanner state which will be useful for accessing the lexer later. */
-PreLexerState *
+PreLexerState*
 pl_create_scanner(const gchar* input)
 {
-	PreLexerState *state;
+	PreLexerState* state;
 	assert(input != NULL);
 	assert(g_utf8_validate(input, -1, NULL));
 	state = (PreLexerState *) malloc(sizeof(PreLexerState));
 
 /* Destroy and free memory used by LexerState object. */
 void
-pl_destroy_scanner(PreLexerState * state)
+pl_destroy_scanner(PreLexerState* state)
 {
 	free(state->stream);
 	free(state);
 
 /* Roll back last scanned unichar. */
 void
-pl_roll_back(PreLexerState * state)
+pl_roll_back(PreLexerState* state)
 {
-	gchar * tmp;
+	gchar* tmp;
 	tmp = g_utf8_find_prev_char(state->stream, state->stream + state->next_index);
 	if(tmp == NULL)
 		/* Already at the beginning of the stram. Reset index. */
 
 /* Get validated gunichar from input stream. */
 gunichar
-pl_get_next_gunichar(PreLexerState * state)
+pl_get_next_gunichar(PreLexerState* state)
 {
 	gunichar ret;
 	if(state->next_index >= state->length)
 
 /* Set marker index. To be used for highlighting and error reporting. */
 void
-pl_set_marker(PreLexerState * state)
+pl_set_marker(PreLexerState* state)
 {
 	state->mark_index = state->next_index;
 }
 
 /* Get marked substring. To be used for error reporting. */
-gchar *
-pl_get_marked_substring(const PreLexerState * state)
+gchar*
+pl_get_marked_substring(const PreLexerState* state)
 {
 	return g_strndup(state->stream + state->mark_index, state->next_index - state->mark_index);
 }
 
 /* Compares a list of strings with given unichar. To be used by pl_get_next_token() only. */
-static gint
+static gboolean
 pl_compare_all(const gunichar ch, const gint count, gchar *arr[])
 {
 	gint l;
 	for(l = 0; l < count; l++)
 	{
 		if(ch == g_utf8_get_char_validated(arr[l], -1))
-			return 1;
+			return TRUE;
 	}
-	return 0;
+	return FALSE;
 }
 
 /* Pre-Lexer tokanizer. To be called only by Lexer. */
 LexerTokenType
-pl_get_next_token(PreLexerState * state)
+pl_get_next_token(PreLexerState* state)
 {
 	gunichar ch = pl_get_next_gunichar(state);
 	if(pl_compare_all(ch, 2, (gchar*[]){",","."}))
 		return T_PERCENTAGE;
 
 	if(pl_compare_all(ch, 4, (gchar*[]){" ","\r","\t","\n"}))
-		return PL_SKIP;		/* Gotta ignore'Em all!!! ;) */
+	/* Gotta ignore'Em all!!! ;) */
+		return PL_SKIP;
 
 	if(ch == 0)
-		return PL_EOS;		/* Least chance of this happening. Thus at the end. */
+		return PL_EOS;
 
 	/* There is no spoon. */
 	return T_UNKNOWN;
 } LexerTokenType;
 
 /* Creates a scanner state. Useful when multiple scanners are in action. */
-PreLexerState *pl_create_scanner(const gchar *);
+PreLexerState* pl_create_scanner(const gchar*);
 
 /* Destroy and free memory used by LexerState object. */
-void pl_destroy_scanner(PreLexerState *);
+void pl_destroy_scanner(PreLexerState*);
 
 /* Roll back last scanned unichar. */
-void pl_roll_back(PreLexerState *);
+void pl_roll_back(PreLexerState*);
 
 /* Get validated gunichar from input stream. */
-gunichar pl_get_next_gunichar(PreLexerState *);
+gunichar pl_get_next_gunichar(PreLexerState*);
 
 /* Set marker index. To be used for highlighting and error reporting. */
-void pl_set_marker(PreLexerState *);
+void pl_set_marker(PreLexerState*);
 
 /* Get marked substring. To be used for error reporting. */
-gchar *pl_get_marked_substring(const PreLexerState *);
+gchar* pl_get_marked_substring(const PreLexerState*);
 
 /* Get next Pre-Lexer token from stream. */
-LexerTokenType pl_get_next_token(PreLexerState *);
+LexerTokenType pl_get_next_token(PreLexerState*);
 
 #endif /* PRE_LEXER_H */