[darcs-devel] FastPackedString issues

Donald Bruce Stewart dons at cse.unsw.edu.au
Wed Aug 24 21:47:37 PDT 2005


Hey,

I've cabalised the FastPackedString module, 
          darcs get http://www.cse.unsw.edu.au/~dons/code/fps

While writing some unit tests for FastPackedString, I found two issues.
The first problem is initPS. It seems to have an off-by-one error:

        Data.FastPackedString> initPS (packString "haskell")
     >  "haskell"
        Data.FastPackedString> initPS (packString "has")
     >  "has"
        Data.FastPackedString> initPS (packString "hs")
     >  "hs"
        Data.FastPackedString> initPS (packString "h")
     ok ""
        Data.FastPackedString> initPS (packString "")
     ok "*** Exception: FastPackedString.initPS: init []

The relevant line is:
     hunk ./FastPackedString.hs 409
     -  | otherwise  = substrPS ps 0 (len - 1)
     +  | otherwise  = substrPS ps 0 (len - 2)

I see that initPS is used twice in Stringalike, so I'm unsure if this behaviour
has been worked around somehow. Anyway, a patch is attached, and has been
merged into fps.

------------------------------------------------------------------------

The second is that linesPS/unlinesPS aren't equivalent to lines/unlines.  The
PS versions behave as follows:
    Data.FastPackedString> let s = "a\nb\nc\n"

    Data.FastPackedString> linesPS . packString $ s
  > ["a","b","c",""]
    Data.FastPackedString> lines s
    ["a","b","c"]

    Data.FastPackedString> unlinesPS . linesPS . packString $ s
    "a\nb\nc\n"
    Data.FastPackedString> unlines . lines $ s
    "a\nb\nc\n"

Since unlinesPS correctly inverts linesPS, this is probably ok to leave
as is, though I've attached a patch for this just in case, and I'm not
sure if darcs somehow depends on the current behaviour. This patch is in
fps as well:

    Prelude Data.FastPackedString> let s = "a\nb\nc\n"
    Prelude Data.FastPackedString> linesPS . packString $ s
    ["a","b","c"]
    Prelude Data.FastPackedString> unlinesPS . linesPS . packString $ s
    "a\nb\nc\n"

Cheers,
   Don
-------------- next part --------------

New patches:

[Fix off-by-one is FastPackedString.initPS. Caught by unit testing
dons at cse.unsw.edu.au**20050825042627] {
hunk ./FastPackedString.hs 409
-  | otherwise  = substrPS ps 0 (len - 1)
+  | otherwise  = substrPS ps 0 (len - 2)
}

Context:

