diff options
Diffstat (limited to 'pkgtools/pkglint/files/varusecontext.go')
-rw-r--r-- | pkgtools/pkglint/files/varusecontext.go | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/pkgtools/pkglint/files/varusecontext.go b/pkgtools/pkglint/files/varusecontext.go deleted file mode 100644 index cf0e4e61668..00000000000 --- a/pkgtools/pkglint/files/varusecontext.go +++ /dev/null @@ -1,75 +0,0 @@ -package main - -// VarUseContext defines the context in which a variable is defined -// or used. Whether that is allowed depends on: -// -// * The variable’s data type, as defined in vardefs.go. -// * When used on the right-hand side of an assigment, the variable can -// represent a list of words, a single word or even only part of a -// word. This distinction decides upon the correct use of the :Q -// operator. -// * When used in preprocessing statements like .if or .for, the other -// operands of that statement should fit to the variable and are -// checked against the variable type. For example, comparing OPSYS to -// x86_64 doesn’t make sense. -type VarUseContext struct { - time vucTime - vartype *Vartype - shellword vucQuoting - extent vucExtent -} - -type vucTime int - -const ( - vucTimeUnknown vucTime = iota - - // When Makefiles are loaded, the operators := and != are evaluated, - // as well as the conditionals .if, .elif and .for. - // During loading, not all variables are available yet. - // Variable values are still subject to change, especially lists. - vucTimeParse - - // All files have been read, all variables can be referenced. - // Variable values don’t change anymore. - vucTimeRun -) - -// The quoting context in which the variable is used. -// Depending on this context, the modifiers :Q or :M can be allowed or not. -type vucQuoting int - -const ( - vucQuotUnknown vucQuoting = iota - vucQuotPlain // Example: echo LOCALBASE=${LOCALBASE} - vucQuotDquot // Example: echo "The version is ${PKGVERSION}." - vucQuotSquot // Example: echo 'The version is ${PKGVERSION}.' - vucQuotBackt // Example: echo \`sed 1q ${WRKSRC}/README\` - - // The .for loop in Makefiles. This is the only place where - // variables are split on whitespace. Everywhere else (:Q, :M) - // they are split like in the shell. - // - // Example: .for f in ${EXAMPLE_FILES} - vucQuotFor -) - -type vucExtent int - -const ( - vucExtentUnknown vucExtent = iota - vucExtentWord // Example: echo ${LOCALBASE} - vucExtentWordpart // Example: echo LOCALBASE=${LOCALBASE} -) - -func (vuc *VarUseContext) String() string { - typename := "no-type" - if vuc.vartype != nil { - typename = vuc.vartype.String() - } - return sprintf("(%s %s %s %s)", - []string{"unknown", "load-time", "run-time"}[vuc.time], - typename, - []string{"unknown", "plain", "dquot", "squot", "backt", "for"}[vuc.shellword], - []string{"unknown", "word", "word-part"}[vuc.extent]) -} |