On Sun, Sep 28, 2008 at 08:15:09PM -0000, [EMAIL PROTECTED] wrote:
> Author: uwestoehr
> Date: Sun Sep 28 22:15:08 2008
> New Revision: 26603
> 
> URL: http://www.lyx.org/trac/changeset/26603
> Log:
> tex2lyx/preamble.cpp: fix bug 19, patch by JMarc (I'm working with this patch 
> for 4 months now and it is really stable.)
> 
> Modified:
>     lyx-devel/trunk/src/tex2lyx/preamble.cpp
> 
> -             else if (t.cat() == catSpace || t.cat() == catNewline)
> +             if (!in_lyx_preamble &&
> +                 (t.cat() == catLetter ||
> +                  t.cat() == catSuper ||
> +                  t.cat() == catSub ||
> +                  t.cat() == catOther ||
> +                  t.cat() == catMath ||
> +                  t.cat() == catActive ||
> +                  t.cat() == catBegin ||
> +                  t.cat() == catEnd ||
> +                  t.cat() == catAlign ||
> +                  t.cat() == catParameter))
> +                     h_preamble << t.character();
> +
> +             else if (!in_lyx_preamble && 
> +                      (t.cat() == catSpace || t.cat() == catNewline))
>                       h_preamble << t.asInput();
>  
> -             else if (t.cat() == catComment)
> -                     h_preamble << t.asInput();
> +             else if (t.cat() == catComment) {
> +                     // regex to parse comments
> +                     static regex const islyxfile("%% LyX .* created this 
> file");
> +                     static regex const usercommands("User specified LaTeX 
> commands");       
> +                     
> +                     string const comment = t.asInput();
> +                     cerr << "Seen comment: " << comment << std::endl;
> +                     smatch sub;
> +                     if (regex_search(comment, sub, islyxfile))
> +                             is_lyx_file = true;
> +                     else if (is_lyx_file 
> +                              && regex_search(comment, sub, usercommands))

Not sure such simple matches require a regexp. 

Andre'

Reply via email to