Commit c8c248e0 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

Minor code cleanup.

* src/libraries/libcommon/parser.c (parse): Code cleanup: get rid
of one level of indentation, and avoid using multiple ways to get
to the next iteration of the main loop.
parent e59d09df
2005-12-25 Per Cederqvist <ceder@lysator.liu.se>
Minor code cleanup.
* src/libraries/libcommon/parser.c (parse): Code cleanup: get rid
of one level of indentation, and avoid using multiple ways to get
to the next iteration of the main loop.
2005-12-24 Per Cederqvist <ceder@lysator.liu.se>
 
Writing to a client that was disconnecting and blocked could cause
......
......@@ -359,73 +359,73 @@ parse (String source_string,
highest_priority = 1;
while (match_table[++index].conf_no != 0)
{
if (! s_empty (match_table[index].name))
{
first_non_matching = match (source_words, match_table[index].tokens,
collat_tab);
if ( ( ! allow_trailing_words
&& first_non_matching < no_of_source_words)
|| ( number_of_words_must_match == TRUE
&& first_non_matching != count_words (match_table[index].tokens)))
{
continue; /* Try next entry in table */
}
if (first_non_matching < best_match)
continue; /* Try next entry in table */
if ( first_non_matching == best_match
&& highest_priority > match_table[index].priority)
continue;
/* If we reach this far, then we have a match that should be
* inserted in the table. But if it is a better match than any
* before, then we clear the table first. */
if ( first_non_matching > best_match
|| match_table[index].priority > highest_priority)
{
highest_priority = match_table[index].priority;
best_match = first_non_matching;
answer.no_of_matches = 0;
}
/* Insert the match in the table */
/* Increase the size if necessary */
if (answer.no_of_matches >= size_of_index_list)
{
temp_indexes = REALLOC (answer.indexes,
(size_of_index_list += chunk_size)
* sizeof(answer.indexes));
if (temp_indexes == NULL)
{
/* Grumble! Out of memory. */
FREE (source_words);
FREE (answer.indexes);
answer.no_of_matches = -1;
return answer;
}
answer.indexes = temp_indexes;
}
highest_priority = match_table [index].priority;
answer.indexes[answer.no_of_matches] = index;
/* Find out where the arguments start.
* This value should not be used if more than one match is found.
*/
/* Special hack needed if no parameters */
if (s_empty (source_words [first_non_matching].word))
answer.arguments = EMPTY_STRING;
else
answer.arguments =
s_fsubstr(source_string,
source_words[first_non_matching].
start_in_string,
END_OF_STRING);
answer.no_of_matches++;
}
if (s_empty (match_table[index].name))
continue;
first_non_matching = match (source_words, match_table[index].tokens,
collat_tab);
if ( ( ! allow_trailing_words
&& first_non_matching < no_of_source_words)
|| ( number_of_words_must_match == TRUE
&& first_non_matching != count_words (match_table[index].tokens)))
{
continue; /* Try next entry in table */
}
if (first_non_matching < best_match)
continue; /* Try next entry in table */
if ( first_non_matching == best_match
&& highest_priority > match_table[index].priority)
continue;
/* If we reach this far, then we have a match that should be
* inserted in the table. But if it is a better match than any
* before, then we clear the table first. */
if ( first_non_matching > best_match
|| match_table[index].priority > highest_priority)
{
highest_priority = match_table[index].priority;
best_match = first_non_matching;
answer.no_of_matches = 0;
}
/* Insert the match in the table */
/* Increase the size if necessary */
if (answer.no_of_matches >= size_of_index_list)
{
temp_indexes = REALLOC (answer.indexes,
(size_of_index_list += chunk_size)
* sizeof(answer.indexes));
if (temp_indexes == NULL)
{
/* Grumble! Out of memory. */
FREE (source_words);
FREE (answer.indexes);
answer.no_of_matches = -1;
return answer;
}
answer.indexes = temp_indexes;
}
highest_priority = match_table [index].priority;
answer.indexes[answer.no_of_matches] = index;
/* Find out where the arguments start.
* This value should not be used if more than one match is found.
*/
/* Special hack needed if no parameters */
if (s_empty (source_words [first_non_matching].word))
answer.arguments = EMPTY_STRING;
else
answer.arguments =
s_fsubstr(source_string,
source_words[first_non_matching].
start_in_string,
END_OF_STRING);
answer.no_of_matches++;
}
/* All matches found by now */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment