Add getLiteralStringDef and simplify with it

This commit is contained in:
Joseph C. Sible 2020-02-09 21:36:38 -05:00
parent f8648e5465
commit 4d92a2e15c
4 changed files with 12 additions and 8 deletions

View file

@ -1066,7 +1066,7 @@ checkNumberComparisons params (TC_Binary id typ op lhs rhs) = do
checkStrings =
mapM_ stringError . take 1 . filter isNonNum
isNonNum t = not . all numChar . runIdentity $ getLiteralStringExt (const $ return "") t
isNonNum t = not . all numChar $ onlyLiteralString t
numChar x = isDigit x || x `elem` "+-. "
stringError t = err (getId t) 2170 $
@ -2593,7 +2593,7 @@ checkTildeInPath _ (T_SimpleCommand _ vars _) =
warn id 2147 "Literal tilde in PATH works poorly across programs."
checkVar _ = return ()
hasTilde t = '~' `elem` runIdentity (getLiteralStringExt (const $ return "") t)
hasTilde t = '~' `elem` onlyLiteralString t
isQuoted T_DoubleQuoted {} = True
isQuoted T_SingleQuoted {} = True
isQuoted _ = False