From 0484d0232b561f7185930304be45739ff8bf0b77 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Wed, 13 Jan 2021 16:56:24 +1100 Subject: [PATCH] Dont use pointer for commment prefs (avoid nil) --- pkg/yqlib/expression_tokeniser.go | 8 ++++---- pkg/yqlib/operator_comments.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/yqlib/expression_tokeniser.go b/pkg/yqlib/expression_tokeniser.go index 9cdec47c..98c2ad62 100644 --- a/pkg/yqlib/expression_tokeniser.go +++ b/pkg/yqlib/expression_tokeniser.go @@ -125,7 +125,7 @@ func assignAllCommentsOp(updateAssign bool) lex.Action { Value: assignCommentOpType.Type, StringValue: value, UpdateAssign: updateAssign, - Preferences: &commentOpPreferences{LineComment: true, HeadComment: true, FootComment: true}, + Preferences: commentOpPreferences{LineComment: true, HeadComment: true, FootComment: true}, } return &token{TokenType: operationToken, Operation: op}, nil } @@ -252,11 +252,11 @@ func initLexer() (*lex.Lexer, error) { lexer.Add([]byte(`fi`), opToken(getFileIndexOpType)) lexer.Add([]byte(`path`), opToken(getPathOpType)) - lexer.Add([]byte(`lineComment`), opTokenWithPrefs(getCommentOpType, assignCommentOpType, &commentOpPreferences{LineComment: true})) + lexer.Add([]byte(`lineComment`), opTokenWithPrefs(getCommentOpType, assignCommentOpType, commentOpPreferences{LineComment: true})) - lexer.Add([]byte(`headComment`), opTokenWithPrefs(getCommentOpType, assignCommentOpType, &commentOpPreferences{HeadComment: true})) + lexer.Add([]byte(`headComment`), opTokenWithPrefs(getCommentOpType, assignCommentOpType, commentOpPreferences{HeadComment: true})) - lexer.Add([]byte(`footComment`), opTokenWithPrefs(getCommentOpType, assignCommentOpType, &commentOpPreferences{FootComment: true})) + lexer.Add([]byte(`footComment`), opTokenWithPrefs(getCommentOpType, assignCommentOpType, commentOpPreferences{FootComment: true})) lexer.Add([]byte(`comments\s*=`), assignAllCommentsOp(false)) lexer.Add([]byte(`comments\s*\|=`), assignAllCommentsOp(true)) diff --git a/pkg/yqlib/operator_comments.go b/pkg/yqlib/operator_comments.go index 95b528b4..b66cba59 100644 --- a/pkg/yqlib/operator_comments.go +++ b/pkg/yqlib/operator_comments.go @@ -23,7 +23,7 @@ func assignCommentsOperator(d *dataTreeNavigator, matchingNodes *list.List, expr return nil, err } - preferences := expressionNode.Operation.Preferences.(*commentOpPreferences) + preferences := expressionNode.Operation.Preferences.(commentOpPreferences) comment := "" if !expressionNode.Operation.UpdateAssign { @@ -67,7 +67,7 @@ func assignCommentsOperator(d *dataTreeNavigator, matchingNodes *list.List, expr } func getCommentsOperator(d *dataTreeNavigator, matchingNodes *list.List, expressionNode *ExpressionNode) (*list.List, error) { - preferences := expressionNode.Operation.Preferences.(*commentOpPreferences) + preferences := expressionNode.Operation.Preferences.(commentOpPreferences) log.Debugf("GetComments operator!") var results = list.New()