Checkout
kfogel
committed
on 26 Oct 08
When can't print a bad filename, then at least print the directory it's in.
(Reproduction recipe given below.)

* subversion/libsvn_subr/io.… Show more
When can't print a bad filename, then at least print the directory it's in.

(Reproduction recipe given below.)

* subversion/libsvn_subr/io.c

 (entry_name_to_utf8): New helper function to give a better error.

 (svn_io_get_dirents2, svn_io_copy_dir_recursively, svn_io_remove_dir2,

  svn_io_get_dir_filenames, svn_io_dir_walk): Use new helper.

 (svn_io_dir_read): Explain why we don't use the new helper here.

* subversion/libsvn_subr/utf.c

 (invalid_utf8, check_utf8, check_cstring_utf8): Document that the

   error code is APR_EINVAL.

* subversion/include/svn_utf.h: Document that when conversion fails the

   error code is APR_EINVAL.

This change replaces cryptic and uninformative errors...

  $ svn st -q

  subversion/libsvn_subr/utf.c:597: (apr_err=22)

  svn: Valid UTF-8 data

  (hex: 20)

  followed by invalid UTF-8 sequence

  (hex: 90 1b 0a 5a)

  $

...with equally cryptic but more informative errors:

  $ svn st -q

  subversion/libsvn_subr/io.c:126: (apr_err=22)

  svn: Error converting entry in directory 'www' to UTF8

  subversion/libsvn_subr/utf.c:597: (apr_err=22)

  svn: Valid UTF-8 data

  (hex: 20)

  followed by invalid UTF-8 sequence

  (hex: 90 1b 0a 5a)

  $  

This program will create such a file in cwd for testing:

  #include <stdio.h>

  #include <string.h>

  

  int main()

  {

    const char fname[] = { 0x20, 0x90, 0x1b, 0x0a, 0x5a, 0 };

    FILE *fp = fopen(fname, "w");

    fclose(fp);

  }

In most Unix shells, you can remove the file with "rm ' '*" afterwards.

Show less