This script manages the HTTP requests for identifier search.
countfiles ($refs)
Function countfiles
returns the number of files for the references.
$refs
a reference to an array containing the references
The result can be used to display a short informative message.
checkvalidref ($file)
Function checkvalidref
is a "$variable" substitution function. It returns CSS class name identinvalid
if the file timestamp is incorrect, meaning the file has been modified after genxref indexing. Otherwise, it returns an empty string.
$file
a string containing the filename to check
Bad referenced file counter is updated to note the existence of possible trouble.
expandwarning ($templ)
Function expandwarning
is a "$function" substitution function. It returns its argument if bad referenced file counter is not zero. Otherwise, it returns an empty string.
$templ
a string containing the template (i.e. argument)
The block for this marker should contain some warning message for inaccurate cross-references.
ref_in_file ($desc, $css, $path, $line)
Function ref_in_file
is an auxiliary front-end function to fileref
to handle the case of negative line numbers.
$desc
a string containing the visible text for the link
$css
a string containing HTML class
attribute
$path
a string containing the file name for the link
$line
an integer equal to the line number
A negative line number flags a match in case insensitive mode. The real identifier may differ in case from the search key. Such a reference will be marked identapprox
to flag the approximative match.
refsexpand ($templ, $refs)
Function refsexpand
is a "$function" substitution function. It returns an HTML string which is the concatenation of its expanded argument applied to every reference in array $refs
.
$templ
a string containing the template (i.e. argument)
$refs
a reference to an array containing the usages
The block may use one of two variants for the usages. The variant is detected from $lines
marker use in the template. Processing is then dispatched on the "one ref per line" (no $lines
marker) or "many refs per line" ($lines
marker used) processing.
This basic expansion function is used both for definitions and uses. The difference is driven by the block content.
CAVEAT:
The element of the references array is a list. This list does not contain the same number of items for definitions and usages. In case of modification (notably the database transactions), take care to keep the file name and the line number as the first two items in the lists. Correct operation relies on this constraint.
cmprefs ($a, $b)
Function cmprefs
compares its arguments and returns +1, 0 or +1 if the left argument precedes, is equal or follows the right argument.
$a
, $b
references to the arrays to compare
The references are arrays containing the file name and line number of the reference. For definitions, these elements are followed by type name and parent name.
Note:
For usages, the last two element do no exist. The comparison stops after the first two steps.
defsexpand ($templ)
Function defsexpand
is a "$function" substitution function. It returns an HTML string which is the concatenation of its expanded argument applied to every declaration.
$templ
a string containing the template (i.e. argument)
The function queries the database for definitions, then hands over definition layout to refsexpand
.
Since some languages are case-insensitive, the database is also queried for the case-insensitive version of the identifier. The returned definitions are flagged with their line numbers set negative. The two lists are merged, removing duplicates and sorted as if a single query was made.
usesexpand ($templ)
Function usesexpand
is a "$function" substitution function. It returns an HTML string which is the concatenation of its expanded argument applied to every usage.
$templ
a string containing the template (i.e. argument)
The function queries the database for usages, then hands over definition layout to refsexpand
.
Since some languages are case-insensitive, the database is also queried for the case-insensitive version of the identifier. The returned definitions are flagged with their line numbers set negative. The two lists are merged, removing duplicates and sorted as if a single query was made.
printident ()
Procedure printident
is the main driver for identifier search.
It retrieves template 'htmldir'
and expands it using the dedicated functions defined in this file.
Builds the header and footer and launches printident
for the real job.