Skip to content
  • Thomas Miedema's avatar
    Don't drop last char of file if -osuf contains dot · 48db13d2
    Thomas Miedema authored
    Given:
     * `file = "foo.a.b"`
     * `osuf = ".a.b"`  -- Note the initial dot.
     * `new_osuf = "c"`
    
    Before (bad, the last character of the filename is dropped):
      `dropTail (length osuf + 1) file <.> new_osuf == "fo.c"`
    After (good):
      `stripExtension osuf file <.> new_osuf` == "foo.c"
    
    This regression was introduced in commit c489af73 (#5554). That commit
    fixed a similar but different bug, and care has been taken to not
    reintroduce it (using the the newly introduced
    `System.Filepath.stripExtension`).
    
    Given:
     * `file = "foo.a.b"`
     * `osuf = "a.b"`
     * `new_osuf = "c"`
    
    Before c489af73 (bad, the full suffix should get replaced):
      `replaceExtension file new_osuf == "foo.a.c"`
    After c489af73 (good):
      `dropTail (length osuf + 1) file <.> new_osuf == "foo.c"`
    After this commit (still good):
      `stripExtension osuf file <.> new_osuf == "foo.c"`
    
    Reviewed by: bgamari
    
    Differential Revision: https://phabricator.haskell.org/D1692
    
    GHC Trac Issues: #9760
    48db13d2