From 2b0fc3c3a84b525557c012562786828371f71abc Mon Sep 17 00:00:00 2001 From: John Maddock Date: Thu, 30 Nov 2000 12:05:15 +0000 Subject: [PATCH] regex: updated snip4.cpp (fixed patholgical expressions). [SVN r8366] --- changes.txt | 9 +++++++++ demo/snippets/snip4.cpp | 26 +++++++++++++------------- template_class_ref.htm | 36 ++++++++++++++++++------------------ 3 files changed, 40 insertions(+), 31 deletions(-) diff --git a/changes.txt b/changes.txt index 82ed0ad3..1c7865bd 100644 --- a/changes.txt +++ b/changes.txt @@ -1,3 +1,11 @@ +FIXED: Pathological regular expressions in snip4.cpp and in docs. +FIXED: Missing std:: prefixes in some headers. + +Version 302: +FIXED: STLPort debug problems. +FIXED: Compatibility with updated Dinkum libraries and VC6. +ADDED: Tentative support for partial matches (not yet documented). + Version 301: First boost release version, CHANGED: reg_match to match_results @@ -209,5 +217,6 @@ BUG: character sets don't function correctly when regbase::char_classes + diff --git a/demo/snippets/snip4.cpp b/demo/snippets/snip4.cpp index 87124161..cacf3be6 100644 --- a/demo/snippets/snip4.cpp +++ b/demo/snippets/snip4.cpp @@ -88,14 +88,14 @@ extern const char* pre_format = "(?1<)(?2>)"; const char* expression_text = // preprocessor directives: index 1 - "(^[[:blank:]]*#([^\\n]*\\\\[[:space:]]+)*[^\\n]*)|" - // comment: index 3 - "(//[^\\n]*|/\\*([^*]|\\*+[^*/])*\\*+/)|" - // literals: index 5 - "\\<([+-]?((0x[[:xdigit:]]+)|(([[:digit:]]*\\.)?[[:digit:]]+([eE][+-]?[[:digit:]]+)?))u?((int(8|16|32|64))|L)?)\\>|" - // string literals: index 14 - "('([^\\\\']|\\\\.)*'|\"([^\\\\\"]|\\\\.)*\")|" - // keywords: index 17 + "(^[[:blank:]]*#(?:[^\\\\\\n]|\\\\[^\\n[:punct:][:word:]]*[\\n[:punct:][:word:]])*)|" + // comment: index 2 + "(//[^\\n]*|/\\*.*?\\*/)|" + // literals: index 3 + "\\<([+-]?(?:(?:0x[[:xdigit:]]+)|(?:(?:[[:digit:]]*\\.)?[[:digit:]]+(?:[eE][+-]?[[:digit:]]+)?))u?(?:(?:int(?:8|16|32|64))|L)?)\\>|" + // string literals: index 4 + "('(?:[^\\\\']|\\\\.)*'|\"(?:[^\\\\\"]|\\\\.)*\")|" + // keywords: index 5 "\\<(__asm|__cdecl|__declspec|__export|__far16|__fastcall|__fortran|__import" "|__pascal|__rtti|__stdcall|_asm|_cdecl|__except|_export|_far16|_fastcall" "|__finally|_fortran|_import|_pascal|_stdcall|__thread|__try|asm|auto|bool" @@ -108,16 +108,16 @@ const char* expression_text = // preprocessor directives: index 1 ; const char* format_string = "(?1$&)" - "(?3$&)" - "(?5$&)" - "(?14$&)" - "(?17$&)"; + "(?2$&)" + "(?3$&)" + "(?4$&)" + "(?5$&)"; const char* header_text = "\n\n" "Auto-generated html formated source\n" "\n" "\n" - "\n" + "\n" "

\n
";
 
 const char* footer_text = "
\n\n\n"; diff --git a/template_class_ref.htm b/template_class_ref.htm index 6eeb2e54..86ad2ded 100644 --- a/template_class_ref.htm +++ b/template_class_ref.htm @@ -2053,7 +2053,7 @@ follows:
takes C/C++ source code as input, and outputs syntax highlighted HTML code.

-
#include <iostream>
+
 #include <fstream>
 #include <sstream>
 #include <string>
@@ -2082,8 +2082,8 @@ boost::regex e1, e2;
    while(is.get(c))
    {
       if(s.capacity() == s.size())
-         s.reserve(s.capacity() * 3);
-      s.append(1, c);
+         s.reserve(s.capacity() * 3);
+      s.append(1, c);
    }
 }
 
@@ -2105,12 +2105,12 @@ color="#0000FF">".htm"));
       // temporary string stream
       std::ostringstream t(std::ios::out | std::ios::binary);
       std::ostream_iterator<char, char> oi(t);
