Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#16 file_lines.pro: minor bugfix

closed
nobody
None
5
2009-02-10
2008-05-31
Anonymous
No

Hi,

I hope I've ended up at the right place, this is my first time to sourceforge or similar places.

I found an inconsistency in the output of file_lines.pro, as compared to the output of file_lines in IDL. file_lines counts the number of lines in a file. The inconsistency occurs if the file doesn't have at the end of the last line. IDL would count that last line, GDL would not. This is because the current implementation relies on wc, which doesn't strictly speaking count lines, but newline chars.

I propose a work-around that consists in first running 'paste' on the file before piping it to wc and further. This may be inefficient on long files (haven't checked), but seems to work.

Please find attached a ZIP containing the old and new .pros and two self-explaining sample files with which the bug can be reproduced. IDL's file_lines counts two lines each, as does the new file_lines.pro; the old version counts one or two lines, respectively.

I'm using Scientific Linux 5.1, i686 arch, GDL 0.9.0pre6 as provided in the EPEL5 repo (the file_lines.pro from the current GDL version is identical), and IDL 6.4.

Hope that helps.

Keep up the good work!
Michael

Discussion

  • 2 sample files along with updated (and old) .pro

     
    Attachments
  • Logged In: YES
    user_id=2103465
    Originator: NO

    I just got myself an account, so you can email me if you like! Michael

     
  • Alain C.
    Alain C.
    2009-02-10

    Thanks for the bug report
    put in CVS
    Sorry for the delay

    Alain C.

    PS: does "paste" exist on any OS ? Please report if problem on OSX or other OS.

     
  • Alain C.
    Alain C.
    2009-02-10

    • status: open --> closed
     
  • Hello,

    The "paste" command is there on OSX, the manual states it's a part of POSIX standard.

    When the input for "wc" comes from standard input (as it does in the new version that uses "paste"), it's no longer neccessary to invoke "awk" to remove the filename from the output of "wc"- the number of lines is the only output produced by "wc" now.

    I've removed the "awk" call from the cvs version of src/pro/file_lines.pro.

    Regards
    Sylwester