#16 file_lines.pro: minor bugfix



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!


  • Nobody/Anonymous

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

  • Michael Mueller

    Michael Mueller - 2008-05-31

    Logged In: YES
    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
  • Sylwester Arabas


    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.



Log in to post a comment.