+
+ if (result) {
+ /* we now have at least the address. now see if this is <bracketed>; in this
+ * case we also scan for the informative part. we could make this a useful
+ * function because it tries to parse out an email address backwards. :) */
+ if ( ((bp_ - 1 > start) && *(bp_ - 1) == '<') && (*ep_ == '>')) {
+ char closure_stack[128];
+ char *ptr = closure_stack;
+#define FULL_STACK() ((ptr - closure_stack) >= sizeof closure_stack)
+#define IN_STACK() (ptr > closure_stack)
+/* has underrun check */
+#define POP_STACK() if(IN_STACK()) --ptr
+/* has overrun check */
+#define PUSH_STACK(c) if(!FULL_STACK()) *ptr++ = (c); else return TRUE
+/* has underrun check */
+#define PEEK_STACK() (IN_STACK() ? *(ptr - 1) : 0)
+
+ ep_++;
+
+ /* scan for the informative part */
+ for (bp_ -= 2; bp_ >= start; bp_--) {
+ /* if closure on the stack keep scanning */
+ if (PEEK_STACK() == *bp_) {
+ POP_STACK();
+ }
+ else {
+ if (*bp_ == '\'' || *bp_ == '"') {
+ PUSH_STACK(*bp_);
+ }
+ else {
+ if (!PEEK_STACK()) {
+ /* if nothing in the closure stack, do the special conditions
+ * the following if..else expression simply checks whether
+ * a token is acceptable. if not acceptable, the clause
+ * should terminate the loop with a 'break' */
+ if ( *bp_ == '-'
+ && (((bp_ - 1) >= start) && isalnum(*(bp_ - 1)))
+ && (((bp_ + 1) < ep_) && isalnum(*(bp_ + 1))) ) {
+ /* hyphens are allowed, but only in between alnums */
+ }
+ else if ( !ispunct(*bp_) ) {
+ /* but anything not being a punctiation is ok */
+ }
+ else {
+ break; /* anything else is rejected */
+ }
+ }
+ }
+ }
+ }
+
+ bp_++;
+
+#undef PEEK_STACK
+#undef PUSH_STACK
+#undef POP_STACK
+#undef IN_STACK
+#undef FULL_STACK