[remove hideous malloc hack.
David Roundy <droundy at darcs.net>**20050818161411] 
[change my AUTHORS email to droundy at darcs.net.
David Roundy <droundy at abridgegame.org>**20050808124703] 
[fix mkstemp implementation for win32
Peter Strand <peter at zarquon.se>**20050810211303] 
[Implement parts of System.Posix.(IO|Files) for win32
peter at zarquon.se**20050809200433] 
[implement RawMode with library functions instead of ffi
peter at zarquon.se**20050809200148] 
[call hsc2hs without output filename argument
peter at zarquon.se**20050808220444] 
[Rename compat.c to c_compat.c to avoid object filename conflict with Compat.hs
peter at zarquon.se**20050731114011] 
[Move atomic_create/sloppy_atomic_create to Compat
Ian Lynagh <igloo at earth.li>**20050730141703] 
[Split the raw mode stuff out into its own .hsc file. Windows needs some TLC
Ian Lynagh <igloo at earth.li>**20050730134030] 
[Move maybe_relink out of compat.c
Ian Lynagh <igloo at earth.li>**20050730131205] 
[Remove is_symlink
Ian Lynagh <igloo at earth.li>**20050730122255] 
[Move mkstemp to Compat.hs
Ian Lynagh <igloo at earth.li>**20050730020918] 
[Remove unused function
Ian Lynagh <igloo at earth.li>**20050730010118] 
[Start Compat.hs, and move stdout_is_a_pipe from compat.c
Ian Lynagh <igloo at earth.li>**20050730004829] 
[fix for bug Ian found in apply.
David Roundy <droundy at abridgegame.org>**20050811162558
 This is the bug manifested in the cabal repository.
] 
[fix compilation errors with ghc-6.2.2 on win32
Peter Strand <peter at zarquon.se>**20050809192759] 
[Retain both Git's author and committer.
Juliusz Chroboczek <jch at pps.jussieu.fr>**20050810000820] 
[Move slurping into syncPristine.
Juliusz Chroboczek <jch at pps.jussieu.fr>**20050809232101
 Avoids creating a useless pristine tree when there is none.  Thanks to
 Ian for pointing this out.
] 
[Split --relink into --relink and --relink-pristine.
Juliusz Chroboczek <jch at pps.jussieu.fr>**20050809230951
 Relinking the pristine tree breaks handling of timestamps, which causes
 Darcs to compare file contents.  It should not be used unless you know
 what you are doing.
] 
[make repair work on partial repositories.
David Roundy <droundy at abridgegame.org>**20050805113001] 
[Cleanup --verbose handling in repair command
Matt Lavin <matt.lavin at gmail.com>**20050805020630] 
[clean up Printer.wrap_text.
David Roundy <droundy at abridgegame.org>**20050808114844] 
[add several changelog entries.
David Roundy <droundy at abridgegame.org>**20050808114800] 
[improve EOD message a tad.
David Roundy <droundy at abridgegame.org>**20050807112644
 This change also introduces a "wrapped_text" function in Printer, so we
 won't have to worry so often about manually wrapping lines.
] 
[changed ***DARCS*** to ***END OF DESCRIPTION***
Jason Dagit <dagit at codersbase.com>**20050729032543] 
[remove unused opts argument from apply_patches and apply_patches_with_feedback
Matt Lavin <matt.lavin at gmail.com>**20050807031038] 
[Use apply_patch_with_feedback from check and repair commands
Matt Lavin <matt.lavin at gmail.com>**20050805020830] 
[add code to read patch bundles with added CRs.
David Roundy <droundy at abridgegame.org>**20050806222631
 I think this'll address bug #291.
] 
[accept command-line flags in any order.
David Roundy <droundy at abridgegame.org>**20050806211828
 In particular, we no longer require that --flags precede filename and
 repository arguments.
] 
[show patch numbers instead of dots on get
Matt Lavin <matt.lavin at gmail.com>**20050804013649] 
[add obliterate command as alias for unpull.
David Roundy <droundy at abridgegame.org>**20050804104929] 
[Do not ask confirmation for revert -a
jani at iv.ro**20050627124011
 Giving -a as a parameter means the user expects all changes to be reverted.
 Just like for unrevert and record go ahead with it do not ask for confirmation.
] 
[clarify help text for 'd' in SelectPatches.
David Roundy <droundy at abridgegame.org>**20050806231117] 
[Add --with-static-libs configure flag for linking static versions of libraries.
v.haisman at sh.cvut.cz**20050729015539] 
[add changelog entry for bug #477.
David Roundy <droundy at abridgegame.org>**20050806212148] 
[changelog entry for bug #189.
David Roundy <droundy at abridgegame.org>**20050731132624] 
[add description of how to add changelog entries to ChangeLog.README.
David Roundy <droundy at abridgegame.org>**20050806225901] 
[Explain the missing ChangeLog
Mark Stosberg <mark at summersault.com>**20050526135421
 
 It should be easy for casual users and contributors to view and update the
 ChangeLog.
 
 Providing a README file in the place where people are most likely to look
 provides a very useful clue.
 
 However, it's still not clear to me exactly how the system works, so I have
 left a stub to complete that documentation.
 
     Mark
 
] 
[fix obsolete error explanation in get_extra bug.
David Roundy <droundy at abridgegame.org>**20050804130610] 
[simplify fix for bug 463; reuse /// from FilePathUtils
Matt Lavin <matt.lavin at gmail.com>**20050804021130] 
[Make curl exit with error on failed downloads
peter at zarquon.se**20050802192833] 
[Bump up AC_PREREQ version to 2.59.
v.haisman at sh.cvut.cz**20050801173925] 
[fix for bug 463 (with new test)
Matt Lavin <matt.lavin at gmail.com>**20050802002116] 
[bump version number, since I just made a release.
David Roundy <droundy at abridgegame.org>**20050731190756] 
[Use simpler curl_version() function to get version string.
Kannan Goundan <kannan at cakoose.com>**20050322221027] 
[fix documentation on --reorder-patches.
David Roundy <droundy at abridgegame.org>**20050731185406] 
[add changelog entry for bug #224.
David Roundy <droundy at abridgegame.org>**20050731133942] 
[fix bug when editing long comment leaves empty file.
David Roundy <droundy at abridgegame.org>**20050731133612] 
[TAG 1.0.4pre2
David Roundy <droundy at abridgegame.org>**20050731121029] 
Patch bundle hash:
8c30e07fe15eda891848bca41656a26163da738a
-------------- next part --------------

New patches:

[Make linesPS/unlinesPS match lines/unlines
dons at cse.unsw.edu.au**20050825043656] {
hunk ./FastPackedString.hs 572
-linesPS ps = case wfindPS (c2w '\n') ps of
+linesPS ps 
+    | nullPS ps = []
+    | otherwise = case wfindPS (c2w '\n') ps of
hunk ./FastPackedString.hs 579
-unlinesPS ss = concatPS $ intersperse_newlines ss
-    where intersperse_newlines (a:b:s) = a:newline: intersperse_newlines (b:s)
-          intersperse_newlines s = s
-          newline = packString "\n"
+unlinesPS ss = concatPS $ map (\s -> s `appendPS` newline) ss
+    where newline = packString "\n"
}

Context:

[remove hideous malloc hack.
David Roundy <droundy at darcs.net>**20050818161411] 
[change my AUTHORS email to droundy at darcs.net.
David Roundy <droundy at abridgegame.org>**20050808124703] 
[fix mkstemp implementation for win32
Peter Strand <peter at zarquon.se>**20050810211303] 
[Implement parts of System.Posix.(IO|Files) for win32
peter at zarquon.se**20050809200433] 
[implement RawMode with library functions instead of ffi
peter at zarquon.se**20050809200148] 
[call hsc2hs without output filename argument
peter at zarquon.se**20050808220444] 
[Rename compat.c to c_compat.c to avoid object filename conflict with Compat.hs
peter at zarquon.se**20050731114011] 
[Move atomic_create/sloppy_atomic_create to Compat
Ian Lynagh <igloo at earth.li>**20050730141703] 
[Split the raw mode stuff out into its own .hsc file. Windows needs some TLC
Ian Lynagh <igloo at earth.li>**20050730134030] 
[Move maybe_relink out of compat.c
Ian Lynagh <igloo at earth.li>**20050730131205] 
[Remove is_symlink
Ian Lynagh <igloo at earth.li>**20050730122255] 
[Move mkstemp to Compat.hs
Ian Lynagh <igloo at earth.li>**20050730020918] 
[Remove unused function
Ian Lynagh <igloo at earth.li>**20050730010118] 
[Start Compat.hs, and move stdout_is_a_pipe from compat.c
Ian Lynagh <igloo at earth.li>**20050730004829] 
[fix for bug Ian found in apply.
David Roundy <droundy at abridgegame.org>**20050811162558
 This is the bug manifested in the cabal repository.
] 
[fix compilation errors with ghc-6.2.2 on win32
Peter Strand <peter at zarquon.se>**20050809192759] 
[Retain both Git's author and committer.
Juliusz Chroboczek <jch at pps.jussieu.fr>**20050810000820] 
[Move slurping into syncPristine.
Juliusz Chroboczek <jch at pps.jussieu.fr>**20050809232101
 Avoids creating a useless pristine tree when there is none.  Thanks to
 Ian for pointing this out.
] 
[Split --relink into --relink and --relink-pristine.
Juliusz Chroboczek <jch at pps.jussieu.fr>**20050809230951
 Relinking the pristine tree breaks handling of timestamps, which causes
 Darcs to compare file contents.  It should not be used unless you know
 what you are doing.
] 
[make repair work on partial repositories.
David Roundy <droundy at abridgegame.org>**20050805113001] 
[Cleanup --verbose handling in repair command
Matt Lavin <matt.lavin at gmail.com>**20050805020630] 
[clean up Printer.wrap_text.
David Roundy <droundy at abridgegame.org>**20050808114844] 
[add several changelog entries.
David Roundy <droundy at abridgegame.org>**20050808114800] 
[improve EOD message a tad.
David Roundy <droundy at abridgegame.org>**20050807112644
 This change also introduces a "wrapped_text" function in Printer, so we
 won't have to worry so often about manually wrapping lines.
] 
[changed ***DARCS*** to ***END OF DESCRIPTION***
Jason Dagit <dagit at codersbase.com>**20050729032543] 
[remove unused opts argument from apply_patches and apply_patches_with_feedback
Matt Lavin <matt.lavin at gmail.com>**20050807031038] 
[Use apply_patch_with_feedback from check and repair commands
Matt Lavin <matt.lavin at gmail.com>**20050805020830] 
[add code to read patch bundles with added CRs.
David Roundy <droundy at abridgegame.org>**20050806222631
 I think this'll address bug #291.
] 
[accept command-line flags in any order.
David Roundy <droundy at abridgegame.org>**20050806211828
 In particular, we no longer require that --flags precede filename and
 repository arguments.
] 
[show patch numbers instead of dots on get
Matt Lavin <matt.lavin at gmail.com>**20050804013649] 
[add obliterate command as alias for unpull.
David Roundy <droundy at abridgegame.org>**20050804104929] 
[Do not ask confirmation for revert -a
jani at iv.ro**20050627124011
 Giving -a as a parameter means the user expects all changes to be reverted.
 Just like for unrevert and record go ahead with it do not ask for confirmation.
] 
[clarify help text for 'd' in SelectPatches.
David Roundy <droundy at abridgegame.org>**20050806231117] 
[Add --with-static-libs configure flag for linking static versions of libraries.
v.haisman at sh.cvut.cz**20050729015539] 
[add changelog entry for bug #477.
David Roundy <droundy at abridgegame.org>**20050806212148] 
[changelog entry for bug #189.
David Roundy <droundy at abridgegame.org>**20050731132624] 
[add description of how to add changelog entries to ChangeLog.README.
David Roundy <droundy at abridgegame.org>**20050806225901] 
[Explain the missing ChangeLog
Mark Stosberg <mark at summersault.com>**20050526135421
 
 It should be easy for casual users and contributors to view and update the
 ChangeLog.
 
 Providing a README file in the place where people are most likely to look
 provides a very useful clue.
 
 However, it's still not clear to me exactly how the system works, so I have
 left a stub to complete that documentation.
 
     Mark
 
] 
[fix obsolete error explanation in get_extra bug.
David Roundy <droundy at abridgegame.org>**20050804130610] 
[simplify fix for bug 463; reuse /// from FilePathUtils
Matt Lavin <matt.lavin at gmail.com>**20050804021130] 
[Make curl exit with error on failed downloads
peter at zarquon.se**20050802192833] 
[Bump up AC_PREREQ version to 2.59.
v.haisman at sh.cvut.cz**20050801173925] 
[fix for bug 463 (with new test)
Matt Lavin <matt.lavin at gmail.com>**20050802002116] 
[bump version number, since I just made a release.
David Roundy <droundy at abridgegame.org>**20050731190756] 
[Use simpler curl_version() function to get version string.
Kannan Goundan <kannan at cakoose.com>**20050322221027] 
[fix documentation on --reorder-patches.
David Roundy <droundy at abridgegame.org>**20050731185406] 
[add changelog entry for bug #224.
David Roundy <droundy at abridgegame.org>**20050731133942] 
[fix bug when editing long comment leaves empty file.
David Roundy <droundy at abridgegame.org>**20050731133612] 
[TAG 1.0.4pre2
David Roundy <droundy at abridgegame.org>**20050731121029] 
Patch bundle hash:
35db5e81f8a75213d85a6dc104fa8f35409052de


More information about the darcs-devel mailing list