-      regex_merge(oi, in.begin(), in.end(), e2, pre_format);
+      boost::regex_merge(oi, in.begin(), in.end(), e2, pre_format);
       // then output to final output stream
       // adding syntax highlighting:
       std::string s(t.str());
       std::ostream_iterator<char, char> out(os);
-      regex_merge(out, s.begin(), s.end(), e1, format_string);
+      boost::regex_merge(out, s.begin(), s.end(), e1, format_string);
       os << footer_text;
    }
    return 0;
@@ -2123,14 +2123,14 @@ color="#0000FF">"(?1<)(?2>)";
 
 
 const char* expression_text = // preprocessor directives: index 1
-                              "(^[[:blank:]]*#([^\\n]*\\\\[[:space:]]+)*[^\\n]*)|"
-                              // comment: index 3
-                              "(//[^\\n]*|/\\*([^*]|\\*+[^*/])*\\*+/)|"
-                              // literals: index 5
-                              "\\<([+-]?((0x[[:xdigit:]]+)|(([[:digit:]]*\\.)?[[:digit:]]+([eE][+-]?[[:digit:]]+)?))u?((int(8|16|32|64))|L)?)\\>|"
-                              // string literals: index 14
-                              "('([^\\\\']|\\\\.)*'|\"([^\\\\\"]|\\\\.)*\")|"
-                              // keywords: index 17
+                              "(^[[:blank:]]*#(?:[^\\\\\\n]|\\\\[^\\n[:punct:][:word:]]*[\\n[:punct:][:word:]])*)|"
+                              // comment: index 2
+                              "(//[^\\n]*|/\\*.*?\\*/)|"
+                              // literals: index 3
+                              "\\<([+-]?(?:(?:0x[[:xdigit:]]+)|(?:(?:[[:digit:]]*\\.)?[[:digit:]]+(?:[eE][+-]?[[:digit:]]+)?))u?(?:(?:int(?:8|16|32|64))|L)?)\\>|"
+                              // string literals: index 4
+                              "('(?:[^\\\\']|\\\\.)*'|\"(?:[^\\\\\"]|\\\\.)*\")|"
+                              // keywords: index 5
                               "\\<(__asm|__cdecl|__declspec|__export|__far16|__fastcall|__fortran|__import"
                               "|__pascal|__rtti|__stdcall|_asm|_cdecl|__except|_export|_far16|_fastcall"
                               "|__finally|_fortran|_import|_pascal|_stdcall|__thread|__try|asm|auto|bool"
@@ -2143,16 +2143,16 @@ color="#0000FF">"(?1<)(?2>)";
                               ;
 
 const char* format_string = "(?1<font color=\"#008040\">$&</font>)"
-                            "(?3<I><font color=\"#000080\">$&</font></I>)"
-                            "(?5<font color=\"#0000A0\">$&</font>)"
-                            "(?14<font color=\"#0000FF\">$&</font>)"
-                            "(?17<B>$&</B>)";
+                            "(?2<I><font color=\"#000080\">$&</font></I>)"
+                            "(?3<font color=\"#0000A0\">$&</font>)"
+                            "(?4<font color=\"#0000FF\">$&</font>)"
+                            "(?5<B>$&</B>)";
 
 const char* header_text = "<HTML>\n<HEAD>\n"
                           "<TITLE>Auto-generated html formated source</TITLE>\n"
                           "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=windows-1252\">\n"
                           "</HEAD>\n"
-                          "<BODY LINK=\"#0000ff\" VLINK=\"#800080\" BGCOLOR=\"#ffff99\">\n"
+                          "<BODY LINK=\"#0000ff\" VLINK=\"#800080\" BGCOLOR=\"#ffffff\">\n"
                           "<P> </P>\n<PRE>";
 
 const char* footer_text = "</PRE>\n</BODY>\n\n";