sas             Thu Mar  8 10:43:52 2001 EDT

  Modified files:              
    /php4/ext/ircg      ircg_scanner.re 
  Log:
  Add handling for underline/bold control sequences
  
  
Index: php4/ext/ircg/ircg_scanner.re
diff -u php4/ext/ircg/ircg_scanner.re:1.6 php4/ext/ircg/ircg_scanner.re:1.7
--- php4/ext/ircg/ircg_scanner.re:1.6   Sat Mar  3 13:22:13 2001
+++ php4/ext/ircg/ircg_scanner.re       Thu Mar  8 10:43:52 2001
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: ircg_scanner.re,v 1.6 2001/03/03 21:22:13 sas Exp $ */
+/* $Id: ircg_scanner.re,v 1.7 2001/03/08 18:43:52 sas Exp $ */
 
 #include <ext/standard/php_smart_str.h>
 #include <stdio.h>
@@ -54,6 +54,8 @@
        int bg_code;
        int fg_code;
        int font_tag_open;
+       int bold_tag_open;
+       int underline_tag_open;
        
        smart_str scheme;
        smart_str *result;
@@ -68,6 +70,8 @@
 digit = [0-9];
 scheme = alpha alnum*;
 coloresc = "";
+bold = "";
+underline = "";
 */
 
 #define YYFILL(n) { }
@@ -129,6 +133,34 @@
        }
 }
 
+static void handle_bold(STD_PARA, int final)
+{
+       switch (ctx->bold_tag_open) {
+       case 0:
+               if (!final) smart_str_appends(ctx->result, "<b>");
+               break;
+       case 1:
+               smart_str_appends(ctx->result, "</b>");
+               break;
+       }
+
+       ctx->bold_tag_open = 1 - ctx->bold_tag_open;
+}
+
+static void handle_underline(STD_PARA, int final)
+{
+       switch (ctx->underline_tag_open) {
+       case 0:
+               if (!final) smart_str_appends(ctx->result, "<ul>");
+               break;
+       case 1:
+               smart_str_appends(ctx->result, "</ul>");
+               break;
+       }
+
+       ctx->underline_tag_open = 1 - ctx->underline_tag_open;
+}
+
 static void commit_color_stuff(STD_PARA)
 {
        finish_color_stuff(STD_ARGS);
@@ -158,7 +190,7 @@
 
        mctx.result = result;
        mctx.scheme.c = NULL;
-       mctx.font_tag_open = 0;
+       mctx.font_tag_open = mctx.bold_tag_open = mctx.underline_tag_open = 0;
        
        if (msg_len == -1)
                msg_len = strlen(msg);
@@ -178,7 +210,9 @@
        "<"                             { add_entity(STD_ARGS, "&lt;"); continue; }
        ">"                             { add_entity(STD_ARGS, "&gt;"); continue; }
        "&"                             { add_entity(STD_ARGS, "&amp;"); continue; }
-       (anynoneof\([<>&])) (anynoneof\[/])*           { passthru(STD_ARGS); 
continue; }
+       bold                    { handle_bold(STD_ARGS, 0); continue; }
+       underline               { handle_underline(STD_ARGS, 0); continue; }
+       (anynoneof\([<>&])) (anynoneof\[/])*         { passthru(STD_ARGS); 
+continue; }
        anynoneof               { passthru(STD_ARGS); continue; }
        eof                             { goto stop; }
 */
@@ -226,4 +260,6 @@
        smart_str_free(&ctx->scheme);
 
        finish_color_stuff(STD_ARGS);
+       handle_bold(STD_ARGS, 1);
+       handle_underline(STD_ARGS, 1);
 }



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to