View Single Post
Old 19 October 2014, 00:23   #17
emufan
Registered User
 
Join Date: Feb 2012
Location: #DrainTheSwamp
Posts: 4,545
it's horror - i'm playing with this reg-exp - we need some expert in regular expressions, which would solve this in minutes - incl. a tea-break

one of my perl-one-liner looks like this:
Code:
cat lxamiga-test.txt | perl -ne 'print   /\s*(.*?)\s+(\d+)/i ;  print "\n"'
these are the first two section of the line 290 reg-exp, matching f_name and f_size.

outputs:
Code:
:R:Kick.rom524288
RAM:Ram Disk133919704
DH0:System367976448
:DH0:System.hdf367976448
DH1:Data3628154880
:DH1:Data.hdf3628154880
content of lxamiga-test.txt :
Code:
  :R:Kick.rom                      524288 (rom) 15/07/93 00:00:00 AMIGA ROM Operating System and Libraries??Copyright ? 1985-1993 ??Commodore-Amiga, Inc. ??All Rights Reserved.??3.1 ROM 
  RAM:Ram Disk                   133919704 (vol) 06/07/94 12:50:00           
  DH0:System                     367976448 (vol) 06/07/94 12:50:00           
  :DH0:System.hdf                367976448 (hdf) 06/07/94 12:50:00 SEC:63 SUR:16 RES:2 PRE:0 SSZ:512 HCY:712 DOS:0x444F5303
  DH1:Data                       3628154880 (vol) 06/07/94 12:51:00           
  :DH1:Data.hdf                  3628154880 (hdf) 06/07/94 12:51:00 SEC:63 SUR:16 RES:2 PRE:0 SSZ:512 HCY:7029 DOS:0x444F5303
so with breaking apart the reg-exp from line 290, i try to find the wrong statement.
the reg-exp in 290 consists of 5 section - so it should match/find "$f_name, $f_size, $f_type, $f_date, $f_text" (line 289).

it's going to be a nightmare

edit: section #4 ($f_date) does not get matched correct.
Code:
?\s+(\d+\/\d+\/\d+\s+\d+:\d+)
which should match this part: 06/07/94 12:50:00
s is matching whitespace, and d matching digits, separated by "/" and ":" .
time field only gots matched by 2x \d+ , so this may be an issue

here is the reg-exp without the f_date section and it outputs til the end of line.
Code:
cat lxamiga-test.txt | perl -ne 'print   /\s*(.*?)\s+(\d+)\s+(?:\((\w+)\))\s(.*)/  ;  print "\n"'
outputs:
Code:
:R:Kick.rom524288rom15/07/93 00:00:00 AMIGA ROM Operating System and Libraries??Copyright ? 1985-1993 ??Commodore-Amiga, Inc. ??All Rights Reserved.??3.1 ROM
RAM:Ram Disk133919704vol06/07/94 12:50:00
DH0:System367976448vol06/07/94 12:50:00
:DH0:System.hdf367976448hdf06/07/94 12:50:00 SEC:63 SUR:16 RES:2 PRE:0 SSZ:512 HCY:712 DOS:0x444F5303
DH1:Data3628154880vol06/07/94 12:51:00
:DH1:Data.hdf3628154880hdf06/07/94 12:51:00 SEC:63 SUR:16 RES:2 PRE:0 SSZ:512 HCY:7029 DOS:0x444F5303
maybe we can fix this.

edit2:
now the full "fixed" regexp:
Code:
 cat lxamiga-test.txt | perl -ne 'print   /\s*(.*?)\s+(\d+)\s+(?:\((\w+)\))?\s+(\d+\/\d+\/\d+\s+\d+:\d+:\d+)\s(.*)/  ;  print "\n"'
outputs the whole line:
Code:
:R:Kick.rom524288rom15/07/93 00:00:00AMIGA ROM Operating System and Libraries??Copyright ? 1985-1993 ??Commodore-Amiga, Inc. ??All Rights Reserved.??3.1 ROM
RAM:Ram Disk133919704vol06/07/94 12:50:00
DH0:System367976448vol06/07/94 12:50:00
:DH0:System.hdf367976448hdf06/07/94 12:50:00SEC:63 SUR:16 RES:2 PRE:0 SSZ:512 HCY:712 DOS:0x444F5303
DH1:Data3628154880vol06/07/94 12:51:00
:DH1:Data.hdf3628154880hdf06/07/94 12:51:00SEC:63 SUR:16 RES:2 PRE:0 SSZ:512 HCY:7029 DOS:0x444F5303
hmm, cool.

so what you can do now, replace line 290:
original:
Code:
/\s*(.*?)\s+(\d+)\s+(?:\((\w+)\))?\s+(\d+\/\d+\/\d+\s+\d+:\d+)\s(.*)/);
with this new one:
Code:
/\s*(.*?)\s+(\d+)\s+(?:\((\w+)\))?\s+(\d+\/\d+\/\d+\s+\d+:\d+:\d+)\s(.*)/);
i just inserted a 3rd "\d+" for the seconds of the time field.
something should be different - at least i hope so

edit3: i'm not yet sure, maybe the leading ":" infront of some lines could be troublesome, but this can be fixed, i think.
in any case, add the console output again.

Last edited by emufan; 19 October 2014 at 01:25.
emufan is offline  
 
Page generated in 0.04431 seconds with 11 queries