To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.admin.generalOpen lugnet.admin.general in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Administrative / General / 2881
2880  |  2882
Subject: 
DAT line parsing (was: Re: Datsville: crane2 (exponents?))
Newsgroups: 
lugnet.cad.dat.models, lugnet.cad.dev, lugnet.admin.general
Followup-To: 
lugnet.cad.dev
Date: 
Tue, 14 Sep 1999 18:10:25 GMT
Viewed: 
2866 times
  
In lugnet.cad.dat.models, John VanZwieten writes:
> In lugnet.cad.dat.models, Kevin Loch writes:
> > For some reason, the lines with exponents don't render in ldlite when
> > I use the dat hyperlink in web mode.  ldlite,ldraw and l3p/povray
> > render them fine locally.  I made it in MLcad.  Is this a bug?
> > There is no need for e-15 exponents anyway so I substituted 0 for all
> > exponents. let's try it again.
> 
> If not a bug, at least a nit.  I think if you open the file in LDAO's
> editor, select the whole text and MoveExact by 1, then move it all back,
> LDAO will get rid of the exponents.

My bad.  'Twas a bug in the code in the ldraw.cgi script on the server which
recognized DAT content.  It wasn't expecting 'e' exponents in numbers.

The old regex (just the non-type-0 portion):

   /^ \s*
    [1-5]
    (?: \s+ [0-9]+ )
    (?: \s+ \-? [0-9]* \.? [0-9]* ){6,12}
    (?: \s+ \S+ \. [Dd][Aa][Tt] )?
    \s* $
   /x

The new regex (just the non-type-0 portion):

   /^ \s*
    [1-5]
    (?: \s+ [0-9]+ )
    (?: \s+ \-? [0-9]* (?: \. [0-9]* )?  (?: [Ee] [\-\+]? [0-9]+ )?  ){6,12}
    (?: \s+ \S+ \. [Dd][Aa][Tt] )?
    \s* $
   /x

This is better in that it now accepts 'e' exponents, but it still gives
false positives on any malformed lines which it might encounter, for example
a type-2 line ending in ".DAT" or containing 13 arguments rather than 7, etc.

If anyone has a Perl5 regex which handles all styles of DAT-content lines
with no false positivies and which isn't non-understandably complex[1] and
doesn't do excessive backtracking, please send it my way!

Also, if anyone knows of any other "funny stuff" that Turbo Pascal might
embed on a line, I'd like to know that too.  (Exponents aren't really "funny
stuff," but I was very surprised to see them output because so many DAT files
have the numbers chopped 2 or 3 places after the decimal point.)

--Todd

[1] for example, the 6598-byte long e-mail address regex in Appendix B of the
wise-owls book is something I'd call "non-understandably complex."  :)

(followups to lugnet.cad.dev)



Message has 1 Reply:
  Re: DAT line parsing (was: Re: Datsville: crane2 (exponents?))
 
(...) <Snipped Regex stuff> (...) Those numbers weren't generated by Turbo Pascal (LEdit). They were generated by MLCad, the recent Windows LDraw program. This is one of the reasons I haven't used it very extensively. :) Jeff (27 years ago, 14-Sep-99, to lugnet.cad.dev)

Message is in Reply To:
  Re: Datsville: crane2 (exponents?)
 
(...) If not a bug, at least a nit. I think if you open the file in LDAO's editor, select the whole text and MoveExact by 1, then move it all back, LDAO will get rid of the exponents. -John Van (27 years ago, 13-Sep-99, to lugnet.cad.dat.models)

8 Messages in This Thread:



Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR