summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2010-05-27 11:55:36 -0700
committerCarl Worth <cworth@cworth.org>2010-05-27 11:55:36 -0700
commita65cf7b1d29e98ef3bf31051df8a06cb394d131f (patch)
tree114b63644453263f82b5b537d3d8689bde663fba
parentdd7490093d84ce74a99922c3544b51c3f5d43345 (diff)
Make two list-processing functions do nothing with an empty list.
This just makes these functions easier to understand all around. In the case of _token_list_append_list this is an actual bug fix, (where append an empty list onto a non-empty list would previously scramble the tail pointer of the original list).
-rw-r--r--glcpp-parse.y5
1 files changed, 4 insertions, 1 deletions
diff --git a/glcpp-parse.y b/glcpp-parse.y
index b2684d0..ba79a61 100644
--- a/glcpp-parse.y
+++ b/glcpp-parse.y
@@ -666,6 +666,9 @@ _token_list_append (token_list_t *list, token_t *token)
void
_token_list_append_list (token_list_t *list, token_list_t *tail)
{
+ if (tail == NULL || tail->head == NULL)
+ return;
+
if (list->head == NULL) {
list->head = tail->head;
} else {
@@ -1218,7 +1221,7 @@ _glcpp_parser_expand_token_list_onto (glcpp_parser_t *parser,
token_list_t *intermediate, *list_orig = list;
int i, need_rescan = 0;
- if (list == NULL)
+ if (list == NULL || list->head == NULL)
return;
intermediate = _token_list_create (parser);