jaytea commented on a Page, Simple Highlight  -  Nov 22, 2010

napa, are you suggesting we use/distribute code that we know to be flawed just because the situation in which it fails is rare and we haven't encountered it yet?

this reminds me of a comment i read here a little while ago, something about claiming a certain small line of code was correct simply because it was used within a much larger script that appeared to work properly.

we should not judge a single line of code such as 'if ($highlight($1-)) {' by its performance in larger scripts; instead, we should examine it in isolation, consider what it's being used for, and try to identify potential problems. if we are using it to detect lines of text ($1-) matched by an entry in our highlight list, and we know that $highlight() can also be used to return the Nth entry in the list, then it should be clear that the following IRC mmessage will result in a false positive:

<Nick> 1

this should be enough of a potential problem to warrant a 3 character fix, with an optional comment describing it since the reason for $lf there might not be clear to your future self or someone looking through your code.

Gummo, i believe what Jethro means to say is that mIRC's highlight system (which supports both the standard 'not surrounded by alphanumeric characters' check i described before, regular expressions, and even evaluates variables and identifiers used as highlight entries) is usually powerful enough for most applications. using it over theme related on TEXT etc. events wherever possible, even in ways that might be considered clumsy and hack-ish, is advisable since things like nick colors (/cnick) and excess spaces are handled implicitly by mIRC. here's an example of using the highlight system in such as way (colouring messages based on channel status), last post in: http://trout.snt.utwente.nl/ubbthreads/ubbthreads.php?ubb=showflat&Board=3&Number=225765

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.