@@ -111,44 +111,50 @@ trap 'exit 44' USR1 # exit with a nonzero status when no results found
111111 gsub("[[:space:]]+", ".*", pattern) # treat whitespace as wildcards
112112 pattern = ignorecase(pattern) # emulate IGNORECASE=1 for POSIX
113113 if (pattern == "") pattern = "^." # grouped by leading character
114+ FS = "\t" # fields are separated by tabs
114115 }
115- NR == 1 { print "<table>" }
116- $2 == "=" { result[$1] = substr($0, index($0, $2) + length($2) + 1) }
117- $1 == "from" { result["from"] = wordbreak_cached(result["from"], "<wbr>") }
118- $1 == "name" {
116+ NR == 1 {
117+ print "<table>"
118+ }
119+ {
120+ name = $1
121+ from = wordbreak_cached($2, "<wbr>")
122+ type = $3
123+ url = $4
124+
119125 # mark search terms with STX and ETX bytes which are ignored by escape()
120126 if (pattern) {
121- gsub(pattern, "\002&\003", result[" name"] )
127+ gsub(pattern, "\002&\003", name)
122128 }
123129
124130 # mark word-wrappable points with VT bytes which are ignored by escape()
125- result[" name"] = wordbreak(result[" name"] , "\v", "\002\003")
131+ name = wordbreak(name, "\v", "\002\003")
126132
127133 # escape XML entities in search result to make them visible in browsers
128- result[" name"] = escape(result[" name"] )
134+ name = escape(name)
129135
130136 # insert word-break opportunity <wbr> tags at points marked by VT bytes
131- gsub("\v", "<wbr>", result[" name"] )
137+ gsub("\v", "<wbr>", name)
132138
133139 # highlight search terms in search result using the STX and ETX markers
134140 if (pattern) {
135- gsub("\002", "<b><i><u>", result[" name"] )
136- gsub("\003", "</u></i></b>", result[" name"] )
141+ gsub("\002", "<b><i><u>", name)
142+ gsub("\003", "</u></i></b>", name)
137143 }
138- }
139- $1 == "url" { print \
140- "<tr>"\
141- "<td><a href=\"" result[" url"] "\">" result[" name"] "</a></td>"\
142- "<td valign=\"bottom\" align=\"right\">" result[" from"] "</td>"\
143- "<td valign=\"bottom\">" tolower(result[" type"] ) "</td>"\
144- "</tr>"
144+
145+ print \
146+ "<tr>"\
147+ "<td><a href=\"" url "\">" name "</a></td>"\
148+ "<td valign=\"bottom\" align=\"right\">" from "</td>"\
149+ "<td valign=\"bottom\">" tolower(type) "</td>"\
150+ "</tr>"
145151 }
146152 END {
147153 if (NR > 0) {
148154 print "</table>"
149- if (NR == 4 ) {
155+ if (NR == 1 ) {
150156 # there was only one search result, so automatically visit its url
151- print "<meta http-equiv=\"refresh\" content=\"0;url=" result[" url"] "\">"
157+ print "<meta http-equiv=\"refresh\" content=\"0;url=" url "\">"
152158 }
153159 }
154160 }
0 commit comments