[Zrouter-src-freebsd] ZRouter.org: push to FreeBSD HEAD tree

zrouter-src-freebsd at zrouter.org zrouter-src-freebsd at zrouter.org
Fri Mar 2 15:37:46 UTC 2012


details:   http://zrouter.org/hg/FreeBSD/head//rev/a6a608a13e37
changeset: 355:a6a608a13e37
user:      ray at terran.dlink.ua
date:      Fri Mar 02 16:54:40 2012 +0200
description:
Update to FreeBSD-HEAD @232391

diffstat:

 head/contrib/gcc/gcc.c                                                         |    13 +-
 head/contrib/libarchive/COPYING                                                |     4 +-
 head/contrib/libarchive/FREEBSD-Xlist                                          |     4 +-
 head/contrib/libarchive/NEWS                                                   |    93 +-
 head/contrib/libarchive/README                                                 |    35 +-
 head/contrib/libarchive/cpio/bsdcpio.1                                         |    67 +-
 head/contrib/libarchive/cpio/cmdline.c                                         |    23 +-
 head/contrib/libarchive/cpio/cpio.c                                            |   164 +-
 head/contrib/libarchive/cpio/cpio.h                                            |    10 +-
 head/contrib/libarchive/cpio/test/main.c                                       |   781 +-
 head/contrib/libarchive/cpio/test/test.h                                       |   100 +-
 head/contrib/libarchive/cpio/test/test_0.c                                     |    16 +-
 head/contrib/libarchive/cpio/test/test_basic.c                                 |    51 +-
 head/contrib/libarchive/cpio/test/test_format_newc.c                           |    47 +-
 head/contrib/libarchive/cpio/test/test_option_c.c                              |    22 +-
 head/contrib/libarchive/cpio/test/test_option_t.c                              |    33 +-
 head/contrib/libarchive/cpio/test/test_option_u.c                              |     8 +-
 head/contrib/libarchive/cpio/test/test_owner_parse.c                           |    13 +-
 head/contrib/libarchive/libarchive/archive.h                                   |   513 +-
 head/contrib/libarchive/libarchive/archive_check_magic.c                       |    82 +-
 head/contrib/libarchive/libarchive/archive_crc32.h                             |    14 +-
 head/contrib/libarchive/libarchive/archive_entry.3                             |   339 +-
 head/contrib/libarchive/libarchive/archive_entry.c                             |  1339 +-
 head/contrib/libarchive/libarchive/archive_entry.h                             |   240 +-
 head/contrib/libarchive/libarchive/archive_entry_copy_stat.c                   |    10 +-
 head/contrib/libarchive/libarchive/archive_entry_link_resolver.c               |   157 +-
 head/contrib/libarchive/libarchive/archive_entry_private.h                     |    88 +-
 head/contrib/libarchive/libarchive/archive_entry_stat.c                        |     6 +-
 head/contrib/libarchive/libarchive/archive_private.h                           |    50 +-
 head/contrib/libarchive/libarchive/archive_read.3                              |   702 +-
 head/contrib/libarchive/libarchive/archive_read.c                              |   925 +-
 head/contrib/libarchive/libarchive/archive_read_data_into_fd.c                 |    84 +-
 head/contrib/libarchive/libarchive/archive_read_disk.3                         |    33 +-
 head/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c         |   567 +-
 head/contrib/libarchive/libarchive/archive_read_disk_private.h                 |    15 +-
 head/contrib/libarchive/libarchive/archive_read_disk_set_standard_lookup.c     |    30 +-
 head/contrib/libarchive/libarchive/archive_read_extract.c                      |    13 +-
 head/contrib/libarchive/libarchive/archive_read_open_fd.c                      |    89 +-
 head/contrib/libarchive/libarchive/archive_read_open_file.c                    |    46 +-
 head/contrib/libarchive/libarchive/archive_read_open_filename.c                |   431 +-
 head/contrib/libarchive/libarchive/archive_read_open_memory.c                  |    79 +-
 head/contrib/libarchive/libarchive/archive_read_private.h                      |    57 +-
 head/contrib/libarchive/libarchive/archive_read_support_format_all.c           |    40 +-
 head/contrib/libarchive/libarchive/archive_read_support_format_ar.c            |   145 +-
 head/contrib/libarchive/libarchive/archive_read_support_format_cpio.c          |   592 +-
 head/contrib/libarchive/libarchive/archive_read_support_format_empty.c         |    22 +-
 head/contrib/libarchive/libarchive/archive_read_support_format_iso9660.c       |   454 +-
 head/contrib/libarchive/libarchive/archive_read_support_format_mtree.c         |   634 +-
 head/contrib/libarchive/libarchive/archive_read_support_format_raw.c           |    60 +-
 head/contrib/libarchive/libarchive/archive_read_support_format_tar.c           |  1182 +-
 head/contrib/libarchive/libarchive/archive_read_support_format_xar.c           |   424 +-
 head/contrib/libarchive/libarchive/archive_read_support_format_zip.c           |  1269 +-
 head/contrib/libarchive/libarchive/archive_string.c                            |  4326 ++++-
 head/contrib/libarchive/libarchive/archive_string.h                            |   180 +-
 head/contrib/libarchive/libarchive/archive_string_sprintf.c                    |    52 +-
 head/contrib/libarchive/libarchive/archive_util.3                              |    76 +-
 head/contrib/libarchive/libarchive/archive_util.c                              |   499 +-
 head/contrib/libarchive/libarchive/archive_virtual.c                           |    61 +-
 head/contrib/libarchive/libarchive/archive_write.3                             |   550 +-
 head/contrib/libarchive/libarchive/archive_write.c                             |   583 +-
 head/contrib/libarchive/libarchive/archive_write_disk.3                        |    48 +-
 head/contrib/libarchive/libarchive/archive_write_disk_set_standard_lookup.c    |    14 +-
 head/contrib/libarchive/libarchive/archive_write_open_filename.c               |   108 +-
 head/contrib/libarchive/libarchive/archive_write_open_memory.c                 |    14 +-
 head/contrib/libarchive/libarchive/archive_write_private.h                     |    66 +-
 head/contrib/libarchive/libarchive/archive_write_set_format.c                  |     8 +-
 head/contrib/libarchive/libarchive/archive_write_set_format_ar.c               |    60 +-
 head/contrib/libarchive/libarchive/archive_write_set_format_by_name.c          |    12 +-
 head/contrib/libarchive/libarchive/archive_write_set_format_cpio.c             |   319 +-
 head/contrib/libarchive/libarchive/archive_write_set_format_cpio_newc.c        |   340 +-
 head/contrib/libarchive/libarchive/archive_write_set_format_mtree.c            |  1131 +-
 head/contrib/libarchive/libarchive/archive_write_set_format_pax.c              |  1193 +-
 head/contrib/libarchive/libarchive/archive_write_set_format_shar.c             |    93 +-
 head/contrib/libarchive/libarchive/archive_write_set_format_ustar.c            |   351 +-
 head/contrib/libarchive/libarchive/archive_write_set_format_zip.c              |   338 +-
 head/contrib/libarchive/libarchive/libarchive-formats.5                        |     8 +-
 head/contrib/libarchive/libarchive/libarchive.3                                |   141 +-
 head/contrib/libarchive/libarchive/libarchive_internals.3                      |     8 +-
 head/contrib/libarchive/libarchive/tar.5                                       |   200 +-
 head/contrib/libarchive/libarchive/test/main.c                                 |   773 +-
 head/contrib/libarchive/libarchive/test/read_open_memory.c                     |   100 +-
 head/contrib/libarchive/libarchive/test/test.h                                 |    98 +-
 head/contrib/libarchive/libarchive/test/test_acl_freebsd.c                     |     6 +-
 head/contrib/libarchive/libarchive/test/test_acl_pax.c                         |   267 +-
 head/contrib/libarchive/libarchive/test/test_archive_api_feature.c             |    30 +-
 head/contrib/libarchive/libarchive/test/test_bad_fd.c                          |    12 +-
 head/contrib/libarchive/libarchive/test/test_compat_bzip2.c                    |    12 +-
 head/contrib/libarchive/libarchive/test/test_compat_cpio.c                     |     6 +-
 head/contrib/libarchive/libarchive/test/test_compat_gtar.c                     |    14 +-
 head/contrib/libarchive/libarchive/test/test_compat_gzip.c                     |    10 +-
 head/contrib/libarchive/libarchive/test/test_compat_lzma.c                     |    10 +-
 head/contrib/libarchive/libarchive/test/test_compat_solaris_tar_acl.c          |     6 +-
 head/contrib/libarchive/libarchive/test/test_compat_tar_hardlink.c             |    10 +-
 head/contrib/libarchive/libarchive/test/test_compat_xz.c                       |    10 +-
 head/contrib/libarchive/libarchive/test/test_compat_zip.c                      |   369 +-
 head/contrib/libarchive/libarchive/test/test_compat_zip_2.zip.uu               |     2 -
 head/contrib/libarchive/libarchive/test/test_empty_write.c                     |    14 +-
 head/contrib/libarchive/libarchive/test/test_entry.c                           |   159 +-
 head/contrib/libarchive/libarchive/test/test_extattr_freebsd.c                 |     7 +-
 head/contrib/libarchive/libarchive/test/test_fuzz.c                            |    69 +-
 head/contrib/libarchive/libarchive/test/test_open_failure.c                    |    42 +-
 head/contrib/libarchive/libarchive/test/test_open_fd.c                         |    12 +-
 head/contrib/libarchive/libarchive/test/test_open_file.c                       |     8 +-
 head/contrib/libarchive/libarchive/test/test_open_filename.c                   |   105 +-
 head/contrib/libarchive/libarchive/test/test_pax_filename_encoding.c           |   298 +-
 head/contrib/libarchive/libarchive/test/test_read_compress_program.c           |    14 +-
 head/contrib/libarchive/libarchive/test/test_read_data_large.c                 |    34 +-
 head/contrib/libarchive/libarchive/test/test_read_disk.c                       |     8 +-
 head/contrib/libarchive/libarchive/test/test_read_disk_entry_from_file.c       |    10 +-
 head/contrib/libarchive/libarchive/test/test_read_extract.c                    |    12 +-
 head/contrib/libarchive/libarchive/test/test_read_file_nonexistent.c           |     4 +-
 head/contrib/libarchive/libarchive/test/test_read_format_ar.c                  |    15 +-
 head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin.c            |    23 +-
 head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_Z.c          |    11 +-
 head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_be.c         |     6 +-
 head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_bz2.c        |     8 +-
 head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_gz.c         |    12 +-
 head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_lzma.c       |    10 +-
 head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_xz.c         |    10 +-
 head/contrib/libarchive/libarchive/test/test_read_format_cpio_odc.c            |    12 +-
 head/contrib/libarchive/libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.c |     8 +-
 head/contrib/libarchive/libarchive/test/test_read_format_cpio_svr4_gzip.c      |    10 +-
 head/contrib/libarchive/libarchive/test/test_read_format_cpio_svr4_gzip_rpm.c  |     8 +-
 head/contrib/libarchive/libarchive/test/test_read_format_cpio_svr4c_Z.c        |    10 +-
 head/contrib/libarchive/libarchive/test/test_read_format_empty.c               |    12 +-
 head/contrib/libarchive/libarchive/test/test_read_format_gtar_gz.c             |    11 +-
 head/contrib/libarchive/libarchive/test/test_read_format_gtar_lzma.c           |    14 +-
 head/contrib/libarchive/libarchive/test/test_read_format_gtar_sparse.c         |    28 +-
 head/contrib/libarchive/libarchive/test/test_read_format_iso_Z.c               |    18 +-
 head/contrib/libarchive/libarchive/test/test_read_format_iso_multi_extent.c    |    10 +-
 head/contrib/libarchive/libarchive/test/test_read_format_isojoliet_bz2.c       |    14 +-
 head/contrib/libarchive/libarchive/test/test_read_format_isojoliet_long.c      |    12 +-
 head/contrib/libarchive/libarchive/test/test_read_format_isojoliet_rr.c        |    12 +-
 head/contrib/libarchive/libarchive/test/test_read_format_isorr_bz2.c           |    10 +-
 head/contrib/libarchive/libarchive/test/test_read_format_isorr_ce.c            |    10 +-
 head/contrib/libarchive/libarchive/test/test_read_format_isorr_new_bz2.c       |    10 +-
 head/contrib/libarchive/libarchive/test/test_read_format_isorr_rr_moved.c      |    10 +-
 head/contrib/libarchive/libarchive/test/test_read_format_isozisofs_bz2.c       |    10 +-
 head/contrib/libarchive/libarchive/test/test_read_format_mtree.c               |   263 +-
 head/contrib/libarchive/libarchive/test/test_read_format_mtree.mtree.uu        |    12 +-
 head/contrib/libarchive/libarchive/test/test_read_format_pax_bz2.c             |     7 +-
 head/contrib/libarchive/libarchive/test/test_read_format_raw.c                 |    14 +-
 head/contrib/libarchive/libarchive/test/test_read_format_tar.c                 |    22 +-
 head/contrib/libarchive/libarchive/test/test_read_format_tar_empty_filename.c  |    10 +-
 head/contrib/libarchive/libarchive/test/test_read_format_tbz.c                 |     9 +-
 head/contrib/libarchive/libarchive/test/test_read_format_tgz.c                 |    11 +-
 head/contrib/libarchive/libarchive/test/test_read_format_tlz.c                 |    11 +-
 head/contrib/libarchive/libarchive/test/test_read_format_txz.c                 |    11 +-
 head/contrib/libarchive/libarchive/test/test_read_format_tz.c                  |    11 +-
 head/contrib/libarchive/libarchive/test/test_read_format_xar.c                 |    21 +-
 head/contrib/libarchive/libarchive/test/test_read_format_zip.c                 |   321 +-
 head/contrib/libarchive/libarchive/test/test_read_format_zip.zip.uu            |     4 +-
 head/contrib/libarchive/libarchive/test/test_read_large.c                      |    19 +-
 head/contrib/libarchive/libarchive/test/test_read_pax_truncated.c              |   168 +-
 head/contrib/libarchive/libarchive/test/test_read_position.c                   |    86 +-
 head/contrib/libarchive/libarchive/test/test_read_truncated.c                  |    74 +-
 head/contrib/libarchive/libarchive/test/test_read_uu.c                         |    73 +-
 head/contrib/libarchive/libarchive/test/test_tar_filenames.c                   |    32 +-
 head/contrib/libarchive/libarchive/test/test_tar_large.c                       |    39 +-
 head/contrib/libarchive/libarchive/test/test_ustar_filenames.c                 |    20 +-
 head/contrib/libarchive/libarchive/test/test_write_compress.c                  |    39 +-
 head/contrib/libarchive/libarchive/test/test_write_compress_bzip2.c            |    94 +-
 head/contrib/libarchive/libarchive/test/test_write_compress_gzip.c             |    92 +-
 head/contrib/libarchive/libarchive/test/test_write_compress_lzma.c             |    87 +-
 head/contrib/libarchive/libarchive/test/test_write_compress_program.c          |    31 +-
 head/contrib/libarchive/libarchive/test/test_write_compress_xz.c               |    86 +-
 head/contrib/libarchive/libarchive/test/test_write_disk.c                      |   109 +-
 head/contrib/libarchive/libarchive/test/test_write_disk_failures.c             |    15 +-
 head/contrib/libarchive/libarchive/test/test_write_disk_hardlink.c             |    14 +-
 head/contrib/libarchive/libarchive/test/test_write_disk_perms.c                |    12 +-
 head/contrib/libarchive/libarchive/test/test_write_disk_secure.c               |    10 +-
 head/contrib/libarchive/libarchive/test/test_write_disk_sparse.c               |     6 +-
 head/contrib/libarchive/libarchive/test/test_write_disk_symlink.c              |     4 +-
 head/contrib/libarchive/libarchive/test/test_write_disk_times.c                |     4 +-
 head/contrib/libarchive/libarchive/test/test_write_format_ar.c                 |    53 +-
 head/contrib/libarchive/libarchive/test/test_write_format_cpio.c               |   124 +-
 head/contrib/libarchive/libarchive/test/test_write_format_cpio_empty.c         |    10 +-
 head/contrib/libarchive/libarchive/test/test_write_format_cpio_newc.c          |     9 +-
 head/contrib/libarchive/libarchive/test/test_write_format_cpio_odc.c           |     8 +-
 head/contrib/libarchive/libarchive/test/test_write_format_mtree.c              |    34 +-
 head/contrib/libarchive/libarchive/test/test_write_format_pax.c                |    61 +-
 head/contrib/libarchive/libarchive/test/test_write_format_shar_empty.c         |    10 +-
 head/contrib/libarchive/libarchive/test/test_write_format_tar.c                |    89 +-
 head/contrib/libarchive/libarchive/test/test_write_format_tar_empty.c          |    28 +-
 head/contrib/libarchive/libarchive/test/test_write_format_tar_ustar.c          |    39 +-
 head/contrib/libarchive/libarchive/test/test_write_format_zip.c                |   191 +-
 head/contrib/libarchive/libarchive/test/test_write_format_zip_empty.c          |    38 +-
 head/contrib/libarchive/libarchive/test/test_write_format_zip_no_compression.c |    50 +-
 head/contrib/libarchive/libarchive/test/test_write_open_memory.c               |    44 +-
 head/contrib/libarchive/libarchive_fe/line_reader.c                            |    62 +-
 head/contrib/libarchive/libarchive_fe/matching.c                               |    59 +-
 head/contrib/libarchive/libarchive_fe/pathmatch.c                              |     4 +-
 head/contrib/libarchive/tar/bsdtar.1                                           |    53 +-
 head/contrib/libarchive/tar/bsdtar.c                                           |   136 +-
 head/contrib/libarchive/tar/bsdtar.h                                           |    19 +-
 head/contrib/libarchive/tar/bsdtar_platform.h                                  |     6 +-
 head/contrib/libarchive/tar/cmdline.c                                          |   100 +-
 head/contrib/libarchive/tar/getdate.c                                          |     4 +-
 head/contrib/libarchive/tar/read.c                                             |    81 +-
 head/contrib/libarchive/tar/subst.c                                            |    55 +-
 head/contrib/libarchive/tar/test/main.c                                        |   685 +-
 head/contrib/libarchive/tar/test/test.h                                        |   101 +-
 head/contrib/libarchive/tar/test/test_0.c                                      |    16 +-
 head/contrib/libarchive/tar/test/test_basic.c                                  |   116 +-
 head/contrib/libarchive/tar/test/test_option_T_upper.c                         |    64 +-
 head/contrib/libarchive/tar/test/test_option_q.c                               |    28 +-
 head/contrib/libarchive/tar/test/test_option_r.c                               |    97 +-
 head/contrib/libarchive/tar/test/test_option_s.c                               |   214 +-
 head/contrib/libarchive/tar/test/test_patterns.c                               |    12 +-
 head/contrib/libarchive/tar/test/test_strip_components.c                       |    82 +-
 head/contrib/libarchive/tar/test/test_symlink_dir.c                            |    36 +-
 head/contrib/libarchive/tar/tree.c                                             |    71 +-
 head/contrib/libarchive/tar/util.c                                             |    48 +-
 head/contrib/libarchive/tar/write.c                                            |   207 +-
 head/contrib/netcat/netcat.c                                                   |    15 +-
 head/contrib/pf/pfctl/parse.y                                                  |    34 +-
 head/contrib/tcsh/Fixes                                                        |   144 +
 head/contrib/tcsh/Imakefile                                                    |     8 +-
 head/contrib/tcsh/Makefile.in                                                  |   313 +-
 head/contrib/tcsh/Ported                                                       |    23 +-
 head/contrib/tcsh/README                                                       |     4 +-
 head/contrib/tcsh/WishList                                                     |    11 -
 head/contrib/tcsh/complete.tcsh                                                |     4 +-
 head/contrib/tcsh/config.guess                                                 |   149 +-
 head/contrib/tcsh/config.h.in                                                  |    59 +-
 head/contrib/tcsh/config.sub                                                   |    39 +-
 head/contrib/tcsh/config/bsd4.4                                                |     5 -
 head/contrib/tcsh/config_f.h                                                   |    24 +-
 head/contrib/tcsh/configure                                                    |  9627 ++++-----
 head/contrib/tcsh/configure.in                                                 |    61 +-
 head/contrib/tcsh/ed.chared.c                                                  |    23 +-
 head/contrib/tcsh/ed.inputl.c                                                  |     6 +-
 head/contrib/tcsh/ed.refresh.c                                                 |   110 +-
 head/contrib/tcsh/ed.screen.c                                                  |    64 +-
 head/contrib/tcsh/ed.term.c                                                    |     7 +-
 head/contrib/tcsh/gethost.c                                                    |    76 +-
 head/contrib/tcsh/glob.c                                                       |   141 +-
 head/contrib/tcsh/glob.h                                                       |     2 +
 head/contrib/tcsh/host.defs                                                    |   583 +-
 head/contrib/tcsh/install-sh                                                   |   513 +-
 head/contrib/tcsh/nls/C/charset                                                |     4 +-
 head/contrib/tcsh/nls/C/set19                                                  |    12 +-
 head/contrib/tcsh/nls/et/charset                                               |     4 +-
 head/contrib/tcsh/nls/et/set1                                                  |   140 +-
 head/contrib/tcsh/nls/et/set10                                                 |     8 +-
 head/contrib/tcsh/nls/et/set11                                                 |     6 +-
 head/contrib/tcsh/nls/et/set13                                                 |    10 +-
 head/contrib/tcsh/nls/et/set14                                                 |     4 +-
 head/contrib/tcsh/nls/et/set15                                                 |     6 +-
 head/contrib/tcsh/nls/et/set16                                                 |     6 +-
 head/contrib/tcsh/nls/et/set17                                                 |    12 +-
 head/contrib/tcsh/nls/et/set18                                                 |     4 +-
 head/contrib/tcsh/nls/et/set19                                                 |    26 +-
 head/contrib/tcsh/nls/et/set2                                                  |    58 +-
 head/contrib/tcsh/nls/et/set20                                                 |    46 +-
 head/contrib/tcsh/nls/et/set21                                                 |     6 +-
 head/contrib/tcsh/nls/et/set22                                                 |    14 +-
 head/contrib/tcsh/nls/et/set23                                                 |    12 +-
 head/contrib/tcsh/nls/et/set24                                                 |     4 +-
 head/contrib/tcsh/nls/et/set25                                                 |     4 +-
 head/contrib/tcsh/nls/et/set26                                                 |    10 +-
 head/contrib/tcsh/nls/et/set27                                                 |     6 +-
 head/contrib/tcsh/nls/et/set3                                                  |   186 +-
 head/contrib/tcsh/nls/et/set30                                                 |     4 +-
 head/contrib/tcsh/nls/et/set4                                                  |    46 +-
 head/contrib/tcsh/nls/et/set5                                                  |     4 +-
 head/contrib/tcsh/nls/et/set6                                                  |     8 +-
 head/contrib/tcsh/nls/et/set7                                                  |    24 +-
 head/contrib/tcsh/nls/et/set8                                                  |     4 +-
 head/contrib/tcsh/nls/et/set9                                                  |    10 +-
 head/contrib/tcsh/nls/finnish/charset                                          |     4 +-
 head/contrib/tcsh/nls/finnish/set1                                             |   134 +-
 head/contrib/tcsh/nls/finnish/set10                                            |    10 +-
 head/contrib/tcsh/nls/finnish/set11                                            |    10 +-
 head/contrib/tcsh/nls/finnish/set12                                            |     4 +-
 head/contrib/tcsh/nls/finnish/set13                                            |    12 +-
 head/contrib/tcsh/nls/finnish/set14                                            |     4 +-
 head/contrib/tcsh/nls/finnish/set16                                            |     6 +-
 head/contrib/tcsh/nls/finnish/set17                                            |     8 +-
 head/contrib/tcsh/nls/finnish/set18                                            |     4 +-
 head/contrib/tcsh/nls/finnish/set19                                            |    20 +-
 head/contrib/tcsh/nls/finnish/set2                                             |    90 +-
 head/contrib/tcsh/nls/finnish/set20                                            |    22 +-
 head/contrib/tcsh/nls/finnish/set22                                            |    10 +-
 head/contrib/tcsh/nls/finnish/set23                                            |    24 +-
 head/contrib/tcsh/nls/finnish/set25                                            |     4 +-
 head/contrib/tcsh/nls/finnish/set26                                            |    10 +-
 head/contrib/tcsh/nls/finnish/set27                                            |     4 +-
 head/contrib/tcsh/nls/finnish/set29                                            |     4 +-
 head/contrib/tcsh/nls/finnish/set3                                             |   142 +-
 head/contrib/tcsh/nls/finnish/set6                                             |    10 +-
 head/contrib/tcsh/nls/finnish/set7                                             |    34 +-
 head/contrib/tcsh/nls/finnish/set9                                             |    10 +-
 head/contrib/tcsh/nls/french/charset                                           |     4 +-
 head/contrib/tcsh/nls/french/set1                                              |   124 +-
 head/contrib/tcsh/nls/french/set10                                             |     6 +-
 head/contrib/tcsh/nls/french/set11                                             |     6 +-
 head/contrib/tcsh/nls/french/set12                                             |     4 +-
 head/contrib/tcsh/nls/french/set13                                             |    16 +-
 head/contrib/tcsh/nls/french/set15                                             |     4 +-
 head/contrib/tcsh/nls/french/set16                                             |     6 +-
 head/contrib/tcsh/nls/french/set17                                             |    12 +-
 head/contrib/tcsh/nls/french/set18                                             |     4 +-
 head/contrib/tcsh/nls/french/set19                                             |    28 +-
 head/contrib/tcsh/nls/french/set2                                              |   102 +-
 head/contrib/tcsh/nls/french/set20                                             |    60 +-
 head/contrib/tcsh/nls/french/set21                                             |     6 +-
 head/contrib/tcsh/nls/french/set22                                             |    14 +-
 head/contrib/tcsh/nls/french/set23                                             |    22 +-
 head/contrib/tcsh/nls/french/set25                                             |     4 +-
 head/contrib/tcsh/nls/french/set26                                             |    16 +-
 head/contrib/tcsh/nls/french/set27                                             |     6 +-
 head/contrib/tcsh/nls/french/set3                                              |   192 +-
 head/contrib/tcsh/nls/french/set30                                             |    12 +-
 head/contrib/tcsh/nls/french/set31                                             |     6 +-
 head/contrib/tcsh/nls/french/set4                                              |    30 +-
 head/contrib/tcsh/nls/french/set6                                              |     6 +-
 head/contrib/tcsh/nls/french/set7                                              |    20 +-
 head/contrib/tcsh/nls/french/set8                                              |     4 +-
 head/contrib/tcsh/nls/french/set9                                              |    16 +-
 head/contrib/tcsh/nls/german/charset                                           |     4 +-
 head/contrib/tcsh/nls/german/set1                                              |    66 +-
 head/contrib/tcsh/nls/german/set10                                             |     8 +-
 head/contrib/tcsh/nls/german/set13                                             |     4 +-
 head/contrib/tcsh/nls/german/set15                                             |     4 +-
 head/contrib/tcsh/nls/german/set16                                             |     6 +-
 head/contrib/tcsh/nls/german/set17                                             |     6 +-
 head/contrib/tcsh/nls/german/set18                                             |     4 +-
 head/contrib/tcsh/nls/german/set19                                             |    12 +-
 head/contrib/tcsh/nls/german/set2                                              |    22 +-
 head/contrib/tcsh/nls/german/set20                                             |    10 +-
 head/contrib/tcsh/nls/german/set22                                             |    10 +-
 head/contrib/tcsh/nls/german/set23                                             |    16 +-
 head/contrib/tcsh/nls/german/set25                                             |     4 +-
 head/contrib/tcsh/nls/german/set26                                             |     6 +-
 head/contrib/tcsh/nls/german/set27                                             |     4 +-
 head/contrib/tcsh/nls/german/set29                                             |     4 +-
 head/contrib/tcsh/nls/german/set3                                              |   126 +-
 head/contrib/tcsh/nls/german/set30                                             |     8 +-
 head/contrib/tcsh/nls/german/set31                                             |     8 +-
 head/contrib/tcsh/nls/german/set4                                              |    36 +-
 head/contrib/tcsh/nls/german/set5                                              |     4 +-
 head/contrib/tcsh/nls/german/set6                                              |     6 +-
 head/contrib/tcsh/nls/german/set7                                              |    30 +-
 head/contrib/tcsh/nls/german/set8                                              |     4 +-
 head/contrib/tcsh/nls/german/set9                                              |     6 +-
 head/contrib/tcsh/nls/greek/charset                                            |     4 +-
 head/contrib/tcsh/nls/greek/set1                                               |   270 +-
 head/contrib/tcsh/nls/greek/set10                                              |    12 +-
 head/contrib/tcsh/nls/greek/set11                                              |    16 +-
 head/contrib/tcsh/nls/greek/set12                                              |     4 +-
 head/contrib/tcsh/nls/greek/set13                                              |    20 +-
 head/contrib/tcsh/nls/greek/set14                                              |     8 +-
 head/contrib/tcsh/nls/greek/set15                                              |    10 +-
 head/contrib/tcsh/nls/greek/set16                                              |     8 +-
 head/contrib/tcsh/nls/greek/set17                                              |    24 +-
 head/contrib/tcsh/nls/greek/set18                                              |     4 +-
 head/contrib/tcsh/nls/greek/set19                                              |    34 +-
 head/contrib/tcsh/nls/greek/set2                                               |   162 +-
 head/contrib/tcsh/nls/greek/set20                                              |    78 +-
 head/contrib/tcsh/nls/greek/set21                                              |     6 +-
 head/contrib/tcsh/nls/greek/set22                                              |    28 +-
 head/contrib/tcsh/nls/greek/set23                                              |    48 +-
 head/contrib/tcsh/nls/greek/set25                                              |     6 +-
 head/contrib/tcsh/nls/greek/set26                                              |    22 +-
 head/contrib/tcsh/nls/greek/set27                                              |     8 +-
 head/contrib/tcsh/nls/greek/set29                                              |     4 +-
 head/contrib/tcsh/nls/greek/set3                                               |   230 +-
 head/contrib/tcsh/nls/greek/set30                                              |    22 +-
 head/contrib/tcsh/nls/greek/set31                                              |    10 +-
 head/contrib/tcsh/nls/greek/set4                                               |    86 +-
 head/contrib/tcsh/nls/greek/set5                                               |     4 +-
 head/contrib/tcsh/nls/greek/set6                                               |    14 +-
 head/contrib/tcsh/nls/greek/set7                                               |    56 +-
 head/contrib/tcsh/nls/greek/set8                                               |     6 +-
 head/contrib/tcsh/nls/greek/set9                                               |    20 +-
 head/contrib/tcsh/nls/italian/charset                                          |     4 +-
 head/contrib/tcsh/nls/italian/set1                                             |    18 +-
 head/contrib/tcsh/nls/italian/set11                                            |     4 +-
 head/contrib/tcsh/nls/italian/set13                                            |     6 +-
 head/contrib/tcsh/nls/italian/set15                                            |     4 +-
 head/contrib/tcsh/nls/italian/set17                                            |     8 +-
 head/contrib/tcsh/nls/italian/set19                                            |    12 +-
 head/contrib/tcsh/nls/italian/set2                                             |    16 +-
 head/contrib/tcsh/nls/italian/set20                                            |    14 +-
 head/contrib/tcsh/nls/italian/set22                                            |     8 +-
 head/contrib/tcsh/nls/italian/set23                                            |     4 +-
 head/contrib/tcsh/nls/italian/set26                                            |    14 +-
 head/contrib/tcsh/nls/italian/set3                                             |    34 +-
 head/contrib/tcsh/nls/italian/set30                                            |     4 +-
 head/contrib/tcsh/nls/italian/set4                                             |    24 +-
 head/contrib/tcsh/nls/italian/set6                                             |     4 +-
 head/contrib/tcsh/nls/italian/set7                                             |    18 +-
 head/contrib/tcsh/nls/ja/charset                                               |     4 +-
 head/contrib/tcsh/nls/ja/set1                                                  |   272 +-
 head/contrib/tcsh/nls/ja/set10                                                 |    12 +-
 head/contrib/tcsh/nls/ja/set11                                                 |    16 +-
 head/contrib/tcsh/nls/ja/set12                                                 |     4 +-
 head/contrib/tcsh/nls/ja/set13                                                 |    18 +-
 head/contrib/tcsh/nls/ja/set15                                                 |    10 +-
 head/contrib/tcsh/nls/ja/set16                                                 |    10 +-
 head/contrib/tcsh/nls/ja/set17                                                 |    24 +-
 head/contrib/tcsh/nls/ja/set18                                                 |     4 +-
 head/contrib/tcsh/nls/ja/set2                                                  |   184 +-
 head/contrib/tcsh/nls/ja/set21                                                 |     6 +-
 head/contrib/tcsh/nls/ja/set29                                                 |     4 +-
 head/contrib/tcsh/nls/ja/set3                                                  |   220 +-
 head/contrib/tcsh/nls/ja/set30                                                 |    22 +-
 head/contrib/tcsh/nls/ja/set4                                                  |    84 +-
 head/contrib/tcsh/nls/ja/set5                                                  |     4 +-
 head/contrib/tcsh/nls/ja/set6                                                  |    18 +-
 head/contrib/tcsh/nls/ja/set7                                                  |    56 +-
 head/contrib/tcsh/nls/ja/set8                                                  |     6 +-
 head/contrib/tcsh/nls/russian/charset                                          |     4 +-
 head/contrib/tcsh/nls/russian/set1                                             |   272 +-
 head/contrib/tcsh/nls/russian/set10                                            |    12 +-
 head/contrib/tcsh/nls/russian/set11                                            |    16 +-
 head/contrib/tcsh/nls/russian/set12                                            |     4 +-
 head/contrib/tcsh/nls/russian/set13                                            |    16 +-
 head/contrib/tcsh/nls/russian/set14                                            |     8 +-
 head/contrib/tcsh/nls/russian/set15                                            |    10 +-
 head/contrib/tcsh/nls/russian/set16                                            |     6 +-
 head/contrib/tcsh/nls/russian/set17                                            |    14 +-
 head/contrib/tcsh/nls/russian/set18                                            |     4 +-
 head/contrib/tcsh/nls/russian/set19                                            |    16 +-
 head/contrib/tcsh/nls/russian/set2                                             |    50 +-
 head/contrib/tcsh/nls/russian/set20                                            |    78 +-
 head/contrib/tcsh/nls/russian/set22                                            |    28 +-
 head/contrib/tcsh/nls/russian/set23                                            |    28 +-
 head/contrib/tcsh/nls/russian/set25                                            |     6 +-
 head/contrib/tcsh/nls/russian/set26                                            |    16 +-
 head/contrib/tcsh/nls/russian/set27                                            |    12 +-
 head/contrib/tcsh/nls/russian/set29                                            |     4 +-
 head/contrib/tcsh/nls/russian/set30                                            |    18 +-
 head/contrib/tcsh/nls/russian/set31                                            |    10 +-
 head/contrib/tcsh/nls/russian/set4                                             |    46 +-
 head/contrib/tcsh/nls/russian/set5                                             |     4 +-
 head/contrib/tcsh/nls/russian/set6                                             |    18 +-
 head/contrib/tcsh/nls/russian/set7                                             |    20 +-
 head/contrib/tcsh/nls/russian/set8                                             |     6 +-
 head/contrib/tcsh/nls/russian/set9                                             |     8 +-
 head/contrib/tcsh/nls/spanish/charset                                          |     4 +-
 head/contrib/tcsh/nls/spanish/set1                                             |   122 +-
 head/contrib/tcsh/nls/spanish/set10                                            |     4 +-
 head/contrib/tcsh/nls/spanish/set13                                            |     4 +-
 head/contrib/tcsh/nls/spanish/set14                                            |     4 +-
 head/contrib/tcsh/nls/spanish/set15                                            |     4 +-
 head/contrib/tcsh/nls/spanish/set16                                            |     4 +-
 head/contrib/tcsh/nls/spanish/set17                                            |     8 +-
 head/contrib/tcsh/nls/spanish/set18                                            |     4 +-
 head/contrib/tcsh/nls/spanish/set19                                            |    26 +-
 head/contrib/tcsh/nls/spanish/set2                                             |    96 +-
 head/contrib/tcsh/nls/spanish/set20                                            |    40 +-
 head/contrib/tcsh/nls/spanish/set22                                            |    22 +-
 head/contrib/tcsh/nls/spanish/set23                                            |    28 +-
 head/contrib/tcsh/nls/spanish/set25                                            |     4 +-
 head/contrib/tcsh/nls/spanish/set26                                            |     8 +-
 head/contrib/tcsh/nls/spanish/set27                                            |     6 +-
 head/contrib/tcsh/nls/spanish/set3                                             |   148 +-
 head/contrib/tcsh/nls/spanish/set30                                            |     8 +-
 head/contrib/tcsh/nls/spanish/set4                                             |    60 +-
 head/contrib/tcsh/nls/spanish/set5                                             |     4 +-
 head/contrib/tcsh/nls/spanish/set6                                             |     4 +-
 head/contrib/tcsh/nls/spanish/set7                                             |    26 +-
 head/contrib/tcsh/nls/spanish/set8                                             |     4 +-
 head/contrib/tcsh/nls/spanish/set9                                             |    12 +-
 head/contrib/tcsh/nls/ukrainian/charset                                        |     4 +-
 head/contrib/tcsh/nls/ukrainian/set1                                           |   248 +-
 head/contrib/tcsh/nls/ukrainian/set10                                          |    12 +-
 head/contrib/tcsh/nls/ukrainian/set11                                          |    16 +-
 head/contrib/tcsh/nls/ukrainian/set12                                          |     4 +-
 head/contrib/tcsh/nls/ukrainian/set13                                          |    18 +-
 head/contrib/tcsh/nls/ukrainian/set14                                          |     8 +-
 head/contrib/tcsh/nls/ukrainian/set15                                          |    10 +-
 head/contrib/tcsh/nls/ukrainian/set16                                          |     6 +-
 head/contrib/tcsh/nls/ukrainian/set17                                          |    26 +-
 head/contrib/tcsh/nls/ukrainian/set18                                          |     4 +-
 head/contrib/tcsh/nls/ukrainian/set19                                          |    22 +-
 head/contrib/tcsh/nls/ukrainian/set2                                           |    56 +-
 head/contrib/tcsh/nls/ukrainian/set20                                          |    12 +-
 head/contrib/tcsh/nls/ukrainian/set22                                          |    20 +-
 head/contrib/tcsh/nls/ukrainian/set23                                          |    12 +-
 head/contrib/tcsh/nls/ukrainian/set25                                          |     6 +-
 head/contrib/tcsh/nls/ukrainian/set26                                          |    18 +-
 head/contrib/tcsh/nls/ukrainian/set27                                          |    12 +-
 head/contrib/tcsh/nls/ukrainian/set29                                          |     4 +-
 head/contrib/tcsh/nls/ukrainian/set30                                          |    12 +-
 head/contrib/tcsh/nls/ukrainian/set31                                          |    10 +-
 head/contrib/tcsh/nls/ukrainian/set5                                           |     4 +-
 head/contrib/tcsh/nls/ukrainian/set6                                           |     8 +-
 head/contrib/tcsh/nls/ukrainian/set7                                           |    12 +-
 head/contrib/tcsh/nls/ukrainian/set8                                           |     6 +-
 head/contrib/tcsh/nls/ukrainian/set9                                           |     4 +-
 head/contrib/tcsh/patchlevel.h                                                 |     8 +-
 head/contrib/tcsh/pathnames.h                                                  |    10 +-
 head/contrib/tcsh/sh.c                                                         |   221 +-
 head/contrib/tcsh/sh.char.c                                                    |     6 +-
 head/contrib/tcsh/sh.char.h                                                    |    12 +-
 head/contrib/tcsh/sh.decls.h                                                   |    37 +-
 head/contrib/tcsh/sh.dir.c                                                     |    20 +-
 head/contrib/tcsh/sh.dol.c                                                     |    65 +-
 head/contrib/tcsh/sh.err.c                                                     |   166 +-
 head/contrib/tcsh/sh.exec.c                                                    |    54 +-
 head/contrib/tcsh/sh.exp.c                                                     |   111 +-
 head/contrib/tcsh/sh.file.c                                                    |     6 +-
 head/contrib/tcsh/sh.func.c                                                    |   138 +-
 head/contrib/tcsh/sh.glob.c                                                    |    24 +-
 head/contrib/tcsh/sh.h                                                         |    88 +-
 head/contrib/tcsh/sh.hist.c                                                    |  1169 +-
 head/contrib/tcsh/sh.lex.c                                                     |    32 +-
 head/contrib/tcsh/sh.misc.c                                                    |     6 +-
 head/contrib/tcsh/sh.parse.c                                                   |     7 +-
 head/contrib/tcsh/sh.print.c                                                   |    31 +-
 head/contrib/tcsh/sh.proc.c                                                    |    44 +-
 head/contrib/tcsh/sh.proc.h                                                    |     4 +-
 head/contrib/tcsh/sh.sem.c                                                     |    73 +-
 head/contrib/tcsh/sh.set.c                                                     |   100 +-
 head/contrib/tcsh/sh.time.c                                                    |    85 +-
 head/contrib/tcsh/tc.alloc.c                                                   |    47 +-
 head/contrib/tcsh/tc.const.c                                                   |    21 +-
 head/contrib/tcsh/tc.decls.h                                                   |     8 +-
 head/contrib/tcsh/tc.disc.c                                                    |     6 +-
 head/contrib/tcsh/tc.func.c                                                    |    39 +-
 head/contrib/tcsh/tc.nls.c                                                     |    32 +-
 head/contrib/tcsh/tc.nls.h                                                     |     4 +-
 head/contrib/tcsh/tc.os.c                                                      |    43 +-
 head/contrib/tcsh/tc.os.h                                                      |    20 +-
 head/contrib/tcsh/tc.prompt.c                                                  |    16 +-
 head/contrib/tcsh/tc.sig.c                                                     |    18 +-
 head/contrib/tcsh/tc.sig.h                                                     |     4 +-
 head/contrib/tcsh/tc.str.c                                                     |   101 +-
 head/contrib/tcsh/tc.wait.h                                                    |     4 +-
 head/contrib/tcsh/tc.who.c                                                     |   172 +-
 head/contrib/tcsh/tcsh.man                                                     |   230 +-
 head/contrib/tcsh/tcsh.man2html                                                |     8 +-
 head/contrib/tcsh/tw.color.c                                                   |     7 +-
 head/contrib/tcsh/tw.init.c                                                    |    17 +-
 head/contrib/tcsh/tw.parse.c                                                   |   142 +-
 head/contrib/tcsh/vms.termcap.c                                                |    29 +-
 head/contrib/top/top.c                                                         |    18 +-
 540 files changed, 32141 insertions(+), 21017 deletions(-)

diffs (82661 lines):

diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/gcc/gcc.c
--- a/head/contrib/gcc/gcc.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/gcc/gcc.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
 This paragraph is here to try to keep Sun CC from dying.
 The number of chars here seems crucial!!!!  */
 
-/* $FreeBSD$ */
+/* $FreeBSD: head/contrib/gcc/gcc.c 231336 2012-02-10 05:05:42Z kientzle $ */
 
 /* This program is the user interface to the C compiler and possibly to
 other compilers.  It is used because compilation is a complicated procedure
@@ -2696,6 +2696,17 @@
     return xstrdup (DEFAULT_LINKER);
 #endif
 
+#ifdef FREEBSD_NATIVE
+  if (! strcmp(name, "include"))
+    {
+#ifdef CROSS_INCLUDE_DIR
+      return xstrdup(CROSS_INCLUDE_DIR);
+#else
+      return xstrdup(STANDARD_INCLUDE_DIR);
+#endif
+    }
+#endif
+
   /* Determine the filename to execute (special case for absolute paths).  */
 
   if (IS_ABSOLUTE_PATH (name))
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/COPYING
--- a/head/contrib/libarchive/COPYING	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/COPYING	Fri Mar 02 16:54:40 2012 +0200
@@ -16,8 +16,8 @@
   a 3-clause UC Regents copyright; please read the individual source
   files for details:
    libarchive/archive_entry.c
-   libarchive/archive_read_support_compression_compress.c
-   libarchive/archive_write_set_compression_compress.c
+   libarchive/archive_read_support_filter_compress.c
+   libarchive/archive_write_set_filter_compress.c
    libarchive/mtree.5
    tar/matching.c
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/FREEBSD-Xlist
--- a/head/contrib/libarchive/FREEBSD-Xlist	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/FREEBSD-Xlist	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$FreeBSD: head/contrib/libarchive/FREEBSD-Xlist 228770 2011-12-21 14:58:44Z mm $
+$FreeBSD: head/contrib/libarchive/FREEBSD-Xlist 232153 2012-02-25 10:58:02Z mm $
 CMakeLists.txt
 CTestConfig.cmake
 INSTALL
@@ -15,8 +15,10 @@
 examples
 libarchive/CMakeLists.txt
 libarchive/archive_entry_copy_bhfi.c
+libarchive/archive_read_disk_windows.c
 libarchive/archive_windows.c
 libarchive/archive_windows.h
+libarchive/archive_write_disk_windows.c
 libarchive/config_freebsd.h
 libarchive/filter_fork_windows.c
 libarchive/mtree.5
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/NEWS
--- a/head/contrib/libarchive/NEWS	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/NEWS	Fri Mar 02 16:54:40 2012 +0200
@@ -1,27 +1,80 @@
-Feb 05, 2011: Fix issue 134: Improve handling of open failures
-Dec 06, 2010: Fix issue 119: Relax ISO verification
-Dec 06, 2010: Fix issue 121: mtree parsing
-Dec 05, 2010: Fix extraction of GNU tar 'D' directory entries
-Dec 05, 2010: Be less demanding in LZMA/XZ compression tests
-Jun 30, 2010: libarchive 2.8.4 released
-Jun 30, 2010: Improved reliability of hash function detection
-Jun 30, 2010: Fix issues on ancient FreeBSD, QNX, ancient NetBSD and Minix
+Jan 10, 2012: Issue 223: Skip atime tests if atime not supported
+Jan 09, 2012: Issue 222: Errors saving sparse files to pax archives
+Jan 09, 2012: Issue 221: allow archive_*_free(NULL)
+Dec 31, 2011: Issue 212: configure script on Solaris
+Dec 30, 2011: Issue 218: empty contents extracting Zip files with bsdcpio
+Dec 30, 2011: Issue 217: fix compile warning
+Dec 30, 2011: Issue 216: truncated filenames in listings
+Dec 28, 2011: Issue 210: memory leak on Windows
+Dec 28, 2011: Issue 206: fix hardlink tests on Windows 2000
+Dec 27, 2011: Issue 208: Don't hang when using external compression
+   program on Windows
 
-Mar 14, 2010: libarchive 2.8.3 released
-Mar 14, 2010: Symlink dereference fix for Linux broke the build there; corrected.
+Dec 24, 2011: libarchive 3.0.2 released
+Dec 23, 2011: Various fixes merged from FreeBSD
+Dec 23, 2011: Symlink support in Zip reader and writer
+Dec 23, 2011: Robustness fixes to 7Zip reader
 
-Mar 14, 2010: libarchive 2.8.2 released
-Mar 12, 2010: Fix NULL deference for short self-extracting zip archives.
+Nov 27, 2011: libarchive 3.0.1b released
+
+Nov 26, 2011: 7Zip reader
+Nov 26, 2011: Small fixes to ISO and Zip to improve robustness with corrupted input
+Nov 24, 2011: Improve streaming Zip reader's support for uncompressed entries
+Nov 20, 2011: New seeking Zip reader supports SFX Zip archives
+Nov 20, 2011: Build fixes on Windows
+
+Nov 13, 2011: libarchive 3.0.0a released
+
+Nov 06, 2011: Update shared-library version calculations for libarchive 3.x
+Sep 04, 2011: Fix tar -s; follow GNU tar for controlling hardlink/symlink substitutions
+Aug 18, 2011: Fix reading ISO images built by NetBSD's mkisofs
+Aug 15, 2011: Old archive_read_support_compression_XXX functions are deprecated and
+   will disappear in libarchive 4.0.
+Jun 26, 2011: RAR reader
+Jun 16, 2011: Add tar:compat-2x option to emulate broken libarchive 2.x
+   handling of pax UTF-8 headers
+Apr 25, 2011: Refactor read_open() into a collection of single-item setters;
+   support the old interfaces as wrappers
+Apr 12, 2011: Split disk writer into separate POSIX and Windows implementations
+Apr 10, 2011: Improvements to character translations on Windows.
+Mar 30, 2011: More work to return errors instead of calling abort()
+Mar 23, 2011: Add charset option to many writers to control MBCS filenames
+Mar 17, 2011: Overhauled support for per-format extension options
+Mar 17, 2011: Track character set used for mbcs strings, support
+   translating to/from user-specified locale
+Mar 09, 2011: Recognize mtree files without requiring a signature
+Mar 06, 2011: Use iconv to convert to/from Unicode instead of making bad
+   assumptions about the C90 character set translation functions
+Feb 17, 2011: Fixes for AIX, TRU64, and other platforms
+Dec 22, 2010: CAB reader
+Dec 20, 2010: LHA/LZH reader
+Jul 03, 2010: minitar example demonstrates archive_read_disk directory traversal
+Jun 29, 2010: Many improvements to ISO reader compatibility
+Jun 26, 2010: Use larger buffers when copy files into an archive
+Jun 18, 2010: Reimplement Mac OS extensions in libarchive
+Jun 09, 2010: archive_read_disk now supports traversals
+May 28, 2010: XAR writer
+May 16, 2010: Fix ^T handling; don't exit on interrupted reads and writes
+May 09, 2010: Improved detection of platform-specific crypto support
+May 04, 2010: lzip read and write filters
+May 01, 2010: New options: tar --gid --gname --uid --uname
+Apr 28, 2010: Use Red-black tree for ISO reader/writer to improve performance
+Apr 17, 2010: Minimal writer for legacy GNU tar format
 Mar 12, 2010: Don't dereference symlinks on Linux when reading ACLs.
-Mar 07, 2010: Better detection of SHA2 support for old OpenSSL versions.
-Mar 07, 2010: Fix parsing of input files for bsdtar -T.
-Mar 07, 2010: Do not leak setup_xattr into the global namespace.
-
-Mar 06, 2010: libarchive 2.8.1 released
 Mar 06, 2010: Fix build when an older libarchive is already installed
-Mar 03, 2010: Use O_BINARY opening files in bsdtar
-Mar 02, 2010: Include missing archive_crc32.h
-Mar 01, 2010: Correctly include iconv.h required by libxml2.
+Feb 28, 2010: Relax handling of state failures; misuse by clients now generally
+      results in a sticky ARCHIVE_FATAL rather than a visit to abort()
+Feb 25, 2010: ISO writer
+Feb 21, 2010: Split many man pages into smaller chunks.
+Feb 21, 2010: Performance: Cheat on block sizes when reading archives from disk.
+Feb 21, 2010: Use int64_t instead of off_t, dev_t, ino_t, uid_t, and gid_t
+Feb 20, 2010: Document new ACL functions.
+Feb 19, 2010: Support multiple write filters
+Feb 07, 2010: Remove some legacy libarchive 1.x APIs
+Feb 04, 2010: Read afio headers
+Feb 02, 2010: Archive sparse files compatibly with GNU tar
+Feb 01, 2010: Integrate Apple extensions for Mac OS extended attributes into bsdtar
+Jan 31, 2010: Support cpio -V
 
 Feb 04, 2010: libarchive 2.8.0 released
 Jan 17, 2010: Fix error handling for 'echo nonexistent | cpio -o'
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/README
--- a/head/contrib/libarchive/README	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/README	Fri Mar 02 16:54:40 2012 +0200
@@ -13,8 +13,6 @@
           essentially the same functionality
    * examples: Some small example programs that you may find useful.
    * examples/minitar: a compact sample demonstrating use of libarchive.
-          I use this for testing link pollution; it should produce a very
-          small executable file on most systems.
    * contrib:  Various items sent to me by third parties;
           please contact the authors with any questions.
 
@@ -51,16 +49,11 @@
 a number of different formats.
 
 You should also read the copious comments in "archive.h" and the
-source code for the sample programs for more details.  Please let me
+source code for the sample programs for more details.  Please let us
 know about any errors or omissions you find.
 
-Currently, the library automatically detects and reads the following:
-  * gzip compression
-  * bzip2 compression
-  * compress/LZW compression
-  * lzma and xz compression
-  * GNU tar format (including GNU long filenames, long link names, and
-    sparse files)
+Currently, the library automatically detects and reads the following fomats:
+  * GNU tar format (including GNU long filenames, long link names, and sparse files)
   * Solaris 9 extended tar format (including ACLs)
   * Old V7 tar archives
   * POSIX ustar
@@ -73,22 +66,40 @@
   * ZIP archives (with uncompressed or "deflate" compressed entries)
   * GNU and BSD 'ar' archives
   * 'mtree' format
+  * Microsoft CAB format
+  * LHA and LZH archives
+  * RAR archives
+  * XAR archives
 
-The library can write:
+The library also detects and handles any of the following before evaluating the archive:
+  * uuencoded files
+  * files with RPM wrapper
   * gzip compression
   * bzip2 compression
   * compress/LZW compression
-  * lzma and xz compression
+  * lzma, lzip, and xz compression
+
+The library can create archives in any of the following formats:
   * POSIX ustar
   * POSIX pax interchange format
   * "restricted" pax format, which will create ustar archives except for
     entries that require pax extensions (for long filenames, ACLs, etc).
+  * Old GNU tar format
   * POSIX octet-oriented cpio
   * SVR4 "newc" cpio
   * shar archives
   * ZIP archives (with uncompressed or "deflate" compressed entries)
   * GNU and BSD 'ar' archives
   * 'mtree' format
+  * ISO9660 format
+  * XAR archives
+
+When creating archives, the result can be filtered with any of the following:
+  * uuencode
+  * gzip compression
+  * bzip2 compression
+  * compress/LZW compression
+  * lzma, lzip, and xz compression
 
 Notes about the library architecture:
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/cpio/bsdcpio.1
--- a/head/contrib/libarchive/cpio/bsdcpio.1	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/cpio/bsdcpio.1	Fri Mar 02 16:54:40 2012 +0200
@@ -22,10 +22,10 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $FreeBSD: head/contrib/libarchive/cpio/bsdcpio.1 228777 2011-12-21 15:33:13Z mm $
+.\" $FreeBSD: head/contrib/libarchive/cpio/bsdcpio.1 232153 2012-02-25 10:58:02Z mm $
 .\"
-.Dd September 5, 2010
-.Dt BSDCPIO 1
+.Dd December 21, 2007
+.Dt CPIO 1
 .Os
 .Sh NAME
 .Nm cpio
@@ -59,7 +59,7 @@
 .Bl -tag -compact -width indent
 .It Fl i
 Input.
-Read an archive from standard input (unless overriden) and extract the
+Read an archive from standard input (unless overridden) and extract the
 contents to disk or (if the
 .Fl t
 option is specified)
@@ -69,7 +69,7 @@
 .It Fl o
 Output.
 Read a list of filenames from standard input and produce a new archive
-on standard output (unless overriden) containing the specified items.
+on standard output (unless overridden) containing the specified items.
 .It Fl p
 Pass-through.
 Read a list of filenames from standard input and copy the files to the
@@ -80,7 +80,7 @@
 Unless specifically stated otherwise, options are applicable in
 all operating modes.
 .Bl -tag -width indent
-.It Fl 0
+.It Fl 0 , Fl Fl null
 Read filenames separated by NUL characters instead of newlines.
 This is necessary if any of the filenames being read might contain newlines.
 .It Fl A
@@ -102,8 +102,8 @@
 (o mode only)
 Use the old POSIX portable character format.
 Equivalent to
-.Fl -format Ar odc .
-.It Fl d
+.Fl Fl format Ar odc .
+.It Fl d , Fl Fl make-directories
 (i and p modes)
 Create directories as necessary.
 .It Fl E Ar file
@@ -111,14 +111,14 @@
 Read list of file name patterns from
 .Ar file
 to list and extract.
-.It Fl F Ar file
+.It Fl F Ar file , Fl Fl file Ar file
 Read archive from or write archive to
 .Ar file .
 .It Fl f Ar pattern
 (i mode only)
 Ignore files that match
 .Ar pattern .
-.It Fl -format Ar format
+.It Fl H Ar format , Fl Fl format Ar format
 (o mode only)
 Produce the output archive in the specified format.
 Supported formats include:
@@ -145,24 +145,21 @@
 formats currently supported by the underlying
 .Xr libarchive 3
 library.
-.It Fl H Ar format
-Synonym for
-.Fl -format .
-.It Fl h , Fl -help
+.It Fl h , Fl Fl help
 Print usage information.
 .It Fl I Ar file
 Read archive from
 .Ar file .
-.It Fl i
+.It Fl i , Fl Fl extract
 Input mode.
 See above for description.
-.It Fl -insecure
+.It Fl Fl insecure
 (i and p mode only)
 Disable security checks during extraction or copying.
 This allows extraction via symbolic links and path names containing
 .Sq ..
 in the name.
-.It Fl J
+.It Fl J , Fl Fl xz
 (o mode only)
 Compress the file with xz-compatible compression before writing it.
 In input mode, this option is ignored; xz compression is recognized
@@ -175,20 +172,20 @@
 All symbolic links will be followed.
 Normally, symbolic links are archived and copied as symbolic links.
 With this option, the target of the link will be archived or copied instead.
-.It Fl l
+.It Fl l , Fl Fl link
 (p mode only)
 Create links from the target directory to the original files,
 instead of copying.
-.It Fl lzma
+.It Fl Fl lzma
 (o mode only)
 Compress the file with lzma-compatible compression before writing it.
 In input mode, this option is ignored; lzma compression is recognized
 automatically on input.
-.It Fl m
+.It Fl m , Fl Fl preserve-modification-time
 (i and p modes)
 Set file modification time on created files to match
 those in the source.
-.It Fl n
+.It Fl n , Fl Fl numeric-uid-gid
 (i mode, only with
 .Fl t )
 Display numeric uid and gid.
@@ -197,26 +194,26 @@
 displays the user and group names when they are provided in the
 archive, or looks up the user and group names in the system
 password database.
-.It Fl no-preserve-owner
+.It Fl Fl no-preserve-owner
 (i mode only)
 Do not attempt to restore file ownership.
 This is the default when run by non-root users.
 .It Fl O Ar file
 Write archive to
 .Ar file .
-.It Fl o
+.It Fl o , Fl Fl create
 Output mode.
 See above for description.
-.It Fl p
+.It Fl p , Fl Fl pass-through
 Pass-through mode.
 See above for description.
-.It Fl preserve-owner
+.It Fl Fl preserve-owner
 (i mode only)
 Restore file ownership.
 This is the default when run by the root user.
-.It Fl -quiet
+.It Fl Fl quiet
 Suppress unnecessary messages.
-.It Fl R Oo user Oc Ns Oo : Oc Ns Oo group Oc
+.It Fl R Oo user Oc Ns Oo : Oc Ns Oo group Oc , Fl Fl owner Oo user Oc Ns Oo : Oc Ns Oo group Oc
 Set the owner and/or group on files in the output.
 If group is specified with no user
 (for example,
@@ -244,20 +241,24 @@
 If the line read is blank, the file is skipped.
 If the line contains a single period, the file is processed normally.
 Otherwise, the line is taken to be the new name of the file.
-.It Fl t
+.It Fl t , Fl Fl list
 (i mode only)
 List the contents of the archive to stdout;
 do not restore the contents to disk.
-.It Fl u
+.It Fl u , Fl Fl unconditional
 (i and p modes)
 Unconditionally overwrite existing files.
 Ordinarily, an older file will not overwrite a newer file on disk.
-.It Fl v
+.It Fl V , Fl Fl dot
+Print a dot to stderr for each file as it is processed.
+Superseded by
+.Fl v .
+.It Fl v , Fl Fl verbose
 Print the name of each file to stderr as it is processed.
 With
 .Fl t ,
 provide a detailed listing of each file.
-.It Fl -version
+.It Fl Fl version
 Print the program version information and exit.
 .It Fl y
 (o mode only)
@@ -275,6 +276,8 @@
 In input mode, this option is ignored;
 gzip compression is recognized automatically on input.
 .El
+.Sh EXIT STATUS
+.Ex -std
 .Sh ENVIRONMENT
 The following environment variables affect the execution of
 .Nm :
@@ -290,8 +293,6 @@
 .Xr environ 7
 for more information.
 .El
-.Sh EXIT STATUS
-.Ex -std
 .Sh EXAMPLES
 The
 .Nm
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/cpio/cmdline.c
--- a/head/contrib/libarchive/cpio/cmdline.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/cpio/cmdline.c	Fri Mar 02 16:54:40 2012 +0200
@@ -26,7 +26,7 @@
 
 
 #include "cpio_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/cpio/cmdline.c 228777 2011-12-21 15:33:13Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/cpio/cmdline.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
@@ -51,7 +51,7 @@
 /*
  * Short options for cpio.  Please keep this sorted.
  */
-static const char *short_options = "0AaBC:cdE:F:f:H:hI:iJjLlmnO:opR:rtuvW:yZz";
+static const char *short_options = "0AaBC:cdE:F:f:H:hI:iJjLlmnO:opR:rtuVvW:yZz";
 
 /*
  * Long options for cpio.  Please keep this sorted.
@@ -62,6 +62,7 @@
 	int equivalent;	/* Equivalent short option. */
 } cpio_longopts[] = {
 	{ "create",			0, 'o' },
+	{ "dot",			0, 'V' },
 	{ "extract",			0, 'i' },
 	{ "file",			1, 'F' },
 	{ "format",             	1, 'H' },
@@ -109,7 +110,7 @@
 	int opt = '?';
 	int required = 0;
 
-	cpio->optarg = NULL;
+	cpio->argument = NULL;
 
 	/* First time through, initialize everything. */
 	if (state == state_start) {
@@ -188,7 +189,7 @@
 				long_prefix = "-W "; /* For clearer errors. */
 			} else {
 				state = state_next_word;
-				cpio->optarg = opt_word;
+				cpio->argument = opt_word;
 			}
 		}
 	}
@@ -202,7 +203,7 @@
 		p = strchr(opt_word, '=');
 		if (p != NULL) {
 			optlength = (size_t)(p - opt_word);
-			cpio->optarg = (char *)(uintptr_t)(p + 1);
+			cpio->argument = (char *)(uintptr_t)(p + 1);
 		} else {
 			optlength = strlen(opt_word);
 		}
@@ -241,9 +242,9 @@
 		/* We've found a unique match; does it need an argument? */
 		if (match->required) {
 			/* Argument required: get next word if necessary. */
-			if (cpio->optarg == NULL) {
-				cpio->optarg = *cpio->argv;
-				if (cpio->optarg == NULL) {
+			if (cpio->argument == NULL) {
+				cpio->argument = *cpio->argv;
+				if (cpio->argument == NULL) {
 					lafe_warnc(0,
 					    "Option %s%s requires an argument",
 					    long_prefix, match->name);
@@ -254,7 +255,7 @@
 			}
 		} else {
 			/* Argument forbidden: fail if there is one. */
-			if (cpio->optarg != NULL) {
+			if (cpio->argument != NULL) {
 				lafe_warnc(0,
 				    "Option %s%s does not allow an argument",
 				    long_prefix, match->name);
@@ -340,7 +341,7 @@
 		} else {
 			char *end;
 			errno = 0;
-			*uid = strtoul(user, &end, 10);
+			*uid = (int)strtoul(user, &end, 10);
 			if (errno || *end != '\0') {
 				snprintf(errbuff, sizeof(errbuff),
 				    "Couldn't lookup user ``%s''", user);
@@ -358,7 +359,7 @@
 		} else {
 			char *end;
 			errno = 0;
-			*gid = strtoul(g, &end, 10);
+			*gid = (int)strtoul(g, &end, 10);
 			if (errno || *end != '\0') {
 				snprintf(errbuff, sizeof(errbuff),
 				    "Couldn't lookup group ``%s''", g);
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/cpio/cpio.c
--- a/head/contrib/libarchive/cpio/cpio.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/cpio/cpio.c	Fri Mar 02 16:54:40 2012 +0200
@@ -26,7 +26,7 @@
 
 
 #include "cpio_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/cpio/cpio.c 228777 2011-12-21 15:33:13Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/cpio/cpio.c 232153 2012-02-25 10:58:02Z mm $");
 
 #include <sys/types.h>
 #include <archive.h>
@@ -50,9 +50,15 @@
 #ifdef HAVE_GRP_H
 #include <grp.h>
 #endif
+#ifdef HAVE_LOCALE_H
+#include <locale.h>
+#endif
 #ifdef HAVE_PWD_H
 #include <pwd.h>
 #endif
+#ifdef HAVE_SIGNAL_H
+#include <signal.h>
+#endif
 #ifdef HAVE_STDARG_H
 #include <stdarg.h>
 #endif
@@ -69,9 +75,6 @@
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
 #ifdef HAVE_TIME_H
 #include <time.h>
 #endif
@@ -116,6 +119,7 @@
 static void	mode_list(struct cpio *);
 static void	mode_out(struct cpio *);
 static void	mode_pass(struct cpio *, const char *);
+static const char *remove_leading_slash(const char *);
 static int	restore_time(struct cpio *, struct archive_entry *,
 		    const char *, int fd);
 static void	usage(void);
@@ -136,20 +140,34 @@
 	cpio->buff = buff;
 	cpio->buff_size = sizeof(buff);
 
+#if defined(HAVE_SIGACTION) && defined(SIGPIPE)
+	{ /* Ignore SIGPIPE signals. */
+		struct sigaction sa;
+		sigemptyset(&sa.sa_mask);
+		sa.sa_flags = 0;
+		sa.sa_handler = SIG_IGN;
+		sigaction(SIGPIPE, &sa, NULL);
+	}
+#endif
+
 	/* Need lafe_progname before calling lafe_warnc. */
 	if (*argv == NULL)
 		lafe_progname = "bsdcpio";
 	else {
 #if defined(_WIN32) && !defined(__CYGWIN__)
 		lafe_progname = strrchr(*argv, '\\');
-#else
+		if (strrchr(*argv, '/') > lafe_progname)
+#endif
 		lafe_progname = strrchr(*argv, '/');
-#endif
 		if (lafe_progname != NULL)
 			lafe_progname++;
 		else
 			lafe_progname = *argv;
 	}
+#if HAVE_SETLOCALE
+	if (setlocale(LC_ALL, "") == NULL)
+		lafe_warnc(0, "Failed to set default locale");
+#endif
 
 	cpio->uid_override = -1;
 	cpio->gid_override = -1;
@@ -187,9 +205,9 @@
 			cpio->bytes_per_block = 5120;
 			break;
 		case 'C': /* NetBSD/OpenBSD */
-			cpio->bytes_per_block = atoi(cpio->optarg);
+			cpio->bytes_per_block = atoi(cpio->argument);
 			if (cpio->bytes_per_block <= 0)
-				lafe_errc(1, 0, "Invalid blocksize %s", cpio->optarg);
+				lafe_errc(1, 0, "Invalid blocksize %s", cpio->argument);
 			break;
 		case 'c': /* POSIX 1997 */
 			cpio->format = "odc";
@@ -199,22 +217,22 @@
 			break;
 		case 'E': /* NetBSD/OpenBSD */
 			lafe_include_from_file(&cpio->matching,
-			    cpio->optarg, cpio->option_null);
+			    cpio->argument, cpio->option_null);
 			break;
 		case 'F': /* NetBSD/OpenBSD/GNU cpio */
-			cpio->filename = cpio->optarg;
+			cpio->filename = cpio->argument;
 			break;
 		case 'f': /* POSIX 1997 */
-			lafe_exclude(&cpio->matching, cpio->optarg);
+			lafe_exclude(&cpio->matching, cpio->argument);
 			break;
 		case 'H': /* GNU cpio (also --format) */
-			cpio->format = cpio->optarg;
+			cpio->format = cpio->argument;
 			break;
 		case 'h':
 			long_help();
 			break;
 		case 'I': /* NetBSD/OpenBSD */
-			cpio->filename = cpio->optarg;
+			cpio->filename = cpio->argument;
 			break;
 		case 'i': /* POSIX 1997 */
 			if (cpio->mode != '\0')
@@ -251,7 +269,7 @@
 			cpio->extract_flags &= ~ARCHIVE_EXTRACT_OWNER;
 			break;
 		case 'O': /* GNU cpio */
-			cpio->filename = cpio->optarg;
+			cpio->filename = cpio->argument;
 			break;
 		case 'o': /* POSIX 1997 */
 			if (cpio->mode != '\0')
@@ -275,7 +293,7 @@
 		case 'R': /* GNU cpio, also --owner */
 			/* TODO: owner_parse should return uname/gname
 			 * also; use that to set [ug]name_override. */
-			errmsg = owner_parse(cpio->optarg, &uid, &gid);
+			errmsg = owner_parse(cpio->argument, &uid, &gid);
 			if (errmsg) {
 				lafe_warnc(-1, "%s", errmsg);
 				usage();
@@ -302,6 +320,9 @@
 		case 'v': /* POSIX 1997 */
 			cpio->verbose++;
 			break;
+		case 'V': /* GNU cpio */
+			cpio->dot++;
+			break;
 		case OPTION_VERSION: /* GNU convention */
 			version();
 			break;
@@ -345,6 +366,12 @@
 	/* -l requires -p */
 	if (cpio->option_link && cpio->mode != 'p')
 		lafe_errc(1, 0, "Option -l requires -p");
+	/* -v overrides -V */
+	if (cpio->dot && cpio->verbose)
+		cpio->dot = 0;
+	/* -v overrides -V */
+	if (cpio->dot && cpio->verbose)
+		cpio->dot = 0;
 	/* TODO: Flag other nonsensical combinations. */
 
 	switch (cpio->mode) {
@@ -402,7 +429,7 @@
 	"First option must be a mode specifier:\n"
 	"  -i Input  -o Output  -p Pass\n"
 	"Common Options:\n"
-	"  -v    Verbose\n"
+	"  -v Verbose filenames     -V  one dot per file\n"
 	"Create: %p -o [options]  < [list of files] > [archive]\n"
 	"  -J,-y,-z,--lzma  Compress archive with xz/bzip2/gzip/lzma\n"
 	"  --format {odc|newc|ustar}  Select archive format\n"
@@ -451,7 +478,7 @@
 {
 	fprintf(stdout,"bsdcpio %s -- %s\n",
 	    BSDCPIO_VERSION_STRING,
-	    archive_version());
+	    archive_version_string());
 	exit(0);
 }
 
@@ -533,6 +560,8 @@
 	}
 
 	r = archive_write_close(cpio->archive);
+	if (cpio->dot)
+		fprintf(stderr, "\n");
 	if (r != ARCHIVE_OK)
 		lafe_errc(1, 0, "%s", archive_error_string(cpio->archive));
 
@@ -543,7 +572,50 @@
 		fprintf(stderr, "%lu %s\n", (unsigned long)blocks,
 		    blocks == 1 ? "block" : "blocks");
 	}
-	archive_write_finish(cpio->archive);
+	archive_write_free(cpio->archive);
+}
+
+static const char *
+remove_leading_slash(const char *p)
+{
+	const char *rp;
+
+	/* Remove leading "//./" or "//?/" or "//?/UNC/"
+	 * (absolute path prefixes used by Windows API) */
+	if ((p[0] == '/' || p[0] == '\\') &&
+	    (p[1] == '/' || p[1] == '\\') &&
+	    (p[2] == '.' || p[2] == '?') &&
+	    (p[3] == '/' || p[3] == '\\'))
+	{
+		if (p[2] == '?' &&
+		    (p[4] == 'U' || p[4] == 'u') &&
+		    (p[5] == 'N' || p[5] == 'n') &&
+		    (p[6] == 'C' || p[6] == 'c') &&
+		    (p[7] == '/' || p[7] == '\\'))
+			p += 8;
+		else
+			p += 4;
+	}
+	do {
+		rp = p;
+		/* Remove leading drive letter from archives created
+		 * on Windows. */
+		if (((p[0] >= 'a' && p[0] <= 'z') ||
+		     (p[0] >= 'A' && p[0] <= 'Z')) &&
+			 p[1] == ':') {
+			p += 2;
+		}
+		/* Remove leading "/../", "//", etc. */
+		while (p[0] == '/' || p[0] == '\\') {
+			if (p[1] == '.' && p[2] == '.' &&
+				(p[3] == '/' || p[3] == '\\')) {
+				p += 3; /* Remove "/..", leave "/"
+					 * for next pass. */
+			} else
+				p += 1; /* Remove "/". */
+		}
+	} while (rp != p);
+	return (p);
 }
 
 /*
@@ -557,7 +629,6 @@
 	const char *destpath;
 	struct archive_entry *entry, *spare;
 	size_t len;
-	const char *p;
 	int r;
 
 	/*
@@ -611,10 +682,7 @@
 				    "Can't allocate path buffer");
 		}
 		strcpy(cpio->pass_destpath, cpio->destdir);
-		p = srcpath;
-		while (p[0] == '/')
-			++p;
-		strcat(cpio->pass_destpath, p);
+		strcat(cpio->pass_destpath, remove_leading_slash(srcpath));
 		destpath = cpio->pass_destpath;
 	}
 	if (cpio->option_rename)
@@ -656,6 +724,8 @@
 	/* Print out the destination name to the user. */
 	if (cpio->verbose)
 		fprintf(stderr,"%s", destpath);
+	if (cpio->dot)
+		fprintf(stderr, ".");
 
 	/*
 	 * Option_link only makes sense in pass mode and for
@@ -725,7 +795,7 @@
 	if (r == ARCHIVE_FATAL)
 		exit(1);
 
-	if (r >= ARCHIVE_WARN && fd >= 0) {
+	if (r >= ARCHIVE_WARN && archive_entry_size(entry) > 0 && fd >= 0) {
 		bytes_read = read(fd, cpio->buff, cpio->buff_size);
 		while (bytes_read > 0) {
 			r = archive_write_data(cpio->archive,
@@ -825,7 +895,7 @@
 	a = archive_read_new();
 	if (a == NULL)
 		lafe_errc(1, 0, "Couldn't allocate archive object");
-	archive_read_support_compression_all(a);
+	archive_read_support_filter_all(a);
 	archive_read_support_format_all(a);
 
 	if (archive_read_open_file(a, cpio->filename, cpio->bytes_per_block))
@@ -849,7 +919,9 @@
 		if (destpath == NULL)
 			continue;
 		if (cpio->verbose)
-			fprintf(stdout, "%s\n", destpath);
+			fprintf(stderr, "%s\n", destpath);
+		if (cpio->dot)
+			fprintf(stderr, ".");
 		if (cpio->uid_override >= 0)
 			archive_entry_set_uid(entry, cpio->uid_override);
 		if (cpio->gid_override >= 0)
@@ -859,13 +931,16 @@
 			fprintf(stderr, "%s: %s\n",
 			    archive_entry_pathname(entry),
 			    archive_error_string(ext));
-		} else if (archive_entry_size(entry) > 0) {
+		} else if (!archive_entry_size_is_set(entry)
+		    || archive_entry_size(entry) > 0) {
 			r = extract_data(a, ext);
 			if (r != ARCHIVE_OK)
 				cpio->return_value = 1;
 		}
 	}
 	r = archive_read_close(a);
+	if (cpio->dot)
+		fprintf(stderr, "\n");
 	if (r != ARCHIVE_OK)
 		lafe_errc(1, 0, "%s", archive_error_string(a));
 	r = archive_write_close(ext);
@@ -877,8 +952,8 @@
 		fprintf(stderr, "%lu %s\n", (unsigned long)blocks,
 		    blocks == 1 ? "block" : "blocks");
 	}
-	archive_read_finish(a);
-	archive_write_finish(ext);
+	archive_read_free(a);
+	archive_write_free(ext);
 	exit(cpio->return_value);
 }
 
@@ -892,7 +967,7 @@
 	int r;
 	size_t size;
 	const void *block;
-	off_t offset;
+	int64_t offset;
 
 	for (;;) {
 		r = archive_read_data_block(ar, &block, &size, &offset);
@@ -922,7 +997,7 @@
 	a = archive_read_new();
 	if (a == NULL)
 		lafe_errc(1, 0, "Couldn't allocate archive object");
-	archive_read_support_compression_all(a);
+	archive_read_support_filter_all(a);
 	archive_read_support_format_all(a);
 
 	if (archive_read_open_file(a, cpio->filename, cpio->bytes_per_block))
@@ -952,7 +1027,7 @@
 		fprintf(stderr, "%lu %s\n", (unsigned long)blocks,
 		    blocks == 1 ? "block" : "blocks");
 	}
-	archive_read_finish(a);
+	archive_read_free(a);
 	exit(0);
 }
 
@@ -989,11 +1064,11 @@
 		/* Use uname if it's present, else lookup name from uid. */
 		uname = archive_entry_uname(entry);
 		if (uname == NULL)
-			uname = lookup_uname(cpio, archive_entry_uid(entry));
+			uname = lookup_uname(cpio, (uid_t)archive_entry_uid(entry));
 		/* Use gname if it's present, else lookup name from gid. */
 		gname = archive_entry_gname(entry);
 		if (gname == NULL)
-			gname = lookup_gname(cpio, archive_entry_gid(entry));
+			gname = lookup_gname(cpio, (uid_t)archive_entry_gid(entry));
 	}
 
 	/* Print device number or file size. */
@@ -1075,6 +1150,8 @@
 
 	archive_entry_linkresolver_free(cpio->linkresolver);
 	r = archive_write_close(cpio->archive);
+	if (cpio->dot)
+		fprintf(stderr, "\n");
 	if (r != ARCHIVE_OK)
 		lafe_errc(1, 0, "%s", archive_error_string(cpio->archive));
 
@@ -1086,7 +1163,7 @@
 		    blocks == 1 ? "block" : "blocks");
 	}
 
-	archive_write_finish(cpio->archive);
+	archive_write_free(cpio->archive);
 }
 
 /*
@@ -1102,12 +1179,24 @@
 	static char buff[1024];
 	FILE *t;
 	char *p, *ret;
+#if defined(_WIN32) && !defined(__CYGWIN__)
+	FILE *to;
 
+	t = fopen("CONIN$", "r");
+	if (t == NULL)
+		return (name);
+	to = fopen("CONOUT$", "w");
+	if (to == NULL)
+		return (name);
+	fprintf(to, "%s (Enter/./(new name))? ", name);
+	fclose(to);
+#else
 	t = fopen("/dev/tty", "r+");
 	if (t == NULL)
 		return (name);
 	fprintf(t, "%s (Enter/./(new name))? ", name);
 	fflush(t);
+#endif
 
 	p = fgets(buff, sizeof(buff), t);
 	fclose(t);
@@ -1260,8 +1349,9 @@
 const char *
 cpio_i64toa(int64_t n0)
 {
-	// 2^64 =~ 1.8 * 10^19, so 20 decimal digits suffice.
-	// We also need 1 byte for '-' and 1 for '\0'.
+	/* 2^64 =~ 1.8 * 10^19, so 20 decimal digits suffice.
+	 * We also need 1 byte for '-' and 1 for '\0'.
+	 */
 	static char buff[22];
 	int64_t n = n0 < 0 ? -n0 : n0;
 	char *p = buff + sizeof(buff);
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/cpio/cpio.h
--- a/head/contrib/libarchive/cpio/cpio.h	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/cpio/cpio.h	Fri Mar 02 16:54:40 2012 +0200
@@ -22,7 +22,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: head/contrib/libarchive/cpio/cpio.h 228777 2011-12-21 15:33:13Z mm $
+ * $FreeBSD: head/contrib/libarchive/cpio/cpio.h 232153 2012-02-25 10:58:02Z mm $
  */
 
 #ifndef CPIO_H_INCLUDED
@@ -43,18 +43,18 @@
  */
 struct cpio {
 	/* Option parsing */
-	const char	 *optarg;
+	const char	 *argument;
 
 	/* Options */
 	const char	 *filename;
-	char		  mode; /* -i -o -p */
-	char		  compress; /* -j, -y, or -z */
+	int		  mode; /* -i -o -p */
+	int		  compress; /* -j, -y, or -z */
 	const char	 *format; /* -H format */
 	int		  bytes_per_block; /* -b block_size */
 	int		  verbose;   /* -v */
+	int		  dot;  /* -V */
 	int		  quiet;   /* --quiet */
 	int		  extract_flags; /* Flags for extract operation */
-	char		  symlink_mode; /* H or L, per BSD conventions */
 	const char	 *compress_program;
 	int		  option_append; /* -A, only relevant for -o */
 	int		  option_atime_restore; /* -a */
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/cpio/test/main.c
--- a/head/contrib/libarchive/cpio/test/main.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/cpio/test/main.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,8 +24,18 @@
  */
 
 #include "test.h"
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
 #include <errno.h>
+#ifdef HAVE_ICONV_H
+#include <iconv.h>
+#endif
+#include <limits.h>
 #include <locale.h>
+#ifdef HAVE_SIGNAL_H
+#include <signal.h>
+#endif
 #include <stdarg.h>
 #include <time.h>
 
@@ -36,12 +46,14 @@
  * TODO: Move this into a separate configuration header, have all test
  * suites share one copy of this file.
  */
-__FBSDID("$FreeBSD: head/contrib/libarchive/cpio/test/main.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/cpio/test/main.c 232153 2012-02-25 10:58:02Z mm $");
 #define KNOWNREF	"test_option_f.cpio.uu"
 #define ENVBASE "BSDCPIO" /* Prefix for environment variables. */
 #define	PROGRAM "bsdcpio" /* Name of program being tested. */
-#undef LIBRARY		  /* Not testing a library. */
-#undef	EXTRA_DUMP	     /* How to dump extra data */
+#define PROGRAM_ALIAS "cpio" /* Generic alias for program */
+#undef	LIBRARY		  /* Not testing a library. */
+#undef	EXTRA_DUMP	  /* How to dump extra data */
+#undef	EXTRA_ERRNO	  /* How to dump errno */
 /* How to generate extra version info. */
 #define	EXTRA_VERSION    (systemf("%s --version", testprog) ? "" : "")
 
@@ -78,6 +90,7 @@
 #endif
 #if !defined(__BORLANDC__)
 #define access _access
+#undef chdir
 #define chdir _chdir
 #endif
 #ifndef fileno
@@ -150,7 +163,7 @@
 
 	memset(bhfi, 0, sizeof(*bhfi));
 	h = CreateFile(path, FILE_READ_ATTRIBUTES, 0, NULL,
-		OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+		OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
 	if (h == INVALID_HANDLE_VALUE)
 		return (0);
 	r = GetFileInformationByHandle(h, bhfi);
@@ -179,6 +192,8 @@
 static int dump_on_failure = 0;
 /* Default is to remove temp dirs and log data for successful tests. */
 static int keep_temp_files = 0;
+/* Default is to run the specified tests once and report errors. */
+static int until_failure = 0;
 /* Default is to just report pass/fail for each test. */
 static int verbosity = 0;
 #define	VERBOSITY_SUMMARY_ONLY -1 /* -q */
@@ -236,10 +251,14 @@
 failure(const char *fmt, ...)
 {
 	va_list ap;
-	va_start(ap, fmt);
-	vsprintf(msgbuff, fmt, ap);
-	va_end(ap);
-	nextmsg = msgbuff;
+	if (fmt == NULL) {
+		nextmsg = NULL;
+	} else {
+		va_start(ap, fmt);
+		vsprintf(msgbuff, fmt, ap);
+		va_end(ap);
+		nextmsg = msgbuff;
+	}
 }
 
 /*
@@ -251,15 +270,14 @@
  * pass __FILE__, __LINE__ directly into the function instead of using
  * this hook.  I suspect this machinery is used so rarely that we
  * would be better off just removing it entirely.  That would simplify
- * the code here noticably.
+ * the code here noticeably.
  */
-static const char *test_filename;
-static int test_line;
-static void *test_extra;
-void assertion_setup(const char *filename, int line)
+static const char *skipping_filename;
+static int skipping_line;
+void skipping_setup(const char *filename, int line)
 {
-	test_filename = filename;
-	test_line = line;
+	skipping_filename = filename;
+	skipping_line = line;
 }
 
 /* Called at the beginning of each assert() function. */
@@ -286,6 +304,7 @@
 	int count;
 	int skip;
 }  failed_lines[10000];
+const char *failed_filename;
 
 /* Count this failure, setup up log destination and handle initial report. */
 static void
@@ -295,19 +314,16 @@
 
 	/* Record another failure for this line. */
 	++failures;
-	/* test_filename = filename; */
+	failed_filename = filename;
 	failed_lines[line].count++;
 
 	/* Determine whether to log header to console. */
 	switch (verbosity) {
-	case VERBOSITY_FULL:
-		log_console = 1;
-		break;
 	case VERBOSITY_LIGHT_REPORT:
 		log_console = (failed_lines[line].count < 2);
 		break;
 	default:
-		log_console = 0;
+		log_console = (verbosity >= VERBOSITY_FULL);
 	}
 
 	/* Log file:line header for this failure */
@@ -343,14 +359,16 @@
 {
 	(void)extra; /* UNUSED (maybe) */
 #ifdef EXTRA_DUMP
-	if (extra != NULL)
+	if (extra != NULL) {
+		logprintf("    errno: %d\n", EXTRA_ERRNO(extra));
 		logprintf("   detail: %s\n", EXTRA_DUMP(extra));
+	}
 #endif
 
 	if (dump_on_failure) {
 		fprintf(stderr,
 		    " *** forcing core dump so failure can be debugged ***\n");
-		*(char *)(NULL) = 0;
+		abort();
 		exit(1);
 	}
 }
@@ -365,12 +383,15 @@
 	va_start(ap, fmt);
 	vsprintf(buff, fmt, ap);
 	va_end(ap);
+	/* Use failure() message if set. */
+	msg = nextmsg;
+	nextmsg = NULL;
 	/* failure_start() isn't quite right, but is awfully convenient. */
-	failure_start(test_filename, test_line, "SKIPPING: %s", buff);
+	failure_start(skipping_filename, skipping_line, "SKIPPING: %s", buff);
 	--failures; /* Undo failures++ in failure_start() */
 	/* Don't failure_finish() here. */
 	/* Mark as skip, so doesn't count as failed test. */
-	failed_lines[test_line].skip = 1;
+	failed_lines[skipping_line].skip = 1;
 	++skips;
 }
 
@@ -421,13 +442,102 @@
 	return (0);
 }
 
-static void strdump(const char *e, const char *p)
+/*
+ * Utility to convert a single UTF-8 sequence.
+ */
+static int
+_utf8_to_unicode(uint32_t *pwc, const char *s, size_t n)
+{
+	static const char utf8_count[256] = {
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 00 - 0F */
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 10 - 1F */
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 20 - 2F */
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 30 - 3F */
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 40 - 4F */
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 50 - 5F */
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 60 - 6F */
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 70 - 7F */
+		 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,/* 80 - 8F */
+		 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,/* 90 - 9F */
+		 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,/* A0 - AF */
+		 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,/* B0 - BF */
+		 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,/* C0 - CF */
+		 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,/* D0 - DF */
+		 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,/* E0 - EF */
+		 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* F0 - FF */
+	};
+	int ch;
+	int cnt;
+	uint32_t wc;
+
+	*pwc = 0;
+
+	/* Sanity check. */
+	if (n == 0)
+		return (0);
+	/*
+	 * Decode 1-4 bytes depending on the value of the first byte.
+	 */
+	ch = (unsigned char)*s;
+	if (ch == 0)
+		return (0); /* Standard:  return 0 for end-of-string. */
+	cnt = utf8_count[ch];
+
+	/* Invalide sequence or there are not plenty bytes. */
+	if (n < (size_t)cnt)
+		return (-1);
+
+	/* Make a Unicode code point from a single UTF-8 sequence. */
+	switch (cnt) {
+	case 1:	/* 1 byte sequence. */
+		*pwc = ch & 0x7f;
+		return (cnt);
+	case 2:	/* 2 bytes sequence. */
+		if ((s[1] & 0xc0) != 0x80) return (-1);
+		*pwc = ((ch & 0x1f) << 6) | (s[1] & 0x3f);
+		return (cnt);
+	case 3:	/* 3 bytes sequence. */
+		if ((s[1] & 0xc0) != 0x80) return (-1);
+		if ((s[2] & 0xc0) != 0x80) return (-1);
+		wc = ((ch & 0x0f) << 12)
+		    | ((s[1] & 0x3f) << 6)
+		    | (s[2] & 0x3f);
+		if (wc < 0x800)
+			return (-1);/* Overlong sequence. */
+		break;
+	case 4:	/* 4 bytes sequence. */
+		if (n < 4)
+			return (-1);
+		if ((s[1] & 0xc0) != 0x80) return (-1);
+		if ((s[2] & 0xc0) != 0x80) return (-1);
+		if ((s[3] & 0xc0) != 0x80) return (-1);
+		wc = ((ch & 0x07) << 18)
+		    | ((s[1] & 0x3f) << 12)
+		    | ((s[2] & 0x3f) << 6)
+		    | (s[3] & 0x3f);
+		if (wc < 0x10000)
+			return (-1);/* Overlong sequence. */
+		break;
+	default:
+		return (-1);
+	}
+
+	/* The code point larger than 0x10FFFF is not leagal
+	 * Unicode values. */
+	if (wc > 0x10FFFF)
+		return (-1);
+	/* Correctly gets a Unicode, returns used bytes. */
+	*pwc = wc;
+	return (cnt);
+}
+
+static void strdump(const char *e, const char *p, int ewidth, int utf8)
 {
 	const char *q = p;
 
-	logprintf("      %s = ", e);
+	logprintf("      %*s = ", ewidth, e);
 	if (p == NULL) {
-		logprintf("NULL");
+		logprintf("NULL\n");
 		return;
 	}
 	logprintf("\"");
@@ -446,7 +556,37 @@
 		}
 	}
 	logprintf("\"");
-	logprintf(" (length %d)\n", q == NULL ? -1 : (int)strlen(q));
+	logprintf(" (length %d)", q == NULL ? -1 : (int)strlen(q));
+
+	/*
+	 * If the current string is UTF-8, dump its code points.
+	 */
+	if (utf8) {
+		size_t len;
+		uint32_t uc;
+		int n;
+		int cnt = 0;
+
+		p = q;
+		len = strlen(p);
+		logprintf(" [");
+		while ((n = _utf8_to_unicode(&uc, p, len)) > 0) {
+			if (p != q)
+				logprintf(" ");
+			logprintf("%04X", uc);
+			p += n;
+			len -= n;
+			cnt++;
+		}
+		logprintf("]");
+		logprintf(" (count %d", cnt);
+		if (n < 0) {
+			logprintf(",unknown %d bytes", len);
+		}
+		logprintf(")");
+
+	}
+	logprintf("\n");
 }
 
 /* Verify two strings are equal, dump them if not. */
@@ -454,14 +594,20 @@
 assertion_equal_string(const char *file, int line,
     const char *v1, const char *e1,
     const char *v2, const char *e2,
-    void *extra)
+    void *extra, int utf8)
 {
+	int l1, l2;
+
 	assertion_count(file, line);
 	if (v1 == v2 || (v1 != NULL && v2 != NULL && strcmp(v1, v2) == 0))
 		return (1);
 	failure_start(file, line, "%s != %s", e1, e2);
-	strdump(e1, v1);
-	strdump(e2, v2);
+	l1 = strlen(e1);
+	l2 = strlen(e2);
+	if (l1 < l2)
+		l1 = l2;
+	strdump(e1, v1, l1, utf8);
+	strdump(e2, v2, l1, utf8);
 	failure_finish(extra);
 	return (0);
 }
@@ -513,7 +659,9 @@
     void *extra)
 {
 	assertion_count(file, line);
-	if (v1 == v2 || wcscmp(v1, v2) == 0)
+	if (v1 == v2)
+		return (1);
+	if (v1 != NULL && v2 != NULL && wcscmp(v1, v2) == 0)
 		return (1);
 	failure_start(file, line, "%s != %s", e1, e2);
 	wcsdump(e1, v1);
@@ -592,9 +740,9 @@
 		offset += 16;
 	}
 	logprintf("      Dump of %s\n", e1);
-	hexdump(v1, v2, l < 64 ? l : 64, offset);
+	hexdump(v1, v2, l < 128 ? l : 128, offset);
 	logprintf("      Dump of %s\n", e2);
-	hexdump(v2, v1, l < 64 ? l : 64, offset);
+	hexdump(v2, v1, l < 128 ? l : 128, offset);
 	logprintf("\n");
 	failure_finish(extra);
 	return (0);
@@ -602,29 +750,24 @@
 
 /* Verify that the named file exists and is empty. */
 int
-assertion_empty_file(const char *f1fmt, ...)
+assertion_empty_file(const char *filename, int line, const char *f1)
 {
 	char buff[1024];
-	char f1[1024];
 	struct stat st;
-	va_list ap;
 	ssize_t s;
 	FILE *f;
 
-	assertion_count(test_filename, test_line);
-	va_start(ap, f1fmt);
-	vsprintf(f1, f1fmt, ap);
-	va_end(ap);
+	assertion_count(filename, line);
 
 	if (stat(f1, &st) != 0) {
-		failure_start(test_filename, test_line, "Stat failed: %s", f1);
+		failure_start(filename, line, "Stat failed: %s", f1);
 		failure_finish(NULL);
 		return (0);
 	}
 	if (st.st_size == 0)
 		return (1);
 
-	failure_start(test_filename, test_line, "File should be empty: %s", f1);
+	failure_start(filename, line, "File should be empty: %s", f1);
 	logprintf("    File size: %d\n", (int)st.st_size);
 	logprintf("    Contents:\n");
 	f = fopen(f1, "rb");
@@ -643,24 +786,19 @@
 
 /* Verify that the named file exists and is not empty. */
 int
-assertion_non_empty_file(const char *f1fmt, ...)
+assertion_non_empty_file(const char *filename, int line, const char *f1)
 {
-	char f1[1024];
 	struct stat st;
-	va_list ap;
 
-	assertion_count(test_filename, test_line);
-	va_start(ap, f1fmt);
-	vsprintf(f1, f1fmt, ap);
-	va_end(ap);
+	assertion_count(filename, line);
 
 	if (stat(f1, &st) != 0) {
-		failure_start(test_filename, test_line, "Stat failed: %s", f1);
+		failure_start(filename, line, "Stat failed: %s", f1);
 		failure_finish(NULL);
 		return (0);
 	}
 	if (st.st_size == 0) {
-		failure_start(test_filename, test_line, "File empty: %s", f1);
+		failure_start(filename, line, "File empty: %s", f1);
 		failure_finish(NULL);
 		return (0);
 	}
@@ -670,19 +808,14 @@
 /* Verify that two files have the same contents. */
 /* TODO: hexdump the first bytes that actually differ. */
 int
-assertion_equal_file(const char *fn1, const char *f2pattern, ...)
+assertion_equal_file(const char *filename, int line, const char *fn1, const char *fn2)
 {
-	char fn2[1024];
-	va_list ap;
 	char buff1[1024];
 	char buff2[1024];
 	FILE *f1, *f2;
 	int n1, n2;
 
-	assertion_count(test_filename, test_line);
-	va_start(ap, f2pattern);
-	vsprintf(fn2, f2pattern, ap);
-	va_end(ap);
+	assertion_count(filename, line);
 
 	f1 = fopen(fn1, "rb");
 	f2 = fopen(fn2, "rb");
@@ -701,24 +834,18 @@
 	}
 	fclose(f1);
 	fclose(f2);
-	failure_start(test_filename, test_line, "Files not identical");
+	failure_start(filename, line, "Files not identical");
 	logprintf("  file1=\"%s\"\n", fn1);
 	logprintf("  file2=\"%s\"\n", fn2);
-	failure_finish(test_extra);
+	failure_finish(NULL);
 	return (0);
 }
 
 /* Verify that the named file does exist. */
 int
-assertion_file_exists(const char *fpattern, ...)
+assertion_file_exists(const char *filename, int line, const char *f)
 {
-	char f[1024];
-	va_list ap;
-
-	assertion_count(test_filename, test_line);
-	va_start(ap, fpattern);
-	vsprintf(f, fpattern, ap);
-	va_end(ap);
+	assertion_count(filename, line);
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
 	if (!_access(f, 0))
@@ -727,22 +854,16 @@
 	if (!access(f, F_OK))
 		return (1);
 #endif
-	failure_start(test_filename, test_line, "File should exist: %s", f);
-	failure_finish(test_extra);
+	failure_start(filename, line, "File should exist: %s", f);
+	failure_finish(NULL);
 	return (0);
 }
 
 /* Verify that the named file doesn't exist. */
 int
-assertion_file_not_exists(const char *fpattern, ...)
+assertion_file_not_exists(const char *filename, int line, const char *f)
 {
-	char f[1024];
-	va_list ap;
-
-	assertion_count(test_filename, test_line);
-	va_start(ap, fpattern);
-	vsprintf(f, fpattern, ap);
-	va_end(ap);
+	assertion_count(filename, line);
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
 	if (_access(f, 0))
@@ -751,31 +872,26 @@
 	if (access(f, F_OK))
 		return (1);
 #endif
-	failure_start(test_filename, test_line, "File should not exist: %s", f);
-	failure_finish(test_extra);
+	failure_start(filename, line, "File should not exist: %s", f);
+	failure_finish(NULL);
 	return (0);
 }
 
 /* Compare the contents of a file to a block of memory. */
 int
-assertion_file_contents(const void *buff, int s, const char *fpattern, ...)
+assertion_file_contents(const char *filename, int line, const void *buff, int s, const char *fn)
 {
-	char fn[1024];
-	va_list ap;
 	char *contents;
 	FILE *f;
 	int n;
 
-	assertion_count(test_filename, test_line);
-	va_start(ap, fpattern);
-	vsprintf(fn, fpattern, ap);
-	va_end(ap);
+	assertion_count(filename, line);
 
 	f = fopen(fn, "rb");
 	if (f == NULL) {
-		failure_start(test_filename, test_line,
+		failure_start(filename, line,
 		    "File should exist: %s", fn);
-		failure_finish(test_extra);
+		failure_finish(NULL);
 		return (0);
 	}
 	contents = malloc(s * 2);
@@ -785,34 +901,34 @@
 		free(contents);
 		return (1);
 	}
-	failure_start(test_filename, test_line, "File contents don't match");
+	failure_start(filename, line, "File contents don't match");
 	logprintf("  file=\"%s\"\n", fn);
 	if (n > 0)
 		hexdump(contents, buff, n > 512 ? 512 : n, 0);
 	else {
 		logprintf("  File empty, contents should be:\n");
-		hexdump(buff, NULL, s > 512 ? 512 : n, 0);
+		hexdump(buff, NULL, s > 512 ? 512 : s, 0);
 	}
-	failure_finish(test_extra);
+	failure_finish(NULL);
 	free(contents);
 	return (0);
 }
 
 /* Check the contents of a text file, being tolerant of line endings. */
 int
-assertion_text_file_contents(const char *buff, const char *fn)
+assertion_text_file_contents(const char *filename, int line, const char *buff, const char *fn)
 {
 	char *contents;
 	const char *btxt, *ftxt;
 	FILE *f;
 	int n, s;
 
-	assertion_count(test_filename, test_line);
+	assertion_count(filename, line);
 	f = fopen(fn, "r");
 	if (f == NULL) {
-		failure_start(test_filename, test_line,
+		failure_start(filename, line,
 		    "File doesn't exist: %s", fn);
-		failure_finish(test_extra);
+		failure_finish(NULL);
 		return (0);
 	}
 	s = strlen(buff);
@@ -842,19 +958,122 @@
 		free(contents);
 		return (1);
 	}
-	failure_start(test_filename, test_line, "Contents don't match");
+	failure_start(filename, line, "Contents don't match");
 	logprintf("  file=\"%s\"\n", fn);
-	if (n > 0)
+	if (n > 0) {
 		hexdump(contents, buff, n, 0);
-	else {
+		logprintf("  expected\n", fn);
+		hexdump(buff, contents, s, 0);
+	} else {
 		logprintf("  File empty, contents should be:\n");
 		hexdump(buff, NULL, s, 0);
 	}
-	failure_finish(test_extra);
+	failure_finish(NULL);
 	free(contents);
 	return (0);
 }
 
+/* Verify that a text file contains the specified lines, regardless of order */
+/* This could be more efficient if we sorted both sets of lines, etc, but
+ * since this is used only for testing and only ever deals with a dozen or so
+ * lines at a time, this relatively crude approach is just fine. */
+int
+assertion_file_contains_lines_any_order(const char *file, int line,
+    const char *pathname, const char *lines[])
+{
+	char *buff;
+	size_t buff_size;
+	size_t expected_count, actual_count, i, j;
+	char **expected;
+	char *p, **actual;
+	char c;
+	int expected_failure = 0, actual_failure = 0;
+
+	assertion_count(file, line);
+
+	buff = slurpfile(&buff_size, "%s", pathname);
+	if (buff == NULL) {
+		failure_start(pathname, line, "Can't read file: %s", pathname);
+		failure_finish(NULL);
+		return (0);
+	}
+
+	/* Make a copy of the provided lines and count up the expected file size. */
+	expected_count = 0;
+	for (i = 0; lines[i] != NULL; ++i) {
+	}
+	expected_count = i;
+	expected = malloc(sizeof(char *) * expected_count);
+	for (i = 0; lines[i] != NULL; ++i) {
+		expected[i] = strdup(lines[i]);
+	}
+
+	/* Break the file into lines */
+	actual_count = 0;
+	for (c = '\0', p = buff; p < buff + buff_size; ++p) {
+		if (*p == '\x0d' || *p == '\x0a')
+			*p = '\0';
+		if (c == '\0' && *p != '\0')
+			++actual_count;
+		c = *p;
+	}
+	actual = malloc(sizeof(char *) * actual_count);
+	for (j = 0, p = buff; p < buff + buff_size; p += 1 + strlen(p)) {
+		if (*p != '\0') {
+			actual[j] = p;
+			++j;
+		}
+	}
+
+	/* Erase matching lines from both lists */
+	for (i = 0; i < expected_count; ++i) {
+		if (expected[i] == NULL)
+			continue;
+		for (j = 0; j < actual_count; ++j) {
+			if (actual[j] == NULL)
+				continue;
+			if (strcmp(expected[i], actual[j]) == 0) {
+				free(expected[i]);
+				expected[i] = NULL;
+				actual[j] = NULL;
+				break;
+			}
+		}
+	}
+
+	/* If there's anything left, it's a failure */
+	for (i = 0; i < expected_count; ++i) {
+		if (expected[i] != NULL)
+			++expected_failure;
+	}
+	for (j = 0; j < actual_count; ++j) {
+		if (actual[j] != NULL)
+			++actual_failure;
+	}
+	if (expected_failure == 0 && actual_failure == 0) {
+		free(buff);
+		free(expected);
+		free(actual);
+		return (1);
+	}
+	failure_start(file, line, "File doesn't match: %s", pathname);
+	for (i = 0; i < expected_count; ++i) {
+		if (expected[i] != NULL) {
+			logprintf("  Expected but not present: %s\n", expected[i]);
+			free(expected[i]);
+		}
+	}
+	for (j = 0; j < actual_count; ++j) {
+		if (actual[j] != NULL)
+			logprintf("  Present but not expected: %s\n", actual[j]);
+	}
+	failure_finish(NULL);
+	free(buff);
+	free(expected);
+	free(actual);
+	return (0);
+}
+
 /* Test that two paths point to the same file. */
 /* As a side-effect, asserts that both files exist. */
 static int
@@ -944,8 +1163,11 @@
 	ftime.dwHighDateTime = 0;
 
 	assertion_count(file, line);
+	/* Note: FILE_FLAG_BACKUP_SEMANTICS applies to open
+	 * a directory file. If not, CreateFile() will fail when
+	 * the pathname is a directory. */
 	h = CreateFile(pathname, FILE_READ_ATTRIBUTES, 0, NULL,
-	    OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+	    OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
 	if (h == INVALID_HANDLE_VALUE) {
 		failure_start(file, line, "Can't access %s\n", pathname);
 		failure_finish(NULL);
@@ -1010,14 +1232,14 @@
 		time_t now = time(NULL);
 		if (filet < now - 10 || filet > now + 1) {
 			failure_start(file, line,
-			    "File %s has %ctime %ld, %ld seconds ago\n",
+			    "File %s has %ctime %lld, %lld seconds ago\n",
 			    pathname, type, filet, now - filet);
 			failure_finish(NULL);
 			return (0);
 		}
 	} else if (filet != t || filet_nsec != nsec) {
 		failure_start(file, line,
-		    "File %s has %ctime %ld.%09ld, expected %ld.%09ld",
+		    "File %s has %ctime %lld.%09lld, expected %lld.%09lld",
 		    pathname, type, filet, filet_nsec, t, nsec);
 		failure_finish(NULL);
 		return (0);
@@ -1094,7 +1316,7 @@
 
 	assertion_count(file, line);
 	r = lstat(pathname, &st);
-	if (r == 0 && st.st_nlink == nlinks)
+	if (r == 0 && (int)st.st_nlink == nlinks)
 			return (1);
 	failure_start(file, line, "File %s has %d links, expected %d",
 	    pathname, st.st_nlink, nlinks);
@@ -1158,7 +1380,7 @@
 	/* Windows doesn't handle permissions the same way as POSIX,
 	 * so just ignore the mode tests. */
 	/* TODO: Can we do better here? */
-	if (mode >= 0 && mode != (st.st_mode & 07777)) {
+	if (mode >= 0 && (mode_t)mode != (st.st_mode & 07777)) {
 		failure_start(file, line, "Dir %s has wrong mode", pathname);
 		logprintf("  Expected: 0%3o\n", mode);
 		logprintf("  Found: 0%3o\n", st.st_mode & 07777);
@@ -1191,7 +1413,7 @@
 	/* Windows doesn't handle permissions the same way as POSIX,
 	 * so just ignore the mode tests. */
 	/* TODO: Can we do better here? */
-	if (mode >= 0 && mode != (st.st_mode & 07777)) {
+	if (mode >= 0 && (mode_t)mode != (st.st_mode & 07777)) {
 		failure_start(file, line, "File %s has wrong mode", pathname);
 		logprintf("  Expected: 0%3o\n", mode);
 		logprintf("  Found: 0%3o\n", st.st_mode & 07777);
@@ -1390,6 +1612,110 @@
 	return (1);
 }
 
+/* Set times, report failures. */
+int
+assertion_utimes(const char *file, int line,
+    const char *pathname, long at, long at_nsec, long mt, long mt_nsec)
+{
+	int r;
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#define WINTIME(sec, nsec) ((Int32x32To64(sec, 10000000) + EPOC_TIME)\
+	 + (((nsec)/1000)*10))
+	HANDLE h;
+	ULARGE_INTEGER wintm;
+	FILETIME fatime, fmtime;
+	FILETIME *pat, *pmt;
+
+	assertion_count(file, line);
+	h = CreateFileA(pathname,GENERIC_READ | GENERIC_WRITE,
+		    FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
+		    FILE_FLAG_BACKUP_SEMANTICS, NULL);
+	if (h == INVALID_HANDLE_VALUE) {
+		failure_start(file, line, "Can't access %s\n", pathname);
+		failure_finish(NULL);
+		return (0);
+	}
+
+	if (at > 0 || at_nsec > 0) {
+		wintm.QuadPart = WINTIME(at, at_nsec);
+		fatime.dwLowDateTime = wintm.LowPart;
+		fatime.dwHighDateTime = wintm.HighPart;
+		pat = &fatime;
+	} else
+		pat = NULL;
+	if (mt > 0 || mt_nsec > 0) {
+		wintm.QuadPart = WINTIME(mt, mt_nsec);
+		fmtime.dwLowDateTime = wintm.LowPart;
+		fmtime.dwHighDateTime = wintm.HighPart;
+		pmt = &fmtime;
+	} else
+		pmt = NULL;
+	if (pat != NULL || pmt != NULL)
+		r = SetFileTime(h, NULL, pat, pmt);
+	else
+		r = 1;
+	CloseHandle(h);
+	if (r == 0) {
+		failure_start(file, line, "Can't SetFileTime %s\n", pathname);
+		failure_finish(NULL);
+		return (0);
+	}
+	return (1);
+#else /* defined(_WIN32) && !defined(__CYGWIN__) */
+	struct stat st;
+	struct timeval times[2];
+
+#if !defined(__FreeBSD__)
+	mt_nsec = at_nsec = 0;	/* Generic POSIX only has whole seconds. */
+#endif
+	if (mt == 0 && mt_nsec == 0 && at == 0 && at_nsec == 0)
+		return (1);
+
+	r = lstat(pathname, &st);
+	if (r < 0) {
+		failure_start(file, line, "Can't stat %s\n", pathname);
+		failure_finish(NULL);
+		return (0);
+	}
+
+	if (mt == 0 && mt_nsec == 0) {
+		mt = st.st_mtime;
+#if defined(__FreeBSD__)
+		mt_nsec = st.st_mtimespec.tv_nsec;
+		/* FreeBSD generally only stores to microsecond res, so round. */
+		mt_nsec = (mt_nsec / 1000) * 1000;
+#endif
+	}
+	if (at == 0 && at_nsec == 0) {
+		at = st.st_atime;
+#if defined(__FreeBSD__)
+		at_nsec = st.st_atimespec.tv_nsec;
+		/* FreeBSD generally only stores to microsecond res, so round. */
+		at_nsec = (at_nsec / 1000) * 1000;
+#endif
+	}
+
+	times[1].tv_sec = mt;
+	times[1].tv_usec = mt_nsec / 1000;
+
+	times[0].tv_sec = at;
+	times[0].tv_usec = at_nsec / 1000;
+
+#ifdef HAVE_LUTIMES
+	r = lutimes(pathname, times);
+#else
+	r = utimes(pathname, times);
+#endif
+	if (r < 0) {
+		failure_start(file, line, "Can't utimes %s\n", pathname);
+		failure_finish(NULL);
+		return (0);
+	}
+	return (1);
+#endif /* defined(_WIN32) && !defined(__CYGWIN__) */
+}
+
 /*
  *
  *  UTILITIES for use by tests.
@@ -1615,6 +1941,27 @@
 	fclose(in);
 }
 
+int
+is_LargeInode(const char *file)
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+	BY_HANDLE_FILE_INFORMATION bhfi;
+	int r;
+
+	r = my_GetFileInformationByName(file, &bhfi);
+	if (r != 0)
+		return (0);
+	return (bhfi.nFileIndexHigh & 0x0000FFFFUL);
+#else
+	struct stat st;
+	int64_t ino;
+
+	if (stat(file, &st) < 0)
+		return (0);
+	ino = (int64_t)st.st_ino;
+	return (ino > 0xffffffff);
+#endif
+}
 /*
  *
  * TEST management
@@ -1644,7 +1991,7 @@
  * Summarize repeated failures in the just-completed test.
  */
 static void
-test_summarize(const char *filename, int failed)
+test_summarize(int failed)
 {
 	unsigned int i;
 
@@ -1663,9 +2010,10 @@
 	for (i = 0; i < sizeof(failed_lines)/sizeof(failed_lines[0]); i++) {
 		if (failed_lines[i].count > 1 && !failed_lines[i].skip)
 			logprintf("%s:%d: Summary: Failed %d times\n",
-			    filename, i, failed_lines[i].count);
+			    failed_filename, i, failed_lines[i].count);
 	}
 	/* Clear the failure history for the next file. */
+	failed_filename = NULL;
 	memset(failed_lines, 0, sizeof(failed_lines));
 }
 
@@ -1675,6 +2023,7 @@
 static int
 test_run(int i, const char *tmpdir)
 {
+	char workdir[1024];
 	char logfilename[64];
 	int failures_before = failures;
 	int oldumask;
@@ -1701,11 +2050,12 @@
 	logfile = fopen(logfilename, "w");
 	fprintf(logfile, "%s\n\n", tests[i].name);
 	/* Chdir() to a work dir for this specific test. */
-	if (!assertMakeDir(tests[i].name, 0755)
-	    || !assertChdir(tests[i].name)) {
+	snprintf(workdir, sizeof(workdir), "%s/%s", tmpdir, tests[i].name);
+	testworkdir = workdir;
+	if (!assertMakeDir(testworkdir, 0755)
+	    || !assertChdir(testworkdir)) {
 		fprintf(stderr,
-		    "ERROR: Can't chdir to work dir %s/%s\n",
-		    tmpdir, tests[i].name);
+		    "ERROR: Can't chdir to work dir %s\n", testworkdir);
 		exit(1);
 	}
 	/* Explicitly reset the locale before each test. */
@@ -1719,6 +2069,7 @@
 	/*
 	 * Clean up and report afterwards.
 	 */
+	testworkdir = NULL;
 	/* Restore umask */
 	umask(oldumask);
 	/* Reset locale. */
@@ -1731,7 +2082,7 @@
 	}
 	/* Report per-test summaries. */
 	tests[i].failures = failures - failures_before;
-	test_summarize(test_filename, tests[i].failures);
+	test_summarize(tests[i].failures);
 	/* Close the per-test log file. */
 	fclose(logfile);
 	logfile = NULL;
@@ -1791,6 +2142,7 @@
 	printf("  -q  Quiet.\n");
 	printf("  -r <dir>   Path to dir containing reference files.\n");
 	printf("      Default: Current directory.\n");
+	printf("  -u  Keep running specifies tests until one fails.\n");
 	printf("  -v  Verbose.\n");
 	printf("Available tests:\n");
 	for (i = 0; i < limit; i++)
@@ -1817,7 +2169,11 @@
 	}
 
 	/* Get the current dir. */
+#ifdef PATH_MAX
+	pwd = getcwd(NULL, PATH_MAX);/* Solaris getcwd needs the size. */
+#else
 	pwd = getcwd(NULL, 0);
+#endif
 	while (pwd[strlen(pwd) - 1] == '\n')
 		pwd[strlen(pwd) - 1] = '\0';
 
@@ -1844,6 +2200,14 @@
 	strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
 	strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
 
+#if defined(PROGRAM_ALIAS)
+	snprintf(buff, sizeof(buff), "%s/%s/test", pwd, PROGRAM_ALIAS);
+	p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
+	if (p != NULL) goto success;
+	strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
+	strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+#endif
+
 	if (memcmp(pwd, "/usr/obj", 8) == 0) {
 		snprintf(buff, sizeof(buff), "%s", pwd + 8);
 		p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
@@ -1876,16 +2240,26 @@
 main(int argc, char **argv)
 {
 	static const int limit = sizeof(tests) / sizeof(tests[0]);
-	int i, tests_run = 0, tests_failed = 0, option;
+	int i = 0, j = 0, start, end, tests_run = 0, tests_failed = 0, option;
 	time_t now;
 	char *refdir_alloc = NULL;
 	const char *progname;
+	char **saved_argv;
 	const char *tmp, *option_arg, *p;
-	char tmpdir[256];
+	char tmpdir[256], *pwd, *testprogdir, *tmp2 = NULL;
 	char tmpdir_timestamp[256];
 
 	(void)argc; /* UNUSED */
 
+	/* Get the current dir. */
+#ifdef PATH_MAX
+	pwd = getcwd(NULL, PATH_MAX);/* Solaris getcwd needs the size. */
+#else
+	pwd = getcwd(NULL, 0);
+#endif
+	while (pwd[strlen(pwd) - 1] == '\n')
+		pwd[strlen(pwd) - 1] = '\0';
+
 #if defined(HAVE__CrtSetReportMode)
 	/* To stop to run the default invalid parameter handler. */
 	_set_invalid_parameter_handler(invalid_parameter_handler);
@@ -1898,11 +2272,44 @@
 	 * tree.
 	 */
 	progname = p = argv[0];
+	if ((testprogdir = (char *)malloc(strlen(progname) + 1)) == NULL)
+	{
+		fprintf(stderr, "ERROR: Out of memory.");
+		exit(1);
+	}
+	strcpy(testprogdir, progname);
 	while (*p != '\0') {
 		/* Support \ or / dir separators for Windows compat. */
 		if (*p == '/' || *p == '\\')
+		{
 			progname = p + 1;
+			i = j;
+		}
 		++p;
+		j++;
+	}
+	testprogdir[i] = '\0';
+#if defined(_WIN32) && !defined(__CYGWIN__)
+	if (testprogdir[0] != '/' && testprogdir[0] != '\\' &&
+	    !(((testprogdir[0] >= 'a' && testprogdir[0] <= 'z') ||
+	       (testprogdir[0] >= 'A' && testprogdir[0] <= 'Z')) &&
+		testprogdir[1] == ':' &&
+		(testprogdir[2] == '/' || testprogdir[2] == '\\')))
+#else
+	if (testprogdir[0] != '/')
+#endif
+	{
+		/* Fixup path for relative directories. */
+		if ((testprogdir = (char *)realloc(testprogdir,
+			strlen(pwd) + 1 + strlen(testprogdir) + 1)) == NULL)
+		{
+			fprintf(stderr, "ERROR: Out of memory.");
+			exit(1);
+		}
+		memmove(testprogdir + strlen(pwd) + 1, testprogdir,
+		    strlen(testprogdir));
+		memcpy(testprogdir, pwd, strlen(pwd));
+		testprogdir[strlen(pwd)] = '/';
 	}
 
 #ifdef PROGRAM
@@ -1967,6 +2374,7 @@
 #ifdef PROGRAM
 				testprogfile = option_arg;
 #else
+				fprintf(stderr, "-p option not permitted\n");
 				usage(progname);
 #endif
 				break;
@@ -1976,10 +2384,15 @@
 			case 'r':
 				refdir = option_arg;
 				break;
+			case 'u':
+				until_failure++;
+				break;
 			case 'v':
 				verbosity++;
 				break;
 			default:
+				fprintf(stderr, "Unrecognized option '%c'\n",
+				    option);
 				usage(progname);
 			}
 		}
@@ -1990,7 +2403,19 @@
 	 */
 #ifdef PROGRAM
 	if (testprogfile == NULL)
-		usage(progname);
+	{
+		if ((tmp2 = (char *)malloc(strlen(testprogdir) + 1 +
+			strlen(PROGRAM) + 1)) == NULL)
+		{
+			fprintf(stderr, "ERROR: Out of memory.");
+			exit(1);
+		}
+		strcpy(tmp2, testprogdir);
+		strcat(tmp2, "/");
+		strcat(tmp2, PROGRAM);
+		testprogfile = tmp2;
+	}
+
 	{
 		char *testprg;
 #if defined(_WIN32) && !defined(__CYGWIN__)
@@ -2011,6 +2436,16 @@
 	}
 #endif
 
+#if !defined(_WIN32) && defined(SIGPIPE)
+	{   /* Ignore SIGPIPE signals */
+		struct sigaction sa;
+		sa.sa_handler = SIG_IGN;
+		sigemptyset(&sa.sa_mask);
+		sa.sa_flags = 0;
+		sigaction(SIGPIPE, &sa, NULL);
+	}
+#endif
+
 	/*
 	 * Create a temp directory for the following tests.
 	 * Include the time the tests started as part of the name,
@@ -2063,42 +2498,88 @@
 	/*
 	 * Run some or all of the individual tests.
 	 */
-	if (*argv == NULL) {
-		/* Default: Run all tests. */
-		for (i = 0; i < limit; i++) {
-			if (test_run(i, tmpdir))
-				tests_failed++;
-			tests_run++;
-		}
-	} else {
-		while (*(argv) != NULL) {
-			if (**argv >= '0' && **argv <= '9') {
-				i = atoi(*argv);
-				if (i < 0 || i >= limit) {
-					printf("*** INVALID Test %s\n", *argv);
-					free(refdir_alloc);
-					usage(progname);
-					/* usage() never returns */
-				}
-			} else {
-				for (i = 0; i < limit; ++i) {
-					if (strcmp(*argv, tests[i].name) == 0)
-						break;
-				}
-				if (i >= limit) {
-					printf("*** INVALID Test ``%s''\n",
-					       *argv);
-					free(refdir_alloc);
-					usage(progname);
-					/* usage() never returns */
+	saved_argv = argv;
+	do {
+		argv = saved_argv;
+		if (*argv == NULL) {
+			/* Default: Run all tests. */
+			for (i = 0; i < limit; i++) {
+				tests_run++;
+				if (test_run(i, tmpdir)) {
+					tests_failed++;
+					if (until_failure)
+						goto finish;
 				}
 			}
-			if (test_run(i, tmpdir))
-				tests_failed++;
-			tests_run++;
-			argv++;
+		} else {
+			while (*(argv) != NULL) {
+				if (**argv >= '0' && **argv <= '9') {
+					char *vp = *argv;
+					start = 0;
+					while (*vp >= '0' && *vp <= '9') {
+						start *= 10;
+						start += *vp - '0';
+						++vp;
+					}
+					if (*vp == '\0') {
+						end = start;
+					} else if (*vp == '-') {
+						++vp;
+						if (*vp == '\0') {
+							end = limit - 1;
+						} else {
+							end = 0;
+							while (*vp >= '0' && *vp <= '9') {
+								end *= 10;
+								end += *vp - '0';
+								++vp;
+							}
+						}
+					} else {
+						printf("*** INVALID Test %s\n", *argv);
+						free(refdir_alloc);
+						usage(progname);
+						return (1);
+					}
+					if (start < 0 || end >= limit || start > end) {
+						printf("*** INVALID Test %s\n", *argv);
+						free(refdir_alloc);
+						usage(progname);
+						return (1);
+					}
+				} else {
+					for (start = 0; start < limit; ++start) {
+						if (strcmp(*argv, tests[start].name) == 0)
+							break;
+					}
+					end = start;
+					if (start >= limit) {
+						printf("*** INVALID Test ``%s''\n",
+						    *argv);
+						free(refdir_alloc);
+						usage(progname);
+						/* usage() never returns */
+					}
+				}
+				while (start <= end) {
+					tests_run++;
+					if (test_run(start, tmpdir)) {
+						tests_failed++;
+						if (until_failure)
+							goto finish;
+					}
+					++start;
+				}
+				argv++;
+			}
 		}
-	}
+	} while (until_failure);
+
+finish:
+	/* Must be freed after all tests run */
+	free(tmp2);
+	free(testprogdir);
+	free(pwd);
 
 	/*
 	 * Report summary statistics.
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/cpio/test/test.h
--- a/head/contrib/libarchive/cpio/test/test.h	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/cpio/test/test.h	Fri Mar 02 16:54:40 2012 +0200
@@ -22,7 +22,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: head/contrib/libarchive/cpio/test/test.h 228763 2011-12-21 11:13:29Z mm $
+ * $FreeBSD: head/contrib/libarchive/cpio/test/test.h 232153 2012-02-25 10:58:02Z mm $
  */
 
 /* Every test program should #include "test.h" as the first thing. */
@@ -48,9 +48,6 @@
 #include <sys/types.h>  /* Windows requires this before sys/stat.h */
 #include <sys/stat.h>
 
-#ifdef USE_DMALLOC
-#include <dmalloc.h>
-#endif
 #if HAVE_DIRENT_H
 #include <dirent.h>
 #endif
@@ -63,6 +60,9 @@
 #ifdef HAVE_IO_H
 #include <io.h>
 #endif
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -83,13 +83,9 @@
 
 /* Windows (including Visual Studio and MinGW but not Cygwin) */
 #if defined(_WIN32) && !defined(__CYGWIN__)
-#include "../cpio_windows.h"
 #if !defined(__BORLANDC__)
 #define strdup _strdup
 #endif
-#define LOCALE_DE	"deu"
-#else
-#define LOCALE_DE	"de_DE.UTF-8"
 #endif
 
 /* Visual Studio */
@@ -97,13 +93,11 @@
 #define snprintf	sprintf_s
 #endif
 
-/* Cygwin */
-#if defined(__CYGWIN__)
-/* Cygwin-1.7.x is lazy about populating nlinks, so don't
- * expect it to be accurate. */
-# define NLINKS_INACCURATE_FOR_DIRS
+#if defined(__BORLANDC__)
+#pragma warn -8068	/* Constant out of range in comparison. */
 #endif
 
+/* Haiku OS and QNX */
 #if defined(__HAIKU__) || defined(__QNXNTO__)
 /* Haiku and QNX have typedefs in stdint.h (needed for int64_t) */
 #include <stdint.h>
@@ -139,24 +133,24 @@
   assertion_equal_int(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
 /* Assert two strings are the same.  Reports value of each one if not. */
 #define assertEqualString(v1,v2)   \
-  assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
+  assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL, 0)
+#define assertEqualUTF8String(v1,v2)   \
+  assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL, 1)
 /* As above, but v1 and v2 are wchar_t * */
 #define assertEqualWString(v1,v2)   \
   assertion_equal_wstring(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
 /* As above, but raw blocks of bytes. */
 #define assertEqualMem(v1, v2, l)	\
   assertion_equal_mem(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (l), #l, NULL)
-/* Assert two files are the same; allow printf-style expansion of second name.
- * See below for comments about variable arguments here...
- */
-#define assertEqualFile		\
-  assertion_setup(__FILE__, __LINE__);assertion_equal_file
-/* Assert that a file is empty; supports printf-style arguments. */
-#define assertEmptyFile		\
-  assertion_setup(__FILE__, __LINE__);assertion_empty_file
-/* Assert that a file is not empty; supports printf-style arguments. */
-#define assertNonEmptyFile		\
-  assertion_setup(__FILE__, __LINE__);assertion_non_empty_file
+/* Assert two files are the same. */
+#define assertEqualFile(f1, f2)	\
+  assertion_equal_file(__FILE__, __LINE__, (f1), (f2))
+/* Assert that a file is empty. */
+#define assertEmptyFile(pathname)	\
+  assertion_empty_file(__FILE__, __LINE__, (pathname))
+/* Assert that a file is not empty. */
+#define assertNonEmptyFile(pathname)		\
+  assertion_non_empty_file(__FILE__, __LINE__, (pathname))
 #define assertFileAtime(pathname, sec, nsec)	\
   assertion_file_atime(__FILE__, __LINE__, pathname, sec, nsec)
 #define assertFileAtimeRecent(pathname)	\
@@ -166,14 +160,14 @@
 #define assertFileBirthtimeRecent(pathname) \
   assertion_file_birthtime_recent(__FILE__, __LINE__, pathname)
 /* Assert that a file exists; supports printf-style arguments. */
-#define assertFileExists		\
-  assertion_setup(__FILE__, __LINE__);assertion_file_exists
-/* Assert that a file exists; supports printf-style arguments. */
-#define assertFileNotExists		\
-  assertion_setup(__FILE__, __LINE__);assertion_file_not_exists
-/* Assert that file contents match a string; supports printf-style arguments. */
-#define assertFileContents             \
-  assertion_setup(__FILE__, __LINE__);assertion_file_contents
+#define assertFileExists(pathname) \
+  assertion_file_exists(__FILE__, __LINE__, pathname)
+/* Assert that a file exists. */
+#define assertFileNotExists(pathname) \
+  assertion_file_not_exists(__FILE__, __LINE__, pathname)
+/* Assert that file contents match a string. */
+#define assertFileContents(data, data_size, pathname) \
+  assertion_file_contents(__FILE__, __LINE__, data, data_size, pathname)
 #define assertFileMtime(pathname, sec, nsec)	\
   assertion_file_mtime(__FILE__, __LINE__, pathname, sec, nsec)
 #define assertFileMtimeRecent(pathname) \
@@ -182,8 +176,10 @@
   assertion_file_nlinks(__FILE__, __LINE__, pathname, nlinks)
 #define assertFileSize(pathname, size)  \
   assertion_file_size(__FILE__, __LINE__, pathname, size)
-#define assertTextFileContents         \
-  assertion_setup(__FILE__, __LINE__);assertion_text_file_contents
+#define assertTextFileContents(text, pathname) \
+  assertion_text_file_contents(__FILE__, __LINE__, text, pathname)
+#define assertFileContainsLinesAnyOrder(pathname, lines)	\
+  assertion_file_contains_lines_any_order(__FILE__, __LINE__, pathname, lines)
 #define assertIsDir(pathname, mode)		\
   assertion_is_dir(__FILE__, __LINE__, pathname, mode)
 #define assertIsHardlink(path1, path2)	\
@@ -205,6 +201,8 @@
   assertion_make_symlink(__FILE__, __LINE__, newfile, linkto)
 #define assertUmask(mask)	\
   assertion_umask(__FILE__, __LINE__, mask)
+#define assertUtimes(pathname, atime, atime_nsec, mtime, mtime_nsec)	\
+  assertion_utimes(__FILE__, __LINE__, pathname, atime, atime_nsec, mtime, mtime_nsec)
 
 /*
  * This would be simple with C99 variadic macros, but I don't want to
@@ -213,28 +211,29 @@
  * but effective.
  */
 #define skipping	\
-  assertion_setup(__FILE__, __LINE__);test_skipping
+  skipping_setup(__FILE__, __LINE__);test_skipping
 
 /* Function declarations.  These are defined in test_utility.c. */
 void failure(const char *fmt, ...);
 int assertion_assert(const char *, int, int, const char *, void *);
 int assertion_chdir(const char *, int, const char *);
-int assertion_empty_file(const char *, ...);
-int assertion_equal_file(const char *, const char *, ...);
+int assertion_empty_file(const char *, int, const char *);
+int assertion_equal_file(const char *, int, const char *, const char *);
 int assertion_equal_int(const char *, int, long long, const char *, long long, const char *, void *);
 int assertion_equal_mem(const char *, int, const void *, const char *, const void *, const char *, size_t, const char *, void *);
-int assertion_equal_string(const char *, int, const char *v1, const char *, const char *v2, const char *, void *);
+int assertion_equal_string(const char *, int, const char *v1, const char *, const char *v2, const char *, void *, int);
 int assertion_equal_wstring(const char *, int, const wchar_t *v1, const char *, const wchar_t *v2, const char *, void *);
 int assertion_file_atime(const char *, int, const char *, long, long);
 int assertion_file_atime_recent(const char *, int, const char *);
 int assertion_file_birthtime(const char *, int, const char *, long, long);
 int assertion_file_birthtime_recent(const char *, int, const char *);
-int assertion_file_contents(const void *, int, const char *, ...);
-int assertion_file_exists(const char *, ...);
+int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **);
+int assertion_file_contents(const char *, int, const void *, int, const char *);
+int assertion_file_exists(const char *, int, const char *);
 int assertion_file_mtime(const char *, int, const char *, long, long);
 int assertion_file_mtime_recent(const char *, int, const char *);
 int assertion_file_nlinks(const char *, int, const char *, int);
-int assertion_file_not_exists(const char *, ...);
+int assertion_file_not_exists(const char *, int, const char *);
 int assertion_file_size(const char *, int, const char *, long);
 int assertion_is_dir(const char *, int, const char *, int);
 int assertion_is_hardlink(const char *, int, const char *, const char *);
@@ -245,11 +244,12 @@
 int assertion_make_file(const char *, int, const char *, int, const char *);
 int assertion_make_hardlink(const char *, int, const char *newpath, const char *);
 int assertion_make_symlink(const char *, int, const char *newpath, const char *);
-int assertion_non_empty_file(const char *, ...);
-int assertion_text_file_contents(const char *buff, const char *f);
+int assertion_non_empty_file(const char *, int, const char *);
+int assertion_text_file_contents(const char *, int, const char *buff, const char *f);
 int assertion_umask(const char *, int, int);
-void assertion_setup(const char *, int);
+int assertion_utimes(const char *, int, const char *, long, long, long, long );
 
+void skipping_setup(const char *, int);
 void test_skipping(const char *fmt, ...);
 
 /* Like sprintf, then system() */
@@ -267,6 +267,9 @@
 /* Return true if this platform can run the "gunzip" program. */
 int canGunzip(void);
 
+/* Return true if the file has large i-node number(>0xffffffff). */
+int is_LargeInode(const char *);
+
 /* Suck file into string allocated via malloc(). Call free() when done. */
 /* Supports printf-style args: slurpfile(NULL, "%s/myfile", refdir); */
 char *slurpfile(size_t *, const char *fmt, ...);
@@ -274,6 +277,9 @@
 /* Extracts named reference file to the current directory. */
 void extract_reference_file(const char *);
 
+/* Path to working directory for current test */
+const char *testworkdir;
+
 /*
  * Special interfaces for program test harness.
  */
@@ -283,3 +289,7 @@
 /* Name of exe to use in printf-formatted command strings. */
 /* On Windows, this includes leading/trailing quotes. */
 const char *testprog;
+
+#ifdef USE_DMALLOC
+#include <dmalloc.h>
+#endif
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/cpio/test/test_0.c
--- a/head/contrib/libarchive/cpio/test/test_0.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/cpio/test/test_0.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/cpio/test/test_0.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/cpio/test/test_0.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * This first test does basic sanity checks on the environment.  For
@@ -40,15 +40,23 @@
 	struct stat st;
 
 	failure("File %s does not exist?!", testprogfile);
-	if (!assertEqualInt(0, stat(testprogfile, &st)))
+	if (!assertEqualInt(0, stat(testprogfile, &st))) {
+		fprintf(stderr,
+		    "\nFile %s does not exist; aborting test.\n\n",
+		    testprog);
 		exit(1);
+	}
 
 	failure("%s is not executable?!", testprogfile);
-	if (!assert((st.st_mode & 0111) != 0))
+	if (!assert((st.st_mode & 0111) != 0)) {
+		fprintf(stderr,
+		    "\nFile %s not executable; aborting test.\n\n",
+		    testprog);
 		exit(1);
+	}
 
 	/*
-	 * Try to succesfully run the program; this requires that
+	 * Try to successfully run the program; this requires that
 	 * we know some option that will succeed.
 	 */
 	if (0 == systemf("%s --version >" DEV_NULL, testprog)) {
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/cpio/test/test_basic.c
--- a/head/contrib/libarchive/cpio/test/test_basic.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/cpio/test/test_basic.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/cpio/test/test_basic.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/cpio/test/test_basic.c 232153 2012-02-25 10:58:02Z mm $");
 
 static void
 verify_files(const char *msg)
@@ -33,12 +33,15 @@
 	 */
 
 	/* Regular file with 2 links. */
+	failure(msg);
 	assertIsReg("file", 0644);
 	failure(msg);
 	assertFileSize("file", 10);
+	failure(msg);
 	assertFileNLinks("file", 2);
 
 	/* Another name for the same file. */
+	failure(msg);
 	assertIsHardlink("linkfile", "file");
 
 	/* Symlink */
@@ -46,8 +49,11 @@
 		assertIsSymlink("symlink", "file");
 
 	/* Another file with 1 link and different permissions. */
+	failure(msg);
 	assertIsReg("file2", 0777);
+	failure(msg);
 	assertFileSize("file2", 10);
+	failure(msg);
 	assertFileNLinks("file2", 1);
 
 	/* dir */
@@ -58,7 +64,7 @@
 basic_cpio(const char *target,
     const char *pack_options,
     const char *unpack_options,
-    const char *se)
+    const char *se, const char *se2)
 {
 	int r;
 
@@ -87,7 +93,7 @@
 
 	/* Verify stderr. */
 	failure("Error invoking %s -i %s in dir %s", testprog, unpack_options, target);
-	assertTextFileContents(se, "unpack.err");
+	assertTextFileContents(se2, "unpack.err");
 
 	verify_files(pack_options);
 
@@ -125,6 +131,7 @@
 {
 	FILE *filelist;
 	const char *msg;
+	char result[1024];
 
 	assertUmask(0);
 
@@ -132,28 +139,56 @@
 	 * Create an assortment of files on disk.
 	 */
 	filelist = fopen("filelist", "w");
+	memset(result, 0, sizeof(result));
 
 	/* File with 10 bytes content. */
 	assertMakeFile("file", 0644, "1234567890");
 	fprintf(filelist, "file\n");
+	if (is_LargeInode("file"))
+		strncat(result,
+		    "bsdcpio: file: large inode number truncated: "
+		    "Numerical result out of range\n",
+		    sizeof(result) - strlen(result));
 
 	/* hardlink to above file. */
 	assertMakeHardlink("linkfile", "file");
 	fprintf(filelist, "linkfile\n");
+	if (is_LargeInode("linkfile"))
+		strncat(result,
+		    "bsdcpio: linkfile: large inode number truncated: "
+		    "Numerical result out of range\n",
+		    sizeof(result) - strlen(result));
 
 	/* Symlink to above file. */
 	if (canSymlink()) {
 		assertMakeSymlink("symlink", "file");
 		fprintf(filelist, "symlink\n");
+		if (is_LargeInode("symlink"))
+			strncat(result,
+			    "bsdcpio: symlink: large inode number truncated: "
+				"Numerical result out of range\n",
+			    sizeof(result) - strlen(result));
 	}
 
 	/* Another file with different permissions. */
 	assertMakeFile("file2", 0777, "1234567890");
 	fprintf(filelist, "file2\n");
+	if (is_LargeInode("file2"))
+		strncat(result,
+		    "bsdcpio: file2: large inode number truncated: "
+		    "Numerical result out of range\n",
+		    sizeof(result) - strlen(result));
 
 	/* Directory. */
 	assertMakeDir("dir", 0775);
 	fprintf(filelist, "dir\n");
+	if (is_LargeInode("dir"))
+		strncat(result,
+		    "bsdcpio: dir: large inode number truncated: "
+		    "Numerical result out of range\n",
+		    sizeof(result) - strlen(result));
+	strncat(result, "2 blocks\n", sizeof(result) - strlen(result));
+
 	/* All done. */
 	fclose(filelist);
 
@@ -161,12 +196,12 @@
 
 	/* Archive/dearchive with a variety of options. */
 	msg = canSymlink() ? "2 blocks\n" : "1 block\n";
-	basic_cpio("copy", "", "", msg);
-	basic_cpio("copy_odc", "--format=odc", "", msg);
-	basic_cpio("copy_newc", "-H newc", "", "2 blocks\n");
-	basic_cpio("copy_cpio", "-H odc", "", msg);
+	basic_cpio("copy", "", "", msg, msg);
+	basic_cpio("copy_odc", "--format=odc", "", msg, msg);
+	basic_cpio("copy_newc", "-H newc", "", result, "2 blocks\n");
+	basic_cpio("copy_cpio", "-H odc", "", msg, msg);
 	msg = canSymlink() ? "9 blocks\n" : "8 blocks\n";
-	basic_cpio("copy_ustar", "-H ustar", "", msg);
+	basic_cpio("copy_ustar", "-H ustar", "", msg, msg);
 
 	/* Copy in one step using -p */
 	passthrough("passthrough");
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/cpio/test/test_format_newc.c
--- a/head/contrib/libarchive/cpio/test/test_format_newc.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/cpio/test/test_format_newc.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/cpio/test/test_format_newc.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/cpio/test/test_format_newc.c 232153 2012-02-25 10:58:02Z mm $");
 
 /* Number of bytes needed to pad 'n' to multiple of 'block', assuming
  * that 'block' is a power of two. This trick can be more easily
@@ -68,6 +68,16 @@
 	return (r);
 }
 
+#if !defined(_WIN32) || defined(__CYGWIN__)
+static int
+nlinks(const char *p)
+{
+	struct stat st;
+	assertEqualInt(0, stat(p, &st));
+	return st.st_nlink;
+}
+#endif
+
 DEFINE_TEST(test_format_newc)
 {
 	FILE *list;
@@ -77,6 +87,7 @@
 	time_t t, t2, now;
 	char *p, *e;
 	size_t s, fs, ns;
+	char result[1024];
 
 	assertUmask(0);
 
@@ -111,6 +122,29 @@
 	assertMakeDir("dir", 0775);
 	fprintf(list, "dir\n");
 
+	/* Setup result message. */
+	memset(result, 0, sizeof(result));
+	if (is_LargeInode("file1"))
+		strncat(result,
+		    "bsdcpio: file1: large inode number truncated: "
+		    "Numerical result out of range\n",
+		    sizeof(result) - strlen(result) -1);
+	if (canSymlink() && is_LargeInode("symlink"))
+		strncat(result,
+		    "bsdcpio: symlink: large inode number truncated: "
+			"Numerical result out of range\n",
+		    sizeof(result) - strlen(result) -1);
+	if (is_LargeInode("dir"))
+		strncat(result,
+		    "bsdcpio: dir: large inode number truncated: "
+		    "Numerical result out of range\n",
+		    sizeof(result) - strlen(result) -1);
+	if (is_LargeInode("hardlink"))
+		strncat(result,
+		    "bsdcpio: hardlink: large inode number truncated: "
+		    "Numerical result out of range\n",
+		    sizeof(result) - strlen(result) -1);
+
 	/* Record some facts about what we just created: */
 	now = time(NULL); /* They were all created w/in last two seconds. */
 
@@ -123,10 +157,11 @@
 
 	/* Verify that nothing went to stderr. */
 	if (canSymlink()) {
-		assertTextFileContents("2 blocks\n", "newc.err");
+		strncat(result, "2 blocks\n", sizeof(result) - strlen(result));
 	} else {
-		assertTextFileContents("1 block\n", "newc.err");
+		strncat(result, "1 block\n", sizeof(result) - strlen(result));
 	}
+	assertTextFileContents(result, "newc.err");
 
 	/* Verify that stdout is a well-formed cpio file in "newc" format. */
 	p = slurpfile(&s, "newc.out");
@@ -216,10 +251,10 @@
 	/* Mode: sgid bit sometimes propagates from parent dirs, ignore it. */
 	assertEqualInt(040775, from_hex(e + 14, 8) & ~02000);
 #endif
-	assertEqualInt(from_hex(e + 22, 8), uid); /* uid */
+	assertEqualInt(uid, from_hex(e + 22, 8)); /* uid */
 	assertEqualInt(gid, from_hex(e + 30, 8)); /* gid */
-#ifndef NLINKS_INACCURATE_FOR_DIRS
-	assertEqualMem(e + 38, "00000002", 8); /* nlink */
+#if !defined(_WIN32) || defined(__CYGWIN__)
+	assertEqualInt(nlinks("dir"), from_hex(e + 38, 8)); /* nlinks */
 #endif
 	t2 = from_hex(e + 46, 8); /* mtime */
 	failure("First entry created at t=0x%08x this entry created at t2=0x%08x", t, t2);
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/cpio/test/test_option_c.c
--- a/head/contrib/libarchive/cpio/test/test_option_c.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/cpio/test/test_option_c.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/cpio/test/test_option_c.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/cpio/test/test_option_c.c 232153 2012-02-25 10:58:02Z mm $");
 
 static int
 is_octal(const char *p, size_t l)
@@ -51,6 +51,16 @@
 	return (r);
 }
 
+#if !defined(_WIN32) || defined(__CYGWIN__)
+static int
+nlinks(const char *p)
+{
+	struct stat st;
+	assertEqualInt(0, stat(p, &st));
+	return st.st_nlink;
+}
+#endif
+
 DEFINE_TEST(test_option_c)
 {
 	FILE *filelist;
@@ -181,17 +191,19 @@
 	/* Group members bits and others bits do not work. */
 	assertEqualMem(e + 18, "040777", 6); /* Mode */
 #else
-	/* Accept 042775 to accomodate systems where sgid bit propagates. */
+	/* Accept 042775 to accommodate systems where sgid bit propagates. */
 	if (memcmp(e + 18, "042775", 6) != 0)
 		assertEqualMem(e + 18, "040775", 6); /* Mode */
 #endif
-	assertEqualInt(from_octal(e + 24, 6), uid); /* uid */
+	assertEqualInt(uid, from_octal(e + 24, 6)); /* uid */
 	/* Gid should be same as first entry. */
 	assert(is_octal(e + 30, 6)); /* gid */
 	assertEqualInt(gid, from_octal(e + 30, 6));
-#ifndef NLINKS_INACCURATE_FOR_DIRS
-	assertEqualMem(e + 36, "000002", 6); /* Nlink */
+
+#if !defined(_WIN32) || defined(__CYGWIN__)
+	assertEqualInt(nlinks("dir"), from_octal(e + 36, 6)); /* Nlink */
 #endif
+
 	t = from_octal(e + 48, 11); /* mtime */
 	assert(t <= now); /* File wasn't created in future. */
 	assert(t >= now - 2); /* File was created w/in last 2 secs. */
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/cpio/test/test_option_t.c
--- a/head/contrib/libarchive/cpio/test/test_option_t.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/cpio/test/test_option_t.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,13 +23,19 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/cpio/test/test_option_t.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/cpio/test/test_option_t.c 232153 2012-02-25 10:58:02Z mm $");
 
+#ifdef HAVE_LOCALE_H
+#include <locale.h>
+#endif
 
 DEFINE_TEST(test_option_t)
 {
 	char *p;
 	int r;
+	time_t mtime;
+	char date[32];
+	char date2[32];
 
 	/* List reference archive, make sure the TOC is correct. */
 	extract_reference_file("test_option_t.cpio");
@@ -75,17 +81,20 @@
 	/* Since -n uses numeric UID/GID, this part should be the
 	 * same on every system. */
 	assertEqualMem(p, "-rw-r--r--   1 1000     1000            0 ",42);
-	/* Date varies depending on local timezone. */
-	if (memcmp(p + 42, "Dec 31  1969", 12) == 0) {
-		/* East of Greenwich we get Dec 31, 1969. */
-	} else {
-		/* West of Greenwich get Jan 1, 1970 */
-		assertEqualMem(p + 42, "Jan ", 4);
-		/* Some systems format "Jan 01", some "Jan  1" */
-		assert(p[46] == ' ' || p[46] == '0');
-		assertEqualMem(p + 47, "1  1970 ", 8);
-	}
-	assertEqualMem(p + 54, " file", 5);
+
+	/* Date varies depending on local timezone and locale. */
+	mtime = 1;
+#ifdef HAVE_LOCALE_H
+	setlocale(LC_ALL, "");
+#endif
+#if defined(_WIN32) && !defined(__CYGWIN__)
+	strftime(date2, sizeof(date), "%b %d  %Y", localtime(&mtime));
+	_snprintf(date, sizeof(date)-1, "%12s file", date2);
+#else
+	strftime(date2, sizeof(date), "%b %e  %Y", localtime(&mtime));
+	snprintf(date, sizeof(date)-1, "%12s file", date2);
+#endif
+	assertEqualMem(p + 42, date, strlen(date));
 	free(p);
 
 	/* But "-n" without "-t" is an error. */
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/cpio/test/test_option_u.c
--- a/head/contrib/libarchive/cpio/test/test_option_u.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/cpio/test/test_option_u.c	Fri Mar 02 16:54:40 2012 +0200
@@ -28,7 +28,7 @@
 #elif defined(HAVE_SYS_UTIME_H)
 #include <sys/utime.h>
 #endif
-__FBSDID("$FreeBSD: head/contrib/libarchive/cpio/test/test_option_u.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/cpio/test/test_option_u.c 232153 2012-02-25 10:58:02Z mm $");
 
 DEFINE_TEST(test_option_u)
 {
@@ -41,7 +41,7 @@
 	assertMakeFile("f", 0644, "a");
 
 	/* Copy the file to the "copy" dir. */
-	r = systemf("echo f | %s -pd copy >copy.out 2>copy.err",
+	r = systemf("echo f| %s -pd copy >copy.out 2>copy.err",
 	    testprog);
 	assertEqualInt(r, 0);
 
@@ -60,7 +60,7 @@
 	assertEqualInt(0, utime("f", &times));
 
 	/* Copy the file to the "copy" dir. */
-	r = systemf("echo f | %s -pd copy >copy.out 2>copy.err",
+	r = systemf("echo f| %s -pd copy >copy.out 2>copy.err",
 	    testprog);
 	assertEqualInt(r, 0);
 
@@ -70,7 +70,7 @@
 	assertEqualMem(p, "a", 1);
 
 	/* Copy the file to the "copy" dir with -u (force) */
-	r = systemf("echo f | %s -pud copy >copy.out 2>copy.err",
+	r = systemf("echo f| %s -pud copy >copy.out 2>copy.err",
 	    testprog);
 	assertEqualInt(r, 0);
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/cpio/test/test_owner_parse.c
--- a/head/contrib/libarchive/cpio/test/test_owner_parse.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/cpio/test/test_owner_parse.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,16 +23,15 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/cpio/test/test_owner_parse.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/cpio/test/test_owner_parse.c 232153 2012-02-25 10:58:02Z mm $");
 
 #include "../cpio.h"
 #include "err.h"
 
 #if !defined(_WIN32)
 #define ROOT "root"
-static int root_uids[] = { 0 };
-/* Solaris 9 root has gid 1 (other) */
-static int root_gids[] = { 0, 1 };
+static const int root_uids[] = { 0 };
+static const int root_gids[] = { 0, 1 };
 #elif defined(__CYGWIN__)
 /* On cygwin, the Administrator user most likely exists (unless
  * it has been renamed or is in a non-English localization), but
@@ -43,13 +42,13 @@
  *       Use CreateWellKnownSID() and LookupAccountName()?
  */
 #define ROOT "Administrator"
-static int root_uids[] = { 500 };
-static int root_gids[] = { 513, 545, 544 };
+static const int root_uids[] = { 500 };
+static const int root_gids[] = { 513, 545, 544 };
 #endif
 
 #if defined(ROOT)
 static int
-int_in_list(int i, int *l, size_t n)
+int_in_list(int i, const int *l, size_t n)
 {
 	while (n-- > 0)
 		if (*l++ == i)
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive.h
--- a/head/contrib/libarchive/libarchive/archive.h	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive.h	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2003-2010 Tim Kientzle
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -22,12 +22,16 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: head/contrib/libarchive/libarchive/archive.h 228773 2011-12-21 15:18:52Z mm $
+ * $FreeBSD: head/contrib/libarchive/libarchive/archive.h 232153 2012-02-25 10:58:02Z mm $
  */
 
 #ifndef ARCHIVE_H_INCLUDED
 #define	ARCHIVE_H_INCLUDED
 
+#include <sys/stat.h>
+#include <stddef.h>  /* for wchar_t */
+#include <stdio.h> /* For FILE * */
+
 /*
  * Note: archive.h is for use outside of libarchive; the configuration
  * headers (config.h, archive_platform.h, etc.) are purely internal.
@@ -36,22 +40,15 @@
  * platform macros.
  */
 #if defined(__BORLANDC__) && __BORLANDC__ >= 0x560
-# define __LA_STDINT_H <stdint.h>
-#elif !defined(__WATCOMC__) && !defined(_MSC_VER) && !defined(__INTERIX) && !defined(__BORLANDC__)
-# define __LA_STDINT_H <inttypes.h>
+# include <stdint.h>
+#elif !defined(__WATCOMC__) && !defined(_MSC_VER) && !defined(__INTERIX) && !defined(__BORLANDC__) && !defined(_SCO_DS)
+# include <inttypes.h>
 #endif
 
-#include <sys/stat.h>
-#include <sys/types.h>  /* Linux requires this for off_t */
-#ifdef __LA_STDINT_H
-# include __LA_STDINT_H /* int64_t, etc. */
-#endif
-#include <stdio.h> /* For FILE * */
-
 /* Get appropriate definitions of standard POSIX-style types. */
 /* These should match the types used in 'struct stat' */
 #if defined(_WIN32) && !defined(__CYGWIN__)
-#define	__LA_INT64_T	__int64
+# define	__LA_INT64_T	__int64
 # if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_)
 #  define	__LA_SSIZE_T	ssize_t
 # elif defined(_WIN64)
@@ -67,11 +64,15 @@
 #  define	__LA_GID_T	short
 # endif
 #else
-#include <unistd.h>  /* ssize_t, uid_t, and gid_t */
-#define	__LA_INT64_T	int64_t
-#define	__LA_SSIZE_T	ssize_t
-#define	__LA_UID_T	uid_t
-#define	__LA_GID_T	gid_t
+# include <unistd.h>  /* ssize_t, uid_t, and gid_t */
+# if defined(_SCO_DS)
+#  define	__LA_INT64_T	long long
+# else
+#  define	__LA_INT64_T	int64_t
+# endif
+# define	__LA_SSIZE_T	ssize_t
+# define	__LA_UID_T	uid_t
+# define	__LA_GID_T	gid_t
 #endif
 
 /*
@@ -88,7 +89,7 @@
 #  endif
 # else
 #  ifdef __GNUC__
-#   define __LA_DECL	__attribute__((dllimport)) extern
+#   define __LA_DECL
 #  else
 #   define __LA_DECL	__declspec(dllimport)
 #  endif
@@ -98,7 +99,7 @@
 # define __LA_DECL
 #endif
 
-#if defined(__GNUC__) && __GNUC__ >= 3
+#if defined(__GNUC__) && __GNUC__ >= 3 && !defined(__MINGW32__)
 #define	__LA_PRINTF(fmtarg, firstvararg) \
 	__attribute__((__format__ (__printf__, fmtarg, firstvararg)))
 #else
@@ -123,50 +124,18 @@
  * easy to compare versions at build time: for version a.b.c, the
  * version number is printf("%d%03d%03d",a,b,c).  For example, if you
  * know your application requires version 2.12.108 or later, you can
- * assert that ARCHIVE_VERSION >= 2012108.
- *
- * This single-number format was introduced with libarchive 1.9.0 in
- * the libarchive 1.x family and libarchive 2.2.4 in the libarchive
- * 2.x family.  The following may be useful if you really want to do
- * feature detection for earlier libarchive versions (which defined
- * ARCHIVE_API_VERSION and ARCHIVE_API_FEATURE instead):
- *
- * #ifndef ARCHIVE_VERSION_NUMBER
- * #define ARCHIVE_VERSION_NUMBER	\
- *             (ARCHIVE_API_VERSION * 1000000 + ARCHIVE_API_FEATURE * 1000)
- * #endif
+ * assert that ARCHIVE_VERSION_NUMBER >= 2012108.
  */
-#define	ARCHIVE_VERSION_NUMBER 2008005
+/* Note: Compiler will complain if this does not match archive_entry.h! */
+#define	ARCHIVE_VERSION_NUMBER 3000003
 __LA_DECL int		archive_version_number(void);
 
 /*
  * Textual name/version of the library, useful for version displays.
  */
-#define	ARCHIVE_VERSION_STRING "libarchive 2.8.5"
+#define	ARCHIVE_VERSION_STRING "libarchive 3.0.3"
 __LA_DECL const char *	archive_version_string(void);
 
-#if ARCHIVE_VERSION_NUMBER < 3000000
-/*
- * Deprecated; these are older names that will be removed in favor of
- * the simpler definitions above.
- */
-#define	ARCHIVE_VERSION_STAMP	ARCHIVE_VERSION_NUMBER
-__LA_DECL int		archive_version_stamp(void);
-#define	ARCHIVE_LIBRARY_VERSION	ARCHIVE_VERSION_STRING
-__LA_DECL const char *	archive_version(void);
-#define	ARCHIVE_API_VERSION	(ARCHIVE_VERSION_NUMBER / 1000000)
-__LA_DECL int		archive_api_version(void);
-#define	ARCHIVE_API_FEATURE	((ARCHIVE_VERSION_NUMBER / 1000) % 1000)
-__LA_DECL int		archive_api_feature(void);
-#endif
-
-#if ARCHIVE_VERSION_NUMBER < 3000000
-/* This should never have been here in the first place. */
-/* Legacy of old tar assumptions, will be removed in libarchive 3.0. */
-#define	ARCHIVE_BYTES_PER_RECORD	  512
-#define	ARCHIVE_DEFAULT_BYTES_PER_BLOCK	10240
-#endif
-
 /* Declare our basic types. */
 struct archive;
 struct archive_entry;
@@ -210,48 +179,56 @@
 typedef __LA_SSIZE_T	archive_read_callback(struct archive *,
 			    void *_client_data, const void **_buffer);
 
-/* Skips at most request bytes from archive and returns the skipped amount */
-#if ARCHIVE_VERSION_NUMBER < 2000000
-/* Libarchive 1.0 used ssize_t for the return, which is only 32 bits
- * on most 32-bit platforms; not large enough. */
-typedef __LA_SSIZE_T	archive_skip_callback(struct archive *,
-			    void *_client_data, size_t request);
-#elif ARCHIVE_VERSION_NUMBER < 3000000
-/* Libarchive 2.0 used off_t here, but that is a bad idea on Linux and a
- * few other platforms where off_t varies with build settings. */
-typedef off_t		archive_skip_callback(struct archive *,
-			    void *_client_data, off_t request);
-#else
-/* Libarchive 3.0 uses int64_t here, which is actually guaranteed to be
- * 64 bits on every platform. */
+/* Skips at most request bytes from archive and returns the skipped amount.
+ * This may skip fewer bytes than requested; it may even skip zero bytes.
+ * If you do skip fewer bytes than requested, libarchive will invoke your
+ * read callback and discard data as necessary to make up the full skip.
+ */
 typedef __LA_INT64_T	archive_skip_callback(struct archive *,
 			    void *_client_data, __LA_INT64_T request);
-#endif
+
+/* Seeks to specified location in the file and returns the position.
+ * Whence values are SEEK_SET, SEEK_CUR, SEEK_END from stdio.h.
+ * Return ARCHIVE_FATAL if the seek fails for any reason.
+ */
+typedef __LA_INT64_T	archive_seek_callback(struct archive *,
+    void *_client_data, __LA_INT64_T offset, int whence);
 
 /* Returns size actually written, zero on EOF, -1 on error. */
 typedef __LA_SSIZE_T	archive_write_callback(struct archive *,
 			    void *_client_data,
 			    const void *_buffer, size_t _length);
 
-#if ARCHIVE_VERSION_NUMBER < 3000000
-/* Open callback is actually never needed; remove it in libarchive 3.0. */
 typedef int	archive_open_callback(struct archive *, void *_client_data);
-#endif
 
 typedef int	archive_close_callback(struct archive *, void *_client_data);
 
 /*
- * Codes for archive_compression.
+ * Codes to identify various stream filters.
  */
-#define	ARCHIVE_COMPRESSION_NONE	0
-#define	ARCHIVE_COMPRESSION_GZIP	1
-#define	ARCHIVE_COMPRESSION_BZIP2	2
-#define	ARCHIVE_COMPRESSION_COMPRESS	3
-#define	ARCHIVE_COMPRESSION_PROGRAM	4
-#define	ARCHIVE_COMPRESSION_LZMA	5
-#define	ARCHIVE_COMPRESSION_XZ		6
-#define	ARCHIVE_COMPRESSION_UU		7
-#define	ARCHIVE_COMPRESSION_RPM		8
+#define	ARCHIVE_FILTER_NONE	0
+#define	ARCHIVE_FILTER_GZIP	1
+#define	ARCHIVE_FILTER_BZIP2	2
+#define	ARCHIVE_FILTER_COMPRESS	3
+#define	ARCHIVE_FILTER_PROGRAM	4
+#define	ARCHIVE_FILTER_LZMA	5
+#define	ARCHIVE_FILTER_XZ	6
+#define	ARCHIVE_FILTER_UU	7
+#define	ARCHIVE_FILTER_RPM	8
+#define	ARCHIVE_FILTER_LZIP	9
+
+#if ARCHIVE_VERSION_NUMBER < 4000000
+#define	ARCHIVE_COMPRESSION_NONE	ARCHIVE_FILTER_NONE
+#define	ARCHIVE_COMPRESSION_GZIP	ARCHIVE_FILTER_GZIP
+#define	ARCHIVE_COMPRESSION_BZIP2	ARCHIVE_FILTER_BZIP2
+#define	ARCHIVE_COMPRESSION_COMPRESS	ARCHIVE_FILTER_COMPRESS
+#define	ARCHIVE_COMPRESSION_PROGRAM	ARCHIVE_FILTER_PROGRAM
+#define	ARCHIVE_COMPRESSION_LZMA	ARCHIVE_FILTER_LZMA
+#define	ARCHIVE_COMPRESSION_XZ		ARCHIVE_FILTER_XZ
+#define	ARCHIVE_COMPRESSION_UU		ARCHIVE_FILTER_UU
+#define	ARCHIVE_COMPRESSION_RPM		ARCHIVE_FILTER_RPM
+#define	ARCHIVE_COMPRESSION_LZIP	ARCHIVE_FILTER_LZIP
+#endif
 
 /*
  * Codes returned by archive_format.
@@ -265,7 +242,7 @@
  * will change the format code to indicate the extended format that
  * was used).  In other cases, it's because different tools have
  * modified the archive and so different parts of the archive
- * actually have slightly different formts.  (Both tar and cpio store
+ * actually have slightly different formats.  (Both tar and cpio store
  * format codes in each entry, so it is quite possible for each
  * entry to be in a different format.)
  */
@@ -276,6 +253,7 @@
 #define	ARCHIVE_FORMAT_CPIO_BIN_BE		(ARCHIVE_FORMAT_CPIO | 3)
 #define	ARCHIVE_FORMAT_CPIO_SVR4_NOCRC		(ARCHIVE_FORMAT_CPIO | 4)
 #define	ARCHIVE_FORMAT_CPIO_SVR4_CRC		(ARCHIVE_FORMAT_CPIO | 5)
+#define	ARCHIVE_FORMAT_CPIO_AFIO_LARGE		(ARCHIVE_FORMAT_CPIO | 6)
 #define	ARCHIVE_FORMAT_SHAR			0x20000
 #define	ARCHIVE_FORMAT_SHAR_BASE		(ARCHIVE_FORMAT_SHAR | 1)
 #define	ARCHIVE_FORMAT_SHAR_DUMP		(ARCHIVE_FORMAT_SHAR | 2)
@@ -294,6 +272,10 @@
 #define	ARCHIVE_FORMAT_MTREE			0x80000
 #define	ARCHIVE_FORMAT_RAW			0x90000
 #define	ARCHIVE_FORMAT_XAR			0xA0000
+#define	ARCHIVE_FORMAT_LHA			0xB0000
+#define	ARCHIVE_FORMAT_CAB			0xC0000
+#define	ARCHIVE_FORMAT_RAR			0xD0000
+#define	ARCHIVE_FORMAT_7ZIP			0xE0000
 
 /*-
  * Basic outline for reading an archive:
@@ -316,40 +298,81 @@
  * support_compression_bzip2().  The "all" functions provide the
  * obvious shorthand.
  */
-__LA_DECL int		 archive_read_support_compression_all(struct archive *);
-__LA_DECL int		 archive_read_support_compression_bzip2(struct archive *);
-__LA_DECL int		 archive_read_support_compression_compress(struct archive *);
-__LA_DECL int		 archive_read_support_compression_gzip(struct archive *);
-__LA_DECL int		 archive_read_support_compression_lzma(struct archive *);
-__LA_DECL int		 archive_read_support_compression_none(struct archive *);
-__LA_DECL int		 archive_read_support_compression_program(struct archive *,
+
+#if ARCHIVE_VERSION_NUMBER < 4000000
+__LA_DECL int archive_read_support_compression_all(struct archive *);
+__LA_DECL int archive_read_support_compression_bzip2(struct archive *);
+__LA_DECL int archive_read_support_compression_compress(struct archive *);
+__LA_DECL int archive_read_support_compression_gzip(struct archive *);
+__LA_DECL int archive_read_support_compression_lzip(struct archive *);
+__LA_DECL int archive_read_support_compression_lzma(struct archive *);
+__LA_DECL int archive_read_support_compression_none(struct archive *);
+__LA_DECL int archive_read_support_compression_program(struct archive *,
 		     const char *command);
-__LA_DECL int		 archive_read_support_compression_program_signature
-				(struct archive *, const char *,
+__LA_DECL int archive_read_support_compression_program_signature
+		(struct archive *, const char *,
 				    const void * /* match */, size_t);
 
-__LA_DECL int		 archive_read_support_compression_rpm(struct archive *);
-__LA_DECL int		 archive_read_support_compression_uu(struct archive *);
-__LA_DECL int		 archive_read_support_compression_xz(struct archive *);
+__LA_DECL int archive_read_support_compression_rpm(struct archive *);
+__LA_DECL int archive_read_support_compression_uu(struct archive *);
+__LA_DECL int archive_read_support_compression_xz(struct archive *);
+#endif
 
-__LA_DECL int		 archive_read_support_format_all(struct archive *);
-__LA_DECL int		 archive_read_support_format_ar(struct archive *);
-__LA_DECL int		 archive_read_support_format_cpio(struct archive *);
-__LA_DECL int		 archive_read_support_format_empty(struct archive *);
-__LA_DECL int		 archive_read_support_format_gnutar(struct archive *);
-__LA_DECL int		 archive_read_support_format_iso9660(struct archive *);
-__LA_DECL int		 archive_read_support_format_mtree(struct archive *);
-__LA_DECL int		 archive_read_support_format_raw(struct archive *);
-__LA_DECL int		 archive_read_support_format_tar(struct archive *);
-__LA_DECL int		 archive_read_support_format_xar(struct archive *);
-__LA_DECL int		 archive_read_support_format_zip(struct archive *);
+__LA_DECL int archive_read_support_filter_all(struct archive *);
+__LA_DECL int archive_read_support_filter_bzip2(struct archive *);
+__LA_DECL int archive_read_support_filter_compress(struct archive *);
+__LA_DECL int archive_read_support_filter_gzip(struct archive *);
+__LA_DECL int archive_read_support_filter_lzip(struct archive *);
+__LA_DECL int archive_read_support_filter_lzma(struct archive *);
+__LA_DECL int archive_read_support_filter_none(struct archive *);
+__LA_DECL int archive_read_support_filter_program(struct archive *,
+		     const char *command);
+__LA_DECL int archive_read_support_filter_program_signature
+		(struct archive *, const char *,
+				    const void * /* match */, size_t);
 
+__LA_DECL int archive_read_support_filter_rpm(struct archive *);
+__LA_DECL int archive_read_support_filter_uu(struct archive *);
+__LA_DECL int archive_read_support_filter_xz(struct archive *);
 
-/* Open the archive using callbacks for archive I/O. */
-__LA_DECL int		 archive_read_open(struct archive *, void *_client_data,
+__LA_DECL int archive_read_support_format_7zip(struct archive *);
+__LA_DECL int archive_read_support_format_all(struct archive *);
+__LA_DECL int archive_read_support_format_ar(struct archive *);
+__LA_DECL int archive_read_support_format_by_code(struct archive *, int);
+__LA_DECL int archive_read_support_format_cab(struct archive *);
+__LA_DECL int archive_read_support_format_cpio(struct archive *);
+__LA_DECL int archive_read_support_format_empty(struct archive *);
+__LA_DECL int archive_read_support_format_gnutar(struct archive *);
+__LA_DECL int archive_read_support_format_iso9660(struct archive *);
+__LA_DECL int archive_read_support_format_lha(struct archive *);
+__LA_DECL int archive_read_support_format_mtree(struct archive *);
+__LA_DECL int archive_read_support_format_rar(struct archive *);
+__LA_DECL int archive_read_support_format_raw(struct archive *);
+__LA_DECL int archive_read_support_format_tar(struct archive *);
+__LA_DECL int archive_read_support_format_xar(struct archive *);
+__LA_DECL int archive_read_support_format_zip(struct archive *);
+
+/* Set various callbacks. */
+__LA_DECL int archive_read_set_open_callback(struct archive *,
+    archive_open_callback *);
+__LA_DECL int archive_read_set_read_callback(struct archive *,
+    archive_read_callback *);
+__LA_DECL int archive_read_set_seek_callback(struct archive *,
+    archive_seek_callback *);
+__LA_DECL int archive_read_set_skip_callback(struct archive *,
+    archive_skip_callback *);
+__LA_DECL int archive_read_set_close_callback(struct archive *,
+    archive_close_callback *);
+/* The callback data is provided to all of the callbacks above. */
+__LA_DECL int archive_read_set_callback_data(struct archive *, void *);
+/* Opening freezes the callbacks. */
+__LA_DECL int archive_read_open1(struct archive *);
+
+/* Convenience wrappers around the above. */
+__LA_DECL int archive_read_open(struct archive *, void *_client_data,
 		     archive_open_callback *, archive_read_callback *,
 		     archive_close_callback *);
-__LA_DECL int		 archive_read_open2(struct archive *, void *_client_data,
+__LA_DECL int archive_read_open2(struct archive *, void *_client_data,
 		     archive_open_callback *, archive_read_callback *,
 		     archive_skip_callback *, archive_close_callback *);
 
@@ -359,30 +382,32 @@
  * accept a block size handle tape blocking correctly.
  */
 /* Use this if you know the filename.  Note: NULL indicates stdin. */
-__LA_DECL int		 archive_read_open_filename(struct archive *,
+__LA_DECL int archive_read_open_filename(struct archive *,
 		     const char *_filename, size_t _block_size);
+__LA_DECL int archive_read_open_filename_w(struct archive *,
+		     const wchar_t *_filename, size_t _block_size);
 /* archive_read_open_file() is a deprecated synonym for ..._open_filename(). */
-__LA_DECL int		 archive_read_open_file(struct archive *,
+__LA_DECL int archive_read_open_file(struct archive *,
 		     const char *_filename, size_t _block_size);
 /* Read an archive that's stored in memory. */
-__LA_DECL int		 archive_read_open_memory(struct archive *,
+__LA_DECL int archive_read_open_memory(struct archive *,
 		     void * buff, size_t size);
 /* A more involved version that is only used for internal testing. */
-__LA_DECL int		archive_read_open_memory2(struct archive *a, void *buff,
+__LA_DECL int archive_read_open_memory2(struct archive *a, void *buff,
 		     size_t size, size_t read_size);
 /* Read an archive that's already open, using the file descriptor. */
-__LA_DECL int		 archive_read_open_fd(struct archive *, int _fd,
+__LA_DECL int archive_read_open_fd(struct archive *, int _fd,
 		     size_t _block_size);
 /* Read an archive that's already open, using a FILE *. */
 /* Note: DO NOT use this with tape drives. */
-__LA_DECL int		 archive_read_open_FILE(struct archive *, FILE *_file);
+__LA_DECL int archive_read_open_FILE(struct archive *, FILE *_file);
 
 /* Parses and returns next entry header. */
-__LA_DECL int		 archive_read_next_header(struct archive *,
+__LA_DECL int archive_read_next_header(struct archive *,
 		     struct archive_entry **);
 
 /* Parses and returns next entry header using the archive_entry passed in */
-__LA_DECL int		 archive_read_next_header2(struct archive *,
+__LA_DECL int archive_read_next_header2(struct archive *,
 		     struct archive_entry *);
 
 /*
@@ -401,14 +426,8 @@
  * the desired size of the block.  The API does guarantee that offsets will
  * be strictly increasing and that returned blocks will not overlap.
  */
-#if ARCHIVE_VERSION_NUMBER < 3000000
-__LA_DECL int		 archive_read_data_block(struct archive *a,
-			    const void **buff, size_t *size, off_t *offset);
-#else
-__LA_DECL int		 archive_read_data_block(struct archive *a,
-			    const void **buff, size_t *size,
-			    __LA_INT64_T *offset);
-#endif
+__LA_DECL int archive_read_data_block(struct archive *a,
+		    const void **buff, size_t *size, __LA_INT64_T *offset);
 
 /*-
  * Some convenience functions that are built on archive_read_data:
@@ -416,23 +435,27 @@
  *  'into_buffer': writes data into memory buffer that you provide
  *  'into_fd': writes data to specified filedes
  */
-__LA_DECL int		 archive_read_data_skip(struct archive *);
-__LA_DECL int		 archive_read_data_into_buffer(struct archive *,
-			    void *buffer, __LA_SSIZE_T len);
-__LA_DECL int		 archive_read_data_into_fd(struct archive *, int fd);
+__LA_DECL int archive_read_data_skip(struct archive *);
+__LA_DECL int archive_read_data_into_fd(struct archive *, int fd);
 
 /*
  * Set read options.
  */
-/* Apply option string to the format only. */
-__LA_DECL int		archive_read_set_format_options(struct archive *_a,
-			    const char *s);
-/* Apply option string to the filter only. */
-__LA_DECL int		archive_read_set_filter_options(struct archive *_a,
-			    const char *s);
+/* Apply option to the format only. */
+__LA_DECL int archive_read_set_format_option(struct archive *_a,
+			    const char *m, const char *o,
+			    const char *v);
+/* Apply option to the filter only. */
+__LA_DECL int archive_read_set_filter_option(struct archive *_a,
+			    const char *m, const char *o,
+			    const char *v);
+/* Apply option to both the format and the filter. */
+__LA_DECL int archive_read_set_option(struct archive *_a,
+			    const char *m, const char *o,
+			    const char *v);
 /* Apply option string to both the format and the filter. */
-__LA_DECL int		archive_read_set_options(struct archive *_a,
-			    const char *s);
+__LA_DECL int archive_read_set_options(struct archive *_a,
+			    const char *opts);
 
 /*-
  * Convenience function to recreate the current entry (whose header
@@ -477,10 +500,13 @@
 #define	ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER	(0x0800)
 /* Detect blocks of 0 and write holes instead. */
 #define	ARCHIVE_EXTRACT_SPARSE			(0x1000)
+/* Default: Do not restore Mac extended metadata. */
+/* This has no effect except on Mac OS. */
+#define	ARCHIVE_EXTRACT_MAC_METADATA		(0x2000)
 
-__LA_DECL int	 archive_read_extract(struct archive *, struct archive_entry *,
+__LA_DECL int archive_read_extract(struct archive *, struct archive_entry *,
 		     int flags);
-__LA_DECL int	 archive_read_extract2(struct archive *, struct archive_entry *,
+__LA_DECL int archive_read_extract2(struct archive *, struct archive_entry *,
 		     struct archive * /* dest */);
 __LA_DECL void	 archive_read_extract_set_progress_callback(struct archive *,
 		     void (*_progress_func)(void *), void *_user_data);
@@ -488,7 +514,7 @@
 /* Record the dev/ino of a file that will not be written.  This is
  * generally set to the dev/ino of the archive being read. */
 __LA_DECL void		archive_read_extract_set_skip_file(struct archive *,
-		     dev_t, ino_t);
+		     __LA_INT64_T, __LA_INT64_T);
 
 /* Close the file and release most resources. */
 __LA_DECL int		 archive_read_close(struct archive *);
@@ -502,7 +528,7 @@
 
 /*-
  * To create an archive:
- *   1) Ask archive_write_new for a archive writer object.
+ *   1) Ask archive_write_new for an archive writer object.
  *   2) Set any global properties.  In particular, you should set
  *      the compression and format to use.
  *   3) Call archive_write_open to open the file (most people
@@ -516,85 +542,93 @@
  *   6) archive_write_free to cleanup the writer and release resources
  */
 __LA_DECL struct archive	*archive_write_new(void);
-__LA_DECL int		 archive_write_set_bytes_per_block(struct archive *,
+__LA_DECL int archive_write_set_bytes_per_block(struct archive *,
 		     int bytes_per_block);
-__LA_DECL int		 archive_write_get_bytes_per_block(struct archive *);
+__LA_DECL int archive_write_get_bytes_per_block(struct archive *);
 /* XXX This is badly misnamed; suggestions appreciated. XXX */
-__LA_DECL int		 archive_write_set_bytes_in_last_block(struct archive *,
+__LA_DECL int archive_write_set_bytes_in_last_block(struct archive *,
 		     int bytes_in_last_block);
-__LA_DECL int		 archive_write_get_bytes_in_last_block(struct archive *);
+__LA_DECL int archive_write_get_bytes_in_last_block(struct archive *);
 
 /* The dev/ino of a file that won't be archived.  This is used
  * to avoid recursively adding an archive to itself. */
-__LA_DECL int		 archive_write_set_skip_file(struct archive *, dev_t, ino_t);
+__LA_DECL int archive_write_set_skip_file(struct archive *,
+    __LA_INT64_T, __LA_INT64_T);
 
-__LA_DECL int		 archive_write_set_compression_bzip2(struct archive *);
-__LA_DECL int		 archive_write_set_compression_compress(struct archive *);
-__LA_DECL int		 archive_write_set_compression_gzip(struct archive *);
-__LA_DECL int		 archive_write_set_compression_lzma(struct archive *);
-__LA_DECL int		 archive_write_set_compression_none(struct archive *);
-__LA_DECL int		 archive_write_set_compression_program(struct archive *,
+#if ARCHIVE_VERSION_NUMBER < 4000000
+__LA_DECL int archive_write_set_compression_bzip2(struct archive *);
+__LA_DECL int archive_write_set_compression_compress(struct archive *);
+__LA_DECL int archive_write_set_compression_gzip(struct archive *);
+__LA_DECL int archive_write_set_compression_lzip(struct archive *);
+__LA_DECL int archive_write_set_compression_lzma(struct archive *);
+__LA_DECL int archive_write_set_compression_none(struct archive *);
+__LA_DECL int archive_write_set_compression_program(struct archive *,
 		     const char *cmd);
-__LA_DECL int		 archive_write_set_compression_xz(struct archive *);
+__LA_DECL int archive_write_set_compression_xz(struct archive *);
+#endif
+
+__LA_DECL int archive_write_add_filter_bzip2(struct archive *);
+__LA_DECL int archive_write_add_filter_compress(struct archive *);
+__LA_DECL int archive_write_add_filter_gzip(struct archive *);
+__LA_DECL int archive_write_add_filter_lzip(struct archive *);
+__LA_DECL int archive_write_add_filter_lzma(struct archive *);
+__LA_DECL int archive_write_add_filter_none(struct archive *);
+__LA_DECL int archive_write_add_filter_program(struct archive *,
+		     const char *cmd);
+__LA_DECL int archive_write_add_filter_xz(struct archive *);
+
+
 /* A convenience function to set the format based on the code or name. */
-__LA_DECL int		 archive_write_set_format(struct archive *, int format_code);
-__LA_DECL int		 archive_write_set_format_by_name(struct archive *,
+__LA_DECL int archive_write_set_format(struct archive *, int format_code);
+__LA_DECL int archive_write_set_format_by_name(struct archive *,
 		     const char *name);
 /* To minimize link pollution, use one or more of the following. */
-__LA_DECL int		 archive_write_set_format_ar_bsd(struct archive *);
-__LA_DECL int		 archive_write_set_format_ar_svr4(struct archive *);
-__LA_DECL int		 archive_write_set_format_cpio(struct archive *);
-__LA_DECL int		 archive_write_set_format_cpio_newc(struct archive *);
-__LA_DECL int		 archive_write_set_format_mtree(struct archive *);
+__LA_DECL int archive_write_set_format_7zip(struct archive *);
+__LA_DECL int archive_write_set_format_ar_bsd(struct archive *);
+__LA_DECL int archive_write_set_format_ar_svr4(struct archive *);
+__LA_DECL int archive_write_set_format_cpio(struct archive *);
+__LA_DECL int archive_write_set_format_cpio_newc(struct archive *);
+__LA_DECL int archive_write_set_format_gnutar(struct archive *);
+__LA_DECL int archive_write_set_format_iso9660(struct archive *);
+__LA_DECL int archive_write_set_format_mtree(struct archive *);
 /* TODO: int archive_write_set_format_old_tar(struct archive *); */
-__LA_DECL int		 archive_write_set_format_pax(struct archive *);
-__LA_DECL int		 archive_write_set_format_pax_restricted(struct archive *);
-__LA_DECL int		 archive_write_set_format_shar(struct archive *);
-__LA_DECL int		 archive_write_set_format_shar_dump(struct archive *);
-__LA_DECL int		 archive_write_set_format_ustar(struct archive *);
-__LA_DECL int		 archive_write_set_format_zip(struct archive *);
-__LA_DECL int		 archive_write_open(struct archive *, void *,
+__LA_DECL int archive_write_set_format_pax(struct archive *);
+__LA_DECL int archive_write_set_format_pax_restricted(struct archive *);
+__LA_DECL int archive_write_set_format_shar(struct archive *);
+__LA_DECL int archive_write_set_format_shar_dump(struct archive *);
+__LA_DECL int archive_write_set_format_ustar(struct archive *);
+__LA_DECL int archive_write_set_format_xar(struct archive *);
+__LA_DECL int archive_write_set_format_zip(struct archive *);
+__LA_DECL int archive_write_open(struct archive *, void *,
 		     archive_open_callback *, archive_write_callback *,
 		     archive_close_callback *);
-__LA_DECL int		 archive_write_open_fd(struct archive *, int _fd);
-__LA_DECL int		 archive_write_open_filename(struct archive *, const char *_file);
+__LA_DECL int archive_write_open_fd(struct archive *, int _fd);
+__LA_DECL int archive_write_open_filename(struct archive *, const char *_file);
+__LA_DECL int archive_write_open_filename_w(struct archive *,
+		     const wchar_t *_file);
 /* A deprecated synonym for archive_write_open_filename() */
-__LA_DECL int		 archive_write_open_file(struct archive *, const char *_file);
-__LA_DECL int		 archive_write_open_FILE(struct archive *, FILE *);
+__LA_DECL int archive_write_open_file(struct archive *, const char *_file);
+__LA_DECL int archive_write_open_FILE(struct archive *, FILE *);
 /* _buffSize is the size of the buffer, _used refers to a variable that
  * will be updated after each write into the buffer. */
-__LA_DECL int		 archive_write_open_memory(struct archive *,
+__LA_DECL int archive_write_open_memory(struct archive *,
 			void *_buffer, size_t _buffSize, size_t *_used);
 
 /*
  * Note that the library will truncate writes beyond the size provided
  * to archive_write_header or pad if the provided data is short.
  */
-__LA_DECL int		 archive_write_header(struct archive *,
+__LA_DECL int archive_write_header(struct archive *,
 		     struct archive_entry *);
-#if ARCHIVE_VERSION_NUMBER < 2000000
-/* This was erroneously declared to return "int" in libarchive 1.x. */
-__LA_DECL int		 archive_write_data(struct archive *,
+__LA_DECL __LA_SSIZE_T	archive_write_data(struct archive *,
 			    const void *, size_t);
-#else
-/* Libarchive 2.0 and later return ssize_t here. */
-__LA_DECL __LA_SSIZE_T	 archive_write_data(struct archive *,
-			    const void *, size_t);
-#endif
 
-#if ARCHIVE_VERSION_NUMBER < 3000000
-/* Libarchive 1.x and 2.x use off_t for the argument, but that's not
- * stable on Linux. */
-__LA_DECL __LA_SSIZE_T	 archive_write_data_block(struct archive *,
-				    const void *, size_t, off_t);
-#else
-/* Libarchive 3.0 uses explicit int64_t to ensure consistent 64-bit support. */
+/* This interface is currently only available for archive_write_disk handles.  */
 __LA_DECL __LA_SSIZE_T	 archive_write_data_block(struct archive *,
 				    const void *, size_t, __LA_INT64_T);
-#endif
+
 __LA_DECL int		 archive_write_finish_entry(struct archive *);
 __LA_DECL int		 archive_write_close(struct archive *);
-
 /* This can fail if the archive wasn't already closed, in which case
  * archive_write_free() will implicitly call archive_write_close(). */
 __LA_DECL int		 archive_write_free(struct archive *);
@@ -606,16 +640,21 @@
 /*
  * Set write options.
  */
-/* Apply option string to the format only. */
-__LA_DECL int		archive_write_set_format_options(struct archive *_a,
-			    const char *s);
-/* Apply option string to the compressor only. */
-__LA_DECL int		archive_write_set_compressor_options(struct archive *_a,
-			    const char *s);
-/* Apply option string to both the format and the compressor. */
-__LA_DECL int		archive_write_set_options(struct archive *_a,
-			    const char *s);
-
+/* Apply option to the format only. */
+__LA_DECL int archive_write_set_format_option(struct archive *_a,
+			    const char *m, const char *o,
+			    const char *v);
+/* Apply option to the filter only. */
+__LA_DECL int archive_write_set_filter_option(struct archive *_a,
+			    const char *m, const char *o,
+			    const char *v);
+/* Apply option to both the format and the filter. */
+__LA_DECL int archive_write_set_option(struct archive *_a,
+			    const char *m, const char *o,
+			    const char *v);
+/* Apply option string to both the format and the filter. */
+__LA_DECL int archive_write_set_options(struct archive *_a,
+			    const char *opts);
 
 /*-
  * ARCHIVE_WRITE_DISK API
@@ -635,8 +674,8 @@
  */
 __LA_DECL struct archive	*archive_write_disk_new(void);
 /* This file will not be overwritten. */
-__LA_DECL int		 archive_write_disk_set_skip_file(struct archive *,
-		     dev_t, ino_t);
+__LA_DECL int archive_write_disk_set_skip_file(struct archive *,
+    __LA_INT64_T, __LA_INT64_T);
 /* Set flags to control how the next item gets created.
  * This accepts a bitmask of ARCHIVE_EXTRACT_XXX flags defined above. */
 __LA_DECL int		 archive_write_disk_set_options(struct archive *,
@@ -664,14 +703,16 @@
  * your needs, you can write your own and register them.  Be sure to
  * include a cleanup function if you have allocated private data.
  */
-__LA_DECL int	 archive_write_disk_set_group_lookup(struct archive *,
-			    void * /* private_data */,
-			    __LA_GID_T (*)(void *, const char *, __LA_GID_T),
-			    void (* /* cleanup */)(void *));
-__LA_DECL int	 archive_write_disk_set_user_lookup(struct archive *,
-			    void * /* private_data */,
-			    __LA_UID_T (*)(void *, const char *, __LA_UID_T),
-			    void (* /* cleanup */)(void *));
+__LA_DECL int archive_write_disk_set_group_lookup(struct archive *,
+    void * /* private_data */,
+    __LA_INT64_T (*)(void *, const char *, __LA_INT64_T),
+    void (* /* cleanup */)(void *));
+__LA_DECL int archive_write_disk_set_user_lookup(struct archive *,
+    void * /* private_data */,
+    __LA_INT64_T (*)(void *, const char *, __LA_INT64_T),
+    void (* /* cleanup */)(void *));
+__LA_DECL __LA_INT64_T archive_write_disk_gid(struct archive *, const char *, __LA_INT64_T);
+__LA_DECL __LA_INT64_T archive_write_disk_uid(struct archive *, const char *, __LA_INT64_T);
 
 /*
  * ARCHIVE_READ_DISK API
@@ -692,32 +733,64 @@
     struct archive_entry *, int /* fd */, const struct stat *);
 /* Look up gname for gid or uname for uid. */
 /* Default implementations are very, very stupid. */
-__LA_DECL const char *archive_read_disk_gname(struct archive *, __LA_GID_T);
-__LA_DECL const char *archive_read_disk_uname(struct archive *, __LA_UID_T);
+__LA_DECL const char *archive_read_disk_gname(struct archive *, __LA_INT64_T);
+__LA_DECL const char *archive_read_disk_uname(struct archive *, __LA_INT64_T);
 /* "Standard" implementation uses getpwuid_r, getgrgid_r and caches the
  * results for performance. */
 __LA_DECL int	archive_read_disk_set_standard_lookup(struct archive *);
 /* You can install your own lookups if you like. */
 __LA_DECL int	archive_read_disk_set_gname_lookup(struct archive *,
     void * /* private_data */,
-    const char *(* /* lookup_fn */)(void *, __LA_GID_T),
+    const char *(* /* lookup_fn */)(void *, __LA_INT64_T),
     void (* /* cleanup_fn */)(void *));
 __LA_DECL int	archive_read_disk_set_uname_lookup(struct archive *,
     void * /* private_data */,
-    const char *(* /* lookup_fn */)(void *, __LA_UID_T),
+    const char *(* /* lookup_fn */)(void *, __LA_INT64_T),
     void (* /* cleanup_fn */)(void *));
+/* Start traversal. */
+__LA_DECL int	archive_read_disk_open(struct archive *, const char *);
+__LA_DECL int	archive_read_disk_open_w(struct archive *, const wchar_t *);
+/*
+ * Request that current entry be visited.  If you invoke it on every
+ * directory, you'll get a physical traversal.  This is ignored if the
+ * current entry isn't a directory or a link to a directory.  So, if
+ * you invoke this on every returned path, you'll get a full logical
+ * traversal.
+ */
+__LA_DECL int	archive_read_disk_descend(struct archive *);
+__LA_DECL int	archive_read_disk_current_filesystem(struct archive *);
+__LA_DECL int	archive_read_disk_current_filesystem_is_synthetic(struct archive *);
+__LA_DECL int	archive_read_disk_current_filesystem_is_remote(struct archive *);
+/* Request that the access time of the entry visited by travesal be restored. */
+__LA_DECL int  archive_read_disk_set_atime_restored(struct archive *);
 
 /*
  * Accessor functions to read/set various information in
  * the struct archive object:
  */
-/* Bytes written after compression or read before decompression. */
+
+/* Number of filters in the current filter pipeline. */
+/* Filter #0 is the one closest to the format, -1 is a synonym for the
+ * last filter, which is always the pseudo-filter that wraps the
+ * client callbacks. */
+__LA_DECL int		 archive_filter_count(struct archive *);
+__LA_DECL __LA_INT64_T	 archive_filter_bytes(struct archive *, int);
+__LA_DECL int		 archive_filter_code(struct archive *, int);
+__LA_DECL const char *	 archive_filter_name(struct archive *, int);
+
+#if ARCHIVE_VERSION_NUMBER < 4000000
+/* These don't properly handle multiple filters, so are deprecated and
+ * will eventually be removed. */
+/* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, -1); */
 __LA_DECL __LA_INT64_T	 archive_position_compressed(struct archive *);
-/* Bytes written to compressor or read from decompressor. */
+/* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, 0); */
 __LA_DECL __LA_INT64_T	 archive_position_uncompressed(struct archive *);
+/* As of libarchive 3.0, this is an alias for archive_filter_name(a, 0); */
+__LA_DECL const char	*archive_compression_name(struct archive *);
+/* As of libarchive 3.0, this is an alias for archive_filter_code(a, 0); */
+__LA_DECL int		 archive_compression(struct archive *);
+#endif
 
-__LA_DECL const char	*archive_compression_name(struct archive *);
-__LA_DECL int		 archive_compression(struct archive *);
 __LA_DECL int		 archive_errno(struct archive *);
 __LA_DECL const char	*archive_error_string(struct archive *);
 __LA_DECL const char	*archive_format_name(struct archive *);
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_check_magic.c
--- a/head/contrib/libarchive/libarchive/archive_check_magic.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_check_magic.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2003-2010 Tim Kientzle
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -24,7 +24,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_check_magic.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_check_magic.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
@@ -86,49 +86,89 @@
 	}
 }
 
+static const char *
+archive_handle_type_name(unsigned m)
+{
+	switch (m) {
+	case ARCHIVE_WRITE_MAGIC:	return ("archive_write");
+	case ARCHIVE_READ_MAGIC:	return ("archive_read");
+	case ARCHIVE_WRITE_DISK_MAGIC:	return ("archive_write_disk");
+	case ARCHIVE_READ_DISK_MAGIC:	return ("archive_read_disk");
+	default:			return NULL;
+	}
+}
 
-static void
-write_all_states(unsigned int states)
+
+static char *
+write_all_states(char *buff, unsigned int states)
 {
 	unsigned int lowbit;
 
+	buff[0] = '\0';
+
 	/* A trick for computing the lowest set bit. */
 	while ((lowbit = states & (1 + ~states)) != 0) {
 		states &= ~lowbit;		/* Clear the low bit. */
-		errmsg(state_name(lowbit));
+		strcat(buff, state_name(lowbit));
 		if (states != 0)
-			errmsg("/");
+			strcat(buff, "/");
 	}
+	return buff;
 }
 
 /*
- * Check magic value and current state; bail if it isn't valid.
+ * Check magic value and current state.
+ *   Magic value mismatches are fatal and result in calls to abort().
+ *   State mismatches return ARCHIVE_FATAL.
+ *   Otherwise, returns ARCHIVE_OK.
  *
  * This is designed to catch serious programming errors that violate
  * the libarchive API.
  */
-void
+int
 __archive_check_magic(struct archive *a, unsigned int magic,
     unsigned int state, const char *function)
 {
-	if (a->magic != magic) {
-		errmsg("INTERNAL ERROR: Function ");
+	char states1[64];
+	char states2[64];
+	const char *handle_type;
+
+	/*
+	 * If this isn't some form of archive handle,
+	 * then the library user has screwed up so bad that
+	 * we don't even have a reliable way to report an error.
+	 */
+	handle_type = archive_handle_type_name(a->magic);
+
+	if (!handle_type) {
+		errmsg("PROGRAMMER ERROR: Function ");
 		errmsg(function);
-		errmsg(" invoked with invalid struct archive structure.\n");
+		errmsg(" invoked with invalid archive handle.\n");
 		diediedie();
 	}
 
-	if (state == ARCHIVE_STATE_ANY)
-		return;
+	if (a->magic != magic) {
+		archive_set_error(a, -1,
+		    "PROGRAMMER ERROR: Function '%s' invoked"
+		    " on '%s' archive object, which is not supported.",
+		    function,
+		    handle_type);
+		a->state = ARCHIVE_STATE_FATAL;
+		return (ARCHIVE_FATAL);
+	}
 
 	if ((a->state & state) == 0) {
-		errmsg("INTERNAL ERROR: Function '");
-		errmsg(function);
-		errmsg("' invoked with archive structure in state '");
-		write_all_states(a->state);
-		errmsg("', should be in state '");
-		write_all_states(state);
-		errmsg("'\n");
-		diediedie();
+		/* If we're already FATAL, don't overwrite the error. */
+		if (a->state != ARCHIVE_STATE_FATAL)
+			archive_set_error(a, -1,
+			    "INTERNAL ERROR: Function '%s' invoked with"
+			    " archive structure in state '%s',"
+			    " should be in state '%s'",
+			    function,
+			    write_all_states(states1, a->state),
+			    write_all_states(states2, state));
+		a->state = ARCHIVE_STATE_FATAL;
+		return (ARCHIVE_FATAL);
 	}
+	return ARCHIVE_OK;
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_crc32.h
--- a/head/contrib/libarchive/libarchive/archive_crc32.h	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_crc32.h	Fri Mar 02 16:54:40 2012 +0200
@@ -22,7 +22,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: head/contrib/libarchive/libarchive/archive_crc32.h 228763 2011-12-21 11:13:29Z mm $
+ * $FreeBSD: head/contrib/libarchive/libarchive/archive_crc32.h 232153 2012-02-25 10:58:02Z mm $
  */
 
 #ifndef __LIBARCHIVE_BUILD
@@ -60,6 +60,18 @@
 	}
 
 	crc = crc ^ 0xffffffffUL;
+	/* A use of this loop is about 20% - 30% faster than
+	 * no use version in any optimization option of gcc.  */
+	for (;len >= 8; len -= 8) {
+		crc = crc_tbl[(crc ^ *p++) & 0xff] ^ (crc >> 8);
+		crc = crc_tbl[(crc ^ *p++) & 0xff] ^ (crc >> 8);
+		crc = crc_tbl[(crc ^ *p++) & 0xff] ^ (crc >> 8);
+		crc = crc_tbl[(crc ^ *p++) & 0xff] ^ (crc >> 8);
+		crc = crc_tbl[(crc ^ *p++) & 0xff] ^ (crc >> 8);
+		crc = crc_tbl[(crc ^ *p++) & 0xff] ^ (crc >> 8);
+		crc = crc_tbl[(crc ^ *p++) & 0xff] ^ (crc >> 8);
+		crc = crc_tbl[(crc ^ *p++) & 0xff] ^ (crc >> 8);
+	}
 	while (len--)
 		crc = crc_tbl[(crc ^ *p++) & 0xff] ^ (crc >> 8);
 	return (crc ^ 0xffffffffUL);
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_entry.3
--- a/head/contrib/libarchive/libarchive/archive_entry.3	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_entry.3	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,5 @@
 .\" Copyright (c) 2003-2007 Tim Kientzle
+.\" Copyright (c) 2010 Joerg Sonnenberger
 .\" All rights reserved.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
@@ -22,269 +23,27 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $FreeBSD: head/contrib/libarchive/libarchive/archive_entry.3 228773 2011-12-21 15:18:52Z mm $
+.\" $FreeBSD: head/contrib/libarchive/libarchive/archive_entry.3 232153 2012-02-25 10:58:02Z mm $
 .\"
-.Dd May 12, 2008
+.Dd Feburary 22, 2010
 .Dt ARCHIVE_ENTRY 3
 .Os
 .Sh NAME
-.Nm archive_entry_acl_add_entry ,
-.Nm archive_entry_acl_add_entry_w ,
-.Nm archive_entry_acl_clear ,
-.Nm archive_entry_acl_count ,
-.Nm archive_entry_acl_next ,
-.Nm archive_entry_acl_next_w ,
-.Nm archive_entry_acl_reset ,
-.Nm archive_entry_acl_text_w ,
-.Nm archive_entry_atime ,
-.Nm archive_entry_atime_nsec ,
 .Nm archive_entry_clear ,
 .Nm archive_entry_clone ,
-.Nm archive_entry_copy_fflags_text ,
-.Nm archive_entry_copy_fflags_text_w ,
-.Nm archive_entry_copy_gname ,
-.Nm archive_entry_copy_gname_w ,
-.Nm archive_entry_copy_hardlink ,
-.Nm archive_entry_copy_hardlink_w ,
-.Nm archive_entry_copy_link ,
-.Nm archive_entry_copy_link_w ,
-.Nm archive_entry_copy_pathname_w ,
-.Nm archive_entry_copy_sourcepath ,
-.Nm archive_entry_copy_stat ,
-.Nm archive_entry_copy_symlink ,
-.Nm archive_entry_copy_symlink_w ,
-.Nm archive_entry_copy_uname ,
-.Nm archive_entry_copy_uname_w ,
-.Nm archive_entry_dev ,
-.Nm archive_entry_devmajor ,
-.Nm archive_entry_devminor ,
-.Nm archive_entry_filetype ,
-.Nm archive_entry_fflags ,
-.Nm archive_entry_fflags_text ,
 .Nm archive_entry_free ,
-.Nm archive_entry_gid ,
-.Nm archive_entry_gname ,
-.Nm archive_entry_hardlink ,
-.Nm archive_entry_ino ,
-.Nm archive_entry_mode ,
-.Nm archive_entry_mtime ,
-.Nm archive_entry_mtime_nsec ,
-.Nm archive_entry_nlink ,
 .Nm archive_entry_new ,
-.Nm archive_entry_pathname ,
-.Nm archive_entry_pathname_w ,
-.Nm archive_entry_rdev ,
-.Nm archive_entry_rdevmajor ,
-.Nm archive_entry_rdevminor ,
-.Nm archive_entry_set_atime ,
-.Nm archive_entry_set_ctime ,
-.Nm archive_entry_set_dev ,
-.Nm archive_entry_set_devmajor ,
-.Nm archive_entry_set_devminor ,
-.Nm archive_entry_set_filetype ,
-.Nm archive_entry_set_fflags ,
-.Nm archive_entry_set_gid ,
-.Nm archive_entry_set_gname ,
-.Nm archive_entry_set_hardlink ,
-.Nm archive_entry_set_link ,
-.Nm archive_entry_set_mode ,
-.Nm archive_entry_set_mtime ,
-.Nm archive_entry_set_pathname ,
-.Nm archive_entry_set_rdevmajor ,
-.Nm archive_entry_set_rdevminor ,
-.Nm archive_entry_set_size ,
-.Nm archive_entry_set_symlink ,
-.Nm archive_entry_set_uid ,
-.Nm archive_entry_set_uname ,
-.Nm archive_entry_size ,
-.Nm archive_entry_sourcepath ,
-.Nm archive_entry_stat ,
-.Nm archive_entry_symlink ,
-.Nm archive_entry_uid ,
-.Nm archive_entry_uname
-.Nd functions for manipulating archive entry descriptions
+.Nd functions for managing archive entry descriptions
 .Sh SYNOPSIS
 .In archive_entry.h
-.Ft void
-.Fo archive_entry_acl_add_entry
-.Fa "struct archive_entry *"
-.Fa "int type"
-.Fa "int permset"
-.Fa "int tag"
-.Fa "int qual"
-.Fa "const char *name"
-.Fc
-.Ft void
-.Fo archive_entry_acl_add_entry_w
-.Fa "struct archive_entry *"
-.Fa "int type"
-.Fa "int permset"
-.Fa "int tag"
-.Fa "int qual"
-.Fa "const wchar_t *name"
-.Fc
-.Ft void
-.Fn archive_entry_acl_clear "struct archive_entry *"
-.Ft int
-.Fn archive_entry_acl_count "struct archive_entry *" "int type"
-.Ft int
-.Fo archive_entry_acl_next
-.Fa "struct archive_entry *"
-.Fa "int want_type"
-.Fa "int *type"
-.Fa "int *permset"
-.Fa "int *tag"
-.Fa "int *qual"
-.Fa "const char **name"
-.Fc
-.Ft int
-.Fo archive_entry_acl_next_w
-.Fa "struct archive_entry *"
-.Fa "int want_type"
-.Fa "int *type"
-.Fa "int *permset"
-.Fa "int *tag"
-.Fa "int *qual"
-.Fa "const wchar_t **name"
-.Fc
-.Ft int
-.Fn archive_entry_acl_reset "struct archive_entry *" "int want_type"
-.Ft const wchar_t *
-.Fn archive_entry_acl_text_w "struct archive_entry *" "int flags"
-.Ft time_t
-.Fn archive_entry_atime "struct archive_entry *"
-.Ft long
-.Fn archive_entry_atime_nsec "struct archive_entry *"
 .Ft "struct archive_entry *"
 .Fn archive_entry_clear "struct archive_entry *"
 .Ft struct archive_entry *
 .Fn archive_entry_clone "struct archive_entry *"
-.Ft const char * *
-.Fn archive_entry_copy_fflags_text_w "struct archive_entry *" "const char *"
-.Ft const wchar_t *
-.Fn archive_entry_copy_fflags_text_w "struct archive_entry *" "const wchar_t *"
-.Ft void
-.Fn archive_entry_copy_gname "struct archive_entry *" "const char *"
-.Ft void
-.Fn archive_entry_copy_gname_w "struct archive_entry *" "const wchar_t *"
-.Ft void
-.Fn archive_entry_copy_hardlink "struct archive_entry *" "const char *"
-.Ft void
-.Fn archive_entry_copy_hardlink_w "struct archive_entry *" "const wchar_t *"
-.Ft void
-.Fn archive_entry_copy_sourcepath "struct archive_entry *" "const char *"
-.Ft void
-.Fn archive_entry_copy_pathname_w "struct archive_entry *" "const wchar_t *"
-.Ft void
-.Fn archive_entry_copy_stat "struct archive_entry *" "const struct stat *"
-.Ft void
-.Fn archive_entry_copy_symlink "struct archive_entry *" "const char *"
-.Ft void
-.Fn archive_entry_copy_symlink_w "struct archive_entry *" "const wchar_t *"
-.Ft void
-.Fn archive_entry_copy_uname "struct archive_entry *" "const char *"
-.Ft void
-.Fn archive_entry_copy_uname_w "struct archive_entry *" "const wchar_t *"
-.Ft dev_t
-.Fn archive_entry_dev "struct archive_entry *"
-.Ft dev_t
-.Fn archive_entry_devmajor "struct archive_entry *"
-.Ft dev_t
-.Fn archive_entry_devminor "struct archive_entry *"
-.Ft mode_t
-.Fn archive_entry_filetype "struct archive_entry *"
-.Ft void
-.Fo archive_entry_fflags
-.Fa "struct archive_entry *"
-.Fa "unsigned long *set"
-.Fa "unsigned long *clear"
-.Fc
-.Ft const char *
-.Fn archive_entry_fflags_text "struct archive_entry *"
 .Ft void
 .Fn archive_entry_free "struct archive_entry *"
-.Ft const char *
-.Fn archive_entry_gname "struct archive_entry *"
-.Ft const char *
-.Fn archive_entry_hardlink "struct archive_entry *"
-.Ft ino_t
-.Fn archive_entry_ino "struct archive_entry *"
-.Ft mode_t
-.Fn archive_entry_mode "struct archive_entry *"
-.Ft time_t
-.Fn archive_entry_mtime "struct archive_entry *"
-.Ft long
-.Fn archive_entry_mtime_nsec "struct archive_entry *"
-.Ft unsigned int
-.Fn archive_entry_nlink "struct archive_entry *"
 .Ft struct archive_entry *
 .Fn archive_entry_new "void"
-.Ft const char *
-.Fn archive_entry_pathname "struct archive_entry *"
-.Ft const wchar_t *
-.Fn archive_entry_pathname_w "struct archive_entry *"
-.Ft dev_t
-.Fn archive_entry_rdev "struct archive_entry *"
-.Ft dev_t
-.Fn archive_entry_rdevmajor "struct archive_entry *"
-.Ft dev_t
-.Fn archive_entry_rdevminor "struct archive_entry *"
-.Ft void
-.Fn archive_entry_set_dev "struct archive_entry *" "dev_t"
-.Ft void
-.Fn archive_entry_set_devmajor "struct archive_entry *" "dev_t"
-.Ft void
-.Fn archive_entry_set_devminor "struct archive_entry *" "dev_t"
-.Ft void
-.Fn archive_entry_set_filetype "struct archive_entry *" "unsigned int"
-.Ft void
-.Fo archive_entry_set_fflags
-.Fa "struct archive_entry *"
-.Fa "unsigned long set"
-.Fa "unsigned long clear"
-.Fc
-.Ft void
-.Fn archive_entry_set_gid "struct archive_entry *" "gid_t"
-.Ft void
-.Fn archive_entry_set_gname "struct archive_entry *" "const char *"
-.Ft void
-.Fn archive_entry_set_hardlink "struct archive_entry *" "const char *"
-.Ft void
-.Fn archive_entry_set_ino "struct archive_entry *" "unsigned long"
-.Ft void
-.Fn archive_entry_set_link "struct archive_entry *" "const char *"
-.Ft void
-.Fn archive_entry_set_mode "struct archive_entry *" "mode_t"
-.Ft void
-.Fn archive_entry_set_mtime "struct archive_entry *" "time_t" "long nanos"
-.Ft void
-.Fn archive_entry_set_nlink "struct archive_entry *" "unsigned int"
-.Ft void
-.Fn archive_entry_set_pathname "struct archive_entry *" "const char *"
-.Ft void
-.Fn archive_entry_set_rdev "struct archive_entry *" "dev_t"
-.Ft void
-.Fn archive_entry_set_rdevmajor "struct archive_entry *" "dev_t"
-.Ft void
-.Fn archive_entry_set_rdevminor "struct archive_entry *" "dev_t"
-.Ft void
-.Fn archive_entry_set_size "struct archive_entry *" "int64_t"
-.Ft void
-.Fn archive_entry_set_symlink "struct archive_entry *" "const char *"
-.Ft void
-.Fn archive_entry_set_uid "struct archive_entry *" "uid_t"
-.Ft void
-.Fn archive_entry_set_uname "struct archive_entry *" "const char *"
-.Ft int64_t
-.Fn archive_entry_size "struct archive_entry *"
-.Ft const char *
-.Fn archive_entry_sourcepath "struct archive_entry *"
-.Ft const struct stat *
-.Fn archive_entry_stat "struct archive_entry *"
-.Ft const char *
-.Fn archive_entry_symlink "struct archive_entry *"
-.Ft const char *
-.Fn archive_entry_uname "struct archive_entry *"
 .Sh DESCRIPTION
 These functions create and manipulate data objects that
 represent entries within an archive.
@@ -320,8 +79,24 @@
 .Tn struct archive_entry
 object.
 .El
-.Ss Set and Get Functions
-Most of the functions here set or read entries in an object.
+.Ss Function groups
+Due to high number of functions, the accessor functions can be found in
+man pages grouped by the purpose.
+.Bl -tag -width ".Xr archive_entry_perms 3"
+.It Xr archive_entry_acl 3
+Access Control List manipulation
+.It Xr archive_entry_paths 3
+Path name manipulation
+.It Xr archive_entry_perms 3
+User, group and mode manipulation
+.It Xr archive_entry_stat 3
+Functions not in the other groups and copying to/from
+.Vt struct stat .
+.It Xr archive_entry_time 3
+Time field manipulation
+.El
+.Pp
+Most of the functions set or read entries in an object.
 Such functions have one of the following forms:
 .Bl -tag -compact -width indent
 .It Fn archive_entry_set_XXXX
@@ -350,75 +125,15 @@
 narrow string for the same data, the previously-set wide string will
 be discarded in favor of the new data.
 .Pp
-There are a few set/get functions that merit additional description:
-.Bl -tag -compact -width indent
-.It Fn archive_entry_set_link
-This function sets the symlink field if it is already set.
-Otherwise, it sets the hardlink field.
-.El
-.Ss File Flags
-File flags are transparently converted between a bitmap
-representation and a textual format.
-For example, if you set the bitmap and ask for text, the library
-will build a canonical text format.
-However, if you set a text format and request a text format,
-you will get back the same text, even if it is ill-formed.
-If you need to canonicalize a textual flags string, you should first set the
-text form, then request the bitmap form, then use that to set the bitmap form.
-Setting the bitmap format will clear the internal text representation
-and force it to be reconstructed when you next request the text form.
-.Pp
-The bitmap format consists of two integers, one containing bits
-that should be set, the other specifying bits that should be
-cleared.
-Bits not mentioned in either bitmap will be ignored.
-Usually, the bitmap of bits to be cleared will be set to zero.
-In unusual circumstances, you can force a fully-specified set
-of file flags by setting the bitmap of flags to clear to the complement
-of the bitmap of flags to set.
-(This differs from
-.Xr fflagstostr 3 ,
-which only includes names for set bits.)
-Converting a bitmap to a textual string is a platform-specific
-operation; bits that are not meaningful on the current platform
-will be ignored.
-.Pp
-The canonical text format is a comma-separated list of flag names.
-The
-.Fn archive_entry_copy_fflags_text
-and
-.Fn archive_entry_copy_fflags_text_w
-functions parse the provided text and sets the internal bitmap values.
-This is a platform-specific operation; names that are not meaningful
-on the current platform will be ignored.
-The function returns a pointer to the start of the first name that was not
-recognized, or NULL if every name was recognized.
-Note that every name--including names that follow an unrecognized name--will
-be evaluated, and the bitmaps will be set to reflect every name that is
-recognized.
-(In particular, this differs from
-.Xr strtofflags 3 ,
-which stops parsing at the first unrecognized name.)
-.Ss ACL Handling
-XXX This needs serious help.
-XXX
-.Pp
-An
-.Dq Access Control List
-(ACL) is a list of permissions that grant access to particular users or
-groups beyond what would normally be provided by standard POSIX mode bits.
-The ACL handling here addresses some deficiencies in the POSIX.1e draft 17 ACL
-specification.
-In particular, POSIX.1e draft 17 specifies several different formats, but
-none of those formats include both textual user/group names and numeric
-UIDs/GIDs.
-.Pp
-XXX explain ACL stuff XXX
 .\" .Sh EXAMPLE
 .\" .Sh RETURN VALUES
 .\" .Sh ERRORS
 .Sh SEE ALSO
-.Xr archive 3
+.Xr archive 3 ,
+.Xr archive_entry_acl 3 ,
+.Xr archive_entry_paths 3 ,
+.Xr archive_entry_perms 3 ,
+.Xr archive_entry_time 3
 .Sh HISTORY
 The
 .Nm libarchive
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_entry.c
--- a/head/contrib/libarchive/libarchive/archive_entry.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_entry.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_entry.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_entry.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
@@ -39,6 +39,9 @@
 #include <sys/sysmacros.h>
 #define HAVE_MAJOR
 #endif
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
 #ifdef HAVE_LIMITS_H
 #include <limits.h>
 #endif
@@ -68,13 +71,12 @@
 #endif
 
 #include "archive.h"
+#include "archive_acl_private.h"
 #include "archive_entry.h"
+#include "archive_entry_locale.h"
 #include "archive_private.h"
 #include "archive_entry_private.h"
 
-#undef max
-#define	max(a, b)	((a)>(b)?(a):(b))
-
 #if !defined(HAVE_MAJOR) && !defined(major)
 /* Replacement for major/minor/makedev. */
 #define	major(x) ((int)(0x00ff & ((x) >> 8)))
@@ -98,39 +100,26 @@
 #define ae_makedev(maj, min) makedev((maj), (min))
 #endif
 
-static void	aes_clean(struct aes *);
-static void	aes_copy(struct aes *dest, struct aes *src);
-static const char *	aes_get_mbs(struct aes *);
-static const wchar_t *	aes_get_wcs(struct aes *);
-static int	aes_set_mbs(struct aes *, const char *mbs);
-static int	aes_copy_mbs(struct aes *, const char *mbs);
-/* static void	aes_set_wcs(struct aes *, const wchar_t *wcs); */
-static int	aes_copy_wcs(struct aes *, const wchar_t *wcs);
-static int	aes_copy_wcs_len(struct aes *, const wchar_t *wcs, size_t);
+/*
+ * This adjustment is needed to support the following idiom for adding
+ * 1000ns to the stored time:
+ * archive_entry_set_atime(archive_entry_atime(),
+ *                         archive_entry_atime_nsec() + 1000)
+ * The additional if() here compensates for ambiguity in the C standard,
+ * which permits two possible interpretations of a % b when a is negative.
+ */
+#define FIX_NS(t,ns) \
+	do {	\
+		t += ns / 1000000000; \
+		ns %= 1000000000; \
+		if (ns < 0) { --t; ns += 1000000000; } \
+	} while (0)
 
 static char *	 ae_fflagstostr(unsigned long bitset, unsigned long bitclear);
 static const wchar_t	*ae_wcstofflags(const wchar_t *stringp,
 		    unsigned long *setp, unsigned long *clrp);
 static const char	*ae_strtofflags(const char *stringp,
 		    unsigned long *setp, unsigned long *clrp);
-static void	append_entry_w(wchar_t **wp, const wchar_t *prefix, int tag,
-		    const wchar_t *wname, int perm, int id);
-static void	append_id_w(wchar_t **wp, int id);
-
-static int	acl_special(struct archive_entry *entry,
-		    int type, int permset, int tag);
-static struct ae_acl *acl_new_entry(struct archive_entry *entry,
-		    int type, int permset, int tag, int id);
-static int	isint_w(const wchar_t *start, const wchar_t *end, int *result);
-static int	ismode_w(const wchar_t *start, const wchar_t *end, int *result);
-static void	next_field_w(const wchar_t **wp, const wchar_t **start,
-		    const wchar_t **end, wchar_t *sep);
-static int	prefix_w(const wchar_t *start, const wchar_t *end,
-		    const wchar_t *test);
-static void
-archive_entry_acl_add_entry_w_len(struct archive_entry *entry, int type,
-		    int permset, int tag, int id, const wchar_t *name, size_t);
-
 
 #ifndef HAVE_WCSCPY
 static wchar_t * wcscpy(wchar_t *s1, const wchar_t *s2)
@@ -154,214 +143,6 @@
 /* Good enough for simple equality testing, but not for sorting. */
 #define wmemcmp(a,b,i)  memcmp((a), (b), (i) * sizeof(wchar_t))
 #endif
-#ifndef HAVE_WMEMCPY
-#define wmemcpy(a,b,i)  (wchar_t *)memcpy((a), (b), (i) * sizeof(wchar_t))
-#endif
-
-static void
-aes_clean(struct aes *aes)
-{
-	if (aes->aes_wcs) {
-		free((wchar_t *)(uintptr_t)aes->aes_wcs);
-		aes->aes_wcs = NULL;
-	}
-	archive_string_free(&(aes->aes_mbs));
-	archive_string_free(&(aes->aes_utf8));
-	aes->aes_set = 0;
-}
-
-static void
-aes_copy(struct aes *dest, struct aes *src)
-{
-	wchar_t *wp;
-
-	dest->aes_set = src->aes_set;
-	archive_string_copy(&(dest->aes_mbs), &(src->aes_mbs));
-	archive_string_copy(&(dest->aes_utf8), &(src->aes_utf8));
-
-	if (src->aes_wcs != NULL) {
-		wp = (wchar_t *)malloc((wcslen(src->aes_wcs) + 1)
-		    * sizeof(wchar_t));
-		if (wp == NULL)
-			__archive_errx(1, "No memory for aes_copy()");
-		wcscpy(wp, src->aes_wcs);
-		dest->aes_wcs = wp;
-	}
-}
-
-static const char *
-aes_get_utf8(struct aes *aes)
-{
-	if (aes->aes_set & AES_SET_UTF8)
-		return (aes->aes_utf8.s);
-	if ((aes->aes_set & AES_SET_WCS)
-	    && archive_strappend_w_utf8(&(aes->aes_utf8), aes->aes_wcs) != NULL) {
-		aes->aes_set |= AES_SET_UTF8;
-		return (aes->aes_utf8.s);
-	}
-	return (NULL);
-}
-
-static const char *
-aes_get_mbs(struct aes *aes)
-{
-	/* If we already have an MBS form, return that immediately. */
-	if (aes->aes_set & AES_SET_MBS)
-		return (aes->aes_mbs.s);
-	/* If there's a WCS form, try converting with the native locale. */
-	if ((aes->aes_set & AES_SET_WCS)
-	    && archive_strappend_w_mbs(&(aes->aes_mbs), aes->aes_wcs) != NULL) {
-		aes->aes_set |= AES_SET_MBS;
-		return (aes->aes_mbs.s);
-	}
-	/* We'll use UTF-8 for MBS if all else fails. */
-	return (aes_get_utf8(aes));
-}
-
-static const wchar_t *
-aes_get_wcs(struct aes *aes)
-{
-	wchar_t *w;
-	size_t r;
-
-	/* Return WCS form if we already have it. */
-	if (aes->aes_set & AES_SET_WCS)
-		return (aes->aes_wcs);
-
-	if (aes->aes_set & AES_SET_MBS) {
-		/* Try converting MBS to WCS using native locale. */
-		/*
-		 * No single byte will be more than one wide character,
-		 * so this length estimate will always be big enough.
-		 */
-		size_t wcs_length = aes->aes_mbs.length;
-
-		w = (wchar_t *)malloc((wcs_length + 1) * sizeof(wchar_t));
-		if (w == NULL)
-			__archive_errx(1, "No memory for aes_get_wcs()");
-		r = mbstowcs(w, aes->aes_mbs.s, wcs_length);
-		if (r != (size_t)-1 && r != 0) {
-			w[r] = 0;
-			aes->aes_set |= AES_SET_WCS;
-			return (aes->aes_wcs = w);
-		}
-		free(w);
-	}
-
-	if (aes->aes_set & AES_SET_UTF8) {
-		/* Try converting UTF8 to WCS. */
-		aes->aes_wcs = __archive_string_utf8_w(&(aes->aes_utf8));
-		if (aes->aes_wcs != NULL)
-			aes->aes_set |= AES_SET_WCS;
-		return (aes->aes_wcs);
-	}
-	return (NULL);
-}
-
-static int
-aes_set_mbs(struct aes *aes, const char *mbs)
-{
-	return (aes_copy_mbs(aes, mbs));
-}
-
-static int
-aes_copy_mbs(struct aes *aes, const char *mbs)
-{
-	if (mbs == NULL) {
-		aes->aes_set = 0;
-		return (0);
-	}
-	aes->aes_set = AES_SET_MBS; /* Only MBS form is set now. */
-	archive_strcpy(&(aes->aes_mbs), mbs);
-	archive_string_empty(&(aes->aes_utf8));
-	if (aes->aes_wcs) {
-		free((wchar_t *)(uintptr_t)aes->aes_wcs);
-		aes->aes_wcs = NULL;
-	}
-	return (0);
-}
-
-/*
- * The 'update' form tries to proactively update all forms of
- * this string (WCS and MBS) and returns an error if any of
- * them fail.  This is used by the 'pax' handler, for instance,
- * to detect and report character-conversion failures early while
- * still allowing clients to get potentially useful values from
- * the more tolerant lazy conversions.  (get_mbs and get_wcs will
- * strive to give the user something useful, so you can get hopefully
- * usable values even if some of the character conversions are failing.)
- */
-static int
-aes_update_utf8(struct aes *aes, const char *utf8)
-{
-	if (utf8 == NULL) {
-		aes->aes_set = 0;
-		return (1); /* Succeeded in clearing everything. */
-	}
-
-	/* Save the UTF8 string. */
-	archive_strcpy(&(aes->aes_utf8), utf8);
-
-	/* Empty the mbs and wcs strings. */
-	archive_string_empty(&(aes->aes_mbs));
-	if (aes->aes_wcs) {
-		free((wchar_t *)(uintptr_t)aes->aes_wcs);
-		aes->aes_wcs = NULL;
-	}
-
-	aes->aes_set = AES_SET_UTF8;	/* Only UTF8 is set now. */
-
-	/* TODO: We should just do a direct UTF-8 to MBS conversion
-	 * here.  That would be faster, use less space, and give the
-	 * same information.  (If a UTF-8 to MBS conversion succeeds,
-	 * then UTF-8->WCS and Unicode->MBS conversions will both
-	 * succeed.) */
-
-	/* Try converting UTF8 to WCS, return false on failure. */
-	aes->aes_wcs = __archive_string_utf8_w(&(aes->aes_utf8));
-	if (aes->aes_wcs == NULL)
-		return (0);
-	aes->aes_set = AES_SET_UTF8 | AES_SET_WCS; /* Both UTF8 and WCS set. */
-
-	/* Try converting WCS to MBS, return false on failure. */
-	if (archive_strappend_w_mbs(&(aes->aes_mbs), aes->aes_wcs) == NULL)
-		return (0);
-	aes->aes_set = AES_SET_UTF8 | AES_SET_WCS | AES_SET_MBS;
-
-	/* All conversions succeeded. */
-	return (1);
-}
-
-static int
-aes_copy_wcs(struct aes *aes, const wchar_t *wcs)
-{
-	return aes_copy_wcs_len(aes, wcs, wcs == NULL ? 0 : wcslen(wcs));
-}
-
-static int
-aes_copy_wcs_len(struct aes *aes, const wchar_t *wcs, size_t len)
-{
-	wchar_t *w;
-
-	if (wcs == NULL) {
-		aes->aes_set = 0;
-		return (0);
-	}
-	aes->aes_set = AES_SET_WCS; /* Only WCS form set. */
-	archive_string_empty(&(aes->aes_mbs));
-	archive_string_empty(&(aes->aes_utf8));
-	if (aes->aes_wcs) {
-		free((wchar_t *)(uintptr_t)aes->aes_wcs);
-		aes->aes_wcs = NULL;
-	}
-	w = (wchar_t *)malloc((len + 1) * sizeof(wchar_t));
-	if (w == NULL)
-		__archive_errx(1, "No memory for aes_copy_wcs()");
-	wmemcpy(w, wcs, len);
-	w[len] = L'\0';
-	aes->aes_wcs = w;
-	return (0);
-}
 
 /****************************************************************************
  *
@@ -374,15 +155,17 @@
 {
 	if (entry == NULL)
 		return (NULL);
-	aes_clean(&entry->ae_fflags_text);
-	aes_clean(&entry->ae_gname);
-	aes_clean(&entry->ae_hardlink);
-	aes_clean(&entry->ae_pathname);
-	aes_clean(&entry->ae_sourcepath);
-	aes_clean(&entry->ae_symlink);
-	aes_clean(&entry->ae_uname);
-	archive_entry_acl_clear(entry);
+	archive_mstring_clean(&entry->ae_fflags_text);
+	archive_mstring_clean(&entry->ae_gname);
+	archive_mstring_clean(&entry->ae_hardlink);
+	archive_mstring_clean(&entry->ae_pathname);
+	archive_mstring_clean(&entry->ae_sourcepath);
+	archive_mstring_clean(&entry->ae_symlink);
+	archive_mstring_clean(&entry->ae_uname);
+	archive_entry_copy_mac_metadata(entry, NULL, 0);
+	archive_acl_clear(&entry->acl);
 	archive_entry_xattr_clear(entry);
+	archive_entry_sparse_clear(entry);
 	free(entry->stat);
 	memset(entry, 0, sizeof(*entry));
 	return entry;
@@ -392,36 +175,38 @@
 archive_entry_clone(struct archive_entry *entry)
 {
 	struct archive_entry *entry2;
-	struct ae_acl *ap, *ap2;
 	struct ae_xattr *xp;
+	struct ae_sparse *sp;
+	size_t s;
+	const void *p;
 
 	/* Allocate new structure and copy over all of the fields. */
-	entry2 = (struct archive_entry *)malloc(sizeof(*entry2));
+	/* TODO: Should we copy the archive over?  Or require a new archive
+	 * as an argument? */
+	entry2 = archive_entry_new2(entry->archive);
 	if (entry2 == NULL)
 		return (NULL);
-	memset(entry2, 0, sizeof(*entry2));
 	entry2->ae_stat = entry->ae_stat;
 	entry2->ae_fflags_set = entry->ae_fflags_set;
 	entry2->ae_fflags_clear = entry->ae_fflags_clear;
 
-	aes_copy(&entry2->ae_fflags_text, &entry->ae_fflags_text);
-	aes_copy(&entry2->ae_gname, &entry->ae_gname);
-	aes_copy(&entry2->ae_hardlink, &entry->ae_hardlink);
-	aes_copy(&entry2->ae_pathname, &entry->ae_pathname);
-	aes_copy(&entry2->ae_sourcepath, &entry->ae_sourcepath);
-	aes_copy(&entry2->ae_symlink, &entry->ae_symlink);
+	/* TODO: XXX If clone can have a different archive, what do we do here if
+	 * character sets are different? XXX */
+	archive_mstring_copy(&entry2->ae_fflags_text, &entry->ae_fflags_text);
+	archive_mstring_copy(&entry2->ae_gname, &entry->ae_gname);
+	archive_mstring_copy(&entry2->ae_hardlink, &entry->ae_hardlink);
+	archive_mstring_copy(&entry2->ae_pathname, &entry->ae_pathname);
+	archive_mstring_copy(&entry2->ae_sourcepath, &entry->ae_sourcepath);
+	archive_mstring_copy(&entry2->ae_symlink, &entry->ae_symlink);
 	entry2->ae_set = entry->ae_set;
-	aes_copy(&entry2->ae_uname, &entry->ae_uname);
+	archive_mstring_copy(&entry2->ae_uname, &entry->ae_uname);
 
 	/* Copy ACL data over. */
-	ap = entry->acl_head;
-	while (ap != NULL) {
-		ap2 = acl_new_entry(entry2,
-		    ap->type, ap->permset, ap->tag, ap->id);
-		if (ap2 != NULL)
-			aes_copy(&ap2->name, &ap->name);
-		ap = ap->next;
-	}
+	archive_acl_copy(&entry2->acl, &entry->acl);
+
+	/* Copy Mac OS metadata. */
+	p = archive_entry_mac_metadata(entry, &s);
+	archive_entry_copy_mac_metadata(entry2, p, s);
 
 	/* Copy xattr data over. */
 	xp = entry->xattr_head;
@@ -431,6 +216,14 @@
 		xp = xp->next;
 	}
 
+	/* Copy sparse data over. */
+	sp = entry->sparse_head;
+	while (sp != NULL) {
+		archive_entry_sparse_add_entry(entry2,
+		    sp->offset, sp->length);
+		sp = sp->next;
+	}
+
 	return (entry2);
 }
 
@@ -444,12 +237,19 @@
 struct archive_entry *
 archive_entry_new(void)
 {
+	return archive_entry_new2(NULL);
+}
+
+struct archive_entry *
+archive_entry_new2(struct archive *a)
+{
 	struct archive_entry *entry;
 
 	entry = (struct archive_entry *)malloc(sizeof(*entry));
 	if (entry == NULL)
 		return (NULL);
 	memset(entry, 0, sizeof(*entry));
+	entry->archive = a;
 	return (entry);
 }
 
@@ -521,6 +321,12 @@
 		return (entry->ae_stat.aest_dev);
 }
 
+int
+archive_entry_dev_is_set(struct archive_entry *entry)
+{
+	return (entry->ae_set & AE_SET_DEV);
+}
+
 dev_t
 archive_entry_devmajor(struct archive_entry *entry)
 {
@@ -542,7 +348,7 @@
 mode_t
 archive_entry_filetype(struct archive_entry *entry)
 {
-	return (AE_IFMT & entry->ae_stat.aest_mode);
+	return (AE_IFMT & entry->acl.mode);
 }
 
 void
@@ -568,8 +374,8 @@
 	const char *f;
 	char *p;
 
-	f = aes_get_mbs(&entry->ae_fflags_text);
-	if (f != NULL)
+	if (archive_mstring_get_mbs(entry->archive,
+	    &entry->ae_fflags_text, &f) == 0 && f != NULL)
 		return (f);
 
 	if (entry->ae_fflags_set == 0  &&  entry->ae_fflags_clear == 0)
@@ -579,13 +385,15 @@
 	if (p == NULL)
 		return (NULL);
 
-	aes_copy_mbs(&entry->ae_fflags_text, p);
+	archive_mstring_copy_mbs(&entry->ae_fflags_text, p);
 	free(p);
-	f = aes_get_mbs(&entry->ae_fflags_text);
-	return (f);
+	if (archive_mstring_get_mbs(entry->archive,
+	    &entry->ae_fflags_text, &f) == 0)
+		return (f);
+	return (NULL);
 }
 
-gid_t
+int64_t
 archive_entry_gid(struct archive_entry *entry)
 {
 	return (entry->ae_stat.aest_gid);
@@ -594,37 +402,72 @@
 const char *
 archive_entry_gname(struct archive_entry *entry)
 {
-	return (aes_get_mbs(&entry->ae_gname));
+	const char *p;
+	if (archive_mstring_get_mbs(entry->archive, &entry->ae_gname, &p) == 0)
+		return (p);
+	return (NULL);
 }
 
 const wchar_t *
 archive_entry_gname_w(struct archive_entry *entry)
 {
-	return (aes_get_wcs(&entry->ae_gname));
+	const wchar_t *p;
+	if (archive_mstring_get_wcs(entry->archive, &entry->ae_gname, &p) == 0)
+		return (p);
+	return (NULL);
+}
+
+int
+_archive_entry_gname_l(struct archive_entry *entry,
+    const char **p, size_t *len, struct archive_string_conv *sc)
+{
+	return (archive_mstring_get_mbs_l(&entry->ae_gname, p, len, sc));
 }
 
 const char *
 archive_entry_hardlink(struct archive_entry *entry)
 {
-	if (entry->ae_set & AE_SET_HARDLINK)
-		return (aes_get_mbs(&entry->ae_hardlink));
+	const char *p;
+	if ((entry->ae_set & AE_SET_HARDLINK) && archive_mstring_get_mbs(
+	    entry->archive, &entry->ae_hardlink, &p) == 0)
+		return (p);
 	return (NULL);
 }
 
 const wchar_t *
 archive_entry_hardlink_w(struct archive_entry *entry)
 {
-	if (entry->ae_set & AE_SET_HARDLINK)
-		return (aes_get_wcs(&entry->ae_hardlink));
+	const wchar_t *p;
+	if ((entry->ae_set & AE_SET_HARDLINK) && archive_mstring_get_wcs(
+	    entry->archive, &entry->ae_hardlink, &p) == 0)
+		return (p);
 	return (NULL);
 }
 
-ino_t
+int
+_archive_entry_hardlink_l(struct archive_entry *entry,
+    const char **p, size_t *len, struct archive_string_conv *sc)
+{
+	if ((entry->ae_set & AE_SET_HARDLINK) == 0) {
+		*p = NULL;
+		*len = 0;
+		return (0);
+	}
+	return (archive_mstring_get_mbs_l(&entry->ae_hardlink, p, len, sc));
+}
+
+int64_t
 archive_entry_ino(struct archive_entry *entry)
 {
 	return (entry->ae_stat.aest_ino);
 }
 
+int
+archive_entry_ino_is_set(struct archive_entry *entry)
+{
+	return (entry->ae_set & AE_SET_INO);
+}
+
 int64_t
 archive_entry_ino64(struct archive_entry *entry)
 {
@@ -634,7 +477,7 @@
 mode_t
 archive_entry_mode(struct archive_entry *entry)
 {
-	return (entry->ae_stat.aest_mode);
+	return (entry->acl.mode);
 }
 
 time_t
@@ -664,13 +507,34 @@
 const char *
 archive_entry_pathname(struct archive_entry *entry)
 {
-	return (aes_get_mbs(&entry->ae_pathname));
+	const char *p;
+	if (archive_mstring_get_mbs(
+	    entry->archive, &entry->ae_pathname, &p) == 0)
+		return (p);
+	return (NULL);
 }
 
 const wchar_t *
 archive_entry_pathname_w(struct archive_entry *entry)
 {
-	return (aes_get_wcs(&entry->ae_pathname));
+	const wchar_t *p;
+	if (archive_mstring_get_wcs(
+	    entry->archive, &entry->ae_pathname, &p) == 0)
+		return (p);
+	return (NULL);
+}
+
+int
+_archive_entry_pathname_l(struct archive_entry *entry,
+    const char **p, size_t *len, struct archive_string_conv *sc)
+{
+	return (archive_mstring_get_mbs_l(&entry->ae_pathname, p, len, sc));
+}
+
+mode_t
+archive_entry_perm(struct archive_entry *entry)
+{
+	return (~AE_IFMT & entry->acl.mode);
 }
 
 dev_t
@@ -716,26 +580,56 @@
 const char *
 archive_entry_sourcepath(struct archive_entry *entry)
 {
-	return (aes_get_mbs(&entry->ae_sourcepath));
+	const char *p;
+	if (archive_mstring_get_mbs(
+	    entry->archive, &entry->ae_sourcepath, &p) == 0)
+		return (p);
+	return (NULL);
+}
+
+const wchar_t *
+archive_entry_sourcepath_w(struct archive_entry *entry)
+{
+	const wchar_t *p;
+	if (archive_mstring_get_wcs(
+	    entry->archive, &entry->ae_sourcepath, &p) == 0)
+		return (p);
+	return (NULL);
 }
 
 const char *
 archive_entry_symlink(struct archive_entry *entry)
 {
-	if (entry->ae_set & AE_SET_SYMLINK)
-		return (aes_get_mbs(&entry->ae_symlink));
+	const char *p;
+	if ((entry->ae_set & AE_SET_SYMLINK) && archive_mstring_get_mbs(
+	    entry->archive, &entry->ae_symlink, &p) == 0)
+		return (p);
 	return (NULL);
 }
 
 const wchar_t *
 archive_entry_symlink_w(struct archive_entry *entry)
 {
-	if (entry->ae_set & AE_SET_SYMLINK)
-		return (aes_get_wcs(&entry->ae_symlink));
+	const wchar_t *p;
+	if ((entry->ae_set & AE_SET_SYMLINK) && archive_mstring_get_wcs(
+	    entry->archive, &entry->ae_symlink, &p) == 0)
+		return (p);
 	return (NULL);
 }
 
-uid_t
+int
+_archive_entry_symlink_l(struct archive_entry *entry,
+    const char **p, size_t *len, struct archive_string_conv *sc)
+{
+	if ((entry->ae_set & AE_SET_SYMLINK) == 0) {
+		*p = NULL;
+		*len = 0;
+		return (0);
+	}
+	return (archive_mstring_get_mbs_l( &entry->ae_symlink, p, len, sc));
+}
+
+int64_t
 archive_entry_uid(struct archive_entry *entry)
 {
 	return (entry->ae_stat.aest_uid);
@@ -744,13 +638,26 @@
 const char *
 archive_entry_uname(struct archive_entry *entry)
 {
-	return (aes_get_mbs(&entry->ae_uname));
+	const char *p;
+	if (archive_mstring_get_mbs(entry->archive, &entry->ae_uname, &p) == 0)
+		return (p);
+	return (NULL);
 }
 
 const wchar_t *
 archive_entry_uname_w(struct archive_entry *entry)
 {
-	return (aes_get_wcs(&entry->ae_uname));
+	const wchar_t *p;
+	if (archive_mstring_get_wcs(entry->archive, &entry->ae_uname, &p) == 0)
+		return (p);
+	return (NULL);
+}
+
+int
+_archive_entry_uname_l(struct archive_entry *entry,
+    const char **p, size_t *len, struct archive_string_conv *sc)
+{
+	return (archive_mstring_get_mbs_l(&entry->ae_uname, p, len, sc));
 }
 
 /*
@@ -761,15 +668,15 @@
 archive_entry_set_filetype(struct archive_entry *entry, unsigned int type)
 {
 	entry->stat_valid = 0;
-	entry->ae_stat.aest_mode &= ~AE_IFMT;
-	entry->ae_stat.aest_mode |= AE_IFMT & type;
+	entry->acl.mode &= ~AE_IFMT;
+	entry->acl.mode |= AE_IFMT & type;
 }
 
 void
 archive_entry_set_fflags(struct archive_entry *entry,
     unsigned long set, unsigned long clear)
 {
-	aes_clean(&entry->ae_fflags_text);
+	archive_mstring_clean(&entry->ae_fflags_text);
 	entry->ae_fflags_set = set;
 	entry->ae_fflags_clear = clear;
 }
@@ -778,7 +685,7 @@
 archive_entry_copy_fflags_text(struct archive_entry *entry,
     const char *flags)
 {
-	aes_copy_mbs(&entry->ae_fflags_text, flags);
+	archive_mstring_copy_mbs(&entry->ae_fflags_text, flags);
 	return (ae_strtofflags(flags,
 		    &entry->ae_fflags_set, &entry->ae_fflags_clear));
 }
@@ -787,13 +694,13 @@
 archive_entry_copy_fflags_text_w(struct archive_entry *entry,
     const wchar_t *flags)
 {
-	aes_copy_wcs(&entry->ae_fflags_text, flags);
+	archive_mstring_copy_wcs(&entry->ae_fflags_text, flags);
 	return (ae_wcstofflags(flags,
 		    &entry->ae_fflags_set, &entry->ae_fflags_clear));
 }
 
 void
-archive_entry_set_gid(struct archive_entry *entry, gid_t g)
+archive_entry_set_gid(struct archive_entry *entry, int64_t g)
 {
 	entry->stat_valid = 0;
 	entry->ae_stat.aest_gid = g;
@@ -802,31 +709,42 @@
 void
 archive_entry_set_gname(struct archive_entry *entry, const char *name)
 {
-	aes_set_mbs(&entry->ae_gname, name);
+	archive_mstring_copy_mbs(&entry->ae_gname, name);
 }
 
 void
 archive_entry_copy_gname(struct archive_entry *entry, const char *name)
 {
-	aes_copy_mbs(&entry->ae_gname, name);
+	archive_mstring_copy_mbs(&entry->ae_gname, name);
 }
 
 void
 archive_entry_copy_gname_w(struct archive_entry *entry, const wchar_t *name)
 {
-	aes_copy_wcs(&entry->ae_gname, name);
+	archive_mstring_copy_wcs(&entry->ae_gname, name);
 }
 
 int
 archive_entry_update_gname_utf8(struct archive_entry *entry, const char *name)
 {
-	return (aes_update_utf8(&entry->ae_gname, name));
+	if (archive_mstring_update_utf8(entry->archive,
+	    &entry->ae_gname, name) == 0)
+		return (1);
+	return (0);
+}
+
+int
+_archive_entry_copy_gname_l(struct archive_entry *entry,
+    const char *name, size_t len, struct archive_string_conv *sc)
+{
+	return (archive_mstring_copy_mbs_len_l(&entry->ae_gname, name, len, sc));
 }
 
 void
-archive_entry_set_ino(struct archive_entry *entry, unsigned long ino)
+archive_entry_set_ino(struct archive_entry *entry, int64_t ino)
 {
 	entry->stat_valid = 0;
+	entry->ae_set |= AE_SET_INO;
 	entry->ae_stat.aest_ino = ino;
 }
 
@@ -834,13 +752,14 @@
 archive_entry_set_ino64(struct archive_entry *entry, int64_t ino)
 {
 	entry->stat_valid = 0;
+	entry->ae_set |= AE_SET_INO;
 	entry->ae_stat.aest_ino = ino;
 }
 
 void
 archive_entry_set_hardlink(struct archive_entry *entry, const char *target)
 {
-	aes_set_mbs(&entry->ae_hardlink, target);
+	archive_mstring_copy_mbs(&entry->ae_hardlink, target);
 	if (target != NULL)
 		entry->ae_set |= AE_SET_HARDLINK;
 	else
@@ -850,7 +769,7 @@
 void
 archive_entry_copy_hardlink(struct archive_entry *entry, const char *target)
 {
-	aes_copy_mbs(&entry->ae_hardlink, target);
+	archive_mstring_copy_mbs(&entry->ae_hardlink, target);
 	if (target != NULL)
 		entry->ae_set |= AE_SET_HARDLINK;
 	else
@@ -860,7 +779,7 @@
 void
 archive_entry_copy_hardlink_w(struct archive_entry *entry, const wchar_t *target)
 {
-	aes_copy_wcs(&entry->ae_hardlink, target);
+	archive_mstring_copy_wcs(&entry->ae_hardlink, target);
 	if (target != NULL)
 		entry->ae_set |= AE_SET_HARDLINK;
 	else
@@ -874,12 +793,31 @@
 		entry->ae_set |= AE_SET_HARDLINK;
 	else
 		entry->ae_set &= ~AE_SET_HARDLINK;
-	return (aes_update_utf8(&entry->ae_hardlink, target));
+	if (archive_mstring_update_utf8(entry->archive,
+	    &entry->ae_hardlink, target) == 0)
+		return (1);
+	return (0);
+}
+
+int
+_archive_entry_copy_hardlink_l(struct archive_entry *entry,
+    const char *target, size_t len, struct archive_string_conv *sc)
+{
+	int r;
+
+	r = archive_mstring_copy_mbs_len_l(&entry->ae_hardlink,
+	    target, len, sc);
+	if (target != NULL && r == 0)
+		entry->ae_set |= AE_SET_HARDLINK;
+	else
+		entry->ae_set &= ~AE_SET_HARDLINK;
+	return (r);
 }
 
 void
 archive_entry_set_atime(struct archive_entry *entry, time_t t, long ns)
 {
+	FIX_NS(t, ns);
 	entry->stat_valid = 0;
 	entry->ae_set |= AE_SET_ATIME;
 	entry->ae_stat.aest_atime = t;
@@ -894,11 +832,12 @@
 }
 
 void
-archive_entry_set_birthtime(struct archive_entry *entry, time_t m, long ns)
+archive_entry_set_birthtime(struct archive_entry *entry, time_t t, long ns)
 {
+	FIX_NS(t, ns);
 	entry->stat_valid = 0;
 	entry->ae_set |= AE_SET_BIRTHTIME;
-	entry->ae_stat.aest_birthtime = m;
+	entry->ae_stat.aest_birthtime = t;
 	entry->ae_stat.aest_birthtime_nsec = ns;
 }
 
@@ -912,6 +851,7 @@
 void
 archive_entry_set_ctime(struct archive_entry *entry, time_t t, long ns)
 {
+	FIX_NS(t, ns);
 	entry->stat_valid = 0;
 	entry->ae_set |= AE_SET_CTIME;
 	entry->ae_stat.aest_ctime = t;
@@ -929,6 +869,7 @@
 archive_entry_set_dev(struct archive_entry *entry, dev_t d)
 {
 	entry->stat_valid = 0;
+	entry->ae_set |= AE_SET_DEV;
 	entry->ae_stat.aest_dev_is_broken_down = 0;
 	entry->ae_stat.aest_dev = d;
 }
@@ -937,6 +878,7 @@
 archive_entry_set_devmajor(struct archive_entry *entry, dev_t m)
 {
 	entry->stat_valid = 0;
+	entry->ae_set |= AE_SET_DEV;
 	entry->ae_stat.aest_dev_is_broken_down = 1;
 	entry->ae_stat.aest_devmajor = m;
 }
@@ -945,6 +887,7 @@
 archive_entry_set_devminor(struct archive_entry *entry, dev_t m)
 {
 	entry->stat_valid = 0;
+	entry->ae_set |= AE_SET_DEV;
 	entry->ae_stat.aest_dev_is_broken_down = 1;
 	entry->ae_stat.aest_devminor = m;
 }
@@ -954,9 +897,9 @@
 archive_entry_set_link(struct archive_entry *entry, const char *target)
 {
 	if (entry->ae_set & AE_SET_SYMLINK)
-		aes_set_mbs(&entry->ae_symlink, target);
+		archive_mstring_copy_mbs(&entry->ae_symlink, target);
 	else
-		aes_set_mbs(&entry->ae_hardlink, target);
+		archive_mstring_copy_mbs(&entry->ae_hardlink, target);
 }
 
 /* Set symlink if symlink is already set, else set hardlink. */
@@ -964,9 +907,9 @@
 archive_entry_copy_link(struct archive_entry *entry, const char *target)
 {
 	if (entry->ae_set & AE_SET_SYMLINK)
-		aes_copy_mbs(&entry->ae_symlink, target);
+		archive_mstring_copy_mbs(&entry->ae_symlink, target);
 	else
-		aes_copy_mbs(&entry->ae_hardlink, target);
+		archive_mstring_copy_mbs(&entry->ae_hardlink, target);
 }
 
 /* Set symlink if symlink is already set, else set hardlink. */
@@ -974,33 +917,53 @@
 archive_entry_copy_link_w(struct archive_entry *entry, const wchar_t *target)
 {
 	if (entry->ae_set & AE_SET_SYMLINK)
-		aes_copy_wcs(&entry->ae_symlink, target);
+		archive_mstring_copy_wcs(&entry->ae_symlink, target);
 	else
-		aes_copy_wcs(&entry->ae_hardlink, target);
+		archive_mstring_copy_wcs(&entry->ae_hardlink, target);
 }
 
 int
 archive_entry_update_link_utf8(struct archive_entry *entry, const char *target)
 {
+	int r;
 	if (entry->ae_set & AE_SET_SYMLINK)
-		return (aes_update_utf8(&entry->ae_symlink, target));
+		r = archive_mstring_update_utf8(entry->archive,
+		    &entry->ae_symlink, target);
 	else
-		return (aes_update_utf8(&entry->ae_hardlink, target));
+		r = archive_mstring_update_utf8(entry->archive,
+		    &entry->ae_hardlink, target);
+	return ((r == 0)? 1: 0);
+}
+
+int
+_archive_entry_copy_link_l(struct archive_entry *entry,
+    const char *target, size_t len, struct archive_string_conv *sc)
+{
+	int r;
+
+	if (entry->ae_set & AE_SET_SYMLINK)
+		r = archive_mstring_copy_mbs_len_l(&entry->ae_symlink,
+		    target, len, sc);
+	else
+		r = archive_mstring_copy_mbs_len_l(&entry->ae_hardlink,
+		    target, len, sc);
+	return (r);
 }
 
 void
 archive_entry_set_mode(struct archive_entry *entry, mode_t m)
 {
 	entry->stat_valid = 0;
-	entry->ae_stat.aest_mode = m;
+	entry->acl.mode = m;
 }
 
 void
-archive_entry_set_mtime(struct archive_entry *entry, time_t m, long ns)
+archive_entry_set_mtime(struct archive_entry *entry, time_t t, long ns)
 {
+	FIX_NS(t, ns);
 	entry->stat_valid = 0;
 	entry->ae_set |= AE_SET_MTIME;
-	entry->ae_stat.aest_mtime = m;
+	entry->ae_stat.aest_mtime = t;
 	entry->ae_stat.aest_mtime_nsec = ns;
 }
 
@@ -1021,33 +984,44 @@
 void
 archive_entry_set_pathname(struct archive_entry *entry, const char *name)
 {
-	aes_set_mbs(&entry->ae_pathname, name);
+	archive_mstring_copy_mbs(&entry->ae_pathname, name);
 }
 
 void
 archive_entry_copy_pathname(struct archive_entry *entry, const char *name)
 {
-	aes_copy_mbs(&entry->ae_pathname, name);
+	archive_mstring_copy_mbs(&entry->ae_pathname, name);
 }
 
 void
 archive_entry_copy_pathname_w(struct archive_entry *entry, const wchar_t *name)
 {
-	aes_copy_wcs(&entry->ae_pathname, name);
+	archive_mstring_copy_wcs(&entry->ae_pathname, name);
 }
 
 int
 archive_entry_update_pathname_utf8(struct archive_entry *entry, const char *name)
 {
-	return (aes_update_utf8(&entry->ae_pathname, name));
+	if (archive_mstring_update_utf8(entry->archive,
+	    &entry->ae_pathname, name) == 0)
+		return (1);
+	return (0);
+}
+
+int
+_archive_entry_copy_pathname_l(struct archive_entry *entry,
+    const char *name, size_t len, struct archive_string_conv *sc)
+{
+	return (archive_mstring_copy_mbs_len_l(&entry->ae_pathname,
+	    name, len, sc));
 }
 
 void
 archive_entry_set_perm(struct archive_entry *entry, mode_t p)
 {
 	entry->stat_valid = 0;
-	entry->ae_stat.aest_mode &= AE_IFMT;
-	entry->ae_stat.aest_mode |= ~AE_IFMT & p;
+	entry->acl.mode &= AE_IFMT;
+	entry->acl.mode |= ~AE_IFMT & p;
 }
 
 void
@@ -1092,13 +1066,19 @@
 void
 archive_entry_copy_sourcepath(struct archive_entry *entry, const char *path)
 {
-	aes_set_mbs(&entry->ae_sourcepath, path);
+	archive_mstring_copy_mbs(&entry->ae_sourcepath, path);
+}
+
+void
+archive_entry_copy_sourcepath_w(struct archive_entry *entry, const wchar_t *path)
+{
+	archive_mstring_copy_wcs(&entry->ae_sourcepath, path);
 }
 
 void
 archive_entry_set_symlink(struct archive_entry *entry, const char *linkname)
 {
-	aes_set_mbs(&entry->ae_symlink, linkname);
+	archive_mstring_copy_mbs(&entry->ae_symlink, linkname);
 	if (linkname != NULL)
 		entry->ae_set |= AE_SET_SYMLINK;
 	else
@@ -1108,7 +1088,7 @@
 void
 archive_entry_copy_symlink(struct archive_entry *entry, const char *linkname)
 {
-	aes_copy_mbs(&entry->ae_symlink, linkname);
+	archive_mstring_copy_mbs(&entry->ae_symlink, linkname);
 	if (linkname != NULL)
 		entry->ae_set |= AE_SET_SYMLINK;
 	else
@@ -1118,7 +1098,7 @@
 void
 archive_entry_copy_symlink_w(struct archive_entry *entry, const wchar_t *linkname)
 {
-	aes_copy_wcs(&entry->ae_symlink, linkname);
+	archive_mstring_copy_wcs(&entry->ae_symlink, linkname);
 	if (linkname != NULL)
 		entry->ae_set |= AE_SET_SYMLINK;
 	else
@@ -1132,11 +1112,29 @@
 		entry->ae_set |= AE_SET_SYMLINK;
 	else
 		entry->ae_set &= ~AE_SET_SYMLINK;
-	return (aes_update_utf8(&entry->ae_symlink, linkname));
+	if (archive_mstring_update_utf8(entry->archive,
+	    &entry->ae_symlink, linkname) == 0)
+		return (1);
+	return (0);
+}
+
+int
+_archive_entry_copy_symlink_l(struct archive_entry *entry,
+    const char *linkname, size_t len, struct archive_string_conv *sc)
+{
+	int r;
+
+	r = archive_mstring_copy_mbs_len_l(&entry->ae_symlink,
+	    linkname, len, sc);
+	if (linkname != NULL && r == 0)
+		entry->ae_set |= AE_SET_SYMLINK;
+	else
+		entry->ae_set &= ~AE_SET_SYMLINK;
+	return (r);
 }
 
 void
-archive_entry_set_uid(struct archive_entry *entry, uid_t u)
+archive_entry_set_uid(struct archive_entry *entry, int64_t u)
 {
 	entry->stat_valid = 0;
 	entry->ae_stat.aest_uid = u;
@@ -1145,25 +1143,60 @@
 void
 archive_entry_set_uname(struct archive_entry *entry, const char *name)
 {
-	aes_set_mbs(&entry->ae_uname, name);
+	archive_mstring_copy_mbs(&entry->ae_uname, name);
 }
 
 void
 archive_entry_copy_uname(struct archive_entry *entry, const char *name)
 {
-	aes_copy_mbs(&entry->ae_uname, name);
+	archive_mstring_copy_mbs(&entry->ae_uname, name);
 }
 
 void
 archive_entry_copy_uname_w(struct archive_entry *entry, const wchar_t *name)
 {
-	aes_copy_wcs(&entry->ae_uname, name);
+	archive_mstring_copy_wcs(&entry->ae_uname, name);
 }
 
 int
 archive_entry_update_uname_utf8(struct archive_entry *entry, const char *name)
 {
-	return (aes_update_utf8(&entry->ae_uname, name));
+	if (archive_mstring_update_utf8(entry->archive,
+	    &entry->ae_uname, name) == 0)
+		return (1);
+	return (0);
+}
+
+int
+_archive_entry_copy_uname_l(struct archive_entry *entry,
+    const char *name, size_t len, struct archive_string_conv *sc)
+{
+	return (archive_mstring_copy_mbs_len_l(&entry->ae_uname,
+	    name, len, sc));
+}
+
+const void *
+archive_entry_mac_metadata(struct archive_entry *entry, size_t *s)
+{
+  *s = entry->mac_metadata_size;
+  return entry->mac_metadata;
+}
+
+void
+archive_entry_copy_mac_metadata(struct archive_entry *entry,
+    const void *p, size_t s)
+{
+  free(entry->mac_metadata);
+  if (p == NULL || s == 0) {
+    entry->mac_metadata = NULL;
+    entry->mac_metadata_size = 0;
+  } else {
+    entry->mac_metadata_size = s;
+    entry->mac_metadata = malloc(s);
+    if (entry->mac_metadata == NULL)
+      abort();
+    memcpy(entry->mac_metadata, p, s);
+  }
 }
 
 /*
@@ -1175,148 +1208,37 @@
  * uninitiated.
  */
 
+struct archive_acl *
+archive_entry_acl(struct archive_entry *entry)
+{
+	return &entry->acl;
+}
+
 void
 archive_entry_acl_clear(struct archive_entry *entry)
 {
-	struct ae_acl	*ap;
-
-	while (entry->acl_head != NULL) {
-		ap = entry->acl_head->next;
-		aes_clean(&entry->acl_head->name);
-		free(entry->acl_head);
-		entry->acl_head = ap;
-	}
-	if (entry->acl_text_w != NULL) {
-		free(entry->acl_text_w);
-		entry->acl_text_w = NULL;
-	}
-	entry->acl_p = NULL;
-	entry->acl_state = 0; /* Not counting. */
+	archive_acl_clear(&entry->acl);
 }
 
 /*
  * Add a single ACL entry to the internal list of ACL data.
  */
-void
+int
 archive_entry_acl_add_entry(struct archive_entry *entry,
     int type, int permset, int tag, int id, const char *name)
 {
-	struct ae_acl *ap;
-
-	if (acl_special(entry, type, permset, tag) == 0)
-		return;
-	ap = acl_new_entry(entry, type, permset, tag, id);
-	if (ap == NULL) {
-		/* XXX Error XXX */
-		return;
-	}
-	if (name != NULL  &&  *name != '\0')
-		aes_copy_mbs(&ap->name, name);
-	else
-		aes_clean(&ap->name);
+	return archive_acl_add_entry(&entry->acl, type, permset, tag, id, name);
 }
 
 /*
  * As above, but with a wide-character name.
  */
-void
+int
 archive_entry_acl_add_entry_w(struct archive_entry *entry,
     int type, int permset, int tag, int id, const wchar_t *name)
 {
-	archive_entry_acl_add_entry_w_len(entry, type, permset, tag, id, name, wcslen(name));
-}
-
-static void
-archive_entry_acl_add_entry_w_len(struct archive_entry *entry,
-    int type, int permset, int tag, int id, const wchar_t *name, size_t len)
-{
-	struct ae_acl *ap;
-
-	if (acl_special(entry, type, permset, tag) == 0)
-		return;
-	ap = acl_new_entry(entry, type, permset, tag, id);
-	if (ap == NULL) {
-		/* XXX Error XXX */
-		return;
-	}
-	if (name != NULL  &&  *name != L'\0' && len > 0)
-		aes_copy_wcs_len(&ap->name, name, len);
-	else
-		aes_clean(&ap->name);
-}
-
-/*
- * If this ACL entry is part of the standard POSIX permissions set,
- * store the permissions in the stat structure and return zero.
- */
-static int
-acl_special(struct archive_entry *entry, int type, int permset, int tag)
-{
-	if (type == ARCHIVE_ENTRY_ACL_TYPE_ACCESS) {
-		switch (tag) {
-		case ARCHIVE_ENTRY_ACL_USER_OBJ:
-			entry->ae_stat.aest_mode &= ~0700;
-			entry->ae_stat.aest_mode |= (permset & 7) << 6;
-			return (0);
-		case ARCHIVE_ENTRY_ACL_GROUP_OBJ:
-			entry->ae_stat.aest_mode &= ~0070;
-			entry->ae_stat.aest_mode |= (permset & 7) << 3;
-			return (0);
-		case ARCHIVE_ENTRY_ACL_OTHER:
-			entry->ae_stat.aest_mode &= ~0007;
-			entry->ae_stat.aest_mode |= permset & 7;
-			return (0);
-		}
-	}
-	return (1);
-}
-
-/*
- * Allocate and populate a new ACL entry with everything but the
- * name.
- */
-static struct ae_acl *
-acl_new_entry(struct archive_entry *entry,
-    int type, int permset, int tag, int id)
-{
-	struct ae_acl *ap, *aq;
-
-	if (type != ARCHIVE_ENTRY_ACL_TYPE_ACCESS &&
-	    type != ARCHIVE_ENTRY_ACL_TYPE_DEFAULT)
-		return (NULL);
-	if (entry->acl_text_w != NULL) {
-		free(entry->acl_text_w);
-		entry->acl_text_w = NULL;
-	}
-
-	/* XXX TODO: More sanity-checks on the arguments XXX */
-
-	/* If there's a matching entry already in the list, overwrite it. */
-	ap = entry->acl_head;
-	aq = NULL;
-	while (ap != NULL) {
-		if (ap->type == type && ap->tag == tag && ap->id == id) {
-			ap->permset = permset;
-			return (ap);
-		}
-		aq = ap;
-		ap = ap->next;
-	}
-
-	/* Add a new entry to the end of the list. */
-	ap = (struct ae_acl *)malloc(sizeof(*ap));
-	if (ap == NULL)
-		return (NULL);
-	memset(ap, 0, sizeof(*ap));
-	if (aq == NULL)
-		entry->acl_head = ap;
-	else
-		aq->next = ap;
-	ap->type = type;
-	ap->tag = tag;
-	ap->id = id;
-	ap->permset = permset;
-	return (ap);
+	return archive_acl_add_entry_w_len(&entry->acl,
+	    type, permset, tag, id, name, wcslen(name));
 }
 
 /*
@@ -1325,20 +1247,7 @@
 int
 archive_entry_acl_count(struct archive_entry *entry, int want_type)
 {
-	int count;
-	struct ae_acl *ap;
-
-	count = 0;
-	ap = entry->acl_head;
-	while (ap != NULL) {
-		if ((ap->type & want_type) != 0)
-			count++;
-		ap = ap->next;
-	}
-
-	if (count > 0 && ((want_type & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0))
-		count += 3;
-	return (count);
+	return archive_acl_count(&entry->acl, want_type);
 }
 
 /*
@@ -1349,93 +1258,18 @@
 int
 archive_entry_acl_reset(struct archive_entry *entry, int want_type)
 {
-	int count, cutoff;
-
-	count = archive_entry_acl_count(entry, want_type);
-
-	/*
-	 * If the only entries are the three standard ones,
-	 * then don't return any ACL data.  (In this case,
-	 * client can just use chmod(2) to set permissions.)
-	 */
-	if ((want_type & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0)
-		cutoff = 3;
-	else
-		cutoff = 0;
-
-	if (count > cutoff)
-		entry->acl_state = ARCHIVE_ENTRY_ACL_USER_OBJ;
-	else
-		entry->acl_state = 0;
-	entry->acl_p = entry->acl_head;
-	return (count);
+	return archive_acl_reset(&entry->acl, want_type);
 }
 
 /*
  * Return the next ACL entry in the list.  Fake entries for the
  * standard permissions and include them in the returned list.
  */
-
 int
 archive_entry_acl_next(struct archive_entry *entry, int want_type, int *type,
     int *permset, int *tag, int *id, const char **name)
 {
-	*name = NULL;
-	*id = -1;
-
-	/*
-	 * The acl_state is either zero (no entries available), -1
-	 * (reading from list), or an entry type (retrieve that type
-	 * from ae_stat.aest_mode).
-	 */
-	if (entry->acl_state == 0)
-		return (ARCHIVE_WARN);
-
-	/* The first three access entries are special. */
-	if ((want_type & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) {
-		switch (entry->acl_state) {
-		case ARCHIVE_ENTRY_ACL_USER_OBJ:
-			*permset = (entry->ae_stat.aest_mode >> 6) & 7;
-			*type = ARCHIVE_ENTRY_ACL_TYPE_ACCESS;
-			*tag = ARCHIVE_ENTRY_ACL_USER_OBJ;
-			entry->acl_state = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
-			return (ARCHIVE_OK);
-		case ARCHIVE_ENTRY_ACL_GROUP_OBJ:
-			*permset = (entry->ae_stat.aest_mode >> 3) & 7;
-			*type = ARCHIVE_ENTRY_ACL_TYPE_ACCESS;
-			*tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
-			entry->acl_state = ARCHIVE_ENTRY_ACL_OTHER;
-			return (ARCHIVE_OK);
-		case ARCHIVE_ENTRY_ACL_OTHER:
-			*permset = entry->ae_stat.aest_mode & 7;
-			*type = ARCHIVE_ENTRY_ACL_TYPE_ACCESS;
-			*tag = ARCHIVE_ENTRY_ACL_OTHER;
-			entry->acl_state = -1;
-			entry->acl_p = entry->acl_head;
-			return (ARCHIVE_OK);
-		default:
-			break;
-		}
-	}
-
-	while (entry->acl_p != NULL && (entry->acl_p->type & want_type) == 0)
-		entry->acl_p = entry->acl_p->next;
-	if (entry->acl_p == NULL) {
-		entry->acl_state = 0;
-		*type = 0;
-		*permset = 0;
-		*tag = 0;
-		*id = -1;
-		*name = NULL;
-		return (ARCHIVE_EOF); /* End of ACL entries. */
-	}
-	*type = entry->acl_p->type;
-	*permset = entry->acl_p->permset;
-	*tag = entry->acl_p->tag;
-	*id = entry->acl_p->id;
-	*name = aes_get_mbs(&entry->acl_p->name);
-	entry->acl_p = entry->acl_p->next;
-	return (ARCHIVE_OK);
+	return archive_acl_next(entry->archive, &entry->acl, want_type, type, permset, tag, id, name);
 }
 
 /*
@@ -1445,412 +1279,27 @@
 const wchar_t *
 archive_entry_acl_text_w(struct archive_entry *entry, int flags)
 {
-	int count;
-	size_t length;
-	const wchar_t *wname;
-	const wchar_t *prefix;
-	wchar_t separator;
-	struct ae_acl *ap;
-	int id;
-	wchar_t *wp;
-
-	if (entry->acl_text_w != NULL) {
-		free (entry->acl_text_w);
-		entry->acl_text_w = NULL;
-	}
-
-	separator = L',';
-	count = 0;
-	length = 0;
-	ap = entry->acl_head;
-	while (ap != NULL) {
-		if ((ap->type & flags) != 0) {
-			count++;
-			if ((flags & ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT) &&
-			    (ap->type & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT))
-				length += 8; /* "default:" */
-			length += 5; /* tag name */
-			length += 1; /* colon */
-			wname = aes_get_wcs(&ap->name);
-			if (wname != NULL)
-				length += wcslen(wname);
-			else
-				length += sizeof(uid_t) * 3 + 1;
-			length ++; /* colon */
-			length += 3; /* rwx */
-			length += 1; /* colon */
-			length += max(sizeof(uid_t), sizeof(gid_t)) * 3 + 1;
-			length ++; /* newline */
-		}
-		ap = ap->next;
-	}
-
-	if (count > 0 && ((flags & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0)) {
-		length += 10; /* "user::rwx\n" */
-		length += 11; /* "group::rwx\n" */
-		length += 11; /* "other::rwx\n" */
-	}
-
-	if (count == 0)
-		return (NULL);
-
-	/* Now, allocate the string and actually populate it. */
-	wp = entry->acl_text_w = (wchar_t *)malloc(length * sizeof(wchar_t));
-	if (wp == NULL)
-		__archive_errx(1, "No memory to generate the text version of the ACL");
-	count = 0;
-	if ((flags & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) {
-		append_entry_w(&wp, NULL, ARCHIVE_ENTRY_ACL_USER_OBJ, NULL,
-		    entry->ae_stat.aest_mode & 0700, -1);
-		*wp++ = ',';
-		append_entry_w(&wp, NULL, ARCHIVE_ENTRY_ACL_GROUP_OBJ, NULL,
-		    entry->ae_stat.aest_mode & 0070, -1);
-		*wp++ = ',';
-		append_entry_w(&wp, NULL, ARCHIVE_ENTRY_ACL_OTHER, NULL,
-		    entry->ae_stat.aest_mode & 0007, -1);
-		count += 3;
-
-		ap = entry->acl_head;
-		while (ap != NULL) {
-			if ((ap->type & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) {
-				wname = aes_get_wcs(&ap->name);
-				*wp++ = separator;
-				if (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID)
-					id = ap->id;
-				else
-					id = -1;
-				append_entry_w(&wp, NULL, ap->tag, wname,
-				    ap->permset, id);
-				count++;
-			}
-			ap = ap->next;
-		}
-	}
-
-
-	if ((flags & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0) {
-		if (flags & ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT)
-			prefix = L"default:";
-		else
-			prefix = NULL;
-		ap = entry->acl_head;
-		count = 0;
-		while (ap != NULL) {
-			if ((ap->type & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0) {
-				wname = aes_get_wcs(&ap->name);
-				if (count > 0)
-					*wp++ = separator;
-				if (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID)
-					id = ap->id;
-				else
-					id = -1;
-				append_entry_w(&wp, prefix, ap->tag,
-				    wname, ap->permset, id);
-				count ++;
-			}
-			ap = ap->next;
-		}
-	}
-
-	return (entry->acl_text_w);
+	return archive_acl_text_w(entry->archive, &entry->acl, flags);
 }
 
-static void
-append_id_w(wchar_t **wp, int id)
+const char *
+archive_entry_acl_text(struct archive_entry *entry, int flags)
 {
-	if (id < 0)
-		id = 0;
-	if (id > 9)
-		append_id_w(wp, id / 10);
-	*(*wp)++ = L"0123456789"[id % 10];
+	const char *p;
+	if (archive_acl_text_l(&entry->acl, flags, &p, NULL, NULL) != 0
+	    && errno == ENOMEM)
+		return (NULL);
+	return (p);
 }
 
-static void
-append_entry_w(wchar_t **wp, const wchar_t *prefix, int tag,
-    const wchar_t *wname, int perm, int id)
+int
+_archive_entry_acl_text_l(struct archive_entry *entry, int flags,
+    const char **acl_text, size_t *len, struct archive_string_conv *sc)
 {
-	if (prefix != NULL) {
-		wcscpy(*wp, prefix);
-		*wp += wcslen(*wp);
-	}
-	switch (tag) {
-	case ARCHIVE_ENTRY_ACL_USER_OBJ:
-		wname = NULL;
-		id = -1;
-		/* FALLTHROUGH */
-	case ARCHIVE_ENTRY_ACL_USER:
-		wcscpy(*wp, L"user");
-		break;
-	case ARCHIVE_ENTRY_ACL_GROUP_OBJ:
-		wname = NULL;
-		id = -1;
-		/* FALLTHROUGH */
-	case ARCHIVE_ENTRY_ACL_GROUP:
-		wcscpy(*wp, L"group");
-		break;
-	case ARCHIVE_ENTRY_ACL_MASK:
-		wcscpy(*wp, L"mask");
-		wname = NULL;
-		id = -1;
-		break;
-	case ARCHIVE_ENTRY_ACL_OTHER:
-		wcscpy(*wp, L"other");
-		wname = NULL;
-		id = -1;
-		break;
-	}
-	*wp += wcslen(*wp);
-	*(*wp)++ = L':';
-	if (wname != NULL) {
-		wcscpy(*wp, wname);
-		*wp += wcslen(*wp);
-	} else if (tag == ARCHIVE_ENTRY_ACL_USER
-	    || tag == ARCHIVE_ENTRY_ACL_GROUP) {
-		append_id_w(wp, id);
-		id = -1;
-	}
-	*(*wp)++ = L':';
-	*(*wp)++ = (perm & 0444) ? L'r' : L'-';
-	*(*wp)++ = (perm & 0222) ? L'w' : L'-';
-	*(*wp)++ = (perm & 0111) ? L'x' : L'-';
-	if (id != -1) {
-		*(*wp)++ = L':';
-		append_id_w(wp, id);
-	}
-	**wp = L'\0';
+	return (archive_acl_text_l(&entry->acl, flags, acl_text, len, sc));
 }
 
 /*
- * Parse a textual ACL.  This automatically recognizes and supports
- * extensions described above.  The 'type' argument is used to
- * indicate the type that should be used for any entries not
- * explicitly marked as "default:".
- */
-int
-__archive_entry_acl_parse_w(struct archive_entry *entry,
-    const wchar_t *text, int default_type)
-{
-	struct {
-		const wchar_t *start;
-		const wchar_t *end;
-	} field[4], name;
-
-	int fields, n;
-	int type, tag, permset, id;
-	wchar_t sep;
-
-	while (text != NULL  &&  *text != L'\0') {
-		/*
-		 * Parse the fields out of the next entry,
-		 * advance 'text' to start of next entry.
-		 */
-		fields = 0;
-		do {
-			const wchar_t *start, *end;
-			next_field_w(&text, &start, &end, &sep);
-			if (fields < 4) {
-				field[fields].start = start;
-				field[fields].end = end;
-			}
-			++fields;
-		} while (sep == L':');
-
-		/* Set remaining fields to blank. */
-		for (n = fields; n < 4; ++n)
-			field[n].start = field[n].end = NULL;
-
-		/* Check for a numeric ID in field 1 or 3. */
-		id = -1;
-		isint_w(field[1].start, field[1].end, &id);
-		/* Field 3 is optional. */
-		if (id == -1 && fields > 3)
-			isint_w(field[3].start, field[3].end, &id);
-
-		/*
-		 * Solaris extension:  "defaultuser::rwx" is the
-		 * default ACL corresponding to "user::rwx", etc.
-		 */
-		if (field[0].end - field[0].start > 7
-		    && wmemcmp(field[0].start, L"default", 7) == 0) {
-			type = ARCHIVE_ENTRY_ACL_TYPE_DEFAULT;
-			field[0].start += 7;
-		} else
-			type = default_type;
-
-		name.start = name.end = NULL;
-		if (prefix_w(field[0].start, field[0].end, L"user")) {
-			if (!ismode_w(field[2].start, field[2].end, &permset))
-				return (ARCHIVE_WARN);
-			if (id != -1 || field[1].start < field[1].end) {
-				tag = ARCHIVE_ENTRY_ACL_USER;
-				name = field[1];
-			} else
-				tag = ARCHIVE_ENTRY_ACL_USER_OBJ;
-		} else if (prefix_w(field[0].start, field[0].end, L"group")) {
-			if (!ismode_w(field[2].start, field[2].end, &permset))
-				return (ARCHIVE_WARN);
-			if (id != -1 || field[1].start < field[1].end) {
-				tag = ARCHIVE_ENTRY_ACL_GROUP;
-				name = field[1];
-			} else
-				tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
-		} else if (prefix_w(field[0].start, field[0].end, L"other")) {
-			if (fields == 2
-			    && field[1].start < field[1].end
-			    && ismode_w(field[1].start, field[1].end, &permset)) {
-				/* This is Solaris-style "other:rwx" */
-			} else if (fields == 3
-			    && field[1].start == field[1].end
-			    && field[2].start < field[2].end
-			    && ismode_w(field[2].start, field[2].end, &permset)) {
-				/* This is FreeBSD-style "other::rwx" */
-			} else
-				return (ARCHIVE_WARN);
-			tag = ARCHIVE_ENTRY_ACL_OTHER;
-		} else if (prefix_w(field[0].start, field[0].end, L"mask")) {
-			if (fields == 2
-			    && field[1].start < field[1].end
-			    && ismode_w(field[1].start, field[1].end, &permset)) {
-				/* This is Solaris-style "mask:rwx" */
-			} else if (fields == 3
-			    && field[1].start == field[1].end
-			    && field[2].start < field[2].end
-			    && ismode_w(field[2].start, field[2].end, &permset)) {
-				/* This is FreeBSD-style "mask::rwx" */
-			} else
-				return (ARCHIVE_WARN);
-			tag = ARCHIVE_ENTRY_ACL_MASK;
-		} else
-			return (ARCHIVE_WARN);
-
-		/* Add entry to the internal list. */
-		archive_entry_acl_add_entry_w_len(entry, type, permset,
-		    tag, id, name.start, name.end - name.start);
-	}
-	return (ARCHIVE_OK);
-}
-
-/*
- * Parse a string to a positive decimal integer.  Returns true if
- * the string is non-empty and consists only of decimal digits,
- * false otherwise.
- */
-static int
-isint_w(const wchar_t *start, const wchar_t *end, int *result)
-{
-	int n = 0;
-	if (start >= end)
-		return (0);
-	while (start < end) {
-		if (*start < '0' || *start > '9')
-			return (0);
-		if (n > (INT_MAX / 10))
-			n = INT_MAX;
-		else {
-			n *= 10;
-			n += *start - '0';
-		}
-		start++;
-	}
-	*result = n;
-	return (1);
-}
-
-/*
- * Parse a string as a mode field.  Returns true if
- * the string is non-empty and consists only of mode characters,
- * false otherwise.
- */
-static int
-ismode_w(const wchar_t *start, const wchar_t *end, int *permset)
-{
-	const wchar_t *p;
-
-	if (start >= end)
-		return (0);
-	p = start;
-	*permset = 0;
-	while (p < end) {
-		switch (*p++) {
-		case 'r': case 'R':
-			*permset |= ARCHIVE_ENTRY_ACL_READ;
-			break;
-		case 'w': case 'W':
-			*permset |= ARCHIVE_ENTRY_ACL_WRITE;
-			break;
-		case 'x': case 'X':
-			*permset |= ARCHIVE_ENTRY_ACL_EXECUTE;
-			break;
-		case '-':
-			break;
-		default:
-			return (0);
-		}
-	}
-	return (1);
-}
-
-/*
- * Match "[:whitespace:]*(.*)[:whitespace:]*[:,\n]".  *wp is updated
- * to point to just after the separator.  *start points to the first
- * character of the matched text and *end just after the last
- * character of the matched identifier.  In particular *end - *start
- * is the length of the field body, not including leading or trailing
- * whitespace.
- */
-static void
-next_field_w(const wchar_t **wp, const wchar_t **start,
-    const wchar_t **end, wchar_t *sep)
-{
-	/* Skip leading whitespace to find start of field. */
-	while (**wp == L' ' || **wp == L'\t' || **wp == L'\n') {
-		(*wp)++;
-	}
-	*start = *wp;
-
-	/* Scan for the separator. */
-	while (**wp != L'\0' && **wp != L',' && **wp != L':' &&
-	    **wp != L'\n') {
-		(*wp)++;
-	}
-	*sep = **wp;
-
-	/* Trim trailing whitespace to locate end of field. */
-	*end = *wp - 1;
-	while (**end == L' ' || **end == L'\t' || **end == L'\n') {
-		(*end)--;
-	}
-	(*end)++;
-
-	/* Adjust scanner location. */
-	if (**wp != L'\0')
-		(*wp)++;
-}
-
-/*
- * Return true if the characters [start...end) are a prefix of 'test'.
- * This makes it easy to handle the obvious abbreviations: 'u' for 'user', etc.
- */
-static int
-prefix_w(const wchar_t *start, const wchar_t *end, const wchar_t *test)
-{
-	if (start == end)
-		return (0);
-
-	if (*start++ != *test++)
-		return (0);
-
-	while (start < end  &&  *start++ == *test++)
-		;
-
-	if (start < end)
-		return (0);
-
-	return (1);
-}
-
-
-/*
  * Following code is modified from UC Berkeley sources, and
  * is subject to the following copyright notice.
  */
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_entry.h
--- a/head/contrib/libarchive/libarchive/archive_entry.h	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_entry.h	Fri Mar 02 16:54:40 2012 +0200
@@ -22,12 +22,15 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: head/contrib/libarchive/libarchive/archive_entry.h 228763 2011-12-21 11:13:29Z mm $
+ * $FreeBSD: head/contrib/libarchive/libarchive/archive_entry.h 232153 2012-02-25 10:58:02Z mm $
  */
 
 #ifndef ARCHIVE_ENTRY_H_INCLUDED
 #define	ARCHIVE_ENTRY_H_INCLUDED
 
+/* Note: Compiler will complain if this does not match archive.h! */
+#define	ARCHIVE_VERSION_NUMBER 3000003
+
 /*
  * Note: archive_entry.h is for use outside of libarchive; the
  * configuration headers (config.h, archive_platform.h, etc.) are
@@ -49,30 +52,31 @@
 #if defined(_WIN32) && !defined(__CYGWIN__)
 #define	__LA_INT64_T	__int64
 # if defined(__BORLANDC__)
-#  define	__LA_UID_T	uid_t
-#  define	__LA_GID_T	gid_t
+#  define	__LA_UID_T	uid_t  /* Remove in libarchive 3.2 */
+#  define	__LA_GID_T	gid_t  /* Remove in libarchive 3.2 */
 #  define	__LA_DEV_T	dev_t
 #  define	__LA_MODE_T	mode_t
 # else
-#  define	__LA_UID_T	short
-#  define	__LA_GID_T	short
+#  define	__LA_UID_T	short  /* Remove in libarchive 3.2 */
+#  define	__LA_GID_T	short  /* Remove in libarchive 3.2 */
 #  define	__LA_DEV_T	unsigned int
 #  define	__LA_MODE_T	unsigned short
 # endif
 #else
 #include <unistd.h>
-#define	__LA_INT64_T	int64_t
-#define	__LA_UID_T	uid_t
-#define	__LA_GID_T	gid_t
-#define	__LA_DEV_T	dev_t
-#define	__LA_MODE_T	mode_t
+# if defined(_SCO_DS)
+#  define	__LA_INT64_T	long long
+# else
+#  define	__LA_INT64_T	int64_t
+# endif
+# define	__LA_UID_T	uid_t /* Remove in libarchive 3.2 */
+# define	__LA_GID_T	gid_t /* Remove in libarchive 3.2 */
+# define	__LA_DEV_T	dev_t
+# define	__LA_MODE_T	mode_t
 #endif
 
 /*
- * XXX Is this defined for all Windows compilers?  If so, in what
- * header?  It would be nice to remove the __LA_INO_T indirection and
- * just use plain ino_t everywhere.  Likewise for the other types just
- * above.
+ * Remove this for libarchive 3.2, since ino_t is no longer used.
  */
 #define	__LA_INO_T	ino_t
 
@@ -91,7 +95,7 @@
 #  endif
 # else
 #  ifdef __GNUC__
-#   define __LA_DECL	__attribute__((dllimport)) extern
+#   define __LA_DECL
 #  else
 #   define __LA_DECL	__declspec(dllimport)
 #  endif
@@ -121,6 +125,7 @@
  * applications (e.g., a package manager could attach special
  * package-management attributes to each entry).
  */
+struct archive;
 struct archive_entry;
 
 /*
@@ -164,6 +169,15 @@
 __LA_DECL struct archive_entry	*archive_entry_new(void);
 
 /*
+ * This form of archive_entry_new2() will pull character-set
+ * conversion information from the specified archive handle.  The
+ * older archive_entry_new(void) form is equivalent to calling
+ * archive_entry_new2(NULL) and will result in the use of an internal
+ * default character-set conversion.
+ */
+__LA_DECL struct archive_entry	*archive_entry_new2(struct archive *);
+
+/*
  * Retrieve fields from an archive_entry.
  *
  * There are a number of implicit conversions among these fields.  For
@@ -192,6 +206,7 @@
 __LA_DECL long		 archive_entry_ctime_nsec(struct archive_entry *);
 __LA_DECL int		 archive_entry_ctime_is_set(struct archive_entry *);
 __LA_DECL dev_t		 archive_entry_dev(struct archive_entry *);
+__LA_DECL int		 archive_entry_dev_is_set(struct archive_entry *);
 __LA_DECL dev_t		 archive_entry_devmajor(struct archive_entry *);
 __LA_DECL dev_t		 archive_entry_devminor(struct archive_entry *);
 __LA_DECL __LA_MODE_T	 archive_entry_filetype(struct archive_entry *);
@@ -199,13 +214,14 @@
 			    unsigned long * /* set */,
 			    unsigned long * /* clear */);
 __LA_DECL const char	*archive_entry_fflags_text(struct archive_entry *);
-__LA_DECL __LA_GID_T	 archive_entry_gid(struct archive_entry *);
+__LA_DECL __LA_INT64_T	 archive_entry_gid(struct archive_entry *);
 __LA_DECL const char	*archive_entry_gname(struct archive_entry *);
 __LA_DECL const wchar_t	*archive_entry_gname_w(struct archive_entry *);
 __LA_DECL const char	*archive_entry_hardlink(struct archive_entry *);
 __LA_DECL const wchar_t	*archive_entry_hardlink_w(struct archive_entry *);
-__LA_DECL __LA_INO_T	 archive_entry_ino(struct archive_entry *);
+__LA_DECL __LA_INT64_T	 archive_entry_ino(struct archive_entry *);
 __LA_DECL __LA_INT64_T	 archive_entry_ino64(struct archive_entry *);
+__LA_DECL int		 archive_entry_ino_is_set(struct archive_entry *);
 __LA_DECL __LA_MODE_T	 archive_entry_mode(struct archive_entry *);
 __LA_DECL time_t	 archive_entry_mtime(struct archive_entry *);
 __LA_DECL long		 archive_entry_mtime_nsec(struct archive_entry *);
@@ -213,35 +229,34 @@
 __LA_DECL unsigned int	 archive_entry_nlink(struct archive_entry *);
 __LA_DECL const char	*archive_entry_pathname(struct archive_entry *);
 __LA_DECL const wchar_t	*archive_entry_pathname_w(struct archive_entry *);
+__LA_DECL __LA_MODE_T	 archive_entry_perm(struct archive_entry *);
 __LA_DECL dev_t		 archive_entry_rdev(struct archive_entry *);
 __LA_DECL dev_t		 archive_entry_rdevmajor(struct archive_entry *);
 __LA_DECL dev_t		 archive_entry_rdevminor(struct archive_entry *);
 __LA_DECL const char	*archive_entry_sourcepath(struct archive_entry *);
+__LA_DECL const wchar_t	*archive_entry_sourcepath_w(struct archive_entry *);
 __LA_DECL __LA_INT64_T	 archive_entry_size(struct archive_entry *);
 __LA_DECL int		 archive_entry_size_is_set(struct archive_entry *);
 __LA_DECL const char	*archive_entry_strmode(struct archive_entry *);
 __LA_DECL const char	*archive_entry_symlink(struct archive_entry *);
 __LA_DECL const wchar_t	*archive_entry_symlink_w(struct archive_entry *);
-__LA_DECL __LA_UID_T	 archive_entry_uid(struct archive_entry *);
+__LA_DECL __LA_INT64_T	 archive_entry_uid(struct archive_entry *);
 __LA_DECL const char	*archive_entry_uname(struct archive_entry *);
 __LA_DECL const wchar_t	*archive_entry_uname_w(struct archive_entry *);
 
 /*
  * Set fields in an archive_entry.
  *
- * Note that string 'set' functions do not copy the string, only the pointer.
- * In contrast, 'copy' functions do copy the object pointed to.
- *
- * Note: As of libarchive 2.4, 'set' functions do copy the string and
- * are therefore exact synonyms for the 'copy' versions.  The 'copy'
- * names will be retired in libarchive 3.0.
+ * Note: Before libarchive 2.4, there were 'set' and 'copy' versions
+ * of the string setters.  'copy' copied the actual string, 'set' just
+ * stored the pointer.  In libarchive 2.4 and later, strings are
+ * always copied.
  */
 
 __LA_DECL void	archive_entry_set_atime(struct archive_entry *, time_t, long);
 __LA_DECL void  archive_entry_unset_atime(struct archive_entry *);
 #if defined(_WIN32) && !defined(__CYGWIN__)
-__LA_DECL void archive_entry_copy_bhfi(struct archive_entry *,
-									   BY_HANDLE_FILE_INFORMATION *);
+__LA_DECL void archive_entry_copy_bhfi(struct archive_entry *, BY_HANDLE_FILE_INFORMATION *);
 #endif
 __LA_DECL void	archive_entry_set_birthtime(struct archive_entry *, time_t, long);
 __LA_DECL void  archive_entry_unset_birthtime(struct archive_entry *);
@@ -259,7 +274,7 @@
 	    const char *);
 __LA_DECL const wchar_t *archive_entry_copy_fflags_text_w(struct archive_entry *,
 	    const wchar_t *);
-__LA_DECL void	archive_entry_set_gid(struct archive_entry *, __LA_GID_T);
+__LA_DECL void	archive_entry_set_gid(struct archive_entry *, __LA_INT64_T);
 __LA_DECL void	archive_entry_set_gname(struct archive_entry *, const char *);
 __LA_DECL void	archive_entry_copy_gname(struct archive_entry *, const char *);
 __LA_DECL void	archive_entry_copy_gname_w(struct archive_entry *, const wchar_t *);
@@ -268,12 +283,7 @@
 __LA_DECL void	archive_entry_copy_hardlink(struct archive_entry *, const char *);
 __LA_DECL void	archive_entry_copy_hardlink_w(struct archive_entry *, const wchar_t *);
 __LA_DECL int	archive_entry_update_hardlink_utf8(struct archive_entry *, const char *);
-#if ARCHIVE_VERSION_NUMBER >= 3000000
-/* Starting with libarchive 3.0, this will be synonym for ino64. */
 __LA_DECL void	archive_entry_set_ino(struct archive_entry *, __LA_INT64_T);
-#else
-__LA_DECL void	archive_entry_set_ino(struct archive_entry *, unsigned long);
-#endif
 __LA_DECL void	archive_entry_set_ino64(struct archive_entry *, __LA_INT64_T);
 __LA_DECL void	archive_entry_set_link(struct archive_entry *, const char *);
 __LA_DECL void	archive_entry_copy_link(struct archive_entry *, const char *);
@@ -294,11 +304,12 @@
 __LA_DECL void	archive_entry_set_size(struct archive_entry *, __LA_INT64_T);
 __LA_DECL void	archive_entry_unset_size(struct archive_entry *);
 __LA_DECL void	archive_entry_copy_sourcepath(struct archive_entry *, const char *);
+__LA_DECL void	archive_entry_copy_sourcepath_w(struct archive_entry *, const wchar_t *);
 __LA_DECL void	archive_entry_set_symlink(struct archive_entry *, const char *);
 __LA_DECL void	archive_entry_copy_symlink(struct archive_entry *, const char *);
 __LA_DECL void	archive_entry_copy_symlink_w(struct archive_entry *, const wchar_t *);
 __LA_DECL int	archive_entry_update_symlink_utf8(struct archive_entry *, const char *);
-__LA_DECL void	archive_entry_set_uid(struct archive_entry *, __LA_UID_T);
+__LA_DECL void	archive_entry_set_uid(struct archive_entry *, __LA_INT64_T);
 __LA_DECL void	archive_entry_set_uname(struct archive_entry *, const char *);
 __LA_DECL void	archive_entry_copy_uname(struct archive_entry *, const char *);
 __LA_DECL void	archive_entry_copy_uname_w(struct archive_entry *, const wchar_t *);
@@ -315,6 +326,15 @@
 __LA_DECL const struct stat	*archive_entry_stat(struct archive_entry *);
 __LA_DECL void	archive_entry_copy_stat(struct archive_entry *, const struct stat *);
 
+/*
+ * Storage for Mac OS-specific AppleDouble metadata information.
+ * Apple-format tar files store a separate binary blob containing
+ * encoded metadata with ACL, extended attributes, etc.
+ * This provides a place to store that blob.
+ */
+
+__LA_DECL const void * archive_entry_mac_metadata(struct archive_entry *, size_t *);
+__LA_DECL void archive_entry_copy_mac_metadata(struct archive_entry *, const void *, size_t);
 
 /*
  * ACL routines.  This used to simply store and return text-format ACL
@@ -326,32 +346,95 @@
  *
  *  This last point, in particular, forces me to implement a reasonably
  *  complete set of ACL support routines.
- *
- *  TODO: Extend this to support NFSv4/NTFS permissions.  That should
- *  allow full ACL support on Mac OS, in particular, which uses
- *  POSIX.1e-style interfaces to manipulate NFSv4/NTFS permissions.
  */
 
 /*
- * Permission bits mimic POSIX.1e.  Note that I've not followed POSIX.1e's
- * "permset"/"perm" abstract type nonsense.  A permset is just a simple
- * bitmap, following long-standing Unix tradition.
+ * Permission bits.
  */
-#define	ARCHIVE_ENTRY_ACL_EXECUTE	1
-#define	ARCHIVE_ENTRY_ACL_WRITE		2
-#define	ARCHIVE_ENTRY_ACL_READ		4
+#define	ARCHIVE_ENTRY_ACL_EXECUTE             0x00000001
+#define	ARCHIVE_ENTRY_ACL_WRITE               0x00000002
+#define	ARCHIVE_ENTRY_ACL_READ                0x00000004
+#define	ARCHIVE_ENTRY_ACL_READ_DATA           0x00000008
+#define	ARCHIVE_ENTRY_ACL_LIST_DIRECTORY      0x00000008
+#define	ARCHIVE_ENTRY_ACL_WRITE_DATA          0x00000010
+#define	ARCHIVE_ENTRY_ACL_ADD_FILE            0x00000010
+#define	ARCHIVE_ENTRY_ACL_APPEND_DATA         0x00000020
+#define	ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY    0x00000020
+#define	ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS    0x00000040
+#define	ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS   0x00000080
+#define	ARCHIVE_ENTRY_ACL_DELETE_CHILD        0x00000100
+#define	ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES     0x00000200
+#define	ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES    0x00000400
+#define	ARCHIVE_ENTRY_ACL_DELETE              0x00000800
+#define	ARCHIVE_ENTRY_ACL_READ_ACL            0x00001000
+#define	ARCHIVE_ENTRY_ACL_WRITE_ACL           0x00002000
+#define	ARCHIVE_ENTRY_ACL_WRITE_OWNER         0x00004000
+#define	ARCHIVE_ENTRY_ACL_SYNCHRONIZE         0x00008000
 
-/* We need to be able to specify either or both of these. */
-#define	ARCHIVE_ENTRY_ACL_TYPE_ACCESS	256
-#define	ARCHIVE_ENTRY_ACL_TYPE_DEFAULT	512
+#define	ARCHIVE_ENTRY_ACL_PERMS_POSIX1E			\
+	(ARCHIVE_ENTRY_ACL_EXECUTE			\
+	    | ARCHIVE_ENTRY_ACL_WRITE			\
+	    | ARCHIVE_ENTRY_ACL_READ)
+
+#define ARCHIVE_ENTRY_ACL_PERMS_NFS4			\
+	(ARCHIVE_ENTRY_ACL_EXECUTE			\
+	    | ARCHIVE_ENTRY_ACL_READ_DATA		\
+	    | ARCHIVE_ENTRY_ACL_LIST_DIRECTORY 		\
+	    | ARCHIVE_ENTRY_ACL_WRITE_DATA		\
+	    | ARCHIVE_ENTRY_ACL_ADD_FILE		\
+	    | ARCHIVE_ENTRY_ACL_APPEND_DATA		\
+	    | ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY	\
+	    | ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS	\
+	    | ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS	\
+	    | ARCHIVE_ENTRY_ACL_DELETE_CHILD		\
+	    | ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES		\
+	    | ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES	\
+	    | ARCHIVE_ENTRY_ACL_DELETE			\
+	    | ARCHIVE_ENTRY_ACL_READ_ACL		\
+	    | ARCHIVE_ENTRY_ACL_WRITE_ACL		\
+	    | ARCHIVE_ENTRY_ACL_WRITE_OWNER		\
+	    | ARCHIVE_ENTRY_ACL_SYNCHRONIZE)
+
+/*
+ * Inheritance values (NFS4 ACLs only); included in permset.
+ */
+#define	ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT                0x02000000
+#define	ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT           0x04000000
+#define	ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT        0x08000000
+#define	ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY                0x10000000
+#define	ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS           0x20000000
+#define	ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS               0x40000000
+
+#define	ARCHIVE_ENTRY_ACL_INHERITANCE_NFS4			\
+	(ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT			\
+	    | ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT		\
+	    | ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT	\
+	    | ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY		\
+	    | ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS		\
+	    | ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS)
+
+/* We need to be able to specify combinations of these. */
+#define	ARCHIVE_ENTRY_ACL_TYPE_ACCESS	256  /* POSIX.1e only */
+#define	ARCHIVE_ENTRY_ACL_TYPE_DEFAULT	512  /* POSIX.1e only */
+#define	ARCHIVE_ENTRY_ACL_TYPE_ALLOW	1024 /* NFS4 only */
+#define	ARCHIVE_ENTRY_ACL_TYPE_DENY	2048 /* NFS4 only */
+#define	ARCHIVE_ENTRY_ACL_TYPE_AUDIT	4096 /* NFS4 only */
+#define	ARCHIVE_ENTRY_ACL_TYPE_ALARM	8192 /* NFS4 only */
+#define	ARCHIVE_ENTRY_ACL_TYPE_POSIX1E	(ARCHIVE_ENTRY_ACL_TYPE_ACCESS \
+	    | ARCHIVE_ENTRY_ACL_TYPE_DEFAULT)
+#define	ARCHIVE_ENTRY_ACL_TYPE_NFS4	(ARCHIVE_ENTRY_ACL_TYPE_ALLOW \
+	    | ARCHIVE_ENTRY_ACL_TYPE_DENY \
+	    | ARCHIVE_ENTRY_ACL_TYPE_AUDIT \
+	    | ARCHIVE_ENTRY_ACL_TYPE_ALARM)
 
 /* Tag values mimic POSIX.1e */
 #define	ARCHIVE_ENTRY_ACL_USER		10001	/* Specified user. */
 #define	ARCHIVE_ENTRY_ACL_USER_OBJ 	10002	/* User who owns the file. */
 #define	ARCHIVE_ENTRY_ACL_GROUP		10003	/* Specified group. */
 #define	ARCHIVE_ENTRY_ACL_GROUP_OBJ	10004	/* Group who owns the file. */
-#define	ARCHIVE_ENTRY_ACL_MASK		10005	/* Modify group access. */
-#define	ARCHIVE_ENTRY_ACL_OTHER		10006	/* Public. */
+#define	ARCHIVE_ENTRY_ACL_MASK		10005	/* Modify group access (POSIX.1e only) */
+#define	ARCHIVE_ENTRY_ACL_OTHER		10006	/* Public (POSIX.1e only) */
+#define	ARCHIVE_ENTRY_ACL_EVERYONE	10107   /* Everyone (NFS4 only) */
 
 /*
  * Set the ACL by clearing it and adding entries one at a time.
@@ -363,17 +446,17 @@
  * default and access information in a single ACL list.
  */
 __LA_DECL void	 archive_entry_acl_clear(struct archive_entry *);
-__LA_DECL void	 archive_entry_acl_add_entry(struct archive_entry *,
+__LA_DECL int	 archive_entry_acl_add_entry(struct archive_entry *,
 	    int /* type */, int /* permset */, int /* tag */,
 	    int /* qual */, const char * /* name */);
-__LA_DECL void	 archive_entry_acl_add_entry_w(struct archive_entry *,
+__LA_DECL int	 archive_entry_acl_add_entry_w(struct archive_entry *,
 	    int /* type */, int /* permset */, int /* tag */,
 	    int /* qual */, const wchar_t * /* name */);
 
 /*
  * To retrieve the ACL, first "reset", then repeatedly ask for the
  * "next" entry.  The want_type parameter allows you to request only
- * access entries or only default entries.
+ * certain types of entries.
  */
 __LA_DECL int	 archive_entry_acl_reset(struct archive_entry *, int /* want_type */);
 __LA_DECL int	 archive_entry_acl_next(struct archive_entry *, int /* want_type */,
@@ -387,36 +470,29 @@
  * Construct a text-format ACL.  The flags argument is a bitmask that
  * can include any of the following:
  *
- * ARCHIVE_ENTRY_ACL_TYPE_ACCESS - Include access entries.
- * ARCHIVE_ENTRY_ACL_TYPE_DEFAULT - Include default entries.
+ * ARCHIVE_ENTRY_ACL_TYPE_ACCESS - Include POSIX.1e "access" entries.
+ * ARCHIVE_ENTRY_ACL_TYPE_DEFAULT - Include POSIX.1e "default" entries.
+ * ARCHIVE_ENTRY_ACL_TYPE_NFS4 - Include NFS4 entries.
  * ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID - Include extra numeric ID field in
- *    each ACL entry.  (As used by 'star'.)
+ *    each ACL entry.  ('star' introduced this for POSIX.1e, this flag
+ *    also applies to NFS4.)
  * ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT - Include "default:" before each
- *    default ACL entry.
+ *    default ACL entry, as used in old Solaris ACLs.
  */
 #define	ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID	1024
 #define	ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT	2048
 __LA_DECL const wchar_t	*archive_entry_acl_text_w(struct archive_entry *,
 		    int /* flags */);
+__LA_DECL const char *archive_entry_acl_text(struct archive_entry *,
+		    int /* flags */);
 
 /* Return a count of entries matching 'want_type' */
 __LA_DECL int	 archive_entry_acl_count(struct archive_entry *, int /* want_type */);
 
-/*
- * Private ACL parser.  This is private because it handles some
- * very weird formats that clients should not be messing with.
- * Clients should only deal with their platform-native formats.
- * Because of the need to support many formats cleanly, new arguments
- * are likely to get added on a regular basis.  Clients who try to use
- * this interface are likely to be surprised when it changes.
- *
- * You were warned!
- *
- * TODO: Move this declaration out of the public header and into
- * a private header.  Warnings above are silly.
- */
-__LA_DECL int		 __archive_entry_acl_parse_w(struct archive_entry *,
-		    const wchar_t *, int /* type */);
+/* Return an opaque ACL object. */
+/* There's not yet anything clients can actually do with this... */
+struct archive_acl;
+__LA_DECL struct archive_acl *archive_entry_acl(struct archive_entry *);
 
 /*
  * extended attributes
@@ -438,6 +514,24 @@
 	    const char ** /* name */, const void ** /* value */, size_t *);
 
 /*
+ * sparse
+ */
+
+__LA_DECL void	 archive_entry_sparse_clear(struct archive_entry *);
+__LA_DECL void	 archive_entry_sparse_add_entry(struct archive_entry *,
+	    __LA_INT64_T /* offset */, __LA_INT64_T /* length */);
+
+/*
+ * To retrieve the xattr list, first "reset", then repeatedly ask for the
+ * "next" entry.
+ */
+
+__LA_DECL int	archive_entry_sparse_count(struct archive_entry *);
+__LA_DECL int	archive_entry_sparse_reset(struct archive_entry *);
+__LA_DECL int	archive_entry_sparse_next(struct archive_entry *,
+	    __LA_INT64_T * /* offset */, __LA_INT64_T * /* length */);
+
+/*
  * Utility to match up hardlinks.
  *
  * The 'struct archive_entry_linkresolver' is a cache of archive entries
@@ -449,7 +543,7 @@
  *      be written.
  *   4. Call archive_entry_linkify(resolver, NULL) until
  *      no more entries are returned.
- *   5. Call archive_entry_link_resolver_free(resolver) to free resources.
+ *   5. Call archive_entry_linkresolver_free(resolver) to free resources.
  *
  * The entries returned have their hardlink and size fields updated
  * appropriately.  If an entry is passed in that does not refer to
@@ -499,7 +593,7 @@
  *           linkify(l2) => l1
  *           linkify(NULL) => l2   (at end, you retrieve remaining links)
  *    As the name suggests, this strategy is used by newer cpio variants.
- *    It's noticably more complex for the archiver, slightly more complex
+ *    It's noticeably more complex for the archiver, slightly more complex
  *    for the dearchiver than the tar strategy, but makes it straightforward
  *    to restore a file using any link by simply continuing to scan until
  *    you see a link that is stored with a body.  In contrast, the tar
@@ -513,6 +607,8 @@
 __LA_DECL void archive_entry_linkresolver_free(struct archive_entry_linkresolver *);
 __LA_DECL void archive_entry_linkify(struct archive_entry_linkresolver *,
     struct archive_entry **, struct archive_entry **);
+__LA_DECL struct archive_entry *archive_entry_partial_links(
+    struct archive_entry_linkresolver *res, unsigned int *links);
 
 #ifdef __cplusplus
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_entry_copy_stat.c
--- a/head/contrib/libarchive/libarchive/archive_entry_copy_stat.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_entry_copy_stat.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,12 +24,13 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_entry_copy_stat.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_entry_copy_stat.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
 #endif
 
+#include "archive.h"
 #include "archive_entry.h"
 
 void
@@ -59,12 +60,13 @@
 	archive_entry_set_atime(entry, st->st_atime, 0);
 	archive_entry_set_ctime(entry, st->st_ctime, 0);
 	archive_entry_set_mtime(entry, st->st_mtime, 0);
-#if HAVE_STRUCT_STAT_ST_BIRTHTIME
-	archive_entry_set_birthtime(entry, st->st_birthtime, 0);
-#endif
 #endif
 #if HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC
 	archive_entry_set_birthtime(entry, st->st_birthtime, st->st_birthtimespec.tv_nsec);
+#elif HAVE_STRUCT_STAT_ST_BIRTHTIME
+	archive_entry_set_birthtime(entry, st->st_birthtime, 0);
+#else
+	archive_entry_unset_birthtime(entry);
 #endif
 	archive_entry_set_dev(entry, st->st_dev);
 	archive_entry_set_gid(entry, st->st_gid);
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_entry_link_resolver.c
--- a/head/contrib/libarchive/libarchive/archive_entry_link_resolver.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_entry_link_resolver.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_entry_link_resolver.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_entry_link_resolver.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
@@ -70,10 +70,10 @@
 struct links_entry {
 	struct links_entry	*next;
 	struct links_entry	*previous;
-	int			 links; /* # links not yet seen */
-	int			 hash;
 	struct archive_entry	*canonical;
 	struct archive_entry	*entry;
+	size_t			 hash;
+	unsigned int		 links; /* # links not yet seen */
 };
 
 struct archive_entry_linkresolver {
@@ -84,32 +84,37 @@
 	int			  strategy;
 };
 
+#define	NEXT_ENTRY_DEFERRED	1
+#define	NEXT_ENTRY_PARTIAL	2
+#define	NEXT_ENTRY_ALL		(NEXT_ENTRY_DEFERRED | NEXT_ENTRY_PARTIAL)
+
 static struct links_entry *find_entry(struct archive_entry_linkresolver *,
 		    struct archive_entry *);
 static void grow_hash(struct archive_entry_linkresolver *);
 static struct links_entry *insert_entry(struct archive_entry_linkresolver *,
 		    struct archive_entry *);
-static struct links_entry *next_entry(struct archive_entry_linkresolver *);
+static struct links_entry *next_entry(struct archive_entry_linkresolver *,
+    int);
 
 struct archive_entry_linkresolver *
 archive_entry_linkresolver_new(void)
 {
 	struct archive_entry_linkresolver *res;
-	size_t i;
 
-	res = malloc(sizeof(struct archive_entry_linkresolver));
+	/* Check for positive power-of-two */
+	if (links_cache_initial_size == 0 ||
+	    (links_cache_initial_size & (links_cache_initial_size - 1)) != 0)
+		return (NULL);
+
+	res = calloc(1, sizeof(struct archive_entry_linkresolver));
 	if (res == NULL)
 		return (NULL);
-	memset(res, 0, sizeof(struct archive_entry_linkresolver));
 	res->number_buckets = links_cache_initial_size;
-	res->buckets = malloc(res->number_buckets *
-	    sizeof(res->buckets[0]));
+	res->buckets = calloc(res->number_buckets, sizeof(res->buckets[0]));
 	if (res->buckets == NULL) {
 		free(res);
 		return (NULL);
 	}
-	for (i = 0; i < res->number_buckets; i++)
-		res->buckets[i] = NULL;
 	return (res);
 }
 
@@ -120,6 +125,11 @@
 	int fmtbase = fmt & ARCHIVE_FORMAT_BASE_MASK;
 
 	switch (fmtbase) {
+	case ARCHIVE_FORMAT_7ZIP:
+	case ARCHIVE_FORMAT_AR:
+	case ARCHIVE_FORMAT_ZIP:
+		res->strategy = ARCHIVE_ENTRY_LINKIFY_LIKE_OLD_CPIO;
+		break;
 	case ARCHIVE_FORMAT_CPIO:
 		switch (fmt) {
 		case ARCHIVE_FORMAT_CPIO_SVR4_NOCRC:
@@ -134,11 +144,14 @@
 	case ARCHIVE_FORMAT_MTREE:
 		res->strategy = ARCHIVE_ENTRY_LINKIFY_LIKE_MTREE;
 		break;
+	case ARCHIVE_FORMAT_ISO9660:
+	case ARCHIVE_FORMAT_SHAR:
 	case ARCHIVE_FORMAT_TAR:
+	case ARCHIVE_FORMAT_XAR:
 		res->strategy = ARCHIVE_ENTRY_LINKIFY_LIKE_TAR;
 		break;
 	default:
-		res->strategy = ARCHIVE_ENTRY_LINKIFY_LIKE_TAR;
+		res->strategy = ARCHIVE_ENTRY_LINKIFY_LIKE_OLD_CPIO;
 		break;
 	}
 }
@@ -151,12 +164,9 @@
 	if (res == NULL)
 		return;
 
-	if (res->buckets != NULL) {
-		while ((le = next_entry(res)) != NULL)
-			archive_entry_free(le->entry);
-		free(res->buckets);
-		res->buckets = NULL;
-	}
+	while ((le = next_entry(res, NEXT_ENTRY_ALL)) != NULL)
+		archive_entry_free(le->entry);
+	free(res->buckets);
 	free(res);
 }
 
@@ -170,7 +180,7 @@
 	*f = NULL; /* Default: Don't return a second entry. */
 
 	if (*e == NULL) {
-		le = next_entry(res);
+		le = next_entry(res, NEXT_ENTRY_DEFERRED);
 		if (le != NULL) {
 			*e = le->entry;
 			le->entry = NULL;
@@ -249,7 +259,7 @@
     struct archive_entry *entry)
 {
 	struct links_entry	*le;
-	int			 hash, bucket;
+	size_t			 hash, bucket;
 	dev_t			 dev;
 	int64_t			 ino;
 
@@ -261,16 +271,12 @@
 		res->spare = NULL;
 	}
 
-	/* If the links cache overflowed and got flushed, don't bother. */
-	if (res->buckets == NULL)
-		return (NULL);
-
 	dev = archive_entry_dev(entry);
 	ino = archive_entry_ino64(entry);
-	hash = (int)(dev ^ ino);
+	hash = (size_t)(dev ^ ino);
 
 	/* Try to locate this entry in the links cache. */
-	bucket = hash % res->number_buckets;
+	bucket = hash & (res->number_buckets - 1);
 	for (le = res->buckets[bucket]; le != NULL; le = le->next) {
 		if (le->hash == hash
 		    && dev == archive_entry_dev(le->canonical)
@@ -301,7 +307,7 @@
 }
 
 static struct links_entry *
-next_entry(struct archive_entry_linkresolver *res)
+next_entry(struct archive_entry_linkresolver *res, int mode)
 {
 	struct links_entry	*le;
 	size_t			 bucket;
@@ -309,22 +315,27 @@
 	/* Free a held entry. */
 	if (res->spare != NULL) {
 		archive_entry_free(res->spare->canonical);
+		archive_entry_free(res->spare->entry);
 		free(res->spare);
 		res->spare = NULL;
 	}
 
-	/* If the links cache overflowed and got flushed, don't bother. */
-	if (res->buckets == NULL)
-		return (NULL);
-
 	/* Look for next non-empty bucket in the links cache. */
 	for (bucket = 0; bucket < res->number_buckets; bucket++) {
-		le = res->buckets[bucket];
-		if (le != NULL) {
+		for (le = res->buckets[bucket]; le != NULL; le = le->next) {
+			if (le->entry != NULL &&
+			    (mode & NEXT_ENTRY_DEFERRED) == 0)
+				continue;
+			if (le->entry == NULL &&
+			    (mode & NEXT_ENTRY_PARTIAL) == 0)
+				continue;
 			/* Remove it from this hash bucket. */
 			if (le->next != NULL)
 				le->next->previous = le->previous;
-			res->buckets[bucket] = le->next;
+			if (le->previous != NULL)
+				le->previous->next = le->next;
+			else
+				res->buckets[bucket] = le->next;
 			res->number_entries--;
 			/* Defer freeing this entry. */
 			res->spare = le;
@@ -339,13 +350,12 @@
     struct archive_entry *entry)
 {
 	struct links_entry *le;
-	int			 hash, bucket;
+	size_t hash, bucket;
 
 	/* Add this entry to the links cache. */
-	le = malloc(sizeof(struct links_entry));
+	le = calloc(1, sizeof(struct links_entry));
 	if (le == NULL)
 		return (NULL);
-	memset(le, 0, sizeof(*le));
 	le->canonical = archive_entry_clone(entry);
 
 	/* If the links cache is getting too full, enlarge the hash table. */
@@ -353,7 +363,7 @@
 		grow_hash(res);
 
 	hash = archive_entry_dev(entry) ^ archive_entry_ino64(entry);
-	bucket = hash % res->number_buckets;
+	bucket = hash & (res->number_buckets - 1);
 
 	/* If we could allocate the entry, record it. */
 	if (res->buckets[bucket] != NULL)
@@ -376,30 +386,59 @@
 
 	/* Try to enlarge the bucket list. */
 	new_size = res->number_buckets * 2;
-	new_buckets = malloc(new_size * sizeof(struct links_entry *));
+	if (new_size < res->number_buckets)
+		return;
+	new_buckets = calloc(new_size, sizeof(struct links_entry *));
 
-	if (new_buckets != NULL) {
-		memset(new_buckets, 0,
-		    new_size * sizeof(struct links_entry *));
-		for (i = 0; i < res->number_buckets; i++) {
-			while (res->buckets[i] != NULL) {
-				/* Remove entry from old bucket. */
-				le = res->buckets[i];
-				res->buckets[i] = le->next;
+	if (new_buckets == NULL)
+		return;
 
-				/* Add entry to new bucket. */
-				bucket = le->hash % new_size;
+	for (i = 0; i < res->number_buckets; i++) {
+		while (res->buckets[i] != NULL) {
+			/* Remove entry from old bucket. */
+			le = res->buckets[i];
+			res->buckets[i] = le->next;
 
-				if (new_buckets[bucket] != NULL)
-					new_buckets[bucket]->previous =
-					    le;
-				le->next = new_buckets[bucket];
-				le->previous = NULL;
-				new_buckets[bucket] = le;
-			}
+			/* Add entry to new bucket. */
+			bucket = le->hash & (new_size - 1);
+
+			if (new_buckets[bucket] != NULL)
+				new_buckets[bucket]->previous = le;
+			le->next = new_buckets[bucket];
+			le->previous = NULL;
+			new_buckets[bucket] = le;
 		}
-		free(res->buckets);
-		res->buckets = new_buckets;
-		res->number_buckets = new_size;
 	}
+	free(res->buckets);
+	res->buckets = new_buckets;
+	res->number_buckets = new_size;
 }
+
+struct archive_entry *
+archive_entry_partial_links(struct archive_entry_linkresolver *res,
+    unsigned int *links)
+{
+	struct archive_entry	*e;
+	struct links_entry	*le;
+
+	/* Free a held entry. */
+	if (res->spare != NULL) {
+		archive_entry_free(res->spare->canonical);
+		archive_entry_free(res->spare->entry);
+		free(res->spare);
+		res->spare = NULL;
+	}
+
+	le = next_entry(res, NEXT_ENTRY_PARTIAL);
+	if (le != NULL) {
+		e = le->canonical;
+		if (links != NULL)
+			*links = le->links;
+		le->canonical = NULL;
+	} else {
+		e = NULL;
+		if (links != NULL)
+			*links = 0;
+	}
+	return (e);
+}
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_entry_private.h
--- a/head/contrib/libarchive/libarchive/archive_entry_private.h	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_entry_private.h	Fri Mar 02 16:54:40 2012 +0200
@@ -22,7 +22,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: head/contrib/libarchive/libarchive/archive_entry_private.h 228763 2011-12-21 11:13:29Z mm $
+ * $FreeBSD: head/contrib/libarchive/libarchive/archive_entry_private.h 232153 2012-02-25 10:58:02Z mm $
  */
 
 #ifndef __LIBARCHIVE_BUILD
@@ -32,36 +32,9 @@
 #ifndef ARCHIVE_ENTRY_PRIVATE_H_INCLUDED
 #define	ARCHIVE_ENTRY_PRIVATE_H_INCLUDED
 
+#include "archive_acl_private.h"
 #include "archive_string.h"
 
-/*
- * Handle wide character (i.e., Unicode) and non-wide character
- * strings transparently.
- */
-
-struct aes {
-	struct archive_string aes_mbs;
-	struct archive_string aes_utf8;
-	const wchar_t *aes_wcs;
-	/* Bitmap of which of the above are valid.  Because we're lazy
-	 * about malloc-ing and reusing the underlying storage, we
-	 * can't rely on NULL pointers to indicate whether a string
-	 * has been set. */
-	int aes_set;
-#define	AES_SET_MBS 1
-#define	AES_SET_UTF8 2
-#define	AES_SET_WCS 4
-};
-
-struct ae_acl {
-	struct ae_acl *next;
-	int	type;			/* E.g., access or default */
-	int	tag;			/* E.g., user/group/other/mask */
-	int	permset;		/* r/w/x bits */
-	int	id;			/* uid/gid for user/group */
-	struct aes name;		/* uname/gname */
-};
-
 struct ae_xattr {
 	struct ae_xattr *next;
 
@@ -70,6 +43,13 @@
 	size_t	size;
 };
 
+struct ae_sparse {
+	struct ae_sparse *next;
+
+	int64_t	 offset;
+	int64_t	 length;
+};
+
 /*
  * Description of an archive entry.
  *
@@ -91,6 +71,8 @@
  * TODO: Design a good API for handling sparse files.
  */
 struct archive_entry {
+	struct archive *archive;
+
 	/*
 	 * Note that ae_stat.st_mode & AE_IFMT  can be  0!
 	 *
@@ -101,10 +83,15 @@
 	 */
 
 	/*
-	 * Read archive_entry_copy_stat.c for an explanation of why I
-	 * don't just use "struct stat" instead of "struct aest" here
-	 * and why I have this odd pointer to a separately-allocated
-	 * struct stat.
+	 * We have a "struct aest" for holding file metadata rather than just
+	 * a "struct stat" because on some platforms the "struct stat" has
+	 * fields which are too narrow to hold the range of possible values;
+	 * we don't want to lose information if we read an archive and write
+	 * out another (e.g., in "tar -cf new.tar @old.tar").
+	 *
+	 * The "stat" pointer points to some form of platform-specific struct
+	 * stat; it is declared as a void * rather than a struct stat * as
+	 * some platforms have multiple varieties of stat structures.
 	 */
 	void *stat;
 	int  stat_valid; /* Set to 0 whenever a field in aest changes. */
@@ -118,12 +105,11 @@
 		uint32_t	aest_mtime_nsec;
 		int64_t		aest_birthtime;
 		uint32_t	aest_birthtime_nsec;
-		gid_t		aest_gid;
+		int64_t		aest_gid;
 		int64_t		aest_ino;
-		mode_t		aest_mode;
 		uint32_t	aest_nlink;
 		uint64_t	aest_size;
-		uid_t		aest_uid;
+		int64_t		aest_uid;
 		/*
 		 * Because converting between device codes and
 		 * major/minor values is platform-specific and
@@ -150,35 +136,41 @@
 #define	AE_SET_MTIME	16
 #define	AE_SET_BIRTHTIME 32
 #define	AE_SET_SIZE	64
+#define	AE_SET_INO	128
+#define	AE_SET_DEV	256
 
 	/*
 	 * Use aes here so that we get transparent mbs<->wcs conversions.
 	 */
-	struct aes ae_fflags_text;	/* Text fflags per fflagstostr(3) */
+	struct archive_mstring ae_fflags_text;	/* Text fflags per fflagstostr(3) */
 	unsigned long ae_fflags_set;		/* Bitmap fflags */
 	unsigned long ae_fflags_clear;
-	struct aes ae_gname;		/* Name of owning group */
-	struct aes ae_hardlink;	/* Name of target for hardlink */
-	struct aes ae_pathname;	/* Name of entry */
-	struct aes ae_symlink;		/* symlink contents */
-	struct aes ae_uname;		/* Name of owner */
+	struct archive_mstring ae_gname;		/* Name of owning group */
+	struct archive_mstring ae_hardlink;	/* Name of target for hardlink */
+	struct archive_mstring ae_pathname;	/* Name of entry */
+	struct archive_mstring ae_symlink;		/* symlink contents */
+	struct archive_mstring ae_uname;		/* Name of owner */
 
 	/* Not used within libarchive; useful for some clients. */
-	struct aes ae_sourcepath;	/* Path this entry is sourced from. */
+	struct archive_mstring ae_sourcepath;	/* Path this entry is sourced from. */
+
+	void *mac_metadata;
+	size_t mac_metadata_size;
 
 	/* ACL support. */
-	struct ae_acl	*acl_head;
-	struct ae_acl	*acl_p;
-	int		 acl_state;	/* See acl_next for details. */
-	wchar_t		*acl_text_w;
+	struct archive_acl    acl;
 
 	/* extattr support. */
 	struct ae_xattr *xattr_head;
 	struct ae_xattr *xattr_p;
 
+	/* sparse support. */
+	struct ae_sparse *sparse_head;
+	struct ae_sparse *sparse_tail;
+	struct ae_sparse *sparse_p;
+
 	/* Miscellaneous. */
 	char		 strmode[12];
 };
 
-
 #endif /* ARCHIVE_ENTRY_PRIVATE_H_INCLUDED */
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_entry_stat.c
--- a/head/contrib/libarchive/libarchive/archive_entry_stat.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_entry_stat.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_entry_stat.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_entry_stat.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
@@ -41,7 +41,7 @@
 {
 	struct stat *st;
 	if (entry->stat == NULL) {
-		entry->stat = malloc(sizeof(*st));
+		entry->stat = calloc(1, sizeof(*st));
 		if (entry->stat == NULL)
 			return (NULL);
 		entry->stat_valid = 0;
@@ -110,7 +110,7 @@
 	/*
 	 * TODO: On Linux, store 32 or 64 here depending on whether
 	 * the cached stat structure is a stat32 or a stat64.  This
-	 * will allow us to support both variants interchangably.
+	 * will allow us to support both variants interchangeably.
 	 */
 	entry->stat_valid = 1;
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_private.h
--- a/head/contrib/libarchive/libarchive/archive_private.h	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_private.h	Fri Mar 02 16:54:40 2012 +0200
@@ -22,7 +22,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: head/contrib/libarchive/libarchive/archive_private.h 228773 2011-12-21 15:18:52Z mm $
+ * $FreeBSD: head/contrib/libarchive/libarchive/archive_private.h 232153 2012-02-25 10:58:02Z mm $
  */
 
 #ifndef __LIBARCHIVE_BUILD
@@ -32,6 +32,10 @@
 #ifndef ARCHIVE_PRIVATE_H_INCLUDED
 #define	ARCHIVE_PRIVATE_H_INCLUDED
 
+#if HAVE_ICONV_H
+#include <iconv.h>
+#endif
+
 #include "archive.h"
 #include "archive_string.h"
 
@@ -47,14 +51,13 @@
 #define	ARCHIVE_WRITE_DISK_MAGIC (0xc001b0c5U)
 #define	ARCHIVE_READ_DISK_MAGIC (0xbadb0c5U)
 
-#define	ARCHIVE_STATE_ANY	0xFFFFU
 #define	ARCHIVE_STATE_NEW	1U
 #define	ARCHIVE_STATE_HEADER	2U
 #define	ARCHIVE_STATE_DATA	4U
-#define	ARCHIVE_STATE_DATA_END	8U
 #define	ARCHIVE_STATE_EOF	0x10U
 #define	ARCHIVE_STATE_CLOSED	0x20U
 #define	ARCHIVE_STATE_FATAL	0x8000U
+#define	ARCHIVE_STATE_ANY	(0xFFFFU & ~ARCHIVE_STATE_FATAL)
 
 struct archive_vtable {
 	int	(*archive_close)(struct archive *);
@@ -65,9 +68,23 @@
 	ssize_t	(*archive_write_data)(struct archive *,
 	    const void *, size_t);
 	ssize_t	(*archive_write_data_block)(struct archive *,
-	    const void *, size_t, off_t);
+	    const void *, size_t, int64_t);
+
+	int	(*archive_read_next_header)(struct archive *,
+	    struct archive_entry **);
+	int	(*archive_read_next_header2)(struct archive *,
+	    struct archive_entry *);
+	int	(*archive_read_data_block)(struct archive *,
+	    const void **, size_t *, int64_t *);
+
+	int	(*archive_filter_count)(struct archive *);
+	int64_t (*archive_filter_bytes)(struct archive *, int);
+	int	(*archive_filter_code)(struct archive *, int);
+	const char * (*archive_filter_name)(struct archive *, int);
 };
 
+struct archive_string_conv;
+
 struct archive {
 	/*
 	 * The magic/state values are used to sanity-check the
@@ -90,26 +107,35 @@
 	int	  compression_code;	/* Currently active compression. */
 	const char *compression_name;
 
-	/* Position in UNCOMPRESSED data stream. */
-	int64_t		  file_position;
-	/* Position in COMPRESSED data stream. */
-	int64_t		  raw_position;
 	/* Number of file entries processed. */
 	int		  file_count;
 
 	int		  archive_error_number;
 	const char	 *error;
 	struct archive_string	error_string;
+
+	char *current_code;
+	unsigned current_codepage; /* Current ACP(ANSI CodePage). */
+	unsigned current_oemcp; /* Current OEMCP(OEM CodePage). */
+	struct archive_string_conv *sconv;
 };
 
-/* Check magic value and state; exit if it isn't valid. */
-void	__archive_check_magic(struct archive *, unsigned int magic,
+/* Check magic value and state; return(ARCHIVE_FATAL) if it isn't valid. */
+int	__archive_check_magic(struct archive *, unsigned int magic,
 	    unsigned int state, const char *func);
+#define	archive_check_magic(a, expected_magic, allowed_states, function_name) \
+	do { \
+		int magic_test = __archive_check_magic((a), (expected_magic), \
+			(allowed_states), (function_name)); \
+		if (magic_test == ARCHIVE_FATAL) \
+			return ARCHIVE_FATAL; \
+	} while (0)
 
 void	__archive_errx(int retvalue, const char *msg) __LA_DEAD;
 
-int	__archive_parse_options(const char *p, const char *fn,
-	    int keysize, char *key, int valsize, char *val);
+int	__archive_mktemp(const char *tmpdir);
+
+int	__archive_clean(struct archive *);
 
 #define	err_combine(a,b)	((a) < (b) ? (a) : (b))
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_read.3
--- a/head/contrib/libarchive/libarchive/archive_read.3	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_read.3	Fri Mar 02 16:54:40 2012 +0200
@@ -22,181 +22,16 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $FreeBSD: head/contrib/libarchive/libarchive/archive_read.3 228773 2011-12-21 15:18:52Z mm $
+.\" $FreeBSD: head/contrib/libarchive/libarchive/archive_read.3 232153 2012-02-25 10:58:02Z mm $
 .\"
-.Dd April 13, 2009
+.Dd March 23, 2011
 .Dt ARCHIVE_READ 3
 .Os
 .Sh NAME
-.Nm archive_read_new ,
-.Nm archive_read_set_filter_options ,
-.Nm archive_read_set_format_options ,
-.Nm archive_read_set_options ,
-.Nm archive_read_support_compression_all ,
-.Nm archive_read_support_compression_bzip2 ,
-.Nm archive_read_support_compression_compress ,
-.Nm archive_read_support_compression_gzip ,
-.Nm archive_read_support_compression_lzma ,
-.Nm archive_read_support_compression_none ,
-.Nm archive_read_support_compression_xz ,
-.Nm archive_read_support_compression_program ,
-.Nm archive_read_support_compression_program_signature ,
-.Nm archive_read_support_format_all ,
-.Nm archive_read_support_format_ar ,
-.Nm archive_read_support_format_cpio ,
-.Nm archive_read_support_format_empty ,
-.Nm archive_read_support_format_iso9660 ,
-.Nm archive_read_support_format_mtree,
-.Nm archive_read_support_format_raw,
-.Nm archive_read_support_format_tar ,
-.Nm archive_read_support_format_zip ,
-.Nm archive_read_open ,
-.Nm archive_read_open2 ,
-.Nm archive_read_open_fd ,
-.Nm archive_read_open_FILE ,
-.Nm archive_read_open_filename ,
-.Nm archive_read_open_memory ,
-.Nm archive_read_next_header ,
-.Nm archive_read_next_header2 ,
-.Nm archive_read_data ,
-.Nm archive_read_data_block ,
-.Nm archive_read_data_skip ,
-.\" #if ARCHIVE_API_VERSION < 3
-.Nm archive_read_data_into_buffer ,
-.\" #endif
-.Nm archive_read_data_into_fd ,
-.Nm archive_read_extract ,
-.Nm archive_read_extract2 ,
-.Nm archive_read_extract_set_progress_callback ,
-.Nm archive_read_close ,
-.Nm archive_read_free
+.Nm archive_read
 .Nd functions for reading streaming archives
 .Sh SYNOPSIS
 .In archive.h
-.Ft struct archive *
-.Fn archive_read_new "void"
-.Ft int
-.Fn archive_read_support_compression_all "struct archive *"
-.Ft int
-.Fn archive_read_support_compression_bzip2 "struct archive *"
-.Ft int
-.Fn archive_read_support_compression_compress "struct archive *"
-.Ft int
-.Fn archive_read_support_compression_gzip "struct archive *"
-.Ft int
-.Fn archive_read_support_compression_lzma "struct archive *"
-.Ft int
-.Fn archive_read_support_compression_none "struct archive *"
-.Ft int
-.Fn archive_read_support_compression_xz "struct archive *"
-.Ft int
-.Fo archive_read_support_compression_program
-.Fa "struct archive *"
-.Fa "const char *cmd"
-.Fc
-.Ft int
-.Fo archive_read_support_compression_program_signature
-.Fa "struct archive *"
-.Fa "const char *cmd"
-.Fa "const void *signature"
-.Fa "size_t signature_length"
-.Fc
-.Ft int
-.Fn archive_read_support_format_all "struct archive *"
-.Ft int
-.Fn archive_read_support_format_ar "struct archive *"
-.Ft int
-.Fn archive_read_support_format_cpio "struct archive *"
-.Ft int
-.Fn archive_read_support_format_empty "struct archive *"
-.Ft int
-.Fn archive_read_support_format_iso9660 "struct archive *"
-.Ft int
-.Fn archive_read_support_format_mtree "struct archive *"
-.Ft int
-.Fn archive_read_support_format_raw "struct archive *"
-.Ft int
-.Fn archive_read_support_format_tar "struct archive *"
-.Ft int
-.Fn archive_read_support_format_zip "struct archive *"
-.Ft int
-.Fn archive_read_set_filter_options "struct archive *" "const char *"
-.Ft int
-.Fn archive_read_set_format_options "struct archive *" "const char *"
-.Ft int
-.Fn archive_read_set_options "struct archive *" "const char *"
-.Ft int
-.Fo archive_read_open
-.Fa "struct archive *"
-.Fa "void *client_data"
-.Fa "archive_open_callback *"
-.Fa "archive_read_callback *"
-.Fa "archive_close_callback *"
-.Fc
-.Ft int
-.Fo archive_read_open2
-.Fa "struct archive *"
-.Fa "void *client_data"
-.Fa "archive_open_callback *"
-.Fa "archive_read_callback *"
-.Fa "archive_skip_callback *"
-.Fa "archive_close_callback *"
-.Fc
-.Ft int
-.Fn archive_read_open_FILE "struct archive *" "FILE *file"
-.Ft int
-.Fn archive_read_open_fd "struct archive *" "int fd" "size_t block_size"
-.Ft int
-.Fo archive_read_open_filename
-.Fa "struct archive *"
-.Fa "const char *filename"
-.Fa "size_t block_size"
-.Fc
-.Ft int
-.Fn archive_read_open_memory "struct archive *" "void *buff" "size_t size"
-.Ft int
-.Fn archive_read_next_header "struct archive *" "struct archive_entry **"
-.Ft int
-.Fn archive_read_next_header2 "struct archive *" "struct archive_entry *"
-.Ft ssize_t
-.Fn archive_read_data "struct archive *" "void *buff" "size_t len"
-.Ft int
-.Fo archive_read_data_block
-.Fa "struct archive *"
-.Fa "const void **buff"
-.Fa "size_t *len"
-.Fa "off_t *offset"
-.Fc
-.Ft int
-.Fn archive_read_data_skip "struct archive *"
-.\" #if ARCHIVE_API_VERSION < 3
-.Ft int
-.Fn archive_read_data_into_buffer "struct archive *" "void *" "ssize_t len"
-.\" #endif
-.Ft int
-.Fn archive_read_data_into_fd "struct archive *" "int fd"
-.Ft int
-.Fo archive_read_extract
-.Fa "struct archive *"
-.Fa "struct archive_entry *"
-.Fa "int flags"
-.Fc
-.Ft int
-.Fo archive_read_extract2
-.Fa "struct archive *src"
-.Fa "struct archive_entry *"
-.Fa "struct archive *dest"
-.Fc
-.Ft void
-.Fo archive_read_extract_set_progress_callback
-.Fa "struct archive *"
-.Fa "void (*func)(void *)"
-.Fa "void *user_data"
-.Fc
-.Ft int
-.Fn archive_read_close "struct archive *"
-.Ft int
-.Fn archive_read_free "struct archive *"
 .Sh DESCRIPTION
 These functions provide a complete API for reading streaming archives.
 The general process is to first create the
@@ -204,375 +39,120 @@
 object, set options, initialize the reader, iterate over the archive
 headers and associated data, then close the archive and release all
 resources.
-The following summary describes the functions in approximately the
-order they would be used:
-.Bl -tag -compact -width indent
-.It Fn archive_read_new
-Allocates and initializes a
+.\"
+.Ss Create archive object
+See
+.Xr archive_read_new 3 .
+.Pp
+To read an archive, you must first obtain an initialized
 .Tn struct archive
-object suitable for reading from an archive.
-.It Xo
-.Fn archive_read_support_compression_bzip2 ,
-.Fn archive_read_support_compression_compress ,
-.Fn archive_read_support_compression_gzip ,
-.Fn archive_read_support_compression_lzma ,
-.Fn archive_read_support_compression_none ,
-.Fn archive_read_support_compression_xz
-.Xc
-Enables auto-detection code and decompression support for the
-specified compression.
-Returns
-.Cm ARCHIVE_OK
-if the compression is fully supported, or
-.Cm ARCHIVE_WARN
-if the compression is supported only through an external program.
-Note that decompression using an external program is usually slower than
-decompression through built-in libraries.
-Note that
-.Dq none
-is always enabled by default.
-.It Fn archive_read_support_compression_all
-Enables all available decompression filters.
-.It Fn archive_read_support_compression_program
-Data is fed through the specified external program before being dearchived.
-Note that this disables automatic detection of the compression format,
-so it makes no sense to specify this in conjunction with any other
-decompression option.
-.It Fn archive_read_support_compression_program_signature
-This feeds data through the specified external program
-but only if the initial bytes of the data match the specified
-signature value.
-.It Xo
-.Fn archive_read_support_format_all ,
-.Fn archive_read_support_format_ar ,
-.Fn archive_read_support_format_cpio ,
-.Fn archive_read_support_format_empty ,
-.Fn archive_read_support_format_iso9660 ,
-.Fn archive_read_support_format_mtree ,
-.Fn archive_read_support_format_tar ,
-.Fn archive_read_support_format_zip
-.Xc
-Enables support---including auto-detection code---for the
-specified archive format.
-For example,
-.Fn archive_read_support_format_tar
-enables support for a variety of standard tar formats, old-style tar,
-ustar, pax interchange format, and many common variants.
-For convenience,
+object from
+.Fn archive_read_new .
+.\"
+.Ss Enable filters and formats
+See
+.Xr archive_read_filter 3
+and
+.Xr archive_read_format 3 .
+.Pp
+You can then modify this object for the desired operations with the
+various
+.Fn archive_read_set_XXX
+and
+.Fn archive_read_support_XXX
+functions.
+In particular, you will need to invoke appropriate
+.Fn archive_read_support_XXX
+functions to enable the corresponding compression and format
+support.
+Note that these latter functions perform two distinct operations:
+they cause the corresponding support code to be linked into your
+program, and they enable the corresponding auto-detect code.
+Unless you have specific constraints, you will generally want
+to invoke
+.Fn archive_read_support_filter_all
+and
 .Fn archive_read_support_format_all
-enables support for all available formats.
-Only empty archives are supported by default.
-.It Fn archive_read_support_format_raw
-The
-.Dq raw
-format handler allows libarchive to be used to read arbitrary data.
-It treats any data stream as an archive with a single entry.
-The pathname of this entry is
-.Dq data ;
-all other entry fields are unset.
-This is not enabled by
-.Fn archive_read_support_format_all
-in order to avoid erroneous handling of damaged archives.
-.It Xo
-.Fn archive_read_set_filter_options ,
-.Fn archive_read_set_format_options ,
-.Fn archive_read_set_options
-.Xc
-Specifies options that will be passed to currently-registered
-filters (including decompression filters) and/or format readers.
-The argument is a comma-separated list of individual options.
-Individual options have one of the following forms:
-.Bl -tag -compact -width indent
-.It Ar option=value
-The option/value pair will be provided to every module.
-Modules that do not accept an option with this name will ignore it.
-.It Ar option
-The option will be provided to every module with a value of
-.Dq 1 .
-.It Ar !option
-The option will be provided to every module with a NULL value.
-.It Ar module:option=value , Ar module:option , Ar module:!option
-As above, but the corresponding option and value will be provided
-only to modules whose name matches
-.Ar module .
-.El
-The return value will be
-.Cm ARCHIVE_OK
-if any module accepts the option, or
-.Cm ARCHIVE_WARN
-if no module accepted the option, or
-.Cm ARCHIVE_FATAL
-if there was a fatal error while attempting to process the option.
+to enable auto-detect for all formats and compression types
+currently supported by the library.
+.\"
+.Ss Set options
+See
+.Xr archive_read_set_options 3 .
+.\"
+.Ss Open archive
+See
+.Xr archive_read_open 3 .
 .Pp
-The currently supported options are:
-.Bl -tag -compact -width indent
-.It Format iso9660
-.Bl -tag -compact -width indent
-.It Cm joliet
-Support Joliet extensions.
-Defaults to enabled, use
-.Cm !joliet
-to disable.
-.El
-.El
-.It Fn archive_read_open
-The same as
-.Fn archive_read_open2 ,
-except that the skip callback is assumed to be
-.Dv NULL .
-.It Fn archive_read_open2
-Freeze the settings, open the archive, and prepare for reading entries.
-This is the most generic version of this call, which accepts
-four callback functions.
-Most clients will want to use
-.Fn archive_read_open_filename ,
-.Fn archive_read_open_FILE ,
-.Fn archive_read_open_fd ,
-or
-.Fn archive_read_open_memory
-instead.
-The library invokes the client-provided functions to obtain
-raw bytes from the archive.
-.It Fn archive_read_open_FILE
-Like
-.Fn archive_read_open ,
-except that it accepts a
+Once you have prepared the
+.Tn struct archive
+object, you call
+.Fn archive_read_open
+to actually open the archive and prepare it for reading.
+There are several variants of this function;
+the most basic expects you to provide pointers to several
+functions that can provide blocks of bytes from the archive.
+There are convenience forms that allow you to
+specify a filename, file descriptor,
 .Ft "FILE *"
-pointer.
-This function should not be used with tape drives or other devices
-that require strict I/O blocking.
-.It Fn archive_read_open_fd
-Like
-.Fn archive_read_open ,
-except that it accepts a file descriptor and block size rather than
-a set of function pointers.
-Note that the file descriptor will not be automatically closed at
-end-of-archive.
-This function is safe for use with tape drives or other blocked devices.
-.It Fn archive_read_open_file
-This is a deprecated synonym for
-.Fn archive_read_open_filename .
-.It Fn archive_read_open_filename
-Like
-.Fn archive_read_open ,
-except that it accepts a simple filename and a block size.
-A NULL filename represents standard input.
-This function is safe for use with tape drives or other blocked devices.
-.It Fn archive_read_open_memory
-Like
-.Fn archive_read_open ,
-except that it accepts a pointer and size of a block of
-memory containing the archive data.
-.It Fn archive_read_next_header
-Read the header for the next entry and return a pointer to
-a
-.Tn struct archive_entry .
-This is a convenience wrapper around
-.Fn archive_read_next_header2
-that reuses an internal
+object, or a block of memory from which to read the archive data.
+Note that the core library makes no assumptions about the
+size of the blocks read;
+callback functions are free to read whatever block size is
+most appropriate for the medium.
+.\"
+.Ss Consume archive
+See
+.Xr archive_read_header 3 ,
+.Xr archive_read_data 3
+and
+.Xr archive_read_extract 3 .
+.Pp
+Each archive entry consists of a header followed by a certain
+amount of data.
+You can obtain the next header with
+.Fn archive_read_next_header ,
+which returns a pointer to an
 .Tn struct archive_entry
-object for each request.
-.It Fn archive_read_next_header2
-Read the header for the next entry and populate the provided
-.Tn struct archive_entry .
-.It Fn archive_read_data
-Read data associated with the header just read.
-Internally, this is a convenience function that calls
+structure with information about the current archive element.
+If the entry is a regular file, then the header will be followed
+by the file data.
+You can use
+.Fn archive_read_data
+(which works much like the
+.Xr read 2
+system call)
+to read this data from the archive, or
 .Fn archive_read_data_block
-and fills any gaps with nulls so that callers see a single
-continuous stream of data.
-.It Fn archive_read_data_block
-Return the next available block of data for this entry.
-Unlike
-.Fn archive_read_data ,
-the
-.Fn archive_read_data_block
-function avoids copying data and allows you to correctly handle
-sparse files, as supported by some archive formats.
-The library guarantees that offsets will increase and that blocks
-will not overlap.
-Note that the blocks returned from this function can be much larger
-than the block size read from disk, due to compression
-and internal buffer optimizations.
-.It Fn archive_read_data_skip
-A convenience function that repeatedly calls
-.Fn archive_read_data_block
-to skip all of the data for this archive entry.
-.\" #if ARCHIVE_API_VERSION < 3
-.It Fn archive_read_data_into_buffer
-This function is deprecated and will be removed.
-Use
-.Fn archive_read_data
-instead.
-.\" #endif
-.It Fn archive_read_data_into_fd
-A convenience function that repeatedly calls
-.Fn archive_read_data_block
-to copy the entire entry to the provided file descriptor.
-.It Fn archive_read_extract , Fn archive_read_extract_set_skip_file
-A convenience function that wraps the corresponding
-.Xr archive_write_disk 3
-interfaces.
-The first call to
+which provides a slightly more efficient interface.
+You may prefer to use the higher-level
+.Fn archive_read_data_skip ,
+which reads and discards the data for this entry,
+.Fn archive_read_data_to_file ,
+which copies the data to the provided file descriptor, or
+.Fn archive_read_extract ,
+which recreates the specified entry on disk and copies data
+from the archive.
+In particular, note that
 .Fn archive_read_extract
-creates a restore object using
-.Xr archive_write_disk_new 3
-and
-.Xr archive_write_disk_set_standard_lookup 3 ,
-then transparently invokes
-.Xr archive_write_disk_set_options 3 ,
-.Xr archive_write_header 3 ,
-.Xr archive_write_data 3 ,
-and
-.Xr archive_write_finish_entry 3
-to create the entry on disk and copy data into it.
-The
-.Va flags
-argument is passed unmodified to
-.Xr archive_write_disk_set_options 3 .
-.It Fn archive_read_extract2
-This is another version of
-.Fn archive_read_extract
-that allows you to provide your own restore object.
-In particular, this allows you to override the standard lookup functions
-using
-.Xr archive_write_disk_set_group_lookup 3 ,
-and
-.Xr archive_write_disk_set_user_lookup 3 .
-Note that
-.Fn archive_read_extract2
-does not accept a
-.Va flags
-argument; you should use
-.Fn archive_write_disk_set_options
-to set the restore options yourself.
-.It Fn archive_read_extract_set_progress_callback
-Sets a pointer to a user-defined callback that can be used
-for updating progress displays during extraction.
-The progress function will be invoked during the extraction of large
-regular files.
-The progress function will be invoked with the pointer provided to this call.
-Generally, the data pointed to should include a reference to the archive
-object and the archive_entry object so that various statistics
-can be retrieved for the progress display.
-.It Fn archive_read_close
-Complete the archive and invoke the close callback.
-.It Fn archive_read_free
-Invokes
+uses the
+.Tn struct archive_entry
+structure that you provide it, which may differ from the
+entry just read from the archive.
+In particular, many applications will want to override the
+pathname, file permissions, or ownership.
+.\"
+.Ss Release resources
+See
+.Xr archive_read_free 3 .
+.Pp
+Once you have finished reading data from the archive, you
+should call
 .Fn archive_read_close
-if it was not invoked manually, then release all resources.
-Note: In libarchive 1.x, this function was declared to return
-.Ft void ,
-which made it impossible to detect certain errors when
-.Fn archive_read_close
-was invoked implicitly from this function.
-The declaration is corrected beginning with libarchive 2.0.
-.El
-.Pp
-Note that the library determines most of the relevant information about
-the archive by inspection.
-In particular, it automatically detects
-.Xr gzip 1
-or
-.Xr bzip2 1
-compression and transparently performs the appropriate decompression.
-It also automatically detects the archive format.
-.Pp
-A complete description of the
-.Tn struct archive
-and
-.Tn struct archive_entry
-objects can be found in the overview manual page for
-.Xr libarchive 3 .
-.Sh CLIENT CALLBACKS
-The callback functions must match the following prototypes:
-.Bl -item -offset indent
-.It
-.Ft typedef ssize_t
-.Fo archive_read_callback
-.Fa "struct archive *"
-.Fa "void *client_data"
-.Fa "const void **buffer"
-.Fc
-.It
-.\" #if ARCHIVE_API_VERSION < 2
-.Ft typedef int
-.Fo archive_skip_callback
-.Fa "struct archive *"
-.Fa "void *client_data"
-.Fa "size_t request"
-.Fc
-.\" #else
-.\" .Ft typedef off_t
-.\" .Fo archive_skip_callback
-.\" .Fa "struct archive *"
-.\" .Fa "void *client_data"
-.\" .Fa "off_t request"
-.\" .Fc
-.\" #endif
-.It
-.Ft typedef int
-.Fn archive_open_callback "struct archive *" "void *client_data"
-.It
-.Ft typedef int
-.Fn archive_close_callback "struct archive *" "void *client_data"
-.El
-.Pp
-The open callback is invoked by
-.Fn archive_open .
-It should return
-.Cm ARCHIVE_OK
-if the underlying file or data source is successfully
-opened.
-If the open fails, it should call
-.Fn archive_set_error
-to register an error code and message and return
-.Cm ARCHIVE_FATAL .
-.Pp
-The read callback is invoked whenever the library
-requires raw bytes from the archive.
-The read callback should read data into a buffer,
-set the
-.Li const void **buffer
-argument to point to the available data, and
-return a count of the number of bytes available.
-The library will invoke the read callback again
-only after it has consumed this data.
-The library imposes no constraints on the size
-of the data blocks returned.
-On end-of-file, the read callback should
-return zero.
-On error, the read callback should invoke
-.Fn archive_set_error
-to register an error code and message and
-return -1.
-.Pp
-The skip callback is invoked when the
-library wants to ignore a block of data.
-The return value is the number of bytes actually
-skipped, which may differ from the request.
-If the callback cannot skip data, it should return
-zero.
-If the skip callback is not provided (the
-function pointer is
-.Dv NULL ),
-the library will invoke the read function
-instead and simply discard the result.
-A skip callback can provide significant
-performance gains when reading uncompressed
-archives from slow disk drives or other media
-that can skip quickly.
-.Pp
-The close callback is invoked by archive_close when
-the archive processing is complete.
-The callback should return
-.Cm ARCHIVE_OK
-on success.
-On failure, the callback should invoke
-.Fn archive_set_error
-to register an error code and message and
-return
-.Cm ARCHIVE_FATAL.
+to close the archive, then call
+.Fn archive_read_free
+to release all resources, including all memory allocated by the library.
+.\"
 .Sh EXAMPLE
 The following illustrates basic usage of the library.
 In this example,
@@ -593,7 +173,7 @@
   mydata = malloc(sizeof(struct mydata));
   a = archive_read_new();
   mydata->name = name;
-  archive_read_support_compression_all(a);
+  archive_read_support_filter_all(a);
   archive_read_support_format_all(a);
   archive_read_open(a, mydata, myopen, myread, myclose);
   while (archive_read_next_header(a, &entry) == ARCHIVE_OK) {
@@ -632,62 +212,18 @@
   return (ARCHIVE_OK);
 }
 .Ed
-.Sh RETURN VALUES
-Most functions return zero on success, non-zero on error.
-The possible return codes include:
-.Cm ARCHIVE_OK
-(the operation succeeded),
-.Cm ARCHIVE_WARN
-(the operation succeeded but a non-critical error was encountered),
-.Cm ARCHIVE_EOF
-(end-of-archive was encountered),
-.Cm ARCHIVE_RETRY
-(the operation failed but can be retried),
-and
-.Cm ARCHIVE_FATAL
-(there was a fatal error; the archive should be closed immediately).
-Detailed error codes and textual descriptions are available from the
-.Fn archive_errno
-and
-.Fn archive_error_string
-functions.
-.Pp
-.Fn archive_read_new
-returns a pointer to a freshly allocated
-.Tn struct archive
-object.
-It returns
-.Dv NULL
-on error.
-.Pp
-.Fn archive_read_data
-returns a count of bytes actually read or zero at the end of the entry.
-On error, a value of
-.Cm ARCHIVE_FATAL ,
-.Cm ARCHIVE_WARN ,
-or
-.Cm ARCHIVE_RETRY
-is returned and an error code and textual description can be retrieved from the
-.Fn archive_errno
-and
-.Fn archive_error_string
-functions.
-.Pp
-The library expects the client callbacks to behave similarly.
-If there is an error, you can use
-.Fn archive_set_error
-to set an appropriate error code and description,
-then return one of the non-zero values above.
-(Note that the value eventually returned to the client may
-not be the same; many errors that are not critical at the level
-of basic I/O can prevent the archive from being properly read,
-thus most I/O errors eventually cause
-.Cm ARCHIVE_FATAL
-to be returned.)
 .\" .Sh ERRORS
 .Sh SEE ALSO
 .Xr tar 1 ,
-.Xr archive 3 ,
+.Xr libarchive 3 ,
+.Xr archive_read_new 3 ,
+.Xr archive_read_data 3 ,
+.Xr archive_read_extract 3 ,
+.Xr archive_read_filter 3 ,
+.Xr archive_read_format 3 ,
+.Xr archive_read_header 3 ,
+.Xr archive_read_open 3 ,
+.Xr archive_read_set_options 3 ,
 .Xr archive_util 3 ,
 .Xr tar 5
 .Sh HISTORY
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_read.c
--- a/head/contrib/libarchive/libarchive/archive_read.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_read.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2003-2011 Tim Kientzle
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -32,7 +32,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read.c 228773 2011-12-21 15:18:52Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
@@ -55,12 +55,24 @@
 
 #define minimum(a, b) (a < b ? a : b)
 
-static int	build_stream(struct archive_read *);
+static int	choose_filters(struct archive_read *);
 static int	choose_format(struct archive_read *);
-static int	cleanup_filters(struct archive_read *);
+static void	free_filters(struct archive_read *);
+static int	close_filters(struct archive_read *);
 static struct archive_vtable *archive_read_vtable(void);
+static int64_t	_archive_filter_bytes(struct archive *, int);
+static int	_archive_filter_code(struct archive *, int);
+static const char *_archive_filter_name(struct archive *, int);
+static int  _archive_filter_count(struct archive *);
 static int	_archive_read_close(struct archive *);
+static int	_archive_read_data_block(struct archive *,
+		    const void **, size_t *, int64_t *);
 static int	_archive_read_free(struct archive *);
+static int	_archive_read_next_header(struct archive *,
+		    struct archive_entry **);
+static int	_archive_read_next_header2(struct archive *,
+		    struct archive_entry *);
+static int64_t  advance_file_pointer(struct archive_read_filter *, int64_t);
 
 static struct archive_vtable *
 archive_read_vtable(void)
@@ -69,8 +81,16 @@
 	static int inited = 0;
 
 	if (!inited) {
+		av.archive_filter_bytes = _archive_filter_bytes;
+		av.archive_filter_code = _archive_filter_code;
+		av.archive_filter_name = _archive_filter_name;
+		av.archive_filter_count = _archive_filter_count;
+		av.archive_read_data_block = _archive_read_data_block;
+		av.archive_read_next_header = _archive_read_next_header;
+		av.archive_read_next_header2 = _archive_read_next_header2;
 		av.archive_free = _archive_read_free;
 		av.archive_close = _archive_read_close;
+		inited = 1;
 	}
 	return (&av);
 }
@@ -90,7 +110,7 @@
 	a->archive.magic = ARCHIVE_READ_MAGIC;
 
 	a->archive.state = ARCHIVE_STATE_NEW;
-	a->entry = archive_entry_new();
+	a->entry = archive_entry_new2(&a->archive);
 	a->archive.vtable = archive_read_vtable();
 
 	return (&a->archive);
@@ -100,132 +120,19 @@
  * Record the do-not-extract-to file. This belongs in archive_read_extract.c.
  */
 void
-archive_read_extract_set_skip_file(struct archive *_a, dev_t d, ino_t i)
+archive_read_extract_set_skip_file(struct archive *_a, int64_t d, int64_t i)
 {
 	struct archive_read *a = (struct archive_read *)_a;
-	__archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_ANY,
-	    "archive_read_extract_set_skip_file");
+
+	if (ARCHIVE_OK != __archive_check_magic(_a, ARCHIVE_READ_MAGIC,
+		ARCHIVE_STATE_ANY, "archive_read_extract_set_skip_file"))
+		return;
+	a->skip_file_set = 1;
 	a->skip_file_dev = d;
 	a->skip_file_ino = i;
 }
 
 /*
- * Set read options for the format.
- */
-int
-archive_read_set_format_options(struct archive *_a, const char *s)
-{
-	struct archive_read *a;
-	struct archive_format_descriptor *format;
-	char key[64], val[64];
-	char *valp;
-	size_t i;
-	int len, r;
-
-	__archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW,
-	    "archive_read_set_format_options");
-
-	if (s == NULL || *s == '\0')
-		return (ARCHIVE_OK);
-	a = (struct archive_read *)_a;
-	__archive_check_magic(&a->archive, ARCHIVE_READ_MAGIC,
-	    ARCHIVE_STATE_NEW, "archive_read_set_format_options");
-	len = 0;
-	for (i = 0; i < sizeof(a->formats)/sizeof(a->formats[0]); i++) {
-		format = &a->formats[i];
-		if (format == NULL || format->options == NULL ||
-		    format->name == NULL)
-			/* This format does not support option. */
-			continue;
-
-		while ((len = __archive_parse_options(s, format->name,
-		    sizeof(key), key, sizeof(val), val)) > 0) {
-			valp = val[0] == '\0' ? NULL : val;
-			a->format = format;
-			r = format->options(a, key, valp);
-			a->format = NULL;
-			if (r == ARCHIVE_FATAL)
-				return (r);
-			s += len;
-		}
-	}
-	if (len < 0) {
-		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
-		    "Illegal format options.");
-		return (ARCHIVE_WARN);
-	}
-	return (ARCHIVE_OK);
-}
-
-/*
- * Set read options for the filter.
- */
-int
-archive_read_set_filter_options(struct archive *_a, const char *s)
-{
-	struct archive_read *a;
-	struct archive_read_filter *filter;
-	struct archive_read_filter_bidder *bidder;
-	char key[64], val[64];
-	int len, r;
-
-	__archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW,
-	    "archive_read_set_filter_options");
-
-	if (s == NULL || *s == '\0')
-		return (ARCHIVE_OK);
-	a = (struct archive_read *)_a;
-	__archive_check_magic(&a->archive, ARCHIVE_READ_MAGIC,
-	    ARCHIVE_STATE_NEW, "archive_read_set_filter_options");
-	len = 0;
-	for (filter = a->filter; filter != NULL; filter = filter->upstream) {
-		bidder = filter->bidder;
-		if (bidder == NULL)
-			continue;
-		if (bidder->options == NULL)
-			/* This bidder does not support option */
-			continue;
-		while ((len = __archive_parse_options(s, filter->name,
-		    sizeof(key), key, sizeof(val), val)) > 0) {
-			if (val[0] == '\0')
-				r = bidder->options(bidder, key, NULL);
-			else
-				r = bidder->options(bidder, key, val);
-			if (r == ARCHIVE_FATAL)
-				return (r);
-			s += len;
-		}
-	}
-	if (len < 0) {
-		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
-		    "Illegal format options.");
-		return (ARCHIVE_WARN);
-	}
-	return (ARCHIVE_OK);
-}
-
-/*
- * Set read options for the format and the filter.
- */
-int
-archive_read_set_options(struct archive *_a, const char *s)
-{
-	int r;
-
-	__archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW,
-	    "archive_read_set_options");
-	archive_clear_error(_a);
-
-	r = archive_read_set_format_options(_a, s);
-	if (r != ARCHIVE_OK)
-		return (r);
-	r = archive_read_set_filter_options(_a, s);
-	if (r != ARCHIVE_OK)
-		return (r);
-	return (ARCHIVE_OK);
-}
-
-/*
  * Open the archive
  */
 int
@@ -234,9 +141,30 @@
     archive_close_callback *client_closer)
 {
 	/* Old archive_read_open() is just a thin shell around
-	 * archive_read_open2. */
-	return archive_read_open2(a, client_data, client_opener,
-	    client_reader, NULL, client_closer);
+	 * archive_read_open1. */
+	archive_read_set_open_callback(a, client_opener);
+	archive_read_set_read_callback(a, client_reader);
+	archive_read_set_close_callback(a, client_closer);
+	archive_read_set_callback_data(a, client_data);
+	return archive_read_open1(a);
+}
+
+
+int
+archive_read_open2(struct archive *a, void *client_data,
+    archive_open_callback *client_opener,
+    archive_read_callback *client_reader,
+    archive_skip_callback *client_skipper,
+    archive_close_callback *client_closer)
+{
+	/* Old archive_read_open2() is just a thin shell around
+	 * archive_read_open1. */
+	archive_read_set_callback_data(a, client_data);
+	archive_read_set_open_callback(a, client_opener);
+	archive_read_set_read_callback(a, client_reader);
+	archive_read_set_skip_callback(a, client_skipper);
+	archive_read_set_close_callback(a, client_closer);
+	return archive_read_open1(a);
 }
 
 static ssize_t
@@ -245,33 +173,70 @@
 	ssize_t r;
 	r = (self->archive->client.reader)(&self->archive->archive,
 	    self->data, buff);
-	self->archive->archive.raw_position += r;
 	return (r);
 }
 
 static int64_t
 client_skip_proxy(struct archive_read_filter *self, int64_t request)
 {
-	int64_t ask, get, total;
-	/* Limit our maximum seek request to 1GB on platforms
-	* with 32-bit off_t (such as Windows). */
-	int64_t skip_limit = ((int64_t)1) << (sizeof(off_t) * 8 - 2);
+	if (request < 0)
+		__archive_errx(1, "Negative skip requested.");
+	if (request == 0)
+		return 0;
 
-	if (self->archive->client.skipper == NULL)
-		return (0);
-	total = 0;
-	for (;;) {
-		ask = request;
-		if (ask > skip_limit)
-			ask = skip_limit;
-		get = (self->archive->client.skipper)(&self->archive->archive,
-			self->data, ask);
-		if (get == 0)
-			return (total);
-		request -= get;
-		self->archive->archive.raw_position += get;
-		total += get;
+	if (self->archive->client.skipper != NULL) {
+		/* Seek requests over 1GiB are broken down into
+		 * multiple seeks.  This avoids overflows when the
+		 * requests get passed through 32-bit arguments. */
+		int64_t skip_limit = (int64_t)1 << 30;
+		int64_t total = 0;
+		for (;;) {
+			int64_t get, ask = request;
+			if (ask > skip_limit)
+				ask = skip_limit;
+			get = (self->archive->client.skipper)(&self->archive->archive,
+			    self->data, ask);
+			if (get == 0)
+				return (total);
+			request -= get;
+			total += get;
+		}
+		return total;
+	} else if (self->archive->client.seeker != NULL
+		&& request > 64 * 1024) {
+		/* If the client provided a seeker but not a skipper,
+		 * we can use the seeker to skip forward.
+		 *
+		 * Note: This isn't always a good idea.  The client
+		 * skipper is allowed to skip by less than requested
+		 * if it needs to maintain block alignment.  The
+		 * seeker is not allowed to play such games, so using
+		 * the seeker here may be a performance loss compared
+		 * to just reading and discarding.  That's why we
+		 * only do this for skips of over 64k.
+		 */
+		int64_t before = self->position;
+		int64_t after = (self->archive->client.seeker)(&self->archive->archive,
+		    self->data, request, SEEK_CUR);
+		if (after != before + request)
+			return ARCHIVE_FATAL;
+		return after - before;
 	}
+	return 0;
+}
+
+static int64_t
+client_seek_proxy(struct archive_read_filter *self, int64_t offset, int whence)
+{
+	/* DO NOT use the skipper here!  If we transparently handled
+	 * forward seek here by using the skipper, that will break
+	 * other libarchive code that assumes a successful forward
+	 * seek means it can also seek backwards.
+	 */
+	if (self->archive->client.seeker == NULL)
+		return (ARCHIVE_FAILED);
+	return (self->archive->client.seeker)(&self->archive->archive,
+	    self->data, offset, whence);
 }
 
 static int
@@ -282,65 +247,134 @@
 	if (self->archive->client.closer != NULL)
 		r = (self->archive->client.closer)((struct archive *)self->archive,
 		    self->data);
-	self->data = NULL;
 	return (r);
 }
 
+int
+archive_read_set_open_callback(struct archive *_a,
+    archive_open_callback *client_opener)
+{
+	struct archive_read *a = (struct archive_read *)_a;
+	archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW,
+	    "archive_read_set_open_callback");
+	a->client.opener = client_opener;
+	return ARCHIVE_OK;
+}
 
 int
-archive_read_open2(struct archive *_a, void *client_data,
-    archive_open_callback *client_opener,
-    archive_read_callback *client_reader,
-    archive_skip_callback *client_skipper,
+archive_read_set_read_callback(struct archive *_a,
+    archive_read_callback *client_reader)
+{
+	struct archive_read *a = (struct archive_read *)_a;
+	archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW,
+	    "archive_read_set_read_callback");
+	a->client.reader = client_reader;
+	return ARCHIVE_OK;
+}
+
+int
+archive_read_set_skip_callback(struct archive *_a,
+    archive_skip_callback *client_skipper)
+{
+	struct archive_read *a = (struct archive_read *)_a;
+	archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW,
+	    "archive_read_set_skip_callback");
+	a->client.skipper = client_skipper;
+	return ARCHIVE_OK;
+}
+
+int
+archive_read_set_seek_callback(struct archive *_a,
+    archive_seek_callback *client_seeker)
+{
+	struct archive_read *a = (struct archive_read *)_a;
+	archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW,
+	    "archive_read_set_seek_callback");
+	a->client.seeker = client_seeker;
+	return ARCHIVE_OK;
+}
+
+int
+archive_read_set_close_callback(struct archive *_a,
     archive_close_callback *client_closer)
 {
 	struct archive_read *a = (struct archive_read *)_a;
+	archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW,
+	    "archive_read_set_close_callback");
+	a->client.closer = client_closer;
+	return ARCHIVE_OK;
+}
+
+int
+archive_read_set_callback_data(struct archive *_a, void *client_data)
+{
+	struct archive_read *a = (struct archive_read *)_a;
+	archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW,
+	    "archive_read_set_callback_data");
+	a->client.data = client_data;
+	return ARCHIVE_OK;
+}
+
+int
+archive_read_open1(struct archive *_a)
+{
+	struct archive_read *a = (struct archive_read *)_a;
 	struct archive_read_filter *filter;
-	int e;
+	int slot, e;
 
-	__archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW,
+	archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW,
 	    "archive_read_open");
 	archive_clear_error(&a->archive);
 
-	if (client_reader == NULL)
-		__archive_errx(1,
+	if (a->client.reader == NULL) {
+		archive_set_error(&a->archive, EINVAL,
 		    "No reader function provided to archive_read_open");
+		a->archive.state = ARCHIVE_STATE_FATAL;
+		return (ARCHIVE_FATAL);
+	}
 
 	/* Open data source. */
-	if (client_opener != NULL) {
-		e =(client_opener)(&a->archive, client_data);
+	if (a->client.opener != NULL) {
+		e =(a->client.opener)(&a->archive, a->client.data);
 		if (e != 0) {
 			/* If the open failed, call the closer to clean up. */
-			if (client_closer)
-				(client_closer)(&a->archive, client_data);
+			if (a->client.closer)
+				(a->client.closer)(&a->archive, a->client.data);
 			return (e);
 		}
 	}
 
-	/* Save the client functions and mock up the initial source. */
-	a->client.reader = client_reader;
-	a->client.skipper = client_skipper;
-	a->client.closer = client_closer;
-
 	filter = calloc(1, sizeof(*filter));
 	if (filter == NULL)
 		return (ARCHIVE_FATAL);
 	filter->bidder = NULL;
 	filter->upstream = NULL;
 	filter->archive = a;
-	filter->data = client_data;
+	filter->data = a->client.data;
 	filter->read = client_read_proxy;
 	filter->skip = client_skip_proxy;
+	filter->seek = client_seek_proxy;
 	filter->close = client_close_proxy;
 	filter->name = "none";
 	filter->code = ARCHIVE_COMPRESSION_NONE;
 	a->filter = filter;
 
 	/* Build out the input pipeline. */
-	e = build_stream(a);
-	if (e == ARCHIVE_OK)
-		a->archive.state = ARCHIVE_STATE_HEADER;
+	e = choose_filters(a);
+	if (e < ARCHIVE_WARN) {
+		a->archive.state = ARCHIVE_STATE_FATAL;
+		return (ARCHIVE_FATAL);
+	}
 
+	slot = choose_format(a);
+	if (slot < 0) {
+		close_filters(a);
+		a->archive.state = ARCHIVE_STATE_FATAL;
+		return (ARCHIVE_FATAL);
+	}
+	a->format = &(a->formats[slot]);
+
+	a->archive.state = ARCHIVE_STATE_HEADER;
 	return (e);
 }
 
@@ -350,7 +384,7 @@
  * building the pipeline.
  */
 static int
-build_stream(struct archive_read *a)
+choose_filters(struct archive_read *a)
 {
 	int number_bidders, i, bid, best_bid;
 	struct archive_read_filter_bidder *bidder, *best_bidder;
@@ -377,10 +411,11 @@
 
 		/* If no bidder, we're done. */
 		if (best_bidder == NULL) {
-			/* Verify the final pipelin by asking it for some data. */
+			/* Verify the filter by asking it for some data. */
 			__archive_read_filter_ahead(a->filter, 1, &avail);
 			if (avail < 0) {
-				cleanup_filters(a);
+				close_filters(a);
+				free_filters(a);
 				return (ARCHIVE_FATAL);
 			}
 			a->archive.compression_name = a->filter->name;
@@ -398,8 +433,9 @@
 		a->filter = filter;
 		r = (best_bidder->init)(a->filter);
 		if (r != ARCHIVE_OK) {
-			cleanup_filters(a);
-			return (r);
+			close_filters(a);
+			free_filters(a);
+			return (ARCHIVE_FATAL);
 		}
 	}
 }
@@ -407,60 +443,49 @@
 /*
  * Read header of next entry.
  */
-int
-archive_read_next_header2(struct archive *_a, struct archive_entry *entry)
+static int
+_archive_read_next_header2(struct archive *_a, struct archive_entry *entry)
 {
 	struct archive_read *a = (struct archive_read *)_a;
-	int slot, ret;
+	int r1 = ARCHIVE_OK, r2;
 
-	__archive_check_magic(_a, ARCHIVE_READ_MAGIC,
+	archive_check_magic(_a, ARCHIVE_READ_MAGIC,
 	    ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA,
 	    "archive_read_next_header");
 
-	++_a->file_count;
 	archive_entry_clear(entry);
 	archive_clear_error(&a->archive);
 
 	/*
-	 * If no format has yet been chosen, choose one.
-	 */
-	if (a->format == NULL) {
-		slot = choose_format(a);
-		if (slot < 0) {
-			a->archive.state = ARCHIVE_STATE_FATAL;
-			return (ARCHIVE_FATAL);
-		}
-		a->format = &(a->formats[slot]);
-	}
-
-	/*
 	 * If client didn't consume entire data, skip any remainder
 	 * (This is especially important for GNU incremental directories.)
 	 */
 	if (a->archive.state == ARCHIVE_STATE_DATA) {
-		ret = archive_read_data_skip(&a->archive);
-		if (ret == ARCHIVE_EOF) {
-			archive_set_error(&a->archive, EIO, "Premature end-of-file.");
+		r1 = archive_read_data_skip(&a->archive);
+		if (r1 == ARCHIVE_EOF)
+			archive_set_error(&a->archive, EIO,
+			    "Premature end-of-file.");
+		if (r1 == ARCHIVE_EOF || r1 == ARCHIVE_FATAL) {
 			a->archive.state = ARCHIVE_STATE_FATAL;
 			return (ARCHIVE_FATAL);
 		}
-		if (ret != ARCHIVE_OK)
-			return (ret);
 	}
 
-	/* Record start-of-header. */
-	a->header_position = a->archive.file_position;
+	/* Record start-of-header offset in uncompressed stream. */
+	a->header_position = a->filter->position;
 
-	ret = (a->format->read_header)(a, entry);
+	++_a->file_count;
+	r2 = (a->format->read_header)(a, entry);
 
 	/*
 	 * EOF and FATAL are persistent at this layer.  By
 	 * modifying the state, we guarantee that future calls to
 	 * read a header or read data will fail.
 	 */
-	switch (ret) {
+	switch (r2) {
 	case ARCHIVE_EOF:
 		a->archive.state = ARCHIVE_STATE_EOF;
+		--_a->file_count;/* Revert a file counter. */
 		break;
 	case ARCHIVE_OK:
 		a->archive.state = ARCHIVE_STATE_DATA;
@@ -477,16 +502,17 @@
 
 	a->read_data_output_offset = 0;
 	a->read_data_remaining = 0;
-	return (ret);
+	/* EOF always wins; otherwise return the worst error. */
+	return (r2 < r1 || r2 == ARCHIVE_EOF) ? r2 : r1;
 }
 
 int
-archive_read_next_header(struct archive *_a, struct archive_entry **entryp)
+_archive_read_next_header(struct archive *_a, struct archive_entry **entryp)
 {
 	int ret;
 	struct archive_read *a = (struct archive_read *)_a;
 	*entryp = NULL;
-	ret = archive_read_next_header2(_a, a->entry);
+	ret = _archive_read_next_header2(_a, a->entry);
 	*entryp = a->entry;
 	return ret;
 }
@@ -507,13 +533,15 @@
 	best_bid = -1;
 	best_bid_slot = -1;
 
-	/* Set up a->format and a->pformat_data for convenience of bidders. */
+	/* Set up a->format for convenience of bidders. */
 	a->format = &(a->formats[0]);
 	for (i = 0; i < slots; i++, a->format++) {
 		if (a->format->bid) {
-			bid = (a->format->bid)(a);
+			bid = (a->format->bid)(a, best_bid);
 			if (bid == ARCHIVE_FATAL)
 				return (ARCHIVE_FATAL);
+			if (a->filter->position != 0)
+				__archive_read_seek(a, 0, SEEK_SET);
 			if ((bid > best_bid) || (best_bid_slot < 0)) {
 				best_bid = bid;
 				best_bid_slot = i;
@@ -525,10 +553,11 @@
 	 * There were no bidders; this is a serious programmer error
 	 * and demands a quick and definitive abort.
 	 */
-	if (best_bid_slot < 0)
-		__archive_errx(1, "No formats were registered; you must "
-		    "invoke at least one archive_read_support_format_XXX "
-		    "function in order to successfully read an archive.");
+	if (best_bid_slot < 0) {
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+		    "No formats registered");
+		return (ARCHIVE_FATAL);
+	}
 
 	/*
 	 * There were bidders, but no non-zero bids; this means we
@@ -551,7 +580,7 @@
 archive_read_header_position(struct archive *_a)
 {
 	struct archive_read *a = (struct archive_read *)_a;
-	__archive_check_magic(_a, ARCHIVE_READ_MAGIC,
+	archive_check_magic(_a, ARCHIVE_READ_MAGIC,
 	    ARCHIVE_STATE_ANY, "archive_read_header_position");
 	return (a->header_position);
 }
@@ -583,7 +612,7 @@
 	while (s > 0) {
 		if (a->read_data_remaining == 0) {
 			read_buf = a->read_data_block;
-			r = archive_read_data_block(&a->archive, &read_buf,
+			r = _archive_read_data_block(&a->archive, &read_buf,
 			    &a->read_data_remaining, &a->read_data_offset);
 			a->read_data_block = read_buf;
 			if (r == ARCHIVE_EOF)
@@ -604,7 +633,7 @@
 		}
 
 		/* Compute the amount of zero padding needed. */
-		if (a->read_data_output_offset + (off_t)s <
+		if (a->read_data_output_offset + (int64_t)s <
 		    a->read_data_offset) {
 			len = s;
 		} else if (a->read_data_output_offset <
@@ -639,22 +668,6 @@
 	return (bytes_read);
 }
 
-#if ARCHIVE_API_VERSION < 3
-/*
- * Obsolete function provided for compatibility only.  Note that the API
- * of this function doesn't allow the caller to detect if the remaining
- * data from the archive entry is shorter than the buffer provided, or
- * even if an error occurred while reading data.
- */
-int
-archive_read_data_into_buffer(struct archive *a, void *d, ssize_t len)
-{
-
-	archive_read_data(a, d, len);
-	return (ARCHIVE_OK);
-}
-#endif
-
 /*
  * Skip over all remaining data in this entry.
  */
@@ -665,9 +678,9 @@
 	int r;
 	const void *buff;
 	size_t size;
-	off_t offset;
+	int64_t offset;
 
-	__archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_DATA,
+	archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_DATA,
 	    "archive_read_data_skip");
 
 	if (a->format->read_data_skip != NULL)
@@ -694,12 +707,12 @@
  * Returns ARCHIVE_OK if the operation is successful, ARCHIVE_EOF if
  * the end of entry is encountered.
  */
-int
-archive_read_data_block(struct archive *_a,
-    const void **buff, size_t *size, off_t *offset)
+static int
+_archive_read_data_block(struct archive *_a,
+    const void **buff, size_t *size, int64_t *offset)
 {
 	struct archive_read *a = (struct archive_read *)_a;
-	__archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_DATA,
+	archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_DATA,
 	    "archive_read_data_block");
 
 	if (a->format->read_data == NULL) {
@@ -712,69 +725,79 @@
 	return (a->format->read_data)(a, buff, size, offset);
 }
 
+static int
+close_filters(struct archive_read *a)
+{
+	struct archive_read_filter *f = a->filter;
+	int r = ARCHIVE_OK;
+	/* Close each filter in the pipeline. */
+	while (f != NULL) {
+		struct archive_read_filter *t = f->upstream;
+		if (!f->closed && f->close != NULL) {
+			int r1 = (f->close)(f);
+			f->closed = 1;
+			if (r1 < r)
+				r = r1;
+		}
+		free(f->buffer);
+		f->buffer = NULL;
+		f = t;
+	}
+	return r;
+}
+
+static void
+free_filters(struct archive_read *a)
+{
+	while (a->filter != NULL) {
+		struct archive_read_filter *t = a->filter->upstream;
+		free(a->filter);
+		a->filter = t;
+	}
+}
+
 /*
- * Close the file and release most resources.
- *
- * Be careful: client might just call read_new and then read_finish.
- * Don't assume we actually read anything or performed any non-trivial
- * initialization.
+ * return the count of # of filters in use
+ */
+static int
+_archive_filter_count(struct archive *_a)
+{
+	struct archive_read *a = (struct archive_read *)_a;
+	struct archive_read_filter *p = a->filter;
+	int count = 0;
+	while(p) {
+		count++;
+		p = p->upstream;
+	}
+	return count;
+}
+
+/*
+ * Close the file and all I/O.
  */
 static int
 _archive_read_close(struct archive *_a)
 {
 	struct archive_read *a = (struct archive_read *)_a;
 	int r = ARCHIVE_OK, r1 = ARCHIVE_OK;
-	size_t i, n;
 
-	__archive_check_magic(&a->archive, ARCHIVE_READ_MAGIC,
-	    ARCHIVE_STATE_ANY, "archive_read_close");
+	archive_check_magic(&a->archive, ARCHIVE_READ_MAGIC,
+	    ARCHIVE_STATE_ANY | ARCHIVE_STATE_FATAL, "archive_read_close");
+	if (a->archive.state == ARCHIVE_STATE_CLOSED)
+		return (ARCHIVE_OK);
 	archive_clear_error(&a->archive);
 	a->archive.state = ARCHIVE_STATE_CLOSED;
 
-
-	/* Call cleanup functions registered by optional components. */
-	if (a->cleanup_archive_extract != NULL)
-		r = (a->cleanup_archive_extract)(a);
-
 	/* TODO: Clean up the formatters. */
 
 	/* Release the filter objects. */
-	r1 = cleanup_filters(a);
+	r1 = close_filters(a);
 	if (r1 < r)
 		r = r1;
 
-	/* Release the bidder objects. */
-	n = sizeof(a->bidders)/sizeof(a->bidders[0]);
-	for (i = 0; i < n; i++) {
-		if (a->bidders[i].free != NULL) {
-			r1 = (a->bidders[i].free)(&a->bidders[i]);
-			if (r1 < r)
-				r = r1;
-		}
-	}
-
 	return (r);
 }
 
-static int
-cleanup_filters(struct archive_read *a)
-{
-	int r = ARCHIVE_OK;
-	/* Clean up the filter pipeline. */
-	while (a->filter != NULL) {
-		struct archive_read_filter *t = a->filter->upstream;
-		if (a->filter->close != NULL) {
-			int r1 = (a->filter->close)(a->filter);
-			if (r1 < r)
-				r = r1;
-		}
-		free(a->filter->buffer);
-		free(a->filter);
-		a->filter = t;
-	}
-	return r;
-}
-
 /*
  * Release memory and other resources.
  */
@@ -782,15 +805,22 @@
 _archive_read_free(struct archive *_a)
 {
 	struct archive_read *a = (struct archive_read *)_a;
-	int i;
+	int i, n;
 	int slots;
 	int r = ARCHIVE_OK;
 
-	__archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_ANY,
-	    "archive_read_free");
-	if (a->archive.state != ARCHIVE_STATE_CLOSED)
+	if (_a == NULL)
+		return (ARCHIVE_OK);
+	archive_check_magic(_a, ARCHIVE_READ_MAGIC,
+	    ARCHIVE_STATE_ANY | ARCHIVE_STATE_FATAL, "archive_read_free");
+	if (a->archive.state != ARCHIVE_STATE_CLOSED
+	    && a->archive.state != ARCHIVE_STATE_FATAL)
 		r = archive_read_close(&a->archive);
 
+	/* Call cleanup functions registered by optional components. */
+	if (a->cleanup_archive_extract != NULL)
+		r = (a->cleanup_archive_extract)(a);
+
 	/* Cleanup format-specific data. */
 	slots = sizeof(a->formats) / sizeof(a->formats[0]);
 	for (i = 0; i < slots; i++) {
@@ -799,14 +829,71 @@
 			(a->formats[i].cleanup)(a);
 	}
 
+	/* Free the filters */
+	free_filters(a);
+
+	/* Release the bidder objects. */
+	n = sizeof(a->bidders)/sizeof(a->bidders[0]);
+	for (i = 0; i < n; i++) {
+		if (a->bidders[i].free != NULL) {
+			int r1 = (a->bidders[i].free)(&a->bidders[i]);
+			if (r1 < r)
+				r = r1;
+		}
+	}
+
 	archive_string_free(&a->archive.error_string);
 	if (a->entry)
 		archive_entry_free(a->entry);
 	a->archive.magic = 0;
+	__archive_clean(&a->archive);
 	free(a);
-#if ARCHIVE_API_VERSION > 1
 	return (r);
-#endif
+}
+
+static struct archive_read_filter *
+get_filter(struct archive *_a, int n)
+{
+	struct archive_read *a = (struct archive_read *)_a;
+	struct archive_read_filter *f = a->filter;
+	/* We use n == -1 for 'the last filter', which is always the client proxy. */
+	if (n == -1 && f != NULL) {
+		struct archive_read_filter *last = f;
+		f = f->upstream;
+		while (f != NULL) {
+			last = f;
+			f = f->upstream;
+		}
+		return (last);
+	}
+	if (n < 0)
+		return NULL;
+	while (n > 0 && f != NULL) {
+		f = f->upstream;
+		--n;
+	}
+	return (f);
+}
+
+static int
+_archive_filter_code(struct archive *_a, int n)
+{
+	struct archive_read_filter *f = get_filter(_a, n);
+	return f == NULL ? -1 : f->code;
+}
+
+static const char *
+_archive_filter_name(struct archive *_a, int n)
+{
+	struct archive_read_filter *f = get_filter(_a, n);
+	return f == NULL ? NULL : f->name;
+}
+
+static int64_t
+_archive_filter_bytes(struct archive *_a, int n)
+{
+	struct archive_read_filter *f = get_filter(_a, n);
+	return f == NULL ? -1 : f->position;
 }
 
 /*
@@ -817,16 +904,16 @@
 __archive_read_register_format(struct archive_read *a,
     void *format_data,
     const char *name,
-    int (*bid)(struct archive_read *),
+    int (*bid)(struct archive_read *, int),
     int (*options)(struct archive_read *, const char *, const char *),
     int (*read_header)(struct archive_read *, struct archive_entry *),
-    int (*read_data)(struct archive_read *, const void **, size_t *, off_t *),
+    int (*read_data)(struct archive_read *, const void **, size_t *, int64_t *),
     int (*read_data_skip)(struct archive_read *),
     int (*cleanup)(struct archive_read *))
 {
 	int i, number_slots;
 
-	__archive_check_magic(&a->archive,
+	archive_check_magic(&a->archive,
 	    ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW,
 	    "__archive_read_register_format");
 
@@ -848,74 +935,68 @@
 		}
 	}
 
-	__archive_errx(1, "Not enough slots for format registration");
-	return (ARCHIVE_FATAL); /* Never actually called. */
+	archive_set_error(&a->archive, ENOMEM,
+	    "Not enough slots for format registration");
+	return (ARCHIVE_FATAL);
 }
 
 /*
  * Used internally by decompression routines to register their bid and
  * initialization functions.
  */
-struct archive_read_filter_bidder *
-__archive_read_get_bidder(struct archive_read *a)
+int
+__archive_read_get_bidder(struct archive_read *a,
+    struct archive_read_filter_bidder **bidder)
 {
 	int i, number_slots;
 
-	__archive_check_magic(&a->archive,
-	    ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW,
-	    "__archive_read_get_bidder");
-
 	number_slots = sizeof(a->bidders) / sizeof(a->bidders[0]);
 
 	for (i = 0; i < number_slots; i++) {
 		if (a->bidders[i].bid == NULL) {
 			memset(a->bidders + i, 0, sizeof(a->bidders[0]));
-			return (a->bidders + i);
+			*bidder = (a->bidders + i);
+			return (ARCHIVE_OK);
 		}
 	}
 
-	__archive_errx(1, "Not enough slots for compression registration");
-	return (NULL); /* Never actually executed. */
+	archive_set_error(&a->archive, ENOMEM,
+	    "Not enough slots for filter registration");
+	return (ARCHIVE_FATAL);
 }
 
 /*
- * The next three functions comprise the peek/consume internal I/O
- * system used by archive format readers.  This system allows fairly
- * flexible read-ahead and allows the I/O code to operate in a
- * zero-copy manner most of the time.
+ * The next section implements the peek/consume internal I/O
+ * system used by archive readers.  This system allows simple
+ * read-ahead for consumers while preserving zero-copy operation
+ * most of the time.
+ *
+ * The two key operations:
+ *  * The read-ahead function returns a pointer to a block of data
+ *    that satisfies a minimum request.
+ *  * The consume function advances the file pointer.
  *
  * In the ideal case, filters generate blocks of data
  * and __archive_read_ahead() just returns pointers directly into
  * those blocks.  Then __archive_read_consume() just bumps those
  * pointers.  Only if your request would span blocks does the I/O
  * layer use a copy buffer to provide you with a contiguous block of
- * data.  The __archive_read_skip() is an optimization; it scans ahead
- * very quickly (it usually translates into a seek() operation if
- * you're reading uncompressed disk files).
+ * data.
  *
  * A couple of useful idioms:
  *  * "I just want some data."  Ask for 1 byte and pay attention to
  *    the "number of bytes available" from __archive_read_ahead().
- *    You can consume more than you asked for; you just can't consume
- *    more than is available.  If you consume everything that's
- *    immediately available, the next read_ahead() call will pull
- *    the next block.
+ *    Consume whatever you actually use.
  *  * "I want to output a large block of data."  As above, ask for 1 byte,
- *    emit all that's available (up to whatever limit you have), then
- *    repeat until you're done.
+ *    emit all that's available (up to whatever limit you have), consume
+ *    it all, then repeat until you're done.  This effectively means that
+ *    you're passing along the blocks that came from your provider.
  *  * "I want to peek ahead by a large amount."  Ask for 4k or so, then
  *    double and repeat until you get an error or have enough.  Note
  *    that the I/O layer will likely end up expanding its copy buffer
  *    to fit your request, so use this technique cautiously.  This
  *    technique is used, for example, by some of the format tasting
  *    code that has uncertain look-ahead needs.
- *
- * TODO: Someday, provide a more generic __archive_read_seek() for
- * those cases where it's useful.  This is tricky because there are lots
- * of cases where seek() is not available (reading gzip data from a
- * network socket, for instance), so there needs to be a good way to
- * communicate whether seek() is available and users of that interface
- * need to use non-seeking strategies whenever seek() is not available.
  */
 
 /*
@@ -924,8 +1005,8 @@
  *    in the current buffer, which may be much larger than requested.
  *  * If end-of-file, *avail gets set to zero.
  *  * If error, *avail gets error code.
- *  * If request can be met, returns pointer to data, returns NULL
- *    if request is not met.
+ *  * If request can be met, returns pointer to data.
+ *  * If minimum request cannot be met, returns NULL.
  *
  * Note: If you just want "some data", ask for 1 byte and pay attention
  * to *avail, which will have the actual amount available.  If you
@@ -935,17 +1016,6 @@
  * Important:  This does NOT move the file pointer.  See
  * __archive_read_consume() below.
  */
-
-/*
- * This is tricky.  We need to provide our clients with pointers to
- * contiguous blocks of memory but we want to avoid copying whenever
- * possible.
- *
- * Mostly, this code returns pointers directly into the block of data
- * provided by the client_read routine.  It can do this unless the
- * request would split across blocks.  In that case, we have to copy
- * into an internal buffer to combine reads.
- */
 const void *
 __archive_read_ahead(struct archive_read *a, size_t min, ssize_t *avail)
 {
@@ -1034,7 +1104,6 @@
 					*avail = filter->avail;
 				return (NULL);
 			}
-			filter->position += bytes_read;
 			filter->client_total = bytes_read;
 			filter->client_avail = filter->client_total;
 			filter->client_next = filter->client_buff;
@@ -1114,136 +1183,160 @@
 }
 
 /*
- * Move the file pointer forward.  This should be called after
- * __archive_read_ahead() returns data to you.  Don't try to move
- * ahead by more than the amount of data available according to
- * __archive_read_ahead().
+ * Move the file pointer forward.
  */
-/*
- * Mark the appropriate data as used.  Note that the request here will
- * often be much smaller than the size of the previous read_ahead
- * request.
- */
-ssize_t
-__archive_read_consume(struct archive_read *a, size_t request)
+int64_t
+__archive_read_consume(struct archive_read *a, int64_t request)
 {
-	ssize_t r;
-	r = __archive_read_filter_consume(a->filter, request);
-	a->archive.file_position += r;
-	return (r);
+	return (__archive_read_filter_consume(a->filter, request));
 }
 
-ssize_t
+int64_t
 __archive_read_filter_consume(struct archive_read_filter * filter,
-    size_t request)
+    int64_t request)
 {
-	if (filter->avail > 0) {
-		/* Read came from copy buffer. */
-		filter->next += request;
-		filter->avail -= request;
-	} else {
-		/* Read came from client buffer. */
-		filter->client_next += request;
-		filter->client_avail -= request;
-	}
-	return (request);
-}
+	int64_t skipped;
 
-/*
- * Move the file pointer ahead by an arbitrary amount.  If you're
- * reading uncompressed data from a disk file, this will actually
- * translate into a seek() operation.  Even in cases where seek()
- * isn't feasible, this at least pushes the read-and-discard loop
- * down closer to the data source.
- */
-int64_t
-__archive_read_skip(struct archive_read *a, int64_t request)
-{
-	int64_t skipped = __archive_read_skip_lenient(a, request);
+	if (request == 0)
+		return 0;
+
+	skipped = advance_file_pointer(filter, request);
 	if (skipped == request)
 		return (skipped);
 	/* We hit EOF before we satisfied the skip request. */
-	if (skipped < 0)  // Map error code to 0 for error message below.
+	if (skipped < 0)  /* Map error code to 0 for error message below. */
 		skipped = 0;
-	archive_set_error(&a->archive,
+	archive_set_error(&filter->archive->archive,
 	    ARCHIVE_ERRNO_MISC,
 	    "Truncated input file (needed %jd bytes, only %jd available)",
 	    (intmax_t)request, (intmax_t)skipped);
 	return (ARCHIVE_FATAL);
 }
 
-int64_t
-__archive_read_skip_lenient(struct archive_read *a, int64_t request)
-{
-	int64_t skipped = __archive_read_filter_skip(a->filter, request);
-	if (skipped > 0)
-		a->archive.file_position += skipped;
-	return (skipped);
-}
-
-int64_t
-__archive_read_filter_skip(struct archive_read_filter *filter, int64_t request)
+/*
+ * Advance the file pointer by the amount requested.
+ * Returns the amount actually advanced, which may be less than the
+ * request if EOF is encountered first.
+ * Returns a negative value if there's an I/O error.
+ */
+static int64_t
+advance_file_pointer(struct archive_read_filter *filter, int64_t request)
 {
 	int64_t bytes_skipped, total_bytes_skipped = 0;
+	ssize_t bytes_read;
 	size_t min;
 
 	if (filter->fatal)
 		return (-1);
-	/*
-	 * If there is data in the buffers already, use that first.
-	 */
+
+	/* Use up the copy buffer first. */
 	if (filter->avail > 0) {
-		min = minimum(request, (off_t)filter->avail);
-		bytes_skipped = __archive_read_filter_consume(filter, min);
-		request -= bytes_skipped;
-		total_bytes_skipped += bytes_skipped;
+		min = minimum(request, (int64_t)filter->avail);
+		filter->next += min;
+		filter->avail -= min;
+		request -= min;
+		filter->position += min;
+		total_bytes_skipped += min;
 	}
+
+	/* Then use up the client buffer. */
 	if (filter->client_avail > 0) {
 		min = minimum(request, (int64_t)filter->client_avail);
-		bytes_skipped = __archive_read_filter_consume(filter, min);
-		request -= bytes_skipped;
-		total_bytes_skipped += bytes_skipped;
+		filter->client_next += min;
+		filter->client_avail -= min;
+		request -= min;
+		filter->position += min;
+		total_bytes_skipped += min;
 	}
 	if (request == 0)
 		return (total_bytes_skipped);
-	/*
-	 * If a client_skipper was provided, try that first.
-	 */
-#if ARCHIVE_API_VERSION < 2
-	if ((filter->skip != NULL) && (request < SSIZE_MAX)) {
-#else
+
+	/* If there's an optimized skip function, use it. */
 	if (filter->skip != NULL) {
-#endif
 		bytes_skipped = (filter->skip)(filter, request);
 		if (bytes_skipped < 0) {	/* error */
-			filter->client_total = filter->client_avail = 0;
-			filter->client_next = filter->client_buff = NULL;
 			filter->fatal = 1;
 			return (bytes_skipped);
 		}
+		filter->position += bytes_skipped;
 		total_bytes_skipped += bytes_skipped;
 		request -= bytes_skipped;
-		filter->client_next = filter->client_buff;
-		filter->client_avail = filter->client_total = 0;
+		if (request == 0)
+			return (total_bytes_skipped);
 	}
-	/*
-	 * Note that client_skipper will usually not satisfy the
-	 * full request (due to low-level blocking concerns),
-	 * so even if client_skipper is provided, we may still
-	 * have to use ordinary reads to finish out the request.
-	 */
-	while (request > 0) {
-		ssize_t bytes_read;
-		(void)__archive_read_filter_ahead(filter, 1, &bytes_read);
-		if (bytes_read < 0)
+
+	/* Use ordinary reads as necessary to complete the request. */
+	for (;;) {
+		bytes_read = (filter->read)(filter, &filter->client_buff);
+		if (bytes_read < 0) {
+			filter->client_buff = NULL;
+			filter->fatal = 1;
 			return (bytes_read);
+		}
+
 		if (bytes_read == 0) {
+			filter->client_buff = NULL;
+			filter->end_of_file = 1;
 			return (total_bytes_skipped);
 		}
-		min = (size_t)(minimum(bytes_read, request));
-		bytes_read = __archive_read_filter_consume(filter, min);
+
+		if (bytes_read >= request) {
+			filter->client_next =
+			    ((const char *)filter->client_buff) + request;
+			filter->client_avail = bytes_read - request;
+			filter->client_total = bytes_read;
+			total_bytes_skipped += request;
+			filter->position += request;
+			return (total_bytes_skipped);
+		}
+
+		filter->position += bytes_read;
 		total_bytes_skipped += bytes_read;
 		request -= bytes_read;
 	}
-	return (total_bytes_skipped);
 }
+
+/**
+ * Returns ARCHIVE_FAILED if seeking isn't supported.
+ */
+int64_t
+__archive_read_seek(struct archive_read *a, int64_t offset, int whence)
+{
+	return __archive_read_filter_seek(a->filter, offset, whence);
+}
+
+int64_t
+__archive_read_filter_seek(struct archive_read_filter *filter, int64_t offset, int whence)
+{
+	int64_t r;
+
+	if (filter->closed || filter->fatal)
+		return (ARCHIVE_FATAL);
+	if (filter->seek == NULL)
+		return (ARCHIVE_FAILED);
+	r = filter->seek(filter, offset, whence);
+	if (r >= 0) {
+		/*
+		 * Ouch.  Clearing the buffer like this hurts, especially
+		 * at bid time.  A lot of our efficiency at bid time comes
+		 * from having bidders reuse the data we've already read.
+		 *
+		 * TODO: If the seek request is in data we already
+		 * have, then don't call the seek callback.
+		 *
+		 * TODO: Zip seeks to end-of-file at bid time.  If
+		 * other formats also start doing this, we may need to
+		 * find a way for clients to fudge the seek offset to
+		 * a block boundary.
+		 *
+		 * Hmmm... If whence was SEEK_END, we know the file
+		 * size is (r - offset).  Can we use that to simplify
+		 * the TODO items above?
+		 */
+		filter->avail = filter->client_avail = 0;
+		filter->next = filter->buffer;
+		filter->position = r;
+		filter->end_of_file = 0;
+	}
+	return r;
+}
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_read_data_into_fd.c
--- a/head/contrib/libarchive/libarchive/archive_read_data_into_fd.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_read_data_into_fd.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_data_into_fd.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_data_into_fd.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
@@ -45,31 +45,68 @@
 /*
  * This implementation minimizes copying of data and is sparse-file aware.
  */
+static int
+pad_to(struct archive *a, int fd, int can_lseek,
+    size_t nulls_size, const char *nulls,
+    int64_t target_offset, int64_t actual_offset)
+{
+	size_t to_write;
+	ssize_t bytes_written;
+
+	if (can_lseek) {
+		actual_offset = lseek(fd,
+		    target_offset - actual_offset, SEEK_CUR);
+		if (actual_offset != target_offset) {
+			archive_set_error(a, errno, "Seek error");
+			return (ARCHIVE_FATAL);
+		}
+		return (ARCHIVE_OK);
+	}
+	while (target_offset > actual_offset) {
+		to_write = nulls_size;
+		if (target_offset < actual_offset + (int64_t)nulls_size)
+			to_write = (size_t)(target_offset - actual_offset);
+		bytes_written = write(fd, nulls, to_write);
+		if (bytes_written < 0) {
+			archive_set_error(a, errno, "Write error");
+			return (ARCHIVE_FATAL);
+		}
+		actual_offset += bytes_written;
+	}
+	return (ARCHIVE_OK);
+}
+
+
 int
 archive_read_data_into_fd(struct archive *a, int fd)
 {
-	int r;
+	struct stat st;
+	int r, r2;
 	const void *buff;
 	size_t size, bytes_to_write;
-	ssize_t bytes_written, total_written;
-	off_t offset;
-	off_t output_offset;
+	ssize_t bytes_written;
+	int64_t target_offset;
+	int64_t actual_offset = 0;
+	int can_lseek;
+	char *nulls = NULL;
+	size_t nulls_size = 16384;
 
-	__archive_check_magic(a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_DATA, "archive_read_data_into_fd");
+	archive_check_magic(a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_DATA,
+	    "archive_read_data_into_fd");
 
-	total_written = 0;
-	output_offset = 0;
+	can_lseek = (fstat(fd, &st) == 0) && S_ISREG(st.st_mode);
+	if (!can_lseek)
+		nulls = calloc(1, nulls_size);
 
-	while ((r = archive_read_data_block(a, &buff, &size, &offset)) ==
+	while ((r = archive_read_data_block(a, &buff, &size, &target_offset)) ==
 	    ARCHIVE_OK) {
 		const char *p = buff;
-		if (offset > output_offset) {
-			output_offset = lseek(fd,
-			    offset - output_offset, SEEK_CUR);
-			if (output_offset != offset) {
-				archive_set_error(a, errno, "Seek error");
-				return (ARCHIVE_FATAL);
-			}
+		if (target_offset > actual_offset) {
+			r = pad_to(a, fd, can_lseek, nulls_size, nulls,
+			    target_offset, actual_offset);
+			if (r != ARCHIVE_OK)
+				break;
+			actual_offset = target_offset;
 		}
 		while (size > 0) {
 			bytes_to_write = size;
@@ -78,15 +115,24 @@
 			bytes_written = write(fd, p, bytes_to_write);
 			if (bytes_written < 0) {
 				archive_set_error(a, errno, "Write error");
-				return (ARCHIVE_FATAL);
+				r = ARCHIVE_FATAL;
+				goto cleanup;
 			}
-			output_offset += bytes_written;
-			total_written += bytes_written;
+			actual_offset += bytes_written;
 			p += bytes_written;
 			size -= bytes_written;
 		}
 	}
 
+	if (r == ARCHIVE_EOF && target_offset > actual_offset) {
+		r2 = pad_to(a, fd, can_lseek, nulls_size, nulls,
+		    target_offset, actual_offset);
+		if (r2 != ARCHIVE_OK)
+			r = r2;
+	}
+
+cleanup:
+	free(nulls);
 	if (r != ARCHIVE_EOF)
 		return (r);
 	return (ARCHIVE_OK);
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_read_disk.3
--- a/head/contrib/libarchive/libarchive/archive_read_disk.3	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_read_disk.3	Fri Mar 02 16:54:40 2012 +0200
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $FreeBSD: head/contrib/libarchive/libarchive/archive_read_disk.3 228773 2011-12-21 15:18:52Z mm $
+.\" $FreeBSD: head/contrib/libarchive/libarchive/archive_read_disk.3 232153 2012-02-25 10:58:02Z mm $
 .\"
 .Dd March 10, 2009
 .Dt ARCHIVE_READ_DISK 3
@@ -39,6 +39,7 @@
 .Nm archive_read_disk_set_gname_lookup ,
 .Nm archive_read_disk_set_standard_lookup ,
 .Nm archive_read_close ,
+.Nm archive_read_finish ,
 .Nm archive_read_free
 .Nd functions for reading objects from disk
 .Sh SYNOPSIS
@@ -81,6 +82,8 @@
 .Ft int
 .Fn archive_read_close "struct archive *"
 .Ft int
+.Fn archive_read_finish "struct archive *"
+.Ft int
 .Fn archive_read_free "struct archive *"
 .Sh DESCRIPTION
 These functions provide an API for reading information about
@@ -177,7 +180,12 @@
 .Tn struct archive_entry
 object.
 .It Fn archive_read_close
-This currently does nothing.
+Does nothing for
+.Tn archive_read_disk
+handles.
+.It Fn archive_read_finish
+This is a deprecated synonym for
+.Fn archive_read_free .
 .It Fn archive_read_free
 Invokes
 .Fn archive_read_close
@@ -207,7 +215,7 @@
   fd = open(name, O_RDONLY);
   if (fd < 0)
      return;
-  archive_entry_copy_sourcepath(entry, name);
+  archive_entry_copy_pathname(entry, name);
   archive_read_disk_entry_from_file(ard, entry, fd, NULL);
   archive_write_header(a, entry);
   while ((bytes_read = read(fd, buff, sizeof(buff))) > 0)
@@ -229,15 +237,6 @@
 for unusual conditions that do not prevent further operations, and
 .Cm ARCHIVE_FATAL
 for serious errors that make remaining operations impossible.
-The
-.Xr archive_errno 3
-and
-.Xr archive_error_string 3
-functions can be used to retrieve an appropriate error code and a
-textual error message.
-(See
-.Xr archive_util 3
-for details.)
 .Pp
 .Fn archive_read_disk_new
 returns a pointer to a newly-allocated
@@ -253,9 +252,17 @@
 The returned pointer points to internal storage that
 may be reused on the next call to either of these functions;
 callers should copy the string if they need to continue accessing it.
-.Pp
+.\"
+.Sh ERRORS
+Detailed error codes and textual descriptions are available from the
+.Fn archive_errno
+and
+.Fn archive_error_string
+functions.
+.\"
 .Sh SEE ALSO
 .Xr archive_read 3 ,
+.Xr archive_util 3 ,
 .Xr archive_write 3 ,
 .Xr archive_write_disk 3 ,
 .Xr tar 1 ,
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c
--- a/head/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,6 @@
 /*-
  * Copyright (c) 2003-2009 Tim Kientzle
+ * Copyright (c) 2010 Michihiro NAKAJIMA
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -24,7 +25,10 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c 232153 2012-02-25 10:58:02Z mm $");
+
+/* This is the tree-walking code for POSIX systems. */
+#if !defined(_WIN32) || defined(__CYGWIN__)
 
 #ifdef HAVE_SYS_TYPES_H
 /* Mac OSX requires sys/types.h before sys/acl.h. */
@@ -36,6 +40,9 @@
 #ifdef HAVE_SYS_EXTATTR_H
 #include <sys/extattr.h>
 #endif
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
 #ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
 #endif
@@ -45,20 +52,48 @@
 #ifdef HAVE_SYS_XATTR_H
 #include <sys/xattr.h>
 #endif
+#ifdef HAVE_SYS_EA_H
+#include <sys/ea.h>
+#endif
 #ifdef HAVE_ACL_LIBACL_H
 #include <acl/libacl.h>
 #endif
 #ifdef HAVE_ATTR_XATTR_H
 #include <attr/xattr.h>
 #endif
+#ifdef HAVE_COPYFILE_H
+#include <copyfile.h>
+#endif
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
 #endif
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
 #ifdef HAVE_LIMITS_H
 #include <limits.h>
 #endif
-#ifdef HAVE_WINDOWS_H
-#include <windows.h>
+#ifdef HAVE_LINUX_FIEMAP_H
+#include <linux/fiemap.h>
+#endif
+#ifdef HAVE_LINUX_FS_H
+#include <linux/fs.h>
+#endif
+/*
+ * Some Linux distributions have both linux/ext2_fs.h and ext2fs/ext2_fs.h.
+ * As the include guards don't agree, the order of include is important.
+ */
+#ifdef HAVE_LINUX_EXT2_FS_H
+#include <linux/ext2_fs.h>      /* for Linux file flags */
+#endif
+#if defined(HAVE_EXT2FS_EXT2_FS_H) && !defined(__CYGWIN__)
+#include <ext2fs/ext2_fs.h>     /* Linux file flags, broken on Cygwin */
+#endif
+#ifdef HAVE_PATHS_H
+#include <paths.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
 #endif
 
 #include "archive.h"
@@ -78,13 +113,18 @@
 
 static int setup_acls_posix1e(struct archive_read_disk *,
     struct archive_entry *, int fd);
+static int setup_mac_metadata(struct archive_read_disk *,
+    struct archive_entry *, int fd);
 static int setup_xattrs(struct archive_read_disk *,
     struct archive_entry *, int fd);
+static int setup_sparse(struct archive_read_disk *,
+    struct archive_entry *, int fd);
 
 int
 archive_read_disk_entry_from_file(struct archive *_a,
     struct archive_entry *entry,
-    int fd, const struct stat *st)
+    int fd,
+    const struct stat *st)
 {
 	struct archive_read_disk *a = (struct archive_read_disk *)_a;
 	const char *path, *name;
@@ -97,54 +137,35 @@
 	if (path == NULL)
 		path = archive_entry_pathname(entry);
 
-#ifdef EXT2_IOC_GETFLAGS
-	/* Linux requires an extra ioctl to pull the flags.  Although
-	 * this is an extra step, it has a nice side-effect: We get an
-	 * open file descriptor which we can use in the subsequent lookups. */
-	if ((S_ISREG(st->st_mode) || S_ISDIR(st->st_mode))) {
-		if (fd < 0)
-			fd = open(pathname, O_RDONLY | O_NONBLOCK | O_BINARY);
-		if (fd >= 0) {
-			unsigned long stflags;
-			int r = ioctl(fd, EXT2_IOC_GETFLAGS, &stflags);
-			if (r == 0 && stflags != 0)
-				archive_entry_set_fflags(entry, stflags, 0);
-		}
-	}
+	if (a->tree == NULL) {
+		if (st == NULL) {
+#if HAVE_FSTAT
+			if (fd >= 0) {
+				if (fstat(fd, &s) != 0) {
+					archive_set_error(&a->archive, errno,
+					    "Can't fstat");
+					return (ARCHIVE_FAILED);
+				}
+			} else
 #endif
-
-	if (st == NULL) {
-		/* TODO: On Windows, use GetFileInfoByHandle() here.
-		 * Using Windows stat() call is badly broken, but
-		 * even the stat() wrapper has problems because
-		 * 'struct stat' is broken on Windows.
-		 */
-#if HAVE_FSTAT
-		if (fd >= 0) {
-			if (fstat(fd, &s) != 0) {
+#if HAVE_LSTAT
+			if (!a->follow_symlinks) {
+				if (lstat(path, &s) != 0) {
+					archive_set_error(&a->archive, errno,
+					    "Can't lstat %s", path);
+					return (ARCHIVE_FAILED);
+				}
+			} else
+#endif
+			if (stat(path, &s) != 0) {
 				archive_set_error(&a->archive, errno,
-				    "Can't fstat");
+				    "Can't stat %s", path);
 				return (ARCHIVE_FAILED);
 			}
-		} else
-#endif
-#if HAVE_LSTAT
-		if (!a->follow_symlinks) {
-			if (lstat(path, &s) != 0) {
-				archive_set_error(&a->archive, errno,
-				    "Can't lstat %s", path);
-				return (ARCHIVE_FAILED);
-			}
-		} else
-#endif
-		if (stat(path, &s) != 0) {
-			archive_set_error(&a->archive, errno,
-			    "Can't lstat %s", path);
-			return (ARCHIVE_FAILED);
+			st = &s;
 		}
-		st = &s;
+		archive_entry_copy_stat(entry, st);
 	}
-	archive_entry_copy_stat(entry, st);
 
 	/* Lookup uname/gname */
 	name = archive_read_disk_uname(_a, archive_entry_uid(entry));
@@ -161,30 +182,185 @@
 		archive_entry_set_fflags(entry, st->st_flags, 0);
 #endif
 
-#ifdef HAVE_READLINK
+#if defined(EXT2_IOC_GETFLAGS) && defined(HAVE_WORKING_EXT2_IOC_GETFLAGS)
+	/* Linux requires an extra ioctl to pull the flags.  Although
+	 * this is an extra step, it has a nice side-effect: We get an
+	 * open file descriptor which we can use in the subsequent lookups. */
+	if ((S_ISREG(st->st_mode) || S_ISDIR(st->st_mode))) {
+		if (fd < 0)
+			fd = open(path, O_RDONLY | O_NONBLOCK);
+		if (fd >= 0) {
+			unsigned long stflags;
+			r = ioctl(fd, EXT2_IOC_GETFLAGS, &stflags);
+			if (r == 0 && stflags != 0)
+				archive_entry_set_fflags(entry, stflags, 0);
+		}
+	}
+#endif
+
+#if defined(HAVE_READLINK) || defined(HAVE_READLINKAT)
 	if (S_ISLNK(st->st_mode)) {
-		char linkbuffer[PATH_MAX + 1];
-		int lnklen = readlink(path, linkbuffer, PATH_MAX);
+		size_t linkbuffer_len = st->st_size + 1;
+		char *linkbuffer;
+		int lnklen;
+
+		linkbuffer = malloc(linkbuffer_len);
+		if (linkbuffer == NULL) {
+			archive_set_error(&a->archive, ENOMEM,
+			    "Couldn't read link data");
+			return (ARCHIVE_FAILED);
+		}
+#ifdef HAVE_READLINKAT
+		if (a->entry_wd_fd >= 0)
+			lnklen = readlinkat(a->entry_wd_fd, path,
+			    linkbuffer, linkbuffer_len);
+		else
+#endif /* HAVE_READLINKAT */
+		lnklen = readlink(path, linkbuffer, linkbuffer_len);
 		if (lnklen < 0) {
 			archive_set_error(&a->archive, errno,
 			    "Couldn't read link data");
+			free(linkbuffer);
 			return (ARCHIVE_FAILED);
 		}
 		linkbuffer[lnklen] = 0;
 		archive_entry_set_symlink(entry, linkbuffer);
+		free(linkbuffer);
 	}
-#endif
+#endif /* HAVE_READLINK || HAVE_READLINKAT */
 
 	r = setup_acls_posix1e(a, entry, fd);
 	r1 = setup_xattrs(a, entry, fd);
 	if (r1 < r)
 		r = r1;
+	r1 = setup_mac_metadata(a, entry, fd);
+	if (r1 < r)
+		r = r1;
+	r1 = setup_sparse(a, entry, fd);
+	if (r1 < r)
+		r = r1;
+
 	/* If we opened the file earlier in this function, close it. */
 	if (initial_fd != fd)
 		close(fd);
 	return (r);
 }
 
+#if defined(__APPLE__) && defined(HAVE_COPYFILE_H)
+/*
+ * The Mac OS "copyfile()" API copies the extended metadata for a
+ * file into a separate file in AppleDouble format (see RFC 1740).
+ *
+ * Mac OS tar and cpio implementations store this extended
+ * metadata as a separate entry just before the regular entry
+ * with a "._" prefix added to the filename.
+ *
+ * Note that this is currently done unconditionally; the tar program has
+ * an option to discard this information before the archive is written.
+ *
+ * TODO: If there's a failure, report it and return ARCHIVE_WARN.
+ */
+static int
+setup_mac_metadata(struct archive_read_disk *a,
+    struct archive_entry *entry, int fd)
+{
+	int tempfd = -1;
+	int copyfile_flags = COPYFILE_NOFOLLOW | COPYFILE_ACL | COPYFILE_XATTR;
+	struct stat copyfile_stat;
+	int ret = ARCHIVE_OK;
+	void *buff;
+	int have_attrs;
+	const char *name, *tempdir, *tempfile = NULL;
+
+	name = archive_entry_sourcepath(entry);
+	if (name == NULL)
+		name = archive_entry_pathname(entry);
+	if (name == NULL) {
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+		    "Can't open file to read extended attributes: No name");
+		return (ARCHIVE_WARN);
+	}
+
+	/* Short-circuit if there's nothing to do. */
+	have_attrs = copyfile(name, NULL, 0, copyfile_flags | COPYFILE_CHECK);
+	if (have_attrs == -1) {
+		archive_set_error(&a->archive, errno,
+			"Could not check extended attributes");
+		return (ARCHIVE_WARN);
+	}
+	if (have_attrs == 0)
+		return (ARCHIVE_OK);
+
+	tempdir = NULL;
+	if (issetugid() == 0)
+		tempdir = getenv("TMPDIR");
+	if (tempdir == NULL)
+		tempdir = _PATH_TMP;
+	tempfile = tempnam(tempdir, "tar.md.");
+
+	/* XXX I wish copyfile() could pack directly to a memory
+	 * buffer; that would avoid the temp file here.  For that
+	 * matter, it would be nice if fcopyfile() actually worked,
+	 * that would reduce the many open/close races here. */
+	if (copyfile(name, tempfile, 0, copyfile_flags | COPYFILE_PACK)) {
+		archive_set_error(&a->archive, errno,
+		    "Could not pack extended attributes");
+		ret = ARCHIVE_WARN;
+		goto cleanup;
+	}
+	tempfd = open(tempfile, O_RDONLY);
+	if (tempfd < 0) {
+		archive_set_error(&a->archive, errno,
+		    "Could not open extended attribute file");
+		ret = ARCHIVE_WARN;
+		goto cleanup;
+	}
+	if (fstat(tempfd, &copyfile_stat)) {
+		archive_set_error(&a->archive, errno,
+		    "Could not check size of extended attributes");
+		ret = ARCHIVE_WARN;
+		goto cleanup;
+	}
+	buff = malloc(copyfile_stat.st_size);
+	if (buff == NULL) {
+		archive_set_error(&a->archive, errno,
+		    "Could not allocate memory for extended attributes");
+		ret = ARCHIVE_WARN;
+		goto cleanup;
+	}
+	if (copyfile_stat.st_size != read(tempfd, buff, copyfile_stat.st_size)) {
+		archive_set_error(&a->archive, errno,
+		    "Could not read extended attributes into memory");
+		ret = ARCHIVE_WARN;
+		goto cleanup;
+	}
+	archive_entry_copy_mac_metadata(entry, buff, copyfile_stat.st_size);
+
+cleanup:
+	if (tempfd >= 0)
+		close(tempfd);
+	if (tempfile != NULL)
+		unlink(tempfile);
+	return (ret);
+}
+
+#else
+
+/*
+ * Stub implementation for non-Mac systems.
+ */
+static int
+setup_mac_metadata(struct archive_read_disk *a,
+    struct archive_entry *entry, int fd)
+{
+	(void)a; /* UNUSED */
+	(void)entry; /* UNUSED */
+	(void)fd; /* UNUSED */
+	return (ARCHIVE_OK);
+}
+#endif
+
+
 #ifdef HAVE_POSIX_ACL
 static void setup_acl_posix1e(struct archive_read_disk *a,
     struct archive_entry *entry, acl_t acl, int archive_entry_acl_type);
@@ -307,10 +483,12 @@
 }
 #endif
 
-#if HAVE_LISTXATTR && HAVE_LLISTXATTR && HAVE_GETXATTR && HAVE_LGETXATTR
+#if (HAVE_FGETXATTR && HAVE_FLISTXATTR && HAVE_LISTXATTR && \
+    HAVE_LLISTXATTR && HAVE_GETXATTR && HAVE_LGETXATTR) || \
+    (HAVE_FGETEA && HAVE_FLISTEA && HAVE_LISTEA)
 
 /*
- * Linux extended attribute support.
+ * Linux and AIX extended attribute support.
  *
  * TODO:  By using a stack-allocated buffer for the first
  * call to getxattr(), we might be able to avoid the second
@@ -329,16 +507,25 @@
 	void *value = NULL;
 	const char *accpath;
 
-	(void)fd; /* UNUSED */
-
 	accpath = archive_entry_sourcepath(entry);
 	if (accpath == NULL)
 		accpath = archive_entry_pathname(entry);
 
-	if (!a->follow_symlinks)
+#if HAVE_FGETXATTR
+	if (fd >= 0)
+		size = fgetxattr(fd, name, NULL, 0);
+	else if (!a->follow_symlinks)
 		size = lgetxattr(accpath, name, NULL, 0);
 	else
 		size = getxattr(accpath, name, NULL, 0);
+#elif HAVE_FGETEA
+	if (fd >= 0)
+		size = fgetea(fd, name, NULL, 0);
+	else if (!a->follow_symlinks)
+		size = lgetea(accpath, name, NULL, 0);
+	else
+		size = getea(accpath, name, NULL, 0);
+#endif
 
 	if (size == -1) {
 		archive_set_error(&a->archive, errno,
@@ -351,10 +538,21 @@
 		return (ARCHIVE_FATAL);
 	}
 
-	if (!a->follow_symlinks)
+#if HAVE_FGETXATTR
+	if (fd >= 0)
+		size = fgetxattr(fd, name, value, size);
+	else if (!a->follow_symlinks)
 		size = lgetxattr(accpath, name, value, size);
 	else
 		size = getxattr(accpath, name, value, size);
+#elif HAVE_FGETEA
+	if (fd >= 0)
+		size = fgetea(fd, name, value, size);
+	else if (!a->follow_symlinks)
+		size = lgetea(accpath, name, value, size);
+	else
+		size = getea(accpath, name, value, size);
+#endif
 
 	if (size == -1) {
 		archive_set_error(&a->archive, errno,
@@ -376,18 +574,28 @@
 	const char *path;
 	ssize_t list_size;
 
-
 	path = archive_entry_sourcepath(entry);
 	if (path == NULL)
 		path = archive_entry_pathname(entry);
 
-	if (!a->follow_symlinks)
+#if HAVE_FLISTXATTR
+	if (fd >= 0)
+		list_size = flistxattr(fd, NULL, 0);
+	else if (!a->follow_symlinks)
 		list_size = llistxattr(path, NULL, 0);
 	else
 		list_size = listxattr(path, NULL, 0);
+#elif HAVE_FLISTEA
+	if (fd >= 0)
+		list_size = flistea(fd, NULL, 0);
+	else if (!a->follow_symlinks)
+		list_size = llistea(path, NULL, 0);
+	else
+		list_size = listea(path, NULL, 0);
+#endif
 
 	if (list_size == -1) {
-		if (errno == ENOTSUP)
+		if (errno == ENOTSUP || errno == ENOSYS)
 			return (ARCHIVE_OK);
 		archive_set_error(&a->archive, errno,
 			"Couldn't list extended attributes");
@@ -402,10 +610,21 @@
 		return (ARCHIVE_FATAL);
 	}
 
-	if (!a->follow_symlinks)
+#if HAVE_FLISTXATTR
+	if (fd >= 0)
+		list_size = flistxattr(fd, list, list_size);
+	else if (!a->follow_symlinks)
 		list_size = llistxattr(path, list, list_size);
 	else
 		list_size = listxattr(path, list, list_size);
+#elif HAVE_FLISTEA
+	if (fd >= 0)
+		list_size = flistea(fd, list, list_size);
+	else if (!a->follow_symlinks)
+		list_size = llistea(path, list, list_size);
+	else
+		list_size = listea(path, list, list_size);
+#endif
 
 	if (list_size == -1) {
 		archive_set_error(&a->archive, errno,
@@ -449,13 +668,13 @@
 	void *value = NULL;
 	const char *accpath;
 
-	(void)fd; /* UNUSED */
-
 	accpath = archive_entry_sourcepath(entry);
 	if (accpath == NULL)
 		accpath = archive_entry_pathname(entry);
 
-	if (!a->follow_symlinks)
+	if (fd >= 0)
+		size = extattr_get_fd(fd, namespace, name, NULL, 0);
+	else if (!a->follow_symlinks)
 		size = extattr_get_link(accpath, namespace, name, NULL, 0);
 	else
 		size = extattr_get_file(accpath, namespace, name, NULL, 0);
@@ -471,7 +690,9 @@
 		return (ARCHIVE_FATAL);
 	}
 
-	if (!a->follow_symlinks)
+	if (fd >= 0)
+		size = extattr_get_fd(fd, namespace, name, value, size);
+	else if (!a->follow_symlinks)
 		size = extattr_get_link(accpath, namespace, name, value, size);
 	else
 		size = extattr_get_file(accpath, namespace, name, value, size);
@@ -502,7 +723,9 @@
 	if (path == NULL)
 		path = archive_entry_pathname(entry);
 
-	if (!a->follow_symlinks)
+	if (fd >= 0)
+		list_size = extattr_list_fd(fd, namespace, NULL, 0);
+	else if (!a->follow_symlinks)
 		list_size = extattr_list_link(path, namespace, NULL, 0);
 	else
 		list_size = extattr_list_file(path, namespace, NULL, 0);
@@ -523,7 +746,9 @@
 		return (ARCHIVE_FATAL);
 	}
 
-	if (!a->follow_symlinks)
+	if (fd >= 0)
+		list_size = extattr_list_fd(fd, namespace, list, list_size);
+	else if (!a->follow_symlinks)
 		list_size = extattr_list_link(path, namespace, list, list_size);
 	else
 		list_size = extattr_list_file(path, namespace, list, list_size);
@@ -568,3 +793,213 @@
 }
 
 #endif
+
+#if defined(HAVE_LINUX_FIEMAP_H)
+
+/*
+ * Linux sparse interface.
+ *
+ * The FIEMAP ioctl returns an "extent" for each physical allocation
+ * on disk.  We need to process those to generate a more compact list
+ * of logical file blocks.  We also need to be very careful to use
+ * FIEMAP_FLAG_SYNC here, since there are reports that Linux sometimes
+ * does not report allocations for newly-written data that hasn't
+ * been synced to disk.
+ *
+ * It's important to return a minimal sparse file list because we want
+ * to not trigger sparse file extensions if we don't have to, since
+ * not all readers support them.
+ */
+
+static int
+setup_sparse(struct archive_read_disk *a,
+    struct archive_entry *entry, int fd)
+{
+	char buff[4096];
+	struct fiemap *fm;
+	struct fiemap_extent *fe;
+	int64_t size;
+	int count, do_fiemap;
+	int initial_fd = fd;
+	int exit_sts = ARCHIVE_OK;
+
+	if (archive_entry_filetype(entry) != AE_IFREG
+	    || archive_entry_size(entry) <= 0
+	    || archive_entry_hardlink(entry) != NULL)
+		return (ARCHIVE_OK);
+
+	if (fd < 0) {
+		const char *path;
+
+		path = archive_entry_sourcepath(entry);
+		if (path == NULL)
+			path = archive_entry_pathname(entry);
+		fd = open(path, O_RDONLY | O_NONBLOCK);
+		if (fd < 0) {
+			archive_set_error(&a->archive, errno,
+			    "Can't open `%s'", path);
+			return (ARCHIVE_FAILED);
+		}
+	}
+
+	count = (sizeof(buff) - sizeof(*fm))/sizeof(*fe);
+	fm = (struct fiemap *)buff;
+	fm->fm_start = 0;
+	fm->fm_length = ~0ULL;;
+	fm->fm_flags = FIEMAP_FLAG_SYNC;
+	fm->fm_extent_count = count;
+	do_fiemap = 1;
+	size = archive_entry_size(entry);
+	for (;;) {
+		int i, r;
+
+		r = ioctl(fd, FS_IOC_FIEMAP, fm); 
+		if (r < 0) {
+			/* When errno is ENOTTY, it is better we should
+			 * return ARCHIVE_OK because an earlier version
+			 *(<2.6.28) cannot perfom FS_IOC_FIEMAP.
+			 * We should also check if errno is EOPNOTSUPP,
+			 * it means "Operation not supported". */
+			if (errno != ENOTTY && errno != EOPNOTSUPP) {
+				archive_set_error(&a->archive, errno,
+				    "FIEMAP failed");
+				exit_sts = ARCHIVE_FAILED;
+			}
+			goto exit_setup_sparse;
+		}
+		if (fm->fm_mapped_extents == 0)
+			break;
+		fe = fm->fm_extents;
+		for (i = 0; i < (int)fm->fm_mapped_extents; i++, fe++) {
+			if (!(fe->fe_flags & FIEMAP_EXTENT_UNWRITTEN)) {
+				/* The fe_length of the last block does not
+				 * adjust itself to its size files. */
+				int64_t length = fe->fe_length;
+				if (fe->fe_logical + length > (uint64_t)size)
+					length -= fe->fe_logical + length - size;
+				if (fe->fe_logical == 0 && length == size) {
+					/* This is not sparse. */
+					do_fiemap = 0;
+					break;
+				}
+				if (length > 0)
+					archive_entry_sparse_add_entry(entry,
+					    fe->fe_logical, length);
+			}
+			if (fe->fe_flags & FIEMAP_EXTENT_LAST)
+				do_fiemap = 0;
+		}
+		if (do_fiemap) {
+			fe = fm->fm_extents + fm->fm_mapped_extents -1;
+			fm->fm_start = fe->fe_logical + fe->fe_length;
+		} else
+			break;
+	}
+exit_setup_sparse:
+	if (initial_fd != fd)
+		close(fd);
+	return (exit_sts);
+}
+
+#elif defined(SEEK_HOLE) && defined(SEEK_DATA) && defined(_PC_MIN_HOLE_SIZE)
+
+/*
+ * FreeBSD and Solaris sparse interface.
+ */
+
+static int
+setup_sparse(struct archive_read_disk *a,
+    struct archive_entry *entry, int fd)
+{
+	int64_t size;
+	int initial_fd = fd;
+	off_t initial_off; /* FreeBSD/Solaris only, so off_t okay here */
+	off_t off_s, off_e; /* FreeBSD/Solaris only, so off_t okay here */
+	int exit_sts = ARCHIVE_OK;
+
+	if (archive_entry_filetype(entry) != AE_IFREG
+	    || archive_entry_size(entry) <= 0
+	    || archive_entry_hardlink(entry) != NULL)
+		return (ARCHIVE_OK);
+
+	/* Does filesystem support the reporting of hole ? */
+	if (fd >= 0) {
+		if (fpathconf(fd, _PC_MIN_HOLE_SIZE) <= 0)
+			return (ARCHIVE_OK);
+		initial_off = lseek(fd, 0, SEEK_CUR);
+		if (initial_off != 0)
+			lseek(fd, 0, SEEK_SET);
+	} else {
+		const char *path;
+
+		path = archive_entry_sourcepath(entry);
+		if (path == NULL)
+			path = archive_entry_pathname(entry);
+		if (pathconf(path, _PC_MIN_HOLE_SIZE) <= 0)
+			return (ARCHIVE_OK);
+		fd = open(path, O_RDONLY | O_NONBLOCK);
+		if (fd < 0) {
+			archive_set_error(&a->archive, errno,
+			    "Can't open `%s'", path);
+			return (ARCHIVE_FAILED);
+		}
+		initial_off = 0;
+	}
+
+	off_s = 0;
+	size = archive_entry_size(entry);
+	while (off_s < size) {
+		off_s = lseek(fd, off_s, SEEK_DATA);
+		if (off_s == (off_t)-1) {
+			if (errno == ENXIO)
+				break;/* no more hole */
+			archive_set_error(&a->archive, errno,
+			    "lseek(SEEK_HOLE) failed");
+			exit_sts = ARCHIVE_FAILED;
+			goto exit_setup_sparse;
+		}
+		off_e = lseek(fd, off_s, SEEK_HOLE);
+		if (off_s == (off_t)-1) {
+			if (errno == ENXIO) {
+				off_e = lseek(fd, 0, SEEK_END);
+				if (off_e != (off_t)-1)
+					break;/* no more data */
+			}
+			archive_set_error(&a->archive, errno,
+			    "lseek(SEEK_DATA) failed");
+			exit_sts = ARCHIVE_FAILED;
+			goto exit_setup_sparse;
+		}
+		if (off_s == 0 && off_e == size)
+			break;/* This is not spase. */
+		archive_entry_sparse_add_entry(entry, off_s,
+			off_e - off_s);
+		off_s = off_e;
+	}
+exit_setup_sparse:
+	if (initial_fd != fd)
+		close(fd);
+	else
+		lseek(fd, initial_off, SEEK_SET);
+	return (exit_sts);
+}
+
+#else
+
+/*
+ * Generic (stub) sparse support.
+ */
+static int
+setup_sparse(struct archive_read_disk *a,
+    struct archive_entry *entry, int fd)
+{
+	(void)a;     /* UNUSED */
+	(void)entry; /* UNUSED */
+	(void)fd;    /* UNUSED */
+	return (ARCHIVE_OK);
+}
+
+#endif
+
+#endif /* !defined(_WIN32) || defined(__CYGWIN__) */
+
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_read_disk_private.h
--- a/head/contrib/libarchive/libarchive/archive_read_disk_private.h	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_read_disk_private.h	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: head/contrib/libarchive/libarchive/archive_read_disk_private.h 228763 2011-12-21 11:13:29Z mm $
+ * $FreeBSD: head/contrib/libarchive/libarchive/archive_read_disk_private.h 232153 2012-02-25 10:58:02Z mm $
  */
 
 #ifndef __LIBARCHIVE_BUILD
@@ -33,6 +33,8 @@
 #ifndef ARCHIVE_READ_DISK_PRIVATE_H_INCLUDED
 #define ARCHIVE_READ_DISK_PRIVATE_H_INCLUDED
 
+struct tree;
+
 struct archive_read_disk {
 	struct archive	archive;
 
@@ -51,10 +53,17 @@
 	 */
 	char	follow_symlinks;  /* Either 'L' or 'P'. */
 
-	const char * (*lookup_gname)(void *private, gid_t gid);
+	/* Directory traversals. */
+	struct tree *tree;
+
+	/* Set 1 if users request to restore atime . */
+	int		 restore_time;
+	int		 entry_wd_fd;
+
+	const char * (*lookup_gname)(void *private, int64_t gid);
 	void	(*cleanup_gname)(void *private);
 	void	 *lookup_gname_data;
-	const char * (*lookup_uname)(void *private, gid_t gid);
+	const char * (*lookup_uname)(void *private, int64_t uid);
 	void	(*cleanup_uname)(void *private);
 	void	 *lookup_uname_data;
 };
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_read_disk_set_standard_lookup.c
--- a/head/contrib/libarchive/libarchive/archive_read_disk_set_standard_lookup.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_read_disk_set_standard_lookup.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_disk_set_standard_lookup.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_disk_set_standard_lookup.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
@@ -72,8 +72,8 @@
 	} cache[name_cache_size];
 };
 
-static const char *	lookup_gname(void *, gid_t);
-static const char *	lookup_uname(void *, uid_t);
+static const char *	lookup_gname(void *, int64_t);
+static const char *	lookup_uname(void *, int64_t);
 static void	cleanup(void *);
 static const char *	lookup_gname_helper(struct name_cache *, id_t gid);
 static const char *	lookup_uname_helper(struct name_cache *, id_t uid);
@@ -175,7 +175,7 @@
 }
 
 static const char *
-lookup_uname(void *data, uid_t uid)
+lookup_uname(void *data, int64_t uid)
 {
 	struct name_cache *uname_cache = (struct name_cache *)data;
 	return (lookup_name(uname_cache,
@@ -187,6 +187,8 @@
 lookup_uname_helper(struct name_cache *cache, id_t id)
 {
 	struct passwd	pwent, *result;
+	char * nbuff;
+	size_t nbuff_size;
 	int r;
 
 	if (cache->buff_size == 0) {
@@ -208,10 +210,12 @@
 		 * we just double it and try again.  Because the buffer
 		 * is kept around in the cache object, we shouldn't
 		 * have to do this very often. */
-		cache->buff_size *= 2;
-		cache->buff = realloc(cache->buff, cache->buff_size);
-		if (cache->buff == NULL)
+		nbuff_size = cache->buff_size * 2;
+		nbuff = realloc(cache->buff, nbuff_size);
+		if (nbuff == NULL)
 			break;
+		cache->buff = nbuff;
+		cache->buff_size = nbuff_size;
 	}
 	if (r != 0) {
 		archive_set_error(cache->archive, errno,
@@ -239,7 +243,7 @@
 #endif
 
 static const char *
-lookup_gname(void *data, gid_t gid)
+lookup_gname(void *data, int64_t gid)
 {
 	struct name_cache *gname_cache = (struct name_cache *)data;
 	return (lookup_name(gname_cache,
@@ -251,6 +255,8 @@
 lookup_gname_helper(struct name_cache *cache, id_t id)
 {
 	struct group	grent, *result;
+	char * nbuff;
+	size_t nbuff_size;
 	int r;
 
 	if (cache->buff_size == 0) {
@@ -270,10 +276,12 @@
 		/* ERANGE means our buffer was too small, but POSIX
 		 * doesn't tell us how big the buffer should be, so
 		 * we just double it and try again. */
-		cache->buff_size *= 2;
-		cache->buff = realloc(cache->buff, cache->buff_size);
-		if (cache->buff == NULL)
+		nbuff_size = cache->buff_size * 2;
+		nbuff = realloc(cache->buff, nbuff_size);
+		if (nbuff == NULL)
 			break;
+		cache->buff = nbuff;
+		cache->buff_size = nbuff_size;
 	}
 	if (r != 0) {
 		archive_set_error(cache->archive, errno,
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_read_extract.c
--- a/head/contrib/libarchive/libarchive/archive_read_extract.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_read_extract.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_extract.c 228773 2011-12-21 15:18:52Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_extract.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
@@ -100,8 +100,9 @@
 	int r, r2;
 
 	/* Set up for this particular entry. */
-	archive_write_disk_set_skip_file(ad,
-	    a->skip_file_dev, a->skip_file_ino);
+	if (a->skip_file_set)
+		archive_write_disk_set_skip_file(ad,
+		    a->skip_file_dev, a->skip_file_ino);
 	r = archive_write_header(ad, entry);
 	if (r < ARCHIVE_WARN)
 		r = ARCHIVE_WARN;
@@ -116,7 +117,7 @@
 		r2 = ARCHIVE_WARN;
 	/* Use the first message. */
 	if (r2 != ARCHIVE_OK && r == ARCHIVE_OK)
- 		archive_copy_error(&a->archive, ad);
+		archive_copy_error(&a->archive, ad);
 	/* Use the worst error return. */
 	if (r2 < r)
 		r = r2;
@@ -138,13 +139,15 @@
 static int
 copy_data(struct archive *ar, struct archive *aw)
 {
-	off_t offset;
+	int64_t offset;
 	const void *buff;
 	struct extract *extract;
 	size_t size;
 	int r;
 
 	extract = get_extract((struct archive_read *)ar);
+	if (extract == NULL)
+		return (ARCHIVE_FATAL);
 	for (;;) {
 		r = archive_read_data_block(ar, &buff, &size, &offset);
 		if (r == ARCHIVE_EOF)
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_read_open_fd.c
--- a/head/contrib/libarchive/libarchive/archive_read_open_fd.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_read_open_fd.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_open_fd.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_open_fd.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
@@ -53,17 +53,13 @@
 struct read_fd_data {
 	int	 fd;
 	size_t	 block_size;
-	char	 can_skip;
+	char	 use_lseek;
 	void	*buffer;
 };
 
 static int	file_close(struct archive *, void *);
 static ssize_t	file_read(struct archive *, void *, const void **buff);
-#if ARCHIVE_API_VERSION < 2
-static ssize_t	file_skip(struct archive *, void *, size_t request);
-#else
-static off_t	file_skip(struct archive *, void *, off_t request);
-#endif
+static int64_t	file_skip(struct archive *, void *, int64_t request);
 
 int
 archive_read_open_fd(struct archive *a, int fd, size_t block_size)
@@ -78,7 +74,7 @@
 		return (ARCHIVE_FATAL);
 	}
 
-	mine = (struct read_fd_data *)malloc(sizeof(*mine));
+	mine = (struct read_fd_data *)calloc(1, sizeof(*mine));
 	b = malloc(block_size);
 	if (mine == NULL || b == NULL) {
 		archive_set_error(a, ENOMEM, "No memory");
@@ -98,15 +94,17 @@
 	 */
 	if (S_ISREG(st.st_mode)) {
 		archive_read_extract_set_skip_file(a, st.st_dev, st.st_ino);
-		mine->can_skip = 1;
-	} else
-		mine->can_skip = 0;
+		mine->use_lseek = 1;
+	}
 #if defined(__CYGWIN__) || defined(_WIN32)
 	setmode(mine->fd, O_BINARY);
 #endif
 
-	return (archive_read_open2(a, mine,
-		NULL, file_read, file_skip, file_close));
+	archive_read_set_read_callback(a, file_read);
+	archive_read_set_skip_callback(a, file_skip);
+	archive_read_set_close_callback(a, file_close);
+	archive_read_set_callback_data(a, mine);
+	return (archive_read_open1(a));
 }
 
 static ssize_t
@@ -127,55 +125,48 @@
 	}
 }
 
-#if ARCHIVE_API_VERSION < 2
-static ssize_t
-file_skip(struct archive *a, void *client_data, size_t request)
-#else
-static off_t
-file_skip(struct archive *a, void *client_data, off_t request)
-#endif
+static int64_t
+file_skip(struct archive *a, void *client_data, int64_t request)
 {
 	struct read_fd_data *mine = (struct read_fd_data *)client_data;
+	off_t skip = (off_t)request;
 	off_t old_offset, new_offset;
+	int skip_bits = sizeof(skip) * 8 - 1;  /* off_t is a signed type. */
 
-	if (!mine->can_skip)
+	if (!mine->use_lseek)
 		return (0);
 
+	/* Reduce a request that would overflow the 'skip' variable. */
+	if (sizeof(request) > sizeof(skip)) {
+		int64_t max_skip =
+		    (((int64_t)1 << (skip_bits - 1)) - 1) * 2 + 1;
+		if (request > max_skip)
+			skip = max_skip;
+	}
+
 	/* Reduce request to the next smallest multiple of block_size */
 	request = (request / mine->block_size) * mine->block_size;
 	if (request == 0)
 		return (0);
 
+	if (((old_offset = lseek(mine->fd, 0, SEEK_CUR)) >= 0) &&
+	    ((new_offset = lseek(mine->fd, skip, SEEK_CUR)) >= 0))
+		return (new_offset - old_offset);
+
+	/* If seek failed once, it will probably fail again. */
+	mine->use_lseek = 0;
+
+	/* Let libarchive recover with read+discard. */
+	if (errno == ESPIPE)
+		return (0);
+
 	/*
-	 * Hurray for lazy evaluation: if the first lseek fails, the second
-	 * one will not be executed.
+	 * There's been an error other than ESPIPE. This is most
+	 * likely caused by a programmer error (too large request)
+	 * or a corrupted archive file.
 	 */
-	if (((old_offset = lseek(mine->fd, 0, SEEK_CUR)) < 0) ||
-	    ((new_offset = lseek(mine->fd, request, SEEK_CUR)) < 0))
-	{
-		/* If seek failed once, it will probably fail again. */
-		mine->can_skip = 0;
-
-		if (errno == ESPIPE)
-		{
-			/*
-			 * Failure to lseek() can be caused by the file
-			 * descriptor pointing to a pipe, socket or FIFO.
-			 * Return 0 here, so the compression layer will use
-			 * read()s instead to advance the file descriptor.
-			 * It's slower of course, but works as well.
-			 */
-			return (0);
-		}
-		/*
-		 * There's been an error other than ESPIPE. This is most
-		 * likely caused by a programmer error (too large request)
-		 * or a corrupted archive file.
-		 */
-		archive_set_error(a, errno, "Error seeking");
-		return (-1);
-	}
-	return (new_offset - old_offset);
+	archive_set_error(a, errno, "Error seeking");
+	return (-1);
 }
 
 static int
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_read_open_file.c
--- a/head/contrib/libarchive/libarchive/archive_read_open_file.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_read_open_file.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_open_file.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_open_file.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
@@ -59,11 +59,7 @@
 
 static int	file_close(struct archive *, void *);
 static ssize_t	file_read(struct archive *, void *, const void **buff);
-#if ARCHIVE_API_VERSION < 2
-static ssize_t	file_skip(struct archive *, void *, size_t request);
-#else
-static off_t	file_skip(struct archive *, void *, off_t request);
-#endif
+static int64_t	file_skip(struct archive *, void *, int64_t request);
 
 int
 archive_read_open_FILE(struct archive *a, FILE *f)
@@ -101,8 +97,11 @@
 	setmode(fileno(mine->f), O_BINARY);
 #endif
 
-	return (archive_read_open2(a, mine, NULL, file_read,
-		    file_skip, file_close));
+	archive_read_set_read_callback(a, file_read);
+	archive_read_set_skip_callback(a, file_skip);
+	archive_read_set_close_callback(a, file_close);
+	archive_read_set_callback_data(a, mine);
+	return (archive_read_open1(a));
 }
 
 static ssize_t
@@ -119,15 +118,18 @@
 	return (bytes_read);
 }
 
-#if ARCHIVE_API_VERSION < 2
-static ssize_t
-file_skip(struct archive *a, void *client_data, size_t request)
-#else
-static off_t
-file_skip(struct archive *a, void *client_data, off_t request)
-#endif
+static int64_t
+file_skip(struct archive *a, void *client_data, int64_t request)
 {
 	struct read_FILE_data *mine = (struct read_FILE_data *)client_data;
+#if HAVE_FSEEKO
+	off_t skip = (off_t)request;
+#elif HAVE__FSEEKI64
+	int64_t skip = request;
+#else
+	long skip = (long)request;
+#endif
+	int skip_bits = sizeof(skip) * 8 - 1;
 
 	(void)a; /* UNUSED */
 
@@ -140,10 +142,20 @@
 	if (request == 0)
 		return (0);
 
+	/* If request is too big for a long or an off_t, reduce it. */
+	if (sizeof(request) > sizeof(skip)) {
+		int64_t max_skip =
+		    (((int64_t)1 << (skip_bits - 1)) - 1) * 2 + 1;
+		if (request > max_skip)
+			skip = max_skip;
+	}
+
 #if HAVE_FSEEKO
-	if (fseeko(mine->f, request, SEEK_CUR) != 0)
+	if (fseeko(mine->f, skip, SEEK_CUR) != 0)
+#elif HAVE__FSEEKI64
+	if (_fseeki64(mine->f, skip, SEEK_CUR) != 0)
 #else
-	if (fseek(mine->f, request, SEEK_CUR) != 0)
+	if (fseek(mine->f, skip, SEEK_CUR) != 0)
 #endif
 	{
 		mine->can_skip = 0;
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_read_open_filename.c
--- a/head/contrib/libarchive/libarchive/archive_read_open_filename.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_read_open_filename.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2003-2010 Tim Kientzle
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -24,8 +24,11 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_open_filename.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_open_filename.c 232153 2012-02-25 10:58:02Z mm $");
 
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
 #endif
@@ -47,8 +50,17 @@
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#include <sys/disk.h>
+#elif defined(__NetBSD__) || defined(__OpenBSD__)
+#include <sys/disklabel.h>
+#include <sys/dkio.h>
+#elif defined(__DragonFly__)
+#include <sys/diskslice.h>
+#endif
 
 #include "archive.h"
+#include "archive_string.h"
 
 #ifndef O_BINARY
 #define O_BINARY 0
@@ -59,17 +71,21 @@
 	size_t	 block_size;
 	void	*buffer;
 	mode_t	 st_mode;  /* Mode bits for opened file. */
-	char	 can_skip; /* This file supports skipping. */
-	char	 filename[1]; /* Must be last! */
+	char	 use_lseek;
+	enum fnt_e { FNT_STDIN, FNT_MBS, FNT_WCS } filename_type;
+	union {
+		char	 m[1];/* MBS filename. */
+		wchar_t	 w[1];/* WCS filename. */
+	} filename; /* Must be last! */
 };
 
 static int	file_close(struct archive *, void *);
+static int	file_open_filename(struct archive *, enum fnt_e, const void *,
+		    size_t);
 static ssize_t	file_read(struct archive *, void *, const void **buff);
-#if ARCHIVE_API_VERSION < 2
-static ssize_t	file_skip(struct archive *, void *, size_t request);
-#else
-static off_t	file_skip(struct archive *, void *, off_t request);
-#endif
+static int64_t	file_seek(struct archive *, void *, int64_t request, int);
+static int64_t	file_skip(struct archive *, void *, int64_t request);
+static int64_t	file_skip_lseek(struct archive *, void *, int64_t request);
 
 int
 archive_read_open_file(struct archive *a, const char *filename,
@@ -82,14 +98,75 @@
 archive_read_open_filename(struct archive *a, const char *filename,
     size_t block_size)
 {
+	enum fnt_e filename_type;
+
+	if (filename == NULL || filename[0] == '\0') {
+		filename_type = FNT_STDIN;
+	} else
+		filename_type = FNT_MBS;
+	return (file_open_filename(a, filename_type, filename, block_size));
+}
+
+int
+archive_read_open_filename_w(struct archive *a, const wchar_t *wfilename,
+    size_t block_size)
+{
+	enum fnt_e filename_type;
+
+	if (wfilename == NULL || wfilename[0] == L'\0') {
+		filename_type = FNT_STDIN;
+	} else {
+#if defined(_WIN32) && !defined(__CYGWIN__)
+		filename_type = FNT_WCS;
+#else
+		/*
+		 * POSIX system does not support a wchar_t interface for
+		 * open() system call, so we have to translate a whcar_t
+		 * filename to multi-byte one and use it.
+		 */
+		struct archive_string fn;
+		int r;
+
+		archive_string_init(&fn);
+		if (archive_string_append_from_wcs(&fn, wfilename,
+		    wcslen(wfilename)) != 0) {
+			archive_set_error(a, EINVAL,
+			    "Failed to convert a wide-character filename to"
+			    " a multi-byte filename");
+			archive_string_free(&fn);
+			return (ARCHIVE_FATAL);
+		}
+		r = file_open_filename(a, FNT_MBS, fn.s, block_size);
+		archive_string_free(&fn);
+		return (r);
+#endif
+	}
+	return (file_open_filename(a, filename_type, wfilename, block_size));
+}
+
+static int
+file_open_filename(struct archive *a, enum fnt_e filename_type,
+    const void *_filename, size_t block_size)
+{
 	struct stat st;
 	struct read_file_data *mine;
-	void *b;
+	void *buffer;
+	const char *filename = NULL;
+	const wchar_t *wfilename = NULL;
 	int fd;
+	int is_disk_like = 0;
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+	off_t mediasize = 0; /* FreeBSD-specific, so off_t okay here. */
+#elif defined(__NetBSD__) || defined(__OpenBSD__)
+	struct disklabel dl;
+#elif defined(__DragonFly__)
+	struct partinfo pi;
+#endif
 
 	archive_clear_error(a);
-	if (filename == NULL || filename[0] == '\0') {
-		/* We used to invoke archive_read_open_fd(a,0,block_size)
+	if (filename_type == FNT_STDIN) {
+		/* We used to delegate stdin support by
+		 * directly calling archive_read_open_fd(a,0,block_size)
 		 * here, but that doesn't (and shouldn't) handle the
 		 * end-of-file flush when reading stdout from a pipe.
 		 * Basically, read_open_fd() is intended for folks who
@@ -97,60 +174,152 @@
 		 * API is intended to be a little smarter for folks who
 		 * want easy handling of the common case.
 		 */
-		filename = ""; /* Normalize NULL to "" */
 		fd = 0;
 #if defined(__CYGWIN__) || defined(_WIN32)
 		setmode(0, O_BINARY);
 #endif
-	} else {
+		filename = "";
+	} else if (filename_type == FNT_MBS) {
+		filename = (const char *)_filename;
 		fd = open(filename, O_RDONLY | O_BINARY);
 		if (fd < 0) {
 			archive_set_error(a, errno,
 			    "Failed to open '%s'", filename);
 			return (ARCHIVE_FATAL);
 		}
+	} else {
+#if defined(_WIN32) && !defined(__CYGWIN__)
+		wfilename = (const wchar_t *)_filename;
+		fd = _wopen(wfilename, O_RDONLY | O_BINARY);
+		if (fd < 0 && errno == ENOENT) {
+			wchar_t *fullpath;
+			fullpath = __la_win_permissive_name_w(wfilename);
+			if (fullpath != NULL) {
+				fd = _wopen(fullpath, O_RDONLY | O_BINARY);
+				free(fullpath);
+			}
+		}
+		if (fd < 0) {
+			archive_set_error(a, errno,
+			    "Failed to open '%S'", wfilename);
+			return (ARCHIVE_FATAL);
+		}
+#else
+		archive_set_error(a, ARCHIVE_ERRNO_MISC,
+		    "Unexpedted operation in archive_read_open_filename");
+		return (ARCHIVE_FATAL);
+#endif
 	}
 	if (fstat(fd, &st) != 0) {
-		archive_set_error(a, errno, "Can't stat '%s'", filename);
+		if (filename_type == FNT_WCS)
+			archive_set_error(a, errno, "Can't stat '%S'",
+			    wfilename);
+		else
+			archive_set_error(a, errno, "Can't stat '%s'",
+			    filename);
 		return (ARCHIVE_FATAL);
 	}
 
-	mine = (struct read_file_data *)calloc(1,
-	    sizeof(*mine) + strlen(filename));
-	b = malloc(block_size);
-	if (mine == NULL || b == NULL) {
+	/*
+	 * Determine whether the input looks like a disk device or a
+	 * tape device.  The results are used below to select an I/O
+	 * strategy:
+	 *  = "disk-like" devices support arbitrary lseek() and will
+	 *    support I/O requests of any size.  So we get easy skipping
+	 *    and can cheat on block sizes to get better performance.
+	 *  = "tape-like" devices require strict blocking and use
+	 *    specialized ioctls for seeking.
+	 *  = "socket-like" devices cannot seek at all but can improve
+	 *    performance by using nonblocking I/O to read "whatever is
+	 *    available right now".
+	 *
+	 * Right now, we only specially recognize disk-like devices,
+	 * but it should be straightforward to add probes and strategy
+	 * here for tape-like and socket-like devices.
+	 */
+	if (S_ISREG(st.st_mode)) {
+		/* Safety:  Tell the extractor not to overwrite the input. */
+		archive_read_extract_set_skip_file(a, st.st_dev, st.st_ino);
+		/* Regular files act like disks. */
+		is_disk_like = 1;
+	}
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+	/* FreeBSD: if it supports DIOCGMEDIASIZE ioctl, it's disk-like. */
+	else if (S_ISCHR(st.st_mode) &&
+	    ioctl(fd, DIOCGMEDIASIZE, &mediasize) == 0 &&
+	    mediasize > 0) {
+		is_disk_like = 1;
+	}
+#elif defined(__NetBSD__) || defined(__OpenBSD__)
+	/* Net/OpenBSD: if it supports DIOCGDINFO ioctl, it's disk-like. */
+	else if ((S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)) &&
+	    ioctl(fd, DIOCGDINFO, &dl) == 0 &&
+	    dl.d_partitions[DISKPART(st.st_rdev)].p_size > 0) {
+		is_disk_like = 1;
+	}
+#elif defined(__DragonFly__)
+	/* DragonFly BSD:  if it supports DIOCGPART ioctl, it's disk-like. */
+	else if (S_ISCHR(st.st_mode) &&
+	    ioctl(fd, DIOCGPART, &pi) == 0 &&
+	    pi.media_size > 0) {
+		is_disk_like = 1;
+	}
+#elif defined(__linux__)
+	/* Linux:  All block devices are disk-like. */
+	else if (S_ISBLK(st.st_mode) &&
+	    lseek(fd, 0, SEEK_CUR) == 0 &&
+	    lseek(fd, 0, SEEK_SET) == 0 &&
+	    lseek(fd, 0, SEEK_END) > 0 &&
+	    lseek(fd, 0, SEEK_SET) == 0) {
+		is_disk_like = 1;
+	}
+#endif
+	/* TODO: Add an "is_tape_like" variable and appropriate tests. */
+
+	if (filename_type == FNT_WCS)
+		mine = (struct read_file_data *)calloc(1,
+		    sizeof(*mine) + wcslen(wfilename) * sizeof(wchar_t));
+	else
+		mine = (struct read_file_data *)calloc(1,
+		    sizeof(*mine) + strlen(filename));
+	/* Disk-like devices prefer power-of-two block sizes.  */
+	/* Use provided block_size as a guide so users have some control. */
+	if (is_disk_like) {
+		size_t new_block_size = 64 * 1024;
+		while (new_block_size < block_size
+		    && new_block_size < 64 * 1024 * 1024)
+			new_block_size *= 2;
+		block_size = new_block_size;
+	}
+	buffer = malloc(block_size);
+	if (mine == NULL || buffer == NULL) {
 		archive_set_error(a, ENOMEM, "No memory");
 		free(mine);
-		free(b);
+		free(buffer);
 		return (ARCHIVE_FATAL);
 	}
-	strcpy(mine->filename, filename);
+	if (filename_type == FNT_WCS)
+		wcscpy(mine->filename.w, wfilename);
+	else
+		strcpy(mine->filename.m, filename);
+	mine->filename_type = filename_type;
 	mine->block_size = block_size;
-	mine->buffer = b;
+	mine->buffer = buffer;
 	mine->fd = fd;
 	/* Remember mode so close can decide whether to flush. */
 	mine->st_mode = st.st_mode;
-	/* If we're reading a file from disk, ensure that we don't
-	   overwrite it with an extracted file. */
-	if (S_ISREG(st.st_mode)) {
-		archive_read_extract_set_skip_file(a, st.st_dev, st.st_ino);
-		/*
-		 * Enabling skip here is a performance optimization
-		 * for anything that supports lseek().  On FreeBSD
-		 * (and probably many other systems), only regular
-		 * files and raw disk devices support lseek() (on
-		 * other input types, lseek() returns success but
-		 * doesn't actually change the file pointer, which
-		 * just completely screws up the position-tracking
-		 * logic).  In addition, I've yet to find a portable
-		 * way to determine if a device is a raw disk device.
-		 * So I don't see a way to do much better than to only
-		 * enable this optimization for regular files.
-		 */
-		mine->can_skip = 1;
+
+	/* Disk-like inputs can use lseek(). */
+	if (is_disk_like) {
+		archive_read_set_seek_callback(a, file_seek);
+		mine->use_lseek = 1;
 	}
-	return (archive_read_open2(a, mine,
-		NULL, file_read, file_skip, file_close));
+
+	archive_read_set_read_callback(a, file_read);
+	archive_read_set_skip_callback(a, file_skip);
+	archive_read_set_close_callback(a, file_close);
+	archive_read_set_callback_data(a, mine);
+	return (archive_read_open1(a));
 }
 
 static ssize_t
@@ -159,79 +328,146 @@
 	struct read_file_data *mine = (struct read_file_data *)client_data;
 	ssize_t bytes_read;
 
+	/* TODO: If a recent lseek() operation has left us
+	 * mis-aligned, read and return a short block to try to get
+	 * us back in alignment. */
+
+	/* TODO: Someday, try mmap() here; if that succeeds, give
+	 * the entire file to libarchive as a single block.  That
+	 * could be a lot faster than block-by-block manual I/O. */
+
+	/* TODO: We might be able to improve performance on pipes and
+	 * sockets by setting non-blocking I/O and just accepting
+	 * whatever we get here instead of waiting for a full block
+	 * worth of data. */
+
 	*buff = mine->buffer;
 	for (;;) {
 		bytes_read = read(mine->fd, mine->buffer, mine->block_size);
 		if (bytes_read < 0) {
 			if (errno == EINTR)
 				continue;
-			else if (mine->filename[0] == '\0')
-				archive_set_error(a, errno, "Error reading stdin");
+			else if (mine->filename_type == FNT_STDIN)
+				archive_set_error(a, errno,
+				    "Error reading stdin");
+			else if (mine->filename_type == FNT_MBS)
+				archive_set_error(a, errno,
+				    "Error reading '%s'", mine->filename.m);
 			else
-				archive_set_error(a, errno, "Error reading '%s'",
-				    mine->filename);
+				archive_set_error(a, errno,
+				    "Error reading '%S'", mine->filename.w);
 		}
 		return (bytes_read);
 	}
 }
 
-#if ARCHIVE_API_VERSION < 2
-static ssize_t
-file_skip(struct archive *a, void *client_data, size_t request)
-#else
-static off_t
-file_skip(struct archive *a, void *client_data, off_t request)
-#endif
+/*
+ * Regular files and disk-like block devices can use simple lseek
+ * without needing to round the request to the block size.
+ *
+ * TODO: This can leave future reads mis-aligned.  Since we know the
+ * offset here, we should store it and use it in file_read() above
+ * to determine whether we should perform a short read to get back
+ * into alignment.  Long series of mis-aligned reads can negatively
+ * impact disk throughput.  (Of course, the performance impact should
+ * be carefully tested; extra code complexity is only worthwhile if
+ * it does provide measurable improvement.)
+ *
+ * TODO: Be lazy about the actual seek.  There are a few pathological
+ * cases where libarchive makes a bunch of seek requests in a row
+ * without any intervening reads.  This isn't a huge performance
+ * problem, since the kernel handles seeks lazily already, but
+ * it would be very slightly faster if we simply remembered the
+ * seek request here and then actually performed the seek at the
+ * top of the read callback above.
+ */
+static int64_t
+file_skip_lseek(struct archive *a, void *client_data, int64_t request)
 {
 	struct read_file_data *mine = (struct read_file_data *)client_data;
+#if defined(_WIN32) && !defined(__CYGWIN__)
+	/* We use _lseeki64() on Windows. */
+	int64_t old_offset, new_offset;
+#else
 	off_t old_offset, new_offset;
+#endif
 
-	if (!mine->can_skip) /* We can't skip, so ... */
-		return (0); /* ... skip zero bytes. */
+	/* We use off_t here because lseek() is declared that way. */
 
-	/* Reduce request to the next smallest multiple of block_size */
-	request = (request / mine->block_size) * mine->block_size;
-	if (request == 0)
+	/* TODO: Deal with case where off_t isn't 64 bits.
+	 * This shouldn't be a problem on Linux or other POSIX
+	 * systems, since the configuration logic for libarchive
+	 * tries to obtain a 64-bit off_t.  It's still an issue
+	 * on Windows, though, so it might suffice to just use
+	 * _lseeki64() on Windows.
+	 */
+	if ((old_offset = lseek(mine->fd, 0, SEEK_CUR)) >= 0 &&
+	    (new_offset = lseek(mine->fd, request, SEEK_CUR)) >= 0)
+		return (new_offset - old_offset);
+
+	/* If lseek() fails, don't bother trying again. */
+	mine->use_lseek = 0;
+
+	/* Let libarchive recover with read+discard */
+	if (errno == ESPIPE)
 		return (0);
 
-	/*
-	 * Hurray for lazy evaluation: if the first lseek fails, the second
-	 * one will not be executed.
-	 */
-	if (((old_offset = lseek(mine->fd, 0, SEEK_CUR)) < 0) ||
-	    ((new_offset = lseek(mine->fd, request, SEEK_CUR)) < 0))
-	{
-		/* If skip failed once, it will probably fail again. */
-		mine->can_skip = 0;
+	/* If the input is corrupted or truncated, fail. */
+	if (mine->filename_type == FNT_STDIN)
+		archive_set_error(a, errno, "Error seeking in stdin");
+	else if (mine->filename_type == FNT_MBS)
+		archive_set_error(a, errno, "Error seeking in '%s'",
+		    mine->filename.m);
+	else
+		archive_set_error(a, errno, "Error seeking in '%S'",
+		    mine->filename.w);
+	return (-1);
+}
 
-		if (errno == ESPIPE)
-		{
-			/*
-			 * Failure to lseek() can be caused by the file
-			 * descriptor pointing to a pipe, socket or FIFO.
-			 * Return 0 here, so the compression layer will use
-			 * read()s instead to advance the file descriptor.
-			 * It's slower of course, but works as well.
-			 */
-			return (0);
-		}
-		/*
-		 * There's been an error other than ESPIPE. This is most
-		 * likely caused by a programmer error (too large request)
-		 * or a corrupted archive file.
-		 */
-		if (mine->filename[0] == '\0')
-			/*
-			 * Should never get here, since lseek() on stdin ought
-			 * to return an ESPIPE error.
-			 */
-			archive_set_error(a, errno, "Error seeking in stdin");
-		else
-			archive_set_error(a, errno, "Error seeking in '%s'",
-			    mine->filename);
-		return (-1);
-	}
-	return (new_offset - old_offset);
+
+/*
+ * TODO: Implement another file_skip_XXXX that uses MTIO ioctls to
+ * accelerate operation on tape drives.
+ */
+
+static int64_t
+file_skip(struct archive *a, void *client_data, int64_t request)
+{
+	struct read_file_data *mine = (struct read_file_data *)client_data;
+
+	/* Delegate skip requests. */
+	if (mine->use_lseek)
+		return (file_skip_lseek(a, client_data, request));
+
+	/* If we can't skip, return 0; libarchive will read+discard instead. */
+	return (0);
+}
+
+/*
+ * TODO: Store the offset and use it in the read callback.
+ */
+static int64_t
+file_seek(struct archive *a, void *client_data, int64_t request, int whence)
+{
+	struct read_file_data *mine = (struct read_file_data *)client_data;
+	off_t r;
+
+	/* We use off_t here because lseek() is declared that way. */
+	/* See above for notes about when off_t is less than 64 bits. */
+	r = lseek(mine->fd, request, whence);
+	if (r >= 0)
+		return r;
+
+	/* If the input is corrupted or truncated, fail. */
+	if (mine->filename_type == FNT_STDIN)
+		archive_set_error(a, errno, "Error seeking in stdin");
+	else if (mine->filename_type == FNT_MBS)
+		archive_set_error(a, errno, "Error seeking in '%s'",
+		    mine->filename.m);
+	else
+		archive_set_error(a, errno, "Error seeking in '%S'",
+		    mine->filename.w);
+	return (ARCHIVE_FATAL);
 }
 
 static int
@@ -246,7 +482,8 @@
 		/*
 		 * Sometimes, we should flush the input before closing.
 		 *   Regular files: faster to just close without flush.
-		 *   Devices: must not flush (user might need to
+		 *   Disk-like devices:  Ditto.
+		 *   Tapes: must not flush (user might need to
 		 *      read the "next" item on a non-rewind device).
 		 *   Pipes and sockets:  must flush (otherwise, the
 		 *      program feeding the pipe or socket may complain).
@@ -263,7 +500,7 @@
 			} while (bytesRead > 0);
 		}
 		/* If a named file was opened, then it needs to be closed. */
-		if (mine->filename[0] != '\0')
+		if (mine->filename_type != FNT_STDIN)
 			close(mine->fd);
 	}
 	free(mine->buffer);
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_read_open_memory.c
--- a/head/contrib/libarchive/libarchive/archive_read_open_memory.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_read_open_memory.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_open_memory.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_open_memory.c 232153 2012-02-25 10:58:02Z mm $");
 
 #include <errno.h>
 #include <stdlib.h>
@@ -41,18 +41,16 @@
  */
 
 struct read_memory_data {
-	unsigned char	*buffer;
+	unsigned char	*start;
+	unsigned char	*p;
 	unsigned char	*end;
 	ssize_t	 read_size;
 };
 
 static int	memory_read_close(struct archive *, void *);
 static int	memory_read_open(struct archive *, void *);
-#if ARCHIVE_API_VERSION < 2
-static ssize_t	memory_read_skip(struct archive *, void *, size_t request);
-#else
-static off_t	memory_read_skip(struct archive *, void *, off_t request);
-#endif
+static int64_t	memory_read_seek(struct archive *, void *, int64_t offset, int whence);
+static int64_t	memory_read_skip(struct archive *, void *, int64_t request);
 static ssize_t	memory_read(struct archive *, void *, const void **buff);
 
 int
@@ -78,11 +76,16 @@
 		return (ARCHIVE_FATAL);
 	}
 	memset(mine, 0, sizeof(*mine));
-	mine->buffer = (unsigned char *)buff;
-	mine->end = mine->buffer + size;
+	mine->start = mine->p = (unsigned char *)buff;
+	mine->end = mine->start + size;
 	mine->read_size = read_size;
-	return (archive_read_open2(a, mine, memory_read_open,
-		    memory_read, memory_read_skip, memory_read_close));
+	archive_read_set_open_callback(a, memory_read_open);
+	archive_read_set_read_callback(a, memory_read);
+	archive_read_set_seek_callback(a, memory_read_seek);
+	archive_read_set_skip_callback(a, memory_read_skip);
+	archive_read_set_close_callback(a, memory_read_close);
+	archive_read_set_callback_data(a, mine);
+	return (archive_read_open1(a));
 }
 
 /*
@@ -110,11 +113,11 @@
 	ssize_t size;
 
 	(void)a; /* UNUSED */
-	*buff = mine->buffer;
-	size = mine->end - mine->buffer;
+	*buff = mine->p;
+	size = mine->end - mine->p;
 	if (size > mine->read_size)
 		size = mine->read_size;
-        mine->buffer += size;
+        mine->p += size;
 	return (size);
 }
 
@@ -123,27 +126,55 @@
  * necessary in order to better exercise internal code when used
  * as a test harness.
  */
-#if ARCHIVE_API_VERSION < 2
-static ssize_t
-memory_read_skip(struct archive *a, void *client_data, size_t skip)
-#else
-static off_t
-memory_read_skip(struct archive *a, void *client_data, off_t skip)
-#endif
+static int64_t
+memory_read_skip(struct archive *a, void *client_data, int64_t skip)
 {
 	struct read_memory_data *mine = (struct read_memory_data *)client_data;
 
 	(void)a; /* UNUSED */
-	if ((off_t)skip > (off_t)(mine->end - mine->buffer))
-		skip = mine->end - mine->buffer;
+	if ((int64_t)skip > (int64_t)(mine->end - mine->p))
+		skip = mine->end - mine->p;
 	/* Round down to block size. */
 	skip /= mine->read_size;
 	skip *= mine->read_size;
-	mine->buffer += skip;
+	mine->p += skip;
 	return (skip);
 }
 
 /*
+ * Seeking.
+ */
+static int64_t
+memory_read_seek(struct archive *a, void *client_data, int64_t offset, int whence)
+{
+	struct read_memory_data *mine = (struct read_memory_data *)client_data;
+
+	(void)a; /* UNUSED */
+	switch (whence) {
+	case SEEK_SET:
+		mine->p = mine->start + offset;
+		break;
+	case SEEK_CUR:
+		mine->p += offset;
+		break;
+	case SEEK_END:
+		mine->p = mine->end + offset;
+		break;
+	default:
+		return ARCHIVE_FATAL;
+	}
+	if (mine->p < mine->start) {
+		mine->p = mine->start;
+		return ARCHIVE_FAILED;
+	}
+	if (mine->p > mine->end) {
+		mine->p = mine->end;
+		return ARCHIVE_FAILED;
+	}
+	return (mine->p - mine->start);
+}
+
+/*
  * Close is just cleaning up our one small bit of data.
  */
 static int
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_read_private.h
--- a/head/contrib/libarchive/libarchive/archive_read_private.h	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_read_private.h	Fri Mar 02 16:54:40 2012 +0200
@@ -22,7 +22,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: head/contrib/libarchive/libarchive/archive_read_private.h 228763 2011-12-21 11:13:29Z mm $
+ * $FreeBSD: head/contrib/libarchive/libarchive/archive_read_private.h 232153 2012-02-25 10:58:02Z mm $
  */
 
 #ifndef __LIBARCHIVE_BUILD
@@ -42,13 +42,18 @@
 
 /*
  * How bidding works for filters:
- *   * The bid manager reads the first block from the current source.
- *   * It shows that block to each registered bidder.
+ *   * The bid manager initializes the client-provided reader as the
+ *     first filter.
+ *   * It invokes the bidder for each registered filter with the
+ *     current head filter.
+ *   * The bidders can use archive_read_filter_ahead() to peek ahead
+ *     at the incoming data to compose their bids.
  *   * The bid manager creates a new filter structure for the winning
  *     bidder and gives the winning bidder a chance to initialize it.
- *   * The new filter becomes the top filter in the archive_read structure
- *     and we repeat the process.
- * This ends only when no bidder provides a non-zero bid.
+ *   * The new filter becomes the new top filter and we repeat the
+ *     process.
+ * This ends only when no bidder provides a non-zero bid.  Then
+ * we perform a similar dance with the registered format handlers.
  */
 struct archive_read_filter_bidder {
 	/* Configuration data for the bidder. */
@@ -71,6 +76,7 @@
  * corresponding bidder above.
  */
 struct archive_read_filter {
+	int64_t position;
 	/* Essentially all filters will need these values, so
 	 * just declare them here. */
 	struct archive_read_filter_bidder *bidder; /* My bidder. */
@@ -80,6 +86,8 @@
 	ssize_t (*read)(struct archive_read_filter *, const void **);
 	/* Skip forward this many bytes. */
 	int64_t (*skip)(struct archive_read_filter *self, int64_t request);
+	/* Seek to an absolute location. */
+	int64_t (*seek)(struct archive_read_filter *self, int64_t offset, int whence);
 	/* Close (just this filter) and free(self). */
 	int (*close)(struct archive_read_filter *self);
 	/* My private data. */
@@ -97,8 +105,8 @@
 	size_t		 client_total;
 	const char	*client_next;
 	size_t		 client_avail;
-	int64_t		 position;
 	char		 end_of_file;
+	char		 closed;
 	char		 fatal;
 };
 
@@ -111,9 +119,12 @@
  * so should be deferred at least until libarchive 3.0.
  */
 struct archive_read_client {
+	archive_open_callback	*opener;
 	archive_read_callback	*reader;
 	archive_skip_callback	*skipper;
+	archive_seek_callback	*seeker;
 	archive_close_callback	*closer;
+	void *data;
 };
 
 struct archive_read {
@@ -122,6 +133,7 @@
 	struct archive_entry	*entry;
 
 	/* Dev/ino of the archive being read/written. */
+	int		  skip_file_set;
 	dev_t		  skip_file_dev;
 	ino_t		  skip_file_ino;
 
@@ -130,21 +142,21 @@
 	 * data to client buffers, filling gaps with zero bytes.
 	 */
 	const char	 *read_data_block;
-	off_t		  read_data_offset;
-	off_t		  read_data_output_offset;
+	int64_t		  read_data_offset;
+	int64_t		  read_data_output_offset;
 	size_t		  read_data_remaining;
 
 	/* Callbacks to open/read/write/close client archive stream. */
 	struct archive_read_client client;
 
 	/* Registered filter bidders. */
-	struct archive_read_filter_bidder bidders[8];
+	struct archive_read_filter_bidder bidders[9];
 
 	/* Last filter in chain */
 	struct archive_read_filter *filter;
 
 	/* File offset of beginning of most recently-read header. */
-	off_t		  header_position;
+	int64_t		  header_position;
 
 	/*
 	 * Format detection is mostly the same as compression
@@ -157,14 +169,14 @@
 	struct archive_format_descriptor {
 		void	 *data;
 		const char *name;
-		int	(*bid)(struct archive_read *);
+		int	(*bid)(struct archive_read *, int best_bid);
 		int	(*options)(struct archive_read *, const char *key,
 		    const char *value);
 		int	(*read_header)(struct archive_read *, struct archive_entry *);
-		int	(*read_data)(struct archive_read *, const void **, size_t *, off_t *);
+		int	(*read_data)(struct archive_read *, const void **, size_t *, int64_t *);
 		int	(*read_data_skip)(struct archive_read *);
 		int	(*cleanup)(struct archive_read *);
-	}	formats[9];
+	}	formats[16];
 	struct archive_format_descriptor	*format; /* Active format. */
 
 	/*
@@ -177,23 +189,22 @@
 int	__archive_read_register_format(struct archive_read *a,
 	    void *format_data,
 	    const char *name,
-	    int (*bid)(struct archive_read *),
+	    int (*bid)(struct archive_read *, int),
 	    int (*options)(struct archive_read *, const char *, const char *),
 	    int (*read_header)(struct archive_read *, struct archive_entry *),
-	    int (*read_data)(struct archive_read *, const void **, size_t *, off_t *),
+	    int (*read_data)(struct archive_read *, const void **, size_t *, int64_t *),
 	    int (*read_data_skip)(struct archive_read *),
 	    int (*cleanup)(struct archive_read *));
 
-struct archive_read_filter_bidder
-	*__archive_read_get_bidder(struct archive_read *a);
+int __archive_read_get_bidder(struct archive_read *a,
+    struct archive_read_filter_bidder **bidder);
 
 const void *__archive_read_ahead(struct archive_read *, size_t, ssize_t *);
 const void *__archive_read_filter_ahead(struct archive_read_filter *,
     size_t, ssize_t *);
-ssize_t	__archive_read_consume(struct archive_read *, size_t);
-ssize_t	__archive_read_filter_consume(struct archive_read_filter *, size_t);
-int64_t	__archive_read_skip(struct archive_read *, int64_t);
-int64_t	__archive_read_skip_lenient(struct archive_read *, int64_t);
-int64_t	__archive_read_filter_skip(struct archive_read_filter *, int64_t);
+int64_t	__archive_read_seek(struct archive_read*, int64_t, int);
+int64_t	__archive_read_filter_seek(struct archive_read_filter *, int64_t, int);
+int64_t	__archive_read_consume(struct archive_read *, int64_t);
+int64_t	__archive_read_filter_consume(struct archive_read_filter *, int64_t);
 int __archive_read_program(struct archive_read_filter *, const char *);
 #endif
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_read_support_format_all.c
--- a/head/contrib/libarchive/libarchive/archive_read_support_format_all.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_read_support_format_all.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,20 +24,56 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_support_format_all.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_support_format_all.c 232153 2012-02-25 10:58:02Z mm $");
 
 #include "archive.h"
+#include "archive_private.h"
 
 int
 archive_read_support_format_all(struct archive *a)
 {
+	archive_check_magic(a, ARCHIVE_READ_MAGIC,
+	    ARCHIVE_STATE_NEW, "archive_read_support_format_all");
+
+	/* TODO: It would be nice to compute the ordering
+	 * here automatically so that people who enable just
+	 * a few formats can still get the benefits.  That
+	 * may just require the format registration to include
+	 * a "maximum read-ahead" value (anything that uses seek
+	 * would be essentially infinite read-ahead).  The core
+	 * bid management can then sort the bidders before calling
+	 * them.
+	 *
+	 * If you implement the above, please return the list below
+	 * to alphabetic order.
+	 */
+
+	/*
+	 * These bidders are all pretty cheap; they just examine a
+	 * small initial part of the archive.  If one of these bids
+	 * high, we can maybe avoid running any of the more expensive
+	 * bidders below.
+	 */
 	archive_read_support_format_ar(a);
 	archive_read_support_format_cpio(a);
 	archive_read_support_format_empty(a);
-	archive_read_support_format_iso9660(a);
+	archive_read_support_format_lha(a);
 	archive_read_support_format_mtree(a);
 	archive_read_support_format_tar(a);
 	archive_read_support_format_xar(a);
+
+	/*
+	 * Install expensive bidders last.  By doing them last, we
+	 * increase the chance that a high bid from someone else will
+	 * make it unnecessary for these to do anything at all.
+	 */
+	/* These three have potentially large look-ahead. */
+	archive_read_support_format_7zip(a);
+	archive_read_support_format_cab(a);
+	archive_read_support_format_rar(a);
+	archive_read_support_format_iso9660(a);
+	/* Seek is really bad, since it forces the read-ahead
+	 * logic to discard buffered data. */
 	archive_read_support_format_zip(a);
 
 	/* Note: We always return ARCHIVE_OK here, even if some of the
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_read_support_format_ar.c
--- a/head/contrib/libarchive/libarchive/archive_read_support_format_ar.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_read_support_format_ar.c	Fri Mar 02 16:54:40 2012 +0200
@@ -26,7 +26,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_support_format_ar.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_support_format_ar.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
@@ -50,11 +50,17 @@
 #include "archive_read_private.h"
 
 struct ar {
-	off_t	 entry_bytes_remaining;
-	off_t	 entry_offset;
-	off_t	 entry_padding;
+	int64_t	 entry_bytes_remaining;
+	/* unconsumed is purely to track data we've gotten from readahead,
+	 * but haven't yet marked as consumed.  Must be paired with
+	 * entry_bytes_remaining usage/modification.
+	 */
+	size_t   entry_bytes_unconsumed;
+	int64_t	 entry_offset;
+	int64_t	 entry_padding;
 	char	*strtab;
 	size_t	 strtab_size;
+	char	 read_global_header;
 };
 
 /*
@@ -75,10 +81,10 @@
 #define AR_fmag_offset 58
 #define AR_fmag_size 2
 
-static int	archive_read_format_ar_bid(struct archive_read *a);
+static int	archive_read_format_ar_bid(struct archive_read *a, int);
 static int	archive_read_format_ar_cleanup(struct archive_read *a);
 static int	archive_read_format_ar_read_data(struct archive_read *a,
-		    const void **buff, size_t *size, off_t *offset);
+		    const void **buff, size_t *size, int64_t *offset);
 static int	archive_read_format_ar_skip(struct archive_read *a);
 static int	archive_read_format_ar_read_header(struct archive_read *a,
 		    struct archive_entry *e);
@@ -95,6 +101,9 @@
 	struct ar *ar;
 	int r;
 
+	archive_check_magic(_a, ARCHIVE_READ_MAGIC,
+	    ARCHIVE_STATE_NEW, "archive_read_support_format_ar");
+
 	ar = (struct ar *)malloc(sizeof(*ar));
 	if (ar == NULL) {
 		archive_set_error(&a->archive, ENOMEM,
@@ -135,14 +144,11 @@
 }
 
 static int
-archive_read_format_ar_bid(struct archive_read *a)
+archive_read_format_ar_bid(struct archive_read *a, int best_bid)
 {
 	const void *h;
 
-	if (a->archive.archive_format != 0 &&
-	    (a->archive.archive_format & ARCHIVE_FORMAT_BASE_MASK) !=
-	    ARCHIVE_FORMAT_AR)
-		return(0);
+	(void)best_bid; /* UNUSED */
 
 	/*
 	 * Verify the 8-byte file signature.
@@ -150,45 +156,23 @@
 	 */
 	if ((h = __archive_read_ahead(a, 8, NULL)) == NULL)
 		return (-1);
-	if (strncmp((const char*)h, "!<arch>\n", 8) == 0) {
+	if (memcmp(h, "!<arch>\n", 8) == 0) {
 		return (64);
 	}
 	return (-1);
 }
 
 static int
-archive_read_format_ar_read_header(struct archive_read *a,
-    struct archive_entry *entry)
+_ar_read_header(struct archive_read *a, struct archive_entry *entry,
+	struct ar *ar, const char *h, size_t *unconsumed)
 {
 	char filename[AR_name_size + 1];
-	struct ar *ar;
 	uint64_t number; /* Used to hold parsed numbers before validation. */
-	ssize_t bytes_read;
 	size_t bsd_name_length, entry_size;
 	char *p, *st;
 	const void *b;
-	const char *h;
 	int r;
 
-	ar = (struct ar*)(a->format->data);
-
-	if (a->archive.file_position == 0) {
-		/*
-		 * We are now at the beginning of the archive,
-		 * so we need first consume the ar global header.
-		 */
-		__archive_read_consume(a, 8);
-		/* Set a default format code for now. */
-		a->archive.archive_format = ARCHIVE_FORMAT_AR;
-	}
-
-	/* Read the header for the next file entry. */
-	if ((b = __archive_read_ahead(a, 60, &bytes_read)) == NULL)
-		/* Broken header. */
-		return (ARCHIVE_EOF);
-	__archive_read_consume(a, 60);
-	h = (const char *)b;
-
 	/* Verify the magic signature on the file header. */
 	if (strncmp(h + AR_fmag_offset, "`\n", 2) != 0) {
 		archive_set_error(&a->archive, EINVAL,
@@ -292,6 +276,12 @@
 		}
 		ar->strtab = st;
 		ar->strtab_size = entry_size;
+
+		if (*unconsumed) {
+			__archive_read_consume(a, *unconsumed);
+			*unconsumed = 0;
+		}
+
 		if ((b = __archive_read_ahead(a, entry_size, NULL)) == NULL)
 			return (ARCHIVE_FATAL);
 		memcpy(st, b, entry_size);
@@ -347,7 +337,7 @@
 		 * overflowing a size_t and against the filename size
 		 * being larger than the entire entry. */
 		if (number > (uint64_t)(bsd_name_length + 1)
-		    || (off_t)bsd_name_length > ar->entry_bytes_remaining) {
+		    || (int64_t)bsd_name_length > ar->entry_bytes_remaining) {
 			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
 			    "Bad input file size");
 			return (ARCHIVE_FATAL);
@@ -356,14 +346,17 @@
 		/* Adjust file size reported to client. */
 		archive_entry_set_size(entry, ar->entry_bytes_remaining);
 
+		if (*unconsumed) {
+			__archive_read_consume(a, *unconsumed);
+			*unconsumed = 0;
+		}
+
 		/* Read the long name into memory. */
 		if ((b = __archive_read_ahead(a, bsd_name_length, NULL)) == NULL) {
 			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
 			    "Truncated input file");
 			return (ARCHIVE_FATAL);
 		}
-		__archive_read_consume(a, bsd_name_length);
-
 		/* Store it in the entry. */
 		p = (char *)malloc(bsd_name_length + 1);
 		if (p == NULL) {
@@ -373,6 +366,9 @@
 		}
 		strncpy(p, b, bsd_name_length);
 		p[bsd_name_length] = '\0';
+
+		__archive_read_consume(a, bsd_name_length);
+
 		archive_entry_copy_pathname(entry, p);
 		free(p);
 		return (ARCHIVE_OK);
@@ -409,6 +405,42 @@
 }
 
 static int
+archive_read_format_ar_read_header(struct archive_read *a,
+    struct archive_entry *entry)
+{
+	struct ar *ar = (struct ar*)(a->format->data);
+	size_t unconsumed;
+	const void *header_data;
+	int ret;
+
+	if (!ar->read_global_header) {
+		/*
+		 * We are now at the beginning of the archive,
+		 * so we need first consume the ar global header.
+		 */
+		__archive_read_consume(a, 8);
+		ar->read_global_header = 1;
+		/* Set a default format code for now. */
+		a->archive.archive_format = ARCHIVE_FORMAT_AR;
+	}
+
+	/* Read the header for the next file entry. */
+	if ((header_data = __archive_read_ahead(a, 60, NULL)) == NULL)
+		/* Broken header. */
+		return (ARCHIVE_EOF);
+	
+	unconsumed = 60;
+	
+	ret = _ar_read_header(a, entry, ar, (const char *)header_data, &unconsumed);
+
+	if (unconsumed)
+		__archive_read_consume(a, unconsumed);
+
+	return ret;
+}
+
+
+static int
 ar_parse_common_header(struct ar *ar, struct archive_entry *entry,
     const char *h)
 {
@@ -434,13 +466,18 @@
 
 static int
 archive_read_format_ar_read_data(struct archive_read *a,
-    const void **buff, size_t *size, off_t *offset)
+    const void **buff, size_t *size, int64_t *offset)
 {
 	ssize_t bytes_read;
 	struct ar *ar;
 
 	ar = (struct ar *)(a->format->data);
 
+	if (ar->entry_bytes_unconsumed) {
+		__archive_read_consume(a, ar->entry_bytes_unconsumed);
+		ar->entry_bytes_unconsumed = 0;
+	}
+
 	if (ar->entry_bytes_remaining > 0) {
 		*buff = __archive_read_ahead(a, 1, &bytes_read);
 		if (bytes_read == 0) {
@@ -453,20 +490,22 @@
 		if (bytes_read > ar->entry_bytes_remaining)
 			bytes_read = (ssize_t)ar->entry_bytes_remaining;
 		*size = bytes_read;
+		ar->entry_bytes_unconsumed = bytes_read;
 		*offset = ar->entry_offset;
 		ar->entry_offset += bytes_read;
 		ar->entry_bytes_remaining -= bytes_read;
-		__archive_read_consume(a, (size_t)bytes_read);
 		return (ARCHIVE_OK);
 	} else {
-		while (ar->entry_padding > 0) {
-			*buff = __archive_read_ahead(a, 1, &bytes_read);
-			if (bytes_read <= 0)
-				return (ARCHIVE_FATAL);
-			if (bytes_read > ar->entry_padding)
-				bytes_read = (ssize_t)ar->entry_padding;
-			__archive_read_consume(a, (size_t)bytes_read);
-			ar->entry_padding -= bytes_read;
+		int64_t skipped = __archive_read_consume(a, ar->entry_padding);
+		if (skipped >= 0) {
+			ar->entry_padding -= skipped;
+		}
+		if (ar->entry_padding) {
+			if (skipped >= 0) {
+				archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+					"Truncated ar archive- failed consuming padding");
+			}
+			return (ARCHIVE_FATAL);
 		}
 		*buff = NULL;
 		*size = 0;
@@ -478,17 +517,19 @@
 static int
 archive_read_format_ar_skip(struct archive_read *a)
 {
-	off_t bytes_skipped;
+	int64_t bytes_skipped;
 	struct ar* ar;
 
 	ar = (struct ar *)(a->format->data);
 
-	bytes_skipped = __archive_read_skip(a,
-	    ar->entry_bytes_remaining + ar->entry_padding);
+	bytes_skipped = __archive_read_consume(a,
+	    ar->entry_bytes_remaining + ar->entry_padding
+	    + ar->entry_bytes_unconsumed);
 	if (bytes_skipped < 0)
 		return (ARCHIVE_FATAL);
 
 	ar->entry_bytes_remaining = 0;
+	ar->entry_bytes_unconsumed = 0;
 	ar->entry_padding = 0;
 
 	return (ARCHIVE_OK);
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_read_support_format_cpio.c
--- a/head/contrib/libarchive/libarchive/archive_read_support_format_cpio.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_read_support_format_cpio.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,6 @@
 /*-
  * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2010-2012 Michihiro NAKAJIMA
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -24,7 +25,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_support_format_cpio.c 228911 2011-12-27 10:36:56Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_support_format_cpio.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
@@ -39,62 +40,127 @@
 
 #include "archive.h"
 #include "archive_entry.h"
+#include "archive_entry_locale.h"
 #include "archive_private.h"
 #include "archive_read_private.h"
 
-#ifdef _MSC_VER
-#define __packed
-#pragma pack(push, 1)
-#endif
-struct cpio_bin_header {
-	unsigned char	c_magic[2];
-	unsigned char	c_dev[2];
-	unsigned char	c_ino[2];
-	unsigned char	c_mode[2];
-	unsigned char	c_uid[2];
-	unsigned char	c_gid[2];
-	unsigned char	c_nlink[2];
-	unsigned char	c_rdev[2];
-	unsigned char	c_mtime[4];
-	unsigned char	c_namesize[2];
-	unsigned char	c_filesize[4];
-} __packed;
+#define	bin_magic_offset 0
+#define	bin_magic_size 2
+#define	bin_dev_offset 2
+#define	bin_dev_size 2
+#define	bin_ino_offset 4
+#define	bin_ino_size 2
+#define	bin_mode_offset 6
+#define	bin_mode_size 2
+#define	bin_uid_offset 8
+#define	bin_uid_size 2
+#define	bin_gid_offset 10
+#define	bin_gid_size 2
+#define	bin_nlink_offset 12
+#define	bin_nlink_size 2
+#define	bin_rdev_offset 14
+#define	bin_rdev_size 2
+#define	bin_mtime_offset 16
+#define	bin_mtime_size 4
+#define	bin_namesize_offset 20
+#define	bin_namesize_size 2
+#define	bin_filesize_offset 22
+#define	bin_filesize_size 4
+#define	bin_header_size 26
 
-struct cpio_odc_header {
-	char	c_magic[6];
-	char	c_dev[6];
-	char	c_ino[6];
-	char	c_mode[6];
-	char	c_uid[6];
-	char	c_gid[6];
-	char	c_nlink[6];
-	char	c_rdev[6];
-	char	c_mtime[11];
-	char	c_namesize[6];
-	char	c_filesize[11];
-} __packed;
+#define	odc_magic_offset 0
+#define	odc_magic_size 6
+#define	odc_dev_offset 6
+#define	odc_dev_size 6
+#define	odc_ino_offset 12
+#define	odc_ino_size 6
+#define	odc_mode_offset 18
+#define	odc_mode_size 6
+#define	odc_uid_offset 24
+#define	odc_uid_size 6
+#define	odc_gid_offset 30
+#define	odc_gid_size 6
+#define	odc_nlink_offset 36
+#define	odc_nlink_size 6
+#define	odc_rdev_offset 42
+#define	odc_rdev_size 6
+#define	odc_mtime_offset 48
+#define	odc_mtime_size 11
+#define	odc_namesize_offset 59
+#define	odc_namesize_size 6
+#define	odc_filesize_offset 65
+#define	odc_filesize_size 11
+#define	odc_header_size 76
 
-struct cpio_newc_header {
-	char	c_magic[6];
-	char	c_ino[8];
-	char	c_mode[8];
-	char	c_uid[8];
-	char	c_gid[8];
-	char	c_nlink[8];
-	char	c_mtime[8];
-	char	c_filesize[8];
-	char	c_devmajor[8];
-	char	c_devminor[8];
-	char	c_rdevmajor[8];
-	char	c_rdevminor[8];
-	char	c_namesize[8];
-	char	c_crc[8];
-} __packed;
+#define	newc_magic_offset 0
+#define	newc_magic_size 6
+#define	newc_ino_offset 6
+#define	newc_ino_size 8
+#define	newc_mode_offset 14
+#define	newc_mode_size 8
+#define	newc_uid_offset 22
+#define	newc_uid_size 8
+#define	newc_gid_offset 30
+#define	newc_gid_size 8
+#define	newc_nlink_offset 38
+#define	newc_nlink_size 8
+#define	newc_mtime_offset 46
+#define	newc_mtime_size 8
+#define	newc_filesize_offset 54
+#define	newc_filesize_size 8
+#define	newc_devmajor_offset 62
+#define	newc_devmajor_size 8
+#define	newc_devminor_offset 70
+#define	newc_devminor_size 8
+#define	newc_rdevmajor_offset 78
+#define	newc_rdevmajor_size 8
+#define	newc_rdevminor_offset 86
+#define	newc_rdevminor_size 8
+#define	newc_namesize_offset 94
+#define	newc_namesize_size 8
+#define	newc_checksum_offset 102
+#define	newc_checksum_size 8
+#define	newc_header_size 110
 
-#ifdef _MSC_VER
-#undef __packed
-#pragma pack(pop)
-#endif
+/*
+ * An afio large ASCII header, which they named itself.
+ * afio utility uses this header, if a file size is larger than 2G bytes
+ * or inode/uid/gid is bigger than 65535(0xFFFF) or mtime is bigger than
+ * 0x7fffffff, which we cannot record to odc header because of its limit.
+ * If not, uses odc header.
+ */
+#define	afiol_magic_offset 0
+#define	afiol_magic_size 6
+#define	afiol_dev_offset 6
+#define	afiol_dev_size 8	/* hex */
+#define	afiol_ino_offset 14
+#define	afiol_ino_size 16	/* hex */
+#define	afiol_ino_m_offset 30	/* 'm' */
+#define	afiol_mode_offset 31
+#define	afiol_mode_size 6	/* oct */
+#define	afiol_uid_offset 37
+#define	afiol_uid_size 8	/* hex */
+#define	afiol_gid_offset 45
+#define	afiol_gid_size 8	/* hex */
+#define	afiol_nlink_offset 53
+#define	afiol_nlink_size 8	/* hex */
+#define	afiol_rdev_offset 61
+#define	afiol_rdev_size 8	/* hex */
+#define	afiol_mtime_offset 69
+#define	afiol_mtime_size 16	/* hex */
+#define	afiol_mtime_n_offset 85	/* 'n' */
+#define	afiol_namesize_offset 86
+#define	afiol_namesize_size 4	/* hex */
+#define	afiol_flag_offset 90
+#define	afiol_flag_size 4	/* hex */
+#define	afiol_xsize_offset 94
+#define	afiol_xsize_size 4	/* hex */
+#define	afiol_xsize_s_offset 98	/* 's' */
+#define	afiol_filesize_offset 99
+#define	afiol_filesize_size 16	/* hex */
+#define	afiol_filesize_c_offset 115	/* ':' */
+#define afiol_header_size 116
+
 
 struct links_entry {
         struct links_entry      *next;
@@ -111,21 +177,27 @@
 	int			(*read_header)(struct archive_read *, struct cpio *,
 				     struct archive_entry *, size_t *, size_t *);
 	struct links_entry	 *links_head;
-	struct archive_string	  entry_name;
-	struct archive_string	  entry_linkname;
-	off_t			  entry_bytes_remaining;
-	off_t			  entry_offset;
-	off_t			  entry_padding;
+	int64_t			  entry_bytes_remaining;
+	int64_t			  entry_bytes_unconsumed;
+	int64_t			  entry_offset;
+	int64_t			  entry_padding;
+
+	struct archive_string_conv *opt_sconv;
+	struct archive_string_conv *sconv_default;
+	int			  init_default_conversion;
 };
 
 static int64_t	atol16(const char *, unsigned);
 static int64_t	atol8(const char *, unsigned);
-static int	archive_read_format_cpio_bid(struct archive_read *);
+static int	archive_read_format_cpio_bid(struct archive_read *, int);
+static int	archive_read_format_cpio_options(struct archive_read *,
+		    const char *, const char *);
 static int	archive_read_format_cpio_cleanup(struct archive_read *);
 static int	archive_read_format_cpio_read_data(struct archive_read *,
-		    const void **, size_t *, off_t *);
+		    const void **, size_t *, int64_t *);
 static int	archive_read_format_cpio_read_header(struct archive_read *,
 		    struct archive_entry *);
+static int	archive_read_format_cpio_skip(struct archive_read *);
 static int	be4(const unsigned char *);
 static int	find_odc_header(struct archive_read *);
 static int	find_newc_header(struct archive_read *);
@@ -137,10 +209,13 @@
 		    struct archive_entry *, size_t *, size_t *);
 static int	header_odc(struct archive_read *, struct cpio *,
 		    struct archive_entry *, size_t *, size_t *);
+static int	header_afiol(struct archive_read *, struct cpio *,
+		    struct archive_entry *, size_t *, size_t *);
 static int	is_octal(const char *, size_t);
 static int	is_hex(const char *, size_t);
 static int	le4(const unsigned char *);
-static void	record_hardlink(struct cpio *cpio, struct archive_entry *entry);
+static int	record_hardlink(struct archive_read *a,
+		    struct cpio *cpio, struct archive_entry *entry);
 
 int
 archive_read_support_format_cpio(struct archive *_a)
@@ -149,22 +224,24 @@
 	struct cpio *cpio;
 	int r;
 
-	cpio = (struct cpio *)malloc(sizeof(*cpio));
+	archive_check_magic(_a, ARCHIVE_READ_MAGIC,
+	    ARCHIVE_STATE_NEW, "archive_read_support_format_cpio");
+
+	cpio = (struct cpio *)calloc(1, sizeof(*cpio));
 	if (cpio == NULL) {
 		archive_set_error(&a->archive, ENOMEM, "Can't allocate cpio data");
 		return (ARCHIVE_FATAL);
 	}
-	memset(cpio, 0, sizeof(*cpio));
 	cpio->magic = CPIO_MAGIC;
 
 	r = __archive_read_register_format(a,
 	    cpio,
 	    "cpio",
 	    archive_read_format_cpio_bid,
-	    NULL,
+	    archive_read_format_cpio_options,
 	    archive_read_format_cpio_read_header,
 	    archive_read_format_cpio_read_data,
-	    NULL,
+	    archive_read_format_cpio_skip,
 	    archive_read_format_cpio_cleanup);
 
 	if (r != ARCHIVE_OK)
@@ -174,19 +251,19 @@
 
 
 static int
-archive_read_format_cpio_bid(struct archive_read *a)
+archive_read_format_cpio_bid(struct archive_read *a, int best_bid)
 {
-	const void *h;
 	const unsigned char *p;
 	struct cpio *cpio;
 	int bid;
 
+	(void)best_bid; /* UNUSED */
+
 	cpio = (struct cpio *)(a->format->data);
 
-	if ((h = __archive_read_ahead(a, 6, NULL)) == NULL)
+	if ((p = __archive_read_ahead(a, 6, NULL)) == NULL)
 		return (-1);
 
-	p = (const unsigned char *)h;
 	bid = 0;
 	if (memcmp(p, "070707", 6) == 0) {
 		/* ASCII cpio archive (odc, POSIX.1) */
@@ -196,6 +273,14 @@
 		 * XXX TODO:  More verification; Could check that only octal
 		 * digits appear in appropriate header locations. XXX
 		 */
+	} else if (memcmp(p, "070727", 6) == 0) {
+		/* afio large ASCII cpio archive */
+		cpio->read_header = header_odc;
+		bid += 48;
+		/*
+		 * XXX TODO:  More verification; Could check that almost hex
+		 * digits appear in appropriate header locations. XXX
+		 */
 	} else if (memcmp(p, "070701", 6) == 0) {
 		/* ASCII cpio archive (SVR4 without CRC) */
 		cpio->read_header = header_newc;
@@ -230,16 +315,62 @@
 }
 
 static int
+archive_read_format_cpio_options(struct archive_read *a,
+    const char *key, const char *val)
+{
+	struct cpio *cpio;
+	int ret = ARCHIVE_FAILED;
+
+	cpio = (struct cpio *)(a->format->data);
+	if (strcmp(key, "compat-2x")  == 0) {
+		/* Handle filnames as libarchive 2.x */
+		cpio->init_default_conversion = (val != NULL)?1:0;
+		return (ARCHIVE_OK);
+	} else if (strcmp(key, "hdrcharset")  == 0) {
+		if (val == NULL || val[0] == 0)
+			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+			    "cpio: hdrcharset option needs a character-set name");
+		else {
+			cpio->opt_sconv =
+			    archive_string_conversion_from_charset(
+				&a->archive, val, 0);
+			if (cpio->opt_sconv != NULL)
+				ret = ARCHIVE_OK;
+			else
+				ret = ARCHIVE_FATAL;
+		}
+		return (ret);
+	}
+
+	/* Note: The "warn" return is just to inform the options
+	 * supervisor that we didn't handle it.  It will generate
+	 * a suitable error if no one used this option. */
+	return (ARCHIVE_WARN);
+}
+
+static int
 archive_read_format_cpio_read_header(struct archive_read *a,
     struct archive_entry *entry)
 {
 	struct cpio *cpio;
 	const void *h;
+	struct archive_string_conv *sconv;
 	size_t namelength;
 	size_t name_pad;
 	int r;
 
 	cpio = (struct cpio *)(a->format->data);
+	sconv = cpio->opt_sconv;
+	if (sconv == NULL) {
+		if (!cpio->init_default_conversion) {
+			cpio->sconv_default =
+			    archive_string_default_conversion_for_read(
+			      &(a->archive));
+			cpio->init_default_conversion = 1;
+		}
+		sconv = cpio->sconv_default;
+	}
+	
 	r = (cpio->read_header(a, cpio, entry, &namelength, &name_pad));
 
 	if (r < ARCHIVE_WARN)
@@ -249,20 +380,42 @@
 	h = __archive_read_ahead(a, namelength + name_pad, NULL);
 	if (h == NULL)
 	    return (ARCHIVE_FATAL);
+	if (archive_entry_copy_pathname_l(entry,
+	    (const char *)h, namelength, sconv) != 0) {
+		if (errno == ENOMEM) {
+			archive_set_error(&a->archive, ENOMEM,
+			    "Can't allocate memory for Pathname");
+			return (ARCHIVE_FATAL);
+		}
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+		    "Pathname can't be converted from %s to current locale.",
+		    archive_string_conversion_charset_name(sconv));
+		r = ARCHIVE_WARN;
+	}
+	cpio->entry_offset = 0;
+
 	__archive_read_consume(a, namelength + name_pad);
-	archive_strncpy(&cpio->entry_name, (const char *)h, namelength);
-	archive_entry_set_pathname(entry, cpio->entry_name.s);
-	cpio->entry_offset = 0;
 
 	/* If this is a symlink, read the link contents. */
 	if (archive_entry_filetype(entry) == AE_IFLNK) {
 		h = __archive_read_ahead(a, cpio->entry_bytes_remaining, NULL);
 		if (h == NULL)
 			return (ARCHIVE_FATAL);
+		if (archive_entry_copy_symlink_l(entry, (const char *)h,
+		    cpio->entry_bytes_remaining, sconv) != 0) {
+			if (errno == ENOMEM) {
+				archive_set_error(&a->archive, ENOMEM,
+				    "Can't allocate memory for Linkname");
+				return (ARCHIVE_FATAL);
+			}
+			archive_set_error(&a->archive,
+			    ARCHIVE_ERRNO_FILE_FORMAT,
+			    "Linkname can't be converted from %s to "
+			    "current locale.",
+			    archive_string_conversion_charset_name(sconv));
+			r = ARCHIVE_WARN;
+		}
 		__archive_read_consume(a, cpio->entry_bytes_remaining);
-		archive_strncpy(&cpio->entry_linkname, (const char *)h,
-		    cpio->entry_bytes_remaining);
-		archive_entry_set_symlink(entry, cpio->entry_linkname.s);
 		cpio->entry_bytes_remaining = 0;
 	}
 
@@ -279,19 +432,27 @@
 	}
 
 	/* Detect and record hardlinks to previously-extracted entries. */
-	record_hardlink(cpio, entry);
+	if (record_hardlink(a, cpio, entry) != ARCHIVE_OK) {
+		return (ARCHIVE_FATAL);
+	}
 
 	return (r);
 }
 
 static int
 archive_read_format_cpio_read_data(struct archive_read *a,
-    const void **buff, size_t *size, off_t *offset)
+    const void **buff, size_t *size, int64_t *offset)
 {
 	ssize_t bytes_read;
 	struct cpio *cpio;
 
 	cpio = (struct cpio *)(a->format->data);
+
+	if (cpio->entry_bytes_unconsumed) {
+		__archive_read_consume(a, cpio->entry_bytes_unconsumed);
+		cpio->entry_bytes_unconsumed = 0;
+	}
+
 	if (cpio->entry_bytes_remaining > 0) {
 		*buff = __archive_read_ahead(a, 1, &bytes_read);
 		if (bytes_read <= 0)
@@ -299,21 +460,17 @@
 		if (bytes_read > cpio->entry_bytes_remaining)
 			bytes_read = cpio->entry_bytes_remaining;
 		*size = bytes_read;
+		cpio->entry_bytes_unconsumed = bytes_read;
 		*offset = cpio->entry_offset;
 		cpio->entry_offset += bytes_read;
 		cpio->entry_bytes_remaining -= bytes_read;
-		__archive_read_consume(a, bytes_read);
 		return (ARCHIVE_OK);
 	} else {
-		while (cpio->entry_padding > 0) {
-			*buff = __archive_read_ahead(a, 1, &bytes_read);
-			if (bytes_read <= 0)
-				return (ARCHIVE_FATAL);
-			if (bytes_read > cpio->entry_padding)
-				bytes_read = cpio->entry_padding;
-			__archive_read_consume(a, bytes_read);
-			cpio->entry_padding -= bytes_read;
+		if (cpio->entry_padding !=
+			__archive_read_consume(a, cpio->entry_padding)) {
+			return (ARCHIVE_FATAL);
 		}
+		cpio->entry_padding = 0;
 		*buff = NULL;
 		*size = 0;
 		*offset = cpio->entry_offset;
@@ -321,6 +478,22 @@
 	}
 }
 
+static int
+archive_read_format_cpio_skip(struct archive_read *a)
+{
+	struct cpio *cpio = (struct cpio *)(a->format->data);
+	int64_t to_skip = cpio->entry_bytes_remaining + cpio->entry_padding +
+		cpio->entry_bytes_unconsumed;
+
+	if (to_skip != __archive_read_consume(a, to_skip)) {
+		return (ARCHIVE_FATAL);
+	}
+	cpio->entry_bytes_remaining = 0;
+	cpio->entry_padding = 0;
+	cpio->entry_bytes_unconsumed = 0;
+	return (ARCHIVE_OK);
+}
+
 /*
  * Skip forward to the next cpio newc header by searching for the
  * 07070[12] string.  This should be generalized and merged with
@@ -349,7 +522,7 @@
 	ssize_t bytes;
 
 	for (;;) {
-		h = __archive_read_ahead(a, sizeof(struct cpio_newc_header), &bytes);
+		h = __archive_read_ahead(a, newc_header_size, &bytes);
 		if (h == NULL)
 			return (ARCHIVE_FATAL);
 		p = h;
@@ -358,19 +531,19 @@
 		/* Try the typical case first, then go into the slow search.*/
 		if (memcmp("07070", p, 5) == 0
 		    && (p[5] == '1' || p[5] == '2')
-		    && is_hex(p, sizeof(struct cpio_newc_header)))
+		    && is_hex(p, newc_header_size))
 			return (ARCHIVE_OK);
 
 		/*
 		 * Scan ahead until we find something that looks
-		 * like an odc header.
+		 * like a newc header.
 		 */
-		while (p + sizeof(struct cpio_newc_header) <= q) {
+		while (p + newc_header_size <= q) {
 			switch (p[5]) {
 			case '1':
 			case '2':
 				if (memcmp("07070", p, 5) == 0
-					&& is_hex(p, sizeof(struct cpio_newc_header))) {
+				    && is_hex(p, newc_header_size)) {
 					skip = p - (const char *)h;
 					__archive_read_consume(a, skip);
 					skipped += skip;
@@ -405,7 +578,7 @@
     struct archive_entry *entry, size_t *namelength, size_t *name_pad)
 {
 	const void *h;
-	const struct cpio_newc_header *header;
+	const char *header;
 	int r;
 
 	r = find_newc_header(a);
@@ -413,35 +586,34 @@
 		return (r);
 
 	/* Read fixed-size portion of header. */
-	h = __archive_read_ahead(a, sizeof(struct cpio_newc_header), NULL);
+	h = __archive_read_ahead(a, newc_header_size, NULL);
 	if (h == NULL)
 	    return (ARCHIVE_FATAL);
-	__archive_read_consume(a, sizeof(struct cpio_newc_header));
 
 	/* Parse out hex fields. */
-	header = (const struct cpio_newc_header *)h;
+	header = (const char *)h;
 
-	if (memcmp(header->c_magic, "070701", 6) == 0) {
+	if (memcmp(header + newc_magic_offset, "070701", 6) == 0) {
 		a->archive.archive_format = ARCHIVE_FORMAT_CPIO_SVR4_NOCRC;
 		a->archive.archive_format_name = "ASCII cpio (SVR4 with no CRC)";
-	} else if (memcmp(header->c_magic, "070702", 6) == 0) {
+	} else if (memcmp(header + newc_magic_offset, "070702", 6) == 0) {
 		a->archive.archive_format = ARCHIVE_FORMAT_CPIO_SVR4_CRC;
 		a->archive.archive_format_name = "ASCII cpio (SVR4 with CRC)";
 	} else {
 		/* TODO: Abort here? */
 	}
 
-	archive_entry_set_devmajor(entry, atol16(header->c_devmajor, sizeof(header->c_devmajor)));
-	archive_entry_set_devminor(entry, atol16(header->c_devminor, sizeof(header->c_devminor)));
-	archive_entry_set_ino(entry, atol16(header->c_ino, sizeof(header->c_ino)));
-	archive_entry_set_mode(entry, atol16(header->c_mode, sizeof(header->c_mode)));
-	archive_entry_set_uid(entry, atol16(header->c_uid, sizeof(header->c_uid)));
-	archive_entry_set_gid(entry, atol16(header->c_gid, sizeof(header->c_gid)));
-	archive_entry_set_nlink(entry, atol16(header->c_nlink, sizeof(header->c_nlink)));
-	archive_entry_set_rdevmajor(entry, atol16(header->c_rdevmajor, sizeof(header->c_rdevmajor)));
-	archive_entry_set_rdevminor(entry, atol16(header->c_rdevminor, sizeof(header->c_rdevminor)));
-	archive_entry_set_mtime(entry, atol16(header->c_mtime, sizeof(header->c_mtime)), 0);
-	*namelength = atol16(header->c_namesize, sizeof(header->c_namesize));
+	archive_entry_set_devmajor(entry, atol16(header + newc_devmajor_offset, newc_devmajor_size));
+	archive_entry_set_devminor(entry, atol16(header + newc_devminor_offset, newc_devminor_size));
+	archive_entry_set_ino(entry, atol16(header + newc_ino_offset, newc_ino_size));
+	archive_entry_set_mode(entry, atol16(header + newc_mode_offset, newc_mode_size));
+	archive_entry_set_uid(entry, atol16(header + newc_uid_offset, newc_uid_size));
+	archive_entry_set_gid(entry, atol16(header + newc_gid_offset, newc_gid_size));
+	archive_entry_set_nlink(entry, atol16(header + newc_nlink_offset, newc_nlink_size));
+	archive_entry_set_rdevmajor(entry, atol16(header + newc_rdevmajor_offset, newc_rdevmajor_size));
+	archive_entry_set_rdevminor(entry, atol16(header + newc_rdevminor_offset, newc_rdevminor_size));
+	archive_entry_set_mtime(entry, atol16(header + newc_mtime_offset, newc_mtime_size), 0);
+	*namelength = atol16(header + newc_namesize_offset, newc_namesize_size);
 	/* Pad name to 2 more than a multiple of 4. */
 	*name_pad = (2 - *namelength) & 3;
 
@@ -451,10 +623,11 @@
 	 * size.
 	 */
 	cpio->entry_bytes_remaining =
-	    atol16(header->c_filesize, sizeof(header->c_filesize));
+	    atol16(header + newc_filesize_offset, newc_filesize_size);
 	archive_entry_set_size(entry, cpio->entry_bytes_remaining);
 	/* Pad file contents to a multiple of 4. */
 	cpio->entry_padding = 3 & -cpio->entry_bytes_remaining;
+	__archive_read_consume(a, newc_header_size);
 	return (r);
 }
 
@@ -476,6 +649,27 @@
 }
 
 static int
+is_afio_large(const char *h, size_t len)
+{
+	if (len < afiol_header_size)
+		return (0);
+	if (h[afiol_ino_m_offset] != 'm'
+	    || h[afiol_mtime_n_offset] != 'n'
+	    || h[afiol_xsize_s_offset] != 's'
+	    || h[afiol_filesize_c_offset] != ':')
+		return (0);
+	if (!is_hex(h + afiol_dev_offset, afiol_ino_m_offset - afiol_dev_offset))
+		return (0);
+	if (!is_hex(h + afiol_mode_offset, afiol_mtime_n_offset - afiol_mode_offset))
+		return (0);
+	if (!is_hex(h + afiol_namesize_offset, afiol_xsize_s_offset - afiol_namesize_offset))
+		return (0);
+	if (!is_hex(h + afiol_filesize_offset, afiol_filesize_size))
+		return (0);
+	return (1);
+}
+
+static int
 find_odc_header(struct archive_read *a)
 {
 	const void *h;
@@ -484,29 +678,37 @@
 	ssize_t bytes;
 
 	for (;;) {
-		h = __archive_read_ahead(a, sizeof(struct cpio_odc_header), &bytes);
+		h = __archive_read_ahead(a, odc_header_size, &bytes);
 		if (h == NULL)
 			return (ARCHIVE_FATAL);
 		p = h;
 		q = p + bytes;
 
 		/* Try the typical case first, then go into the slow search.*/
-		if (memcmp("070707", p, 6) == 0
-		    && is_octal(p, sizeof(struct cpio_odc_header)))
+		if (memcmp("070707", p, 6) == 0 && is_octal(p, odc_header_size))
 			return (ARCHIVE_OK);
+		if (memcmp("070727", p, 6) == 0 && is_afio_large(p, bytes)) {
+			a->archive.archive_format = ARCHIVE_FORMAT_CPIO_AFIO_LARGE;
+			return (ARCHIVE_OK);
+		}
 
 		/*
 		 * Scan ahead until we find something that looks
 		 * like an odc header.
 		 */
-		while (p + sizeof(struct cpio_odc_header) <= q) {
+		while (p + odc_header_size <= q) {
 			switch (p[5]) {
 			case '7':
-				if (memcmp("070707", p, 6) == 0
-					&& is_octal(p, sizeof(struct cpio_odc_header))) {
+				if ((memcmp("070707", p, 6) == 0
+				    && is_octal(p, odc_header_size))
+				    || (memcmp("070727", p, 6) == 0
+				        && is_afio_large(p, q - p))) {
 					skip = p - (const char *)h;
 					__archive_read_consume(a, skip);
 					skipped += skip;
+					if (p[4] == '2')
+						a->archive.archive_format =
+						    ARCHIVE_FORMAT_CPIO_AFIO_LARGE;
 					if (skipped > 0) {
 						archive_set_error(&a->archive,
 						    0,
@@ -539,7 +741,7 @@
 {
 	const void *h;
 	int r;
-	const struct cpio_odc_header *header;
+	const char *header;
 
 	a->archive.archive_format = ARCHIVE_FORMAT_CPIO_POSIX;
 	a->archive.archive_format_name = "POSIX octet-oriented cpio";
@@ -549,24 +751,31 @@
 	if (r < ARCHIVE_WARN)
 		return (r);
 
+	if (a->archive.archive_format == ARCHIVE_FORMAT_CPIO_AFIO_LARGE) {
+		int r2 = (header_afiol(a, cpio, entry, namelength, name_pad));
+		if (r2 == ARCHIVE_OK)
+			return (r);
+		else
+			return (r2);
+	}
+
 	/* Read fixed-size portion of header. */
-	h = __archive_read_ahead(a, sizeof(struct cpio_odc_header), NULL);
+	h = __archive_read_ahead(a, odc_header_size, NULL);
 	if (h == NULL)
 	    return (ARCHIVE_FATAL);
-	__archive_read_consume(a, sizeof(struct cpio_odc_header));
 
 	/* Parse out octal fields. */
-	header = (const struct cpio_odc_header *)h;
+	header = (const char *)h;
 
-	archive_entry_set_dev(entry, atol8(header->c_dev, sizeof(header->c_dev)));
-	archive_entry_set_ino(entry, atol8(header->c_ino, sizeof(header->c_ino)));
-	archive_entry_set_mode(entry, atol8(header->c_mode, sizeof(header->c_mode)));
-	archive_entry_set_uid(entry, atol8(header->c_uid, sizeof(header->c_uid)));
-	archive_entry_set_gid(entry, atol8(header->c_gid, sizeof(header->c_gid)));
-	archive_entry_set_nlink(entry, atol8(header->c_nlink, sizeof(header->c_nlink)));
-	archive_entry_set_rdev(entry, atol8(header->c_rdev, sizeof(header->c_rdev)));
-	archive_entry_set_mtime(entry, atol8(header->c_mtime, sizeof(header->c_mtime)), 0);
-	*namelength = atol8(header->c_namesize, sizeof(header->c_namesize));
+	archive_entry_set_dev(entry, atol8(header + odc_dev_offset, odc_dev_size));
+	archive_entry_set_ino(entry, atol8(header + odc_ino_offset, odc_ino_size));
+	archive_entry_set_mode(entry, atol8(header + odc_mode_offset, odc_mode_size));
+	archive_entry_set_uid(entry, atol8(header + odc_uid_offset, odc_uid_size));
+	archive_entry_set_gid(entry, atol8(header + odc_gid_offset, odc_gid_size));
+	archive_entry_set_nlink(entry, atol8(header + odc_nlink_offset, odc_nlink_size));
+	archive_entry_set_rdev(entry, atol8(header + odc_rdev_offset, odc_rdev_size));
+	archive_entry_set_mtime(entry, atol8(header + odc_mtime_offset, odc_mtime_size), 0);
+	*namelength = atol8(header + odc_namesize_offset, odc_namesize_size);
 	*name_pad = 0; /* No padding of filename. */
 
 	/*
@@ -575,45 +784,91 @@
 	 * size.
 	 */
 	cpio->entry_bytes_remaining =
-	    atol8(header->c_filesize, sizeof(header->c_filesize));
+	    atol8(header + odc_filesize_offset, odc_filesize_size);
 	archive_entry_set_size(entry, cpio->entry_bytes_remaining);
 	cpio->entry_padding = 0;
+	__archive_read_consume(a, odc_header_size);
 	return (r);
 }
 
+/*
+ * NOTE: if a filename suffix is ".z", it is the file gziped by afio.
+ * it would be nice that we can show uncompressed file size and we can
+ * uncompressed file contents automatically, unfortunately we have nothing
+ * to get a uncompressed file size while reading each header. it means
+ * we also cannot uncompressed file contens under the our framework.
+ */
+static int
+header_afiol(struct archive_read *a, struct cpio *cpio,
+    struct archive_entry *entry, size_t *namelength, size_t *name_pad)
+{
+	const void *h;
+	const char *header;
+
+	a->archive.archive_format = ARCHIVE_FORMAT_CPIO_AFIO_LARGE;
+	a->archive.archive_format_name = "afio large ASCII";
+
+	/* Read fixed-size portion of header. */
+	h = __archive_read_ahead(a, afiol_header_size, NULL);
+	if (h == NULL)
+	    return (ARCHIVE_FATAL);
+
+	/* Parse out octal fields. */
+	header = (const char *)h;
+
+	archive_entry_set_dev(entry, atol16(header + afiol_dev_offset, afiol_dev_size));
+	archive_entry_set_ino(entry, atol16(header + afiol_ino_offset, afiol_ino_size));
+	archive_entry_set_mode(entry, atol8(header + afiol_mode_offset, afiol_mode_size));
+	archive_entry_set_uid(entry, atol16(header + afiol_uid_offset, afiol_uid_size));
+	archive_entry_set_gid(entry, atol16(header + afiol_gid_offset, afiol_gid_size));
+	archive_entry_set_nlink(entry, atol16(header + afiol_nlink_offset, afiol_nlink_size));
+	archive_entry_set_rdev(entry, atol16(header + afiol_rdev_offset, afiol_rdev_size));
+	archive_entry_set_mtime(entry, atol16(header + afiol_mtime_offset, afiol_mtime_size), 0);
+	*namelength = atol16(header + afiol_namesize_offset, afiol_namesize_size);
+	*name_pad = 0; /* No padding of filename. */
+
+	cpio->entry_bytes_remaining =
+	    atol16(header + afiol_filesize_offset, afiol_filesize_size);
+	archive_entry_set_size(entry, cpio->entry_bytes_remaining);
+	cpio->entry_padding = 0;
+	__archive_read_consume(a, afiol_header_size);
+	return (ARCHIVE_OK);
+}
+
+
 static int
 header_bin_le(struct archive_read *a, struct cpio *cpio,
     struct archive_entry *entry, size_t *namelength, size_t *name_pad)
 {
 	const void *h;
-	const struct cpio_bin_header *header;
+	const unsigned char *header;
 
 	a->archive.archive_format = ARCHIVE_FORMAT_CPIO_BIN_LE;
 	a->archive.archive_format_name = "cpio (little-endian binary)";
 
 	/* Read fixed-size portion of header. */
-	h = __archive_read_ahead(a, sizeof(struct cpio_bin_header), NULL);
+	h = __archive_read_ahead(a, bin_header_size, NULL);
 	if (h == NULL)
 	    return (ARCHIVE_FATAL);
-	__archive_read_consume(a, sizeof(struct cpio_bin_header));
 
 	/* Parse out binary fields. */
-	header = (const struct cpio_bin_header *)h;
+	header = (const unsigned char *)h;
 
-	archive_entry_set_dev(entry, header->c_dev[0] + header->c_dev[1] * 256);
-	archive_entry_set_ino(entry, header->c_ino[0] + header->c_ino[1] * 256);
-	archive_entry_set_mode(entry, header->c_mode[0] + header->c_mode[1] * 256);
-	archive_entry_set_uid(entry, header->c_uid[0] + header->c_uid[1] * 256);
-	archive_entry_set_gid(entry, header->c_gid[0] + header->c_gid[1] * 256);
-	archive_entry_set_nlink(entry, header->c_nlink[0] + header->c_nlink[1] * 256);
-	archive_entry_set_rdev(entry, header->c_rdev[0] + header->c_rdev[1] * 256);
-	archive_entry_set_mtime(entry, le4(header->c_mtime), 0);
-	*namelength = header->c_namesize[0] + header->c_namesize[1] * 256;
+	archive_entry_set_dev(entry, header[bin_dev_offset] + header[bin_dev_offset + 1] * 256);
+	archive_entry_set_ino(entry, header[bin_ino_offset] + header[bin_ino_offset + 1] * 256);
+	archive_entry_set_mode(entry, header[bin_mode_offset] + header[bin_mode_offset + 1] * 256);
+	archive_entry_set_uid(entry, header[bin_uid_offset] + header[bin_uid_offset + 1] * 256);
+	archive_entry_set_gid(entry, header[bin_gid_offset] + header[bin_gid_offset + 1] * 256);
+	archive_entry_set_nlink(entry, header[bin_nlink_offset] + header[bin_nlink_offset + 1] * 256);
+	archive_entry_set_rdev(entry, header[bin_rdev_offset] + header[bin_rdev_offset + 1] * 256);
+	archive_entry_set_mtime(entry, le4(header + bin_mtime_offset), 0);
+	*namelength = header[bin_namesize_offset] + header[bin_namesize_offset + 1] * 256;
 	*name_pad = *namelength & 1; /* Pad to even. */
 
-	cpio->entry_bytes_remaining = le4(header->c_filesize);
+	cpio->entry_bytes_remaining = le4(header + bin_filesize_offset);
 	archive_entry_set_size(entry, cpio->entry_bytes_remaining);
 	cpio->entry_padding = cpio->entry_bytes_remaining & 1; /* Pad to even. */
+	__archive_read_consume(a, bin_header_size);
 	return (ARCHIVE_OK);
 }
 
@@ -622,33 +877,34 @@
     struct archive_entry *entry, size_t *namelength, size_t *name_pad)
 {
 	const void *h;
-	const struct cpio_bin_header *header;
+	const unsigned char *header;
 
 	a->archive.archive_format = ARCHIVE_FORMAT_CPIO_BIN_BE;
 	a->archive.archive_format_name = "cpio (big-endian binary)";
 
 	/* Read fixed-size portion of header. */
-	h = __archive_read_ahead(a, sizeof(struct cpio_bin_header), NULL);
+	h = __archive_read_ahead(a, bin_header_size, NULL);
 	if (h == NULL)
 	    return (ARCHIVE_FATAL);
-	__archive_read_consume(a, sizeof(struct cpio_bin_header));
 
 	/* Parse out binary fields. */
-	header = (const struct cpio_bin_header *)h;
-	archive_entry_set_dev(entry, header->c_dev[0] * 256 + header->c_dev[1]);
-	archive_entry_set_ino(entry, header->c_ino[0] * 256 + header->c_ino[1]);
-	archive_entry_set_mode(entry, header->c_mode[0] * 256 + header->c_mode[1]);
-	archive_entry_set_uid(entry, header->c_uid[0] * 256 + header->c_uid[1]);
-	archive_entry_set_gid(entry, header->c_gid[0] * 256 + header->c_gid[1]);
-	archive_entry_set_nlink(entry, header->c_nlink[0] * 256 + header->c_nlink[1]);
-	archive_entry_set_rdev(entry, header->c_rdev[0] * 256 + header->c_rdev[1]);
-	archive_entry_set_mtime(entry, be4(header->c_mtime), 0);
-	*namelength = header->c_namesize[0] * 256 + header->c_namesize[1];
+	header = (const unsigned char *)h;
+
+	archive_entry_set_dev(entry, header[bin_dev_offset] * 256 + header[bin_dev_offset + 1]);
+	archive_entry_set_ino(entry, header[bin_ino_offset] * 256 + header[bin_ino_offset + 1]);
+	archive_entry_set_mode(entry, header[bin_mode_offset] * 256 + header[bin_mode_offset + 1]);
+	archive_entry_set_uid(entry, header[bin_uid_offset] * 256 + header[bin_uid_offset + 1]);
+	archive_entry_set_gid(entry, header[bin_gid_offset] * 256 + header[bin_gid_offset + 1]);
+	archive_entry_set_nlink(entry, header[bin_nlink_offset] * 256 + header[bin_nlink_offset + 1]);
+	archive_entry_set_rdev(entry, header[bin_rdev_offset] * 256 + header[bin_rdev_offset + 1]);
+	archive_entry_set_mtime(entry, be4(header + bin_mtime_offset), 0);
+	*namelength = header[bin_namesize_offset] * 256 + header[bin_namesize_offset + 1];
 	*name_pad = *namelength & 1; /* Pad to even. */
 
-	cpio->entry_bytes_remaining = be4(header->c_filesize);
+	cpio->entry_bytes_remaining = be4(header + bin_filesize_offset);
 	archive_entry_set_size(entry, cpio->entry_bytes_remaining);
 	cpio->entry_padding = cpio->entry_bytes_remaining & 1; /* Pad to even. */
+	    __archive_read_consume(a, bin_header_size);
 	return (ARCHIVE_OK);
 }
 
@@ -667,7 +923,6 @@
                 free(cpio->links_head);
                 cpio->links_head = lp;
         }
-	archive_string_free(&cpio->entry_name);
 	free(cpio);
 	(a->format->data) = NULL;
 	return (ARCHIVE_OK);
@@ -733,15 +988,16 @@
 	return (l);
 }
 
-static void
-record_hardlink(struct cpio *cpio, struct archive_entry *entry)
+static int
+record_hardlink(struct archive_read *a,
+    struct cpio *cpio, struct archive_entry *entry)
 {
 	struct links_entry      *le;
 	dev_t dev;
 	int64_t ino;
 
 	if (archive_entry_nlink(entry) <= 1)
-		return;
+		return (ARCHIVE_OK);
 
 	dev = archive_entry_dev(entry);
 	ino = archive_entry_ino64(entry);
@@ -765,13 +1021,16 @@
 				free(le);
 			}
 
-			return;
+			return (ARCHIVE_OK);
 		}
 	}
 
 	le = (struct links_entry *)malloc(sizeof(struct links_entry));
-	if (le == NULL)
-		__archive_errx(1, "Out of memory adding file to list");
+	if (le == NULL) {
+		archive_set_error(&a->archive,
+		    ENOMEM, "Out of memory adding file to list");
+		return (ARCHIVE_FATAL);
+	}
 	if (cpio->links_head != NULL)
 		cpio->links_head->previous = le;
 	le->next = cpio->links_head;
@@ -781,6 +1040,11 @@
 	le->ino = ino;
 	le->links = archive_entry_nlink(entry) - 1;
 	le->name = strdup(archive_entry_pathname(entry));
-	if (le->name == NULL)
-		__archive_errx(1, "Out of memory adding file to list");
+	if (le->name == NULL) {
+		archive_set_error(&a->archive,
+		    ENOMEM, "Out of memory adding file to list");
+		return (ARCHIVE_FATAL);
+	}
+
+	return (ARCHIVE_OK);
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_read_support_format_empty.c
--- a/head/contrib/libarchive/libarchive/archive_read_support_format_empty.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_read_support_format_empty.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,16 +24,16 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_support_format_empty.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_support_format_empty.c 232153 2012-02-25 10:58:02Z mm $");
 
 #include "archive.h"
 #include "archive_entry.h"
 #include "archive_private.h"
 #include "archive_read_private.h"
 
-static int	archive_read_format_empty_bid(struct archive_read *);
+static int	archive_read_format_empty_bid(struct archive_read *, int);
 static int	archive_read_format_empty_read_data(struct archive_read *,
-		    const void **, size_t *, off_t *);
+		    const void **, size_t *, int64_t *);
 static int	archive_read_format_empty_read_header(struct archive_read *,
 		    struct archive_entry *);
 int
@@ -42,6 +42,9 @@
 	struct archive_read *a = (struct archive_read *)_a;
 	int r;
 
+	archive_check_magic(_a, ARCHIVE_READ_MAGIC,
+	    ARCHIVE_STATE_NEW, "archive_read_support_format_empty");
+
 	r = __archive_read_register_format(a,
 	    NULL,
 	    NULL,
@@ -57,14 +60,11 @@
 
 
 static int
-archive_read_format_empty_bid(struct archive_read *a)
+archive_read_format_empty_bid(struct archive_read *a, int best_bid)
 {
-	ssize_t avail;
-
-	(void)__archive_read_ahead(a, 1, &avail);
-	if (avail != 0)
-		return (-1);
-	return (1);
+	if (best_bid < 1 && __archive_read_ahead(a, 1, NULL) == NULL)
+		return (1);
+	return (-1);
 }
 
 static int
@@ -82,7 +82,7 @@
 
 static int
 archive_read_format_empty_read_data(struct archive_read *a,
-    const void **buff, size_t *size, off_t *offset)
+    const void **buff, size_t *size, int64_t *offset)
 {
 	(void)a; /* UNUSED */
 	(void)buff; /* UNUSED */
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_read_support_format_iso9660.c
--- a/head/contrib/libarchive/libarchive/archive_read_support_format_iso9660.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_read_support_format_iso9660.c	Fri Mar 02 16:54:40 2012 +0200
@@ -26,7 +26,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_support_format_iso9660.c 230759 2012-01-29 22:20:28Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_support_format_iso9660.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
@@ -47,6 +47,7 @@
 #include "archive.h"
 #include "archive_endian.h"
 #include "archive_entry.h"
+#include "archive_entry_locale.h"
 #include "archive_private.h"
 #include "archive_read_private.h"
 #include "archive_string.h"
@@ -285,6 +286,8 @@
 	int64_t		 number;
 	int		 nlinks;
 	struct archive_string name; /* Pathname */
+	unsigned char	*utf16be_name;
+	size_t		 utf16be_bytes;
 	char		 name_continues; /* Non-zero if name continues */
 	struct archive_string symlink;
 	char		 symlink_continues; /* Non-zero if link continues */
@@ -357,22 +360,34 @@
 		uint32_t	size;
 	} primary, joliet;
 
-	off_t	entry_sparse_offset;
+	int64_t	entry_sparse_offset;
 	int64_t	entry_bytes_remaining;
+	size_t  entry_bytes_unconsumed;
 	struct zisofs	 entry_zisofs;
 	struct content	*entry_content;
+	struct archive_string_conv *sconv_utf16be;
+	/*
+	 * Buffers for a full pathname in UTF-16BE in Joliet extensions.
+	 */
+#define UTF16_NAME_MAX	1024
+	unsigned char *utf16be_path;
+	size_t		 utf16be_path_len;
+	unsigned char *utf16be_previous_path;
+	size_t		 utf16be_previous_path_len;
 };
 
-static int	archive_read_format_iso9660_bid(struct archive_read *);
+static int	archive_read_format_iso9660_bid(struct archive_read *, int);
 static int	archive_read_format_iso9660_options(struct archive_read *,
 		    const char *, const char *);
 static int	archive_read_format_iso9660_cleanup(struct archive_read *);
 static int	archive_read_format_iso9660_read_data(struct archive_read *,
-		    const void **, size_t *, off_t *);
+		    const void **, size_t *, int64_t *);
 static int	archive_read_format_iso9660_read_data_skip(struct archive_read *);
 static int	archive_read_format_iso9660_read_header(struct archive_read *,
 		    struct archive_entry *);
 static const char *build_pathname(struct archive_string *, struct file_info *);
+static int	build_pathname_utf16be(unsigned char *, size_t, size_t *,
+		    struct file_info *);
 #if DEBUG
 static void	dump_isodirrec(FILE *, const unsigned char *isodirrec);
 #endif
@@ -388,8 +403,8 @@
 static int	isPVD(struct iso9660 *, const unsigned char *);
 static int	next_cache_entry(struct archive_read *, struct iso9660 *,
 		    struct file_info **);
-static int	next_entry_seek(struct archive_read *a, struct iso9660 *iso9660,
-		    struct file_info **pfile);
+static int	next_entry_seek(struct archive_read *, struct iso9660 *,
+		    struct file_info **);
 static struct file_info *
 		parse_file_info(struct archive_read *a,
 		    struct file_info *parent, const unsigned char *isodirrec);
@@ -417,12 +432,12 @@
 static inline void cache_add_entry(struct iso9660 *iso9660,
 		    struct file_info *file);
 static inline struct file_info *cache_get_entry(struct iso9660 *iso9660);
-static void	heap_add_entry(struct heap_queue *heap,
+static int	heap_add_entry(struct archive_read *a, struct heap_queue *heap,
 		    struct file_info *file, uint64_t key);
 static struct file_info *heap_get_entry(struct heap_queue *heap);
 
-#define add_entry(iso9660, file)	\
-	heap_add_entry(&((iso9660)->pending_files), file, file->offset)
+#define add_entry(arch, iso9660, file)	\
+	heap_add_entry(arch, &((iso9660)->pending_files), file, file->offset)
 #define next_entry(iso9660)		\
 	heap_get_entry(&((iso9660)->pending_files))
 
@@ -433,12 +448,15 @@
 	struct iso9660 *iso9660;
 	int r;
 
-	iso9660 = (struct iso9660 *)malloc(sizeof(*iso9660));
+	archive_check_magic(_a, ARCHIVE_READ_MAGIC,
+	    ARCHIVE_STATE_NEW, "archive_read_support_format_iso9660");
+
+	iso9660 = (struct iso9660 *)calloc(1, sizeof(*iso9660));
 	if (iso9660 == NULL) {
-		archive_set_error(&a->archive, ENOMEM, "Can't allocate iso9660 data");
+		archive_set_error(&a->archive, ENOMEM,
+		    "Can't allocate iso9660 data");
 		return (ARCHIVE_FATAL);
 	}
-	memset(iso9660, 0, sizeof(*iso9660));
 	iso9660->magic = ISO9660_MAGIC;
 	iso9660->cache_files.first = NULL;
 	iso9660->cache_files.last = &(iso9660->cache_files.first);
@@ -468,14 +486,18 @@
 
 
 static int
-archive_read_format_iso9660_bid(struct archive_read *a)
+archive_read_format_iso9660_bid(struct archive_read *a, int best_bid)
 {
 	struct iso9660 *iso9660;
 	ssize_t bytes_read;
-	const void *h;
 	const unsigned char *p;
 	int seenTerminator;
 
+	/* If there's already a better bid than we can ever
+	   make, don't bother testing. */
+	if (best_bid > 48)
+		return (-1);
+
 	iso9660 = (struct iso9660 *)(a->format->data);
 
 	/*
@@ -484,12 +506,11 @@
 	 * if the I/O layer gives us more, we'll take it.
 	 */
 #define RESERVED_AREA	(SYSTEM_AREA_BLOCK * LOGICAL_BLOCK_SIZE)
-	h = __archive_read_ahead(a,
+	p = __archive_read_ahead(a,
 	    RESERVED_AREA + 8 * LOGICAL_BLOCK_SIZE,
 	    &bytes_read);
-	if (h == NULL)
+	if (p == NULL)
 	    return (-1);
-	p = (const unsigned char *)h;
 
 	/* Skip the reserved area. */
 	bytes_read -= RESERVED_AREA;
@@ -505,10 +526,8 @@
 		/* Standard Identifier must be "CD001" */
 		if (memcmp(p + 1, "CD001", 5) != 0)
 			return (0);
-		if (!iso9660->primary.location) {
-			if (isPVD(iso9660, p))
-				continue;
-		}
+		if (isPVD(iso9660, p))
+			continue;
 		if (!iso9660->joliet.location) {
 			if (isJolietSVD(iso9660, p))
 				continue;
@@ -564,7 +583,7 @@
 
 	/* Note: The "warn" return is just to inform the options
 	 * supervisor that we didn't handle it.  It will generate
-	 * a suitable error if noone used this option. */
+	 * a suitable error if no one used this option. */
 	return (ARCHIVE_WARN);
 }
 
@@ -893,10 +912,10 @@
 		return (0);
 
 	/* Reserved field must be 0. */
-	/* FreeBSD: makefs erroneously created images with 0x20 */
+	/* But accept NetBSD/FreeBSD "makefs" images with 0x20 here. */
 	for (i = 0; i < PVD_reserved4_size; ++i)
-		if (h[PVD_reserved4_offset + i] != 0 &&
-		    h[PVD_reserved4_offset + i] != 32)
+		if (h[PVD_reserved4_offset + i] != 0
+		    && h[PVD_reserved4_offset + i] != 0x20)
 			return (0);
 
 	/* Reserved field must be 0. */
@@ -912,11 +931,13 @@
 	if (p[DR_length_offset] != 34)
 		return (0);
 
-	iso9660->logical_block_size = logical_block_size;
-	iso9660->volume_block = volume_block;
-	iso9660->volume_size = logical_block_size * (uint64_t)volume_block;
-	iso9660->primary.location = archive_le32dec(p + DR_extent_offset);
-	iso9660->primary.size = archive_le32dec(p + DR_size_offset);
+	if (!iso9660->primary.location) {
+		iso9660->logical_block_size = logical_block_size;
+		iso9660->volume_block = volume_block;
+		iso9660->volume_size = logical_block_size * (uint64_t)volume_block;
+		iso9660->primary.location = archive_le32dec(p + DR_extent_offset);
+		iso9660->primary.size = archive_le32dec(p + DR_size_offset);
+	}
 
 	return (48);
 }
@@ -927,7 +948,7 @@
 	struct iso9660 *iso9660;
 	const unsigned char *b, *p;
 	struct file_info *multi;
-	size_t step;
+	size_t step, skip_size;
 
 	iso9660 = (struct iso9660 *)(a->format->data);
 	if (iso9660->current_position > parent->offset) {
@@ -948,7 +969,7 @@
 		int64_t skipsize;
 
 		skipsize = parent->offset - iso9660->current_position;
-		skipsize = __archive_read_skip(a, skipsize);
+		skipsize = __archive_read_consume(a, skipsize);
 		if (skipsize < 0)
 			return ((int)skipsize);
 		iso9660->current_position = parent->offset;
@@ -963,9 +984,9 @@
 		    "ISO9660 directory list");
 		return (ARCHIVE_FATAL);
 	}
-	__archive_read_consume(a, step);
 	iso9660->current_position += step;
 	multi = NULL;
+	skip_size = step;
 	while (step) {
 		p = b;
 		b += iso9660->logical_block_size;
@@ -987,8 +1008,10 @@
 			    && *(p + DR_name_offset) == '\001')
 				continue;
 			child = parse_file_info(a, parent, p);
-			if (child == NULL)
+			if (child == NULL) {
+				__archive_read_consume(a, skip_size);
 				return (ARCHIVE_FATAL);
+			}
 			if (child->cl_offset == 0 &&
 			    (child->multi_extent || multi != NULL)) {
 				struct content *con;
@@ -1003,8 +1026,8 @@
 				if (con == NULL) {
 					archive_set_error(
 					    &a->archive, ENOMEM,
-					    "No memory for "
-					    "multi extent");
+					    "No memory for multi extent");
+					__archive_read_consume(a, skip_size);
 					return (ARCHIVE_FATAL);
 				}
 				con->offset = child->offset;
@@ -1012,18 +1035,23 @@
 				con->next = NULL;
 				*multi->contents.last = con;
 				multi->contents.last = &(con->next);
-				if (multi == child)
-					add_entry(iso9660, child);
-				else {
+				if (multi == child) {
+					if (add_entry(a, iso9660, child)
+					    != ARCHIVE_OK)
+						return (ARCHIVE_FATAL);
+				} else {
 					multi->size += child->size;
 					if (!child->multi_extent)
 						multi = NULL;
 				}
 			} else
-				add_entry(iso9660, child);
+				if (add_entry(a, iso9660, child) != ARCHIVE_OK)
+					return (ARCHIVE_FATAL);
 		}
 	}
 
+	__archive_read_consume(a, skip_size);
+
 	/* Read data which recorded by RRIP "CE" extension. */
 	if (read_CE(a, iso9660) != ARCHIVE_OK)
 		return (ARCHIVE_FATAL);
@@ -1061,7 +1089,7 @@
 			vd = &(iso9660->joliet);
 
 		skipsize = LOGICAL_BLOCK_SIZE * vd->location;
-		skipsize = __archive_read_skip(a, skipsize);
+		skipsize = __archive_read_consume(a, skipsize);
 		if (skipsize < 0)
 			return ((int)skipsize);
 		iso9660->current_position = skipsize;
@@ -1099,7 +1127,7 @@
 			vd = &(iso9660->joliet);
 			skipsize = LOGICAL_BLOCK_SIZE * vd->location;
 			skipsize -= iso9660->current_position;
-			skipsize = __archive_read_skip(a, skipsize);
+			skipsize = __archive_read_consume(a, skipsize);
 			if (skipsize < 0)
 				return ((int)skipsize);
 			iso9660->current_position += skipsize;
@@ -1112,7 +1140,6 @@
 				    "ISO9660 directory list");
 				return (ARCHIVE_FATAL);
 			}
-			seenJoliet = iso9660->seenJoliet;/* Save flag. */
 			iso9660->seenJoliet = 0;
 			file = parse_file_info(a, NULL, block);
 			if (file == NULL)
@@ -1120,7 +1147,8 @@
 			iso9660->seenJoliet = seenJoliet;
 		}
 		/* Store the root directory in the pending list. */
-		add_entry(iso9660, file);
+		if (add_entry(a, iso9660, file) != ARCHIVE_OK)
+			return (ARCHIVE_FATAL);
 		if (iso9660->seenRockridge) {
 			a->archive.archive_format =
 			    ARCHIVE_FORMAT_ISO9660_ROCKRIDGE;
@@ -1129,17 +1157,82 @@
 		}
 	}
 
+	file = NULL;/* Eliminate a warning. */
 	/* Get the next entry that appears after the current offset. */
 	r = next_entry_seek(a, iso9660, &file);
 	if (r != ARCHIVE_OK)
 		return (r);
 
+	if (iso9660->seenJoliet) {
+		/*
+		 * Convert UTF-16BE of a filename to local locale MBS
+		 * and store the result into a filename field.
+		 */
+		if (iso9660->sconv_utf16be == NULL) {
+			iso9660->sconv_utf16be =
+			    archive_string_conversion_from_charset(
+				&(a->archive), "UTF-16BE", 1);
+			if (iso9660->sconv_utf16be == NULL)
+				/* Coundn't allocate memory */
+				return (ARCHIVE_FATAL);
+		}
+		if (iso9660->utf16be_path == NULL) {
+			iso9660->utf16be_path = malloc(UTF16_NAME_MAX);
+			if (iso9660->utf16be_path == NULL) {
+				archive_set_error(&a->archive, ENOMEM,
+				    "No memory");
+				return (ARCHIVE_FATAL);
+			}
+		}
+		if (iso9660->utf16be_previous_path == NULL) {
+			iso9660->utf16be_previous_path = malloc(UTF16_NAME_MAX);
+			if (iso9660->utf16be_previous_path == NULL) {
+				archive_set_error(&a->archive, ENOMEM,
+				    "No memory");
+				return (ARCHIVE_FATAL);
+			}
+		}
+
+		iso9660->utf16be_path_len = 0;
+		if (build_pathname_utf16be(iso9660->utf16be_path,
+		    UTF16_NAME_MAX, &(iso9660->utf16be_path_len), file) != 0) {
+			archive_set_error(&a->archive,
+			    ARCHIVE_ERRNO_FILE_FORMAT,
+			    "Pathname is too long");
+		}
+
+		r = archive_entry_copy_pathname_l(entry,
+		    (const char *)iso9660->utf16be_path,
+		    iso9660->utf16be_path_len,
+		    iso9660->sconv_utf16be);
+		if (r != 0) {
+			if (errno == ENOMEM) {
+				archive_set_error(&a->archive, ENOMEM,
+				    "No memory for Pathname");
+				return (ARCHIVE_FATAL);
+			}
+			archive_set_error(&a->archive,
+			    ARCHIVE_ERRNO_FILE_FORMAT,
+			    "Pathname cannot be converted "
+			    "from %s to current locale.",
+			    archive_string_conversion_charset_name(
+			      iso9660->sconv_utf16be));
+
+			rd_r = ARCHIVE_WARN;
+		}
+	} else {
+		archive_string_empty(&iso9660->pathname);
+		archive_entry_set_pathname(entry,
+		    build_pathname(&iso9660->pathname, file));
+	}
+
 	iso9660->entry_bytes_remaining = file->size;
 	iso9660->entry_sparse_offset = 0; /* Offset for sparse-file-aware clients. */
 
 	if (file->offset + file->size > iso9660->volume_size) {
 		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
-		    "File is beyond end-of-media: %s", file->name.s);
+		    "File is beyond end-of-media: %s",
+		    archive_entry_pathname(entry));
 		iso9660->entry_bytes_remaining = 0;
 		iso9660->entry_sparse_offset = 0;
 		return (ARCHIVE_WARN);
@@ -1160,9 +1253,6 @@
 	/* N.B.: Rock Ridge supports 64-bit device numbers. */
 	archive_entry_set_rdev(entry, (dev_t)file->rdev);
 	archive_entry_set_size(entry, iso9660->entry_bytes_remaining);
-	archive_string_empty(&iso9660->pathname);
-	archive_entry_set_pathname(entry,
-	    build_pathname(&iso9660->pathname, file));
 	if (file->symlink.s != NULL)
 		archive_entry_copy_symlink(entry, file->symlink.s);
 
@@ -1172,12 +1262,32 @@
 	 * original entry. */
 	if (file->number != -1 &&
 	    file->number == iso9660->previous_number) {
-		archive_entry_set_hardlink(entry,
-		    iso9660->previous_pathname.s);
+		if (iso9660->seenJoliet) {
+			r = archive_entry_copy_hardlink_l(entry,
+			    (const char *)iso9660->utf16be_previous_path,
+			    iso9660->utf16be_previous_path_len,
+			    iso9660->sconv_utf16be);
+			if (r != 0) {
+				if (errno == ENOMEM) {
+					archive_set_error(&a->archive, ENOMEM,
+					    "No memory for Linkname");
+					return (ARCHIVE_FATAL);
+				}
+				archive_set_error(&a->archive,
+				    ARCHIVE_ERRNO_FILE_FORMAT,
+				    "Linkname cannot be converted "
+				    "from %s to current locale.",
+				    archive_string_conversion_charset_name(
+				      iso9660->sconv_utf16be));
+				rd_r = ARCHIVE_WARN;
+			}
+		} else
+			archive_entry_set_hardlink(entry,
+			    iso9660->previous_pathname.s);
 		archive_entry_unset_size(entry);
 		iso9660->entry_bytes_remaining = 0;
 		iso9660->entry_sparse_offset = 0;
-		return (ARCHIVE_OK);
+		return (rd_r);
 	}
 
 	/* Except for the hardlink case above, if the offset of the
@@ -1198,7 +1308,8 @@
 	if ((file->mode & AE_IFMT) != AE_IFDIR &&
 	    file->offset < iso9660->current_position) {
 		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
-		    "Ignoring out-of-order file (%s) %jd < %jd",
+		    "Ignoring out-of-order file @%jx (%s) %jd < %jd",
+		    (intmax_t)file->number,
 		    iso9660->pathname.s,
 		    (intmax_t)file->offset,
 		    (intmax_t)iso9660->current_position);
@@ -1226,7 +1337,13 @@
 	}
 
 	iso9660->previous_number = file->number;
-	archive_strcpy(&iso9660->previous_pathname, iso9660->pathname.s);
+	if (iso9660->seenJoliet) {
+		memcpy(iso9660->utf16be_previous_path, iso9660->utf16be_path,
+		    iso9660->utf16be_path_len);
+		iso9660->utf16be_previous_path_len = iso9660->utf16be_path_len;
+	} else
+		archive_strcpy(
+		    &iso9660->previous_pathname, iso9660->pathname.s);
 
 	/* Reset entry_bytes_remaining if the file is multi extent. */
 	iso9660->entry_content = file->contents.first;
@@ -1260,7 +1377,7 @@
 
 static int
 zisofs_read_data(struct archive_read *a,
-    const void **buff, size_t *size, off_t *offset)
+    const void **buff, size_t *size, int64_t *offset)
 {
 	struct iso9660 *iso9660;
 	struct zisofs  *zisofs;
@@ -1382,7 +1499,7 @@
 		}
 
 		if (!zisofs->initialized)
-			goto next_data; /* We need more datas. */
+			goto next_data; /* We need more data. */
 	}
 
 	/*
@@ -1393,21 +1510,26 @@
 
 		if (zisofs->block_off + 4 >= zisofs->block_pointers_size) {
 			/* There isn't a pair of offsets. */
-			archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+			archive_set_error(&a->archive,
+			    ARCHIVE_ERRNO_FILE_FORMAT,
 			    "Illegal zisofs block pointers");
 			return (ARCHIVE_FATAL);
 		}
-		bst = archive_le32dec(zisofs->block_pointers + zisofs->block_off);
+		bst = archive_le32dec(
+		    zisofs->block_pointers + zisofs->block_off);
 		if (bst != zisofs->pz_offset + (bytes_read - avail)) {
-			/* TODO: Should we seek offset of current file by bst ? */
-			archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+			/* TODO: Should we seek offset of current file
+			 * by bst ? */
+			archive_set_error(&a->archive,
+			    ARCHIVE_ERRNO_FILE_FORMAT,
 			    "Illegal zisofs block pointers(cannot seek)");
 			return (ARCHIVE_FATAL);
 		}
 		bed = archive_le32dec(
 		    zisofs->block_pointers + zisofs->block_off + 4);
 		if (bed < bst) {
-			archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+			archive_set_error(&a->archive,
+			    ARCHIVE_ERRNO_FILE_FORMAT,
 			    "Illegal zisofs block pointers");
 			return (ARCHIVE_FATAL);
 		}
@@ -1430,7 +1552,7 @@
 	}
 
 	/*
-	 * Make uncompressed datas.
+	 * Make uncompressed data.
 	 */
 	if (zisofs->block_avail == 0) {
 		memset(zisofs->uncompressed_buffer, 0,
@@ -1469,7 +1591,7 @@
 	iso9660->entry_bytes_remaining -= bytes_read;
 	iso9660->current_position += bytes_read;
 	zisofs->pz_offset += bytes_read;
-	__archive_read_consume(a, bytes_read);
+	iso9660->entry_bytes_unconsumed += bytes_read;
 
 	return (ARCHIVE_OK);
 }
@@ -1478,7 +1600,7 @@
 
 static int
 zisofs_read_data(struct archive_read *a,
-    const void **buff, size_t *size, off_t *offset)
+    const void **buff, size_t *size, int64_t *offset)
 {
 
 	(void)buff;/* UNUSED */
@@ -1493,12 +1615,18 @@
 
 static int
 archive_read_format_iso9660_read_data(struct archive_read *a,
-    const void **buff, size_t *size, off_t *offset)
+    const void **buff, size_t *size, int64_t *offset)
 {
 	ssize_t bytes_read;
 	struct iso9660 *iso9660;
 
 	iso9660 = (struct iso9660 *)(a->format->data);
+
+	if (iso9660->entry_bytes_unconsumed) {
+		__archive_read_consume(a, iso9660->entry_bytes_unconsumed);
+		iso9660->entry_bytes_unconsumed = 0;
+	}
+
 	if (iso9660->entry_bytes_remaining <= 0) {
 		if (iso9660->entry_content != NULL)
 			iso9660->entry_content = iso9660->entry_content->next;
@@ -1514,7 +1642,7 @@
 
 			step = iso9660->entry_content->offset -
 			    iso9660->current_position;
-			step = __archive_read_skip(a, step);
+			step = __archive_read_consume(a, step);
 			if (step < 0)
 				return ((int)step);
 			iso9660->current_position =
@@ -1548,8 +1676,8 @@
 	*offset = iso9660->entry_sparse_offset;
 	iso9660->entry_sparse_offset += bytes_read;
 	iso9660->entry_bytes_remaining -= bytes_read;
+	iso9660->entry_bytes_unconsumed = bytes_read;
 	iso9660->current_position += bytes_read;
-	__archive_read_consume(a, bytes_read);
 	return (ARCHIVE_OK);
 }
 
@@ -1577,6 +1705,8 @@
 		}
 	}
 #endif
+	free(iso9660->utf16be_path);
+	free(iso9660->utf16be_previous_path);
 	free(iso9660);
 	(a->format->data) = NULL;
 	return (r);
@@ -1627,20 +1757,26 @@
 	if (location > 0 &&
 	    (location + ((fsize + iso9660->logical_block_size -1)
 	       / iso9660->logical_block_size))
-		> (uint32_t)iso9660->volume_block) {
+			> (uint32_t)iso9660->volume_block) {
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+		    "Invalid location of extent of file");
+		return (NULL);
+	}
+	/* Sanity check that location doesn't have a negative value
+	 * when the file is not empty. it's too large. */
+	if (fsize != 0 && location < 0) {
 		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
 		    "Invalid location of extent of file");
 		return (NULL);
 	}
 
 	/* Create a new file entry and copy data from the ISO dir record. */
-	file = (struct file_info *)malloc(sizeof(*file));
+	file = (struct file_info *)calloc(1, sizeof(*file));
 	if (file == NULL) {
 		archive_set_error(&a->archive, ENOMEM,
 		    "No memory for file entry");
 		return (NULL);
 	}
-	memset(file, 0, sizeof(*file));
 	file->parent = parent;
 	file->offset = iso9660->logical_block_size * (uint64_t)location;
 	file->size = fsize;
@@ -1661,24 +1797,13 @@
 		 * names which are 103 UCS2 characters(206 bytes) by their
 		 * option '-joliet-long'.
 		 */
-		wchar_t wbuff[103+1], *wp;
-		const unsigned char *c;
-
 		if (name_len > 206)
 			name_len = 206;
-		/* convert BE UTF-16 to wchar_t */
-		for (c = p, wp = wbuff;
-				c < (p + name_len) &&
-				wp < (wbuff + sizeof(wbuff)/sizeof(*wbuff) - 1);
-				c += 2) {
-			*wp++ = (((255 & (int)c[0]) << 8) | (255 & (int)c[1]));
-		}
-		*wp = L'\0';
+		name_len &= ~1;
 
-#if 0 /* untested code, is it at all useful on Joliet? */
 		/* trim trailing first version and dot from filename.
 		 *
-		 * Remember we where in UTF-16BE land!
+		 * Remember we were in UTF-16BE land!
 		 * SEPARATOR 1 (.) and SEPARATOR 2 (;) are both
 		 * 16 bits big endian characters on Joliet.
 		 *
@@ -1687,18 +1812,21 @@
 		 *       *, /, :, ;, ? and \.
 		 */
 		/* Chop off trailing ';1' from files. */
-		if (*(wp-2) == ';' && *(wp-1) == '1') {
-			wp-=2;
-			*wp = L'\0';
+		if (name_len > 4 && p[name_len-4] == 0 && p[name_len-3] == ';'
+		    && p[name_len-2] == 0 && p[name_len-1] == '1')
+			name_len -= 4;
+#if 0 /* XXX: this somehow manages to strip of single-character file extensions, like '.c'. */
+		/* Chop off trailing '.' from filenames. */
+		if (name_len > 2 && p[name_len-2] == 0 && p[name_len-1] == '.')
+			name_len -= 2;
+#endif
+		if ((file->utf16be_name = malloc(name_len)) == NULL) {
+			archive_set_error(&a->archive, ENOMEM,
+			    "No memory for file name");
+			return (NULL);
 		}
-
-		/* Chop off trailing '.' from filenames. */
-		if (*(wp-1) == '.')
-			*(--wp) = L'\0';
-#endif
-
-		/* store the result in the file name field. */
-		archive_strappend_w_utf8(&file->name, wbuff);
+		memcpy(file->utf16be_name, p, name_len);
+		file->utf16be_bytes = name_len;
 	} else {
 		/* Chop off trailing ';1' from files. */
 		if (name_len > 2 && p[name_len - 2] == ';' &&
@@ -1721,22 +1849,24 @@
 	else
 		file->multi_extent = 0;
 	/*
-	 * Use location for file number.
-	 * File number is treated as inode number to find out harlink
-	 * target. If Rockridge extensions is being used, file number
-	 * will be overwritten by FILE SERIAL NUMBER of RRIP "PX"
-	 * extension.
-	 * NOTE: Old mkisofs did not record that FILE SERIAL NUMBER
+	 * Use a location for the file number, which is treated as an inode
+	 * number to find out hardlink target. If Rockridge extensions is
+	 * being used, the file number will be overwritten by FILE SERIAL
+	 * NUMBER of RRIP "PX" extension.
+	 * Note: Old mkisofs did not record that FILE SERIAL NUMBER
 	 * in ISO images.
+	 * Note2: xorriso set 0 to the location of a symlink file. 
 	 */
-	if (file->size == 0 && location >= 0)
-		/* If file->size is zero, its location points wrong place.
-		 * Dot not use it for file number.
-		 * When location has negative value, it can be used
-		 * for file number.
+	if (file->size == 0 && location >= 0) {
+		/* If file->size is zero, its location points wrong place,
+		 * and so we should not use it for the file number.
+		 * When the location has negative value, it can be used
+		 * for the file number.
 		 */
 		file->number = -1;
-	else
+		/* Do not appear before any directory entries. */
+		file->offset = -1;
+	} else
 		file->number = (int64_t)(uint32_t)location;
 
 	/* Rockridge extensions overwrite information from above. */
@@ -2123,9 +2253,13 @@
 	offset = ((uint64_t)location) * (uint64_t)iso9660->logical_block_size;
 	if (((file->mode & AE_IFMT) == AE_IFREG &&
 	    offset >= file->offset) ||
-	    offset < iso9660->current_position) {
+	    offset < iso9660->current_position ||
+	    (((uint64_t)file->ce_offset) + file->ce_size)
+	      > (uint64_t)iso9660->logical_block_size ||
+	    offset + file->ce_offset + file->ce_size
+		  > iso9660->volume_size) {
 		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
-		    "Invalid location in SUSP \"CE\" extension");
+		    "Invalid parameter in SUSP \"CE\" extension");
 		return (ARCHIVE_FATAL);
 	}
 
@@ -2139,11 +2273,15 @@
 		else
 			new_size = heap->allocated * 2;
 		/* Overflow might keep us from growing the list. */
-		if (new_size <= heap->allocated)
-			__archive_errx(1, "Out of memory");
+		if (new_size <= heap->allocated) {
+			archive_set_error(&a->archive, ENOMEM, "Out of memory");
+			return (ARCHIVE_FATAL);
+		}
 		p = malloc(new_size * sizeof(p[0]));
-		if (p == NULL)
-			__archive_errx(1, "Out of memory");
+		if (p == NULL) {
+			archive_set_error(&a->archive, ENOMEM, "Out of memory");
+			return (ARCHIVE_FATAL);
+		}
 		if (heap->reqs != NULL) {
 			memcpy(p, heap->reqs, heap->cnt * sizeof(*p));
 			free(heap->reqs);
@@ -2164,7 +2302,7 @@
 			heap->reqs[hole].file = file;
 			return (ARCHIVE_OK);
 		}
-		// Move parent into hole <==> move hole up tree.
+		/* Move parent into hole <==> move hole up tree. */
 		heap->reqs[hole] = heap->reqs[parent];
 		hole = parent;
 	}
@@ -2191,14 +2329,14 @@
 	/*
 	 * Rebalance the heap.
 	 */
-	a = 0; // Starting element and its offset
+	a = 0; /* Starting element and its offset */
 	a_offset = heap->reqs[a].offset;
 	for (;;) {
-		b = a + a + 1; // First child
+		b = a + a + 1; /* First child */
 		if (b >= heap->cnt)
 			return;
 		b_offset = heap->reqs[b].offset;
-		c = b + 1; // Use second child if it is smaller.
+		c = b + 1; /* Use second child if it is smaller. */
 		if (c < heap->cnt) {
 			c_offset = heap->reqs[c].offset;
 			if (c_offset < b_offset) {
@@ -2240,6 +2378,12 @@
 		}
 		do {
 			file = heap->reqs[0].file;
+			if (file->ce_offset + file->ce_size > step) {
+				archive_set_error(&a->archive,
+				    ARCHIVE_ERRNO_FILE_FORMAT,
+				    "Malformed CE information");
+				return (ARCHIVE_FATAL);
+			}
 			p = b + file->ce_offset;
 			end = p + file->ce_size;
 			next_CE(heap);
@@ -2280,12 +2424,14 @@
 	case 0:
 		if (data_length < 2)
 			return;
-		archive_strncat(&file->name, (const char *)data + 1, data_length - 1);
+		archive_strncat(&file->name,
+		    (const char *)data + 1, data_length - 1);
 		break;
 	case 1:
 		if (data_length < 2)
 			return;
-		archive_strncat(&file->name, (const char *)data + 1, data_length - 1);
+		archive_strncat(&file->name,
+		    (const char *)data + 1, data_length - 1);
 		file->name_continues = 1;
 		break;
 	case 2:
@@ -2496,6 +2642,7 @@
 
 		archive_string_free(&file->name);
 		archive_string_free(&file->symlink);
+		free(file->utf16be_name);
 		con = file->contents.first;
 		while (con != NULL) {
 			connext = con->next;
@@ -2523,12 +2670,19 @@
 	if (file->size == 0)
 		file->offset = iso9660->current_position;
 
+	/* flush any remaining bytes from the last round to ensure
+	 * we're positioned */
+	if (iso9660->entry_bytes_unconsumed) {
+		__archive_read_consume(a, iso9660->entry_bytes_unconsumed);
+		iso9660->entry_bytes_unconsumed = 0;
+	}
+
 	/* Seek forward to the start of the entry. */
 	if (iso9660->current_position < file->offset) {
 		int64_t step;
 
 		step = file->offset - iso9660->current_position;
-		step = __archive_read_skip(a, step);
+		step = __archive_read_consume(a, step);
 		if (step < 0)
 			return ((int)step);
 		iso9660->current_position = file->offset;
@@ -2819,13 +2973,15 @@
 	if ((file = iso9660->cache_files.first) != NULL) {
 		iso9660->cache_files.first = file->next;
 		if (iso9660->cache_files.first == NULL)
-			iso9660->cache_files.last = &(iso9660->cache_files.first);
+			iso9660->cache_files.last =
+			    &(iso9660->cache_files.first);
 	}
 	return (file);
 }
 
-static void
-heap_add_entry(struct heap_queue *heap, struct file_info *file, uint64_t key)
+static int
+heap_add_entry(struct archive_read *a, struct heap_queue *heap,
+    struct file_info *file, uint64_t key)
 {
 	uint64_t file_key, parent_key;
 	int hole, parent;
@@ -2838,12 +2994,18 @@
 		if (heap->allocated < 1024)
 			new_size = 1024;
 		/* Overflow might keep us from growing the list. */
-		if (new_size <= heap->allocated)
-			__archive_errx(1, "Out of memory");
+		if (new_size <= heap->allocated) {
+			archive_set_error(&a->archive,
+			    ENOMEM, "Out of memory");
+			return (ARCHIVE_FATAL);
+		}
 		new_pending_files = (struct file_info **)
 		    malloc(new_size * sizeof(new_pending_files[0]));
-		if (new_pending_files == NULL)
-			__archive_errx(1, "Out of memory");
+		if (new_pending_files == NULL) {
+			archive_set_error(&a->archive,
+			    ENOMEM, "Out of memory");
+			return (ARCHIVE_FATAL);
+		}
 		memcpy(new_pending_files, heap->files,
 		    heap->allocated * sizeof(new_pending_files[0]));
 		if (heap->files != NULL)
@@ -2863,13 +3025,15 @@
 		parent_key = heap->files[parent]->key;
 		if (file_key >= parent_key) {
 			heap->files[hole] = file;
-			return;
+			return (ARCHIVE_OK);
 		}
-		// Move parent into hole <==> move hole up tree.
+		/* Move parent into hole <==> move hole up tree. */
 		heap->files[hole] = heap->files[parent];
 		hole = parent;
 	}
 	heap->files[0] = file;
+
+	return (ARCHIVE_OK);
 }
 
 static struct file_info *
@@ -2895,14 +3059,14 @@
 	/*
 	 * Rebalance the heap.
 	 */
-	a = 0; // Starting element and its heap key
+	a = 0; /* Starting element and its heap key */
 	a_key = heap->files[a]->key;
 	for (;;) {
-		b = a + a + 1; // First child
+		b = a + a + 1; /* First child */
 		if (b >= heap->used)
 			return (r);
 		b_key = heap->files[b]->key;
-		c = b + 1; // Use second child if it is smaller.
+		c = b + 1; /* Use second child if it is smaller. */
 		if (c < heap->used) {
 			c_key = heap->files[c]->key;
 			if (c_key < b_key) {
@@ -2980,6 +3144,8 @@
 #if HAVE_TIMEGM
 	/* Use platform timegm() if available. */
 	return (timegm(t));
+#elif HAVE__MKGMTIME64
+	return (_mkgmtime64(t));
 #else
 	/* Else use direct calculation using POSIX assumptions. */
 	/* First, fix up tm_yday based on the year/month/day. */
@@ -3007,6 +3173,32 @@
 	return (as->s);
 }
 
+static int
+build_pathname_utf16be(unsigned char *p, size_t max, size_t *len,
+    struct file_info *file)
+{
+	if (file->parent != NULL && file->parent->utf16be_bytes > 0) {
+		if (build_pathname_utf16be(p, max, len, file->parent) != 0)
+			return (-1);
+		p[*len] = 0;
+		p[*len + 1] = '/';
+		*len += 2;
+	}
+	if (file->utf16be_bytes == 0) {
+		if (*len + 2 > max)
+			return (-1);/* Path is too long! */
+		p[*len] = 0;
+		p[*len + 1] = '.';
+		*len += 2;
+	} else {
+		if (*len + file->utf16be_bytes > max)
+			return (-1);/* Path is too long! */
+		memcpy(p + *len, file->utf16be_name, file->utf16be_bytes);
+		*len += file->utf16be_bytes;
+	}
+	return (0);
+}
+
 #if DEBUG
 static void
 dump_isodirrec(FILE *out, const unsigned char *isodirrec)
@@ -3019,7 +3211,7 @@
 	    toi(isodirrec + DR_extent_offset, DR_extent_size));
 	fprintf(out, " s %d,",
 	    toi(isodirrec + DR_size_offset, DR_extent_size));
-	fprintf(out, " f 0x%02x,",
+	fprintf(out, " f 0x%x,",
 	    toi(isodirrec + DR_flags_offset, DR_flags_size));
 	fprintf(out, " u %d,",
 	    toi(isodirrec + DR_file_unit_size_offset, DR_file_unit_size_size));
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_read_support_format_mtree.c
--- a/head/contrib/libarchive/libarchive/archive_read_support_format_mtree.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_read_support_format_mtree.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,6 +1,7 @@
 /*-
  * Copyright (c) 2003-2007 Tim Kientzle
  * Copyright (c) 2008 Joerg Sonnenberger
+ * Copyright (c) 2011 Michihiro NAKAJIMA
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -25,7 +26,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_support_format_mtree.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_support_format_mtree.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
@@ -86,9 +87,8 @@
 	struct archive_string	 line;
 	size_t			 buffsize;
 	char			*buff;
-	off_t			 offset;
+	int64_t			 offset;
 	int			 fd;
-	int			 filetype;
 	int			 archive_format;
 	const char		*archive_format_name;
 	struct mtree_entry	*entries;
@@ -98,11 +98,12 @@
 
 	struct archive_entry_linkresolver *resolver;
 
-	off_t			 cur_size, cur_offset;
+	int64_t			 cur_size;
 };
 
+static int	bid_keycmp(const char *, const char *, ssize_t);
 static int	cleanup(struct archive_read *);
-static int	mtree_bid(struct archive_read *);
+static int	mtree_bid(struct archive_read *, int);
 static int	parse_file(struct archive_read *, struct archive_entry *,
 		    struct mtree *, struct mtree_entry *, int *);
 static void	parse_escapes(char *, struct mtree_entry *);
@@ -111,7 +112,7 @@
 static int	parse_keyword(struct archive_read *, struct mtree *,
 		    struct archive_entry *, struct mtree_option *, int *);
 static int	read_data(struct archive_read *a,
-		    const void **buff, size_t *size, off_t *offset);
+		    const void **buff, size_t *size, int64_t *offset);
 static ssize_t	readline(struct archive_read *, struct mtree *, char **, ssize_t);
 static int	skip(struct archive_read *a);
 static int	read_header(struct archive_read *,
@@ -120,6 +121,53 @@
 static int64_t	mtree_atol8(char **);
 static int64_t	mtree_atol(char **);
 
+/*
+ * There's no standard for TIME_T_MAX/TIME_T_MIN.  So we compute them
+ * here.  TODO: Move this to configure time, but be careful
+ * about cross-compile environments.
+ */
+static int64_t
+get_time_t_max(void)
+{
+#if defined(TIME_T_MAX)
+	return TIME_T_MAX;
+#else
+	static time_t t;
+	time_t a;
+	if (t == 0) {
+		a = 1;
+		while (a > t) {
+			t = a;
+			a = a * 2 + 1;
+		}
+	}
+	return t;
+#endif
+}
+
+static int64_t
+get_time_t_min(void)
+{
+#if defined(TIME_T_MIN)
+	return TIME_T_MIN;
+#else
+	/* 't' will hold the minimum value, which will be zero (if
+	 * time_t is unsigned) or -2^n (if time_t is signed). */
+	static int computed;
+	static time_t t;
+	time_t a;
+	if (computed == 0) {
+		a = (time_t)-1;
+		while (a < t) {
+			t = a;
+			a = a * 2;
+		}			
+		computed = 1;
+	}
+	return t;
+#endif
+}
+
 static void
 free_options(struct mtree_option *head)
 {
@@ -139,6 +187,9 @@
 	struct mtree *mtree;
 	int r;
 
+	archive_check_magic(_a, ARCHIVE_READ_MAGIC,
+	    ARCHIVE_STATE_NEW, "archive_read_support_format_mtree");
+
 	mtree = (struct mtree *)malloc(sizeof(*mtree));
 	if (mtree == NULL) {
 		archive_set_error(&a->archive, ENOMEM,
@@ -183,20 +234,389 @@
 	return (ARCHIVE_OK);
 }
 
+static ssize_t
+get_line_size(const char *b, ssize_t avail, ssize_t *nlsize)
+{
+	ssize_t len;
+
+	len = 0;
+	while (len < avail) {
+		switch (*b) {
+		case '\0':/* Non-ascii character or control character. */
+			if (nlsize != NULL)
+				*nlsize = 0;
+			return (-1);
+		case '\r':
+			if (avail-len > 1 && b[1] == '\n') {
+				if (nlsize != NULL)
+					*nlsize = 2;
+				return (len+2);
+			}
+			/* FALL THROUGH */
+		case '\n':
+			if (nlsize != NULL)
+				*nlsize = 1;
+			return (len+1);
+		default:
+			b++;
+			len++;
+			break;
+		}
+	}
+	if (nlsize != NULL)
+		*nlsize = 0;
+	return (avail);
+}
+
+static ssize_t
+next_line(struct archive_read *a,
+    const char **b, ssize_t *avail, ssize_t *ravail, ssize_t *nl)
+{
+	ssize_t len;
+	int quit;
+	
+	quit = 0;
+	if (*avail == 0) {
+		*nl = 0;
+		len = 0;
+	} else
+		len = get_line_size(*b, *avail, nl);
+	/*
+	 * Read bytes more while it does not reach the end of line.
+	 */
+	while (*nl == 0 && len == *avail && !quit) {
+		ssize_t diff = *ravail - *avail;
+		size_t nbytes_req = (*ravail+1023) & ~1023U;
+		ssize_t tested;
+
+		/* Increase reading bytes if it is not enough to at least
+		 * new two lines. */
+		if (nbytes_req < (size_t)*ravail + 160)
+			nbytes_req <<= 1;
+
+		*b = __archive_read_ahead(a, nbytes_req, avail);
+		if (*b == NULL) {
+			if (*ravail >= *avail)
+				return (0);
+			/* Reading bytes reaches the end of file. */
+			*b = __archive_read_ahead(a, *avail, avail);
+			quit = 1;
+		}
+		*ravail = *avail;
+		*b += diff;
+		*avail -= diff;
+		tested = len;/* Skip some bytes we already determinated. */
+		len = get_line_size(*b, *avail, nl);
+		if (len >= 0)
+			len += tested;
+	}
+	return (len);
+}
+
+/*
+ * Compare characters with a mtree keyword.
+ * Returns the length of a mtree keyword if matched.
+ * Returns 0 if not matched.
+ */
+static int
+bid_keycmp(const char *p, const char *key, ssize_t len)
+{
+	int match_len = 0;
+
+	while (len > 0 && *p && *key) {
+		if (*p == *key) {
+			--len;
+			++p;
+			++key;
+			++match_len;
+			continue;
+		}
+		return (0);/* Not match */
+	}
+	if (*key != '\0')
+		return (0);/* Not match */
+
+	/* A following character should be specified characters */
+	if (p[0] == '=' || p[0] == ' ' || p[0] == '\t' ||
+	    p[0] == '\n' || p[0] == '\r' ||
+	   (p[0] == '\\' && (p[1] == '\n' || p[1] == '\r')))
+		return (match_len);
+	return (0);/* Not match */
+}
+
+/*
+ * Test whether the characters 'p' has is mtree keyword.
+ * Returns the length of a detected keyword.
+ * Returns 0 if any keywords were not found.
+ */
+static ssize_t
+bid_keyword(const char *p,  ssize_t len)
+{
+	static const char *keys_c[] = {
+		"content", "contents", "cksum", NULL
+	};
+	static const char *keys_df[] = {
+		"device", "flags", NULL
+	};
+	static const char *keys_g[] = {
+		"gid", "gname", NULL
+	};
+	static const char *keys_il[] = {
+		"ignore", "link", NULL
+	};
+	static const char *keys_m[] = {
+		"md5", "md5digest", "mode", NULL
+	};
+	static const char *keys_no[] = {
+		"nlink", "optional", NULL
+	};
+	static const char *keys_r[] = {
+		"rmd160", "rmd160digest", NULL
+	};
+	static const char *keys_s[] = {
+		"sha1", "sha1digest",
+		"sha256", "sha256digest",
+		"sha384", "sha384digest",
+		"sha512", "sha512digest",
+		"size", NULL
+	};
+	static const char *keys_t[] = {
+		"tags", "time", "type", NULL
+	};
+	static const char *keys_u[] = {
+		"uid", "uname",	NULL
+	};
+	const char **keys;
+	int i;
+
+	switch (*p) {
+	case 'c': keys = keys_c; break;
+	case 'd': case 'f': keys = keys_df; break;
+	case 'g': keys = keys_g; break;
+	case 'i': case 'l': keys = keys_il; break;
+	case 'm': keys = keys_m; break;
+	case 'n': case 'o': keys = keys_no; break;
+	case 'r': keys = keys_r; break;
+	case 's': keys = keys_s; break;
+	case 't': keys = keys_t; break;
+	case 'u': keys = keys_u; break;
+	default: return (0);/* Unknown key */
+	}
+
+	for (i = 0; keys[i] != NULL; i++) {
+		int l = bid_keycmp(p, keys[i], len);
+		if (l > 0)
+			return (l);
+	}
+	return (0);/* Unknown key */
+}
+
+/*
+ * Test whether there is a set of mtree keywords.
+ * Returns the number of keyword.
+ * Returns -1 if we got incorrect sequence.
+ * This function expects a set of "<space characters>keyword=value".
+ * When "unset" is specified, expects a set of "<space characters>keyword".
+ */
+static int
+bid_keyword_list(const char *p,  ssize_t len, int unset)
+{
+	int l;
+	int keycnt = 0;
+
+	while (len > 0 && *p) {
+		int blank = 0;
+
+		/* Test whether there are blank characters in the line. */
+		while (len >0 && (*p == ' ' || *p == '\t')) {
+			++p;
+			--len;
+			blank = 1;
+		}
+		if (*p == '\n' || *p == '\r')
+			break;
+		if (p[0] == '\\' && (p[1] == '\n' || p[1] == '\r'))
+			break;
+		if (!blank) /* No blank character. */
+			return (-1);
+
+		if (unset) {
+			l = bid_keycmp(p, "all", len);
+			if (l > 0)
+				return (1);
+		}
+		/* Test whether there is a correct key in the line. */
+		l = bid_keyword(p, len);
+		if (l == 0)
+			return (-1);/* Unknown keyword was found. */
+		p += l;
+		len -= l;
+		keycnt++;
+
+		/* Skip value */
+		if (*p == '=') {
+			int value = 0;
+			++p;
+			--len;
+			while (len > 0 && *p != ' ' && *p != '\t') {
+				++p;
+				--len;
+				value = 1;
+			}
+			/* A keyword should have a its value unless
+			 * "/unset" operation. */ 
+			if (!unset && value == 0)
+				return (-1);
+		}
+	}
+	return (keycnt);
+}
 
 static int
-mtree_bid(struct archive_read *a)
+bid_entry(const char *p, ssize_t len)
+{
+	int f = 0;
+	static const unsigned char safe_char[256] = {
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 00 - 0F */
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 10 - 1F */
+		/* !"$%&'()*+,-./  EXCLUSION:( )(#) */
+		0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 20 - 2F */
+		/* 0123456789:;<>?  EXCLUSION:(=) */
+		1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, /* 30 - 3F */
+		/* @ABCDEFGHIJKLMNO */
+		1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 40 - 4F */
+		/* PQRSTUVWXYZ[\]^_  */
+		1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 50 - 5F */
+		/* `abcdefghijklmno */
+		1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 60 - 6F */
+		/* pqrstuvwxyz{|}~ */
+		1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, /* 70 - 7F */
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 80 - 8F */
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 90 - 9F */
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* A0 - AF */
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* B0 - BF */
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* C0 - CF */
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* D0 - DF */
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* E0 - EF */
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* F0 - FF */
+	};
+
+	/*
+	 * Skip the path-name which is quoted.
+	 */
+	while (len > 0 && *p != ' ' && *p != '\t') {
+		if (!safe_char[*(const unsigned char *)p])
+			return (-1);
+		++p;
+		--len;
+		++f;
+	}
+	/* If a path-name was not found, returns error. */
+	if (f == 0)
+		return (-1);
+
+	return (bid_keyword_list(p, len, 0));
+}
+
+#define MAX_BID_ENTRY	3
+
+static int
+mtree_bid(struct archive_read *a, int best_bid)
 {
 	const char *signature = "#mtree";
 	const char *p;
+	ssize_t avail, ravail;
+	ssize_t len, nl;
+	int detected_bytes = 0, entry_cnt = 0, multiline = 0;
+
+	(void)best_bid; /* UNUSED */
 
 	/* Now let's look at the actual header and see if it matches. */
-	p = __archive_read_ahead(a, strlen(signature), NULL);
+	p = __archive_read_ahead(a, strlen(signature), &avail);
 	if (p == NULL)
 		return (-1);
 
-	if (strncmp(p, signature, strlen(signature)) == 0)
+	if (memcmp(p, signature, strlen(signature)) == 0)
 		return (8 * (int)strlen(signature));
+
+	/*
+	 * There is not a mtree signature. Let's try to detect mtree format.
+	 */
+	ravail = avail;
+	for (;;) {
+		len = next_line(a, &p, &avail, &ravail, &nl);
+		/* The terminal character of the line should be
+		 * a new line character, '\r\n' or '\n'. */
+		if (len <= 0 || nl == 0)
+			break;
+		if (!multiline) {
+			/* Leading whitespace is never significant,
+			 * ignore it. */
+			while (len > 0 && (*p == ' ' || *p == '\t')) {
+				++p;
+				--avail;
+				--len;
+			}
+			/* Skip comment or empty line. */ 
+			if (p[0] == '#' || p[0] == '\n' || p[0] == '\r') {
+				p += len;
+				avail -= len;
+				continue;
+			}
+		} else {
+			/* A continuance line; the terminal
+			 * character of previous line was '\' character. */
+			if (bid_keyword_list(p, len, 0) <= 0)
+				break;
+			if (multiline == 1)
+				detected_bytes += len;
+			if (p[len-nl-1] != '\\') {
+				if (multiline == 1 &&
+				    ++entry_cnt >= MAX_BID_ENTRY)
+					break;
+				multiline = 0;
+			}
+			p += len;
+			avail -= len;
+			continue;
+		}
+		if (p[0] != '/') {
+			if (bid_entry(p, len) >= 0) {
+				detected_bytes += len;
+				if (p[len-nl-1] == '\\')
+					/* This line continues. */
+					multiline = 1;
+				else {
+					/* We've got plenty of correct lines
+					 * to assume that this file is a mtree
+					 * format. */
+					if (++entry_cnt >= MAX_BID_ENTRY)
+						break;
+				}
+			} else
+				break;
+		} else if (strncmp(p, "/set", 4) == 0) {
+			if (bid_keyword_list(p+4, len-4, 0) <= 0)
+				break;
+			/* This line continues. */
+			if (p[len-nl-1] == '\\')
+				multiline = 2;
+		} else if (strncmp(p, "/unset", 6) == 0) {
+			if (bid_keyword_list(p+6, len-6, 1) <= 0)
+				break;
+			/* This line continues. */
+			if (p[len-nl-1] == '\\')
+				multiline = 2;
+		} else
+			break;
+
+		/* Test next line. */
+		p += len;
+		avail -= len;
+	}
+	if (entry_cnt >= MAX_BID_ENTRY || (entry_cnt > 0 && len == 0))
+		return (32);
+
 	return (0);
 }
 
@@ -215,21 +635,21 @@
 add_option(struct archive_read *a, struct mtree_option **global,
     const char *value, size_t len)
 {
-	struct mtree_option *option;
+	struct mtree_option *opt;
 
-	if ((option = malloc(sizeof(*option))) == NULL) {
+	if ((opt = malloc(sizeof(*opt))) == NULL) {
 		archive_set_error(&a->archive, errno, "Can't allocate memory");
 		return (ARCHIVE_FATAL);
 	}
-	if ((option->value = malloc(len + 1)) == NULL) {
-		free(option);
+	if ((opt->value = malloc(len + 1)) == NULL) {
+		free(opt);
 		archive_set_error(&a->archive, errno, "Can't allocate memory");
 		return (ARCHIVE_FATAL);
 	}
-	memcpy(option->value, value, len);
-	option->value[len] = '\0';
-	option->next = *global;
-	*global = option;
+	memcpy(opt->value, value, len);
+	opt->value[len] = '\0';
+	opt->next = *global;
+	*global = opt;
 	return (ARCHIVE_OK);
 }
 
@@ -400,7 +820,7 @@
 	last_entry = NULL;
 
 	for (counter = 1; ; ++counter) {
-		len = readline(a, mtree, &p, 256);
+		len = readline(a, mtree, &p, 65536);
 		if (len == 0) {
 			mtree->this_entry = mtree->entries;
 			free_options(global);
@@ -518,12 +938,12 @@
 	struct stat st_storage, *st;
 	struct mtree_entry *mp;
 	struct archive_entry *sparse_entry;
-	int r = ARCHIVE_OK, r1, parsed_kws, mismatched_type;
+	int r = ARCHIVE_OK, r1, parsed_kws;
 
 	mentry->used = 1;
 
 	/* Initialize reasonable defaults. */
-	mtree->filetype = AE_IFREG;
+	archive_entry_set_filetype(entry, AE_IFREG);
 	archive_entry_set_size(entry, 0);
 	archive_string_empty(&mtree->contents_name);
 
@@ -618,44 +1038,49 @@
 	 * the type of the contents object on disk.
 	 */
 	if (st != NULL) {
-		mismatched_type = 0;
-		if ((st->st_mode & S_IFMT) == S_IFREG &&
-		    archive_entry_filetype(entry) != AE_IFREG)
-			mismatched_type = 1;
-		if ((st->st_mode & S_IFMT) == S_IFLNK &&
-		    archive_entry_filetype(entry) != AE_IFLNK)
-			mismatched_type = 1;
-		if ((st->st_mode & S_IFSOCK) == S_IFSOCK &&
-		    archive_entry_filetype(entry) != AE_IFSOCK)
-			mismatched_type = 1;
-		if ((st->st_mode & S_IFMT) == S_IFCHR &&
-		    archive_entry_filetype(entry) != AE_IFCHR)
-			mismatched_type = 1;
-		if ((st->st_mode & S_IFMT) == S_IFBLK &&
-		    archive_entry_filetype(entry) != AE_IFBLK)
-			mismatched_type = 1;
-		if ((st->st_mode & S_IFMT) == S_IFDIR &&
-		    archive_entry_filetype(entry) != AE_IFDIR)
-			mismatched_type = 1;
-		if ((st->st_mode & S_IFMT) == S_IFIFO &&
-		    archive_entry_filetype(entry) != AE_IFIFO)
-			mismatched_type = 1;
-
-		if (mismatched_type) {
-			if ((parsed_kws & MTREE_HAS_OPTIONAL) == 0) {
+		if (
+		    ((st->st_mode & S_IFMT) == S_IFREG &&
+		     archive_entry_filetype(entry) == AE_IFREG)
+#ifdef S_IFLNK
+		    || ((st->st_mode & S_IFMT) == S_IFLNK &&
+			archive_entry_filetype(entry) == AE_IFLNK)
+#endif
+#ifdef S_IFSOCK
+		    || ((st->st_mode & S_IFSOCK) == S_IFSOCK &&
+			archive_entry_filetype(entry) == AE_IFSOCK)
+#endif
+#ifdef S_IFCHR
+		    || ((st->st_mode & S_IFMT) == S_IFCHR &&
+			archive_entry_filetype(entry) == AE_IFCHR)
+#endif
+#ifdef S_IFBLK
+		    || ((st->st_mode & S_IFMT) == S_IFBLK &&
+			archive_entry_filetype(entry) == AE_IFBLK)
+#endif
+		    || ((st->st_mode & S_IFMT) == S_IFDIR &&
+			archive_entry_filetype(entry) == AE_IFDIR)
+#ifdef S_IFIFO
+		    || ((st->st_mode & S_IFMT) == S_IFIFO &&
+			archive_entry_filetype(entry) == AE_IFIFO)
+#endif
+		    ) {
+			/* Types match. */
+		} else {
+			/* Types don't match; bail out gracefully. */
+			if (mtree->fd >= 0)
+				close(mtree->fd);
+			mtree->fd = -1;
+			if (parsed_kws & MTREE_HAS_OPTIONAL) {
+				/* It's not an error for an optional entry
+				   to not match disk. */
+				*use_next = 1;
+			} else if (r == ARCHIVE_OK) {
 				archive_set_error(&a->archive,
 				    ARCHIVE_ERRNO_MISC,
 				    "mtree specification has different type for %s",
 				    archive_entry_pathname(entry));
 				r = ARCHIVE_WARN;
-			} else {
-				*use_next = 1;
 			}
-			/* Don't hold a non-regular file open. */
-			if (mtree->fd >= 0)
-				close(mtree->fd);
-			mtree->fd = -1;
-			st = NULL;
 			return r;
 		}
 	}
@@ -735,7 +1160,7 @@
 		if (r1 < r)
 			r = r1;
 	}
-	if ((*parsed_kws & MTREE_HAS_TYPE) == 0) {
+	if (r == ARCHIVE_OK && (*parsed_kws & MTREE_HAS_TYPE) == 0) {
 		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
 		    "Missing type keyword in mtree specification");
 		return (ARCHIVE_WARN);
@@ -779,11 +1204,11 @@
  */
 static int
 parse_keyword(struct archive_read *a, struct mtree *mtree,
-    struct archive_entry *entry, struct mtree_option *option, int *parsed_kws)
+    struct archive_entry *entry, struct mtree_option *opt, int *parsed_kws)
 {
 	char *val, *key;
 
-	key = option->value;
+	key = opt->value;
 
 	if (*key == '\0')
 		return (ARCHIVE_OK);
@@ -900,58 +1325,67 @@
 			break;
 		}
 		if (strcmp(key, "time") == 0) {
-			time_t m;
+			int64_t m;
+			int64_t my_time_t_max = get_time_t_max();
+			int64_t my_time_t_min = get_time_t_min();
 			long ns;
 
 			*parsed_kws |= MTREE_HAS_MTIME;
-			m = (time_t)mtree_atol10(&val);
+			m = mtree_atol10(&val);
+			/* Replicate an old mtree bug:
+			 * 123456789.1 represents 123456789
+			 * seconds and 1 nanosecond. */
 			if (*val == '.') {
 				++val;
 				ns = (long)mtree_atol10(&val);
 			} else
 				ns = 0;
-			archive_entry_set_mtime(entry, m, ns);
+			if (m > my_time_t_max)
+				m = my_time_t_max;
+			else if (m < my_time_t_min)
+				m = my_time_t_min;
+			archive_entry_set_mtime(entry, (time_t)m, ns);
 			break;
 		}
 		if (strcmp(key, "type") == 0) {
-			*parsed_kws |= MTREE_HAS_TYPE;
 			switch (val[0]) {
 			case 'b':
 				if (strcmp(val, "block") == 0) {
-					mtree->filetype = AE_IFBLK;
+					archive_entry_set_filetype(entry, AE_IFBLK);
 					break;
 				}
 			case 'c':
 				if (strcmp(val, "char") == 0) {
-					mtree->filetype = AE_IFCHR;
+					archive_entry_set_filetype(entry, AE_IFCHR);
 					break;
 				}
 			case 'd':
 				if (strcmp(val, "dir") == 0) {
-					mtree->filetype = AE_IFDIR;
+					archive_entry_set_filetype(entry, AE_IFDIR);
 					break;
 				}
 			case 'f':
 				if (strcmp(val, "fifo") == 0) {
-					mtree->filetype = AE_IFIFO;
+					archive_entry_set_filetype(entry, AE_IFIFO);
 					break;
 				}
 				if (strcmp(val, "file") == 0) {
-					mtree->filetype = AE_IFREG;
+					archive_entry_set_filetype(entry, AE_IFREG);
 					break;
 				}
 			case 'l':
 				if (strcmp(val, "link") == 0) {
-					mtree->filetype = AE_IFLNK;
+					archive_entry_set_filetype(entry, AE_IFLNK);
 					break;
 				}
 			default:
 				archive_set_error(&a->archive,
 				    ARCHIVE_ERRNO_FILE_FORMAT,
-				    "Unrecognized file type \"%s\"", val);
+				    "Unrecognized file type \"%s\"; assuming \"file\"", val);
+				archive_entry_set_filetype(entry, AE_IFREG);
 				return (ARCHIVE_WARN);
 			}
-			archive_entry_set_filetype(entry, mtree->filetype);
+			*parsed_kws |= MTREE_HAS_TYPE;
 			break;
 		}
 	case 'u':
@@ -974,7 +1408,7 @@
 }
 
 static int
-read_data(struct archive_read *a, const void **buff, size_t *size, off_t *offset)
+read_data(struct archive_read *a, const void **buff, size_t *size, int64_t *offset)
 {
 	size_t bytes_to_read;
 	ssize_t bytes_read;
@@ -999,7 +1433,7 @@
 
 	*buff = mtree->buff;
 	*offset = mtree->offset;
-	if ((off_t)mtree->buffsize > mtree->cur_size - mtree->offset)
+	if ((int64_t)mtree->buffsize > mtree->cur_size - mtree->offset)
 		bytes_to_read = mtree->cur_size - mtree->offset;
 	else
 		bytes_to_read = mtree->buffsize;
@@ -1147,28 +1581,43 @@
 	int base, digit, sign;
 
 	base = 10;
-	limit = INT64_MAX / base;
-	last_digit_limit = INT64_MAX % base;
 
 	if (**p == '-') {
 		sign = -1;
+		limit = ((uint64_t)(INT64_MAX) + 1) / base;
+		last_digit_limit = ((uint64_t)(INT64_MAX) + 1) % base;
 		++(*p);
-	} else
+	} else {
 		sign = 1;
+		limit = INT64_MAX / base;
+		last_digit_limit = INT64_MAX % base;
+	}
 
 	l = 0;
 	digit = **p - '0';
 	while (digit >= 0 && digit < base) {
-		if (l > limit || (l == limit && digit > last_digit_limit)) {
-			l = INT64_MAX; /* Truncate on overflow. */
-			break;
-		}
+		if (l > limit || (l == limit && digit > last_digit_limit))
+			return (sign < 0) ? INT64_MIN : INT64_MAX;
 		l = (l * base) + digit;
 		digit = *++(*p) - '0';
 	}
 	return (sign < 0) ? -l : l;
 }
 
+/* Parse a hex digit. */
+static int
+parsehex(char c)
+{
+	if (c >= '0' && c <= '9')
+		return c - '0';
+	else if (c >= 'a' && c <= 'f')
+		return c - 'a';
+	else if (c >= 'A' && c <= 'F')
+		return c - 'A';
+	else
+		return -1;
+}
+
 /*
  * Note that this implementation does not (and should not!) obey
  * locale settings; you cannot simply substitute strtol here, since
@@ -1181,38 +1630,25 @@
 	int base, digit, sign;
 
 	base = 16;
-	limit = INT64_MAX / base;
-	last_digit_limit = INT64_MAX % base;
 
 	if (**p == '-') {
 		sign = -1;
+		limit = ((uint64_t)(INT64_MAX) + 1) / base;
+		last_digit_limit = ((uint64_t)(INT64_MAX) + 1) % base;
 		++(*p);
-	} else
+	} else {
 		sign = 1;
+		limit = INT64_MAX / base;
+		last_digit_limit = INT64_MAX % base;
+	}
 
 	l = 0;
-	if (**p >= '0' && **p <= '9')
-		digit = **p - '0';
-	else if (**p >= 'a' && **p <= 'f')
-		digit = **p - 'a' + 10;
-	else if (**p >= 'A' && **p <= 'F')
-		digit = **p - 'A' + 10;
-	else
-		digit = -1;
+	digit = parsehex(**p);
 	while (digit >= 0 && digit < base) {
-		if (l > limit || (l == limit && digit > last_digit_limit)) {
-			l = INT64_MAX; /* Truncate on overflow. */
-			break;
-		}
+		if (l > limit || (l == limit && digit > last_digit_limit))
+			return (sign < 0) ? INT64_MIN : INT64_MAX;
 		l = (l * base) + digit;
-		if (**p >= '0' && **p <= '9')
-			digit = **p - '0';
-		else if (**p >= 'a' && **p <= 'f')
-			digit = **p - 'a' + 10;
-		else if (**p >= 'A' && **p <= 'F')
-			digit = **p - 'A' + 10;
-		else
-			digit = -1;
+		digit = parsehex(*++(*p));
 	}
 	return (sign < 0) ? -l : l;
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_read_support_format_raw.c
--- a/head/contrib/libarchive/libarchive/archive_read_support_format_raw.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_read_support_format_raw.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_support_format_raw.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_support_format_raw.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
@@ -40,13 +40,14 @@
 
 struct raw_info {
 	int64_t offset; /* Current position in the file. */
+	int64_t unconsumed;
 	int     end_of_file;
 };
 
-static int	archive_read_format_raw_bid(struct archive_read *);
+static int	archive_read_format_raw_bid(struct archive_read *, int);
 static int	archive_read_format_raw_cleanup(struct archive_read *);
 static int	archive_read_format_raw_read_data(struct archive_read *,
-		    const void **, size_t *, off_t *);
+		    const void **, size_t *, int64_t *);
 static int	archive_read_format_raw_read_data_skip(struct archive_read *);
 static int	archive_read_format_raw_read_header(struct archive_read *,
 		    struct archive_entry *);
@@ -58,6 +59,9 @@
 	struct archive_read *a = (struct archive_read *)_a;
 	int r;
 
+	archive_check_magic(_a, ARCHIVE_READ_MAGIC,
+	    ARCHIVE_STATE_NEW, "archive_read_support_format_raw");
+
 	info = (struct raw_info *)calloc(1, sizeof(*info));
 	if (info == NULL) {
 		archive_set_error(&a->archive, ENOMEM,
@@ -87,12 +91,11 @@
  * include "raw" as part of support_format_all().
  */
 static int
-archive_read_format_raw_bid(struct archive_read *a)
+archive_read_format_raw_bid(struct archive_read *a, int best_bid)
 {
-
-	if (__archive_read_ahead(a, 1, NULL) == NULL)
-		return (-1);
-	return (1);
+	if (best_bid < 1 && __archive_read_ahead(a, 1, NULL) != NULL)
+		return (1);
+	return (-1);
 }
 
 /*
@@ -109,32 +112,40 @@
 		return (ARCHIVE_EOF);
 
 	a->archive.archive_format = ARCHIVE_FORMAT_RAW;
-	a->archive.archive_format_name = "Raw data";
+	a->archive.archive_format_name = "raw";
 	archive_entry_set_pathname(entry, "data");
-	/* XXX should we set mode to mimic a regular file? XXX */
+	archive_entry_set_filetype(entry, AE_IFREG);
+	archive_entry_set_perm(entry, 0644);
 	/* I'm deliberately leaving most fields unset here. */
 	return (ARCHIVE_OK);
 }
 
 static int
 archive_read_format_raw_read_data(struct archive_read *a,
-    const void **buff, size_t *size, off_t *offset)
+    const void **buff, size_t *size, int64_t *offset)
 {
 	struct raw_info *info;
 	ssize_t avail;
 
 	info = (struct raw_info *)(a->format->data);
+
+	/* Consume the bytes we read last time. */
+	if (info->unconsumed) {
+		__archive_read_consume(a, info->unconsumed);
+		info->unconsumed = 0;
+	}
+
 	if (info->end_of_file)
 		return (ARCHIVE_EOF);
 
 	/* Get whatever bytes are immediately available. */
 	*buff = __archive_read_ahead(a, 1, &avail);
 	if (avail > 0) {
-		/* Consume and return the bytes we just read */
-		__archive_read_consume(a, avail);
+		/* Return the bytes we just read */
 		*size = avail;
 		*offset = info->offset;
 		info->offset += *size;
+		info->unconsumed = avail;
 		return (ARCHIVE_OK);
 	} else if (0 == avail) {
 		/* Record and return end-of-file. */
@@ -153,24 +164,15 @@
 static int
 archive_read_format_raw_read_data_skip(struct archive_read *a)
 {
-	struct raw_info *info;
-	off_t bytes_skipped;
-	int64_t request = 1024 * 1024 * 1024UL; /* Skip 1 GB at a time. */
+	struct raw_info *info = (struct raw_info *)(a->format->data);
 
-	info = (struct raw_info *)(a->format->data);
-	if (info->end_of_file)
-		return (ARCHIVE_EOF);
+	/* Consume the bytes we read last time. */
+	if (info->unconsumed) {
+		__archive_read_consume(a, info->unconsumed);
+		info->unconsumed = 0;
+	}
 	info->end_of_file = 1;
-
-	for (;;) {
-		bytes_skipped = __archive_read_skip_lenient(a, request);
-		if (bytes_skipped < 0)
-			return (ARCHIVE_FATAL);
-		if (bytes_skipped < request)
-			return (ARCHIVE_OK);
-		/* We skipped all the bytes we asked for.  There might
-		 * be more, so try again. */
-	}
+	return (ARCHIVE_OK);
 }
 
 static int
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_read_support_format_tar.c
--- a/head/contrib/libarchive/libarchive/archive_read_support_format_tar.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_read_support_format_tar.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,6 @@
 /*-
  * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2011-2012 Michihiro NAKAJIMA
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -24,13 +25,12 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_support_format_tar.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_support_format_tar.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
 #endif
 #include <stddef.h>
-/* #include <stdint.h> */ /* See archive_platform.h */
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
@@ -38,37 +38,10 @@
 #include <string.h>
 #endif
 
-/* Obtain suitable wide-character manipulation functions. */
-#ifdef HAVE_WCHAR_H
-#include <wchar.h>
-#else
-/* Good enough for equality testing, which is all we need. */
-static int wcscmp(const wchar_t *s1, const wchar_t *s2)
-{
-	int diff = *s1 - *s2;
-	while (*s1 && diff == 0)
-		diff = (int)*++s1 - (int)*++s2;
-	return diff;
-}
-/* Good enough for equality testing, which is all we need. */
-static int wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n)
-{
-	int diff = *s1 - *s2;
-	while (*s1 && diff == 0 && n-- > 0)
-		diff = (int)*++s1 - (int)*++s2;
-	return diff;
-}
-static size_t wcslen(const wchar_t *s)
-{
-	const wchar_t *p = s;
-	while (*p)
-		p++;
-	return p - s;
-}
-#endif
-
 #include "archive.h"
+#include "archive_acl_private.h" /* For ACL parsing routines. */
 #include "archive_entry.h"
+#include "archive_entry_locale.h"
 #include "archive_private.h"
 #include "archive_read_private.h"
 
@@ -138,8 +111,9 @@
  */
 struct sparse_block {
 	struct sparse_block	*next;
-	off_t	offset;
-	off_t	remaining;
+	int64_t	offset;
+	int64_t	remaining;
+	int hole;
 };
 
 struct tar {
@@ -156,12 +130,11 @@
 	struct archive_string	 pax_global;
 	struct archive_string	 line;
 	int			 pax_hdrcharset_binary;
-	wchar_t 		*pax_entry;
-	size_t			 pax_entry_length;
 	int			 header_recursion_depth;
 	int64_t			 entry_bytes_remaining;
 	int64_t			 entry_offset;
 	int64_t			 entry_padding;
+	int64_t 		 entry_bytes_unconsumed;
 	int64_t			 realsize;
 	struct sparse_block	*sparse_list;
 	struct sparse_block	*sparse_last;
@@ -170,70 +143,89 @@
 	int			 sparse_gnu_major;
 	int			 sparse_gnu_minor;
 	char			 sparse_gnu_pending;
+
+	struct archive_string	 localname;
+	struct archive_string_conv *opt_sconv;
+	struct archive_string_conv *sconv;
+	struct archive_string_conv *sconv_acl;
+	struct archive_string_conv *sconv_default;
+	int			 init_default_conversion;
+	int			 compat_2x;
 };
 
-static ssize_t	UTF8_mbrtowc(wchar_t *pwc, const char *s, size_t n);
-static int	archive_block_is_null(const unsigned char *p);
+static int	archive_block_is_null(const char *p);
 static char	*base64_decode(const char *, size_t, size_t *);
-static void	 gnu_add_sparse_entry(struct tar *,
-		    off_t offset, off_t remaining);
+static int	gnu_add_sparse_entry(struct archive_read *, struct tar *,
+		    int64_t offset, int64_t remaining);
+
 static void	gnu_clear_sparse_list(struct tar *);
 static int	gnu_sparse_old_read(struct archive_read *, struct tar *,
-		    const struct archive_entry_header_gnutar *header);
-static void	gnu_sparse_old_parse(struct tar *,
+		    const struct archive_entry_header_gnutar *header, size_t *);
+static int	gnu_sparse_old_parse(struct archive_read *, struct tar *,
 		    const struct gnu_sparse *sparse, int length);
-static int	gnu_sparse_01_parse(struct tar *, const char *);
-static ssize_t	gnu_sparse_10_read(struct archive_read *, struct tar *);
+static int	gnu_sparse_01_parse(struct archive_read *, struct tar *,
+		    const char *);
+static ssize_t	gnu_sparse_10_read(struct archive_read *, struct tar *,
+			size_t *);
 static int	header_Solaris_ACL(struct archive_read *,  struct tar *,
-		    struct archive_entry *, const void *);
+		    struct archive_entry *, const void *, size_t *);
 static int	header_common(struct archive_read *,  struct tar *,
 		    struct archive_entry *, const void *);
 static int	header_old_tar(struct archive_read *, struct tar *,
 		    struct archive_entry *, const void *);
 static int	header_pax_extensions(struct archive_read *, struct tar *,
-		    struct archive_entry *, const void *);
+		    struct archive_entry *, const void *, size_t *);
 static int	header_pax_global(struct archive_read *, struct tar *,
-		    struct archive_entry *, const void *h);
+		    struct archive_entry *, const void *h, size_t *);
 static int	header_longlink(struct archive_read *, struct tar *,
-		    struct archive_entry *, const void *h);
+		    struct archive_entry *, const void *h, size_t *);
 static int	header_longname(struct archive_read *, struct tar *,
-		    struct archive_entry *, const void *h);
+		    struct archive_entry *, const void *h, size_t *);
+static int	read_mac_metadata_blob(struct archive_read *, struct tar *,
+		    struct archive_entry *, const void *h, size_t *);
 static int	header_volume(struct archive_read *, struct tar *,
-		    struct archive_entry *, const void *h);
+		    struct archive_entry *, const void *h, size_t *);
 static int	header_ustar(struct archive_read *, struct tar *,
 		    struct archive_entry *, const void *h);
 static int	header_gnutar(struct archive_read *, struct tar *,
-		    struct archive_entry *, const void *h);
-static int	archive_read_format_tar_bid(struct archive_read *);
+		    struct archive_entry *, const void *h, size_t *);
+static int	archive_read_format_tar_bid(struct archive_read *, int);
+static int	archive_read_format_tar_options(struct archive_read *,
+		    const char *, const char *);
 static int	archive_read_format_tar_cleanup(struct archive_read *);
 static int	archive_read_format_tar_read_data(struct archive_read *a,
-		    const void **buff, size_t *size, off_t *offset);
+		    const void **buff, size_t *size, int64_t *offset);
 static int	archive_read_format_tar_skip(struct archive_read *a);
 static int	archive_read_format_tar_read_header(struct archive_read *,
 		    struct archive_entry *);
 static int	checksum(struct archive_read *, const void *);
-static int 	pax_attribute(struct tar *, struct archive_entry *,
-		    char *key, char *value);
+static int 	pax_attribute(struct archive_read *, struct tar *,
+		    struct archive_entry *, char *key, char *value);
 static int 	pax_header(struct archive_read *, struct tar *,
 		    struct archive_entry *, char *attr);
 static void	pax_time(const char *, int64_t *sec, long *nanos);
 static ssize_t	readline(struct archive_read *, struct tar *, const char **,
-		    ssize_t limit);
+		    ssize_t limit, size_t *);
 static int	read_body_to_string(struct archive_read *, struct tar *,
-		    struct archive_string *, const void *h);
+		    struct archive_string *, const void *h, size_t *);
+static int	solaris_sparse_parse(struct archive_read *, struct tar *,
+		    struct archive_entry *, const char *);
 static int64_t	tar_atol(const char *, unsigned);
 static int64_t	tar_atol10(const char *, unsigned);
 static int64_t	tar_atol256(const char *, unsigned);
 static int64_t	tar_atol8(const char *, unsigned);
 static int	tar_read_header(struct archive_read *, struct tar *,
-		    struct archive_entry *);
+		    struct archive_entry *, size_t *);
 static int	tohex(int c);
 static char	*url_decode(const char *);
-static wchar_t	*utf8_decode(struct tar *, const char *, size_t length);
+static void	tar_flush_unconsumed(struct archive_read *, size_t *);
+
 
 int
 archive_read_support_format_gnutar(struct archive *a)
 {
+	archive_check_magic(a, ARCHIVE_READ_MAGIC,
+	    ARCHIVE_STATE_NEW, "archive_read_support_format_gnutar");
 	return (archive_read_support_format_tar(a));
 }
 
@@ -245,17 +237,19 @@
 	struct tar *tar;
 	int r;
 
-	tar = (struct tar *)malloc(sizeof(*tar));
+	archive_check_magic(_a, ARCHIVE_READ_MAGIC,
+	    ARCHIVE_STATE_NEW, "archive_read_support_format_tar");
+
+	tar = (struct tar *)calloc(1, sizeof(*tar));
 	if (tar == NULL) {
 		archive_set_error(&a->archive, ENOMEM,
 		    "Can't allocate tar data");
 		return (ARCHIVE_FATAL);
 	}
-	memset(tar, 0, sizeof(*tar));
 
 	r = __archive_read_register_format(a, tar, "tar",
 	    archive_read_format_tar_bid,
-	    NULL,
+	    archive_read_format_tar_options,
 	    archive_read_format_tar_read_header,
 	    archive_read_format_tar_read_data,
 	    archive_read_format_tar_skip,
@@ -284,7 +278,7 @@
 	archive_string_free(&tar->pax_header);
 	archive_string_free(&tar->longname);
 	archive_string_free(&tar->longlink);
-	free(tar->pax_entry);
+	archive_string_free(&tar->localname);
 	free(tar);
 	(a->format->data) = NULL;
 	return (ARCHIVE_OK);
@@ -292,12 +286,14 @@
 
 
 static int
-archive_read_format_tar_bid(struct archive_read *a)
+archive_read_format_tar_bid(struct archive_read *a, int best_bid)
 {
 	int bid;
-	const void *h;
+	const char *h;
 	const struct archive_entry_header_ustar *header;
 
+	(void)best_bid; /* UNUSED */
+
 	bid = 0;
 
 	/* Now let's look at the actual header and see if it matches. */
@@ -306,8 +302,7 @@
 		return (-1);
 
 	/* If it's an end-of-archive mark, we can handle it. */
-	if ((*(const char *)h) == 0
-	    && archive_block_is_null((const unsigned char *)h)) {
+	if (h[0] == 0 && archive_block_is_null(h)) {
 		/*
 		 * Usually, I bid the number of bits verified, but
 		 * in this case, 4096 seems excessive so I picked 10 as
@@ -325,12 +320,12 @@
 
 	/* Recognize POSIX formats. */
 	if ((memcmp(header->magic, "ustar\0", 6) == 0)
-	    &&(memcmp(header->version, "00", 2)==0))
+	    && (memcmp(header->version, "00", 2) == 0))
 		bid += 56;
 
 	/* Recognize GNU tar format. */
 	if ((memcmp(header->magic, "ustar ", 6) == 0)
-	    &&(memcmp(header->version, " \0", 2)==0))
+	    && (memcmp(header->version, " \0", 2) == 0))
 		bid += 56;
 
 	/* Type flag must be null, digit or A-Z, a-z. */
@@ -362,8 +357,65 @@
 	return (bid);
 }
 
+static int
+archive_read_format_tar_options(struct archive_read *a,
+    const char *key, const char *val)
+{
+	struct tar *tar;
+	int ret = ARCHIVE_FAILED;
+
+	tar = (struct tar *)(a->format->data);
+	if (strcmp(key, "compat-2x")  == 0) {
+		/* Handle UTF-8 filnames as libarchive 2.x */
+		tar->compat_2x = (val != NULL)?1:0;
+		tar->init_default_conversion = tar->compat_2x;
+		return (ARCHIVE_OK);
+	} else if (strcmp(key, "hdrcharset")  == 0) {
+		if (val == NULL || val[0] == 0)
+			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+			    "tar: hdrcharset option needs a character-set name");
+		else {
+			tar->opt_sconv =
+			    archive_string_conversion_from_charset(
+				&a->archive, val, 0);
+			if (tar->opt_sconv != NULL)
+				ret = ARCHIVE_OK;
+			else
+				ret = ARCHIVE_FATAL;
+		}
+		return (ret);
+	}
+
+	/* Note: The "warn" return is just to inform the options
+	 * supervisor that we didn't handle it.  It will generate
+	 * a suitable error if no one used this option. */
+	return (ARCHIVE_WARN);
+}
+
+/* utility function- this exists to centralize the logic of tracking
+ * how much unconsumed data we have floating around, and to consume
+ * anything outstanding since we're going to do read_aheads
+ */
+static void 
+tar_flush_unconsumed(struct archive_read *a, size_t *unconsumed)
+{
+	if (*unconsumed) {
 /*
- * The function invoked by archive_read_header().  This
+		void *data = (void *)__archive_read_ahead(a, *unconsumed, NULL);
+		 * this block of code is to poison claimed unconsumed space, ensuring
+		 * things break if it is in use still.
+		 * currently it WILL break things, so enable it only for debugging this issue
+		if (data) {
+			memset(data, 0xff, *unconsumed);
+		}
+*/
+		__archive_read_consume(a, *unconsumed);
+		*unconsumed = 0;
+	}
+}
+
+/*
+ * The function invoked by archive_read_next_header().  This
  * just sets up a few things and then calls the internal
  * tar_read_header() function below.
  */
@@ -388,10 +440,9 @@
 	static int default_inode;
 	static int default_dev;
 	struct tar *tar;
-	struct sparse_block *sp;
 	const char *p;
 	int r;
-	size_t l;
+	size_t l, unconsumed = 0;
 
 	/* Assign default device/inode values. */
 	archive_entry_set_dev(entry, 1 + default_dev); /* Don't use zero. */
@@ -404,22 +455,41 @@
 
 	tar = (struct tar *)(a->format->data);
 	tar->entry_offset = 0;
-	while (tar->sparse_list != NULL) {
-		sp = tar->sparse_list;
-		tar->sparse_list = sp->next;
-		free(sp);
-	}
-	tar->sparse_last = NULL;
+	gnu_clear_sparse_list(tar);
 	tar->realsize = -1; /* Mark this as "unset" */
 
-	r = tar_read_header(a, tar, entry);
+	/* Setup default string conversion. */
+	tar->sconv = tar->opt_sconv;
+	if (tar->sconv == NULL) {
+		if (!tar->init_default_conversion) {
+			tar->sconv_default =
+			    archive_string_default_conversion_for_read(&(a->archive));
+			tar->init_default_conversion = 1;
+		}
+		tar->sconv = tar->sconv_default;
+	}
+
+	r = tar_read_header(a, tar, entry, &unconsumed);
+
+	tar_flush_unconsumed(a, &unconsumed);
 
 	/*
 	 * "non-sparse" files are really just sparse files with
 	 * a single block.
 	 */
-	if (tar->sparse_list == NULL)
-		gnu_add_sparse_entry(tar, 0, tar->entry_bytes_remaining);
+	if (tar->sparse_list == NULL) {
+		if (gnu_add_sparse_entry(a, tar, 0, tar->entry_bytes_remaining)
+		    != ARCHIVE_OK)
+			return (ARCHIVE_FATAL);
+	} else {
+		struct sparse_block *sb;
+
+		for (sb = tar->sparse_list; sb != NULL; sb = sb->next) {
+			if (!sb->hole)
+				archive_entry_sparse_add_entry(entry,
+				    sb->offset, sb->remaining);
+		}
+	}
 
 	if (r == ARCHIVE_OK) {
 		/*
@@ -427,18 +497,29 @@
 		 * directory: This is needed for certain old tar
 		 * variants and even for some broken newer ones.
 		 */
-		p = archive_entry_pathname(entry);
-		l = strlen(p);
-		if (archive_entry_filetype(entry) == AE_IFREG
-		    && p[l-1] == '/')
-			archive_entry_set_filetype(entry, AE_IFDIR);
+		const wchar_t *wp;
+		wp = archive_entry_pathname_w(entry);
+		if (wp != NULL) {
+			l = wcslen(wp);
+			if (archive_entry_filetype(entry) == AE_IFREG
+			    && wp[l-1] == L'/')
+				archive_entry_set_filetype(entry, AE_IFDIR);
+		} else {
+			p = archive_entry_pathname(entry);
+			if (p == NULL)
+				return (ARCHIVE_FAILED);
+			l = strlen(p);
+			if (archive_entry_filetype(entry) == AE_IFREG
+			    && p[l-1] == '/')
+				archive_entry_set_filetype(entry, AE_IFDIR);
+		}
 	}
 	return (r);
 }
 
 static int
 archive_read_format_tar_read_data(struct archive_read *a,
-    const void **buff, size_t *size, off_t *offset)
+    const void **buff, size_t *size, int64_t *offset)
 {
 	ssize_t bytes_read;
 	struct tar *tar;
@@ -446,24 +527,7 @@
 
 	tar = (struct tar *)(a->format->data);
 
-	if (tar->sparse_gnu_pending) {
-		if (tar->sparse_gnu_major == 1 && tar->sparse_gnu_minor == 0) {
-			tar->sparse_gnu_pending = 0;
-			/* Read initial sparse map. */
-			bytes_read = gnu_sparse_10_read(a, tar);
-			tar->entry_bytes_remaining -= bytes_read;
-			if (bytes_read < 0)
-				return (bytes_read);
-		} else {
-			*size = 0;
-			*offset = 0;
-			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
-			    "Unrecognized GNU sparse file format");
-			return (ARCHIVE_WARN);
-		}
-		tar->sparse_gnu_pending = 0;
-	}
-
+skip_hole:
 	/* Remove exhausted entries from sparse list. */
 	while (tar->sparse_list != NULL &&
 	    tar->sparse_list->remaining == 0) {
@@ -472,9 +536,14 @@
 		free(p);
 	}
 
+	if (tar->entry_bytes_unconsumed) {
+		__archive_read_consume(a, tar->entry_bytes_unconsumed);
+		tar->entry_bytes_unconsumed = 0;
+	}
+
 	/* If we're at end of file, return EOF. */
 	if (tar->sparse_list == NULL || tar->entry_bytes_remaining == 0) {
-		if (__archive_read_skip(a, tar->entry_padding) < 0)
+		if (__archive_read_consume(a, tar->entry_padding) < 0)
 			return (ARCHIVE_FATAL);
 		tar->entry_padding = 0;
 		*buff = NULL;
@@ -502,7 +571,11 @@
 	tar->sparse_list->remaining -= bytes_read;
 	tar->sparse_list->offset += bytes_read;
 	tar->entry_bytes_remaining -= bytes_read;
-	__archive_read_consume(a, bytes_read);
+	tar->entry_bytes_unconsumed = bytes_read;
+
+	if (tar->sparse_list->hole)
+		goto skip_hole;
+
 	return (ARCHIVE_OK);
 }
 
@@ -514,17 +587,14 @@
 
 	tar = (struct tar *)(a->format->data);
 
-	/*
-	 * Compression layer skip functions are required to either skip the
-	 * length requested or fail, so we can rely upon the entire entry
-	 * plus padding being skipped.
-	 */
-	bytes_skipped = __archive_read_skip(a,
-	    tar->entry_bytes_remaining + tar->entry_padding);
+	bytes_skipped = __archive_read_consume(a,
+	    tar->entry_bytes_remaining + tar->entry_padding + 
+	    tar->entry_bytes_unconsumed);
 	if (bytes_skipped < 0)
 		return (ARCHIVE_FATAL);
 
 	tar->entry_bytes_remaining = 0;
+	tar->entry_bytes_unconsumed = 0;
 	tar->entry_padding = 0;
 
 	/* Free the sparse list. */
@@ -539,40 +609,34 @@
  */
 static int
 tar_read_header(struct archive_read *a, struct tar *tar,
-    struct archive_entry *entry)
+    struct archive_entry *entry, size_t *unconsumed)
 {
 	ssize_t bytes;
 	int err;
-	const void *h;
+	const char *h;
 	const struct archive_entry_header_ustar *header;
 
+	tar_flush_unconsumed(a, unconsumed);
+
 	/* Read 512-byte header record */
 	h = __archive_read_ahead(a, 512, &bytes);
 	if (bytes < 0)
 		return (bytes);
-	if (bytes < 512) {  /* Short read or EOF. */
-		/* Try requesting just one byte and see what happens. */
-		(void)__archive_read_ahead(a, 1, &bytes);
-		if (bytes == 0) {
-			/*
-			 * The archive ends at a 512-byte boundary but
-			 * without a proper end-of-archive marker.
-			 * Yes, there are tar writers that do this;
-			 * hold our nose and accept it.
-			 */
-			return (ARCHIVE_EOF);
-		}
-		/* Archive ends with a partial block; this is bad. */
+	if (bytes == 0) { /* EOF at a block boundary. */
+		/* Some writers do omit the block of nulls. <sigh> */
+		return (ARCHIVE_EOF);
+	}
+	if (bytes < 512) {  /* Short block at EOF; this is bad. */
 		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
 		    "Truncated tar archive");
 		return (ARCHIVE_FATAL);
 	}
-	__archive_read_consume(a, 512);
-
+	*unconsumed = 512;
 
 	/* Check for end-of-archive mark. */
-	if (((*(const char *)h)==0) && archive_block_is_null((const unsigned char *)h)) {
+	if (h[0] == 0 && archive_block_is_null(h)) {
 		/* Try to consume a second all-null record, as well. */
+		tar_flush_unconsumed(a, unconsumed);
 		h = __archive_read_ahead(a, 512, NULL);
 		if (h != NULL)
 			__archive_read_consume(a, 512);
@@ -592,53 +656,56 @@
 	 * TODO: Improve this by implementing a real header scan.
 	 */
 	if (!checksum(a, h)) {
+		tar_flush_unconsumed(a, unconsumed);
 		archive_set_error(&a->archive, EINVAL, "Damaged tar archive");
 		return (ARCHIVE_RETRY); /* Retryable: Invalid header */
 	}
 
 	if (++tar->header_recursion_depth > 32) {
+		tar_flush_unconsumed(a, unconsumed);
 		archive_set_error(&a->archive, EINVAL, "Too many special headers");
 		return (ARCHIVE_WARN);
 	}
 
 	/* Determine the format variant. */
 	header = (const struct archive_entry_header_ustar *)h;
+
 	switch(header->typeflag[0]) {
 	case 'A': /* Solaris tar ACL */
 		a->archive.archive_format = ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE;
 		a->archive.archive_format_name = "Solaris tar";
-		err = header_Solaris_ACL(a, tar, entry, h);
+		err = header_Solaris_ACL(a, tar, entry, h, unconsumed);
 		break;
 	case 'g': /* POSIX-standard 'g' header. */
 		a->archive.archive_format = ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE;
 		a->archive.archive_format_name = "POSIX pax interchange format";
-		err = header_pax_global(a, tar, entry, h);
+		err = header_pax_global(a, tar, entry, h, unconsumed);
 		break;
 	case 'K': /* Long link name (GNU tar, others) */
-		err = header_longlink(a, tar, entry, h);
+		err = header_longlink(a, tar, entry, h, unconsumed);
 		break;
 	case 'L': /* Long filename (GNU tar, others) */
-		err = header_longname(a, tar, entry, h);
+		err = header_longname(a, tar, entry, h, unconsumed);
 		break;
 	case 'V': /* GNU volume header */
-		err = header_volume(a, tar, entry, h);
+		err = header_volume(a, tar, entry, h, unconsumed);
 		break;
 	case 'X': /* Used by SUN tar; same as 'x'. */
 		a->archive.archive_format = ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE;
 		a->archive.archive_format_name =
 		    "POSIX pax interchange format (Sun variant)";
-		err = header_pax_extensions(a, tar, entry, h);
+		err = header_pax_extensions(a, tar, entry, h, unconsumed);
 		break;
 	case 'x': /* POSIX-standard 'x' header. */
 		a->archive.archive_format = ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE;
 		a->archive.archive_format_name = "POSIX pax interchange format";
-		err = header_pax_extensions(a, tar, entry, h);
+		err = header_pax_extensions(a, tar, entry, h, unconsumed);
 		break;
 	default:
 		if (memcmp(header->magic, "ustar  \0", 8) == 0) {
 			a->archive.archive_format = ARCHIVE_FORMAT_TAR_GNUTAR;
 			a->archive.archive_format_name = "GNU tar format";
-			err = header_gnutar(a, tar, entry, h);
+			err = header_gnutar(a, tar, entry, h, unconsumed);
 		} else if (memcmp(header->magic, "ustar", 5) == 0) {
 			if (a->archive.archive_format != ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE) {
 				a->archive.archive_format = ARCHIVE_FORMAT_TAR_USTAR;
@@ -651,10 +718,50 @@
 			err = header_old_tar(a, tar, entry, h);
 		}
 	}
+	if (err == ARCHIVE_FATAL)
+		return (err);
+
+	tar_flush_unconsumed(a, unconsumed);
+
+	h = NULL;
+	header = NULL;
+
 	--tar->header_recursion_depth;
+	/* Yuck.  Apple's design here ends up storing long pathname
+	 * extensions for both the AppleDouble extension entry and the
+	 * regular entry.
+	 */
+	/* TODO: Should this be disabled on non-Mac platforms? */
+	if ((err == ARCHIVE_WARN || err == ARCHIVE_OK) &&
+	    tar->header_recursion_depth == 0) {
+		int err2 = read_mac_metadata_blob(a, tar, entry, h, unconsumed);
+		if (err2 < err)
+			err = err2;
+	}
+
 	/* We return warnings or success as-is.  Anything else is fatal. */
-	if (err == ARCHIVE_WARN || err == ARCHIVE_OK)
+	if (err == ARCHIVE_WARN || err == ARCHIVE_OK) {
+		if (tar->sparse_gnu_pending) {
+			if (tar->sparse_gnu_major == 1 &&
+			    tar->sparse_gnu_minor == 0) {
+				ssize_t bytes_read;
+
+				tar->sparse_gnu_pending = 0;
+				/* Read initial sparse map. */
+				bytes_read = gnu_sparse_10_read(a, tar, unconsumed);
+				tar->entry_bytes_remaining -= bytes_read;
+				if (bytes_read < 0)
+					return (bytes_read);
+			} else {
+				archive_set_error(&a->archive,
+				    ARCHIVE_ERRNO_MISC,
+				    "Unrecognized GNU sparse file format");
+				return (ARCHIVE_WARN);
+			}
+			tar->sparse_gnu_pending = 0;
+		}
 		return (err);
+	}
 	if (err == ARCHIVE_EOF)
 		/* EOF when recursively reading a header is bad. */
 		archive_set_error(&a->archive, EINVAL, "Damaged tar archive");
@@ -712,7 +819,7 @@
  * Return true if this block contains only nulls.
  */
 static int
-archive_block_is_null(const unsigned char *p)
+archive_block_is_null(const char *p)
 {
 	unsigned i;
 
@@ -727,14 +834,13 @@
  */
 static int
 header_Solaris_ACL(struct archive_read *a, struct tar *tar,
-    struct archive_entry *entry, const void *h)
+    struct archive_entry *entry, const void *h, size_t *unconsumed)
 {
 	const struct archive_entry_header_ustar *header;
 	size_t size;
 	int err;
 	int64_t type;
 	char *acl, *p;
-	wchar_t *wp;
 
 	/*
 	 * read_body_to_string adds a NUL terminator, but we need a little
@@ -742,11 +848,12 @@
 	 */
 	header = (const struct archive_entry_header_ustar *)h;
 	size = tar_atol(header->size, sizeof(header->size));
-	err = read_body_to_string(a, tar, &(tar->acl_text), h);
+	err = read_body_to_string(a, tar, &(tar->acl_text), h, unconsumed);
 	if (err != ARCHIVE_OK)
 		return (err);
+
 	/* Recursively read next header */
-	err = tar_read_header(a, tar, entry);
+	err = tar_read_header(a, tar, entry, unconsumed);
 	if ((err != ARCHIVE_OK) && (err != ARCHIVE_WARN))
 		return (err);
 
@@ -802,12 +909,23 @@
 	while (*p != '\0' && p < acl + size)
 		p++;
 
-	wp = utf8_decode(tar, acl, p - acl);
-	err = __archive_entry_acl_parse_w(entry, wp,
-	    ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
-	if (err != ARCHIVE_OK)
-		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
-		    "Malformed Solaris ACL attribute (unparsable)");
+	if (tar->sconv_acl == NULL) {
+		tar->sconv_acl = archive_string_conversion_from_charset(
+		    &(a->archive), "UTF-8", 1);
+		if (tar->sconv_acl == NULL)
+			return (ARCHIVE_FATAL);
+	}
+	archive_strncpy(&(tar->localname), acl, p - acl);
+	err = archive_acl_parse_l(archive_entry_acl(entry),
+	    tar->localname.s, ARCHIVE_ENTRY_ACL_TYPE_ACCESS, tar->sconv_acl);
+	if (err != ARCHIVE_OK) {
+		if (errno == ENOMEM) {
+			archive_set_error(&a->archive, ENOMEM,
+			    "Can't allocate memory for ACL");
+		} else
+			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+			    "Malformed Solaris ACL attribute (unparsable)");
+	}
 	return (err);
 }
 
@@ -816,14 +934,14 @@
  */
 static int
 header_longlink(struct archive_read *a, struct tar *tar,
-    struct archive_entry *entry, const void *h)
+    struct archive_entry *entry, const void *h, size_t *unconsumed)
 {
 	int err;
 
-	err = read_body_to_string(a, tar, &(tar->longlink), h);
+	err = read_body_to_string(a, tar, &(tar->longlink), h, unconsumed);
 	if (err != ARCHIVE_OK)
 		return (err);
-	err = tar_read_header(a, tar, entry);
+	err = tar_read_header(a, tar, entry, unconsumed);
 	if ((err != ARCHIVE_OK) && (err != ARCHIVE_WARN))
 		return (err);
 	/* Set symlink if symlink already set, else hardlink. */
@@ -831,24 +949,41 @@
 	return (ARCHIVE_OK);
 }
 
+static int
+set_conversion_failed_error(struct archive_read *a,
+    struct archive_string_conv *sconv, const char *name)
+{
+	if (errno == ENOMEM) {
+		archive_set_error(&a->archive, ENOMEM,
+		    "Can't allocate memory for %s", name);
+		return (ARCHIVE_FATAL);
+	}
+	archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+	    "%s can't be converted from %s to current locale.",
+	    name, archive_string_conversion_charset_name(sconv));
+	return (ARCHIVE_WARN);
+}
+
 /*
  * Interpret 'L' long filename header.
  */
 static int
 header_longname(struct archive_read *a, struct tar *tar,
-    struct archive_entry *entry, const void *h)
+    struct archive_entry *entry, const void *h, size_t *unconsumed)
 {
 	int err;
 
-	err = read_body_to_string(a, tar, &(tar->longname), h);
+	err = read_body_to_string(a, tar, &(tar->longname), h, unconsumed);
 	if (err != ARCHIVE_OK)
 		return (err);
 	/* Read and parse "real" header, then override name. */
-	err = tar_read_header(a, tar, entry);
+	err = tar_read_header(a, tar, entry, unconsumed);
 	if ((err != ARCHIVE_OK) && (err != ARCHIVE_WARN))
 		return (err);
-	archive_entry_copy_pathname(entry, tar->longname.s);
-	return (ARCHIVE_OK);
+	if (archive_entry_copy_pathname_l(entry, tar->longname.s,
+	    archive_strlen(&(tar->longname)), tar->sconv) != 0)
+		err = set_conversion_failed_error(a, tar->sconv, "Pathname");
+	return (err);
 }
 
 
@@ -857,12 +992,12 @@
  */
 static int
 header_volume(struct archive_read *a, struct tar *tar,
-    struct archive_entry *entry, const void *h)
+    struct archive_entry *entry, const void *h, size_t *unconsumed)
 {
 	(void)h;
 
 	/* Just skip this and read the next header. */
-	return (tar_read_header(a, tar, entry));
+	return (tar_read_header(a, tar, entry, unconsumed));
 }
 
 /*
@@ -870,9 +1005,9 @@
  */
 static int
 read_body_to_string(struct archive_read *a, struct tar *tar,
-    struct archive_string *as, const void *h)
+    struct archive_string *as, const void *h, size_t *unconsumed)
 {
-	off_t size, padded_size;
+	int64_t size;
 	const struct archive_entry_header_ustar *header;
 	const void *src;
 
@@ -892,14 +1027,18 @@
 		return (ARCHIVE_FATAL);
 	}
 
- 	/* Read the body into the string. */
-	padded_size = (size + 511) & ~ 511;
-	src = __archive_read_ahead(a, padded_size, NULL);
-	if (src == NULL)
+	tar_flush_unconsumed(a, unconsumed);
+
+	/* Read the body into the string. */
+	*unconsumed = (size + 511) & ~ 511;
+	src = __archive_read_ahead(a, *unconsumed, NULL);
+	if (src == NULL) {
+		*unconsumed = 0;
 		return (ARCHIVE_FATAL);
+	}
 	memcpy(as->s, src, size);
-	__archive_read_consume(a, padded_size);
 	as->s[size] = '\0';
+	as->length = size;
 	return (ARCHIVE_OK);
 }
 
@@ -919,13 +1058,12 @@
 {
 	const struct archive_entry_header_ustar	*header;
 	char	tartype;
-
-	(void)a; /* UNUSED */
+	int     err = ARCHIVE_OK;
 
 	header = (const struct archive_entry_header_ustar *)h;
 	if (header->linkname[0])
-		archive_strncpy(&(tar->entry_linkpath), header->linkname,
-		    sizeof(header->linkname));
+		archive_strncpy(&(tar->entry_linkpath),
+		    header->linkname, sizeof(header->linkname));
 	else
 		archive_string_empty(&(tar->entry_linkpath));
 
@@ -934,6 +1072,12 @@
 	archive_entry_set_uid(entry, tar_atol(header->uid, sizeof(header->uid)));
 	archive_entry_set_gid(entry, tar_atol(header->gid, sizeof(header->gid)));
 	tar->entry_bytes_remaining = tar_atol(header->size, sizeof(header->size));
+	if (tar->entry_bytes_remaining < 0) {
+		tar->entry_bytes_remaining = 0;
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+		    "Tar entry has negative size?");
+		err = ARCHIVE_WARN;
+	}
 	tar->realsize = tar->entry_bytes_remaining;
 	archive_entry_set_size(entry, tar->entry_bytes_remaining);
 	archive_entry_set_mtime(entry, tar_atol(header->mtime, sizeof(header->mtime)), 0);
@@ -943,7 +1087,13 @@
 
 	switch (tartype) {
 	case '1': /* Hard link */
-		archive_entry_copy_hardlink(entry, tar->entry_linkpath.s);
+		if (archive_entry_copy_hardlink_l(entry, tar->entry_linkpath.s,
+		    archive_strlen(&(tar->entry_linkpath)), tar->sconv) != 0) {
+			err = set_conversion_failed_error(a, tar->sconv,
+			    "Linkname");
+			if (err == ARCHIVE_FATAL)
+				return (err);
+		}
 		/*
 		 * The following may seem odd, but: Technically, tar
 		 * does not store the file type for a "hard link"
@@ -980,7 +1130,7 @@
 			/* Old-style or GNU tar: we must ignore the size. */
 			archive_entry_set_size(entry, 0);
 			tar->entry_bytes_remaining = 0;
-		} else if (archive_read_format_tar_bid(a) > 50) {
+		} else if (archive_read_format_tar_bid(a, 50) > 50) {
 			/*
 			 * We don't know if it's pax: If the bid
 			 * function sees a valid ustar header
@@ -1005,7 +1155,13 @@
 		archive_entry_set_filetype(entry, AE_IFLNK);
 		archive_entry_set_size(entry, 0);
 		tar->entry_bytes_remaining = 0;
-		archive_entry_copy_symlink(entry, tar->entry_linkpath.s);
+		if (archive_entry_copy_symlink_l(entry, tar->entry_linkpath.s,
+		    archive_strlen(&(tar->entry_linkpath)), tar->sconv) != 0) {
+			err = set_conversion_failed_error(a, tar->sconv,
+			    "Linkname");
+			if (err == ARCHIVE_FATAL)
+				return (err);
+		}
 		break;
 	case '3': /* Character device */
 		archive_entry_set_filetype(entry, AE_IFCHR);
@@ -1063,7 +1219,7 @@
 		archive_entry_set_filetype(entry, AE_IFREG);
 		break;
 	}
-	return (0);
+	return (err);
 }
 
 /*
@@ -1074,17 +1230,95 @@
     struct archive_entry *entry, const void *h)
 {
 	const struct archive_entry_header_ustar	*header;
+	int err = ARCHIVE_OK, err2;
 
 	/* Copy filename over (to ensure null termination). */
 	header = (const struct archive_entry_header_ustar *)h;
-	archive_strncpy(&(tar->entry_pathname), header->name, sizeof(header->name));
-	archive_entry_copy_pathname(entry, tar->entry_pathname.s);
+	if (archive_entry_copy_pathname_l(entry,
+	    header->name, sizeof(header->name), tar->sconv) != 0) {
+		err = set_conversion_failed_error(a, tar->sconv, "Pathname");
+		if (err == ARCHIVE_FATAL)
+			return (err);
+	}
 
 	/* Grab rest of common fields */
-	header_common(a, tar, entry, h);
+	err2 = header_common(a, tar, entry, h);
+	if (err > err2)
+		err = err2;
 
 	tar->entry_padding = 0x1ff & (-tar->entry_bytes_remaining);
-	return (0);
+	return (err);
+}
+
+/*
+ * Read a Mac AppleDouble-encoded blob of file metadata,
+ * if there is one.
+ */
+static int
+read_mac_metadata_blob(struct archive_read *a, struct tar *tar,
+    struct archive_entry *entry, const void *h, size_t *unconsumed)
+{
+	int64_t size;
+	const void *data;
+	const char *p, *name;
+	const wchar_t *wp, *wname;
+
+	(void)h; /* UNUSED */
+
+	wname = wp = archive_entry_pathname_w(entry);
+	if (wp != NULL) {
+		/* Find the last path element. */
+		for (; *wp != L'\0'; ++wp) {
+			if (wp[0] == '/' && wp[1] != L'\0')
+				wname = wp + 1;
+		}
+		/* 
+		 * If last path element starts with "._", then
+		 * this is a Mac extension.
+		 */
+		if (wname[0] != L'.' || wname[1] != L'_' || wname[2] == L'\0')
+			return ARCHIVE_OK;
+	} else {
+		/* Find the last path element. */
+		name = p = archive_entry_pathname(entry);
+		if (p == NULL)
+			return (ARCHIVE_FAILED);
+		for (; *p != '\0'; ++p) {
+			if (p[0] == '/' && p[1] != '\0')
+				name = p + 1;
+		}
+		/* 
+		 * If last path element starts with "._", then
+		 * this is a Mac extension.
+		 */
+		if (name[0] != '.' || name[1] != '_' || name[2] == '\0')
+			return ARCHIVE_OK;
+	}
+
+ 	/* Read the body as a Mac OS metadata blob. */
+	size = archive_entry_size(entry);
+
+	/*
+	 * TODO: Look beyond the body here to peek at the next header.
+	 * If it's a regular header (not an extension header)
+	 * that has the wrong name, just return the current
+	 * entry as-is, without consuming the body here.
+	 * That would reduce the risk of us mis-identifying
+	 * an ordinary file that just happened to have
+	 * a name starting with "._".
+	 *
+	 * Q: Is the above idea really possible?  Even
+	 * when there are GNU or pax extension entries?
+	 */
+	data = __archive_read_ahead(a, size, NULL);
+	if (data == NULL) {
+		*unconsumed = 0;
+		return (ARCHIVE_FATAL);
+	}
+	archive_entry_copy_mac_metadata(entry, data, size);
+	*unconsumed = (size + 511) & ~ 511;
+	tar_flush_unconsumed(a, unconsumed);
+	return (tar_read_header(a, tar, entry, unconsumed));
 }
 
 /*
@@ -1092,29 +1326,29 @@
  */
 static int
 header_pax_global(struct archive_read *a, struct tar *tar,
-    struct archive_entry *entry, const void *h)
+    struct archive_entry *entry, const void *h, size_t *unconsumed)
 {
 	int err;
 
-	err = read_body_to_string(a, tar, &(tar->pax_global), h);
+	err = read_body_to_string(a, tar, &(tar->pax_global), h, unconsumed);
 	if (err != ARCHIVE_OK)
 		return (err);
-	err = tar_read_header(a, tar, entry);
+	err = tar_read_header(a, tar, entry, unconsumed);
 	return (err);
 }
 
 static int
 header_pax_extensions(struct archive_read *a, struct tar *tar,
-    struct archive_entry *entry, const void *h)
+    struct archive_entry *entry, const void *h, size_t *unconsumed)
 {
 	int err, err2;
 
-	err = read_body_to_string(a, tar, &(tar->pax_header), h);
+	err = read_body_to_string(a, tar, &(tar->pax_header), h, unconsumed);
 	if (err != ARCHIVE_OK)
 		return (err);
 
 	/* Parse the next header. */
-	err = tar_read_header(a, tar, entry);
+	err = tar_read_header(a, tar, entry, unconsumed);
 	if ((err != ARCHIVE_OK) && (err != ARCHIVE_WARN))
 		return (err);
 
@@ -1145,6 +1379,7 @@
 {
 	const struct archive_entry_header_ustar	*header;
 	struct archive_string *as;
+	int err = ARCHIVE_OK, r;
 
 	header = (const struct archive_entry_header_ustar *)h;
 
@@ -1155,22 +1390,37 @@
 		if (as->s[archive_strlen(as) - 1] != '/')
 			archive_strappend_char(as, '/');
 		archive_strncat(as, header->name, sizeof(header->name));
-	} else
+	} else {
 		archive_strncpy(as, header->name, sizeof(header->name));
-
-	archive_entry_copy_pathname(entry, as->s);
+	}
+	if (archive_entry_copy_pathname_l(entry, as->s, archive_strlen(as),
+	    tar->sconv) != 0) {
+		err = set_conversion_failed_error(a, tar->sconv, "Pathname");
+		if (err == ARCHIVE_FATAL)
+			return (err);
+	}
 
 	/* Handle rest of common fields. */
-	header_common(a, tar, entry, h);
+	r = header_common(a, tar, entry, h);
+	if (r == ARCHIVE_FATAL)
+		return (r);
+	if (r < err)
+		err = r;
 
 	/* Handle POSIX ustar fields. */
-	archive_strncpy(&(tar->entry_uname), header->uname,
-	    sizeof(header->uname));
-	archive_entry_copy_uname(entry, tar->entry_uname.s);
+	if (archive_entry_copy_uname_l(entry,
+	    header->uname, sizeof(header->uname), tar->sconv) != 0) {
+		err = set_conversion_failed_error(a, tar->sconv, "Uname");
+		if (err == ARCHIVE_FATAL)
+			return (err);
+	}
 
-	archive_strncpy(&(tar->entry_gname), header->gname,
-	    sizeof(header->gname));
-	archive_entry_copy_gname(entry, tar->entry_gname.s);
+	if (archive_entry_copy_gname_l(entry,
+	    header->gname, sizeof(header->gname), tar->sconv) != 0) {
+		err = set_conversion_failed_error(a, tar->sconv, "Gname");
+		if (err == ARCHIVE_FATAL)
+			return (err);
+	}
 
 	/* Parse out device numbers only for char and block specials. */
 	if (header->typeflag[0] == '3' || header->typeflag[0] == '4') {
@@ -1182,7 +1432,7 @@
 
 	tar->entry_padding = 0x1ff & (-tar->entry_bytes_remaining);
 
-	return (0);
+	return (err);
 }
 
 
@@ -1198,6 +1448,8 @@
 	size_t attr_length, l, line_length;
 	char *p;
 	char *key, *value;
+	struct archive_string *as;
+	struct archive_string_conv *sconv;
 	int err, err2;
 
 	attr_length = strlen(attr);
@@ -1269,39 +1521,55 @@
 		value = p + 1;
 
 		/* Identify this attribute and set it in the entry. */
-		err2 = pax_attribute(tar, entry, key, value);
+		err2 = pax_attribute(a, tar, entry, key, value);
+		if (err2 == ARCHIVE_FATAL)
+			return (err2);
 		err = err_combine(err, err2);
 
 		/* Skip to next line */
 		attr += line_length;
 		attr_length -= line_length;
 	}
+
+	/*
+	 * PAX format uses UTF-8 as default charset for its metadata
+	 * unless hdrcharset=BINARY is present in its header.
+	 * We apply the charset specified by the hdrcharset option only
+	 * when the hdrcharset attribute(in PAX header) is BINARY because
+	 * we respect the charset described in PAX header and BINARY also
+	 * means that metadata(filename,uname and gname) character-set
+	 * is unknown.
+	 */
+	if (tar->pax_hdrcharset_binary)
+		sconv = tar->opt_sconv;
+	else {
+		sconv = archive_string_conversion_from_charset(
+		    &(a->archive), "UTF-8", 1);
+		if (sconv == NULL)
+			return (ARCHIVE_FATAL);
+		if (tar->compat_2x)
+			archive_string_conversion_set_opt(sconv,
+			    SCONV_SET_OPT_UTF8_LIBARCHIVE2X);
+	}
+
 	if (archive_strlen(&(tar->entry_gname)) > 0) {
-		value = tar->entry_gname.s;
-		if (tar->pax_hdrcharset_binary)
-			archive_entry_copy_gname(entry, value);
-		else {
-			if (!archive_entry_update_gname_utf8(entry, value)) {
-				err = ARCHIVE_WARN;
-				archive_set_error(&a->archive,
-				    ARCHIVE_ERRNO_FILE_FORMAT,
-				    "Gname in pax header can't "
-				    "be converted to current locale.");
-			}
+		if (archive_entry_copy_gname_l(entry, tar->entry_gname.s,
+		    archive_strlen(&(tar->entry_gname)), sconv) != 0) {
+			err = set_conversion_failed_error(a, sconv, "Gname");
+			if (err == ARCHIVE_FATAL)
+				return (err);
+			/* Use a converted an original name. */
+			archive_entry_copy_gname(entry, tar->entry_gname.s);
 		}
 	}
 	if (archive_strlen(&(tar->entry_linkpath)) > 0) {
-		value = tar->entry_linkpath.s;
-		if (tar->pax_hdrcharset_binary)
-			archive_entry_copy_link(entry, value);
-		else {
-			if (!archive_entry_update_link_utf8(entry, value)) {
-				err = ARCHIVE_WARN;
-				archive_set_error(&a->archive,
-				    ARCHIVE_ERRNO_FILE_FORMAT,
-				    "Linkname in pax header can't "
-				    "be converted to current locale.");
-			}
+		if (archive_entry_copy_link_l(entry, tar->entry_linkpath.s,
+		    archive_strlen(&(tar->entry_linkpath)), sconv) != 0) {
+			err = set_conversion_failed_error(a, sconv, "Linkname");
+			if (err == ARCHIVE_FATAL)
+				return (err);
+			/* Use a converted an original name. */
+			archive_entry_copy_link(entry, tar->entry_linkpath.s);
 		}
 	}
 	/*
@@ -1313,36 +1581,29 @@
 	 * we find and figure it all out afterwards.  This is the
 	 * figuring out part.
 	 */
-	value = NULL;
+	as = NULL;
 	if (archive_strlen(&(tar->entry_pathname_override)) > 0)
-		value = tar->entry_pathname_override.s;
+		as = &(tar->entry_pathname_override);
 	else if (archive_strlen(&(tar->entry_pathname)) > 0)
-		value = tar->entry_pathname.s;
-	if (value != NULL) {
-		if (tar->pax_hdrcharset_binary)
-			archive_entry_copy_pathname(entry, value);
-		else {
-			if (!archive_entry_update_pathname_utf8(entry, value)) {
-				err = ARCHIVE_WARN;
-				archive_set_error(&a->archive,
-				    ARCHIVE_ERRNO_FILE_FORMAT,
-				    "Pathname in pax header can't be "
-				    "converted to current locale.");
-			}
+		as = &(tar->entry_pathname);
+	if (as != NULL) {
+		if (archive_entry_copy_pathname_l(entry, as->s,
+		    archive_strlen(as), sconv) != 0) {
+			err = set_conversion_failed_error(a, sconv, "Pathname");
+			if (err == ARCHIVE_FATAL)
+				return (err);
+			/* Use a converted an original name. */
+			archive_entry_copy_pathname(entry, as->s);
 		}
 	}
 	if (archive_strlen(&(tar->entry_uname)) > 0) {
-		value = tar->entry_uname.s;
-		if (tar->pax_hdrcharset_binary)
-			archive_entry_copy_uname(entry, value);
-		else {
-			if (!archive_entry_update_uname_utf8(entry, value)) {
-				err = ARCHIVE_WARN;
-				archive_set_error(&a->archive,
-				    ARCHIVE_ERRNO_FILE_FORMAT,
-				    "Uname in pax header can't "
-				    "be converted to current locale.");
-			}
+		if (archive_entry_copy_uname_l(entry, tar->entry_uname.s,
+		    archive_strlen(&(tar->entry_uname)), sconv) != 0) {
+			err = set_conversion_failed_error(a, sconv, "Uname");
+			if (err == ARCHIVE_FATAL)
+				return (err);
+			/* Use a converted an original name. */
+			archive_entry_copy_uname(entry, tar->entry_uname.s);
 		}
 	}
 	return (err);
@@ -1356,7 +1617,7 @@
 	void *value_decoded;
 	size_t value_len;
 
-	if (strlen(name) < 18 || (strncmp(name, "LIBARCHIVE.xattr.", 17)) != 0)
+	if (strlen(name) < 18 || (memcmp(name, "LIBARCHIVE.xattr.", 17)) != 0)
 		return 3;
 
 	name += 17;
@@ -1395,12 +1656,12 @@
  * any of them look useful.
  */
 static int
-pax_attribute(struct tar *tar, struct archive_entry *entry,
-    char *key, char *value)
+pax_attribute(struct archive_read *a, struct tar *tar,
+    struct archive_entry *entry, char *key, char *value)
 {
 	int64_t s;
 	long n;
-	wchar_t *wp;
+	int err = ARCHIVE_OK, r;
 
 	switch (key[0]) {
 	case 'G':
@@ -1414,8 +1675,10 @@
 		if (strcmp(key, "GNU.sparse.offset") == 0) {
 			tar->sparse_offset = tar_atol10(value, strlen(value));
 			if (tar->sparse_numbytes != -1) {
-				gnu_add_sparse_entry(tar,
-				    tar->sparse_offset, tar->sparse_numbytes);
+				if (gnu_add_sparse_entry(a, tar,
+				    tar->sparse_offset, tar->sparse_numbytes)
+				    != ARCHIVE_OK)
+					return (ARCHIVE_FATAL);
 				tar->sparse_offset = -1;
 				tar->sparse_numbytes = -1;
 			}
@@ -1423,8 +1686,10 @@
 		if (strcmp(key, "GNU.sparse.numbytes") == 0) {
 			tar->sparse_numbytes = tar_atol10(value, strlen(value));
 			if (tar->sparse_numbytes != -1) {
-				gnu_add_sparse_entry(tar,
-				    tar->sparse_offset, tar->sparse_numbytes);
+				if (gnu_add_sparse_entry(a, tar,
+				    tar->sparse_offset, tar->sparse_numbytes)
+				    != ARCHIVE_OK)
+					return (ARCHIVE_FATAL);
 				tar->sparse_offset = -1;
 				tar->sparse_numbytes = -1;
 			}
@@ -1438,7 +1703,7 @@
 		if (strcmp(key, "GNU.sparse.map") == 0) {
 			tar->sparse_gnu_major = 0;
 			tar->sparse_gnu_minor = 1;
-			if (gnu_sparse_01_parse(tar, value) != ARCHIVE_OK)
+			if (gnu_sparse_01_parse(a, tar, value) != ARCHIVE_OK)
 				return (ARCHIVE_WARN);
 		}
 
@@ -1469,99 +1734,146 @@
 		/* Our extensions */
 /* TODO: Handle arbitrary extended attributes... */
 /*
-		if (strcmp(key, "LIBARCHIVE.xxxxxxx")==0)
+		if (strcmp(key, "LIBARCHIVE.xxxxxxx") == 0)
 			archive_entry_set_xxxxxx(entry, value);
 */
-		if (strcmp(key, "LIBARCHIVE.creationtime")==0) {
+		if (strcmp(key, "LIBARCHIVE.creationtime") == 0) {
 			pax_time(value, &s, &n);
 			archive_entry_set_birthtime(entry, s, n);
 		}
-		if (strncmp(key, "LIBARCHIVE.xattr.", 17)==0)
+		if (memcmp(key, "LIBARCHIVE.xattr.", 17) == 0)
 			pax_attribute_xattr(entry, key, value);
 		break;
 	case 'S':
 		/* We support some keys used by the "star" archiver */
-		if (strcmp(key, "SCHILY.acl.access")==0) {
-			wp = utf8_decode(tar, value, strlen(value));
-			/* TODO: if (wp == NULL) */
-			__archive_entry_acl_parse_w(entry, wp,
-			    ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
-		} else if (strcmp(key, "SCHILY.acl.default")==0) {
-			wp = utf8_decode(tar, value, strlen(value));
-			/* TODO: if (wp == NULL) */
-			__archive_entry_acl_parse_w(entry, wp,
-			    ARCHIVE_ENTRY_ACL_TYPE_DEFAULT);
-		} else if (strcmp(key, "SCHILY.devmajor")==0) {
+		if (strcmp(key, "SCHILY.acl.access") == 0) {
+			if (tar->sconv_acl == NULL) {
+				tar->sconv_acl =
+				    archive_string_conversion_from_charset(
+					&(a->archive), "UTF-8", 1);
+				if (tar->sconv_acl == NULL)
+					return (ARCHIVE_FATAL);
+			}
+
+			r = archive_acl_parse_l(archive_entry_acl(entry),
+			    value, ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
+			    tar->sconv_acl);
+			if (r != ARCHIVE_OK) {
+				err = r;
+				if (err == ARCHIVE_FATAL) {
+					archive_set_error(&a->archive, ENOMEM,
+					    "Can't allocate memory for "
+					    "SCHILY.acl.access");
+					return (err);
+				}
+				archive_set_error(&a->archive,
+				    ARCHIVE_ERRNO_MISC,
+				    "Parse error: SCHILY.acl.access");
+			}
+		} else if (strcmp(key, "SCHILY.acl.default") == 0) {
+			if (tar->sconv_acl == NULL) {
+				tar->sconv_acl =
+				    archive_string_conversion_from_charset(
+					&(a->archive), "UTF-8", 1);
+				if (tar->sconv_acl == NULL)
+					return (ARCHIVE_FATAL);
+			}
+
+			r = archive_acl_parse_l(archive_entry_acl(entry),
+			    value, ARCHIVE_ENTRY_ACL_TYPE_DEFAULT,
+			    tar->sconv_acl);
+			if (r != ARCHIVE_OK) {
+				err = r;
+				if (err == ARCHIVE_FATAL) {
+					archive_set_error(&a->archive, ENOMEM,
+					    "Can't allocate memory for "
+					    "SCHILY.acl.default");
+					return (err);
+				}
+				archive_set_error(&a->archive,
+				    ARCHIVE_ERRNO_MISC,
+				    "Parse error: SCHILY.acl.default");
+			}
+		} else if (strcmp(key, "SCHILY.devmajor") == 0) {
 			archive_entry_set_rdevmajor(entry,
 			    tar_atol10(value, strlen(value)));
-		} else if (strcmp(key, "SCHILY.devminor")==0) {
+		} else if (strcmp(key, "SCHILY.devminor") == 0) {
 			archive_entry_set_rdevminor(entry,
 			    tar_atol10(value, strlen(value)));
-		} else if (strcmp(key, "SCHILY.fflags")==0) {
+		} else if (strcmp(key, "SCHILY.fflags") == 0) {
 			archive_entry_copy_fflags_text(entry, value);
-		} else if (strcmp(key, "SCHILY.dev")==0) {
+		} else if (strcmp(key, "SCHILY.dev") == 0) {
 			archive_entry_set_dev(entry,
 			    tar_atol10(value, strlen(value)));
-		} else if (strcmp(key, "SCHILY.ino")==0) {
+		} else if (strcmp(key, "SCHILY.ino") == 0) {
 			archive_entry_set_ino(entry,
 			    tar_atol10(value, strlen(value)));
-		} else if (strcmp(key, "SCHILY.nlink")==0) {
+		} else if (strcmp(key, "SCHILY.nlink") == 0) {
 			archive_entry_set_nlink(entry,
 			    tar_atol10(value, strlen(value)));
-		} else if (strcmp(key, "SCHILY.realsize")==0) {
+		} else if (strcmp(key, "SCHILY.realsize") == 0) {
 			tar->realsize = tar_atol10(value, strlen(value));
 			archive_entry_set_size(entry, tar->realsize);
+		} else if (strcmp(key, "SUN.holesdata") == 0) {
+			/* A Solaris extension for sparse. */
+			r = solaris_sparse_parse(a, tar, entry, value);
+			if (r < err) {
+				if (r == ARCHIVE_FATAL)
+					return (r);
+				err = r;
+				archive_set_error(&a->archive,
+				    ARCHIVE_ERRNO_MISC,
+				    "Parse error: SUN.holesdata");
+			}
 		}
 		break;
 	case 'a':
-		if (strcmp(key, "atime")==0) {
+		if (strcmp(key, "atime") == 0) {
 			pax_time(value, &s, &n);
 			archive_entry_set_atime(entry, s, n);
 		}
 		break;
 	case 'c':
-		if (strcmp(key, "ctime")==0) {
+		if (strcmp(key, "ctime") == 0) {
 			pax_time(value, &s, &n);
 			archive_entry_set_ctime(entry, s, n);
-		} else if (strcmp(key, "charset")==0) {
+		} else if (strcmp(key, "charset") == 0) {
 			/* TODO: Publish charset information in entry. */
-		} else if (strcmp(key, "comment")==0) {
+		} else if (strcmp(key, "comment") == 0) {
 			/* TODO: Publish comment in entry. */
 		}
 		break;
 	case 'g':
-		if (strcmp(key, "gid")==0) {
+		if (strcmp(key, "gid") == 0) {
 			archive_entry_set_gid(entry,
 			    tar_atol10(value, strlen(value)));
-		} else if (strcmp(key, "gname")==0) {
+		} else if (strcmp(key, "gname") == 0) {
 			archive_strcpy(&(tar->entry_gname), value);
 		}
 		break;
 	case 'h':
 		if (strcmp(key, "hdrcharset") == 0) {
 			if (strcmp(value, "BINARY") == 0)
+				/* Binary  mode. */
 				tar->pax_hdrcharset_binary = 1;
 			else if (strcmp(value, "ISO-IR 10646 2000 UTF-8") == 0)
 				tar->pax_hdrcharset_binary = 0;
-			else {
-				/* TODO: Warn about unsupported hdrcharset */
-			}
 		}
 		break;
 	case 'l':
 		/* pax interchange doesn't distinguish hardlink vs. symlink. */
-		if (strcmp(key, "linkpath")==0) {
+		if (strcmp(key, "linkpath") == 0) {
 			archive_strcpy(&(tar->entry_linkpath), value);
 		}
 		break;
 	case 'm':
-		if (strcmp(key, "mtime")==0) {
+		if (strcmp(key, "mtime") == 0) {
 			pax_time(value, &s, &n);
 			archive_entry_set_mtime(entry, s, n);
 		}
 		break;
 	case 'p':
-		if (strcmp(key, "path")==0) {
+		if (strcmp(key, "path") == 0) {
 			archive_strcpy(&(tar->entry_pathname), value);
 		}
 		break;
@@ -1570,8 +1882,8 @@
 		break;
 	case 's':
 		/* POSIX has reserved 'security.*' */
-		/* Someday: if (strcmp(key, "security.acl")==0) { ... } */
-		if (strcmp(key, "size")==0) {
+		/* Someday: if (strcmp(key, "security.acl") == 0) { ... } */
+		if (strcmp(key, "size") == 0) {
 			/* "size" is the size of the data in the entry. */
 			tar->entry_bytes_remaining
 			    = tar_atol10(value, strlen(value));
@@ -1592,15 +1904,15 @@
 		}
 		break;
 	case 'u':
-		if (strcmp(key, "uid")==0) {
+		if (strcmp(key, "uid") == 0) {
 			archive_entry_set_uid(entry,
 			    tar_atol10(value, strlen(value)));
-		} else if (strcmp(key, "uname")==0) {
+		} else if (strcmp(key, "uname") == 0) {
 			archive_strcpy(&(tar->entry_uname), value);
 		}
 		break;
 	}
-	return (0);
+	return (err);
 }
 
 
@@ -1660,11 +1972,11 @@
  */
 static int
 header_gnutar(struct archive_read *a, struct tar *tar,
-    struct archive_entry *entry, const void *h)
+    struct archive_entry *entry, const void *h, size_t *unconsumed)
 {
 	const struct archive_entry_header_gnutar *header;
-
-	(void)a;
+	int64_t t;
+	int err = ARCHIVE_OK;
 
 	/*
 	 * GNU header is like POSIX ustar, except 'prefix' is
@@ -1673,25 +1985,36 @@
 	 */
 
 	/* Grab fields common to all tar variants. */
-	header_common(a, tar, entry, h);
+	err = header_common(a, tar, entry, h);
+	if (err == ARCHIVE_FATAL)
+		return (err);
 
 	/* Copy filename over (to ensure null termination). */
 	header = (const struct archive_entry_header_gnutar *)h;
-	archive_strncpy(&(tar->entry_pathname), header->name,
-	    sizeof(header->name));
-	archive_entry_copy_pathname(entry, tar->entry_pathname.s);
+	if (archive_entry_copy_pathname_l(entry,
+	    header->name, sizeof(header->name), tar->sconv) != 0) {
+		err = set_conversion_failed_error(a, tar->sconv, "Pathname");
+		if (err == ARCHIVE_FATAL)
+			return (err);
+	}
 
 	/* Fields common to ustar and GNU */
 	/* XXX Can the following be factored out since it's common
 	 * to ustar and gnu tar?  Is it okay to move it down into
 	 * header_common, perhaps?  */
-	archive_strncpy(&(tar->entry_uname),
-	    header->uname, sizeof(header->uname));
-	archive_entry_copy_uname(entry, tar->entry_uname.s);
+	if (archive_entry_copy_uname_l(entry,
+	    header->uname, sizeof(header->uname), tar->sconv) != 0) {
+		err = set_conversion_failed_error(a, tar->sconv, "Uname");
+		if (err == ARCHIVE_FATAL)
+			return (err);
+	}
 
-	archive_strncpy(&(tar->entry_gname),
-	    header->gname, sizeof(header->gname));
-	archive_entry_copy_gname(entry, tar->entry_gname.s);
+	if (archive_entry_copy_gname_l(entry,
+	    header->gname, sizeof(header->gname), tar->sconv) != 0) {
+		err = set_conversion_failed_error(a, tar->sconv, "Gname");
+		if (err == ARCHIVE_FATAL)
+			return (err);
+	}
 
 	/* Parse out device numbers only for char and block specials */
 	if (header->typeflag[0] == '3' || header->typeflag[0] == '4') {
@@ -1705,10 +2028,13 @@
 	tar->entry_padding = 0x1ff & (-tar->entry_bytes_remaining);
 
 	/* Grab GNU-specific fields. */
-	archive_entry_set_atime(entry,
-	    tar_atol(header->atime, sizeof(header->atime)), 0);
-	archive_entry_set_ctime(entry,
-	    tar_atol(header->ctime, sizeof(header->ctime)), 0);
+	t = tar_atol(header->atime, sizeof(header->atime));
+	if (t > 0)
+		archive_entry_set_atime(entry, t, 0);
+	t = tar_atol(header->ctime, sizeof(header->ctime));
+	if (t > 0)
+		archive_entry_set_ctime(entry, t, 0);
+
 	if (header->realsize[0] != 0) {
 		tar->realsize
 		    = tar_atol(header->realsize, sizeof(header->realsize));
@@ -1716,24 +2042,29 @@
 	}
 
 	if (header->sparse[0].offset[0] != 0) {
-		gnu_sparse_old_read(a, tar, header);
+		if (gnu_sparse_old_read(a, tar, header, unconsumed)
+		    != ARCHIVE_OK)
+			return (ARCHIVE_FATAL);
 	} else {
 		if (header->isextended[0] != 0) {
 			/* XXX WTF? XXX */
 		}
 	}
 
-	return (0);
+	return (err);
 }
 
-static void
-gnu_add_sparse_entry(struct tar *tar, off_t offset, off_t remaining)
+static int
+gnu_add_sparse_entry(struct archive_read *a, struct tar *tar,
+    int64_t offset, int64_t remaining)
 {
 	struct sparse_block *p;
 
 	p = (struct sparse_block *)malloc(sizeof(*p));
-	if (p == NULL)
-		__archive_errx(1, "Out of memory");
+	if (p == NULL) {
+		archive_set_error(&a->archive, ENOMEM, "Out of memory");
+		return (ARCHIVE_FATAL);
+	}
 	memset(p, 0, sizeof(*p));
 	if (tar->sparse_last != NULL)
 		tar->sparse_last->next = p;
@@ -1742,6 +2073,7 @@
 	tar->sparse_last = p;
 	p->offset = offset;
 	p->remaining = remaining;
+	return (ARCHIVE_OK);
 }
 
 static void
@@ -1771,7 +2103,7 @@
 
 static int
 gnu_sparse_old_read(struct archive_read *a, struct tar *tar,
-    const struct archive_entry_header_gnutar *header)
+    const struct archive_entry_header_gnutar *header, size_t *unconsumed)
 {
 	ssize_t bytes_read;
 	const void *data;
@@ -1782,11 +2114,13 @@
 	};
 	const struct extended *ext;
 
-	gnu_sparse_old_parse(tar, header->sparse, 4);
+	if (gnu_sparse_old_parse(a, tar, header->sparse, 4) != ARCHIVE_OK)
+		return (ARCHIVE_FATAL);
 	if (header->isextended[0] == 0)
 		return (ARCHIVE_OK);
 
 	do {
+		tar_flush_unconsumed(a, unconsumed);
 		data = __archive_read_ahead(a, 512, &bytes_read);
 		if (bytes_read < 0)
 			return (ARCHIVE_FATAL);
@@ -1796,26 +2130,30 @@
 			    "detected while reading sparse file data");
 			return (ARCHIVE_FATAL);
 		}
-		__archive_read_consume(a, 512);
+		*unconsumed = 512;
 		ext = (const struct extended *)data;
-		gnu_sparse_old_parse(tar, ext->sparse, 21);
+		if (gnu_sparse_old_parse(a, tar, ext->sparse, 21) != ARCHIVE_OK)
+			return (ARCHIVE_FATAL);
 	} while (ext->isextended[0] != 0);
 	if (tar->sparse_list != NULL)
 		tar->entry_offset = tar->sparse_list->offset;
 	return (ARCHIVE_OK);
 }
 
-static void
-gnu_sparse_old_parse(struct tar *tar,
+static int
+gnu_sparse_old_parse(struct archive_read *a, struct tar *tar,
     const struct gnu_sparse *sparse, int length)
 {
 	while (length > 0 && sparse->offset[0] != 0) {
-		gnu_add_sparse_entry(tar,
+		if (gnu_add_sparse_entry(a, tar,
 		    tar_atol(sparse->offset, sizeof(sparse->offset)),
-		    tar_atol(sparse->numbytes, sizeof(sparse->numbytes)));
+		    tar_atol(sparse->numbytes, sizeof(sparse->numbytes)))
+		    != ARCHIVE_OK)
+			return (ARCHIVE_FATAL);
 		sparse++;
 		length--;
 	}
+	return (ARCHIVE_OK);
 }
 
 /*
@@ -1824,7 +2162,7 @@
  * Beginning with GNU tar 1.15, sparse files are stored using
  * information in the pax extended header.  The GNU tar maintainers
  * have gone through a number of variations in the process of working
- * out this scheme; furtunately, they're all numbered.
+ * out this scheme; fortunately, they're all numbered.
  *
  * Sparse format 0.0 uses attribute GNU.sparse.numblocks to store the
  * number of blocks, and GNU.sparse.offset/GNU.sparse.numbytes to
@@ -1845,10 +2183,10 @@
  */
 
 static int
-gnu_sparse_01_parse(struct tar *tar, const char *p)
+gnu_sparse_01_parse(struct archive_read *a, struct tar *tar, const char *p)
 {
 	const char *e;
-	off_t offset = -1, size = -1;
+	int64_t offset = -1, size = -1;
 
 	for (;;) {
 		e = p;
@@ -1865,7 +2203,9 @@
 			size = tar_atol10(p, e - p);
 			if (size < 0)
 				return (ARCHIVE_WARN);
-			gnu_add_sparse_entry(tar, offset, size);
+			if (gnu_add_sparse_entry(a, tar, offset, size)
+			    != ARCHIVE_OK)
+				return (ARCHIVE_FATAL);
 			offset = -1;
 		}
 		if (*e == '\0')
@@ -1899,7 +2239,7 @@
  */
 static int64_t
 gnu_sparse_10_atol(struct archive_read *a, struct tar *tar,
-    ssize_t *remaining)
+    int64_t *remaining, size_t *unconsumed)
 {
 	int64_t l, limit, last_digit_limit;
 	const char *p;
@@ -1915,7 +2255,7 @@
 	 * don't require this, but they should.
 	 */
 	do {
-		bytes_read = readline(a, tar, &p, tar_min(*remaining, 100));
+		bytes_read = readline(a, tar, &p, tar_min(*remaining, 100), unconsumed);
 		if (bytes_read <= 0)
 			return (ARCHIVE_FATAL);
 		*remaining -= bytes_read;
@@ -1944,11 +2284,11 @@
  * that was read.
  */
 static ssize_t
-gnu_sparse_10_read(struct archive_read *a, struct tar *tar)
+gnu_sparse_10_read(struct archive_read *a, struct tar *tar, size_t *unconsumed)
 {
-	ssize_t remaining, bytes_read;
+	ssize_t bytes_read;
 	int entries;
-	off_t offset, size, to_skip;
+	int64_t offset, size, to_skip, remaining;
 
 	/* Clear out the existing sparse list. */
 	gnu_clear_sparse_list(tar);
@@ -1956,29 +2296,76 @@
 	remaining = tar->entry_bytes_remaining;
 
 	/* Parse entries. */
-	entries = gnu_sparse_10_atol(a, tar, &remaining);
+	entries = gnu_sparse_10_atol(a, tar, &remaining, unconsumed);
 	if (entries < 0)
 		return (ARCHIVE_FATAL);
 	/* Parse the individual entries. */
 	while (entries-- > 0) {
 		/* Parse offset/size */
-		offset = gnu_sparse_10_atol(a, tar, &remaining);
+		offset = gnu_sparse_10_atol(a, tar, &remaining, unconsumed);
 		if (offset < 0)
 			return (ARCHIVE_FATAL);
-		size = gnu_sparse_10_atol(a, tar, &remaining);
+		size = gnu_sparse_10_atol(a, tar, &remaining, unconsumed);
 		if (size < 0)
 			return (ARCHIVE_FATAL);
 		/* Add a new sparse entry. */
-		gnu_add_sparse_entry(tar, offset, size);
+		if (gnu_add_sparse_entry(a, tar, offset, size) != ARCHIVE_OK)
+			return (ARCHIVE_FATAL);
 	}
 	/* Skip rest of block... */
+	tar_flush_unconsumed(a, unconsumed);
 	bytes_read = tar->entry_bytes_remaining - remaining;
 	to_skip = 0x1ff & -bytes_read;
-	if (to_skip != __archive_read_skip(a, to_skip))
+	if (to_skip != __archive_read_consume(a, to_skip))
 		return (ARCHIVE_FATAL);
 	return (bytes_read + to_skip);
 }
 
+/*
+ * Solaris pax extension for a sparse file. This is recorded with the
+ * data and hole pairs. The way recording sparse information by Solaris'
+ * pax simply indicates where data and sparse are, so the stored contents
+ * consist of both data and hole.
+ */
+static int
+solaris_sparse_parse(struct archive_read *a, struct tar *tar,
+    struct archive_entry *entry, const char *p)
+{
+	const char *e;
+	int64_t start, end;
+	int hole = 1;
+
+	(void)entry; /* UNUSED */
+
+	end = 0;
+	if (*p == ' ')
+		p++;
+	else
+		return (ARCHIVE_WARN);
+	for (;;) {
+		e = p;
+		while (*e != '\0' && *e != ' ') {
+			if (*e < '0' || *e > '9')
+				return (ARCHIVE_WARN);
+			e++;
+		}
+		start = end;
+		end = tar_atol10(p, e - p);
+		if (end < 0)
+			return (ARCHIVE_WARN);
+		if (start < end) {
+			if (gnu_add_sparse_entry(a, tar, start,
+			    end - start) != ARCHIVE_OK)
+				return (ARCHIVE_FATAL);
+			tar->sparse_last->hole = hole;
+		}
+		if (*e == '\0')
+			return (ARCHIVE_OK);
+		p = e + 1;
+		hole = hole == 0;
+	}
+}
+
 /*-
  * Convert text->integer.
  *
@@ -2121,7 +2508,7 @@
  */
 static ssize_t
 readline(struct archive_read *a, struct tar *tar, const char **start,
-    ssize_t limit)
+    ssize_t limit, size_t *unconsumed)
 {
 	ssize_t bytes_read;
 	ssize_t total_size = 0;
@@ -2129,6 +2516,8 @@
 	const char *s;
 	void *p;
 
+	tar_flush_unconsumed(a, unconsumed);
+
 	t = __archive_read_ahead(a, 1, &bytes_read);
 	if (bytes_read <= 0)
 		return (ARCHIVE_FATAL);
@@ -2143,10 +2532,11 @@
 			    "Line too long");
 			return (ARCHIVE_FATAL);
 		}
-		__archive_read_consume(a, bytes_read);
+		*unconsumed = bytes_read;
 		*start = s;
 		return (bytes_read);
 	}
+	*unconsumed = bytes_read;
 	/* Otherwise, we need to accumulate in a line buffer. */
 	for (;;) {
 		if (total_size + bytes_read > limit) {
@@ -2161,7 +2551,7 @@
 			return (ARCHIVE_FATAL);
 		}
 		memcpy(tar->line.s + total_size, t, bytes_read);
-		__archive_read_consume(a, bytes_read);
+		tar_flush_unconsumed(a, unconsumed);
 		total_size += bytes_read;
 		/* If we found '\n', clean up and return. */
 		if (p != NULL) {
@@ -2178,122 +2568,10 @@
 		if (p != NULL) {
 			bytes_read = 1 + ((const char *)p) - s;
 		}
+		*unconsumed = bytes_read;
 	}
 }
 
-static wchar_t *
-utf8_decode(struct tar *tar, const char *src, size_t length)
-{
-	wchar_t *dest;
-	ssize_t n;
-
-	/* Ensure pax_entry buffer is big enough. */
-	if (tar->pax_entry_length <= length) {
-		wchar_t *old_entry;
-
-		if (tar->pax_entry_length <= 0)
-			tar->pax_entry_length = 1024;
-		while (tar->pax_entry_length <= length + 1)
-			tar->pax_entry_length *= 2;
-
-		old_entry = tar->pax_entry;
-		tar->pax_entry = (wchar_t *)realloc(tar->pax_entry,
-		    tar->pax_entry_length * sizeof(wchar_t));
-		if (tar->pax_entry == NULL) {
-			free(old_entry);
-			/* TODO: Handle this error. */
-			return (NULL);
-		}
-	}
-
-	dest = tar->pax_entry;
-	while (length > 0) {
-		n = UTF8_mbrtowc(dest, src, length);
-		if (n < 0)
-			return (NULL);
-		if (n == 0)
-			break;
-		dest++;
-		src += n;
-		length -= n;
-	}
-	*dest = L'\0';
-	return (tar->pax_entry);
-}
-
-/*
- * Copied and simplified from FreeBSD libc/locale.
- */
-static ssize_t
-UTF8_mbrtowc(wchar_t *pwc, const char *s, size_t n)
-{
-        int ch, i, len, mask;
-        unsigned long wch;
-
-        if (s == NULL || n == 0 || pwc == NULL)
-                return (0);
-
-        /*
-         * Determine the number of octets that make up this character from
-         * the first octet, and a mask that extracts the interesting bits of
-         * the first octet.
-         */
-        ch = (unsigned char)*s;
-        if ((ch & 0x80) == 0) {
-                mask = 0x7f;
-                len = 1;
-        } else if ((ch & 0xe0) == 0xc0) {
-                mask = 0x1f;
-                len = 2;
-        } else if ((ch & 0xf0) == 0xe0) {
-                mask = 0x0f;
-                len = 3;
-        } else if ((ch & 0xf8) == 0xf0) {
-                mask = 0x07;
-                len = 4;
-        } else {
-		/* Invalid first byte. */
-		return (-1);
-        }
-
-        if (n < (size_t)len) {
-		/* Valid first byte but truncated. */
-                return (-2);
-	}
-
-        /*
-         * Decode the octet sequence representing the character in chunks
-         * of 6 bits, most significant first.
-         */
-        wch = (unsigned char)*s++ & mask;
-        i = len;
-        while (--i != 0) {
-                if ((*s & 0xc0) != 0x80) {
-			/* Invalid intermediate byte; consume one byte and
-			 * emit '?' */
-			*pwc = '?';
-			return (1);
-                }
-                wch <<= 6;
-                wch |= *s++ & 0x3f;
-        }
-
-	/* Assign the value to the output; out-of-range values
-	 * just get truncated. */
-	*pwc = (wchar_t)wch;
-#ifdef WCHAR_MAX
-	/*
-	 * If platform has WCHAR_MAX, we can do something
-	 * more sensible with out-of-range values.
-	 */
-	if (wch >= WCHAR_MAX)
-		*pwc = '?';
-#endif
-	/* Return number of bytes input consumed: 0 for end-of-string. */
-        return (wch == L'\0' ? 0 : len);
-}
-
-
 /*
  * base64_decode - Base64 decode
  *
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_read_support_format_xar.c
--- a/head/contrib/libarchive/libarchive/archive_read_support_format_xar.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_read_support_format_xar.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,12 +23,11 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_support_format_xar.c 228772 2011-12-21 15:06:01Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_support_format_xar.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
 #endif
-#include <stdio.h>
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
@@ -52,9 +51,10 @@
 #endif
 
 #include "archive.h"
+#include "archive_crypto_private.h"
 #include "archive_endian.h"
 #include "archive_entry.h"
-#include "archive_hash.h"
+#include "archive_entry_locale.h"
 #include "archive_private.h"
 #include "archive_read_private.h"
 
@@ -74,6 +74,8 @@
 archive_read_support_format_xar(struct archive *_a)
 {
 	struct archive_read *a = (struct archive_read *)_a;
+	archive_check_magic(_a, ARCHIVE_READ_MAGIC,
+	    ARCHIVE_STATE_NEW, "archive_read_support_format_xar");
 
 	archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
 	    "Xar not supported on this platform");
@@ -82,8 +84,8 @@
 
 #else	/* Support xar format */
 
-//#define DEBUG 1
-//#define DEBUG_PRINT_TOC 1
+/* #define DEBUG 1 */
+/* #define DEBUG_PRINT_TOC 1 */
 #if DEBUG_PRINT_TOC
 #define PRINT_TOC(d, outbytes)	do {				\
 	unsigned char *x = (unsigned char *)(uintptr_t)d;	\
@@ -303,7 +305,8 @@
 	int64_t			 total;
 	uint64_t		 h_base;
 	int			 end_of_file;
-	unsigned char		 buff[1024*32];
+#define OUTBUFF_SIZE	(1024 * 64)
+	unsigned char		*outbuff;
 
 	enum xmlstatus		 xmlsts;
 	enum xmlstatus		 xmlsts_unknown;
@@ -350,10 +353,13 @@
 	int	 		 entry_init;
 	uint64_t		 entry_total;
 	uint64_t		 entry_remaining;
+	size_t			 entry_unconsumed;
 	uint64_t		 entry_size;
 	enum enctype 		 entry_encoding;
 	struct chksumval	 entry_a_sum;
 	struct chksumval	 entry_e_sum;
+
+	struct archive_string_conv *sconv;
 };
 
 struct xmlattr {
@@ -367,11 +373,11 @@
 	struct xmlattr	**last;
 };
 
-static int	xar_bid(struct archive_read *);
+static int	xar_bid(struct archive_read *, int);
 static int	xar_read_header(struct archive_read *,
 		    struct archive_entry *);
 static int	xar_read_data(struct archive_read *,
-		    const void **, size_t *, off_t *);
+		    const void **, size_t *, int64_t *);
 static int	xar_read_data_skip(struct archive_read *);
 static int	xar_cleanup(struct archive_read *);
 static int	move_reading_point(struct archive_read *, uint64_t);
@@ -383,9 +389,11 @@
 static int64_t	atol8(const char *, size_t);
 static size_t	atohex(unsigned char *, size_t, const char *, size_t);
 static time_t	parse_time(const char *p, size_t n);
-static void	heap_add_entry(struct heap_queue *, struct xar_file *);
+static int	heap_add_entry(struct archive_read *a,
+    struct heap_queue *, struct xar_file *);
 static struct xar_file *heap_get_entry(struct heap_queue *);
-static void	add_link(struct xar *, struct xar_file *);
+static int	add_link(struct archive_read *,
+    struct xar *, struct xar_file *);
 static void	checksum_init(struct archive_read *, int, int);
 static void	checksum_update(struct archive_read *, const void *,
 		    size_t, const void *, size_t);
@@ -396,28 +404,38 @@
 		    size_t *, const void *, size_t *);
 static int	decompression_cleanup(struct archive_read *);
 static void	xmlattr_cleanup(struct xmlattr_list *);
-static void	file_new(struct xar *, struct xmlattr_list *);
+static int	file_new(struct archive_read *,
+    struct xar *, struct xmlattr_list *);
 static void	file_free(struct xar_file *);
-static void	xattr_new(struct xar *, struct xmlattr_list *);
+static int	xattr_new(struct archive_read *,
+    struct xar *, struct xmlattr_list *);
 static void	xattr_free(struct xattr *);
 static int	getencoding(struct xmlattr_list *);
 static int	getsumalgorithm(struct xmlattr_list *);
-static void	unknowntag_start(struct xar *, const char *);
+static int	unknowntag_start(struct archive_read *,
+    struct xar *, const char *);
 static void	unknowntag_end(struct xar *, const char *);
-static void	xml_start(void *, const char *, struct xmlattr_list *);
+static int	xml_start(struct archive_read *,
+    const char *, struct xmlattr_list *);
 static void	xml_end(void *, const char *);
 static void	xml_data(void *, const char *, int);
 static int	xml_parse_file_flags(struct xar *, const char *);
 static int	xml_parse_file_ext2(struct xar *, const char *);
 #if defined(HAVE_LIBXML_XMLREADER_H)
-static int	xml2_xmlattr_setup(struct xmlattr_list *, xmlTextReaderPtr);
+static int	xml2_xmlattr_setup(struct archive_read *,
+    struct xmlattr_list *, xmlTextReaderPtr);
 static int	xml2_read_cb(void *, char *, int);
 static int	xml2_close_cb(void *);
 static void	xml2_error_hdr(void *, const char *, xmlParserSeverities,
 		    xmlTextReaderLocatorPtr);
 static int	xml2_read_toc(struct archive_read *);
 #elif defined(HAVE_BSDXML_H) || defined(HAVE_EXPAT_H)
-static void	expat_xmlattr_setup(struct xmlattr_list *, const XML_Char **);
+struct expat_userData {
+	int state;
+	struct archive_read *archive;
+};
+static int	expat_xmlattr_setup(struct archive_read *,
+    struct xmlattr_list *, const XML_Char **);
 static void	expat_start_cb(void *, const XML_Char *, const XML_Char **);
 static void	expat_end_cb(void *, const XML_Char *);
 static void	expat_data_cb(void *, const XML_Char *, int);
@@ -431,6 +449,9 @@
 	struct archive_read *a = (struct archive_read *)_a;
 	int r;
 
+	archive_check_magic(_a, ARCHIVE_READ_MAGIC,
+	    ARCHIVE_STATE_NEW, "archive_read_support_format_xar");
+
 	xar = (struct xar *)calloc(1, sizeof(*xar));
 	if (xar == NULL) {
 		archive_set_error(&a->archive, ENOMEM,
@@ -453,11 +474,13 @@
 }
 
 static int
-xar_bid(struct archive_read *a)
+xar_bid(struct archive_read *a, int best_bid)
 {
 	const unsigned char *b;
 	int bid;
 
+	(void)best_bid; /* UNUSED */
+
 	b = __archive_read_ahead(a, HEADER_SIZE, NULL);
 	if (b == NULL)
 		return (-1);
@@ -638,8 +661,17 @@
 	int r;
 
 	xar = (struct xar *)(a->format->data);
+	r = ARCHIVE_OK;
 
 	if (xar->offset == 0) {
+		/* Create a character conversion object. */
+		if (xar->sconv == NULL) {
+			xar->sconv = archive_string_conversion_from_charset(
+			    &(a->archive), "UTF-8", 1);
+			if (xar->sconv == NULL)
+				return (ARCHIVE_FATAL);
+		}
+
 		/* Read TOC. */
 		r = read_toc(a);
 		if (r != ARCHIVE_OK)
@@ -666,15 +698,65 @@
 	archive_entry_set_ctime(entry, file->ctime, 0);
 	archive_entry_set_mtime(entry, file->mtime, 0);
 	archive_entry_set_gid(entry, file->gid);
-	if (file->gname.length > 0)
-		archive_entry_update_gname_utf8(entry, file->gname.s);
+	if (file->gname.length > 0 &&
+	    archive_entry_copy_gname_l(entry, file->gname.s,
+		archive_strlen(&(file->gname)), xar->sconv) != 0) {
+		if (errno == ENOMEM) {
+			archive_set_error(&a->archive, ENOMEM,
+			    "Can't allocate memory for Gname");
+			return (ARCHIVE_FATAL);
+		}
+		archive_set_error(&a->archive,
+		    ARCHIVE_ERRNO_FILE_FORMAT,
+		    "Gname cannot be converted from %s to current locale.",
+		    archive_string_conversion_charset_name(xar->sconv));
+		r = ARCHIVE_WARN;
+	}
 	archive_entry_set_uid(entry, file->uid);
-	if (file->uname.length > 0)
-		archive_entry_update_uname_utf8(entry, file->uname.s);
+	if (file->uname.length > 0 &&
+	    archive_entry_copy_uname_l(entry, file->uname.s,
+		archive_strlen(&(file->uname)), xar->sconv) != 0) {
+		if (errno == ENOMEM) {
+			archive_set_error(&a->archive, ENOMEM,
+			    "Can't allocate memory for Uname");
+			return (ARCHIVE_FATAL);
+		}
+		archive_set_error(&a->archive,
+		    ARCHIVE_ERRNO_FILE_FORMAT,
+		    "Uname cannot be converted from %s to current locale.",
+		    archive_string_conversion_charset_name(xar->sconv));
+		r = ARCHIVE_WARN;
+	}
 	archive_entry_set_mode(entry, file->mode);
-	archive_entry_update_pathname_utf8(entry, file->pathname.s);
-	if (file->symlink.length > 0)
-		archive_entry_update_symlink_utf8(entry, file->symlink.s);
+	if (archive_entry_copy_pathname_l(entry, file->pathname.s,
+	    archive_strlen(&(file->pathname)), xar->sconv) != 0) {
+		if (errno == ENOMEM) {
+			archive_set_error(&a->archive, ENOMEM,
+			    "Can't allocate memory for Pathname");
+			return (ARCHIVE_FATAL);
+		}
+		archive_set_error(&a->archive,
+		    ARCHIVE_ERRNO_FILE_FORMAT,
+		    "Pathname cannot be converted from %s to current locale.",
+		    archive_string_conversion_charset_name(xar->sconv));
+		r = ARCHIVE_WARN;
+	}
+
+
+	if (file->symlink.length > 0 &&
+	    archive_entry_copy_symlink_l(entry, file->symlink.s,
+		archive_strlen(&(file->symlink)), xar->sconv) != 0) {
+		if (errno == ENOMEM) {
+			archive_set_error(&a->archive, ENOMEM,
+			    "Can't allocate memory for Linkname");
+			return (ARCHIVE_FATAL);
+		}
+		archive_set_error(&a->archive,
+		    ARCHIVE_ERRNO_FILE_FORMAT,
+		    "Linkname cannot be converted from %s to current locale.",
+		    archive_string_conversion_charset_name(xar->sconv));
+		r = ARCHIVE_WARN;
+	}
 	/* Set proper nlink. */
 	if ((file->mode & AE_IFMT) == AE_IFDIR)
 		archive_entry_set_nlink(entry, file->subdirs + 2);
@@ -682,8 +764,7 @@
 		archive_entry_set_nlink(entry, file->nlink);
 	archive_entry_set_size(entry, file->size);
 	if (archive_strlen(&(file->hardlink)) > 0)
-		archive_entry_update_hardlink_utf8(entry,
-			file->hardlink.s);
+		archive_entry_set_hardlink(entry, file->hardlink.s);
 	archive_entry_set_ino64(entry, file->ino64);
 	if (file->has & HAS_DEV)
 		archive_entry_set_dev(entry, file->dev);
@@ -704,7 +785,6 @@
 	/*
 	 * Read extended attributes.
 	 */
-	r = ARCHIVE_OK;
 	xattr = file->xattr_list;
 	while (xattr != NULL) {
 		const void *d;
@@ -754,13 +834,19 @@
 
 static int
 xar_read_data(struct archive_read *a,
-    const void **buff, size_t *size, off_t *offset)
+    const void **buff, size_t *size, int64_t *offset)
 {
 	struct xar *xar;
 	size_t used;
 	int r;
 
 	xar = (struct xar *)(a->format->data);
+
+	if (xar->entry_unconsumed) {
+		__archive_read_consume(a, xar->entry_unconsumed);
+		xar->entry_unconsumed = 0;
+	}
+
 	if (xar->end_of_file || xar->entry_remaining <= 0) {
 		r = ARCHIVE_EOF;
 		goto abort_read_data;
@@ -786,7 +872,7 @@
 	xar->total += *size;
 	xar->offset += used;
 	xar->entry_remaining -= used;
-	__archive_read_consume(a, used);
+	xar->entry_unconsumed = used;
 
 	if (xar->entry_remaining == 0) {
 		if (xar->entry_total != xar->entry_size) {
@@ -819,10 +905,12 @@
 	xar = (struct xar *)(a->format->data);
 	if (xar->end_of_file)
 		return (ARCHIVE_EOF);
-	bytes_skipped = __archive_read_skip(a, xar->entry_remaining);
+	bytes_skipped = __archive_read_consume(a, xar->entry_remaining +
+		xar->entry_unconsumed);
 	if (bytes_skipped < 0)
 		return (ARCHIVE_FATAL);
 	xar->offset += bytes_skipped;
+	xar->entry_unconsumed = 0;
 	return (ARCHIVE_OK);
 }
 
@@ -853,6 +941,7 @@
 		archive_string_free(&(tag->name));
 		free(tag);
 	}
+	free(xar->outbuff);
 	free(xar);
 	a->format->data = NULL;
 	return (r);
@@ -870,7 +959,7 @@
 
 		step = offset - (xar->offset - xar->h_base);
 		if (step > 0) {
-			step = __archive_read_skip(a, step);
+			step = __archive_read_consume(a, step);
 			if (step < 0)
 				return ((int)step);
 			xar->offset += step;
@@ -1011,6 +1100,8 @@
 #if HAVE_TIMEGM
 	/* Use platform timegm() if available. */
 	return (timegm(t));
+#elif HAVE__MKGMTIME64
+	return (_mkgmtime64(t));
 #else
 	/* Else use direct calculation using POSIX assumptions. */
 	/* First, fix up tm_yday based on the year/month/day. */
@@ -1084,8 +1175,9 @@
 	return (t);
 }
 
-static void
-heap_add_entry(struct heap_queue *heap, struct xar_file *file)
+static int
+heap_add_entry(struct archive_read *a,
+    struct heap_queue *heap, struct xar_file *file)
 {
 	uint64_t file_id, parent_id;
 	int hole, parent;
@@ -1098,12 +1190,18 @@
 		if (heap->allocated < 1024)
 			new_size = 1024;
 		/* Overflow might keep us from growing the list. */
-		if (new_size <= heap->allocated)
-			__archive_errx(1, "Out of memory");
+		if (new_size <= heap->allocated) {
+			archive_set_error(&a->archive,
+			    ENOMEM, "Out of memory");
+			return (ARCHIVE_FATAL);
+		}
 		new_pending_files = (struct xar_file **)
 		    malloc(new_size * sizeof(new_pending_files[0]));
-		if (new_pending_files == NULL)
-			__archive_errx(1, "Out of memory");
+		if (new_pending_files == NULL) {
+			archive_set_error(&a->archive,
+			    ENOMEM, "Out of memory");
+			return (ARCHIVE_FATAL);
+		}
 		memcpy(new_pending_files, heap->files,
 		    heap->allocated * sizeof(new_pending_files[0]));
 		if (heap->files != NULL)
@@ -1123,13 +1221,15 @@
 		parent_id = heap->files[parent]->id;
 		if (file_id >= parent_id) {
 			heap->files[hole] = file;
-			return;
+			return (ARCHIVE_OK);
 		}
-		// Move parent into hole <==> move hole up tree.
+		/* Move parent into hole <==> move hole up tree. */
 		heap->files[hole] = heap->files[parent];
 		hole = parent;
 	}
 	heap->files[0] = file;
+
+	return (ARCHIVE_OK);
 }
 
 static struct xar_file *
@@ -1155,14 +1255,14 @@
 	/*
 	 * Rebalance the heap.
 	 */
-	a = 0; // Starting element and its heap key
+	a = 0; /* Starting element and its heap key */
 	a_id = heap->files[a]->id;
 	for (;;) {
-		b = a + a + 1; // First child
+		b = a + a + 1; /* First child */
 		if (b >= heap->used)
 			return (r);
 		b_id = heap->files[b]->id;
-		c = b + 1; // Use second child if it is smaller.
+		c = b + 1; /* Use second child if it is smaller. */
 		if (c < heap->used) {
 			c_id = heap->files[c]->id;
 			if (c_id < b_id) {
@@ -1179,8 +1279,8 @@
 	}
 }
 
-static void
-add_link(struct xar *xar, struct xar_file *file)
+static int
+add_link(struct archive_read *a, struct xar *xar, struct xar_file *file)
 {
 	struct hdlink *hdlink;
 
@@ -1189,18 +1289,21 @@
 			file->hdnext = hdlink->files;
 			hdlink->cnt++;
 			hdlink->files = file;
-			return;
+			return (ARCHIVE_OK);
 		}
 	}
 	hdlink = malloc(sizeof(*hdlink));
-	if (hdlink == NULL)
-		__archive_errx(1, "No memory for add_link()");
+	if (hdlink == NULL) {
+		archive_set_error(&a->archive, ENOMEM, "Out of memory");
+		return (ARCHIVE_FATAL);
+	}
 	file->hdnext = NULL;
 	hdlink->id = file->link;
 	hdlink->cnt = 1;
 	hdlink->files = file;
 	hdlink->next = xar->hdlink_list;
 	xar->hdlink_list = hdlink;
+	return (ARCHIVE_OK);
 }
 
 static void
@@ -1362,6 +1465,13 @@
 		break;
 #endif
 #if defined(HAVE_LZMA_H) && defined(HAVE_LIBLZMA)
+#if LZMA_VERSION_MAJOR >= 5
+/* Effectively disable the limiter. */
+#define LZMA_MEMLIMIT   UINT64_MAX
+#else
+/* NOTE: This needs to check memory size which running system has. */
+#define LZMA_MEMLIMIT   (1U << 30)
+#endif
 	case XZ:
 	case LZMA:
 		if (xar->lzstream_valid) {
@@ -1370,11 +1480,11 @@
 		}
 		if (xar->entry_encoding == XZ)
 			r = lzma_stream_decoder(&(xar->lzstream),
-			    (1U << 30),/* memlimit */
+			    LZMA_MEMLIMIT,/* memlimit */
 			    LZMA_CONCATENATED);
 		else
 			r = lzma_alone_decoder(&(xar->lzstream),
-			    (1U << 30));/* memlimit */
+			    LZMA_MEMLIMIT);/* memlimit */
 		if (r != LZMA_OK) {
 			switch (r) {
 			case LZMA_MEM_ERROR:
@@ -1473,9 +1583,17 @@
 	avail_in = *used;
 	outbuff = (void *)(uintptr_t)*buff;
 	if (outbuff == NULL) {
-		outbuff = xar->buff;
+		if (xar->outbuff == NULL) {
+			xar->outbuff = malloc(OUTBUFF_SIZE);
+			if (xar->outbuff == NULL) {
+				archive_set_error(&a->archive, ENOMEM,
+				    "Couldn't allocate memory for out buffer");
+				return (ARCHIVE_FATAL);
+			}
+		}
+		outbuff = xar->outbuff;
 		*buff = outbuff;
-		avail_out = sizeof(xar->buff);
+		avail_out = OUTBUFF_SIZE;
 	} else
 		avail_out = *outbytes;
 	switch (xar->rd_encoding) {
@@ -1599,7 +1717,7 @@
 #endif
 	case NONE:
 	default:
-		if (outbuff == xar->buff) {
+		if (outbuff == xar->outbuff) {
 			*buff = b;
 			*used = avail_in;
 			*outbytes = avail_in;
@@ -1674,15 +1792,17 @@
 	list->last = &(list->first);
 }
 
-static void
-file_new(struct xar *xar, struct xmlattr_list *list)
+static int
+file_new(struct archive_read *a, struct xar *xar, struct xmlattr_list *list)
 {
 	struct xar_file *file;
 	struct xmlattr *attr;
 
 	file = calloc(1, sizeof(*file));
-	if (file == NULL)
-		__archive_errx(1, "Out of memory");
+	if (file == NULL) {
+		archive_set_error(&a->archive, ENOMEM, "Out of memory");
+		return (ARCHIVE_FATAL);
+	}
 	file->parent = xar->file;
 	file->mode = 0777 | AE_IFREG;
 	file->atime = time(NULL);
@@ -1694,7 +1814,9 @@
 			file->id = atol10(attr->value, strlen(attr->value));
 	}
 	file->nlink = 1;
-	heap_add_entry(&(xar->file_queue), file);
+	if (heap_add_entry(a, &(xar->file_queue), file) != ARCHIVE_OK)
+		return (ARCHIVE_FATAL);
+	return (ARCHIVE_OK);
 }
 
 static void
@@ -1719,15 +1841,17 @@
 	free(file);
 }
 
-static void
-xattr_new(struct xar *xar, struct xmlattr_list *list)
+static int
+xattr_new(struct archive_read *a, struct xar *xar, struct xmlattr_list *list)
 {
 	struct xattr *xattr, **nx;
 	struct xmlattr *attr;
 
 	xattr = calloc(1, sizeof(*xattr));
-	if (xattr == NULL)
-		__archive_errx(1, "Out of memory");
+	if (xattr == NULL) {
+		archive_set_error(&a->archive, ENOMEM, "Out of memory");
+		return (ARCHIVE_FATAL);
+	}
 	xar->xattr = xattr;
 	for (attr = list->first; attr != NULL; attr = attr->next) {
 		if (strcmp(attr->name, "id") == 0)
@@ -1741,6 +1865,8 @@
 	}
 	xattr->next = *nx;
 	*nx = xattr;
+
+	return (ARCHIVE_OK);
 }
 
 static void
@@ -1796,8 +1922,8 @@
 	return (alg);
 }
 
-static void
-unknowntag_start(struct xar *xar, const char *name)
+static int
+unknowntag_start(struct archive_read *a, struct xar *xar, const char *name)
 {
 	struct unknown_tag *tag;
 
@@ -1805,8 +1931,10 @@
 	fprintf(stderr, "unknowntag_start:%s\n", name);
 #endif
 	tag = malloc(sizeof(*tag));
-	if (tag == NULL)
-		__archive_errx(1, "Out of memory");
+	if (tag == NULL) {
+		archive_set_error(&a->archive, ENOMEM, "Out of memory");
+		return (ARCHIVE_FATAL);
+	}
 	tag->next = xar->unknowntags;
 	archive_string_init(&(tag->name));
 	archive_strcpy(&(tag->name), name);
@@ -1815,6 +1943,7 @@
 		xar->xmlsts = UNKNOWN;
 	}
 	xar->unknowntags = tag;
+	return (ARCHIVE_OK);
 }
 
 static void
@@ -1837,14 +1966,12 @@
 	}
 }
 
-static void
-xml_start(void *userData, const char *name, struct xmlattr_list *list)
+static int
+xml_start(struct archive_read *a, const char *name, struct xmlattr_list *list)
 {
-	struct archive_read *a;
 	struct xar *xar;
 	struct xmlattr *attr;
 
-	a = (struct archive_read *)userData;
 	xar = (struct xar *)(a->format->data);
 
 #if DEBUG
@@ -1859,13 +1986,15 @@
 		if (strcmp(name, "xar") == 0)
 			xar->xmlsts = XAR;
 		else
-			unknowntag_start(xar, name);
+			if (unknowntag_start(a, xar, name) != ARCHIVE_OK)
+				return (ARCHIVE_FATAL);
 		break;
 	case XAR:
 		if (strcmp(name, "toc") == 0)
 			xar->xmlsts = TOC;
 		else
-			unknowntag_start(xar, name);
+			if (unknowntag_start(a, xar, name) != ARCHIVE_OK)
+				return (ARCHIVE_FATAL);
 		break;
 	case TOC:
 		if (strcmp(name, "creation-time") == 0)
@@ -1873,11 +2002,13 @@
 		else if (strcmp(name, "checksum") == 0)
 			xar->xmlsts = TOC_CHECKSUM;
 		else if (strcmp(name, "file") == 0) {
-			file_new(xar, list);
+			if (file_new(a, xar, list) != ARCHIVE_OK)
+				return (ARCHIVE_FATAL);
 			xar->xmlsts = TOC_FILE;
 		}
 		else
-			unknowntag_start(xar, name);
+			if (unknowntag_start(a, xar, name) != ARCHIVE_OK)
+				return (ARCHIVE_FATAL);
 		break;
 	case TOC_CHECKSUM:
 		if (strcmp(name, "offset") == 0)
@@ -1885,16 +2016,19 @@
 		else if (strcmp(name, "size") == 0)
 			xar->xmlsts = TOC_CHECKSUM_SIZE;
 		else
-			unknowntag_start(xar, name);
+			if (unknowntag_start(a, xar, name) != ARCHIVE_OK)
+				return (ARCHIVE_FATAL);
 		break;
 	case TOC_FILE:
 		if (strcmp(name, "file") == 0) {
-			file_new(xar, list);
+			if (file_new(a, xar, list) != ARCHIVE_OK)
+				return (ARCHIVE_FATAL);
 		}
 		else if (strcmp(name, "data") == 0)
 			xar->xmlsts = FILE_DATA;
 		else if (strcmp(name, "ea") == 0) {
-			xattr_new(xar, list);
+			if (xattr_new(a, xar, list) != ARCHIVE_OK)
+				return (ARCHIVE_FATAL);
 			xar->xmlsts = FILE_EA;
 		}
 		else if (strcmp(name, "ctime") == 0)
@@ -1934,7 +2068,9 @@
 					xar->file->link = atol10(attr->value,
 					    strlen(attr->value));
 					if (xar->file->link > 0)
-						add_link(xar, xar->file);
+						if (add_link(a, xar, xar->file) != ARCHIVE_OK) {
+							return (ARCHIVE_FATAL);
+						};
 				}
 			}
 		}
@@ -1954,7 +2090,8 @@
 		else if (strcmp(name, "ext2") == 0)
 			xar->xmlsts = FILE_EXT2;
 		else
-			unknowntag_start(xar, name);
+			if (unknowntag_start(a, xar, name) != ARCHIVE_OK)
+				return (ARCHIVE_FATAL);
 		break;
 	case FILE_DATA:
 		if (strcmp(name, "length") == 0)
@@ -1978,7 +2115,8 @@
 		else if (strcmp(name, "content") == 0)
 			xar->xmlsts = FILE_DATA_CONTENT;
 		else
-			unknowntag_start(xar, name);
+			if (unknowntag_start(a, xar, name) != ARCHIVE_OK)
+				return (ARCHIVE_FATAL);
 		break;
 	case FILE_DEVICE:
 		if (strcmp(name, "major") == 0)
@@ -1986,10 +2124,12 @@
 		else if (strcmp(name, "minor") == 0)
 			xar->xmlsts = FILE_DEVICE_MINOR;
 		else
-			unknowntag_start(xar, name);
+			if (unknowntag_start(a, xar, name) != ARCHIVE_OK)
+				return (ARCHIVE_FATAL);
 		break;
 	case FILE_DATA_CONTENT:
-		unknowntag_start(xar, name);
+		if (unknowntag_start(a, xar, name) != ARCHIVE_OK)
+			return (ARCHIVE_FATAL);
 		break;
 	case FILE_EA:
 		if (strcmp(name, "length") == 0)
@@ -2010,7 +2150,8 @@
 		else if (strcmp(name, "fstype") == 0)
 			xar->xmlsts = FILE_EA_FSTYPE;
 		else
-			unknowntag_start(xar, name);
+			if (unknowntag_start(a, xar, name) != ARCHIVE_OK)
+				return (ARCHIVE_FATAL);
 		break;
 	case FILE_ACL:
 		if (strcmp(name, "appleextended") == 0)
@@ -2020,15 +2161,18 @@
 		else if (strcmp(name, "access") == 0)
 			xar->xmlsts = FILE_ACL_ACCESS;
 		else
-			unknowntag_start(xar, name);
+			if (unknowntag_start(a, xar, name) != ARCHIVE_OK)
+				return (ARCHIVE_FATAL);
 		break;
 	case FILE_FLAGS:
 		if (!xml_parse_file_flags(xar, name))
-			unknowntag_start(xar, name);
+			if (unknowntag_start(a, xar, name) != ARCHIVE_OK)
+				return (ARCHIVE_FATAL);
 		break;
 	case FILE_EXT2:
 		if (!xml_parse_file_ext2(xar, name))
-			unknowntag_start(xar, name);
+			if (unknowntag_start(a, xar, name) != ARCHIVE_OK)
+				return (ARCHIVE_FATAL);
 		break;
 	case TOC_CREATION_TIME:
 	case TOC_CHECKSUM_OFFSET:
@@ -2096,9 +2240,11 @@
 	case FILE_EXT2_TopDir:
 	case FILE_EXT2_Reserved:
 	case UNKNOWN:
-		unknowntag_start(xar, name);
+		if (unknowntag_start(a, xar, name) != ARCHIVE_OK)
+			return (ARCHIVE_FATAL);
 		break;
 	}
+	return (ARCHIVE_OK);
 }
 
 static void
@@ -2470,13 +2616,15 @@
 };
 
 static void
-strappend_base64(struct archive_string *as, const char *s, size_t l)
+strappend_base64(struct xar *xar,
+    struct archive_string *as, const char *s, size_t l)
 {
 	unsigned char buff[256];
 	unsigned char *out;
 	const unsigned char *b;
 	size_t len;
 
+	(void)xar; /* UNUSED */
 	len = 0;
 	out = buff;
 	b = (const unsigned char *)s;
@@ -2530,8 +2678,8 @@
 #if DEBUG
 	{
 		char buff[1024];
-		if (len > (int)sizeof(buff)-1)
-			len = (int)sizeof(buff)-1;
+		if (len > sizeof(buff)-1)
+			len = sizeof(buff)-1;
 		memcpy(buff, s, len);
 		buff[len] = 0;
 		fprintf(stderr, "\tlen=%d:\"%s\"\n", len, buff);
@@ -2558,9 +2706,10 @@
 			archive_strappend_char(&(xar->file->pathname), '/');
 		}
 		xar->file->has |= HAS_PATHNAME;
-		if (xar->base64text)
-			strappend_base64(&(xar->file->pathname), s, len);
-		else
+		if (xar->base64text) {
+			strappend_base64(xar,
+			    &(xar->file->pathname), s, len);
+		} else
 			archive_strncat(&(xar->file->pathname), s, len);
 		break;
 	case FILE_LINK:
@@ -2909,7 +3058,8 @@
 #ifdef HAVE_LIBXML_XMLREADER_H
 
 static int
-xml2_xmlattr_setup(struct xmlattr_list *list, xmlTextReaderPtr reader)
+xml2_xmlattr_setup(struct archive_read *a,
+    struct xmlattr_list *list, xmlTextReaderPtr reader)
 {
 	struct xmlattr *attr;
 	int r;
@@ -2919,16 +3069,22 @@
 	r = xmlTextReaderMoveToFirstAttribute(reader);
 	while (r == 1) {
 		attr = malloc(sizeof*(attr));
-		if (attr == NULL)
-			__archive_errx(1, "Out of memory");
+		if (attr == NULL) {
+			archive_set_error(&a->archive, ENOMEM, "Out of memory");
+			return (ARCHIVE_FATAL);
+		}
 		attr->name = strdup(
 		    (const char *)xmlTextReaderConstLocalName(reader));
-		if (attr->name == NULL)
-			__archive_errx(1, "Out of memory");
+		if (attr->name == NULL) {
+			archive_set_error(&a->archive, ENOMEM, "Out of memory");
+			return (ARCHIVE_FATAL);
+		}
 		attr->value = strdup(
 		    (const char *)xmlTextReaderConstValue(reader));
-		if (attr->value == NULL)
-			__archive_errx(1, "Out of memory");
+		if (attr->value == NULL) {
+			archive_set_error(&a->archive, ENOMEM, "Out of memory");
+			return (ARCHIVE_FATAL);
+		}
 		attr->next = NULL;
 		*list->last = attr;
 		list->last = &(attr->next);
@@ -3020,13 +3176,15 @@
 		switch (type) {
 		case XML_READER_TYPE_ELEMENT:
 			empty = xmlTextReaderIsEmptyElement(reader);
-			r = xml2_xmlattr_setup(&list, reader);
-			if (r == 0) {
-				xml_start(a, name, &list);
-				xmlattr_cleanup(&list);
-				if (empty)
-					xml_end(a, name);
-			}
+			r = xml2_xmlattr_setup(a, &list, reader);
+			if (r != ARCHIVE_OK)
+				return (r);
+			r = xml_start(a, name, &list);
+			xmlattr_cleanup(&list);
+			if (r != ARCHIVE_OK)
+				return (r);
+			if (empty)
+				xml_end(a, name);
 			break;
 		case XML_READER_TYPE_END_ELEMENT:
 			xml_end(a, name);
@@ -3050,52 +3208,64 @@
 
 #elif defined(HAVE_BSDXML_H) || defined(HAVE_EXPAT_H)
 
-static void
-expat_xmlattr_setup(struct xmlattr_list *list, const XML_Char **atts)
+static int
+expat_xmlattr_setup(struct archive_read *a,
+    struct xmlattr_list *list, const XML_Char **atts)
 {
 	struct xmlattr *attr;
+	char *name, *value;
 
 	list->first = NULL;
 	list->last = &(list->first);
 	if (atts == NULL)
-		return;
+		return (ARCHIVE_OK);
 	while (atts[0] != NULL && atts[1] != NULL) {
 		attr = malloc(sizeof*(attr));
-		if (attr == NULL)
-			__archive_errx(1, "Out of memory");
-		attr->name = strdup(atts[0]);
-		if (attr->name == NULL)
-			__archive_errx(1, "Out of memory");
-		attr->value = strdup(atts[1]);
-		if (attr->value == NULL)
-			__archive_errx(1, "Out of memory");
+		name = strdup(atts[0]);
+		value = strdup(atts[1]);
+		if (attr == NULL || name == NULL || value == NULL) {
+			archive_set_error(&a->archive, ENOMEM, "Out of memory");
+			return (ARCHIVE_FATAL);
+		}
+		attr->name = name;
+		attr->value = value;
 		attr->next = NULL;
 		*list->last = attr;
 		list->last = &(attr->next);
 		atts += 2;
 	}
+	return (ARCHIVE_OK);
 }
 
 static void
 expat_start_cb(void *userData, const XML_Char *name, const XML_Char **atts)
 {
+	struct expat_userData *ud = (struct expat_userData *)userData;
+	struct archive_read *a = ud->archive;
 	struct xmlattr_list list;
+	int r;
 
-	expat_xmlattr_setup(&list, atts);
-	xml_start(userData, (const char *)name, &list);
+	r = expat_xmlattr_setup(a, &list, atts);
+	if (r == ARCHIVE_OK)
+		r = xml_start(a, (const char *)name, &list);
 	xmlattr_cleanup(&list);
+	ud->state = r;
 }
 
 static void
 expat_end_cb(void *userData, const XML_Char *name)
 {
-	xml_end(userData, (const char *)name);
+	struct expat_userData *ud = (struct expat_userData *)userData;
+
+	xml_end(ud->archive, (const char *)name);
 }
 
 static void
 expat_data_cb(void *userData, const XML_Char *s, int len)
 {
-	xml_data(userData, s, len);
+	struct expat_userData *ud = (struct expat_userData *)userData;
+
+	xml_data(ud->archive, s, len);
 }
 
 static int
@@ -3103,6 +3273,10 @@
 {
 	struct xar *xar;
 	XML_Parser parser;
+	struct expat_userData ud;
+
+	ud.state = ARCHIVE_OK;
+	ud.archive = a;
 
 	xar = (struct xar *)(a->format->data);
 
@@ -3113,12 +3287,12 @@
 		    "Couldn't allocate memory for xml parser");
 		return (ARCHIVE_FATAL);
 	}
-	XML_SetUserData(parser, a);
+	XML_SetUserData(parser, &ud);
 	XML_SetElementHandler(parser, expat_start_cb, expat_end_cb);
 	XML_SetCharacterDataHandler(parser, expat_data_cb);
 	xar->xmlsts = INIT;
 
-	while (xar->toc_remaining) {
+	while (xar->toc_remaining && ud.state == ARCHIVE_OK) {
 		enum XML_Status xr;
 		const void *d;
 		size_t outbytes;
@@ -3129,13 +3303,13 @@
 		r = rd_contents(a, &d, &outbytes, &used, xar->toc_remaining);
 		if (r != ARCHIVE_OK)
 			return (r);
-		__archive_read_consume(a, used);
 		xar->toc_remaining -= used;
 		xar->offset += used;
 		xar->toc_total += outbytes;
 		PRINT_TOC(d, outbytes);
 
 		xr = XML_Parse(parser, d, outbytes, xar->toc_remaining == 0);
+		__archive_read_consume(a, used);
 		if (xr == XML_STATUS_ERROR) {
 			XML_ParserFree(parser);
 			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
@@ -3144,7 +3318,7 @@
 		}
 	}
 	XML_ParserFree(parser);
-	return (ARCHIVE_OK);
+	return (ud.state);
 }
 #endif /* defined(HAVE_BSDXML_H) || defined(HAVE_EXPAT_H) */
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_read_support_format_zip.c
--- a/head/contrib/libarchive/libarchive/archive_read_support_format_zip.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_read_support_format_zip.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,6 @@
 /*-
  * Copyright (c) 2004 Tim Kientzle
+ * Copyright (c) 2011-2012 Michihiro NAKAJIMA
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -24,22 +25,21 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_support_format_zip.c 228773 2011-12-21 15:18:52Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_support_format_zip.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
 #endif
-#include <stdio.h>
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
-#include <time.h>
 #ifdef HAVE_ZLIB_H
 #include <zlib.h>
 #endif
 
 #include "archive.h"
 #include "archive_entry.h"
+#include "archive_entry_locale.h"
 #include "archive_private.h"
 #include "archive_read_private.h"
 #include "archive_endian.h"
@@ -48,10 +48,39 @@
 #include "archive_crc32.h"
 #endif
 
+struct zip_entry {
+	int64_t			local_header_offset;
+	int64_t			compressed_size;
+	int64_t			uncompressed_size;
+	int64_t			gid;
+	int64_t			uid;
+	struct archive_entry	*entry;
+	time_t			mtime;
+	time_t			atime;
+	time_t			ctime;
+	uint32_t		crc32;
+	uint16_t		mode;
+	uint16_t		flags;
+	char			compression;
+	char			system;
+};
+
 struct zip {
+	/* Structural information about the archive. */
+	int64_t			central_directory_offset;
+	size_t			central_directory_size;
+	size_t			central_directory_entries;
+	char			have_central_directory;
+
+	/* List of entries (seekable Zip only) */
+	size_t			entries_remaining;
+	struct zip_entry	*zip_entries;
+	struct zip_entry	*entry;
+
+	size_t			unconsumed;
+
 	/* entry_bytes_remaining is the number of bytes we expect. */
 	int64_t			entry_bytes_remaining;
-	int64_t			entry_offset;
 
 	/* These count the number of bytes actually read for the entry. */
 	int64_t			entry_compressed_bytes_read;
@@ -60,27 +89,12 @@
 	/* Running CRC32 of the decompressed data */
 	unsigned long		entry_crc32;
 
-	unsigned		version;
-	unsigned		system;
-	unsigned		flags;
-	unsigned		compression;
-	const char *		compression_name;
-	time_t			mtime;
-	time_t			ctime;
-	time_t			atime;
-	mode_t			mode;
-	uid_t			uid;
-	gid_t			gid;
-
 	/* Flags to mark progress of decompression. */
 	char			decompress_init;
 	char			end_of_entry;
 
-	unsigned long		crc32;
 	ssize_t			filename_length;
 	ssize_t			extra_length;
-	int64_t			uncompressed_size;
-	int64_t			compressed_size;
 
 	unsigned char 		*uncompressed_buffer;
 	size_t 			uncompressed_buffer_size;
@@ -89,65 +103,60 @@
 	char			stream_valid;
 #endif
 
-	struct archive_string	pathname;
 	struct archive_string	extra;
+	struct archive_string_conv *sconv;
+	struct archive_string_conv *sconv_default;
+	struct archive_string_conv *sconv_utf8;
+	int			init_default_conversion;
 	char	format_name[64];
 };
 
 #define ZIP_LENGTH_AT_END	8
+#define ZIP_ENCRYPTED		(1<<0)	
+#define ZIP_STRONG_ENCRYPTED	(1<<6)	
+#define ZIP_UTF8_NAME		(1<<11)	
 
-struct zip_file_header {
-	char	signature[4];
-	char	version[2];
-	char	flags[2];
-	char	compression[2];
-	char	timedate[4];
-	char	crc32[4];
-	char	compressed_size[4];
-	char	uncompressed_size[4];
-	char	filename_length[2];
-	char	extra_length[2];
-};
-
-static const char *compression_names[] = {
-	"uncompressed",
-	"shrinking",
-	"reduced-1",
-	"reduced-2",
-	"reduced-3",
-	"reduced-4",
-	"imploded",
-	"reserved",
-	"deflation"
-};
-
-static int	archive_read_format_zip_bid(struct archive_read *);
+static int	archive_read_format_zip_streamable_bid(struct archive_read *, int);
+static int	archive_read_format_zip_seekable_bid(struct archive_read *, int);
+static int	archive_read_format_zip_options(struct archive_read *,
+		    const char *, const char *);
 static int	archive_read_format_zip_cleanup(struct archive_read *);
 static int	archive_read_format_zip_read_data(struct archive_read *,
-		    const void **, size_t *, off_t *);
+		    const void **, size_t *, int64_t *);
 static int	archive_read_format_zip_read_data_skip(struct archive_read *a);
-static int	archive_read_format_zip_read_header(struct archive_read *,
+static int	archive_read_format_zip_seekable_read_header(struct archive_read *,
 		    struct archive_entry *);
-static int	search_next_signature(struct archive_read *);
+static int	archive_read_format_zip_streamable_read_header(struct archive_read *,
+		    struct archive_entry *);
+#ifdef HAVE_ZLIB_H
 static int	zip_read_data_deflate(struct archive_read *a, const void **buff,
-		    size_t *size, off_t *offset);
+		    size_t *size, int64_t *offset);
+#endif
 static int	zip_read_data_none(struct archive_read *a, const void **buff,
-		    size_t *size, off_t *offset);
-static int	zip_read_file_header(struct archive_read *a,
-		    struct archive_entry *entry, struct zip *zip);
+		    size_t *size, int64_t *offset);
+static int	zip_read_local_file_header(struct archive_read *a,
+    struct archive_entry *entry, struct zip *);
 static time_t	zip_time(const char *);
-static void process_extra(const void* extra, struct zip* zip);
+static const char *compression_name(int compression);
+static void process_extra(const char *, size_t, struct zip_entry *);
+
+int	archive_read_support_format_zip_streamable(struct archive *);
+int	archive_read_support_format_zip_seekable(struct archive *);
 
 int
-archive_read_support_format_zip(struct archive *_a)
+archive_read_support_format_zip_streamable(struct archive *_a)
 {
 	struct archive_read *a = (struct archive_read *)_a;
 	struct zip *zip;
 	int r;
 
+	archive_check_magic(_a, ARCHIVE_READ_MAGIC,
+	    ARCHIVE_STATE_NEW, "archive_read_support_format_zip");
+
 	zip = (struct zip *)malloc(sizeof(*zip));
 	if (zip == NULL) {
-		archive_set_error(&a->archive, ENOMEM, "Can't allocate zip data");
+		archive_set_error(&a->archive, ENOMEM,
+		    "Can't allocate zip data");
 		return (ARCHIVE_FATAL);
 	}
 	memset(zip, 0, sizeof(*zip));
@@ -155,9 +164,9 @@
 	r = __archive_read_register_format(a,
 	    zip,
 	    "zip",
-	    archive_read_format_zip_bid,
-	    NULL,
-	    archive_read_format_zip_read_header,
+	    archive_read_format_zip_streamable_bid,
+	    archive_read_format_zip_options,
+	    archive_read_format_zip_streamable_read_header,
 	    archive_read_format_zip_read_data,
 	    archive_read_format_zip_read_data_skip,
 	    archive_read_format_zip_cleanup);
@@ -167,13 +176,234 @@
 	return (ARCHIVE_OK);
 }
 
+int
+archive_read_support_format_zip_seekable(struct archive *_a)
+{
+	struct archive_read *a = (struct archive_read *)_a;
+	struct zip *zip;
+	int r;
+
+	archive_check_magic(_a, ARCHIVE_READ_MAGIC,
+	    ARCHIVE_STATE_NEW, "archive_read_support_format_zip_seekable");
+
+	zip = (struct zip *)malloc(sizeof(*zip));
+	if (zip == NULL) {
+		archive_set_error(&a->archive, ENOMEM,
+		    "Can't allocate zip data");
+		return (ARCHIVE_FATAL);
+	}
+	memset(zip, 0, sizeof(*zip));
+
+	r = __archive_read_register_format(a,
+	    zip,
+	    "zip",
+	    archive_read_format_zip_seekable_bid,
+	    archive_read_format_zip_options,
+	    archive_read_format_zip_seekable_read_header,
+	    archive_read_format_zip_read_data,
+	    archive_read_format_zip_read_data_skip,
+	    archive_read_format_zip_cleanup);
+
+	if (r != ARCHIVE_OK)
+		free(zip);
+	return (ARCHIVE_OK);
+}
+
+int
+archive_read_support_format_zip(struct archive *a)
+{
+	int r;
+	r = archive_read_support_format_zip_streamable(a);
+	if (r != ARCHIVE_OK)
+		return r;
+	return (archive_read_support_format_zip_seekable(a));
+}
+
+/*
+ * TODO: This is a performance sink because it forces the read core to
+ * drop buffered data from the start of file, which will then have to
+ * be re-read again if this bidder loses.
+ *
+ * We workaround this a little by passing in the best bid so far so
+ * that later bidders can do nothing if they know they'll never
+ * outbid.  But we can certainly do better...
+ */
+static int
+archive_read_format_zip_seekable_bid(struct archive_read *a, int best_bid)
+{
+	struct zip *zip = (struct zip *)a->format->data;
+	int64_t filesize;
+	const char *p;
+
+	/* If someone has already bid more than 32, then avoid
+	   trashing the look-ahead buffers with a seek. */
+	if (best_bid > 32)
+		return (-1);
+
+	filesize = __archive_read_seek(a, -22, SEEK_END);
+	/* If we can't seek, then we can't bid. */
+	if (filesize <= 0)
+		return 0;
+
+	/* TODO: More robust search for end of central directory record. */
+	if ((p = __archive_read_ahead(a, 22, NULL)) == NULL)
+		return 0;
+	/* First four bytes are signature for end of central directory
+	   record.  Four zero bytes ensure this isn't a multi-volume
+	   Zip file (which we don't yet support). */
+	if (memcmp(p, "PK\005\006\000\000\000\000", 8) != 0)
+		return 0;
+
+	/* Since we've already done the hard work of finding the
+	   end of central directory record, let's save the important
+	   information. */
+	zip->central_directory_entries = archive_le16dec(p + 10);
+	zip->central_directory_size = archive_le32dec(p + 12);
+	zip->central_directory_offset = archive_le32dec(p + 16);
+
+	/* Just one volume, so central dir must all be on this volume. */
+	if (zip->central_directory_entries != archive_le16dec(p + 8))
+		return 0;
+	/* Central directory can't extend beyond end of this file. */
+	if (zip->central_directory_offset + (int64_t)zip->central_directory_size > filesize)
+		return 0;
+
+	/* This is just a tiny bit higher than the maximum returned by
+	   the streaming Zip bidder.  This ensures that the more accurate
+	   seeking Zip parser wins whenever seek is available. */
+	return 32;
+}
 
 static int
-archive_read_format_zip_bid(struct archive_read *a)
+slurp_central_directory(struct archive_read *a, struct zip *zip)
+{
+	unsigned i;
+
+	__archive_read_seek(a, zip->central_directory_offset, SEEK_SET);
+
+	zip->zip_entries = calloc(zip->central_directory_entries, sizeof(struct zip_entry));
+	for (i = 0; i < zip->central_directory_entries; ++i) {
+		struct zip_entry *zip_entry = &zip->zip_entries[i];
+		size_t filename_length, extra_length, comment_length;
+		uint32_t external_attributes;
+		const char *p;
+
+		if ((p = __archive_read_ahead(a, 46, NULL)) == NULL)
+			return ARCHIVE_FATAL;
+		if (memcmp(p, "PK\001\002", 4) != 0) {
+			archive_set_error(&a->archive,
+			    -1, "Invalid central directory signature");
+			return ARCHIVE_FATAL;
+		}
+		zip->have_central_directory = 1;
+		/* version = p[4]; */
+		zip_entry->system = p[5];
+		/* version_required = archive_le16dec(p + 6); */
+		zip_entry->flags = archive_le16dec(p + 8);
+		zip_entry->compression = archive_le16dec(p + 10);
+		zip_entry->mtime = zip_time(p + 12);
+		zip_entry->crc32 = archive_le32dec(p + 16);
+		zip_entry->compressed_size = archive_le32dec(p + 20);
+		zip_entry->uncompressed_size = archive_le32dec(p + 24);
+		filename_length = archive_le16dec(p + 28);
+		extra_length = archive_le16dec(p + 30);
+		comment_length = archive_le16dec(p + 32);
+		/* disk_start = archive_le16dec(p + 34); */ /* Better be zero. */
+		/* internal_attributes = archive_le16dec(p + 36); */ /* text bit */
+		external_attributes = archive_le32dec(p + 38);
+		zip_entry->local_header_offset = archive_le32dec(p + 42);
+
+		/* If we can't guess the mode, leave it zero here;
+		   when we read the local file header we might get
+		   more information. */
+		zip_entry->mode = 0;
+		if (zip_entry->system == 3) {
+			zip_entry->mode = external_attributes >> 16;
+		}
+
+		/* We don't read the filename until we get to the
+		   local file header.  Reading it here would speed up
+		   table-of-contents operations (removing the need to
+		   find and read local file header to get the
+		   filename) at the cost of requiring a lot of extra
+		   space. */
+		/* We don't read the extra block here.  We assume it
+		   will be duplicated at the local file header. */
+		__archive_read_consume(a,
+		    46 + filename_length + extra_length + comment_length);
+	}
+
+	/* TODO: Sort zip entries by file offset so that we
+	   can optimize get_next_header() to use skip instead of
+	   seek. */
+
+	return ARCHIVE_OK;
+}
+
+static int
+archive_read_format_zip_seekable_read_header(struct archive_read *a,
+	struct archive_entry *entry)
+{
+	struct zip *zip = (struct zip *)a->format->data;
+	int r;
+
+	a->archive.archive_format = ARCHIVE_FORMAT_ZIP;
+	if (a->archive.archive_format_name == NULL)
+		a->archive.archive_format_name = "ZIP";
+
+	if (zip->zip_entries == NULL) {
+		r = slurp_central_directory(a, zip);
+		zip->entries_remaining = zip->central_directory_entries;
+		if (r != ARCHIVE_OK)
+			return r;
+		zip->entry = zip->zip_entries;
+	} else {
+		++zip->entry;
+	}
+
+	if (zip->entries_remaining <= 0)
+		return ARCHIVE_EOF;
+	--zip->entries_remaining;
+
+	/* TODO: If entries are sorted by offset within the file, we
+	   should be able to skip here instead of seeking.  Skipping is
+	   typically faster (easier for I/O layer to optimize). */
+	__archive_read_seek(a, zip->entry->local_header_offset, SEEK_SET);
+	zip->unconsumed = 0;
+	r = zip_read_local_file_header(a, entry, zip);
+	if (r != ARCHIVE_OK)
+		return r;
+	if ((zip->entry->mode & AE_IFMT) == AE_IFLNK) {
+		const void *p;
+		size_t linkname_length = archive_entry_size(entry);
+
+		archive_entry_set_size(entry, 0);
+		p = __archive_read_ahead(a, linkname_length, NULL);
+		if (p == NULL) {
+			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+			    "Truncated Zip file");
+			return ARCHIVE_FATAL;
+		}
+
+		if (archive_entry_copy_symlink_l(entry, p, linkname_length,
+		    NULL) != 0) {
+			/* NOTE: If the last argument is NULL, this will
+			 * fail only by memeory allocation failure. */
+			archive_set_error(&a->archive, ENOMEM,
+			    "Can't allocate memory for Symlink");
+			return (ARCHIVE_FATAL);
+		}
+		/* TODO: handle character-set issues? */
+	}
+	return ARCHIVE_OK;
+}
+
+static int
+archive_read_format_zip_streamable_bid(struct archive_read *a, int best_bid)
 {
 	const char *p;
-	const void *buff;
-	ssize_t bytes_avail, offset;
+
+	(void)best_bid; /* UNUSED */
 
 	if ((p = __archive_read_ahead(a, 4, NULL)) == NULL)
 		return (-1);
@@ -192,321 +422,310 @@
 			return (30);
 	}
 
-	/*
-	 * Attempt to handle self-extracting archives
-	 * by noting a PE header and searching forward
-	 * up to 128k for a 'PK\003\004' marker.
-	 */
-	if (p[0] == 'M' && p[1] == 'Z') {
-		/*
-		 * TODO: Optimize by initializing 'offset' to an
-		 * estimate of the likely start of the archive data
-		 * based on values in the PE header.  Note that we
-		 * don't need to be exact, but we mustn't skip too
-		 * far.  The search below will compensate if we
-		 * undershoot.
-		 */
-		offset = 0;
-		while (offset < 124000) {
-			/* Get 4k of data beyond where we stopped. */
-			buff = __archive_read_ahead(a, offset + 4096,
-			    &bytes_avail);
-			if (buff == NULL)
-				break;
-			p = (const char *)buff + offset;
-			while (p + 9 < (const char *)buff + bytes_avail) {
-				if (p[0] == 'P' && p[1] == 'K' /* signature */
-				    && p[2] == 3 && p[3] == 4 /* File entry */
-				    && p[8] == 8 /* compression == deflate */
-				    && p[9] == 0 /* High byte of compression */
-					)
-				{
-					return (30);
-				}
-				++p;
-			}
-			offset = p - (const char *)buff;
-		}
-	}
+	/* TODO: It's worth looking ahead a little bit for a valid
+	 * PK signature.  In particular, that would make it possible
+	 * to read some UUEncoded SFX files or SFX files coming from
+	 * a network socket. */
 
 	return (0);
 }
 
-/*
- * Search forward for a "PK\003\004" file header.  This handles the
- * case of self-extracting archives, where there is an executable
- * prepended to the ZIP archive.
- */
 static int
-skip_sfx(struct archive_read *a)
+archive_read_format_zip_options(struct archive_read *a,
+    const char *key, const char *val)
 {
-	const void *h;
-	const char *p, *q;
-	size_t skip;
-	ssize_t bytes;
+	struct zip *zip;
+	int ret = ARCHIVE_FAILED;
 
-	/*
-	 * TODO: We should be able to skip forward by a bunch
-	 * by lifting some values from the PE header.  We don't
-	 * need to be exact (we're still going to search forward
-	 * to find the header), but it will speed things up and
-	 * reduce the chance of a false positive.
-	 */
-	for (;;) {
-		h = __archive_read_ahead(a, 4, &bytes);
-		if (bytes < 4)
-			return (ARCHIVE_FATAL);
-		p = h;
-		q = p + bytes;
+	zip = (struct zip *)(a->format->data);
+	if (strcmp(key, "compat-2x")  == 0) {
+		/* Handle filnames as libarchive 2.x */
+		zip->init_default_conversion = (val != NULL) ? 1 : 0;
+		return (ARCHIVE_OK);
+	} else if (strcmp(key, "hdrcharset")  == 0) {
+		if (val == NULL || val[0] == 0)
+			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+			    "zip: hdrcharset option needs a character-set name");
+		else {
+			zip->sconv = archive_string_conversion_from_charset(
+			    &a->archive, val, 0);
+			if (zip->sconv != NULL) {
+				if (strcmp(val, "UTF-8") == 0)
+					zip->sconv_utf8 = zip->sconv;
+				ret = ARCHIVE_OK;
+			} else
+				ret = ARCHIVE_FATAL;
+		}
+		return (ret);
+	}
 
-		/*
-		 * Scan ahead until we find something that looks
-		 * like the zip header.
-		 */
-		while (p + 4 < q) {
-			switch (p[3]) {
-			case '\004':
-				/* TODO: Additional verification here. */
-				if (memcmp("PK\003\004", p, 4) == 0) {
-					skip = p - (const char *)h;
-					__archive_read_consume(a, skip);
-					return (ARCHIVE_OK);
-				}
-				p += 4;
-				break;
-			case '\003': p += 1; break;
-			case 'K': p += 2; break;
-			case 'P': p += 3; break;
-			default: p += 4; break;
-			}
-		}
-		skip = p - (const char *)h;
-		__archive_read_consume(a, skip);
-	}
+	/* Note: The "warn" return is just to inform the options
+	 * supervisor that we didn't handle it.  It will generate
+	 * a suitable error if no one used this option. */
+	return (ARCHIVE_WARN);
 }
 
 static int
-archive_read_format_zip_read_header(struct archive_read *a,
+archive_read_format_zip_streamable_read_header(struct archive_read *a,
     struct archive_entry *entry)
 {
-	const void *h;
-	const char *signature;
 	struct zip *zip;
-	int r = ARCHIVE_OK, r1;
 
 	a->archive.archive_format = ARCHIVE_FORMAT_ZIP;
 	if (a->archive.archive_format_name == NULL)
 		a->archive.archive_format_name = "ZIP";
 
 	zip = (struct zip *)(a->format->data);
+
+	/* Make sure we have a zip_entry structure to use. */
+	if (zip->zip_entries == NULL) {
+		zip->zip_entries = malloc(sizeof(struct zip_entry));
+		if (zip->zip_entries == NULL) {
+			archive_set_error(&a->archive, ENOMEM, "Out  of memory");
+			return ARCHIVE_FATAL;
+		}
+	}
+	zip->entry = zip->zip_entries;
+	memset(zip->entry, 0, sizeof(struct zip_entry));
+
+	/* Search ahead for the next local file header. */
+	__archive_read_consume(a, zip->unconsumed);
+	zip->unconsumed = 0;
+	for (;;) {
+		int64_t skipped = 0;
+		const char *p, *end;
+		ssize_t bytes;
+
+		p = __archive_read_ahead(a, 4, &bytes);
+		if (p == NULL)
+			return (ARCHIVE_FATAL);
+		end = p + bytes;
+
+		while (p + 4 <= end) {
+			if (p[0] == 'P' && p[1] == 'K') {
+				if (p[2] == '\001' && p[3] == '\002')
+					/* Beginning of central directory. */
+					return (ARCHIVE_EOF);
+
+				if (p[2] == '\003' && p[3] == '\004') {
+					/* Regular file entry. */
+					__archive_read_consume(a, skipped);
+					return zip_read_local_file_header(a, entry, zip);
+				}
+
+				if (p[2] == '\005' && p[3] == '\006')
+					/* End of central directory. */
+					return (ARCHIVE_EOF);
+			}
+			++p;
+			++skipped;
+		}
+		__archive_read_consume(a, skipped);
+	}
+}
+
+/*
+ * Assumes file pointer is at beginning of local file header.
+ */
+static int
+zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry,
+    struct zip *zip)
+{
+	const char *p;
+	const void *h;
+	const wchar_t *wp;
+	const char *cp;
+	size_t len, filename_length, extra_length;
+	struct archive_string_conv *sconv;
+	struct zip_entry *zip_entry = zip->entry;
+	uint32_t local_crc32;
+	int64_t compressed_size, uncompressed_size;
+	int ret = ARCHIVE_OK;
+	char version;
+
 	zip->decompress_init = 0;
 	zip->end_of_entry = 0;
 	zip->entry_uncompressed_bytes_read = 0;
 	zip->entry_compressed_bytes_read = 0;
 	zip->entry_crc32 = crc32(0, NULL, 0);
-	if ((h = __archive_read_ahead(a, 4, NULL)) == NULL)
-		return (ARCHIVE_FATAL);
 
-	signature = (const char *)h;
-	if (signature[0] == 'M' && signature[1] == 'Z') {
-		/* This is an executable?  Must be self-extracting... */
-		r = skip_sfx(a);
-		if (r < ARCHIVE_WARN)
-			return (r);
-		if ((h = __archive_read_ahead(a, 4, NULL)) == NULL)
-			return (ARCHIVE_FATAL);
-		signature = (const char *)h;
+	/* Setup default conversion. */
+	if (zip->sconv == NULL && !zip->init_default_conversion) {
+		zip->sconv_default =
+		    archive_string_default_conversion_for_read(&(a->archive));
+		zip->init_default_conversion = 1;
 	}
 
-	/* If we don't see a PK signature here, scan forward. */
-	if (signature[0] != 'P' || signature[1] != 'K') {
-		r = search_next_signature(a);
-		if (r != ARCHIVE_OK) {
-			archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
-			    "Bad ZIP file");
-			return (ARCHIVE_FATAL);
-		}
-		if ((h = __archive_read_ahead(a, 4, NULL)) == NULL)
-			return (ARCHIVE_FATAL);
-		signature = (const char *)h;
-	}
-
-	/*
-	 * "PK00" signature is used for "split" archives that
-	 * only have a single segment.  This means we can just
-	 * skip the PK00; the first real file header should follow.
-	 */
-	if (signature[2] == '0' && signature[3] == '0') {
-		__archive_read_consume(a, 4);
-		if ((h = __archive_read_ahead(a, 4, NULL)) == NULL)
-			return (ARCHIVE_FATAL);
-		signature = (const char *)h;
-		if (signature[0] != 'P' || signature[1] != 'K') {
-			archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
-			    "Bad ZIP file");
-			return (ARCHIVE_FATAL);
-		}
-	}
-
-	if (signature[2] == '\001' && signature[3] == '\002') {
-		/* Beginning of central directory. */
-		return (ARCHIVE_EOF);
-	}
-
-	if (signature[2] == '\003' && signature[3] == '\004') {
-		/* Regular file entry. */
-		r1 = zip_read_file_header(a, entry, zip);
-		if (r1 != ARCHIVE_OK)
-			return (r1);
-		return (r);
-	}
-
-	if (signature[2] == '\005' && signature[3] == '\006') {
-		/* End-of-archive record. */
-		return (ARCHIVE_EOF);
-	}
-
-	if (signature[2] == '\007' && signature[3] == '\010') {
-		/*
-		 * We should never encounter this record here;
-		 * see ZIP_LENGTH_AT_END handling below for details.
-		 */
-		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
-		    "Bad ZIP file: Unexpected end-of-entry record");
-		return (ARCHIVE_FATAL);
-	}
-
-	archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
-	    "Damaged ZIP file or unsupported format variant (%d,%d)",
-	    signature[2], signature[3]);
-	return (ARCHIVE_FATAL);
-}
-
-static int
-search_next_signature(struct archive_read *a)
-{
-	const void *h;
-	const char *p, *q;
-	size_t skip;
-	ssize_t bytes;
-	int64_t skipped = 0;
-
-	for (;;) {
-		h = __archive_read_ahead(a, 4, &bytes);
-		if (h == NULL)
-			return (ARCHIVE_FATAL);
-		p = h;
-		q = p + bytes;
-
-		while (p + 4 <= q) {
-			if (p[0] == 'P' && p[1] == 'K') {
-				if ((p[2] == '\001' && p[3] == '\002')
-				    || (p[2] == '\003' && p[3] == '\004')
-				    || (p[2] == '\005' && p[3] == '\006')
-				    || (p[2] == '\007' && p[3] == '\010')
-				    || (p[2] == '0' && p[3] == '0')) {
-					skip = p - (const char *)h;
-					__archive_read_consume(a, skip);
-					return (ARCHIVE_OK);
-				}
-			}
-			++p;
-		}
-		skip = p - (const char *)h;
-		__archive_read_consume(a, skip);
-		skipped += skip;
-	}
-}
-
-static int
-zip_read_file_header(struct archive_read *a, struct archive_entry *entry,
-    struct zip *zip)
-{
-	const struct zip_file_header *p;
-	const void *h;
-
-	if ((p = __archive_read_ahead(a, sizeof *p, NULL)) == NULL) {
+	if ((p = __archive_read_ahead(a, 30, NULL)) == NULL) {
 		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
 		    "Truncated ZIP file header");
 		return (ARCHIVE_FATAL);
 	}
 
-	zip->version = p->version[0];
-	zip->system = p->version[1];
-	zip->flags = archive_le16dec(p->flags);
-	zip->compression = archive_le16dec(p->compression);
-	if (zip->compression <
-	    sizeof(compression_names)/sizeof(compression_names[0]))
-		zip->compression_name = compression_names[zip->compression];
-	else
-		zip->compression_name = "??";
-	zip->mtime = zip_time(p->timedate);
-	zip->ctime = 0;
-	zip->atime = 0;
-	zip->mode = 0;
-	zip->uid = 0;
-	zip->gid = 0;
-	zip->crc32 = archive_le32dec(p->crc32);
-	zip->filename_length = archive_le16dec(p->filename_length);
-	zip->extra_length = archive_le16dec(p->extra_length);
-	zip->uncompressed_size = archive_le32dec(p->uncompressed_size);
-	zip->compressed_size = archive_le32dec(p->compressed_size);
+	if (memcmp(p, "PK\003\004", 4) != 0) {
+		archive_set_error(&a->archive, -1, "Damaged Zip archive");
+		return ARCHIVE_FATAL;
+	}
+	version = p[4];
+	zip_entry->system = p[5];
+	zip_entry->flags = archive_le16dec(p + 6);
+	zip_entry->compression = archive_le16dec(p + 8);
+	zip_entry->mtime = zip_time(p + 10);
+	local_crc32 = archive_le32dec(p + 14);
+	compressed_size = archive_le32dec(p + 18);
+	uncompressed_size = archive_le32dec(p + 22);
+	filename_length = archive_le16dec(p + 26);
+	extra_length = archive_le16dec(p + 28);
 
-	__archive_read_consume(a, sizeof(struct zip_file_header));
+	__archive_read_consume(a, 30);
 
+	if (zip->have_central_directory) {
+		/* If we read the central dir entry, we must have size information
+		   as well, so ignore the length-at-end flag. */
+		zip_entry->flags &= ~ZIP_LENGTH_AT_END;
+		/* If we have values from both the local file header
+		   and the central directory, warn about mismatches
+		   which might indicate a damaged file.  But some
+		   writers always put zero in the local header; don't
+		   bother warning about that. */
+		if (local_crc32 != 0 && local_crc32 != zip_entry->crc32) {
+			archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+			    "Inconsistent CRC32 values");
+			ret = ARCHIVE_WARN;
+		}
+		if (compressed_size != 0
+		    && compressed_size != zip_entry->compressed_size) {
+			archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+			    "Inconsistent compressed size");
+			ret = ARCHIVE_WARN;
+		}
+		if (uncompressed_size != 0
+		    && uncompressed_size != zip_entry->uncompressed_size) {
+			archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+			    "Inconsistent uncompressed size");
+			ret = ARCHIVE_WARN;
+		}
+	} else {
+		/* If we don't have the CD info, use whatever we do have. */
+		zip_entry->crc32 = local_crc32;
+		zip_entry->compressed_size = compressed_size;
+		zip_entry->uncompressed_size = uncompressed_size;
+	}
 
 	/* Read the filename. */
-	if ((h = __archive_read_ahead(a, zip->filename_length, NULL)) == NULL) {
+	if ((h = __archive_read_ahead(a, filename_length, NULL)) == NULL) {
 		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
 		    "Truncated ZIP file header");
 		return (ARCHIVE_FATAL);
 	}
-	if (archive_string_ensure(&zip->pathname, zip->filename_length) == NULL)
-		__archive_errx(1, "Out of memory");
-	archive_strncpy(&zip->pathname, h, zip->filename_length);
-	__archive_read_consume(a, zip->filename_length);
-	archive_entry_set_pathname(entry, zip->pathname.s);
+	if (zip_entry->flags & ZIP_UTF8_NAME) {
+		/* The filename is stored to be UTF-8. */
+		if (zip->sconv_utf8 == NULL) {
+			zip->sconv_utf8 =
+			    archive_string_conversion_from_charset(
+				&a->archive, "UTF-8", 1);
+			if (zip->sconv_utf8 == NULL)
+				return (ARCHIVE_FATAL);
+		}
+		sconv = zip->sconv_utf8;
+	} else if (zip->sconv != NULL)
+		sconv = zip->sconv;
+	else
+		sconv = zip->sconv_default;
 
-	if (zip->pathname.s[archive_strlen(&zip->pathname) - 1] == '/')
-		zip->mode = AE_IFDIR | 0777;
-	else
-		zip->mode = AE_IFREG | 0777;
+	if (archive_entry_copy_pathname_l(entry,
+	    h, filename_length, sconv) != 0) {
+		if (errno == ENOMEM) {
+			archive_set_error(&a->archive, ENOMEM,
+			    "Can't allocate memory for Pathname");
+			return (ARCHIVE_FATAL);
+		}
+		archive_set_error(&a->archive,
+		    ARCHIVE_ERRNO_FILE_FORMAT,
+		    "Pathname cannot be converted "
+		    "from %s to current locale.",
+		    archive_string_conversion_charset_name(sconv));
+		ret = ARCHIVE_WARN;
+	}
+	__archive_read_consume(a, filename_length);
+
+	if (zip_entry->mode == 0) {
+		/* Especially in streaming mode, we can end up
+		   here without having seen any mode information.
+		   Guess from the filename. */
+		wp = archive_entry_pathname_w(entry);
+		if (wp != NULL) {
+			len = wcslen(wp);
+			if (len > 0 && wp[len - 1] == L'/')
+				zip_entry->mode = AE_IFDIR | 0777;
+			else
+				zip_entry->mode = AE_IFREG | 0777;
+		} else {
+			cp = archive_entry_pathname(entry);
+			len = (cp != NULL)?strlen(cp):0;
+			if (len > 0 && cp[len - 1] == '/')
+				zip_entry->mode = AE_IFDIR | 0777;
+			else
+				zip_entry->mode = AE_IFREG | 0777;
+		}
+	}
 
 	/* Read the extra data. */
-	if ((h = __archive_read_ahead(a, zip->extra_length, NULL)) == NULL) {
+	if ((h = __archive_read_ahead(a, extra_length, NULL)) == NULL) {
 		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
 		    "Truncated ZIP file header");
 		return (ARCHIVE_FATAL);
 	}
-	process_extra(h, zip);
-	__archive_read_consume(a, zip->extra_length);
+	process_extra(h, extra_length, zip_entry);
+	__archive_read_consume(a, extra_length);
 
 	/* Populate some additional entry fields: */
-	archive_entry_set_mode(entry, zip->mode);
-	archive_entry_set_uid(entry, zip->uid);
-	archive_entry_set_gid(entry, zip->gid);
-	archive_entry_set_mtime(entry, zip->mtime, 0);
-	archive_entry_set_ctime(entry, zip->ctime, 0);
-	archive_entry_set_atime(entry, zip->atime, 0);
+	archive_entry_set_mode(entry, zip_entry->mode);
+	archive_entry_set_uid(entry, zip_entry->uid);
+	archive_entry_set_gid(entry, zip_entry->gid);
+	archive_entry_set_mtime(entry, zip_entry->mtime, 0);
+	archive_entry_set_ctime(entry, zip_entry->ctime, 0);
+	archive_entry_set_atime(entry, zip_entry->atime, 0);
 	/* Set the size only if it's meaningful. */
-	if (0 == (zip->flags & ZIP_LENGTH_AT_END))
-		archive_entry_set_size(entry, zip->uncompressed_size);
+	if (0 == (zip_entry->flags & ZIP_LENGTH_AT_END))
+		archive_entry_set_size(entry, zip_entry->uncompressed_size);
 
-	zip->entry_bytes_remaining = zip->compressed_size;
-	zip->entry_offset = 0;
+	zip->entry_bytes_remaining = zip_entry->compressed_size;
 
 	/* If there's no body, force read_data() to return EOF immediately. */
-	if (0 == (zip->flags & ZIP_LENGTH_AT_END)
+	if (0 == (zip_entry->flags & ZIP_LENGTH_AT_END)
 	    && zip->entry_bytes_remaining < 1)
 		zip->end_of_entry = 1;
 
 	/* Set up a more descriptive format name. */
 	sprintf(zip->format_name, "ZIP %d.%d (%s)",
-	    zip->version / 10, zip->version % 10,
-	    zip->compression_name);
+	    version / 10, version % 10,
+	    compression_name(zip->entry->compression));
 	a->archive.archive_format_name = zip->format_name;
 
-	return (ARCHIVE_OK);
+	return (ret);
+}
+
+static const char *
+compression_name(int compression)
+{
+	static const char *compression_names[] = {
+		"uncompressed",
+		"shrinking",
+		"reduced-1",
+		"reduced-2",
+		"reduced-3",
+		"reduced-4",
+		"imploded",
+		"reserved",
+		"deflation"
+	};
+
+	if (0 <= compression && compression <
+	    (int)(sizeof(compression_names)/sizeof(compression_names[0])))
+		return compression_names[compression];
+	else
+		return "??";
 }
 
 /* Convert an MSDOS-style date/time into Unix-style time. */
@@ -532,52 +751,49 @@
 
 static int
 archive_read_format_zip_read_data(struct archive_read *a,
-    const void **buff, size_t *size, off_t *offset)
+    const void **buff, size_t *size, int64_t *offset)
 {
 	int r;
-	struct zip *zip;
+	struct zip *zip = (struct zip *)(a->format->data);
 
-	zip = (struct zip *)(a->format->data);
+	*offset = zip->entry_uncompressed_bytes_read;
+	*size = 0;
+	*buff = NULL;
 
-	/*
-	 * If we hit end-of-entry last time, clean up and return
-	 * ARCHIVE_EOF this time.
-	 */
-	if (zip->end_of_entry) {
-		*offset = zip->entry_uncompressed_bytes_read;
-		*size = 0;
-		*buff = NULL;
+	/* If we hit end-of-entry last time, return ARCHIVE_EOF. */
+	if (zip->end_of_entry)
 		return (ARCHIVE_EOF);
+
+	/* Return EOF immediately if this is a non-regular file. */
+	if (AE_IFREG != (zip->entry->mode & AE_IFMT))
+		return (ARCHIVE_EOF);
+
+	if (zip->entry->flags & (ZIP_ENCRYPTED | ZIP_STRONG_ENCRYPTED)) {
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+		    "Encrypted file is unsupported");
+		return (ARCHIVE_FAILED);
 	}
 
-	switch(zip->compression) {
+	__archive_read_consume(a, zip->unconsumed);
+	zip->unconsumed = 0;
+
+	switch(zip->entry->compression) {
 	case 0:  /* No compression. */
 		r =  zip_read_data_none(a, buff, size, offset);
 		break;
+#ifdef HAVE_ZLIB_H
 	case 8: /* Deflate compression. */
 		r =  zip_read_data_deflate(a, buff, size, offset);
 		break;
+#endif
 	default: /* Unsupported compression. */
-		*buff = NULL;
-		*size = 0;
-		*offset = 0;
 		/* Return a warning. */
 		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
 		    "Unsupported ZIP compression method (%s)",
-		    zip->compression_name);
-		if (zip->flags & ZIP_LENGTH_AT_END) {
-			/*
-			 * ZIP_LENGTH_AT_END requires us to
-			 * decompress the entry in order to
-			 * skip it, but we don't know this
-			 * compression method, so we give up.
-			 */
-			r = ARCHIVE_FATAL;
-		} else {
-			/* We can't decompress this entry, but we will
-			 * be able to skip() it and try the next entry. */
-			r = ARCHIVE_WARN;
-		}
+		    compression_name(zip->entry->compression));
+		/* We can't decompress this entry, but we will
+		 * be able to skip() it and try the next entry. */
+		return (ARCHIVE_FAILED);
 		break;
 	}
 	if (r != ARCHIVE_OK)
@@ -587,116 +803,157 @@
 		zip->entry_crc32 = crc32(zip->entry_crc32, *buff, *size);
 	/* If we hit the end, swallow any end-of-data marker. */
 	if (zip->end_of_entry) {
-		if (zip->flags & ZIP_LENGTH_AT_END) {
-			const char *p;
-
-			if ((p = __archive_read_ahead(a, 16, NULL)) == NULL) {
-				archive_set_error(&a->archive,
-				    ARCHIVE_ERRNO_FILE_FORMAT,
-				    "Truncated ZIP end-of-file record");
-				return (ARCHIVE_FATAL);
-			}
-			zip->crc32 = archive_le32dec(p + 4);
-			zip->compressed_size = archive_le32dec(p + 8);
-			zip->uncompressed_size = archive_le32dec(p + 12);
-			__archive_read_consume(a, 16);
-		}
 		/* Check file size, CRC against these values. */
-		if (zip->compressed_size != zip->entry_compressed_bytes_read) {
+		if (zip->entry->compressed_size != zip->entry_compressed_bytes_read) {
 			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
-			    "ZIP compressed data is wrong size");
+			    "ZIP compressed data is wrong size (read %jd, expected %jd)",
+			    (intmax_t)zip->entry_compressed_bytes_read,
+			    (intmax_t)zip->entry->compressed_size);
 			return (ARCHIVE_WARN);
 		}
-		/* Size field only stores the lower 32 bits of the actual size. */
-		if ((zip->uncompressed_size & UINT32_MAX)
+		/* Size field only stores the lower 32 bits of the actual
+		 * size. */
+		if ((zip->entry->uncompressed_size & UINT32_MAX)
 		    != (zip->entry_uncompressed_bytes_read & UINT32_MAX)) {
 			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
-			    "ZIP uncompressed data is wrong size");
+			    "ZIP uncompressed data is wrong size (read %jd, expected %jd)",
+			    (intmax_t)zip->entry_uncompressed_bytes_read,
+			    (intmax_t)zip->entry->uncompressed_size);
 			return (ARCHIVE_WARN);
 		}
 		/* Check computed CRC against header */
-		if (zip->crc32 != zip->entry_crc32) {
+		if (zip->entry->crc32 != zip->entry_crc32) {
 			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
 			    "ZIP bad CRC: 0x%lx should be 0x%lx",
-			    zip->entry_crc32, zip->crc32);
+			    (unsigned long)zip->entry_crc32,
+			    (unsigned long)zip->entry->crc32);
 			return (ARCHIVE_WARN);
 		}
 	}
 
-	/* Return EOF immediately if this is a non-regular file. */
-	if (AE_IFREG != (zip->mode & AE_IFMT))
-		return (ARCHIVE_EOF);
 	return (ARCHIVE_OK);
 }
 
 /*
- * Read "uncompressed" data.  According to the current specification,
- * if ZIP_LENGTH_AT_END is specified, then the size fields in the
- * initial file header are supposed to be set to zero.  This would, of
- * course, make it impossible for us to read the archive, since we
- * couldn't determine the end of the file data.  Info-ZIP seems to
- * include the real size fields both before and after the data in this
- * case (the CRC only appears afterwards), so this works as you would
- * expect.
+ * Read "uncompressed" data.  There are three cases:
+ *  1) We know the size of the data.  This is always true for the
+ * seeking reader (we've examined the Central Directory already).
+ *  2) ZIP_LENGTH_AT_END was set, but only the CRC was deferred.
+ * Info-ZIP seems to do this; we know the size but have to grab
+ * the CRC from the data descriptor afterwards.
+ *  3) We're streaming and ZIP_LENGTH_AT_END was specified and
+ * we have no size information.  In this case, we can do pretty
+ * well by watching for the data descriptor record.  The data
+ * descriptor is 16 bytes and includes a computed CRC that should
+ * provide a strong check.
+ *
+ * TODO: Technically, the PK\007\010 signature is optional.
+ * In the original spec, the data descriptor contained CRC
+ * and size fields but had no leading signature.  In practice,
+ * newer writers seem to provide the signature pretty consistently,
+ * but we might need to do something more complex here if
+ * we want to handle older archives that lack that signature.
  *
  * Returns ARCHIVE_OK if successful, ARCHIVE_FATAL otherwise, sets
  * zip->end_of_entry if it consumes all of the data.
  */
 static int
-zip_read_data_none(struct archive_read *a, const void **buff,
-    size_t *size, off_t *offset)
+zip_read_data_none(struct archive_read *a, const void **_buff,
+    size_t *size, int64_t *offset)
 {
 	struct zip *zip;
+	const char *buff;
 	ssize_t bytes_avail;
 
+	(void)offset; /* UNUSED */
+
 	zip = (struct zip *)(a->format->data);
 
-	if (zip->entry_bytes_remaining == 0) {
-		*buff = NULL;
-		*size = 0;
-		*offset = zip->entry_offset;
-		zip->end_of_entry = 1;
-		return (ARCHIVE_OK);
+	if (zip->entry->flags & ZIP_LENGTH_AT_END) {
+		const char *p;
+
+		/* Grab at least 16 bytes. */
+		buff = __archive_read_ahead(a, 16, &bytes_avail);
+		if (bytes_avail < 16) {
+			/* Zip archives have end-of-archive markers
+			   that are longer than this, so a failure to get at
+			   least 16 bytes really does indicate a truncated
+			   file. */
+			archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+			    "Truncated ZIP file data");
+			return (ARCHIVE_FATAL);
+		}
+		/* Check for a complete PK\007\010 signature. */
+		p = buff;
+		if (p[0] == 'P' && p[1] == 'K' 
+		    && p[2] == '\007' && p[3] == '\010'
+		    && archive_le32dec(p + 4) == zip->entry_crc32
+		    && archive_le32dec(p + 8) == zip->entry_compressed_bytes_read
+		    && archive_le32dec(p + 12) == zip->entry_uncompressed_bytes_read) {
+			zip->entry->crc32 = archive_le32dec(p + 4);
+			zip->entry->compressed_size = archive_le32dec(p + 8);
+			zip->entry->uncompressed_size = archive_le32dec(p + 12);
+			zip->end_of_entry = 1;
+			zip->unconsumed = 16;
+			return (ARCHIVE_OK);
+		}
+		/* If not at EOF, ensure we consume at least one byte. */
+		++p;
+
+		/* Scan forward until we see where a PK\007\010 signature might be. */
+		/* Return bytes up until that point.  On the next call, the code
+		   above will verify the data descriptor. */
+		while (p < buff + bytes_avail - 4) {
+			if (p[3] == 'P') { p += 3; }
+			else if (p[3] == 'K') { p += 2; }
+			else if (p[3] == '\007') { p += 1; }
+			else if (p[3] == '\010' && p[2] == '\007'
+			    && p[1] == 'K' && p[0] == 'P') {
+				break;
+			} else { p += 4; }
+		}
+		bytes_avail = p - buff;
+	} else {
+		if (zip->entry_bytes_remaining == 0) {
+			zip->end_of_entry = 1;
+			return (ARCHIVE_OK);
+		}
+		/* Grab a bunch of bytes. */
+		buff = __archive_read_ahead(a, 1, &bytes_avail);
+		if (bytes_avail <= 0) {
+			archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+			    "Truncated ZIP file data");
+			return (ARCHIVE_FATAL);
+		}
+		if (bytes_avail > zip->entry_bytes_remaining)
+			bytes_avail = zip->entry_bytes_remaining;
 	}
-	/*
-	 * Note: '1' here is a performance optimization.
-	 * Recall that the decompression layer returns a count of
-	 * available bytes; asking for more than that forces the
-	 * decompressor to combine reads by copying data.
-	 */
-	*buff = __archive_read_ahead(a, 1, &bytes_avail);
-	if (bytes_avail <= 0) {
-		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
-		    "Truncated ZIP file data");
-		return (ARCHIVE_FATAL);
-	}
-	if (bytes_avail > zip->entry_bytes_remaining)
-		bytes_avail = zip->entry_bytes_remaining;
-	__archive_read_consume(a, bytes_avail);
 	*size = bytes_avail;
-	*offset = zip->entry_offset;
-	zip->entry_offset += *size;
-	zip->entry_bytes_remaining -= *size;
-	zip->entry_uncompressed_bytes_read += *size;
-	zip->entry_compressed_bytes_read += *size;
+	zip->entry_bytes_remaining -= bytes_avail;
+	zip->entry_uncompressed_bytes_read += bytes_avail;
+	zip->entry_compressed_bytes_read += bytes_avail;
+	zip->unconsumed += bytes_avail;
+	*_buff = buff;
 	return (ARCHIVE_OK);
 }
 
 #ifdef HAVE_ZLIB_H
 static int
 zip_read_data_deflate(struct archive_read *a, const void **buff,
-    size_t *size, off_t *offset)
+    size_t *size, int64_t *offset)
 {
 	struct zip *zip;
 	ssize_t bytes_avail;
 	const void *compressed_buff;
 	int r;
 
+	(void)offset; /* UNUSED */
+
 	zip = (struct zip *)(a->format->data);
 
 	/* If the buffer hasn't been allocated, allocate it now. */
 	if (zip->uncompressed_buffer == NULL) {
-		zip->uncompressed_buffer_size = 32 * 1024;
+		zip->uncompressed_buffer_size = 256 * 1024;
 		zip->uncompressed_buffer
 		    = (unsigned char *)malloc(zip->uncompressed_buffer_size);
 		if (zip->uncompressed_buffer == NULL) {
@@ -731,6 +988,10 @@
 	 * decompressor to combine reads by copying data.
 	 */
 	compressed_buff = __archive_read_ahead(a, 1, &bytes_avail);
+	if (0 == (zip->entry->flags & ZIP_LENGTH_AT_END)
+	    && bytes_avail > zip->entry_bytes_remaining) {
+		bytes_avail = zip->entry_bytes_remaining;
+	}
 	if (bytes_avail <= 0) {
 		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
 		    "Truncated ZIP file body");
@@ -773,66 +1034,102 @@
 	zip->entry_bytes_remaining -= bytes_avail;
 	zip->entry_compressed_bytes_read += bytes_avail;
 
-	*offset = zip->entry_offset;
 	*size = zip->stream.total_out;
-	zip->entry_uncompressed_bytes_read += *size;
+	zip->entry_uncompressed_bytes_read += zip->stream.total_out;
 	*buff = zip->uncompressed_buffer;
-	zip->entry_offset += *size;
+
+	if (zip->end_of_entry && (zip->entry->flags & ZIP_LENGTH_AT_END)) {
+		const char *p;
+
+		if (NULL == (p = __archive_read_ahead(a, 16, NULL))) {
+			archive_set_error(&a->archive,
+			    ARCHIVE_ERRNO_FILE_FORMAT,
+			    "Truncated ZIP end-of-file record");
+			return (ARCHIVE_FATAL);
+		}
+		/* Consume the optional PK\007\010 marker. */
+		if (p[0] == 'P' && p[1] == 'K' && p[2] == '\007' && p[3] == '\010') {
+			zip->entry->crc32 = archive_le32dec(p + 4);
+			zip->entry->compressed_size = archive_le32dec(p + 8);
+			zip->entry->uncompressed_size = archive_le32dec(p + 12);
+			zip->unconsumed = 16;
+		}
+	}
+
 	return (ARCHIVE_OK);
 }
-#else
-static int
-zip_read_data_deflate(struct archive_read *a, const void **buff,
-    size_t *size, off_t *offset)
-{
-	*buff = NULL;
-	*size = 0;
-	*offset = 0;
-	archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
-	    "libarchive compiled without deflate support (no libz)");
-	return (ARCHIVE_FATAL);
-}
 #endif
 
 static int
 archive_read_format_zip_read_data_skip(struct archive_read *a)
 {
 	struct zip *zip;
-	const void *buff = NULL;
-	off_t bytes_skipped;
 
 	zip = (struct zip *)(a->format->data);
 
 	/* If we've already read to end of data, we're done. */
 	if (zip->end_of_entry)
 		return (ARCHIVE_OK);
+	/* If we're seeking, we're done. */
+	if (zip->have_central_directory)
+		return (ARCHIVE_OK);
 
-	/*
-	 * If the length is at the end, we have no choice but
-	 * to decompress all the data to find the end marker.
-	 */
-	if (zip->flags & ZIP_LENGTH_AT_END) {
-		size_t size;
-		off_t offset;
-		int r;
-		do {
-			r = archive_read_format_zip_read_data(a, &buff,
-			    &size, &offset);
-		} while (r == ARCHIVE_OK);
-		return (r);
+	/* So we know we're streaming... */
+	if (0 == (zip->entry->flags & ZIP_LENGTH_AT_END)) {
+		/* We know the compressed length, so we can just skip. */
+		int64_t bytes_skipped = __archive_read_consume(a,
+		    zip->entry_bytes_remaining + zip->unconsumed);
+		if (bytes_skipped < 0)
+			return (ARCHIVE_FATAL);
+		zip->unconsumed = 0;
+		return (ARCHIVE_OK);
 	}
 
-	/*
-	 * If the length is at the beginning, we can skip the
-	 * compressed data much more quickly.
-	 */
-	bytes_skipped = __archive_read_skip(a, zip->entry_bytes_remaining);
-	if (bytes_skipped < 0)
-		return (ARCHIVE_FATAL);
-
-	/* This entry is finished and done. */
-	zip->end_of_entry = 1;
-	return (ARCHIVE_OK);
+	/* We're streaming and we don't know the length. */
+	/* If the body is compressed and we know the format, we can
+	 * find an exact end-of-entry by decompressing it. */
+	switch (zip->entry->compression) {
+#ifdef HAVE_ZLIB_H
+	case 8: /* Deflate compression. */
+		while (!zip->end_of_entry) {
+			int64_t offset = 0;
+			const void *buff = NULL;
+			size_t size = 0;
+			int r;
+			r =  zip_read_data_deflate(a, &buff, &size, &offset);
+			if (r != ARCHIVE_OK)
+				return (r);
+		}
+		break;
+#endif
+	default: /* Uncompressed or unknown. */
+		/* Scan for a PK\007\010 signature. */
+		__archive_read_consume(a, zip->unconsumed);
+		zip->unconsumed = 0;
+		for (;;) {
+			const char *p, *buff;
+			ssize_t bytes_avail;
+			buff = __archive_read_ahead(a, 16, &bytes_avail);
+			if (bytes_avail < 16) {
+				archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+				    "Truncated ZIP file data");
+				return (ARCHIVE_FATAL);
+			}
+			p = buff;
+			while (p <= buff + bytes_avail - 16) {
+				if (p[3] == 'P') { p += 3; }
+				else if (p[3] == 'K') { p += 2; }
+				else if (p[3] == '\007') { p += 1; }
+				else if (p[3] == '\010' && p[2] == '\007'
+				    && p[1] == 'K' && p[0] == 'P') {
+					__archive_read_consume(a, p - buff + 16);
+					return ARCHIVE_OK;
+				} else { p += 4; }
+			}
+			__archive_read_consume(a, p - buff);
+		}
+	}
+	return ARCHIVE_OK;
 }
 
 static int
@@ -845,8 +1142,8 @@
 	if (zip->stream_valid)
 		inflateEnd(&zip->stream);
 #endif
+	free(zip->zip_entries);
 	free(zip->uncompressed_buffer);
-	archive_string_free(&(zip->pathname));
 	archive_string_free(&(zip->extra));
 	free(zip);
 	(a->format->data) = NULL;
@@ -859,28 +1156,30 @@
  *  triplets.  id and size are 2 bytes each.
  */
 static void
-process_extra(const void* extra, struct zip* zip)
+process_extra(const char *p, size_t extra_length, struct zip_entry* zip_entry)
 {
-	int offset = 0;
-	const char *p = (const char *)extra;
-	while (offset < zip->extra_length - 4)
+	unsigned offset = 0;
+
+	while (offset < extra_length - 4)
 	{
 		unsigned short headerid = archive_le16dec(p + offset);
 		unsigned short datasize = archive_le16dec(p + offset + 2);
 		offset += 4;
-		if (offset + datasize > zip->extra_length)
+		if (offset + datasize > extra_length)
 			break;
 #ifdef DEBUG
-		fprintf(stderr, "Header id 0x%04x, length %d\n",
+		fprintf(stderr, "Header id 0x%x, length %d\n",
 		    headerid, datasize);
 #endif
 		switch (headerid) {
 		case 0x0001:
 			/* Zip64 extended information extra field. */
 			if (datasize >= 8)
-				zip->uncompressed_size = archive_le64dec(p + offset);
+				zip_entry->uncompressed_size =
+				    archive_le64dec(p + offset);
 			if (datasize >= 16)
-				zip->compressed_size = archive_le64dec(p + offset + 8);
+				zip_entry->compressed_size =
+				    archive_le64dec(p + offset + 8);
 			break;
 		case 0x5455:
 		{
@@ -893,12 +1192,12 @@
 			{
 #ifdef DEBUG
 				fprintf(stderr, "mtime: %lld -> %d\n",
-				    (long long)zip->mtime,
+				    (long long)zip_entry->mtime,
 				    archive_le32dec(p + offset));
 #endif
 				if (datasize < 4)
 					break;
-				zip->mtime = archive_le32dec(p + offset);
+				zip_entry->mtime = archive_le32dec(p + offset);
 				offset += 4;
 				datasize -= 4;
 			}
@@ -906,7 +1205,7 @@
 			{
 				if (datasize < 4)
 					break;
-				zip->atime = archive_le32dec(p + offset);
+				zip_entry->atime = archive_le32dec(p + offset);
 				offset += 4;
 				datasize -= 4;
 			}
@@ -914,12 +1213,25 @@
 			{
 				if (datasize < 4)
 					break;
-				zip->ctime = archive_le32dec(p + offset);
+				zip_entry->ctime = archive_le32dec(p + offset);
 				offset += 4;
 				datasize -= 4;
 			}
 			break;
 		}
+		case 0x5855:
+		{
+			/* Info-ZIP Unix Extra Field (old version) "UX". */
+			if (datasize >= 8) {
+				zip_entry->atime = archive_le32dec(p + offset);
+				zip_entry->mtime = archive_le32dec(p + offset + 4);
+			}
+			if (datasize >= 12) {
+				zip_entry->uid = archive_le16dec(p + offset + 8);
+				zip_entry->gid = archive_le16dec(p + offset + 10);
+			}
+			break;
+		}
 		case 0x7855:
 			/* Info-ZIP Unix Extra Field (type 2) "Ux". */
 #ifdef DEBUG
@@ -928,23 +1240,50 @@
 			    archive_le16dec(p + offset + 2));
 #endif
 			if (datasize >= 2)
-				zip->uid = archive_le16dec(p + offset);
+				zip_entry->uid = archive_le16dec(p + offset);
 			if (datasize >= 4)
-				zip->gid = archive_le16dec(p + offset + 2);
+				zip_entry->gid = archive_le16dec(p + offset + 2);
 			break;
 		case 0x7875:
+		{
 			/* Info-Zip Unix Extra Field (type 3) "ux". */
+			int uidsize = 0, gidsize = 0;
+
+			if (datasize >= 1 && p[offset] == 1) {/* version=1 */
+				if (datasize >= 4) {
+					/* get a uid size. */
+					uidsize = p[offset+1];
+					if (uidsize == 2)
+						zip_entry->uid = archive_le16dec(
+						     p + offset + 2);
+					else if (uidsize == 4 && datasize >= 6)
+						zip_entry->uid = archive_le32dec(
+						     p + offset + 2);
+				}
+				if (datasize >= (2 + uidsize + 3)) {
+					/* get a gid size. */
+					gidsize = p[offset+2+uidsize];
+					if (gidsize == 2)
+						zip_entry->gid = archive_le16dec(
+						    p+offset+2+uidsize+1);
+					else if (gidsize == 4 &&
+					    datasize >= (2 + uidsize + 5))
+						zip_entry->gid = archive_le32dec(
+						    p+offset+2+uidsize+1);
+				}
+			}
 			break;
+		}
 		default:
 			break;
 		}
 		offset += datasize;
 	}
 #ifdef DEBUG
-	if (offset != zip->extra_length)
+	if (offset != extra_length)
 	{
 		fprintf(stderr,
-		    "Extra data field contents do not match reported size!");
+		    "Extra data field contents do not match reported size!\n");
 	}
 #endif
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_string.c
--- a/head/contrib/libarchive/libarchive/archive_string.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_string.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,6 @@
 /*-
- * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2003-2011 Tim Kientzle
+ * Copyright (c) 2011-2012 Michihiro NAKAJIMA
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -24,13 +25,29 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_string.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_string.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * Basic resizable string support, to simplify manipulating arbitrary-sized
  * strings while minimizing heap activity.
+ *
+ * In particular, the buffer used by a string object is only grown, it
+ * never shrinks, so you can clear and reuse the same string object
+ * without incurring additional memory allocations.
  */
 
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#ifdef HAVE_ICONV_H
+#include <iconv.h>
+#endif
+#ifdef HAVE_LANGINFO_H
+#include <langinfo.h>
+#endif
+#ifdef HAVE_LOCALCHARSET_H
+#include <localcharset.h>
+#endif
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
@@ -42,63 +59,224 @@
 #endif
 #if defined(_WIN32) && !defined(__CYGWIN__)
 #include <windows.h>
+#include <locale.h>
 #endif
-
+#if defined(__APPLE__)
+#include <CoreServices/CoreServices.h>
+#endif
+
+#include "archive_endian.h"
 #include "archive_private.h"
 #include "archive_string.h"
-
-struct archive_string *
-__archive_string_append(struct archive_string *as, const char *p, size_t s)
+#include "archive_string_composition.h"
+
+#if !defined(HAVE_WMEMCPY) && !defined(wmemcpy)
+#define wmemcpy(a,b,i)  (wchar_t *)memcpy((a), (b), (i) * sizeof(wchar_t))
+#endif
+
+struct archive_string_conv {
+	struct archive_string_conv	*next;
+	char				*from_charset;
+	char				*to_charset;
+	unsigned			 from_cp;
+	unsigned			 to_cp;
+	/* Set 1 if from_charset and to_charset are the same. */
+	int				 same;
+	int				 flag;
+#define SCONV_TO_CHARSET	1	/* MBS is being converted to specified
+					 * charset. */
+#define SCONV_FROM_CHARSET	(1<<1)	/* MBS is being converted from
+					 * specified charset. */
+#define SCONV_BEST_EFFORT 	(1<<2)	/* Copy at least ASCII code. */
+#define SCONV_WIN_CP	 	(1<<3)	/* Use Windows API for converting
+					 * MBS. */
+#define SCONV_UTF8_LIBARCHIVE_2 (1<<4)	/* Incorrect UTF-8 made by libarchive
+					 * 2.x in the wrong assumption. */
+#define SCONV_NORMALIZATION_C	(1<<6)	/* Need normalization to be Form C.
+					 * Before UTF-8 characters are actually
+					 * processed. */
+#define SCONV_NORMALIZATION_D	(1<<7)	/* Need normalization to be Form D.
+					 * Before UTF-8 characters are actually
+					 * processed.
+					 * Currently this only for MAC OS X. */
+#define SCONV_TO_UTF8		(1<<8)	/* "to charset" side is UTF-8. */
+#define SCONV_FROM_UTF8		(1<<9)	/* "from charset" side is UTF-8. */
+#define SCONV_TO_UTF16BE 	(1<<10)	/* "to charset" side is UTF-16BE. */
+#define SCONV_FROM_UTF16BE 	(1<<11)	/* "from charset" side is UTF-16BE. */
+#define SCONV_TO_UTF16LE 	(1<<12)	/* "to charset" side is UTF-16LE. */
+#define SCONV_FROM_UTF16LE 	(1<<13)	/* "from charset" side is UTF-16LE. */
+#define SCONV_TO_UTF16		(SCONV_TO_UTF16BE | SCONV_TO_UTF16LE)
+#define SCONV_FROM_UTF16	(SCONV_FROM_UTF16BE | SCONV_FROM_UTF16LE)
+
+#if HAVE_ICONV
+	iconv_t				 cd;
+	iconv_t				 cd_w;/* Use at archive_mstring on
+				 	       * Windows. */
+#endif
+	/* A temporary buffer for normalization. */
+	struct archive_string		 utftmp;
+#if defined(__APPLE__)
+	UnicodeToTextInfo		 uniInfo;
+	struct archive_string		 utf16nfc;
+	struct archive_string		 utf16nfd;
+#endif
+	int (*converter[2])(struct archive_string *, const void *, size_t,
+	    struct archive_string_conv *);
+	int				 nconverter;
+};
+
+#define CP_C_LOCALE	0	/* "C" locale only for this file. */
+#define CP_UTF16LE	1200
+#define CP_UTF16BE	1201
+
+#define IS_HIGH_SURROGATE_LA(uc) ((uc) >= 0xD800 && (uc) <= 0xDBFF)
+#define IS_LOW_SURROGATE_LA(uc)	 ((uc) >= 0xDC00 && (uc) <= 0xDFFF)
+#define IS_SURROGATE_PAIR_LA(uc) ((uc) >= 0xD800 && (uc) <= 0xDFFF)
+#define UNICODE_MAX		0x10FFFF
+#define UNICODE_R_CHAR		0xFFFD	/* Replacement character. */
+/* Set U+FFFD(Replacement character) in UTF-8. */
+#define UTF8_SET_R_CHAR(outp) do {		\
+			(outp)[0] = 0xef;	\
+			(outp)[1] = 0xbf;	\
+			(outp)[2] = 0xbd;	\
+} while (0)
+#define UTF8_R_CHAR_SIZE	3
+
+static struct archive_string_conv *find_sconv_object(struct archive *,
+	const char *, const char *);
+static void add_sconv_object(struct archive *, struct archive_string_conv *);
+static struct archive_string_conv *create_sconv_object(const char *,
+	const char *, unsigned, int);
+static void free_sconv_object(struct archive_string_conv *);
+static struct archive_string_conv *get_sconv_object(struct archive *,
+	const char *, const char *, int);
+static unsigned make_codepage_from_charset(const char *);
+static unsigned get_current_codepage(void);
+static unsigned get_current_oemcp(void);
+static size_t mbsnbytes(const void *, size_t);
+static size_t utf16nbytes(const void *, size_t);
+#if defined(_WIN32) && !defined(__CYGWIN__)
+static int archive_wstring_append_from_mbs_in_codepage(
+    struct archive_wstring *, const char *, size_t,
+    struct archive_string_conv *);
+static int archive_string_append_from_wcs_in_codepage(struct archive_string *,
+    const wchar_t *, size_t, struct archive_string_conv *);
+static int is_big_endian(void);
+static int strncat_in_codepage(struct archive_string *, const void *,
+    size_t, struct archive_string_conv *);
+static int win_strncat_from_utf16be(struct archive_string *, const void *, size_t,
+    struct archive_string_conv *);
+static int win_strncat_from_utf16le(struct archive_string *, const void *, size_t,
+    struct archive_string_conv *);
+static int win_strncat_to_utf16be(struct archive_string *, const void *, size_t,
+    struct archive_string_conv *);
+static int win_strncat_to_utf16le(struct archive_string *, const void *, size_t,
+    struct archive_string_conv *);
+#endif
+static int best_effort_strncat_from_utf16be(struct archive_string *, const void *,
+    size_t, struct archive_string_conv *);
+static int best_effort_strncat_from_utf16le(struct archive_string *, const void *,
+    size_t, struct archive_string_conv *);
+static int best_effort_strncat_to_utf16be(struct archive_string *, const void *,
+    size_t, struct archive_string_conv *);
+static int best_effort_strncat_to_utf16le(struct archive_string *, const void *,
+    size_t, struct archive_string_conv *);
+#if defined(HAVE_ICONV)
+static int iconv_strncat_in_locale(struct archive_string *, const void *,
+    size_t, struct archive_string_conv *);
+#endif
+static int best_effort_strncat_in_locale(struct archive_string *, const void *,
+    size_t, struct archive_string_conv *);
+static int _utf8_to_unicode(uint32_t *, const char *, size_t);
+static int utf8_to_unicode(uint32_t *, const char *, size_t);
+static inline uint32_t combine_surrogate_pair(uint32_t, uint32_t);
+static int cesu8_to_unicode(uint32_t *, const char *, size_t);
+static size_t unicode_to_utf8(char *, size_t, uint32_t);
+static int utf16_to_unicode(uint32_t *, const char *, size_t, int);
+static size_t unicode_to_utf16be(char *, size_t, uint32_t);
+static size_t unicode_to_utf16le(char *, size_t, uint32_t);
+static int strncat_from_utf8_libarchive2(struct archive_string *,
+    const void *, size_t, struct archive_string_conv *);
+static int strncat_from_utf8_to_utf8(struct archive_string *, const void *,
+    size_t, struct archive_string_conv *);
+static int archive_string_normalize_C(struct archive_string *, const void *,
+    size_t, struct archive_string_conv *);
+#if defined(__APPLE__)
+static int archive_string_normalize_D(struct archive_string *, const void *,
+    size_t, struct archive_string_conv *);
+#endif
+static int archive_string_append_unicode(struct archive_string *,
+    const void *, size_t, struct archive_string_conv *);
+
+static struct archive_string *
+archive_string_append(struct archive_string *as, const char *p, size_t s)
 {
-	if (__archive_string_ensure(as, as->length + s + 1) == NULL)
-		__archive_errx(1, "Out of memory");
+	if (archive_string_ensure(as, as->length + s + 1) == NULL)
+		return (NULL);
 	memcpy(as->s + as->length, p, s);
-	as->s[as->length + s] = 0;
 	as->length += s;
+	as->s[as->length] = 0;
 	return (as);
 }
 
+static struct archive_wstring *
+archive_wstring_append(struct archive_wstring *as, const wchar_t *p, size_t s)
+{
+	if (archive_wstring_ensure(as, as->length + s + 1) == NULL)
+		return (NULL);
+	wmemcpy(as->s + as->length, p, s);
+	as->length += s;
+	as->s[as->length] = 0;
+	return (as);
+}
+
 void
-__archive_string_copy(struct archive_string *dest, struct archive_string *src)
+archive_string_concat(struct archive_string *dest, struct archive_string *src)
 {
-	if (src->length == 0)
-		dest->length = 0;
-	else {
-		if (__archive_string_ensure(dest, src->length + 1) == NULL)
-			__archive_errx(1, "Out of memory");
-		memcpy(dest->s, src->s, src->length);
-		dest->length = src->length;
-		dest->s[dest->length] = 0;
-	}
+	if (archive_string_append(dest, src->s, src->length) == NULL)
+		__archive_errx(1, "Out of memory");
 }
 
 void
-__archive_string_concat(struct archive_string *dest, struct archive_string *src)
+archive_wstring_concat(struct archive_wstring *dest, struct archive_wstring *src)
 {
-	if (src->length > 0) {
-		if (__archive_string_ensure(dest, dest->length + src->length + 1) == NULL)
-			__archive_errx(1, "Out of memory");
-		memcpy(dest->s + dest->length, src->s, src->length);
-		dest->length += src->length;
-		dest->s[dest->length] = 0;
-	}
+	if (archive_wstring_append(dest, src->s, src->length) == NULL)
+		__archive_errx(1, "Out of memory");
 }
 
 void
-__archive_string_free(struct archive_string *as)
+archive_string_free(struct archive_string *as)
 {
 	as->length = 0;
 	as->buffer_length = 0;
-	if (as->s != NULL) {
-		free(as->s);
-		as->s = NULL;
-	}
+	free(as->s);
+	as->s = NULL;
+}
+
+void
+archive_wstring_free(struct archive_wstring *as)
+{
+	as->length = 0;
+	as->buffer_length = 0;
+	free(as->s);
+	as->s = NULL;
+}
+
+struct archive_wstring *
+archive_wstring_ensure(struct archive_wstring *as, size_t s)
+{
+	return (struct archive_wstring *)
+		archive_string_ensure((struct archive_string *)as,
+					s * sizeof(wchar_t));
 }
 
 /* Returns NULL on any allocation failure. */
 struct archive_string *
-__archive_string_ensure(struct archive_string *as, size_t s)
+archive_string_ensure(struct archive_string *as, size_t s)
 {
+	char *p;
+	size_t new_length;
+
 	/* If buffer is already big enough, don't reallocate. */
 	if (as->s && (s <= as->buffer_length))
 		return (as);
@@ -112,18 +290,18 @@
 	 */
 	if (as->buffer_length < 32)
 		/* Start with a minimum 32-character buffer. */
-		as->buffer_length = 32;
+		new_length = 32;
 	else if (as->buffer_length < 8192)
 		/* Buffers under 8k are doubled for speed. */
-		as->buffer_length += as->buffer_length;
+		new_length = as->buffer_length + as->buffer_length;
 	else {
 		/* Buffers 8k and over grow by at least 25% each time. */
-		size_t old_length = as->buffer_length;
-		as->buffer_length += as->buffer_length / 4;
-		/* Be safe: If size wraps, release buffer and return NULL. */
-		if (as->buffer_length < old_length) {
-			free(as->s);
-			as->s = NULL;
+		new_length = as->buffer_length + as->buffer_length / 4;
+		/* Be safe: If size wraps, fail. */
+		if (new_length < as->buffer_length) {
+			/* On failure, wipe the string and return NULL. */
+			archive_string_free(as);
+			errno = ENOMEM;/* Make sure errno has ENOMEM. */
 			return (NULL);
 		}
 	}
@@ -132,17 +310,31 @@
 	 * grow the buffer.  In any case, we have to grow it enough to
 	 * hold the request.
 	 */
-	if (as->buffer_length < s)
-		as->buffer_length = s;
+	if (new_length < s)
+		new_length = s;
 	/* Now we can reallocate the buffer. */
-	as->s = (char *)realloc(as->s, as->buffer_length);
-	if (as->s == NULL)
+	p = (char *)realloc(as->s, new_length);
+	if (p == NULL) {
+		/* On failure, wipe the string and return NULL. */
+		archive_string_free(as);
+		errno = ENOMEM;/* Make sure errno has ENOMEM. */
 		return (NULL);
+	}
+
+	as->s = p;
+	as->buffer_length = new_length;
 	return (as);
 }
 
+/*
+ * TODO: See if there's a way to avoid scanning
+ * the source string twice.  Then test to see
+ * if it actually helps (remember that we're almost
+ * always called with pretty short arguments, so
+ * such an optimization might not help).
+ */
 struct archive_string *
-__archive_strncat(struct archive_string *as, const void *_p, size_t n)
+archive_strncat(struct archive_string *as, const void *_p, size_t n)
 {
 	size_t s;
 	const char *p, *pp;
@@ -156,263 +348,537 @@
 		pp++;
 		s++;
 	}
-	return (__archive_string_append(as, p, s));
+	if ((as = archive_string_append(as, p, s)) == NULL)
+		__archive_errx(1, "Out of memory");
+	return (as);
 }
 
+struct archive_wstring *
+archive_wstrncat(struct archive_wstring *as, const wchar_t *p, size_t n)
+{
+	size_t s;
+	const wchar_t *pp;
+
+	/* Like strlen(p), except won't examine positions beyond p[n]. */
+	s = 0;
+	pp = p;
+	while (s < n && *pp) {
+		pp++;
+		s++;
+	}
+	if ((as = archive_wstring_append(as, p, s)) == NULL)
+		__archive_errx(1, "Out of memory");
+	return (as);
+}
+
 struct archive_string *
-__archive_strappend_char(struct archive_string *as, char c)
+archive_strcat(struct archive_string *as, const void *p)
 {
-	return (__archive_string_append(as, &c, 1));
+	/* strcat is just strncat without an effective limit. 
+	 * Assert that we'll never get called with a source
+	 * string over 16MB.
+	 * TODO: Review all uses of strcat in the source
+	 * and try to replace them with strncat().
+	 */
+	return archive_strncat(as, p, 0x1000000);
 }
 
+struct archive_wstring *
+archive_wstrcat(struct archive_wstring *as, const wchar_t *p)
+{
+	/* Ditto. */
+	return archive_wstrncat(as, p, 0x1000000);
+}
+
+struct archive_string *
+archive_strappend_char(struct archive_string *as, char c)
+{
+	if ((as = archive_string_append(as, &c, 1)) == NULL)
+		__archive_errx(1, "Out of memory");
+	return (as);
+}
+
+struct archive_wstring *
+archive_wstrappend_wchar(struct archive_wstring *as, wchar_t c)
+{
+	if ((as = archive_wstring_append(as, &c, 1)) == NULL)
+		__archive_errx(1, "Out of memory");
+	return (as);
+}
+
 /*
- * Translates a wide character string into UTF-8 and appends
- * to the archive_string.  Note: returns NULL if conversion fails,
- * but still leaves a best-effort conversion in the argument as.
+ * Get the "current character set" name to use with iconv.
+ * On FreeBSD, the empty character set name "" chooses
+ * the correct character encoding for the current locale,
+ * so this isn't necessary.
+ * But iconv on Mac OS 10.6 doesn't seem to handle this correctly;
+ * on that system, we have to explicitly call nl_langinfo()
+ * to get the right name.  Not sure about other platforms.
+ *
+ * NOTE: GNU libiconv does not recognize the character-set name
+ * which some platform nl_langinfo(CODESET) returns, so we should
+ * use locale_charset() instead of nl_langinfo(CODESET) for GNU libiconv.
  */
-struct archive_string *
-__archive_strappend_w_utf8(struct archive_string *as, const wchar_t *w)
+static const char *
+default_iconv_charset(const char *charset) {
+	if (charset != NULL && charset[0] != '\0')
+		return charset;
+#if HAVE_LOCALE_CHARSET && !defined(__APPLE__)
+	/* locale_charset() is broken on Mac OS */
+	return locale_charset();
+#elif HAVE_NL_LANGINFO
+	return nl_langinfo(CODESET);
+#else
+	return "";
+#endif
+}
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+
+/*
+ * Convert MBS to WCS.
+ * Note: returns -1 if conversion fails.
+ */
+int
+archive_wstring_append_from_mbs(struct archive_wstring *dest,
+    const char *p, size_t len)
 {
-	char *p;
-	unsigned wc;
-	char buff[256];
-	struct archive_string *return_val = as;
-
+	int r = archive_wstring_append_from_mbs_in_codepage(dest, p, len, NULL);
+	if (r != 0 && errno == ENOMEM)
+		__archive_errx(1, "No memory");
+	return (r);
+}
+
+static int
+archive_wstring_append_from_mbs_in_codepage(struct archive_wstring *dest,
+    const char *s, size_t length, struct archive_string_conv *sc)
+{
+	int count, ret = 0;
+	UINT from_cp;
+
+	if (sc != NULL)
+		from_cp = sc->from_cp;
+	else
+		from_cp = get_current_codepage();
+
+	if (from_cp == CP_C_LOCALE) {
+		/*
+		 * "C" locale special process.
+		 */
+		wchar_t *ws;
+		const unsigned char *mp;
+
+		if (NULL == archive_wstring_ensure(dest,
+		    dest->length + length + 1))
+			return (-1);
+
+		ws = dest->s + dest->length;
+		mp = (const unsigned char *)s;
+		count = 0;
+		while (count < (int)length && *mp) {
+			*ws++ = (wchar_t)*mp++;
+			count++;
+		}
+	} else if (sc != NULL && (sc->flag & SCONV_NORMALIZATION_C)) {
+		/*
+		 * Normalize UTF-8 and UTF-16BE and convert it directly
+		 * to UTF-16 as wchar_t.
+		 */
+		struct archive_string u16;
+		int saved_flag = sc->flag;/* save current flag. */
+
+		if (is_big_endian())
+			sc->flag |= SCONV_TO_UTF16BE;
+		else
+			sc->flag |= SCONV_TO_UTF16LE;
+
+		if (sc->flag & SCONV_FROM_UTF16) {
+			/*
+			 *  UTF-16BE/LE NFD ===> UTF-16 NFC
+			 */
+			count = utf16nbytes(s, length);
+		} else {
+			/*
+			 *  UTF-8 NFD ===> UTF-16 NFC
+			 */
+			count = mbsnbytes(s, length);
+		}
+		u16.s = (char *)dest->s;
+		u16.length = dest->length << 1;;
+		u16.buffer_length = dest->buffer_length;
+		ret = archive_string_normalize_C(&u16, s, count, sc);
+		dest->s = (wchar_t *)u16.s;
+		dest->length = u16.length >> 1;
+		dest->buffer_length = u16.buffer_length;
+		sc->flag = saved_flag;/* restore the saved flag. */
+		return (ret);
+	} else if (sc != NULL && (sc->flag & SCONV_FROM_UTF16)) {
+		count = utf16nbytes(s, length);
+		count >>= 1; /* to be WCS length */
+		/* Allocate memory for WCS. */
+		if (NULL == archive_wstring_ensure(dest,
+		    dest->length + count + 1))
+			return (-1);
+		wmemcpy(dest->s + dest->length, (wchar_t *)s, count);
+		if ((sc->flag & SCONV_FROM_UTF16BE) && !is_big_endian()) {
+			uint16_t *u16 = (uint16_t *)(dest->s + dest->length);
+			int b;
+			for (b = 0; b < count; b++) {
+				uint16_t val = archive_le16dec(u16+b);
+				archive_be16enc(u16+b, val);
+			}
+		} else if ((sc->flag & SCONV_FROM_UTF16LE) && is_big_endian()) {
+			uint16_t *u16 = (uint16_t *)(dest->s + dest->length);
+			int b;
+			for (b = 0; b < count; b++) {
+				uint16_t val = archive_be16dec(u16+b);
+				archive_le16enc(u16+b, val);
+			}
+		}
+	} else {
+		DWORD mbflag;
+
+		if (sc == NULL)
+			mbflag = 0;
+		else if (sc->flag & SCONV_FROM_CHARSET) {
+			/* Do not trust the length which comes from
+			 * an archive file. */
+			length = mbsnbytes(s, length);
+			mbflag = 0;
+		} else
+			mbflag = MB_PRECOMPOSED;
+
+		if (length == 0) {
+			/*
+			 * We do not need to convert any characters but make
+			 * sure `dest' has a valid buffer(no NULL pointer).
+			 */
+			if (NULL == archive_wstring_ensure(dest,
+			    dest->length + 1))
+				return (-1);
+			dest->s[dest->length] = L'\0';
+			return (0);
+		}
+
+		/*
+		 * Count how many bytes are needed for WCS.
+		 */
+		count = MultiByteToWideChar(from_cp,
+		    mbflag, s, length, NULL, 0);
+		if (count == 0) {
+			if (dest->s == NULL) {
+				if (NULL == archive_wstring_ensure(dest,
+				    dest->length + 1))
+					return (-1);
+			}
+			dest->s[dest->length] = L'\0';
+			return (-1);
+		}
+		/* Allocate memory for WCS. */
+		if (NULL == archive_wstring_ensure(dest,
+		    dest->length + count + 1))
+			return (-1);
+		/* Convert MBS to WCS. */
+		count = MultiByteToWideChar(from_cp,
+		    mbflag, s, length, dest->s + dest->length, count);
+		if (count == 0)
+			ret = -1;
+	}
+	dest->length += count;
+	dest->s[dest->length] = L'\0';
+	return (ret);
+}
+
+#elif defined(HAVE_MBSNRTOWCS)
+
+/*
+ * Convert MBS to WCS.
+ * Note: returns -1 if conversion fails.
+ */
+int
+archive_wstring_append_from_mbs(struct archive_wstring *dest,
+    const char *p, size_t len)
+{
+	size_t r;
 	/*
-	 * Convert one wide char at a time into 'buff', whenever that
-	 * fills, append it to the string.
+	 * No single byte will be more than one wide character,
+	 * so this length estimate will always be big enough.
 	 */
-	p = buff;
-	while (*w != L'\0') {
-		/* Flush the buffer when we have <=16 bytes free. */
-		/* (No encoding has a single character >16 bytes.) */
-		if ((size_t)(p - buff) >= (size_t)(sizeof(buff) - 16)) {
-			*p = '\0';
-			archive_strcat(as, buff);
-			p = buff;
-		}
-		wc = *w++;
-		/* If this is a surrogate pair, assemble the full code point.*/
-		/* Note: wc must not be wchar_t here, because the full code
-		 * point can be more than 16 bits! */
-		if (wc >= 0xD800 && wc <= 0xDBff
-		    && *w >= 0xDC00 && *w <= 0xDFFF) {
-			wc -= 0xD800;
-			wc *= 0x400;
-			wc += (*w - 0xDC00);
-			wc += 0x10000;
-			++w;
-		}
-		/* Translate code point to UTF8 */
-		if (wc <= 0x7f) {
-			*p++ = (char)wc;
-		} else if (wc <= 0x7ff) {
-			*p++ = 0xc0 | ((wc >> 6) & 0x1f);
-			*p++ = 0x80 | (wc & 0x3f);
-		} else if (wc <= 0xffff) {
-			*p++ = 0xe0 | ((wc >> 12) & 0x0f);
-			*p++ = 0x80 | ((wc >> 6) & 0x3f);
-			*p++ = 0x80 | (wc & 0x3f);
-		} else if (wc <= 0x1fffff) {
-			*p++ = 0xf0 | ((wc >> 18) & 0x07);
-			*p++ = 0x80 | ((wc >> 12) & 0x3f);
-			*p++ = 0x80 | ((wc >> 6) & 0x3f);
-			*p++ = 0x80 | (wc & 0x3f);
-		} else {
-			/* Unicode has no codes larger than 0x1fffff. */
-			/* TODO: use \uXXXX escape here instead of ? */
-			*p++ = '?';
-			return_val = NULL;
-		}
+	size_t wcs_length = len;
+	size_t mbs_length = len;
+	const char *mbs = p;
+	wchar_t *wcs;
+	mbstate_t shift_state;
+
+	memset(&shift_state, 0, sizeof(shift_state));
+	if (NULL == archive_wstring_ensure(dest, dest->length + wcs_length + 1))
+		__archive_errx(1,
+		    "No memory for archive_wstring_append_from_mbs()");
+	wcs = dest->s + dest->length;
+	r = mbsnrtowcs(wcs, &mbs, mbs_length, wcs_length, &shift_state);
+	if (r != (size_t)-1) {
+		dest->length += r;
+		dest->s[dest->length] = L'\0';
+		return (0);
 	}
-	*p = '\0';
-	archive_strcat(as, buff);
-	return (return_val);
-}
-
-static int
-utf8_to_unicode(int *pwc, const char *s, size_t n)
-{
-        int ch;
-
-        /*
-	 * Decode 1-4 bytes depending on the value of the first byte.
-	 */
-        ch = (unsigned char)*s;
-	if (ch == 0) {
-		return (0); /* Standard:  return 0 for end-of-string. */
-	}
-	if ((ch & 0x80) == 0) {
-                *pwc = ch & 0x7f;
-		return (1);
-        }
-	if ((ch & 0xe0) == 0xc0) {
-		if (n < 2)
-			return (-1);
-		if ((s[1] & 0xc0) != 0x80) return (-1);
-                *pwc = ((ch & 0x1f) << 6) | (s[1] & 0x3f);
-		return (2);
-        }
-	if ((ch & 0xf0) == 0xe0) {
-		if (n < 3)
-			return (-1);
-		if ((s[1] & 0xc0) != 0x80) return (-1);
-		if ((s[2] & 0xc0) != 0x80) return (-1);
-                *pwc = ((ch & 0x0f) << 12)
-		    | ((s[1] & 0x3f) << 6)
-		    | (s[2] & 0x3f);
-		return (3);
-        }
-	if ((ch & 0xf8) == 0xf0) {
-		if (n < 4)
-			return (-1);
-		if ((s[1] & 0xc0) != 0x80) return (-1);
-		if ((s[2] & 0xc0) != 0x80) return (-1);
-		if ((s[3] & 0xc0) != 0x80) return (-1);
-                *pwc = ((ch & 0x07) << 18)
-		    | ((s[1] & 0x3f) << 12)
-		    | ((s[2] & 0x3f) << 6)
-		    | (s[3] & 0x3f);
-		return (4);
-        }
-	/* Invalid first byte. */
+	dest->s[dest->length] = L'\0';
 	return (-1);
 }
 
+#else
+
 /*
- * Return a wide-character Unicode string by converting this archive_string
- * from UTF-8.  We assume that systems with 16-bit wchar_t always use
- * UTF16 and systems with 32-bit wchar_t can accept UCS4.
+ * Convert MBS to WCS.
+ * Note: returns -1 if conversion fails.
  */
-wchar_t *
-__archive_string_utf8_w(struct archive_string *as)
+int
+archive_wstring_append_from_mbs(struct archive_wstring *dest,
+    const char *p, size_t len)
 {
-	wchar_t *ws, *dest;
-	int wc, wc2;/* Must be large enough for a 21-bit Unicode code point. */
-	const char *src;
-	int n;
-
-	ws = (wchar_t *)malloc((as->length + 1) * sizeof(wchar_t));
-	if (ws == NULL)
-		__archive_errx(1, "Out of memory");
-	dest = ws;
-	src = as->s;
-	while (*src != '\0') {
-		n = utf8_to_unicode(&wc, src, 8);
-		if (n == 0)
+	size_t r;
+	/*
+	 * No single byte will be more than one wide character,
+	 * so this length estimate will always be big enough.
+	 */
+	size_t wcs_length = len;
+	size_t mbs_length = len;
+	const char *mbs = p;
+	wchar_t *wcs;
+#if HAVE_MBRTOWC
+	mbstate_t shift_state;
+
+	memset(&shift_state, 0, sizeof(shift_state));
+#endif
+	if (NULL == archive_wstring_ensure(dest, dest->length + wcs_length + 1))
+		__archive_errx(1,
+		    "No memory for archive_wstring_append_from_mbs()");
+	wcs = dest->s + dest->length;
+	/*
+	 * We cannot use mbsrtowcs/mbstowcs here because those may convert
+	 * extra MBS when strlen(p) > len and one wide character consis of
+	 * multi bytes.
+	 */
+	while (wcs_length > 0 && *mbs && mbs_length > 0) {
+#if HAVE_MBRTOWC
+		r = mbrtowc(wcs, mbs, wcs_length, &shift_state);
+#else
+		r = mbtowc(wcs, mbs, wcs_length);
+#endif
+		if (r == (size_t)-1 || r == (size_t)-2) {
+			dest->s[dest->length] = L'\0';
+			return (-1);
+		}
+		if (r == 0 || r > mbs_length)
 			break;
-		if (n < 0) {
-			free(ws);
-			return (NULL);
-		}
-		src += n;
-		if (wc >= 0xDC00 && wc <= 0xDBFF) {
-			/* This is a leading surrogate; some idiot
-			 * has translated UTF16 to UTF8 without combining
-			 * surrogates; rebuild the full code point before
-			 * continuing. */
-			n = utf8_to_unicode(&wc2, src, 8);
-			if (n < 0) {
-				free(ws);
-				return (NULL);
-			}
-			if (n == 0) /* Ignore the leading surrogate */
-				break;
-			if (wc2 < 0xDC00 || wc2 > 0xDFFF) {
-				/* If the second character isn't a
-				 * trailing surrogate, then someone
-				 * has really screwed up and this is
-				 * invalid. */
-				free(ws);
-				return (NULL);
-			} else {
-				src += n;
-				wc -= 0xD800;
-				wc *= 0x400;
-				wc += wc2 - 0xDC00;
-				wc += 0x10000;
-			}
-		}
-		if ((sizeof(wchar_t) < 4) && (wc > 0xffff)) {
-			/* We have a code point that won't fit into a
-			 * wchar_t; convert it to a surrogate pair. */
-			wc -= 0x10000;
-			*dest++ = ((wc >> 10) & 0x3ff) + 0xD800;
-			*dest++ = (wc & 0x3ff) + 0xDC00;
-		} else
-			*dest++ = wc;
+		wcs++;
+		wcs_length--;
+		mbs += r;
+		mbs_length -= r;
 	}
-	*dest = L'\0';
-	return (ws);
+	dest->length = wcs - dest->s;
+	dest->s[dest->length] = L'\0';
+	return (0);
 }
 
+#endif
+
 #if defined(_WIN32) && !defined(__CYGWIN__)
 
 /*
- * Translates a wide character string into current locale character set
- * and appends to the archive_string.  Note: returns NULL if conversion
- * fails.
+ * WCS ==> MBS.
+ * Note: returns -1 if conversion fails.
  *
  * Win32 builds use WideCharToMultiByte from the Windows API.
  * (Maybe Cygwin should too?  WideCharToMultiByte will know a
  * lot more about local character encodings than the wcrtomb()
  * wrapper is going to know.)
  */
-struct archive_string *
-__archive_strappend_w_mbs(struct archive_string *as, const wchar_t *w)
+int
+archive_string_append_from_wcs(struct archive_string *as,
+    const wchar_t *w, size_t len)
 {
-	char *p;
-	int l, wl;
-	BOOL useDefaultChar = FALSE;
-
-	wl = (int)wcslen(w);
-	l = wl * 4 + 4;
-	p = malloc(l);
-	if (p == NULL)
-		__archive_errx(1, "Out of memory");
-	/* To check a useDefaultChar is to simulate error handling of
-	 * the my_wcstombs() which is running on non Windows system with
-	 * wctomb().
-	 * And to set NULL for last argument is necessary when a codepage
-	 * is not CP_ACP(current locale).
-	 */
-	l = WideCharToMultiByte(CP_ACP, 0, w, wl, p, l, NULL, &useDefaultChar);
-	if (l == 0) {
-		free(p);
-		return (NULL);
+	int r = archive_string_append_from_wcs_in_codepage(as, w, len, NULL);
+	if (r != 0 && errno == ENOMEM)
+		__archive_errx(1, "No memory");
+	return (r);
+}
+
+static int
+archive_string_append_from_wcs_in_codepage(struct archive_string *as,
+    const wchar_t *ws, size_t len, struct archive_string_conv *sc)
+{
+	BOOL defchar_used, *dp;
+	int count, ret = 0;
+	UINT to_cp;
+	int wslen = (int)len;
+
+	if (sc != NULL)
+		to_cp = sc->to_cp;
+	else
+		to_cp = get_current_codepage();
+
+	if (to_cp == CP_C_LOCALE) {
+		/*
+		 * "C" locale special process.
+		 */
+		const wchar_t *wp = ws;
+		char *p;
+
+		if (NULL == archive_string_ensure(as,
+		    as->length + wslen +1))
+			return (-1);
+		p = as->s + as->length;
+		count = 0;
+		defchar_used = 0;
+		while (count < wslen && *wp) {
+			if (*wp > 255) {
+				*p++ = '?';
+				wp++;
+				defchar_used = 1;
+			} else
+				*p++ = (char)*wp++;
+			count++;
+		}
+	} else if (sc != NULL && (sc->flag & SCONV_TO_UTF16)) {
+		uint16_t *u16;
+
+		if (NULL ==
+		    archive_string_ensure(as, as->length + len * 2 + 2))
+			return (-1);
+		u16 = (uint16_t *)(as->s + as->length);
+		count = 0;
+		defchar_used = 0;
+		if (sc->flag & SCONV_TO_UTF16BE) {
+			while (count < (int)len && *ws) {
+				archive_be16enc(u16+count, *ws);
+				ws++;
+				count++;
+			}
+		} else {
+			while (count < (int)len && *ws) {
+				archive_le16enc(u16+count, *ws);
+				ws++;
+				count++;
+			}
+		}
+		count <<= 1; /* to be byte size */
+	} else {
+		/* Make sure the MBS buffer has plenty to set. */
+		if (NULL ==
+		    archive_string_ensure(as, as->length + len * 2 + 1))
+			return (-1);
+		do {
+			defchar_used = 0;
+			if (to_cp == CP_UTF8 || sc == NULL)
+				dp = NULL;
+			else
+				dp = &defchar_used;
+			count = WideCharToMultiByte(to_cp, 0, ws, wslen,
+			    as->s + as->length, as->buffer_length-1, NULL, dp);
+			if (count == 0 &&
+			    GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
+				/* Expand the MBS buffer and retry. */
+				if (NULL == archive_string_ensure(as,
+					as->buffer_length + len))
+					return (-1);
+				continue;
+			}
+			if (count == 0)
+				ret = -1;
+		} while (0);
 	}
-	__archive_string_append(as, p, l);
-	free(p);
-	return (as);
+	as->length += count;
+	as->s[as->length] = '\0';
+	return (defchar_used?-1:ret);
 }
 
-#else
+#elif defined(HAVE_WCSNRTOMBS)
 
 /*
  * Translates a wide character string into current locale character set
- * and appends to the archive_string.  Note: returns NULL if conversion
+ * and appends to the archive_string.  Note: returns -1 if conversion
  * fails.
- *
- * Non-Windows uses ISO C wcrtomb() or wctomb() to perform the conversion
- * one character at a time.  If a non-Windows platform doesn't have
- * either of these, fall back to the built-in UTF8 conversion.
  */
-struct archive_string *
-__archive_strappend_w_mbs(struct archive_string *as, const wchar_t *w)
+int
+archive_string_append_from_wcs(struct archive_string *as,
+    const wchar_t *w, size_t len)
 {
-#if !defined(HAVE_WCTOMB) && !defined(HAVE_WCRTOMB)
-	/* If there's no built-in locale support, fall back to UTF8 always. */
-	return __archive_strappend_w_utf8(as, w);
-#else
+	mbstate_t shift_state;
+	size_t r, ndest, nwc;
+	char *dest;
+	const wchar_t *wp, *wpp;
+	int ret_val = 0;
+
+	wp = w;
+	nwc = len;
+	ndest = len * 2;
+	/* Initialize the shift state. */
+	memset(&shift_state, 0, sizeof(shift_state));
+	while (nwc > 0) {
+		/* Allocate buffer for MBS. */
+		if (archive_string_ensure(as, as->length + ndest + 1) == NULL)
+			__archive_errx(1, "Out of memory");
+
+		dest = as->s + as->length;
+		wpp = wp;
+		r = wcsnrtombs(dest, &wp, nwc,
+		    as->buffer_length - as->length -1,
+		    &shift_state);
+		if (r == (size_t)-1) {
+			if (errno == EILSEQ) {
+				/* Retry conversion just for safe WCS. */
+				size_t xwc = wp - wpp;
+				wp = wpp;
+				r = wcsnrtombs(dest, &wp, xwc,
+				    as->buffer_length - as->length -1,
+				    &shift_state);
+				if (r == (size_t)-1)
+					/* This would not happen. */
+					return (-1);
+				as->length += r;
+				nwc -= wp - wpp;
+				/* Skip an illegal wide char. */
+				as->s[as->length++] = '?';
+				wp++;
+				nwc--;
+				ret_val = -1;
+				continue;
+			} else {
+				ret_val = -1;
+				break;
+			}
+		}
+		as->length += r;
+		if (wp == NULL || (wp - wpp) >= (int64_t)nwc)
+			break;
+		/* Get a remaining WCS lenth. */
+		nwc -= wp - wpp;
+	}
+	/* All wide characters are translated to MBS. */
+	as->s[as->length] = '\0';
+	return (ret_val);
+}
+
+#elif defined(HAVE_WCTOMB) || defined(HAVE_WCRTOMB)
+
+/*
+ * Translates a wide character string into current locale character set
+ * and appends to the archive_string.  Note: returns -1 if conversion
+ * fails.
+ */
+int
+archive_string_append_from_wcs(struct archive_string *as,
+    const wchar_t *w, size_t len)
+{
 	/* We cannot use the standard wcstombs() here because it
 	 * cannot tell us how big the output buffer should be.  So
 	 * I've built a loop around wcrtomb() or wctomb() that
 	 * converts a character at a time and resizes the string as
 	 * needed.  We prefer wcrtomb() when it's available because
 	 * it's thread-safe. */
-	int n;
+	int n, ret_val = 0;
 	char *p;
-	char buff[256];
+	char *end;
 #if HAVE_WCRTOMB
 	mbstate_t shift_state;
 
@@ -421,33 +887,3351 @@
 	/* Clear the shift state before starting. */
 	wctomb(NULL, L'\0');
 #endif
-
 	/*
-	 * Convert one wide char at a time into 'buff', whenever that
-	 * fills, append it to the string.
+	 * Allocate buffer for MBS.
+	 * We need this allocation here since it is possible that
+	 * as->s is still NULL.
 	 */
-	p = buff;
-	while (*w != L'\0') {
-		/* Flush the buffer when we have <=16 bytes free. */
-		/* (No encoding has a single character >16 bytes.) */
-		if ((size_t)(p - buff) >= (size_t)(sizeof(buff) - MB_CUR_MAX)) {
-			*p = '\0';
-			archive_strcat(as, buff);
-			p = buff;
+	if (archive_string_ensure(as, as->length + len + 1) == NULL)
+		__archive_errx(1, "Out of memory");
+
+	p = as->s + as->length;
+	end = as->s + as->buffer_length - MB_CUR_MAX -1;
+	while (*w != L'\0' && len > 0) {
+		if (p >= end) {
+			as->length = p - as->s;
+			as->s[as->length] = '\0';
+			/* Re-allocate buffer for MBS. */
+			if (archive_string_ensure(as,
+			    as->length + len * 2 + 1) == NULL)
+				__archive_errx(1, "Out of memory");
+			p = as->s + as->length;
+			end = as->s + as->buffer_length - MB_CUR_MAX -1;
 		}
 #if HAVE_WCRTOMB
 		n = wcrtomb(p, *w++, &shift_state);
 #else
 		n = wctomb(p, *w++);
 #endif
+		if (n == -1) {
+			if (errno == EILSEQ) {
+				/* Skip an illegal wide char. */
+				*p++ = '?';
+				ret_val = -1;
+			} else {
+				ret_val = -1;
+				break;
+			}
+		} else
+			p += n;
+		len--;
+	}
+	as->length = p - as->s;
+	as->s[as->length] = '\0';
+	return (ret_val);
+}
+
+#else /* HAVE_WCTOMB || HAVE_WCRTOMB */
+
+/*
+ * TODO: Test if __STDC_ISO_10646__ is defined.
+ * Non-Windows uses ISO C wcrtomb() or wctomb() to perform the conversion
+ * one character at a time.  If a non-Windows platform doesn't have
+ * either of these, fall back to the built-in UTF8 conversion.
+ */
+int
+archive_string_append_from_wcs(struct archive_string *as,
+    const wchar_t *w, size_t len)
+{
+	(void)as;/* UNUSED */
+	(void)w;/* UNUSED */
+	(void)len;/* UNUSED */
+	return (-1);
+}
+
+#endif /* HAVE_WCTOMB || HAVE_WCRTOMB */
+
+/*
+ * Find a string conversion object by a pair of 'from' charset name
+ * and 'to' charset name from an archive object.
+ * Return NULL if not found.
+ */
+static struct archive_string_conv *
+find_sconv_object(struct archive *a, const char *fc, const char *tc)
+{
+	struct archive_string_conv *sc; 
+
+	if (a == NULL)
+		return (NULL);
+
+	for (sc = a->sconv; sc != NULL; sc = sc->next) {
+		if (strcmp(sc->from_charset, fc) == 0 &&
+		    strcmp(sc->to_charset, tc) == 0)
+			break;
+	}
+	return (sc);
+}
+
+/*
+ * Register a string object to an archive object.
+ */
+static void
+add_sconv_object(struct archive *a, struct archive_string_conv *sc)
+{
+	struct archive_string_conv **psc; 
+
+	/* Add a new sconv to sconv list. */
+	psc = &(a->sconv);
+	while (*psc != NULL)
+		psc = &((*psc)->next);
+	*psc = sc;
+}
+
+#if defined(__APPLE__)
+
+static int
+createUniInfo(struct archive_string_conv *sconv)
+{
+	UnicodeMapping map;
+	OSStatus err;
+
+	map.unicodeEncoding = CreateTextEncoding(kTextEncodingUnicodeDefault,
+	    kUnicodeNoSubset, kUnicode16BitFormat);
+	map.otherEncoding = CreateTextEncoding(kTextEncodingUnicodeDefault,
+	    kUnicodeHFSPlusDecompVariant, kUnicode16BitFormat);
+	map.mappingVersion = kUnicodeUseLatestMapping;
+
+	sconv->uniInfo = NULL;
+	err = CreateUnicodeToTextInfo(&map, &(sconv->uniInfo));
+	return ((err == noErr)? 0: -1);
+}
+
+#endif /* __APPLE__ */
+
+static void
+add_converter(struct archive_string_conv *sc, int (*converter)
+    (struct archive_string *, const void *, size_t,
+     struct archive_string_conv *))
+{
+	if (sc == NULL || sc->nconverter >= 2)
+		__archive_errx(1, "Programing error");
+	sc->converter[sc->nconverter++] = converter;
+}
+
+static void
+setup_converter(struct archive_string_conv *sc)
+{
+
+	/* Reset. */
+	sc->nconverter = 0;
+
+	/*
+	 * Perform special sequence for the incorrect UTF-8 filenames
+	 * made by libarchive2.x.
+	 */
+	if (sc->flag & SCONV_UTF8_LIBARCHIVE_2) {
+		add_converter(sc, strncat_from_utf8_libarchive2);
+		return;
+	}
+
+	/*
+	 * Convert a string to UTF-16BE/LE.
+	 */
+	if (sc->flag & SCONV_TO_UTF16) {
+		/*
+		 * If the current locale is UTF-8, we can translate
+		 * a UTF-8 string into a UTF-16BE string.
+		 */
+		if (sc->flag & SCONV_FROM_UTF8) {
+			add_converter(sc, archive_string_append_unicode);
+			return;
+		}
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+		if (sc->flag & SCONV_WIN_CP) {
+			if (sc->flag & SCONV_TO_UTF16BE)
+				add_converter(sc, win_strncat_to_utf16be);
+			else
+				add_converter(sc, win_strncat_to_utf16le);
+			return;
+		}
+#endif
+
+#if defined(HAVE_ICONV)
+		if (sc->cd != (iconv_t)-1) {
+			add_converter(sc, iconv_strncat_in_locale);
+			return;
+		}
+#endif
+
+		if (sc->flag & SCONV_BEST_EFFORT) {
+			if (sc->flag & SCONV_TO_UTF16BE)
+				add_converter(sc, best_effort_strncat_to_utf16be);
+			else
+				add_converter(sc, best_effort_strncat_to_utf16le);
+		} else
+			/* Make sure we have no converter. */
+			sc->nconverter = 0;
+		return;
+	}
+
+	/*
+	 * Convert a string from UTF-16BE/LE.
+	 */
+	if (sc->flag & SCONV_FROM_UTF16) {
+		/*
+		 * At least we should normalize a UTF-16BE string.
+		 */
+#if defined(__APPLE__)
+		if (sc->flag & SCONV_NORMALIZATION_D)
+			add_converter(sc,archive_string_normalize_D);
+		else
+#endif
+		if (sc->flag & SCONV_NORMALIZATION_C)
+			add_converter(sc, archive_string_normalize_C);
+
+		if (sc->flag & SCONV_TO_UTF8) {
+			/*
+			 * If the current locale is UTF-8, we can translate
+			 * a UTF-16BE/LE string into a UTF-8 string directly.
+			 */
+			if (!(sc->flag &
+			    (SCONV_NORMALIZATION_D |SCONV_NORMALIZATION_C)))
+				add_converter(sc,
+				    archive_string_append_unicode);
+			return;
+		}
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+		if (sc->flag & SCONV_WIN_CP) {
+			if (sc->flag & SCONV_FROM_UTF16BE)
+				add_converter(sc, win_strncat_from_utf16be);
+			else
+				add_converter(sc, win_strncat_from_utf16le);
+			return;
+		}
+#endif
+
+#if defined(HAVE_ICONV)
+		if (sc->cd != (iconv_t)-1) {
+			add_converter(sc, iconv_strncat_in_locale);
+			return;
+		}
+#endif
+
+		if ((sc->flag & (SCONV_BEST_EFFORT | SCONV_FROM_UTF16BE))
+		    == (SCONV_BEST_EFFORT | SCONV_FROM_UTF16BE))
+			add_converter(sc, best_effort_strncat_from_utf16be);
+		else if ((sc->flag & (SCONV_BEST_EFFORT | SCONV_FROM_UTF16LE))
+		    == (SCONV_BEST_EFFORT | SCONV_FROM_UTF16LE))
+			add_converter(sc, best_effort_strncat_from_utf16le);
+		else
+			/* Make sure we have no converter. */
+			sc->nconverter = 0;
+		return;
+	}
+
+	if (sc->flag & SCONV_FROM_UTF8) {
+		/*
+		 * At least we should normalize a UTF-8 string.
+		 */
+#if defined(__APPLE__)
+		if (sc->flag & SCONV_NORMALIZATION_D)
+			add_converter(sc,archive_string_normalize_D);
+		else
+#endif
+		if (sc->flag & SCONV_NORMALIZATION_C)
+			add_converter(sc, archive_string_normalize_C);
+
+		/*
+		 * Copy UTF-8 string with a check of CESU-8.
+		 * Apparently, iconv does not check surrogate pairs in UTF-8
+		 * when both from-charset and to-charset are UTF-8, and then
+		 * we use our UTF-8 copy code.
+		 */
+		if (sc->flag & SCONV_TO_UTF8) {
+			/*
+			 * If the current locale is UTF-8, we can translate
+			 * a UTF-16BE string into a UTF-8 string directly.
+			 */
+			if (!(sc->flag &
+			    (SCONV_NORMALIZATION_D |SCONV_NORMALIZATION_C)))
+				add_converter(sc, strncat_from_utf8_to_utf8);
+			return;
+		}
+	}
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+	/*
+	 * On Windows we can use Windows API for a string conversion.
+	 */
+	if (sc->flag & SCONV_WIN_CP) {
+		add_converter(sc, strncat_in_codepage);
+		return;
+	}
+#endif
+
+#if HAVE_ICONV
+	if (sc->cd != (iconv_t)-1) {
+		add_converter(sc, iconv_strncat_in_locale);
+		return;
+	}
+#endif
+
+	/*
+	 * Try conversion in the best effort or no conversion.
+	 */
+	if ((sc->flag & SCONV_BEST_EFFORT) || sc->same)
+		add_converter(sc, best_effort_strncat_in_locale);
+	else
+		/* Make sure we have no converter. */
+		sc->nconverter = 0;
+}
+
+/*
+ * Return canonicalized charset-name but this supports just UTF-8, UTF-16BE
+ * and CP932 which are referenced in create_sconv_object().
+ */
+static const char *
+canonical_charset_name(const char *charset)
+{
+	char cs[16];
+	char *p;
+	const char *s;
+
+	if (charset == NULL || charset[0] == '\0'
+	    || strlen(charset) > 15)
+		return (charset);
+
+	/* Copy name to uppercase. */
+	p = cs;
+	s = charset;
+	while (*s) {
+		char c = *s++;
+		if (c >= 'a' && c <= 'z')
+			c -= 'a' - 'A';
+		*p++ = c;
+	}
+	*p++ = '\0';
+
+	if (strcmp(cs, "UTF-8") == 0 ||
+	    strcmp(cs, "UTF8") == 0)
+		return ("UTF-8");
+	if (strcmp(cs, "UTF-16BE") == 0 ||
+	    strcmp(cs, "UTF16BE") == 0)
+		return ("UTF-16BE");
+	if (strcmp(cs, "UTF-16LE") == 0 ||
+	    strcmp(cs, "UTF16LE") == 0)
+		return ("UTF-16LE");
+	if (strcmp(cs, "CP932") == 0)
+		return ("CP932");
+	return (charset);
+}
+
+/*
+ * Create a string conversion object.
+ */
+static struct archive_string_conv *
+create_sconv_object(const char *fc, const char *tc,
+    unsigned current_codepage, int flag)
+{
+	struct archive_string_conv *sc; 
+
+	sc = calloc(1, sizeof(*sc));
+	if (sc == NULL)
+		return (NULL);
+	sc->next = NULL;
+	sc->from_charset = strdup(fc);
+	if (sc->from_charset == NULL) {
+		free(sc);
+		return (NULL);
+	}
+	sc->to_charset = strdup(tc);
+	if (sc->to_charset == NULL) {
+		free(sc);
+		free(sc->from_charset);
+		return (NULL);
+	}
+	archive_string_init(&sc->utftmp);
+#if defined(__APPLE__)
+	archive_string_init(&sc->utf16nfc);
+	archive_string_init(&sc->utf16nfd);
+#endif
+
+	if (flag & SCONV_TO_CHARSET) {
+		/*
+		 * Convert characters from the current locale charset to
+		 * a specified charset.
+		 */
+		sc->from_cp = current_codepage;
+		sc->to_cp = make_codepage_from_charset(tc);
+#if defined(_WIN32) && !defined(__CYGWIN__)
+		if (IsValidCodePage(sc->to_cp))
+			flag |= SCONV_WIN_CP;
+#endif
+	} else if (flag & SCONV_FROM_CHARSET) {
+		/*
+		 * Convert characters from a specified charset to
+		 * the current locale charset.
+		 */
+		sc->to_cp = current_codepage;
+		sc->from_cp = make_codepage_from_charset(fc);
+#if defined(_WIN32) && !defined(__CYGWIN__)
+		if (IsValidCodePage(sc->from_cp))
+			flag |= SCONV_WIN_CP;
+#endif
+	}
+
+	/*
+	 * Check if "from charset" and "to charset" are the same.
+	 */
+	if (strcmp(fc, tc) == 0 ||
+	    (sc->from_cp != (unsigned)-1 && sc->from_cp == sc->to_cp))
+		sc->same = 1;
+	else
+		sc->same = 0;
+
+	/*
+	 * Mark if "from charset" or "to charset" are UTF-8 or UTF-16BE/LE.
+	 */
+	if (strcmp(tc, "UTF-8") == 0)
+		flag |= SCONV_TO_UTF8;
+	else if (strcmp(tc, "UTF-16BE") == 0)
+		flag |= SCONV_TO_UTF16BE;
+	else if (strcmp(tc, "UTF-16LE") == 0)
+		flag |= SCONV_TO_UTF16LE;
+	if (strcmp(fc, "UTF-8") == 0)
+		flag |= SCONV_FROM_UTF8;
+	else if (strcmp(fc, "UTF-16BE") == 0)
+		flag |= SCONV_FROM_UTF16BE;
+	else if (strcmp(fc, "UTF-16LE") == 0)
+		flag |= SCONV_FROM_UTF16LE;
+#if defined(_WIN32) && !defined(__CYGWIN__)
+	if (sc->to_cp == CP_UTF8)
+		flag |= SCONV_TO_UTF8;
+	else if (sc->to_cp == CP_UTF16BE)
+		flag |= SCONV_TO_UTF16BE | SCONV_WIN_CP;
+	else if (sc->to_cp == CP_UTF16LE)
+		flag |= SCONV_TO_UTF16LE | SCONV_WIN_CP;
+	if (sc->from_cp == CP_UTF8)
+		flag |= SCONV_FROM_UTF8;
+	else if (sc->from_cp == CP_UTF16BE)
+		flag |= SCONV_FROM_UTF16BE | SCONV_WIN_CP;
+	else if (sc->from_cp == CP_UTF16LE)
+		flag |= SCONV_FROM_UTF16LE | SCONV_WIN_CP;
+#endif
+
+	/*
+	 * Set a flag for Unicode NFD. Usually iconv cannot correctly
+	 * handle it. So we have to translate NFD characters to NFC ones
+	 * ourselves before iconv handles. Another reason is to prevent
+	 * that the same sight of two filenames, one is NFC and other
+	 * is NFD, would be in its directory.
+	 * On Mac OS X, although its filesystem layer automatically
+	 * convert filenames to NFD, it would be useful for filename
+	 * comparing to find out the same filenames that we normalize
+	 * that to be NFD ourselves.
+	 */
+	if ((flag & SCONV_FROM_CHARSET) &&
+	    (flag & (SCONV_FROM_UTF16 | SCONV_FROM_UTF8))) {
+#if defined(__APPLE__)
+		if (flag & SCONV_TO_UTF8) {
+			if (createUniInfo(sc) == 0)
+				flag |= SCONV_NORMALIZATION_D;
+		} else
+#endif
+			flag |= SCONV_NORMALIZATION_C;
+	}
+
+#if defined(HAVE_ICONV)
+	sc->cd_w = (iconv_t)-1;
+	/*
+	 * Create an iconv object.
+	 */
+	if (((flag & (SCONV_TO_UTF8 | SCONV_TO_UTF16)) &&
+	    (flag & (SCONV_FROM_UTF8 | SCONV_FROM_UTF16))) ||
+	    (flag & SCONV_WIN_CP)) {
+		/* This case we won't use iconv. */
+		sc->cd = (iconv_t)-1;
+#if defined(__APPLE__)
+	} else if ((flag & SCONV_FROM_CHARSET) && (flag & SCONV_TO_UTF8)) {
+		/*
+		 * In case reading an archive file.
+		 * Translate non-Unicode filenames in an archive file to
+		 * UTF-8-MAC filenames.
+		 */
+		sc->cd = iconv_open("UTF-8-MAC", fc);
+		if (sc->cd == (iconv_t)-1) {
+			if ((sc->flag & SCONV_BEST_EFFORT) &&
+			    strcmp(fc, "CP932") == 0) {
+				sc->cd = iconv_open("UTF-8-MAC", "SJIS");
+				if (sc->cd == (iconv_t)-1) {
+					sc->cd = iconv_open(tc, fc);
+					if (sc->cd == (iconv_t)-1)
+						sc->cd = iconv_open(tc, "SJIS");
+				}
+			} else
+				sc->cd = iconv_open(tc, fc);
+		}
+	} else if ((flag & SCONV_TO_CHARSET) && (flag & SCONV_FROM_UTF8)) {
+		/*
+		 * In case writing an archive file.
+		 * Translate UTF-8-MAC filenames in HFS Plus to non-Unicode
+		 * filenames.
+		 */
+		sc->cd = iconv_open(tc, "UTF-8-MAC");
+		if (sc->cd == (iconv_t)-1) {
+			if ((sc->flag & SCONV_BEST_EFFORT) &&
+			    strcmp(tc, "CP932") == 0) {
+				sc->cd = iconv_open("SJIS", "UTF-8-MAC");
+				if (sc->cd == (iconv_t)-1) {
+					sc->cd = iconv_open(tc, fc);
+					if (sc->cd == (iconv_t)-1)
+						sc->cd = iconv_open("SJIS", fc);
+				}
+			} else
+				sc->cd = iconv_open(tc, fc);
+		}
+#endif
+	} else {
+		sc->cd = iconv_open(tc, fc);
+		if (sc->cd == (iconv_t)-1 && (sc->flag & SCONV_BEST_EFFORT)) {
+			/*
+			 * Unfortunaly, all of iconv implements do support 
+			 * "CP932" character-set, so we should use "SJIS"
+			 * instead if iconv_open failed.
+			 */
+			if (strcmp(tc, "CP932") == 0)
+				sc->cd = iconv_open("SJIS", fc);
+			else if (strcmp(fc, "CP932") == 0)
+				sc->cd = iconv_open(tc, "SJIS");
+		}
+#if defined(_WIN32) && !defined(__CYGWIN__)
+		/*
+		 * archive_mstring on Windows directly convert multi-bytes
+		 * into archive_wstring in order not to depend on locale
+		 * so that you can do a I18N programing. This will be
+		 * used only in archive_mstring_copy_mbs_len_l so far.
+		 */
+		if (flag & SCONV_FROM_CHARSET) {
+			sc->cd_w = iconv_open("UTF-8", fc);
+			if (sc->cd_w == (iconv_t)-1 &&
+			    (sc->flag & SCONV_BEST_EFFORT)) {
+				if (strcmp(fc, "CP932") == 0)
+					sc->cd_w = iconv_open("UTF-8", "SJIS");
+			}
+		}
+#endif /* _WIN32 && !__CYGWIN__ */
+	}
+#endif	/* HAVE_ICONV */
+
+	sc->flag = flag;
+
+	/*
+	 * Setup converters.
+	 */
+	setup_converter(sc);
+
+	return (sc);
+}
+
+/*
+ * Free a string conversion object.
+ */
+static void
+free_sconv_object(struct archive_string_conv *sc)
+{
+	free(sc->from_charset);
+	free(sc->to_charset);
+	archive_string_free(&sc->utftmp);
+#if HAVE_ICONV
+	if (sc->cd != (iconv_t)-1)
+		iconv_close(sc->cd);
+	if (sc->cd_w != (iconv_t)-1)
+		iconv_close(sc->cd_w);
+#endif
+#if defined(__APPLE__)
+	archive_string_free(&sc->utf16nfc);
+	archive_string_free(&sc->utf16nfd);
+	if (sc->uniInfo != NULL)
+		DisposeUnicodeToTextInfo(&(sc->uniInfo));
+#endif
+	free(sc);
+}
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+static unsigned
+my_atoi(const char *p)
+{
+	unsigned cp;
+
+	cp = 0;
+	while (*p) {
+		if (*p >= '0' && *p <= '9')
+			cp = cp * 10 + (*p - '0');
+		else
+			return (-1);
+		p++;
+	}
+	return (cp);
+}
+
+/*
+ * Translate Charset name (as used by iconv) into CodePage (as used by Windows)
+ * Return -1 if failed.
+ *
+ * Note: This translation code may be insufficient.
+ */
+static struct charset {
+	const char *name;
+	unsigned cp;
+} charsets[] = {
+	/* MUST BE SORTED! */
+	{"ASCII", 1252},
+	{"ASMO-708", 708},
+	{"BIG5", 950},
+	{"CHINESE", 936},
+	{"CP367", 1252},
+	{"CP819", 1252},
+	{"CP1025", 21025},
+	{"DOS-720", 720},
+	{"DOS-862", 862},
+	{"EUC-CN", 51936},
+	{"EUC-JP", 51932},
+	{"EUC-KR", 949},
+	{"EUCCN", 51936},
+	{"EUCJP", 51932},
+	{"EUCKR", 949},
+	{"GB18030", 54936},
+	{"GB2312", 936},
+	{"HEBREW", 1255},
+	{"HZ-GB-2312", 52936},
+	{"IBM273", 20273},
+	{"IBM277", 20277},
+	{"IBM278", 20278},
+	{"IBM280", 20280},
+	{"IBM284", 20284},
+	{"IBM285", 20285},
+	{"IBM290", 20290},
+	{"IBM297", 20297},
+	{"IBM367", 1252},
+	{"IBM420", 20420},
+	{"IBM423", 20423},
+	{"IBM424", 20424},
+	{"IBM819", 1252},
+	{"IBM871", 20871},
+	{"IBM880", 20880},
+	{"IBM905", 20905},
+	{"IBM924", 20924},
+	{"ISO-8859-1", 28591},
+	{"ISO-8859-13", 28603},
+	{"ISO-8859-15", 28605},
+	{"ISO-8859-2", 28592},
+	{"ISO-8859-3", 28593},
+	{"ISO-8859-4", 28594},
+	{"ISO-8859-5", 28595},
+	{"ISO-8859-6", 28596},
+	{"ISO-8859-7", 28597},
+	{"ISO-8859-8", 28598},
+	{"ISO-8859-9", 28599},
+	{"ISO8859-1", 28591},
+	{"ISO8859-13", 28603},
+	{"ISO8859-15", 28605},
+	{"ISO8859-2", 28592},
+	{"ISO8859-3", 28593},
+	{"ISO8859-4", 28594},
+	{"ISO8859-5", 28595},
+	{"ISO8859-6", 28596},
+	{"ISO8859-7", 28597},
+	{"ISO8859-8", 28598},
+	{"ISO8859-9", 28599},
+	{"JOHAB", 1361},
+	{"KOI8-R", 20866},
+	{"KOI8-U", 21866},
+	{"KS_C_5601-1987", 949},
+	{"LATIN1", 1252},
+	{"LATIN2", 28592},
+	{"MACINTOSH", 10000},
+	{"SHIFT-JIS", 932},
+	{"SHIFT_JIS", 932},
+	{"SJIS", 932},
+	{"US", 1252},
+	{"US-ASCII", 1252},
+	{"UTF-16", 1200},
+	{"UTF-16BE", 1201},
+	{"UTF-16LE", 1200},
+	{"UTF-8", CP_UTF8},
+	{"X-EUROPA", 29001},
+	{"X-MAC-ARABIC", 10004},
+	{"X-MAC-CE", 10029},
+	{"X-MAC-CHINESEIMP", 10008},
+	{"X-MAC-CHINESETRAD", 10002},
+	{"X-MAC-CROATIAN", 10082},
+	{"X-MAC-CYRILLIC", 10007},
+	{"X-MAC-GREEK", 10006},
+	{"X-MAC-HEBREW", 10005},
+	{"X-MAC-ICELANDIC", 10079},
+	{"X-MAC-JAPANESE", 10001},
+	{"X-MAC-KOREAN", 10003},
+	{"X-MAC-ROMANIAN", 10010},
+	{"X-MAC-THAI", 10021},
+	{"X-MAC-TURKISH", 10081},
+	{"X-MAC-UKRAINIAN", 10017},
+};
+static unsigned
+make_codepage_from_charset(const char *charset)
+{
+	char cs[16];
+	char *p;
+	unsigned cp;
+	int a, b;
+
+	if (charset == NULL || strlen(charset) > 15)
+		return -1;
+
+	/* Copy name to uppercase. */
+	p = cs;
+	while (*charset) {
+		char c = *charset++;
+		if (c >= 'a' && c <= 'z')
+			c -= 'a' - 'A';
+		*p++ = c;
+	}
+	*p++ = '\0';
+	cp = -1;
+
+	/* Look it up in the table first, so that we can easily
+	 * override CP367, which we map to 1252 instead of 367. */
+	a = 0;
+	b = sizeof(charsets)/sizeof(charsets[0]);
+	while (b > a) {
+		int c = (b + a) / 2;
+		int r = strcmp(charsets[c].name, cs);
+		if (r < 0)
+			a = c + 1;
+		else if (r > 0)
+			b = c;
+		else
+			return charsets[c].cp;
+	}
+
+	/* If it's not in the table, try to parse it. */
+	switch (*cs) {
+	case 'C':
+		if (cs[1] == 'P' && cs[2] >= '0' && cs[2] <= '9') {
+			cp = my_atoi(cs + 2);
+		} else if (strcmp(cs, "CP_ACP") == 0)
+			cp = get_current_codepage();
+		else if (strcmp(cs, "CP_OEMCP") == 0)
+			cp = get_current_oemcp();
+		break;
+	case 'I':
+		if (cs[1] == 'B' && cs[2] == 'M' &&
+		    cs[3] >= '0' && cs[3] <= '9') {
+			cp = my_atoi(cs + 3);
+		}
+		break;
+	case 'W':
+		if (strncmp(cs, "WINDOWS-", 8) == 0) {
+			cp = my_atoi(cs + 8);
+			if (cp != 874 && (cp < 1250 || cp > 1258))
+				cp = -1;/* This may invalid code. */
+		}
+		break;
+	}
+	return (cp);
+}
+
+/*
+ * Return ANSI Code Page of current locale set by setlocale().
+ */
+static unsigned
+get_current_codepage(void)
+{
+	char *locale, *p;
+	unsigned cp;
+
+	locale = setlocale(LC_CTYPE, NULL);
+	if (locale == NULL)
+		return (GetACP());
+	if (locale[0] == 'C' && locale[1] == '\0')
+		return (CP_C_LOCALE);
+	p = strrchr(locale, '.');
+	if (p == NULL)
+		return (GetACP());
+	cp = my_atoi(p+1);
+	if (cp <= 0)
+		return (GetACP());
+	return (cp);
+}
+
+/*
+ * Translation table between Locale Name and ACP/OEMCP.
+ */
+static struct {
+	unsigned acp;
+	unsigned ocp;
+	const char *locale;
+} acp_ocp_map[] = {
+	{  950,  950, "Chinese_Taiwan" },
+	{  936,  936, "Chinese_People's Republic of China" },
+	{  950,  950, "Chinese_Taiwan" },
+	{ 1250,  852, "Czech_Czech Republic" },
+	{ 1252,  850, "Danish_Denmark" },
+	{ 1252,  850, "Dutch_Netherlands" },
+	{ 1252,  850, "Dutch_Belgium" },
+	{ 1252,  437, "English_United States" },
+	{ 1252,  850, "English_Australia" },
+	{ 1252,  850, "English_Canada" },
+	{ 1252,  850, "English_New Zealand" },
+	{ 1252,  850, "English_United Kingdom" },
+	{ 1252,  437, "English_United States" },
+	{ 1252,  850, "Finnish_Finland" },
+	{ 1252,  850, "French_France" },
+	{ 1252,  850, "French_Belgium" },
+	{ 1252,  850, "French_Canada" },
+	{ 1252,  850, "French_Switzerland" },
+	{ 1252,  850, "German_Germany" },
+	{ 1252,  850, "German_Austria" },
+	{ 1252,  850, "German_Switzerland" },
+	{ 1253,  737, "Greek_Greece" },
+	{ 1250,  852, "Hungarian_Hungary" },
+	{ 1252,  850, "Icelandic_Iceland" },
+	{ 1252,  850, "Italian_Italy" },
+	{ 1252,  850, "Italian_Switzerland" },
+	{  932,  932, "Japanese_Japan" },
+	{  949,  949, "Korean_Korea" },
+	{ 1252,  850, "Norwegian (BokmOl)_Norway" },
+	{ 1252,  850, "Norwegian (BokmOl)_Norway" },
+	{ 1252,  850, "Norwegian-Nynorsk_Norway" },
+	{ 1250,  852, "Polish_Poland" },
+	{ 1252,  850, "Portuguese_Portugal" },
+	{ 1252,  850, "Portuguese_Brazil" },
+	{ 1251,  866, "Russian_Russia" },
+	{ 1250,  852, "Slovak_Slovakia" },
+	{ 1252,  850, "Spanish_Spain" },
+	{ 1252,  850, "Spanish_Mexico" },
+	{ 1252,  850, "Spanish_Spain" },
+	{ 1252,  850, "Swedish_Sweden" },
+	{ 1254,  857, "Turkish_Turkey" },
+	{ 0, 0, NULL}
+};
+
+/*
+ * Return OEM Code Page of current locale set by setlocale().
+ */
+static unsigned
+get_current_oemcp(void)
+{
+	int i;
+	char *locale, *p;
+	size_t len;
+
+	locale = setlocale(LC_CTYPE, NULL);
+	if (locale == NULL)
+		return (GetOEMCP());
+	if (locale[0] == 'C' && locale[1] == '\0')
+		return (CP_C_LOCALE);
+
+	p = strrchr(locale, '.');
+	if (p == NULL)
+		return (GetOEMCP());
+	len = p - locale;
+	for (i = 0; acp_ocp_map[i].acp; i++) {
+		if (strncmp(acp_ocp_map[i].locale, locale, len) == 0)
+			return (acp_ocp_map[i].ocp);
+	}
+	return (GetOEMCP());
+}
+#else
+
+/*
+ * POSIX platform does not use CodePage.
+ */
+
+static unsigned
+get_current_codepage(void)
+{
+	return (-1);/* Unknown */
+}
+static unsigned
+make_codepage_from_charset(const char *charset)
+{
+	(void)charset; /* UNUSED */
+	return (-1);/* Unknown */
+}
+static unsigned
+get_current_oemcp(void)
+{
+	return (-1);/* Unknown */
+}
+
+#endif /* defined(_WIN32) && !defined(__CYGWIN__) */
+
+/*
+ * Return a string conversion object.
+ */
+static struct archive_string_conv *
+get_sconv_object(struct archive *a, const char *fc, const char *tc, int flag)
+{
+	struct archive_string_conv *sc;
+	unsigned current_codepage;
+
+	/* Check if we have made the sconv object. */
+	sc = find_sconv_object(a, fc, tc);
+	if (sc != NULL)
+		return (sc);
+
+	if (a == NULL)
+		current_codepage = get_current_codepage();
+	else
+		current_codepage = a->current_codepage;
+
+	sc = create_sconv_object(canonical_charset_name(fc),
+	    canonical_charset_name(tc), current_codepage, flag);
+	if (sc == NULL) {
+		if (a != NULL)
+			archive_set_error(a, ENOMEM,
+			    "Could not allocate memory for "
+			    "a string conversion object");
+		return (NULL);
+	}
+
+	/*
+	 * If there is no converter for current string conversion object,
+	 * we cannot handle this conversion.
+	 */
+	if (sc->nconverter == 0) {
+		if (a != NULL) {
+#if HAVE_ICONV
+			archive_set_error(a, ARCHIVE_ERRNO_MISC,
+			    "iconv_open failed : Cannot handle ``%s''",
+			    (flag & SCONV_TO_CHARSET)?tc:fc);
+#else
+			archive_set_error(a, ARCHIVE_ERRNO_MISC,
+			    "A character-set conversion not fully supported "
+			    "on this platform");
+#endif
+		}
+		/* Failed; free a sconv object. */
+		free_sconv_object(sc);
+		return (NULL);
+	}
+
+	/*
+	 * Success!
+	 */
+	if (a != NULL)
+		add_sconv_object(a, sc);
+	return (sc);
+}
+
+static const char *
+get_current_charset(struct archive *a)
+{
+	const char *cur_charset;
+
+	if (a == NULL)
+		cur_charset = default_iconv_charset("");
+	else {
+		cur_charset = default_iconv_charset(a->current_code);
+		if (a->current_code == NULL) {
+			a->current_code = strdup(cur_charset);
+			a->current_codepage = get_current_codepage();
+			a->current_oemcp = get_current_oemcp();
+		}
+	}
+	return (cur_charset);
+}
+
+/*
+ * Make and Return a string conversion object.
+ * Return NULL if the platform does not support the specified conversion
+ * and best_effort is 0.
+ * If best_effort is set, A string conversion object must be returned
+ * unless memory allocation for the object fails, but the conversion
+ * might fail when non-ASCII code is found.
+ */
+struct archive_string_conv *
+archive_string_conversion_to_charset(struct archive *a, const char *charset,
+    int best_effort)
+{
+	int flag = SCONV_TO_CHARSET;
+
+	if (best_effort)
+		flag |= SCONV_BEST_EFFORT;
+	return (get_sconv_object(a, get_current_charset(a), charset, flag));
+}
+
+struct archive_string_conv *
+archive_string_conversion_from_charset(struct archive *a, const char *charset,
+    int best_effort)
+{
+	int flag = SCONV_FROM_CHARSET;
+
+	if (best_effort)
+		flag |= SCONV_BEST_EFFORT;
+	return (get_sconv_object(a, charset, get_current_charset(a), flag));
+}
+
+/*
+ * archive_string_default_conversion_*_archive() are provided for Windows
+ * platform because other archiver application use CP_OEMCP for
+ * MultiByteToWideChar() and WideCharToMultiByte() for the filenames
+ * in tar or zip files. But mbstowcs/wcstombs(CRT) usually use CP_ACP
+ * unless you use setlocale(LC_ALL, ".OCP")(specify CP_OEMCP).
+ * So we should make a string conversion between CP_ACP and CP_OEMCP
+ * for compatibillty.
+ */
+#if defined(_WIN32) && !defined(__CYGWIN__)
+struct archive_string_conv *
+archive_string_default_conversion_for_read(struct archive *a)
+{
+	const char *cur_charset = get_current_charset(a);
+	char oemcp[16];
+
+	/* NOTE: a check of cur_charset is unneeded but we need
+	 * that get_current_charset() has been surely called at
+	 * this time whatever C compiler optimized. */
+	if (cur_charset != NULL &&
+	    (a->current_codepage == CP_C_LOCALE ||
+	     a->current_codepage == a->current_oemcp))
+		return (NULL);/* no conversion. */
+
+	_snprintf(oemcp, sizeof(oemcp)-1, "CP%d", a->current_oemcp);
+	/* Make sure a null termination must be set. */
+	oemcp[sizeof(oemcp)-1] = '\0';
+	return (get_sconv_object(a, oemcp, cur_charset,
+	    SCONV_FROM_CHARSET));
+}
+
+struct archive_string_conv *
+archive_string_default_conversion_for_write(struct archive *a)
+{
+	const char *cur_charset = get_current_charset(a);
+	char oemcp[16];
+
+	/* NOTE: a check of cur_charset is unneeded but we need
+	 * that get_current_charset() has been surely called at
+	 * this time whatever C compiler optimized. */
+	if (cur_charset != NULL &&
+	    (a->current_codepage == CP_C_LOCALE ||
+	     a->current_codepage == a->current_oemcp))
+		return (NULL);/* no conversion. */
+
+	_snprintf(oemcp, sizeof(oemcp)-1, "CP%d", a->current_oemcp);
+	/* Make sure a null termination must be set. */
+	oemcp[sizeof(oemcp)-1] = '\0';
+	return (get_sconv_object(a, cur_charset, oemcp,
+	    SCONV_TO_CHARSET));
+}
+#else
+struct archive_string_conv *
+archive_string_default_conversion_for_read(struct archive *a)
+{
+	(void)a; /* UNUSED */
+	return (NULL);
+}
+
+struct archive_string_conv *
+archive_string_default_conversion_for_write(struct archive *a)
+{
+	(void)a; /* UNUSED */
+	return (NULL);
+}
+#endif
+
+/*
+ * Dispose of all character conversion objects in the archive object.
+ */
+void
+archive_string_conversion_free(struct archive *a)
+{
+	struct archive_string_conv *sc; 
+	struct archive_string_conv *sc_next; 
+
+	for (sc = a->sconv; sc != NULL; sc = sc_next) {
+		sc_next = sc->next;
+		free_sconv_object(sc);
+	}
+	a->sconv = NULL;
+	free(a->current_code);
+	a->current_code = NULL;
+}
+
+/*
+ * Return a conversion charset name.
+ */
+const char *
+archive_string_conversion_charset_name(struct archive_string_conv *sc)
+{
+	if (sc->flag & SCONV_TO_CHARSET)
+		return (sc->to_charset);
+	else
+		return (sc->from_charset);
+}
+
+/*
+ * Change the behavior of a string conversion.
+ */
+void
+archive_string_conversion_set_opt(struct archive_string_conv *sc, int opt)
+{
+	switch (opt) {
+	/*
+	 * A filename in UTF-8 was made with libarchive 2.x in a wrong
+	 * assumption that wchar_t was Unicode.
+	 * This option enables simulating the assumption in order to read
+	 * that filname correctly.
+	 */
+	case SCONV_SET_OPT_UTF8_LIBARCHIVE2X:
+#if (defined(_WIN32) && !defined(__CYGWIN__)) \
+	 || defined(__STDC_ISO_10646__) || defined(__APPLE__)
+		/*
+		 * Nothing to do for it since wchar_t on these platforms
+		 * is really Unicode.
+		 */
+		(void)sc; /* UNUSED */
+#else
+		if ((sc->flag & SCONV_UTF8_LIBARCHIVE_2) == 0) {
+			sc->flag |= SCONV_UTF8_LIBARCHIVE_2;
+			/* Re-setup string converters. */
+			setup_converter(sc);
+		}
+#endif
+		break;
+	default:
+		break;
+	}
+}
+
+/*
+ *
+ * Copy one archive_string to another in locale conversion.
+ *
+ *	archive_strncpy_in_locale();
+ *	archive_strcpy_in_locale();
+ *
+ */
+
+static size_t
+mbsnbytes(const void *_p, size_t n)
+{
+	size_t s;
+	const char *p, *pp;
+
+	if (_p == NULL)
+		return (0);
+	p = (const char *)_p;
+
+	/* Like strlen(p), except won't examine positions beyond p[n]. */
+	s = 0;
+	pp = p;
+	while (s < n && *pp) {
+		pp++;
+		s++;
+	}
+	return (s);
+}
+
+static size_t
+utf16nbytes(const void *_p, size_t n)
+{
+	size_t s;
+	const char *p, *pp;
+
+	if (_p == NULL)
+		return (0);
+	p = (const char *)_p;
+
+	/* Like strlen(p), except won't examine positions beyond p[n]. */
+	s = 0;
+	pp = p;
+	n >>= 1;
+	while (s < n && (pp[0] || pp[1])) {
+		pp += 2;
+		s++;
+	}
+	return (s<<1);
+}
+
+int
+archive_strncpy_in_locale(struct archive_string *as, const void *_p, size_t n,
+    struct archive_string_conv *sc)
+{
+	as->length = 0;
+	return (archive_strncat_in_locale(as, _p, n, sc));
+}
+
+int
+archive_strncat_in_locale(struct archive_string *as, const void *_p, size_t n,
+    struct archive_string_conv *sc)
+{
+	const void *s;
+	size_t length;
+	int i, r = 0, r2;
+
+	/* We must allocate memory even if there is no data for conversion
+	 * or copy. This simulates archive_string_append behavior. */
+	if (_p == NULL || n == 0) {
+		int tn = 1;
+		if (sc != NULL && (sc->flag & SCONV_TO_UTF16))
+			tn = 2;
+		if (archive_string_ensure(as, as->length + tn) == NULL)
+			return (-1);
+		as->s[as->length] = 0;
+		if (tn == 2)
+			as->s[as->length+1] = 0;
+		return (0);
+	}
+
+	/*
+	 * If sc is NULL, we just make a copy.
+	 */
+	if (sc == NULL) {
+		length = mbsnbytes(_p, n);
+		if (archive_string_append(as, _p, length) == NULL)
+			return (-1);/* No memory */
+		return (0);
+	}
+
+	if (sc->flag & SCONV_FROM_UTF16)
+		length = utf16nbytes(_p, n);
+	else
+		length = mbsnbytes(_p, n);
+	s = _p;
+	i = 0;
+	if (sc->nconverter > 1) {
+		sc->utftmp.length = 0;
+		r2 = sc->converter[0](&(sc->utftmp), s, length, sc);
+		if (r2 != 0 && errno == ENOMEM)
+			return (r2);
+		if (r > r2)
+			r = r2;
+		s = sc->utftmp.s;
+		length = sc->utftmp.length;
+		++i;
+	}
+	r2 = sc->converter[i](as, s, length, sc);
+	if (r > r2)
+		r = r2;
+	return (r);
+}
+
+#if HAVE_ICONV
+
+/*
+ * Return -1 if conversion failes.
+ */
+static int
+iconv_strncat_in_locale(struct archive_string *as, const void *_p,
+    size_t length, struct archive_string_conv *sc)
+{
+	ICONV_CONST char *inp;
+	size_t remaining;
+	iconv_t cd;
+	char *outp;
+	size_t avail, bs;
+	int return_value = 0; /* success */
+	int to_size, from_size;
+
+	if (sc->flag & SCONV_TO_UTF16)
+		to_size = 2;
+	else
+		to_size = 1;
+	if (sc->flag & SCONV_FROM_UTF16)
+		from_size = 2;
+	else
+		from_size = 1;
+
+	if (archive_string_ensure(as, as->length + length*2+to_size) == NULL)
+		return (-1);
+
+	cd = sc->cd;
+	inp = (char *)(uintptr_t)_p;
+	remaining = length;
+	outp = as->s + as->length;
+	avail = as->buffer_length - as->length - to_size;
+	while (remaining >= (size_t)from_size) {
+		size_t result = iconv(cd, &inp, &remaining, &outp, &avail);
+
+		if (result != (size_t)-1)
+			break; /* Conversion completed. */
+
+		if (errno == EILSEQ || errno == EINVAL) {
+			/*
+		 	 * If an output charset is UTF-8 or UTF-16BE/LE,
+			 * unknown character should be U+FFFD
+			 * (replacement character).
+			 */
+			if (sc->flag & (SCONV_TO_UTF8 | SCONV_TO_UTF16)) {
+				size_t rbytes;
+				if (sc->flag & SCONV_TO_UTF8)
+					rbytes = UTF8_R_CHAR_SIZE;
+				else
+					rbytes = 2;
+
+				if (avail < rbytes) {
+					as->length = outp - as->s;
+					bs = as->buffer_length +
+					    (remaining * to_size) + rbytes;
+					if (NULL ==
+					    archive_string_ensure(as, bs))
+						return (-1);
+					outp = as->s + as->length;
+					avail = as->buffer_length
+					    - as->length - to_size;
+				}
+				if (sc->flag & SCONV_TO_UTF8)
+					UTF8_SET_R_CHAR(outp);
+				else if (sc->flag & SCONV_TO_UTF16BE)
+					archive_be16enc(outp, UNICODE_R_CHAR);
+				else
+					archive_le16enc(outp, UNICODE_R_CHAR);
+				outp += rbytes;
+				avail -= rbytes;
+			} else {
+				/* Skip the illegal input bytes. */
+				*outp++ = '?';
+				avail--;
+			}
+			inp += from_size;
+			remaining -= from_size;
+			return_value = -1; /* failure */
+		} else {
+			/* E2BIG no output buffer,
+			 * Increase an output buffer.  */
+			as->length = outp - as->s;
+			bs = as->buffer_length + remaining * 2;
+			if (NULL == archive_string_ensure(as, bs))
+				return (-1);
+			outp = as->s + as->length;
+			avail = as->buffer_length - as->length - to_size;
+		}
+	}
+	as->length = outp - as->s;
+	as->s[as->length] = 0;
+	if (to_size == 2)
+		as->s[as->length+1] = 0;
+	return (return_value);
+}
+
+#endif /* HAVE_ICONV */
+
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+
+/*
+ * Translate a string from a some CodePage to an another CodePage by
+ * Windows APIs, and copy the result. Return -1 if conversion failes.
+ */
+static int
+strncat_in_codepage(struct archive_string *as,
+    const void *_p, size_t length, struct archive_string_conv *sc)
+{
+	const char *s = (const char *)_p;
+	struct archive_wstring aws;
+	size_t l;
+	int r, saved_flag;
+
+	archive_string_init(&aws);
+	saved_flag = sc->flag;
+	sc->flag &= ~(SCONV_NORMALIZATION_D | SCONV_NORMALIZATION_C);
+	r = archive_wstring_append_from_mbs_in_codepage(&aws, s, length, sc);
+	sc->flag = saved_flag;
+	if (r != 0) {
+		archive_wstring_free(&aws);
+		if (errno != ENOMEM)
+			archive_string_append(as, s, length);
+		return (-1);
+	}
+
+	l = as->length;
+	r = archive_string_append_from_wcs_in_codepage(
+	    as, aws.s, aws.length, sc);
+	if (r != 0 && errno != ENOMEM && l == as->length)
+		archive_string_append(as, s, length);
+	archive_wstring_free(&aws);
+	return (r);
+}
+
+/*
+ * Test whether MBS ==> WCS is okay.
+ */
+static int
+invalid_mbs(const void *_p, size_t n, struct archive_string_conv *sc)
+{
+	const char *p = (const char *)_p;
+	unsigned codepage;
+	DWORD mbflag = MB_ERR_INVALID_CHARS;
+
+	if (sc->flag & SCONV_FROM_CHARSET)
+		codepage = sc->to_cp;
+	else
+		codepage = sc->from_cp;
+
+	if (codepage == CP_C_LOCALE)
+		return (0);
+	if (codepage != CP_UTF8)
+		mbflag |= MB_PRECOMPOSED;
+
+	if (MultiByteToWideChar(codepage, mbflag, p, n, NULL, 0) == 0)
+		return (-1); /* Invalid */
+	return (0); /* Okay */
+}
+
+#else
+
+/*
+ * Test whether MBS ==> WCS is okay.
+ */
+static int
+invalid_mbs(const void *_p, size_t n, struct archive_string_conv *sc)
+{
+	const char *p = (const char *)_p;
+	size_t r;
+
+	(void)sc; /* UNUSED */
+#if HAVE_MBRTOWC
+	mbstate_t shift_state;
+
+	memset(&shift_state, 0, sizeof(shift_state));
+#else
+	/* Clear the shift state before starting. */
+	mbtowc(NULL, NULL, 0);
+#endif
+	while (n) {
+		wchar_t wc;
+
+#if HAVE_MBRTOWC
+		r = mbrtowc(&wc, p, n, &shift_state);
+#else
+		r = mbtowc(&wc, p, n);
+#endif
+		if (r == (size_t)-1 || r == (size_t)-2)
+			return (-1);/* Invalid. */
+		if (r == 0)
+			break;
+		p += r;
+		n -= r;
+	}
+	return (0); /* All Okey. */
+}
+
+#endif /* defined(_WIN32) && !defined(__CYGWIN__) */
+
+/*
+ * Basically returns -1 because we cannot make a conversion of charset
+ * without iconv but in some cases this would return 0.
+ * Returns 0 if all copied characters are ASCII.
+ * Returns 0 if both from-locale and to-locale are the same and those
+ * can be WCS with no error.
+ */
+static int
+best_effort_strncat_in_locale(struct archive_string *as, const void *_p,
+    size_t length, struct archive_string_conv *sc)
+{
+	size_t remaining;
+	char *outp;
+	const uint8_t *inp;
+	size_t avail;
+	int return_value = 0; /* success */
+
+	/*
+	 * If both from-locale and to-locale is the same, this makes a copy.
+	 * And then this checks all copied MBS can be WCS if so returns 0.
+	 */
+	if (sc->same) {
+		if (archive_string_append(as, _p, length) == NULL)
+			return (-1);/* No memory */
+		return (invalid_mbs(_p, length, sc));
+	}
+
+	/*
+	 * If a character is ASCII, this just copies it. If not, this
+	 * assigns '?' charater instead but in UTF-8 locale this assigns
+	 * byte sequence 0xEF 0xBD 0xBD, which are code point U+FFFD,
+	 * a Replacement Character in Unicode.
+	 */
+	if (archive_string_ensure(as, as->length + length + 1) == NULL)
+		return (-1);
+
+	remaining = length;
+	inp = (const uint8_t *)_p;
+	outp = as->s + as->length;
+	avail = as->buffer_length - as->length -1;
+	while (*inp && remaining > 0) {
+		if (*inp > 127 && (sc->flag & SCONV_TO_UTF8)) {
+			if (avail < UTF8_R_CHAR_SIZE) {
+				as->length = outp - as->s;
+				if (NULL == archive_string_ensure(as,
+				    as->buffer_length + remaining +
+				    UTF8_R_CHAR_SIZE))
+					return (-1);
+				outp = as->s + as->length;
+				avail = as->buffer_length - as->length -1;
+			}
+			/*
+		 	 * When coping a string in UTF-8, unknown character
+			 * should be U+FFFD (replacement character).
+			 */
+			UTF8_SET_R_CHAR(outp);
+			outp += UTF8_R_CHAR_SIZE;
+			avail -= UTF8_R_CHAR_SIZE;
+			inp++;
+			remaining--;
+			return_value = -1;
+		} else if (*inp > 127) {
+			*outp++ = '?';
+			inp++;
+			remaining--;
+			return_value = -1;
+		} else {
+			*outp++ = (char)*inp++;
+			remaining--;
+		}
+	}
+	as->length = outp - as->s;
+	as->s[as->length] = '\0';
+	return (return_value);
+}
+
+
+/*
+ * Unicode conversion functions.
+ *   - UTF-8 <===> UTF-8 in removing surrogate pairs.
+ *   - UTF-8 NFD ===> UTF-8 NFC in removing surrogate pairs.
+ *   - UTF-8 made by libarchive 2.x ===> UTF-8.
+ *   - UTF-16BE <===> UTF-8.
+ *
+ */
+
+/*
+ * Utility to convert a single UTF-8 sequence.
+ *
+ * Usually return used bytes, return used byte in negative value when
+ * a unicode character is replaced with U+FFFD.
+ * See also http://unicode.org/review/pr-121.html Public Review Issue #121
+ * Recommended Practice for Replacement Characters.
+ */
+static int
+_utf8_to_unicode(uint32_t *pwc, const char *s, size_t n)
+{
+	static const char utf8_count[256] = {
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 00 - 0F */
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 10 - 1F */
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 20 - 2F */
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 30 - 3F */
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 40 - 4F */
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 50 - 5F */
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 60 - 6F */
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 70 - 7F */
+		 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,/* 80 - 8F */
+		 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,/* 90 - 9F */
+		 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,/* A0 - AF */
+		 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,/* B0 - BF */
+		 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,/* C0 - CF */
+		 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,/* D0 - DF */
+		 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,/* E0 - EF */
+		 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* F0 - FF */
+	};
+	int ch, i;
+	int cnt;
+	uint32_t wc;
+
+	/* Sanity check. */
+	if (n == 0)
+		return (0);
+	/*
+	 * Decode 1-4 bytes depending on the value of the first byte.
+	 */
+	ch = (unsigned char)*s;
+	if (ch == 0)
+		return (0); /* Standard:  return 0 for end-of-string. */
+	cnt = utf8_count[ch];
+
+	/* Invalide sequence or there are not plenty bytes. */
+	if ((int)n < cnt) {
+		cnt = n;
+		for (i = 1; i < cnt; i++) {
+			if ((s[i] & 0xc0) != 0x80) {
+				cnt = i;
+				break;
+			}
+		}
+		goto invalid_sequence;
+	}
+
+	/* Make a Unicode code point from a single UTF-8 sequence. */
+	switch (cnt) {
+	case 1:	/* 1 byte sequence. */
+		*pwc = ch & 0x7f;
+		return (cnt);
+	case 2:	/* 2 bytes sequence. */
+		if ((s[1] & 0xc0) != 0x80) {
+			cnt = 1;
+			goto invalid_sequence;
+		}
+		*pwc = ((ch & 0x1f) << 6) | (s[1] & 0x3f);
+		return (cnt);
+	case 3:	/* 3 bytes sequence. */
+		if ((s[1] & 0xc0) != 0x80) {
+			cnt = 1;
+			goto invalid_sequence;
+		}
+		if ((s[2] & 0xc0) != 0x80) {
+			cnt = 2;
+			goto invalid_sequence;
+		}
+		wc = ((ch & 0x0f) << 12)
+		    | ((s[1] & 0x3f) << 6)
+		    | (s[2] & 0x3f);
+		if (wc < 0x800)
+			goto invalid_sequence;/* Overlong sequence. */
+		break;
+	case 4:	/* 4 bytes sequence. */
+		if ((s[1] & 0xc0) != 0x80) {
+			cnt = 1;
+			goto invalid_sequence;
+		}
+		if ((s[2] & 0xc0) != 0x80) {
+			cnt = 2;
+			goto invalid_sequence;
+		}
+		if ((s[3] & 0xc0) != 0x80) {
+			cnt = 3;
+			goto invalid_sequence;
+		}
+		wc = ((ch & 0x07) << 18)
+		    | ((s[1] & 0x3f) << 12)
+		    | ((s[2] & 0x3f) << 6)
+		    | (s[3] & 0x3f);
+		if (wc < 0x10000)
+			goto invalid_sequence;/* Overlong sequence. */
+		break;
+	default: /* Others are all invalid sequence. */
+		if (ch == 0xc0 || ch == 0xc1)
+			cnt = 2;
+		else if (ch >= 0xf5 && ch <= 0xf7)
+			cnt = 4;
+		else if (ch >= 0xf8 && ch <= 0xfb)
+			cnt = 5;
+		else if (ch == 0xfc || ch == 0xfd)
+			cnt = 6;
+		else
+			cnt = 1;
+		if ((int)n < cnt)
+			cnt = n;
+		for (i = 1; i < cnt; i++) {
+			if ((s[i] & 0xc0) != 0x80) {
+				cnt = i;
+				break;
+			}
+		}
+		goto invalid_sequence;
+	}
+
+	/* The code point larger than 0x10FFFF is not leagal
+	 * Unicode values. */
+	if (wc > UNICODE_MAX)
+		goto invalid_sequence;
+	/* Correctly gets a Unicode, returns used bytes. */
+	*pwc = wc;
+	return (cnt);
+invalid_sequence:
+	*pwc = UNICODE_R_CHAR;/* set the Replacement Character instead. */
+	return (cnt * -1);
+}
+
+static int
+utf8_to_unicode(uint32_t *pwc, const char *s, size_t n)
+{
+	int cnt;
+
+	cnt = _utf8_to_unicode(pwc, s, n);
+	/* Any of Surrogate pair is not leagal Unicode values. */
+	if (cnt == 3 && IS_SURROGATE_PAIR_LA(*pwc))
+		return (-3);
+	return (cnt);
+}
+
+static inline uint32_t
+combine_surrogate_pair(uint32_t uc, uint32_t uc2)
+{
+	uc -= 0xD800;
+	uc *= 0x400;
+	uc += uc2 - 0xDC00;
+	uc += 0x10000;
+	return (uc);
+}
+
+/*
+ * Convert a single UTF-8/CESU-8 sequence to a Unicode code point in
+ * removing surrogate pairs.
+ *
+ * CESU-8: The Compatibility Encoding Scheme for UTF-16.
+ *
+ * Usually return used bytes, return used byte in negative value when
+ * a unicode character is replaced with U+FFFD.
+ */
+static int
+cesu8_to_unicode(uint32_t *pwc, const char *s, size_t n)
+{
+	uint32_t wc, wc2;
+	int cnt;
+
+	cnt = _utf8_to_unicode(&wc, s, n);
+	if (cnt == 3 && IS_HIGH_SURROGATE_LA(wc)) {
+		if (n - 3 < 3) {
+			/* Invalid byte sequence. */
+			goto invalid_sequence;
+		}
+		cnt = _utf8_to_unicode(&wc2, s+3, n-3);
+		if (cnt != 3 || !IS_LOW_SURROGATE_LA(wc2)) {
+			/* Invalid byte sequence. */
+			goto invalid_sequence;
+		}
+		wc = combine_surrogate_pair(wc, wc2);
+		cnt = 6;
+	} else if (cnt == 3 && IS_LOW_SURROGATE_LA(wc)) {
+		/* Invalid byte sequence. */
+		goto invalid_sequence;
+	}
+	*pwc = wc;
+	return (cnt);
+invalid_sequence:
+	*pwc = UNICODE_R_CHAR;/* set the Replacement Character instead. */
+	if (cnt > 0)
+		cnt *= -1;
+	return (cnt);
+}
+
+/*
+ * Convert a Unicode code point to a single UTF-8 sequence.
+ *
+ * NOTE:This function does not check if the Unicode is leagal or not.
+ * Please you definitely check it before calling this.
+ */
+static size_t
+unicode_to_utf8(char *p, size_t remaining, uint32_t uc)
+{
+	char *_p = p;
+
+	/* Translate code point to UTF8 */
+	if (uc <= 0x7f) {
+		if (remaining == 0)
+			return (0);
+		*p++ = (char)uc;
+	} else if (uc <= 0x7ff) {
+		if (remaining < 2)
+			return (0);
+		*p++ = 0xc0 | ((uc >> 6) & 0x1f);
+		*p++ = 0x80 | (uc & 0x3f);
+	} else if (uc <= 0xffff) {
+		if (remaining < 3)
+			return (0);
+		*p++ = 0xe0 | ((uc >> 12) & 0x0f);
+		*p++ = 0x80 | ((uc >> 6) & 0x3f);
+		*p++ = 0x80 | (uc & 0x3f);
+	} else if (uc <= UNICODE_MAX) {
+		if (remaining < 4)
+			return (0);
+		*p++ = 0xf0 | ((uc >> 18) & 0x07);
+		*p++ = 0x80 | ((uc >> 12) & 0x3f);
+		*p++ = 0x80 | ((uc >> 6) & 0x3f);
+		*p++ = 0x80 | (uc & 0x3f);
+	} else {
+		/*
+		 * Undescribed code point should be U+FFFD
+		 * (replacement character).
+		 */
+		if (remaining < UTF8_R_CHAR_SIZE)
+			return (0);
+		UTF8_SET_R_CHAR(p);
+		p += UTF8_R_CHAR_SIZE;
+	}
+	return (p - _p);
+}
+
+static int
+utf16be_to_unicode(uint32_t *pwc, const char *s, size_t n)
+{
+	return (utf16_to_unicode(pwc, s, n, 1));
+}
+
+static int
+utf16le_to_unicode(uint32_t *pwc, const char *s, size_t n)
+{
+	return (utf16_to_unicode(pwc, s, n, 0));
+}
+
+static int
+utf16_to_unicode(uint32_t *pwc, const char *s, size_t n, int be)
+{
+	const char *utf16 = s;
+	unsigned uc;
+
+	if (n == 0)
+		return (0);
+	if (n == 1) {
+		/* set the Replacement Character instead. */
+		*pwc = UNICODE_R_CHAR;
+		return (-1);
+	}
+
+	if (be)
+		uc = archive_be16dec(utf16);
+	else
+		uc = archive_le16dec(utf16);
+	utf16 += 2;
+		
+	/* If this is a surrogate pair, assemble the full code point.*/
+	if (IS_HIGH_SURROGATE_LA(uc)) {
+		unsigned uc2;
+
+		if (n >= 4) {
+			if (be)
+				uc2 = archive_be16dec(utf16);
+			else
+				uc2 = archive_le16dec(utf16);
+		} else
+			uc2 = 0;
+		if (IS_LOW_SURROGATE_LA(uc2)) {
+			uc = combine_surrogate_pair(uc, uc2);
+			utf16 += 2;
+		} else {
+	 		/* Undescribed code point should be U+FFFD
+		 	* (replacement character). */
+			*pwc = UNICODE_R_CHAR;
+			return (-2);
+		}
+	}
+
+	/*
+	 * Surrogate pair values(0xd800 through 0xdfff) are only
+	 * used by UTF-16, so, after above culculation, the code
+	 * must not be surrogate values, and Unicode has no codes
+	 * larger than 0x10ffff. Thus, those are not leagal Unicode
+	 * values.
+	 */
+	if (IS_SURROGATE_PAIR_LA(uc) || uc > UNICODE_MAX) {
+	 	/* Undescribed code point should be U+FFFD
+	 	* (replacement character). */
+		*pwc = UNICODE_R_CHAR;
+		return (((int)(utf16 - s)) * -1);
+	}
+	*pwc = uc;
+	return ((int)(utf16 - s));
+}
+
+static size_t
+unicode_to_utf16be(char *p, size_t remaining, uint32_t uc)
+{
+	char *utf16 = p;
+
+	if (uc > 0xffff) {
+		/* We have a code point that won't fit into a
+		 * wchar_t; convert it to a surrogate pair. */
+		if (remaining < 4)
+			return (0);
+		uc -= 0x10000;
+		archive_be16enc(utf16, ((uc >> 10) & 0x3ff) + 0xD800);
+		archive_be16enc(utf16+2, (uc & 0x3ff) + 0xDC00);
+		return (4);
+	} else {
+		if (remaining < 2)
+			return (0);
+		archive_be16enc(utf16, uc);
+		return (2);
+	}
+}
+
+static size_t
+unicode_to_utf16le(char *p, size_t remaining, uint32_t uc)
+{
+	char *utf16 = p;
+
+	if (uc > 0xffff) {
+		/* We have a code point that won't fit into a
+		 * wchar_t; convert it to a surrogate pair. */
+		if (remaining < 4)
+			return (0);
+		uc -= 0x10000;
+		archive_le16enc(utf16, ((uc >> 10) & 0x3ff) + 0xD800);
+		archive_le16enc(utf16+2, (uc & 0x3ff) + 0xDC00);
+		return (4);
+	} else {
+		if (remaining < 2)
+			return (0);
+		archive_le16enc(utf16, uc);
+		return (2);
+	}
+}
+
+/*
+ * Copy UTF-8 string in checking surrogate pair.
+ * If any surrogate pair are found, it would be canonicalized.
+ */
+static int
+strncat_from_utf8_to_utf8(struct archive_string *as, const void *_p, size_t len,
+    struct archive_string_conv *sc)
+{
+	const char *s;
+	char *p, *endp;
+	int n, ret = 0;
+
+	(void)sc; /* UNUSED */
+
+	if (archive_string_ensure(as, as->length + len + 1) == NULL)
+		return (-1);
+
+	s = (const char *)_p;
+	p = as->s + as->length;
+	endp = as->s + as->buffer_length -1;
+	do {
+		uint32_t uc;
+		const char *ss = s;
+		size_t w;
+
+		/*
+		 * Forward byte sequence until a conversion of that is needed.
+		 */
+		while ((n = utf8_to_unicode(&uc, s, len)) > 0) {
+			s += n;
+			len -= n;
+		}
+		if (ss < s) {
+			if (p + (s - ss) > endp) {
+				as->length = p - as->s;
+				if (archive_string_ensure(as,
+				    as->buffer_length + len + 1) == NULL)
+					return (-1);
+				p = as->s + as->length;
+				endp = as->s + as->buffer_length -1;
+			}
+
+			memcpy(p, ss, s - ss);
+			p += s - ss;
+		}
+
+		/*
+		 * If n is negative, current byte sequence needs a replacement.
+		 */
+		if (n < 0) {
+			if (n == -3 && IS_SURROGATE_PAIR_LA(uc)) {
+				/* Current byte sequence may be CESU-8. */
+				n = cesu8_to_unicode(&uc, s, len);
+			}
+			if (n < 0) {
+				ret = -1;
+				n *= -1;/* Use a replaced unicode character. */
+			}
+
+			/* Rebuild UTF-8 byte sequence. */
+			while ((w = unicode_to_utf8(p, endp - p, uc)) == 0) {
+				as->length = p - as->s;
+				if (archive_string_ensure(as,
+				    as->buffer_length + len + 1) == NULL)
+					return (-1);
+				p = as->s + as->length;
+				endp = as->s + as->buffer_length -1;
+			}
+			p += w;
+			s += n;
+			len -= n;
+		}
+	} while (n > 0);
+	as->length = p - as->s;
+	as->s[as->length] = '\0';
+	return (ret);
+}
+
+static int
+archive_string_append_unicode(struct archive_string *as, const void *_p,
+    size_t len, struct archive_string_conv *sc)
+{
+	const char *s;
+	char *p, *endp;
+	uint32_t uc;
+	size_t w;
+	int n, ret = 0, ts, tm;
+	int (*parse)(uint32_t *, const char *, size_t);
+	size_t (*unparse)(char *, size_t, uint32_t);
+
+	if (sc->flag & SCONV_TO_UTF16BE) {
+		unparse = unicode_to_utf16be;
+		ts = 2;
+	} else if (sc->flag & SCONV_TO_UTF16LE) {
+		unparse = unicode_to_utf16le;
+		ts = 2;
+	} else if (sc->flag & SCONV_TO_UTF8) {
+		unparse = unicode_to_utf8;
+		ts = 1;
+	} else {
+		/*
+		 * This case is going to be converted to another
+		 * character-set through iconv.
+		 */
+		if (sc->flag & SCONV_FROM_UTF16BE) {
+			unparse = unicode_to_utf16be;
+			ts = 2;
+		} else if (sc->flag & SCONV_FROM_UTF16LE) {
+			unparse = unicode_to_utf16le;
+			ts = 2;
+		} else {
+			unparse = unicode_to_utf8;
+			ts = 1;
+		}
+	}
+
+	if (sc->flag & SCONV_FROM_UTF16BE) {
+		parse = utf16be_to_unicode;
+		tm = 1;
+	} else if (sc->flag & SCONV_FROM_UTF16LE) {
+		parse = utf16le_to_unicode;
+		tm = 1;
+	} else {
+		parse = cesu8_to_unicode;
+		tm = ts;
+	}
+
+	if (archive_string_ensure(as, as->length + len * tm + ts) == NULL)
+		return (-1);
+
+	s = (const char *)_p;
+	p = as->s + as->length;
+	endp = as->s + as->buffer_length - ts;
+	while ((n = parse(&uc, s, len)) != 0) {
+		if (n < 0) {
+			/* Use a replaced unicode character. */
+			n *= -1;
+			ret = -1;
+		}
+		s += n;
+		len -= n;
+		while ((w = unparse(p, endp - p, uc)) == 0) {
+			/* There is not enough output buffer so
+			 * we have to expand it. */
+			as->length = p - as->s;
+			if (archive_string_ensure(as,
+			    as->buffer_length + len * tm + ts) == NULL)
+				return (-1);
+			p = as->s + as->length;
+			endp = as->s + as->buffer_length - ts;
+		}
+		p += w;
+	}
+	as->length = p - as->s;
+	as->s[as->length] = '\0';
+	if (ts == 2)
+		as->s[as->length+1] = '\0';
+	return (ret);
+}
+
+/*
+ * Following Constants for Hangul compositions this information comes from
+ * Unicode Standard Annex #15  http://unicode.org/reports/tr15/
+ */
+#define HC_SBASE	0xAC00
+#define HC_LBASE	0x1100
+#define HC_VBASE	0x1161
+#define HC_TBASE	0x11A7
+#define HC_LCOUNT	19
+#define HC_VCOUNT	21
+#define HC_TCOUNT	28
+#define HC_NCOUNT	(HC_VCOUNT * HC_TCOUNT)
+#define HC_SCOUNT	(HC_LCOUNT * HC_NCOUNT)
+
+static uint32_t
+get_nfc(uint32_t uc, uint32_t uc2)
+{
+	int t, b;
+
+	t = 0;
+	b = sizeof(u_composition_table)/sizeof(u_composition_table[0]) -1;
+	while (b >= t) {
+		int m = (t + b) / 2;
+		if (u_composition_table[m].cp1 < uc)
+			t = m + 1;
+		else if (u_composition_table[m].cp1 > uc)
+			b = m - 1;
+		else if (u_composition_table[m].cp2 < uc2)
+			t = m + 1;
+		else if (u_composition_table[m].cp2 > uc2)
+			b = m - 1;
+		else
+			return (u_composition_table[m].nfc);
+	}
+	return (0);
+}
+
+#define FDC_MAX 10	/* The maximum number of Following Decomposable
+			 * Characters. */
+
+/*
+ * Update first code point.
+ */
+#define UPDATE_UC(new_uc)	do {		\
+	uc = new_uc;				\
+	ucptr = NULL;				\
+} while (0)
+
+/*
+ * Replace first code point with second code point.
+ */
+#define REPLACE_UC_WITH_UC2() do {		\
+	uc = uc2;				\
+	ucptr = uc2ptr;				\
+	n = n2;					\
+} while (0)
+
+#define EXPAND_BUFFER() do {			\
+	as->length = p - as->s;			\
+	if (archive_string_ensure(as,		\
+	    as->buffer_length + len * tm + ts) == NULL)\
+		return (-1);			\
+	p = as->s + as->length;			\
+	endp = as->s + as->buffer_length - ts;	\
+} while (0)
+
+#define UNPARSE(p, endp, uc)	do {		\
+	while ((w = unparse(p, (endp) - (p), uc)) == 0) {\
+		EXPAND_BUFFER();		\
+	}					\
+	p += w;					\
+} while (0)
+
+/*
+ * Write first code point.
+ * If the code point has not be changed from its original code,
+ * this just copies it from its original buffer pointer.
+ * If not, this converts it to UTF-8 byte sequence and copies it.
+ */
+#define WRITE_UC()	do {			\
+	if (ucptr) {				\
+		if (p + n > endp)		\
+			EXPAND_BUFFER();	\
+		switch (n) {			\
+		case 4:				\
+			*p++ = *ucptr++;	\
+			/* FALL THROUGH */	\
+		case 3:				\
+			*p++ = *ucptr++;	\
+			/* FALL THROUGH */	\
+		case 2:				\
+			*p++ = *ucptr++;	\
+			/* FALL THROUGH */	\
+		case 1:				\
+			*p++ = *ucptr;		\
+			break;			\
+		}				\
+		ucptr = NULL;			\
+	} else {				\
+		UNPARSE(p, endp, uc);		\
+	}					\
+} while (0)
+
+/*
+ * Collect following decomposable code points.
+ */
+#define COLLECT_CPS(start)	do {		\
+	int _i;					\
+	for (_i = start; _i < FDC_MAX ; _i++) {	\
+		nx = parse(&ucx[_i], s, len);	\
+		if (nx <= 0)			\
+			break;			\
+		cx = CCC(ucx[_i]);		\
+		if (cl >= cx && cl != 228 && cx != 228)\
+			break;			\
+		s += nx;			\
+		len -= nx;			\
+		cl = cx;			\
+		ccx[_i] = cx;			\
+	}					\
+	if (_i >= FDC_MAX) {			\
+		ret = -1;			\
+		ucx_size = FDC_MAX;		\
+	} else					\
+		ucx_size = _i;			\
+} while (0)
+
+/*
+ * Normalize UTF-8/UTF-16BE characters to Form C and copy the result.
+ *
+ * TODO: Convert composition exclusions,which are never converted
+ * from NFC,NFD,NFKC and NFKD, to Form C.
+ */
+static int
+archive_string_normalize_C(struct archive_string *as, const void *_p,
+    size_t len, struct archive_string_conv *sc)
+{
+	const char *s = (const char *)_p;
+	char *p, *endp;
+	uint32_t uc, uc2;
+	size_t w;
+	int always_replace, n, n2, ret = 0, spair, ts, tm;
+	int (*parse)(uint32_t *, const char *, size_t);
+	size_t (*unparse)(char *, size_t, uint32_t);
+
+	always_replace = 1;
+	ts = 1;/* text size. */
+	if (sc->flag & SCONV_TO_UTF16BE) {
+		unparse = unicode_to_utf16be;
+		ts = 2;
+		if (sc->flag & SCONV_FROM_UTF16BE)
+			always_replace = 0;
+	} else if (sc->flag & SCONV_TO_UTF16LE) {
+		unparse = unicode_to_utf16le;
+		ts = 2;
+		if (sc->flag & SCONV_FROM_UTF16LE)
+			always_replace = 0;
+	} else if (sc->flag & SCONV_TO_UTF8) {
+		unparse = unicode_to_utf8;
+		if (sc->flag & SCONV_FROM_UTF8)
+			always_replace = 0;
+	} else {
+		/*
+		 * This case is going to be converted to another
+		 * character-set through iconv.
+		 */
+		always_replace = 0;
+		if (sc->flag & SCONV_FROM_UTF16BE) {
+			unparse = unicode_to_utf16be;
+			ts = 2;
+		} else if (sc->flag & SCONV_FROM_UTF16LE) {
+			unparse = unicode_to_utf16le;
+			ts = 2;
+		} else {
+			unparse = unicode_to_utf8;
+		}
+	}
+
+	if (sc->flag & SCONV_FROM_UTF16BE) {
+		parse = utf16be_to_unicode;
+		tm = 1;
+		spair = 4;/* surrogate pair size in UTF-16. */
+	} else if (sc->flag & SCONV_FROM_UTF16LE) {
+		parse = utf16le_to_unicode;
+		tm = 1;
+		spair = 4;/* surrogate pair size in UTF-16. */
+	} else {
+		parse = cesu8_to_unicode;
+		tm = ts;
+		spair = 6;/* surrogate pair size in UTF-8. */
+	}
+
+	if (archive_string_ensure(as, as->length + len * tm + ts) == NULL)
+		return (-1);
+
+	p = as->s + as->length;
+	endp = as->s + as->buffer_length - ts;
+	while ((n = parse(&uc, s, len)) != 0) {
+		const char *ucptr, *uc2ptr;
+
+		if (n < 0) {
+			/* Use a replaced unicode character. */
+			UNPARSE(p, endp, uc);
+			s += n*-1;
+			len -= n*-1;
+			ret = -1;
+			continue;
+		} else if (n == spair || always_replace)
+			/* uc is converted from a surrogate pair.
+			 * this should be treated as a changed code. */
+			ucptr = NULL;
+		else
+			ucptr = s;
+		s += n;
+		len -= n;
+
+		/* Read second code point. */
+		while ((n2 = parse(&uc2, s, len)) > 0) {
+			uint32_t ucx[FDC_MAX];
+			int ccx[FDC_MAX];
+			int cl, cx, i, nx, ucx_size;
+			int LIndex,SIndex;
+			uint32_t nfc;
+
+			if (n2 == spair || always_replace)
+				/* uc2 is converted from a surrogate pair.
+			 	 * this should be treated as a changed code. */
+				uc2ptr = NULL;
+			else
+				uc2ptr = s;
+			s += n2;
+			len -= n2;
+
+			/*
+			 * If current second code point is out of decomposable
+			 * code points, finding compositions is unneeded.
+			 */
+			if (!IS_DECOMPOSABLE_BLOCK(uc2)) {
+				WRITE_UC();
+				REPLACE_UC_WITH_UC2();
+				continue;
+			}
+
+			/*
+			 * Try to combine current code points.
+			 */
+			/*
+			 * We have to combine Hangul characters according to
+			 * http://uniicode.org/reports/tr15/#Hangul
+			 */
+			if (0 <= (LIndex = uc - HC_LBASE) &&
+			    LIndex < HC_LCOUNT) {
+				/*
+				 * Hangul Composition.
+				 * 1. Two current code points are L and V.
+				 */
+				int VIndex = uc2 - HC_VBASE;
+				if (0 <= VIndex && VIndex < HC_VCOUNT) {
+					/* Make syllable of form LV. */
+					UPDATE_UC(HC_SBASE +
+					    (LIndex * HC_VCOUNT + VIndex) *
+					     HC_TCOUNT);
+				} else {
+					WRITE_UC();
+					REPLACE_UC_WITH_UC2();
+				}
+				continue;
+			} else if (0 <= (SIndex = uc - HC_SBASE) &&
+			    SIndex < HC_SCOUNT && (SIndex % HC_TCOUNT) == 0) {
+				/*
+				 * Hangul Composition.
+				 * 2. Two current code points are LV and T.
+				 */
+				int TIndex = uc2 - HC_TBASE;
+				if (0 < TIndex && TIndex < HC_TCOUNT) {
+					/* Make syllable of form LVT. */
+					UPDATE_UC(uc + TIndex);
+				} else {
+					WRITE_UC();
+					REPLACE_UC_WITH_UC2();
+				}
+				continue;
+			} else if ((nfc = get_nfc(uc, uc2)) != 0) {
+				/* A composition to current code points
+				 * is found. */
+				UPDATE_UC(nfc);
+				continue;
+			} else if ((cl = CCC(uc2)) == 0) {
+				/* Clearly 'uc2' the second code point is not
+				 * a decomposable code. */
+				WRITE_UC();
+				REPLACE_UC_WITH_UC2();
+				continue;
+			}
+
+			/*
+			 * Collect following decomposable code points.
+			 */
+			cx = 0;
+			ucx[0] = uc2;
+			ccx[0] = cl;
+			COLLECT_CPS(1);
+
+			/*
+			 * Find a composed code in the collected code points.
+			 */
+			i = 1;
+			while (i < ucx_size) {
+				int j;
+
+				if ((nfc = get_nfc(uc, ucx[i])) == 0) {
+					i++;
+					continue;
+				}
+
+				/*
+				 * nfc is composed of uc and ucx[i].
+				 */
+				UPDATE_UC(nfc);
+
+				/*
+				 * Remove ucx[i] by shifting
+				 * following code points.
+				 */
+				for (j = i; j+1 < ucx_size; j++) {
+					ucx[j] = ucx[j+1];
+					ccx[j] = ccx[j+1];
+				}
+				ucx_size --;
+
+				/*
+				 * Collect following code points blocked
+				 * by ucx[i] the removed code point.
+				 */
+				if (ucx_size > 0 && i == ucx_size &&
+				    nx > 0 && cx == cl) {
+					cl =  ccx[ucx_size-1];
+					COLLECT_CPS(ucx_size);
+				}
+				/*
+				 * Restart finding a composed code with
+				 * the updated uc from the top of the
+				 * collected code points.
+				 */
+				i = 0;
+			}
+
+			/*
+			 * Apparently the current code points are not
+			 * decomposed characters or already composed.
+			 */
+			WRITE_UC();
+			for (i = 0; i < ucx_size; i++)
+				UNPARSE(p, endp, ucx[i]);
+
+			/*
+			 * Flush out remaining canonical combining characters.
+			 */
+			if (nx > 0 && cx == cl && len > 0) {
+				while ((nx = parse(&ucx[0], s, len))
+				    > 0) {
+					cx = CCC(ucx[0]);
+					if (cl > cx)
+						break;
+					s += nx;
+					len -= nx;
+					cl = cx;
+					UNPARSE(p, endp, ucx[0]);
+				}
+			}
+			break;
+		}
+		if (n2 < 0) {
+			WRITE_UC();
+			/* Use a replaced unicode character. */
+			UNPARSE(p, endp, uc2);
+			s += n2*-1;
+			len -= n2*-1;
+			ret = -1;
+			continue;
+		} else if (n2 == 0) {
+			WRITE_UC();
+			break;
+		}
+	}
+	as->length = p - as->s;
+	as->s[as->length] = '\0';
+	if (ts == 2)
+		as->s[as->length+1] = '\0';
+	return (ret);
+}
+
+#if defined(__APPLE__)
+
+/*
+ * Normalize UTF-8 characters to Form D and copy the result.
+ */
+static int
+archive_string_normalize_D(struct archive_string *as, const void *_p,
+    size_t len, struct archive_string_conv *sc)
+{
+	const UniChar *inp;
+	char *outp;
+	size_t newsize;
+	ByteCount inCount, outCount;
+	ByteCount inAvail, outAvail;
+	OSStatus err;
+	int ret, saved_flag;
+
+	/*
+	 * Convert the current string to UTF-16LE for normalization.
+	 * The character-set of the current string must be UTF-16BE or
+	 * UTF-8.
+	 */
+	archive_string_empty(&(sc->utf16nfc));
+	saved_flag = sc->flag;/* save a flag. */
+	sc->flag &= ~(SCONV_TO_UTF16BE | SCONV_TO_UTF8);
+	sc->flag |= SCONV_TO_UTF16LE;
+	ret = archive_string_append_unicode(&(sc->utf16nfc), _p, len, sc);
+	sc->flag = saved_flag;/* restore the saved flag */
+	if (archive_strlen(&(sc->utf16nfc)) == 0) {
+		if (archive_string_ensure(as, as->length + 1) == NULL)
+			return (-1);
+		return (ret);
+	}
+
+	/*
+	 * Normalize an NFC string to be an NFD(HFS Plus version).
+	 */
+	newsize = sc->utf16nfc.length + 2;
+	if (archive_string_ensure(&(sc->utf16nfd), newsize) == NULL)
+		return (-1);
+
+	inp = (UniChar *)sc->utf16nfc.s;
+	inAvail = archive_strlen(&(sc->utf16nfc));
+	sc->utf16nfd.length = 0;
+	outp = sc->utf16nfd.s;
+	outAvail = sc->utf16nfd.buffer_length -2;
+
+	do {
+		/* Reinitialize all state information. */
+		if (ResetUnicodeToTextInfo(sc->uniInfo) != noErr)
+			goto return_no_changed_data;
+
+		inCount = outCount = 0;
+		err = ConvertFromUnicodeToText(sc->uniInfo,
+		    inAvail, inp,
+		    kUnicodeDefaultDirectionMask, 0, NULL, NULL, NULL,
+		    outAvail, &inCount, &outCount, outp);
+
+		if (err == noErr) {
+			sc->utf16nfd.length = outCount;
+			sc->utf16nfd.s[sc->utf16nfd.length] = 0;
+			sc->utf16nfd.s[sc->utf16nfd.length+1] = 0;
+		} else if (err == kTECOutputBufferFullStatus) {
+			newsize = inAvail - inCount;
+			if (newsize > inAvail)
+				newsize = inAvail;
+			newsize += sc->utf16nfd.buffer_length + 2;
+			if (archive_string_ensure(&(sc->utf16nfd), newsize)
+			    == NULL)
+				return (-1);
+			outp = sc->utf16nfd.s;
+			outAvail = sc->utf16nfd.buffer_length -2;
+		} else
+			goto return_no_changed_data;
+	} while (err == kTECOutputBufferFullStatus);
+
+	/*
+	 * If there is a next-step conversion, we should convert
+	 * a UTF-16LE(NFD) string back to the original Unicode type.
+	 */
+	saved_flag = sc->flag;/* save a flag. */
+	if (!(sc->flag &
+	    (SCONV_TO_UTF16BE | SCONV_TO_UTF16LE | SCONV_TO_UTF8))) {
+		/*
+		 * This case is going to be converted to another
+		 * character-set through iconv.
+		 */
+		if (sc->flag & SCONV_FROM_UTF16BE)
+			sc->flag |= SCONV_TO_UTF16BE;
+		else if (sc->flag & SCONV_FROM_UTF16LE)
+			sc->flag |= SCONV_TO_UTF16LE;
+		else
+			sc->flag |= SCONV_TO_UTF8;
+	}
+	sc->flag &= ~(SCONV_FROM_UTF16BE | SCONV_FROM_UTF8);
+	sc->flag |= SCONV_FROM_UTF16LE;
+	if (archive_string_append_unicode(as, sc->utf16nfd.s,
+	    sc->utf16nfd.length, sc) != 0)
+		ret = -1;
+	sc->flag = saved_flag;/* restore the saved flag */
+	return (ret);
+
+return_no_changed_data:
+	/*
+	 * Something conversion error happened, so we return a no normalized
+	 * string with an error.
+	 */
+	(void)archive_string_append_unicode(as, _p, len, sc);
+	return (-1);
+}
+
+#endif /* __APPLE__ */
+
+/*
+ * libarchive 2.x made incorrect UTF-8 strings in the wrong assumption
+ * that WCS is Unicode. It is true for several platforms but some are false.
+ * And then people who did not use UTF-8 locale on the non Unicode WCS
+ * platform and made a tar file with libarchive(mostly bsdtar) 2.x. Those
+ * now cannot get right filename from libarchive 3.x and later since we
+ * fixed the wrong assumption and it is incompatible to older its versions.
+ * So we provide special option, "compat-2x.x", for resolving it.
+ * That option enable the string conversion of libarchive 2.x.
+ *
+ * Translates the wrong UTF-8 string made by libarchive 2.x into current
+ * locale character set and appends to the archive_string.
+ * Note: returns -1 if conversion fails.
+ */
+static int
+strncat_from_utf8_libarchive2(struct archive_string *as,
+    const void *_p, size_t len, struct archive_string_conv *sc)
+{
+	const char *s;
+	int n;
+	char *p;
+	char *end;
+	uint32_t unicode;
+#if HAVE_WCRTOMB
+	mbstate_t shift_state;
+
+	memset(&shift_state, 0, sizeof(shift_state));
+#else
+	/* Clear the shift state before starting. */
+	wctomb(NULL, L'\0');
+#endif
+	(void)sc; /* UNUSED */
+	/*
+	 * Allocate buffer for MBS.
+	 * We need this allocation here since it is possible that
+	 * as->s is still NULL.
+	 */
+	if (archive_string_ensure(as, as->length + len + 1) == NULL)
+		return (-1);
+
+	s = (const char *)_p;
+	p = as->s + as->length;
+	end = as->s + as->buffer_length - MB_CUR_MAX -1;
+	while ((n = _utf8_to_unicode(&unicode, s, len)) != 0) {
+		wchar_t wc;
+
+		if (p >= end) {
+			as->length = p - as->s;
+			/* Re-allocate buffer for MBS. */
+			if (archive_string_ensure(as,
+			    as->length + len * 2 + 1) == NULL)
+				return (-1);
+			p = as->s + as->length;
+			end = as->s + as->buffer_length - MB_CUR_MAX -1;
+		}
+
+		/*
+		 * As libarchie 2.x, translates the UTF-8 characters into
+		 * wide-characters in the assumption that WCS is Unicode.
+		 */
+		if (n < 0) {
+			n *= -1;
+			wc = L'?';
+		} else
+			wc = (wchar_t)unicode;
+
+		s += n;
+		len -= n;
+		/*
+		 * Translates the wide-character into the current locale MBS.
+		 */
+#if HAVE_WCRTOMB
+		n = wcrtomb(p, wc, &shift_state);
+#else
+		n = wctomb(p, wc);
+#endif
 		if (n == -1)
-			return (NULL);
+			return (-1);
 		p += n;
 	}
-	*p = '\0';
-	archive_strcat(as, buff);
-	return (as);
+	as->length = p - as->s;
+	as->s[as->length] = '\0';
+	return (0);
+}
+
+
+/*
+ * Conversion functions between current locale dependent MBS and UTF-16BE.
+ *   strncat_from_utf16be() : UTF-16BE --> MBS
+ *   strncat_to_utf16be()   : MBS --> UTF16BE
+ */
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+
+/*
+ * Convert a UTF-16BE/LE string to current locale and copy the result.
+ * Return -1 if conversion failes.
+ */
+static int
+win_strncat_from_utf16(struct archive_string *as, const void *_p, size_t bytes,
+    struct archive_string_conv *sc, int be)
+{
+	struct archive_string tmp;
+	const char *u16;
+	int ll;
+	BOOL defchar;
+	char *mbs;
+	size_t mbs_size, b;
+	int ret = 0;
+
+	bytes &= ~1;
+	if (archive_string_ensure(as, as->length + bytes +1) == NULL)
+		return (-1);
+
+	mbs = as->s + as->length;
+	mbs_size = as->buffer_length - as->length -1;
+
+	if (sc->to_cp == CP_C_LOCALE) {
+		/*
+		 * "C" locale special process.
+		 */
+		u16 = _p;
+		ll = 0;
+		for (b = 0; b < bytes; b += 2) {
+			uint16_t val;
+			if (be)
+				val = archive_be16dec(u16+b);
+			else
+				val = archive_le16dec(u16+b);
+			if (val > 255) {
+				*mbs++ = '?';
+				ret = -1;
+			} else
+				*mbs++ = (char)(val&0xff);
+			ll++;
+		}
+		as->length += ll;
+		as->s[as->length] = '\0';
+		return (ret);
+	}
+
+	archive_string_init(&tmp);
+	if (be) {
+		if (is_big_endian()) {
+			u16 = _p;
+		} else {
+			if (archive_string_ensure(&tmp, bytes+2) == NULL)
+				return (-1);
+			memcpy(tmp.s, _p, bytes);
+			for (b = 0; b < bytes; b += 2) {
+				uint16_t val = archive_be16dec(tmp.s+b);
+				archive_le16enc(tmp.s+b, val);
+			}
+			u16 = tmp.s;
+		}
+	} else {
+		if (!is_big_endian()) {
+			u16 = _p;
+		} else {
+			if (archive_string_ensure(&tmp, bytes+2) == NULL)
+				return (-1);
+			memcpy(tmp.s, _p, bytes);
+			for (b = 0; b < bytes; b += 2) {
+				uint16_t val = archive_le16dec(tmp.s+b);
+				archive_be16enc(tmp.s+b, val);
+			}
+			u16 = tmp.s;
+		}
+	}
+
+	do {
+		defchar = 0;
+		ll = WideCharToMultiByte(sc->to_cp, 0,
+		    (LPCWSTR)u16, bytes>>1, mbs, mbs_size,
+			NULL, &defchar);
+		if (ll == 0 &&
+		    GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
+			/* Need more buffer for MBS. */
+			ll = WideCharToMultiByte(sc->to_cp, 0,
+			    (LPCWSTR)u16, bytes, NULL, 0, NULL, NULL);
+			if (archive_string_ensure(as, ll +1) == NULL)
+				return (-1);
+			mbs = as->s + as->length;
+			mbs_size = as->buffer_length - as->length -1;
+			continue;
+		}
+	} while (0);
+	archive_string_free(&tmp);
+	as->length += ll;
+	as->s[as->length] = '\0';
+	if (ll == 0 || defchar)
+		ret = -1;
+	return (ret);
+}
+
+static int
+win_strncat_from_utf16be(struct archive_string *as, const void *_p, size_t bytes,
+    struct archive_string_conv *sc)
+{
+	return (win_strncat_from_utf16(as, _p, bytes, sc, 1));
+}
+
+static int
+win_strncat_from_utf16le(struct archive_string *as, const void *_p, size_t bytes,
+    struct archive_string_conv *sc)
+{
+	return (win_strncat_from_utf16(as, _p, bytes, sc, 0));
+}
+
+static int
+is_big_endian(void)
+{
+	uint16_t d = 1;
+
+	return (archive_be16dec(&d) == 1);
+}
+
+/*
+ * Convert a current locale string to UTF-16BE/LE and copy the result.
+ * Return -1 if conversion failes.
+ */
+static int
+win_strncat_to_utf16(struct archive_string *as16, const void *_p, size_t length,
+    struct archive_string_conv *sc, int bigendian)
+{
+	const char *s = (const char *)_p;
+	char *u16;
+	size_t count, avail;
+
+	if (archive_string_ensure(as16,
+	    as16->length + (length + 1) * 2) == NULL)
+		return (-1);
+
+	u16 = as16->s + as16->length;
+	avail = as16->buffer_length - 2;
+	if (sc->from_cp == CP_C_LOCALE) {
+		/*
+		 * "C" locale special process.
+		 */
+		count = 0;
+		while (count < length && *s) {
+			if (bigendian)
+				archive_be16enc(u16, *s);
+			else
+				archive_le16enc(u16, *s);
+			u16 += 2;
+			s++;
+			count++;
+		}
+		as16->length += count << 1;
+		as16->s[as16->length] = 0;
+		as16->s[as16->length+1] = 0;
+		return (0);
+	}
+	do {
+		count = MultiByteToWideChar(sc->from_cp,
+		    MB_PRECOMPOSED, s, length, (LPWSTR)u16, (int)avail>>1);
+		if (count == 0 &&
+		    GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
+			/* Need more buffer for UTF-16 string */
+			count = MultiByteToWideChar(sc->from_cp,
+			    MB_PRECOMPOSED, s, length, NULL, 0);
+			if (archive_string_ensure(as16, (count +1) * 2)
+			    == NULL)
+				return (-1);
+			u16 = as16->s + as16->length;
+			avail = as16->buffer_length - 2;
+			continue;
+		}
+	} while (0);
+	as16->length += count * 2;
+	as16->s[as16->length] = 0;
+	as16->s[as16->length+1] = 0;
+	if (count == 0)
+		return (-1);
+
+	if (is_big_endian()) {
+		if (!bigendian) {
+			while (count > 0) {
+				uint16_t v = archive_be16dec(u16);
+				archive_le16enc(u16, v);
+				u16 += 2;
+				count--;
+			}
+		}
+	} else {
+		if (bigendian) {
+			while (count > 0) {
+				uint16_t v = archive_le16dec(u16);
+				archive_be16enc(u16, v);
+				u16 += 2;
+				count--;
+			}
+		}
+	}
+	return (0);
+}
+
+static int
+win_strncat_to_utf16be(struct archive_string *as16, const void *_p, size_t length,
+    struct archive_string_conv *sc)
+{
+	return (win_strncat_to_utf16(as16, _p, length, sc, 1));
+}
+
+static int
+win_strncat_to_utf16le(struct archive_string *as16, const void *_p, size_t length,
+    struct archive_string_conv *sc)
+{
+	return (win_strncat_to_utf16(as16, _p, length, sc, 0));
+}
+
+#endif /* _WIN32 && !__CYGWIN__ */
+
+/*
+ * Do the best effort for conversions.
+ * We cannot handle UTF-16BE character-set without such iconv,
+ * but there is a chance if a string consists just ASCII code or
+ * a current locale is UTF-8.
+ */
+
+/*
+ * Convert a UTF-16BE string to current locale and copy the result.
+ * Return -1 if conversion failes.
+ */
+static int
+best_effort_strncat_from_utf16(struct archive_string *as, const void *_p,
+    size_t bytes, struct archive_string_conv *sc, int be)
+{
+	const char *utf16 = (const char *)_p;
+	char *mbs;
+	uint32_t uc;
+	int n, ret;
+
+	(void)sc; /* UNUSED */
+	/*
+	 * Other case, we should do the best effort.
+	 * If all character are ASCII(<0x7f), we can convert it.
+	 * if not , we set a alternative character and return -1.
+	 */
+	ret = 0;
+	if (archive_string_ensure(as, as->length + bytes +1) == NULL)
+		return (-1);
+	mbs = as->s + as->length;
+
+	while ((n = utf16_to_unicode(&uc, utf16, bytes, be)) != 0) {
+		if (n < 0) {
+			n *= -1;
+			ret =  -1;
+		}
+		bytes -= n;
+		utf16 += n;
+
+		if (uc > 127) {
+			/* We cannot handle it. */
+			*mbs++ = '?';
+			ret =  -1;
+		} else
+			*mbs++ = (char)uc;
+	}
+	as->length = mbs - as->s;
+	as->s[as->length] = '\0';
+	return (ret);
+}
+
+static int
+best_effort_strncat_from_utf16be(struct archive_string *as, const void *_p,
+    size_t bytes, struct archive_string_conv *sc)
+{
+	return (best_effort_strncat_from_utf16(as, _p, bytes, sc, 1));
+}
+
+static int
+best_effort_strncat_from_utf16le(struct archive_string *as, const void *_p,
+    size_t bytes, struct archive_string_conv *sc)
+{
+	return (best_effort_strncat_from_utf16(as, _p, bytes, sc, 0));
+}
+
+/*
+ * Convert a current locale string to UTF-16BE/LE and copy the result.
+ * Return -1 if conversion failes.
+ */
+static int
+best_effort_strncat_to_utf16(struct archive_string *as16, const void *_p,
+    size_t length, struct archive_string_conv *sc, int bigendian)
+{
+	const char *s = (const char *)_p;
+	char *utf16;
+	size_t remaining;
+	int ret;
+
+	(void)sc; /* UNUSED */
+	/*
+	 * Other case, we should do the best effort.
+	 * If all character are ASCII(<0x7f), we can convert it.
+	 * if not , we set a alternative character and return -1.
+	 */
+	ret = 0;
+	remaining = length;
+
+	if (archive_string_ensure(as16,
+	    as16->length + (length + 1) * 2) == NULL)
+		return (-1);
+
+	utf16 = as16->s + as16->length;
+	while (remaining--) {
+		unsigned c = *s++;
+		if (c > 127) {
+			/* We cannot handle it. */
+			c = UNICODE_R_CHAR;
+			ret = -1;
+		}
+		if (bigendian)
+			archive_be16enc(utf16, c);
+		else
+			archive_le16enc(utf16, c);
+		utf16 += 2;
+	}
+	as16->length = utf16 - as16->s;
+	as16->s[as16->length] = 0;
+	as16->s[as16->length+1] = 0;
+	return (ret);
+}
+
+static int
+best_effort_strncat_to_utf16be(struct archive_string *as16, const void *_p,
+    size_t length, struct archive_string_conv *sc)
+{
+	return (best_effort_strncat_to_utf16(as16, _p, length, sc, 1));
+}
+
+static int
+best_effort_strncat_to_utf16le(struct archive_string *as16, const void *_p,
+    size_t length, struct archive_string_conv *sc)
+{
+	return (best_effort_strncat_to_utf16(as16, _p, length, sc, 0));
+}
+
+
+/*
+ * Multistring operations.
+ */
+
+void
+archive_mstring_clean(struct archive_mstring *aes)
+{
+	archive_wstring_free(&(aes->aes_wcs));
+	archive_string_free(&(aes->aes_mbs));
+	archive_string_free(&(aes->aes_utf8));
+	archive_string_free(&(aes->aes_mbs_in_locale));
+	aes->aes_set = 0;
+}
+
+void
+archive_mstring_copy(struct archive_mstring *dest, struct archive_mstring *src)
+{
+	dest->aes_set = src->aes_set;
+	archive_string_copy(&(dest->aes_mbs), &(src->aes_mbs));
+	archive_string_copy(&(dest->aes_utf8), &(src->aes_utf8));
+	archive_wstring_copy(&(dest->aes_wcs), &(src->aes_wcs));
+}
+
+int
+archive_mstring_get_utf8(struct archive *a, struct archive_mstring *aes,
+  const char **p)
+{
+	struct archive_string_conv *sc;
+	int r;
+
+	/* If we already have a UTF8 form, return that immediately. */
+	if (aes->aes_set & AES_SET_UTF8) {
+		*p = aes->aes_utf8.s;
+		return (0);
+	}
+
+	*p = NULL;
+	if (aes->aes_set & AES_SET_MBS) {
+		sc = archive_string_conversion_to_charset(a, "UTF-8", 1);
+		if (sc == NULL)
+			return (-1);/* Couldn't allocate memory for sc. */
+		r = archive_strncpy_in_locale(&(aes->aes_mbs), aes->aes_mbs.s,
+		    aes->aes_mbs.length, sc);
+		if (a == NULL)
+			free_sconv_object(sc);
+		if (r == 0) {
+			aes->aes_set |= AES_SET_UTF8;
+			*p = aes->aes_utf8.s;
+			return (0);/* success. */
+		} else
+			return (-1);/* failure. */
+	}
+	return (0);/* success. */
+}
+
+int
+archive_mstring_get_mbs(struct archive *a, struct archive_mstring *aes,
+    const char **p)
+{
+	int r, ret = 0;
+
+	(void)a; /* UNUSED */
+	/* If we already have an MBS form, return that immediately. */
+	if (aes->aes_set & AES_SET_MBS) {
+		*p = aes->aes_mbs.s;
+		return (ret);
+	}
+
+	*p = NULL;
+	/* If there's a WCS form, try converting with the native locale. */
+	if (aes->aes_set & AES_SET_WCS) {
+		archive_string_empty(&(aes->aes_mbs));
+		r = archive_string_append_from_wcs(&(aes->aes_mbs),
+		    aes->aes_wcs.s, aes->aes_wcs.length);
+		*p = aes->aes_mbs.s;
+		if (r == 0) {
+			aes->aes_set |= AES_SET_MBS;
+			return (ret);
+		} else
+			ret = -1;
+	}
+
+	/*
+	 * Only a UTF-8 form cannot avail because its conversion already
+	 * failed at archive_mstring_update_utf8().
+	 */
+	return (ret);
+}
+
+int
+archive_mstring_get_wcs(struct archive *a, struct archive_mstring *aes,
+    const wchar_t **wp)
+{
+	int r, ret = 0;
+
+	(void)a;/* UNUSED */
+	/* Return WCS form if we already have it. */
+	if (aes->aes_set & AES_SET_WCS) {
+		*wp = aes->aes_wcs.s;
+		return (ret);
+	}
+
+	*wp = NULL;
+	/* Try converting MBS to WCS using native locale. */
+	if (aes->aes_set & AES_SET_MBS) {
+		archive_wstring_empty(&(aes->aes_wcs));
+		r = archive_wstring_append_from_mbs(&(aes->aes_wcs),
+		    aes->aes_mbs.s, aes->aes_mbs.length);
+		if (r == 0) {
+			aes->aes_set |= AES_SET_WCS;
+			*wp = aes->aes_wcs.s;
+		} else
+			ret = -1;/* failure. */
+	}
+	return (ret);
+}
+
+int
+archive_mstring_get_mbs_l(struct archive_mstring *aes,
+    const char **p, size_t *length, struct archive_string_conv *sc)
+{
+	int r, ret = 0;
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+	/*
+	 * Internationalization programing on Windows must use Wide
+	 * characters because Windows platform cannot make locale UTF-8.
+	 */
+	if (sc != NULL && (aes->aes_set & AES_SET_WCS) != 0) {
+		archive_string_empty(&(aes->aes_mbs_in_locale));
+		r = archive_string_append_from_wcs_in_codepage(
+		    &(aes->aes_mbs_in_locale), aes->aes_wcs.s,
+		    aes->aes_wcs.length, sc);
+		if (r == 0) {
+			*p = aes->aes_mbs_in_locale.s;
+			if (length != NULL)
+				*length = aes->aes_mbs_in_locale.length;
+			return (0);
+		} else if (errno == ENOMEM)
+			return (-1);
+		else
+			ret = -1;
+	}
 #endif
+
+	/* If there is not an MBS form but is a WCS form, try converting
+	 * with the native locale to be used for translating it to specified
+	 * character-set. */
+	if ((aes->aes_set & AES_SET_MBS) == 0 &&
+	    (aes->aes_set & AES_SET_WCS) != 0) {
+		archive_string_empty(&(aes->aes_mbs));
+		r = archive_string_append_from_wcs(&(aes->aes_mbs),
+		    aes->aes_wcs.s, aes->aes_wcs.length);
+		if (r == 0)
+			aes->aes_set |= AES_SET_MBS;
+		else if (errno == ENOMEM)
+			return (-1);
+		else
+			ret = -1;
+	}
+	/* If we already have an MBS form, use it to be translated to
+	 * specified character-set. */
+	if (aes->aes_set & AES_SET_MBS) {
+		if (sc == NULL) {
+			/* Conversion is unneeded. */
+			*p = aes->aes_mbs.s;
+			if (length != NULL)
+				*length = aes->aes_mbs.length;
+			return (0);
+		}
+		ret = archive_strncpy_in_locale(&(aes->aes_mbs_in_locale),
+		    aes->aes_mbs.s, aes->aes_mbs.length, sc);
+		*p = aes->aes_mbs_in_locale.s;
+		if (length != NULL)
+			*length = aes->aes_mbs_in_locale.length;
+	} else {
+		*p = NULL;
+		if (length != NULL)
+			*length = 0;
+	}
+	return (ret);
 }
 
-#endif /* _WIN32 && ! __CYGWIN__ */
+int
+archive_mstring_copy_mbs(struct archive_mstring *aes, const char *mbs)
+{
+	if (mbs == NULL) {
+		aes->aes_set = 0;
+		return (0);
+	}
+	return (archive_mstring_copy_mbs_len(aes, mbs, strlen(mbs)));
+}
+
+int
+archive_mstring_copy_mbs_len(struct archive_mstring *aes, const char *mbs,
+    size_t len)
+{
+	if (mbs == NULL) {
+		aes->aes_set = 0;
+		return (0);
+	}
+	aes->aes_set = AES_SET_MBS; /* Only MBS form is set now. */
+	archive_strncpy(&(aes->aes_mbs), mbs, len);
+	archive_string_empty(&(aes->aes_utf8));
+	archive_wstring_empty(&(aes->aes_wcs));
+	return (0);
+}
+
+int
+archive_mstring_copy_wcs(struct archive_mstring *aes, const wchar_t *wcs)
+{
+	return archive_mstring_copy_wcs_len(aes, wcs, wcs == NULL ? 0 : wcslen(wcs));
+}
+
+int
+archive_mstring_copy_wcs_len(struct archive_mstring *aes, const wchar_t *wcs,
+    size_t len)
+{
+	if (wcs == NULL) {
+		aes->aes_set = 0;
+	}
+	aes->aes_set = AES_SET_WCS; /* Only WCS form set. */
+	archive_string_empty(&(aes->aes_mbs));
+	archive_string_empty(&(aes->aes_utf8));
+	archive_wstrncpy(&(aes->aes_wcs), wcs, len);
+	return (0);
+}
+
+int
+archive_mstring_copy_mbs_len_l(struct archive_mstring *aes,
+    const char *mbs, size_t len, struct archive_string_conv *sc)
+{
+	int r;
+
+	if (mbs == NULL) {
+		aes->aes_set = 0;
+		return (0);
+	}
+	archive_string_empty(&(aes->aes_mbs));
+	archive_wstring_empty(&(aes->aes_wcs));
+	archive_string_empty(&(aes->aes_utf8));
+#if defined(_WIN32) && !defined(__CYGWIN__)
+	/*
+	 * Internationalization programing on Windows must use Wide
+	 * characters because Windows platform cannot make locale UTF-8.
+	 */
+	if (sc == NULL) {
+		if (archive_string_append(&(aes->aes_mbs),
+			mbs, mbsnbytes(mbs, len)) == NULL) {
+			aes->aes_set = 0;
+			r = -1;
+		} else {
+			aes->aes_set = AES_SET_MBS;
+			r = 0;
+		}
+#if defined(HAVE_ICONV)
+	} else if (sc != NULL && sc->cd_w != (iconv_t)-1) {
+		/*
+		 * This case happens only when MultiByteToWideChar() cannot
+		 * handle sc->from_cp, and we have to iconv in order to
+		 * translate character-set to wchar_t,UTF-16.
+		 */
+		iconv_t cd = sc->cd;
+		unsigned from_cp;
+		int flag;
+
+		/*
+		 * Translate multi-bytes from some character-set to UTF-8.
+		 */ 
+		sc->cd = sc->cd_w;
+		r = archive_strncpy_in_locale(&(aes->aes_utf8), mbs, len, sc);
+		sc->cd = cd;
+		if (r != 0) {
+			aes->aes_set = 0;
+			return (r);
+		}
+		aes->aes_set = AES_SET_UTF8;
+
+		/*
+		 * Append the UTF-8 string into wstring.
+		 */ 
+		flag = sc->flag;
+		sc->flag &= ~(SCONV_NORMALIZATION_C
+				| SCONV_TO_UTF16| SCONV_FROM_UTF16);
+		from_cp = sc->from_cp;
+		sc->from_cp = CP_UTF8;
+		r = archive_wstring_append_from_mbs_in_codepage(&(aes->aes_wcs),
+			aes->aes_utf8.s, aes->aes_utf8.length, sc);
+		sc->flag = flag;
+		sc->from_cp = from_cp;
+		if (r == 0)
+			aes->aes_set |= AES_SET_WCS;
+#endif
+	} else {
+		r = archive_wstring_append_from_mbs_in_codepage(
+		    &(aes->aes_wcs), mbs, len, sc);
+		if (r == 0)
+			aes->aes_set = AES_SET_WCS;
+		else
+			aes->aes_set = 0;
+	}
+#else
+	r = archive_strncpy_in_locale(&(aes->aes_mbs), mbs, len, sc);
+	if (r == 0)
+		aes->aes_set = AES_SET_MBS; /* Only MBS form is set now. */
+	else
+		aes->aes_set = 0;
+#endif
+	return (r);
+}
+
+/*
+ * The 'update' form tries to proactively update all forms of
+ * this string (WCS and MBS) and returns an error if any of
+ * them fail.  This is used by the 'pax' handler, for instance,
+ * to detect and report character-conversion failures early while
+ * still allowing clients to get potentially useful values from
+ * the more tolerant lazy conversions.  (get_mbs and get_wcs will
+ * strive to give the user something useful, so you can get hopefully
+ * usable values even if some of the character conversions are failing.)
+ */
+int
+archive_mstring_update_utf8(struct archive *a, struct archive_mstring *aes,
+    const char *utf8)
+{
+	struct archive_string_conv *sc;
+	int r;
+
+	if (utf8 == NULL) {
+		aes->aes_set = 0;
+		return (0); /* Succeeded in clearing everything. */
+	}
+
+	/* Save the UTF8 string. */
+	archive_strcpy(&(aes->aes_utf8), utf8);
+
+	/* Empty the mbs and wcs strings. */
+	archive_string_empty(&(aes->aes_mbs));
+	archive_wstring_empty(&(aes->aes_wcs));
+
+	aes->aes_set = AES_SET_UTF8;	/* Only UTF8 is set now. */
+
+	/* Try converting UTF-8 to MBS, return false on failure. */
+	sc = archive_string_conversion_from_charset(a, "UTF-8", 1);
+	if (sc == NULL)
+		return (-1);/* Couldn't allocate memory for sc. */
+	r = archive_strcpy_in_locale(&(aes->aes_mbs), utf8, sc);
+	if (a == NULL)
+		free_sconv_object(sc);
+	if (r != 0)
+		return (-1);
+	aes->aes_set = AES_SET_UTF8 | AES_SET_MBS; /* Both UTF8 and MBS set. */
+
+	/* Try converting MBS to WCS, return false on failure. */
+	if (archive_wstring_append_from_mbs(&(aes->aes_wcs), aes->aes_mbs.s,
+	    aes->aes_mbs.length))
+		return (-1);
+	aes->aes_set = AES_SET_UTF8 | AES_SET_WCS | AES_SET_MBS;
+
+	/* All conversions succeeded. */
+	return (0);
+}
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_string.h
--- a/head/contrib/libarchive/libarchive/archive_string.h	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_string.h	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2003-2010 Tim Kientzle
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -22,13 +22,15 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: head/contrib/libarchive/libarchive/archive_string.h 228763 2011-12-21 11:13:29Z mm $
+ * $FreeBSD: head/contrib/libarchive/libarchive/archive_string.h 232153 2012-02-25 10:58:02Z mm $
  *
  */
 
 #ifndef __LIBARCHIVE_BUILD
+#ifndef __LIBARCHIVE_TEST
 #error This header is only to be used internally to libarchive.
 #endif
+#endif
 
 #ifndef ARCHIVE_STRING_H_INCLUDED
 #define	ARCHIVE_STRING_H_INCLUDED
@@ -47,62 +49,97 @@
 #include "archive.h"
 
 /*
- * Basic resizable/reusable string support a la Java's "StringBuffer."
+ * Basic resizable/reusable string support similar to Java's "StringBuffer."
  *
  * Unlike sbuf(9), the buffers here are fully reusable and track the
  * length throughout.
- *
- * Note that all visible symbols here begin with "__archive" as they
- * are internal symbols not intended for anyone outside of this library
- * to see or use.
  */
 
 struct archive_string {
 	char	*s;  /* Pointer to the storage */
-	size_t	 length; /* Length of 's' */
-	size_t	 buffer_length; /* Length of malloc-ed storage */
+	size_t	 length; /* Length of 's' in characters */
+	size_t	 buffer_length; /* Length of malloc-ed storage in bytes. */
 };
 
+struct archive_wstring {
+	wchar_t	*s;  /* Pointer to the storage */
+	size_t	 length; /* Length of 's' in characters */
+	size_t	 buffer_length; /* Length of malloc-ed storage in bytes. */
+};
+
+struct archive_string_conv;
+
 /* Initialize an archive_string object on the stack or elsewhere. */
 #define	archive_string_init(a)	\
 	do { (a)->s = NULL; (a)->length = 0; (a)->buffer_length = 0; } while(0)
 
 /* Append a C char to an archive_string, resizing as necessary. */
 struct archive_string *
-__archive_strappend_char(struct archive_string *, char);
-#define	archive_strappend_char __archive_strappend_char
+archive_strappend_char(struct archive_string *, char);
 
-/* Convert a wide-char string to UTF-8 and append the result. */
-struct archive_string *
-__archive_strappend_w_utf8(struct archive_string *, const wchar_t *);
-#define	archive_strappend_w_utf8	__archive_strappend_w_utf8
+/* Ditto for a wchar_t and an archive_wstring. */
+struct archive_wstring *
+archive_wstrappend_wchar(struct archive_wstring *, wchar_t);
 
-/* Convert a wide-char string to current locale and append the result. */
-/* Returns NULL if conversion fails. */
-struct archive_string *
-__archive_strappend_w_mbs(struct archive_string *, const wchar_t *);
-#define	archive_strappend_w_mbs	__archive_strappend_w_mbs
+/* Convert a Unicode string to current locale and append the result. */
+/* Returns -1 if conversion fails. */
+int
+archive_string_append_from_wcs(struct archive_string *, const wchar_t *, size_t);
 
-/* Basic append operation. */
-struct archive_string *
-__archive_string_append(struct archive_string *as, const char *p, size_t s);
+
+/* Create a string conversion object.
+ * Return NULL and set a error message if the conversion is not supported
+ * on the platform. */
+struct archive_string_conv *
+archive_string_conversion_to_charset(struct archive *, const char *, int);
+struct archive_string_conv *
+archive_string_conversion_from_charset(struct archive *, const char *, int);
+/* Create the default string conversion object for reading/writing an archive.
+ * Return NULL if the conversion is unneeded.
+ * Note: On non Windows platform this always returns NULL.
+ */
+struct archive_string_conv *
+archive_string_default_conversion_for_read(struct archive *);
+struct archive_string_conv *
+archive_string_default_conversion_for_write(struct archive *);
+/* Dispose of a string conversion object. */
+void
+archive_string_conversion_free(struct archive *);
+const char *
+archive_string_conversion_charset_name(struct archive_string_conv *);
+void
+archive_string_conversion_set_opt(struct archive_string_conv *, int);
+#define SCONV_SET_OPT_UTF8_LIBARCHIVE2X	1
+
+
+/* Copy one archive_string to another in locale conversion.
+ * Return -1 if conversion failes. */
+int
+archive_strncpy_in_locale(struct archive_string *, const void *, size_t,
+    struct archive_string_conv *);
+
+/* Copy one archive_string to another in locale conversion.
+ * Return -1 if conversion failes. */
+int
+archive_strncat_in_locale(struct archive_string *, const void *, size_t,
+    struct archive_string_conv *);
+
 
 /* Copy one archive_string to another */
-void
-__archive_string_copy(struct archive_string *dest, struct archive_string *src);
-#define archive_string_copy(dest, src) \
-	__archive_string_copy(dest, src)
+#define	archive_string_copy(dest, src) \
+	((dest)->length = 0, archive_string_concat((dest), (src)))
+#define	archive_wstring_copy(dest, src) \
+	((dest)->length = 0, archive_wstring_concat((dest), (src)))
 
 /* Concatenate one archive_string to another */
-void
-__archive_string_concat(struct archive_string *dest, struct archive_string *src);
-#define archive_string_concat(dest, src) \
-	__archive_string_concat(dest, src)
+void archive_string_concat(struct archive_string *dest, struct archive_string *src);
+void archive_wstring_concat(struct archive_wstring *dest, struct archive_wstring *src);
 
 /* Ensure that the underlying buffer is at least as large as the request. */
 struct archive_string *
-__archive_string_ensure(struct archive_string *, size_t);
-#define	archive_string_ensure __archive_string_ensure
+archive_string_ensure(struct archive_string *, size_t);
+struct archive_wstring *
+archive_wstring_ensure(struct archive_wstring *, size_t);
 
 /* Append C string, which may lack trailing \0. */
 /* The source is declared void * here because this gets used with
@@ -110,42 +147,91 @@
  * Declaring it "char *" as with some of the other functions just
  * leads to a lot of extra casts. */
 struct archive_string *
-__archive_strncat(struct archive_string *, const void *, size_t);
-#define	archive_strncat  __archive_strncat
+archive_strncat(struct archive_string *, const void *, size_t);
+struct archive_wstring *
+archive_wstrncat(struct archive_wstring *, const wchar_t *, size_t);
 
 /* Append a C string to an archive_string, resizing as necessary. */
-#define	archive_strcat(as,p) __archive_string_append((as),(p),strlen(p))
+struct archive_string *
+archive_strcat(struct archive_string *, const void *);
+struct archive_wstring *
+archive_wstrcat(struct archive_wstring *, const wchar_t *);
 
 /* Copy a C string to an archive_string, resizing as necessary. */
 #define	archive_strcpy(as,p) \
-	((as)->length = 0, __archive_string_append((as), (p), p == NULL ? 0 : strlen(p)))
+	archive_strncpy((as), (p), ((p) == NULL ? 0 : strlen(p)))
+#define	archive_wstrcpy(as,p) \
+	archive_wstrncpy((as), (p), ((p) == NULL ? 0 : wcslen(p)))
+#define	archive_strcpy_in_locale(as,p,lo) \
+	archive_strncpy_in_locale((as), (p), ((p) == NULL ? 0 : strlen(p)), (lo))
 
 /* Copy a C string to an archive_string with limit, resizing as necessary. */
 #define	archive_strncpy(as,p,l) \
 	((as)->length=0, archive_strncat((as), (p), (l)))
+#define	archive_wstrncpy(as,p,l) \
+	((as)->length = 0, archive_wstrncat((as), (p), (l)))
 
 /* Return length of string. */
 #define	archive_strlen(a) ((a)->length)
 
 /* Set string length to zero. */
 #define	archive_string_empty(a) ((a)->length = 0)
+#define	archive_wstring_empty(a) ((a)->length = 0)
 
 /* Release any allocated storage resources. */
-void	__archive_string_free(struct archive_string *);
-#define	archive_string_free  __archive_string_free
+void	archive_string_free(struct archive_string *);
+void	archive_wstring_free(struct archive_wstring *);
 
 /* Like 'vsprintf', but resizes the underlying string as necessary. */
-void	__archive_string_vsprintf(struct archive_string *, const char *,
+/* Note: This only implements a small subset of standard printf functionality. */
+void	archive_string_vsprintf(struct archive_string *, const char *,
 	    va_list) __LA_PRINTF(2, 0);
-#define	archive_string_vsprintf	__archive_string_vsprintf
+void	archive_string_sprintf(struct archive_string *, const char *, ...)
+	    __LA_PRINTF(2, 3);
 
-void	__archive_string_sprintf(struct archive_string *, const char *, ...)
-	    __LA_PRINTF(2, 3);
-#define	archive_string_sprintf	__archive_string_sprintf
+/* Translates from MBS to Unicode. */
+/* Returns non-zero if conversion failed in any way. */
+int archive_wstring_append_from_mbs(struct archive_wstring *dest,
+    const char *, size_t);
 
-/* Allocates a fresh buffer and converts as (assumed to be UTF-8) into it.
- * Returns NULL if conversion failed in any way. */
-wchar_t *__archive_string_utf8_w(struct archive_string *as);
+
+/* A "multistring" can hold Unicode, UTF8, or MBS versions of
+ * the string.  If you set and read the same version, no translation
+ * is done.  If you set and read different versions, the library
+ * will attempt to transparently convert.
+ */
+struct archive_mstring {
+	struct archive_string aes_mbs;
+	struct archive_string aes_utf8;
+	struct archive_wstring aes_wcs;
+	struct archive_string aes_mbs_in_locale;
+	/* Bitmap of which of the above are valid.  Because we're lazy
+	 * about malloc-ing and reusing the underlying storage, we
+	 * can't rely on NULL pointers to indicate whether a string
+	 * has been set. */
+	int aes_set;
+#define	AES_SET_MBS 1
+#define	AES_SET_UTF8 2
+#define	AES_SET_WCS 4
+};
+
+void	archive_mstring_clean(struct archive_mstring *);
+void	archive_mstring_copy(struct archive_mstring *dest, struct archive_mstring *src);
+int archive_mstring_get_mbs(struct archive *, struct archive_mstring *, const char **);
+int archive_mstring_get_utf8(struct archive *, struct archive_mstring *, const char **);
+int archive_mstring_get_wcs(struct archive *, struct archive_mstring *, const wchar_t **);
+int	archive_mstring_get_mbs_l(struct archive_mstring *, const char **,
+	    size_t *, struct archive_string_conv *);
+int	archive_mstring_copy_mbs(struct archive_mstring *, const char *mbs);
+int	archive_mstring_copy_mbs_len(struct archive_mstring *, const char *mbs,
+	    size_t);
+int	archive_mstring_copy_utf8(struct archive_mstring *, const char *utf8);
+int	archive_mstring_copy_wcs(struct archive_mstring *, const wchar_t *wcs);
+int	archive_mstring_copy_wcs_len(struct archive_mstring *,
+	    const wchar_t *wcs, size_t);
+int	archive_mstring_copy_mbs_len_l(struct archive_mstring *,
+	    const char *mbs, size_t, struct archive_string_conv *);
+int     archive_mstring_update_utf8(struct archive *, struct archive_mstring *aes, const char *utf8);
 
 
 #endif
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_string_sprintf.c
--- a/head/contrib/libarchive/libarchive/archive_string_sprintf.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_string_sprintf.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_string_sprintf.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_string_sprintf.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * The use of printf()-family functions can be troublesome
@@ -60,16 +60,19 @@
 static void
 append_int(struct archive_string *as, intmax_t d, unsigned base)
 {
+	uintmax_t ud;
+
 	if (d < 0) {
 		archive_strappend_char(as, '-');
-		d = -d;
-	}
-	append_uint(as, d, base);
+		ud = (d == INTMAX_MIN) ? (uintmax_t)(INTMAX_MAX) + 1 : (uintmax_t)(-d);
+	} else
+		ud = d;
+	append_uint(as, ud, base);
 }
 
 
 void
-__archive_string_sprintf(struct archive_string *as, const char *fmt, ...)
+archive_string_sprintf(struct archive_string *as, const char *fmt, ...)
 {
 	va_list ap;
 
@@ -83,15 +86,16 @@
  * necessary.
  */
 void
-__archive_string_vsprintf(struct archive_string *as, const char *fmt,
+archive_string_vsprintf(struct archive_string *as, const char *fmt,
     va_list ap)
 {
 	char long_flag;
 	intmax_t s; /* Signed integer temp. */
 	uintmax_t u; /* Unsigned integer temp. */
 	const char *p, *p2;
+	const wchar_t *pw;
 
-	if (__archive_string_ensure(as, 64) == NULL)
+	if (archive_string_ensure(as, 64) == NULL)
 		__archive_errx(1, "Out of memory");
 
 	if (fmt == NULL) {
@@ -112,40 +116,58 @@
 		long_flag = '\0';
 		switch(*p) {
 		case 'j':
-			long_flag = 'j';
-			p++;
-			break;
 		case 'l':
-			long_flag = 'l';
+		case 'z':
+			long_flag = *p;
 			p++;
 			break;
 		}
 
 		switch (*p) {
 		case '%':
-			__archive_strappend_char(as, '%');
+			archive_strappend_char(as, '%');
 			break;
 		case 'c':
 			s = va_arg(ap, int);
-			__archive_strappend_char(as, s);
+			archive_strappend_char(as, s);
 			break;
 		case 'd':
 			switch(long_flag) {
 			case 'j': s = va_arg(ap, intmax_t); break;
 			case 'l': s = va_arg(ap, long); break;
+			case 'z': s = va_arg(ap, ssize_t); break;
 			default:  s = va_arg(ap, int); break;
 			}
 		        append_int(as, s, 10);
 			break;
 		case 's':
-			p2 = va_arg(ap, char *);
-			archive_strcat(as, p2);
+			switch(long_flag) {
+			case 'l':
+				pw = va_arg(ap, wchar_t *);
+				if (pw == NULL)
+					pw = L"(null)";
+				archive_string_append_from_wcs(as, pw, wcslen(pw));
+				break;
+			default:
+				p2 = va_arg(ap, char *);
+				if (p2 == NULL)
+					p2 = "(null)";
+				archive_strcat(as, p2);
+				break;
+			}
+			break;
+		case 'S':
+			pw = va_arg(ap, wchar_t *);
+			if (pw == NULL)
+				pw = L"(null)";
+			archive_string_append_from_wcs(as, pw, wcslen(pw));
 			break;
 		case 'o': case 'u': case 'x': case 'X':
 			/* Common handling for unsigned integer formats. */
 			switch(long_flag) {
 			case 'j': u = va_arg(ap, uintmax_t); break;
 			case 'l': u = va_arg(ap, unsigned long); break;
+			case 'z': u = va_arg(ap, size_t); break;
 			default:  u = va_arg(ap, unsigned int); break;
 			}
 			/* Format it in the correct base. */
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_util.3
--- a/head/contrib/libarchive/libarchive/archive_util.3	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_util.3	Fri Mar 02 16:54:40 2012 +0200
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $FreeBSD: head/contrib/libarchive/libarchive/archive_util.3 228773 2011-12-21 15:18:52Z mm $
+.\" $FreeBSD: head/contrib/libarchive/libarchive/archive_util.3 232153 2012-02-25 10:58:02Z mm $
 .\"
 .Dd January 8, 2005
 .Dt ARCHIVE_UTIL 3
@@ -35,8 +35,12 @@
 .Nm archive_errno ,
 .Nm archive_error_string ,
 .Nm archive_file_count ,
+.Nm archive_filter_code ,
+.Nm archive_filter_count ,
+.Nm archive_filter_name ,
 .Nm archive_format ,
 .Nm archive_format_name ,
+.Nm archive_position ,
 .Nm archive_set_error
 .Nd libarchive utility functions
 .Sh SYNOPSIS
@@ -56,9 +60,17 @@
 .Ft int
 .Fn archive_file_count "struct archive *"
 .Ft int
+.Fn archive_filter_code "struct archive *" "int"
+.Ft int
+.Fn archive_filter_count "struct archive *" "int"
+.Ft const char *
+.Fn archive_filter_name "struct archive *" "int"
+.Ft int
 .Fn archive_format "struct archive *"
 .Ft const char *
 .Fn archive_format_name "struct archive *"
+.Ft int64_t
+.Fn archive_position "struct archive *" "int"
 .Ft void
 .Fo archive_set_error
 .Fa "struct archive *"
@@ -77,17 +89,21 @@
 Clears any error information left over from a previous call.
 Not generally used in client code.
 .It Fn archive_compression
-Returns a numeric code indicating the current compression.
-This value is set by
-.Fn archive_read_open .
+Synonym for
+.Fn archive_filter_code(a, 0) .
 .It Fn archive_compression_name
-Returns a text description of the current compression suitable for display.
+Synonym for
+.Fn archive_filter_name(a, 0) .
 .It Fn archive_copy_error
 Copies error information from one archive to another.
 .It Fn archive_errno
 Returns a numeric error code (see
 .Xr errno 2 )
 indicating the reason for the most recent error return.
+Note that this can not be reliably used to detect whether an
+error has occurred.
+It should be used only after another libarchive function
+has returned an error status.
 .It Fn archive_error_string
 Returns a textual error message suitable for display.
 The error message here is usually more specific than that
@@ -98,9 +114,45 @@
 .It Fn archive_file_count
 Returns a count of the number of files processed by this archive object.
 The count is incremented by calls to
-.Xr archive_write_header
+.Xr archive_write_header 3
 or
-.Xr archive_read_next_header .
+.Xr archive_read_next_header 3 .
+.It Fn archive_filter_code
+Returns a numeric code identifying the indicated filter.
+See
+.Fn archive_filter_count
+for details of the numbering.
+.It Fn archive_filter_count
+Returns the number of filters in the current pipeline.
+For read archive handles, these filters are added automatically
+by the automatic format detection.
+For write archive handles, these filters are added by calls to the various
+.Fn archive_write_add_filter_XXX
+functions.
+Filters in the resulting pipeline are numbered so that filter 0
+is the filter closest to the format handler.
+As a convenience, functions that expect a filter number will
+accept -1 as a synonym for the highest-numbered filter.
+.Pp
+For example, when reading a uuencoded gzipped tar archive, there
+are three filters:
+filter 0 is the gunzip filter,
+filter 1 is the uudecode filter,
+and filter 2 is the pseudo-filter that wraps the archive read functions.
+In this case, requesting
+.Fn archive_position(a, -1)
+would be a synonym for
+.Fn archive_position(a, 2)
+which would return the number of bytes currently read from the archive, while
+.Fn archive_position(a, 1)
+would return the number of bytes after uudecoding, and
+.Fn archive_position(a, 0)
+would return the number of bytes after decompression.
+.It Fn archive_filter_name
+Returns a textual name identifying the indicated filter.
+See
+.Fn archive_filter_count
+for details of the numbering.
 .It Fn archive_format
 Returns a numeric code indicating the format of the current
 archive entry.
@@ -113,6 +165,16 @@
 These entries will have different format codes.
 .It Fn archive_format_name
 A textual description of the format of the current entry.
+.It Fn archive_position
+Returns the number of bytes read from or written to the indicated filter.
+In particular,
+.Fn archive_position(a, 0)
+returns the number of bytes read or written by the format handler, while
+.Fn archive_position(a, -1)
+returns the number of bytes read or written to the archive.
+See
+.Fn archive_filter_count
+for details of the numbering here.
 .It Fn archive_set_error
 Sets the numeric error code and error description that will be returned
 by
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_util.c
--- a/head/contrib/libarchive/libarchive/archive_util.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_util.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2009 Michihiro NAKAJIMA
+ * Copyright (c) 2009,2010 Michihiro NAKAJIMA
  * Copyright (c) 2003-2007 Tim Kientzle
  * All rights reserved.
  *
@@ -25,53 +25,39 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_util.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_util.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
 #ifdef HAVE_STRING_H
 #include <string.h>
 #endif
+#if defined(HAVE_WINCRYPT_H) && !defined(__CYGWIN__)
+#include <wincrypt.h>
+#endif
 
 #include "archive.h"
 #include "archive_private.h"
 #include "archive_string.h"
 
-#if ARCHIVE_VERSION_NUMBER < 3000000
-/* These disappear in libarchive 3.0 */
-/* Deprecated. */
+/* Generic initialization of 'struct archive' objects. */
 int
-archive_api_feature(void)
+__archive_clean(struct archive *a)
 {
-	return (ARCHIVE_API_FEATURE);
+	archive_string_conversion_free(a);
+	return (ARCHIVE_OK);
 }
 
-/* Deprecated. */
-int
-archive_api_version(void)
-{
-	return (ARCHIVE_API_VERSION);
-}
-
-/* Deprecated synonym for archive_version_number() */
-int
-archive_version_stamp(void)
-{
-	return (archive_version_number());
-}
-
-/* Deprecated synonym for archive_version_string() */
-const char *
-archive_version(void)
-{
-	return (archive_version_string());
-}
-#endif
-
 int
 archive_version_number(void)
 {
@@ -97,7 +83,7 @@
 	if (a->error != NULL  &&  *a->error != '\0')
 		return (a->error);
 	else
-		return ("(Empty error message)");
+		return (NULL);
 }
 
 int
@@ -122,13 +108,13 @@
 int
 archive_compression(struct archive *a)
 {
-	return (a->compression_code);
+	return archive_filter_code(a, 0);
 }
 
 const char *
 archive_compression_name(struct archive *a)
 {
-	return (a->compression_name);
+	return archive_filter_name(a, 0);
 }
 
 
@@ -138,7 +124,7 @@
 int64_t
 archive_position_compressed(struct archive *a)
 {
-	return (a->raw_position);
+	return archive_filter_bytes(a, -1);
 }
 
 /*
@@ -147,7 +133,7 @@
 int64_t
 archive_position_uncompressed(struct archive *a)
 {
-	return (a->file_position);
+	return archive_filter_bytes(a, 0);
 }
 
 void
@@ -169,6 +155,7 @@
 		return;
 	}
 
+	archive_string_empty(&(a->error_string));
 	va_start(ap, fmt);
 	archive_string_vsprintf(&(a->error_string), fmt, ap);
 	va_end(ap);
@@ -200,193 +187,279 @@
 }
 
 /*
- * Parse option strings
- *  Detail of option format.
- *    - The option can accept:
- *     "opt-name", "!opt-name", "opt-name=value".
- *
- *    - The option entries are separated by comma.
- *        e.g  "compression=9,opt=XXX,opt-b=ZZZ"
- *
- *    - The name of option string consist of '-' and alphabet
- *      but character '-' cannot be used for the first character.
- *      (Regular expression is [a-z][-a-z]+)
- *
- *    - For a specfic format/filter, using the format name with ':'.
- *        e.g  "zip:compression=9"
- *        (This "compression=9" option entry is for "zip" format only)
- *
- *      If another entries follow it, those are not for
- *      the specfic format/filter.
- *        e.g  handle "zip:compression=9,opt=XXX,opt-b=ZZZ"
- *          "zip" format/filter handler will get "compression=9"
- *          all format/filter handler will get "opt=XXX"
- *          all format/filter handler will get "opt-b=ZZZ"
- *
- *    - Whitespace and tab are bypassed.
- *
+ * Create a temporary file
+ */
+#if defined(_WIN32) && !defined(__CYGWIN__)
+
+/*
+ * Do not use Windows tmpfile() function.
+ * It will make a temporary file under the root directory
+ * and it'll cause permission error if a user who is
+ * non-Administrator creates temporary files.
+ * Also Windows version of mktemp family including _mktemp_s
+ * are not secure.
  */
 int
-__archive_parse_options(const char *p, const char *fn, int keysize, char *key,
-    int valsize, char *val)
+__archive_mktemp(const char *tmpdir)
 {
-	const char *p_org;
-	int apply;
-	int kidx, vidx;
-	int negative; 
-	enum {
-		/* Requested for initialization. */
-		INIT,
-		/* Finding format/filter-name and option-name. */
-		F_BOTH,
-		/* Finding option-name only.
-		 * (already detected format/filter-name) */
-		F_NAME,
-		/* Getting option-value. */
-		G_VALUE,
-	} state;
+	static const wchar_t num[] = {
+		L'0', L'1', L'2', L'3', L'4', L'5', L'6', L'7',
+		L'8', L'9', L'A', L'B', L'C', L'D', L'E', L'F',
+		L'G', L'H', L'I', L'J', L'K', L'L', L'M', L'N',
+		L'O', L'P', L'Q', L'R', L'S', L'T', L'U', L'V',
+		L'W', L'X', L'Y', L'Z', L'a', L'b', L'c', L'd',
+		L'e', L'f', L'g', L'h', L'i', L'j', L'k', L'l',
+		L'm', L'n', L'o', L'p', L'q', L'r', L's', L't',
+		L'u', L'v', L'w', L'x', L'y', L'z'
+	};
+	HCRYPTPROV hProv;
+	struct archive_wstring temp_name;
+	wchar_t *ws;
+	DWORD attr;
+	wchar_t *xp, *ep;
+	int fd;
 
-	p_org = p;
-	state = INIT;
-	kidx = vidx = negative = 0;
-	apply = 1;
-	while (*p) {
-		switch (state) {
-		case INIT:
-			kidx = vidx = 0;
-			negative = 0;
-			apply = 1;
-			state = F_BOTH;
-			break;
-		case F_BOTH:
-		case F_NAME:
-			if ((*p >= 'a' && *p <= 'z') ||
-			    (*p >= '0' && *p <= '9') || *p == '-') {
-				if (kidx == 0 && !(*p >= 'a' && *p <= 'z'))
-					/* Illegal sequence. */
-					return (-1);
-				if (kidx >= keysize -1)
-					/* Too many characters. */
-					return (-1);
-				key[kidx++] = *p++;
-			} else if (*p == '!') {
-				if (kidx != 0)
-					/* Illegal sequence. */
-					return (-1);
-				negative = 1;
-				++p;
-			} else if (*p == ',') {
-				if (kidx == 0)
-					/* Illegal sequence. */
-					return (-1);
-				if (!negative)
-					val[vidx++] = '1';
-				/* We have got boolean option data. */
-				++p;
-				if (apply)
-					goto complete;
-				else
-					/* This option does not apply to the
-					 * format which the fn variable
-					 * indicate. */
-					state = INIT;
-			} else if (*p == ':') {
-				/* obuf data is format name */
-				if (state == F_NAME)
-					/* We already found it. */
-					return (-1);
-				if (kidx == 0)
-					/* Illegal sequence. */
-					return (-1);
-				if (negative)
-					/* We cannot accept "!format-name:". */
-					return (-1);
-				key[kidx] = '\0';
-				if (strcmp(fn, key) != 0)
-					/* This option does not apply to the
-					 * format which the fn variable
-					 * indicate. */
-					apply = 0;
-				kidx = 0;
-				++p;
-				state = F_NAME;
-			} else if (*p == '=') {
-				if (kidx == 0)
-					/* Illegal sequence. */
-					return (-1);
-				if (negative)
-					/* We cannot accept "!opt-name=value". */
-					return (-1);
-				++p;
-				state = G_VALUE;
-			} else if (*p == ' ') {
-				/* Pass the space character */
-				++p;
-			} else {
-				/* Illegal character. */
-				return (-1);
-			}
-			break;
-		case G_VALUE:
-			if (*p == ',') {
-				if (vidx == 0)
-					/* Illegal sequence. */
-					return (-1);
-				/* We have got option data. */
-				++p;
-				if (apply)
-					goto complete;
-				else
-					/* This option does not apply to the
-					 * format which the fn variable
-					 * indicate. */
-					state = INIT;
-			} else if (*p == ' ') {
-				/* Pass the space character */
-				++p;
-			} else {
-				if (vidx >= valsize -1)
-					/* Too many characters. */
-					return (-1);
-				val[vidx++] = *p++;
-			}
-			break;
-		} 
+	hProv = (HCRYPTPROV)NULL;
+	fd = -1;
+	ws = NULL;
+	archive_string_init(&temp_name);
+
+	/* Get a temporary directory. */
+	if (tmpdir == NULL) {
+		size_t l;
+		wchar_t *tmp;
+
+		l = GetTempPathW(0, NULL);
+		if (l == 0) {
+			la_dosmaperr(GetLastError());
+			goto exit_tmpfile;
+		}
+		tmp = malloc(l*sizeof(wchar_t));
+		if (tmp == NULL) {
+			errno = ENOMEM;
+			goto exit_tmpfile;
+		}
+		GetTempPathW(l, tmp);
+		archive_wstrcpy(&temp_name, tmp);
+		free(tmp);
+	} else {
+		archive_wstring_append_from_mbs(&temp_name, tmpdir,
+		    strlen(tmpdir));
+		if (temp_name.s[temp_name.length-1] != L'/')
+			archive_wstrappend_wchar(&temp_name, L'/');
 	}
 
-	switch (state) {
-	case F_BOTH:
-	case F_NAME:
-		if (kidx != 0) {
-			if (!negative)
-				val[vidx++] = '1';
-			/* We have got boolean option. */
-			if (apply)
-				/* This option apply to the format which the
-				 * fn variable indicate. */
-				goto complete;
+	/* Check if temp_name is a directory. */
+	attr = GetFileAttributesW(temp_name.s);
+	if (attr == (DWORD)-1) {
+		if (GetLastError() != ERROR_FILE_NOT_FOUND) {
+			la_dosmaperr(GetLastError());
+			goto exit_tmpfile;
 		}
-		break;
-	case G_VALUE:
-		if (vidx == 0)
-			/* Illegal sequence. */
-			return (-1);
-		/* We have got option value. */
-		if (apply)
-			/* This option apply to the format which the fn
-			 * variable indicate. */
-			goto complete;
-		break;
-	case INIT:/* nothing */
-		break;
+		ws = __la_win_permissive_name_w(temp_name.s);
+		if (ws == NULL) {
+			errno = EINVAL;
+			goto exit_tmpfile;
+		}
+		attr = GetFileAttributesW(ws);
+		if (attr == (DWORD)-1) {
+			la_dosmaperr(GetLastError());
+			goto exit_tmpfile;
+		}
+	}
+	if (!(attr & FILE_ATTRIBUTE_DIRECTORY)) {
+		errno = ENOTDIR;
+		goto exit_tmpfile;
 	}
 
-	/* End of Option string. */
-	return (0);
+	/*
+	 * Create a temporary file.
+	 */
+	archive_wstrcat(&temp_name, L"libarchive_");
+	xp = temp_name.s + archive_strlen(&temp_name);
+	archive_wstrcat(&temp_name, L"XXXXXXXXXX");
+	ep = temp_name.s + archive_strlen(&temp_name);
 
-complete:
-	key[kidx] = '\0';
-	val[vidx] = '\0';
-	/* Return a size which we've consumed for detecting option */
-	return ((int)(p - p_org));
+	if (!CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL,
+		CRYPT_VERIFYCONTEXT)) {
+		la_dosmaperr(GetLastError());
+		goto exit_tmpfile;
+	}
+
+	for (;;) {
+		wchar_t *p;
+		HANDLE h;
+
+		/* Generate a random file name through CryptGenRandom(). */
+		p = xp;
+		if (!CryptGenRandom(hProv, (ep - p)*sizeof(wchar_t), (BYTE*)p)) {
+			la_dosmaperr(GetLastError());
+			goto exit_tmpfile;
+		}
+		for (; p < ep; p++)
+			*p = num[((DWORD)*p) % (sizeof(num)/sizeof(num[0]))];
+
+		free(ws);
+		ws = __la_win_permissive_name_w(temp_name.s);
+		if (ws == NULL) {
+			errno = EINVAL;
+			goto exit_tmpfile;
+		}
+		/* Specifies FILE_FLAG_DELETE_ON_CLOSE flag is to
+		 * delete this temporary file immediately when this
+		 * file closed. */
+		h = CreateFileW(ws,
+		    GENERIC_READ | GENERIC_WRITE | DELETE,
+		    0,/* Not share */
+		    NULL,
+		    CREATE_NEW,/* Create a new file only */
+		    FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE,
+		    NULL);
+		if (h == INVALID_HANDLE_VALUE) {
+			/* The same file already exists. retry with
+			 * a new filename. */
+			if (GetLastError() == ERROR_FILE_EXISTS)
+				continue;
+			/* Otherwise, fail creation temporary file. */
+			la_dosmaperr(GetLastError());
+			goto exit_tmpfile;
+		}
+		fd = _open_osfhandle((intptr_t)h, _O_BINARY | _O_RDWR);
+		if (fd == -1) {
+			CloseHandle(h);
+			goto exit_tmpfile;
+		} else
+			break;/* success! */
+	}
+exit_tmpfile:
+	if (hProv != (HCRYPTPROV)NULL)
+		CryptReleaseContext(hProv, 0);
+	free(ws);
+	archive_wstring_free(&temp_name);
+	return (fd);
 }
+
+#else
+
+static int
+get_tempdir(struct archive_string *temppath)
+{
+	const char *tmp;
+
+	tmp = getenv("TMPDIR");
+	if (tmp == NULL)
+#ifdef _PATH_TMP
+		tmp = _PATH_TMP;
+#else
+                tmp = "/tmp";
+#endif
+	archive_strcpy(temppath, tmp);
+	if (temppath->s[temppath->length-1] != '/')
+		archive_strappend_char(temppath, '/');
+	return (ARCHIVE_OK);
+}
+
+#if defined(HAVE_MKSTEMP)
+
+/*
+ * We can use mkstemp().
+ */
+
+int
+__archive_mktemp(const char *tmpdir)
+{
+	struct archive_string temp_name;
+	int fd = -1;
+
+	archive_string_init(&temp_name);
+	if (tmpdir == NULL) {
+		if (get_tempdir(&temp_name) != ARCHIVE_OK)
+			goto exit_tmpfile;
+	} else {
+		archive_strcpy(&temp_name, tmpdir);
+		if (temp_name.s[temp_name.length-1] != '/')
+			archive_strappend_char(&temp_name, '/');
+	}
+	archive_strcat(&temp_name, "libarchive_XXXXXX");
+	fd = mkstemp(temp_name.s);
+	if (fd < 0)
+		goto exit_tmpfile;
+	unlink(temp_name.s);
+exit_tmpfile:
+	archive_string_free(&temp_name);
+	return (fd);
+}
+
+#else
+
+/*
+ * We use a private routine.
+ */
+
+int
+__archive_mktemp(const char *tmpdir)
+{
+        static const char num[] = {
+		'0', '1', '2', '3', '4', '5', '6', '7',
+		'8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
+		'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
+		'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
+		'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
+		'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
+		'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
+		'u', 'v', 'w', 'x', 'y', 'z'
+        };
+	struct archive_string temp_name;
+	struct stat st;
+	int fd;
+	char *tp, *ep;
+	unsigned seed;
+
+	fd = -1;
+	archive_string_init(&temp_name);
+	if (tmpdir == NULL) {
+		if (get_tempdir(&temp_name) != ARCHIVE_OK)
+			goto exit_tmpfile;
+	} else
+		archive_strcpy(&temp_name, tmpdir);
+	if (temp_name.s[temp_name.length-1] == '/') {
+		temp_name.s[temp_name.length-1] = '\0';
+		temp_name.length --;
+	}
+	if (stat(temp_name.s, &st) < 0)
+		goto exit_tmpfile;
+	if (!S_ISDIR(st.st_mode)) {
+		errno = ENOTDIR;
+		goto exit_tmpfile;
+	}
+	archive_strcat(&temp_name, "/libarchive_");
+	tp = temp_name.s + archive_strlen(&temp_name);
+	archive_strcat(&temp_name, "XXXXXXXXXX");
+	ep = temp_name.s + archive_strlen(&temp_name);
+
+	fd = open("/dev/random", O_RDONLY);
+	if (fd < 0)
+		seed = time(NULL);
+	else {
+		if (read(fd, &seed, sizeof(seed)) < 0)
+			seed = time(NULL);
+		close(fd);
+	}
+	do {
+		char *p;
+
+		p = tp;
+		while (p < ep)
+			*p++ = num[((unsigned)rand_r(&seed)) % sizeof(num)];
+		fd = open(temp_name.s, O_CREAT | O_EXCL | O_RDWR, 0600);
+	} while (fd < 0 && errno == EEXIST);
+	if (fd < 0)
+		goto exit_tmpfile;
+	unlink(temp_name.s);
+exit_tmpfile:
+	archive_string_free(&temp_name);
+	return (fd);
+}
+
+#endif /* HAVE_MKSTEMP */
+#endif /* !_WIN32 || __CYGWIN__ */
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_virtual.c
--- a/head/contrib/libarchive/libarchive/archive_virtual.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_virtual.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,13 +24,37 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_virtual.c 228773 2011-12-21 15:18:52Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_virtual.c 232153 2012-02-25 10:58:02Z mm $");
 
 #include "archive.h"
 #include "archive_entry.h"
 #include "archive_private.h"
 
 int
+archive_filter_code(struct archive *a, int n)
+{
+	return ((a->vtable->archive_filter_code)(a, n));
+}
+
+int
+archive_filter_count(struct archive *a)
+{
+	return ((a->vtable->archive_filter_count)(a));
+}
+
+const char *
+archive_filter_name(struct archive *a, int n)
+{
+	return ((a->vtable->archive_filter_name)(a, n));
+}
+
+int64_t
+archive_filter_bytes(struct archive *a, int n)
+{
+	return ((a->vtable->archive_filter_bytes)(a, n));
+}
+
+int
 archive_write_close(struct archive *a)
 {
 	return ((a->vtable->archive_close)(a));
@@ -45,6 +69,8 @@
 int
 archive_write_free(struct archive *a)
 {
+	if (a == NULL)
+		return (ARCHIVE_OK);
 	return ((a->vtable->archive_free)(a));
 }
 
@@ -53,13 +79,15 @@
 int
 archive_write_finish(struct archive *a)
 {
-	return ((a->vtable->archive_free)(a));
+	return archive_write_free(a);
 }
 #endif
 
 int
 archive_read_free(struct archive *a)
 {
+	if (a == NULL)
+		return (ARCHIVE_OK);
 	return ((a->vtable->archive_free)(a));
 }
 
@@ -68,7 +96,7 @@
 int
 archive_read_finish(struct archive *a)
 {
-	return ((a->vtable->archive_free)(a));
+	return archive_read_free(a);
 }
 #endif
 
@@ -92,7 +120,32 @@
 }
 
 ssize_t
-archive_write_data_block(struct archive *a, const void *buff, size_t s, off_t o)
+archive_write_data_block(struct archive *a, const void *buff, size_t s, int64_t o)
 {
+	if (a->vtable->archive_write_data_block == NULL) {
+		archive_set_error(a, ARCHIVE_ERRNO_MISC,
+		    "archive_write_data_block not supported");
+		a->state = ARCHIVE_STATE_FATAL;
+		return (ARCHIVE_FATAL);
+	}
 	return ((a->vtable->archive_write_data_block)(a, buff, s, o));
 }
+
+int
+archive_read_next_header(struct archive *a, struct archive_entry **entry)
+{
+	return ((a->vtable->archive_read_next_header)(a, entry));
+}
+
+int
+archive_read_next_header2(struct archive *a, struct archive_entry *entry)
+{
+	return ((a->vtable->archive_read_next_header2)(a, entry));
+}
+
+int
+archive_read_data_block(struct archive *a,
+    const void **buff, size_t *s, int64_t *o)
+{
+	return ((a->vtable->archive_read_data_block)(a, buff, s, o));
+}
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_write.3
--- a/head/contrib/libarchive/libarchive/archive_write.3	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_write.3	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-.\" Copyright (c) 2003-2007 Tim Kientzle
+.\" Copyright (c) 2003-2011 Tim Kientzle
 .\" All rights reserved.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
@@ -22,110 +22,16 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $FreeBSD: head/contrib/libarchive/libarchive/archive_write.3 228773 2011-12-21 15:18:52Z mm $
+.\" $FreeBSD: head/contrib/libarchive/libarchive/archive_write.3 232153 2012-02-25 10:58:02Z mm $
 .\"
-.Dd May 11, 2008
+.Dd March 23, 2011
 .Dt ARCHIVE_WRITE 3
 .Os
 .Sh NAME
-.Nm archive_write_new ,
-.Nm archive_write_set_format_cpio ,
-.Nm archive_write_set_format_pax ,
-.Nm archive_write_set_format_pax_restricted ,
-.Nm archive_write_set_format_shar ,
-.Nm archive_write_set_format_shar_binary ,
-.Nm archive_write_set_format_ustar ,
-.Nm archive_write_get_bytes_per_block ,
-.Nm archive_write_set_bytes_per_block ,
-.Nm archive_write_set_bytes_in_last_block ,
-.Nm archive_write_set_compression_bzip2 ,
-.Nm archive_write_set_compression_compress ,
-.Nm archive_write_set_compression_gzip ,
-.Nm archive_write_set_compression_none ,
-.Nm archive_write_set_compression_program ,
-.Nm archive_write_set_compressor_options ,
-.Nm archive_write_set_format_options ,
-.Nm archive_write_set_options ,
-.Nm archive_write_open ,
-.Nm archive_write_open_fd ,
-.Nm archive_write_open_FILE ,
-.Nm archive_write_open_filename ,
-.Nm archive_write_open_memory ,
-.Nm archive_write_header ,
-.Nm archive_write_data ,
-.Nm archive_write_finish_entry ,
-.Nm archive_write_close ,
-.Nm archive_write_free
+.Nm archive_write
 .Nd functions for creating archives
 .Sh SYNOPSIS
 .In archive.h
-.Ft struct archive *
-.Fn archive_write_new "void"
-.Ft int
-.Fn archive_write_get_bytes_per_block "struct archive *"
-.Ft int
-.Fn archive_write_set_bytes_per_block "struct archive *" "int bytes_per_block"
-.Ft int
-.Fn archive_write_set_bytes_in_last_block "struct archive *" "int"
-.Ft int
-.Fn archive_write_set_compression_bzip2 "struct archive *"
-.Ft int
-.Fn archive_write_set_compression_compress "struct archive *"
-.Ft int
-.Fn archive_write_set_compression_gzip "struct archive *"
-.Ft int
-.Fn archive_write_set_compression_none "struct archive *"
-.Ft int
-.Fn archive_write_set_compression_program "struct archive *" "const char * cmd"
-.Ft int
-.Fn archive_write_set_format_cpio "struct archive *"
-.Ft int
-.Fn archive_write_set_format_pax "struct archive *"
-.Ft int
-.Fn archive_write_set_format_pax_restricted "struct archive *"
-.Ft int
-.Fn archive_write_set_format_shar "struct archive *"
-.Ft int
-.Fn archive_write_set_format_shar_binary "struct archive *"
-.Ft int
-.Fn archive_write_set_format_ustar "struct archive *"
-.Ft int
-.Fn archive_write_set_format_options "struct archive *" "const char *"
-.Ft int
-.Fn archive_write_set_compressor_options "struct archive *" "const char *"
-.Ft int
-.Fn archive_write_set_options "struct archive *" "const char *"
-.Ft int
-.Fo archive_write_open
-.Fa "struct archive *"
-.Fa "void *client_data"
-.Fa "archive_open_callback *"
-.Fa "archive_write_callback *"
-.Fa "archive_close_callback *"
-.Fc
-.Ft int
-.Fn archive_write_open_fd "struct archive *" "int fd"
-.Ft int
-.Fn archive_write_open_FILE "struct archive *" "FILE *file"
-.Ft int
-.Fn archive_write_open_filename "struct archive *" "const char *filename"
-.Ft int
-.Fo archive_write_open_memory
-.Fa "struct archive *"
-.Fa "void *buffer"
-.Fa "size_t bufferSize"
-.Fa "size_t *outUsed"
-.Fc
-.Ft int
-.Fn archive_write_header "struct archive *" "struct archive_entry *"
-.Ft ssize_t
-.Fn archive_write_data "struct archive *" "const void *" "size_t"
-.Ft int
-.Fn archive_write_finish_entry "struct archive *"
-.Ft int
-.Fn archive_write_close "struct archive *"
-.Ft int
-.Fn archive_write_free "struct archive *"
 .Sh DESCRIPTION
 These functions provide a complete API for creating streaming
 archive files.
@@ -133,316 +39,83 @@
 .Tn struct archive
 object, set any desired options, initialize the archive, append entries, then
 close the archive and release all resources.
-The following summary describes the functions in approximately
-the order they are ordinarily used:
-.Bl -tag -width indent
-.It Fn archive_write_new
-Allocates and initializes a
+.\"
+.Ss Create archive object
+See
+.Xr archive_write_new 3 .
+.Pp
+To write an archive, you must first obtain an initialized
 .Tn struct archive
-object suitable for writing a tar archive.
-.It Fn archive_write_set_bytes_per_block
-Sets the block size used for writing the archive data.
-Every call to the write callback function, except possibly the last one, will
-use this value for the length.
-The third parameter is a boolean that specifies whether or not the final block
-written will be padded to the full block size.
-If it is zero, the last block will not be padded.
-If it is non-zero, padding will be added both before and after compression.
-The default is to use a block size of 10240 bytes and to pad the last block.
-Note that a block size of zero will suppress internal blocking
-and cause writes to be sent directly to the write callback as they occur.
-.It Fn archive_write_get_bytes_per_block
-Retrieve the block size to be used for writing.
-A value of -1 here indicates that the library should use default values.
-A value of zero indicates that internal blocking is suppressed.
-.It Fn archive_write_set_bytes_in_last_block
-Sets the block size used for writing the last block.
-If this value is zero, the last block will be padded to the same size
-as the other blocks.
-Otherwise, the final block will be padded to a multiple of this size.
-In particular, setting it to 1 will cause the final block to not be padded.
-For compressed output, any padding generated by this option
-is applied only after the compression.
-The uncompressed data is always unpadded.
-The default is to pad the last block to the full block size (note that
-.Fn archive_write_open_filename
-will set this based on the file type).
-Unlike the other
-.Dq set
-functions, this function can be called after the archive is opened.
-.It Fn archive_write_get_bytes_in_last_block
-Retrieve the currently-set value for last block size.
-A value of -1 here indicates that the library should use default values.
-.It Xo
-.Fn archive_write_set_format_cpio ,
-.Fn archive_write_set_format_pax ,
-.Fn archive_write_set_format_pax_restricted ,
-.Fn archive_write_set_format_shar ,
-.Fn archive_write_set_format_shar_binary ,
-.Fn archive_write_set_format_ustar
-.Xc
-Sets the format that will be used for the archive.
-The library can write
-POSIX octet-oriented cpio format archives,
-POSIX-standard
-.Dq pax interchange
-format archives,
-traditional
-.Dq shar
-archives,
-enhanced
-.Dq binary
-shar archives that store a variety of file attributes and handle binary files,
+object from
+.Fn archive_write_new .
+.\"
+.Ss Enable filters and formats, configure block size and padding
+See
+.Xr archive_write_filter 3 ,
+.Xr archive_write_format 3
 and
-POSIX-standard
-.Dq ustar
-archives.
-The pax interchange format is a backwards-compatible tar format that
-adds key/value attributes to each entry and supports arbitrary
-filenames, linknames, uids, sizes, etc.
-.Dq Restricted pax interchange format
-is the library default; this is the same as pax format, but suppresses
-the pax extended header for most normal files.
-In most cases, this will result in ordinary ustar archives.
-.It Xo
-.Fn archive_write_set_compression_bzip2 ,
-.Fn archive_write_set_compression_compress ,
-.Fn archive_write_set_compression_gzip ,
-.Fn archive_write_set_compression_none
-.Xc
-The resulting archive will be compressed as specified.
-Note that the compressed output is always properly blocked.
-.It Fn archive_write_set_compression_program
-The archive will be fed into the specified compression program.
-The output of that program is blocked and written to the client
-write callbacks.
-.It Xo
-.Fn archive_write_set_compressor_options ,
-.Fn archive_write_set_format_options ,
-.Fn archive_write_set_options
-.Xc
-Specifies options that will be passed to the currently-enabled
-compressor and/or format writer.
-The argument is a comma-separated list of individual options.
-Individual options have one of the following forms:
-.Bl -tag -compact -width indent
-.It Ar option=value
-The option/value pair will be provided to every module.
-Modules that do not accept an option with this name will ignore it.
-.It Ar option
-The option will be provided to every module with a value of
-.Dq 1 .
-.It Ar !option
-The option will be provided to every module with a NULL value.
-.It Ar module:option=value , Ar module:option , Ar module:!option
-As above, but the corresponding option and value will be provided
-only to modules whose name matches
-.Ar module .
-.El
-The return value will be
-.Cm ARCHIVE_OK
-if any module accepts the option, or
-.Cm ARCHIVE_WARN
-if no module accepted the option, or
-.Cm ARCHIVE_FATAL
-if there was a fatal error while attempting to process the option.
+.Xr archive_write_blocksize 3 .
 .Pp
-The currently supported options are:
-.Bl -tag -compact -width indent
-.It Compressor gzip
-.Bl -tag -compact -width indent
-.It Cm compression-level
-The value is interpreted as a decimal integer specifying the
-gzip compression level.
-.El
-.It Compressor xz
-.Bl -tag -compact -width indent
-.It Cm compression-level
-The value is interpreted as a decimal integer specifying the
-compression level.
-.El
-.It Format mtree
-.Bl -tag -compact -width indent
-.It Cm cksum , Cm device , Cm flags , Cm gid , Cm gname , Cm indent , Cm link , Cm md5 , Cm mode , Cm nlink , Cm rmd160 , Cm sha1 , Cm sha256 , Cm sha384 , Cm sha512 , Cm size , Cm time , Cm uid , Cm uname
-Enable a particular keyword in the mtree output.
-Prefix with an exclamation mark to disable the corresponding keyword.
-The default is equivalent to
-.Dq device, flags, gid, gname, link, mode, nlink, size, time, type, uid, uname .
-.It Cm all
-Enables all of the above keywords.
-.It Cm use-set
-Enables generation of
-.Cm /set
-lines that specify default values for the following files and/or directories.
-.It Cm indent
-XXX needs explanation XXX
-.El
-.El
-.It Fn archive_write_open
-Freeze the settings, open the archive, and prepare for writing entries.
-This is the most generic form of this function, which accepts
-pointers to three callback functions which will be invoked by
-the compression layer to write the constructed archive.
-.It Fn archive_write_open_fd
-A convenience form of
+You can then modify this object for the desired operations with the
+various
+.Fn archive_write_set_XXX
+functions.
+In particular, you will need to invoke appropriate
+.Fn archive_write_add_XXX
+and
+.Fn archive_write_set_XXX
+functions to enable the corresponding compression and format
+support.
+.\"
+.Ss Set options
+See
+.Xr archive_read_set_options 3 .
+.\"
+.Ss Open archive
+See
+.Xr archive_write_open 3 .
+.Pp
+Once you have prepared the
+.Tn struct archive
+object, you call
 .Fn archive_write_open
-that accepts a file descriptor.
-The
-.Fn archive_write_open_fd
-function is safe for use with tape drives or other
-block-oriented devices.
-.It Fn archive_write_open_FILE
-A convenience form of
-.Fn archive_write_open
-that accepts a
+to actually open the archive and prepare it for writing.
+There are several variants of this function;
+the most basic expects you to provide pointers to several
+functions that can provide blocks of bytes from the archive.
+There are convenience forms that allow you to
+specify a filename, file descriptor,
 .Ft "FILE *"
-pointer.
-Note that
-.Fn archive_write_open_FILE
-is not safe for writing to tape drives or other devices
-that require correct blocking.
-.It Fn archive_write_open_file
-A deprecated synonym for
-.Fn archive_write_open_filename .
-.It Fn archive_write_open_filename
-A convenience form of
-.Fn archive_write_open
-that accepts a filename.
-A NULL argument indicates that the output should be written to standard output;
-an argument of
-.Dq -
-will open a file with that name.
-If you have not invoked
-.Fn archive_write_set_bytes_in_last_block ,
-then
-.Fn archive_write_open_filename
-will adjust the last-block padding depending on the file:
-it will enable padding when writing to standard output or
-to a character or block device node, it will disable padding otherwise.
-You can override this by manually invoking
-.Fn archive_write_set_bytes_in_last_block
-before calling
-.Fn archive_write_open .
-The
-.Fn archive_write_open_filename
-function is safe for use with tape drives or other
-block-oriented devices.
-.It Fn archive_write_open_memory
-A convenience form of
-.Fn archive_write_open
-that accepts a pointer to a block of memory that will receive
-the archive.
-The final
-.Ft "size_t *"
-argument points to a variable that will be updated
-after each write to reflect how much of the buffer
-is currently in use.
-You should be careful to ensure that this variable
-remains allocated until after the archive is
-closed.
-.It Fn archive_write_header
-Build and write a header using the data in the provided
+object, or a block of memory from which to write the archive data.
+.\"
+.Ss Produce archive
+See
+.Xr archive_write_header 3
+and
+.Xr archive_write_data 3 .
+.Pp
+Individual archive entries are written in a three-step
+process:
+You first initialize a
 .Tn struct archive_entry
-structure.
+structure with information about the new entry.
+At a minimum, you should set the pathname of the
+entry and provide a
+.Va struct stat
+with a valid
+.Va st_mode
+field, which specifies the type of object and
+.Va st_size
+field, which specifies the size of the data portion of the object.
+.\"
+.Ss Release resources
 See
-.Xr archive_entry 3
-for information on creating and populating
-.Tn struct archive_entry
-objects.
-.It Fn archive_write_data
-Write data corresponding to the header just written.
-Returns number of bytes written or -1 on error.
-.It Fn archive_write_finish_entry
-Close out the entry just written.
-In particular, this writes out the final padding required by some formats.
-Ordinarily, clients never need to call this, as it
-is called automatically by
-.Fn archive_write_next_header
-and
-.Fn archive_write_close
-as needed.
-.It Fn archive_write_close
-Complete the archive and invoke the close callback.
-.It Fn archive_write_free
-Invokes
-.Fn archive_write_close
-if necessary, then releases all resources.
-If you need detailed information about
-.Fn archive_write_close
-failures, you should be careful to call it separately, as
-you cannot obtain error information after
+.Xr archive_write_free 3 .
+.Pp
+After all entries have been written, use the
 .Fn archive_write_free
-returns.
-.El
-More information about the
-.Va struct archive
-object and the overall design of the library can be found in the
-.Xr libarchive 3
-overview.
-.Sh IMPLEMENTATION
-Compression support is built-in to libarchive, which uses zlib and bzlib
-to handle gzip and bzip2 compression, respectively.
-.Sh CLIENT CALLBACKS
-To use this library, you will need to define and register
-callback functions that will be invoked to write data to the
-resulting archive.
-These functions are registered by calling
-.Fn archive_write_open :
-.Bl -item -offset indent
-.It
-.Ft typedef int
-.Fn archive_open_callback "struct archive *" "void *client_data"
-.El
-.Pp
-The open callback is invoked by
-.Fn archive_write_open .
-It should return
-.Cm ARCHIVE_OK
-if the underlying file or data source is successfully
-opened.
-If the open fails, it should call
-.Fn archive_set_error
-to register an error code and message and return
-.Cm ARCHIVE_FATAL .
-.Bl -item -offset indent
-.It
-.Ft typedef ssize_t
-.Fo archive_write_callback
-.Fa "struct archive *"
-.Fa "void *client_data"
-.Fa "const void *buffer"
-.Fa "size_t length"
-.Fc
-.El
-.Pp
-The write callback is invoked whenever the library
-needs to write raw bytes to the archive.
-For correct blocking, each call to the write callback function
-should translate into a single
-.Xr write 2
-system call.
-This is especially critical when writing archives to tape drives.
-On success, the write callback should return the
-number of bytes actually written.
-On error, the callback should invoke
-.Fn archive_set_error
-to register an error code and message and return -1.
-.Bl -item -offset indent
-.It
-.Ft typedef int
-.Fn archive_close_callback "struct archive *" "void *client_data"
-.El
-.Pp
-The close callback is invoked by archive_close when
-the archive processing is complete.
-The callback should return
-.Cm ARCHIVE_OK
-on success.
-On failure, the callback should invoke
-.Fn archive_set_error
-to register an error code and message and
-return
-.Cm ARCHIVE_FATAL.
+function to release all resources.
+.\"
 .Sh EXAMPLE
 The following sketch illustrates basic usage of the library.
 In this example,
@@ -464,8 +137,8 @@
 #include <unistd.h>
 
 struct mydata {
-	const char *name;
-	int fd;
+  const char *name;
+  int fd;
 };
 
 int
@@ -511,7 +184,7 @@
 
   a = archive_write_new();
   mydata->name = outname;
-  archive_write_set_compression_gzip(a);
+  archive_write_add_filter_gzip(a);
   archive_write_set_format_ustar(a);
   archive_write_open(a, mydata, myopen, mywrite, myclose);
   while (*filename) {
@@ -520,11 +193,13 @@
     archive_entry_copy_stat(entry, &st);
     archive_entry_set_pathname(entry, *filename);
     archive_write_header(a, entry);
-    fd = open(*filename, O_RDONLY);
-    len = read(fd, buff, sizeof(buff));
-    while ( len > 0 ) {
-	archive_write_data(a, buff, len);
-	len = read(fd, buff, sizeof(buff));
+    if ((fd = open(*filename, O_RDONLY)) != -1) {
+      len = read(fd, buff, sizeof(buff));
+      while ( len > 0 ) {
+        archive_write_data(a, buff, len);
+        len = read(fd, buff, sizeof(buff));
+      }
+      close(fd);
     }
     archive_entry_free(entry);
     filename++;
@@ -534,62 +209,19 @@
 
 int main(int argc, const char **argv)
 {
-	const char *outname;
-	argv++;
-	outname = argv++;
-	write_archive(outname, argv);
-	return 0;
+  const char *outname;
+  argv++;
+  outname = argv++;
+  write_archive(outname, argv);
+  return 0;
 }
 .Ed
-.Sh RETURN VALUES
-Most functions return
-.Cm ARCHIVE_OK
-(zero) on success, or one of several non-zero
-error codes for errors.
-Specific error codes include:
-.Cm ARCHIVE_RETRY
-for operations that might succeed if retried,
-.Cm ARCHIVE_WARN
-for unusual conditions that do not prevent further operations, and
-.Cm ARCHIVE_FATAL
-for serious errors that make remaining operations impossible.
-The
-.Fn archive_errno
-and
-.Fn archive_error_string
-functions can be used to retrieve an appropriate error code and a
-textual error message.
-.Pp
-.Fn archive_write_new
-returns a pointer to a newly-allocated
-.Tn struct archive
-object.
-.Pp
-.Fn archive_write_data
-returns a count of the number of bytes actually written.
-On error, -1 is returned and the
-.Fn archive_errno
-and
-.Fn archive_error_string
-functions will return appropriate values.
-Note that if the client-provided write callback function
-returns a non-zero value, that error will be propagated back to the caller
-through whatever API function resulted in that call, which
-may include
-.Fn archive_write_header ,
-.Fn archive_write_data ,
-.Fn archive_write_close ,
-or
-.Fn archive_write_free .
-The client callback can call
-.Fn archive_set_error
-to provide values that can then be retrieved by
-.Fn archive_errno
-and
-.Fn archive_error_string .
 .Sh SEE ALSO
 .Xr tar 1 ,
 .Xr libarchive 3 ,
+.Xr archive_write_set_options 3 ,
+.Xr cpio 5 ,
+.Xr mtree 5 ,
 .Xr tar 5
 .Sh HISTORY
 The
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_write.c
--- a/head/contrib/libarchive/libarchive/archive_write.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_write.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2003-2010 Tim Kientzle
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -24,12 +24,12 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write.c 228773 2011-12-21 15:18:52Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * This file contains the "essential" portions of the write API, that
  * is, stuff that will essentially always be used by any client that
- * actually needs to write a archive.  Optional pieces have been, as
+ * actually needs to write an archive.  Optional pieces have been, as
  * far as possible, separated out into separate files to reduce
  * needlessly bloating statically-linked clients.
  */
@@ -37,6 +37,9 @@
 #ifdef HAVE_SYS_WAIT_H
 #include <sys/wait.h>
 #endif
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
 #ifdef HAVE_LIMITS_H
 #include <limits.h>
 #endif
@@ -59,12 +62,23 @@
 
 static struct archive_vtable *archive_write_vtable(void);
 
+static int	_archive_filter_code(struct archive *, int);
+static const char *_archive_filter_name(struct archive *, int);
+static int64_t	_archive_filter_bytes(struct archive *, int);
+static int  _archive_write_filter_count(struct archive *);
 static int	_archive_write_close(struct archive *);
 static int	_archive_write_free(struct archive *);
 static int	_archive_write_header(struct archive *, struct archive_entry *);
 static int	_archive_write_finish_entry(struct archive *);
 static ssize_t	_archive_write_data(struct archive *, const void *, size_t);
 
+struct archive_none {
+	size_t buffer_size;
+	size_t avail;
+	char *buffer;
+	char *next;
+};
+
 static struct archive_vtable *
 archive_write_vtable(void)
 {
@@ -73,10 +87,15 @@
 
 	if (!inited) {
 		av.archive_close = _archive_write_close;
+		av.archive_filter_bytes = _archive_filter_bytes;
+		av.archive_filter_code = _archive_filter_code;
+		av.archive_filter_name = _archive_filter_name;
+		av.archive_filter_count = _archive_write_filter_count;
 		av.archive_free = _archive_write_free;
 		av.archive_write_header = _archive_write_header;
 		av.archive_write_finish_entry = _archive_write_finish_entry;
 		av.archive_write_data = _archive_write_data;
+		inited = 1;
 	}
 	return (&av);
 }
@@ -114,133 +133,17 @@
 	}
 	memset(nulls, 0, a->null_length);
 	a->nulls = nulls;
-	/*
-	 * Set default compression, but don't set a default format.
-	 * Were we to set a default format here, we would force every
-	 * client to link in support for that format, even if they didn't
-	 * ever use it.
-	 */
-	archive_write_set_compression_none(&a->archive);
 	return (&a->archive);
 }
 
 /*
- * Set write options for the format. Returns 0 if successful.
- */
-int
-archive_write_set_format_options(struct archive *_a, const char *s)
-{
-	struct archive_write *a = (struct archive_write *)_a;
-	char key[64], val[64];
-	int len, r, ret = ARCHIVE_OK;
-
-	__archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
-	    ARCHIVE_STATE_NEW, "archive_write_set_format_options");
-	archive_clear_error(&a->archive);
-
-	if (s == NULL || *s == '\0')
-		return (ARCHIVE_OK);
-	if (a->format_options == NULL)
-		/* This format does not support option. */
-		return (ARCHIVE_OK);
-
-	while ((len = __archive_parse_options(s, a->format_name,
-	    sizeof(key), key, sizeof(val), val)) > 0) {
-		if (val[0] == '\0')
-			r = a->format_options(a, key, NULL);
-		else
-			r = a->format_options(a, key, val);
-		if (r == ARCHIVE_FATAL)
-			return (r);
-		if (r < ARCHIVE_OK) { /* This key was not handled. */
-			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
-			    "Unsupported option ``%s''", key);
-			ret = ARCHIVE_WARN;
-		}
-		s += len;
-	}
-	if (len < 0) {
-		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
-		    "Malformed options string.");
-		return (ARCHIVE_WARN);
-	}
-	return (ret);
-}
-
-/*
- * Set write options for the compressor. Returns 0 if successful.
- */
-int
-archive_write_set_compressor_options(struct archive *_a, const char *s)
-{
-	struct archive_write *a = (struct archive_write *)_a;
-	char key[64], val[64];
-	int len, r;
-	int ret = ARCHIVE_OK;
-
-	__archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
-	    ARCHIVE_STATE_NEW, "archive_write_set_compressor_options");
-	archive_clear_error(&a->archive);
-
-	if (s == NULL || *s == '\0')
-		return (ARCHIVE_OK);
-	if (a->compressor.options == NULL) {
-		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
-		    "Unsupported option ``%s''", s);
-		/* This compressor does not support option. */
-		return (ARCHIVE_WARN);
-	}
-
-	while ((len = __archive_parse_options(s, a->archive.compression_name,
-	    sizeof(key), key, sizeof(val), val)) > 0) {
-		if (val[0] == '\0')
-			r = a->compressor.options(a, key, NULL);
-		else
-			r = a->compressor.options(a, key, val);
-		if (r == ARCHIVE_FATAL)
-			return (r);
-		if (r < ARCHIVE_OK) {
-			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
-			    "Unsupported option ``%s''", key);
-			ret = ARCHIVE_WARN;
-		}
-		s += len;
-	}
-	if (len < 0) {
-		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
-		    "Illegal format options.");
-		return (ARCHIVE_WARN);
-	}
-	return (ret);
-}
-
-/*
- * Set write options for the format and the compressor. Returns 0 if successful.
- */
-int
-archive_write_set_options(struct archive *_a, const char *s)
-{
-	int r1, r2;
-
-	r1 = archive_write_set_format_options(_a, s);
-	if (r1 < ARCHIVE_WARN)
-		return (r1);
-	r2 = archive_write_set_compressor_options(_a, s);
-	if (r2 < ARCHIVE_WARN)
-		return (r2);
-	if (r1 == ARCHIVE_WARN && r2 == ARCHIVE_WARN)
-		return (ARCHIVE_WARN);
-	return (ARCHIVE_OK);
-}
-
-/*
  * Set the block size.  Returns 0 if successful.
  */
 int
 archive_write_set_bytes_per_block(struct archive *_a, int bytes_per_block)
 {
 	struct archive_write *a = (struct archive_write *)_a;
-	__archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
+	archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
 	    ARCHIVE_STATE_NEW, "archive_write_set_bytes_per_block");
 	a->bytes_per_block = bytes_per_block;
 	return (ARCHIVE_OK);
@@ -253,7 +156,7 @@
 archive_write_get_bytes_per_block(struct archive *_a)
 {
 	struct archive_write *a = (struct archive_write *)_a;
-	__archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
+	archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
 	    ARCHIVE_STATE_ANY, "archive_write_get_bytes_per_block");
 	return (a->bytes_per_block);
 }
@@ -266,7 +169,7 @@
 archive_write_set_bytes_in_last_block(struct archive *_a, int bytes)
 {
 	struct archive_write *a = (struct archive_write *)_a;
-	__archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
+	archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
 	    ARCHIVE_STATE_ANY, "archive_write_set_bytes_in_last_block");
 	a->bytes_in_last_block = bytes;
 	return (ARCHIVE_OK);
@@ -279,27 +182,264 @@
 archive_write_get_bytes_in_last_block(struct archive *_a)
 {
 	struct archive_write *a = (struct archive_write *)_a;
-	__archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
+	archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
 	    ARCHIVE_STATE_ANY, "archive_write_get_bytes_in_last_block");
 	return (a->bytes_in_last_block);
 }
 
-
 /*
  * dev/ino of a file to be rejected.  Used to prevent adding
  * an archive to itself recursively.
  */
 int
-archive_write_set_skip_file(struct archive *_a, dev_t d, ino_t i)
+archive_write_set_skip_file(struct archive *_a, int64_t d, int64_t i)
 {
 	struct archive_write *a = (struct archive_write *)_a;
-	__archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
+	archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
 	    ARCHIVE_STATE_ANY, "archive_write_set_skip_file");
+	a->skip_file_set = 1;
 	a->skip_file_dev = d;
 	a->skip_file_ino = i;
 	return (ARCHIVE_OK);
 }
 
+/*
+ * Allocate and return the next filter structure.
+ */
+struct archive_write_filter *
+__archive_write_allocate_filter(struct archive *_a)
+{
+	struct archive_write *a = (struct archive_write *)_a;
+	struct archive_write_filter *f;
+
+	f = calloc(1, sizeof(*f));
+	f->archive = _a;
+	if (a->filter_first == NULL)
+		a->filter_first = f;
+	else
+		a->filter_last->next_filter = f;
+	a->filter_last = f;
+	return f;
+}
+
+/*
+ * Write data to a particular filter.
+ */
+int
+__archive_write_filter(struct archive_write_filter *f,
+    const void *buff, size_t length)
+{
+	int r;
+	if (length == 0)
+		return(ARCHIVE_OK);
+	r = (f->write)(f, buff, length);
+	f->bytes_written += length;
+	return (r);
+}
+
+/*
+ * Open a filter.
+ */
+int
+__archive_write_open_filter(struct archive_write_filter *f)
+{
+	if (f->open == NULL)
+		return (ARCHIVE_OK);
+	return (f->open)(f);
+}
+
+/*
+ * Close a filter.
+ */
+int
+__archive_write_close_filter(struct archive_write_filter *f)
+{
+	if (f->close != NULL)
+		return (f->close)(f);
+	if (f->next_filter != NULL)
+		return (__archive_write_close_filter(f->next_filter));
+	return (ARCHIVE_OK);
+}
+
+int
+__archive_write_output(struct archive_write *a, const void *buff, size_t length)
+{
+	return (__archive_write_filter(a->filter_first, buff, length));
+}
+
+int
+__archive_write_nulls(struct archive_write *a, size_t length)
+{
+	if (length == 0)
+		return (ARCHIVE_OK);
+
+	while (length > 0) {
+		size_t to_write = length < a->null_length ? length : a->null_length;
+		int r = __archive_write_output(a, a->nulls, to_write);
+		if (r < ARCHIVE_OK)
+			return (r);
+		length -= to_write;
+	}
+	return (ARCHIVE_OK);
+}
+
+static int
+archive_write_client_open(struct archive_write_filter *f)
+{
+	struct archive_write *a = (struct archive_write *)f->archive;
+	struct archive_none *state;
+	void *buffer;
+	size_t buffer_size;
+
+	f->bytes_per_block = archive_write_get_bytes_per_block(f->archive);
+	f->bytes_in_last_block =
+	    archive_write_get_bytes_in_last_block(f->archive);
+	buffer_size = f->bytes_per_block;
+
+	state = (struct archive_none *)calloc(1, sizeof(*state));
+	buffer = (char *)malloc(buffer_size);
+	if (state == NULL || buffer == NULL) {
+		free(state);
+		free(buffer);
+		archive_set_error(f->archive, ENOMEM,
+		    "Can't allocate data for output buffering");
+		return (ARCHIVE_FATAL);
+	}
+
+	state->buffer_size = buffer_size;
+	state->buffer = buffer;
+	state->next = state->buffer;
+	state->avail = state->buffer_size;
+	f->data = state;
+
+	if (a->client_opener == NULL)
+		return (ARCHIVE_OK);
+	return (a->client_opener(f->archive, a->client_data));
+}
+
+static int
+archive_write_client_write(struct archive_write_filter *f,
+    const void *_buff, size_t length)
+{
+	struct archive_write *a = (struct archive_write *)f->archive;
+        struct archive_none *state = (struct archive_none *)f->data;
+	const char *buff = (const char *)_buff;
+	ssize_t remaining, to_copy;
+	ssize_t bytes_written;
+
+	remaining = length;
+
+	/*
+	 * If there is no buffer for blocking, just pass the data
+	 * straight through to the client write callback.  In
+	 * particular, this supports "no write delay" operation for
+	 * special applications.  Just set the block size to zero.
+	 */
+	if (state->buffer_size == 0) {
+		while (remaining > 0) {
+			bytes_written = (a->client_writer)(&a->archive,
+			    a->client_data, buff, remaining);
+			if (bytes_written <= 0)
+				return (ARCHIVE_FATAL);
+			remaining -= bytes_written;
+			buff += bytes_written;
+		}
+		return (ARCHIVE_OK);
+	}
+
+	/* If the copy buffer isn't empty, try to fill it. */
+	if (state->avail < state->buffer_size) {
+		/* If buffer is not empty... */
+		/* ... copy data into buffer ... */
+		to_copy = ((size_t)remaining > state->avail) ?
+			state->avail : (size_t)remaining;
+		memcpy(state->next, buff, to_copy);
+		state->next += to_copy;
+		state->avail -= to_copy;
+		buff += to_copy;
+		remaining -= to_copy;
+		/* ... if it's full, write it out. */
+		if (state->avail == 0) {
+			char *p = state->buffer;
+			size_t to_write = state->buffer_size;
+			while (to_write > 0) {
+				bytes_written = (a->client_writer)(&a->archive,
+				    a->client_data, p, to_write);
+				if (bytes_written <= 0)
+					return (ARCHIVE_FATAL);
+				if ((size_t)bytes_written > to_write) {
+					archive_set_error(&(a->archive),
+					    -1, "write overrun");
+					return (ARCHIVE_FATAL);
+				}
+				p += bytes_written;
+				to_write -= bytes_written;
+			}
+			state->next = state->buffer;
+			state->avail = state->buffer_size;
+		}
+	}
+
+	while ((size_t)remaining > state->buffer_size) {
+		/* Write out full blocks directly to client. */
+		bytes_written = (a->client_writer)(&a->archive,
+		    a->client_data, buff, state->buffer_size);
+		if (bytes_written <= 0)
+			return (ARCHIVE_FATAL);
+		buff += bytes_written;
+		remaining -= bytes_written;
+	}
+
+	if (remaining > 0) {
+		/* Copy last bit into copy buffer. */
+		memcpy(state->next, buff, remaining);
+		state->next += remaining;
+		state->avail -= remaining;
+	}
+	return (ARCHIVE_OK);
+}
+
+static int
+archive_write_client_close(struct archive_write_filter *f)
+{
+	struct archive_write *a = (struct archive_write *)f->archive;
+	struct archive_none *state = (struct archive_none *)f->data;
+	ssize_t block_length;
+	ssize_t target_block_length;
+	ssize_t bytes_written;
+	int ret = ARCHIVE_OK;
+
+	/* If there's pending data, pad and write the last block */
+	if (state->next != state->buffer) {
+		block_length = state->buffer_size - state->avail;
+
+		/* Tricky calculation to determine size of last block */
+		if (a->bytes_in_last_block <= 0)
+			/* Default or Zero: pad to full block */
+			target_block_length = a->bytes_per_block;
+		else
+			/* Round to next multiple of bytes_in_last_block. */
+			target_block_length = a->bytes_in_last_block *
+			    ( (block_length + a->bytes_in_last_block - 1) /
+			        a->bytes_in_last_block);
+		if (target_block_length > a->bytes_per_block)
+			target_block_length = a->bytes_per_block;
+		if (block_length < target_block_length) {
+			memset(state->next, 0,
+			    target_block_length - block_length);
+			block_length = target_block_length;
+		}
+		bytes_written = (a->client_writer)(&a->archive,
+		    a->client_data, state->buffer, block_length);
+		ret = bytes_written <= 0 ? ARCHIVE_FATAL : ARCHIVE_OK;
+	}
+	if (a->client_closer)
+		(*a->client_closer)(&a->archive, a->client_data);
+	free(state->buffer);
+	free(state);
+	a->client_data = NULL;
+	return (ret);
+}
 
 /*
  * Open the archive using the current settings.
@@ -310,29 +450,37 @@
     archive_close_callback *closer)
 {
 	struct archive_write *a = (struct archive_write *)_a;
-	int ret;
+	struct archive_write_filter *client_filter;
+	int ret, r1;
 
-	__archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
+	archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
 	    ARCHIVE_STATE_NEW, "archive_write_open");
 	archive_clear_error(&a->archive);
-	a->archive.state = ARCHIVE_STATE_HEADER;
-	a->client_data = client_data;
+
 	a->client_writer = writer;
 	a->client_opener = opener;
 	a->client_closer = closer;
-	ret = (a->compressor.init)(a);
-	if (a->format_init && ret == ARCHIVE_OK)
+	a->client_data = client_data;
+
+	client_filter = __archive_write_allocate_filter(_a);
+	client_filter->open = archive_write_client_open;
+	client_filter->write = archive_write_client_write;
+	client_filter->close = archive_write_client_close;
+
+	ret = __archive_write_open_filter(a->filter_first);
+	if (ret < ARCHIVE_WARN) {
+		r1 = __archive_write_close_filter(a->filter_first);
+		return (r1 < ret ? r1 : ret);
+	}
+
+	a->archive.state = ARCHIVE_STATE_HEADER;
+	if (a->format_init)
 		ret = (a->format_init)(a);
 	return (ret);
 }
 
-
 /*
  * Close out the archive.
- *
- * Be careful: user might just call write_new and then write_finish.
- * Don't assume we actually wrote anything or performed any non-trivial
- * initialization.
  */
 static int
 _archive_write_close(struct archive *_a)
@@ -340,63 +488,105 @@
 	struct archive_write *a = (struct archive_write *)_a;
 	int r = ARCHIVE_OK, r1 = ARCHIVE_OK;
 
-	__archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
-	    ARCHIVE_STATE_ANY, "archive_write_close");
+	archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
+	    ARCHIVE_STATE_ANY | ARCHIVE_STATE_FATAL,
+	    "archive_write_close");
+	if (a->archive.state == ARCHIVE_STATE_NEW
+	    || a->archive.state == ARCHIVE_STATE_CLOSED)
+		return (ARCHIVE_OK); /* Okay to close() when not open. */
+
+	archive_clear_error(&a->archive);
 
 	/* Finish the last entry. */
-	if (a->archive.state & ARCHIVE_STATE_DATA)
+	if (a->archive.state == ARCHIVE_STATE_DATA)
 		r = ((a->format_finish_entry)(a));
 
 	/* Finish off the archive. */
-	if (a->format_finish != NULL) {
-		r1 = (a->format_finish)(a);
-		if (r1 < r)
-			r = r1;
-	}
-
-	/* Release format resources. */
-	if (a->format_destroy != NULL) {
-		r1 = (a->format_destroy)(a);
+	/* TODO: have format closers invoke compression close. */
+	if (a->format_close != NULL) {
+		r1 = (a->format_close)(a);
 		if (r1 < r)
 			r = r1;
 	}
 
 	/* Finish the compression and close the stream. */
-	if (a->compressor.finish != NULL) {
-		r1 = (a->compressor.finish)(a);
-		if (r1 < r)
-			r = r1;
+	r1 = __archive_write_close_filter(a->filter_first);
+	if (r1 < r)
+		r = r1;
+
+	if (a->archive.state != ARCHIVE_STATE_FATAL)
+		a->archive.state = ARCHIVE_STATE_CLOSED;
+	return (r);
+}
+
+static int
+_archive_write_filter_count(struct archive *_a)
+{
+	struct archive_write *a = (struct archive_write *)_a;
+	struct archive_write_filter *p = a->filter_first;
+	int count = 0;
+	while(p) {
+		count++;
+		p = p->next_filter;
 	}
+	return count;
+}
 
-	/* Close out the client stream. */
-	if (a->client_closer != NULL) {
-		r1 = (a->client_closer)(&a->archive, a->client_data);
-		if (r1 < r)
-			r = r1;
+void
+__archive_write_filters_free(struct archive *_a)
+{
+	struct archive_write *a = (struct archive_write *)_a;
+	int r = ARCHIVE_OK, r1;
+
+	while (a->filter_first != NULL) {
+		struct archive_write_filter *next
+		    = a->filter_first->next_filter;
+		if (a->filter_first->free != NULL) {
+			r1 = (*a->filter_first->free)(a->filter_first);
+			if (r > r1)
+				r = r1;
+		}
+		free(a->filter_first);
+		a->filter_first = next;
 	}
-
-	a->archive.state = ARCHIVE_STATE_CLOSED;
-	return (r);
+	a->filter_last = NULL;
 }
 
 /*
  * Destroy the archive structure.
+ *
+ * Be careful: user might just call write_new and then write_free.
+ * Don't assume we actually wrote anything or performed any non-trivial
+ * initialization.
  */
 static int
 _archive_write_free(struct archive *_a)
 {
 	struct archive_write *a = (struct archive_write *)_a;
-	int r = ARCHIVE_OK;
+	int r = ARCHIVE_OK, r1;
 
-	__archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
-	    ARCHIVE_STATE_ANY, "archive_write_free");
-	if (a->archive.state != ARCHIVE_STATE_CLOSED)
+	if (_a == NULL)
+		return (ARCHIVE_OK);
+	/* It is okay to call free() in state FATAL. */
+	archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
+	    ARCHIVE_STATE_ANY | ARCHIVE_STATE_FATAL, "archive_write_free");
+	if (a->archive.state != ARCHIVE_STATE_FATAL)
 		r = archive_write_close(&a->archive);
 
+	/* Release format resources. */
+	if (a->format_free != NULL) {
+		r1 = (a->format_free)(a);
+		if (r1 < r)
+			r = r1;
+	}
+
+	__archive_write_filters_free(_a);
+
 	/* Release various dynamic buffers. */
 	free((void *)(uintptr_t)(const void *)a->nulls);
 	archive_string_free(&a->archive.error_string);
 	a->archive.magic = 0;
+	__archive_clean(&a->archive);
 	free(a);
 	return (r);
 }
@@ -410,18 +600,30 @@
 	struct archive_write *a = (struct archive_write *)_a;
 	int ret, r2;
 
-	__archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
+	archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
 	    ARCHIVE_STATE_DATA | ARCHIVE_STATE_HEADER, "archive_write_header");
 	archive_clear_error(&a->archive);
 
+	if (a->format_write_header == NULL) {
+		archive_set_error(&(a->archive), -1,
+		    "Format must be set before you can write to an archive.");
+		a->archive.state = ARCHIVE_STATE_FATAL;
+		return (ARCHIVE_FATAL);
+	}
+
 	/* In particular, "retry" and "fatal" get returned immediately. */
 	ret = archive_write_finish_entry(&a->archive);
+	if (ret == ARCHIVE_FATAL) {
+		a->archive.state = ARCHIVE_STATE_FATAL;
+		return (ARCHIVE_FATAL);
+	}
 	if (ret < ARCHIVE_OK && ret != ARCHIVE_WARN)
 		return (ret);
 
-	if (a->skip_file_dev != 0 &&
+	if (a->skip_file_set &&
+	    archive_entry_dev_is_set(entry) &&
+	    archive_entry_ino_is_set(entry) &&
 	    archive_entry_dev(entry) == a->skip_file_dev &&
-	    a->skip_file_ino != 0 &&
 	    archive_entry_ino64(entry) == a->skip_file_ino) {
 		archive_set_error(&a->archive, 0,
 		    "Can't add archive to itself");
@@ -430,6 +632,10 @@
 
 	/* Format and write header. */
 	r2 = ((a->format_write_header)(a, entry));
+	if (r2 == ARCHIVE_FATAL) {
+		a->archive.state = ARCHIVE_STATE_FATAL;
+		return (ARCHIVE_FATAL);
+	}
 	if (r2 < ret)
 		ret = r2;
 
@@ -443,7 +649,7 @@
 	struct archive_write *a = (struct archive_write *)_a;
 	int ret = ARCHIVE_OK;
 
-	__archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
+	archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
 	    ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA,
 	    "archive_write_finish_entry");
 	if (a->archive.state & ARCHIVE_STATE_DATA)
@@ -459,8 +665,45 @@
 _archive_write_data(struct archive *_a, const void *buff, size_t s)
 {
 	struct archive_write *a = (struct archive_write *)_a;
-	__archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
+	archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
 	    ARCHIVE_STATE_DATA, "archive_write_data");
 	archive_clear_error(&a->archive);
 	return ((a->format_write_data)(a, buff, s));
 }
+
+static struct archive_write_filter *
+filter_lookup(struct archive *_a, int n)
+{
+	struct archive_write *a = (struct archive_write *)_a;
+	struct archive_write_filter *f = a->filter_first;
+	if (n == -1)
+		return a->filter_last;
+	if (n < 0)
+		return NULL;
+	while (n > 0 && f != NULL) {
+		f = f->next_filter;
+		--n;
+	}
+	return f;
+}
+
+static int
+_archive_filter_code(struct archive *_a, int n)
+{
+	struct archive_write_filter *f = filter_lookup(_a, n);
+	return f == NULL ? -1 : f->code;
+}
+
+static const char *
+_archive_filter_name(struct archive *_a, int n)
+{
+	struct archive_write_filter *f = filter_lookup(_a, n);
+	return f == NULL ? NULL : f->name;
+}
+
+static int64_t
+_archive_filter_bytes(struct archive *_a, int n)
+{
+	struct archive_write_filter *f = filter_lookup(_a, n);
+	return f == NULL ? -1 : f->bytes_written;
+}
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_write_disk.3
--- a/head/contrib/libarchive/libarchive/archive_write_disk.3	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_write_disk.3	Fri Mar 02 16:54:40 2012 +0200
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $FreeBSD: head/contrib/libarchive/libarchive/archive_write_disk.3 228773 2011-12-21 15:18:52Z mm $
+.\" $FreeBSD: head/contrib/libarchive/libarchive/archive_write_disk.3 232153 2012-02-25 10:58:02Z mm $
 .\"
 .Dd August 5, 2008
 .Dt ARCHIVE_WRITE_DISK 3
@@ -36,8 +36,10 @@
 .Nm archive_write_disk_set_user_lookup ,
 .Nm archive_write_header ,
 .Nm archive_write_data ,
+.Nm archive_write_data_block ,
 .Nm archive_write_finish_entry ,
 .Nm archive_write_close ,
+.Nm archive_write_finish
 .Nm archive_write_free
 .Nd functions for creating objects on disk
 .Sh SYNOPSIS
@@ -68,11 +70,15 @@
 .Fn archive_write_header "struct archive *" "struct archive_entry *"
 .Ft ssize_t
 .Fn archive_write_data "struct archive *" "const void *" "size_t"
+.Ft ssize_t
+.Fn archive_write_data_block "struct archive *" "const void *" "size_t size" "int64_t offset"
 .Ft int
 .Fn archive_write_finish_entry "struct archive *"
 .Ft int
 .Fn archive_write_close "struct archive *"
 .Ft int
+.Fn archive_write_finish "struct archive *"
+.Ft int
 .Fn archive_write_free "struct archive *"
 .Sh DESCRIPTION
 These functions provide a complete API for creating objects on
@@ -221,6 +227,20 @@
 .It Fn archive_write_data
 Write data corresponding to the header just written.
 Returns number of bytes written or -1 on error.
+.It Fn archive_write_data_block
+Write data corresponding to the header just written.
+This is like
+.Fn archive_write_data
+except that it performs a seek on the file being
+written to the specified offset before writing the data.
+This is useful when restoring sparse files from archive
+formats that support sparse files.
+Returns number of bytes written or -1 on error.
+(Note: This is currently not supported for
+.Tn archive_write
+handles, only for
+.Tn archive_write_disk
+handles.)
 .It Fn archive_write_finish_entry
 Close out the entry just written.
 Ordinarily, clients never need to call this, as it
@@ -229,6 +249,9 @@
 and
 .Fn archive_write_close
 as needed.
+However, some file attributes are written to disk only
+after the file is closed, so this can be necessary
+if you need to work with the file on disk right away.
 .It Fn archive_write_close
 Set any attributes that could not be set during the initial restore.
 For example, directory timestamps are not restored initially because
@@ -239,6 +262,9 @@
 .Nm
 library maintains a list of all such deferred attributes and
 sets them when this function is invoked.
+.It Fn archive_write_finish
+This is a deprecated synonym for
+.Fn archive_write_free .
 .It Fn archive_write_free
 Invokes
 .Fn archive_write_close
@@ -263,12 +289,6 @@
 for unusual conditions that do not prevent further operations, and
 .Cm ARCHIVE_FATAL
 for serious errors that make remaining operations impossible.
-The
-.Fn archive_errno
-and
-.Fn archive_error_string
-functions can be used to retrieve an appropriate error code and a
-textual error message.
 .Pp
 .Fn archive_write_disk_new
 returns a pointer to a newly-allocated
@@ -276,12 +296,18 @@
 object.
 .Pp
 .Fn archive_write_data
-returns a count of the number of bytes actually written.
-On error, -1 is returned and the
+returns a count of the number of bytes actually written,
+or
+.Li -1
+on error.
+.\"
+.Sh ERRORS
+Detailed error codes and textual descriptions are available from the
 .Fn archive_errno
 and
 .Fn archive_error_string
-functions will return appropriate values.
+functions.
+.\"
 .Sh SEE ALSO
 .Xr archive_read 3 ,
 .Xr archive_write 3 ,
@@ -372,4 +398,4 @@
 There should be a corresponding
 .Nm archive_read_disk
 interface that walks a directory hierarchy and returns archive
-entry objects.
\ No newline at end of file
+entry objects.
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_write_disk_set_standard_lookup.c
--- a/head/contrib/libarchive/libarchive/archive_write_disk_set_standard_lookup.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_write_disk_set_standard_lookup.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write_disk_set_standard_lookup.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write_disk_set_standard_lookup.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
@@ -58,8 +58,8 @@
 
 static const size_t cache_size = 127;
 static unsigned int	hash(const char *);
-static gid_t	lookup_gid(void *, const char *uname, gid_t);
-static uid_t	lookup_uid(void *, const char *uname, uid_t);
+static int64_t	lookup_gid(void *, const char *uname, int64_t);
+static int64_t	lookup_uid(void *, const char *uname, int64_t);
 static void	cleanup(void *);
 
 /*
@@ -93,8 +93,8 @@
 	return (ARCHIVE_OK);
 }
 
-static gid_t
-lookup_gid(void *private_data, const char *gname, gid_t gid)
+static int64_t
+lookup_gid(void *private_data, const char *gname, int64_t gid)
 {
 	int h;
 	struct bucket *b;
@@ -163,8 +163,8 @@
 	return (gid);
 }
 
-static uid_t
-lookup_uid(void *private_data, const char *uname, uid_t uid)
+static int64_t
+lookup_uid(void *private_data, const char *uname, int64_t uid)
 {
 	int h;
 	struct bucket *b;
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_write_open_filename.c
--- a/head/contrib/libarchive/libarchive/archive_write_open_filename.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_write_open_filename.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write_open_filename.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write_open_filename.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
@@ -46,6 +46,7 @@
 #endif
 
 #include "archive.h"
+#include "archive_string.h"
 
 #ifndef O_BINARY
 #define O_BINARY 0
@@ -53,7 +54,11 @@
 
 struct write_file_data {
 	int		fd;
-	char		filename[1];
+	char		mbs_filename;
+	union {
+		char		m[1];
+		wchar_t		w[1];
+	} filename; /* Must be last! */
 };
 
 static int	file_close(struct archive *, void *);
@@ -79,12 +84,60 @@
 		archive_set_error(a, ENOMEM, "No memory");
 		return (ARCHIVE_FATAL);
 	}
-	strcpy(mine->filename, filename);
+	strcpy(mine->filename.m, filename);
+	mine->mbs_filename = 1;
 	mine->fd = -1;
 	return (archive_write_open(a, mine,
 		file_open, file_write, file_close));
 }
 
+int
+archive_write_open_filename_w(struct archive *a, const wchar_t *filename)
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+	struct write_file_data *mine;
+
+	if (filename == NULL || filename[0] == L'\0')
+		return (archive_write_open_fd(a, 1));
+
+	mine = malloc(sizeof(*mine) + wcslen(filename) * sizeof(wchar_t));
+	if (mine == NULL) {
+		archive_set_error(a, ENOMEM, "No memory");
+		return (ARCHIVE_FATAL);
+	}
+	wcscpy(mine->filename.w, filename);
+	mine->mbs_filename = 0;
+	mine->fd = -1;
+	return (archive_write_open(a, mine,
+		file_open, file_write, file_close));
+#else
+	/*
+	 * POSIX system does not support a wchar_t interface for
+	 * open() system call, so we have to translate a wchar_t
+	 * filename to multi-byte one and use it.
+	 */
+	struct archive_string fn;
+	int r;
+
+	if (filename == NULL || filename[0] == L'\0')
+		return (archive_write_open_fd(a, 1));
+
+	archive_string_init(&fn);
+	if (archive_string_append_from_wcs(&fn, filename,
+	    wcslen(filename)) != 0) {
+		archive_set_error(a, EINVAL,
+		    "Failed to convert a wide-character filename to"
+		    " a multi-byte filename");
+		archive_string_free(&fn);
+		return (ARCHIVE_FATAL);
+	}
+	r = archive_write_open_filename(a, fn.s);
+	archive_string_free(&fn);
+	return (r);
+#endif
+}
+
+
 static int
 file_open(struct archive *a, void *client_data)
 {
@@ -98,17 +151,46 @@
 	/*
 	 * Open the file.
 	 */
-	mine->fd = open(mine->filename, flags, 0666);
-	if (mine->fd < 0) {
-		archive_set_error(a, errno, "Failed to open '%s'",
-		    mine->filename);
+	if (mine->mbs_filename) {
+		mine->fd = open(mine->filename.m, flags, 0666);
+		if (mine->fd < 0) {
+			archive_set_error(a, errno, "Failed to open '%s'",
+			    mine->filename.m);
+			return (ARCHIVE_FATAL);
+		}
+
+		if (fstat(mine->fd, &st) != 0) {
+			archive_set_error(a, errno, "Couldn't stat '%s'",
+			    mine->filename.m);
+			return (ARCHIVE_FATAL);
+		}
+	} else {
+#if defined(_WIN32) && !defined(__CYGWIN__)
+		mine->fd = _wopen(mine->filename.w, flags, 0666);
+		if (mine->fd < 0 && errno == ENOENT) {
+			wchar_t *fullpath;
+			fullpath = __la_win_permissive_name_w(mine->filename.w);
+			if (fullpath != NULL) {
+				mine->fd = _wopen(fullpath, flags, 0666);
+				free(fullpath);
+			}
+		}
+		if (mine->fd < 0) {
+			archive_set_error(a, errno, "Failed to open '%S'",
+			    mine->filename.w);
+			return (ARCHIVE_FATAL);
+		}
+
+		if (fstat(mine->fd, &st) != 0) {
+			archive_set_error(a, errno, "Couldn't stat '%S'",
+			    mine->filename.w);
+			return (ARCHIVE_FATAL);
+		}
+#else
+		archive_set_error(a, ARCHIVE_ERRNO_MISC,
+		    "Unexpedted operation in archive_write_open_filename");
 		return (ARCHIVE_FATAL);
-	}
-
-	if (fstat(mine->fd, &st) != 0) {
-               archive_set_error(a, errno, "Couldn't stat '%s'",
-                   mine->filename);
-               return (ARCHIVE_FATAL);
+#endif
 	}
 
 	/*
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_write_open_memory.c
--- a/head/contrib/libarchive/libarchive/archive_write_open_memory.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_write_open_memory.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write_open_memory.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write_open_memory.c 232153 2012-02-25 10:58:02Z mm $");
 
 #include <errno.h>
 #include <stdlib.h>
@@ -32,18 +32,6 @@
 
 #include "archive.h"
 
-/*
- * This is a little tricky.  I used to allow the
- * compression handling layer to fork the compressor,
- * which means this write function gets invoked in
- * a separate process.  That would, of course, make it impossible
- * to actually use the data stored into memory here.
- * Fortunately, none of the compressors fork today and
- * I'm reluctant to use that route in the future but, if
- * forking compressors ever do reappear, this will have
- * to get a lot more complicated.
- */
-
 struct write_memory_data {
 	size_t	used;
 	size_t  size;
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_write_private.h
--- a/head/contrib/libarchive/libarchive/archive_write_private.h	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_write_private.h	Fri Mar 02 16:54:40 2012 +0200
@@ -22,7 +22,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: head/contrib/libarchive/libarchive/archive_write_private.h 228763 2011-12-21 11:13:29Z mm $
+ * $FreeBSD: head/contrib/libarchive/libarchive/archive_write_private.h 232153 2012-02-25 10:58:02Z mm $
  */
 
 #ifndef __LIBARCHIVE_BUILD
@@ -36,10 +36,42 @@
 #include "archive_string.h"
 #include "archive_private.h"
 
+struct archive_write;
+
+struct archive_write_filter {
+	int64_t bytes_written;
+	struct archive *archive; /* Associated archive. */
+	struct archive_write_filter *next_filter; /* Who I write to. */
+	int	(*options)(struct archive_write_filter *,
+	    const char *key, const char *value);
+	int	(*open)(struct archive_write_filter *);
+	int	(*write)(struct archive_write_filter *, const void *, size_t);
+	int	(*close)(struct archive_write_filter *);
+	int	(*free)(struct archive_write_filter *);
+	void	 *data;
+	const char *name;
+	int	  code;
+	int	  bytes_per_block;
+	int	  bytes_in_last_block;
+};
+
+#if ARCHIVE_VERSION < 4000000
+void __archive_write_filters_free(struct archive *);
+#endif
+
+struct archive_write_filter *__archive_write_allocate_filter(struct archive *);
+
+int __archive_write_output(struct archive_write *, const void *, size_t);
+int __archive_write_nulls(struct archive_write *, size_t);
+int __archive_write_filter(struct archive_write_filter *, const void *, size_t);
+int __archive_write_open_filter(struct archive_write_filter *);
+int __archive_write_close_filter(struct archive_write_filter *);
+
 struct archive_write {
 	struct archive	archive;
 
 	/* Dev/ino of the archive being written. */
+	int		  skip_file_set;
 	dev_t		  skip_file_dev;
 	int64_t		  skip_file_ino;
 
@@ -63,29 +95,10 @@
 	int		  bytes_in_last_block;
 
 	/*
-	 * These control whether data within a gzip/bzip2 compressed
-	 * stream gets padded or not.  If pad_uncompressed is set,
-	 * the data will be padded to a full block before being
-	 * compressed.  The pad_uncompressed_byte determines the value
-	 * that will be used for padding.  Note that these have no
-	 * effect on compression "none."
+	 * First and last write filters in the pipeline.
 	 */
-	int		  pad_uncompressed;
-	int		  pad_uncompressed_byte; /* TODO: Support this. */
-
-	/*
-	 * On write, the client just invokes an archive_write_set function
-	 * which sets up the data here directly.
-	 */
-	struct {
-		void	 *data;
-		void	 *config;
-		int	(*init)(struct archive_write *);
-		int	(*options)(struct archive_write *,
-			    const char *key, const char *value);
-		int	(*finish)(struct archive_write *);
-		int	(*write)(struct archive_write *, const void *, size_t);
-	} compressor;
+	struct archive_write_filter *filter_first;
+	struct archive_write_filter *filter_last;
 
 	/*
 	 * Pointers to format-specific functions for writing.  They're
@@ -96,13 +109,13 @@
 	int	(*format_init)(struct archive_write *);
 	int	(*format_options)(struct archive_write *,
 		    const char *key, const char *value);
-	int	(*format_finish)(struct archive_write *);
-	int	(*format_destroy)(struct archive_write *);
 	int	(*format_finish_entry)(struct archive_write *);
 	int 	(*format_write_header)(struct archive_write *,
 		    struct archive_entry *);
 	ssize_t	(*format_write_data)(struct archive_write *,
 		    const void *buff, size_t);
+	int	(*format_close)(struct archive_write *);
+	int	(*format_free)(struct archive_write *);
 };
 
 /*
@@ -117,6 +130,7 @@
  */
 int
 __archive_write_format_header_ustar(struct archive_write *, char buff[512],
-    struct archive_entry *, int tartype, int strict);
+    struct archive_entry *, int tartype, int strict,
+    struct archive_string_conv *);
 
 #endif
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_write_set_format.c
--- a/head/contrib/libarchive/libarchive/archive_write_set_format.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_write_set_format.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write_set_format.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write_set_format.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
@@ -41,18 +41,22 @@
 static
 struct { int code; int (*setter)(struct archive *); } codes[] =
 {
+	{ ARCHIVE_FORMAT_7ZIP,		archive_write_set_format_7zip },
 	{ ARCHIVE_FORMAT_CPIO,		archive_write_set_format_cpio },
+	{ ARCHIVE_FORMAT_CPIO_POSIX,	archive_write_set_format_cpio },
 	{ ARCHIVE_FORMAT_CPIO_SVR4_NOCRC,	archive_write_set_format_cpio_newc },
-	{ ARCHIVE_FORMAT_CPIO_POSIX,	archive_write_set_format_cpio },
+	{ ARCHIVE_FORMAT_ISO9660,	archive_write_set_format_iso9660 },
 	{ ARCHIVE_FORMAT_MTREE,		archive_write_set_format_mtree },
 	{ ARCHIVE_FORMAT_SHAR,		archive_write_set_format_shar },
 	{ ARCHIVE_FORMAT_SHAR_BASE,	archive_write_set_format_shar },
 	{ ARCHIVE_FORMAT_SHAR_DUMP,	archive_write_set_format_shar_dump },
 	{ ARCHIVE_FORMAT_TAR,	archive_write_set_format_pax_restricted },
+	{ ARCHIVE_FORMAT_TAR_GNUTAR,	archive_write_set_format_gnutar },
 	{ ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE, archive_write_set_format_pax },
 	{ ARCHIVE_FORMAT_TAR_PAX_RESTRICTED,
 				archive_write_set_format_pax_restricted },
 	{ ARCHIVE_FORMAT_TAR_USTAR,	archive_write_set_format_ustar },
+	{ ARCHIVE_FORMAT_XAR,		archive_write_set_format_xar },
 	{ ARCHIVE_FORMAT_ZIP,	archive_write_set_format_zip },
 	{ 0,		NULL }
 };
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_write_set_format_ar.c
--- a/head/contrib/libarchive/libarchive/archive_write_set_format_ar.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_write_set_format_ar.c	Fri Mar 02 16:54:40 2012 +0200
@@ -26,7 +26,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write_set_format_ar.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write_set_format_ar.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
@@ -48,6 +48,7 @@
 	uint64_t	 entry_padding;
 	int		 is_strtab;
 	int		 has_strtab;
+	char		 wrote_global_header;
 	char		*strtab;
 };
 
@@ -74,8 +75,8 @@
 			     struct archive_entry *);
 static ssize_t		 archive_write_ar_data(struct archive_write *,
 			     const void *buff, size_t s);
-static int		 archive_write_ar_destroy(struct archive_write *);
-static int		 archive_write_ar_finish(struct archive_write *);
+static int		 archive_write_ar_free(struct archive_write *);
+static int		 archive_write_ar_close(struct archive_write *);
 static int		 archive_write_ar_finish_entry(struct archive_write *);
 static const char	*ar_basename(const char *path);
 static int		 format_octal(int64_t v, char *p, int s);
@@ -85,7 +86,11 @@
 archive_write_set_format_ar_bsd(struct archive *_a)
 {
 	struct archive_write *a = (struct archive_write *)_a;
-	int r = archive_write_set_format_ar(a);
+	int r;
+
+	archive_check_magic(_a, ARCHIVE_WRITE_MAGIC,
+	    ARCHIVE_STATE_NEW, "archive_write_set_format_ar_bsd");
+	r = archive_write_set_format_ar(a);
 	if (r == ARCHIVE_OK) {
 		a->archive.archive_format = ARCHIVE_FORMAT_AR_BSD;
 		a->archive.archive_format_name = "ar (BSD)";
@@ -97,7 +102,11 @@
 archive_write_set_format_ar_svr4(struct archive *_a)
 {
 	struct archive_write *a = (struct archive_write *)_a;
-	int r = archive_write_set_format_ar(a);
+	int r;
+
+	archive_check_magic(_a, ARCHIVE_WRITE_MAGIC,
+	    ARCHIVE_STATE_NEW, "archive_write_set_format_ar_svr4");
+	r = archive_write_set_format_ar(a);
 	if (r == ARCHIVE_OK) {
 		a->archive.archive_format = ARCHIVE_FORMAT_AR_GNU;
 		a->archive.archive_format_name = "ar (GNU/SVR4)";
@@ -114,8 +123,8 @@
 	struct ar_w *ar;
 
 	/* If someone else was already registered, unregister them. */
-	if (a->format_destroy != NULL)
-		(a->format_destroy)(a);
+	if (a->format_free != NULL)
+		(a->format_free)(a);
 
 	ar = (struct ar_w *)malloc(sizeof(*ar));
 	if (ar == NULL) {
@@ -128,8 +137,8 @@
 	a->format_name = "ar";
 	a->format_write_header = archive_write_ar_header;
 	a->format_write_data = archive_write_ar_data;
-	a->format_finish = archive_write_ar_finish;
-	a->format_destroy = archive_write_ar_destroy;
+	a->format_close = archive_write_ar_close;
+	a->format_free = archive_write_ar_free;
 	a->format_finish_entry = archive_write_ar_finish_entry;
 	return (ARCHIVE_OK);
 }
@@ -166,8 +175,10 @@
 	 * If we are now at the beginning of the archive,
 	 * we need first write the ar global header.
 	 */
-	if (a->archive.file_position == 0)
-		(a->compressor.write)(a, "!<arch>\n", 8);
+	if (!ar->wrote_global_header) {
+		__archive_write_output(a, "!<arch>\n", 8);
+		ar->wrote_global_header = 1;
+	}
 
 	memset(buff, ' ', 60);
 	strncpy(&buff[AR_fmag_offset], "`\n", 2);
@@ -190,7 +201,7 @@
 		ar->is_strtab = 1;
 		buff[AR_name_offset] = buff[AR_name_offset + 1] = '/';
 		/*
-		 * For archive string table, only ar_size filed should
+		 * For archive string table, only ar_size field should
 		 * be set.
 		 */
 		goto size;
@@ -330,7 +341,7 @@
 		return (ARCHIVE_WARN);
 	}
 
-	ret = (a->compressor.write)(a, buff, 60);
+	ret = __archive_write_output(a, buff, 60);
 	if (ret != ARCHIVE_OK)
 		return (ret);
 
@@ -338,7 +349,7 @@
 	ar->entry_padding = ar->entry_bytes_remaining % 2;
 
 	if (append_fn > 0) {
-		ret = (a->compressor.write)(a, filename, strlen(filename));
+		ret = __archive_write_output(a, filename, strlen(filename));
 		if (ret != ARCHIVE_OK)
 			return (ret);
 		ar->entry_bytes_remaining -= strlen(filename);
@@ -374,7 +385,7 @@
 		ar->has_strtab = 1;
 	}
 
-	ret = (a->compressor.write)(a, buff, s);
+	ret = __archive_write_output(a, buff, s);
 	if (ret != ARCHIVE_OK)
 		return (ret);
 
@@ -383,7 +394,7 @@
 }
 
 static int
-archive_write_ar_destroy(struct archive_write *a)
+archive_write_ar_free(struct archive_write *a)
 {
 	struct ar_w *ar;
 
@@ -403,16 +414,19 @@
 }
 
 static int
-archive_write_ar_finish(struct archive_write *a)
+archive_write_ar_close(struct archive_write *a)
 {
+	struct ar_w *ar;
 	int ret;
 
 	/*
 	 * If we haven't written anything yet, we need to write
 	 * the ar global header now to make it a valid ar archive.
 	 */
-	if (a->archive.file_position == 0) {
-		ret = (a->compressor.write)(a, "!<arch>\n", 8);
+	ar = (struct ar_w *)a->format_data;
+	if (!ar->wrote_global_header) {
+		ar->wrote_global_header = 1;
+		ret = __archive_write_output(a, "!<arch>\n", 8);
 		return (ret);
 	}
 
@@ -439,12 +453,12 @@
 
 	if (ar->entry_padding != 1) {
 		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
-		    "Padding wrong size: %d should be 1 or 0",
-		    (int)ar->entry_padding);
+		    "Padding wrong size: %ju should be 1 or 0",
+		    (uintmax_t)ar->entry_padding);
 		return (ARCHIVE_WARN);
 	}
 
-	ret = (a->compressor.write)(a, "\n", 1);
+	ret = __archive_write_output(a, "\n", 1);
 	return (ret);
 }
 
@@ -501,7 +515,7 @@
 	len = s;
 	h = p;
 
-	/* Negative values in ar header are meaningless , so use 0. */
+	/* Negative values in ar header are meaningless, so use 0. */
 	if (v < 0) {
 		while (len-- > 0)
 			*p++ = '0';
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_write_set_format_by_name.c
--- a/head/contrib/libarchive/libarchive/archive_write_set_format_by_name.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_write_set_format_by_name.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write_set_format_by_name.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write_set_format_by_name.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
@@ -44,19 +44,28 @@
 static
 struct { const char *name; int (*setter)(struct archive *); } names[] =
 {
+	{ "7zip",	archive_write_set_format_7zip },
 	{ "ar",		archive_write_set_format_ar_bsd },
 	{ "arbsd",	archive_write_set_format_ar_bsd },
 	{ "argnu",	archive_write_set_format_ar_svr4 },
 	{ "arsvr4",	archive_write_set_format_ar_svr4 },
+	{ "bsdtar",	archive_write_set_format_pax_restricted },
+	{ "cd9660",	archive_write_set_format_iso9660 },
 	{ "cpio",	archive_write_set_format_cpio },
+	{ "gnutar",	archive_write_set_format_gnutar },
+	{ "iso",	archive_write_set_format_iso9660 },
+	{ "iso9660",	archive_write_set_format_iso9660 },
 	{ "mtree",	archive_write_set_format_mtree },
 	{ "newc",	archive_write_set_format_cpio_newc },
 	{ "odc",	archive_write_set_format_cpio },
 	{ "pax",	archive_write_set_format_pax },
+	{ "paxr",	archive_write_set_format_pax_restricted },
 	{ "posix",	archive_write_set_format_pax },
+	{ "rpax",	archive_write_set_format_pax_restricted },
 	{ "shar",	archive_write_set_format_shar },
 	{ "shardump",	archive_write_set_format_shar_dump },
 	{ "ustar",	archive_write_set_format_ustar },
+	{ "xar",	archive_write_set_format_xar },
 	{ "zip",	archive_write_set_format_zip },
 	{ NULL,		NULL }
 };
@@ -72,5 +81,6 @@
 	}
 
 	archive_set_error(a, EINVAL, "No such format '%s'", name);
+	a->state = ARCHIVE_STATE_FATAL;
 	return (ARCHIVE_FATAL);
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_write_set_format_cpio.c
--- a/head/contrib/libarchive/libarchive/archive_write_set_format_cpio.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_write_set_format_cpio.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,6 @@
 /*-
  * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2011-2012 Michihiro NAKAJIMA
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -24,7 +25,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write_set_format_cpio.c 228911 2011-12-27 10:36:56Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write_set_format_cpio.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
@@ -39,18 +40,22 @@
 
 #include "archive.h"
 #include "archive_entry.h"
+#include "archive_entry_locale.h"
 #include "archive_private.h"
 #include "archive_write_private.h"
 
 static ssize_t	archive_write_cpio_data(struct archive_write *,
 		    const void *buff, size_t s);
-static int	archive_write_cpio_finish(struct archive_write *);
-static int	archive_write_cpio_destroy(struct archive_write *);
+static int	archive_write_cpio_close(struct archive_write *);
+static int	archive_write_cpio_free(struct archive_write *);
 static int	archive_write_cpio_finish_entry(struct archive_write *);
 static int	archive_write_cpio_header(struct archive_write *,
 		    struct archive_entry *);
+static int	archive_write_cpio_options(struct archive_write *,
+		    const char *, const char *);
 static int	format_octal(int64_t, void *, int);
 static int64_t	format_octal_recursive(int64_t, char *, int);
+static int	write_header(struct archive_write *, struct archive_entry *);
 
 struct cpio {
 	uint64_t	  entry_bytes_remaining;
@@ -60,31 +65,34 @@
 	struct		 { int64_t old; int new;} *ino_list;
 	size_t		  ino_list_size;
 	size_t		  ino_list_next;
+
+	struct archive_string_conv *opt_sconv;
+	struct archive_string_conv *sconv_default;
+	int		  init_default_conversion;
 };
 
-#ifdef _MSC_VER
-#define __packed
-#pragma pack(push, 1)
-#endif
-
-struct cpio_header {
-	char	c_magic[6];
-	char	c_dev[6];
-	char	c_ino[6];
-	char	c_mode[6];
-	char	c_uid[6];
-	char	c_gid[6];
-	char	c_nlink[6];
-	char	c_rdev[6];
-	char	c_mtime[11];
-	char	c_namesize[6];
-	char	c_filesize[11];
-} __packed;
-
-#ifdef _MSC_VER
-#undef __packed
-#pragma pack(pop)
-#endif
+#define	c_magic_offset 0
+#define	c_magic_size 6
+#define	c_dev_offset 6
+#define	c_dev_size 6
+#define	c_ino_offset 12
+#define	c_ino_size 6
+#define	c_mode_offset 18
+#define	c_mode_size 6
+#define	c_uid_offset 24
+#define	c_uid_size 6
+#define	c_gid_offset 30
+#define	c_gid_size 6
+#define	c_nlink_offset 36
+#define	c_nlink_size 6
+#define	c_rdev_offset 42
+#define	c_rdev_size 6
+#define	c_mtime_offset 48
+#define	c_mtime_size 11
+#define	c_namesize_offset 59
+#define	c_namesize_size 6
+#define	c_filesize_offset 65
+#define	c_filesize_size 11
 
 /*
  * Set output format to 'cpio' format.
@@ -95,30 +103,60 @@
 	struct archive_write *a = (struct archive_write *)_a;
 	struct cpio *cpio;
 
+	archive_check_magic(_a, ARCHIVE_WRITE_MAGIC,
+	    ARCHIVE_STATE_NEW, "archive_write_set_format_cpio");
+
 	/* If someone else was already registered, unregister them. */
-	if (a->format_destroy != NULL)
-		(a->format_destroy)(a);
+	if (a->format_free != NULL)
+		(a->format_free)(a);
 
-	cpio = (struct cpio *)malloc(sizeof(*cpio));
+	cpio = (struct cpio *)calloc(1, sizeof(*cpio));
 	if (cpio == NULL) {
 		archive_set_error(&a->archive, ENOMEM, "Can't allocate cpio data");
 		return (ARCHIVE_FATAL);
 	}
-	memset(cpio, 0, sizeof(*cpio));
 	a->format_data = cpio;
-
-	a->pad_uncompressed = 1;
 	a->format_name = "cpio";
+	a->format_options = archive_write_cpio_options;
 	a->format_write_header = archive_write_cpio_header;
 	a->format_write_data = archive_write_cpio_data;
 	a->format_finish_entry = archive_write_cpio_finish_entry;
-	a->format_finish = archive_write_cpio_finish;
-	a->format_destroy = archive_write_cpio_destroy;
+	a->format_close = archive_write_cpio_close;
+	a->format_free = archive_write_cpio_free;
 	a->archive.archive_format = ARCHIVE_FORMAT_CPIO_POSIX;
 	a->archive.archive_format_name = "POSIX cpio";
 	return (ARCHIVE_OK);
 }
 
+static int
+archive_write_cpio_options(struct archive_write *a, const char *key,
+    const char *val)
+{
+	struct cpio *cpio = (struct cpio *)a->format_data;
+	int ret = ARCHIVE_FAILED;
+
+	if (strcmp(key, "hdrcharset")  == 0) {
+		if (val == NULL || val[0] == 0)
+			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+			    "%s: hdrcharset option needs a character-set name",
+			    a->format_name);
+		else {
+			cpio->opt_sconv = archive_string_conversion_to_charset(
+			    &a->archive, val, 0);
+			if (cpio->opt_sconv != NULL)
+				ret = ARCHIVE_OK;
+			else
+				ret = ARCHIVE_FATAL;
+		}
+		return (ret);
+	}
+
+	/* Note: The "warn" return is just to inform the options
+	 * supervisor that we didn't handle it.  It will generate
+	 * a suitable error if no one used this option. */
+	return (ARCHIVE_WARN);
+}
+
 /*
  * Ino values are as long as 64 bits on some systems; cpio format
  * only allows 18 bits and relies on the ino values to identify hardlinked
@@ -184,78 +222,195 @@
 	return (ino_new);
 }
 
+
+static struct archive_string_conv *
+get_sconv(struct archive_write *a)
+{
+	struct cpio *cpio;
+	struct archive_string_conv *sconv;
+
+	cpio = (struct cpio *)a->format_data;
+	sconv = cpio->opt_sconv;
+	if (sconv == NULL) {
+		if (!cpio->init_default_conversion) {
+			cpio->sconv_default =
+			    archive_string_default_conversion_for_write(
+			      &(a->archive));
+			cpio->init_default_conversion = 1;
+		}
+		sconv = cpio->sconv_default;
+	}
+	return (sconv);
+}
+
 static int
 archive_write_cpio_header(struct archive_write *a, struct archive_entry *entry)
 {
+	const char *path;
+	size_t len;
+
+	if (archive_entry_filetype(entry) == 0) {
+		archive_set_error(&a->archive, -1, "Filetype required");
+		return (ARCHIVE_FAILED);
+	}
+
+	if (archive_entry_pathname_l(entry, &path, &len, get_sconv(a)) != 0
+	    && errno == ENOMEM) {
+		archive_set_error(&a->archive, ENOMEM,
+		    "Can't allocate memory for Pathname");
+		return (ARCHIVE_FATAL);
+	}
+	if (len == 0 || path == NULL || path[0] == '\0') {
+		archive_set_error(&a->archive, -1, "Pathname required");
+		return (ARCHIVE_FAILED);
+	}
+
+	if (!archive_entry_size_is_set(entry) || archive_entry_size(entry) < 0) {
+		archive_set_error(&a->archive, -1, "Size required");
+		return (ARCHIVE_FAILED);
+	}
+	return write_header(a, entry);
+}
+
+static int
+write_header(struct archive_write *a, struct archive_entry *entry)
+{
 	struct cpio *cpio;
 	const char *p, *path;
-	int pathlength, ret, ret2;
+	int pathlength, ret, ret_final;
 	int64_t	ino;
-	struct cpio_header	 h;
+	char h[76];
+	struct archive_string_conv *sconv;
+	struct archive_entry *entry_main;
+	size_t len;
 
 	cpio = (struct cpio *)a->format_data;
-	ret2 = ARCHIVE_OK;
+	ret_final = ARCHIVE_OK;
+	sconv = get_sconv(a);
 
-	path = archive_entry_pathname(entry);
-	pathlength = (int)strlen(path) + 1; /* Include trailing null. */
+#if defined(_WIN32) && !defined(__CYGWIN__)
+	/* Make sure the path separators in pahtname, hardlink and symlink
+	 * are all slash '/', not the Windows path separator '\'. */
+	entry_main = __la_win_entry_in_posix_pathseparator(entry);
+	if (entry_main == NULL) {
+		archive_set_error(&a->archive, ENOMEM,
+		    "Can't allocate ustar data");
+		return(ARCHIVE_FATAL);
+	}
+	if (entry != entry_main)
+		entry = entry_main;
+	else
+		entry_main = NULL;
+#else
+	entry_main = NULL;
+#endif
 
-	memset(&h, 0, sizeof(h));
-	format_octal(070707, &h.c_magic, sizeof(h.c_magic));
-	format_octal(archive_entry_dev(entry), &h.c_dev, sizeof(h.c_dev));
+	ret = archive_entry_pathname_l(entry, &path, &len, sconv);
+	if (ret != 0) {
+		if (errno == ENOMEM) {
+			archive_set_error(&a->archive, ENOMEM,
+			    "Can't allocate memory for Pathname");
+			ret_final = ARCHIVE_FATAL;
+			goto exit_write_header;
+		}
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+		    "Can't translate pathname '%s' to %s",
+		    archive_entry_pathname(entry),
+		    archive_string_conversion_charset_name(sconv));
+		ret_final = ARCHIVE_WARN;
+	}
+	/* Include trailing null. */
+	pathlength = (int)len + 1;
+
+	memset(h, 0, sizeof(h));
+	format_octal(070707, h + c_magic_offset, c_magic_size);
+	format_octal(archive_entry_dev(entry), h + c_dev_offset, c_dev_size);
 
 	ino = synthesize_ino_value(cpio, entry);
 	if (ino < 0) {
 		archive_set_error(&a->archive, ENOMEM,
 		    "No memory for ino translation table");
-		return (ARCHIVE_FATAL);
+		ret_final = ARCHIVE_FATAL;
+		goto exit_write_header;
 	} else if (ino > 0777777) {
 		archive_set_error(&a->archive, ERANGE,
 		    "Too many files for this cpio format");
-		return (ARCHIVE_FATAL);
+		ret_final = ARCHIVE_FATAL;
+		goto exit_write_header;
 	}
-	format_octal(ino & 0777777, &h.c_ino, sizeof(h.c_ino));
+	format_octal(ino & 0777777, h + c_ino_offset, c_ino_size);
 
-	format_octal(archive_entry_mode(entry), &h.c_mode, sizeof(h.c_mode));
-	format_octal(archive_entry_uid(entry), &h.c_uid, sizeof(h.c_uid));
-	format_octal(archive_entry_gid(entry), &h.c_gid, sizeof(h.c_gid));
-	format_octal(archive_entry_nlink(entry), &h.c_nlink, sizeof(h.c_nlink));
+	/* TODO: Set ret_final to ARCHIVE_WARN if any of these overflow. */
+	format_octal(archive_entry_mode(entry), h + c_mode_offset, c_mode_size);
+	format_octal(archive_entry_uid(entry), h + c_uid_offset, c_uid_size);
+	format_octal(archive_entry_gid(entry), h + c_gid_offset, c_gid_size);
+	format_octal(archive_entry_nlink(entry), h + c_nlink_offset, c_nlink_size);
 	if (archive_entry_filetype(entry) == AE_IFBLK
 	    || archive_entry_filetype(entry) == AE_IFCHR)
-	    format_octal(archive_entry_dev(entry), &h.c_rdev, sizeof(h.c_rdev));
+	    format_octal(archive_entry_dev(entry), h + c_rdev_offset, c_rdev_size);
 	else
-	    format_octal(0, &h.c_rdev, sizeof(h.c_rdev));
-	format_octal(archive_entry_mtime(entry), &h.c_mtime, sizeof(h.c_mtime));
-	format_octal(pathlength, &h.c_namesize, sizeof(h.c_namesize));
+	    format_octal(0, h + c_rdev_offset, c_rdev_size);
+	format_octal(archive_entry_mtime(entry), h + c_mtime_offset, c_mtime_size);
+	format_octal(pathlength, h + c_namesize_offset, c_namesize_size);
 
 	/* Non-regular files don't store bodies. */
 	if (archive_entry_filetype(entry) != AE_IFREG)
 		archive_entry_set_size(entry, 0);
 
 	/* Symlinks get the link written as the body of the entry. */
-	p = archive_entry_symlink(entry);
-	if (p != NULL  &&  *p != '\0')
-		format_octal(strlen(p), &h.c_filesize, sizeof(h.c_filesize));
+	ret = archive_entry_symlink_l(entry, &p, &len, sconv);
+	if (ret != 0) {
+		if (errno == ENOMEM) {
+			archive_set_error(&a->archive, ENOMEM,
+			    "Can't allocate memory for Linkname");
+			ret_final = ARCHIVE_FATAL;
+			goto exit_write_header;
+		}
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+		    "Can't translate linkname '%s' to %s",
+		    archive_entry_symlink(entry),
+		    archive_string_conversion_charset_name(sconv));
+		ret_final = ARCHIVE_WARN;
+	}
+	if (len > 0 && p != NULL  &&  *p != '\0')
+		ret = format_octal(strlen(p), h + c_filesize_offset,
+		    c_filesize_size);
 	else
-		format_octal(archive_entry_size(entry),
-		    &h.c_filesize, sizeof(h.c_filesize));
+		ret = format_octal(archive_entry_size(entry),
+		    h + c_filesize_offset, c_filesize_size);
+	if (ret) {
+		archive_set_error(&a->archive, ERANGE,
+		    "File is too large for cpio format.");
+		ret_final = ARCHIVE_FAILED;
+		goto exit_write_header;
+	}
 
-	ret = (a->compressor.write)(a, &h, sizeof(h));
-	if (ret != ARCHIVE_OK)
-		return (ARCHIVE_FATAL);
+	ret = __archive_write_output(a, h, sizeof(h));
+	if (ret != ARCHIVE_OK) {
+		ret_final = ARCHIVE_FATAL;
+		goto exit_write_header;
+	}
 
-	ret = (a->compressor.write)(a, path, pathlength);
-	if (ret != ARCHIVE_OK)
-		return (ARCHIVE_FATAL);
+	ret = __archive_write_output(a, path, pathlength);
+	if (ret != ARCHIVE_OK) {
+		ret_final = ARCHIVE_FATAL;
+		goto exit_write_header;
+	}
 
 	cpio->entry_bytes_remaining = archive_entry_size(entry);
 
 	/* Write the symlink now. */
-	if (p != NULL  &&  *p != '\0')
-		ret = (a->compressor.write)(a, p, strlen(p));
-
-	if (ret == ARCHIVE_OK)
-		ret = ret2;
-	return (ret);
+	if (p != NULL  &&  *p != '\0') {
+		ret = __archive_write_output(a, p, strlen(p));
+		if (ret != ARCHIVE_OK) {
+			ret_final = ARCHIVE_FATAL;
+			goto exit_write_header;
+		}
+	}
+exit_write_header:
+	if (entry_main)
+		archive_entry_free(entry_main);
+	return (ret_final);
 }
 
 static ssize_t
@@ -268,7 +423,7 @@
 	if (s > cpio->entry_bytes_remaining)
 		s = cpio->entry_bytes_remaining;
 
-	ret = (a->compressor.write)(a, buff, s);
+	ret = __archive_write_output(a, buff, s);
 	cpio->entry_bytes_remaining -= s;
 	if (ret >= 0)
 		return (s);
@@ -307,22 +462,23 @@
 }
 
 static int
-archive_write_cpio_finish(struct archive_write *a)
+archive_write_cpio_close(struct archive_write *a)
 {
 	int er;
 	struct archive_entry *trailer;
 
-	trailer = archive_entry_new();
+	trailer = archive_entry_new2(NULL);
 	/* nlink = 1 here for GNU cpio compat. */
 	archive_entry_set_nlink(trailer, 1);
+	archive_entry_set_size(trailer, 0);
 	archive_entry_set_pathname(trailer, "TRAILER!!!");
-	er = archive_write_cpio_header(a, trailer);
+	er = write_header(a, trailer);
 	archive_entry_free(trailer);
 	return (er);
 }
 
 static int
-archive_write_cpio_destroy(struct archive_write *a)
+archive_write_cpio_free(struct archive_write *a)
 {
 	struct cpio *cpio;
 
@@ -337,18 +493,7 @@
 archive_write_cpio_finish_entry(struct archive_write *a)
 {
 	struct cpio *cpio;
-	size_t to_write;
-	int ret;
 
 	cpio = (struct cpio *)a->format_data;
-	ret = ARCHIVE_OK;
-	while (cpio->entry_bytes_remaining > 0) {
-		to_write = cpio->entry_bytes_remaining < a->null_length ?
-		    cpio->entry_bytes_remaining : a->null_length;
-		ret = (a->compressor.write)(a, a->nulls, to_write);
-		if (ret != ARCHIVE_OK)
-			return (ret);
-		cpio->entry_bytes_remaining -= to_write;
-	}
-	return (ret);
+	return (__archive_write_nulls(a, cpio->entry_bytes_remaining));
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_write_set_format_cpio_newc.c
--- a/head/contrib/libarchive/libarchive/archive_write_set_format_cpio_newc.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_write_set_format_cpio_newc.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,6 +1,7 @@
 /*-
  * Copyright (c) 2003-2007 Tim Kientzle
  * Copyright (c) 2006 Rudolf Marek SYSGO s.r.o.
+ * Copyright (c) 2011-2012 Michihiro NAKAJIMA
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -25,7 +26,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write_set_format_cpio_newc.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write_set_format_cpio_newc.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
@@ -40,40 +41,61 @@
 
 #include "archive.h"
 #include "archive_entry.h"
+#include "archive_entry_locale.h"
 #include "archive_private.h"
 #include "archive_write_private.h"
 
 static ssize_t	archive_write_newc_data(struct archive_write *,
 		    const void *buff, size_t s);
-static int	archive_write_newc_finish(struct archive_write *);
-static int	archive_write_newc_destroy(struct archive_write *);
+static int	archive_write_newc_close(struct archive_write *);
+static int	archive_write_newc_free(struct archive_write *);
 static int	archive_write_newc_finish_entry(struct archive_write *);
 static int	archive_write_newc_header(struct archive_write *,
 		    struct archive_entry *);
+static int      archive_write_newc_options(struct archive_write *,
+		    const char *, const char *);
 static int	format_hex(int64_t, void *, int);
 static int64_t	format_hex_recursive(int64_t, char *, int);
+static int	write_header(struct archive_write *, struct archive_entry *);
 
 struct cpio {
 	uint64_t	  entry_bytes_remaining;
 	int		  padding;
+
+	struct archive_string_conv *opt_sconv;
+	struct archive_string_conv *sconv_default;
+	int		  init_default_conversion;
 };
 
-struct cpio_header_newc {
-	char	c_magic[6];
-	char	c_ino[8];
-	char	c_mode[8];
-	char	c_uid[8];
-	char	c_gid[8];
-	char	c_nlink[8];
-	char	c_mtime[8];
-	char	c_filesize[8];
-	char	c_devmajor[8];
-	char	c_devminor[8];
-	char	c_rdevmajor[8];
-	char	c_rdevminor[8];
-	char	c_namesize[8];
-	char	c_checksum[8];
-};
+#define	c_magic_offset 0
+#define	c_magic_size 6
+#define	c_ino_offset 6
+#define	c_ino_size 8
+#define	c_mode_offset 14
+#define	c_mode_size 8
+#define	c_uid_offset 22
+#define	c_uid_size 8
+#define	c_gid_offset 30
+#define	c_gid_size 8
+#define	c_nlink_offset 38
+#define	c_nlink_size 8
+#define	c_mtime_offset 46
+#define	c_mtime_size 8
+#define	c_filesize_offset 54
+#define	c_filesize_size 8
+#define	c_devmajor_offset 62
+#define	c_devmajor_size 8
+#define	c_devminor_offset 70
+#define	c_devminor_size 8
+#define	c_rdevmajor_offset 78
+#define	c_rdevmajor_size 8
+#define	c_rdevminor_offset 86
+#define	c_rdevminor_size 8
+#define	c_namesize_offset 94
+#define	c_namesize_size 8
+#define	c_checksum_offset 102
+#define	c_checksum_size 8
+#define	c_header_size 110
 
 /* Logic trick: difference between 'n' and next multiple of 4 */
 #define PAD4(n)	(3 & (1 + ~(n)))
@@ -87,9 +109,12 @@
 	struct archive_write *a = (struct archive_write *)_a;
 	struct cpio *cpio;
 
+	archive_check_magic(_a, ARCHIVE_WRITE_MAGIC,
+	    ARCHIVE_STATE_NEW, "archive_write_set_format_cpio_newc");
+
 	/* If someone else was already registered, unregister them. */
-	if (a->format_destroy != NULL)
-		(a->format_destroy)(a);
+	if (a->format_free != NULL)
+		(a->format_free)(a);
 
 	cpio = (struct cpio *)malloc(sizeof(*cpio));
 	if (cpio == NULL) {
@@ -98,107 +123,253 @@
 	}
 	memset(cpio, 0, sizeof(*cpio));
 	a->format_data = cpio;
-
-	a->pad_uncompressed = 1;
 	a->format_name = "cpio";
+	a->format_options = archive_write_newc_options;
 	a->format_write_header = archive_write_newc_header;
 	a->format_write_data = archive_write_newc_data;
 	a->format_finish_entry = archive_write_newc_finish_entry;
-	a->format_finish = archive_write_newc_finish;
-	a->format_destroy = archive_write_newc_destroy;
+	a->format_close = archive_write_newc_close;
+	a->format_free = archive_write_newc_free;
 	a->archive.archive_format = ARCHIVE_FORMAT_CPIO_SVR4_NOCRC;
 	a->archive.archive_format_name = "SVR4 cpio nocrc";
 	return (ARCHIVE_OK);
 }
 
 static int
+archive_write_newc_options(struct archive_write *a, const char *key,
+    const char *val)
+{
+	struct cpio *cpio = (struct cpio *)a->format_data;
+	int ret = ARCHIVE_FAILED;
+
+	if (strcmp(key, "hdrcharset")  == 0) {
+		if (val == NULL || val[0] == 0)
+			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+			    "%s: hdrcharset option needs a character-set name",
+			    a->format_name);
+		else {
+			cpio->opt_sconv = archive_string_conversion_to_charset(
+			    &a->archive, val, 0);
+			if (cpio->opt_sconv != NULL)
+				ret = ARCHIVE_OK;
+			else
+				ret = ARCHIVE_FATAL;
+		}
+		return (ret);
+	}
+
+	/* Note: The "warn" return is just to inform the options
+	 * supervisor that we didn't handle it.  It will generate
+	 * a suitable error if no one used this option. */
+	return (ARCHIVE_WARN);
+}
+
+static struct archive_string_conv *
+get_sconv(struct archive_write *a)
+{
+	struct cpio *cpio;
+	struct archive_string_conv *sconv;
+
+	cpio = (struct cpio *)a->format_data;
+	sconv = cpio->opt_sconv;
+	if (sconv == NULL) {
+		if (!cpio->init_default_conversion) {
+			cpio->sconv_default =
+			    archive_string_default_conversion_for_write(
+			      &(a->archive));
+			cpio->init_default_conversion = 1;
+		}
+		sconv = cpio->sconv_default;
+	}
+	return (sconv);
+}
+
+static int
 archive_write_newc_header(struct archive_write *a, struct archive_entry *entry)
 {
+	const char *path;
+	size_t len;
+
+	if (archive_entry_filetype(entry) == 0) {
+		archive_set_error(&a->archive, -1, "Filetype required");
+		return (ARCHIVE_FAILED);
+	}
+
+	if (archive_entry_pathname_l(entry, &path, &len, get_sconv(a)) != 0
+	    && errno == ENOMEM) {
+		archive_set_error(&a->archive, ENOMEM,
+		    "Can't allocate memory for Pathname");
+		return (ARCHIVE_FATAL);
+	}
+	if (len == 0 || path == NULL || path[0] == '\0') {
+		archive_set_error(&a->archive, -1, "Pathname required");
+		return (ARCHIVE_FAILED);
+	}
+
+	if (archive_entry_hardlink(entry) == NULL
+	    && (!archive_entry_size_is_set(entry) || archive_entry_size(entry) < 0)) {
+		archive_set_error(&a->archive, -1, "Size required");
+		return (ARCHIVE_FAILED);
+	}
+	return write_header(a, entry);
+}
+
+static int
+write_header(struct archive_write *a, struct archive_entry *entry)
+{
 	int64_t ino;
 	struct cpio *cpio;
 	const char *p, *path;
-	int pathlength, ret, ret2;
-	struct cpio_header_newc	 h;
+	int pathlength, ret, ret_final;
+	char h[c_header_size];
+	struct archive_string_conv *sconv;
+	struct archive_entry *entry_main;
+	size_t len;
 	int pad;
 
 	cpio = (struct cpio *)a->format_data;
-	ret2 = ARCHIVE_OK;
+	ret_final = ARCHIVE_OK;
+	sconv = get_sconv(a);
 
-	path = archive_entry_pathname(entry);
-	pathlength = (int)strlen(path) + 1; /* Include trailing null. */
+#if defined(_WIN32) && !defined(__CYGWIN__)
+	/* Make sure the path separators in pahtname, hardlink and symlink
+	 * are all slash '/', not the Windows path separator '\'. */
+	entry_main = __la_win_entry_in_posix_pathseparator(entry);
+	if (entry_main == NULL) {
+		archive_set_error(&a->archive, ENOMEM,
+		    "Can't allocate ustar data");
+		return(ARCHIVE_FATAL);
+	}
+	if (entry != entry_main)
+		entry = entry_main;
+	else
+		entry_main = NULL;
+#else
+	entry_main = NULL;
+#endif
 
-	memset(&h, 0, sizeof(h));
-	format_hex(0x070701, &h.c_magic, sizeof(h.c_magic));
-	format_hex(archive_entry_devmajor(entry), &h.c_devmajor,
-	    sizeof(h.c_devmajor));
-	format_hex(archive_entry_devminor(entry), &h.c_devminor,
-	    sizeof(h.c_devminor));
+	ret = archive_entry_pathname_l(entry, &path, &len, sconv);
+	if (ret != 0) {
+		if (errno == ENOMEM) {
+			archive_set_error(&a->archive, ENOMEM,
+			    "Can't allocate memory for Pathname");
+			ret_final = ARCHIVE_FATAL;
+			goto exit_write_header;
+		}
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+		    "Can't translate pathname '%s' to %s",
+		    archive_entry_pathname(entry),
+		    archive_string_conversion_charset_name(sconv));
+		ret_final = ARCHIVE_WARN;
+	}
+	pathlength = (int)len + 1; /* Include trailing null. */
+
+	memset(h, 0, c_header_size);
+	format_hex(0x070701, h + c_magic_offset, c_magic_size);
+	format_hex(archive_entry_devmajor(entry), h + c_devmajor_offset,
+	    c_devmajor_size);
+	format_hex(archive_entry_devminor(entry), h + c_devminor_offset,
+	    c_devminor_size);
 
 	ino = archive_entry_ino64(entry);
 	if (ino > 0xffffffff) {
 		archive_set_error(&a->archive, ERANGE,
 		    "large inode number truncated");
-		ret2 = ARCHIVE_WARN;
+		ret_final = ARCHIVE_WARN;
 	}
 
-	format_hex(ino & 0xffffffff, &h.c_ino, sizeof(h.c_ino));
-	format_hex(archive_entry_mode(entry), &h.c_mode, sizeof(h.c_mode));
-	format_hex(archive_entry_uid(entry), &h.c_uid, sizeof(h.c_uid));
-	format_hex(archive_entry_gid(entry), &h.c_gid, sizeof(h.c_gid));
-	format_hex(archive_entry_nlink(entry), &h.c_nlink, sizeof(h.c_nlink));
+	/* TODO: Set ret_final to ARCHIVE_WARN if any of these overflow. */
+	format_hex(ino & 0xffffffff, h + c_ino_offset, c_ino_size);
+	format_hex(archive_entry_mode(entry), h + c_mode_offset, c_mode_size);
+	format_hex(archive_entry_uid(entry), h + c_uid_offset, c_uid_size);
+	format_hex(archive_entry_gid(entry), h + c_gid_offset, c_gid_size);
+	format_hex(archive_entry_nlink(entry), h + c_nlink_offset, c_nlink_size);
 	if (archive_entry_filetype(entry) == AE_IFBLK
 	    || archive_entry_filetype(entry) == AE_IFCHR) {
-	    format_hex(archive_entry_rdevmajor(entry), &h.c_rdevmajor, sizeof(h.c_rdevmajor));
-	    format_hex(archive_entry_rdevminor(entry), &h.c_rdevminor, sizeof(h.c_rdevminor));
+	    format_hex(archive_entry_rdevmajor(entry), h + c_rdevmajor_offset, c_rdevmajor_size);
+	    format_hex(archive_entry_rdevminor(entry), h + c_rdevminor_offset, c_rdevminor_size);
 	} else {
-	    format_hex(0, &h.c_rdevmajor, sizeof(h.c_rdevmajor));
-	    format_hex(0, &h.c_rdevminor, sizeof(h.c_rdevminor));
+	    format_hex(0, h + c_rdevmajor_offset, c_rdevmajor_size);
+	    format_hex(0, h + c_rdevminor_offset, c_rdevminor_size);
 	}
-	format_hex(archive_entry_mtime(entry), &h.c_mtime, sizeof(h.c_mtime));
-	format_hex(pathlength, &h.c_namesize, sizeof(h.c_namesize));
-	format_hex(0, &h.c_checksum, sizeof(h.c_checksum));
+	format_hex(archive_entry_mtime(entry), h + c_mtime_offset, c_mtime_size);
+	format_hex(pathlength, h + c_namesize_offset, c_namesize_size);
+	format_hex(0, h + c_checksum_offset, c_checksum_size);
 
 	/* Non-regular files don't store bodies. */
 	if (archive_entry_filetype(entry) != AE_IFREG)
 		archive_entry_set_size(entry, 0);
 
 	/* Symlinks get the link written as the body of the entry. */
-	p = archive_entry_symlink(entry);
-	if (p != NULL  &&  *p != '\0')
-		format_hex(strlen(p), &h.c_filesize, sizeof(h.c_filesize));
+	ret = archive_entry_symlink_l(entry, &p, &len, sconv);
+	if (ret != 0) {
+		if (errno == ENOMEM) {
+			archive_set_error(&a->archive, ENOMEM,
+			    "Can't allocate memory for Likname");
+			ret_final = ARCHIVE_FATAL;
+			goto exit_write_header;
+		}
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+		    "Can't translate linkname '%s' to %s",
+		    archive_entry_symlink(entry),
+		    archive_string_conversion_charset_name(sconv));
+		ret_final = ARCHIVE_WARN;
+	}
+	if (len > 0 && p != NULL  &&  *p != '\0')
+		ret = format_hex(strlen(p), h + c_filesize_offset,
+		    c_filesize_size);
 	else
-		format_hex(archive_entry_size(entry),
-		    &h.c_filesize, sizeof(h.c_filesize));
+		ret = format_hex(archive_entry_size(entry),
+		    h + c_filesize_offset, c_filesize_size);
+	if (ret) {
+		archive_set_error(&a->archive, ERANGE,
+		    "File is too large for this format.");
+		ret_final = ARCHIVE_FAILED;
+		goto exit_write_header;
+	}
 
-	ret = (a->compressor.write)(a, &h, sizeof(h));
-	if (ret != ARCHIVE_OK)
-		return (ARCHIVE_FATAL);
+	ret = __archive_write_output(a, h, c_header_size);
+	if (ret != ARCHIVE_OK) {
+		ret_final = ARCHIVE_FATAL;
+		goto exit_write_header;
+	}
 
 	/* Pad pathname to even length. */
-	ret = (a->compressor.write)(a, path, pathlength);
-	if (ret != ARCHIVE_OK)
-		return (ARCHIVE_FATAL);
-	pad = PAD4(pathlength + sizeof(struct cpio_header_newc));
-	if (pad)
-		ret = (a->compressor.write)(a, "\0\0\0", pad);
-	if (ret != ARCHIVE_OK)
-		return (ARCHIVE_FATAL);
+	ret = __archive_write_output(a, path, pathlength);
+	if (ret != ARCHIVE_OK) {
+		ret_final = ARCHIVE_FATAL;
+		goto exit_write_header;
+	}
+	pad = PAD4(pathlength + c_header_size);
+	if (pad) {
+		ret = __archive_write_output(a, "\0\0\0", pad);
+		if (ret != ARCHIVE_OK) {
+			ret_final = ARCHIVE_FATAL;
+			goto exit_write_header;
+		}
+	}
 
 	cpio->entry_bytes_remaining = archive_entry_size(entry);
 	cpio->padding = PAD4(cpio->entry_bytes_remaining);
 
 	/* Write the symlink now. */
 	if (p != NULL  &&  *p != '\0') {
-		ret = (a->compressor.write)(a, p, strlen(p));
-		if (ret != ARCHIVE_OK)
-			return (ARCHIVE_FATAL);
+		ret = __archive_write_output(a, p, strlen(p));
+		if (ret != ARCHIVE_OK) {
+			ret_final = ARCHIVE_FATAL;
+			goto exit_write_header;
+		}
 		pad = PAD4(strlen(p));
-		ret = (a->compressor.write)(a, "\0\0\0", pad);
+		ret = __archive_write_output(a, "\0\0\0", pad);
+		if (ret != ARCHIVE_OK) {
+			ret_final = ARCHIVE_FATAL;
+			goto exit_write_header;
+		}
 	}
-
-	if (ret == ARCHIVE_OK)
-		ret = ret2;
-	return (ret);
+exit_write_header:
+	if (entry_main)
+		archive_entry_free(entry_main);
+	return (ret_final);
 }
 
 static ssize_t
@@ -211,7 +382,7 @@
 	if (s > cpio->entry_bytes_remaining)
 		s = cpio->entry_bytes_remaining;
 
-	ret = (a->compressor.write)(a, buff, s);
+	ret = __archive_write_output(a, buff, s);
 	cpio->entry_bytes_remaining -= s;
 	if (ret >= 0)
 		return (s);
@@ -250,21 +421,23 @@
 }
 
 static int
-archive_write_newc_finish(struct archive_write *a)
+archive_write_newc_close(struct archive_write *a)
 {
 	int er;
 	struct archive_entry *trailer;
 
 	trailer = archive_entry_new();
 	archive_entry_set_nlink(trailer, 1);
+	archive_entry_set_size(trailer, 0);
 	archive_entry_set_pathname(trailer, "TRAILER!!!");
-	er = archive_write_newc_header(a, trailer);
+	/* Bypass the required data checks. */
+	er = write_header(a, trailer);
 	archive_entry_free(trailer);
 	return (er);
 }
 
 static int
-archive_write_newc_destroy(struct archive_write *a)
+archive_write_newc_free(struct archive_write *a)
 {
 	struct cpio *cpio;
 
@@ -278,18 +451,7 @@
 archive_write_newc_finish_entry(struct archive_write *a)
 {
 	struct cpio *cpio;
-	size_t to_write;
-	int ret;
 
 	cpio = (struct cpio *)a->format_data;
-	while (cpio->entry_bytes_remaining > 0) {
-		to_write = cpio->entry_bytes_remaining < a->null_length ?
-		    cpio->entry_bytes_remaining : a->null_length;
-		ret = (a->compressor.write)(a, a->nulls, to_write);
-		if (ret != ARCHIVE_OK)
-			return (ret);
-		cpio->entry_bytes_remaining -= to_write;
-	}
-	ret = (a->compressor.write)(a, a->nulls, cpio->padding);
-	return (ret);
+	return (__archive_write_nulls(a, cpio->entry_bytes_remaining + cpio->padding));
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_write_set_format_mtree.c
--- a/head/contrib/libarchive/libarchive/archive_write_set_format_mtree.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_write_set_format_mtree.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,6 +1,6 @@
 /*-
- * Copyright (c) 2009 Michihiro NAKAJIMA
  * Copyright (c) 2008 Joerg Sonnenberger
+ * Copyright (c) 2009-2012 Michihiro NAKAJIMA
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -25,7 +25,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write_set_format_mtree.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write_set_format_mtree.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
@@ -35,17 +35,68 @@
 #include <string.h>
 
 #include "archive.h"
+#include "archive_crypto_private.h"
 #include "archive_entry.h"
 #include "archive_private.h"
 #include "archive_write_private.h"
 
-#include "archive_hash.h"
-
 #define INDENTNAMELEN	15
 #define MAXLINELEN	80
+#define SET_KEYS	\
+	(F_FLAGS | F_GID | F_GNAME | F_MODE | F_TYPE | F_UID | F_UNAME)
+
+struct mtree_entry {
+	struct mtree_entry *next;
+
+	char *pathname;
+	char *symlink;
+	unsigned int nlink;
+	mode_t filetype;
+	mode_t mode;
+	int64_t uid;
+	int64_t gid;
+	char *uname;
+	char *gname;
+	char *fflags_text;
+	unsigned long fflags_set;
+	unsigned long fflags_clear;
+	time_t mtime;
+	long mtime_nsec;
+	dev_t rdevmajor;
+	dev_t rdevminor;
+	int64_t size;
+
+	int compute_sum;
+	uint32_t crc;
+#ifdef ARCHIVE_HAS_MD5
+	unsigned char buf_md5[16];
+#endif
+#ifdef ARCHIVE_HAS_RMD160
+	unsigned char buf_rmd160[20];
+#endif
+#ifdef ARCHIVE_HAS_SHA1
+	unsigned char buf_sha1[20];
+#endif
+#ifdef ARCHIVE_HAS_SHA256
+	unsigned char buf_sha256[32];
+#endif
+#ifdef ARCHIVE_HAS_SHA384
+	unsigned char buf_sha384[48];
+#endif
+#ifdef ARCHIVE_HAS_SHA512
+	unsigned char buf_sha512[64];
+#endif
+};
+
+struct attr_counter {
+	struct attr_counter *prev;
+	struct attr_counter *next;
+	int count;
+	struct mtree_entry *m_entry;
+};
 
 struct mtree_writer {
-	struct archive_entry *entry;
+	struct mtree_entry *mtree_entry;
 	struct archive_string ebuf;
 	struct archive_string buf;
 	int first;
@@ -56,13 +107,20 @@
 		struct archive_string parent;
 		mode_t		type;
 		int		keys;
-		uid_t		uid;
-		gid_t		gid;
+		int64_t		uid;
+		int64_t		gid;
 		mode_t		mode;
 		unsigned long	fflags_set;
 		unsigned long	fflags_clear;
+
+		struct attr_counter *uid_list;
+		struct attr_counter *gid_list;
+		struct attr_counter *mode_list;
+		struct attr_counter *flags_list;
+		struct mtree_entry *me_first;
+		struct mtree_entry **me_last;
 	} set;
-	/* chekc sum */
+	/* check sum */
 	int compute_sum;
 	uint32_t crc;
 	uint64_t crc_len;
@@ -125,6 +183,18 @@
 			 | F_NLINK | F_SIZE | F_TIME | F_TYPE | F_UID\
 			 | F_UNAME)
 
+static struct attr_counter * new_attr_count(struct mtree_entry *,
+	struct attr_counter *);
+static void free_attr_count(struct attr_counter **);
+static int inc_attr_count(struct attr_counter **, struct attr_counter *,
+	struct attr_counter *, struct mtree_entry *);
+static int collect_set_values(struct mtree_writer *, struct mtree_entry *);
+static int get_keys(struct mtree_writer *, struct mtree_entry *);
+static void sum_init(struct mtree_writer *);
+static void sum_update(struct mtree_writer *, const void *, size_t);
+static void sum_final(struct mtree_writer *, struct mtree_entry *);
+static void sum_write(struct archive_string *, struct mtree_entry *);
+
 #define	COMPUTE_CRC(var, ch)	(var) = (var) << 8 ^ crctab[(var) >> 24 ^ (ch)]
 static const uint32_t crctab[] = {
 	0x0,
@@ -227,6 +297,9 @@
 		archive_strncat(s, start, str - start);
 }
 
+/*
+ * Indent a line as mtree utility to be readable for people.
+ */
 static void
 mtree_indent(struct mtree_writer *mtree)
 {
@@ -281,11 +354,11 @@
 
 #if !defined(_WIN32) || defined(__CYGWIN__)
 static size_t
-dir_len(struct archive_entry *entry)
+dir_len(struct mtree_entry *me)
 {
 	const char *path, *r;
 
-	path = archive_entry_pathname(entry);
+	path = me->pathname;
 	r = strrchr(path, '/');
 	if (r == NULL)
 		return (0);
@@ -301,14 +374,14 @@
  * code.
  */
 static size_t
-dir_len(struct archive_entry *entry)
+dir_len(struct mtree_entry *me)
 {
 	wchar_t wc;
 	const char *path;
 	const char *p, *rp;
 	size_t al, l, size;
 
-	path = archive_entry_pathname(entry);
+	path = me->pathname;
 	al = l = -1;
 	for (p = path; *p != '\0'; ++p) {
 		if (*p == '\\')
@@ -337,14 +410,17 @@
 }
 #endif /* _WIN32 && !__CYGWIN__ */
 
+/*
+ * Test if a parent directory of the current entry is changed.
+ */
 static int
-parent_dir_changed(struct archive_string *dir, struct archive_entry *entry)
+parent_dir_changed(struct archive_string *dir, struct mtree_entry *me)
 {
 	const char *path;
 	size_t l;
 
-	l = dir_len(entry);
-	path = archive_entry_pathname(entry);
+	l = dir_len(me);
+	path = me->pathname;
 	if (archive_strlen(dir) > 0) {
 		if (l == 0) {
 			archive_string_empty(dir);
@@ -359,129 +435,141 @@
 }
 
 /*
- * Write /set keyword. It means set global datas.
- * [directory-only mode]
- *   - It is only once to write /set keyword. It is using values of the
- *     first entry.
- * [normal mode]
- *   - Write /set keyword. It is using values of the first entry whose
- *     filetype is a regular file.
- *   - When a parent directory of the entry whose filetype is the regular
- *     file is changed, check the global datas and write it again if its
- *     values are different from the entry's.
+ * Write /set keyword.
+ * Set most used value of uid,gid,mode and fflags, which are
+ * collected by collect_set_values() function.
  */
 static void
-set_global(struct mtree_writer *mtree, struct archive_entry *entry)
+write_global(struct mtree_writer *mtree)
 {
 	struct archive_string setstr;
 	struct archive_string unsetstr;
 	const char *name;
 	int keys, oldkeys, effkeys;
-	mode_t set_type = 0;
-
-	switch (archive_entry_filetype(entry)) {
-	case AE_IFLNK: case AE_IFSOCK: case AE_IFCHR:
-	case AE_IFBLK: case AE_IFIFO:
-		break;
-	case AE_IFDIR:
-		if (mtree->dironly)
-			set_type = AE_IFDIR;
-		break;
-	case AE_IFREG:
-	default:	/* Handle unknown file types as regular files. */
-		if (!mtree->dironly)
-			set_type = AE_IFREG;
-		break;
-	}
-	if (set_type == 0)
-		return;
-	if (mtree->set.processed &&
-	    !parent_dir_changed(&mtree->set.parent, entry))
-		return;
-	/* At first, save a parent directory of the entry for following
-	 * entries. */
-	if (!mtree->set.processed && set_type == AE_IFREG)
-		parent_dir_changed(&mtree->set.parent, entry);
+	struct attr_counter *ac;
 
 	archive_string_init(&setstr);
 	archive_string_init(&unsetstr);
-	keys = mtree->keys & (F_FLAGS | F_GID | F_GNAME | F_NLINK | F_MODE
-	    | F_TYPE | F_UID | F_UNAME);
+	keys = mtree->keys & SET_KEYS;
 	oldkeys = mtree->set.keys;
 	effkeys = keys;
 	if (mtree->set.processed) {
 		/*
-		 * Check the global datas for whether it needs updating.
+		 * Check if the global data needs updating.
 		 */
 		effkeys &= ~F_TYPE;
-		if ((oldkeys & (F_UNAME | F_UID)) != 0 &&
-		    mtree->set.uid == archive_entry_uid(entry))
-			effkeys &= ~(F_UNAME | F_UID);
-		if ((oldkeys & (F_GNAME | F_GID)) != 0 &&
-		    mtree->set.gid == archive_entry_gid(entry))
-			effkeys &= ~(F_GNAME | F_GID);
-		if ((oldkeys & F_MODE) != 0 &&
-		    mtree->set.mode == (archive_entry_mode(entry) & 07777))
-			effkeys &= ~F_MODE;
+		if (oldkeys & (F_UNAME | F_UID)) {
+			ac = mtree->set.uid_list;
+			do {
+				if (mtree->set.uid == ac->m_entry->uid) {
+					effkeys &= ~(F_UNAME | F_UID);
+					break;
+				}
+				if (ac->next != NULL &&
+				    ac->next->count == ac->count)
+					continue;
+			} while (0);
+		}
+		if (oldkeys & (F_GNAME | F_GID)) {
+			ac = mtree->set.gid_list;
+			do {
+				if (mtree->set.gid == ac->m_entry->gid) {
+					effkeys &= ~(F_GNAME | F_GID);
+					break;
+				}
+				if (ac->next != NULL &&
+				    ac->next->count == ac->count)
+					continue;
+			} while (0);
+		}
+		if (oldkeys & F_MODE) {
+			ac = mtree->set.mode_list;
+			do {
+				if (mtree->set.mode == ac->m_entry->mode) {
+					effkeys &= ~F_MODE;
+					break;
+				}
+				if (ac->next != NULL &&
+				    ac->next->count == ac->count)
+					continue;
+			} while (0);
+		}
 		if ((oldkeys & F_FLAGS) != 0) {
-			unsigned long	fflags_set;
-			unsigned long	fflags_clear;
-
-			archive_entry_fflags(entry, &fflags_set, &fflags_clear);
-			if (fflags_set == mtree->set.fflags_set &&
-			    fflags_clear == mtree->set.fflags_clear)
-				effkeys &= ~F_FLAGS;
+			ac = mtree->set.flags_list;
+			do {
+				if (ac->m_entry->fflags_set ==
+					mtree->set.fflags_set &&
+				    ac->m_entry->fflags_clear ==
+					mtree->set.fflags_clear) {
+					effkeys &= ~F_FLAGS;
+					break;
+				}
+				if (ac->next != NULL &&
+				    ac->next->count == ac->count)
+					continue;
+			} while (0);
 		}
 	}
 	if ((keys & effkeys & F_TYPE) != 0) {
-		mtree->set.type = set_type;
-		if (set_type == AE_IFDIR)
+		if (mtree->dironly) {
 			archive_strcat(&setstr, " type=dir");
-		else
+			mtree->set.type = AE_IFDIR;
+		} else {
 			archive_strcat(&setstr, " type=file");
+			mtree->set.type = AE_IFREG;
+		}
 	}
 	if ((keys & effkeys & F_UNAME) != 0) {
-		if ((name = archive_entry_uname(entry)) != NULL) {
+		name = mtree->set.uid_list->m_entry->uname;
+		if (name != NULL) {
 			archive_strcat(&setstr, " uname=");
 			mtree_quote(&setstr, name);
-		} else if ((oldkeys & F_UNAME) != 0)
-			archive_strcat(&unsetstr, " uname");
-		else
+		} else {
 			keys &= ~F_UNAME;
+			if ((oldkeys & F_UNAME) != 0)
+				archive_strcat(&unsetstr, " uname");
+		}
 	}
 	if ((keys & effkeys & F_UID) != 0) {
-		mtree->set.uid = archive_entry_uid(entry);
+		mtree->set.uid = mtree->set.uid_list->m_entry->uid;
 		archive_string_sprintf(&setstr, " uid=%jd",
 		    (intmax_t)mtree->set.uid);
 	}
 	if ((keys & effkeys & F_GNAME) != 0) {
-		if ((name = archive_entry_gname(entry)) != NULL) {
+		name = mtree->set.gid_list->m_entry->gname;
+		if (name != NULL) {
 			archive_strcat(&setstr, " gname=");
 			mtree_quote(&setstr, name);
-		} else if ((oldkeys & F_GNAME) != 0)
-			archive_strcat(&unsetstr, " gname");
-		else
+		} else {
 			keys &= ~F_GNAME;
+			if ((oldkeys & F_GNAME) != 0)
+				archive_strcat(&unsetstr, " gname");
+		}
 	}
 	if ((keys & effkeys & F_GID) != 0) {
-		mtree->set.gid = archive_entry_gid(entry);
+		mtree->set.gid = mtree->set.gid_list->m_entry->gid;
 		archive_string_sprintf(&setstr, " gid=%jd",
 		    (intmax_t)mtree->set.gid);
 	}
 	if ((keys & effkeys & F_MODE) != 0) {
-		mtree->set.mode = archive_entry_mode(entry) & 07777;
-		archive_string_sprintf(&setstr, " mode=%o", mtree->set.mode);
+		mtree->set.mode = mtree->set.mode_list->m_entry->mode;
+		archive_string_sprintf(&setstr, " mode=%o",
+		    (unsigned int)mtree->set.mode);
 	}
 	if ((keys & effkeys & F_FLAGS) != 0) {
-		if ((name = archive_entry_fflags_text(entry)) != NULL) {
+		name = mtree->set.flags_list->m_entry->fflags_text;
+		if (name != NULL) {
 			archive_strcat(&setstr, " flags=");
 			mtree_quote(&setstr, name);
-			archive_entry_fflags(entry, &mtree->set.fflags_set,
-			    &mtree->set.fflags_clear);
-		} else if ((oldkeys & F_FLAGS) != 0)
-			archive_strcat(&unsetstr, " flags");
-		else
+			mtree->set.fflags_set =
+			    mtree->set.flags_list->m_entry->fflags_set;
+			mtree->set.fflags_clear =
+			    mtree->set.flags_list->m_entry->fflags_clear;
+		} else {
 			keys &= ~F_FLAGS;
+			if ((oldkeys & F_FLAGS) != 0)
+				archive_strcat(&unsetstr, " flags");
+		}
 	}
 	if (unsetstr.length > 0)
 		archive_string_sprintf(&mtree->buf, "/unset%s\n", unsetstr.s);
@@ -491,38 +579,196 @@
 	archive_string_free(&setstr);
 	mtree->set.keys = keys;
 	mtree->set.processed = 1;
-	/* On directory-only mode, it is only once to write /set keyword. */
-	if (mtree->dironly)
-		mtree->set.output = 0;
+
+	free_attr_count(&mtree->set.uid_list);
+	free_attr_count(&mtree->set.gid_list);
+	free_attr_count(&mtree->set.mode_list);
+	free_attr_count(&mtree->set.flags_list);
+}
+
+static struct attr_counter *
+new_attr_count(struct mtree_entry *me, struct attr_counter *prev)
+{
+	struct attr_counter *ac;
+
+	ac = malloc(sizeof(*ac));
+	if (ac != NULL) {
+		ac->prev = prev;
+		ac->next = NULL;
+		ac->count = 1;
+		ac->m_entry = me;
+	}
+	return (ac);
+}
+
+static void
+free_attr_count(struct attr_counter **top)
+{
+	struct attr_counter *ac, *tac;
+
+	if (*top == NULL)
+		return;
+	ac = *top;
+        while (ac != NULL) {
+		tac = ac->next;
+		free(ac);
+		ac = tac;
+	}
+	*top = NULL;
 }
 
 static int
-get_keys(struct mtree_writer *mtree, struct archive_entry *entry)
+inc_attr_count(struct attr_counter **top, struct attr_counter *ac,
+    struct attr_counter *last, struct mtree_entry *me)
+{
+	struct attr_counter *pac;
+
+	if (ac != NULL) {
+		ac->count++;
+		if (*top == ac || ac->prev->count >= ac->count)
+			return (0);
+		for (pac = ac->prev; pac; pac = pac->prev) {
+			if (pac->count >= ac->count)
+				break;
+		}
+		ac->prev->next = ac->next;
+		if (ac->next != NULL)
+			ac->next->prev = ac->prev;
+		if (pac != NULL) {
+			ac->prev = pac;
+			ac->next = pac->next;
+			pac->next = ac;
+			if (ac->next != NULL)
+				ac->next->prev = ac;
+		} else {
+			ac->prev = NULL;
+			ac->next = *top;
+			*top = ac;
+			ac->next->prev = ac;
+		}
+	} else {
+		ac = new_attr_count(me, last);
+		if (ac == NULL)
+			return (-1);
+		last->next = ac;
+	}
+	return (0);
+}
+
+static int
+collect_set_values(struct mtree_writer *mtree, struct mtree_entry *me)
+{
+	int keys = mtree->keys;
+	struct attr_counter *ac, *last;
+
+	if (keys & (F_UNAME | F_UID)) {
+		if (mtree->set.uid_list == NULL) {
+			mtree->set.uid_list = new_attr_count(me, NULL);
+			if (mtree->set.uid_list == NULL)
+				return (-1);
+		} else {
+			last = NULL;
+			for (ac = mtree->set.uid_list; ac; ac = ac->next) {
+				if (ac->m_entry->uid == me->uid)
+					break;
+				last = ac;
+			}
+			if (inc_attr_count(
+			    &mtree->set.uid_list, ac, last, me) < 0)
+				return (-1);
+		}
+	}
+	if (keys & (F_GNAME | F_GID)) {
+		if (mtree->set.gid_list == NULL) {
+			mtree->set.gid_list = new_attr_count(me, NULL);
+			if (mtree->set.gid_list == NULL)
+				return (-1);
+		} else {
+			last = NULL;
+			for (ac = mtree->set.gid_list; ac; ac = ac->next) {
+				if (ac->m_entry->gid == me->gid)
+					break;
+				last = ac;
+			}
+			if (inc_attr_count(
+			    &mtree->set.gid_list, ac, last, me) < 0)
+				return (-1);
+		}
+	}
+	if (keys & F_MODE) {
+		if (mtree->set.mode_list == NULL) {
+			mtree->set.mode_list = new_attr_count(me, NULL);
+			if (mtree->set.mode_list == NULL)
+				return (-1);
+		} else {
+			last = NULL;
+			for (ac = mtree->set.mode_list; ac; ac = ac->next) {
+				if (ac->m_entry->mode == me->mode)
+					break;
+				last = ac;
+			}
+			if (inc_attr_count(
+			    &mtree->set.mode_list, ac, last, me) < 0)
+				return (-1);
+		}
+	}
+	if (keys & F_FLAGS) {
+		if (mtree->set.flags_list == NULL) {
+			mtree->set.flags_list = new_attr_count(me, NULL);
+			if (mtree->set.flags_list == NULL)
+				return (-1);
+		} else {
+			last = NULL;
+			for (ac = mtree->set.flags_list; ac; ac = ac->next) {
+				if (ac->m_entry->fflags_set == me->fflags_set &&
+				    ac->m_entry->fflags_clear == me->fflags_clear)
+					break;
+				last = ac;
+			}
+			if (inc_attr_count(
+			    &mtree->set.flags_list, ac, last, me) < 0)
+				return (-1);
+		}
+	}
+
+	/*
+	 * Save a entry.
+	 */
+	me->next = NULL;
+	*mtree->set.me_last = me;
+	mtree->set.me_last = &me->next;
+	return (0);
+}
+
+static int
+get_keys(struct mtree_writer *mtree, struct mtree_entry *me)
 {
 	int keys;
 
 	keys = mtree->keys;
+
+	/*
+	 * If a keyword has been set by /set, we do not need to
+	 * output it.
+	 */
 	if (mtree->set.keys == 0)
-		return (keys);
+		return (keys);/* /set is not used. */
+
 	if ((mtree->set.keys & (F_GNAME | F_GID)) != 0 &&
-	     mtree->set.gid == archive_entry_gid(entry))
+	     mtree->set.gid == me->gid)
 		keys &= ~(F_GNAME | F_GID);
 	if ((mtree->set.keys & (F_UNAME | F_UID)) != 0 &&
-	     mtree->set.uid == archive_entry_uid(entry))
+	     mtree->set.uid == me->uid)
 		keys &= ~(F_UNAME | F_UID);
 	if (mtree->set.keys & F_FLAGS) {
-		unsigned long set, clear;
-
-		archive_entry_fflags(entry, &set, &clear);
-		if (mtree->set.fflags_set == set &&
-		    mtree->set.fflags_clear == clear)
+		if (mtree->set.fflags_set == me->fflags_set &&
+		    mtree->set.fflags_clear == me->fflags_clear)
 			keys &= ~F_FLAGS;
 	}
-	if ((mtree->set.keys & F_MODE) != 0 &&
-	     mtree->set.mode == (archive_entry_mode(entry) & 07777))
+	if ((mtree->set.keys & F_MODE) != 0 && mtree->set.mode == me->mode)
 		keys &= ~F_MODE;
 
-	switch (archive_entry_filetype(entry)) {
+	switch (me->filetype) {
 	case AE_IFLNK: case AE_IFSOCK: case AE_IFCHR:
 	case AE_IFBLK: case AE_IFIFO:
 		break;
@@ -542,171 +788,145 @@
 	return (keys);
 }
 
+static struct mtree_entry *
+new_mtree_entry(struct archive_entry *entry)
+{
+	struct mtree_entry *me;
+	const char *s;
+
+	me = calloc(1, sizeof(*me));
+	if (me == NULL)
+		return (NULL);
+	me->pathname = strdup(archive_entry_pathname(entry));
+	if ((s = archive_entry_symlink(entry)) != NULL)
+		me->symlink = strdup(s);
+	else
+		me->symlink = NULL;
+	me->nlink = archive_entry_nlink(entry);
+	me->filetype = archive_entry_filetype(entry);
+	me->mode = archive_entry_mode(entry) & 07777;
+	me->uid = archive_entry_uid(entry);
+	me->gid = archive_entry_gid(entry);
+	if ((s = archive_entry_uname(entry)) != NULL)
+		me->uname = strdup(s);
+	else
+		me->uname = NULL;
+	if ((s = archive_entry_gname(entry)) != NULL)
+		me->gname = strdup(s);
+	else
+		me->gname = NULL;
+	if ((s = archive_entry_fflags_text(entry)) != NULL)
+		me->fflags_text = strdup(s);
+	else
+		me->fflags_text = NULL;
+	archive_entry_fflags(entry, &me->fflags_set, &me->fflags_clear);
+	me->mtime = archive_entry_mtime(entry);
+	me->mtime_nsec = archive_entry_mtime_nsec(entry);
+	me->rdevmajor =	archive_entry_rdevmajor(entry);
+	me->rdevminor = archive_entry_rdevminor(entry);
+	me->size = archive_entry_size(entry);
+	me->compute_sum = 0;
+
+	return (me);
+}
+
+static void
+free_mtree_entry(struct mtree_entry *me)
+{
+	free(me->pathname);
+	free(me->symlink);
+	free(me->uname);
+	free(me->gname);
+	free(me->fflags_text);
+	free(me);
+}
+
 static int
 archive_write_mtree_header(struct archive_write *a,
     struct archive_entry *entry)
 {
 	struct mtree_writer *mtree= a->format_data;
-	struct archive_string *str;
-	const char *path;
-
-	mtree->entry = archive_entry_clone(entry);
-	path = archive_entry_pathname(mtree->entry);
 
 	if (mtree->first) {
 		mtree->first = 0;
 		archive_strcat(&mtree->buf, "#mtree\n");
+		if ((mtree->keys & SET_KEYS) == 0)
+			mtree->set.output = 0;/* Disalbed. */
 	}
-	if (mtree->set.output)
-		set_global(mtree, entry);
-
-	archive_string_empty(&mtree->ebuf);
-	str = (mtree->indent)? &mtree->ebuf : &mtree->buf;
-	if (!mtree->dironly || archive_entry_filetype(entry) == AE_IFDIR)
-		mtree_quote(str, path);
 
 	mtree->entry_bytes_remaining = archive_entry_size(entry);
-	if ((mtree->keys & F_CKSUM) != 0 &&
-	    archive_entry_filetype(entry) == AE_IFREG) {
-		mtree->compute_sum |= F_CKSUM;
-		mtree->crc = 0;
-		mtree->crc_len = 0;
-	} else
-		mtree->compute_sum &= ~F_CKSUM;
-#ifdef ARCHIVE_HAS_MD5
-	if ((mtree->keys & F_MD5) != 0 &&
-	    archive_entry_filetype(entry) == AE_IFREG) {
-		mtree->compute_sum |= F_MD5;
-		archive_md5_init(&mtree->md5ctx);
-	} else
-		mtree->compute_sum &= ~F_MD5;
-#endif
-#ifdef ARCHIVE_HAS_RMD160
-	if ((mtree->keys & F_RMD160) != 0 &&
-	    archive_entry_filetype(entry) == AE_IFREG) {
-		mtree->compute_sum |= F_RMD160;
-		archive_rmd160_init(&mtree->rmd160ctx);
-	} else
-		mtree->compute_sum &= ~F_RMD160;
-#endif
-#ifdef ARCHIVE_HAS_SHA1
-	if ((mtree->keys & F_SHA1) != 0 &&
-	    archive_entry_filetype(entry) == AE_IFREG) {
-		mtree->compute_sum |= F_SHA1;
-		archive_sha1_init(&mtree->sha1ctx);
-	} else
-		mtree->compute_sum &= ~F_SHA1;
-#endif
-#ifdef ARCHIVE_HAS_SHA256
-	if ((mtree->keys & F_SHA256) != 0 &&
-	    archive_entry_filetype(entry) == AE_IFREG) {
-		mtree->compute_sum |= F_SHA256;
-		archive_sha256_init(&mtree->sha256ctx);
-	} else
-		mtree->compute_sum &= ~F_SHA256;
-#endif
-#ifdef ARCHIVE_HAS_SHA384
-	if ((mtree->keys & F_SHA384) != 0 &&
-	    archive_entry_filetype(entry) == AE_IFREG) {
-		mtree->compute_sum |= F_SHA384;
-		archive_sha384_init(&mtree->sha384ctx);
-	} else
-		mtree->compute_sum &= ~F_SHA384;
-#endif
-#ifdef ARCHIVE_HAS_SHA512
-	if ((mtree->keys & F_SHA512) != 0 &&
-	    archive_entry_filetype(entry) == AE_IFREG) {
-		mtree->compute_sum |= F_SHA512;
-		archive_sha512_init(&mtree->sha512ctx);
-	} else
-		mtree->compute_sum &= ~F_SHA512;
-#endif
+	if (mtree->dironly && archive_entry_filetype(entry) != AE_IFDIR)
+		return (ARCHIVE_OK);
+
+	mtree->mtree_entry = new_mtree_entry(entry);
+	if (mtree->mtree_entry == NULL) {
+		archive_set_error(&a->archive, ENOMEM,
+		    "Can't allocate mtree entry");
+		return (ARCHIVE_FATAL);
+	}
+
+	mtree->compute_sum = 0;
+
+	/* If current file is not a regular file, we do not have to
+	 * compute the sum of its content. */ 
+	if (archive_entry_filetype(entry) != AE_IFREG)
+		return (ARCHIVE_OK);
+		
+	/* Initialize a bunch of sum check context. */
+	sum_init(mtree);
 
 	return (ARCHIVE_OK);
 }
 
-#if defined(ARCHIVE_HAS_MD5) || defined(ARCHIVE_HAS_RMD160) || \
-    defined(ARCHIVE_HAS_SHA1) || defined(ARCHIVE_HAS_SHA256) || \
-    defined(ARCHIVE_HAS_SHA384) || defined(ARCHIVE_HAS_SHA512)
-static void
-strappend_bin(struct archive_string *s, const unsigned char *bin, int n)
-{
-	static const char hex[] = "0123456789abcdef";
-	int i;
-
-	for (i = 0; i < n; i++) {
-		archive_strappend_char(s, hex[bin[i] >> 4]);
-		archive_strappend_char(s, hex[bin[i] & 0x0f]);
-	}
-}
-#endif
-
 static int
-archive_write_mtree_finish_entry(struct archive_write *a)
+write_entry(struct archive_write *a, struct mtree_entry *me)
 {
 	struct mtree_writer *mtree = a->format_data;
-	struct archive_entry *entry;
 	struct archive_string *str;
-	const char *name;
 	int keys, ret;
 
-	entry = mtree->entry;
-	if (entry == NULL) {
-		archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER,
-		    "Finished entry without being open first.");
-		return (ARCHIVE_FATAL);
+	archive_string_empty(&mtree->ebuf);
+	str = (mtree->indent)? &mtree->ebuf : &mtree->buf;
+	mtree_quote(str, me->pathname);
+	keys = get_keys(mtree, me);
+	if ((keys & F_NLINK) != 0 &&
+	    me->nlink != 1 && me->filetype != AE_IFDIR)
+		archive_string_sprintf(str, " nlink=%u", me->nlink);
+
+	if ((keys & F_GNAME) != 0 && me->gname != NULL) {
+		archive_strcat(str, " gname=");
+		mtree_quote(str, me->gname);
 	}
-	mtree->entry = NULL;
-
-	if (mtree->dironly && archive_entry_filetype(entry) != AE_IFDIR) {
-		archive_entry_free(entry);
-		return (ARCHIVE_OK);
+	if ((keys & F_UNAME) != 0 && me->uname != NULL) {
+		archive_strcat(str, " uname=");
+		mtree_quote(str, me->uname);
 	}
-
-	str = (mtree->indent)? &mtree->ebuf : &mtree->buf;
-	keys = get_keys(mtree, entry);
-	if ((keys & F_NLINK) != 0 &&
-	    archive_entry_nlink(entry) != 1 &&
-	    archive_entry_filetype(entry) != AE_IFDIR)
-		archive_string_sprintf(str,
-		    " nlink=%u", archive_entry_nlink(entry));
-
-	if ((keys & F_GNAME) != 0 &&
-	    (name = archive_entry_gname(entry)) != NULL) {
-		archive_strcat(str, " gname=");
-		mtree_quote(str, name);
-	}
-	if ((keys & F_UNAME) != 0 &&
-	    (name = archive_entry_uname(entry)) != NULL) {
-		archive_strcat(str, " uname=");
-		mtree_quote(str, name);
-	}
-	if ((keys & F_FLAGS) != 0 &&
-	    (name = archive_entry_fflags_text(entry)) != NULL) {
-		archive_strcat(str, " flags=");
-		mtree_quote(str, name);
+	if ((keys & F_FLAGS) != 0) {
+		if (me->fflags_text != NULL) {
+			archive_strcat(str, " flags=");
+			mtree_quote(str, me->fflags_text);
+		} else if (mtree->set.processed &&
+		    (mtree->set.keys & F_FLAGS) != 0)
+			/* Overwrite the global parameter. */
+			archive_strcat(str, " flags=none");
 	}
 	if ((keys & F_TIME) != 0)
 		archive_string_sprintf(str, " time=%jd.%jd",
-		    (intmax_t)archive_entry_mtime(entry),
-		    (intmax_t)archive_entry_mtime_nsec(entry));
+		    (intmax_t)me->mtime, (intmax_t)me->mtime_nsec);
 	if ((keys & F_MODE) != 0)
-		archive_string_sprintf(str, " mode=%o",
-		    archive_entry_mode(entry) & 07777);
+		archive_string_sprintf(str, " mode=%o", (unsigned int)me->mode);
 	if ((keys & F_GID) != 0)
-		archive_string_sprintf(str, " gid=%jd",
-		    (intmax_t)archive_entry_gid(entry));
+		archive_string_sprintf(str, " gid=%jd", (intmax_t)me->gid);
 	if ((keys & F_UID) != 0)
-		archive_string_sprintf(str, " uid=%jd",
-		    (intmax_t)archive_entry_uid(entry));
+		archive_string_sprintf(str, " uid=%jd", (intmax_t)me->uid);
 
-	switch (archive_entry_filetype(entry)) {
+	switch (me->filetype) {
 	case AE_IFLNK:
 		if ((keys & F_TYPE) != 0)
 			archive_strcat(str, " type=link");
 		if ((keys & F_SLINK) != 0) {
 			archive_strcat(str, " link=");
-			mtree_quote(str, archive_entry_symlink(entry));
+			mtree_quote(str, me->symlink);
 		}
 		break;
 	case AE_IFSOCK:
@@ -718,9 +938,9 @@
 			archive_strcat(str, " type=char");
 		if ((keys & F_DEV) != 0) {
 			archive_string_sprintf(str,
-			    " device=native,%d,%d",
-			    archive_entry_rdevmajor(entry),
-			    archive_entry_rdevminor(entry));
+			    " device=native,%ju,%ju",
+			    (uintmax_t)me->rdevmajor,
+			    (uintmax_t)me->rdevminor);
 		}
 		break;
 	case AE_IFBLK:
@@ -728,9 +948,9 @@
 			archive_strcat(str, " type=block");
 		if ((keys & F_DEV) != 0) {
 			archive_string_sprintf(str,
-			    " device=native,%d,%d",
-			    archive_entry_rdevmajor(entry),
-			    archive_entry_rdevminor(entry));
+			    " device=native,%ju,%ju",
+			    (uintmax_t)me->rdevmajor,
+			    (uintmax_t)me->rdevminor);
 		}
 		break;
 	case AE_IFDIR:
@@ -747,96 +967,110 @@
 			archive_strcat(str, " type=file");
 		if ((keys & F_SIZE) != 0)
 			archive_string_sprintf(str, " size=%jd",
-			    (intmax_t)archive_entry_size(entry));
+			    (intmax_t)me->size);
 		break;
 	}
 
-	if (mtree->compute_sum & F_CKSUM) {
-		uint64_t len;
-		/* Include the length of the file. */
-		for (len = mtree->crc_len; len != 0; len >>= 8)
-			COMPUTE_CRC(mtree->crc, len & 0xff);
-		mtree->crc = ~mtree->crc;
-		archive_string_sprintf(str, " cksum=%ju",
-		    (uintmax_t)mtree->crc);
-	}
-#ifdef ARCHIVE_HAS_MD5
-	if (mtree->compute_sum & F_MD5) {
-		unsigned char buf[16];
+	/* Write a bunch of sum. */
+	if (me->filetype == AE_IFREG)
+		sum_write(str, me);
 
-		archive_md5_final(&mtree->md5ctx, buf);
-		archive_strcat(str, " md5digest=");
-		strappend_bin(str, buf, sizeof(buf));
-	}
-#endif
-#ifdef ARCHIVE_HAS_RMD160
-	if (mtree->compute_sum & F_RMD160) {
-		unsigned char buf[20];
-
-		archive_rmd160_final(&mtree->rmd160ctx, buf);
-		archive_strcat(str, " rmd160digest=");
-		strappend_bin(str, buf, sizeof(buf));
-	}
-#endif
-#ifdef ARCHIVE_HAS_SHA1
-	if (mtree->compute_sum & F_SHA1) {
-		unsigned char buf[20];
-
-		archive_sha1_final(&mtree->sha1ctx, buf);
-		archive_strcat(str, " sha1digest=");
-		strappend_bin(str, buf, sizeof(buf));
-	}
-#endif
-#ifdef ARCHIVE_HAS_SHA256
-	if (mtree->compute_sum & F_SHA256) {
-		unsigned char buf[32];
-
-		archive_sha256_final(&mtree->sha256ctx, buf);
-		archive_strcat(str, " sha256digest=");
-		strappend_bin(str, buf, sizeof(buf));
-	}
-#endif
-#ifdef ARCHIVE_HAS_SHA384
-	if (mtree->compute_sum & F_SHA384) {
-		unsigned char buf[48];
-
-		archive_sha384_final(&mtree->sha384ctx, buf);
-		archive_strcat(str, " sha384digest=");
-		strappend_bin(str, buf, sizeof(buf));
-	}
-#endif
-#ifdef ARCHIVE_HAS_SHA512
-	if (mtree->compute_sum & F_SHA512) {
-		unsigned char buf[64];
-
-		archive_sha512_final(&mtree->sha512ctx, buf);
-		archive_strcat(str, " sha512digest=");
-		strappend_bin(str, buf, sizeof(buf));
-	}
-#endif
 	archive_strcat(str, "\n");
 	if (mtree->indent)
 		mtree_indent(mtree);
 
-	archive_entry_free(entry);
-
 	if (mtree->buf.length > 32768) {
-		ret = (a->compressor.write)(a, mtree->buf.s, mtree->buf.length);
+		ret = __archive_write_output(a, mtree->buf.s, mtree->buf.length);
 		archive_string_empty(&mtree->buf);
 	} else
 		ret = ARCHIVE_OK;
+	return (ret);
+}
 
+/*
+ * Write mtree entries saved at collect_set_values() function.
+ */
+static int
+write_mtree_entries(struct archive_write *a)
+{
+	struct mtree_writer *mtree = a->format_data;
+	struct mtree_entry *me, *tme;
+	int ret;
+
+	for (me = mtree->set.me_first; me; me = me->next) {
+		ret = write_entry(a, me);
+		if (ret != ARCHIVE_OK)
+			return (ARCHIVE_FATAL);
+	}
+
+	me = mtree->set.me_first;
+	while (me != NULL) {
+		tme = me->next;
+		free_mtree_entry(me);
+		me = tme;
+	}
+	mtree->set.me_first = NULL;
+	mtree->set.me_last = &mtree->set.me_first;
+	return (ARCHIVE_OK);
+}
+
+static int
+archive_write_mtree_finish_entry(struct archive_write *a)
+{
+	struct mtree_writer *mtree = a->format_data;
+	struct mtree_entry *me;
+	int ret;
+
+	if ((me = mtree->mtree_entry) == NULL)
+		return (ARCHIVE_OK);
+	mtree->mtree_entry = NULL;
+
+	if (me->filetype == AE_IFREG)
+		sum_final(mtree, me);
+
+	if (mtree->set.output) {
+		if (!mtree->dironly) {
+			if (archive_strlen(&mtree->set.parent) == 0)
+				parent_dir_changed(&mtree->set.parent, me);
+			if (parent_dir_changed(&mtree->set.parent, me)) {
+				/* Write /set keyword */
+				write_global(mtree);
+				/* Write entries saved by
+				 * collect_set_values() function. */
+				ret = write_mtree_entries(a);
+				if (ret != ARCHIVE_OK)
+					return (ARCHIVE_FATAL);
+			}
+		}
+		/* Tabulate uid,gid,mode and fflags of a entry
+		 * in order to be used for /set. and, at this time
+		 * we do not write a entry.  */
+		collect_set_values(mtree, me);
+		return (ARCHIVE_OK);
+	} else {
+		/* Write the current entry and free it. */
+		ret = write_entry(a, me);
+		free_mtree_entry(me);
+	}
 	return (ret == ARCHIVE_OK ? ret : ARCHIVE_FATAL);
 }
 
 static int
-archive_write_mtree_finish(struct archive_write *a)
+archive_write_mtree_close(struct archive_write *a)
 {
 	struct mtree_writer *mtree= a->format_data;
+	int ret;
+
+	if (mtree->set.output && mtree->set.me_first != NULL) {
+		write_global(mtree);
+		ret = write_mtree_entries(a);
+		if (ret != ARCHIVE_OK)
+			return (ARCHIVE_FATAL);
+	}
 
 	archive_write_set_bytes_in_last_block(&a->archive, 1);
 
-	return (a->compressor.write)(a, mtree->buf.s, mtree->buf.length);
+	return __archive_write_output(a, mtree->buf.s, mtree->buf.length);
 }
 
 static ssize_t
@@ -846,59 +1080,41 @@
 
 	if (n > mtree->entry_bytes_remaining)
 		n = mtree->entry_bytes_remaining;
-	if (mtree->dironly)
-		/* We don't need compute a regular file sum */
+	mtree->entry_bytes_remaining -= n;
+
+	/* We don't need to compute a regular file sum */
+	if (mtree->mtree_entry == NULL)
 		return (n);
-	if (mtree->compute_sum & F_CKSUM) {
-		/*
-		 * Compute a POSIX 1003.2 checksum
-		 */
-		const unsigned char *p;
-		size_t nn;
 
-		for (nn = n, p = buff; nn--; ++p)
-			COMPUTE_CRC(mtree->crc, *p);
-		mtree->crc_len += n;
-	}
-#ifdef ARCHIVE_HAS_MD5
-	if (mtree->compute_sum & F_MD5)
-		archive_md5_update(&mtree->md5ctx, buff, n);
-#endif
-#ifdef ARCHIVE_HAS_RMD160
-	if (mtree->compute_sum & F_RMD160)
-		archive_rmd160_update(&mtree->rmd160ctx, buff, n);
-#endif
-#ifdef ARCHIVE_HAS_SHA1
-	if (mtree->compute_sum & F_SHA1)
-		archive_sha1_update(&mtree->sha1ctx, buff, n);
-#endif
-#ifdef ARCHIVE_HAS_SHA256
-	if (mtree->compute_sum & F_SHA256)
-		archive_sha256_update(&mtree->sha256ctx, buff, n);
-#endif
-#ifdef ARCHIVE_HAS_SHA384
-	if (mtree->compute_sum & F_SHA384)
-		archive_sha384_update(&mtree->sha384ctx, buff, n);
-#endif
-#ifdef ARCHIVE_HAS_SHA512
-	if (mtree->compute_sum & F_SHA512)
-		archive_sha512_update(&mtree->sha512ctx, buff, n);
-#endif
+	if (mtree->mtree_entry->filetype == AE_IFREG)
+		sum_update(mtree, buff, n);
+
 	return (n);
 }
 
 static int
-archive_write_mtree_destroy(struct archive_write *a)
+archive_write_mtree_free(struct archive_write *a)
 {
 	struct mtree_writer *mtree= a->format_data;
+	struct mtree_entry *me, *tme;
 
 	if (mtree == NULL)
 		return (ARCHIVE_OK);
 
-	archive_entry_free(mtree->entry);
+	/* Make sure we dot not leave any entries. */
+	me = mtree->set.me_first;
+	while (me != NULL) {
+		tme = me->next;
+		free_mtree_entry(me);
+		me = tme;
+	}
 	archive_string_free(&mtree->ebuf);
 	archive_string_free(&mtree->buf);
 	archive_string_free(&mtree->set.parent);
+	free_attr_count(&mtree->set.uid_list);
+	free_attr_count(&mtree->set.gid_list);
+	free_attr_count(&mtree->set.mode_list);
+	free_attr_count(&mtree->set.flags_list);
 	free(mtree);
 	a->format_data = NULL;
 	return (ARCHIVE_OK);
@@ -1006,6 +1222,9 @@
 		return (ARCHIVE_OK);
 	}
 
+	/* Note: The "warn" return is just to inform the options
+	 * supervisor that we didn't handle it.  It will generate
+	 * a suitable error if no one used this option. */
 	return (ARCHIVE_WARN);
 }
 
@@ -1015,16 +1234,19 @@
 	struct archive_write *a = (struct archive_write *)_a;
 	struct mtree_writer *mtree;
 
-	if (a->format_destroy != NULL)
-		(a->format_destroy)(a);
+	archive_check_magic(_a, ARCHIVE_WRITE_MAGIC,
+	    ARCHIVE_STATE_NEW, "archive_write_set_format_mtree");
 
-	if ((mtree = malloc(sizeof(*mtree))) == NULL) {
+	if (a->format_free != NULL)
+		(a->format_free)(a);
+
+	if ((mtree = calloc(1, sizeof(*mtree))) == NULL) {
 		archive_set_error(&a->archive, ENOMEM,
 		    "Can't allocate mtree data");
 		return (ARCHIVE_FATAL);
 	}
 
-	mtree->entry = NULL;
+	mtree->mtree_entry = NULL;
 	mtree->first = 1;
 	memset(&(mtree->set), 0, sizeof(mtree->set));
 	archive_string_init(&mtree->set.parent);
@@ -1033,14 +1255,14 @@
 	mtree->indent = 0;
 	archive_string_init(&mtree->ebuf);
 	archive_string_init(&mtree->buf);
+	mtree->set.me_first = NULL;
+	mtree->set.me_last = &mtree->set.me_first;
 	a->format_data = mtree;
-	a->format_destroy = archive_write_mtree_destroy;
-
-	a->pad_uncompressed = 0;
+	a->format_free = archive_write_mtree_free;
 	a->format_name = "mtree";
 	a->format_options = archive_write_mtree_options;
 	a->format_write_header = archive_write_mtree_header;
-	a->format_finish = archive_write_mtree_finish;
+	a->format_close = archive_write_mtree_close;
 	a->format_write_data = archive_write_mtree_data;
 	a->format_finish_entry = archive_write_mtree_finish_entry;
 	a->archive.archive_format = ARCHIVE_FORMAT_MTREE;
@@ -1048,3 +1270,202 @@
 
 	return (ARCHIVE_OK);
 }
+
+static void
+sum_init(struct mtree_writer *mtree)
+{
+	if (mtree->keys & F_CKSUM) {
+		mtree->compute_sum |= F_CKSUM;
+		mtree->crc = 0;
+		mtree->crc_len = 0;
+	}
+#ifdef ARCHIVE_HAS_MD5
+	if (mtree->keys & F_MD5) {
+		if (archive_md5_init(&mtree->md5ctx) == ARCHIVE_OK)
+			mtree->compute_sum |= F_MD5;
+		else
+			mtree->keys &= ~F_MD5;/* Not supported. */
+	}
+#endif
+#ifdef ARCHIVE_HAS_RMD160
+	if (mtree->keys & F_RMD160) {
+		if (archive_rmd160_init(&mtree->rmd160ctx) == ARCHIVE_OK)
+			mtree->compute_sum |= F_RMD160;
+		else
+			mtree->keys &= ~F_RMD160;/* Not supported. */
+	}
+#endif
+#ifdef ARCHIVE_HAS_SHA1
+	if (mtree->keys & F_SHA1) {
+		if (archive_sha1_init(&mtree->sha1ctx) == ARCHIVE_OK)
+			mtree->compute_sum |= F_SHA1;
+		else
+			mtree->keys &= ~F_SHA1;/* Not supported. */
+	}
+#endif
+#ifdef ARCHIVE_HAS_SHA256
+	if (mtree->keys & F_SHA256) {
+		if (archive_sha256_init(&mtree->sha256ctx) == ARCHIVE_OK)
+			mtree->compute_sum |= F_SHA256;
+		else
+			mtree->keys &= ~F_SHA256;/* Not supported. */
+	}
+#endif
+#ifdef ARCHIVE_HAS_SHA384
+	if (mtree->keys & F_SHA384) {
+		if (archive_sha384_init(&mtree->sha384ctx) == ARCHIVE_OK)
+			mtree->compute_sum |= F_SHA384;
+		else
+			mtree->keys &= ~F_SHA384;/* Not supported. */
+	}
+#endif
+#ifdef ARCHIVE_HAS_SHA512
+	if (mtree->keys & F_SHA512) {
+		if (archive_sha512_init(&mtree->sha512ctx) == ARCHIVE_OK)
+			mtree->compute_sum |= F_SHA512;
+		else
+			mtree->keys &= ~F_SHA512;/* Not supported. */
+	}
+#endif
+}
+
+static void
+sum_update(struct mtree_writer *mtree, const void *buff, size_t n)
+{
+	if (mtree->compute_sum & F_CKSUM) {
+		/*
+		 * Compute a POSIX 1003.2 checksum
+		 */
+		const unsigned char *p;
+		size_t nn;
+
+		for (nn = n, p = buff; nn--; ++p)
+			COMPUTE_CRC(mtree->crc, *p);
+		mtree->crc_len += n;
+	}
+#ifdef ARCHIVE_HAS_MD5
+	if (mtree->compute_sum & F_MD5)
+		archive_md5_update(&mtree->md5ctx, buff, n);
+#endif
+#ifdef ARCHIVE_HAS_RMD160
+	if (mtree->compute_sum & F_RMD160)
+		archive_rmd160_update(&mtree->rmd160ctx, buff, n);
+#endif
+#ifdef ARCHIVE_HAS_SHA1
+	if (mtree->compute_sum & F_SHA1)
+		archive_sha1_update(&mtree->sha1ctx, buff, n);
+#endif
+#ifdef ARCHIVE_HAS_SHA256
+	if (mtree->compute_sum & F_SHA256)
+		archive_sha256_update(&mtree->sha256ctx, buff, n);
+#endif
+#ifdef ARCHIVE_HAS_SHA384
+	if (mtree->compute_sum & F_SHA384)
+		archive_sha384_update(&mtree->sha384ctx, buff, n);
+#endif
+#ifdef ARCHIVE_HAS_SHA512
+	if (mtree->compute_sum & F_SHA512)
+		archive_sha512_update(&mtree->sha512ctx, buff, n);
+#endif
+}
+
+static void
+sum_final(struct mtree_writer *mtree, struct mtree_entry *me)
+{
+
+	if (mtree->compute_sum & F_CKSUM) {
+		uint64_t len;
+		/* Include the length of the file. */
+		for (len = mtree->crc_len; len != 0; len >>= 8)
+			COMPUTE_CRC(mtree->crc, len & 0xff);
+		me->crc = ~mtree->crc;
+	}
+#ifdef ARCHIVE_HAS_MD5
+	if (mtree->compute_sum & F_MD5)
+		archive_md5_final(&mtree->md5ctx, me->buf_md5);
+#endif
+#ifdef ARCHIVE_HAS_RMD160
+	if (mtree->compute_sum & F_RMD160)
+		archive_rmd160_final(&mtree->rmd160ctx, me->buf_rmd160);
+#endif
+#ifdef ARCHIVE_HAS_SHA1
+	if (mtree->compute_sum & F_SHA1)
+		archive_sha1_final(&mtree->sha1ctx, me->buf_sha1);
+#endif
+#ifdef ARCHIVE_HAS_SHA256
+	if (mtree->compute_sum & F_SHA256)
+		archive_sha256_final(&mtree->sha256ctx, me->buf_sha256);
+#endif
+#ifdef ARCHIVE_HAS_SHA384
+	if (mtree->compute_sum & F_SHA384)
+		archive_sha384_final(&mtree->sha384ctx, me->buf_sha384);
+#endif
+#ifdef ARCHIVE_HAS_SHA512
+	if (mtree->compute_sum & F_SHA512)
+		archive_sha512_final(&mtree->sha512ctx, me->buf_sha512);
+#endif
+	/* Save what types of sum are computed. */
+	me->compute_sum = mtree->compute_sum;
+}
+
+#if defined(ARCHIVE_HAS_MD5) || defined(ARCHIVE_HAS_RMD160) || \
+    defined(ARCHIVE_HAS_SHA1) || defined(ARCHIVE_HAS_SHA256) || \
+    defined(ARCHIVE_HAS_SHA384) || defined(ARCHIVE_HAS_SHA512)
+static void
+strappend_bin(struct archive_string *s, const unsigned char *bin, int n)
+{
+	static const char hex[] = "0123456789abcdef";
+	int i;
+
+	for (i = 0; i < n; i++) {
+		archive_strappend_char(s, hex[bin[i] >> 4]);
+		archive_strappend_char(s, hex[bin[i] & 0x0f]);
+	}
+}
+#endif
+
+static void
+sum_write(struct archive_string *str, struct mtree_entry *me)
+{
+
+	if (me->compute_sum & F_CKSUM) {
+		archive_string_sprintf(str, " cksum=%ju",
+		    (uintmax_t)me->crc);
+	}
+#ifdef ARCHIVE_HAS_MD5
+	if (me->compute_sum & F_MD5) {
+		archive_strcat(str, " md5digest=");
+		strappend_bin(str, me->buf_md5, sizeof(me->buf_md5));
+	}
+#endif
+#ifdef ARCHIVE_HAS_RMD160
+	if (me->compute_sum & F_RMD160) {
+		archive_strcat(str, " rmd160digest=");
+		strappend_bin(str, me->buf_rmd160, sizeof(me->buf_rmd160));
+	}
+#endif
+#ifdef ARCHIVE_HAS_SHA1
+	if (me->compute_sum & F_SHA1) {
+		archive_strcat(str, " sha1digest=");
+		strappend_bin(str, me->buf_sha1, sizeof(me->buf_sha1));
+	}
+#endif
+#ifdef ARCHIVE_HAS_SHA256
+	if (me->compute_sum & F_SHA256) {
+		archive_strcat(str, " sha256digest=");
+		strappend_bin(str, me->buf_sha256, sizeof(me->buf_sha256));
+	}
+#endif
+#ifdef ARCHIVE_HAS_SHA384
+	if (me->compute_sum & F_SHA384) {
+		archive_strcat(str, " sha384digest=");
+		strappend_bin(str, me->buf_sha384, sizeof(me->buf_sha384));
+	}
+#endif
+#ifdef ARCHIVE_HAS_SHA512
+	if (me->compute_sum & F_SHA512) {
+		archive_strcat(str, " sha512digest=");
+		strappend_bin(str, me->buf_sha512, sizeof(me->buf_sha512));
+	}
+#endif
+}
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_write_set_format_pax.c
--- a/head/contrib/libarchive/libarchive/archive_write_set_format_pax.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_write_set_format_pax.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,6 @@
 /*-
  * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2010-2012 Michihiro NAKAJIMA
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -24,7 +25,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write_set_format_pax.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write_set_format_pax.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
@@ -38,13 +39,28 @@
 
 #include "archive.h"
 #include "archive_entry.h"
+#include "archive_entry_locale.h"
 #include "archive_private.h"
 #include "archive_write_private.h"
 
+struct sparse_block {
+	struct sparse_block	*next;
+	int		is_hole;
+	uint64_t	offset;
+	uint64_t	remaining;
+};
+
 struct pax {
 	uint64_t	entry_bytes_remaining;
 	uint64_t	entry_padding;
+	struct archive_string	l_url_encoded_name;
 	struct archive_string	pax_header;
+	struct archive_string	sparse_map;
+	size_t			sparse_map_padding;
+	struct sparse_block	*sparse_list;
+	struct sparse_block	*sparse_tail;
+	struct archive_string_conv *sconv_utf8;
+	int			 opt_binary;
 };
 
 static void		 add_pax_attr(struct archive_string *, const char *key,
@@ -54,23 +70,25 @@
 static void		 add_pax_attr_time(struct archive_string *,
 			     const char *key, int64_t sec,
 			     unsigned long nanos);
-static void		 add_pax_attr_w(struct archive_string *,
-			     const char *key, const wchar_t *wvalue);
 static ssize_t		 archive_write_pax_data(struct archive_write *,
 			     const void *, size_t);
-static int		 archive_write_pax_finish(struct archive_write *);
-static int		 archive_write_pax_destroy(struct archive_write *);
+static int		 archive_write_pax_close(struct archive_write *);
+static int		 archive_write_pax_free(struct archive_write *);
 static int		 archive_write_pax_finish_entry(struct archive_write *);
 static int		 archive_write_pax_header(struct archive_write *,
 			     struct archive_entry *);
+static int		 archive_write_pax_options(struct archive_write *,
+			     const char *, const char *);
 static char		*base64_encode(const char *src, size_t len);
+static char		*build_gnu_sparse_name(char *dest, const char *src);
 static char		*build_pax_attribute_name(char *dest, const char *src);
 static char		*build_ustar_entry_name(char *dest, const char *src,
 			     size_t src_length, const char *insert);
 static char		*format_int(char *dest, int64_t);
-static int		 has_non_ASCII(const wchar_t *);
+static int		 has_non_ASCII(const char *);
+static void		 sparse_list_clear(struct pax *);
+static int		 sparse_list_add(struct pax *, int64_t, int64_t);
 static char		*url_encode(const char *in);
-static int		 write_nulls(struct archive_write *, size_t);
 
 /*
  * Set output format to 'restricted pax' format.
@@ -84,6 +102,10 @@
 {
 	struct archive_write *a = (struct archive_write *)_a;
 	int r;
+
+	archive_check_magic(_a, ARCHIVE_WRITE_MAGIC,
+	    ARCHIVE_STATE_NEW, "archive_write_set_format_pax_restricted");
+
 	r = archive_write_set_format_pax(&a->archive);
 	a->archive.archive_format = ARCHIVE_FORMAT_TAR_PAX_RESTRICTED;
 	a->archive.archive_format_name = "restricted POSIX pax interchange";
@@ -99,29 +121,81 @@
 	struct archive_write *a = (struct archive_write *)_a;
 	struct pax *pax;
 
-	if (a->format_destroy != NULL)
-		(a->format_destroy)(a);
+	archive_check_magic(_a, ARCHIVE_WRITE_MAGIC,
+	    ARCHIVE_STATE_NEW, "archive_write_set_format_pax");
+
+	if (a->format_free != NULL)
+		(a->format_free)(a);
 
 	pax = (struct pax *)malloc(sizeof(*pax));
 	if (pax == NULL) {
-		archive_set_error(&a->archive, ENOMEM, "Can't allocate pax data");
+		archive_set_error(&a->archive, ENOMEM,
+		    "Can't allocate pax data");
 		return (ARCHIVE_FATAL);
 	}
 	memset(pax, 0, sizeof(*pax));
 	a->format_data = pax;
-
-	a->pad_uncompressed = 1;
 	a->format_name = "pax";
+	a->format_options = archive_write_pax_options;
 	a->format_write_header = archive_write_pax_header;
 	a->format_write_data = archive_write_pax_data;
-	a->format_finish = archive_write_pax_finish;
-	a->format_destroy = archive_write_pax_destroy;
+	a->format_close = archive_write_pax_close;
+	a->format_free = archive_write_pax_free;
 	a->format_finish_entry = archive_write_pax_finish_entry;
 	a->archive.archive_format = ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE;
 	a->archive.archive_format_name = "POSIX pax interchange";
 	return (ARCHIVE_OK);
 }
 
+static int
+archive_write_pax_options(struct archive_write *a, const char *key,
+    const char *val)
+{
+	struct pax *pax = (struct pax *)a->format_data;
+	int ret = ARCHIVE_FAILED;
+
+	if (strcmp(key, "hdrcharset")  == 0) {
+		/*
+		 * The character-set we can use are defined in
+		 * IEEE Std 1003.1-2001
+		 */
+		if (val == NULL || val[0] == 0)
+			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+			    "pax: hdrcharset option needs a character-set name");
+		else if (strcmp(val, "BINARY") == 0 ||
+		    strcmp(val, "binary") == 0) {
+			/*
+			 * Specify binary mode. We will not convert
+			 * filenames, uname and gname to any charsets.
+			 */
+			pax->opt_binary = 1;
+			ret = ARCHIVE_OK;
+		} else if (strcmp(val, "UTF-8") == 0) {
+			/*
+			 * Specify UTF-8 character-set to be used for
+			 * filenames. This is almost the test that
+			 * running platform supports the string conversion.
+			 * Especially libarchive_test needs this trick for
+			 * its test.
+			 */
+			pax->sconv_utf8 = archive_string_conversion_to_charset(
+			    &(a->archive), "UTF-8", 0);
+			if (pax->sconv_utf8 == NULL)
+				ret = ARCHIVE_FATAL;
+			else
+				ret = ARCHIVE_OK;
+		} else
+			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+			    "pax: invalid charset name");
+		return (ret);
+	}
+
+	/* Note: The "warn" return is just to inform the options
+	 * supervisor that we didn't handle it.  It will generate
+	 * a suitable error if no one used this option. */
+	return (ARCHIVE_WARN);
+}
+
 /*
  * Note: This code assumes that 'nanos' has the same sign as 'sec',
  * which implies that sec=-1, nanos=200000000 represents -1.2 seconds
@@ -168,18 +242,17 @@
 static char *
 format_int(char *t, int64_t i)
 {
-	int sign;
+	uint64_t ui;
 
-	if (i < 0) {
-		sign = -1;
-		i = -i;
-	} else
-		sign = 1;
+	if (i < 0) 
+		ui = (i == INT64_MIN) ? (uint64_t)(INT64_MAX) + 1 : (uint64_t)(-i);
+	else
+		ui = i;
 
 	do {
-		*--t = "0123456789"[i % 10];
-	} while (i /= 10);
-	if (sign < 0)
+		*--t = "0123456789"[ui % 10];
+	} while (ui /= 10);
+	if (i < 0)
 		*--t = '-';
 	return (t);
 }
@@ -193,106 +266,6 @@
 	add_pax_attr(as, key, format_int(tmp + sizeof(tmp) - 1, value));
 }
 
-static char *
-utf8_encode(const wchar_t *wval)
-{
-	int utf8len;
-	const wchar_t *wp;
-	unsigned long wc;
-	char *utf8_value, *p;
-
-	utf8len = 0;
-	for (wp = wval; *wp != L'\0'; ) {
-		wc = *wp++;
-
-		if (wc >= 0xd800 && wc <= 0xdbff
-		    && *wp >= 0xdc00 && *wp <= 0xdfff) {
-			/* This is a surrogate pair.  Combine into a
-			 * full Unicode value before encoding into
-			 * UTF-8. */
-			wc = (wc - 0xd800) << 10; /* High 10 bits */
-			wc += (*wp++ - 0xdc00); /* Low 10 bits */
-			wc += 0x10000; /* Skip BMP */
-		}
-		if (wc <= 0x7f)
-			utf8len++;
-		else if (wc <= 0x7ff)
-			utf8len += 2;
-		else if (wc <= 0xffff)
-			utf8len += 3;
-		else if (wc <= 0x1fffff)
-			utf8len += 4;
-		else if (wc <= 0x3ffffff)
-			utf8len += 5;
-		else if (wc <= 0x7fffffff)
-			utf8len += 6;
-		/* Ignore larger values; UTF-8 can't encode them. */
-	}
-
-	utf8_value = (char *)malloc(utf8len + 1);
-	if (utf8_value == NULL) {
-		__archive_errx(1, "Not enough memory for attributes");
-		return (NULL);
-	}
-
-	for (wp = wval, p = utf8_value; *wp != L'\0'; ) {
-		wc = *wp++;
-		if (wc >= 0xd800 && wc <= 0xdbff
-		    && *wp >= 0xdc00 && *wp <= 0xdfff) {
-			/* Combine surrogate pair. */
-			wc = (wc - 0xd800) << 10;
-			wc += *wp++ - 0xdc00 + 0x10000;
-		}
-		if (wc <= 0x7f) {
-			*p++ = (char)wc;
-		} else if (wc <= 0x7ff) {
-			p[0] = 0xc0 | ((wc >> 6) & 0x1f);
-			p[1] = 0x80 | (wc & 0x3f);
-			p += 2;
-		} else if (wc <= 0xffff) {
-			p[0] = 0xe0 | ((wc >> 12) & 0x0f);
-			p[1] = 0x80 | ((wc >> 6) & 0x3f);
-			p[2] = 0x80 | (wc & 0x3f);
-			p += 3;
-		} else if (wc <= 0x1fffff) {
-			p[0] = 0xf0 | ((wc >> 18) & 0x07);
-			p[1] = 0x80 | ((wc >> 12) & 0x3f);
-			p[2] = 0x80 | ((wc >> 6) & 0x3f);
-			p[3] = 0x80 | (wc & 0x3f);
-			p += 4;
-		} else if (wc <= 0x3ffffff) {
-			p[0] = 0xf8 | ((wc >> 24) & 0x03);
-			p[1] = 0x80 | ((wc >> 18) & 0x3f);
-			p[2] = 0x80 | ((wc >> 12) & 0x3f);
-			p[3] = 0x80 | ((wc >> 6) & 0x3f);
-			p[4] = 0x80 | (wc & 0x3f);
-			p += 5;
-		} else if (wc <= 0x7fffffff) {
-			p[0] = 0xfc | ((wc >> 30) & 0x01);
-			p[1] = 0x80 | ((wc >> 24) & 0x3f);
-			p[1] = 0x80 | ((wc >> 18) & 0x3f);
-			p[2] = 0x80 | ((wc >> 12) & 0x3f);
-			p[3] = 0x80 | ((wc >> 6) & 0x3f);
-			p[4] = 0x80 | (wc & 0x3f);
-			p += 6;
-		}
-		/* Ignore larger values; UTF-8 can't encode them. */
-	}
-	*p = '\0';
-
-	return (utf8_value);
-}
-
-static void
-add_pax_attr_w(struct archive_string *as, const char *key, const wchar_t *wval)
-{
-	char *utf8_value = utf8_encode(wval);
-	if (utf8_value == NULL)
-		return;
-	add_pax_attr(as, key, utf8_value);
-	free(utf8_value);
-}
-
 /*
  * Add a key/value attribute to the pax header.  This function handles
  * the length field and various other syntactic requirements.
@@ -342,8 +315,9 @@
 	archive_strappend_char(as, '\n');
 }
 
-static void
-archive_write_pax_header_xattrs(struct pax *pax, struct archive_entry *entry)
+static int
+archive_write_pax_header_xattrs(struct archive_write *a,
+    struct pax *pax, struct archive_entry *entry)
 {
 	struct archive_string s;
 	int i = archive_entry_xattr_reset(entry);
@@ -353,26 +327,24 @@
 		const void *value;
 		char *encoded_value;
 		char *url_encoded_name = NULL, *encoded_name = NULL;
-		wchar_t *wcs_name = NULL;
 		size_t size;
+		int r;
 
 		archive_entry_xattr_next(entry, &name, &value, &size);
-		/* Name is URL-encoded, then converted to wchar_t,
-		 * then UTF-8 encoded. */
 		url_encoded_name = url_encode(name);
 		if (url_encoded_name != NULL) {
-			/* Convert narrow-character to wide-character. */
-			size_t wcs_length = strlen(url_encoded_name);
-			wcs_name = (wchar_t *)malloc((wcs_length + 1) * sizeof(wchar_t));
-			if (wcs_name == NULL)
-				__archive_errx(1, "No memory for xattr conversion");
-			mbstowcs(wcs_name, url_encoded_name, wcs_length);
-			wcs_name[wcs_length] = 0;
+			/* Convert narrow-character to UTF-8. */
+			r = archive_strcpy_in_locale(
+			    &(pax->l_url_encoded_name),
+			    url_encoded_name, pax->sconv_utf8);
 			free(url_encoded_name); /* Done with this. */
-		}
-		if (wcs_name != NULL) {
-			encoded_name = utf8_encode(wcs_name);
-			free(wcs_name); /* Done with wchar_t name. */
+			if (r == 0)
+				encoded_name = pax->l_url_encoded_name.s;
+			else if (errno == ENOMEM) {
+				archive_set_error(&a->archive, ENOMEM,
+				    "Can't allocate memory for Linkname");
+				return (ARCHIVE_FATAL);
+			}
 		}
 
 		encoded_value = base64_encode((const char *)value, size);
@@ -384,9 +356,99 @@
 			add_pax_attr(&(pax->pax_header), s.s, encoded_value);
 			archive_string_free(&s);
 		}
-		free(encoded_name);
 		free(encoded_value);
 	}
+	return (ARCHIVE_OK);
+}
+
+static int
+get_entry_hardlink(struct archive_write *a, struct archive_entry *entry,
+    const char **name, size_t *length, struct archive_string_conv *sc)
+{
+	int r;
+	
+	r = archive_entry_hardlink_l(entry, name, length, sc);
+	if (r != 0) {
+		if (errno == ENOMEM) {
+			archive_set_error(&a->archive, ENOMEM,
+			    "Can't allocate memory for Linkname");
+			return (ARCHIVE_FATAL);
+		}
+		return (ARCHIVE_WARN);
+	}
+	return (ARCHIVE_OK);
+}
+
+static int
+get_entry_pathname(struct archive_write *a, struct archive_entry *entry,
+    const char **name, size_t *length, struct archive_string_conv *sc)
+{
+	int r;
+
+	r = archive_entry_pathname_l(entry, name, length, sc);
+	if (r != 0) {
+		if (errno == ENOMEM) {
+			archive_set_error(&a->archive, ENOMEM,
+			    "Can't allocate memory for Pathname");
+			return (ARCHIVE_FATAL);
+		}
+		return (ARCHIVE_WARN);
+	}
+	return (ARCHIVE_OK);
+}
+
+static int
+get_entry_uname(struct archive_write *a, struct archive_entry *entry,
+    const char **name, size_t *length, struct archive_string_conv *sc)
+{
+	int r;
+
+	r = archive_entry_uname_l(entry, name, length, sc);
+	if (r != 0) {
+		if (errno == ENOMEM) {
+			archive_set_error(&a->archive, ENOMEM,
+			    "Can't allocate memory for Uname");
+			return (ARCHIVE_FATAL);
+		}
+		return (ARCHIVE_WARN);
+	}
+	return (ARCHIVE_OK);
+}
+
+static int
+get_entry_gname(struct archive_write *a, struct archive_entry *entry,
+    const char **name, size_t *length, struct archive_string_conv *sc)
+{
+	int r;
+
+	r = archive_entry_gname_l(entry, name, length, sc);
+	if (r != 0) {
+		if (errno == ENOMEM) {
+			archive_set_error(&a->archive, ENOMEM,
+			    "Can't allocate memory for Gname");
+			return (ARCHIVE_FATAL);
+		}
+		return (ARCHIVE_WARN);
+	}
+	return (ARCHIVE_OK);
+}
+
+static int
+get_entry_symlink(struct archive_write *a, struct archive_entry *entry,
+    const char **name, size_t *length, struct archive_string_conv *sc)
+{
+	int r;
+
+	r = archive_entry_symlink_l(entry, name, length, sc);
+	if (r != 0) {
+		if (errno == ENOMEM) {
+			archive_set_error(&a->archive, ENOMEM,
+			    "Can't allocate memory for Linkname");
+			return (ARCHIVE_FATAL);
+		}
+		return (ARCHIVE_WARN);
+	}
+	return (ARCHIVE_OK);
 }
 
 /*
@@ -394,6 +456,8 @@
  * archive_entry so that clients can specify them.  Also, consider
  * adding generic key/value tags so clients can add arbitrary
  * key/value data.
+ *
+ * TODO: Break up this 700-line function!!!!  Yowza!
  */
 static int
 archive_write_pax_header(struct archive_write *a,
@@ -401,28 +465,72 @@
 {
 	struct archive_entry *entry_main;
 	const char *p;
-	char *t;
-	const wchar_t *wp;
 	const char *suffix;
 	int need_extension, r, ret;
+	int sparse_count;
+	uint64_t sparse_total, real_size;
 	struct pax *pax;
-	const char *hdrcharset = NULL;
 	const char *hardlink;
 	const char *path = NULL, *linkpath = NULL;
 	const char *uname = NULL, *gname = NULL;
-	const wchar_t *path_w = NULL, *linkpath_w = NULL;
-	const wchar_t *uname_w = NULL, *gname_w = NULL;
+	const void *mac_metadata;
+	size_t mac_metadata_size;
+	struct archive_string_conv *sconv;
+	size_t hardlink_length, path_length, linkpath_length;
+	size_t uname_length, gname_length;
 
 	char paxbuff[512];
 	char ustarbuff[512];
 	char ustar_entry_name[256];
 	char pax_entry_name[256];
+	char gnu_sparse_name[256];
+	struct archive_string entry_name;
 
 	ret = ARCHIVE_OK;
 	need_extension = 0;
 	pax = (struct pax *)a->format_data;
 
-	hardlink = archive_entry_hardlink(entry_original);
+	/* Sanity check. */
+	if (archive_entry_pathname(entry_original) == NULL) {
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+			  "Can't record entry in tar file without pathname");
+		return (ARCHIVE_FAILED);
+	}
+
+	/*
+	 * Choose a header encoding.
+	 */
+	if (pax->opt_binary)
+		sconv = NULL;/* Binary mode. */
+	else {
+		/* Header encoding is UTF-8. */
+		if (pax->sconv_utf8 == NULL) {
+			/* Initialize the string conversion object
+			 * we must need */
+			pax->sconv_utf8 = archive_string_conversion_to_charset(
+			    &(a->archive), "UTF-8", 1);
+			if (pax->sconv_utf8 == NULL)
+				/* Couldn't allocate memory */
+				return (ARCHIVE_FAILED);
+		}
+		sconv = pax->sconv_utf8;
+	}
+
+	r = get_entry_hardlink(a, entry_original, &hardlink,
+	    &hardlink_length, sconv);
+	if (r == ARCHIVE_FATAL)
+		return (r);
+	else if (r != ARCHIVE_OK) {
+		r = get_entry_hardlink(a, entry_original, &hardlink,
+		    &hardlink_length, NULL);
+		if (r == ARCHIVE_FATAL)
+			return (r);
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+		    "Can't translate linkname '%s' to %s", hardlink,
+		    archive_string_conversion_charset_name(sconv));
+		ret = ARCHIVE_WARN;
+		sconv = NULL;/* The header charset switches to binary mode. */
+	}
 
 	/* Make sure this is a type of entry that we can handle here */
 	if (hardlink == NULL) {
@@ -434,90 +542,301 @@
 		case AE_IFREG:
 			break;
 		case AE_IFDIR:
+		{
 			/*
 			 * Ensure a trailing '/'.  Modify the original
 			 * entry so the client sees the change.
 			 */
-			p = archive_entry_pathname(entry_original);
-			if (p[strlen(p) - 1] != '/') {
-				t = (char *)malloc(strlen(p) + 2);
-				if (t == NULL) {
+#if defined(_WIN32) && !defined(__CYGWIN__)
+			const wchar_t *wp;
+
+			wp = archive_entry_pathname_w(entry_original);
+			if (wp != NULL && wp[wcslen(wp) -1] != L'/') {
+				struct archive_wstring ws;
+
+				archive_string_init(&ws);
+				path_length = wcslen(wp);
+				if (archive_wstring_ensure(&ws,
+				    path_length + 2) == NULL) {
 					archive_set_error(&a->archive, ENOMEM,
-					"Can't allocate pax data");
+					    "Can't allocate pax data");
+					archive_wstring_free(&ws);
 					return(ARCHIVE_FATAL);
 				}
-				strcpy(t, p);
-				strcat(t, "/");
-				archive_entry_copy_pathname(entry_original, t);
-				free(t);
+				/* Should we keep '\' ? */
+				if (wp[path_length -1] == L'\\')
+					path_length--;
+				archive_wstrncpy(&ws, wp, path_length);
+				archive_wstrappend_wchar(&ws, L'/');
+				archive_entry_copy_pathname_w(
+				    entry_original, ws.s);
+				archive_wstring_free(&ws);
+				p = NULL;
+			} else
+#endif
+				p = archive_entry_pathname(entry_original);
+			/*
+			 * On Windows, this is a backup operation just in
+			 * case getting WCS failed. On POSIX, this is a
+			 * normal operation.
+			 */
+			if (p != NULL && p[strlen(p) - 1] != '/') {
+				struct archive_string as;
+
+				archive_string_init(&as);
+				path_length = strlen(p);
+				if (archive_string_ensure(&as,
+				    path_length + 2) == NULL) {
+					archive_set_error(&a->archive, ENOMEM,
+					    "Can't allocate pax data");
+					archive_string_free(&as);
+					return(ARCHIVE_FATAL);
+				}
+#if defined(_WIN32) && !defined(__CYGWIN__)
+				/* NOTE: This might break the pathname
+				 * if the current code page is CP932 and
+				 * the pathname includes a character '\'
+				 * as a part of its multibyte pathname. */
+				if (p[strlen(p) -1] == '\\')
+					path_length--;
+				else
+#endif
+				archive_strncpy(&as, p, path_length);
+				archive_strappend_char(&as, '/');
+				archive_entry_copy_pathname(
+				    entry_original, as.s);
+				archive_string_free(&as);
 			}
 			break;
+		}
 		case AE_IFSOCK:
 			archive_set_error(&a->archive,
 			    ARCHIVE_ERRNO_FILE_FORMAT,
 			    "tar format cannot archive socket");
-			return (ARCHIVE_WARN);
+			return (ARCHIVE_FAILED);
 		default:
 			archive_set_error(&a->archive,
 			    ARCHIVE_ERRNO_FILE_FORMAT,
 			    "tar format cannot archive this (type=0%lo)",
-			    (unsigned long)archive_entry_filetype(entry_original));
-			return (ARCHIVE_WARN);
+			    (unsigned long)
+			    archive_entry_filetype(entry_original));
+			return (ARCHIVE_FAILED);
 		}
 	}
 
+	/*
+	 * If Mac OS metadata blob is here, recurse to write that
+	 * as a separate entry.  This is really a pretty poor design:
+	 * In particular, it doubles the overhead for long filenames.
+	 * TODO: Help Apple folks design something better and figure
+	 * out how to transition from this legacy format.
+	 *
+	 * Note that this code is present on every platform; clients
+	 * on non-Mac are unlikely to ever provide this data, but
+	 * applications that copy entries from one archive to another
+	 * should not lose data just because the local filesystem
+	 * can't store it.
+	 */
+	mac_metadata =
+	    archive_entry_mac_metadata(entry_original, &mac_metadata_size);
+	if (mac_metadata != NULL) {
+		const char *oname;
+		char *name, *bname;
+		size_t name_length;
+		struct archive_entry *extra = archive_entry_new2(&a->archive);
+
+		oname = archive_entry_pathname(entry_original);
+		name_length = strlen(oname);
+		name = malloc(name_length + 3);
+		if (name == NULL) {
+			/* XXX error message */
+			return (ARCHIVE_FAILED);
+		}
+		strcpy(name, oname);
+		/* Find last '/'; strip trailing '/' characters */
+		bname = strrchr(name, '/');
+		while (bname != NULL && bname[1] == '\0') {
+			*bname = '\0';
+			bname = strrchr(name, '/');
+		}
+		if (bname == NULL) {
+			memmove(name + 2, name, name_length + 1);
+			memmove(name, "._", 2);
+		} else {
+			bname += 1;
+			memmove(bname + 2, bname, strlen(bname) + 1);
+			memmove(bname, "._", 2);
+		}
+		archive_entry_copy_pathname(extra, name);
+		free(name);
+
+		archive_entry_set_size(extra, mac_metadata_size);
+		archive_entry_set_filetype(extra, AE_IFREG);
+		archive_entry_set_perm(extra,
+		    archive_entry_perm(entry_original));
+		archive_entry_set_mtime(extra,
+		    archive_entry_mtime(entry_original),
+		    archive_entry_mtime_nsec(entry_original));
+		archive_entry_set_gid(extra,
+		    archive_entry_gid(entry_original));
+		archive_entry_set_gname(extra,
+		    archive_entry_gname(entry_original));
+		archive_entry_set_uid(extra,
+		    archive_entry_uid(entry_original));
+		archive_entry_set_uname(extra,
+		    archive_entry_uname(entry_original));
+
+		/* Recurse to write the special copyfile entry. */
+		r = archive_write_pax_header(a, extra);
+		if (r < ARCHIVE_WARN)
+			return (r);
+		if (r < ret)
+			ret = r;
+		r = archive_write_pax_data(a, mac_metadata, mac_metadata_size);
+		if (r < ARCHIVE_WARN)
+			return (r);
+		if (r < ret)
+			ret = r;
+		r = archive_write_pax_finish_entry(a);
+		if (r < ARCHIVE_WARN)
+			return (r);
+		if (r < ret)
+			ret = r;
+	}
+
 	/* Copy entry so we can modify it as needed. */
+#if defined(_WIN32) && !defined(__CYGWIN__)
+	/* Make sure the path separators in pahtname, hardlink and symlink
+	 * are all slash '/', not the Windows path separator '\'. */
+	entry_main = __la_win_entry_in_posix_pathseparator(entry_original);
+	if (entry_main == entry_original)
+		entry_main = archive_entry_clone(entry_original);
+#else
 	entry_main = archive_entry_clone(entry_original);
+#endif
+	if (entry_main == NULL) {
+		archive_set_error(&a->archive, ENOMEM,
+		    "Can't allocate pax data");
+		return(ARCHIVE_FATAL);
+	}
 	archive_string_empty(&(pax->pax_header)); /* Blank our work area. */
+	archive_string_empty(&(pax->sparse_map));
+	sparse_total = 0;
+	sparse_list_clear(pax);
+
+	if (hardlink == NULL &&
+	    archive_entry_filetype(entry_main) == AE_IFREG)
+		sparse_count = archive_entry_sparse_reset(entry_main);
+	else
+		sparse_count = 0;
+	if (sparse_count) {
+		int64_t offset, length, last_offset = 0;
+		/* Get the last entry of sparse block. */
+		while (archive_entry_sparse_next(
+		    entry_main, &offset, &length) == ARCHIVE_OK)
+			last_offset = offset + length;
+
+		/* If the last sparse block does not reach the end of file,
+		 * We have to add a empty sparse block as the last entry to
+		 * manage storing file data. */
+		if (last_offset < archive_entry_size(entry_main))
+			archive_entry_sparse_add_entry(entry_main,
+			    archive_entry_size(entry_main), 0);
+		sparse_count = archive_entry_sparse_reset(entry_main);
+	}
 
 	/*
 	 * First, check the name fields and see if any of them
 	 * require binary coding.  If any of them does, then all of
 	 * them do.
 	 */
-	hdrcharset = NULL;
-	path = archive_entry_pathname(entry_main);
-	path_w = archive_entry_pathname_w(entry_main);
-	if (path != NULL && path_w == NULL) {
+	r = get_entry_pathname(a, entry_main, &path, &path_length, sconv);
+	if (r == ARCHIVE_FATAL)
+		return (r);
+	else if (r != ARCHIVE_OK) {
+		r = get_entry_pathname(a, entry_main, &path,
+		    &path_length, NULL);
+		if (r == ARCHIVE_FATAL)
+			return (r);
 		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
-		    "Can't translate pathname '%s' to UTF-8", path);
+		    "Can't translate pathname '%s' to %s", path,
+		    archive_string_conversion_charset_name(sconv));
 		ret = ARCHIVE_WARN;
-		hdrcharset = "BINARY";
+		sconv = NULL;/* The header charset switches to binary mode. */
 	}
-	uname = archive_entry_uname(entry_main);
-	uname_w = archive_entry_uname_w(entry_main);
-	if (uname != NULL && uname_w == NULL) {
+	r = get_entry_uname(a, entry_main, &uname, &uname_length, sconv);
+	if (r == ARCHIVE_FATAL)
+		return (r);
+	else if (r != ARCHIVE_OK) {
+		r = get_entry_uname(a, entry_main, &uname, &uname_length, NULL);
+		if (r == ARCHIVE_FATAL)
+			return (r);
 		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
-		    "Can't translate uname '%s' to UTF-8", uname);
+		    "Can't translate uname '%s' to %s", uname,
+		    archive_string_conversion_charset_name(sconv));
 		ret = ARCHIVE_WARN;
-		hdrcharset = "BINARY";
+		sconv = NULL;/* The header charset switches to binary mode. */
 	}
-	gname = archive_entry_gname(entry_main);
-	gname_w = archive_entry_gname_w(entry_main);
-	if (gname != NULL && gname_w == NULL) {
+	r = get_entry_gname(a, entry_main, &gname, &gname_length, sconv);
+	if (r == ARCHIVE_FATAL)
+		return (r);
+	else if (r != ARCHIVE_OK) {
+		r = get_entry_gname(a, entry_main, &gname, &gname_length, NULL);
+		if (r == ARCHIVE_FATAL)
+			return (r);
 		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
-		    "Can't translate gname '%s' to UTF-8", gname);
+		    "Can't translate gname '%s' to %s", gname,
+		    archive_string_conversion_charset_name(sconv));
 		ret = ARCHIVE_WARN;
-		hdrcharset = "BINARY";
+		sconv = NULL;/* The header charset switches to binary mode. */
 	}
 	linkpath = hardlink;
-	if (linkpath != NULL) {
-		linkpath_w = archive_entry_hardlink_w(entry_main);
-	} else {
-		linkpath = archive_entry_symlink(entry_main);
-		if (linkpath != NULL)
-			linkpath_w = archive_entry_symlink_w(entry_main);
+	linkpath_length = hardlink_length;
+	if (linkpath == NULL) {
+		r = get_entry_symlink(a, entry_main, &linkpath,
+		    &linkpath_length, sconv);
+		if (r == ARCHIVE_FATAL)
+			return (r);
+		else if (r != ARCHIVE_OK) {
+			r = get_entry_symlink(a, entry_main, &linkpath,
+			    &linkpath_length, NULL);
+			if (r == ARCHIVE_FATAL)
+				return (r);
+			archive_set_error(&a->archive,
+			    ARCHIVE_ERRNO_FILE_FORMAT,
+			    "Can't translate linkname '%s' to %s", linkpath,
+			    archive_string_conversion_charset_name(sconv));
+			ret = ARCHIVE_WARN;
+			sconv = NULL;
+		}
 	}
-	if (linkpath != NULL && linkpath_w == NULL) {
-		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
-		    "Can't translate linkpath '%s' to UTF-8", linkpath);
-		ret = ARCHIVE_WARN;
-		hdrcharset = "BINARY";
+
+	/* If any string conversions failed, get all attributes
+	 * in binary-mode. */
+	if (sconv == NULL && !pax->opt_binary) {
+		if (hardlink != NULL) {
+			r = get_entry_hardlink(a, entry_main, &hardlink,
+			    &hardlink_length, NULL);
+			if (r == ARCHIVE_FATAL)
+				return (r);
+			linkpath = hardlink;
+			linkpath_length = hardlink_length;
+		}
+		r = get_entry_pathname(a, entry_main, &path,
+		    &path_length, NULL);
+		if (r == ARCHIVE_FATAL)
+			return (r);
+		r = get_entry_uname(a, entry_main, &uname, &uname_length, NULL);
+		if (r == ARCHIVE_FATAL)
+			return (r);
+		r = get_entry_gname(a, entry_main, &gname, &gname_length, NULL);
+		if (r == ARCHIVE_FATAL)
+			return (r);
 	}
 
 	/* Store the header encoding first, to be nice to readers. */
-	if (hdrcharset != NULL)
-		add_pax_attr(&(pax->pax_header), "hdrcharset", hdrcharset);
+	if (sconv == NULL)
+		add_pax_attr(&(pax->pax_header), "hdrcharset", "BINARY");
 
 
 	/*
@@ -525,38 +844,25 @@
 	 * 'path' to pax extended attrs.  (Note that an unconvertible
 	 * name must have non-ASCII characters.)
 	 */
-	if (path == NULL) {
-		/* We don't have a narrow version, so we have to store
-		 * the wide version. */
-		add_pax_attr_w(&(pax->pax_header), "path", path_w);
-		archive_entry_set_pathname(entry_main, "@WidePath");
-		need_extension = 1;
-	} else if (has_non_ASCII(path_w)) {
+	if (has_non_ASCII(path)) {
 		/* We have non-ASCII characters. */
-		if (path_w == NULL || hdrcharset != NULL) {
-			/* Can't do UTF-8, so store it raw. */
-			add_pax_attr(&(pax->pax_header), "path", path);
-		} else {
-			/* Store UTF-8 */
-			add_pax_attr_w(&(pax->pax_header),
-			    "path", path_w);
-		}
+		add_pax_attr(&(pax->pax_header), "path", path);
 		archive_entry_set_pathname(entry_main,
 		    build_ustar_entry_name(ustar_entry_name,
-			path, strlen(path), NULL));
+			path, path_length, NULL));
 		need_extension = 1;
 	} else {
 		/* We have an all-ASCII path; we'd like to just store
 		 * it in the ustar header if it will fit.  Yes, this
 		 * duplicates some of the logic in
-		 * write_set_format_ustar.c
+		 * archive_write_set_format_ustar.c
 		 */
-		if (strlen(path) <= 100) {
+		if (path_length <= 100) {
 			/* Fits in the old 100-char tar name field. */
 		} else {
 			/* Find largest suffix that will fit. */
 			/* Note: strlen() > 100, so strlen() - 100 - 1 >= 0 */
-			suffix = strchr(path + strlen(path) - 100 - 1, '/');
+			suffix = strchr(path + path_length - 100 - 1, '/');
 			/* Don't attempt an empty prefix. */
 			if (suffix == path)
 				suffix = strchr(suffix + 1, '/');
@@ -571,18 +877,10 @@
 			    || suffix[1] == '\0'    /* empty suffix */
 			    || suffix - path > 155)  /* Prefix > 155 chars */
 			{
-				if (path_w == NULL || hdrcharset != NULL) {
-					/* Can't do UTF-8, so store it raw. */
-					add_pax_attr(&(pax->pax_header),
-					    "path", path);
-				} else {
-					/* Store UTF-8 */
-					add_pax_attr_w(&(pax->pax_header),
-					    "path", path_w);
-				}
+				add_pax_attr(&(pax->pax_header), "path", path);
 				archive_entry_set_pathname(entry_main,
 				    build_ustar_entry_name(ustar_entry_name,
-					path, strlen(path), NULL));
+					path, path_length, NULL));
 				need_extension = 1;
 			}
 		}
@@ -591,21 +889,9 @@
 	if (linkpath != NULL) {
 		/* If link name is too long or has non-ASCII characters, add
 		 * 'linkpath' to pax extended attrs. */
-		if (strlen(linkpath) > 100 || linkpath_w == NULL
-		    || linkpath_w == NULL || has_non_ASCII(linkpath_w)) {
-			if (linkpath_w == NULL || hdrcharset != NULL)
-				/* If the linkpath is not convertible
-				 * to wide, or we're encoding in
-				 * binary anyway, store it raw. */
-				add_pax_attr(&(pax->pax_header),
-				    "linkpath", linkpath);
-			else
-				/* If the link is long or has a
-				 * non-ASCII character, store it as a
-				 * pax extended attribute. */
-				add_pax_attr_w(&(pax->pax_header),
-				    "linkpath", linkpath_w);
-			if (strlen(linkpath) > 100) {
+		if (linkpath_length > 100 || has_non_ASCII(linkpath)) {
+			add_pax_attr(&(pax->pax_header), "linkpath", linkpath);
+			if (linkpath_length > 100) {
 				if (hardlink != NULL)
 					archive_entry_set_hardlink(entry_main,
 					    "././@LongHardLink");
@@ -616,6 +902,10 @@
 			need_extension = 1;
 		}
 	}
+	/* Save a pathname since it will be renamed if `entry_main` has
+	 * sparse blocks. */
+	archive_string_init(&entry_name);
+	archive_strcpy(&entry_name, archive_entry_pathname(entry_main));
 
 	/* If file size is too large, add 'size' to pax extended attrs. */
 	if (archive_entry_size(entry_main) >= (((int64_t)1) << 33)) {
@@ -634,17 +924,8 @@
 	/* If group name is too large or has non-ASCII characters, add
 	 * 'gname' to pax extended attrs. */
 	if (gname != NULL) {
-		if (strlen(gname) > 31
-		    || gname_w == NULL
-		    || has_non_ASCII(gname_w))
-		{
-			if (gname_w == NULL || hdrcharset != NULL) {
-				add_pax_attr(&(pax->pax_header),
-				    "gname", gname);
-			} else  {
-				add_pax_attr_w(&(pax->pax_header),
-				    "gname", gname_w);
-			}
+		if (gname_length > 31 || has_non_ASCII(gname)) {
+			add_pax_attr(&(pax->pax_header), "gname", gname);
 			need_extension = 1;
 		}
 	}
@@ -658,17 +939,8 @@
 
 	/* Add 'uname' to pax extended attrs if necessary. */
 	if (uname != NULL) {
-		if (strlen(uname) > 31
-		    || uname_w == NULL
-		    || has_non_ASCII(uname_w))
-		{
-			if (uname_w == NULL || hdrcharset != NULL) {
-				add_pax_attr(&(pax->pax_header),
-				    "uname", uname);
-			} else {
-				add_pax_attr_w(&(pax->pax_header),
-				    "uname", uname_w);
-			}
+		if (uname_length > 31 || has_non_ASCII(uname)) {
+			add_pax_attr(&(pax->pax_header), "uname", uname);
 			need_extension = 1;
 		}
 	}
@@ -690,7 +962,7 @@
 		 * If rdevmajor is too large, add 'SCHILY.devmajor' to
 		 * extended attributes.
 		 */
-		dev_t rdevmajor, rdevminor;
+		int rdevmajor, rdevminor;
 		rdevmajor = archive_entry_rdevmajor(entry_main);
 		rdevminor = archive_entry_rdevminor(entry_main);
 		if (rdevmajor >= (1 << 18)) {
@@ -756,6 +1028,10 @@
 	if (!need_extension && archive_entry_xattr_count(entry_original) > 0)
 		need_extension = 1;
 
+	/* If there are sparse info, we need an extension */
+	if (!need_extension && sparse_count > 0)
+		need_extension = 1;
+
 	/*
 	 * The following items are handled differently in "pax
 	 * restricted" format.  In particular, in "pax restricted"
@@ -800,31 +1076,98 @@
 			add_pax_attr(&(pax->pax_header), "SCHILY.fflags", p);
 
 		/* I use star-compatible ACL attributes. */
-		wp = archive_entry_acl_text_w(entry_original,
+		r = archive_entry_acl_text_l(entry_original,
 		    ARCHIVE_ENTRY_ACL_TYPE_ACCESS |
-		    ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID);
-		if (wp != NULL && *wp != L'\0')
-			add_pax_attr_w(&(pax->pax_header),
-			    "SCHILY.acl.access", wp);
-		wp = archive_entry_acl_text_w(entry_original,
+		    ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID,
+		    &p, NULL, pax->sconv_utf8);
+		if (r != 0) {
+			if (errno == ENOMEM) {
+				archive_set_error(&a->archive, ENOMEM,
+				    "Can't allocate memory for "
+				    "ACL.access");
+				return (ARCHIVE_FATAL);
+			}
+			archive_set_error(&a->archive,
+			    ARCHIVE_ERRNO_FILE_FORMAT,
+			    "Can't translate ACL.access to UTF-8");
+			ret = ARCHIVE_WARN;
+		} else if (p != NULL && *p != '\0') {
+			add_pax_attr(&(pax->pax_header),
+			    "SCHILY.acl.access", p);
+		}
+		r = archive_entry_acl_text_l(entry_original,
 		    ARCHIVE_ENTRY_ACL_TYPE_DEFAULT |
-		    ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID);
-		if (wp != NULL && *wp != L'\0')
-			add_pax_attr_w(&(pax->pax_header),
-			    "SCHILY.acl.default", wp);
+		    ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID,
+		    &p, NULL, pax->sconv_utf8);
+		if (r != 0) {
+			if (errno == ENOMEM) {
+				archive_set_error(&a->archive, ENOMEM,
+				    "Can't allocate memory for "
+				    "ACL.default");
+				return (ARCHIVE_FATAL);
+			}
+			archive_set_error(&a->archive,
+			    ARCHIVE_ERRNO_FILE_FORMAT,
+			    "Can't translate ACL.default to UTF-8");
+			ret = ARCHIVE_WARN;
+		} else if (p != NULL && *p != '\0') {
+			add_pax_attr(&(pax->pax_header),
+			    "SCHILY.acl.default", p);
+		}
 
-		/* Include star-compatible metadata info. */
-		/* Note: "SCHILY.dev{major,minor}" are NOT the
-		 * major/minor portions of "SCHILY.dev". */
-		add_pax_attr_int(&(pax->pax_header), "SCHILY.dev",
-		    archive_entry_dev(entry_main));
-		add_pax_attr_int(&(pax->pax_header), "SCHILY.ino",
-		    archive_entry_ino64(entry_main));
-		add_pax_attr_int(&(pax->pax_header), "SCHILY.nlink",
-		    archive_entry_nlink(entry_main));
+		/* We use GNU-tar-compatible sparse attributes. */
+		if (sparse_count > 0) {
+			int64_t soffset, slength;
+
+			add_pax_attr_int(&(pax->pax_header),
+			    "GNU.sparse.major", 1);
+			add_pax_attr_int(&(pax->pax_header),
+			    "GNU.sparse.minor", 0);
+			add_pax_attr(&(pax->pax_header),
+			    "GNU.sparse.name", entry_name.s);
+			add_pax_attr_int(&(pax->pax_header),
+			    "GNU.sparse.realsize",
+			    archive_entry_size(entry_main));
+
+			/* Rename the file name which will be used for
+			 * ustar header to a special name, which GNU
+			 * PAX Format 1.0 requires */
+			archive_entry_set_pathname(entry_main,
+			    build_gnu_sparse_name(gnu_sparse_name,
+			        entry_name.s));
+
+			/*
+			 * - Make a sparse map, which will precede a file data.
+			 * - Get the total size of available data of sparse.
+			 */
+			archive_string_sprintf(&(pax->sparse_map), "%d\n",
+			    sparse_count);
+			while (archive_entry_sparse_next(entry_main,
+			    &soffset, &slength) == ARCHIVE_OK) {
+				archive_string_sprintf(&(pax->sparse_map),
+				    "%jd\n%jd\n",
+				    (intmax_t)soffset,
+				    (intmax_t)slength);
+				sparse_total += slength;
+				if (sparse_list_add(pax, soffset, slength)
+				    != ARCHIVE_OK) {
+					archive_set_error(&a->archive,
+					    ENOMEM,
+					    "Can't allocate memory");
+					archive_entry_free(entry_main);
+					archive_string_free(&entry_name);
+					return (ARCHIVE_FATAL);
+				}
+			}
+		}
 
 		/* Store extended attributes */
-		archive_write_pax_header_xattrs(pax, entry_original);
+		if (archive_write_pax_header_xattrs(a, pax, entry_original)
+		    == ARCHIVE_FATAL) {
+			archive_entry_free(entry_main);
+			archive_string_free(&entry_name);
+			return (ARCHIVE_FATAL);
+		}
 	}
 
 	/* Only regular files have data. */
@@ -852,6 +1195,20 @@
 	if (hardlink != NULL)
 		archive_entry_set_size(entry_main, 0);
 
+	/* Save a real file size. */
+	real_size = archive_entry_size(entry_main);
+	/*
+	 * Overwrite a file size by the total size of sparse blocks and
+	 * the size of sparse map info. That file size is the length of
+	 * the data, which we will exactly store into an archive file.
+	 */
+	if (archive_strlen(&(pax->sparse_map))) {
+		size_t mapsize = archive_strlen(&(pax->sparse_map));
+		pax->sparse_map_padding = 0x1ff & (-(ssize_t)mapsize);
+		archive_entry_set_size(entry_main,
+		    mapsize + pax->sparse_map_padding + sparse_total);
+	}
+
 	/* Format 'ustar' header for main entry.
 	 *
 	 * The trouble with file size: If the reader can't understand
@@ -878,30 +1235,31 @@
 	 * The non-strict formatter uses similar logic for other
 	 * numeric fields, though they're less critical.
 	 */
-	__archive_write_format_header_ustar(a, ustarbuff, entry_main, -1, 0);
+	if (__archive_write_format_header_ustar(a, ustarbuff, entry_main, -1, 0,
+	    NULL) == ARCHIVE_FATAL)
+		return (ARCHIVE_FATAL);
 
 	/* If we built any extended attributes, write that entry first. */
 	if (archive_strlen(&(pax->pax_header)) > 0) {
 		struct archive_entry *pax_attr_entry;
 		time_t s;
-		uid_t uid;
-		gid_t gid;
-		mode_t mode;
+		int64_t uid, gid;
+		int mode;
 
-		pax_attr_entry = archive_entry_new();
-		p = archive_entry_pathname(entry_main);
+		pax_attr_entry = archive_entry_new2(&a->archive);
+		p = entry_name.s;
 		archive_entry_set_pathname(pax_attr_entry,
 		    build_pax_attribute_name(pax_entry_name, p));
 		archive_entry_set_size(pax_attr_entry,
 		    archive_strlen(&(pax->pax_header)));
 		/* Copy uid/gid (but clip to ustar limits). */
 		uid = archive_entry_uid(entry_main);
-		if ((unsigned int)uid >= 1 << 18)
-			uid = (uid_t)(1 << 18) - 1;
+		if (uid >= 1 << 18)
+			uid = (1 << 18) - 1;
 		archive_entry_set_uid(pax_attr_entry, uid);
 		gid = archive_entry_gid(entry_main);
-		if ((unsigned int)gid >= 1 << 18)
-			gid = (gid_t)(1 << 18) - 1;
+		if (gid >= 1 << 18)
+			gid = (1 << 18) - 1;
 		archive_entry_set_gid(pax_attr_entry, gid);
 		/* Copy mode over (but not setuid/setgid bits) */
 		mode = archive_entry_mode(entry_main);
@@ -935,36 +1293,38 @@
 		archive_entry_set_ctime(pax_attr_entry, 0, 0);
 
 		r = __archive_write_format_header_ustar(a, paxbuff,
-		    pax_attr_entry, 'x', 1);
+		    pax_attr_entry, 'x', 1, NULL);
 
 		archive_entry_free(pax_attr_entry);
 
 		/* Note that the 'x' header shouldn't ever fail to format */
-		if (r != 0) {
-			const char *msg = "archive_write_pax_header: "
-			    "'x' header failed?!  This can't happen.\n";
-			size_t u = write(2, msg, strlen(msg));
-			(void)u; /* UNUSED */
-			exit(1);
-		}
-		r = (a->compressor.write)(a, paxbuff, 512);
+		if (r < ARCHIVE_WARN) {
+			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+			    "archive_write_pax_header: "
+			    "'x' header failed?!  This can't happen.\n");
+			return (ARCHIVE_FATAL);
+		} else if (r < ret)
+			ret = r;
+		r = __archive_write_output(a, paxbuff, 512);
 		if (r != ARCHIVE_OK) {
+			sparse_list_clear(pax);
 			pax->entry_bytes_remaining = 0;
 			pax->entry_padding = 0;
 			return (ARCHIVE_FATAL);
 		}
 
 		pax->entry_bytes_remaining = archive_strlen(&(pax->pax_header));
-		pax->entry_padding = 0x1ff & (-(int64_t)pax->entry_bytes_remaining);
+		pax->entry_padding =
+		    0x1ff & (-(int64_t)pax->entry_bytes_remaining);
 
-		r = (a->compressor.write)(a, pax->pax_header.s,
+		r = __archive_write_output(a, pax->pax_header.s,
 		    archive_strlen(&(pax->pax_header)));
 		if (r != ARCHIVE_OK) {
 			/* If a write fails, we're pretty much toast. */
 			return (ARCHIVE_FATAL);
 		}
 		/* Pad out the end of the entry. */
-		r = write_nulls(a, pax->entry_padding);
+		r = __archive_write_nulls(a, pax->entry_padding);
 		if (r != ARCHIVE_OK) {
 			/* If a write fails, we're pretty much toast. */
 			return (ARCHIVE_FATAL);
@@ -973,7 +1333,7 @@
 	}
 
 	/* Write the header for main entry. */
-	r = (a->compressor.write)(a, ustarbuff, 512);
+	r = __archive_write_output(a, ustarbuff, 512);
 	if (r != ARCHIVE_OK)
 		return (r);
 
@@ -982,10 +1342,16 @@
 	 * they can avoid unnecessarily writing a body for something
 	 * that we're just going to ignore.
 	 */
-	archive_entry_set_size(entry_original, archive_entry_size(entry_main));
-	pax->entry_bytes_remaining = archive_entry_size(entry_main);
-	pax->entry_padding = 0x1ff & (-(int64_t)pax->entry_bytes_remaining);
+	archive_entry_set_size(entry_original, real_size);
+	if (pax->sparse_list == NULL && real_size > 0) {
+		/* This is not a sparse file but we handle its data as
+		 * a sparse block. */
+		sparse_list_add(pax, 0, real_size);
+		sparse_total = real_size;
+	}
+	pax->entry_padding = 0x1ff & (-(int64_t)sparse_total);
 	archive_entry_free(entry_main);
+	archive_string_free(&entry_name);
 
 	return (ret);
 }
@@ -1136,7 +1502,7 @@
  *
  * Joerg Schilling has argued that this is unnecessary because, in
  * practice, if the pax extended attributes get extracted as regular
- * files, noone is going to bother reading those attributes to
+ * files, no one is going to bother reading those attributes to
  * manually restore them.  Based on this, 'star' uses
  * /tmp/PaxHeader/'basename' as the ustar header name.  This is a
  * tempting argument, in part because it's simpler than the SUSv3
@@ -1200,7 +1566,57 @@
 	/* If the platform can't fetch the pid, don't include it. */
 	strcpy(buff, "PaxHeader");
 #endif
-	/* General case: build a ustar-compatible name adding "/PaxHeader/". */
+	/* General case: build a ustar-compatible name adding
+	 * "/PaxHeader/". */
+	build_ustar_entry_name(dest, src, p - src, buff);
+
+	return (dest);
+}
+
+/*
+ * GNU PAX Format 1.0 requires the special name, which pattern is:
+ * <dir>/GNUSparseFile.<pid>/<original file name>
+ *
+ * This function is used for only Sparse file, a file type of which
+ * is regular file.
+ */
+static char *
+build_gnu_sparse_name(char *dest, const char *src)
+{
+	char buff[64];
+	const char *p;
+
+	/* Handle the null filename case. */
+	if (src == NULL || *src == '\0') {
+		strcpy(dest, "GNUSparseFile/blank");
+		return (dest);
+	}
+
+	/* Prune final '/' and other unwanted final elements. */
+	p = src + strlen(src);
+	for (;;) {
+		/* Ends in "/", remove the '/' */
+		if (p > src && p[-1] == '/') {
+			--p;
+			continue;
+		}
+		/* Ends in "/.", remove the '.' */
+		if (p > src + 1 && p[-1] == '.'
+		    && p[-2] == '/') {
+			--p;
+			continue;
+		}
+		break;
+	}
+
+#if HAVE_GETPID && 0  /* Disable this as pax attribute name. */
+	sprintf(buff, "GNUSparseFile.%d", getpid());
+#else
+	/* If the platform can't fetch the pid, don't include it. */
+	strcpy(buff, "GNUSparseFile");
+#endif
+	/* General case: build a ustar-compatible name adding
+	 * "/GNUSparseFile/". */
 	build_ustar_entry_name(dest, src, p - src, buff);
 
 	return (dest);
@@ -1208,19 +1624,13 @@
 
 /* Write two null blocks for the end of archive */
 static int
-archive_write_pax_finish(struct archive_write *a)
+archive_write_pax_close(struct archive_write *a)
 {
-	int r;
-
-	if (a->compressor.write == NULL)
-		return (ARCHIVE_OK);
-
-	r = write_nulls(a, 512 * 2);
-	return (r);
+	return (__archive_write_nulls(a, 512 * 2));
 }
 
 static int
-archive_write_pax_destroy(struct archive_write *a)
+archive_write_pax_free(struct archive_write *a)
 {
 	struct pax *pax;
 
@@ -1229,6 +1639,9 @@
 		return (ARCHIVE_OK);
 
 	archive_string_free(&pax->pax_header);
+	archive_string_free(&pax->sparse_map);
+	archive_string_free(&pax->l_url_encoded_name);
+	sparse_list_clear(pax);
 	free(pax);
 	a->format_data = NULL;
 	return (ARCHIVE_OK);
@@ -1238,56 +1651,97 @@
 archive_write_pax_finish_entry(struct archive_write *a)
 {
 	struct pax *pax;
+	uint64_t remaining;
 	int ret;
 
 	pax = (struct pax *)a->format_data;
-	ret = write_nulls(a, pax->entry_bytes_remaining + pax->entry_padding);
+	remaining = pax->entry_bytes_remaining;
+	if (remaining == 0) {
+		while (pax->sparse_list) {
+			struct sparse_block *sb;
+			if (!pax->sparse_list->is_hole)
+				remaining += pax->sparse_list->remaining;
+			sb = pax->sparse_list->next;
+			free(pax->sparse_list);
+			pax->sparse_list = sb;
+		}
+	}
+	ret = __archive_write_nulls(a, remaining + pax->entry_padding);
 	pax->entry_bytes_remaining = pax->entry_padding = 0;
 	return (ret);
 }
 
-static int
-write_nulls(struct archive_write *a, size_t padding)
-{
-	int ret;
-	size_t to_write;
-
-	while (padding > 0) {
-		to_write = padding < a->null_length ? padding : a->null_length;
-		ret = (a->compressor.write)(a, a->nulls, to_write);
-		if (ret != ARCHIVE_OK)
-			return (ret);
-		padding -= to_write;
-	}
-	return (ARCHIVE_OK);
-}
-
 static ssize_t
 archive_write_pax_data(struct archive_write *a, const void *buff, size_t s)
 {
 	struct pax *pax;
+	size_t ws;
+	size_t total;
 	int ret;
 
 	pax = (struct pax *)a->format_data;
-	if (s > pax->entry_bytes_remaining)
-		s = pax->entry_bytes_remaining;
 
-	ret = (a->compressor.write)(a, buff, s);
-	pax->entry_bytes_remaining -= s;
-	if (ret == ARCHIVE_OK)
-		return (s);
-	else
-		return (ret);
+	/*
+	 * According to GNU PAX format 1.0, write a sparse map
+	 * before the body.
+	 */
+	if (archive_strlen(&(pax->sparse_map))) {
+		ret = __archive_write_output(a, pax->sparse_map.s,
+		    archive_strlen(&(pax->sparse_map)));
+		if (ret != ARCHIVE_OK)
+			return (ret);
+		ret = __archive_write_nulls(a, pax->sparse_map_padding);
+		if (ret != ARCHIVE_OK)
+			return (ret);
+		archive_string_empty(&(pax->sparse_map));
+	}
+
+	total = 0;
+	while (total < s) {
+		const unsigned char *p;
+
+		while (pax->sparse_list != NULL &&
+		    pax->sparse_list->remaining == 0) {
+			struct sparse_block *sb = pax->sparse_list->next;
+			free(pax->sparse_list);
+			pax->sparse_list = sb;
+		}
+
+		if (pax->sparse_list == NULL)
+			return (total);
+
+		p = ((const unsigned char *)buff) + total;
+		ws = s - total;
+		if (ws > pax->sparse_list->remaining)
+			ws = pax->sparse_list->remaining;
+
+		if (pax->sparse_list->is_hole) {
+			/* Current block is hole thus we do not write
+			 * the body. */
+			pax->sparse_list->remaining -= ws;
+			total += ws;
+			continue;
+		}
+
+		ret = __archive_write_output(a, p, ws);
+		pax->sparse_list->remaining -= ws;
+		total += ws;
+		if (ret != ARCHIVE_OK)
+			return (ret);
+	}
+	return (total);
 }
 
 static int
-has_non_ASCII(const wchar_t *wp)
+has_non_ASCII(const char *_p)
 {
-	if (wp == NULL)
+	const unsigned char *p = (const unsigned char *)_p;
+
+	if (p == NULL)
 		return (1);
-	while (*wp != L'\0' && *wp < 128)
-		wp++;
-	return (*wp != L'\0');
+	while (*p != '\0' && *p < 128)
+		p++;
+	return (*p != '\0');
 }
 
 /*
@@ -1384,3 +1838,60 @@
 	*d = '\0';
 	return (out);
 }
+
+static void
+sparse_list_clear(struct pax *pax)
+{
+	while (pax->sparse_list != NULL) {
+		struct sparse_block *sb = pax->sparse_list;
+		pax->sparse_list = sb->next;
+		free(sb);
+	}
+	pax->sparse_tail = NULL;
+}
+
+static int
+_sparse_list_add_block(struct pax *pax, int64_t offset, int64_t length,
+    int is_hole)
+{
+	struct sparse_block *sb;
+
+	sb = (struct sparse_block *)malloc(sizeof(*sb));
+	if (sb == NULL)
+		return (ARCHIVE_FATAL);
+	sb->next = NULL;
+	sb->is_hole = is_hole;
+	sb->offset = offset;
+	sb->remaining = length;
+	if (pax->sparse_list == NULL)
+		pax->sparse_list = pax->sparse_tail = sb;
+	else {
+		pax->sparse_tail->next = sb;
+		pax->sparse_tail = sb;
+	}
+	return (ARCHIVE_OK);
+}
+
+static int
+sparse_list_add(struct pax *pax, int64_t offset, int64_t length)
+{
+	int64_t last_offset;
+	int r;
+
+	if (pax->sparse_tail == NULL)
+		last_offset = 0;
+	else {
+		last_offset = pax->sparse_tail->offset +
+		    pax->sparse_tail->remaining;
+	}
+	if (last_offset < offset) {
+		/* Add a hole block. */
+		r = _sparse_list_add_block(pax, last_offset,
+		    offset - last_offset, 1);
+		if (r != ARCHIVE_OK)
+			return (r);
+	}
+	/* Add data block. */
+	return (_sparse_list_add_block(pax, offset, length, 0));
+}
+
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_write_set_format_shar.c
--- a/head/contrib/libarchive/libarchive/archive_write_set_format_shar.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_write_set_format_shar.c	Fri Mar 02 16:54:40 2012 +0200
@@ -25,7 +25,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write_set_format_shar.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write_set_format_shar.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
@@ -59,8 +59,8 @@
 	struct archive_string	 quoted_name;
 };
 
-static int	archive_write_shar_finish(struct archive_write *);
-static int	archive_write_shar_destroy(struct archive_write *);
+static int	archive_write_shar_close(struct archive_write *);
+static int	archive_write_shar_free(struct archive_write *);
 static int	archive_write_shar_header(struct archive_write *,
 		    struct archive_entry *);
 static ssize_t	archive_write_shar_data_sed(struct archive_write *,
@@ -106,9 +106,12 @@
 	struct archive_write *a = (struct archive_write *)_a;
 	struct shar *shar;
 
+	archive_check_magic(_a, ARCHIVE_WRITE_MAGIC,
+	    ARCHIVE_STATE_NEW, "archive_write_set_format_shar");
+
 	/* If someone else was already registered, unregister them. */
-	if (a->format_destroy != NULL)
-		(a->format_destroy)(a);
+	if (a->format_free != NULL)
+		(a->format_free)(a);
 
 	shar = (struct shar *)malloc(sizeof(*shar));
 	if (shar == NULL) {
@@ -119,12 +122,10 @@
 	archive_string_init(&shar->work);
 	archive_string_init(&shar->quoted_name);
 	a->format_data = shar;
-
-	a->pad_uncompressed = 0;
 	a->format_name = "shar";
 	a->format_write_header = archive_write_shar_header;
-	a->format_finish = archive_write_shar_finish;
-	a->format_destroy = archive_write_shar_destroy;
+	a->format_close = archive_write_shar_close;
+	a->format_free = archive_write_shar_free;
 	a->format_write_data = archive_write_shar_data_sed;
 	a->format_finish_entry = archive_write_shar_finish_entry;
 	a->archive.archive_format = ARCHIVE_FORMAT_SHAR_BASE;
@@ -266,12 +267,12 @@
 				    shar->quoted_name.s, shar->quoted_name.s);
 			} else {
 				if (shar->dump) {
+					unsigned int mode = archive_entry_mode(entry) & 0777;
 					archive_string_sprintf(&shar->work,
 					    "uudecode -p > %s << 'SHAR_END'\n",
 					    shar->quoted_name.s);
 					archive_string_sprintf(&shar->work,
-					    "begin %o ",
-					    archive_entry_mode(entry) & 0777);
+					    "begin %o ", mode);
 					shar_quote(&shar->work, name, 0);
 					archive_strcat(&shar->work, "\n");
 				} else {
@@ -308,15 +309,15 @@
 			break;
 		case AE_IFCHR:
 			archive_string_sprintf(&shar->work,
-			    "mknod %s c %d %d\n", shar->quoted_name.s,
-			    archive_entry_rdevmajor(entry),
-			    archive_entry_rdevminor(entry));
+			    "mknod %s c %ju %ju\n", shar->quoted_name.s,
+			    (uintmax_t)archive_entry_rdevmajor(entry),
+			    (uintmax_t)archive_entry_rdevminor(entry));
 			break;
 		case AE_IFBLK:
 			archive_string_sprintf(&shar->work,
-			    "mknod %s b %d %d\n", shar->quoted_name.s,
-			    archive_entry_rdevmajor(entry),
-			    archive_entry_rdevminor(entry));
+			    "mknod %s b %ju %ju\n", shar->quoted_name.s,
+			    (uintmax_t)archive_entry_rdevmajor(entry),
+			    (uintmax_t)archive_entry_rdevminor(entry));
 			break;
 		default:
 			return (ARCHIVE_WARN);
@@ -349,11 +350,13 @@
 	 * twice before entering the loop, so make sure three additional
 	 * bytes can be written.
 	 */
-	if (archive_string_ensure(&shar->work, ensured + 3) == NULL)
-		__archive_errx(1, "Out of memory");
+	if (archive_string_ensure(&shar->work, ensured + 3) == NULL) {
+		archive_set_error(&a->archive, ENOMEM, "Out of memory");
+		return (ARCHIVE_FATAL);
+	}
 
 	if (shar->work.length > ensured) {
-		ret = (*a->compressor.write)(a, shar->work.s,
+		ret = __archive_write_output(a, shar->work.s,
 		    shar->work.length);
 		if (ret != ARCHIVE_OK)
 			return (ARCHIVE_FATAL);
@@ -377,7 +380,7 @@
 
 		if (buf >= buf_end) {
 			shar->work.length = buf - shar->work.s;
-			ret = (*a->compressor.write)(a, shar->work.s,
+			ret = __archive_write_output(a, shar->work.s,
 			    shar->work.length);
 			if (ret != ARCHIVE_OK)
 				return (ARCHIVE_FATAL);
@@ -406,16 +409,18 @@
 	out[3] = UUENC( 0x3f & t );
 }
 
-static void
-uuencode_line(struct shar *shar, const char *inbuf, size_t len)
+static int
+_uuencode_line(struct archive_write *a, struct shar *shar, const char *inbuf, size_t len)
 {
-	char tmp_buf[3], *buf;
+	char *buf;
 	size_t alloc_len;
 
 	/* len <= 45 -> expanded to 60 + len byte + new line */
 	alloc_len = shar->work.length + 62;
-	if (archive_string_ensure(&shar->work, alloc_len) == NULL)
-		__archive_errx(1, "Out of memory");
+	if (archive_string_ensure(&shar->work, alloc_len) == NULL) {
+		archive_set_error(&a->archive, ENOMEM, "Out of memory");
+		return (ARCHIVE_FATAL);
+	}
 
 	buf = shar->work.s + shar->work.length;
 	*buf++ = UUENC(len);
@@ -426,21 +431,33 @@
 		buf += 4;
 	}
 	if (len != 0) {
+		char tmp_buf[3];
 		tmp_buf[0] = inbuf[0];
 		if (len == 1)
 			tmp_buf[1] = '\0';
 		else
 			tmp_buf[1] = inbuf[1];
 		tmp_buf[2] = '\0';
-		uuencode_group(inbuf, buf);
+		uuencode_group(tmp_buf, buf);
 		buf += 4;
 	}
 	*buf++ = '\n';
-	if ((buf - shar->work.s) > (ptrdiff_t)(shar->work.length + 62))
-		__archive_errx(1, "Buffer overflow");
+	if ((buf - shar->work.s) > (ptrdiff_t)(shar->work.length + 62)) {
+		archive_set_error(&a->archive,
+		    ARCHIVE_ERRNO_MISC, "Buffer overflow");
+		return (ARCHIVE_FATAL);
+	}
 	shar->work.length = buf - shar->work.s;
+	return (ARCHIVE_OK);
 }
 
+#define uuencode_line(__a, __shar, __inbuf, __len) \
+	do { \
+		int r = _uuencode_line(__a, __shar, __inbuf, __len); \
+		if (r != ARCHIVE_OK) \
+			return (ARCHIVE_FATAL); \
+	} while (0)
+
 static ssize_t
 archive_write_shar_data_uuencode(struct archive_write *a, const void *buff,
     size_t length)
@@ -464,7 +481,7 @@
 			shar->outpos += n;
 			return length;
 		}
-		uuencode_line(shar, shar->outbuff, 45);
+		uuencode_line(a, shar, shar->outbuff, 45);
 		src += n;
 		n = length - n;
 	} else {
@@ -472,13 +489,13 @@
 	}
 
 	while (n >= 45) {
-		uuencode_line(shar, src, 45);
+		uuencode_line(a, shar, src, 45);
 		src += 45;
 		n -= 45;
 
 		if (shar->work.length < 65536)
 			continue;
-		ret = (*a->compressor.write)(a, shar->work.s,
+		ret = __archive_write_output(a, shar->work.s,
 		    shar->work.length);
 		if (ret != ARCHIVE_OK)
 			return (ARCHIVE_FATAL);
@@ -506,7 +523,7 @@
 		/* Finish uuencoded data. */
 		if (shar->has_data) {
 			if (shar->outpos > 0)
-				uuencode_line(shar, shar->outbuff,
+				uuencode_line(a, shar, shar->outbuff,
 				    shar->outpos);
 			archive_strcat(&shar->work, "`\nend\n");
 			archive_strcat(&shar->work, "SHAR_END\n");
@@ -517,7 +534,7 @@
 		 * directories; defer that to end of script.
 		 */
 		archive_string_sprintf(&shar->work, "chmod %o ",
-		    archive_entry_mode(shar->entry) & 07777);
+		    (unsigned int)(archive_entry_mode(shar->entry) & 07777));
 		shar_quote(&shar->work, archive_entry_pathname(shar->entry), 1);
 		archive_strcat(&shar->work, "\n");
 
@@ -560,7 +577,7 @@
 	if (shar->work.length < 65536)
 		return (ARCHIVE_OK);
 
-	ret = (*a->compressor.write)(a, shar->work.s, shar->work.length);
+	ret = __archive_write_output(a, shar->work.s, shar->work.length);
 	if (ret != ARCHIVE_OK)
 		return (ARCHIVE_FATAL);
 	archive_string_empty(&shar->work);
@@ -569,7 +586,7 @@
 }
 
 static int
-archive_write_shar_finish(struct archive_write *a)
+archive_write_shar_close(struct archive_write *a)
 {
 	struct shar *shar;
 	int ret;
@@ -592,7 +609,7 @@
 
 	archive_strcat(&shar->work, "exit\n");
 
-	ret = (*a->compressor.write)(a, shar->work.s, shar->work.length);
+	ret = __archive_write_output(a, shar->work.s, shar->work.length);
 	if (ret != ARCHIVE_OK)
 		return (ARCHIVE_FATAL);
 
@@ -607,7 +624,7 @@
 }
 
 static int
-archive_write_shar_destroy(struct archive_write *a)
+archive_write_shar_free(struct archive_write *a)
 {
 	struct shar *shar;
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_write_set_format_ustar.c
--- a/head/contrib/libarchive/libarchive/archive_write_set_format_ustar.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_write_set_format_ustar.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,6 @@
 /*-
  * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2011-2012 Michihiro NAKAJIMA
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -24,7 +25,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write_set_format_ustar.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write_set_format_ustar.c 232153 2012-02-25 10:58:02Z mm $");
 
 
 #ifdef HAVE_ERRNO_H
@@ -40,12 +41,17 @@
 
 #include "archive.h"
 #include "archive_entry.h"
+#include "archive_entry_locale.h"
 #include "archive_private.h"
 #include "archive_write_private.h"
 
 struct ustar {
 	uint64_t	entry_bytes_remaining;
 	uint64_t	entry_padding;
+
+	struct archive_string_conv *opt_sconv;
+	struct archive_string_conv *sconv_default;
+	int	init_default_conversion;
 };
 
 /*
@@ -143,15 +149,16 @@
 
 static ssize_t	archive_write_ustar_data(struct archive_write *a, const void *buff,
 		    size_t s);
-static int	archive_write_ustar_destroy(struct archive_write *);
-static int	archive_write_ustar_finish(struct archive_write *);
+static int	archive_write_ustar_free(struct archive_write *);
+static int	archive_write_ustar_close(struct archive_write *);
 static int	archive_write_ustar_finish_entry(struct archive_write *);
 static int	archive_write_ustar_header(struct archive_write *,
 		    struct archive_entry *entry);
+static int	archive_write_ustar_options(struct archive_write *,
+		    const char *, const char *);
 static int	format_256(int64_t, char *, int);
 static int	format_number(int64_t, char *, int size, int max, int strict);
 static int	format_octal(int64_t, char *, int);
-static int	write_nulls(struct archive_write *a, size_t);
 
 /*
  * Set output format to 'ustar' format.
@@ -162,30 +169,35 @@
 	struct archive_write *a = (struct archive_write *)_a;
 	struct ustar *ustar;
 
+	archive_check_magic(_a, ARCHIVE_WRITE_MAGIC,
+	    ARCHIVE_STATE_NEW, "archive_write_set_format_ustar");
+
 	/* If someone else was already registered, unregister them. */
-	if (a->format_destroy != NULL)
-		(a->format_destroy)(a);
+	if (a->format_free != NULL)
+		(a->format_free)(a);
 
 	/* Basic internal sanity test. */
 	if (sizeof(template_header) != 512) {
-		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Internal: template_header wrong size: %d should be 512", (int)sizeof(template_header));
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+		    "Internal: template_header wrong size: %zu should be 512",
+		    sizeof(template_header));
 		return (ARCHIVE_FATAL);
 	}
 
 	ustar = (struct ustar *)malloc(sizeof(*ustar));
 	if (ustar == NULL) {
-		archive_set_error(&a->archive, ENOMEM, "Can't allocate ustar data");
+		archive_set_error(&a->archive, ENOMEM,
+		    "Can't allocate ustar data");
 		return (ARCHIVE_FATAL);
 	}
 	memset(ustar, 0, sizeof(*ustar));
 	a->format_data = ustar;
-
-	a->pad_uncompressed = 1;	/* Mimic gtar in this respect. */
 	a->format_name = "ustar";
+	a->format_options = archive_write_ustar_options;
 	a->format_write_header = archive_write_ustar_header;
 	a->format_write_data = archive_write_ustar_data;
-	a->format_finish = archive_write_ustar_finish;
-	a->format_destroy = archive_write_ustar_destroy;
+	a->format_close = archive_write_ustar_close;
+	a->format_free = archive_write_ustar_free;
 	a->format_finish_entry = archive_write_ustar_finish_entry;
 	a->archive.archive_format = ARCHIVE_FORMAT_TAR_USTAR;
 	a->archive.archive_format_name = "POSIX ustar";
@@ -193,14 +205,63 @@
 }
 
 static int
+archive_write_ustar_options(struct archive_write *a, const char *key,
+    const char *val)
+{
+	struct ustar *ustar = (struct ustar *)a->format_data;
+	int ret = ARCHIVE_FAILED;
+
+	if (strcmp(key, "hdrcharset")  == 0) {
+		if (val == NULL || val[0] == 0)
+			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+			    "%s: hdrcharset option needs a character-set name",
+			    a->format_name);
+		else {
+			ustar->opt_sconv = archive_string_conversion_to_charset(
+			    &a->archive, val, 0);
+			if (ustar->opt_sconv != NULL)
+				ret = ARCHIVE_OK;
+			else
+				ret = ARCHIVE_FATAL;
+		}
+		return (ret);
+	}
+
+	/* Note: The "warn" return is just to inform the options
+	 * supervisor that we didn't handle it.  It will generate
+	 * a suitable error if no one used this option. */
+	return (ARCHIVE_WARN);
+}
+
+static int
 archive_write_ustar_header(struct archive_write *a, struct archive_entry *entry)
 {
 	char buff[512];
 	int ret, ret2;
 	struct ustar *ustar;
+	struct archive_entry *entry_main;
+	struct archive_string_conv *sconv;
 
 	ustar = (struct ustar *)a->format_data;
 
+	/* Setup default string conversion. */
+	if (ustar->opt_sconv == NULL) {
+		if (!ustar->init_default_conversion) {
+			ustar->sconv_default =
+			    archive_string_default_conversion_for_write(&(a->archive));
+			ustar->init_default_conversion = 1;
+		}
+		sconv = ustar->sconv_default;
+	} else
+		sconv = ustar->opt_sconv;
+
+	/* Sanity check. */
+	if (archive_entry_pathname(entry) == NULL) {
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+		    "Can't record entry in tar file without pathname");
+		return (ARCHIVE_FAILED);
+	}
+
 	/* Only regular files (not hardlinks) have data. */
 	if (archive_entry_hardlink(entry) != NULL ||
 	    archive_entry_symlink(entry) != NULL ||
@@ -209,37 +270,106 @@
 
 	if (AE_IFDIR == archive_entry_filetype(entry)) {
 		const char *p;
-		char *t;
+		size_t path_length;
 		/*
 		 * Ensure a trailing '/'.  Modify the entry so
 		 * the client sees the change.
 		 */
-		p = archive_entry_pathname(entry);
-		if (p[strlen(p) - 1] != '/') {
-			t = (char *)malloc(strlen(p) + 2);
-			if (t == NULL) {
+#if defined(_WIN32) && !defined(__CYGWIN__)
+		const wchar_t *wp;
+
+		wp = archive_entry_pathname_w(entry);
+		if (wp != NULL && wp[wcslen(wp) -1] != L'/') {
+			struct archive_wstring ws;
+
+			archive_string_init(&ws);
+			path_length = wcslen(wp);
+			if (archive_wstring_ensure(&ws,
+			    path_length + 2) == NULL) {
 				archive_set_error(&a->archive, ENOMEM,
-				"Can't allocate ustar data");
+				    "Can't allocate ustar data");
+				archive_wstring_free(&ws);
 				return(ARCHIVE_FATAL);
 			}
-			strcpy(t, p);
-			strcat(t, "/");
-			archive_entry_copy_pathname(entry, t);
-			free(t);
+			/* Should we keep '\' ? */
+			if (wp[path_length -1] == L'\\')
+				path_length--;
+			archive_wstrncpy(&ws, wp, path_length);
+			archive_wstrappend_wchar(&ws, L'/');
+			archive_entry_copy_pathname_w(entry, ws.s);
+			archive_wstring_free(&ws);
+			p = NULL;
+		} else
+#endif
+			p = archive_entry_pathname(entry);
+		/*
+		 * On Windows, this is a backup operation just in
+		 * case getting WCS failed. On POSIX, this is a
+		 * normal operation.
+		 */
+		if (p != NULL && p[strlen(p) - 1] != '/') {
+			struct archive_string as;
+
+			archive_string_init(&as);
+			path_length = strlen(p);
+			if (archive_string_ensure(&as,
+			    path_length + 2) == NULL) {
+				archive_set_error(&a->archive, ENOMEM,
+				    "Can't allocate ustar data");
+				archive_string_free(&as);
+				return(ARCHIVE_FATAL);
+			}
+#if defined(_WIN32) && !defined(__CYGWIN__)
+			/* NOTE: This might break the pathname
+			 * if the current code page is CP932 and
+			 * the pathname includes a character '\'
+			 * as a part of its multibyte pathname. */
+			if (p[strlen(p) -1] == '\\')
+				path_length--;
+			else
+#endif
+			archive_strncpy(&as, p, path_length);
+			archive_strappend_char(&as, '/');
+			archive_entry_copy_pathname(entry, as.s);
+			archive_string_free(&as);
 		}
 	}
 
-	ret = __archive_write_format_header_ustar(a, buff, entry, -1, 1);
-	if (ret < ARCHIVE_WARN)
+#if defined(_WIN32) && !defined(__CYGWIN__)
+	/* Make sure the path separators in pahtname, hardlink and symlink
+	 * are all slash '/', not the Windows path separator '\'. */
+	entry_main = __la_win_entry_in_posix_pathseparator(entry);
+	if (entry_main == NULL) {
+		archive_set_error(&a->archive, ENOMEM,
+		    "Can't allocate ustar data");
+		return(ARCHIVE_FATAL);
+	}
+	if (entry != entry_main)
+		entry = entry_main;
+	else
+		entry_main = NULL;
+#else
+	entry_main = NULL;
+#endif
+	ret = __archive_write_format_header_ustar(a, buff, entry, -1, 1, sconv);
+	if (ret < ARCHIVE_WARN) {
+		if (entry_main)
+			archive_entry_free(entry_main);
 		return (ret);
-	ret2 = (a->compressor.write)(a, buff, 512);
-	if (ret2 < ARCHIVE_WARN)
+	}
+	ret2 = __archive_write_output(a, buff, 512);
+	if (ret2 < ARCHIVE_WARN) {
+		if (entry_main)
+			archive_entry_free(entry_main);
 		return (ret2);
+	}
 	if (ret2 < ret)
 		ret = ret2;
 
 	ustar->entry_bytes_remaining = archive_entry_size(entry);
 	ustar->entry_padding = 0x1ff & (-(int64_t)ustar->entry_bytes_remaining);
+	if (entry_main)
+		archive_entry_free(entry_main);
 	return (ret);
 }
 
@@ -255,10 +385,11 @@
  */
 int
 __archive_write_format_header_ustar(struct archive_write *a, char h[512],
-    struct archive_entry *entry, int tartype, int strict)
+    struct archive_entry *entry, int tartype, int strict,
+    struct archive_string_conv *sconv)
 {
 	unsigned int checksum;
-	int i, ret;
+	int i, r, ret;
 	size_t copy_length;
 	const char *p, *pp;
 	int mytartype;
@@ -277,13 +408,23 @@
 	 * are allowed to exactly fill their destination (without null),
 	 * I use memcpy(dest, src, strlen()) here a lot to copy strings.
 	 */
-
-	pp = archive_entry_pathname(entry);
-	if (strlen(pp) <= USTAR_name_size)
-		memcpy(h + USTAR_name_offset, pp, strlen(pp));
+	r = archive_entry_pathname_l(entry, &pp, &copy_length, sconv);
+	if (r != 0) {
+		if (errno == ENOMEM) {
+			archive_set_error(&a->archive, ENOMEM,
+			    "Can't allocate memory for Pathname");
+			return (ARCHIVE_FATAL);
+		}
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+		    "Can't translate pathname '%s' to %s",
+		    pp, archive_string_conversion_charset_name(sconv));
+		ret = ARCHIVE_WARN;
+	}
+	if (copy_length <= USTAR_name_size)
+		memcpy(h + USTAR_name_offset, pp, copy_length);
 	else {
 		/* Store in two pieces, splitting at a '/'. */
-		p = strchr(pp + strlen(pp) - USTAR_name_size - 1, '/');
+		p = strchr(pp + copy_length - USTAR_name_size - 1, '/');
 		/*
 		 * Look for the next '/' if we chose the first character
 		 * as the separator.  (ustar format doesn't permit
@@ -302,7 +443,7 @@
 			 * The only feasible separator is a final '/';
 			 * this would result in a non-empty prefix and
 			 * an empty name, which POSIX doesn't
-			 * explicity forbid, but it just feels wrong.
+			 * explicitly forbid, but it just feels wrong.
 			 */
 			archive_set_error(&a->archive, ENAMETOOLONG,
 			    "Pathname too long");
@@ -315,17 +456,42 @@
 		} else {
 			/* Copy prefix and remainder to appropriate places */
 			memcpy(h + USTAR_prefix_offset, pp, p - pp);
-			memcpy(h + USTAR_name_offset, p + 1, pp + strlen(pp) - p - 1);
+			memcpy(h + USTAR_name_offset, p + 1,
+			    pp + copy_length - p - 1);
 		}
 	}
 
-	p = archive_entry_hardlink(entry);
-	if (p != NULL)
+	r = archive_entry_hardlink_l(entry, &p, &copy_length, sconv);
+	if (r != 0) {
+		if (errno == ENOMEM) {
+			archive_set_error(&a->archive, ENOMEM,
+			    "Can't allocate memory for Linkname");
+			return (ARCHIVE_FATAL);
+		}
+		archive_set_error(&a->archive,
+		    ARCHIVE_ERRNO_FILE_FORMAT,
+		    "Can't translate linkname '%s' to %s",
+		    p, archive_string_conversion_charset_name(sconv));
+		ret = ARCHIVE_WARN;
+	}
+	if (copy_length > 0)
 		mytartype = '1';
-	else
-		p = archive_entry_symlink(entry);
-	if (p != NULL && p[0] != '\0') {
-		copy_length = strlen(p);
+	else {
+		r = archive_entry_symlink_l(entry, &p, &copy_length, sconv);
+		if (r != 0) {
+			if (errno == ENOMEM) {
+				archive_set_error(&a->archive, ENOMEM,
+				    "Can't allocate memory for Linkname");
+				return (ARCHIVE_FATAL);
+			}
+			archive_set_error(&a->archive,
+			    ARCHIVE_ERRNO_FILE_FORMAT,
+			    "Can't translate linkname '%s' to %s",
+			    p, archive_string_conversion_charset_name(sconv));
+			ret = ARCHIVE_WARN;
+		}
+	}
+	if (copy_length > 0) {
 		if (copy_length > USTAR_linkname_size) {
 			archive_set_error(&a->archive, ENAMETOOLONG,
 			    "Link contents too long");
@@ -335,9 +501,20 @@
 		memcpy(h + USTAR_linkname_offset, p, copy_length);
 	}
 
-	p = archive_entry_uname(entry);
-	if (p != NULL && p[0] != '\0') {
-		copy_length = strlen(p);
+	r = archive_entry_uname_l(entry, &p, &copy_length, sconv);
+	if (r != 0) {
+		if (errno == ENOMEM) {
+			archive_set_error(&a->archive, ENOMEM,
+			    "Can't allocate memory for Uname");
+			return (ARCHIVE_FATAL);
+		}
+		archive_set_error(&a->archive,
+		    ARCHIVE_ERRNO_FILE_FORMAT,
+		    "Can't translate uname '%s' to %s",
+		    p, archive_string_conversion_charset_name(sconv));
+		ret = ARCHIVE_WARN;
+	}
+	if (copy_length > 0) {
 		if (copy_length > USTAR_uname_size) {
 			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
 			    "Username too long");
@@ -347,9 +524,20 @@
 		memcpy(h + USTAR_uname_offset, p, copy_length);
 	}
 
-	p = archive_entry_gname(entry);
-	if (p != NULL && p[0] != '\0') {
-		copy_length = strlen(p);
+	r = archive_entry_gname_l(entry, &p, &copy_length, sconv);
+	if (r != 0) {
+		if (errno == ENOMEM) {
+			archive_set_error(&a->archive, ENOMEM,
+			    "Can't allocate memory for Gname");
+			return (ARCHIVE_FATAL);
+		}
+		archive_set_error(&a->archive,
+		    ARCHIVE_ERRNO_FILE_FORMAT,
+		    "Can't translate gname '%s' to %s",
+		    p, archive_string_conversion_charset_name(sconv));
+		ret = ARCHIVE_WARN;
+	}
+	if (copy_length > 0) {
 		if (strlen(p) > USTAR_gname_size) {
 			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
 			    "Group name too long");
@@ -359,27 +547,36 @@
 		memcpy(h + USTAR_gname_offset, p, copy_length);
 	}
 
-	if (format_number(archive_entry_mode(entry) & 07777, h + USTAR_mode_offset, USTAR_mode_size, USTAR_mode_max_size, strict)) {
-		archive_set_error(&a->archive, ERANGE, "Numeric mode too large");
+	if (format_number(archive_entry_mode(entry) & 07777,
+	    h + USTAR_mode_offset, USTAR_mode_size, USTAR_mode_max_size, strict)) {
+		archive_set_error(&a->archive, ERANGE,
+		    "Numeric mode too large");
 		ret = ARCHIVE_FAILED;
 	}
 
-	if (format_number(archive_entry_uid(entry), h + USTAR_uid_offset, USTAR_uid_size, USTAR_uid_max_size, strict)) {
-		archive_set_error(&a->archive, ERANGE, "Numeric user ID too large");
+	if (format_number(archive_entry_uid(entry),
+	    h + USTAR_uid_offset, USTAR_uid_size, USTAR_uid_max_size, strict)) {
+		archive_set_error(&a->archive, ERANGE,
+		    "Numeric user ID too large");
 		ret = ARCHIVE_FAILED;
 	}
 
-	if (format_number(archive_entry_gid(entry), h + USTAR_gid_offset, USTAR_gid_size, USTAR_gid_max_size, strict)) {
-		archive_set_error(&a->archive, ERANGE, "Numeric group ID too large");
+	if (format_number(archive_entry_gid(entry),
+	    h + USTAR_gid_offset, USTAR_gid_size, USTAR_gid_max_size, strict)) {
+		archive_set_error(&a->archive, ERANGE,
+		    "Numeric group ID too large");
 		ret = ARCHIVE_FAILED;
 	}
 
-	if (format_number(archive_entry_size(entry), h + USTAR_size_offset, USTAR_size_size, USTAR_size_max_size, strict)) {
-		archive_set_error(&a->archive, ERANGE, "File size out of range");
+	if (format_number(archive_entry_size(entry),
+	    h + USTAR_size_offset, USTAR_size_size, USTAR_size_max_size, strict)) {
+		archive_set_error(&a->archive, ERANGE,
+		    "File size out of range");
 		ret = ARCHIVE_FAILED;
 	}
 
-	if (format_number(archive_entry_mtime(entry), h + USTAR_mtime_offset, USTAR_mtime_size, USTAR_mtime_max_size, strict)) {
+	if (format_number(archive_entry_mtime(entry),
+	    h + USTAR_mtime_offset, USTAR_mtime_size, USTAR_mtime_max_size, strict)) {
 		archive_set_error(&a->archive, ERANGE,
 		    "File modification time too large");
 		ret = ARCHIVE_FAILED;
@@ -387,15 +584,17 @@
 
 	if (archive_entry_filetype(entry) == AE_IFBLK
 	    || archive_entry_filetype(entry) == AE_IFCHR) {
-		if (format_number(archive_entry_rdevmajor(entry), h + USTAR_rdevmajor_offset,
-			USTAR_rdevmajor_size, USTAR_rdevmajor_max_size, strict)) {
+		if (format_number(archive_entry_rdevmajor(entry),
+		    h + USTAR_rdevmajor_offset, USTAR_rdevmajor_size,
+		    USTAR_rdevmajor_max_size, strict)) {
 			archive_set_error(&a->archive, ERANGE,
 			    "Major device number too large");
 			ret = ARCHIVE_FAILED;
 		}
 
-		if (format_number(archive_entry_rdevminor(entry), h + USTAR_rdevminor_offset,
-			USTAR_rdevminor_size, USTAR_rdevminor_max_size, strict)) {
+		if (format_number(archive_entry_rdevminor(entry),
+		    h + USTAR_rdevminor_offset, USTAR_rdevminor_size,
+		    USTAR_rdevminor_max_size, strict)) {
 			archive_set_error(&a->archive, ERANGE,
 			    "Minor device number too large");
 			ret = ARCHIVE_FAILED;
@@ -519,19 +718,13 @@
 }
 
 static int
-archive_write_ustar_finish(struct archive_write *a)
+archive_write_ustar_close(struct archive_write *a)
 {
-	int r;
-
-	if (a->compressor.write == NULL)
-		return (ARCHIVE_OK);
-
-	r = write_nulls(a, 512*2);
-	return (r);
+	return (__archive_write_nulls(a, 512*2));
 }
 
 static int
-archive_write_ustar_destroy(struct archive_write *a)
+archive_write_ustar_free(struct archive_write *a)
 {
 	struct ustar *ustar;
 
@@ -548,28 +741,12 @@
 	int ret;
 
 	ustar = (struct ustar *)a->format_data;
-	ret = write_nulls(a,
+	ret = __archive_write_nulls(a,
 	    ustar->entry_bytes_remaining + ustar->entry_padding);
 	ustar->entry_bytes_remaining = ustar->entry_padding = 0;
 	return (ret);
 }
 
-static int
-write_nulls(struct archive_write *a, size_t padding)
-{
-	int ret;
-	size_t to_write;
-
-	while (padding > 0) {
-		to_write = padding < a->null_length ? padding : a->null_length;
-		ret = (a->compressor.write)(a, a->nulls, to_write);
-		if (ret != ARCHIVE_OK)
-			return (ret);
-		padding -= to_write;
-	}
-	return (ARCHIVE_OK);
-}
-
 static ssize_t
 archive_write_ustar_data(struct archive_write *a, const void *buff, size_t s)
 {
@@ -579,7 +756,7 @@
 	ustar = (struct ustar *)a->format_data;
 	if (s > ustar->entry_bytes_remaining)
 		s = ustar->entry_bytes_remaining;
-	ret = (a->compressor.write)(a, buff, s);
+	ret = __archive_write_output(a, buff, s);
 	ustar->entry_bytes_remaining -= s;
 	if (ret != ARCHIVE_OK)
 		return (ret);
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/archive_write_set_format_zip.c
--- a/head/contrib/libarchive/libarchive/archive_write_set_format_zip.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_write_set_format_zip.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,6 +1,7 @@
 /*-
  * Copyright (c) 2008 Anselm Strauss
  * Copyright (c) 2009 Joerg Sonnenberger
+ * Copyright (c) 2011-2012 Michihiro NAKAJIMA
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -47,12 +48,14 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write_set_format_zip.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_write_set_format_zip.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
 #endif
-#include <stdio.h>
+#ifdef HAVE_LANGINFO_H
+#include <langinfo.h>
+#endif
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
@@ -66,6 +69,7 @@
 #include "archive.h"
 #include "archive_endian.h"
 #include "archive_entry.h"
+#include "archive_entry_locale.h"
 #include "archive_private.h"
 #include "archive_write_private.h"
 
@@ -78,10 +82,11 @@
 #define ZIP_SIGNATURE_FILE_HEADER 0x02014b50
 #define ZIP_SIGNATURE_CENTRAL_DIRECTORY_END 0x06054b50
 #define ZIP_SIGNATURE_EXTRA_TIMESTAMP 0x5455
-#define ZIP_SIGNATURE_EXTRA_UNIX 0x7855
+#define ZIP_SIGNATURE_EXTRA_NEW_UNIX 0x7875
 #define ZIP_VERSION_EXTRACT 0x0014 /* ZIP version 2.0 is needed. */
 #define ZIP_VERSION_BY 0x0314 /* Made by UNIX, using ZIP version 2.0. */
 #define ZIP_FLAGS 0x08 /* Flagging bit 3 (count from 0) for using data descriptor. */
+#define ZIP_FLAGS_UTF8_NAME	(1 << 11)
 
 enum compression {
 	COMPRESSION_STORE = 0
@@ -91,11 +96,15 @@
 #endif
 };
 
-static ssize_t archive_write_zip_data(struct archive_write *, const void *buff, size_t s);
-static int archive_write_zip_finish(struct archive_write *);
-static int archive_write_zip_destroy(struct archive_write *);
+static ssize_t archive_write_zip_data(struct archive_write *,
+		   const void *buff, size_t s);
+static int archive_write_zip_close(struct archive_write *);
+static int archive_write_zip_free(struct archive_write *);
 static int archive_write_zip_finish_entry(struct archive_write *);
-static int archive_write_zip_header(struct archive_write *, struct archive_entry *);
+static int archive_write_zip_header(struct archive_write *,
+	      struct archive_entry *);
+static int archive_write_zip_options(struct archive_write *,
+	      const char *, const char *);
 static unsigned int dos_time(const time_t);
 static size_t path_length(struct archive_entry *);
 static int write_path(struct archive_entry *, struct archive_write *);
@@ -148,8 +157,11 @@
 	char ctime[4];
 	char unix_id[2];
 	char unix_size[2];
-	char unix_uid[2];
-	char unix_gid[2];
+	char unix_version;
+	char unix_uid_size;
+	char unix_uid[4];
+	char unix_gid_size;
+	char unix_gid[4];
 };
 
 struct zip_extra_data_central {
@@ -164,10 +176,11 @@
 struct zip_file_header_link {
 	struct zip_file_header_link *next;
 	struct archive_entry *entry;
-	off_t offset;
+	int64_t offset;
 	unsigned long crc32;
-	off_t compressed_size;
+	int64_t compressed_size;
 	enum compression compression;
+	int flags;
 };
 
 struct zip {
@@ -178,6 +191,10 @@
 	int64_t written_bytes;
 	int64_t remaining_data_bytes;
 	enum compression compression;
+	int flags;
+	struct archive_string_conv *opt_sconv;
+	struct archive_string_conv *sconv_default;
+	int	init_default_conversion;
 
 #ifdef HAVE_ZLIB_H
 	z_stream stream;
@@ -199,25 +216,48 @@
 
 static int
 archive_write_zip_options(struct archive_write *a, const char *key,
-    const char *value)
+    const char *val)
 {
 	struct zip *zip = a->format_data;
+	int ret = ARCHIVE_FAILED;
 
 	if (strcmp(key, "compression") == 0) {
-		if (strcmp(value, "deflate") == 0) {
+		if (val == NULL || val[0] == 0) {
+			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+			    "%s: compression option needs a compression name",
+			    a->format_name);
+		} else if (strcmp(val, "deflate") == 0) {
 #ifdef HAVE_ZLIB_H
 			zip->compression = COMPRESSION_DEFLATE;
+			ret = ARCHIVE_OK;
 #else
 			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
 			    "deflate compression not supported");
-			return ARCHIVE_WARN;
 #endif
-		} else if (strcmp(value, "store") == 0)
+		} else if (strcmp(val, "store") == 0) {
 			zip->compression = COMPRESSION_STORE;
-		else
-			return (ARCHIVE_WARN);
-		return (ARCHIVE_OK);
+			ret = ARCHIVE_OK;
+		}
+		return (ret);
+	} else if (strcmp(key, "hdrcharset")  == 0) {
+		if (val == NULL || val[0] == 0) {
+			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+			    "%s: hdrcharset option needs a character-set name",
+			    a->format_name);
+		} else {
+			zip->opt_sconv = archive_string_conversion_to_charset(
+			    &a->archive, val, 0);
+			if (zip->opt_sconv != NULL)
+				ret = ARCHIVE_OK;
+			else
+				ret = ARCHIVE_FATAL;
+		}
+		return (ret);
 	}
+
+	/* Note: The "warn" return is just to inform the options
+	 * supervisor that we didn't handle it.  It will generate
+	 * a suitable error if no one used this option. */
 	return (ARCHIVE_WARN);
 }
 
@@ -227,13 +267,17 @@
 	struct archive_write *a = (struct archive_write *)_a;
 	struct zip *zip;
 
+	archive_check_magic(_a, ARCHIVE_WRITE_MAGIC,
+	    ARCHIVE_STATE_NEW, "archive_write_set_format_zip");
+
 	/* If another format was already registered, unregister it. */
-	if (a->format_destroy != NULL)
-		(a->format_destroy)(a);
+	if (a->format_free != NULL)
+		(a->format_free)(a);
 
 	zip = (struct zip *) calloc(1, sizeof(*zip));
 	if (zip == NULL) {
-		archive_set_error(&a->archive, ENOMEM, "Can't allocate zip data");
+		archive_set_error(&a->archive, ENOMEM,
+		    "Can't allocate zip data");
 		return (ARCHIVE_FATAL);
 	}
 	zip->central_directory = NULL;
@@ -247,7 +291,8 @@
 	zip->len_buf = 65536;
 	zip->buf = malloc(zip->len_buf);
 	if (zip->buf == NULL) {
-		archive_set_error(&a->archive, ENOMEM, "Can't allocate compression buffer");
+		archive_set_error(&a->archive, ENOMEM,
+		    "Can't allocate compression buffer");
 		return (ARCHIVE_FATAL);
 	}
 #else
@@ -255,15 +300,13 @@
 #endif
 
 	a->format_data = zip;
-
-	a->pad_uncompressed = 0; /* Actually not needed for now, since no compression support yet. */
 	a->format_name = "zip";
 	a->format_options = archive_write_zip_options;
 	a->format_write_header = archive_write_zip_header;
 	a->format_write_data = archive_write_zip_data;
 	a->format_finish_entry = archive_write_zip_finish_entry;
-	a->format_finish = archive_write_zip_finish;
-	a->format_destroy = archive_write_zip_destroy;
+	a->format_close = archive_write_zip_close;
+	a->format_free = archive_write_zip_free;
 	a->archive.archive_format = ARCHIVE_FORMAT_ZIP;
 	a->archive.archive_format_name = "ZIP";
 
@@ -274,6 +317,18 @@
 }
 
 static int
+is_all_ascii(const char *p)
+{
+	const unsigned char *pp = (const unsigned char *)p;
+
+	while (*pp) {
+		if (*pp++ > 127)
+			return (0);
+	}
+	return (1);
+}
+
+static int
 archive_write_zip_header(struct archive_write *a, struct archive_entry *entry)
 {
 	struct zip *zip;
@@ -281,22 +336,44 @@
 	struct zip_extra_data_local e;
 	struct zip_data_descriptor *d;
 	struct zip_file_header_link *l;
-	int ret;
+	struct archive_string_conv *sconv;
+	int ret, ret2 = ARCHIVE_OK;
 	int64_t size;
 	mode_t type;
 
 	/* Entries other than a regular file or a folder are skipped. */
 	type = archive_entry_filetype(entry);
-	if ((type != AE_IFREG) & (type != AE_IFDIR)) {
-		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Filetype not supported");
+	if (type != AE_IFREG && type != AE_IFDIR && type != AE_IFLNK) {
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+		    "Filetype not supported");
 		return ARCHIVE_FAILED;
-	};
+	}; 
 
 	/* Directory entries should have a size of 0. */
 	if (type == AE_IFDIR)
 		archive_entry_set_size(entry, 0);
 
 	zip = a->format_data;
+	/* Setup default conversion. */
+	if (zip->opt_sconv == NULL && !zip->init_default_conversion) {
+		zip->sconv_default =
+		    archive_string_default_conversion_for_write(&(a->archive));
+		zip->init_default_conversion = 1;
+	}
+
+	if (zip->flags == 0) {
+		/* Initialize the general purpose flags. */
+		zip->flags = ZIP_FLAGS;
+		if (zip->opt_sconv != NULL) {
+			if (strcmp(archive_string_conversion_charset_name(
+			    zip->opt_sconv), "UTF-8") == 0)
+				zip->flags |= ZIP_FLAGS_UTF8_NAME;
+#if HAVE_NL_LANGINFO
+		} else if (strcmp(nl_langinfo(CODESET), "UTF-8") == 0) {
+			zip->flags |= ZIP_FLAGS_UTF8_NAME;
+#endif
+		}
+	}
 	d = &zip->data_descriptor;
 	size = archive_entry_size(entry);
 	zip->remaining_data_bytes = size;
@@ -304,14 +381,71 @@
 	/* Append archive entry to the central directory data. */
 	l = (struct zip_file_header_link *) malloc(sizeof(*l));
 	if (l == NULL) {
-		archive_set_error(&a->archive, ENOMEM, "Can't allocate zip header data");
+		archive_set_error(&a->archive, ENOMEM,
+		    "Can't allocate zip header data");
 		return (ARCHIVE_FATAL);
 	}
+#if defined(_WIN32) && !defined(__CYGWIN__)
+	/* Make sure the path separators in pahtname, hardlink and symlink
+	 * are all slash '/', not the Windows path separator '\'. */
+	l->entry = __la_win_entry_in_posix_pathseparator(entry);
+	if (l->entry == entry)
+		l->entry = archive_entry_clone(entry);
+#else
 	l->entry = archive_entry_clone(entry);
+#endif
+	if (l->entry == NULL) {
+		archive_set_error(&a->archive, ENOMEM,
+		    "Can't allocate zip header data");
+		free(l);
+		return (ARCHIVE_FATAL);
+	}
+	l->flags = zip->flags;
+	if (zip->opt_sconv != NULL)
+		sconv = zip->opt_sconv;
+	else
+		sconv = zip->sconv_default;
+	if (sconv != NULL) {
+		const char *p;
+		size_t len;
+
+		if (archive_entry_pathname_l(entry, &p, &len, sconv) != 0) {
+			if (errno == ENOMEM) {
+				archive_set_error(&a->archive, ENOMEM,
+				    "Can't allocate memory for Pathname");
+				return (ARCHIVE_FATAL);
+			}
+			archive_set_error(&a->archive,
+			    ARCHIVE_ERRNO_FILE_FORMAT,
+			    "Can't translate pathname '%s' to %s",
+			    archive_entry_pathname(entry),
+			    archive_string_conversion_charset_name(sconv));
+			ret2 = ARCHIVE_WARN;
+		}
+		if (len > 0)
+			archive_entry_set_pathname(l->entry, p);
+	}
+	/* If all character of a filename is ASCII, Reset UTF-8 Name flag. */
+	if ((l->flags & ZIP_FLAGS_UTF8_NAME) != 0 &&
+	    is_all_ascii(archive_entry_pathname(l->entry)))
+		l->flags &= ~ZIP_FLAGS_UTF8_NAME;
+
 	/* Initialize the CRC variable and potentially the local crc32(). */
 	l->crc32 = crc32(0, NULL, 0);
-	l->compression = zip->compression;
-	l->compressed_size = 0;
+	if (type == AE_IFLNK) {
+		const char *p = archive_entry_symlink(l->entry);
+		if (p != NULL)
+			size = strlen(p);
+		else
+			size = 0;
+		zip->remaining_data_bytes = 0;
+		archive_entry_set_size(l->entry, size);
+		l->compression = COMPRESSION_STORE;
+		l->compressed_size = size;
+	} else {
+		l->compression = zip->compression;
+		l->compressed_size = 0;
+	}
 	l->next = NULL;
 	if (zip->central_directory == NULL) {
 		zip->central_directory = l;
@@ -320,22 +454,24 @@
 	}
 	zip->central_directory_end = l;
 
-	/* Store the offset of this header for later use in central directory. */
+	/* Store the offset of this header for later use in central
+	 * directory. */
 	l->offset = zip->written_bytes;
 
 	memset(&h, 0, sizeof(h));
 	archive_le32enc(&h.signature, ZIP_SIGNATURE_LOCAL_FILE_HEADER);
 	archive_le16enc(&h.version, ZIP_VERSION_EXTRACT);
-	archive_le16enc(&h.flags, ZIP_FLAGS);
-	archive_le16enc(&h.compression, zip->compression);
+	archive_le16enc(&h.flags, l->flags);
+	archive_le16enc(&h.compression, l->compression);
 	archive_le32enc(&h.timedate, dos_time(archive_entry_mtime(entry)));
-	archive_le16enc(&h.filename_length, (uint16_t)path_length(entry));
+	archive_le16enc(&h.filename_length, (uint16_t)path_length(l->entry));
 
-	switch (zip->compression) {
+	switch (l->compression) {
 	case COMPRESSION_STORE:
-		/* Setting compressed and uncompressed sizes even when specification says
-		 * to set to zero when using data descriptors. Otherwise the end of the
-		 * data for an entry is rather difficult to find. */
+		/* Setting compressed and uncompressed sizes even when
+		 * specification says to set to zero when using data
+		 * descriptors. Otherwise the end of the data for an
+		 * entry is rather difficult to find. */
 		archive_le32enc(&h.compressed_size, size);
 		archive_le32enc(&h.uncompressed_size, size);
 		break;
@@ -348,9 +484,10 @@
 		zip->stream.opaque = Z_NULL;
 		zip->stream.next_out = zip->buf;
 		zip->stream.avail_out = zip->len_buf;
-		if (deflateInit2(&zip->stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED,
-		    -15, 8, Z_DEFAULT_STRATEGY) != Z_OK) {
-			archive_set_error(&a->archive, ENOMEM, "Can't init deflate compressor");
+		if (deflateInit2(&zip->stream, Z_DEFAULT_COMPRESSION,
+		    Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY) != Z_OK) {
+			archive_set_error(&a->archive, ENOMEM,
+			    "Can't init deflate compressor");
 			return (ARCHIVE_FATAL);
 		}
 		break;
@@ -366,29 +503,47 @@
 	archive_le32enc(&e.mtime, archive_entry_mtime(entry));
 	archive_le32enc(&e.atime, archive_entry_atime(entry));
 	archive_le32enc(&e.ctime, archive_entry_ctime(entry));
-	    
-	archive_le16enc(&e.unix_id, ZIP_SIGNATURE_EXTRA_UNIX);
-	archive_le16enc(&e.unix_size, sizeof(e.unix_uid) + sizeof(e.unix_gid));
-	archive_le16enc(&e.unix_uid, archive_entry_uid(entry));
-	archive_le16enc(&e.unix_gid, archive_entry_gid(entry));
+
+	archive_le16enc(&e.unix_id, ZIP_SIGNATURE_EXTRA_NEW_UNIX);
+	archive_le16enc(&e.unix_size, sizeof(e.unix_version) +
+	    sizeof(e.unix_uid_size) + sizeof(e.unix_uid) +
+	    sizeof(e.unix_gid_size) + sizeof(e.unix_gid));
+	e.unix_version = 1;
+	e.unix_uid_size = 4;
+	archive_le32enc(&e.unix_uid, archive_entry_uid(entry));
+	e.unix_gid_size = 4;
+	archive_le32enc(&e.unix_gid, archive_entry_gid(entry));
 
 	archive_le32enc(&d->uncompressed_size, size);
 
-	ret = (a->compressor.write)(a, &h, sizeof(h));
+	ret = __archive_write_output(a, &h, sizeof(h));
 	if (ret != ARCHIVE_OK)
 		return (ARCHIVE_FATAL);
 	zip->written_bytes += sizeof(h);
 
-	ret = write_path(entry, a);
+	ret = write_path(l->entry, a);
 	if (ret <= ARCHIVE_OK)
 		return (ARCHIVE_FATAL);
 	zip->written_bytes += ret;
 
-	ret = (a->compressor.write)(a, &e, sizeof(e));
+	ret = __archive_write_output(a, &e, sizeof(e));
 	if (ret != ARCHIVE_OK)
 		return (ARCHIVE_FATAL);
 	zip->written_bytes += sizeof(e);
 
+	if (type == AE_IFLNK) {
+		const unsigned char *p;
+
+		p = (const unsigned char *)archive_entry_symlink(l->entry);
+		ret = __archive_write_output(a, p, size);
+		if (ret != ARCHIVE_OK)
+			return (ARCHIVE_FATAL);
+		zip->written_bytes += size;
+		l->crc32 = crc32(l->crc32, p, size);
+	}
+
+	if (ret2 != ARCHIVE_OK)
+		return (ret2);
 	return (ARCHIVE_OK);
 }
 
@@ -404,9 +559,9 @@
 
 	if (s == 0) return 0;
 
-	switch (zip->compression) {
+	switch (l->compression) {
 	case COMPRESSION_STORE:
-		ret = (a->compressor.write)(a, buff, s);
+		ret = __archive_write_output(a, buff, s);
 		if (ret != ARCHIVE_OK) return (ret);
 		zip->written_bytes += s;
 		zip->remaining_data_bytes -= s;
@@ -422,7 +577,8 @@
 			if (ret == Z_STREAM_ERROR)
 				return (ARCHIVE_FATAL);
 			if (zip->stream.avail_out == 0) {
-				ret = (a->compressor.write)(a, zip->buf, zip->len_buf);
+				ret = __archive_write_output(a, zip->buf,
+					zip->len_buf);
 				if (ret != ARCHIVE_OK)
 					return (ret);
 				l->compressed_size += zip->len_buf;
@@ -456,7 +612,7 @@
 	size_t reminder;
 #endif
 
-	switch(zip->compression) {
+	switch(l->compression) {
 	case COMPRESSION_STORE:
 		break;
 #if HAVE_ZLIB_H
@@ -466,7 +622,7 @@
 			if (ret == Z_STREAM_ERROR)
 				return (ARCHIVE_FATAL);
 			reminder = zip->len_buf - zip->stream.avail_out;
-			ret = (a->compressor.write)(a, zip->buf, reminder);
+			ret = __archive_write_output(a, zip->buf, reminder);
 			if (ret != ARCHIVE_OK)
 				return (ret);
 			l->compressed_size += reminder;
@@ -483,7 +639,7 @@
 
 	archive_le32enc(&d->crc32, l->crc32);
 	archive_le32enc(&d->compressed_size, l->compressed_size);
-	ret = (a->compressor.write)(a, d, sizeof(*d));
+	ret = __archive_write_output(a, d, sizeof(*d));
 	if (ret != ARCHIVE_OK)
 		return (ARCHIVE_FATAL);
 	zip->written_bytes += sizeof(*d);
@@ -491,25 +647,23 @@
 }
 
 static int
-archive_write_zip_finish(struct archive_write *a)
+archive_write_zip_close(struct archive_write *a)
 {
 	struct zip *zip;
 	struct zip_file_header_link *l;
 	struct zip_file_header h;
 	struct zip_central_directory_end end;
 	struct zip_extra_data_central e;
-	off_t offset_start, offset_end;
+	int64_t offset_start, offset_end;
 	int entries;
 	int ret;
 
-	if (a->compressor.write == NULL)
-		return (ARCHIVE_OK);
-
 	zip = a->format_data;
 	l = zip->central_directory;
 
 	/*
-	 * Formatting central directory file header fields that are fixed for all entries.
+	 * Formatting central directory file header fields that are
+	 * fixed for all entries.
 	 * Fields not used (and therefor 0) are:
 	 *
 	 *   - comment_length
@@ -520,7 +674,6 @@
 	archive_le32enc(&h.signature, ZIP_SIGNATURE_FILE_HEADER);
 	archive_le16enc(&h.version_by, ZIP_VERSION_BY);
 	archive_le16enc(&h.version_extract, ZIP_VERSION_EXTRACT);
-	archive_le16enc(&h.flags, ZIP_FLAGS);
 
 	entries = 0;
 	offset_start = zip->written_bytes;
@@ -528,25 +681,31 @@
 	/* Formatting individual header fields per entry and
 	 * writing each entry. */
 	while (l != NULL) {
+		archive_le16enc(&h.flags, l->flags);
 		archive_le16enc(&h.compression, l->compression);
-		archive_le32enc(&h.timedate, dos_time(archive_entry_mtime(l->entry)));
+		archive_le32enc(&h.timedate,
+			dos_time(archive_entry_mtime(l->entry)));
 		archive_le32enc(&h.crc32, l->crc32);
 		archive_le32enc(&h.compressed_size, l->compressed_size);
-		archive_le32enc(&h.uncompressed_size, archive_entry_size(l->entry));
-		archive_le16enc(&h.filename_length, (uint16_t)path_length(l->entry));
+		archive_le32enc(&h.uncompressed_size,
+			archive_entry_size(l->entry));
+		archive_le16enc(&h.filename_length,
+			(uint16_t)path_length(l->entry));
 		archive_le16enc(&h.extra_length, sizeof(e));
-		archive_le16enc(&h.attributes_external[2], archive_entry_mode(l->entry));
+		archive_le16enc(&h.attributes_external[2],
+			archive_entry_mode(l->entry));
 		archive_le32enc(&h.offset, l->offset);
 
 		/* Formatting extra data. */
 		archive_le16enc(&e.time_id, ZIP_SIGNATURE_EXTRA_TIMESTAMP);
-		archive_le16enc(&e.time_size, sizeof(e.mtime) + sizeof(e.time_flag));
+		archive_le16enc(&e.time_size,
+			sizeof(e.mtime) + sizeof(e.time_flag));
 		e.time_flag[0] = 0x07;
 		archive_le32enc(&e.mtime, archive_entry_mtime(l->entry));
-		archive_le16enc(&e.unix_id, ZIP_SIGNATURE_EXTRA_UNIX);
+		archive_le16enc(&e.unix_id, ZIP_SIGNATURE_EXTRA_NEW_UNIX);
 		archive_le16enc(&e.unix_size, 0x0000);
 
-		ret = (a->compressor.write)(a, &h, sizeof(h));
+		ret = __archive_write_output(a, &h, sizeof(h));
 		if (ret != ARCHIVE_OK)
 			return (ARCHIVE_FATAL);
 		zip->written_bytes += sizeof(h);
@@ -556,7 +715,7 @@
 			return (ARCHIVE_FATAL);
 		zip->written_bytes += ret;
 
-		ret = (a->compressor.write)(a, &e, sizeof(e));
+		ret = __archive_write_output(a, &e, sizeof(e));
 		if (ret != ARCHIVE_OK)
 			return (ARCHIVE_FATAL);
 		zip->written_bytes += sizeof(e);
@@ -575,7 +734,7 @@
 	archive_le32enc(&end.offset, offset_start);
 
 	/* Writing end of central directory. */
-	ret = (a->compressor.write)(a, &end, sizeof(end));
+	ret = __archive_write_output(a, &end, sizeof(end));
 	if (ret != ARCHIVE_OK)
 		return (ARCHIVE_FATAL);
 	zip->written_bytes += sizeof(end);
@@ -583,7 +742,7 @@
 }
 
 static int
-archive_write_zip_destroy(struct archive_write *a)
+archive_write_zip_free(struct archive_write *a)
 {
 	struct zip *zip;
 	struct zip_file_header_link *l;
@@ -614,14 +773,23 @@
 	 * on two systems with different time zones. */
 	t = localtime(&unix_time);
 
-	dt = 0;
-	dt += ((t->tm_year - 80) & 0x7f) << 9;
-	dt += ((t->tm_mon + 1) & 0x0f) << 5;
-	dt += (t->tm_mday & 0x1f);
-	dt <<= 16;
-	dt += (t->tm_hour & 0x1f) << 11;
-	dt += (t->tm_min & 0x3f) << 5;
-	dt += (t->tm_sec & 0x3e) >> 1; /* Only counting every 2 seconds. */
+	/* MSDOS-style date/time is only between 1980-01-01 and 2107-12-31 */
+	if (t->tm_year < 1980 - 1900)
+		/* Set minimum date/time '1980-01-01 00:00:00'. */
+		dt = 0x00210000U;
+	else if (t->tm_year > 2107 - 1900)
+		/* Set maximum date/time '2107-12-31 23:59:58'. */
+		dt = 0xff9fbf7dU;
+	else {
+		dt = 0;
+		dt += ((t->tm_year - 80) & 0x7f) << 9;
+		dt += ((t->tm_mon + 1) & 0x0f) << 5;
+		dt += (t->tm_mday & 0x1f);
+		dt <<= 16;
+		dt += (t->tm_hour & 0x1f) << 11;
+		dt += (t->tm_min & 0x3f) << 5;
+		dt += (t->tm_sec & 0x3e) >> 1; /* Only counting every 2 seconds. */
+	}
 	return dt;
 }
 
@@ -653,14 +821,14 @@
 	type = archive_entry_filetype(entry);
 	written_bytes = 0;
 
-	ret = (archive->compressor.write)(archive, path, strlen(path));
+	ret = __archive_write_output(archive, path, strlen(path));
 	if (ret != ARCHIVE_OK)
 		return (ARCHIVE_FATAL);
 	written_bytes += strlen(path);
 
 	/* Folders are recognized by a traling slash. */
 	if ((type == AE_IFDIR) & (path[strlen(path) - 1] != '/')) {
-		ret = (archive->compressor.write)(archive, "/", 1);
+		ret = __archive_write_output(archive, "/", 1);
 		if (ret != ARCHIVE_OK)
 			return (ARCHIVE_FATAL);
 		written_bytes += 1;
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/libarchive-formats.5
--- a/head/contrib/libarchive/libarchive/libarchive-formats.5	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/libarchive-formats.5	Fri Mar 02 16:54:40 2012 +0200
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $FreeBSD: head/contrib/libarchive/libarchive/libarchive-formats.5 228773 2011-12-21 15:18:52Z mm $
+.\" $FreeBSD: head/contrib/libarchive/libarchive/libarchive-formats.5 232153 2012-02-25 10:58:02Z mm $
 .\"
 .Dd December 27, 2009
 .Dt LIBARCHIVE-FORMATS 5
@@ -342,6 +342,12 @@
 If it cannot locate and open the file on disk, libarchive
 will return an error for any attempt to read the entry
 body.
+.Ss RAR
+libarchive has limited support to read files in RAR format. Currently,
+libarchive can read single RAR files in RARv3 format which have been either
+created uncompressed, or compressed using any of the compression methods
+supported by the RARv3 format. libarchive can also extract RAR files which have
+been created as self-extracting RAR files.
 .Sh SEE ALSO
 .Xr ar 1 ,
 .Xr cpio 1 ,
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/libarchive.3
--- a/head/contrib/libarchive/libarchive/libarchive.3	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/libarchive.3	Fri Mar 02 16:54:40 2012 +0200
@@ -22,9 +22,9 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $FreeBSD: head/contrib/libarchive/libarchive/libarchive.3 228773 2011-12-21 15:18:52Z mm $
+.\" $FreeBSD: head/contrib/libarchive/libarchive/libarchive.3 232153 2012-02-25 10:58:02Z mm $
 .\"
-.Dd July 17, 2010
+.Dd February 6, 2010
 .Dt LIBARCHIVE 3
 .Os
 .Sh NAME
@@ -36,10 +36,13 @@
 The
 .Nm
 library provides a flexible interface for reading and writing
-streaming archive files such as tar and cpio.
+archives in various formats such as tar and cpio.
+.Nm
+also supports reading and writing archives compressed using
+various compression filters such as gzip and bzip2.
 The library is inherently stream-oriented; readers serially iterate through
 the archive, writers serially add things to the archive.
-In particular, note that there is no built-in support for
+In particular, note that there is currently no built-in support for
 random access nor for in-place modification.
 .Pp
 When reading an archive, the library automatically detects the
@@ -114,131 +117,15 @@
 operation.
 More detailed information can be found in the individual manual
 pages for each API or utility function.
+.\"
 .Sh READING AN ARCHIVE
-To read an archive, you must first obtain an initialized
-.Tn struct archive
-object from
-.Fn archive_read_new .
-You can then modify this object for the desired operations with the
-various
-.Fn archive_read_set_XXX
-and
-.Fn archive_read_support_XXX
-functions.
-In particular, you will need to invoke appropriate
-.Fn archive_read_support_XXX
-functions to enable the corresponding compression and format
-support.
-Note that these latter functions perform two distinct operations:
-they cause the corresponding support code to be linked into your
-program, and they enable the corresponding auto-detect code.
-Unless you have specific constraints, you will generally want
-to invoke
-.Fn archive_read_support_compression_all
-and
-.Fn archive_read_support_format_all
-to enable auto-detect for all formats and compression types
-currently supported by the library.
-.Pp
-Once you have prepared the
-.Tn struct archive
-object, you call
-.Fn archive_read_open
-to actually open the archive and prepare it for reading.
-There are several variants of this function;
-the most basic expects you to provide pointers to several
-functions that can provide blocks of bytes from the archive.
-There are convenience forms that allow you to
-specify a filename, file descriptor,
-.Ft "FILE *"
-object, or a block of memory from which to read the archive data.
-Note that the core library makes no assumptions about the
-size of the blocks read;
-callback functions are free to read whatever block size is
-most appropriate for the medium.
-.Pp
-Each archive entry consists of a header followed by a certain
-amount of data.
-You can obtain the next header with
-.Fn archive_read_next_header ,
-which returns a pointer to an
-.Tn struct archive_entry
-structure with information about the current archive element.
-If the entry is a regular file, then the header will be followed
-by the file data.
-You can use
-.Fn archive_read_data
-(which works much like the
-.Xr read 2
-system call)
-to read this data from the archive, or
-.Fn archive_read_data_block
-which provides a slightly more efficient interface.
-You may prefer to use the higher-level
-.Fn archive_read_data_skip ,
-which reads and discards the data for this entry,
-.Fn archive_read_data_to_file ,
-which copies the data to the provided file descriptor, or
-.Fn archive_read_extract ,
-which recreates the specified entry on disk and copies data
-from the archive.
-In particular, note that
-.Fn archive_read_extract
-uses the
-.Tn struct archive_entry
-structure that you provide it, which may differ from the
-entry just read from the archive.
-In particular, many applications will want to override the
-pathname, file permissions, or ownership.
-.Pp
-Once you have finished reading data from the archive, you
-should call
-.Fn archive_read_close
-to close the archive, then call
-.Fn archive_read_free
-to release all resources, including all memory allocated by the library.
-.Pp
-The
-.Xr archive_read 3
-manual page provides more detailed calling information for this API.
+See
+.Xr libarchive_read 3 .
+.\"
 .Sh WRITING AN ARCHIVE
-You use a similar process to write an archive.
-The
-.Fn archive_write_new
-function creates an archive object useful for writing,
-the various
-.Fn archive_write_set_XXX
-functions are used to set parameters for writing the archive, and
-.Fn archive_write_open
-completes the setup and opens the archive for writing.
-.Pp
-Individual archive entries are written in a three-step
-process:
-You first initialize a
-.Tn struct archive_entry
-structure with information about the new entry.
-At a minimum, you should set the pathname of the
-entry and provide a
-.Va struct stat
-with a valid
-.Va st_mode
-field, which specifies the type of object and
-.Va st_size
-field, which specifies the size of the data portion of the object.
-The
-.Fn archive_write_header
-function actually writes the header data to the archive.
-You can then use
-.Fn archive_write_data
-to write the actual data.
-.Pp
-After all entries have been written, use the
-.Fn archive_write_free
-function to release all resources.
-.Pp
-The
-.Xr archive_write 3
-manual page provides more detailed calling information for this API.
+See
+.Xr libarchive_write 3 .
+.\"
 .Sh WRITING ENTRIES TO DISK
 The
 .Xr archive_write_disk 3
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/libarchive_internals.3
--- a/head/contrib/libarchive/libarchive/libarchive_internals.3	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/libarchive_internals.3	Fri Mar 02 16:54:40 2012 +0200
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $FreeBSD: head/contrib/libarchive/libarchive/libarchive_internals.3 228763 2011-12-21 11:13:29Z mm $
+.\" $FreeBSD: head/contrib/libarchive/libarchive/libarchive_internals.3 232153 2012-02-25 10:58:02Z mm $
 .\"
 .Dd April 16, 2007
 .Dt LIBARCHIVE 3
@@ -41,15 +41,15 @@
 Externally, libarchive exposes most operations through an
 opaque, object-style interface.
 The
-.Xr archive_entry 1
+.Xr archive_entry 3
 objects store information about a single filesystem object.
 The rest of the library provides facilities to write
-.Xr archive_entry 1
+.Xr archive_entry 3
 objects to archive files,
 read them from archive files,
 and write them to disk.
 (There are plans to add a facility to read
-.Xr archive_entry 1
+.Xr archive_entry 3
 objects from disk as well.)
 .Pp
 The read and write APIs each have four layers: a public API
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/tar.5
--- a/head/contrib/libarchive/libarchive/tar.5	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/tar.5	Fri Mar 02 16:54:40 2012 +0200
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $FreeBSD: head/contrib/libarchive/libarchive/tar.5 228773 2011-12-21 15:18:52Z mm $
+.\" $FreeBSD: head/contrib/libarchive/libarchive/tar.5 232153 2012-02-25 10:58:02Z mm $
 .\"
 .Dd December 27, 2009
 .Dt TAR 5
@@ -171,9 +171,9 @@
 format described below with the following variations:
 .Bl -bullet -compact -width indent
 .It
-The magic value is
-.Dq ustar\ \&
-(note the following space).
+The magic value consists of the five characters
+.Dq ustar
+followed by a space.
 The version field contains a space character followed by a null.
 .It
 The numeric fields are generally filled with leading spaces
@@ -322,6 +322,39 @@
 Currently, most tar implementations comply with the ustar
 format, occasionally extending it by adding new fields to the
 blank area at the end of the header record.
+.Ss Numeric Extensions
+There have been several attempts to extend the range of sizes
+or times supported by modifying how numbers are stored in the
+header.
+.Pp
+One obvious extension to increase the size of files is to
+eliminate the terminating characters from the various
+numeric fields.
+For example, the standard only allows the size field to contain
+11 octal digits, reserving the twelfth byte for a trailing
+NUL character.
+Allowing 12 octal digits allows file sizes up to 64 GB.
+.Pp
+Another extension, utilized by GNU tar, star, and other newer
+.Nm
+implementations, permits binary numbers in the standard numeric fields.
+This is flagged by setting the high bit of the first byte.
+The remainder of the field is treated as a signed twos-complement
+value.
+This permits 95-bit values for the length and time fields
+and 63-bit values for the uid, gid, and device numbers.
+In particular, this provides a consistent way to handle
+negative time values.
+GNU tar supports this extension for the
+length, mtime, ctime, and atime fields.
+Joerg Schilling's star program and the libarchive library support
+this extension for all numeric fields.
+Note that this extension is largely obsoleted by the extended
+attribute record provided by the pax interchange format.
+.Pp
+Another early GNU extension allowed base-64 values rather than octal.
+This extension was short-lived and is no longer supported by any
+implementation.
 .Ss Pax Interchange Format
 There are many attributes that cannot be portably stored in a
 POSIX ustar archive.
@@ -365,6 +398,27 @@
 .It Cm atime , Cm ctime , Cm mtime
 File access, inode change, and modification times.
 These fields can be negative or include a decimal point and a fractional value.
+.It Cm hdrcharset
+The character set used by the pax extension values.
+By default, all textual values in the pax extended attributes
+are assumed to be in UTF-8, including pathnames, user names,
+and group names.
+In some cases, it is not possible to translate local
+conventions into UTF-8.
+If this key is present and the value is the six-character ASCII string
+.Dq BINARY ,
+then all textual values are assumed to be in a platform-dependent
+multi-byte encoding.
+Note that there are only two valid values for this key:
+.Dq BINARY
+or
+.Dq ISO-IR\ 10646\ 2000\ UTF-8 .
+No other values are permitted by the standard, and
+the latter value should generally not be used as it is the
+default when this key is not specified.
+In particular, this flag should not be used as a general
+mechanism to allow filenames to be stored in arbitrary
+encodings.
 .It Cm uname , Cm uid , Cm gname , Cm gid
 User name, group name, and numeric UID and GID values.
 The user name and group name stored here are encoded in UTF8
@@ -408,6 +462,16 @@
 .Cm SCHILY.*
 extensions can store all of the data from
 .Va struct stat .
+.It Cm LIBARCHIVE.*
+Vendor-specific attributes used by the
+.Nm libarchive
+library and programs that use it.
+.It Cm LIBARCHIVE.creationtime
+The time when the file was created.
+(This should not be confused with the POSIX
+.Dq ctime
+attribute, which refers to the time when the file
+metadata was last changed.)
 .It Cm LIBARCHIVE.xattr. Ns Ar namespace Ns . Ns Ar key
 Libarchive stores POSIX.1e-style extended attributes using
 keys of this form.
@@ -659,8 +723,11 @@
 pax interchange format archives when you specify the
 .Fl -posix
 flag.
-This format uses custom keywords to store sparse file information.
-There have been three iterations of this support, referred to
+This format follows the pax interchange format closely,
+using some
+.Cm SCHILY
+tags and introducing new keywords to store sparse file information.
+There have been three iterations of the sparse file support, referred to
 as
 .Dq 0.0 ,
 .Dq 0.1 ,
@@ -735,7 +802,7 @@
 .It
 An additional
 .Cm A
-entry is used to store an ACL for the following regular entry.
+header is used to store an ACL for the following regular entry.
 The body of this entry contains a seven-digit octal number
 followed by a zero byte, followed by the
 textual ACL description.
@@ -745,46 +812,95 @@
 .El
 .Ss AIX Tar
 XXX More details needed XXX
+.Pp
+AIX Tar uses a ustar-formatted header with the type
+.Cm A
+for storing coded ACL information.
+Unlike the Solaris format, AIX tar writes this header after the
+regular file body to which it applies.
+The pathname in this header is either
+.Cm NFS4
+or
+.Cm AIXC
+to indicate the type of ACL stored.
+The actual ACL is stored in platform-specific binary format.
 .Ss Mac OS X Tar
 The tar distributed with Apple's Mac OS X stores most regular files
-as two separate entries in the tar archive.
-The two entries have the same name except that the first
+as two separate files in the tar archive.
+The two files have the same name except that the first
 one has
 .Dq ._
-added to the beginning of the name.
-This first entry stores the
-.Dq resource fork
-with additional attributes for the file.
-The Mac OS X
-.Fn CopyFile
-API is used to separate a file on disk into separate
-resource and data streams and to reassemble those separate
-streams when the file is restored to disk.
-.Ss Other Extensions
-One obvious extension to increase the size of files is to
-eliminate the terminating characters from the various
-numeric fields.
-For example, the standard only allows the size field to contain
-11 octal digits, reserving the twelfth byte for a trailing
-NUL character.
-Allowing 12 octal digits allows file sizes up to 64 GB.
+prepended to the last path element.
+This special file stores an AppleDouble-encoded
+binary blob with additional metadata about the second file,
+including ACL, extended attributes, and resources.
+To recreate the original file on disk, each
+separate file can be extracted and the Mac OS X
+.Fn copyfile
+function can be used to unpack the separate
+metadata file and apply it to th regular file.
+Conversely, the same function provides a
+.Dq pack
+option to encode the extended metadata from
+a file into a separate file whose contents
+can then be put into a tar archive.
 .Pp
-Another extension, utilized by GNU tar, star, and other newer
-.Nm
-implementations, permits binary numbers in the standard numeric fields.
-This is flagged by setting the high bit of the first byte.
-This permits 95-bit values for the length and time fields
-and 63-bit values for the uid, gid, and device numbers.
-GNU tar supports this extension for the
-length, mtime, ctime, and atime fields.
-Joerg Schilling's star program supports this extension for
-all numeric fields.
-Note that this extension is largely obsoleted by the extended attribute
-record provided by the pax interchange format.
-.Pp
-Another early GNU extension allowed base-64 values rather than octal.
-This extension was short-lived and is no longer supported by any
-implementation.
+Note that the Apple extended attributes interact
+badly with long filenames.
+Since each file is stored with the full name,
+a separate set of extensions needs to be included
+in the archive for each one, doubling the overhead
+required for files with long names.
+.Ss Summary of tar type codes
+The following list is a condensed summary of the type codes
+used in tar header records generated by different tar implementations.
+More details about specific implementations can be found above:
+.Bl -tag -compact -width XXX
+.It NUL
+Early tar programs stored a zero byte for regular files.
+.It Cm 0
+POSIX standard type code for a regular file.
+.It Cm 1
+POSIX standard type code for a hard link description.
+.It Cm 2
+POSIX standard type code for a symbolic link description.
+.It Cm 3
+POSIX standard type code for a character device node.
+.It Cm 4
+POSIX standard type code for a block device node.
+.It Cm 5
+POSIX standard type code for a directory.
+.It Cm 6
+POSIX standard type code for a FIFO.
+.It Cm 7
+POSIX reserved.
+.It Cm 7
+GNU tar used for pre-allocated files on some systems.
+.It Cm A
+Solaris tar ACL description stored prior to a regular file header.
+.It Cm A
+AIX tar ACL description stored after the file body.
+.It Cm D
+GNU tar directory dump.
+.It Cm K
+GNU tar long linkname for the following header.
+.It Cm L
+GNU tar long pathname for the following header.
+.It Cm M
+GNU tar multivolume marker, indicating the file is a continuation of a file from the previous volume.
+.It Cm N
+GNU tar long filename support.  Deprecated.
+.It Cm S
+GNU tar sparse regular file.
+.It Cm V
+GNU tar tape/volume header name.
+.It Cm X
+Solaris tar general-purpose extension header.
+.It Cm g
+POSIX pax interchange format global extensions.
+.It Cm x
+POSIX pax interchange format per-file extensions.
+.El
 .Sh SEE ALSO
 .Xr ar 1 ,
 .Xr pax 1 ,
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/main.c
--- a/head/contrib/libarchive/libarchive/test/main.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/main.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,8 +24,18 @@
  */
 
 #include "test.h"
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
 #include <errno.h>
+#ifdef HAVE_ICONV_H
+#include <iconv.h>
+#endif
+#include <limits.h>
 #include <locale.h>
+#ifdef HAVE_SIGNAL_H
+#include <signal.h>
+#endif
 #include <stdarg.h>
 #include <time.h>
 
@@ -36,13 +46,14 @@
  * TODO: Move this into a separate configuration header, have all test
  * suites share one copy of this file.
  */
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/main.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/main.c 232153 2012-02-25 10:58:02Z mm $");
 #define KNOWNREF	"test_compat_gtar_1.tar.uu"
 #define	ENVBASE "LIBARCHIVE" /* Prefix for environment variables. */
 #undef	PROGRAM              /* Testing a library, not a program. */
 #define	LIBRARY	"libarchive"
 #define	EXTRA_DUMP(x)	archive_error_string((struct archive *)(x))
-#define	EXTRA_VERSION	archive_version()
+#define	EXTRA_ERRNO(x)	archive_errno((struct archive *)(x))
+#define	EXTRA_VERSION	archive_version_string()
 
 /*
  *
@@ -77,6 +88,7 @@
 #endif
 #if !defined(__BORLANDC__)
 #define access _access
+#undef chdir
 #define chdir _chdir
 #endif
 #ifndef fileno
@@ -149,7 +161,7 @@
 
 	memset(bhfi, 0, sizeof(*bhfi));
 	h = CreateFile(path, FILE_READ_ATTRIBUTES, 0, NULL,
-		OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+		OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
 	if (h == INVALID_HANDLE_VALUE)
 		return (0);
 	r = GetFileInformationByHandle(h, bhfi);
@@ -178,6 +190,8 @@
 static int dump_on_failure = 0;
 /* Default is to remove temp dirs and log data for successful tests. */
 static int keep_temp_files = 0;
+/* Default is to run the specified tests once and report errors. */
+static int until_failure = 0;
 /* Default is to just report pass/fail for each test. */
 static int verbosity = 0;
 #define	VERBOSITY_SUMMARY_ONLY -1 /* -q */
@@ -235,10 +249,14 @@
 failure(const char *fmt, ...)
 {
 	va_list ap;
-	va_start(ap, fmt);
-	vsprintf(msgbuff, fmt, ap);
-	va_end(ap);
-	nextmsg = msgbuff;
+	if (fmt == NULL) {
+		nextmsg = NULL;
+	} else {
+		va_start(ap, fmt);
+		vsprintf(msgbuff, fmt, ap);
+		va_end(ap);
+		nextmsg = msgbuff;
+	}
 }
 
 /*
@@ -250,15 +268,14 @@
  * pass __FILE__, __LINE__ directly into the function instead of using
  * this hook.  I suspect this machinery is used so rarely that we
  * would be better off just removing it entirely.  That would simplify
- * the code here noticably.
+ * the code here noticeably.
  */
-static const char *test_filename;
-static int test_line;
-static void *test_extra;
-void assertion_setup(const char *filename, int line)
+static const char *skipping_filename;
+static int skipping_line;
+void skipping_setup(const char *filename, int line)
 {
-	test_filename = filename;
-	test_line = line;
+	skipping_filename = filename;
+	skipping_line = line;
 }
 
 /* Called at the beginning of each assert() function. */
@@ -285,6 +302,7 @@
 	int count;
 	int skip;
 }  failed_lines[10000];
+const char *failed_filename;
 
 /* Count this failure, setup up log destination and handle initial report. */
 static void
@@ -294,7 +312,7 @@
 
 	/* Record another failure for this line. */
 	++failures;
-	/* test_filename = filename; */
+	failed_filename = filename;
 	failed_lines[line].count++;
 
 	/* Determine whether to log header to console. */
@@ -339,8 +357,10 @@
 {
 	(void)extra; /* UNUSED (maybe) */
 #ifdef EXTRA_DUMP
-	if (extra != NULL)
+	if (extra != NULL) {
+		logprintf("    errno: %d\n", EXTRA_ERRNO(extra));
 		logprintf("   detail: %s\n", EXTRA_DUMP(extra));
+	}
 #endif
 
 	if (dump_on_failure) {
@@ -361,12 +381,15 @@
 	va_start(ap, fmt);
 	vsprintf(buff, fmt, ap);
 	va_end(ap);
+	/* Use failure() message if set. */
+	msg = nextmsg;
+	nextmsg = NULL;
 	/* failure_start() isn't quite right, but is awfully convenient. */
-	failure_start(test_filename, test_line, "SKIPPING: %s", buff);
+	failure_start(skipping_filename, skipping_line, "SKIPPING: %s", buff);
 	--failures; /* Undo failures++ in failure_start() */
 	/* Don't failure_finish() here. */
 	/* Mark as skip, so doesn't count as failed test. */
-	failed_lines[test_line].skip = 1;
+	failed_lines[skipping_line].skip = 1;
 	++skips;
 }
 
@@ -417,13 +440,102 @@
 	return (0);
 }
 
-static void strdump(const char *e, const char *p)
+/*
+ * Utility to convert a single UTF-8 sequence.
+ */
+static int
+_utf8_to_unicode(uint32_t *pwc, const char *s, size_t n)
+{
+	static const char utf8_count[256] = {
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 00 - 0F */
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 10 - 1F */
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 20 - 2F */
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 30 - 3F */
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 40 - 4F */
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 50 - 5F */
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 60 - 6F */
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 70 - 7F */
+		 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,/* 80 - 8F */
+		 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,/* 90 - 9F */
+		 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,/* A0 - AF */
+		 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,/* B0 - BF */
+		 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,/* C0 - CF */
+		 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,/* D0 - DF */
+		 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,/* E0 - EF */
+		 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* F0 - FF */
+	};
+	int ch;
+	int cnt;
+	uint32_t wc;
+
+	*pwc = 0;
+
+	/* Sanity check. */
+	if (n == 0)
+		return (0);
+	/*
+	 * Decode 1-4 bytes depending on the value of the first byte.
+	 */
+	ch = (unsigned char)*s;
+	if (ch == 0)
+		return (0); /* Standard:  return 0 for end-of-string. */
+	cnt = utf8_count[ch];
+
+	/* Invalide sequence or there are not plenty bytes. */
+	if (n < (size_t)cnt)
+		return (-1);
+
+	/* Make a Unicode code point from a single UTF-8 sequence. */
+	switch (cnt) {
+	case 1:	/* 1 byte sequence. */
+		*pwc = ch & 0x7f;
+		return (cnt);
+	case 2:	/* 2 bytes sequence. */
+		if ((s[1] & 0xc0) != 0x80) return (-1);
+		*pwc = ((ch & 0x1f) << 6) | (s[1] & 0x3f);
+		return (cnt);
+	case 3:	/* 3 bytes sequence. */
+		if ((s[1] & 0xc0) != 0x80) return (-1);
+		if ((s[2] & 0xc0) != 0x80) return (-1);
+		wc = ((ch & 0x0f) << 12)
+		    | ((s[1] & 0x3f) << 6)
+		    | (s[2] & 0x3f);
+		if (wc < 0x800)
+			return (-1);/* Overlong sequence. */
+		break;
+	case 4:	/* 4 bytes sequence. */
+		if (n < 4)
+			return (-1);
+		if ((s[1] & 0xc0) != 0x80) return (-1);
+		if ((s[2] & 0xc0) != 0x80) return (-1);
+		if ((s[3] & 0xc0) != 0x80) return (-1);
+		wc = ((ch & 0x07) << 18)
+		    | ((s[1] & 0x3f) << 12)
+		    | ((s[2] & 0x3f) << 6)
+		    | (s[3] & 0x3f);
+		if (wc < 0x10000)
+			return (-1);/* Overlong sequence. */
+		break;
+	default:
+		return (-1);
+	}
+
+	/* The code point larger than 0x10FFFF is not leagal
+	 * Unicode values. */
+	if (wc > 0x10FFFF)
+		return (-1);
+	/* Correctly gets a Unicode, returns used bytes. */
+	*pwc = wc;
+	return (cnt);
+}
+
+static void strdump(const char *e, const char *p, int ewidth, int utf8)
 {
 	const char *q = p;
 
-	logprintf("      %s = ", e);
+	logprintf("      %*s = ", ewidth, e);
 	if (p == NULL) {
-		logprintf("NULL");
+		logprintf("NULL\n");
 		return;
 	}
 	logprintf("\"");
@@ -442,7 +554,37 @@
 		}
 	}
 	logprintf("\"");
-	logprintf(" (length %d)\n", q == NULL ? -1 : (int)strlen(q));
+	logprintf(" (length %d)", q == NULL ? -1 : (int)strlen(q));
+
+	/*
+	 * If the current string is UTF-8, dump its code points.
+	 */
+	if (utf8) {
+		size_t len;
+		uint32_t uc;
+		int n;
+		int cnt = 0;
+
+		p = q;
+		len = strlen(p);
+		logprintf(" [");
+		while ((n = _utf8_to_unicode(&uc, p, len)) > 0) {
+			if (p != q)
+				logprintf(" ");
+			logprintf("%04X", uc);
+			p += n;
+			len -= n;
+			cnt++;
+		}
+		logprintf("]");
+		logprintf(" (count %d", cnt);
+		if (n < 0) {
+			logprintf(",unknown %d bytes", len);
+		}
+		logprintf(")");
+
+	}
+	logprintf("\n");
 }
 
 /* Verify two strings are equal, dump them if not. */
@@ -450,14 +592,20 @@
 assertion_equal_string(const char *file, int line,
     const char *v1, const char *e1,
     const char *v2, const char *e2,
-    void *extra)
+    void *extra, int utf8)
 {
+	int l1, l2;
+
 	assertion_count(file, line);
 	if (v1 == v2 || (v1 != NULL && v2 != NULL && strcmp(v1, v2) == 0))
 		return (1);
 	failure_start(file, line, "%s != %s", e1, e2);
-	strdump(e1, v1);
-	strdump(e2, v2);
+	l1 = strlen(e1);
+	l2 = strlen(e2);
+	if (l1 < l2)
+		l1 = l2;
+	strdump(e1, v1, l1, utf8);
+	strdump(e2, v2, l1, utf8);
 	failure_finish(extra);
 	return (0);
 }
@@ -509,7 +657,9 @@
     void *extra)
 {
 	assertion_count(file, line);
-	if (v1 == v2 || wcscmp(v1, v2) == 0)
+	if (v1 == v2)
+		return (1);
+	if (v1 != NULL && v2 != NULL && wcscmp(v1, v2) == 0)
 		return (1);
 	failure_start(file, line, "%s != %s", e1, e2);
 	wcsdump(e1, v1);
@@ -588,9 +738,9 @@
 		offset += 16;
 	}
 	logprintf("      Dump of %s\n", e1);
-	hexdump(v1, v2, l < 64 ? l : 64, offset);
+	hexdump(v1, v2, l < 128 ? l : 128, offset);
 	logprintf("      Dump of %s\n", e2);
-	hexdump(v2, v1, l < 64 ? l : 64, offset);
+	hexdump(v2, v1, l < 128 ? l : 128, offset);
 	logprintf("\n");
 	failure_finish(extra);
 	return (0);
@@ -598,29 +748,24 @@
 
 /* Verify that the named file exists and is empty. */
 int
-assertion_empty_file(const char *f1fmt, ...)
+assertion_empty_file(const char *filename, int line, const char *f1)
 {
 	char buff[1024];
-	char f1[1024];
 	struct stat st;
-	va_list ap;
 	ssize_t s;
 	FILE *f;
 
-	assertion_count(test_filename, test_line);
-	va_start(ap, f1fmt);
-	vsprintf(f1, f1fmt, ap);
-	va_end(ap);
+	assertion_count(filename, line);
 
 	if (stat(f1, &st) != 0) {
-		failure_start(test_filename, test_line, "Stat failed: %s", f1);
+		failure_start(filename, line, "Stat failed: %s", f1);
 		failure_finish(NULL);
 		return (0);
 	}
 	if (st.st_size == 0)
 		return (1);
 
-	failure_start(test_filename, test_line, "File should be empty: %s", f1);
+	failure_start(filename, line, "File should be empty: %s", f1);
 	logprintf("    File size: %d\n", (int)st.st_size);
 	logprintf("    Contents:\n");
 	f = fopen(f1, "rb");
@@ -639,24 +784,19 @@
 
 /* Verify that the named file exists and is not empty. */
 int
-assertion_non_empty_file(const char *f1fmt, ...)
+assertion_non_empty_file(const char *filename, int line, const char *f1)
 {
-	char f1[1024];
 	struct stat st;
-	va_list ap;
 
-	assertion_count(test_filename, test_line);
-	va_start(ap, f1fmt);
-	vsprintf(f1, f1fmt, ap);
-	va_end(ap);
+	assertion_count(filename, line);
 
 	if (stat(f1, &st) != 0) {
-		failure_start(test_filename, test_line, "Stat failed: %s", f1);
+		failure_start(filename, line, "Stat failed: %s", f1);
 		failure_finish(NULL);
 		return (0);
 	}
 	if (st.st_size == 0) {
-		failure_start(test_filename, test_line, "File empty: %s", f1);
+		failure_start(filename, line, "File empty: %s", f1);
 		failure_finish(NULL);
 		return (0);
 	}
@@ -666,19 +806,14 @@
 /* Verify that two files have the same contents. */
 /* TODO: hexdump the first bytes that actually differ. */
 int
-assertion_equal_file(const char *fn1, const char *f2pattern, ...)
+assertion_equal_file(const char *filename, int line, const char *fn1, const char *fn2)
 {
-	char fn2[1024];
-	va_list ap;
 	char buff1[1024];
 	char buff2[1024];
 	FILE *f1, *f2;
 	int n1, n2;
 
-	assertion_count(test_filename, test_line);
-	va_start(ap, f2pattern);
-	vsprintf(fn2, f2pattern, ap);
-	va_end(ap);
+	assertion_count(filename, line);
 
 	f1 = fopen(fn1, "rb");
 	f2 = fopen(fn2, "rb");
@@ -697,24 +832,18 @@
 	}
 	fclose(f1);
 	fclose(f2);
-	failure_start(test_filename, test_line, "Files not identical");
+	failure_start(filename, line, "Files not identical");
 	logprintf("  file1=\"%s\"\n", fn1);
 	logprintf("  file2=\"%s\"\n", fn2);
-	failure_finish(test_extra);
+	failure_finish(NULL);
 	return (0);
 }
 
 /* Verify that the named file does exist. */
 int
-assertion_file_exists(const char *fpattern, ...)
+assertion_file_exists(const char *filename, int line, const char *f)
 {
-	char f[1024];
-	va_list ap;
-
-	assertion_count(test_filename, test_line);
-	va_start(ap, fpattern);
-	vsprintf(f, fpattern, ap);
-	va_end(ap);
+	assertion_count(filename, line);
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
 	if (!_access(f, 0))
@@ -723,22 +852,16 @@
 	if (!access(f, F_OK))
 		return (1);
 #endif
-	failure_start(test_filename, test_line, "File should exist: %s", f);
-	failure_finish(test_extra);
+	failure_start(filename, line, "File should exist: %s", f);
+	failure_finish(NULL);
 	return (0);
 }
 
 /* Verify that the named file doesn't exist. */
 int
-assertion_file_not_exists(const char *fpattern, ...)
+assertion_file_not_exists(const char *filename, int line, const char *f)
 {
-	char f[1024];
-	va_list ap;
-
-	assertion_count(test_filename, test_line);
-	va_start(ap, fpattern);
-	vsprintf(f, fpattern, ap);
-	va_end(ap);
+	assertion_count(filename, line);
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
 	if (_access(f, 0))
@@ -747,31 +870,26 @@
 	if (access(f, F_OK))
 		return (1);
 #endif
-	failure_start(test_filename, test_line, "File should not exist: %s", f);
-	failure_finish(test_extra);
+	failure_start(filename, line, "File should not exist: %s", f);
+	failure_finish(NULL);
 	return (0);
 }
 
 /* Compare the contents of a file to a block of memory. */
 int
-assertion_file_contents(const void *buff, int s, const char *fpattern, ...)
+assertion_file_contents(const char *filename, int line, const void *buff, int s, const char *fn)
 {
-	char fn[1024];
-	va_list ap;
 	char *contents;
 	FILE *f;
 	int n;
 
-	assertion_count(test_filename, test_line);
-	va_start(ap, fpattern);
-	vsprintf(fn, fpattern, ap);
-	va_end(ap);
+	assertion_count(filename, line);
 
 	f = fopen(fn, "rb");
 	if (f == NULL) {
-		failure_start(test_filename, test_line,
+		failure_start(filename, line,
 		    "File should exist: %s", fn);
-		failure_finish(test_extra);
+		failure_finish(NULL);
 		return (0);
 	}
 	contents = malloc(s * 2);
@@ -781,30 +899,36 @@
 		free(contents);
 		return (1);
 	}
-	failure_start(test_filename, test_line, "File contents don't match");
+	failure_start(filename, line, "File contents don't match");
 	logprintf("  file=\"%s\"\n", fn);
 	if (n > 0)
 		hexdump(contents, buff, n > 512 ? 512 : n, 0);
 	else {
 		logprintf("  File empty, contents should be:\n");
-		hexdump(buff, NULL, s > 512 ? 512 : n, 0);
+		hexdump(buff, NULL, s > 512 ? 512 : s, 0);
 	}
-	failure_finish(test_extra);
+	failure_finish(NULL);
 	free(contents);
 	return (0);
 }
 
 /* Check the contents of a text file, being tolerant of line endings. */
 int
-assertion_text_file_contents(const char *buff, const char *fn)
+assertion_text_file_contents(const char *filename, int line, const char *buff, const char *fn)
 {
 	char *contents;
 	const char *btxt, *ftxt;
 	FILE *f;
 	int n, s;
 
-	assertion_count(test_filename, test_line);
+	assertion_count(filename, line);
 	f = fopen(fn, "r");
+	if (f == NULL) {
+		failure_start(filename, line,
+		    "File doesn't exist: %s", fn);
+		failure_finish(NULL);
+		return (0);
+	}
 	s = strlen(buff);
 	contents = malloc(s * 2 + 128);
 	n = fread(contents, 1, s * 2 + 128 - 1, f);
@@ -832,19 +956,122 @@
 		free(contents);
 		return (1);
 	}
-	failure_start(test_filename, test_line, "Contents don't match");
+	failure_start(filename, line, "Contents don't match");
 	logprintf("  file=\"%s\"\n", fn);
-	if (n > 0)
+	if (n > 0) {
 		hexdump(contents, buff, n, 0);
-	else {
+		logprintf("  expected\n", fn);
+		hexdump(buff, contents, s, 0);
+	} else {
 		logprintf("  File empty, contents should be:\n");
 		hexdump(buff, NULL, s, 0);
 	}
-	failure_finish(test_extra);
+	failure_finish(NULL);
 	free(contents);
 	return (0);
 }
 
+/* Verify that a text file contains the specified lines, regardless of order */
+/* This could be more efficient if we sorted both sets of lines, etc, but
+ * since this is used only for testing and only ever deals with a dozen or so
+ * lines at a time, this relatively crude approach is just fine. */
+int
+assertion_file_contains_lines_any_order(const char *file, int line,
+    const char *pathname, const char *lines[])
+{
+	char *buff;
+	size_t buff_size;
+	size_t expected_count, actual_count, i, j;
+	char **expected;
+	char *p, **actual;
+	char c;
+	int expected_failure = 0, actual_failure = 0;
+
+	assertion_count(file, line);
+
+	buff = slurpfile(&buff_size, "%s", pathname);
+	if (buff == NULL) {
+		failure_start(pathname, line, "Can't read file: %s", pathname);
+		failure_finish(NULL);
+		return (0);
+	}
+
+	/* Make a copy of the provided lines and count up the expected file size. */
+	expected_count = 0;
+	for (i = 0; lines[i] != NULL; ++i) {
+	}
+	expected_count = i;
+	expected = malloc(sizeof(char *) * expected_count);
+	for (i = 0; lines[i] != NULL; ++i) {
+		expected[i] = strdup(lines[i]);
+	}
+
+	/* Break the file into lines */
+	actual_count = 0;
+	for (c = '\0', p = buff; p < buff + buff_size; ++p) {
+		if (*p == '\x0d' || *p == '\x0a')
+			*p = '\0';
+		if (c == '\0' && *p != '\0')
+			++actual_count;
+		c = *p;
+	}
+	actual = malloc(sizeof(char *) * actual_count);
+	for (j = 0, p = buff; p < buff + buff_size; p += 1 + strlen(p)) {
+		if (*p != '\0') {
+			actual[j] = p;
+			++j;
+		}
+	}
+
+	/* Erase matching lines from both lists */
+	for (i = 0; i < expected_count; ++i) {
+		if (expected[i] == NULL)
+			continue;
+		for (j = 0; j < actual_count; ++j) {
+			if (actual[j] == NULL)
+				continue;
+			if (strcmp(expected[i], actual[j]) == 0) {
+				free(expected[i]);
+				expected[i] = NULL;
+				actual[j] = NULL;
+				break;
+			}
+		}
+	}
+
+	/* If there's anything left, it's a failure */
+	for (i = 0; i < expected_count; ++i) {
+		if (expected[i] != NULL)
+			++expected_failure;
+	}
+	for (j = 0; j < actual_count; ++j) {
+		if (actual[j] != NULL)
+			++actual_failure;
+	}
+	if (expected_failure == 0 && actual_failure == 0) {
+		free(buff);
+		free(expected);
+		free(actual);
+		return (1);
+	}
+	failure_start(file, line, "File doesn't match: %s", pathname);
+	for (i = 0; i < expected_count; ++i) {
+		if (expected[i] != NULL) {
+			logprintf("  Expected but not present: %s\n", expected[i]);
+			free(expected[i]);
+		}
+	}
+	for (j = 0; j < actual_count; ++j) {
+		if (actual[j] != NULL)
+			logprintf("  Present but not expected: %s\n", actual[j]);
+	}
+	failure_finish(NULL);
+	free(buff);
+	free(expected);
+	free(actual);
+	return (0);
+}
+
 /* Test that two paths point to the same file. */
 /* As a side-effect, asserts that both files exist. */
 static int
@@ -934,8 +1161,11 @@
 	ftime.dwHighDateTime = 0;
 
 	assertion_count(file, line);
+	/* Note: FILE_FLAG_BACKUP_SEMANTICS applies to open
+	 * a directory file. If not, CreateFile() will fail when
+	 * the pathname is a directory. */
 	h = CreateFile(pathname, FILE_READ_ATTRIBUTES, 0, NULL,
-	    OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+	    OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
 	if (h == INVALID_HANDLE_VALUE) {
 		failure_start(file, line, "Can't access %s\n", pathname);
 		failure_finish(NULL);
@@ -1000,14 +1230,14 @@
 		time_t now = time(NULL);
 		if (filet < now - 10 || filet > now + 1) {
 			failure_start(file, line,
-			    "File %s has %ctime %ld, %ld seconds ago\n",
+			    "File %s has %ctime %lld, %lld seconds ago\n",
 			    pathname, type, filet, now - filet);
 			failure_finish(NULL);
 			return (0);
 		}
 	} else if (filet != t || filet_nsec != nsec) {
 		failure_start(file, line,
-		    "File %s has %ctime %ld.%09ld, expected %ld.%09ld",
+		    "File %s has %ctime %lld.%09lld, expected %lld.%09lld",
 		    pathname, type, filet, filet_nsec, t, nsec);
 		failure_finish(NULL);
 		return (0);
@@ -1084,7 +1314,7 @@
 
 	assertion_count(file, line);
 	r = lstat(pathname, &st);
-	if (r == 0 && st.st_nlink == nlinks)
+	if (r == 0 && (int)st.st_nlink == nlinks)
 			return (1);
 	failure_start(file, line, "File %s has %d links, expected %d",
 	    pathname, st.st_nlink, nlinks);
@@ -1148,7 +1378,7 @@
 	/* Windows doesn't handle permissions the same way as POSIX,
 	 * so just ignore the mode tests. */
 	/* TODO: Can we do better here? */
-	if (mode >= 0 && mode != (st.st_mode & 07777)) {
+	if (mode >= 0 && (mode_t)mode != (st.st_mode & 07777)) {
 		failure_start(file, line, "Dir %s has wrong mode", pathname);
 		logprintf("  Expected: 0%3o\n", mode);
 		logprintf("  Found: 0%3o\n", st.st_mode & 07777);
@@ -1181,7 +1411,7 @@
 	/* Windows doesn't handle permissions the same way as POSIX,
 	 * so just ignore the mode tests. */
 	/* TODO: Can we do better here? */
-	if (mode >= 0 && mode != (st.st_mode & 07777)) {
+	if (mode >= 0 && (mode_t)mode != (st.st_mode & 07777)) {
 		failure_start(file, line, "File %s has wrong mode", pathname);
 		logprintf("  Expected: 0%3o\n", mode);
 		logprintf("  Found: 0%3o\n", st.st_mode & 07777);
@@ -1380,6 +1610,110 @@
 	return (1);
 }
 
+/* Set times, report failures. */
+int
+assertion_utimes(const char *file, int line,
+    const char *pathname, long at, long at_nsec, long mt, long mt_nsec)
+{
+	int r;
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#define WINTIME(sec, nsec) ((Int32x32To64(sec, 10000000) + EPOC_TIME)\
+	 + (((nsec)/1000)*10))
+	HANDLE h;
+	ULARGE_INTEGER wintm;
+	FILETIME fatime, fmtime;
+	FILETIME *pat, *pmt;
+
+	assertion_count(file, line);
+	h = CreateFileA(pathname,GENERIC_READ | GENERIC_WRITE,
+		    FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
+		    FILE_FLAG_BACKUP_SEMANTICS, NULL);
+	if (h == INVALID_HANDLE_VALUE) {
+		failure_start(file, line, "Can't access %s\n", pathname);
+		failure_finish(NULL);
+		return (0);
+	}
+
+	if (at > 0 || at_nsec > 0) {
+		wintm.QuadPart = WINTIME(at, at_nsec);
+		fatime.dwLowDateTime = wintm.LowPart;
+		fatime.dwHighDateTime = wintm.HighPart;
+		pat = &fatime;
+	} else
+		pat = NULL;
+	if (mt > 0 || mt_nsec > 0) {
+		wintm.QuadPart = WINTIME(mt, mt_nsec);
+		fmtime.dwLowDateTime = wintm.LowPart;
+		fmtime.dwHighDateTime = wintm.HighPart;
+		pmt = &fmtime;
+	} else
+		pmt = NULL;
+	if (pat != NULL || pmt != NULL)
+		r = SetFileTime(h, NULL, pat, pmt);
+	else
+		r = 1;
+	CloseHandle(h);
+	if (r == 0) {
+		failure_start(file, line, "Can't SetFileTime %s\n", pathname);
+		failure_finish(NULL);
+		return (0);
+	}
+	return (1);
+#else /* defined(_WIN32) && !defined(__CYGWIN__) */
+	struct stat st;
+	struct timeval times[2];
+
+#if !defined(__FreeBSD__)
+	mt_nsec = at_nsec = 0;	/* Generic POSIX only has whole seconds. */
+#endif
+	if (mt == 0 && mt_nsec == 0 && at == 0 && at_nsec == 0)
+		return (1);
+
+	r = lstat(pathname, &st);
+	if (r < 0) {
+		failure_start(file, line, "Can't stat %s\n", pathname);
+		failure_finish(NULL);
+		return (0);
+	}
+
+	if (mt == 0 && mt_nsec == 0) {
+		mt = st.st_mtime;
+#if defined(__FreeBSD__)
+		mt_nsec = st.st_mtimespec.tv_nsec;
+		/* FreeBSD generally only stores to microsecond res, so round. */
+		mt_nsec = (mt_nsec / 1000) * 1000;
+#endif
+	}
+	if (at == 0 && at_nsec == 0) {
+		at = st.st_atime;
+#if defined(__FreeBSD__)
+		at_nsec = st.st_atimespec.tv_nsec;
+		/* FreeBSD generally only stores to microsecond res, so round. */
+		at_nsec = (at_nsec / 1000) * 1000;
+#endif
+	}
+
+	times[1].tv_sec = mt;
+	times[1].tv_usec = mt_nsec / 1000;
+
+	times[0].tv_sec = at;
+	times[0].tv_usec = at_nsec / 1000;
+
+#ifdef HAVE_LUTIMES
+	r = lutimes(pathname, times);
+#else
+	r = utimes(pathname, times);
+#endif
+	if (r < 0) {
+		failure_start(file, line, "Can't utimes %s\n", pathname);
+		failure_finish(NULL);
+		return (0);
+	}
+	return (1);
+#endif /* defined(_WIN32) && !defined(__CYGWIN__) */
+}
+
 /*
  *
  *  UTILITIES for use by tests.
@@ -1605,6 +1939,27 @@
 	fclose(in);
 }
 
+int
+is_LargeInode(const char *file)
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+	BY_HANDLE_FILE_INFORMATION bhfi;
+	int r;
+
+	r = my_GetFileInformationByName(file, &bhfi);
+	if (r != 0)
+		return (0);
+	return (bhfi.nFileIndexHigh & 0x0000FFFFUL);
+#else
+	struct stat st;
+	int64_t ino;
+
+	if (stat(file, &st) < 0)
+		return (0);
+	ino = (int64_t)st.st_ino;
+	return (ino > 0xffffffff);
+#endif
+}
 /*
  *
  * TEST management
@@ -1634,7 +1989,7 @@
  * Summarize repeated failures in the just-completed test.
  */
 static void
-test_summarize(const char *filename, int failed)
+test_summarize(int failed)
 {
 	unsigned int i;
 
@@ -1653,9 +2008,10 @@
 	for (i = 0; i < sizeof(failed_lines)/sizeof(failed_lines[0]); i++) {
 		if (failed_lines[i].count > 1 && !failed_lines[i].skip)
 			logprintf("%s:%d: Summary: Failed %d times\n",
-			    filename, i, failed_lines[i].count);
+			    failed_filename, i, failed_lines[i].count);
 	}
 	/* Clear the failure history for the next file. */
+	failed_filename = NULL;
 	memset(failed_lines, 0, sizeof(failed_lines));
 }
 
@@ -1665,6 +2021,7 @@
 static int
 test_run(int i, const char *tmpdir)
 {
+	char workdir[1024];
 	char logfilename[64];
 	int failures_before = failures;
 	int oldumask;
@@ -1691,11 +2048,12 @@
 	logfile = fopen(logfilename, "w");
 	fprintf(logfile, "%s\n\n", tests[i].name);
 	/* Chdir() to a work dir for this specific test. */
-	if (!assertMakeDir(tests[i].name, 0755)
-	    || !assertChdir(tests[i].name)) {
+	snprintf(workdir, sizeof(workdir), "%s/%s", tmpdir, tests[i].name);
+	testworkdir = workdir;
+	if (!assertMakeDir(testworkdir, 0755)
+	    || !assertChdir(testworkdir)) {
 		fprintf(stderr,
-		    "ERROR: Can't chdir to work dir %s/%s\n",
-		    tmpdir, tests[i].name);
+		    "ERROR: Can't chdir to work dir %s\n", testworkdir);
 		exit(1);
 	}
 	/* Explicitly reset the locale before each test. */
@@ -1709,6 +2067,7 @@
 	/*
 	 * Clean up and report afterwards.
 	 */
+	testworkdir = NULL;
 	/* Restore umask */
 	umask(oldumask);
 	/* Reset locale. */
@@ -1721,7 +2080,7 @@
 	}
 	/* Report per-test summaries. */
 	tests[i].failures = failures - failures_before;
-	test_summarize(test_filename, tests[i].failures);
+	test_summarize(tests[i].failures);
 	/* Close the per-test log file. */
 	fclose(logfile);
 	logfile = NULL;
@@ -1781,6 +2140,7 @@
 	printf("  -q  Quiet.\n");
 	printf("  -r <dir>   Path to dir containing reference files.\n");
 	printf("      Default: Current directory.\n");
+	printf("  -u  Keep running specifies tests until one fails.\n");
 	printf("  -v  Verbose.\n");
 	printf("Available tests:\n");
 	for (i = 0; i < limit; i++)
@@ -1807,7 +2167,11 @@
 	}
 
 	/* Get the current dir. */
+#ifdef PATH_MAX
+	pwd = getcwd(NULL, PATH_MAX);/* Solaris getcwd needs the size. */
+#else
 	pwd = getcwd(NULL, 0);
+#endif
 	while (pwd[strlen(pwd) - 1] == '\n')
 		pwd[strlen(pwd) - 1] = '\0';
 
@@ -1834,6 +2198,14 @@
 	strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
 	strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
 
+#if defined(PROGRAM_ALIAS)
+	snprintf(buff, sizeof(buff), "%s/%s/test", pwd, PROGRAM_ALIAS);
+	p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
+	if (p != NULL) goto success;
+	strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
+	strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+#endif
+
 	if (memcmp(pwd, "/usr/obj", 8) == 0) {
 		snprintf(buff, sizeof(buff), "%s", pwd + 8);
 		p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
@@ -1866,16 +2238,26 @@
 main(int argc, char **argv)
 {
 	static const int limit = sizeof(tests) / sizeof(tests[0]);
-	int i, tests_run = 0, tests_failed = 0, option;
+	int i = 0, j = 0, start, end, tests_run = 0, tests_failed = 0, option;
 	time_t now;
 	char *refdir_alloc = NULL;
 	const char *progname;
+	char **saved_argv;
 	const char *tmp, *option_arg, *p;
-	char tmpdir[256];
+	char tmpdir[256], *pwd, *testprogdir, *tmp2 = NULL;
 	char tmpdir_timestamp[256];
 
 	(void)argc; /* UNUSED */
 
+	/* Get the current dir. */
+#ifdef PATH_MAX
+	pwd = getcwd(NULL, PATH_MAX);/* Solaris getcwd needs the size. */
+#else
+	pwd = getcwd(NULL, 0);
+#endif
+	while (pwd[strlen(pwd) - 1] == '\n')
+		pwd[strlen(pwd) - 1] = '\0';
+
 #if defined(HAVE__CrtSetReportMode)
 	/* To stop to run the default invalid parameter handler. */
 	_set_invalid_parameter_handler(invalid_parameter_handler);
@@ -1888,11 +2270,44 @@
 	 * tree.
 	 */
 	progname = p = argv[0];
+	if ((testprogdir = (char *)malloc(strlen(progname) + 1)) == NULL)
+	{
+		fprintf(stderr, "ERROR: Out of memory.");
+		exit(1);
+	}
+	strcpy(testprogdir, progname);
 	while (*p != '\0') {
 		/* Support \ or / dir separators for Windows compat. */
 		if (*p == '/' || *p == '\\')
+		{
 			progname = p + 1;
+			i = j;
+		}
 		++p;
+		j++;
+	}
+	testprogdir[i] = '\0';
+#if defined(_WIN32) && !defined(__CYGWIN__)
+	if (testprogdir[0] != '/' && testprogdir[0] != '\\' &&
+	    !(((testprogdir[0] >= 'a' && testprogdir[0] <= 'z') ||
+	       (testprogdir[0] >= 'A' && testprogdir[0] <= 'Z')) &&
+		testprogdir[1] == ':' &&
+		(testprogdir[2] == '/' || testprogdir[2] == '\\')))
+#else
+	if (testprogdir[0] != '/')
+#endif
+	{
+		/* Fixup path for relative directories. */
+		if ((testprogdir = (char *)realloc(testprogdir,
+			strlen(pwd) + 1 + strlen(testprogdir) + 1)) == NULL)
+		{
+			fprintf(stderr, "ERROR: Out of memory.");
+			exit(1);
+		}
+		memmove(testprogdir + strlen(pwd) + 1, testprogdir,
+		    strlen(testprogdir));
+		memcpy(testprogdir, pwd, strlen(pwd));
+		testprogdir[strlen(pwd)] = '/';
 	}
 
 #ifdef PROGRAM
@@ -1957,6 +2372,7 @@
 #ifdef PROGRAM
 				testprogfile = option_arg;
 #else
+				fprintf(stderr, "-p option not permitted\n");
 				usage(progname);
 #endif
 				break;
@@ -1966,10 +2382,15 @@
 			case 'r':
 				refdir = option_arg;
 				break;
+			case 'u':
+				until_failure++;
+				break;
 			case 'v':
 				verbosity++;
 				break;
 			default:
+				fprintf(stderr, "Unrecognized option '%c'\n",
+				    option);
 				usage(progname);
 			}
 		}
@@ -1980,7 +2401,19 @@
 	 */
 #ifdef PROGRAM
 	if (testprogfile == NULL)
-		usage(progname);
+	{
+		if ((tmp2 = (char *)malloc(strlen(testprogdir) + 1 +
+			strlen(PROGRAM) + 1)) == NULL)
+		{
+			fprintf(stderr, "ERROR: Out of memory.");
+			exit(1);
+		}
+		strcpy(tmp2, testprogdir);
+		strcat(tmp2, "/");
+		strcat(tmp2, PROGRAM);
+		testprogfile = tmp2;
+	}
+
 	{
 		char *testprg;
 #if defined(_WIN32) && !defined(__CYGWIN__)
@@ -2001,6 +2434,16 @@
 	}
 #endif
 
+#if !defined(_WIN32) && defined(SIGPIPE)
+	{   /* Ignore SIGPIPE signals */
+		struct sigaction sa;
+		sa.sa_handler = SIG_IGN;
+		sigemptyset(&sa.sa_mask);
+		sa.sa_flags = 0;
+		sigaction(SIGPIPE, &sa, NULL);
+	}
+#endif
+
 	/*
 	 * Create a temp directory for the following tests.
 	 * Include the time the tests started as part of the name,
@@ -2053,42 +2496,88 @@
 	/*
 	 * Run some or all of the individual tests.
 	 */
-	if (*argv == NULL) {
-		/* Default: Run all tests. */
-		for (i = 0; i < limit; i++) {
-			if (test_run(i, tmpdir))
-				tests_failed++;
-			tests_run++;
-		}
-	} else {
-		while (*(argv) != NULL) {
-			if (**argv >= '0' && **argv <= '9') {
-				i = atoi(*argv);
-				if (i < 0 || i >= limit) {
-					printf("*** INVALID Test %s\n", *argv);
-					free(refdir_alloc);
-					usage(progname);
-					/* usage() never returns */
-				}
-			} else {
-				for (i = 0; i < limit; ++i) {
-					if (strcmp(*argv, tests[i].name) == 0)
-						break;
-				}
-				if (i >= limit) {
-					printf("*** INVALID Test ``%s''\n",
-					       *argv);
-					free(refdir_alloc);
-					usage(progname);
-					/* usage() never returns */
+	saved_argv = argv;
+	do {
+		argv = saved_argv;
+		if (*argv == NULL) {
+			/* Default: Run all tests. */
+			for (i = 0; i < limit; i++) {
+				tests_run++;
+				if (test_run(i, tmpdir)) {
+					tests_failed++;
+					if (until_failure)
+						goto finish;
 				}
 			}
-			if (test_run(i, tmpdir))
-				tests_failed++;
-			tests_run++;
-			argv++;
+		} else {
+			while (*(argv) != NULL) {
+				if (**argv >= '0' && **argv <= '9') {
+					char *vp = *argv;
+					start = 0;
+					while (*vp >= '0' && *vp <= '9') {
+						start *= 10;
+						start += *vp - '0';
+						++vp;
+					}
+					if (*vp == '\0') {
+						end = start;
+					} else if (*vp == '-') {
+						++vp;
+						if (*vp == '\0') {
+							end = limit - 1;
+						} else {
+							end = 0;
+							while (*vp >= '0' && *vp <= '9') {
+								end *= 10;
+								end += *vp - '0';
+								++vp;
+							}
+						}
+					} else {
+						printf("*** INVALID Test %s\n", *argv);
+						free(refdir_alloc);
+						usage(progname);
+						return (1);
+					}
+					if (start < 0 || end >= limit || start > end) {
+						printf("*** INVALID Test %s\n", *argv);
+						free(refdir_alloc);
+						usage(progname);
+						return (1);
+					}
+				} else {
+					for (start = 0; start < limit; ++start) {
+						if (strcmp(*argv, tests[start].name) == 0)
+							break;
+					}
+					end = start;
+					if (start >= limit) {
+						printf("*** INVALID Test ``%s''\n",
+						    *argv);
+						free(refdir_alloc);
+						usage(progname);
+						/* usage() never returns */
+					}
+				}
+				while (start <= end) {
+					tests_run++;
+					if (test_run(start, tmpdir)) {
+						tests_failed++;
+						if (until_failure)
+							goto finish;
+					}
+					++start;
+				}
+				argv++;
+			}
 		}
-	}
+	} while (until_failure);
+
+finish:
+	/* Must be freed after all tests run */
+	free(tmp2);
+	free(testprogdir);
+	free(pwd);
 
 	/*
 	 * Report summary statistics.
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/read_open_memory.c
--- a/head/contrib/libarchive/libarchive/test/read_open_memory.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/read_open_memory.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  */
 
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/read_open_memory.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/read_open_memory.c 232153 2012-02-25 10:58:02Z mm $");
 
 #include <errno.h>
 #include <stdlib.h>
@@ -39,7 +39,8 @@
  */
 
 struct read_memory_data {
-	unsigned char	*buffer;
+	unsigned char	*start;
+	unsigned char	*p;
 	unsigned char	*end;
 	size_t	 read_size;
 	size_t copy_buff_size;
@@ -49,7 +50,8 @@
 
 static int	memory_read_close(struct archive *, void *);
 static int	memory_read_open(struct archive *, void *);
-static off_t	memory_read_skip(struct archive *, void *, off_t request);
+static int64_t	memory_read_seek(struct archive *, void *, int64_t request, int whence);
+static int64_t	memory_read_skip(struct archive *, void *, int64_t request);
 static ssize_t	memory_read(struct archive *, void *, const void **buff);
 static int	read_open_memory_internal(struct archive *a, void *buff,
     size_t size, size_t read_size, int fullapi);
@@ -58,7 +60,7 @@
 int
 read_open_memory(struct archive *a, void *buff, size_t size, size_t read_size)
 {
-	return read_open_memory_internal(a, buff, size, read_size, 1);
+	return read_open_memory_internal(a, buff, size, read_size, 2);
 }
 
 /*
@@ -68,12 +70,21 @@
 int
 read_open_memory2(struct archive *a, void *buff, size_t size, size_t read_size)
 {
-	return read_open_memory_internal(a, buff, size, read_size, 0);
+	return read_open_memory_internal(a, buff, size, read_size, 1);
+}
+
+/*
+ * Include a seek callback as well.
+ */
+int
+read_open_memory_seek(struct archive *a, void *buff, size_t size, size_t read_size)
+{
+	return read_open_memory_internal(a, buff, size, read_size, 3);
 }
 
 static int
 read_open_memory_internal(struct archive *a, void *buff,
-    size_t size, size_t read_size, int fullapi)
+    size_t size, size_t read_size, int level)
 {
 	struct read_memory_data *mine;
 
@@ -83,19 +94,26 @@
 		return (ARCHIVE_FATAL);
 	}
 	memset(mine, 0, sizeof(*mine));
-	mine->buffer = (unsigned char *)buff;
-	mine->end = mine->buffer + size;
+	mine->start = mine->p = (unsigned char *)buff;
+	mine->end = mine->start + size;
 	mine->read_size = read_size;
 	mine->copy_buff_offset = 32;
 	mine->copy_buff_size = read_size + mine->copy_buff_offset * 2;
 	mine->copy_buff = malloc(mine->copy_buff_size);
 	memset(mine->copy_buff, 0xA5, mine->copy_buff_size);
-	if (fullapi)
-		return (archive_read_open2(a, mine, memory_read_open,
-			    memory_read, memory_read_skip, memory_read_close));
-	else
-		return (archive_read_open2(a, mine, NULL,
-			    memory_read, NULL, memory_read_close));
+
+	switch (level) {
+	case 3:
+		archive_read_set_seek_callback(a, memory_read_seek);
+	case 2:
+		archive_read_set_open_callback(a, memory_read_open);
+		archive_read_set_skip_callback(a, memory_read_skip);
+	case 1:
+		archive_read_set_read_callback(a, memory_read);
+		archive_read_set_close_callback(a, memory_read_close);
+		archive_read_set_callback_data(a, mine);
+	}
+	return archive_read_open1(a);
 }
 
 /*
@@ -119,41 +137,75 @@
 memory_read(struct archive *a, void *client_data, const void **buff)
 {
 	struct read_memory_data *mine = (struct read_memory_data *)client_data;
-	size_t size;
+	ssize_t size;
 
 	(void)a; /* UNUSED */
-	size = mine->end - mine->buffer;
-	if (size > mine->read_size)
+	size = mine->end - mine->p;
+	if (size < 0) {
+		buff = NULL;
+		return 0;
+	}
+	if ((size_t)size > mine->read_size)
 		size = mine->read_size;
 	else
 		memset(mine->copy_buff, 0xA5, mine->copy_buff_size);
-	memcpy(mine->copy_buff + mine->copy_buff_offset, mine->buffer, size);
+	memcpy(mine->copy_buff + mine->copy_buff_offset, mine->p, size);
 	*buff = mine->copy_buff + mine->copy_buff_offset;
 
-        mine->buffer += size;
+        mine->p += size;
 	return ((ssize_t)size);
 }
 
 /*
  * How mean can a skip() routine be?  Let's try to find out.
  */
-static off_t
-memory_read_skip(struct archive *a, void *client_data, off_t skip)
+static int64_t
+memory_read_skip(struct archive *a, void *client_data, int64_t skip)
 {
 	struct read_memory_data *mine = (struct read_memory_data *)client_data;
 
 	(void)a; /* UNUSED */
 	/* We can't skip by more than is available. */
-	if ((off_t)skip > (off_t)(mine->end - mine->buffer))
-		skip = mine->end - mine->buffer;
+	if ((off_t)skip > (off_t)(mine->end - mine->p))
+		skip = mine->end - mine->p;
 	/* Always do small skips by prime amounts. */
 	if (skip > 71)
 		skip = 71;
-	mine->buffer += skip;
+	mine->p += skip;
 	return (skip);
 }
 
 /*
+ */
+static int64_t
+memory_read_seek(struct archive *a, void *client_data, int64_t offset, int whence)
+{
+	struct read_memory_data *mine = (struct read_memory_data *)client_data;
+
+	(void)a; /* UNUSED */
+	switch (whence) {
+	case SEEK_SET:
+		mine->p = mine->start + offset;
+		break;
+	case SEEK_END:
+		mine->p = mine->end + offset;
+		break;
+	case SEEK_CUR:
+		mine->p += offset;
+		break;
+	}
+	if (mine->p < mine->start) {
+		mine->p = mine->start;
+		return ARCHIVE_FAILED;
+	}
+	if (mine->p > mine->end) {
+		mine->p = mine->end;
+		return ARCHIVE_FAILED;
+	}
+	return (mine->p - mine->start);
+}
+
+/*
  * Close is just cleaning up our one small bit of data.
  */
 static int
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test.h
--- a/head/contrib/libarchive/libarchive/test/test.h	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test.h	Fri Mar 02 16:54:40 2012 +0200
@@ -22,7 +22,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: head/contrib/libarchive/libarchive/test/test.h 228763 2011-12-21 11:13:29Z mm $
+ * $FreeBSD: head/contrib/libarchive/libarchive/test/test.h 232153 2012-02-25 10:58:02Z mm $
  */
 
 /* Every test program should #include "test.h" as the first thing. */
@@ -86,9 +86,6 @@
 #if !defined(__BORLANDC__)
 #define strdup _strdup
 #endif
-#define	LOCALE_UTF8	NULL
-#else
-#define LOCALE_UTF8	"de_DE.UTF-8"
 #endif
 
 /* Visual Studio */
@@ -100,16 +97,9 @@
 #pragma warn -8068	/* Constant out of range in comparison. */
 #endif
 
-/* Cygwin */
-#if defined(__CYGWIN__)
-/* Cygwin-1.7.x is lazy about populating nlinks, so don't
- * expect it to be accurate. */
-# define NLINKS_INACCURATE_FOR_DIRS
-#endif
-
-/* Haiku OS */
-#if defined(__HAIKU__)
-/* Haiku has typedefs in stdint.h (needed for int64_t) */
+/* Haiku OS and QNX */
+#if defined(__HAIKU__) || defined(__QNXNTO__)
+/* Haiku and QNX have typedefs in stdint.h (needed for int64_t) */
 #include <stdint.h>
 #endif
 
@@ -143,24 +133,24 @@
   assertion_equal_int(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
 /* Assert two strings are the same.  Reports value of each one if not. */
 #define assertEqualString(v1,v2)   \
-  assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
+  assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL, 0)
+#define assertEqualUTF8String(v1,v2)   \
+  assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL, 1)
 /* As above, but v1 and v2 are wchar_t * */
 #define assertEqualWString(v1,v2)   \
   assertion_equal_wstring(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
 /* As above, but raw blocks of bytes. */
 #define assertEqualMem(v1, v2, l)	\
   assertion_equal_mem(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (l), #l, NULL)
-/* Assert two files are the same; allow printf-style expansion of second name.
- * See below for comments about variable arguments here...
- */
-#define assertEqualFile		\
-  assertion_setup(__FILE__, __LINE__);assertion_equal_file
-/* Assert that a file is empty; supports printf-style arguments. */
-#define assertEmptyFile		\
-  assertion_setup(__FILE__, __LINE__);assertion_empty_file
-/* Assert that a file is not empty; supports printf-style arguments. */
-#define assertNonEmptyFile		\
-  assertion_setup(__FILE__, __LINE__);assertion_non_empty_file
+/* Assert two files are the same. */
+#define assertEqualFile(f1, f2)	\
+  assertion_equal_file(__FILE__, __LINE__, (f1), (f2))
+/* Assert that a file is empty. */
+#define assertEmptyFile(pathname)	\
+  assertion_empty_file(__FILE__, __LINE__, (pathname))
+/* Assert that a file is not empty. */
+#define assertNonEmptyFile(pathname)		\
+  assertion_non_empty_file(__FILE__, __LINE__, (pathname))
 #define assertFileAtime(pathname, sec, nsec)	\
   assertion_file_atime(__FILE__, __LINE__, pathname, sec, nsec)
 #define assertFileAtimeRecent(pathname)	\
@@ -170,14 +160,14 @@
 #define assertFileBirthtimeRecent(pathname) \
   assertion_file_birthtime_recent(__FILE__, __LINE__, pathname)
 /* Assert that a file exists; supports printf-style arguments. */
-#define assertFileExists		\
-  assertion_setup(__FILE__, __LINE__);assertion_file_exists
-/* Assert that a file exists; supports printf-style arguments. */
-#define assertFileNotExists		\
-  assertion_setup(__FILE__, __LINE__);assertion_file_not_exists
-/* Assert that file contents match a string; supports printf-style arguments. */
-#define assertFileContents             \
-  assertion_setup(__FILE__, __LINE__);assertion_file_contents
+#define assertFileExists(pathname) \
+  assertion_file_exists(__FILE__, __LINE__, pathname)
+/* Assert that a file exists. */
+#define assertFileNotExists(pathname) \
+  assertion_file_not_exists(__FILE__, __LINE__, pathname)
+/* Assert that file contents match a string. */
+#define assertFileContents(data, data_size, pathname) \
+  assertion_file_contents(__FILE__, __LINE__, data, data_size, pathname)
 #define assertFileMtime(pathname, sec, nsec)	\
   assertion_file_mtime(__FILE__, __LINE__, pathname, sec, nsec)
 #define assertFileMtimeRecent(pathname) \
@@ -186,8 +176,10 @@
   assertion_file_nlinks(__FILE__, __LINE__, pathname, nlinks)
 #define assertFileSize(pathname, size)  \
   assertion_file_size(__FILE__, __LINE__, pathname, size)
-#define assertTextFileContents         \
-  assertion_setup(__FILE__, __LINE__);assertion_text_file_contents
+#define assertTextFileContents(text, pathname) \
+  assertion_text_file_contents(__FILE__, __LINE__, text, pathname)
+#define assertFileContainsLinesAnyOrder(pathname, lines)	\
+  assertion_file_contains_lines_any_order(__FILE__, __LINE__, pathname, lines)
 #define assertIsDir(pathname, mode)		\
   assertion_is_dir(__FILE__, __LINE__, pathname, mode)
 #define assertIsHardlink(path1, path2)	\
@@ -209,6 +201,8 @@
   assertion_make_symlink(__FILE__, __LINE__, newfile, linkto)
 #define assertUmask(mask)	\
   assertion_umask(__FILE__, __LINE__, mask)
+#define assertUtimes(pathname, atime, atime_nsec, mtime, mtime_nsec)	\
+  assertion_utimes(__FILE__, __LINE__, pathname, atime, atime_nsec, mtime, mtime_nsec)
 
 /*
  * This would be simple with C99 variadic macros, but I don't want to
@@ -217,28 +211,29 @@
  * but effective.
  */
 #define skipping	\
-  assertion_setup(__FILE__, __LINE__);test_skipping
+  skipping_setup(__FILE__, __LINE__);test_skipping
 
 /* Function declarations.  These are defined in test_utility.c. */
 void failure(const char *fmt, ...);
 int assertion_assert(const char *, int, int, const char *, void *);
 int assertion_chdir(const char *, int, const char *);
-int assertion_empty_file(const char *, ...);
-int assertion_equal_file(const char *, const char *, ...);
+int assertion_empty_file(const char *, int, const char *);
+int assertion_equal_file(const char *, int, const char *, const char *);
 int assertion_equal_int(const char *, int, long long, const char *, long long, const char *, void *);
 int assertion_equal_mem(const char *, int, const void *, const char *, const void *, const char *, size_t, const char *, void *);
-int assertion_equal_string(const char *, int, const char *v1, const char *, const char *v2, const char *, void *);
+int assertion_equal_string(const char *, int, const char *v1, const char *, const char *v2, const char *, void *, int);
 int assertion_equal_wstring(const char *, int, const wchar_t *v1, const char *, const wchar_t *v2, const char *, void *);
 int assertion_file_atime(const char *, int, const char *, long, long);
 int assertion_file_atime_recent(const char *, int, const char *);
 int assertion_file_birthtime(const char *, int, const char *, long, long);
 int assertion_file_birthtime_recent(const char *, int, const char *);
-int assertion_file_contents(const void *, int, const char *, ...);
-int assertion_file_exists(const char *, ...);
+int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **);
+int assertion_file_contents(const char *, int, const void *, int, const char *);
+int assertion_file_exists(const char *, int, const char *);
 int assertion_file_mtime(const char *, int, const char *, long, long);
 int assertion_file_mtime_recent(const char *, int, const char *);
 int assertion_file_nlinks(const char *, int, const char *, int);
-int assertion_file_not_exists(const char *, ...);
+int assertion_file_not_exists(const char *, int, const char *);
 int assertion_file_size(const char *, int, const char *, long);
 int assertion_is_dir(const char *, int, const char *, int);
 int assertion_is_hardlink(const char *, int, const char *, const char *);
@@ -249,11 +244,12 @@
 int assertion_make_file(const char *, int, const char *, int, const char *);
 int assertion_make_hardlink(const char *, int, const char *newpath, const char *);
 int assertion_make_symlink(const char *, int, const char *newpath, const char *);
-int assertion_non_empty_file(const char *, ...);
-int assertion_text_file_contents(const char *buff, const char *f);
+int assertion_non_empty_file(const char *, int, const char *);
+int assertion_text_file_contents(const char *, int, const char *buff, const char *f);
 int assertion_umask(const char *, int, int);
-void assertion_setup(const char *, int);
+int assertion_utimes(const char *, int, const char *, long, long, long, long );
 
+void skipping_setup(const char *, int);
 void test_skipping(const char *fmt, ...);
 
 /* Like sprintf, then system() */
@@ -271,6 +267,9 @@
 /* Return true if this platform can run the "gunzip" program. */
 int canGunzip(void);
 
+/* Return true if the file has large i-node number(>0xffffffff). */
+int is_LargeInode(const char *);
+
 /* Suck file into string allocated via malloc(). Call free() when done. */
 /* Supports printf-style args: slurpfile(NULL, "%s/myfile", refdir); */
 char *slurpfile(size_t *, const char *fmt, ...);
@@ -278,6 +277,9 @@
 /* Extracts named reference file to the current directory. */
 void extract_reference_file(const char *);
 
+/* Path to working directory for current test */
+const char *testworkdir;
+
 /*
  * Special interfaces for libarchive test harness.
  */
@@ -289,13 +291,15 @@
 int read_open_memory(struct archive *, void *, size_t, size_t);
 /* "2" version exercises a slightly different set of libarchive APIs. */
 int read_open_memory2(struct archive *, void *, size_t, size_t);
+/* _seek version produces a seekable file. */
+int read_open_memory_seek(struct archive *, void *, size_t, size_t);
 
 /* Versions of above that accept an archive argument for additional info. */
 #define assertA(e)   assertion_assert(__FILE__, __LINE__, (e), #e, (a))
 #define assertEqualIntA(a,v1,v2)   \
   assertion_equal_int(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (a))
 #define assertEqualStringA(a,v1,v2)   \
-  assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (a))
+  assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (a), 0)
 
 #ifdef USE_DMALLOC
 #include <dmalloc.h>
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_acl_freebsd.c
--- a/head/contrib/libarchive/libarchive/test/test_acl_freebsd.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_acl_freebsd.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_acl_freebsd.c 228773 2011-12-21 15:18:52Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_acl_freebsd.c 232153 2012-02-25 10:58:02Z mm $");
 
 #if defined(__FreeBSD__) && __FreeBSD__ > 4
 #include <sys/acl.h>
@@ -222,7 +222,7 @@
 	}
 	if (n != 0 && errno == EINVAL) {
 		close(fd);
-		skipping("POSIX.1e ACL tests require that POSIX.1e ACL support be enabled on the filesystem");
+		skipping("This filesystem does not support POSIX.1e ACLs");
 		return;
 	}
 	failure("acl_set_fd(): errno = %d (%s)",
@@ -247,7 +247,7 @@
 
 	/* Close the archive. */
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/* Verify the data on disk. */
 	assertEqualInt(0, stat("test0", &st));
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_acl_pax.c
--- a/head/contrib/libarchive/libarchive/test/test_acl_pax.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_acl_pax.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_acl_pax.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_acl_pax.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * Exercise the system-independent portion of the ACL support.
@@ -35,230 +35,6 @@
 
 static unsigned char buff[16384];
 
-static unsigned char reference[] = {
-'P','a','x','H','e','a','d','e','r','/','f','i','l','e',0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ',0,'0','0',
-'0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','0','6','2',' ','0',
-'0','0','0','0','0','0','0','0','0','0',' ','0','1','1','7','6','7',0,' ',
-'x',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a','r',
-0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0','0',
-'0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,'1','6',' ','S','C','H','I','L','Y','.','d','e','v','=','0',10,
-'1','6',' ','S','C','H','I','L','Y','.','i','n','o','=','0',10,'1','8',' ',
-'S','C','H','I','L','Y','.','n','l','i','n','k','=','0',10,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,'f','i','l','e',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ',0,'0','0',
-'0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','0','0','0',' ','0',
-'0','0','0','0','0','0','0','0','0','0',' ','0','1','0','0','0','6',0,' ',
-'0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a','r',
-0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0','0',
-'0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,'P','a','x','H','e','a','d','e','r','/','f','i','l','e',0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ',
-0,'0','0','0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','1','7','2',
-' ','0','0','0','0','0','0','0','0','0','0','0',' ','0','1','1','7','7','1',
-0,' ','x',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t',
-'a','r',0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0',
-'0','0','0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,'7','2',' ','S','C','H','I','L','Y','.','a','c','l','.',
-'a','c','c','e','s','s','=','u','s','e','r',':',':','-','-','x',',','g','r',
-'o','u','p',':',':','r','-','-',',','o','t','h','e','r',':',':','-','w','-',
-',','u','s','e','r',':','u','s','e','r','7','7',':','r','-','-',':','7','7',
-10,'1','6',' ','S','C','H','I','L','Y','.','d','e','v','=','0',10,'1','6',
-' ','S','C','H','I','L','Y','.','i','n','o','=','0',10,'1','8',' ','S','C',
-'H','I','L','Y','.','n','l','i','n','k','=','0',10,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,'f','i','l','e',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ',0,'0','0','0',
-'0','0','0',' ',0,'0','0','0','0','0','0','0','0','0','0','0',' ','0','0',
-'0','0','0','0','0','0','0','0','0',' ','0','1','0','0','0','6',0,' ','0',
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a','r',0,
-'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0','0',
-'0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,'P','a','x','H','e','a','d','e','r','/','f','i','l','e',0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,'0','0','0','5','4','3',' ',0,'0','0','0','0','0','0',' ',
-0,'0','0','0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','2','4','3',
-' ','0','0','0','0','0','0','0','0','0','0','0',' ','0','1','1','7','7','5',
-0,' ','x',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t',
-'a','r',0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0',
-'0','0','0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,'1','1','3',' ','S','C','H','I','L','Y','.','a','c','l',
-'.','a','c','c','e','s','s','=','u','s','e','r',':',':','r','-','x',',','g',
-'r','o','u','p',':',':','r','-','-',',','o','t','h','e','r',':',':','-','w',
-'x',',','u','s','e','r',':','u','s','e','r','7','7',':','r','-','-',':','7',
-'7',',','u','s','e','r',':','u','s','e','r','7','8',':','-','-','-',':','7',
-'8',',','g','r','o','u','p',':','g','r','o','u','p','7','8',':','r','w','x',
-':','7','8',10,'1','6',' ','S','C','H','I','L','Y','.','d','e','v','=','0',
-10,'1','6',' ','S','C','H','I','L','Y','.','i','n','o','=','0',10,'1','8',
-' ','S','C','H','I','L','Y','.','n','l','i','n','k','=','0',10,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,'f','i','l','e',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,'0','0','0','5','4','3',' ',0,'0','0','0','0','0','0',' ',0,'0','0',
-'0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','0','0','0',' ','0',
-'0','0','0','0','0','0','0','0','0','0',' ','0','1','0','0','1','3',0,' ',
-'0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a','r',
-0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0','0',
-'0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,'P','a','x','H','e','a','d','e','r','/','f','i','l','e',0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ',
-0,'0','0','0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','0','6','2',
-' ','0','0','0','0','0','0','0','0','0','0','0',' ','0','1','1','7','6','7',
-0,' ','x',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t',
-'a','r',0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0',
-'0','0','0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,'1','6',' ','S','C','H','I','L','Y','.','d','e','v','=',
-'0',10,'1','6',' ','S','C','H','I','L','Y','.','i','n','o','=','0',10,'1',
-'8',' ','S','C','H','I','L','Y','.','n','l','i','n','k','=','0',10,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'f','i','l','e',0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ',
-0,'0','0','0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','0','0','0',
-' ','0','0','0','0','0','0','0','0','0','0','0',' ','0','1','0','0','0','6',
-0,' ','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t',
-'a','r',0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0',
-'0','0','0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
-
-
 struct acl_t {
 	int type;  /* Type of ACL: "access" or "default" */
 	int permset; /* Permissions for this class of users. */
@@ -386,13 +162,8 @@
 			assert(matched == 1);
 		}
 	}
-#if ARCHIVE_VERSION_NUMBER < 1009000
-	/* Known broken before 1.9.0. */
-	skipping("archive_entry_acl_next() exits with ARCHIVE_EOF");
-#else
 	assertEqualInt(ARCHIVE_EOF, r);
-#endif
-	assert((mode & 0777) == (archive_entry_mode(ae) & 0777));
+	assert((mode_t)(mode & 0777) == (archive_entry_mode(ae) & 0777));
 	failure("Could not find match for ACL "
 	    "(type=%d,permset=%d,tag=%d,qual=%d,name=``%s'')",
 	    acls[marker[0]].type, acls[marker[0]].permset,
@@ -407,6 +178,8 @@
 	struct archive_entry *ae;
 	size_t used;
 	FILE *f;
+	void *reference;
+	size_t reference_size;
 
 	/* Write an archive to memory. */
 	assert(NULL != (a = archive_write_new()));
@@ -445,12 +218,8 @@
 	archive_entry_free(ae);
 
 	/* Close out the archive. */
-	assertA(0 == archive_write_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_write_finish(a);
-#else
-	assertA(0 == archive_write_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/* Write out the data we generated to a file for manual inspection. */
 	assert(NULL != (f = fopen("testout", "wb")));
@@ -458,20 +227,20 @@
 	fclose(f);
 
 	/* Write out the reference data to a file for manual inspection. */
-	assert(NULL != (f = fopen("reference", "wb")));
-	assert(sizeof(reference) == fwrite(reference, 1, sizeof(reference), f));
-	fclose(f);
+	extract_reference_file("test_acl_pax.tar");
+	reference = slurpfile(&reference_size, "test_acl_pax.tar");
 
 	/* Assert that the generated data matches the built-in reference data.*/
-	failure("Generated pax archive does not match reference; check 'testout' and 'reference' files.");
-	assertEqualMem(buff, reference, sizeof(reference));
-	failure("Generated pax archive does not match reference; check 'testout' and 'reference' files.");
-	assertEqualInt((int)used, sizeof(reference));
+	failure("Generated pax archive does not match reference; compare 'testout' to 'test_acl_pax.tar' reference file.");
+	assertEqualMem(buff, reference, reference_size);
+	failure("Generated pax archive does not match reference; compare 'testout' to 'test_acl_pax.tar' reference file.");
+	assertEqualInt((int)used, reference_size);
+	free(reference);
 
 	/* Read back each entry and check that the ACL data is right. */
 	assert(NULL != (a = archive_read_new()));
 	assertA(0 == archive_read_support_format_all(a));
-	assertA(0 == archive_read_support_compression_all(a));
+	assertA(0 == archive_read_support_filter_all(a));
 	assertA(0 == archive_read_open_memory(a, buff, used));
 
 	/* First item has no ACLs */
@@ -508,10 +277,6 @@
 	assert((archive_entry_mode(ae) & 0777) == 0142);
 
 	/* Close the archive. */
-	assertA(0 == archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assertA(0 == archive_read_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_archive_api_feature.c
--- a/head/contrib/libarchive/libarchive/test/test_archive_api_feature.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_archive_api_feature.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_archive_api_feature.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_archive_api_feature.c 232153 2012-02-25 10:58:02Z mm $");
 
 DEFINE_TEST(test_archive_api_feature)
 {
@@ -38,7 +38,7 @@
 	    archive_version_number() % 1000);
 	failure("Version string is: %s, computed is: %s",
 	    archive_version_string(), buff);
-	assert(memcmp(buff, archive_version_string(), strlen(buff)) == 0);
+	assertEqualMem(buff, archive_version_string(), strlen(buff));
 	if (strlen(buff) < strlen(archive_version_string())) {
 		p = archive_version_string() + strlen(buff);
 		failure("Version string is: %s", archive_version_string());
@@ -47,30 +47,4 @@
 		failure("Version string is: %s", archive_version_string());
 		assert(*p == '\0');
 	}
-
-/* This is all scheduled to disappear in libarchive 3.0 */
-#if ARCHIVE_VERSION_NUMBER < 3000000
-	assertEqualInt(ARCHIVE_VERSION_STAMP, ARCHIVE_VERSION_NUMBER);
-	assertEqualInt(ARCHIVE_API_FEATURE, archive_api_feature());
-	assertEqualInt(ARCHIVE_API_VERSION, archive_api_version());
-	/*
-	 * Even though ARCHIVE_VERSION_STAMP only appears in
-	 * archive.h after 1.9.0 and 2.2.3, the macro is synthesized
-	 * in test.h, so this test is always valid.
-	 */
-	assertEqualInt(ARCHIVE_VERSION_STAMP / 1000, ARCHIVE_API_VERSION * 1000 + ARCHIVE_API_FEATURE);
-	/*
-	 * The function, however, isn't always available.  It appeared
-	 * sometime in the middle of 2.2.3, but the synthesized value
-	 * never has a release version, so the following conditional
-	 * exactly determines whether the current library has the
-	 * function.
-	 */
-#if ARCHIVE_VERSION_STAMP / 1000 == 1009 || ARCHIVE_VERSION_STAMP > 2002000
-	assertEqualInt(ARCHIVE_VERSION_STAMP, archive_version_stamp());
-#else
-	skipping("archive_version_stamp()");
-#endif
-	assertEqualString(ARCHIVE_LIBRARY_VERSION, archive_version());
-#endif
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_bad_fd.c
--- a/head/contrib/libarchive/libarchive/test/test_bad_fd.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_bad_fd.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,19 +23,15 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_bad_fd.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_bad_fd.c 232153 2012-02-25 10:58:02Z mm $");
 
 /* Verify that attempting to open an invalid fd returns correct error. */
 DEFINE_TEST(test_bad_fd)
 {
 	struct archive *a;
 	assert((a = archive_read_new()) != NULL);
-	assertA(0 == archive_read_support_compression_all(a));
+	assertA(0 == archive_read_support_filter_all(a));
 	assertA(ARCHIVE_FATAL == archive_read_open_fd(a, -1, 1024));
-	assertA(0 == archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assertA(0 == archive_read_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_compat_bzip2.c
--- a/head/contrib/libarchive/libarchive/test/test_compat_bzip2.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_compat_bzip2.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_compat_bzip2.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_compat_bzip2.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * Verify our ability to read sample files compatibly with bunzip2.
@@ -47,7 +47,7 @@
 	int i;
 
 	assert((a = archive_read_new()) != NULL);
-	if (ARCHIVE_OK != archive_read_support_compression_bzip2(a)) {
+	if (ARCHIVE_OK != archive_read_support_filter_bzip2(a)) {
 		skipping("Unsupported bzip2");
 		return;
 	}
@@ -71,8 +71,12 @@
 	assertEqualString(archive_compression_name(a), "bzip2");
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
 
-	assertEqualInt(ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_BZIP2);
+	assertEqualString(archive_compression_name(a), "bzip2");
+	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
+
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_compat_cpio.c
--- a/head/contrib/libarchive/libarchive/test/test_compat_cpio.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_compat_cpio.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_compat_cpio.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_compat_cpio.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * Verify our ability to read various sample files.
@@ -48,7 +48,7 @@
 	struct archive *a;
 
 	assert((a = archive_read_new()) != NULL);
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
 	extract_reference_file(name);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 17));
@@ -94,7 +94,7 @@
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_SVR4_NOCRC);
 
 	assertEqualInt(ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_compat_gtar.c
--- a/head/contrib/libarchive/libarchive/test/test_compat_gtar.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_compat_gtar.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_compat_gtar.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_compat_gtar.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * Verify our ability to read sample files created by GNU tar.
@@ -46,7 +46,7 @@
 	int r;
 
 	assert((a = archive_read_new()) != NULL);
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
 	extract_reference_file(name);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 10240));
@@ -54,7 +54,7 @@
 	/* Read first entry. */
 	assertEqualIntA(a, ARCHIVE_OK, r = archive_read_next_header(a, &ae));
 	if (r != ARCHIVE_OK) {
-		archive_read_finish(a);
+		archive_read_free(a);
 		return;
 	}
 	assertEqualString(
@@ -73,7 +73,7 @@
 	/* Read second entry. */
 	assertEqualIntA(a, ARCHIVE_OK, r = archive_read_next_header(a, &ae));
 	if (r != ARCHIVE_OK) {
-		archive_read_finish(a);
+		archive_read_free(a);
 		return;
 	}
 	assertEqualString(
@@ -103,11 +103,7 @@
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_GNUTAR);
 
 	assertEqualInt(ARCHIVE_OK, archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
-#endif
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_compat_gzip.c
--- a/head/contrib/libarchive/libarchive/test/test_compat_gzip.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_compat_gzip.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_compat_gzip.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_compat_gzip.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * Verify our ability to read sample files compatibly with gunzip.
@@ -47,10 +47,10 @@
 	int i,r;
 
 	assert((a = archive_read_new()) != NULL);
-	r = archive_read_support_compression_gzip(a);
+	r = archive_read_support_filter_gzip(a);
 	if (r == ARCHIVE_WARN) {
 		skipping("gzip reading not fully supported on this platform");
-		assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+		assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 		return;
 	}
 	assertEqualIntA(a, ARCHIVE_OK, r);
@@ -64,7 +64,7 @@
 		assertEqualIntA(a, ARCHIVE_OK,
 		    archive_read_next_header(a, &ae));
 		if (r != ARCHIVE_OK) {
-			archive_read_finish(a);
+			archive_read_free(a);
 			return;
 		}
 		assertEqualString(n[i], archive_entry_pathname(ae));
@@ -79,7 +79,7 @@
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
 
 	assertEqualInt(ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_compat_lzma.c
--- a/head/contrib/libarchive/libarchive/test/test_compat_lzma.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_compat_lzma.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_compat_lzma.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_compat_lzma.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
 Execute the following to rebuild the data for this program:
@@ -107,11 +107,11 @@
 	int i, r;
 
 	assert((a = archive_read_new()) != NULL);
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
-	r = archive_read_support_compression_lzma(a);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	r = archive_read_support_filter_lzma(a);
 	if (r == ARCHIVE_WARN) {
 		skipping("lzma reading not fully supported on this platform");
-		assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+		assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 		return;
 	}
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
@@ -135,7 +135,7 @@
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
 
 	assertEqualInt(ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_compat_solaris_tar_acl.c
--- a/head/contrib/libarchive/libarchive/test/test_compat_solaris_tar_acl.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_compat_solaris_tar_acl.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_compat_solaris_tar_acl.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_compat_solaris_tar_acl.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * Exercise support for reading Solaris-style ACL data
@@ -45,7 +45,7 @@
 	extract_reference_file(reference1);
 	assert(NULL != (a = archive_read_new()));
 	assertA(0 == archive_read_support_format_all(a));
-	assertA(0 == archive_read_support_compression_all(a));
+	assertA(0 == archive_read_support_filter_all(a));
 	assertA(0 == archive_read_open_filename(a, reference1, 512));
 
 	/* Archive has 1 entry with some ACLs set on it. */
@@ -124,5 +124,5 @@
 
 	/* Close the archive. */
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_compat_tar_hardlink.c
--- a/head/contrib/libarchive/libarchive/test/test_compat_tar_hardlink.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_compat_tar_hardlink.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_compat_tar_hardlink.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_compat_tar_hardlink.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * Background:  There are two written standards for the tar file format.
@@ -51,7 +51,7 @@
 	struct archive *a;
 
 	assert((a = archive_read_new()) != NULL);
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
 	extract_reference_file(name);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 10240));
@@ -93,11 +93,7 @@
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR);
 
 	assertEqualInt(ARCHIVE_OK, archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
-#endif
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 DEFINE_TEST(test_compat_tar_hardlink)
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_compat_xz.c
--- a/head/contrib/libarchive/libarchive/test/test_compat_xz.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_compat_xz.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_compat_xz.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_compat_xz.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * Verify our ability to read sample files compatibly with unxz.
@@ -46,11 +46,11 @@
 	int i, r;
 
 	assert((a = archive_read_new()) != NULL);
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
-	r = archive_read_support_compression_xz(a);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	r = archive_read_support_filter_xz(a);
 	if (r == ARCHIVE_WARN) {
 		skipping("xz reading not fully supported on this platform");
-		assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+		assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 		return;
 	}
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
@@ -74,7 +74,7 @@
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
 
 	assertEqualInt(ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_compat_zip.c
--- a/head/contrib/libarchive/libarchive/test/test_compat_zip.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_compat_zip.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,13 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_compat_zip.c 228773 2011-12-21 15:18:52Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_compat_zip.c 232153 2012-02-25 10:58:02Z mm $");
+
+#ifdef HAVE_LIBZ
+static const int libz_enabled = 1;
+#else
+static const int libz_enabled = 0;
+#endif
 
 /* Copy this function for each test file and adjust it accordingly. */
 static void
@@ -35,7 +41,7 @@
 	int r;
 
 	assert((a = archive_read_new()) != NULL);
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a));
 	extract_reference_file(name);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 10240));
@@ -46,13 +52,10 @@
 
 	/* Read second entry. */
 	r = archive_read_next_header(a, &ae);
-	if (r != ARCHIVE_OK) {
-		if (strcmp(archive_error_string(a),
-		    "libarchive compiled without deflate support (no libz)") == 0) {
-			skipping("Skipping ZIP compression check: %s",
-			    archive_error_string(a));
-			goto finish;
-		}
+	if (r == ARCHIVE_FATAL && !libz_enabled) {
+		skipping("Skipping ZIP compression check: %s",
+			archive_error_string(a));
+		goto finish;
 	}
 	assertEqualIntA(a, ARCHIVE_OK, r);
 	assertEqualString("tmp.class", archive_entry_pathname(ae));
@@ -62,13 +65,9 @@
 	assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_NONE);
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ZIP);
 
+finish:
 	assertEqualInt(ARCHIVE_OK, archive_read_close(a));
-finish:
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
-#endif
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 /*
@@ -85,7 +84,7 @@
 	struct archive *a;
 
 	assert((a = archive_read_new()) != NULL);
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a));
 	extract_reference_file(name);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 10240));
@@ -103,11 +102,349 @@
 	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
+/*
+ * Issue 185:  Test a regression that got in between 2.6 and 2.7 that
+ * broke extraction of Zip entries with length-at-end.
+ */
+static void
+test_compat_zip_3(void)
+{
+	const char *refname = "test_compat_zip_3.zip";
+	struct archive_entry *ae;
+	struct archive *a;
+
+	extract_reference_file(refname);
+	assert((a = archive_read_new()) != NULL);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 10240));
+
+	/* First entry. */
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("soapui-4.0.0/", archive_entry_pathname(ae));
+	assertEqualInt(0, archive_entry_size(ae));
+	assert(archive_entry_size_is_set(ae));
+	assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+
+	/* Second entry. */
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("soapui-4.0.0/soapui-settings.xml", archive_entry_pathname(ae));
+	assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+	assertEqualInt(1030, archive_entry_size(ae));
+	assert(archive_entry_size_is_set(ae));
+
+	/* Extract under a different name. */
+	archive_entry_set_pathname(ae, "test_3.txt");
+	if(libz_enabled) {
+		char *p;
+		size_t s;
+		assertEqualIntA(a, ARCHIVE_OK, archive_read_extract(a, ae, 0));
+		/* Verify the first 12 bytes actually got written to disk correctly. */
+		p = slurpfile(&s, "test_3.txt");
+		assertEqualInt(s, 1030);
+		assertEqualMem(p, "<?xml versio", 12);
+		free(p);
+	} else {
+		skipping("Skipping ZIP compression check, no libz support");
+	}
+	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
+}
+
+/**
+ * A file with leading garbage (similar to an SFX file).
+ */
+static void
+test_compat_zip_4(void)
+{
+	const char *refname = "test_compat_zip_4.zip";
+	struct archive_entry *ae;
+	struct archive *a;
+	void *p;
+	size_t s;
+
+	extract_reference_file(refname);
+	p = slurpfile(&s, refname);
+
+	/* SFX files require seek support. */
+	assert((a = archive_read_new()) != NULL);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, read_open_memory_seek(a, p, s, 18));
+
+	/* First entry. */
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("foo", archive_entry_pathname(ae));
+	assertEqualInt(4, archive_entry_size(ae));
+	assert(archive_entry_size_is_set(ae));
+	assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+	assertEqualInt(0412, archive_entry_perm(ae));
+
+	/* Second entry. */
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("bar", archive_entry_pathname(ae));
+	assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+	assertEqualInt(4, archive_entry_size(ae));
+	assert(archive_entry_size_is_set(ae));
+	assertEqualInt(0567, archive_entry_perm(ae));
+
+	/* Third entry. */
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("baz", archive_entry_pathname(ae));
+	assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+	assertEqualInt(4, archive_entry_size(ae));
+	assert(archive_entry_size_is_set(ae));
+	assertEqualInt(0644, archive_entry_perm(ae));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
+
+	/* Try reading without seek support and watch it fail. */
+	assert((a = archive_read_new()) != NULL);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_FATAL, read_open_memory(a, p, s, 3));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
+	free(p);
+}
+/**
+ * Issue 152: A file generated by a tool that doesn't really
+ * believe in populating local file headers at all.  This
+ * is only readable with the seeking reader.
+ */
+static void
+test_compat_zip_5(void)
+{
+	const char *refname = "test_compat_zip_5.zip";
+	struct archive_entry *ae;
+	struct archive *a;
+	void *p;
+	size_t s;
+
+	extract_reference_file(refname);
+	p = slurpfile(&s, refname);
+
+	/* Verify with seek support.
+	 * Everything works correctly here. */
+	assert((a = archive_read_new()) != NULL);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, read_open_memory_seek(a, p, s, 18));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("Metadata/Job_PT.xml", archive_entry_pathname(ae));
+	assertEqualInt(3559, archive_entry_size(ae));
+	assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+	assertEqualInt(0777, archive_entry_perm(ae));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("Metadata/MXDC_Empty_PT.xml", archive_entry_pathname(ae));
+	assertEqualInt(456, archive_entry_size(ae));
+	assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+	assertEqualInt(0777, archive_entry_perm(ae));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("Documents/1/Metadata/Page1_Thumbnail.JPG", archive_entry_pathname(ae));
+	assertEqualInt(1495, archive_entry_size(ae));
+	assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+	assertEqualInt(0777, archive_entry_perm(ae));
+	/* TODO: Read some of the file data and verify it.
+	   The code to read uncompressed Zip entries with "file at end" semantics
+	   is tricky and should be verified more carefully. */
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("Documents/1/Pages/_rels/1.fpage.rels", archive_entry_pathname(ae));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("Documents/1/Pages/1.fpage", archive_entry_pathname(ae));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("Documents/1/Resources/Fonts/3DFDBC8B-4514-41F1-A808-DEA1C79BAC2B.odttf", archive_entry_pathname(ae));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("Documents/1/_rels/FixedDocument.fdoc.rels", archive_entry_pathname(ae));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("Documents/1/FixedDocument.fdoc", archive_entry_pathname(ae));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("_rels/FixedDocumentSequence.fdseq.rels", archive_entry_pathname(ae));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("FixedDocumentSequence.fdseq", archive_entry_pathname(ae));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("_rels/.rels", archive_entry_pathname(ae));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("[Content_Types].xml", archive_entry_pathname(ae));
+
+	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
+
+	/* Try reading without seek support. */
+	assert((a = archive_read_new()) != NULL);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, read_open_memory(a, p, s, 3));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("Metadata/Job_PT.xml", archive_entry_pathname(ae));
+	assertEqualInt(0, archive_entry_size(ae));
+	assert(!archive_entry_size_is_set(ae));
+	assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+	assertEqualInt(0777, archive_entry_perm(ae));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("Metadata/MXDC_Empty_PT.xml", archive_entry_pathname(ae));
+	assertEqualInt(0, archive_entry_size(ae));
+	assert(!archive_entry_size_is_set(ae));
+	assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+	assertEqualInt(0777, archive_entry_perm(ae));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("Documents/1/Metadata/Page1_Thumbnail.JPG", archive_entry_pathname(ae));
+	assertEqualInt(0, archive_entry_size(ae));
+	assert(!archive_entry_size_is_set(ae));
+	assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+	assertEqualInt(0777, archive_entry_perm(ae));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("Documents/1/Pages/_rels/1.fpage.rels", archive_entry_pathname(ae));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("Documents/1/Pages/1.fpage", archive_entry_pathname(ae));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("Documents/1/Resources/Fonts/3DFDBC8B-4514-41F1-A808-DEA1C79BAC2B.odttf", archive_entry_pathname(ae));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("Documents/1/_rels/FixedDocument.fdoc.rels", archive_entry_pathname(ae));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("Documents/1/FixedDocument.fdoc", archive_entry_pathname(ae));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("_rels/FixedDocumentSequence.fdseq.rels", archive_entry_pathname(ae));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("FixedDocumentSequence.fdseq", archive_entry_pathname(ae));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("_rels/.rels", archive_entry_pathname(ae));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("[Content_Types].xml", archive_entry_pathname(ae));
+
+	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
+	free(p);
+}
+
+/*
+ * Issue 225: Errors extracting MSDOS Zip archives with directories.
+ */
+static void
+compat_zip_6_verify(struct archive *a)
+{
+	struct archive_entry *ae;
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("New Folder/New Folder/", archive_entry_pathname(ae));
+	assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+	/* Zip timestamps are local time, so vary by time zone. */
+	/* TODO: A more complex assert would work here; we could
+	   verify that it's within +/- 24 hours of a particular value. */
+	/* assertEqualInt(1327314468, archive_entry_mtime(ae)); */
+	assertEqualInt(0, archive_entry_size(ae));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("New Folder/New Folder/New Text Document.txt", archive_entry_pathname(ae));
+	assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+	/* Zip timestamps are local time, so vary by time zone. */
+	/* assertEqualInt(1327314476, archive_entry_mtime(ae)); */
+	assertEqualInt(11, archive_entry_size(ae));
+	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+}
+
+static void
+test_compat_zip_6(void)
+{
+	const char *refname = "test_compat_zip_6.zip";
+	struct archive *a;
+	void *p;
+	size_t s;
+
+	extract_reference_file(refname);
+	p = slurpfile(&s, refname);
+
+	assert((a = archive_read_new()) != NULL);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, read_open_memory_seek(a, p, s, 7));
+	compat_zip_6_verify(a);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
+
+	assert((a = archive_read_new()) != NULL);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, read_open_memory(a, p, s, 7));
+	compat_zip_6_verify(a);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
+	free(p);
+}
+
+/*
+ * Issue 226: Try to reproduce hang when reading archives where the
+ * length-at-end marker ends exactly on a block boundary.
+ */
+static void
+test_compat_zip_7(void)
+{
+	const char *refname = "test_compat_zip_7.xps";
+	struct archive *a;
+	struct archive_entry *ae;
+	void *p;
+	size_t s;
+	int i;
+
+	extract_reference_file(refname);
+	p = slurpfile(&s, refname);
+
+	for (i = 1; i < 1000; ++i) {
+		assert((a = archive_read_new()) != NULL);
+		assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a));
+		assertEqualIntA(a, ARCHIVE_OK, read_open_memory2(a, p, s, i));
+
+		assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+		assertEqualIntA(a, ARCHIVE_OK, archive_read_data_skip(a));
+		assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+		assertEqualIntA(a, ARCHIVE_OK, archive_read_data_skip(a));
+		assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+		assertEqualIntA(a, ARCHIVE_OK, archive_read_data_skip(a));
+		assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+		assertEqualIntA(a, ARCHIVE_OK, archive_read_data_skip(a));
+
+		assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
+	}
+	free(p);
+}
 
 DEFINE_TEST(test_compat_zip)
 {
 	test_compat_zip_1();
 	test_compat_zip_2();
+	test_compat_zip_3();
+	test_compat_zip_4();
+	test_compat_zip_5();
+	test_compat_zip_6();
+	test_compat_zip_7();
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_compat_zip_2.zip.uu
--- a/head/contrib/libarchive/libarchive/test/test_compat_zip_2.zip.uu	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_compat_zip_2.zip.uu	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,3 @@
-$FreeBSD: head/contrib/libarchive/libarchive/test/test_compat_zip_2.zip.uu 228911 2011-12-27 10:36:56Z mm $
-
 begin 644 test_compat_zip_2.zip
 M4$L#!`H``````'V59CT````````````````%````9FEL93$M2E5.2RU02P,$
 M"@``````@95F/<>D!,D&````!@````4```!F:6QE,F9I;&4R"E!+`0(>`PH`
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_empty_write.c
--- a/head/contrib/libarchive/libarchive/test/test_empty_write.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_empty_write.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_empty_write.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_empty_write.c 232153 2012-02-25 10:58:02Z mm $");
 
 DEFINE_TEST(test_empty_write)
 {
@@ -60,8 +60,8 @@
 		assertEqualIntA(a, 0, archive_write_data(a, "", 0));
 
 		/* Close out the archive. */
-		assertA(0 == archive_write_close(a));
-		assertA(0 == archive_write_finish(a));
+		assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+		assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 	}
 
 	/*
@@ -90,8 +90,8 @@
 		assertEqualIntA(a, 0, archive_write_data(a, "", 0));
 
 		/* Close out the archive. */
-		assertA(0 == archive_write_close(a));
-		assertA(0 == archive_write_finish(a));
+		assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+		assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 	}
 
 	/*
@@ -115,6 +115,6 @@
 	assertEqualIntA(a, 0, archive_write_data(a, "", 0));
 
 	/* Close out the archive. */
-	assertA(0 == archive_write_close(a));
-	assertA(0 == archive_write_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_entry.c
--- a/head/contrib/libarchive/libarchive/test/test_entry.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_entry.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_entry.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_entry.c 232153 2012-02-25 10:58:02Z mm $");
 
 #include <locale.h>
 
@@ -63,6 +63,7 @@
 	size_t xsize; /* For xattr tests. */
 	wchar_t wc;
 	long l;
+	int i;
 
 	assert((e = archive_entry_new()) != NULL);
 
@@ -111,6 +112,12 @@
 	archive_entry_set_atime(e, 13579, 24680);
 	assertEqualInt(archive_entry_atime(e), 13579);
 	assertEqualInt(archive_entry_atime_nsec(e), 24680);
+	archive_entry_set_atime(e, 13580, 1000000001L);
+	assertEqualInt(archive_entry_atime(e), 13581);
+	assertEqualInt(archive_entry_atime_nsec(e), 1);
+	archive_entry_set_atime(e, 13580, -7);
+	assertEqualInt(archive_entry_atime(e), 13579);
+	assertEqualInt(archive_entry_atime_nsec(e), 999999993);
 	archive_entry_unset_atime(e);
 	assertEqualInt(archive_entry_atime(e), 0);
 	assertEqualInt(archive_entry_atime_nsec(e), 0);
@@ -120,6 +127,12 @@
 	archive_entry_set_birthtime(e, 17579, 24990);
 	assertEqualInt(archive_entry_birthtime(e), 17579);
 	assertEqualInt(archive_entry_birthtime_nsec(e), 24990);
+	archive_entry_set_birthtime(e, 17580, 1234567890L);
+	assertEqualInt(archive_entry_birthtime(e), 17581);
+	assertEqualInt(archive_entry_birthtime_nsec(e), 234567890);
+	archive_entry_set_birthtime(e, 17581, -24990);
+	assertEqualInt(archive_entry_birthtime(e), 17580);
+	assertEqualInt(archive_entry_birthtime_nsec(e), 999975010);
 	archive_entry_unset_birthtime(e);
 	assertEqualInt(archive_entry_birthtime(e), 0);
 	assertEqualInt(archive_entry_birthtime_nsec(e), 0);
@@ -129,27 +142,27 @@
 	archive_entry_set_ctime(e, 13580, 24681);
 	assertEqualInt(archive_entry_ctime(e), 13580);
 	assertEqualInt(archive_entry_ctime_nsec(e), 24681);
+	archive_entry_set_ctime(e, 13581, 2008182348L);
+	assertEqualInt(archive_entry_ctime(e), 13583);
+	assertEqualInt(archive_entry_ctime_nsec(e), 8182348);
+	archive_entry_set_ctime(e, 13582, -24681);
+	assertEqualInt(archive_entry_ctime(e), 13581);
+	assertEqualInt(archive_entry_ctime_nsec(e), 999975319);
 	archive_entry_unset_ctime(e);
 	assertEqualInt(archive_entry_ctime(e), 0);
 	assertEqualInt(archive_entry_ctime_nsec(e), 0);
 	assert(!archive_entry_ctime_is_set(e));
 
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	/* dev */
+	assert(!archive_entry_dev_is_set(e));
 	archive_entry_set_dev(e, 235);
+	assert(archive_entry_dev_is_set(e));
 	assertEqualInt(archive_entry_dev(e), 235);
-#else
-	skipping("archive_entry_dev()");
-#endif
 	/* devmajor/devminor are tested specially below. */
 
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	/* filetype */
 	archive_entry_set_filetype(e, AE_IFREG);
 	assertEqualInt(archive_entry_filetype(e), AE_IFREG);
-#else
-	skipping("archive_entry_filetype()");
-#endif
 
 	/* fflags are tested specially below */
 
@@ -185,13 +198,17 @@
 	archive_entry_copy_hardlink_w(e, NULL);
 	assertEqualString(archive_entry_hardlink(e), NULL);
 	assertEqualWString(archive_entry_hardlink_w(e), NULL);
-#if ARCHIVE_VERSION_NUMBER >= 1009000
+
 	/* ino */
+	assert(!archive_entry_ino_is_set(e));
 	archive_entry_set_ino(e, 8593);
+	assert(archive_entry_ino_is_set(e));
 	assertEqualInt(archive_entry_ino(e), 8593);
-#else
-	skipping("archive_entry_ino()");
-#endif
+	assertEqualInt(archive_entry_ino64(e), 8593);
+	archive_entry_set_ino64(e, 8594);
+	assert(archive_entry_ino_is_set(e));
+	assertEqualInt(archive_entry_ino(e), 8594);
+	assertEqualInt(archive_entry_ino64(e), 8594);
 
 	/* link */
 	archive_entry_set_hardlink(e, "hardlinkname");
@@ -231,18 +248,20 @@
 	archive_entry_set_mtime(e, 13581, 24682);
 	assertEqualInt(archive_entry_mtime(e), 13581);
 	assertEqualInt(archive_entry_mtime_nsec(e), 24682);
+	archive_entry_set_mtime(e, 13582, 1358297468);
+	assertEqualInt(archive_entry_mtime(e), 13583);
+	assertEqualInt(archive_entry_mtime_nsec(e), 358297468);
+	archive_entry_set_mtime(e, 13583, -24682);
+	assertEqualInt(archive_entry_mtime(e), 13582);
+	assertEqualInt(archive_entry_mtime_nsec(e), 999975318);
 	archive_entry_unset_mtime(e);
 	assertEqualInt(archive_entry_mtime(e), 0);
 	assertEqualInt(archive_entry_mtime_nsec(e), 0);
 	assert(!archive_entry_mtime_is_set(e));
 
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	/* nlink */
 	archive_entry_set_nlink(e, 736);
 	assertEqualInt(archive_entry_nlink(e), 736);
-#else
-	skipping("archive_entry_nlink()");
-#endif
 
 	/* pathname */
 	archive_entry_set_pathname(e, "path");
@@ -260,13 +279,9 @@
 	memset(wbuff, 0, sizeof(wbuff));
 	assertEqualWString(archive_entry_pathname_w(e), L"wpath");
 
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	/* rdev */
 	archive_entry_set_rdev(e, 532);
 	assertEqualInt(archive_entry_rdev(e), 532);
-#else
-	skipping("archive_entry_rdev()");
-#endif
 	/* rdevmajor/rdevminor are tested specially below. */
 
 	/* size */
@@ -283,13 +298,11 @@
 	/* symlink */
 	archive_entry_set_symlink(e, "symlinkname");
 	assertEqualString(archive_entry_symlink(e), "symlinkname");
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	strcpy(buff, "symlinkname2");
 	archive_entry_copy_symlink(e, buff);
 	assertEqualString(archive_entry_symlink(e), "symlinkname2");
 	memset(buff, 0, sizeof(buff));
 	assertEqualString(archive_entry_symlink(e), "symlinkname2");
-#endif
 	archive_entry_copy_symlink_w(e, NULL);
 	assertEqualWString(archive_entry_symlink_w(e), NULL);
 	assertEqualString(archive_entry_symlink(e), NULL);
@@ -380,25 +393,17 @@
 	archive_entry_set_atime(e, 13579, 24680);
 	archive_entry_set_birthtime(e, 13779, 24990);
 	archive_entry_set_ctime(e, 13580, 24681);
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	archive_entry_set_dev(e, 235);
-#endif
 	archive_entry_set_fflags(e, 0x55, 0xAA);
 	archive_entry_set_gid(e, 204);
 	archive_entry_set_gname(e, "group");
 	archive_entry_set_hardlink(e, "hardlinkname");
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	archive_entry_set_ino(e, 8593);
-#endif
 	archive_entry_set_mode(e, 0123456);
 	archive_entry_set_mtime(e, 13581, 24682);
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	archive_entry_set_nlink(e, 736);
-#endif
 	archive_entry_set_pathname(e, "path");
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	archive_entry_set_rdev(e, 532);
-#endif
 	archive_entry_set_size(e, 987654321);
 	archive_entry_copy_sourcepath(e, "source");
 	archive_entry_set_symlink(e, "symlinkname");
@@ -420,36 +425,26 @@
 	assertEqualInt(archive_entry_birthtime_nsec(e2), 24990);
 	assertEqualInt(archive_entry_ctime(e2), 13580);
 	assertEqualInt(archive_entry_ctime_nsec(e2), 24681);
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	assertEqualInt(archive_entry_dev(e2), 235);
-#endif
 	archive_entry_fflags(e, &set, &clear);
 	assertEqualInt(clear, 0xAA);
 	assertEqualInt(set, 0x55);
 	assertEqualInt(archive_entry_gid(e2), 204);
 	assertEqualString(archive_entry_gname(e2), "group");
 	assertEqualString(archive_entry_hardlink(e2), "hardlinkname");
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	assertEqualInt(archive_entry_ino(e2), 8593);
-#endif
 	assertEqualInt(archive_entry_mode(e2), 0123456);
 	assertEqualInt(archive_entry_mtime(e2), 13581);
 	assertEqualInt(archive_entry_mtime_nsec(e2), 24682);
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	assertEqualInt(archive_entry_nlink(e2), 736);
-#endif
 	assertEqualString(archive_entry_pathname(e2), "path");
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	assertEqualInt(archive_entry_rdev(e2), 532);
-#endif
 	assertEqualInt(archive_entry_size(e2), 987654321);
 	assertEqualString(archive_entry_sourcepath(e2), "source");
 	assertEqualString(archive_entry_symlink(e2), "symlinkname");
 	assertEqualInt(archive_entry_uid(e2), 83);
 	assertEqualString(archive_entry_uname(e2), "user");
-#if ARCHIVE_VERSION_NUMBER < 1009000
-	skipping("ACL preserved by archive_entry_clone()");
-#else
+
 	/* Verify ACL was copied. */
 	assertEqualInt(4, archive_entry_acl_reset(e2,
 			   ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
@@ -487,10 +482,7 @@
 	assertEqualInt(tag, ARCHIVE_ENTRY_ACL_USER);
 	assertEqualInt(qual, 77);
 	assertEqualString(name, "user77");
-#endif
-#if ARCHIVE_VERSION_NUMBER < 1009000
-	skipping("xattr data preserved by archive_entry_clone");
-#else
+
 	/* Verify xattr was copied. */
 	assertEqualInt(1, archive_entry_xattr_reset(e2));
 	assertEqualInt(0, archive_entry_xattr_next(e2, &xname, &xval, &xsize));
@@ -502,34 +494,23 @@
 	assertEqualString(xname, NULL);
 	assertEqualString(xval, NULL);
 	assertEqualInt((int)xsize, 0);
-#endif
 
 	/* Change the original */
 	archive_entry_set_atime(e, 13580, 24690);
 	archive_entry_set_birthtime(e, 13980, 24999);
 	archive_entry_set_ctime(e, 13590, 24691);
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	archive_entry_set_dev(e, 245);
-#endif
 	archive_entry_set_fflags(e, 0x85, 0xDA);
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	archive_entry_set_filetype(e, AE_IFLNK);
-#endif
 	archive_entry_set_gid(e, 214);
 	archive_entry_set_gname(e, "grouper");
 	archive_entry_set_hardlink(e, "hardlinkpath");
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	archive_entry_set_ino(e, 8763);
-#endif
 	archive_entry_set_mode(e, 0123654);
 	archive_entry_set_mtime(e, 18351, 28642);
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	archive_entry_set_nlink(e, 73);
-#endif
 	archive_entry_set_pathname(e, "pathest");
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	archive_entry_set_rdev(e, 132);
-#endif
 	archive_entry_set_size(e, 987456321);
 	archive_entry_copy_sourcepath(e, "source2");
 	archive_entry_set_symlink(e, "symlinkpath");
@@ -545,36 +526,26 @@
 	assertEqualInt(archive_entry_birthtime_nsec(e2), 24990);
 	assertEqualInt(archive_entry_ctime(e2), 13580);
 	assertEqualInt(archive_entry_ctime_nsec(e2), 24681);
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	assertEqualInt(archive_entry_dev(e2), 235);
-#endif
 	archive_entry_fflags(e2, &set, &clear);
 	assertEqualInt(clear, 0xAA);
 	assertEqualInt(set, 0x55);
 	assertEqualInt(archive_entry_gid(e2), 204);
 	assertEqualString(archive_entry_gname(e2), "group");
 	assertEqualString(archive_entry_hardlink(e2), "hardlinkname");
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	assertEqualInt(archive_entry_ino(e2), 8593);
-#endif
 	assertEqualInt(archive_entry_mode(e2), 0123456);
 	assertEqualInt(archive_entry_mtime(e2), 13581);
 	assertEqualInt(archive_entry_mtime_nsec(e2), 24682);
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	assertEqualInt(archive_entry_nlink(e2), 736);
-#endif
 	assertEqualString(archive_entry_pathname(e2), "path");
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	assertEqualInt(archive_entry_rdev(e2), 532);
-#endif
 	assertEqualInt(archive_entry_size(e2), 987654321);
 	assertEqualString(archive_entry_sourcepath(e2), "source");
 	assertEqualString(archive_entry_symlink(e2), "symlinkname");
 	assertEqualInt(archive_entry_uid(e2), 83);
 	assertEqualString(archive_entry_uname(e2), "user");
-#if ARCHIVE_VERSION_NUMBER < 1009000
-	skipping("ACL held by clone of archive_entry");
-#else
+
 	/* Verify ACL was unchanged. */
 	assertEqualInt(4, archive_entry_acl_reset(e2,
 			   ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
@@ -620,13 +591,9 @@
 	assertEqualInt(tag, 0);
 	assertEqualInt(qual, -1);
 	assertEqualString(name, NULL);
-#endif
-#if ARCHIVE_VERSION_NUMBER < 1009000
-	skipping("xattr preserved in archive_entry copy");
-#else
+
 	/* Verify xattr was unchanged. */
 	assertEqualInt(1, archive_entry_xattr_reset(e2));
-#endif
 
 	/* Release clone. */
 	archive_entry_free(e2);
@@ -645,9 +612,7 @@
 	archive_entry_fflags(e, &set, &clear);
 	assertEqualInt(clear, 0);
 	assertEqualInt(set, 0);
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	assertEqualInt(archive_entry_filetype(e), 0);
-#endif
 	assertEqualInt(archive_entry_gid(e), 0);
 	assertEqualString(archive_entry_gname(e), NULL);
 	assertEqualString(archive_entry_hardlink(e), NULL);
@@ -655,9 +620,7 @@
 	assertEqualInt(archive_entry_mode(e), 0);
 	assertEqualInt(archive_entry_mtime(e), 0);
 	assertEqualInt(archive_entry_mtime_nsec(e), 0);
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	assertEqualInt(archive_entry_nlink(e), 0);
-#endif
 	assertEqualString(archive_entry_pathname(e), NULL);
 	assertEqualInt(archive_entry_rdev(e), 0);
 	assertEqualInt(archive_entry_size(e), 0);
@@ -702,9 +665,7 @@
 	assertEqualInt(archive_entry_ino(e), 234);
 	assertEqualInt(archive_entry_mode(e), 077777);
 	assertEqualInt(archive_entry_mtime(e), 234567);
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	assertEqualInt(archive_entry_nlink(e), 345);
-#endif
 	assertEqualInt(archive_entry_size(e), 123456789);
 	assertEqualInt(archive_entry_uid(e), 23);
 #if __FreeBSD__
@@ -724,19 +685,13 @@
 	/* Set a bunch of fields individually. */
 	archive_entry_set_atime(e, 456789, 321);
 	archive_entry_set_ctime(e, 345678, 432);
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	archive_entry_set_dev(e, 123);
-#endif
 	archive_entry_set_gid(e, 34);
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	archive_entry_set_ino(e, 234);
-#endif
 	archive_entry_set_mode(e, 012345);
 	archive_entry_set_mode(e, 012345);
 	archive_entry_set_mtime(e, 234567, 543);
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	archive_entry_set_nlink(e, 345);
-#endif
 	archive_entry_set_size(e, 123456789);
 	archive_entry_set_uid(e, 23);
 	/* Retrieve a stat structure. */
@@ -744,18 +699,12 @@
 	/* Check that the values match. */
 	assertEqualInt(pst->st_atime, 456789);
 	assertEqualInt(pst->st_ctime, 345678);
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	assertEqualInt(pst->st_dev, 123);
-#endif
 	assertEqualInt(pst->st_gid, 34);
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	assertEqualInt(pst->st_ino, 234);
-#endif
 	assertEqualInt(pst->st_mode, 012345);
 	assertEqualInt(pst->st_mtime, 234567);
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	assertEqualInt(pst->st_nlink, 345);
-#endif
 	assertEqualInt(pst->st_size, 123456789);
 	assertEqualInt(pst->st_uid, 23);
 #ifdef __FreeBSD__
@@ -772,30 +721,24 @@
 	archive_entry_set_ctime(e, 345677, 431);
 	assert((pst = archive_entry_stat(e)) != NULL);
 	assertEqualInt(pst->st_ctime, 345677);
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	archive_entry_set_dev(e, 122);
 	assert((pst = archive_entry_stat(e)) != NULL);
 	assertEqualInt(pst->st_dev, 122);
-#endif
 	archive_entry_set_gid(e, 33);
 	assert((pst = archive_entry_stat(e)) != NULL);
 	assertEqualInt(pst->st_gid, 33);
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	archive_entry_set_ino(e, 233);
 	assert((pst = archive_entry_stat(e)) != NULL);
 	assertEqualInt(pst->st_ino, 233);
-#endif
 	archive_entry_set_mode(e, 012344);
 	assert((pst = archive_entry_stat(e)) != NULL);
 	assertEqualInt(pst->st_mode, 012344);
 	archive_entry_set_mtime(e, 234566, 542);
 	assert((pst = archive_entry_stat(e)) != NULL);
 	assertEqualInt(pst->st_mtime, 234566);
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	archive_entry_set_nlink(e, 344);
 	assert((pst = archive_entry_stat(e)) != NULL);
 	assertEqualInt(pst->st_nlink, 344);
-#endif
 	archive_entry_set_size(e, 123456788);
 	assert((pst = archive_entry_stat(e)) != NULL);
 	assertEqualInt(pst->st_size, 123456788);
@@ -819,7 +762,6 @@
 	 * the necessary definitions on every platform.
 	 */
 #if __FreeBSD__
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 	archive_entry_set_dev(e, 0x12345678);
 	assertEqualInt(archive_entry_devmajor(e), major(0x12345678));
 	assertEqualInt(archive_entry_devminor(e), minor(0x12345678));
@@ -839,12 +781,11 @@
 	assertEqualInt(archive_entry_rdevminor(e), 0xdcba98);
 	assertEqualInt(archive_entry_rdev(e), makedev(0xfe, 0xdcba98));
 #endif
-#endif
 
 	/*
 	 * Exercise the character-conversion logic, if we can.
 	 */
-	if (NULL == LOCALE_UTF8 || NULL == setlocale(LC_ALL, LOCALE_UTF8)) {
+	if (NULL == setlocale(LC_ALL, "en_US.UTF-8")) {
 		skipping("Can't exercise charset-conversion logic without"
 			" a suitable locale.");
 	} else {
@@ -852,8 +793,10 @@
 		archive_entry_copy_pathname(e, "abc\314\214mno\374xyz");
 		failure("Converting invalid chars to Unicode should fail.");
 		assert(NULL == archive_entry_pathname_w(e));
-		//failure("Converting invalid chars to UTF-8 should fail.");
-		//assert(NULL == archive_entry_pathname_utf8(e));
+		/*
+		  failure("Converting invalid chars to UTF-8 should fail.");
+		  assert(NULL == archive_entry_pathname_utf8(e));
+		*/
 
 		/* A group name that cannot be converted. */
 		archive_entry_copy_gname(e, "abc\314\214mno\374xyz");
@@ -876,7 +819,6 @@
 		assert(NULL == archive_entry_symlink_w(e));
 	}
 
-#if HAVE_WCSCPY
 	l = 0x12345678L;
 	wc = (wchar_t)l; /* Wide character too big for UTF-8. */
 	if (NULL == setlocale(LC_ALL, "C") || (long)wc != l) {
@@ -884,19 +826,18 @@
 	} else {
 		/*
 		 * Build the string L"xxx\U12345678yyy\u5678zzz" without
-		 * using C99 \u#### syntax, which isn't uniformly
-		 * supported.  (GCC 3.4.6, for instance, defaults to
-		 * "c89 plus GNU extensions.")
+		 * using wcscpy or C99 \u#### syntax.
 		 */
-		wcscpy(wbuff, L"xxxAyyyBzzz");
+		name = "xxxAyyyBzzz";
+		for (i = 0; i < (int)strlen(name); ++i)
+			wbuff[i] = name[i];
 		wbuff[3] = (wchar_t)0x12345678;
 		wbuff[7] = (wchar_t)0x5678;
-		/* A wide filename that cannot be converted to narrow. */
+		/* A Unicode filename that cannot be converted to UTF-8. */
 		archive_entry_copy_pathname_w(e, wbuff);
 		failure("Converting wide characters from Unicode should fail.");
 		assertEqualString(NULL, archive_entry_pathname(e));
 	}
-#endif
 
 	/* Release the experimental entry. */
 	archive_entry_free(e);
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_extattr_freebsd.c
--- a/head/contrib/libarchive/libarchive/test/test_extattr_freebsd.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_extattr_freebsd.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_extattr_freebsd.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_extattr_freebsd.c 232153 2012-02-25 10:58:02Z mm $");
 
 #if defined(__FreeBSD__) && __FreeBSD__ > 4
 #include <sys/extattr.h>
@@ -104,6 +104,7 @@
 	archive_entry_set_mode(ae, 0755);
 	archive_entry_xattr_add_entry(ae, "user.foo", "12345", 5);
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_finish_entry(a));
 	archive_entry_free(ae);
 
 	/* Another entry; similar but with mode = 0. */
@@ -123,7 +124,7 @@
 		assertEqualIntA(a, ARCHIVE_WARN, archive_write_close(a));
 	else
 		assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/* Verify the data on disk. */
 	assertEqualInt(0, stat("test0", &st));
@@ -166,7 +167,7 @@
 	assertEqualInt(xsize, 5);
 	assertEqualMem(xval, "12345", xsize);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 	archive_entry_free(ae);
 #endif
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_fuzz.c
--- a/head/contrib/libarchive/libarchive/test/test_fuzz.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_fuzz.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_fuzz.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_fuzz.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * This was inspired by an ISO fuzz tester written by Michal Zalewski
@@ -52,6 +52,8 @@
 } files[] = {
 	{0, "test_fuzz_1.iso.Z"}, /* Exercise compress decompressor. */
 	{1, "test_fuzz_1.iso.Z"},
+	{0, "test_fuzz.cab"},
+	{0, "test_fuzz.lzh"},
 	{0, "test_compat_bzip2_1.tbz"}, /* Exercise bzip2 decompressor. */
 	{1, "test_compat_bzip2_1.tbz"},
 	{0, "test_compat_gtar_1.tar"},
@@ -60,9 +62,36 @@
 	{0, "test_compat_tar_hardlink_1.tar"},
 	{0, "test_compat_xz_1.txz"}, /* Exercise xz decompressor. */
 	{0, "test_compat_zip_1.zip"},
+	{0, "test_read_format_7zip_bzip2.7z"},
+	{0, "test_read_format_7zip_bcj_lzma1.7z"},
+	{0, "test_read_format_7zip_bcj_lzma2.7z"},
+	{0, "test_read_format_7zip_bcj2_lzma1_1.7z"},
+	{0, "test_read_format_7zip_bcj2_lzma1_2.7z"},
+	{0, "test_read_format_7zip_bcj2_lzma2_1.7z"},
+	{0, "test_read_format_7zip_bcj2_lzma2_2.7z"},
+	{0, "test_read_format_7zip_copy.7z"},
+	{0, "test_read_format_7zip_deflate.7z"},
+	{0, "test_read_format_7zip_lzma1.7z"},
+	{0, "test_read_format_7zip_lzma1_lzma2.7z"},
+	{0, "test_read_format_7zip_ppmd.7z"},
 	{0, "test_read_format_ar.ar"},
 	{0, "test_read_format_cpio_bin_be.cpio"},
 	{0, "test_read_format_cpio_svr4_gzip_rpm.rpm"}, /* Test RPM unwrapper */
+	{0, "test_read_format_rar.rar"}, /* Uncompressed RAR test */
+	{0, "test_read_format_rar_binary_data.rar"}, /* RAR file with binary data */
+	{0, "test_read_format_rar_compress_best.rar"}, /* Best Compressed RAR test */
+	{0, "test_read_format_rar_compress_normal.rar"}, /* Normal Compressed RAR
+	                                                  * test */
+	{0, "test_read_format_rar_multi_lzss_blocks.rar"}, /* Normal Compressed Multi
+	                                                    * LZSS blocks RAR test */
+	{0, "test_read_format_rar_noeof.rar"}, /* RAR with no EOF header */
+	{0, "test_read_format_rar_ppmd_lzss_conversion.rar"}, /* Best Compressed
+	                                                       * RAR file with both
+	                                                       * PPMd and LZSS
+	                                                       * blocks */
+	{0, "test_read_format_rar_sfx.exe"}, /* RAR SFX archive */
+	{0, "test_read_format_rar_subblock.rar"}, /* RAR with subblocks */
+	{0, "test_read_format_rar_unicode.rar"}, /* RAR with Unicode filenames */
 	{0, "test_read_format_gtar_sparse_1_17_posix10_modified.tar"},
 	{0, "test_read_format_mtree.mtree"},
 	{0, "test_read_format_tar_empty_filename.tar"},
@@ -74,7 +103,7 @@
 {
 	const void *blk;
 	size_t blk_size;
-	off_t blk_offset;
+	int64_t blk_offset;
 	int n;
 
 	for (n = 0; files[n].name != NULL; ++n) {
@@ -84,7 +113,7 @@
 		struct archive *a;
 		char *rawimage, *image;
 		size_t size;
-		int i;
+		int i, q;
 
 		extract_reference_file(filename);
 		if (files[n].uncompress) {
@@ -92,12 +121,12 @@
 			/* Use format_raw to decompress the data. */
 			assert((a = archive_read_new()) != NULL);
 			assertEqualIntA(a, ARCHIVE_OK,
-			    archive_read_support_compression_all(a));
+			    archive_read_support_filter_all(a));
 			assertEqualIntA(a, ARCHIVE_OK,
 			    archive_read_support_format_raw(a));
 			r = archive_read_open_filename(a, filename, 16384);
 			if (r != ARCHIVE_OK) {
-				archive_read_finish(a);
+				archive_read_free(a);
 				skipping("Cannot uncompress %s", filename);
 				continue;
 			}
@@ -108,7 +137,7 @@
 			assertEqualIntA(a, ARCHIVE_EOF,
 			    archive_read_next_header(a, &ae));
 			assertEqualInt(ARCHIVE_OK,
-			    archive_read_finish(a));
+			    archive_read_free(a));
 			assert(size > 0);
 			failure("Internal buffer is not big enough for "
 			    "uncompressed test file: %s", filename);
@@ -127,24 +156,38 @@
 
 		for (i = 0; i < 100; ++i) {
 			FILE *f;
-			int j, numbytes;
+			int j, numbytes, trycnt;
 
 			/* Fuzz < 1% of the bytes in the archive. */
 			memcpy(image, rawimage, size);
-			numbytes = (int)(rand() % (size / 100));
+			q = size / 100;
+			if (!q) q = 1;
+			numbytes = (int)(rand() % q);
 			for (j = 0; j < numbytes; ++j)
 				image[rand() % size] = (char)rand();
 
 			/* Save the messed-up image to a file.
 			 * If we crash, that file will be useful. */
-			f = fopen("after.test.failure.send.this.file."
-			    "to.libarchive.maintainers.with.system.details", "wb");
-			fwrite(image, 1, (size_t)size, f);
+			for (trycnt = 0; trycnt < 3; trycnt++) {
+				f = fopen("after.test.failure.send.this.file."
+				    "to.libarchive.maintainers.with.system.details", "wb");
+				if (f != NULL)
+					break;
+#if defined(_WIN32) && !defined(__CYGWIN__)
+				/*
+				 * Sometimes previous close operation does not completely
+				 * end at this time. So we should take a wait while
+				 * the operation running.
+				 */
+				Sleep(100);
+#endif
+			}
+			assertEqualInt((size_t)size, fwrite(image, 1, (size_t)size, f));
 			fclose(f);
 
 			assert((a = archive_read_new()) != NULL);
 			assertEqualIntA(a, ARCHIVE_OK,
-			    archive_read_support_compression_all(a));
+			    archive_read_support_filter_all(a));
 			assertEqualIntA(a, ARCHIVE_OK,
 			    archive_read_support_format_all(a));
 
@@ -156,7 +199,7 @@
 				}
 				archive_read_close(a);
 			}
-			archive_read_finish(a);
+			archive_read_free(a);
 		}
 		free(image);
 		free(rawimage);
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_open_failure.c
--- a/head/contrib/libarchive/libarchive/test/test_open_failure.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_open_failure.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_open_failure.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_open_failure.c 232153 2012-02-25 10:58:02Z mm $");
 
 #define MAGIC 123456789
 struct my_data {
@@ -42,6 +42,8 @@
 my_read(struct archive *a, void *_private, const void **buff)
 {
 	struct my_data *private = (struct my_data *)_private;
+	(void)a; /* UNUSED */
+	(void)buff; /* UNUSED */
 	assertEqualInt(MAGIC, private->magic);
 	++private->read_called;
 	return (private->read_return);
@@ -51,6 +53,9 @@
 my_write(struct archive *a, void *_private, const void *buff, size_t s)
 {
 	struct my_data *private = (struct my_data *)_private;
+	(void)a; /* UNUSED */
+	(void)buff; /* UNUSED */
+	(void)s; /* UNUSED */
 	assertEqualInt(MAGIC, private->magic);
 	++private->write_called;
 	return (private->write_return);
@@ -60,6 +65,7 @@
 my_open(struct archive *a, void *_private)
 {
 	struct my_data *private = (struct my_data *)_private;
+	(void)a; /* UNUSED */
 	assertEqualInt(MAGIC, private->magic);
 	++private->open_called;
 	return (private->open_return);
@@ -69,6 +75,7 @@
 my_close(struct archive *a, void *_private)
 {
 	struct my_data *private = (struct my_data *)_private;
+	(void)a; /* UNUSED */
 	assertEqualInt(MAGIC, private->magic);
 	++private->close_called;
 	return (private->close_return);
@@ -132,7 +139,7 @@
 	a = archive_read_new();
 	assert(a != NULL);
 	assertEqualInt(ARCHIVE_OK,
-	    archive_read_support_compression_compress(a));
+	    archive_read_support_filter_compress(a));
 	assertEqualInt(ARCHIVE_OK, archive_read_support_format_tar(a));
 	assertEqualInt(ARCHIVE_FATAL,
 	    archive_read_open(a, &private, my_open, my_read, my_close));
@@ -153,8 +160,7 @@
 	    archive_write_open(a, &private, my_open, my_write, my_close));
 	assertEqualInt(1, private.open_called);
 	assertEqualInt(0, private.write_called);
-	// Broken in 2.8, fixed in 3.0
-	//assertEqualInt(1, private.close_called);
+	assertEqualInt(1, private.close_called);
 	assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
 	assertEqualInt(1, private.open_called);
 	assertEqualInt(0, private.write_called);
@@ -165,14 +171,13 @@
 	private.open_return = ARCHIVE_FATAL;
 	a = archive_write_new();
 	assert(a != NULL);
-	archive_write_set_compression_compress(a);
-	archive_write_set_format_zip(a);
+	archive_write_add_filter_compress(a);
+	archive_write_set_format_ustar(a);
 	assertEqualInt(ARCHIVE_FATAL,
 	    archive_write_open(a, &private, my_open, my_write, my_close));
 	assertEqualInt(1, private.open_called);
 	assertEqualInt(0, private.write_called);
-	// Broken in 2.8, fixed in 3.0
-	//assertEqualInt(1, private.close_called);
+	assertEqualInt(1, private.close_called);
 	assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
 	assertEqualInt(1, private.open_called);
 	assertEqualInt(0, private.write_called);
@@ -183,13 +188,28 @@
 	private.open_return = ARCHIVE_FATAL;
 	a = archive_write_new();
 	assert(a != NULL);
-	archive_write_set_compression_gzip(a);
+	archive_write_set_format_zip(a);
 	assertEqualInt(ARCHIVE_FATAL,
 	    archive_write_open(a, &private, my_open, my_write, my_close));
 	assertEqualInt(1, private.open_called);
 	assertEqualInt(0, private.write_called);
-	// Broken in 2.8, fixed in 3.0
-	//assertEqualInt(1, private.close_called);
+	assertEqualInt(1, private.close_called);
+	assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+	assertEqualInt(1, private.open_called);
+	assertEqualInt(0, private.write_called);
+	assertEqualInt(1, private.close_called);
+
+	memset(&private, 0, sizeof(private));
+	private.magic = MAGIC;
+	private.open_return = ARCHIVE_FATAL;
+	a = archive_write_new();
+	assert(a != NULL);
+	archive_write_add_filter_gzip(a);
+	assertEqualInt(ARCHIVE_FATAL,
+	    archive_write_open(a, &private, my_open, my_write, my_close));
+	assertEqualInt(1, private.open_called);
+	assertEqualInt(0, private.write_called);
+	assertEqualInt(1, private.close_called);
 	assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
 	assertEqualInt(1, private.open_called);
 	assertEqualInt(0, private.write_called);
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_open_fd.c
--- a/head/contrib/libarchive/libarchive/test/test_open_fd.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_open_fd.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_open_fd.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_open_fd.c 232153 2012-02-25 10:58:02Z mm $");
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
 #define open _open
@@ -79,7 +79,7 @@
 
 	/* Close out the archive. */
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/*
 	 * Now, read the data back.
@@ -87,7 +87,7 @@
 	assert(lseek(fd, 0, SEEK_SET) == 0);
 	assert((a = archive_read_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_fd(a, fd, 512));
 
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
@@ -110,7 +110,7 @@
 	/* Verify the end of the archive. */
 	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 	close(fd);
 
 
@@ -119,10 +119,10 @@
 	 */
 	assert((a = archive_read_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
 	/* FD 100 shouldn't be open. */
 	assertEqualIntA(a, ARCHIVE_FATAL,
 	    archive_read_open_fd(a, 100, 512));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_open_file.c
--- a/head/contrib/libarchive/libarchive/test/test_open_file.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_open_file.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_open_file.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_open_file.c 232153 2012-02-25 10:58:02Z mm $");
 
 DEFINE_TEST(test_open_file)
 {
@@ -67,7 +67,7 @@
 
 	/* Close out the archive. */
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 	fclose(f);
 
 	/*
@@ -79,7 +79,7 @@
 		return;
 	assert((a = archive_read_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_FILE(a, f));
 
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
@@ -102,7 +102,7 @@
 	/* Verify the end of the archive. */
 	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	fclose(f);
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_open_filename.c
--- a/head/contrib/libarchive/libarchive/test/test_open_filename.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_open_filename.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,9 +23,10 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_open_filename.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_open_filename.c 232153 2012-02-25 10:58:02Z mm $");
 
-DEFINE_TEST(test_open_filename)
+static void
+test_open_filename_mbs(void)
 {
 	char buff[64];
 	struct archive_entry *ae;
@@ -62,14 +63,14 @@
 
 	/* Close out the archive. */
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/*
 	 * Now, read the data back.
 	 */
 	assert((a = archive_read_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_read_open_filename(a, "test.tar", 512));
 
@@ -93,17 +94,107 @@
 	/* Verify the end of the archive. */
 	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	/*
 	 * Verify some of the error handling.
 	 */
 	assert((a = archive_read_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
 	assertEqualIntA(a, ARCHIVE_FATAL,
 	    archive_read_open_filename(a, "nonexistent.tar", 512));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 }
+
+static void
+test_open_filename_wcs(void)
+{
+	char buff[64];
+	struct archive_entry *ae;
+	struct archive *a;
+
+	/* Write an archive through this FILE *. */
+	assert((a = archive_write_new()) != NULL);
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_none(a));
+	assertEqualIntA(a, ARCHIVE_OK,
+	    archive_write_open_filename_w(a, L"test.tar"));
+
+	/*
+	 * Write a file to it.
+	 */
+	assert((ae = archive_entry_new()) != NULL);
+	archive_entry_set_mtime(ae, 1, 0);
+	archive_entry_copy_pathname_w(ae, L"file");
+	archive_entry_set_mode(ae, S_IFREG | 0755);
+	archive_entry_set_size(ae, 8);
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
+	archive_entry_free(ae);
+	assertEqualIntA(a, 8, archive_write_data(a, "12345678", 9));
+
+	/*
+	 * Write a second file to it.
+	 */
+	assert((ae = archive_entry_new()) != NULL);
+	archive_entry_copy_pathname_w(ae, L"file2");
+	archive_entry_set_mode(ae, S_IFREG | 0755);
+	archive_entry_set_size(ae, 819200);
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
+	archive_entry_free(ae);
+
+	/* Close out the archive. */
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
+
+	/*
+	 * Now, read the data back.
+	 */
+	assert((a = archive_read_new()) != NULL);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK,
+	    archive_read_open_filename_w(a, L"test.tar", 512));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualInt(1, archive_entry_mtime(ae));
+	assertEqualInt(0, archive_entry_mtime_nsec(ae));
+	assertEqualInt(0, archive_entry_atime(ae));
+	assertEqualInt(0, archive_entry_ctime(ae));
+	assertEqualWString(L"file", archive_entry_pathname_w(ae));
+	assert((S_IFREG | 0755) == archive_entry_mode(ae));
+	assertEqualInt(8, archive_entry_size(ae));
+	assertEqualIntA(a, 8, archive_read_data(a, buff, 10));
+	assertEqualMem(buff, "12345678", 8);
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualWString(L"file2", archive_entry_pathname_w(ae));
+	assert((S_IFREG | 0755) == archive_entry_mode(ae));
+	assertEqualInt(819200, archive_entry_size(ae));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_data_skip(a));
+
+	/* Verify the end of the archive. */
+	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+
+	/*
+	 * Verify some of the error handling.
+	 */
+	assert((a = archive_read_new()) != NULL);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_FATAL,
+	    archive_read_open_filename_w(a, L"nonexistent.tar", 512));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+
+}
+
+DEFINE_TEST(test_open_filename)
+{
+	test_open_filename_mbs();
+	test_open_filename_wcs();
+}
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_pax_filename_encoding.c
--- a/head/contrib/libarchive/libarchive/test/test_pax_filename_encoding.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_pax_filename_encoding.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_pax_filename_encoding.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_pax_filename_encoding.c 232153 2012-02-25 10:58:02Z mm $");
 
 #include <locale.h>
 
@@ -58,7 +58,7 @@
 	extract_reference_file(testname);
 	a = archive_read_new();
 	assertEqualInt(ARCHIVE_OK, archive_read_support_format_tar(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_support_compression_all(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_support_filter_all(a));
 	assertEqualInt(ARCHIVE_OK,
 	    archive_read_open_filename(a, testname, 10240));
 	/*
@@ -77,7 +77,7 @@
 	    " characters in it without generating a warning");
 	assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &entry));
 	assertEqualString(filename, archive_entry_pathname(entry));
-	archive_read_finish(a);
+	archive_read_free(a);
 }
 
 /*
@@ -104,13 +104,12 @@
 
 	/*
 	 * We need a starting locale which has invalid sequences.
-	 * de_DE.UTF-8 seems to be commonly supported.
+	 * en_US.UTF-8 seems to be commonly supported.
 	 */
 	/* If it doesn't exist, just warn and return. */
-	if (LOCALE_UTF8 == NULL
-	    || NULL == setlocale(LC_ALL, LOCALE_UTF8)) {
+	if (NULL == setlocale(LC_ALL, "en_US.UTF-8")) {
 		skipping("invalid encoding tests require a suitable locale;"
-		    " %s not available on this system", LOCALE_UTF8);
+		    " en_US.UTF-8 not available on this system");
 		return;
 	}
 
@@ -151,8 +150,8 @@
 	assertEqualInt(ARCHIVE_WARN, archive_write_header(a, entry));
 	archive_entry_free(entry);
 
-	assertEqualInt(0, archive_write_close(a));
-	assertEqualInt(0, archive_write_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/*
 	 * Now read the entries back.
@@ -177,10 +176,12 @@
 	assertEqualInt(0, archive_read_next_header(a, &entry));
 	assertEqualString(longname, archive_entry_pathname(entry));
 
-	assertEqualInt(0, archive_read_close(a));
-	assertEqualInt(0, archive_read_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
+#if 0 /* Disable this until Tim check out it. */
+
 /*
  * Create an entry starting from a wide-character Unicode pathname,
  * read it back into "C" locale, which doesn't support the name.
@@ -277,8 +278,8 @@
 	assertEqualInt(ARCHIVE_OK, archive_write_header(a, entry));
 	archive_entry_free(entry);
 
-	assertEqualInt(0, archive_write_close(a));
-	assertEqualInt(0, archive_write_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/*
 	 * Now read the entries back.
@@ -321,13 +322,280 @@
 
 	assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &entry));
 
-	assertEqualInt(0, archive_read_close(a));
-	assertEqualInt(0, archive_read_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
+#else
+static void
+test_pax_filename_encoding_3(void)
+{
+}
+#endif
+
+/*
+ * Verify that KOI8-R filenames are correctly translated to Unicode and UTF-8.
+ */
+static void
+test_pax_filename_encoding_KOI8R(void)
+{
+  	struct archive *a;
+  	struct archive_entry *entry;
+	char buff[4096];
+	size_t used;
+
+	if (NULL == setlocale(LC_ALL, "ru_RU.KOI8-R")) {
+		skipping("KOI8-R locale not available on this system.");
+		return;
+	}
+
+	/* Check if the paltform completely supports the string conversion. */
+	a = archive_write_new();
+	assertEqualInt(ARCHIVE_OK, archive_write_set_format_pax(a));
+	if (archive_write_set_options(a, "hdrcharset=UTF-8") != ARCHIVE_OK) {
+		skipping("This system cannot convert character-set"
+		    " from KOI8-R to UTF-8.");
+		archive_write_free(a);
+		return;
+	}
+	archive_write_free(a);
+
+	/* Re-create a write archive object since filenames should be written
+	 * in UTF-8 by default. */
+	a = archive_write_new();
+	assertEqualInt(ARCHIVE_OK, archive_write_set_format_pax(a));
+	assertEqualInt(ARCHIVE_OK,
+	    archive_write_open_memory(a, buff, sizeof(buff), &used));
+
+	entry = archive_entry_new2(a);
+	archive_entry_set_pathname(entry, "\xD0\xD2\xC9");
+	archive_entry_set_filetype(entry, AE_IFREG);
+	archive_entry_set_size(entry, 0);
+	assertEqualInt(ARCHIVE_OK, archive_write_header(a, entry));
+	archive_entry_free(entry);
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
+
+	/* Above three characters in KOI8-R should translate to the following
+	 * three characters (two bytes each) in UTF-8. */
+	assertEqualMem(buff + 512, "15 path=\xD0\xBF\xD1\x80\xD0\xB8\x0A", 15);
+}
+
+/*
+ * Verify that CP1251 filenames are correctly translated to Unicode and UTF-8.
+ */
+static void
+test_pax_filename_encoding_CP1251(void)
+{
+  	struct archive *a;
+  	struct archive_entry *entry;
+	char buff[4096];
+	size_t used;
+
+	if (NULL == setlocale(LC_ALL, "Russian_Russia") &&
+	    NULL == setlocale(LC_ALL, "ru_RU.CP1251")) {
+		skipping("KOI8-R locale not available on this system.");
+		return;
+	}
+
+	/* Check if the paltform completely supports the string conversion. */
+	a = archive_write_new();
+	assertEqualInt(ARCHIVE_OK, archive_write_set_format_pax(a));
+	if (archive_write_set_options(a, "hdrcharset=UTF-8") != ARCHIVE_OK) {
+		skipping("This system cannot convert character-set"
+		    " from KOI8-R to UTF-8.");
+		archive_write_free(a);
+		return;
+	}
+	archive_write_free(a);
+
+	/* Re-create a write archive object since filenames should be written
+	 * in UTF-8 by default. */
+	a = archive_write_new();
+	assertEqualInt(ARCHIVE_OK, archive_write_set_format_pax(a));
+	assertEqualInt(ARCHIVE_OK,
+	    archive_write_open_memory(a, buff, sizeof(buff), &used));
+
+	entry = archive_entry_new2(a);
+	archive_entry_set_pathname(entry, "\xef\xf0\xe8");
+	archive_entry_set_filetype(entry, AE_IFREG);
+	archive_entry_set_size(entry, 0);
+	assertEqualInt(ARCHIVE_OK, archive_write_header(a, entry));
+	archive_entry_free(entry);
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
+
+	/* Above three characters in KOI8-R should translate to the following
+	 * three characters (two bytes each) in UTF-8. */
+	assertEqualMem(buff + 512, "15 path=\xD0\xBF\xD1\x80\xD0\xB8\x0A", 15);
+}
+
+/*
+ * Verify that EUC-JP filenames are correctly translated to Unicode and UTF-8.
+ */
+static void
+test_pax_filename_encoding_EUCJP(void)
+{
+  	struct archive *a;
+  	struct archive_entry *entry;
+	char buff[4096];
+	size_t used;
+
+	if (NULL == setlocale(LC_ALL, "ja_JP.eucJP")) {
+		skipping("eucJP locale not available on this system.");
+		return;
+	}
+
+	/* Check if the paltform completely supports the string conversion. */
+	a = archive_write_new();
+	assertEqualInt(ARCHIVE_OK, archive_write_set_format_pax(a));
+	if (archive_write_set_options(a, "hdrcharset=UTF-8") != ARCHIVE_OK) {
+		skipping("This system cannot convert character-set"
+		    " from eucJP to UTF-8.");
+		archive_write_free(a);
+		return;
+	}
+	archive_write_free(a);
+
+	/* Re-create a write archive object since filenames should be written
+	 * in UTF-8 by default. */
+	a = archive_write_new();
+	assertEqualInt(ARCHIVE_OK, archive_write_set_format_pax(a));
+	assertEqualInt(ARCHIVE_OK,
+	    archive_write_open_memory(a, buff, sizeof(buff), &used));
+
+	entry = archive_entry_new2(a);
+	archive_entry_set_pathname(entry, "\xC9\xBD.txt");
+	/* Check the Unicode version. */
+	archive_entry_set_filetype(entry, AE_IFREG);
+	archive_entry_set_size(entry, 0);
+	assertEqualInt(ARCHIVE_OK, archive_write_header(a, entry));
+	archive_entry_free(entry);
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
+
+	/* Check UTF-8 version. */
+	assertEqualMem(buff + 512, "16 path=\xE8\xA1\xA8.txt\x0A", 16);
+
+}
+
+/*
+ * Verify that CP932/SJIS filenames are correctly translated to Unicode and UTF-8.
+ */
+static void
+test_pax_filename_encoding_CP932(void)
+{
+  	struct archive *a;
+  	struct archive_entry *entry;
+	char buff[4096];
+	size_t used;
+
+	if (NULL == setlocale(LC_ALL, "Japanese_Japan") &&
+	    NULL == setlocale(LC_ALL, "ja_JP.SJIS")) {
+		skipping("eucJP locale not available on this system.");
+		return;
+	}
+
+	/* Check if the paltform completely supports the string conversion. */
+	a = archive_write_new();
+	assertEqualInt(ARCHIVE_OK, archive_write_set_format_pax(a));
+	if (archive_write_set_options(a, "hdrcharset=UTF-8") != ARCHIVE_OK) {
+		skipping("This system cannot convert character-set"
+		    " from CP932/SJIS to UTF-8.");
+		archive_write_free(a);
+		return;
+	}
+	archive_write_free(a);
+
+	/* Re-create a write archive object since filenames should be written
+	 * in UTF-8 by default. */
+	a = archive_write_new();
+	assertEqualInt(ARCHIVE_OK, archive_write_set_format_pax(a));
+	assertEqualInt(ARCHIVE_OK,
+	    archive_write_open_memory(a, buff, sizeof(buff), &used));
+
+	entry = archive_entry_new2(a);
+	archive_entry_set_pathname(entry, "\x95\x5C.txt");
+	/* Check the Unicode version. */
+	archive_entry_set_filetype(entry, AE_IFREG);
+	archive_entry_set_size(entry, 0);
+	assertEqualInt(ARCHIVE_OK, archive_write_header(a, entry));
+	archive_entry_free(entry);
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
+
+	/* Check UTF-8 version. */
+	assertEqualMem(buff + 512, "16 path=\xE8\xA1\xA8.txt\x0A", 16);
+
+}
+
+/*
+ * Verify that KOI8-R filenames are not translated to Unicode and UTF-8
+ * when using hdrcharset=BINARY option.
+ */
+static void
+test_pax_filename_encoding_KOI8R_BINARY(void)
+{
+  	struct archive *a;
+  	struct archive_entry *entry;
+	char buff[4096];
+	size_t used;
+
+	if (NULL == setlocale(LC_ALL, "ru_RU.KOI8-R")) {
+		skipping("KOI8-R locale not available on this system.");
+		return;
+	}
+
+	a = archive_write_new();
+	assertEqualInt(ARCHIVE_OK, archive_write_set_format_pax(a));
+	/* BINARY mode should be accepted. */
+	assertEqualInt(ARCHIVE_OK,
+	    archive_write_set_options(a, "hdrcharset=BINARY"));
+	assertEqualInt(ARCHIVE_OK,
+	    archive_write_open_memory(a, buff, sizeof(buff), &used));
+
+	entry = archive_entry_new2(a);
+	archive_entry_set_pathname(entry, "\xD0\xD2\xC9");
+	archive_entry_set_filetype(entry, AE_IFREG);
+	archive_entry_set_size(entry, 0);
+	assertEqualInt(ARCHIVE_OK, archive_write_header(a, entry));
+	archive_entry_free(entry);
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
+
+	/* "hdrcharset=BINARY" pax attribute should be written. */
+	assertEqualMem(buff + 512, "21 hdrcharset=BINARY\x0A", 21);
+	/* Above three characters in KOI8-R should not translate to any
+	 * character-set. */
+	assertEqualMem(buff + 512+21, "12 path=\xD0\xD2\xC9\x0A", 12);
+}
+
+/*
+ * Pax format writer only accepts both BINARY and UTF-8.
+ * If other character-set name is specified, you will get ARCHIVE_FAILED.
+ */
+static void
+test_pax_filename_encoding_KOI8R_CP1251(void)
+{
+  	struct archive *a;
+
+	if (NULL == setlocale(LC_ALL, "ru_RU.KOI8-R")) {
+		skipping("KOI8-R locale not available on this system.");
+		return;
+	}
+
+	a = archive_write_new();
+	assertEqualInt(ARCHIVE_OK, archive_write_set_format_pax(a));
+	/* pax format writer only accepts both BINARY and UTF-8. */
+	assertEqualInt(ARCHIVE_FAILED,
+	    archive_write_set_options(a, "hdrcharset=CP1251"));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
+}
+
 
 DEFINE_TEST(test_pax_filename_encoding)
 {
 	test_pax_filename_encoding_1();
 	test_pax_filename_encoding_2();
 	test_pax_filename_encoding_3();
+	test_pax_filename_encoding_KOI8R();
+	test_pax_filename_encoding_CP1251();
+	test_pax_filename_encoding_EUCJP();
+	test_pax_filename_encoding_CP932();
+	test_pax_filename_encoding_KOI8R_BINARY();
+	test_pax_filename_encoding_KOI8R_CP1251();
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_compress_program.c
--- a/head/contrib/libarchive/libarchive/test/test_read_compress_program.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_compress_program.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_compress_program.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_compress_program.c 232153 2012-02-25 10:58:02Z mm $");
 
 static unsigned char archive[] = {
 31,139,8,0,222,'C','p','C',0,3,211,'c',160,'=','0','0','0','0','7','5','U',
@@ -43,9 +43,9 @@
 	 * program is requested.
 	 */
 	assert((a = archive_read_new()) != NULL);
-	r = archive_read_support_compression_program(a, "nonexistent");
+	r = archive_read_support_filter_program(a, "nonexistent");
 	if (r == ARCHIVE_FATAL) {
-		skipping("archive_read_support_compression_program() "
+		skipping("archive_read_support_filter_program() "
 		    "unsupported on this platform");
 		return;
 	}
@@ -55,7 +55,7 @@
 	assertEqualIntA(a, ARCHIVE_FATAL,
 	    archive_read_open_memory(a, archive, sizeof(archive)));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	/*
 	 * If we have "gzip -d", try using that.
@@ -66,9 +66,9 @@
 	}
 	assert((a = archive_read_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK,
-	    archive_read_support_compression_none(a));
+	    archive_read_support_filter_none(a));
 	assertEqualIntA(a, ARCHIVE_OK,
-	    archive_read_support_compression_program(a, "gunzip"));
+	    archive_read_support_filter_program(a, "gunzip"));
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_read_support_format_all(a));
 	assertEqualIntA(a, ARCHIVE_OK,
@@ -78,7 +78,7 @@
 	assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_PROGRAM);
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_data_large.c
--- a/head/contrib/libarchive/libarchive/test/test_read_data_large.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_data_large.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_data_large.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_data_large.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * Test read/write of a 10M block of data in a single operation.
@@ -72,34 +72,26 @@
 	assertA((int)sizeof(buff2) == archive_write_data(a, buff2, sizeof(buff2)));
 
 	/* Close out the archive. */
-	assertA(0 == archive_write_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_write_finish(a);
-#else
-	assertA(0 == archive_write_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/* Check that archive_read_data can handle 10*10^6 at a pop. */
 	assert((a = archive_read_new()) != NULL);
 	assertA(0 == archive_read_support_format_all(a));
-	assertA(0 == archive_read_support_compression_all(a));
+	assertA(0 == archive_read_support_filter_all(a));
 	assertA(0 == archive_read_open_memory(a, buff1, sizeof(buff1)));
 	assertA(0 == archive_read_next_header(a, &ae));
 	failure("Wrote 10MB, but didn't read the same amount");
 	assertEqualIntA(a, sizeof(buff2),archive_read_data(a, buff3, sizeof(buff3)));
 	failure("Read expected 10MB, but data read didn't match what was written");
-	assert(0 == memcmp(buff2, buff3, sizeof(buff3)));
-	assert(0 == archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assert(0 == archive_read_finish(a));
-#endif
+	assertEqualMem(buff2, buff3, sizeof(buff3));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	/* Check archive_read_data_into_fd */
 	assert((a = archive_read_new()) != NULL);
 	assertA(0 == archive_read_support_format_all(a));
-	assertA(0 == archive_read_support_compression_all(a));
+	assertA(0 == archive_read_support_filter_all(a));
 	assertA(0 == archive_read_open_memory(a, buff1, sizeof(buff1)));
 	assertA(0 == archive_read_next_header(a, &ae));
 #if defined(__BORLANDC__)
@@ -109,17 +101,13 @@
 #endif
 	assert(tmpfilefd != 0);
 	assertEqualIntA(a, 0, archive_read_data_into_fd(a, tmpfilefd));
-	assert(0 == archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assert(0 == archive_read_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 	close(tmpfilefd);
 
 	f = fopen(tmpfilename, "rb");
 	assert(f != NULL);
 	assertEqualInt(sizeof(buff3), fread(buff3, 1, sizeof(buff3), f));
 	fclose(f);
-	assert(0 == memcmp(buff2, buff3, sizeof(buff3)));
+	assertEqualMem(buff2, buff3, sizeof(buff3));
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_disk.c
--- a/head/contrib/libarchive/libarchive/test/test_read_disk.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_disk.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_disk.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_disk.c 232153 2012-02-25 10:58:02Z mm $");
 
 static void
 gname_cleanup(void *d)
@@ -34,7 +34,7 @@
 }
 
 static const char *
-gname_lookup(void *d, gid_t g)
+gname_lookup(void *d, int64_t g)
 {
 	int *mp = d;
 	assertEqualInt(*mp, 0x13579);
@@ -52,7 +52,7 @@
 }
 
 static const char *
-uname_lookup(void *d, uid_t u)
+uname_lookup(void *d, int64_t u)
 {
 	int *mp = d;
 	assertEqualInt(*mp, 0x1234);
@@ -164,7 +164,7 @@
 			   &umagic, &uname_lookup, &uname_cleanup));
 
 	/* Destroy the archive. */
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	/* Verify our cleanup functions got called. */
 	assertEqualInt(gmagic, 0x2468);
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_disk_entry_from_file.c
--- a/head/contrib/libarchive/libarchive/test/test_read_disk_entry_from_file.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_disk_entry_from_file.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,10 +23,10 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_disk_entry_from_file.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_disk_entry_from_file.c 232153 2012-02-25 10:58:02Z mm $");
 
 static const char *
-gname_lookup(void *d, gid_t g)
+gname_lookup(void *d, int64_t g)
 {
 	(void)d; /* UNUSED */
 	(void)g; /* UNUSED */
@@ -34,7 +34,7 @@
 }
 
 static const char *
-uname_lookup(void *d, uid_t u)
+uname_lookup(void *d, int64_t u)
 {
 	(void)d; /* UNUSED */
 	(void)u; /* UNUSED */
@@ -66,7 +66,7 @@
 	entry = archive_entry_new();
 	assert(entry != NULL);
 	archive_entry_copy_pathname(entry, "foo");
-	assertEqualInt(ARCHIVE_OK,
+	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_read_disk_entry_from_file(a, entry, -1, NULL));
 
 	/* Verify the information we got back. */
@@ -76,5 +76,5 @@
 
 	/* Destroy the archive. */
 	archive_entry_free(entry);
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_extract.c
--- a/head/contrib/libarchive/libarchive/test/test_read_extract.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_extract.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_extract.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_extract.c 232153 2012-02-25 10:58:02Z mm $");
 
 #define BUFF_SIZE 1000000
 #define FILE_BUFF_SIZE 100000
@@ -111,13 +111,13 @@
 		archive_entry_free(ae);
 	}
 	/* Close out the archive. */
-	assertA(0 == archive_write_close(a));
-	assertA(0 == archive_write_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/* Extract the entries to disk. */
 	assert((a = archive_read_new()) != NULL);
 	assertA(0 == archive_read_support_format_all(a));
-	assertA(0 == archive_read_support_compression_all(a));
+	assertA(0 == archive_read_support_filter_all(a));
 	assertA(0 == archive_read_open_memory(a, buff, BUFF_SIZE));
 	/* Restore first entry with _EXTRACT_PERM. */
 	failure("Error reading first entry", i);
@@ -132,8 +132,8 @@
 		assertA(0 == archive_read_extract(a, ae, 0));
 	}
 	assertA(ARCHIVE_EOF == archive_read_next_header(a, &ae));
-	assert(0 == archive_read_close(a));
-	assert(0 == archive_read_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	/* Test the entries on disk. */
 	/* This first entry was extracted with ARCHIVE_EXTRACT_PERM,
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_file_nonexistent.c
--- a/head/contrib/libarchive/libarchive/test/test_read_file_nonexistent.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_file_nonexistent.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_file_nonexistent.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_file_nonexistent.c 232153 2012-02-25 10:58:02Z mm $");
 
 DEFINE_TEST(test_read_file_nonexistent)
 {
@@ -31,7 +31,7 @@
 	assertEqualInt(ARCHIVE_OK, archive_read_support_format_all(a));
 	assertEqualInt(ARCHIVE_FATAL,
 	    archive_read_open_filename(a, "notexistent.tar", 512));
-	archive_read_finish(a);
+	archive_read_free(a);
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_ar.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_ar.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_ar.c	Fri Mar 02 16:54:40 2012 +0200
@@ -26,7 +26,7 @@
  */
 
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_ar.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_ar.c 232153 2012-02-25 10:58:02Z mm $");
 
 
 DEFINE_TEST(test_read_format_ar)
@@ -38,7 +38,7 @@
 
 	extract_reference_file(reffile);
 	assert((a = archive_read_new()) != NULL);
-	assertA(0 == archive_read_support_compression_all(a));
+	assertA(0 == archive_read_support_filter_all(a));
 	assertA(0 == archive_read_support_format_all(a));
 	assertA(0 == archive_read_open_file(a, reffile, 7));
 
@@ -58,7 +58,7 @@
 	assertEqualInt(0, archive_entry_gid(ae));
 	assert(8 == archive_entry_size(ae));
 	assertA(8 == archive_read_data(a, buff, 10));
-	assert(0 == memcmp(buff, "55667788", 8));
+	assertEqualMem(buff, "55667788", 8);
 
 	/* Second Entry */
 	assertA(0 == archive_read_next_header(a, &ae));
@@ -68,7 +68,7 @@
 	assertEqualInt(0, archive_entry_gid(ae));
 	assert(4 == archive_entry_size(ae));
 	assertA(4 == archive_read_data(a, buff, 10));
-	assert(0 == memcmp(buff, "3333", 4));
+	assertEqualMem(buff, "3333", 4);
 
 	/* Third Entry */
 	assertA(0 == archive_read_next_header(a, &ae));
@@ -78,10 +78,11 @@
 	assertEqualInt(0, archive_entry_gid(ae));
 	assert(9 == archive_entry_size(ae));
 	assertA(9 == archive_read_data(a, buff, 9));
-	assert(0 == memcmp(buff, "987654321", 9));
+	assertEqualMem(buff, "987654321", 9);
 
 	/* Test EOF */
 	assertA(1 == archive_read_next_header(a, &ae));
-	assert(0 == archive_read_close(a));
-	assert(0 == archive_read_finish(a));
+	assertEqualInt(4, archive_file_count(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin.c 232153 2012-02-25 10:58:02Z mm $");
 
 static unsigned char archive[] = {
 199,'q',21,4,177,'y',237,'A',232,3,232,3,2,0,0,0,'p','C',244,'M',2,0,0,0,
@@ -47,18 +47,15 @@
 	struct archive_entry *ae;
 	struct archive *a;
 	assert((a = archive_read_new()) != NULL);
-	assertA(0 == archive_read_support_compression_all(a));
-	assertA(0 == archive_read_support_format_all(a));
-	assertA(0 == archive_read_open_memory(a, archive, sizeof(archive)));
-	assertA(0 == archive_read_next_header(a, &ae));
-	assertA(archive_compression(a) == ARCHIVE_COMPRESSION_NONE);
-	assertA(archive_format(a) == ARCHIVE_FORMAT_CPIO_BIN_LE);
-	assert(0 == archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assert(0 == archive_read_finish(a));
-#endif
+	assertEqualIntA(a, 0, archive_read_support_filter_all(a));
+	assertEqualIntA(a, 0, archive_read_support_format_all(a));
+	assertEqualIntA(a, 0, archive_read_open_memory(a, archive, sizeof(archive)));
+	assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
+	assertEqualInt(1, archive_file_count(a));
+	assertEqualIntA(a, ARCHIVE_COMPRESSION_NONE, archive_compression(a));
+	assertEqualIntA(a, ARCHIVE_FORMAT_CPIO_BIN_LE, archive_format(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_Z.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_Z.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_Z.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_Z.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_Z.c 232153 2012-02-25 10:58:02Z mm $");
 
 static unsigned char archive[] = {
 31,157,144,199,226,'T',' ',16,'+','O',187,' ',232,6,'$',20,0,160,'!',156,
@@ -37,12 +37,13 @@
 	struct archive *a;
 	assert((a = archive_read_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK,
-	    archive_read_support_compression_all(a));
+	    archive_read_support_filter_all(a));
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_read_support_format_all(a));
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_read_open_memory(a, archive, sizeof(archive)));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualInt(1, archive_file_count(a));
 	failure("archive_compression_name(a)=\"%s\"",
 	    archive_compression_name(a));
 	assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_COMPRESS);
@@ -51,11 +52,7 @@
 	    archive_format_name(a));
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_BIN_LE);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
-#endif
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_be.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_be.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_be.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_be.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_be.c 232153 2012-02-25 10:58:02Z mm $");
 
 DEFINE_TEST(test_read_format_cpio_bin_be)
 {
@@ -33,7 +33,7 @@
 
 	extract_reference_file(reference);
 	assert((a = archive_read_new()) != NULL);
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_read_open_filename(a, reference, 10));
@@ -49,7 +49,7 @@
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_BIN_BE);
 	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_bz2.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_bz2.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_bz2.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_bz2.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_bz2.c 232153 2012-02-25 10:58:02Z mm $");
 
 static unsigned char archive[] = {
 'B','Z','h','9','1','A','Y','&','S','Y',134,'J',208,'4',0,0,30,246,141,253,
@@ -39,7 +39,7 @@
 	int r;
 
 	assert((a = archive_read_new()) != NULL);
-	r = archive_read_support_compression_bzip2(a);
+	r = archive_read_support_filter_bzip2(a);
 	if (r != ARCHIVE_OK) {
 		skipping("bzip2 support unavailable");
 		archive_read_close(a);
@@ -51,8 +51,8 @@
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
 	assert(archive_compression(a) == ARCHIVE_COMPRESSION_BZIP2);
 	assert(archive_format(a) == ARCHIVE_FORMAT_CPIO_BIN_LE);
-	assert(0 == archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_gz.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_gz.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_gz.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_gz.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_gz.c 232153 2012-02-25 10:58:02Z mm $");
 
 static unsigned char archive[] = {
 31,139,8,0,244,'M','p','C',0,3,';','^','(',202,178,177,242,173,227,11,230,
@@ -38,14 +38,14 @@
 	int r;
 
 	assert((a = archive_read_new()) != NULL);
-	assertEqualInt(ARCHIVE_OK, archive_read_support_compression_all(a));
-	r = archive_read_support_compression_gzip(a);
+	assertEqualInt(ARCHIVE_OK, archive_read_support_filter_all(a));
+	r = archive_read_support_filter_gzip(a);
 	if (r == ARCHIVE_WARN) {
 		skipping("gzip reading not fully supported on this platform");
-		assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+		assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 		return;
 	}
-	failure("archive_read_support_compression_gzip");
+	failure("archive_read_support_filter_gzip");
 	assertEqualInt(ARCHIVE_OK, r);
 	assertEqualInt(ARCHIVE_OK, archive_read_support_format_all(a));
 	assertEqualInt(ARCHIVE_OK,
@@ -55,7 +55,7 @@
 	    ARCHIVE_COMPRESSION_GZIP);
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_BIN_LE);
 	assertEqualInt(ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_lzma.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_lzma.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_lzma.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_lzma.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_lzma.c 232153 2012-02-25 10:58:02Z mm $");
 
 static unsigned char archive[] = {
  93,  0,  0,128,  0,255,255,255,255,255,255,255,255,  0, 99,156,
@@ -41,11 +41,11 @@
 	int r;
 
 	assert((a = archive_read_new()) != NULL);
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
-	r = archive_read_support_compression_lzma(a);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	r = archive_read_support_filter_lzma(a);
 	if (r == ARCHIVE_WARN) {
 		skipping("lzma reading not fully supported on this platform");
-		assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+		assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 		return;
 	}
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
@@ -55,6 +55,6 @@
 	assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_LZMA);
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_BIN_LE);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_xz.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_xz.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_xz.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_xz.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_xz.c 232153 2012-02-25 10:58:02Z mm $");
 
 static unsigned char archive[] = {
  0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00, 0x00, 0x04,
@@ -51,11 +51,11 @@
 	int r;
 
 	assert((a = archive_read_new()) != NULL);
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
-	r = archive_read_support_compression_xz(a);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	r = archive_read_support_filter_xz(a);
 	if (r == ARCHIVE_WARN) {
 		skipping("xz reading not fully supported on this platform");
-		assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+		assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 		return;
 	}
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
@@ -65,6 +65,6 @@
 	assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_XZ);
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_BIN_LE);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_cpio_odc.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_cpio_odc.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_cpio_odc.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_cpio_odc.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_cpio_odc.c 232153 2012-02-25 10:58:02Z mm $");
 
 static unsigned char archive[] = {
 '0','7','0','7','0','7','0','0','2','0','2','5','0','7','4','6','6','1','0',
@@ -51,18 +51,14 @@
 	struct archive_entry *ae;
 	struct archive *a;
 	assert((a = archive_read_new()) != NULL);
-	assertA(0 == archive_read_support_compression_all(a));
+	assertA(0 == archive_read_support_filter_all(a));
 	assertA(0 == archive_read_support_format_all(a));
 	assertA(0 == archive_read_open_memory(a, archive, sizeof(archive)));
 	assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
 	assertA(archive_compression(a) == ARCHIVE_COMPRESSION_NONE);
 	assertA(archive_format(a) == ARCHIVE_FORMAT_CPIO_POSIX);
-	assert(0 == archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assert(0 == archive_read_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.c	Fri Mar 02 16:54:40 2012 +0200
@@ -90,15 +90,15 @@
 	int r;
 
 	assert((a = archive_read_new()) != NULL);
-        r = archive_read_support_compression_bzip2(a);
+        r = archive_read_support_filter_bzip2(a);
 	if (r == ARCHIVE_WARN) {
 		skipping("bzip2 reading not fully supported on this platform");
-		assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+		assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 		return;
         }
 	assertEqualIntA(a, ARCHIVE_OK, r);
 	assertEqualIntA(a, ARCHIVE_OK,
-	    archive_read_support_compression_rpm(a));
+	    archive_read_support_filter_rpm(a));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
 	extract_reference_file(name);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 2));
@@ -122,6 +122,6 @@
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_SVR4_NOCRC);
  
 	assertEqualInt(ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_cpio_svr4_gzip.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_cpio_svr4_gzip.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_cpio_svr4_gzip.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_cpio_svr4_gzip.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_cpio_svr4_gzip.c 232153 2012-02-25 10:58:02Z mm $");
 
 static unsigned char archive[] = {
 31,139,8,0,236,'c',217,'D',0,3,'3','0','7','0','7','0','4','0','0',181,'0',
@@ -39,11 +39,11 @@
 	int r;
 
 	assert((a = archive_read_new()) != NULL);
-	assertEqualInt(ARCHIVE_OK, archive_read_support_compression_all(a));
-	r = archive_read_support_compression_gzip(a);
+	assertEqualInt(ARCHIVE_OK, archive_read_support_filter_all(a));
+	r = archive_read_support_filter_gzip(a);
 	if (r == ARCHIVE_WARN) {
 		skipping("gzip reading not fully supported on this platform");
-		assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+		assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 		return;
 	}
 	assertEqualInt(ARCHIVE_OK, archive_read_support_format_all(a));
@@ -55,7 +55,7 @@
 	assertEqualInt(archive_format(a),
 	    ARCHIVE_FORMAT_CPIO_SVR4_NOCRC);
 	assertEqualInt(ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_cpio_svr4_gzip_rpm.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_cpio_svr4_gzip_rpm.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_cpio_svr4_gzip_rpm.c	Fri Mar 02 16:54:40 2012 +0200
@@ -90,15 +90,15 @@
 	int r;
 
 	assert((a = archive_read_new()) != NULL);
-        r = archive_read_support_compression_gzip(a);
+        r = archive_read_support_filter_gzip(a);
 	if (r == ARCHIVE_WARN) {
 		skipping("gzip reading not fully supported on this platform");
-		assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+		assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 		return;
         }
 	assertEqualIntA(a, ARCHIVE_OK, r);
 	assertEqualIntA(a, ARCHIVE_OK,
-	    archive_read_support_compression_rpm(a));
+	    archive_read_support_filter_rpm(a));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
 	extract_reference_file(name);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 2));
@@ -122,6 +122,6 @@
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_SVR4_NOCRC);
  
 	assertEqualInt(ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_cpio_svr4c_Z.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_cpio_svr4c_Z.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_cpio_svr4c_Z.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_cpio_svr4c_Z.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_cpio_svr4c_Z.c 232153 2012-02-25 10:58:02Z mm $");
 
 static unsigned char archive[] = {
 31,157,144,'0','n',4,132,'!',3,6,140,26,'8','n',228,16,19,195,160,'A',26,
@@ -40,7 +40,7 @@
 /*	printf("Archive address: start=%X, end=%X\n", archive, archive+sizeof(archive)); */
 	assert((a = archive_read_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK,
-	    archive_read_support_compression_all(a));
+	    archive_read_support_filter_all(a));
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_read_support_format_all(a));
 	assertEqualIntA(a, ARCHIVE_OK,
@@ -52,11 +52,7 @@
 	failure("archive_format_name(a)=\"%s\"", archive_format_name(a));
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_SVR4_CRC);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
-#endif
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_empty.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_empty.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_empty.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_empty.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_empty.c 232153 2012-02-25 10:58:02Z mm $");
 
 static unsigned char archive[] = { 0 };
 
@@ -32,16 +32,12 @@
 	struct archive_entry *ae;
 	struct archive *a;
 	assert((a = archive_read_new()) != NULL);
-	assertA(0 == archive_read_support_compression_all(a));
+	assertA(0 == archive_read_support_filter_all(a));
 	assertA(0 == archive_read_support_format_all(a));
 	assertA(0 == archive_read_open_memory(a, archive, 0));
 	assertA(ARCHIVE_EOF == archive_read_next_header(a, &ae));
 	assertA(archive_compression(a) == ARCHIVE_COMPRESSION_NONE);
 	assertA(archive_format(a) == ARCHIVE_FORMAT_EMPTY);
-	assert(0 == archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assert(0 == archive_read_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_gtar_gz.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_gtar_gz.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_gtar_gz.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_gtar_gz.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_gtar_gz.c 232153 2012-02-25 10:58:02Z mm $");
 
 static unsigned char archive[] = {
 31,139,8,0,'+','e',217,'D',0,3,211,211,'g',160,'9','0',0,2,'s','S','S',16,
@@ -39,22 +39,23 @@
 	int r;
 
 	assert((a = archive_read_new()) != NULL);
-	assertEqualInt(ARCHIVE_OK, archive_read_support_compression_all(a));
-	r = archive_read_support_compression_gzip(a);
+	assertEqualInt(ARCHIVE_OK, archive_read_support_filter_all(a));
+	r = archive_read_support_filter_gzip(a);
 	if (r == ARCHIVE_WARN) {
 		skipping("gzip reading not fully supported on this platform");
-		assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+		assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 		return;
 	}
 	assertEqualInt(ARCHIVE_OK, archive_read_support_format_all(a));
 	assertEqualInt(ARCHIVE_OK,
 	    archive_read_open_memory(a, archive, sizeof(archive)));
 	assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualInt(1, archive_file_count(a));
 	assertEqualInt(archive_compression(a),
 	    ARCHIVE_COMPRESSION_GZIP);
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_GNUTAR);
 	assertEqualInt(ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_gtar_lzma.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_gtar_lzma.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_gtar_lzma.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_gtar_lzma.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_gtar_lzma.c 232153 2012-02-25 10:58:02Z mm $");
 
 static unsigned char archive[] = {
 0x5d, 0x0, 0x0, 0x80, 0x0, 0x0, 0x28, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
@@ -45,11 +45,11 @@
 	struct archive *a;
 	assert((a = archive_read_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK,
-	    archive_read_support_compression_all(a));
-	r = archive_read_support_compression_lzma(a);
+	    archive_read_support_filter_all(a));
+	r = archive_read_support_filter_lzma(a);
 	if (r == ARCHIVE_WARN) {
 		skipping("lzma reading not fully supported on this platform");
-		assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+		assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 		return;
 	}
 
@@ -68,11 +68,7 @@
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_GNUTAR);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
 finish:
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
-#endif
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_gtar_sparse.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_gtar_sparse.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_gtar_sparse.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,11 +23,11 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_gtar_sparse.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_gtar_sparse.c 232153 2012-02-25 10:58:02Z mm $");
 
 
 struct contents {
-	off_t	o;
+	int64_t	o;
 	size_t	s;
 	const char *d;
 };
@@ -186,7 +186,7 @@
 	extract_reference_file(name);
 
 	assert((a = archive_read_new()) != NULL);
-	assert(0 == archive_read_support_compression_all(a));
+	assert(0 == archive_read_support_filter_all(a));
 	assert(0 == archive_read_support_format_tar(a));
 	failure("Can't open %s", name);
 	assert(0 == archive_read_open_filename(a, name, 3));
@@ -195,7 +195,7 @@
 		struct contents *cts = ac->contents;
 
 		if (!assertEqualIntA(a, 0, archive_read_next_header(a, &ae))) {
-			assert(0 == archive_read_finish(a));
+			assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 			return;
 		}
 		failure("Name mismatch in archive %s", name);
@@ -233,7 +233,7 @@
 					failure("%s: Unexpected trailing data",
 					    name);
 					assert(actual.o <= expect.o);
-					archive_read_finish(a);
+					archive_read_free(a);
 					return;
 				}
 				actual.d++;
@@ -245,13 +245,8 @@
 		assertEqualIntA(a, err, ARCHIVE_EOF);
 		failure("%s: Size returned at EOF must be zero", name);
 		assertEqualInt((int)actual.s, 0);
-#if ARCHIVE_VERSION_NUMBER < 1009000
-		/* libarchive < 1.9 doesn't get this right */
-		skipping("offset of final sparse chunk");
-#else
 		failure("%s: Offset of final empty chunk must be same as file size", name);
 		assertEqualInt(actual.o, expect.o);
-#endif
 		/* Step to next file description. */
 		++ac;
 	}
@@ -259,12 +254,8 @@
 	err = archive_read_next_header(a, &ae);
 	assertEqualIntA(a, ARCHIVE_EOF, err);
 
-	assert(0 == archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assert(0 == archive_read_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 
@@ -278,9 +269,7 @@
 	 * libarchive < 1.9 doesn't support the newer --posix sparse formats
 	 * from GNU tar 1.15 and later.
 	 */
-#if ARCHIVE_VERSION_NUMBER < 1009000
-	skipping("read support for GNUtar --posix sparse formats");
-#else
+
 	/*
 	 * An archive created by GNU tar 1.17 using --posix --sparse-format=0.1
 	 */
@@ -312,7 +301,6 @@
 	verify_archive_file(
 		"test_read_format_gtar_sparse_1_17_posix10_modified.tar",
 		files);
-#endif
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_iso_Z.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_iso_Z.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_iso_Z.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_iso_Z.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_iso_Z.c 232153 2012-02-25 10:58:02Z mm $");
 
 static void
 test1(void)
@@ -36,22 +36,23 @@
 
 	assert((a = archive_read_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK,
-	    archive_read_support_compression_all(a));
+	    archive_read_support_filter_all(a));
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_read_support_format_all(a));
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_read_open_filename(a, name, 512));
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_read_next_header(a, &ae));
+	assertEqualInt(1, archive_file_count(a));
 	assertEqualInt(archive_compression(a),
 	    ARCHIVE_COMPRESSION_COMPRESS);
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
-static
-void test2(void)
+static void
+test2(void)
 {
 	struct archive_entry *ae;
 	struct archive *a;
@@ -61,7 +62,7 @@
 
 	assert((a = archive_read_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK,
-	    archive_read_support_compression_all(a));
+	    archive_read_support_filter_all(a));
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_read_support_format_all(a));
 	assertEqualIntA(a, ARCHIVE_OK,
@@ -83,11 +84,12 @@
 	assertEqualString("C/D", archive_entry_pathname(ae));
 	assertEqualIntA(a, ARCHIVE_EOF,
 	    archive_read_next_header(a, &ae));
+	assertEqualInt(5, archive_file_count(a));
 	assertEqualInt(archive_compression(a),
 	    ARCHIVE_COMPRESSION_COMPRESS);
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 DEFINE_TEST(test_read_format_iso_Z)
@@ -95,5 +97,3 @@
 	test1();
 	test2();
 }
-
-
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_iso_multi_extent.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_iso_multi_extent.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_iso_multi_extent.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_iso_multi_extent.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_iso_multi_extent.c 232153 2012-02-25 10:58:02Z mm $");
 
 DEFINE_TEST(test_read_format_iso_multi_extent)
 {
@@ -33,12 +33,12 @@
 	struct archive *a;
 	const void *p;
 	size_t size;
-	off_t offset;
+	int64_t offset;
 	int i;
 
 	extract_reference_file(refname);
 	assert((a = archive_read_new()) != NULL);
-	assertEqualInt(0, archive_read_support_compression_all(a));
+	assertEqualInt(0, archive_read_support_filter_all(a));
 	assertEqualInt(0, archive_read_support_format_all(a));
 	assertEqualInt(ARCHIVE_OK,
 	    archive_read_open_filename(a, refname, 10240));
@@ -87,8 +87,8 @@
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660_ROCKRIDGE);
 
 	/* Close the archive. */
-	assertEqualInt(0, archive_read_close(a));
-	assertEqualInt(0, archive_read_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_isojoliet_bz2.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_isojoliet_bz2.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_isojoliet_bz2.c	Fri Mar 02 16:54:40 2012 +0200
@@ -27,7 +27,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_isojoliet_bz2.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_isojoliet_bz2.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
 Execute the following to rebuild the data for this program:
@@ -59,14 +59,14 @@
 	struct archive *a;
 	const void *p;
 	size_t size;
-	off_t offset;
+	int64_t offset;
 
 	extract_reference_file(refname);
 	assert((a = archive_read_new()) != NULL);
-	assertEqualInt(0, archive_read_support_compression_all(a));
+	assertEqualInt(0, archive_read_support_filter_all(a));
 	assertEqualInt(0, archive_read_support_format_all(a));
 	assertEqualInt(ARCHIVE_OK,
-	    archive_read_set_options(a, "iso9660:!rockridge"));
+	    archive_read_set_option(a, "iso9660", "rockridge", NULL));
 	assertEqualInt(ARCHIVE_OK,
 	    archive_read_open_filename(a, refname, 10240));
 
@@ -103,7 +103,7 @@
 	assertEqualInt(0, archive_read_data_block(a, &p, &size, &offset));
 	assertEqualInt(6, (int)size);
 	assertEqualInt(0, offset);
-	assertEqualInt(0, memcmp(p, "hello\n", 6));
+	assertEqualMem(p, "hello\n", 6);
 
 	/* Second name for the same regular file (this happens to be
 	 * returned second, so does get marked as a hardlink). */
@@ -129,7 +129,7 @@
 	assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_COMPRESS);
 
 	/* Close the archive. */
-	assertEqualInt(0, archive_read_close(a));
-	assertEqualInt(0, archive_read_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_isojoliet_long.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_isojoliet_long.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_isojoliet_long.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_isojoliet_long.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_isojoliet_long.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
 Execute the following to rebuild the data for this program:
@@ -64,14 +64,14 @@
 	struct archive *a;
 	const void *p;
 	size_t size;
-	off_t offset;
+	int64_t offset;
 	int i;
 
 	for (i = 0; i < 100; i++)
 		pathname[i] = '0' + ((i+1) % 10); 
 	extract_reference_file(refname);
 	assert((a = archive_read_new()) != NULL);
-	assertEqualInt(0, archive_read_support_compression_all(a));
+	assertEqualInt(0, archive_read_support_filter_all(a));
 	assertEqualInt(0, archive_read_support_format_all(a));
 	assertEqualInt(ARCHIVE_OK,
 	    archive_read_set_options(a, "iso9660:!rockridge"));
@@ -118,7 +118,7 @@
 	assertEqualInt(0, archive_read_data_block(a, &p, &size, &offset));
 	assertEqualInt(6, (int)size);
 	assertEqualInt(0, offset);
-	assertEqualInt(0, memcmp(p, "hello\n", 6));
+	assertEqualMem(p, "hello\n", 6);
 
 	/* Second name for the same regular file (this happens to be
 	 * returned second, so does get marked as a hardlink). */
@@ -135,7 +135,7 @@
 	assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_COMPRESS);
 
 	/* Close the archive. */
-	assertEqualInt(0, archive_read_close(a));
-	assertEqualInt(0, archive_read_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_isojoliet_rr.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_isojoliet_rr.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_isojoliet_rr.c	Fri Mar 02 16:54:40 2012 +0200
@@ -27,7 +27,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_isojoliet_rr.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_isojoliet_rr.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
 Execute the following to rebuild the data for this program:
@@ -62,11 +62,11 @@
 	struct archive *a;
 	const void *p;
 	size_t size;
-	off_t offset;
+	int64_t offset;
 
 	extract_reference_file(refname);
 	assert((a = archive_read_new()) != NULL);
-	assertEqualInt(0, archive_read_support_compression_all(a));
+	assertEqualInt(0, archive_read_support_filter_all(a));
 	assertEqualInt(0, archive_read_support_format_all(a));
 	assertEqualInt(ARCHIVE_OK,
 	    archive_read_open_filename(a, refname, 10240));
@@ -106,7 +106,7 @@
 	assertEqualInt(0, archive_read_data_block(a, &p, &size, &offset));
 	assertEqualInt(6, (int)size);
 	assertEqualInt(0, offset);
-	assertEqualInt(0, memcmp(p, "hello\n", 6));
+	assertEqualMem(p, "hello\n", 6);
 	assertEqualInt(86401, archive_entry_mtime(ae));
 	/* mkisofs records their access time. */
 	/*assertEqualInt(86401, archive_entry_atime(ae));*/
@@ -154,7 +154,7 @@
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660_ROCKRIDGE);
 
 	/* Close the archive. */
-	assertEqualInt(0, archive_read_close(a));
-	assertEqualInt(0, archive_read_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_isorr_bz2.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_isorr_bz2.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_isorr_bz2.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_isorr_bz2.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_isorr_bz2.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
 PLEASE use old cdrtools; mkisofs verion is 2.01.
@@ -59,12 +59,12 @@
 	struct archive *a;
 	const void *p;
 	size_t size;
-	off_t offset;
+	int64_t offset;
 	int i;
 
 	extract_reference_file(refname);
 	assert((a = archive_read_new()) != NULL);
-	assertEqualInt(0, archive_read_support_compression_all(a));
+	assertEqualInt(0, archive_read_support_filter_all(a));
 	assertEqualInt(0, archive_read_support_format_all(a));
 	assertEqualInt(ARCHIVE_OK,
 	    archive_read_open_filename(a, refname, 10240));
@@ -196,8 +196,8 @@
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660_ROCKRIDGE);
 
 	/* Close the archive. */
-	assertEqualInt(0, archive_read_close(a));
-	assertEqualInt(0, archive_read_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_isorr_ce.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_isorr_ce.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_isorr_ce.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_isorr_ce.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_isorr_ce.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
 Execute the following command to rebuild the data for this program:
@@ -92,7 +92,7 @@
 	struct archive *a;
 	const void *p;
 	size_t size;
-	off_t offset;
+	int64_t offset;
 	int i;
 
 	mkpath(path1, 151);
@@ -100,7 +100,7 @@
 	mkpath(path3, 153);
 	extract_reference_file(refname);
 	assert((a = archive_read_new()) != NULL);
-	assertEqualInt(0, archive_read_support_compression_all(a));
+	assertEqualInt(0, archive_read_support_filter_all(a));
 	assertEqualInt(0, archive_read_support_format_all(a));
 	assertEqualInt(ARCHIVE_OK,
 	    archive_read_open_filename(a, refname, 10240));
@@ -216,8 +216,8 @@
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660_ROCKRIDGE);
 
 	/* Close the archive. */
-	assertEqualInt(0, archive_read_close(a));
-	assertEqualInt(0, archive_read_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_isorr_new_bz2.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_isorr_new_bz2.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_isorr_new_bz2.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_isorr_new_bz2.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_isorr_new_bz2.c 232153 2012-02-25 10:58:02Z mm $");
 
 
 /*
@@ -60,12 +60,12 @@
 	struct archive *a;
 	const void *p;
 	size_t size;
-	off_t offset;
+	int64_t offset;
 	int i;
 
 	extract_reference_file(refname);
 	assert((a = archive_read_new()) != NULL);
-	assertEqualInt(0, archive_read_support_compression_all(a));
+	assertEqualInt(0, archive_read_support_filter_all(a));
 	assertEqualInt(0, archive_read_support_format_all(a));
 	assertEqualInt(ARCHIVE_OK,
 	    archive_read_open_filename(a, refname, 10240));
@@ -197,8 +197,8 @@
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660_ROCKRIDGE);
 
 	/* Close the archive. */
-	assertEqualInt(0, archive_read_close(a));
-	assertEqualInt(0, archive_read_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_isorr_rr_moved.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_isorr_rr_moved.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_isorr_rr_moved.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_isorr_rr_moved.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_isorr_rr_moved.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
 Execute the following command to rebuild the data for this program:
@@ -65,12 +65,12 @@
 	struct archive *a;
 	const void *p;
 	size_t size;
-	off_t offset;
+	int64_t offset;
 	int i;
 
 	extract_reference_file(refname);
 	assert((a = archive_read_new()) != NULL);
-	assertEqualInt(0, archive_read_support_compression_all(a));
+	assertEqualInt(0, archive_read_support_filter_all(a));
 	assertEqualInt(0, archive_read_support_format_all(a));
 	assertEqualInt(ARCHIVE_OK,
 	    archive_read_open_filename(a, refname, 10240));
@@ -263,8 +263,8 @@
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660_ROCKRIDGE);
 
 	/* Close the archive. */
-	assertEqualInt(0, archive_read_close(a));
-	assertEqualInt(0, archive_read_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_isozisofs_bz2.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_isozisofs_bz2.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_isozisofs_bz2.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_isozisofs_bz2.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_isozisofs_bz2.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
 Execute the following command to rebuild the data for this program:
@@ -58,12 +58,12 @@
 	struct archive *a;
 	const void *p;
 	size_t size;
-	off_t offset;
+	int64_t offset;
 	int i;
 
 	extract_reference_file(refname);
 	assert((a = archive_read_new()) != NULL);
-	assertEqualInt(0, archive_read_support_compression_all(a));
+	assertEqualInt(0, archive_read_support_filter_all(a));
 	assertEqualInt(0, archive_read_support_format_all(a));
 	assertEqualInt(ARCHIVE_OK,
 	    archive_read_open_filename(a, refname, 10240));
@@ -180,8 +180,8 @@
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660_ROCKRIDGE);
 
 	/* Close the archive. */
-	assertEqualInt(0, archive_read_close(a));
-	assertEqualInt(0, archive_read_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_mtree.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_mtree.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_mtree.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_mtree.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_mtree.c 232153 2012-02-25 10:58:02Z mm $");
 
 static void
 test_read_format_mtree1(void)
@@ -33,6 +33,11 @@
 	struct archive_entry *ae;
 	struct archive *a;
 	FILE *f;
+	/* Compute max 64-bit signed twos-complement value
+	 * without relying on overflow.  This assumes that long long
+	 * is at least 64 bits. */
+	static const long long max_int64 = ((((long long)1) << 62) - 1) + (((long long)1) << 62);
+	time_t min_time, t;
 
 	extract_reference_file(reffile);
 
@@ -47,7 +52,194 @@
 
 	assert((a = archive_read_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK,
-	    archive_read_support_compression_all(a));
+	    archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK,
+	    archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_file(a, reffile, 11));
+
+	/*
+	 * Read "file", whose data is available on disk.
+	 */
+	f = fopen("file", "wb");
+	assert(f != NULL);
+	assertEqualInt(3, fwrite("hi\n", 1, 3, f));
+	fclose(f);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_MTREE);
+	assertEqualString(archive_entry_pathname(ae), "file");
+	assertEqualInt(archive_entry_uid(ae), 18);
+	assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+	assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0123);
+	assertEqualInt(archive_entry_size(ae), 3);
+	assertEqualInt(3, archive_read_data(a, buff, 3));
+	assertEqualMem(buff, "hi\n", 3);
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString(archive_entry_pathname(ae), "dir");
+	assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString(archive_entry_pathname(ae), "dir/file with space");
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString(archive_entry_pathname(ae), "file with space");
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString(archive_entry_pathname(ae), "dir2");
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString(archive_entry_pathname(ae), "dir2/dir3a");
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString(archive_entry_pathname(ae), "dir2/dir3a/indir3a");
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString(archive_entry_pathname(ae), "dir2/fullindir2");
+	assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0644);
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString(archive_entry_pathname(ae), "dir2/indir2");
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString(archive_entry_pathname(ae), "dir2/dir3b");
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString(archive_entry_pathname(ae), "dir2/dir3b/indir3b");
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString(archive_entry_pathname(ae), "notindir");
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString(archive_entry_pathname(ae), "dir2/emptyfile");
+	assertEqualInt(archive_entry_size(ae), 0);
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString(archive_entry_pathname(ae), "dir2/smallfile");
+	assertEqualInt(archive_entry_size(ae), 1);
+
+	/* TODO: Mtree reader should probably return ARCHIVE_WARN for this. */
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString(archive_entry_pathname(ae), "dir2/toosmallfile");
+	assertEqualInt(archive_entry_size(ae), -1);
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString(archive_entry_pathname(ae), "dir2/bigfile");
+	assertEqualInt(archive_entry_size(ae), max_int64);
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString(archive_entry_pathname(ae), "dir2/toobigfile");
+	/* Size in mtree is max_int64 + 1; should return max_int64. */
+	assertEqualInt(archive_entry_size(ae), max_int64);
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString(archive_entry_pathname(ae), "dir2/veryoldfile");
+	/* The value in the file is MIN_INT64_T, but time_t may be narrower. */
+	/* Verify min_time is the smallest possible time_t. */
+	min_time = archive_entry_mtime(ae);
+	assert(min_time <= 0);
+	/* Simply asserting min_time - 1 > 0 breaks with some compiler optimizations. */
+	t = min_time - 1;
+	assert(t > 0);
+
+	/* toooldfile is 1 sec older, which should overflow and get returned
+	 * with the same value. */
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString(archive_entry_pathname(ae), "dir2/toooldfile");
+	assertEqualInt(archive_entry_mtime(ae), min_time);
+
+	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+	assertEqualInt(19, archive_file_count(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+}
+
+static void
+test_read_format_mtree2(void)
+{
+	static char archive[] =
+	    "#mtree\n"
+	    "d type=dir content=.\n";
+	struct archive_entry *ae;
+	struct archive *a;
+
+	assert((a = archive_read_new()) != NULL);
+	assertEqualIntA(a, ARCHIVE_OK,
+	    archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK,
+	    archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK,
+	    archive_read_open_memory(a, archive, sizeof(archive)));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_MTREE);
+	assertEqualString(archive_entry_pathname(ae), "d");
+	assertEqualInt(archive_entry_filetype(ae), AE_IFDIR);
+	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+	assertEqualInt(1, archive_file_count(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+}
+
+/*
+ * Reported to libarchive.googlecode.com as Issue 121.
+ */
+static void
+test_read_format_mtree3(void)
+{
+	static char archive[] =
+	    "#mtree\n"
+	    "a type=file contents=file\n"
+	    "b type=link link=a\n"
+	    "c type=file contents=file\n";
+	struct archive_entry *ae;
+	struct archive *a;
+
+	assertMakeDir("mtree3", 0777);
+	assertChdir("mtree3");
+	assertMakeFile("file", 0644, "file contents");
+
+	assert((a = archive_read_new()) != NULL);
+	assertEqualIntA(a, ARCHIVE_OK,
+	    archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK,
+	    archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK,
+	    archive_read_open_memory(a, archive, sizeof(archive)));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString(archive_entry_pathname(ae), "a");
+	assertEqualInt(archive_entry_filetype(ae), AE_IFREG);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString(archive_entry_pathname(ae), "b");
+	assertEqualInt(archive_entry_filetype(ae), AE_IFLNK);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString(archive_entry_pathname(ae), "c");
+	assertEqualInt(archive_entry_filetype(ae), AE_IFREG);
+
+	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+	assertEqualInt(3, archive_file_count(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+
+	assertChdir("..");
+}
+
+
+static void
+test_read_format_mtree4(void)
+{
+	const char reffile[] = "test_read_format_mtree_nomagic.mtree";
+	char buff[16];
+	struct archive_entry *ae;
+	struct archive *a;
+	FILE *f;
+
+	assertMakeDir("mtree4", 0777);
+	assertChdir("mtree4");
+
+	extract_reference_file(reffile);
+
+	assert((a = archive_read_new()) != NULL);
+	assertEqualIntA(a, ARCHIVE_OK,
+	    archive_read_support_filter_all(a));
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_read_support_format_all(a));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_file(a, reffile, 11));
@@ -105,82 +297,53 @@
 	assertEqualString(archive_entry_pathname(ae), "notindir");
 
 	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+	assertEqualInt(12, archive_file_count(a));
 	assertEqualInt(ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+
+	assertChdir("..");
 }
 
+/*
+ * We should get a warning if the contents file doesn't exist.
+ */
 static void
-test_read_format_mtree2(void)
+test_read_format_mtree5(void)
 {
 	static char archive[] =
 	    "#mtree\n"
-	    "d type=dir content=.\n";
+	    "a type=file contents=nonexistent_file\n";
 	struct archive_entry *ae;
 	struct archive *a;
 
+	assertMakeDir("mtree5", 0777);
+	assertChdir("mtree5");
+
 	assert((a = archive_read_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK,
-	    archive_read_support_compression_all(a));
+	    archive_read_support_filter_all(a));
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_read_support_format_all(a));
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_read_open_memory(a, archive, sizeof(archive)));
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
-	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_MTREE);
-	assertEqualString(archive_entry_pathname(ae), "d");
-	assertEqualInt(archive_entry_filetype(ae), AE_IFDIR);
-	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
-	assertEqualInt(ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
-}
-
-/*
- * Reported to libarchive.googlecode.com as Issue 121.
- */
-static void
-test_read_format_mtree3(void)
-{
-	static char archive[] =
-	    "#mtree\n"
-	    "a type=file contents=file\n"
-	    "b type=link link=a\n"
-	    "c type=file contents=file\n";
-	struct archive_entry *ae;
-	struct archive *a;
-
-	assertMakeDir("mtree3", 0777);
-	assertChdir("mtree3");
-	assertMakeFile("file", 0644, "file contents");
-
-	assert((a = archive_read_new()) != NULL);
-	assertEqualIntA(a, ARCHIVE_OK,
-	    archive_read_support_compression_all(a));
-	assertEqualIntA(a, ARCHIVE_OK,
-	    archive_read_support_format_all(a));
-	assertEqualIntA(a, ARCHIVE_OK,
-	    archive_read_open_memory(a, archive, sizeof(archive)));
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualIntA(a, ARCHIVE_WARN, archive_read_next_header(a, &ae));
+	assert(strlen(archive_error_string(a)) > 0);
 	assertEqualString(archive_entry_pathname(ae), "a");
 	assertEqualInt(archive_entry_filetype(ae), AE_IFREG);
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
-	assertEqualString(archive_entry_pathname(ae), "b");
-	assertEqualInt(archive_entry_filetype(ae), AE_IFLNK);
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
-	assertEqualString(archive_entry_pathname(ae), "c");
-	assertEqualInt(archive_entry_filetype(ae), AE_IFREG);
 
 	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+	assertEqualInt(1, archive_file_count(a));
 	assertEqualInt(ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	assertChdir("..");
 }
 
-
-
 DEFINE_TEST(test_read_format_mtree)
 {
 	test_read_format_mtree1();
 	test_read_format_mtree2();
 	test_read_format_mtree3();
+	test_read_format_mtree4();
+	test_read_format_mtree5();
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_mtree.mtree.uu
--- a/head/contrib/libarchive/libarchive/test/test_read_format_mtree.mtree.uu	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_mtree.mtree.uu	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,4 @@
-$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_mtree.mtree.uu 228763 2011-12-21 11:13:29Z mm $
-
+$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_mtree.mtree.uu 232153 2012-02-25 10:58:02Z mm $
 begin 644 test_read_format_mtree.mtree
 M(VUT<F5E"F9I;&4@='EP93UF:6QE('5I9#TQ."!M;V1E/3`Q,C,@<VEZ93TS
 M"F1I<B!T>7!E/61I<@H at 9FEL95PP-#!W:71H7#`T,'-P86-E('1Y<&4]9FEL
@@ -8,6 +7,13 @@
 M9FEL90ID:7(R+V9U;&QI;F1I<C(@='EP93UF:6QE(&UO9&4],#<W-PH@("XN
 M"B!I;F1I<C(@='EP93UF:6QE"B!D:7(S8B!T>7!E/61I<@H@(&EN9&ER,V(@
 M='EP93UF:6QE"B`@+BX*("XN"FYO=&EN9&ER('1Y<&4]9FEL90ID:7(R+V9U
-3;&QI;F1I<C(@;6]D93TP-C0T"@``
+M;&QI;F1I<C(@;6]D93TP-C0T"F1I<C(O96UP='EF:6QE('1Y<&4]9FEL92!S
+M:7IE/3!X,`ID:7(R+W-M86QL9FEL92!T>7!E/69I;&4@<VEZ93TP,#`P,#`P
+M,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#$*9&ER,B]T;V]S;6%L;&9I;&4@='EP
+M93UF:6QE('-I>F4]+3$*9&ER,B]B:6=F:6QE('1Y<&4]9FEL92!S:7IE/3DR
+M,C,S-S(P,S8X-30W-S4X,#<*9&ER,B]T;V]B:6=F:6QE('1Y<&4]9FEL92!S
+M:7IE/3DR,C,S-S(P,S8X-30W-S4X,#@*9&ER,B]V97)Y;VQD9FEL92!T>7!E
+M/69I;&4@=&EM93TM.3(R,S,W,C`S-C at U-#<W-3 at P.`ID:7(R+W1O;V]L9&9I
+H;&4@='EP93UF:6QE('1I;64]+3DR,C,S-S(P,S8X-30W-S4X,#D*"@``
 `
 end
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_pax_bz2.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_pax_bz2.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_pax_bz2.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_pax_bz2.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_pax_bz2.c 232153 2012-02-25 10:58:02Z mm $");
 
 static unsigned char archive[] = {
 'B','Z','h','9','1','A','Y','&','S','Y',152,180,30,185,0,0,140,127,176,212,
@@ -47,7 +47,7 @@
 	int r;
 
 	assert((a = archive_read_new()) != NULL);
-	r = archive_read_support_compression_bzip2(a);
+	r = archive_read_support_filter_bzip2(a);
 	if (r != ARCHIVE_OK) {
 		archive_read_close(a);
 		skipping("Bzip2 unavailable");
@@ -57,10 +57,11 @@
 	assertEqualIntA(a,ARCHIVE_OK,
 	    archive_read_open_memory(a, archive, sizeof(archive)));
 	assertEqualIntA(a,ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualInt(1, archive_file_count(a));
 	assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_BZIP2);
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE);
 	assertEqualIntA(a,ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_raw.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_raw.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_raw.c	Fri Mar 02 16:54:40 2012 +0200
@@ -26,7 +26,7 @@
  */
 
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_raw.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_raw.c 232153 2012-02-25 10:58:02Z mm $");
 
 DEFINE_TEST(test_read_format_raw)
 {
@@ -39,14 +39,14 @@
 	/* First, try pulling data out of an uninterpretable file. */
 	extract_reference_file(reffile1);
 	assert((a = archive_read_new()) != NULL);
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_raw(a));
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_read_open_filename(a, reffile1, 512));
 
 	/* First (and only!) Entry */
-	assertA(0 == archive_read_next_header(a, &ae));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
 	assertEqualString("data", archive_entry_pathname(ae));
 	/* Most fields should be unset (unknown) */
 	assert(!archive_entry_size_is_set(ae));
@@ -59,20 +59,20 @@
 	/* Test EOF */
 	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 
 	/* Second, try the same with a compressed file. */
 	extract_reference_file(reffile2);
 	assert((a = archive_read_new()) != NULL);
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_raw(a));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_read_open_filename(a, reffile2, 1));
 
 	/* First (and only!) Entry */
-	assertA(0 == archive_read_next_header(a, &ae));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
 	assertEqualString("data", archive_entry_pathname(ae));
 	/* Most fields should be unset (unknown) */
 	assert(!archive_entry_size_is_set(ae));
@@ -85,5 +85,5 @@
 	/* Test EOF */
 	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_tar.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_tar.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_tar.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_tar.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_tar.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * Each of these archives is a short archive with a single entry.  The
@@ -66,7 +66,7 @@
 	struct archive *a;
 
 	assert((a = archive_read_new()) != NULL);
-	assertA(0 == archive_read_support_compression_all(a));
+	assertA(0 == archive_read_support_filter_all(a));
 	assertA(0 == archive_read_support_format_all(a));
 	assertA(0 == archive_read_open_memory(a, archiveEmpty, 512));
 	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
@@ -75,12 +75,8 @@
 	failure("512 zero bytes should be recognized as a tar archive.");
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR);
 
-	assert(0 == archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assert(0 == archive_read_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 /* Single entry with a hardlink. */
@@ -437,7 +433,7 @@
 	memset(buff + s, 0, 2048);
 
 	assert((a = archive_read_new()) != NULL);
-	assertA(0 == archive_read_support_compression_all(a));
+	assertA(0 == archive_read_support_filter_all(a));
 	assertA(0 == archive_read_support_format_all(a));
 	assertA(0 == archive_read_open_memory(a, buff, s + 1024));
 	assertA(0 == archive_read_next_header(a, &ae));
@@ -447,12 +443,8 @@
 	/* Verify the only entry. */
 	f(ae);
 
-	assert(0 == archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assert(0 == archive_read_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 	free(buff);
 }
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_tar_empty_filename.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_tar_empty_filename.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_tar_empty_filename.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_tar_empty_filename.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_tar_empty_filename.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * Tar entries with empty filenames are unusual, but shouldn't crash us.
@@ -35,7 +35,7 @@
 	struct archive *a;
 
 	assert((a = archive_read_new()) != NULL);
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
 	extract_reference_file(name);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 10240));
@@ -58,9 +58,5 @@
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
 
 	assertEqualInt(ARCHIVE_OK, archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
-#endif
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_tbz.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_tbz.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_tbz.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_tbz.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_tbz.c 232153 2012-02-25 10:58:02Z mm $");
 
 static unsigned char archive[] = {
 'B','Z','h','9','1','A','Y','&','S','Y',237,7,140,'W',0,0,27,251,144,208,
@@ -40,20 +40,21 @@
 	int r;
 
 	assert((a = archive_read_new()) != NULL);
-	r = archive_read_support_compression_bzip2(a);
+	r = archive_read_support_filter_bzip2(a);
 	if (r != ARCHIVE_OK) {
 		skipping("Bzip2 support");
-		archive_read_finish(a);
+		archive_read_free(a);
 		return;
 	}
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_read_open_memory(a, archive, sizeof(archive)));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualInt(1, archive_file_count(a));
 	assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_BZIP2);
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_tgz.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_tgz.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_tgz.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_tgz.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_tgz.c 232153 2012-02-25 10:58:02Z mm $");
 
 static unsigned char archive[] = {
 31,139,8,0,222,'C','p','C',0,3,211,'c',160,'=','0','0','0','0','7','5','U',
@@ -39,22 +39,23 @@
 	int r;
 
 	assert((a = archive_read_new()) != NULL);
-	assertEqualInt(ARCHIVE_OK, archive_read_support_compression_all(a));
-	r = archive_read_support_compression_gzip(a);
+	assertEqualInt(ARCHIVE_OK, archive_read_support_filter_all(a));
+	r = archive_read_support_filter_gzip(a);
 	if (r == ARCHIVE_WARN) {
 		skipping("gzip reading not fully supported on this platform");
-		assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+		assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 		return;
 	}
 	assertEqualInt(ARCHIVE_OK, archive_read_support_format_all(a));
 	assertEqualInt(ARCHIVE_OK,
 	    archive_read_open_memory(a, archive, sizeof(archive)));
 	assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualInt(1, archive_file_count(a));
 	assertEqualInt(archive_compression(a),
 	    ARCHIVE_COMPRESSION_GZIP);
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
 	assertEqualInt(ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK,archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK,archive_read_free(a));
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_tlz.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_tlz.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_tlz.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_tlz.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_tlz.c 232153 2012-02-25 10:58:02Z mm $");
 
 static unsigned char archive[] = {
  93,  0,  0,128,  0,255,255,255,255,255,255,255,255,  0, 23,  0,
@@ -42,19 +42,20 @@
 	int r;
 
 	assert((a = archive_read_new()) != NULL);
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
-	r = archive_read_support_compression_lzma(a);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	r = archive_read_support_filter_lzma(a);
 	if (r == ARCHIVE_WARN) {
 		skipping("lzma reading not fully supported on this platform");
-		assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+		assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 		return;
 	}
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_read_open_memory(a, archive, sizeof(archive)));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualInt(1, archive_file_count(a));
 	assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_LZMA);
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_txz.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_txz.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_txz.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_txz.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_txz.c 232153 2012-02-25 10:58:02Z mm $");
 
 static unsigned char archive[] = {
 253, 55,122, 88, 90,  0,  0,  4,230,214,180, 70,  2,  0, 33,  1,
@@ -45,19 +45,20 @@
 	int r;
 
 	assert((a = archive_read_new()) != NULL);
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
-	r = archive_read_support_compression_xz(a);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	r = archive_read_support_filter_xz(a);
 	if (r == ARCHIVE_WARN) {
 		skipping("xz reading not fully supported on this platform");
-		assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+		assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 		return;
 	}
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_read_open_memory(a, archive, sizeof(archive)));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualInt(1, archive_file_count(a));
 	assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_XZ);
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_tz.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_tz.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_tz.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_tz.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_tz.c 232153 2012-02-25 10:58:02Z mm $");
 
 static unsigned char archive[] = {
 31,157,144,'.',0,8,28,'H',176,160,193,131,8,19,'*','\\',200,176,'!','B',24,
@@ -40,22 +40,19 @@
 	struct archive *a;
 	assert((a = archive_read_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK,
-	    archive_read_support_compression_all(a));
+	    archive_read_support_filter_all(a));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_read_open_memory(a, archive, sizeof(archive)));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualInt(1, archive_file_count(a));
 	failure("archive_compression_name(a)=\"%s\"",
 	    archive_compression_name(a));
 	assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_COMPRESS);
 	failure("archive_format_name(a)=\"%s\"", archive_format_name(a));
 	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
-#endif
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_xar.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_xar.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_xar.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_xar.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_xar.c 232153 2012-02-25 10:58:02Z mm $");
 
 #define UID	1001
 #define UNAME	"cue"
@@ -83,7 +83,7 @@
 {
 	const void *p;
 	size_t size;
-	off_t offset;
+	int64_t offset;
 
 	assert(archive_entry_filetype(ae) == AE_IFREG);
 	assertEqualInt(archive_entry_mode(ae) & 0777, 0644);
@@ -99,7 +99,7 @@
 	assertEqualInt(archive_read_data_block(a, &p, &size, &offset), 0);
 	assertEqualInt((int)size, 16);
 	assertEqualInt((int)offset, 0);
-	assertEqualInt(memcmp(p, "hellohellohello\n", 16), 0);
+	assertEqualMem(p, "hellohellohello\n", 16);
 }
 
 static void verify1(struct archive *a, struct archive_entry *ae)
@@ -634,9 +634,9 @@
 	case BZIP2:
 		/* This is only check whether bzip is supported or not.
 		 * This filter won't be used this test.  */
-		if (ARCHIVE_OK != archive_read_support_compression_bzip2(a)) {
+		if (ARCHIVE_OK != archive_read_support_filter_bzip2(a)) {
 			skipping("Unsupported bzip2");
-			assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+			assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 			return;
 		}
 		break;
@@ -645,11 +645,11 @@
 		 * will return a warning if gzip is unsupported. */
 		break;
 	}
-	assertA(0 == archive_read_support_compression_all(a));
+	assertA(0 == archive_read_support_filter_all(a));
 	r = archive_read_support_format_xar(a);
 	if (r == ARCHIVE_WARN) {
 		skipping("xar reading not fully supported on this platform");
-		assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+		assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 		return;
 	}
 	assert((buff = malloc(100000)) != NULL);
@@ -671,12 +671,15 @@
 		assertEqualInt(archive_format(a), ARCHIVE_FORMAT_XAR);
 		/* Verify the only entry. */
 		f2(a, ae);
+		assertEqualInt(2, archive_file_count(a));
+	} else {
+		assertEqualInt(1, archive_file_count(a));
 	}
 	/* End of archive. */
 	assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae));
 
-	assertA(0 == archive_read_close(a));
-	assertA(0 == archive_read_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 	free(buff);
 }
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_zip.c
--- a/head/contrib/libarchive/libarchive/test/test_read_format_zip.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_zip.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,6 @@
 /*-
  * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2011 Michihiro NAKAJIMA
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -23,70 +24,276 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_zip.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_zip.c 232153 2012-02-25 10:58:02Z mm $");
+
+#ifdef HAVE_LIBZ
+static const int libz_enabled = 1;
+#else
+static const int libz_enabled = 0;
+#endif
 
 /*
  * The reference file for this has been manually tweaked so that:
  *   * file2 has length-at-end but file1 does not
  *   * file2 has an invalid CRC
  */
+static void
+verify_basic(struct archive *a, int seek_checks)
+{
+	struct archive_entry *ae;
+	char *buff[128];
+	const void *pv;
+	size_t s;
+	int64_t o;
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("dir/", archive_entry_pathname(ae));
+	assertEqualInt(1179604249, archive_entry_mtime(ae));
+	assertEqualInt(0, archive_entry_size(ae));
+	if (seek_checks)
+		assertEqualInt(AE_IFDIR | 0755, archive_entry_mode(ae));
+	assertEqualIntA(a, ARCHIVE_EOF,
+	    archive_read_data_block(a, &pv, &s, &o));
+	assertEqualInt((int)s, 0);
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("file1", archive_entry_pathname(ae));
+	assertEqualInt(1179604289, archive_entry_mtime(ae));
+	if (seek_checks)
+		assertEqualInt(AE_IFREG | 0755, archive_entry_mode(ae));
+	assertEqualInt(18, archive_entry_size(ae));
+	failure("archive_read_data() returns number of bytes read");
+	if (libz_enabled) {
+		assertEqualInt(18, archive_read_data(a, buff, 19));
+		assertEqualMem(buff, "hello\nhello\nhello\n", 18);
+	} else {
+		assertEqualInt(ARCHIVE_FAILED, archive_read_data(a, buff, 19));
+		assertEqualString(archive_error_string(a),
+		    "Unsupported ZIP compression method (deflation)");
+		assert(archive_errno(a) != 0);
+	}
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("file2", archive_entry_pathname(ae));
+	assertEqualInt(1179605932, archive_entry_mtime(ae));
+	if (seek_checks) {
+		assertEqualInt(AE_IFREG | 0755, archive_entry_mode(ae));
+		assertEqualInt(64, archive_entry_size_is_set(ae));
+	} else {
+		failure("file2 has length-at-end, so we shouldn't see a valid size when streaming");
+		assertEqualInt(0, archive_entry_size_is_set(ae));
+	}
+	if (libz_enabled) {
+		failure("file2 has a bad CRC, so read should fail and not change buff");
+		memset(buff, 'a', 19);
+		assertEqualInt(ARCHIVE_WARN, archive_read_data(a, buff, 19));
+		assertEqualMem(buff, "aaaaaaaaaaaaaaaaaaa", 19);
+	} else {
+		assertEqualInt(ARCHIVE_FAILED, archive_read_data(a, buff, 19));
+		assertEqualString(archive_error_string(a),
+		    "Unsupported ZIP compression method (deflation)");
+		assert(archive_errno(a) != 0);
+	}
+	assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae));
+	/* Verify the number of files read. */
+	failure("the archive file has three files");
+	assertEqualInt(3, archive_file_count(a));
+	assertEqualIntA(a, ARCHIVE_COMPRESSION_NONE, archive_compression(a));
+	assertEqualIntA(a, ARCHIVE_FORMAT_ZIP, archive_format(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+}
+
+static void
+test_basic(void)
+{
+	const char *refname = "test_read_format_zip.zip";
+	struct archive *a;
+	char *p;
+	size_t s;
+
+	extract_reference_file(refname);
+
+	/* Verify with seeking reader. */
+	assert((a = archive_read_new()) != NULL);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 10240));
+	verify_basic(a, 1);
+
+	/* Verify with streaming reader. */
+	p = slurpfile(&s, refname);
+	assert((a = archive_read_new()) != NULL);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, read_open_memory(a, p, s, 31));
+	verify_basic(a, 0);
+}
+
+/*
+ * Read Info-ZIP New Unix Extra Field 0x7875 "ux".
+ *  Currently stores Unix UID/GID up to 32 bits.
+ */
+static void
+verify_info_zip_ux(struct archive *a, int seek_checks)
+{
+	struct archive_entry *ae;
+	char *buff[128];
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("file1", archive_entry_pathname(ae));
+	assertEqualInt(1300668680, archive_entry_mtime(ae));
+	assertEqualInt(18, archive_entry_size(ae));
+	if (seek_checks)
+		assertEqualInt(AE_IFREG | 0644, archive_entry_mode(ae));
+	failure("zip reader should read Info-ZIP New Unix Extra Field");
+	assertEqualInt(1001, archive_entry_uid(ae));
+	assertEqualInt(1001, archive_entry_gid(ae));
+	if (libz_enabled) {
+		failure("archive_read_data() returns number of bytes read");
+		assertEqualInt(18, archive_read_data(a, buff, 19));
+		assertEqualMem(buff, "hello\nhello\nhello\n", 18);
+	} else {
+		assertEqualInt(ARCHIVE_FAILED, archive_read_data(a, buff, 19));
+		assertEqualString(archive_error_string(a),
+		    "Unsupported ZIP compression method (deflation)");
+		assert(archive_errno(a) != 0);
+	}
+	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+
+	/* Verify the number of files read. */
+	failure("the archive file has just one file");
+	assertEqualInt(1, archive_file_count(a));
+
+	assertEqualIntA(a, ARCHIVE_COMPRESSION_NONE, archive_compression(a));
+	assertEqualIntA(a, ARCHIVE_FORMAT_ZIP, archive_format(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+}
+
+static void
+test_info_zip_ux(void)
+{
+	const char *refname = "test_read_format_zip_ux.zip";
+	struct archive *a;
+	char *p;
+	size_t s;
+
+	extract_reference_file(refname);
+
+	/* Verify with seeking reader. */
+	assert((a = archive_read_new()) != NULL);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 10240));
+	verify_info_zip_ux(a, 1);
+
+	/* Verify with streaming reader. */
+	p = slurpfile(&s, refname);
+	assert((a = archive_read_new()) != NULL);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, read_open_memory(a, p, s, 108));
+	verify_info_zip_ux(a, 0);
+}
+
+/*
+ * Verify that test_read_extract correctly works with
+ * Zip entries that use length-at-end.
+ */
+static void
+verify_extract_length_at_end(struct archive *a, int seek_checks)
+{
+	struct archive_entry *ae;
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+
+	assertEqualString("hello.txt", archive_entry_pathname(ae));
+	if (seek_checks) {
+		assertEqualInt(AE_IFREG | 0644, archive_entry_mode(ae));
+		assert(archive_entry_size_is_set(ae));
+		assertEqualInt(6, archive_entry_size(ae));
+	} else {
+		assert(!archive_entry_size_is_set(ae));
+		assertEqualInt(0, archive_entry_size(ae));
+	}
+
+	if (libz_enabled) {
+		assertEqualIntA(a, ARCHIVE_OK, archive_read_extract(a, ae, 0));
+		assertFileContents("hello\x0A", 6, "hello.txt");
+	} else {
+		assertEqualIntA(a, ARCHIVE_FAILED, archive_read_extract(a, ae, 0));
+		assertEqualString(archive_error_string(a),
+		    "Unsupported ZIP compression method (deflation)");
+		assert(archive_errno(a) != 0);
+	}
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
+}
+
+static void
+test_extract_length_at_end(void)
+{
+	const char *refname = "test_read_format_zip_length_at_end.zip";
+	char *p;
+	size_t s;
+	struct archive *a;
+
+	extract_reference_file(refname);
+
+	/* Verify extraction with seeking reader. */
+	assert((a = archive_read_new()) != NULL);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 10240));
+	verify_extract_length_at_end(a, 1);
+
+	/* Verify extraction with streaming reader. */
+	p = slurpfile(&s, refname);
+	assert((a = archive_read_new()) != NULL);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, read_open_memory(a, p, s, 108));
+	verify_extract_length_at_end(a, 0);
+}
+
+static void
+test_symlink(void)
+{
+	const char *refname = "test_read_format_zip_symlink.zip";
+	char *p;
+	size_t s;
+	struct archive *a;
+	struct archive_entry *ae;
+
+	extract_reference_file(refname);
+	p = slurpfile(&s, refname);
+
+	/* Symlinks can only be extracted with the seeking reader. */
+	assert((a = archive_read_new()) != NULL);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a));
+	assertEqualIntA(a, ARCHIVE_OK, read_open_memory_seek(a, p, s, 1));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("file", archive_entry_pathname(ae));
+	assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualString("symlink", archive_entry_pathname(ae));
+	assertEqualInt(AE_IFLNK, archive_entry_filetype(ae));
+	assertEqualInt(0, archive_entry_size(ae));
+	assertEqualString("file", archive_entry_symlink(ae));
+
+	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
+}
 
 DEFINE_TEST(test_read_format_zip)
 {
-	const char *refname = "test_read_format_zip.zip";
-	struct archive_entry *ae;
-	struct archive *a;
-	char *buff[128];
-	const void *pv;
-	size_t s;
-	off_t o;
-	int r;
-
-	extract_reference_file(refname);
-	assert((a = archive_read_new()) != NULL);
-	assertA(0 == archive_read_support_compression_all(a));
-	assertA(0 == archive_read_support_format_all(a));
-	assertA(0 == archive_read_open_filename(a, refname, 10240));
-	assertA(0 == archive_read_next_header(a, &ae));
-	assertEqualString("dir/", archive_entry_pathname(ae));
-	assertEqualInt(1179604249, archive_entry_mtime(ae));
-	assertEqualInt(0, archive_entry_size(ae));
-	assertEqualIntA(a, ARCHIVE_EOF,
-	    archive_read_data_block(a, &pv, &s, &o));
-	assertEqualInt((int)s, 0);
-	assertA(0 == archive_read_next_header(a, &ae));
-	assertEqualString("file1", archive_entry_pathname(ae));
-	assertEqualInt(1179604289, archive_entry_mtime(ae));
-	assertEqualInt(18, archive_entry_size(ae));
-	failure("archive_read_data() returns number of bytes read");
-	r = archive_read_data(a, buff, 19);
-	if (r < ARCHIVE_OK) {
-		if (strcmp(archive_error_string(a),
-		    "libarchive compiled without deflate support (no libz)") == 0) {
-			skipping("Skipping ZIP compression check: %s",
-			    archive_error_string(a));
-			goto finish;
-		}
-	}
-	assertEqualInt(18, r);
-	assert(0 == memcmp(buff, "hello\nhello\nhello\n", 18));
-	assertA(0 == archive_read_next_header(a, &ae));
-	assertEqualString("file2", archive_entry_pathname(ae));
-	assertEqualInt(1179605932, archive_entry_mtime(ae));
-	failure("file2 has length-at-end, so we shouldn't see a valid size");
-	assertEqualInt(0, archive_entry_size_is_set(ae));
-	failure("file2 has a bad CRC, so reading to end should fail");
-	assertEqualInt(ARCHIVE_WARN, archive_read_data(a, buff, 19));
-	assert(0 == memcmp(buff, "hello\nhello\nhello\n", 18));
-	assertA(archive_compression(a) == ARCHIVE_COMPRESSION_NONE);
-	assertA(archive_format(a) == ARCHIVE_FORMAT_ZIP);
-	assert(0 == archive_read_close(a));
-finish:
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assert(0 == archive_read_finish(a));
-#endif
+	test_basic();
+	test_info_zip_ux();
+	test_extract_length_at_end();
+	test_symlink();
 }
-
-
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_format_zip.zip.uu
--- a/head/contrib/libarchive/libarchive/test/test_read_format_zip.zip.uu	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_format_zip.zip.uu	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_zip.zip.uu 228763 2011-12-21 11:13:29Z mm $
+$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_format_zip.zip.uu 232153 2012-02-25 10:58:02Z mm $
 begin 644 test_read_format_zip.zip
 M4$L#!`H`"````%EFLS8````````````````$`!4`9&ER+U54"0`#&55/1M19
 M_4A5>`0`Z`/H`U!+!P@```````````````!02P,$%`````@`;V:S-CHW9CT*
@@ -8,7 +8,7 @@
 M"@`(````66:S-@````````````````0`#0`````````0`.U!`````&1I<B]5
 M5`4``QE53T95>```4$L!`A<#%``(``@`;V:S-CHW9CT*````$@````4`#0``
 M`````0```.V!1P```&9I;&4Q550%``-!54]&57@``%!+`0(7`Q0`"``(`%IJ
-MLS8Z-V8]"@```!(````%``T```````$```#M at 8D```!F:6QE,E54!0`#K%M/
+MLS9X>'AX"@```!(````%``T```````$```#M at 8D```!F:6QE,E54!0`#K%M/
 ;1E5X``!02P4&``````,``P"_````VP``````
 `
 end
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_large.c
--- a/head/contrib/libarchive/libarchive/test/test_read_large.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_large.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_large.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_large.c 232153 2012-02-25 10:58:02Z mm $");
 
 static unsigned char testdata[10 * 1024 * 1024];
 static unsigned char testdatacopy[10 * 1024 * 1024];
@@ -58,21 +58,22 @@
 	assertA(0 == archive_write_header(a, entry));
 	archive_entry_free(entry);
 	assertA((int)sizeof(testdata) == archive_write_data(a, testdata, sizeof(testdata)));
-	assertA(0 == archive_write_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	assert(NULL != (a = archive_read_new()));
 	assertA(0 == archive_read_support_format_all(a));
-	assertA(0 == archive_read_support_compression_all(a));
+	assertA(0 == archive_read_support_filter_all(a));
 	assertA(0 == archive_read_open_memory(a, buff, sizeof(buff)));
 	assertA(0 == archive_read_next_header(a, &entry));
-	assertA(0 == archive_read_data_into_buffer(a, testdatacopy, sizeof(testdatacopy)));
-	assertA(0 == archive_read_finish(a));
-	assert(0 == memcmp(testdata, testdatacopy, sizeof(testdata)));
+	assertEqualIntA(a, sizeof(testdatacopy),
+	    archive_read_data(a, testdatacopy, sizeof(testdatacopy)));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+	assertEqualMem(testdata, testdatacopy, sizeof(testdata));
 
 
 	assert(NULL != (a = archive_read_new()));
 	assertA(0 == archive_read_support_format_all(a));
-	assertA(0 == archive_read_support_compression_all(a));
+	assertA(0 == archive_read_support_filter_all(a));
 	assertA(0 == archive_read_open_memory(a, buff, sizeof(buff)));
 	assertA(0 == archive_read_next_header(a, &entry));
 #if defined(__BORLANDC__)
@@ -83,11 +84,11 @@
 	assert(0 < tmpfilefd);
 	assertA(0 == archive_read_data_into_fd(a, tmpfilefd));
 	close(tmpfilefd);
-	assertA(0 == archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	f = fopen(tmpfilename, "rb");
 	assertEqualInt(sizeof(testdatacopy),
 	    fread(testdatacopy, 1, sizeof(testdatacopy), f));
 	fclose(f);
-	assert(0 == memcmp(testdata, testdatacopy, sizeof(testdata)));
+	assertEqualMem(testdata, testdatacopy, sizeof(testdata));
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_pax_truncated.c
--- a/head/contrib/libarchive/libarchive/test/test_read_pax_truncated.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_pax_truncated.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_pax_truncated.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_pax_truncated.c 232153 2012-02-25 10:58:02Z mm $");
 
 DEFINE_TEST(test_read_pax_truncated)
 {
@@ -37,8 +37,8 @@
 
 	/* Create a new archive in memory. */
 	assert((a = archive_write_new()) != NULL);
-	assertA(0 == archive_write_set_format_pax(a));
-	assertA(0 == archive_write_set_compression_none(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_pax(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_none(a));
 	assertEqualIntA(a, ARCHIVE_OK,
 			archive_write_open_memory(a, buff, buff_size, &used));
 
@@ -54,27 +54,30 @@
 	archive_entry_set_ctime(ae, 3, 4);
 	archive_entry_set_mtime(ae, 5, 6);
 	archive_entry_set_size(ae, filedata_size);
-	assertA(0 == archive_write_header(a, ae));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
 	archive_entry_free(ae);
-	assertA((ssize_t)filedata_size
-	    == archive_write_data(a, filedata, filedata_size));
+	assertEqualIntA(a, (int)filedata_size, 
+	    (int)archive_write_data(a, filedata, filedata_size));
 
 	/* Close out the archive. */
-	assertA(0 == archive_write_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_write_finish(a);
-#else
-	assertA(0 == archive_write_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/* Now, read back a truncated version of the archive and
 	 * verify that we get an appropriate error. */
 	for (i = 1; i < used + 100; i += 100) {
 		assert((a = archive_read_new()) != NULL);
-		assertA(0 == archive_read_support_format_all(a));
-		assertA(0 == archive_read_support_compression_all(a));
-		assertA(0 == read_open_memory2(a, buff, i, 13));
+		assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+		assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+		/* If it's truncated very early, the file type detection should fail. */
+		if (i < 512) {
+			assertEqualIntA(a, ARCHIVE_FATAL, read_open_memory2(a, buff, i, 13));
+			goto wrap_up;
+		} else {
+			assertEqualIntA(a, ARCHIVE_OK, read_open_memory2(a, buff, i, 13));
+		}
 
+		/* If it's truncated in a header, the header read should fail. */
 		if (i < 1536) {
 			assertEqualIntA(a, ARCHIVE_FATAL, archive_read_next_header(a, &ae));
 			goto wrap_up;
@@ -83,8 +86,9 @@
 			assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
 		}
 
+		/* If it's truncated in the body, the body read should fail. */
 		if (i < 1536 + filedata_size) {
-			assertA(ARCHIVE_FATAL == archive_read_data(a, filedata, filedata_size));
+			assertEqualIntA(a, ARCHIVE_FATAL, archive_read_data(a, filedata, filedata_size));
 			goto wrap_up;
 		} else {
 			failure("Archive truncated to %d bytes", i);
@@ -108,12 +112,8 @@
 			    archive_read_next_header(a, &ae));
 		}
 	wrap_up:
-		assert(0 == archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-		archive_read_finish(a);
-#else
-		assert(0 == archive_read_finish(a));
-#endif
+		assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+		assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 	}
 
 
@@ -121,22 +121,28 @@
 	/* Same as above, except skip the body instead of reading it. */
 	for (i = 1; i < used + 100; i += 100) {
 		assert((a = archive_read_new()) != NULL);
-		assertA(0 == archive_read_support_format_all(a));
-		assertA(0 == archive_read_support_compression_all(a));
-		assertA(0 == read_open_memory(a, buff, i, 7));
+		assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+		assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+		/* If it's truncated very early, file type detection should fail. */
+		if (i < 512) {
+			assertEqualIntA(a, ARCHIVE_FATAL, read_open_memory(a, buff, i, 7));
+			goto wrap_up2;
+		} else {
+			assertEqualIntA(a, ARCHIVE_OK, read_open_memory(a, buff, i, 7));
+		}
 
 		if (i < 1536) {
-			assertA(ARCHIVE_FATAL == archive_read_next_header(a, &ae));
+			assertEqualIntA(a, ARCHIVE_FATAL, archive_read_next_header(a, &ae));
 			goto wrap_up2;
 		} else {
 			assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
 		}
 
 		if (i < 1536 + 512*((filedata_size+511)/512)) {
-			assertA(ARCHIVE_FATAL == archive_read_data_skip(a));
+			assertEqualIntA(a, ARCHIVE_FATAL, archive_read_data_skip(a));
 			goto wrap_up2;
 		} else {
-			assertA(ARCHIVE_OK == archive_read_data_skip(a));
+			assertEqualIntA(a, ARCHIVE_OK, archive_read_data_skip(a));
 		}
 
 		/* Verify the end of the archive. */
@@ -153,12 +159,8 @@
 			    archive_read_next_header(a, &ae));
 		}
 	wrap_up2:
-		assert(0 == archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-		archive_read_finish(a);
-#else
-		assert(0 == archive_read_finish(a));
-#endif
+		assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+		assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 	}
 
 	/* Now, damage the archive in various ways and test the responses. */
@@ -169,31 +171,23 @@
 	buff2[513] = '9';
 	buff2[514] = 'A'; /* Non-digit in size. */
 	assert((a = archive_read_new()) != NULL);
-	assertA(0 == archive_read_support_format_all(a));
-	assertA(0 == archive_read_support_compression_all(a));
-	assertA(0 == archive_read_open_memory(a, buff2, used));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff2, used));
 	assertEqualIntA(a, ARCHIVE_WARN, archive_read_next_header(a, &ae));
-	assert(0 == archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assert(0 == archive_read_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	/* Damage the size field in the pax attributes. */
 	memcpy(buff2, buff, buff_size);
 	buff2[512] = 'A'; /* First character not a digit. */
 	assert((a = archive_read_new()) != NULL);
-	assertA(0 == archive_read_support_format_all(a));
-	assertA(0 == archive_read_support_compression_all(a));
-	assertA(0 == archive_read_open_memory(a, buff2, used));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff2, used));
 	assertEqualIntA(a, ARCHIVE_WARN, archive_read_next_header(a, &ae));
-	assert(0 == archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assert(0 == archive_read_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	/* Damage the size field in the pax attributes. */
 	memcpy(buff2, buff, buff_size);
@@ -201,16 +195,12 @@
 		buff2[i] = '9';
 	buff2[i] = ' ';
 	assert((a = archive_read_new()) != NULL);
-	assertA(0 == archive_read_support_format_all(a));
-	assertA(0 == archive_read_support_compression_all(a));
-	assertA(0 == archive_read_open_memory(a, buff2, used));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff2, used));
 	assertEqualIntA(a, ARCHIVE_WARN, archive_read_next_header(a, &ae));
-	assert(0 == archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assert(0 == archive_read_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	/* Damage the size field in the pax attributes. */
 	memcpy(buff2, buff, buff_size);
@@ -219,62 +209,46 @@
 	buff2[514] = '9';
 	buff2[515] = ' ';
 	assert((a = archive_read_new()) != NULL);
-	assertA(0 == archive_read_support_format_all(a));
-	assertA(0 == archive_read_support_compression_all(a));
-	assertA(0 == archive_read_open_memory(a, buff2, used));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff2, used));
 	assertEqualIntA(a, ARCHIVE_WARN, archive_read_next_header(a, &ae));
-	assert(0 == archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assert(0 == archive_read_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	/* Damage the size field in the pax attributes. */
 	memcpy(buff2, buff, buff_size);
 	buff2[512] = '1'; /* Too small. */
 	buff2[513] = ' ';
 	assert((a = archive_read_new()) != NULL);
-	assertA(0 == archive_read_support_format_all(a));
-	assertA(0 == archive_read_support_compression_all(a));
-	assertA(0 == archive_read_open_memory(a, buff2, used));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff2, used));
 	assertEqualIntA(a, ARCHIVE_WARN, archive_read_next_header(a, &ae));
-	assert(0 == archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assert(0 == archive_read_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	/* Damage the size field in the pax attributes. */
 	memcpy(buff2, buff, buff_size);
 	buff2[512] = ' '; /* No size given. */
 	assert((a = archive_read_new()) != NULL);
-	assertA(0 == archive_read_support_format_all(a));
-	assertA(0 == archive_read_support_compression_all(a));
-	assertA(0 == archive_read_open_memory(a, buff2, used));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff2, used));
 	assertEqualIntA(a, ARCHIVE_WARN, archive_read_next_header(a, &ae));
-	assert(0 == archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assert(0 == archive_read_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	/* Damage the ustar header. */
 	memcpy(buff2, buff, buff_size);
 	buff2[1024]++; /* Break the checksum. */
 	assert((a = archive_read_new()) != NULL);
-	assertA(0 == archive_read_support_format_all(a));
-	assertA(0 == archive_read_support_compression_all(a));
-	assertA(0 == archive_read_open_memory(a, buff2, used));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff2, used));
 	assertEqualIntA(a, ARCHIVE_FATAL, archive_read_next_header(a, &ae));
-	assert(0 == archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assert(0 == archive_read_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	/*
 	 * TODO: Damage the ustar header in various ways and fixup the
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_position.c
--- a/head/contrib/libarchive/libarchive/test/test_read_position.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_position.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,10 +23,46 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_position.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_position.c 232153 2012-02-25 10:58:02Z mm $");
 
-static unsigned char nulls[10000];
-static unsigned char  buff[10000000];
+static unsigned char nulls[1000];
+static unsigned char tmp[1000];
+static unsigned char  buff[10000];
+size_t data_sizes[] = {0, 5, 511, 512, 513};
+
+static void verify_read_positions(struct archive *a);
+
+static void
+verify_read_positions(struct archive *a)
+{
+	struct archive_entry *ae;
+	intmax_t read_position = 0;
+	size_t j;
+
+	/* Initial header position is zero. */
+	assert(read_position == (intmax_t)archive_read_header_position(a));
+	for (j = 0; j < sizeof(data_sizes)/sizeof(data_sizes[0]); ++j) {
+		assertA(0 == archive_read_next_header(a, &ae));
+		assertEqualInt(read_position,
+		    (intmax_t)archive_read_header_position(a));
+		/* Every other entry: read, then skip */
+		if (j & 1)
+			assertEqualInt(1,
+			    archive_read_data(a, tmp, 1));
+		assertA(0 == archive_read_data_skip(a));
+		/* read_data_skip() doesn't change header_position */
+		assertEqualInt(read_position,
+		    (intmax_t)archive_read_header_position(a));
+
+		read_position += 512; /* Size of header. */
+		read_position += (data_sizes[j] + 511) & ~511;
+	}
+
+	assertA(1 == archive_read_next_header(a, &ae));
+	assertEqualInt(read_position, (intmax_t)archive_read_header_position(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(read_position, (intmax_t)archive_read_header_position(a));
+}
 
 /* Check that header_position tracks correctly on read. */
 DEFINE_TEST(test_read_position)
@@ -34,9 +70,7 @@
 	struct archive *a;
 	struct archive_entry *ae;
 	size_t write_pos;
-	intmax_t read_position;
-	size_t i, j;
-	size_t data_sizes[] = {0, 5, 511, 512, 513};
+	size_t i;
 
 	/* Sanity test */
 	assert(sizeof(nulls) + 512 + 1024 <= sizeof(buff));
@@ -58,37 +92,21 @@
 		assertA(data_sizes[i]
 		    == (size_t)archive_write_data(a, nulls, sizeof(nulls)));
 	}
-	assertA(0 == archive_write_close(a));
-	assertA(0 == archive_write_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
-	/* Read the archive back. */
+	/* Read the archive back with a skip function. */
 	assert(NULL != (a = archive_read_new()));
 	assertA(0 == archive_read_support_format_tar(a));
-	assertA(0 == archive_read_open_memory2(a, buff, sizeof(buff), 512));
+	assertA(0 == read_open_memory(a, buff, sizeof(buff), 512));
+	verify_read_positions(a);
+	archive_read_free(a);
 
-	read_position = 0;
-	/* Initial header position is zero. */
-	assert(read_position == (intmax_t)archive_read_header_position(a));
-	for (j = 0; j < i; ++j) {
-		assertA(0 == archive_read_next_header(a, &ae));
-		assert(read_position
-		    == (intmax_t)archive_read_header_position(a));
-		/* Every other entry: read, then skip */
-		if (j & 1)
-			assertEqualInt(ARCHIVE_OK,
-			    archive_read_data_into_buffer(a, buff, 1));
-		assertA(0 == archive_read_data_skip(a));
-		/* read_data_skip() doesn't change header_position */
-		assert(read_position
-		    == (intmax_t)archive_read_header_position(a));
+	/* Read the archive back without a skip function. */
+	assert(NULL != (a = archive_read_new()));
+	assertA(0 == archive_read_support_format_tar(a));
+	assertA(0 == read_open_memory2(a, buff, sizeof(buff), 512));
+	verify_read_positions(a);
+	archive_read_free(a);
 
-		read_position += 512; /* Size of header. */
-		read_position += (data_sizes[j] + 511) & ~511;
-	}
-
-	assertA(1 == archive_read_next_header(a, &ae));
-	assert(read_position == (intmax_t)archive_read_header_position(a));
-	assertA(0 == archive_read_close(a));
-	assert(read_position == (intmax_t)archive_read_header_position(a));
-	archive_read_finish(a);
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_truncated.c
--- a/head/contrib/libarchive/libarchive/test/test_read_truncated.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_truncated.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_truncated.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_truncated.c 232153 2012-02-25 10:58:02Z mm $");
 
 char buff[1000000];
 char buff2[100000];
@@ -37,9 +37,9 @@
 
 	/* Create a new archive in memory. */
 	assert((a = archive_write_new()) != NULL);
-	assertA(0 == archive_write_set_format_ustar(a));
-	assertA(0 == archive_write_set_compression_none(a));
-	assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_none(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, sizeof(buff), &used));
 
 	/*
 	 * Write a file to it.
@@ -50,38 +50,33 @@
 	for (i = 0; i < sizeof(buff2); i++)
 		buff2[i] = (unsigned char)rand();
 	archive_entry_set_size(ae, sizeof(buff2));
-	assertA(0 == archive_write_header(a, ae));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
 	archive_entry_free(ae);
-	assertA((int)sizeof(buff2) == archive_write_data(a, buff2, sizeof(buff2)));
+	assertEqualIntA(a, sizeof(buff2), archive_write_data(a, buff2, sizeof(buff2)));
 
 	/* Close out the archive. */
-	assertA(0 == archive_write_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_write_finish(a);
-#else
-	assertA(0 == archive_write_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/* Now, read back a truncated version of the archive and
 	 * verify that we get an appropriate error. */
 	for (i = 1; i < used + 100; i += 100) {
 		assert((a = archive_read_new()) != NULL);
-		assertA(0 == archive_read_support_format_all(a));
-		assertA(0 == archive_read_support_compression_all(a));
-		assertA(0 == archive_read_open_memory(a, buff, i));
-
+		assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+		assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
 		if (i < 512) {
-			assertA(ARCHIVE_FATAL == archive_read_next_header(a, &ae));
+			assertEqualIntA(a, ARCHIVE_FATAL, archive_read_open_memory(a, buff, i));
 			goto wrap_up;
 		} else {
-			assertA(0 == archive_read_next_header(a, &ae));
+			assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff, i));
 		}
+		assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
 
 		if (i < 512 + sizeof(buff2)) {
-			assertA(ARCHIVE_FATAL == archive_read_data(a, buff2, sizeof(buff2)));
+			assertEqualIntA(a, ARCHIVE_FATAL, archive_read_data(a, buff2, sizeof(buff2)));
 			goto wrap_up;
 		} else {
-			assertA((int)sizeof(buff2) == archive_read_data(a, buff2, sizeof(buff2)));
+			assertEqualIntA(a, sizeof(buff2), archive_read_data(a, buff2, sizeof(buff2)));
 		}
 
 		/* Verify the end of the archive. */
@@ -91,17 +86,13 @@
 		 * does not return an error if it can't consume
 		 * it.) */
 		if (i < 512 + 512*((sizeof(buff2) + 511)/512) + 512) {
-			assertA(ARCHIVE_FATAL == archive_read_next_header(a, &ae));
+			assertEqualIntA(a, ARCHIVE_FATAL, archive_read_next_header(a, &ae));
 		} else {
-			assertA(ARCHIVE_EOF == archive_read_next_header(a, &ae));
+			assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
 		}
 	wrap_up:
-		assert(0 == archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-		archive_read_finish(a);
-#else
-		assert(0 == archive_read_finish(a));
-#endif
+		assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+		assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 	}
 
 
@@ -109,22 +100,21 @@
 	/* Same as above, except skip the body instead of reading it. */
 	for (i = 1; i < used + 100; i += 100) {
 		assert((a = archive_read_new()) != NULL);
-		assertA(0 == archive_read_support_format_all(a));
-		assertA(0 == archive_read_support_compression_all(a));
-		assertA(0 == archive_read_open_memory(a, buff, i));
-
+		assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+		assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
 		if (i < 512) {
-			assertA(ARCHIVE_FATAL == archive_read_next_header(a, &ae));
+			assertEqualIntA(a, ARCHIVE_FATAL, archive_read_open_memory(a, buff, i));
 			goto wrap_up2;
 		} else {
-			assertA(0 == archive_read_next_header(a, &ae));
+			assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff, i));
 		}
+		assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
 
 		if (i < 512 + 512*((sizeof(buff2)+511)/512)) {
-			assertA(ARCHIVE_FATAL == archive_read_data_skip(a));
+			assertEqualIntA(a, ARCHIVE_FATAL, archive_read_data_skip(a));
 			goto wrap_up2;
 		} else {
-			assertA(ARCHIVE_OK == archive_read_data_skip(a));
+			assertEqualIntA(a, ARCHIVE_OK, archive_read_data_skip(a));
 		}
 
 		/* Verify the end of the archive. */
@@ -134,16 +124,12 @@
 		 * does not return an error if it can't consume
 		 * it.) */
 		if (i < 512 + 512*((sizeof(buff2) + 511)/512) + 512) {
-			assertA(ARCHIVE_FATAL == archive_read_next_header(a, &ae));
+			assertEqualIntA(a, ARCHIVE_FATAL, archive_read_next_header(a, &ae));
 		} else {
-			assertA(ARCHIVE_EOF == archive_read_next_header(a, &ae));
+			assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
 		}
 	wrap_up2:
-		assert(0 == archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-		archive_read_finish(a);
-#else
-		assert(0 == archive_read_finish(a));
-#endif
+		assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+		assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 	}
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_read_uu.c
--- a/head/contrib/libarchive/libarchive/test/test_read_uu.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_read_uu.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,6 +1,6 @@
 /*-
  * Copyright (c) 2003-2007 Tim Kientzle
- * Copyright (c) 2009 Michihiro NAKAJIMA
+ * Copyright (c) 2009-2011 Michihiro NAKAJIMA
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -24,7 +24,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_uu.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_read_uu.c 232153 2012-02-25 10:58:02Z mm $");
 
 static const char archive[] = {
 "begin 644 test_read_uu.Z\n"
@@ -70,29 +70,43 @@
 };
 
 static void
-test_read_uu_sub(const char *uudata, size_t uusize)
+test_read_uu_sub(const char *uudata, size_t uusize, int no_nl)
 {
 	struct archive_entry *ae;
 	struct archive *a;
 	char *buff;
+	char extradata_no_nl[sizeof(extradata)];
+	const char *extradata_ptr;
 	int extra;
+	size_t size;
 
-	assert(NULL != (buff = malloc(uusize + 64 * 1024)));
+	if (no_nl) {
+		/* Remove '\n' from extra data to make a very long line. */
+		char *p;
+		memcpy(extradata_no_nl, extradata, sizeof(extradata));
+		extradata_ptr = extradata_no_nl;
+		for (p = extradata_no_nl;
+		    *p && (p = strchr(p, '\n')) != NULL; p++)
+			*p = ' ';/* Replace '\n' with ' ' a space character. */
+	} else
+		extradata_ptr = extradata;
+
+	assert(NULL != (buff = malloc(uusize + 1024 * 1024)));
 	if (buff == NULL)
 		return;
 	for (extra = 0; extra <= 64; extra = extra==0?1:extra*2) {
-		size_t size = extra * 1024;
 		char *p = buff;
 
+		size = extra * 1024;
 		/* Add extra text size of which is from 1K bytes to
 		 * 64Kbytes before uuencoded data. */
 		while (size) {
 			if (size > sizeof(extradata)-1) {
-				memcpy(p, extradata, sizeof(extradata)-1);
+				memcpy(p, extradata_ptr, sizeof(extradata)-1);
 				p += sizeof(extradata)-1;
 				size -= sizeof(extradata)-1;
 			} else {
-				memcpy(p, extradata, size-1);
+				memcpy(p, extradata_ptr, size-1);
 				p += size-1;
 				*p++ = '\n';/* the last of extra text must have
 					     * '\n' character. */
@@ -104,31 +118,58 @@
 
 		assert((a = archive_read_new()) != NULL);
 		assertEqualIntA(a, ARCHIVE_OK,
-		    archive_read_support_compression_all(a));
+		    archive_read_support_filter_all(a));
 		assertEqualIntA(a, ARCHIVE_OK,
 		    archive_read_support_format_all(a));
 		assertEqualIntA(a, ARCHIVE_OK,
 		    read_open_memory(a, buff, size, 2));
 		assertEqualIntA(a, ARCHIVE_OK,
 		    archive_read_next_header(a, &ae));
-		failure("archive_compression_name(a)=\"%s\"",
-		    archive_compression_name(a));
+		failure("archive_compression_name(a)=\"%s\""
+		    "extra %d, NL %d",
+		    archive_compression_name(a), extra, !no_nl);
 		assertEqualInt(archive_compression(a),
 		    ARCHIVE_COMPRESSION_COMPRESS);
-		failure("archive_format_name(a)=\"%s\"",
-		    archive_format_name(a));
-		assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
+		failure("archive_format_name(a)=\"%s\""
+		    "extra %d, NL %d",
+		    archive_format_name(a), extra, !no_nl);
+		assertEqualInt(archive_format(a),
+		    ARCHIVE_FORMAT_TAR_USTAR);
 		assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
-		assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+		assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 	}
+
+	/* UUdecode bidder shouldn't scan too much data; make sure it
+	 * fails if we put 512k of data before the start. */
+	size = 512 * 1024;
+	for (extra = 0; (size_t)extra < size; ++extra)
+		buff[extra + 1024] = buff[extra];
+	buff[size - 1] = '\n';
+	memcpy(buff + size, uudata, uusize);
+	size += uusize;
+	assert((a = archive_read_new()) != NULL);
+	assertEqualIntA(a, ARCHIVE_OK,
+	    archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK,
+	    archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_FATAL,
+	    read_open_memory(a, buff, size, 2));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+
 	free(buff);
 }
 
 DEFINE_TEST(test_read_uu)
 {
 	/* Read the traditional uuencoded data. */
-	test_read_uu_sub(archive, sizeof(archive)-1);
+	test_read_uu_sub(archive, sizeof(archive)-1, 0);
 	/* Read the Base64 uuencoded data. */
-	test_read_uu_sub(archive64, sizeof(archive64)-1);
+	test_read_uu_sub(archive64, sizeof(archive64)-1, 0);
+	/* Read the traditional uuencoded data with very long line extra
+	 * data in front of it. */
+	test_read_uu_sub(archive, sizeof(archive)-1, 1);
+	/* Read the Base64 uuencoded data with very long line extra data
+	 * in front of it. */
+	test_read_uu_sub(archive64, sizeof(archive64)-1, 1);
 }
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_tar_filenames.c
--- a/head/contrib/libarchive/libarchive/test/test_tar_filenames.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_tar_filenames.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_tar_filenames.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_tar_filenames.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * Exercise various lengths of filenames in tar archives,
@@ -100,28 +100,20 @@
 	archive_entry_free(ae);
 
 	/* Close out the archive. */
-	assertA(0 == archive_write_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_write_finish(a);
-#else
-	assertA(0 == archive_write_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/*
 	 * Now, read the data back.
 	 */
 	assert((a = archive_read_new()) != NULL);
 	assertA(0 == archive_read_support_format_all(a));
-	assertA(0 == archive_read_support_compression_all(a));
+	assertA(0 == archive_read_support_filter_all(a));
 	assertA(0 == archive_read_open_memory(a, buff, used));
 
 	/* Read the file and check the filename. */
 	assertA(0 == archive_read_next_header(a, &ae));
-#if ARCHIVE_VERSION_NUMBER < 1009000
-	skipping("Leading '/' preserved on long filenames");
-#else
 	assertEqualString(filename, archive_entry_pathname(ae));
-#endif
 	assertEqualInt((S_IFREG | 0755), archive_entry_mode(ae));
 
 	/*
@@ -133,29 +125,17 @@
 	 * here.
 	 */
 	assertA(0 == archive_read_next_header(a, &ae));
-#if ARCHIVE_VERSION_NUMBER < 1009000
-	skipping("Trailing '/' preserved on dirnames");
-#else
 	assertEqualString(dirname, archive_entry_pathname(ae));
-#endif
 	assert((S_IFDIR | 0755) == archive_entry_mode(ae));
 
 	assertA(0 == archive_read_next_header(a, &ae));
-#if ARCHIVE_VERSION_NUMBER < 1009000
-	skipping("Trailing '/' added to dir names");
-#else
 	assertEqualString(dirname, archive_entry_pathname(ae));
-#endif
 	assert((S_IFDIR | 0755) == archive_entry_mode(ae));
 
 	/* Verify the end of the archive. */
 	assert(1 == archive_read_next_header(a, &ae));
-	assert(0 == archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assert(0 == archive_read_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 DEFINE_TEST(test_tar_filenames)
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_tar_large.c
--- a/head/contrib/libarchive/libarchive/test/test_tar_large.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_tar_large.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_tar_large.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_tar_large.c 232153 2012-02-25 10:58:02Z mm $");
 
 #include <errno.h>
 #include <stdlib.h>
@@ -73,11 +73,7 @@
 #define GB ((int64_t)1024 * MB)
 #define TB ((int64_t)1024 * GB)
 
-#if ARCHIVE_VERSION_NUMBER < 2000000
-static ssize_t	memory_read_skip(struct archive *, void *, size_t request);
-#else
-static off_t	memory_read_skip(struct archive *, void *, off_t request);
-#endif
+static int64_t	memory_read_skip(struct archive *, void *, int64_t request);
 static ssize_t	memory_read(struct archive *, void *, const void **buff);
 static ssize_t	memory_write(struct archive *, void *, const void *, size_t);
 
@@ -167,18 +163,8 @@
 }
 
 
-#if ARCHIVE_VERSION_NUMBER < 2000000
-static ssize_t
-memory_read_skip(struct archive *a, void *private, size_t skip)
-{
-	(void)a;  /* UNUSED */
-	(void)private; /* UNUSED */
-	(void)skip; /* UNUSED */
-	return (0);
-}
-#else
-static off_t
-memory_read_skip(struct archive *a, void *_private, off_t skip)
+static int64_t
+memory_read_skip(struct archive *a, void *_private, int64_t skip)
 {
 	struct memdata *private = _private;
 
@@ -197,7 +183,6 @@
 	}
 	return (skip);
 }
-#endif
 
 DEFINE_TEST(test_tar_large)
 {
@@ -270,12 +255,8 @@
 
 
 	/* Close out the archive. */
-	assertA(0 == archive_write_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_write_finish(a);
-#else
-	assertA(0 == archive_write_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/*
 	 * Open the same archive for reading.
@@ -300,12 +281,8 @@
 	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
 
 	/* Close out the archive. */
-	assertA(0 == archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assertA(0 == archive_read_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	free(memdata.buff);
 	free(filedata);
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_ustar_filenames.c
--- a/head/contrib/libarchive/libarchive/test/test_ustar_filenames.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_ustar_filenames.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_ustar_filenames.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_ustar_filenames.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * Exercise various lengths of filenames in ustar archives.
@@ -110,19 +110,15 @@
 	archive_entry_free(ae);
 
 	/* Close out the archive. */
-	assertA(0 == archive_write_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_write_finish(a);
-#else
-	assertEqualInt(0, archive_write_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/*
 	 * Now, read the data back.
 	 */
 	assert((a = archive_read_new()) != NULL);
 	assertA(0 == archive_read_support_format_all(a));
-	assertA(0 == archive_read_support_compression_all(a));
+	assertA(0 == archive_read_support_filter_all(a));
 	assertA(0 == archive_read_open_memory(a, buff, used));
 
 	if (flen <= 100) {
@@ -156,12 +152,8 @@
 	/* Verify the end of the archive. */
 	failure("This fails if entries were written that should not have been written.  dlen=%d, flen=%d", dlen, flen);
 	assertEqualInt(1, archive_read_next_header(a, &ae));
-	assert(0 == archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assertEqualInt(0, archive_read_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 DEFINE_TEST(test_ustar_filenames)
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_write_compress.c
--- a/head/contrib/libarchive/libarchive/test/test_write_compress.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_write_compress.c	Fri Mar 02 16:54:40 2012 +0200
@@ -25,7 +25,7 @@
  */
 
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_compress.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_compress.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * A basic exercise of compress reading and writing.
@@ -51,9 +51,12 @@
 	memset(data, 0, datasize);
 
 	assert((a = archive_write_new()) != NULL);
-	assertA(0 == archive_write_set_format_ustar(a));
-	assertA(0 == archive_write_set_compression_compress(a));
-	assertA(0 == archive_write_open_memory(a, buff, buffsize, &used));
+	assertEqualIntA(a, ARCHIVE_OK,
+	    archive_write_set_format_ustar(a));
+	assertEqualIntA(a, ARCHIVE_OK,
+	    archive_write_set_compression_compress(a));
+	assertEqualIntA(a, ARCHIVE_OK,
+	    archive_write_open_memory(a, buff, buffsize, &used));
 
 	for (i = 0; i < 100; i++) {
 		sprintf(path, "file%03d", i);
@@ -61,26 +64,22 @@
 		archive_entry_copy_pathname(ae, path);
 		archive_entry_set_size(ae, datasize);
 		archive_entry_set_filetype(ae, AE_IFREG);
-		assertA(0 == archive_write_header(a, ae));
-		assertA(datasize == (size_t)archive_write_data(a, data, datasize));
+		assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
+		assertEqualInt(datasize,
+		    archive_write_data(a, data, datasize));
 		archive_entry_free(ae);
 	}
 
-
-	archive_write_close(a);
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_write_finish(a);
-#else
-	assert(0 == archive_write_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/*
 	 * Now, read the data back.
 	 */
 	assert((a = archive_read_new()) != NULL);
-	assertA(0 == archive_read_support_format_all(a));
-	assertA(0 == archive_read_support_compression_all(a));
-	assertA(0 == archive_read_open_memory(a, buff, used));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff, used));
 
 
 	for (i = 0; i < 100; i++) {
@@ -90,12 +89,8 @@
 		assertEqualString(path, archive_entry_pathname(ae));
 		assertEqualInt((int)datasize, archive_entry_size(ae));
 	}
-	assert(0 == archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assert(0 == archive_read_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	free(data);
 	free(buff);
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_write_compress_bzip2.c
--- a/head/contrib/libarchive/libarchive/test/test_write_compress_bzip2.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_write_compress_bzip2.c	Fri Mar 02 16:54:40 2012 +0200
@@ -25,7 +25,7 @@
  */
 
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_compress_bzip2.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_compress_bzip2.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * A basic exercise of bzip2 reading and writing.
@@ -54,18 +54,18 @@
 	 * Write a 100 files and read them all back.
 	 */
 	assert((a = archive_write_new()) != NULL);
-	assertA(0 == archive_write_set_format_ustar(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
 	r = archive_write_set_compression_bzip2(a);
 	if (r == ARCHIVE_FATAL) {
 		skipping("bzip2 writing not supported on this platform");
-		assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+		assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 		return;
 	}
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_write_set_bytes_per_block(a, 10));
 	assertEqualInt(ARCHIVE_COMPRESSION_BZIP2, archive_compression(a));
 	assertEqualString("bzip2", archive_compression_name(a));
-	assertA(0 == archive_write_open_memory(a, buff, buffsize, &used1));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used1));
 	assertEqualInt(ARCHIVE_COMPRESSION_BZIP2, archive_compression(a));
 	assertEqualString("bzip2", archive_compression_name(a));
 	assert((ae = archive_entry_new()) != NULL);
@@ -74,18 +74,18 @@
 	for (i = 0; i < 999; i++) {
 		sprintf(path, "file%03d", i);
 		archive_entry_copy_pathname(ae, path);
-		assertA(0 == archive_write_header(a, ae));
+		assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
 		assertA(datasize
 		    == (size_t)archive_write_data(a, data, datasize));
 	}
 	archive_entry_free(ae);
-	archive_write_close(a);
-	assert(0 == archive_write_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	assert((a = archive_read_new()) != NULL);
-	assertA(0 == archive_read_support_format_all(a));
-	assertA(0 == archive_read_support_compression_all(a));
-	assertA(0 == archive_read_open_memory(a, buff, used1));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff, used1));
 	for (i = 0; i < 999; i++) {
 		sprintf(path, "file%03d", i);
 		if (!assertEqualInt(0, archive_read_next_header(a, &ae)))
@@ -93,39 +93,39 @@
 		assertEqualString(path, archive_entry_pathname(ae));
 		assertEqualInt((int)datasize, archive_entry_size(ae));
 	}
-	assert(0 == archive_read_close(a));
-	assert(0 == archive_read_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	/*
 	 * Repeat the cycle again, this time setting some compression
 	 * options.
 	 */
 	assert((a = archive_write_new()) != NULL);
-	assertA(0 == archive_write_set_format_ustar(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_write_set_bytes_per_block(a, 10));
-	assertA(0 == archive_write_set_compression_bzip2(a));
-	assertEqualIntA(a, ARCHIVE_WARN,
-	    archive_write_set_compressor_options(a, "nonexistent-option=0"));
-	assertEqualIntA(a, ARCHIVE_WARN,
-	    archive_write_set_compressor_options(a, "compression-level=abc"));
-	assertEqualIntA(a, ARCHIVE_WARN,
-	    archive_write_set_compressor_options(a, "compression-level=99"));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_bzip2(a));
+	assertEqualIntA(a, ARCHIVE_FAILED,
+	    archive_write_set_filter_option(a, NULL, "nonexistent-option", "0"));
+	assertEqualIntA(a, ARCHIVE_FAILED,
+	    archive_write_set_filter_option(a, NULL, "compression-level", "abc"));
+	assertEqualIntA(a, ARCHIVE_FAILED,
+	    archive_write_set_filter_option(a, NULL, "compression-level", "99"));
 	assertEqualIntA(a, ARCHIVE_OK,
-	    archive_write_set_compressor_options(a, "compression-level=9"));
-	assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2));
+	    archive_write_set_filter_option(a, NULL, "compression-level", "9"));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used2));
 	for (i = 0; i < 999; i++) {
 		sprintf(path, "file%03d", i);
 		assert((ae = archive_entry_new()) != NULL);
 		archive_entry_copy_pathname(ae, path);
 		archive_entry_set_size(ae, datasize);
 		archive_entry_set_filetype(ae, AE_IFREG);
-		assertA(0 == archive_write_header(a, ae));
+		assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
 		assertA(datasize == (size_t)archive_write_data(a, data, datasize));
 		archive_entry_free(ae);
 	}
-	archive_write_close(a);
-	assert(0 == archive_write_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/* Curiously, this test fails; the test data above compresses
 	 * better at default compression than at level 9. */
@@ -136,9 +136,9 @@
 	*/
 
 	assert((a = archive_read_new()) != NULL);
-	assertA(0 == archive_read_support_format_all(a));
-	assertA(0 == archive_read_support_compression_all(a));
-	assertA(0 == archive_read_open_memory(a, buff, used2));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff, used2));
 	for (i = 0; i < 999; i++) {
 		sprintf(path, "file%03d", i);
 		if (!assertEqualInt(0, archive_read_next_header(a, &ae)))
@@ -146,34 +146,34 @@
 		assertEqualString(path, archive_entry_pathname(ae));
 		assertEqualInt((int)datasize, archive_entry_size(ae));
 	}
-	assert(0 == archive_read_close(a));
-	assert(0 == archive_read_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	/*
 	 * Repeat again, with much lower compression.
 	 */
 	assert((a = archive_write_new()) != NULL);
-	assertA(0 == archive_write_set_format_ustar(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_write_set_bytes_per_block(a, 10));
-	assertA(0 == archive_write_set_compression_bzip2(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_bzip2(a));
 	assertEqualIntA(a, ARCHIVE_OK,
-	    archive_write_set_compressor_options(a, "compression-level=1"));
-	assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2));
+	    archive_write_set_filter_option(a, NULL, "compression-level", "1"));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used2));
 	for (i = 0; i < 999; i++) {
 		sprintf(path, "file%03d", i);
 		assert((ae = archive_entry_new()) != NULL);
 		archive_entry_copy_pathname(ae, path);
 		archive_entry_set_size(ae, datasize);
 		archive_entry_set_filetype(ae, AE_IFREG);
-		assertA(0 == archive_write_header(a, ae));
+		assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
 		failure("Writing file %s", path);
 		assertEqualIntA(a, datasize,
 		    (size_t)archive_write_data(a, data, datasize));
 		archive_entry_free(ae);
 	}
-	archive_write_close(a);
-	assert(0 == archive_write_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/* Level 0 really does result in larger data. */
 	failure("Compression-level=0 wrote %d bytes; default wrote %d bytes",
@@ -181,9 +181,9 @@
 	assert(used2 > used1);
 
 	assert((a = archive_read_new()) != NULL);
-	assertA(0 == archive_read_support_format_all(a));
-	assertA(0 == archive_read_support_compression_all(a));
-	assertA(0 == archive_read_open_memory(a, buff, used2));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff, used2));
 	for (i = 0; i < 999; i++) {
 		sprintf(path, "file%03d", i);
 		if (!assertEqualInt(0, archive_read_next_header(a, &ae)))
@@ -191,8 +191,8 @@
 		assertEqualString(path, archive_entry_pathname(ae));
 		assertEqualInt((int)datasize, archive_entry_size(ae));
 	}
-	assert(0 == archive_read_close(a));
-	assert(0 == archive_read_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	/*
 	 * Test various premature shutdown scenarios to make sure we
@@ -200,25 +200,25 @@
 	 */
 	assert((a = archive_write_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_bzip2(a));
-	assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	assert((a = archive_write_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_bzip2(a));
 	assertEqualInt(ARCHIVE_OK, archive_write_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	assert((a = archive_write_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_bzip2(a));
 	assertEqualInt(ARCHIVE_OK, archive_write_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	assert((a = archive_write_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_bzip2(a));
-	assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used2));
 	assertEqualInt(ARCHIVE_OK, archive_write_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/*
 	 * Clean up.
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_write_compress_gzip.c
--- a/head/contrib/libarchive/libarchive/test/test_write_compress_gzip.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_write_compress_gzip.c	Fri Mar 02 16:54:40 2012 +0200
@@ -25,7 +25,7 @@
  */
 
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_compress_gzip.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_compress_gzip.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * A basic exercise of gzip reading and writing.
@@ -54,18 +54,20 @@
 	 * Write a 100 files and read them all back.
 	 */
 	assert((a = archive_write_new()) != NULL);
-	assertA(0 == archive_write_set_format_ustar(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
+	assertEqualIntA(a, ARCHIVE_OK,
+	    archive_write_set_compression_compress(a));
 	r = archive_write_set_compression_gzip(a);
 	if (r == ARCHIVE_FATAL) {
 		skipping("gzip writing not supported on this platform");
-		assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+		assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 		return;
 	}
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_write_set_bytes_per_block(a, 10));
 	assertEqualInt(ARCHIVE_COMPRESSION_GZIP, archive_compression(a));
 	assertEqualString("gzip", archive_compression_name(a));
-	assertA(0 == archive_write_open_memory(a, buff, buffsize, &used1));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used1));
 	assertEqualInt(ARCHIVE_COMPRESSION_GZIP, archive_compression(a));
 	assertEqualString("gzip", archive_compression_name(a));
 	assert((ae = archive_entry_new()) != NULL);
@@ -74,24 +76,22 @@
 	for (i = 0; i < 100; i++) {
 		sprintf(path, "file%03d", i);
 		archive_entry_copy_pathname(ae, path);
-		assertA(0 == archive_write_header(a, ae));
+		assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
 		assertA(datasize
 		    == (size_t)archive_write_data(a, data, datasize));
 	}
 	archive_entry_free(ae);
-	archive_write_close(a);
-	assert(0 == archive_write_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	assert((a = archive_read_new()) != NULL);
-	assertA(0 == archive_read_support_format_all(a));
-	r = archive_read_support_compression_gzip(a);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	r = archive_read_support_filter_gzip(a);
 	if (r == ARCHIVE_WARN) {
 		skipping("Can't verify gzip writing by reading back;"
 		    " gzip reading not fully supported on this platform");
 	} else {
 		assertEqualIntA(a, ARCHIVE_OK,
-		    archive_read_support_compression_all(a));
-		assertEqualIntA(a, ARCHIVE_OK,
 		    archive_read_open_memory(a, buff, used1));
 		for (i = 0; i < 100; i++) {
 			sprintf(path, "file%03d", i);
@@ -103,38 +103,42 @@
 		}
 		assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
 	}
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	/*
 	 * Repeat the cycle again, this time setting some compression
 	 * options.
 	 */
 	assert((a = archive_write_new()) != NULL);
-	assertA(0 == archive_write_set_format_ustar(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_write_set_bytes_per_block(a, 10));
-	assertA(0 == archive_write_set_compression_gzip(a));
-	assertEqualIntA(a, ARCHIVE_WARN,
-	    archive_write_set_compressor_options(a, "nonexistent-option=0"));
-	assertEqualIntA(a, ARCHIVE_WARN,
-	    archive_write_set_compressor_options(a, "compression-level=abc"));
-	assertEqualIntA(a, ARCHIVE_WARN,
-	    archive_write_set_compressor_options(a, "compression-level=99"));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_gzip(a));
+	assertEqualIntA(a, ARCHIVE_FAILED,
+	    archive_write_set_options(a, "gzip:nonexistent-option=0"));
 	assertEqualIntA(a, ARCHIVE_OK,
-	    archive_write_set_compressor_options(a, "compression-level=9"));
-	assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2));
+	    archive_write_set_options(a, "gzip:compression-level=0"));
+	assertEqualIntA(a, ARCHIVE_OK,
+	    archive_write_set_filter_option(a, NULL, "compression-level", "9"));
+	assertEqualIntA(a, ARCHIVE_FAILED,
+	    archive_write_set_filter_option(a, NULL, "compression-level", "abc"));
+	assertEqualIntA(a, ARCHIVE_FAILED,
+	    archive_write_set_filter_option(a, NULL, "compression-level", "99"));
+	assertEqualIntA(a, ARCHIVE_OK,
+	    archive_write_set_options(a, "gzip:compression-level=9"));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used2));
 	for (i = 0; i < 100; i++) {
 		sprintf(path, "file%03d", i);
 		assert((ae = archive_entry_new()) != NULL);
 		archive_entry_copy_pathname(ae, path);
 		archive_entry_set_size(ae, datasize);
 		archive_entry_set_filetype(ae, AE_IFREG);
-		assertA(0 == archive_write_header(a, ae));
+		assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
 		assertA(datasize == (size_t)archive_write_data(a, data, datasize));
 		archive_entry_free(ae);
 	}
-	archive_write_close(a);
-	assert(0 == archive_write_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/* Curiously, this test fails; the test data above compresses
 	 * better at default compression than at level 9. */
@@ -146,12 +150,12 @@
 
 	assert((a = archive_read_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
-	r = archive_read_support_compression_gzip(a);
+	r = archive_read_support_filter_gzip(a);
 	if (r == ARCHIVE_WARN) {
 		skipping("gzip reading not fully supported on this platform");
 	} else {
 		assertEqualIntA(a, ARCHIVE_OK,
-		    archive_read_support_compression_all(a));
+		    archive_read_support_filter_all(a));
 		assertEqualIntA(a, ARCHIVE_OK,
 		    archive_read_open_memory(a, buff, used2));
 		for (i = 0; i < 100; i++) {
@@ -164,33 +168,33 @@
 		}
 		assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
 	}
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	/*
 	 * Repeat again, with much lower compression.
 	 */
 	assert((a = archive_write_new()) != NULL);
-	assertA(0 == archive_write_set_format_ustar(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_write_set_bytes_per_block(a, 10));
-	assertA(0 == archive_write_set_compression_gzip(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_gzip(a));
 	assertEqualIntA(a, ARCHIVE_OK,
-	    archive_write_set_compressor_options(a, "compression-level=0"));
-	assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2));
+	    archive_write_set_filter_option(a, NULL, "compression-level", "0"));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used2));
 	for (i = 0; i < 100; i++) {
 		sprintf(path, "file%03d", i);
 		assert((ae = archive_entry_new()) != NULL);
 		archive_entry_copy_pathname(ae, path);
 		archive_entry_set_size(ae, datasize);
 		archive_entry_set_filetype(ae, AE_IFREG);
-		assertA(0 == archive_write_header(a, ae));
+		assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
 		failure("Writing file %s", path);
 		assertEqualIntA(a, datasize,
 		    (size_t)archive_write_data(a, data, datasize));
 		archive_entry_free(ae);
 	}
-	archive_write_close(a);
-	assert(0 == archive_write_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/* Level 0 really does result in larger data. */
 	failure("Compression-level=0 wrote %d bytes; default wrote %d bytes",
@@ -198,9 +202,9 @@
 	assert(used2 > used1);
 
 	assert((a = archive_read_new()) != NULL);
-	assertA(0 == archive_read_support_format_all(a));
-	assertA(0 == archive_read_support_compression_all(a));
-	r = archive_read_support_compression_gzip(a);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	r = archive_read_support_filter_gzip(a);
 	if (r == ARCHIVE_WARN) {
 		skipping("gzip reading not fully supported on this platform");
 	} else {
@@ -216,7 +220,7 @@
 		}
 		assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
 	}
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	/*
 	 * Test various premature shutdown scenarios to make sure we
@@ -224,25 +228,25 @@
 	 */
 	assert((a = archive_write_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_gzip(a));
-	assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	assert((a = archive_write_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_gzip(a));
 	assertEqualInt(ARCHIVE_OK, archive_write_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	assert((a = archive_write_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_gzip(a));
 	assertEqualInt(ARCHIVE_OK, archive_write_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	assert((a = archive_write_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_gzip(a));
-	assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used2));
 	assertEqualInt(ARCHIVE_OK, archive_write_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/*
 	 * Clean up.
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_write_compress_lzma.c
--- a/head/contrib/libarchive/libarchive/test/test_write_compress_lzma.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_write_compress_lzma.c	Fri Mar 02 16:54:40 2012 +0200
@@ -25,7 +25,7 @@
  */
 
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_compress_lzma.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_compress_lzma.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * A basic exercise of lzma reading and writing.
@@ -53,18 +53,19 @@
 	 * Write a 100 files and read them all back.
 	 */
 	assert((a = archive_write_new()) != NULL);
-	assertA(0 == archive_write_set_format_ustar(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
 	r = archive_write_set_compression_lzma(a);
 	if (r == ARCHIVE_FATAL) {
 		skipping("lzma writing not supported on this platform");
-		assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+		assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 		return;
 	}
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_write_set_bytes_per_block(a, 10));
 	assertEqualInt(ARCHIVE_COMPRESSION_LZMA, archive_compression(a));
 	assertEqualString("lzma", archive_compression_name(a));
-	assertA(0 == archive_write_open_memory(a, buff, buffsize, &used1));
+	assertEqualIntA(a, ARCHIVE_OK,
+	    archive_write_open_memory(a, buff, buffsize, &used1));
 	assertEqualInt(ARCHIVE_COMPRESSION_LZMA, archive_compression(a));
 	assertEqualString("lzma", archive_compression_name(a));
 	assert((ae = archive_entry_new()) != NULL);
@@ -73,23 +74,23 @@
 	for (i = 0; i < 100; i++) {
 		sprintf(path, "file%03d", i);
 		archive_entry_copy_pathname(ae, path);
-		assertA(0 == archive_write_header(a, ae));
+		assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
 		assertA(datasize
 		    == (size_t)archive_write_data(a, data, datasize));
 	}
 	archive_entry_free(ae);
-	archive_write_close(a);
-	assert(0 == archive_write_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	assert((a = archive_read_new()) != NULL);
-	assertA(0 == archive_read_support_format_all(a));
-	r = archive_read_support_compression_lzma(a);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	r = archive_read_support_filter_lzma(a);
 	if (r == ARCHIVE_WARN) {
 		skipping("Can't verify lzma writing by reading back;"
 		    " lzma reading not fully supported on this platform");
 	} else {
 		assertEqualIntA(a, ARCHIVE_OK,
-		    archive_read_support_compression_all(a));
+		    archive_read_support_filter_all(a));
 		assertEqualIntA(a, ARCHIVE_OK,
 		    archive_read_open_memory(a, buff, used1));
 		for (i = 0; i < 100; i++) {
@@ -102,48 +103,48 @@
 		}
 		assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
 	}
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	/*
 	 * Repeat the cycle again, this time setting some compression
 	 * options.
 	 */
 	assert((a = archive_write_new()) != NULL);
-	assertA(0 == archive_write_set_format_ustar(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_write_set_bytes_per_block(a, 10));
-	assertA(0 == archive_write_set_compression_lzma(a));
-	assertEqualIntA(a, ARCHIVE_WARN,
-	    archive_write_set_compressor_options(a, "nonexistent-option=0"));
-	assertEqualIntA(a, ARCHIVE_WARN,
-	    archive_write_set_compressor_options(a, "compression-level=abc"));
-	assertEqualIntA(a, ARCHIVE_WARN,
-	    archive_write_set_compressor_options(a, "compression-level=99"));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_lzma(a));
+	assertEqualIntA(a, ARCHIVE_FAILED,
+	    archive_write_set_filter_option(a, NULL, "nonexistent-option", "0"));
+	assertEqualIntA(a, ARCHIVE_FAILED,
+	    archive_write_set_filter_option(a, NULL, "compression-level", "abc"));
+	assertEqualIntA(a, ARCHIVE_FAILED,
+	    archive_write_set_filter_option(a, NULL, "compression-level", "99"));
 	assertEqualIntA(a, ARCHIVE_OK,
-	    archive_write_set_compressor_options(a, "compression-level=9"));
-	assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2));
+	    archive_write_set_filter_option(a, NULL, "compression-level", "9"));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used2));
 	for (i = 0; i < 100; i++) {
 		sprintf(path, "file%03d", i);
 		assert((ae = archive_entry_new()) != NULL);
 		archive_entry_copy_pathname(ae, path);
 		archive_entry_set_size(ae, datasize);
 		archive_entry_set_filetype(ae, AE_IFREG);
-		assertA(0 == archive_write_header(a, ae));
+		assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
 		assertA(datasize == (size_t)archive_write_data(a, data, datasize));
 		archive_entry_free(ae);
 	}
-	archive_write_close(a);
-	assert(0 == archive_write_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 
 	assert((a = archive_read_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
-	r = archive_read_support_compression_lzma(a);
+	r = archive_read_support_filter_lzma(a);
 	if (r == ARCHIVE_WARN) {
 		skipping("lzma reading not fully supported on this platform");
 	} else {
 		assertEqualIntA(a, ARCHIVE_OK,
-		    archive_read_support_compression_all(a));
+		    archive_read_support_filter_all(a));
 		assertEqualIntA(a, ARCHIVE_OK,
 		    archive_read_open_memory(a, buff, used2));
 		for (i = 0; i < 100; i++) {
@@ -157,33 +158,33 @@
 		}
 		assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
 	}
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	/*
 	 * Repeat again, with much lower compression.
 	 */
 	assert((a = archive_write_new()) != NULL);
-	assertA(0 == archive_write_set_format_ustar(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_write_set_bytes_per_block(a, 10));
-	assertA(0 == archive_write_set_compression_lzma(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_lzma(a));
 	assertEqualIntA(a, ARCHIVE_OK,
-	    archive_write_set_compressor_options(a, "compression-level=0"));
-	assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2));
+	    archive_write_set_filter_option(a, NULL, "compression-level", "0"));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used2));
 	for (i = 0; i < 100; i++) {
 		sprintf(path, "file%03d", i);
 		assert((ae = archive_entry_new()) != NULL);
 		archive_entry_copy_pathname(ae, path);
 		archive_entry_set_size(ae, datasize);
 		archive_entry_set_filetype(ae, AE_IFREG);
-		assertA(0 == archive_write_header(a, ae));
+		assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
 		failure("Writing file %s", path);
 		assertEqualIntA(a, datasize,
 		    (size_t)archive_write_data(a, data, datasize));
 		archive_entry_free(ae);
 	}
-	archive_write_close(a);
-	assert(0 == archive_write_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/* It would be nice to assert that compression-level=0 produced
 	 * consistently larger/smaller results than the default compression,
@@ -196,9 +197,9 @@
 	*/
 
 	assert((a = archive_read_new()) != NULL);
-	assertA(0 == archive_read_support_format_all(a));
-	assertA(0 == archive_read_support_compression_all(a));
-	r = archive_read_support_compression_lzma(a);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	r = archive_read_support_filter_lzma(a);
 	if (r == ARCHIVE_WARN) {
 		skipping("lzma reading not fully supported on this platform");
 	} else {
@@ -214,7 +215,7 @@
 		}
 		assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
 	}
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	/*
 	 * Test various premature shutdown scenarios to make sure we
@@ -222,25 +223,25 @@
 	 */
 	assert((a = archive_write_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_lzma(a));
-	assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	assert((a = archive_write_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_lzma(a));
 	assertEqualInt(ARCHIVE_OK, archive_write_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	assert((a = archive_write_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_lzma(a));
 	assertEqualInt(ARCHIVE_OK, archive_write_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	assert((a = archive_write_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_lzma(a));
-	assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used2));
 	assertEqualInt(ARCHIVE_OK, archive_write_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/*
 	 * Clean up.
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_write_compress_program.c
--- a/head/contrib/libarchive/libarchive/test/test_write_compress_program.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_write_compress_program.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,16 +23,13 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_compress_program.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_compress_program.c 232153 2012-02-25 10:58:02Z mm $");
 
 char buff[1000000];
 char buff2[64];
 
 DEFINE_TEST(test_write_compress_program)
 {
-#if ARCHIVE_VERSION_NUMBER < 1009000
-	skipping("archive_write_set_compress_program()");
-#else
 	struct archive_entry *ae;
 	struct archive *a;
 	size_t used;
@@ -43,6 +40,15 @@
 		skipping("Cannot run 'gzip'");
 		return;
 	}
+	/* NOTE: Setting blocksize=1024 will cause gunzip failure because
+	 * it add extra bytes that gunzip ignores with its warning and
+	 * exit code 1. So we should set blocksize=1 in order not to
+	 * yield the extra bytes when using gunzip. */
+	assert((a = archive_read_new()) != NULL);
+	r = archive_read_support_filter_gzip(a);
+	if (r != ARCHIVE_OK && canGunzip())
+		blocksize = 1;
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	/* Create a new archive in memory. */
 	/* Write it through an external "gzip" program. */
@@ -52,7 +58,7 @@
 	if (r == ARCHIVE_FATAL) {
 		skipping("Write compression via external "
 		    "program unsupported on this platform");
-		archive_write_finish(a);
+		archive_write_free(a);
 		return;
 	}
 	assertA(0 == archive_write_set_bytes_per_block(a, blocksize));
@@ -75,29 +81,29 @@
 	assertA(8 == archive_write_data(a, "12345678", 9));
 
 	/* Close out the archive. */
-	assertA(0 == archive_write_close(a));
-	assertA(0 == archive_write_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/*
 	 * Now, read the data back through the built-in gzip support.
 	 */
 	assert((a = archive_read_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
-	r = archive_read_support_compression_gzip(a);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	r = archive_read_support_filter_gzip(a);
 	/* The compression_gzip() handler will fall back to gunzip
 	 * automatically, but if we know gunzip isn't available, then
 	 * skip the rest. */
 	if (r != ARCHIVE_OK && !canGunzip()) {
 		skipping("No libz and no gunzip program, "
 		    "unable to verify gzip compression");
-		assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+		assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 		return;
 	}
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff, used));
 
 	if (!assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae))) {
-		archive_read_finish(a);
+		archive_read_free(a);
 		return;
 	}
 
@@ -113,6 +119,5 @@
 	/* Verify the end of the archive. */
 	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
-#endif
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_write_compress_xz.c
--- a/head/contrib/libarchive/libarchive/test/test_write_compress_xz.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_write_compress_xz.c	Fri Mar 02 16:54:40 2012 +0200
@@ -25,7 +25,7 @@
  */
 
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_compress_xz.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_compress_xz.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * A basic exercise of xz reading and writing.
@@ -54,18 +54,18 @@
 	 * Write a 100 files and read them all back.
 	 */
 	assert((a = archive_write_new()) != NULL);
-	assertA(0 == archive_write_set_format_ustar(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
 	r = archive_write_set_compression_xz(a);
 	if (r == ARCHIVE_FATAL) {
 		skipping("xz writing not supported on this platform");
-		assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+		assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 		return;
 	}
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_write_set_bytes_per_block(a, 10));
 	assertEqualInt(ARCHIVE_COMPRESSION_XZ, archive_compression(a));
 	assertEqualString("xz", archive_compression_name(a));
-	assertA(0 == archive_write_open_memory(a, buff, buffsize, &used1));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used1));
 	assertEqualInt(ARCHIVE_COMPRESSION_XZ, archive_compression(a));
 	assertEqualString("xz", archive_compression_name(a));
 	assert((ae = archive_entry_new()) != NULL);
@@ -74,23 +74,23 @@
 	for (i = 0; i < 100; i++) {
 		sprintf(path, "file%03d", i);
 		archive_entry_copy_pathname(ae, path);
-		assertA(0 == archive_write_header(a, ae));
+		assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
 		assertA(datasize
 		    == (size_t)archive_write_data(a, data, datasize));
 	}
 	archive_entry_free(ae);
-	archive_write_close(a);
-	assert(0 == archive_write_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	assert((a = archive_read_new()) != NULL);
-	assertA(0 == archive_read_support_format_all(a));
-	r = archive_read_support_compression_xz(a);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	r = archive_read_support_filter_xz(a);
 	if (r == ARCHIVE_WARN) {
 		skipping("Can't verify xz writing by reading back;"
 		    " xz reading not fully supported on this platform");
 	} else {
 		assertEqualIntA(a, ARCHIVE_OK,
-		    archive_read_support_compression_all(a));
+		    archive_read_support_filter_all(a));
 		assertEqualIntA(a, ARCHIVE_OK,
 		    archive_read_open_memory(a, buff, used1));
 		for (i = 0; i < 100; i++) {
@@ -103,38 +103,38 @@
 		}
 		assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
 	}
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	/*
 	 * Repeat the cycle again, this time setting some compression
 	 * options.
 	 */
 	assert((a = archive_write_new()) != NULL);
-	assertA(0 == archive_write_set_format_ustar(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_write_set_bytes_per_block(a, 10));
-	assertA(0 == archive_write_set_compression_xz(a));
-	assertEqualIntA(a, ARCHIVE_WARN,
-	    archive_write_set_compressor_options(a, "nonexistent-option=0"));
-	assertEqualIntA(a, ARCHIVE_WARN,
-	    archive_write_set_compressor_options(a, "compression-level=abc"));
-	assertEqualIntA(a, ARCHIVE_WARN,
-	    archive_write_set_compressor_options(a, "compression-level=99"));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_xz(a));
+	assertEqualIntA(a, ARCHIVE_FAILED,
+	    archive_write_set_filter_option(a, NULL, "nonexistent-option", "0"));
+	assertEqualIntA(a, ARCHIVE_FAILED,
+	    archive_write_set_filter_option(a, NULL, "compression-level", "abc"));
+	assertEqualIntA(a, ARCHIVE_FAILED,
+	    archive_write_set_filter_option(a, NULL, "compression-level", "99"));
 	assertEqualIntA(a, ARCHIVE_OK,
-	    archive_write_set_compressor_options(a, "compression-level=9"));
-	assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2));
+	    archive_write_set_filter_option(a, NULL, "compression-level", "9"));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used2));
 	for (i = 0; i < 100; i++) {
 		sprintf(path, "file%03d", i);
 		assert((ae = archive_entry_new()) != NULL);
 		archive_entry_copy_pathname(ae, path);
 		archive_entry_set_size(ae, datasize);
 		archive_entry_set_filetype(ae, AE_IFREG);
-		assertA(0 == archive_write_header(a, ae));
+		assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
 		assertA(datasize == (size_t)archive_write_data(a, data, datasize));
 		archive_entry_free(ae);
 	}
-	archive_write_close(a);
-	assert(0 == archive_write_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/* Curiously, this test fails; the test data above compresses
 	 * better at default compression than at level 9. */
@@ -146,12 +146,12 @@
 
 	assert((a = archive_read_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
-	r = archive_read_support_compression_xz(a);
+	r = archive_read_support_filter_xz(a);
 	if (r == ARCHIVE_WARN) {
 		skipping("xz reading not fully supported on this platform");
 	} else {
 		assertEqualIntA(a, ARCHIVE_OK,
-		    archive_read_support_compression_all(a));
+		    archive_read_support_filter_all(a));
 		assertEqualIntA(a, ARCHIVE_OK,
 		    archive_read_open_memory(a, buff, used2));
 		for (i = 0; i < 100; i++) {
@@ -165,33 +165,33 @@
 		}
 		assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
 	}
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	/*
 	 * Repeat again, with much lower compression.
 	 */
 	assert((a = archive_write_new()) != NULL);
-	assertA(0 == archive_write_set_format_ustar(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_write_set_bytes_per_block(a, 10));
-	assertA(0 == archive_write_set_compression_xz(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_xz(a));
 	assertEqualIntA(a, ARCHIVE_OK,
-	    archive_write_set_compressor_options(a, "compression-level=0"));
-	assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2));
+	    archive_write_set_filter_option(a, NULL, "compression-level", "0"));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used2));
 	for (i = 0; i < 100; i++) {
 		sprintf(path, "file%03d", i);
 		assert((ae = archive_entry_new()) != NULL);
 		archive_entry_copy_pathname(ae, path);
 		archive_entry_set_size(ae, datasize);
 		archive_entry_set_filetype(ae, AE_IFREG);
-		assertA(0 == archive_write_header(a, ae));
+		assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
 		failure("Writing file %s", path);
 		assertEqualIntA(a, datasize,
 		    (size_t)archive_write_data(a, data, datasize));
 		archive_entry_free(ae);
 	}
-	archive_write_close(a);
-	assert(0 == archive_write_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/* I would like to assert that compression-level=0 results in
 	 * larger data than the default compression, but that's not true
@@ -203,9 +203,9 @@
 	*/
 
 	assert((a = archive_read_new()) != NULL);
-	assertA(0 == archive_read_support_format_all(a));
-	assertA(0 == archive_read_support_compression_all(a));
-	r = archive_read_support_compression_xz(a);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	r = archive_read_support_filter_xz(a);
 	if (r == ARCHIVE_WARN) {
 		skipping("xz reading not fully supported on this platform");
 	} else {
@@ -221,7 +221,7 @@
 		}
 		assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
 	}
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	/*
 	 * Test various premature shutdown scenarios to make sure we
@@ -229,25 +229,25 @@
 	 */
 	assert((a = archive_write_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_xz(a));
-	assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	assert((a = archive_write_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_xz(a));
 	assertEqualInt(ARCHIVE_OK, archive_write_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	assert((a = archive_write_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_xz(a));
 	assertEqualInt(ARCHIVE_OK, archive_write_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	assert((a = archive_write_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_xz(a));
-	assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used2));
 	assertEqualInt(ARCHIVE_OK, archive_write_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/*
 	 * Clean up.
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_write_disk.c
--- a/head/contrib/libarchive/libarchive/test/test_write_disk.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_write_disk.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,9 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_disk.c 228763 2011-12-21 11:13:29Z mm $");
-
-#if ARCHIVE_VERSION_NUMBER >= 1009000
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_disk.c 232153 2012-02-25 10:58:02Z mm $");
 
 #define UMASK 022
 /*
@@ -47,11 +45,8 @@
 	failure("%s", msg);
 	assertEqualIntA(ad, 0, archive_write_header(ad, ae));
 	assertEqualIntA(ad, 0, archive_write_finish_entry(ad));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_write_finish(ad);
-#else
-	assertEqualInt(0, archive_write_finish(ad));
-#endif
+	assertEqualInt(0, archive_write_free(ad));
+
 	/* Test the entries on disk. */
 	assert(0 == stat(archive_entry_pathname(ae), &st));
 	failure("%s", msg);
@@ -97,11 +92,8 @@
 	assertEqualIntA(ad, 0, archive_write_header(ad, ae));
 	assertEqualInt(sizeof(data), archive_write_data(ad, data, sizeof(data)));
 	assertEqualIntA(ad, 0, archive_write_finish_entry(ad));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_write_finish(ad);
-#else
-	assertEqualInt(0, archive_write_finish(ad));
-#endif
+	assertEqualInt(0, archive_write_free(ad));
+
 	/* Test the entries on disk. */
 	assertIsReg(archive_entry_pathname(ae), archive_entry_mode(ae) & 0777);
 	assertFileSize(archive_entry_pathname(ae), sizeof(data));
@@ -136,7 +128,7 @@
 		    archive_write_data_block(ad, data + i, 1000, i));
 	}
 	assertEqualIntA(ad, 0, archive_write_finish_entry(ad));
-	assertEqualInt(0, archive_write_finish(ad));
+	assertEqualInt(0, archive_write_free(ad));
 
 	/* Test the entries on disk. */
 	assertIsReg(archive_entry_pathname(ae), archive_entry_mode(ae) & 0777);
@@ -159,11 +151,8 @@
 	assertEqualIntA(ad, 0, archive_write_header(ad, ae));
 	assertEqualInt(5, archive_write_data(ad, data, sizeof(data)));
 	assertEqualIntA(ad, 0, archive_write_finish_entry(ad));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_write_finish(ad);
-#else
-	assertEqualInt(0, archive_write_finish(ad));
-#endif
+	assertEqualInt(0, archive_write_free(ad));
+
 	/* Test the entry on disk. */
 	assert(0 == stat(archive_entry_pathname(ae), &st));
 	failure("st.st_mode=%o archive_entry_mode(ae)=%o",
@@ -188,11 +177,8 @@
 	assertEqualInt(ARCHIVE_OK,
 	    archive_write_data_block(ad, data, sizeof(data), 0));
 	assertEqualIntA(ad, 0, archive_write_finish_entry(ad));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_write_finish(ad);
-#else
-	assertEqualInt(0, archive_write_finish(ad));
-#endif
+	assertEqualInt(0, archive_write_free(ad));
+
 	/* Test the entry on disk. */
 	assert(0 == stat(archive_entry_pathname(ae), &st));
 	failure("st.st_mode=%o archive_entry_mode(ae)=%o",
@@ -209,48 +195,54 @@
 {
 	static const char data[]="abcdefghijklmnopqrstuvwxyz";
 	struct archive *ad;
-	struct stat st;
-	char *p, *fname;
+	struct _stat st;
+	wchar_t *p, *fname;
 	size_t l;
 
 	/* Write the entry to disk. */
 	assert((ad = archive_write_disk_new()) != NULL);
-        archive_write_disk_set_options(ad, ARCHIVE_EXTRACT_TIME);
+	archive_write_disk_set_options(ad, ARCHIVE_EXTRACT_TIME);
 	failure("%s", msg);
 	archive_entry_set_size(ae, sizeof(data));
 	archive_entry_set_mtime(ae, 123456789, 0);
 	assertEqualIntA(ad, 0, archive_write_header(ad, ae));
 	assertEqualInt(sizeof(data), archive_write_data(ad, data, sizeof(data)));
 	assertEqualIntA(ad, 0, archive_write_finish_entry(ad));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_write_finish(ad);
-#else
-	assertEqualInt(0, archive_write_finish(ad));
-#endif
+	assertEqualInt(0, archive_write_free(ad));
+
 	/* Test the entries on disk. */
-	l = strlen(archive_entry_pathname(ae));
-	fname = malloc(l + 1);
+	l = wcslen(archive_entry_pathname_w(ae));
+	fname = malloc((l + 1) * sizeof(wchar_t));
 	assert(NULL != fname);
-	strcpy(fname, archive_entry_pathname(ae));
+	wcscpy(fname, archive_entry_pathname_w(ae));
+	p = fname;
+	/* Skip leading drive letter from archives created
+	 * on Windows. */
+	if (((p[0] >= L'a' && p[0] <= L'z') ||
+	     (p[0] >= L'A' && p[0] <= L'Z')) &&
+		 p[1] == L':' && p[2] == L'\\') {
+		p += 3;
+	}
 	/* Replace unusable characters in Windows to '_' */
-	for (p = fname; *p != '\0'; p++)
-		if (*p == ':' || *p == '*' || *p == '?' ||
-		    *p == '"' || *p == '<' || *p == '>' || *p == '|')
+	for (; *p != L'\0'; p++)
+		if (*p == L':' || *p == L'*' || *p == L'?' ||
+		    *p == L'"' || *p == L'<' || *p == L'>' || *p == L'|')
 			*p = '_';
-	assert(0 == stat(fname, &st));
+	assert(0 == _wstat(fname, &st));
 	failure("st.st_mode=%o archive_entry_mode(ae)=%o",
 	    st.st_mode, archive_entry_mode(ae));
 	assertEqualInt(st.st_size, sizeof(data));
+	free(fname);
 }
 #endif /* _WIN32 && !__CYGWIN__ */
-#endif
 
 DEFINE_TEST(test_write_disk)
 {
-#if ARCHIVE_VERSION_NUMBER < 1009000
-	skipping("archive_write_disk interface");
-#else
 	struct archive_entry *ae;
+#if defined(_WIN32) && !defined(__CYGWIN__)
+	wchar_t *fullpath;
+	DWORD l;
+#endif
 
 	/* Force the umask to something predictable. */
 	assertUmask(UMASK);
@@ -314,7 +306,7 @@
 #if defined(_WIN32) && !defined(__CYGWIN__)
 	/* A file with unusable characters in its file name. */
 	assert((ae = archive_entry_new()) != NULL);
-	archive_entry_copy_pathname(ae, "f:i*l?e\"f<i>l|e");
+	archive_entry_copy_pathname_w(ae, L"f:i*l?e\"f<i>l|e");
 	archive_entry_set_mode(ae, S_IFREG | 0755);
 	create_reg_file_win(ae, "Test creating a regular file"
 	    " with unusable characters in its file name");
@@ -322,11 +314,36 @@
 
 	/* A file with unusable characters in its directory name. */
 	assert((ae = archive_entry_new()) != NULL);
-	archive_entry_copy_pathname(ae, "d:i*r?e\"c<t>o|ry/file1");
+	archive_entry_copy_pathname_w(ae, L"d:i*r?e\"c<t>o|ry/file1");
 	archive_entry_set_mode(ae, S_IFREG | 0755);
 	create_reg_file_win(ae, "Test creating a regular file"
 	    " with unusable characters in its file name");
 	archive_entry_free(ae);
+
+	/* A full-path file with unusable characters in its file name. */
+	assert((l = GetCurrentDirectoryW(0, NULL)) != 0);
+	assert((fullpath = malloc((l + 20) * sizeof(wchar_t))) != NULL);
+	assert((l = GetCurrentDirectoryW(l, fullpath)) != 0);
+	wcscat(fullpath, L"\\f:i*l?e\"f<i>l|e");
+	assert((ae = archive_entry_new()) != NULL);
+	archive_entry_copy_pathname_w(ae, fullpath);
+	archive_entry_set_mode(ae, S_IFREG | 0755);
+	create_reg_file_win(ae, "Test creating a regular file"
+	    " with unusable characters in its file name");
+	archive_entry_free(ae);
+	free(fullpath);
+
+	/* A full-path file with unusable characters in its directory name. */
+	assert((l = GetCurrentDirectoryW(0, NULL)) != 0);
+	assert((fullpath = malloc((l + 30) * sizeof(wchar_t))) != NULL);
+	assert((l = GetCurrentDirectoryW(l, fullpath)) != 0);
+	wcscat(fullpath, L"\\d:i*r?e\"c<t>o|ry/file1");
+	assert((ae = archive_entry_new()) != NULL);
+	archive_entry_copy_pathname_w(ae, fullpath);
+	archive_entry_set_mode(ae, S_IFREG | 0755);
+	create_reg_file_win(ae, "Test creating a regular file"
+	    " with unusable characters in its file name");
+	archive_entry_free(ae);
+	free(fullpath);
 #endif /* _WIN32 && !__CYGWIN__ */
-#endif
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_write_disk_failures.c
--- a/head/contrib/libarchive/libarchive/test/test_write_disk_failures.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_write_disk_failures.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,18 +23,11 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_disk_failures.c 228763 2011-12-21 11:13:29Z mm $");
-
-#if ARCHIVE_VERSION_NUMBER >= 1009000
-
-#define UMASK 022
-
-
-#endif
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_disk_failures.c 232153 2012-02-25 10:58:02Z mm $");
 
 DEFINE_TEST(test_write_disk_failures)
 {
-#if ARCHIVE_VERSION_NUMBER < 1009000 || (defined(_WIN32) && !defined(__CYGWIN__))
+#if defined(_WIN32) && !defined(__CYGWIN__)
 	skipping("archive_write_disk interface");
 #else
 	struct archive_entry *ae;
@@ -42,7 +35,7 @@
 	int fd;
 
 	/* Force the umask to something predictable. */
-	assertUmask(UMASK);
+	assertUmask(022);
 
 	/* A directory that we can't write to. */
 	assertMakeDir("dir", 0555);
@@ -66,7 +59,7 @@
 	archive_entry_set_mtime(ae, 123456789, 0);
 	assertEqualIntA(a, ARCHIVE_FAILED, archive_write_header(a, ae));
 	assertEqualIntA(a, 0, archive_write_finish_entry(a));
-	assertEqualInt(0, archive_write_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 	archive_entry_free(ae);
 #endif
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_write_disk_hardlink.c
--- a/head/contrib/libarchive/libarchive/test/test_write_disk_hardlink.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_write_disk_hardlink.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_disk_hardlink.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_disk_hardlink.c 232153 2012-02-25 10:58:02Z mm $");
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
 /* Execution bits, Group members bits and others bits do not work. */
@@ -37,8 +37,8 @@
 /*
  * Exercise hardlink recreation.
  *
- * File permissions are chosen so that the authoritive entry
- * has the correct permission and the non-authoritive versions
+ * File permissions are chosen so that the authoritative entry
+ * has the correct permission and the non-authoritative versions
  * are just writeable files.
  */
 DEFINE_TEST(test_write_disk_hardlink)
@@ -157,11 +157,7 @@
 	archive_entry_set_mode(ae, S_IFREG | 0600);
 	archive_entry_set_size(ae, 0);
 	assertEqualIntA(ad, 0, archive_write_header(ad, ae));
-#if ARCHIVE_VERSION_NUMBER < 3000000
 	assertEqualInt(ARCHIVE_WARN, archive_write_data(ad, data, 1));
-#else
-	assertEqualInt(-1, archive_write_data(ad, data, 1));
-#endif
 	assertEqualIntA(ad, 0, archive_write_finish_entry(ad));
 	archive_entry_free(ae);
 
@@ -178,14 +174,14 @@
 		assertEqualIntA(ad, 0, archive_write_finish_entry(ad));
 	}
 	archive_entry_free(ae);
-	assertEqualInt(0, archive_write_finish(ad));
+	assertEqualInt(0, archive_write_free(ad));
 
 	/* Test the entries on disk. */
 
 	/* Test #1 */
 	/* If the hardlink was successfully created and the archive
 	 * doesn't carry data for it, we consider it to be
-	 * non-authoritive for meta data as well.  This is consistent
+	 * non-authoritative for meta data as well.  This is consistent
 	 * with GNU tar and BSD pax.  */
 	assertIsReg("link1a", 0755 & ~UMASK);
 	assertFileSize("link1a", sizeof(data));
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_write_disk_perms.c
--- a/head/contrib/libarchive/libarchive/test/test_write_disk_perms.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_write_disk_perms.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,9 +23,9 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_disk_perms.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_disk_perms.c 232153 2012-02-25 10:58:02Z mm $");
 
-#if ARCHIVE_VERSION_NUMBER >= 1009000 && (!defined(_WIN32) || defined(__CYGWIN__))
+#if !defined(_WIN32) || defined(__CYGWIN__)
 
 #define UMASK 022
 
@@ -125,7 +125,7 @@
 
 DEFINE_TEST(test_write_disk_perms)
 {
-#if ARCHIVE_VERSION_NUMBER < 1009000 || (defined(_WIN32) && !defined(__CYGWIN__))
+#if defined(_WIN32) && !defined(__CYGWIN__)
 	skipping("archive_write_disk interface");
 #else
 	struct archive *a;
@@ -365,11 +365,7 @@
 		assertEqualIntA(a,ARCHIVE_WARN,archive_write_finish_entry(a));
 	}
 
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_write_finish(a);
-#else
-	assert(0 == archive_write_finish(a));
-#endif
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 	archive_entry_free(ae);
 
 	/* Test the entries on disk. */
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_write_disk_secure.c
--- a/head/contrib/libarchive/libarchive/test/test_write_disk_secure.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_write_disk_secure.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_disk_secure.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_disk_secure.c 232153 2012-02-25 10:58:02Z mm $");
 
 #define UMASK 022
 
@@ -34,9 +34,9 @@
 
 DEFINE_TEST(test_write_disk_secure)
 {
-#if ARCHIVE_VERSION_NUMBER < 1009000
-	skipping("archive_write_disk interface");
-#elif !defined(_WIN32) || defined(__CYGWIN__)
+#if defined(_WIN32) && !defined(__CYGWIN__)
+	skipping("archive_write_disk security checks not supported on Windows");
+#else
 	struct archive *a;
 	struct archive_entry *ae;
 	struct stat st;
@@ -178,7 +178,7 @@
 	assert(S_ISDIR(st.st_mode));
 	archive_entry_free(ae);
 
-	assert(0 == archive_write_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/* Test the entries on disk. */
 	assert(0 == lstat("dir", &st));
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_write_disk_sparse.c
--- a/head/contrib/libarchive/libarchive/test/test_write_disk_sparse.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_write_disk_sparse.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_disk_sparse.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_disk_sparse.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * Write a file using archive_write_data call, read the file
@@ -269,12 +269,12 @@
         archive_write_disk_set_options(ad, 0);
 	verify_write_data(ad, 0);
 	verify_write_data_block(ad, 0);
-	assertEqualInt(0, archive_write_finish(ad));
+	assertEqualInt(0, archive_write_free(ad));
 
 	assert((ad = archive_write_disk_new()) != NULL);
         archive_write_disk_set_options(ad, ARCHIVE_EXTRACT_SPARSE);
 	verify_write_data(ad, 1);
 	verify_write_data_block(ad, 1);
-	assertEqualInt(0, archive_write_finish(ad));
+	assertEqualInt(0, archive_write_free(ad));
 
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_write_disk_symlink.c
--- a/head/contrib/libarchive/libarchive/test/test_write_disk_symlink.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_write_disk_symlink.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_disk_symlink.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_disk_symlink.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * Exercise symlink recreation.
@@ -99,7 +99,7 @@
 	assertEqualIntA(ad, 0, archive_write_finish_entry(ad));
 	archive_entry_free(ae);
 
-	assertEqualInt(ARCHIVE_OK, archive_write_finish(ad));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(ad));
 
 	/* Test the entries on disk. */
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_write_disk_times.c
--- a/head/contrib/libarchive/libarchive/test/test_write_disk_times.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_write_disk_times.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_disk_times.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_disk_times.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * Exercise time restores in archive_write_disk(), including
@@ -163,5 +163,5 @@
 	skipping("Platform-specific time restore tests");
 #endif
 
-	archive_write_finish(a);
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_write_format_ar.c
--- a/head/contrib/libarchive/libarchive/test/test_write_format_ar.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_write_format_ar.c	Fri Mar 02 16:54:40 2012 +0200
@@ -26,7 +26,7 @@
  */
 
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_format_ar.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_format_ar.c 232153 2012-02-25 10:58:02Z mm $");
 
 char buff[4096];
 char buff2[64];
@@ -34,9 +34,6 @@
 
 DEFINE_TEST(test_write_format_ar)
 {
-#if ARCHIVE_VERSION_NUMBER < 1009000
-	skipping("ar write support");
-#else
 	struct archive_entry *ae;
 	struct archive* a;
 	size_t used;
@@ -45,14 +42,14 @@
 	 * First we try to create a SVR4/GNU format archive.
 	 */
 	assert((a = archive_write_new()) != NULL);
-	assertA(0 == archive_write_set_format_ar_svr4(a));
-	assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ar_svr4(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, sizeof(buff), &used));
 
 	/* write the filename table */
 	assert((ae = archive_entry_new()) != NULL);
 	archive_entry_copy_pathname(ae, "//");
 	archive_entry_set_size(ae, strlen(strtab));
-	assertA(0 == archive_write_header(a, ae));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
 	assertA(strlen(strtab) == (size_t)archive_write_data(a, strtab, strlen(strtab)));
 	archive_entry_free(ae);
 
@@ -64,7 +61,7 @@
 	assert((S_IFREG | 0755) == archive_entry_mode(ae));
 	archive_entry_copy_pathname(ae, "abcdefghijklmn.o");
 	archive_entry_set_size(ae, 8);
-	assertA(0 == archive_write_header(a, ae));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
 	assertA(8 == archive_write_data(a, "87654321", 15));
 	archive_entry_free(ae);
 
@@ -100,19 +97,18 @@
 	assertA(0 != archive_write_header(a, ae));
 	archive_entry_free(ae);
 
-	archive_write_close(a);
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_write_finish(a);
-#else
-	assertEqualInt(0, archive_write_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(archive_position_compressed(a),
+	    archive_position_uncompressed(a));
+	assertEqualInt(used, archive_position_uncompressed(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/*
 	 * Now, read the data back.
 	 */
 	assert((a = archive_read_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff, used));
 
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
@@ -139,12 +135,8 @@
 	assertEqualIntA(a, 8, archive_read_data(a, buff2, 17));
 	assertEqualMem(buff2, "88877766", 8);
 
-	assertEqualIntA(a, 0, archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assertEqualInt(0, archive_read_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	/*
 	 * Then, we try to create a BSD format archive.
@@ -172,17 +164,13 @@
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
 	assertEqualIntA(a, 6, archive_write_data(a, "555555", 7));
 	archive_entry_free(ae);
-	archive_write_close(a);
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_write_finish(a);
-#else
-	assertEqualInt(0, archive_write_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/* Now, Read the data back */
 	assert((a = archive_read_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff, used));
 
 	assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
@@ -199,11 +187,6 @@
 
 	/* Test EOF */
 	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
-	assertEqualIntA(a, 0, archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assertEqualInt(0, archive_read_finish(a));
-#endif
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_write_format_cpio.c
--- a/head/contrib/libarchive/libarchive/test/test_write_format_cpio.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_write_format_cpio.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,10 +23,8 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_format_cpio.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_format_cpio.c 232153 2012-02-25 10:58:02Z mm $");
 
-/* The version stamp macro was introduced after cpio write support. */
-#if ARCHIVE_VERSION_NUMBER >= 1009000
 static void
 test_format(int	(*set_format)(struct archive *))
 {
@@ -88,6 +86,48 @@
 	assertA(4 == archive_write_data(a, "1234", 5));
 
 	/*
+	 * Write a file with a name, filetype, and size.
+	 */
+	assert((ae = archive_entry_new()) != NULL);
+	archive_entry_copy_pathname(ae, "name");
+	archive_entry_set_size(ae, 0);
+	archive_entry_set_filetype(ae, AE_IFREG);
+	assertEqualInt(ARCHIVE_OK, archive_write_header(a, ae));
+	assert(archive_error_string(a) == NULL);
+	archive_entry_free(ae);
+
+	/*
+	 * Write a file with a name and filetype but no size.
+	 */
+	assert((ae = archive_entry_new()) != NULL);
+	archive_entry_copy_pathname(ae, "name");
+	archive_entry_unset_size(ae);
+	archive_entry_set_filetype(ae, AE_IFREG);
+	assertEqualInt(ARCHIVE_FAILED, archive_write_header(a, ae));
+	assert(archive_error_string(a) != NULL);
+	archive_entry_free(ae);
+
+	/*
+	 * Write a file with a name and size but no filetype.
+	 */
+	assert((ae = archive_entry_new()) != NULL);
+	archive_entry_copy_pathname(ae, "name");
+	archive_entry_set_size(ae, 0);
+	assertEqualInt(ARCHIVE_FAILED, archive_write_header(a, ae));
+	assert(archive_error_string(a) != NULL);
+	archive_entry_free(ae);
+
+	/*
+	 * Write a file with a size and filetype but no name.
+	 */
+	assert((ae = archive_entry_new()) != NULL);
+	archive_entry_set_size(ae, 0);
+	archive_entry_set_filetype(ae, AE_IFREG);
+	assertEqualInt(ARCHIVE_FAILED, archive_write_header(a, ae));
+	assert(archive_error_string(a) != NULL);
+	archive_entry_free(ae);
+
+	/*
 	 * Write a directory to it.
 	 */
 	assert((ae = archive_entry_new()) != NULL);
@@ -103,12 +143,8 @@
 
 
 	/* Close out the archive. */
-	assertA(0 == archive_write_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_write_finish(a);
-#else
-	assertA(0 == archive_write_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/*
 	 * Damage the second entry to test the search-ahead recovery.
@@ -133,11 +169,11 @@
 	 */
 	assert((a = archive_read_new()) != NULL);
 	assertA(0 == archive_read_support_format_all(a));
-	assertA(0 == archive_read_support_compression_all(a));
+	assertA(0 == archive_read_support_filter_all(a));
 	assertA(0 == archive_read_open_memory(a, buff, used));
 
 	if (!assertEqualIntA(a, 0, archive_read_next_header(a, &ae))) {
-		archive_read_finish(a);
+		archive_read_free(a);
 		return;
 	}
 
@@ -150,17 +186,23 @@
 	assertEqualInt((S_IFREG | 0755), archive_entry_mode(ae));
 	assertEqualInt(8, archive_entry_size(ae));
 	assertA(8 == archive_read_data(a, filedata, 10));
-	assert(0 == memcmp(filedata, "12345678", 8));
+	assertEqualMem(filedata, "12345678", 8);
 
 	/*
 	 * The second file can't be read because we damaged its header.
 	 */
 
 	/*
-	 * Read the dir entry back.
+	 * Read the third file back.
 	 * ARCHIVE_WARN here because the damaged entry was skipped.
 	 */
 	assertEqualIntA(a, ARCHIVE_WARN, archive_read_next_header(a, &ae));
+	assertEqualString("name", archive_entry_pathname(ae));
+
+	/*
+	 * Read the dir entry back.
+	 */
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
 	assertEqualInt(11, archive_entry_mtime(ae));
 	assert(0 == archive_entry_mtime_nsec(ae));
 	assert(0 == archive_entry_atime(ae));
@@ -172,23 +214,57 @@
 
 	/* Verify the end of the archive. */
 	assertEqualIntA(a, 1, archive_read_next_header(a, &ae));
-	assert(0 == archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assert(0 == archive_read_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
 	free(buff);
 }
-#endif
+
+static void
+test_big_entries(int (*set_format)(struct archive *), int64_t size, int expected)
+{
+	struct archive_entry *ae;
+	struct archive *a;
+	size_t buffsize = 1000000;
+	size_t used;
+	char *buff;
+
+	buff = malloc(buffsize);
+
+	/* Create a new archive in memory. */
+	assert((a = archive_write_new()) != NULL);
+	assertA(0 == (*set_format)(a));
+	assertA(0 == archive_write_set_compression_none(a));
+	assertA(0 == archive_write_open_memory(a, buff, buffsize, &used));
+
+	assert((ae = archive_entry_new()) != NULL);
+	archive_entry_copy_pathname(ae, "file");
+	archive_entry_set_size(ae, size);
+	archive_entry_set_filetype(ae, AE_IFREG);
+	assertEqualInt(expected, archive_write_header(a, ae));
+	if (expected != ARCHIVE_OK)
+		assert(archive_error_string(a) != NULL);
+
+	archive_entry_free(ae);
+	archive_write_free(a);
+	free(buff);
+}
+
 
 DEFINE_TEST(test_write_format_cpio)
 {
-#if ARCHIVE_VERSION_NUMBER >= 1009000
+	int64_t size_4g = ((int64_t)1) << 32;
+	int64_t size_8g = ((int64_t)1) << 33;
+
 	test_format(archive_write_set_format_cpio);
 	test_format(archive_write_set_format_cpio_newc);
-#else
-	skipping("cpio write support");
-#endif
+
+	test_big_entries(archive_write_set_format_cpio,
+	    size_8g - 1, ARCHIVE_OK);
+	test_big_entries(archive_write_set_format_cpio,
+	    size_8g, ARCHIVE_FAILED);
+	test_big_entries(archive_write_set_format_cpio_newc,
+	    size_4g - 1, ARCHIVE_OK);
+	test_big_entries(archive_write_set_format_cpio_newc,
+	    size_4g, ARCHIVE_FAILED);
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_write_format_cpio_empty.c
--- a/head/contrib/libarchive/libarchive/test/test_write_format_cpio_empty.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_write_format_cpio_empty.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_format_cpio_empty.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_format_cpio_empty.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * Check that an "empty" cpio archive is correctly created.
@@ -61,12 +61,8 @@
 	assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used));
 
 	/* Close out the archive. */
-	assertA(0 == archive_write_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_write_finish(a);
-#else
-	assertA(0 == archive_write_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	failure("Empty cpio archive should be exactly 87 bytes, was %d.", used);
 	assert(used == 87);
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_write_format_cpio_newc.c
--- a/head/contrib/libarchive/libarchive/test/test_write_format_cpio_newc.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_write_format_cpio_newc.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_format_cpio_newc.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_format_cpio_newc.c 232153 2012-02-25 10:58:02Z mm $");
 
 
 static int
@@ -111,12 +111,7 @@
 	assertEqualIntA(a, 0, archive_write_header(a, entry));
 	archive_entry_free(entry);
 
-
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_write_finish(a);
-#else
-	assert(0 == archive_write_finish(a));
-#endif
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/*
 	 * Verify the archive format.
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_write_format_cpio_odc.c
--- a/head/contrib/libarchive/libarchive/test/test_write_format_cpio_odc.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_write_format_cpio_odc.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_format_cpio_odc.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_format_cpio_odc.c 232153 2012-02-25 10:58:02Z mm $");
 
 
 static int
@@ -123,11 +123,7 @@
 	/* Write of data to symlink should fail == zero bytes get written. */
 	assertEqualIntA(a, 0, archive_write_data(a, "1234567890", 10));
 
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_write_finish(a);
-#else
-	assert(0 == archive_write_finish(a));
-#endif
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/*
 	 * Verify the archive format.
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_write_format_mtree.c
--- a/head/contrib/libarchive/libarchive/test/test_write_format_mtree.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_write_format_mtree.c	Fri Mar 02 16:54:40 2012 +0200
@@ -25,7 +25,7 @@
  */
 
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_format_mtree.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_format_mtree.c 232153 2012-02-25 10:58:02Z mm $");
 
 static char buff[4096];
 static struct {
@@ -59,12 +59,12 @@
 
 	/* Create a mtree format archive. */
 	assert((a = archive_write_new()) != NULL);
-	assertA(0 == archive_write_set_format_mtree(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_mtree(a));
 	if (use_set)
-		assertA(0 == archive_write_set_options(a, "use-set"));
+		assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_option(a, NULL, "use-set", "1"));
 	if (dironly)
-		assertA(0 == archive_write_set_options(a, "dironly"));
-	assertA(0 == archive_write_open_memory(a, buff, sizeof(buff)-1, &used));
+		assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_option(a, NULL, "dironly", "1"));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, sizeof(buff)-1, &used));
 
 	/* Write entries */
 	for (i = 0; entries[i].path != NULL; i++) {
@@ -80,17 +80,15 @@
 		archive_entry_copy_pathname(ae, entries[i].path);
 		if ((entries[i].mode & AE_IFMT) != S_IFDIR)
 			archive_entry_set_size(ae, 8);
-		assertA(0 == archive_write_header(a, ae));
+		assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
 		if ((entries[i].mode & AE_IFMT) != S_IFDIR)
-			assertA(8 == archive_write_data(a, "Hello012", 15));
+			assertEqualIntA(a, 8,
+			    archive_write_data(a, "Hello012", 15));
 		archive_entry_free(ae);
 	}
-	archive_write_close(a);
-#if ARCHIVE_VERSION_NUMBER < 2000000
-        archive_write_finish(a);
-#else
-        assertEqualInt(0, archive_write_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+        assertEqualInt(ARCHIVE_OK, archive_write_free(a));
+
 	if (use_set) {
 		const char *p;
 
@@ -118,7 +116,7 @@
 	 */
 	assert((a = archive_read_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff, used));
 
 	/* Read entries */
@@ -134,12 +132,8 @@
 		if ((entries[i].mode & AE_IFMT) != S_IFDIR)
 			assertEqualInt(8, archive_entry_size(ae));
 	}
-	assertEqualIntA(a, 0, archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_read_finish(a);
-#else
-	assertEqualInt(0, archive_read_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
 
 DEFINE_TEST(test_write_format_mtree)
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_write_format_pax.c
--- a/head/contrib/libarchive/libarchive/test/test_write_format_pax.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_write_format_pax.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_format_pax.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_format_pax.c 232153 2012-02-25 10:58:02Z mm $");
 
 char buff2[64];
 
@@ -34,6 +34,9 @@
 	struct archive_entry *ae;
 	struct archive *a;
 	size_t used;
+	int i;
+	char nulls[1024];
+	int64_t offset, length;
 
 	buff = malloc(buffsize); /* million bytes of work area */
 	assert(buff != NULL);
@@ -75,6 +78,27 @@
 	assertEqualIntA(a, 8, archive_write_data(a, "12345678", 9));
 
 	/*
+	 * "file3" is sparse file and has hole size of which is
+	 * 1024000 bytes, and has 8 bytes data after the hole.
+	 */
+	assert((ae = archive_entry_new()) != NULL);
+	archive_entry_set_atime(ae, 2, 20);
+	archive_entry_set_birthtime(ae, 3, 30);
+	archive_entry_set_ctime(ae, 4, 40);
+	archive_entry_set_mtime(ae, 5, 50);
+	archive_entry_copy_pathname(ae, "file3");
+	archive_entry_set_mode(ae, S_IFREG | 0755);
+	archive_entry_set_size(ae, 1024008);
+	archive_entry_sparse_add_entry(ae, 1024000, 8);
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
+	archive_entry_free(ae);
+	memset(nulls, 0, sizeof(nulls));
+	for (i = 0; i < 1024000; i += 1024)
+		/* write hole data, which won't be stored into an archive file. */
+		assertEqualIntA(a, 1024, archive_write_data(a, nulls, 1024));
+	assertEqualIntA(a, 8, archive_write_data(a, "12345678", 9));
+
+	/*
 	 * XXX TODO XXX Archive directory, other file types.
 	 * Archive extended attributes, ACLs, other metadata.
 	 * Verify they get read back correctly.
@@ -82,7 +106,7 @@
 
 	/* Close out the archive. */
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
-	assertEqualIntA(a, ARCHIVE_OK, archive_write_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_free(a));
 
 	/*
 	 *
@@ -91,7 +115,7 @@
 	 */
 	assert((a = archive_read_new()) != NULL);
 	assertEqualIntA(a, 0, archive_read_support_format_all(a));
-	assertEqualIntA(a, 0, archive_read_support_compression_all(a));
+	assertEqualIntA(a, 0, archive_read_support_filter_all(a));
 	assertEqualIntA(a, 0, archive_read_open_memory(a, buff, used));
 
 	/*
@@ -136,11 +160,40 @@
 	assertEqualMem(buff2, "12345678", 8);
 
 	/*
+	 * Read "file3"
+	 */
+	assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
+	assertEqualInt(2, archive_entry_atime(ae));
+	assertEqualInt(20, archive_entry_atime_nsec(ae));
+	assertEqualInt(3, archive_entry_birthtime(ae));
+	assertEqualInt(30, archive_entry_birthtime_nsec(ae));
+	assertEqualInt(4, archive_entry_ctime(ae));
+	assertEqualInt(40, archive_entry_ctime_nsec(ae));
+	assertEqualInt(5, archive_entry_mtime(ae));
+	assertEqualInt(50, archive_entry_mtime_nsec(ae));
+	assertEqualString("file3", archive_entry_pathname(ae));
+	assert((S_IFREG | 0755) == archive_entry_mode(ae));
+	assertEqualInt(1024008, archive_entry_size(ae));
+	assertEqualInt(1, archive_entry_sparse_reset(ae));
+	assertEqualInt(ARCHIVE_OK,
+	    archive_entry_sparse_next(ae, &offset, &length));
+	assertEqualInt(1024000, offset);
+	assertEqualInt(8, length);
+	for (i = 0; i < 1024000; i += 1024) {
+		int j;
+		assertEqualIntA(a, 1024, archive_read_data(a, nulls, 1024));
+		for (j = 0; j < 1024; j++)
+			assertEqualInt(0, nulls[j]);
+	}
+	assertEqualIntA(a, 8, archive_read_data(a, buff2, 10));
+	assertEqualMem(buff2, "12345678", 8);
+
+	/*
 	 * Verify the end of the archive.
 	 */
 	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
 
 	free(buff);
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_write_format_shar_empty.c
--- a/head/contrib/libarchive/libarchive/test/test_write_format_shar_empty.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_write_format_shar_empty.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_format_shar_empty.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_format_shar_empty.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * Check that an "empty" shar archive is correctly created as an empty file.
@@ -46,12 +46,8 @@
 	assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used));
 
 	/* Close out the archive. */
-	assertA(0 == archive_write_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_write_finish(a);
-#else
-	assertA(0 == archive_write_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	failure("Empty shar archive should be exactly 0 bytes, was %d.", used);
 	assert(used == 0);
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_write_format_tar.c
--- a/head/contrib/libarchive/libarchive/test/test_write_format_tar.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_write_format_tar.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2003-2010 Tim Kientzle
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_format_tar.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_format_tar.c 232153 2012-02-25 10:58:02Z mm $");
 
 char buff[1000000];
 char buff2[64];
@@ -40,75 +40,80 @@
 	for (blocksize = 1; blocksize < 100000; blocksize += blocksize + 3) {
 		/* Create a new archive in memory. */
 		assert((a = archive_write_new()) != NULL);
-		assertA(0 == archive_write_set_format_ustar(a));
-		assertA(0 == archive_write_set_compression_none(a));
-		assertA(0 == archive_write_set_bytes_per_block(a, (int)blocksize));
-		assertA(0 == archive_write_set_bytes_in_last_block(a, (int)blocksize));
-		assertA(blocksize == (size_t)archive_write_get_bytes_in_last_block(a));
-		assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used));
-		assertA(blocksize == (size_t)archive_write_get_bytes_in_last_block(a));
+		assertEqualIntA(a, ARCHIVE_OK,
+		    archive_write_set_format_ustar(a));
+		assertEqualIntA(a, ARCHIVE_OK,
+		    archive_write_set_compression_none(a));
+		assertEqualIntA(a, ARCHIVE_OK,
+		    archive_write_set_bytes_per_block(a, (int)blocksize));
+		assertEqualIntA(a, ARCHIVE_OK,
+		    archive_write_set_bytes_in_last_block(a, (int)blocksize));
+		assertEqualInt(blocksize,
+		    archive_write_get_bytes_in_last_block(a));
+		assertEqualIntA(a, ARCHIVE_OK,
+		    archive_write_open_memory(a, buff, sizeof(buff), &used));
+		assertEqualInt(blocksize,
+		    archive_write_get_bytes_in_last_block(a));
 
 		/*
 		 * Write a file to it.
 		 */
 		assert((ae = archive_entry_new()) != NULL);
 		archive_entry_set_mtime(ae, 1, 10);
-		assert(1 == archive_entry_mtime(ae));
-#if !defined(__INTERIX)
-		assert(10 == archive_entry_mtime_nsec(ae));
-#endif
+		assertEqualInt(1, archive_entry_mtime(ae));
+		assertEqualInt(10, archive_entry_mtime_nsec(ae));
 		p = strdup("file");
 		archive_entry_copy_pathname(ae, p);
 		strcpy(p, "XXXX");
 		free(p);
 		assertEqualString("file", archive_entry_pathname(ae));
 		archive_entry_set_mode(ae, S_IFREG | 0755);
-		assert((S_IFREG | 0755) == archive_entry_mode(ae));
+		assertEqualInt(S_IFREG | 0755, archive_entry_mode(ae));
 		archive_entry_set_size(ae, 8);
 
-		assertA(0 == archive_write_header(a, ae));
+		assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
 		archive_entry_free(ae);
-		assertA(8 == archive_write_data(a, "12345678", 9));
+		assertEqualInt(8, archive_write_data(a, "12345678", 9));
 
 		/* Close out the archive. */
-		assertA(0 == archive_write_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-		archive_write_finish(a);
-#else
-		assertA(0 == archive_write_finish(a));
-#endif
+		assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+		assertEqualInt(ARCHIVE_OK, archive_write_free(a));
+
 		/* This calculation gives "the smallest multiple of
 		 * the block size that is at least 2048 bytes". */
-		assert(((2048 - 1)/blocksize+1)*blocksize == used);
+		failure("blocksize=%d", blocksize);
+		assertEqualInt(((2048 - 1)/blocksize+1)*blocksize, used);
 
 		/*
 		 * Now, read the data back.
 		 */
 		assert((a = archive_read_new()) != NULL);
-		assertA(0 == archive_read_support_format_all(a));
-		assertA(0 == archive_read_support_compression_all(a));
-		assertA(0 == archive_read_open_memory(a, buff, used));
+		assertEqualIntA(a, ARCHIVE_OK,
+		    archive_read_support_format_all(a));
+		assertEqualIntA(a, ARCHIVE_OK,
+		    archive_read_support_filter_all(a));
+		assertEqualIntA(a, ARCHIVE_OK,
+		    archive_read_open_memory(a, buff, used));
 
-		assertA(0 == archive_read_next_header(a, &ae));
+		assertEqualIntA(a, ARCHIVE_OK,
+		    archive_read_next_header(a, &ae));
 
-		assert(1 == archive_entry_mtime(ae));
+		assertEqualInt(1, archive_entry_mtime(ae));
 		/* Not the same as above: ustar doesn't store hi-res times. */
-		assert(0 == archive_entry_mtime_nsec(ae));
-		assert(0 == archive_entry_atime(ae));
-		assert(0 == archive_entry_ctime(ae));
+		assertEqualInt(0, archive_entry_mtime_nsec(ae));
+		assertEqualInt(0, archive_entry_atime(ae));
+		assertEqualInt(0, archive_entry_ctime(ae));
 		assertEqualString("file", archive_entry_pathname(ae));
-		assert((S_IFREG | 0755) == archive_entry_mode(ae));
-		assert(8 == archive_entry_size(ae));
-		assertA(8 == archive_read_data(a, buff2, 10));
-		assert(0 == memcmp(buff2, "12345678", 8));
+		assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+		assertEqualInt(AE_IFREG | 0755, archive_entry_mode(ae));
+		assertEqualInt(8, archive_entry_size(ae));
+		assertEqualInt(8, archive_read_data(a, buff2, 10));
+		assertEqualMem(buff2, "12345678", 8);
 
 		/* Verify the end of the archive. */
-		assert(1 == archive_read_next_header(a, &ae));
-		assert(0 == archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-		archive_read_finish(a);
-#else
-		assert(0 == archive_read_finish(a));
-#endif
+		assertEqualIntA(a, ARCHIVE_EOF,
+		    archive_read_next_header(a, &ae));
+		assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+		assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 	}
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_write_format_tar_empty.c
--- a/head/contrib/libarchive/libarchive/test/test_write_format_tar_empty.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_write_format_tar_empty.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_format_tar_empty.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_format_tar_empty.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * Check that an "empty" tar archive is correctly created.
@@ -45,19 +45,10 @@
 	assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used));
 
 	/* Close out the archive. */
-	assertA(0 == archive_write_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_write_finish(a);
-#else
-	assertA(0 == archive_write_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
-#if ARCHIVE_VERSION_NUMBER < 1009000
-	/* Earlier versions wrote 0-length files for empty tar archives. */
-	skipping("empty tar archive size");
-#else
 	assert(used == 1024);
-#endif
 	for (i = 0; i < used; i++) {
 		failure("Empty tar archive should be all nulls.");
 		assert(buff[i] == 0);
@@ -72,19 +63,10 @@
 	assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used));
 
 	/* Close out the archive. */
-	assertA(0 == archive_write_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_write_finish(a);
-#else
-	assertA(0 == archive_write_finish(a));
-#endif
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
-#if ARCHIVE_VERSION_NUMBER < 1009000
-	/* Earlier versions wrote 0-length files for empty tar archives. */
-	skipping("empty tar archive size");
-#else
 	assertEqualInt((int)used, 1024);
-#endif
 	for (i = 0; i < used; i++) {
 		failure("Empty tar archive should be all nulls.");
 		assert(buff[i] == 0);
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_write_format_tar_ustar.c
--- a/head/contrib/libarchive/libarchive/test/test_write_format_tar_ustar.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_write_format_tar_ustar.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_format_tar_ustar.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_format_tar_ustar.c 232153 2012-02-25 10:58:02Z mm $");
 
 static int
 is_null(const char *p, size_t l)
@@ -76,9 +76,12 @@
 
 	/* Create a new archive in memory. */
 	assert((a = archive_write_new()) != NULL);
-	assertEqualIntA(a, 0, archive_write_set_format_ustar(a));
-	assertEqualIntA(a, 0, archive_write_set_compression_none(a));
-	assertEqualIntA(a, 0, archive_write_open_memory(a, buff, buffsize, &used));
+	assertEqualIntA(a, ARCHIVE_OK,
+	    archive_write_set_format_ustar(a));
+	assertEqualIntA(a, ARCHIVE_OK,
+	    archive_write_set_compression_none(a));
+	assertEqualIntA(a, ARCHIVE_OK,
+	    archive_write_open_memory(a, buff, buffsize, &used));
 
 	/*
 	 * Add various files to it.
@@ -96,7 +99,8 @@
 	archive_entry_set_dev(entry, 12);
 	archive_entry_set_ino(entry, 89);
 	archive_entry_set_nlink(entry, 2);
-	assertEqualIntA(a, 0, archive_write_header(a, entry));
+	assertEqualIntA(a, ARCHIVE_OK,
+	    archive_write_header(a, entry));
 	archive_entry_free(entry);
 	assertEqualIntA(a, 10, archive_write_data(a, "1234567890", 10));
 
@@ -112,7 +116,8 @@
 	archive_entry_set_dev(entry, 12);
 	archive_entry_set_ino(entry, 89);
 	archive_entry_set_nlink(entry, 2);
-	assertEqualIntA(a, 0, archive_write_header(a, entry));
+	assertEqualIntA(a, ARCHIVE_OK,
+	    archive_write_header(a, entry));
 	archive_entry_free(entry);
 	/* Write of data to dir should fail == zero bytes get written. */
 	assertEqualIntA(a, 0, archive_write_data(a, "1234567890", 10));
@@ -124,7 +129,8 @@
 	archive_entry_set_mode(entry, S_IFDIR | 0775);
 	archive_entry_set_size(entry, 10);
 	archive_entry_set_nlink(entry, 2);
-	assertEqualIntA(a, 0, archive_write_header(a, entry));
+	assertEqualIntA(a, ARCHIVE_OK,
+	    archive_write_header(a, entry));
 	archive_entry_free(entry);
 	/* Write of data to dir should fail == zero bytes get written. */
 	assertEqualIntA(a, 0, archive_write_data(a, "1234567890", 10));
@@ -142,7 +148,8 @@
 	archive_entry_set_dev(entry, 12);
 	archive_entry_set_ino(entry, 90);
 	archive_entry_set_nlink(entry, 1);
-	assertEqualIntA(a, 0, archive_write_header(a, entry));
+	assertEqualIntA(a, ARCHIVE_OK,
+	    archive_write_header(a, entry));
 	archive_entry_free(entry);
 	/* Write of data to symlink should fail == zero bytes get written. */
 	assertEqualIntA(a, 0, archive_write_data(a, "1234567890", 10));
@@ -158,7 +165,8 @@
 	archive_entry_set_dev(entry, 102);
 	archive_entry_set_ino(entry, 7);
 	archive_entry_set_nlink(entry, 1);
-	assertEqualIntA(a, 0, archive_write_header(a, entry));
+	assertEqualIntA(a, ARCHIVE_OK,
+	    archive_write_header(a, entry));
 	archive_entry_free(entry);
 
 	/* file with 100-char filename. */
@@ -172,7 +180,8 @@
 	archive_entry_set_dev(entry, 102);
 	archive_entry_set_ino(entry, 7);
 	archive_entry_set_nlink(entry, 1);
-	assertEqualIntA(a, 0, archive_write_header(a, entry));
+	assertEqualIntA(a, ARCHIVE_OK,
+	    archive_write_header(a, entry));
 	archive_entry_free(entry);
 
 	/* file with 256-char filename. */
@@ -186,14 +195,12 @@
 	archive_entry_set_dev(entry, 102);
 	archive_entry_set_ino(entry, 7);
 	archive_entry_set_nlink(entry, 1);
-	assertEqualIntA(a, 0, archive_write_header(a, entry));
+	assertEqualIntA(a, ARCHIVE_OK,
+	    archive_write_header(a, entry));
 	archive_entry_free(entry);
 
-#if ARCHIVE_VERSION_NUMBER < 2000000
-	archive_write_finish(a);
-#else
-	assert(0 == archive_write_finish(a));
-#endif
+	/* Close out the archive. */
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/*
 	 * Verify the archive format.
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_write_format_zip.c
--- a/head/contrib/libarchive/libarchive/test/test_write_format_zip.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_write_format_zip.c	Fri Mar 02 16:54:40 2012 +0200
@@ -28,14 +28,95 @@
  * Development supported by Google Summer of Code 2008.
  */
 
-/* TODO: reader does not yet restore permissions. */
+#include "test.h"
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_format_zip.c 232153 2012-02-25 10:58:02Z mm $");
 
-#include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_format_zip.c 228763 2011-12-21 11:13:29Z mm $");
+static void
+verify_contents(struct archive *a, int expect_details)
+{
+	char filedata[64];
+	struct archive_entry *ae;
+
+	/*
+	 * Read and verify first file.
+	 */
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualInt(1, archive_entry_mtime(ae));
+	/* Zip doesn't store high-resolution mtime. */
+	assertEqualInt(0, archive_entry_mtime_nsec(ae));
+	assertEqualInt(0, archive_entry_atime(ae));
+	assertEqualInt(0, archive_entry_ctime(ae));
+	assertEqualString("file", archive_entry_pathname(ae));
+	if (expect_details) {
+		assertEqualInt(AE_IFREG | 0755, archive_entry_mode(ae));
+		assertEqualInt(8, archive_entry_size(ae));
+	} else {
+		assertEqualInt(0, archive_entry_size(ae));
+	}
+	assertEqualIntA(a, 8,
+	    archive_read_data(a, filedata, sizeof(filedata)));
+	assertEqualMem(filedata, "12345678", 8);
+
+
+	/*
+	 * Read the second file back.
+	 */
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualInt(1, archive_entry_mtime(ae));
+	assertEqualInt(0, archive_entry_mtime_nsec(ae));
+	assertEqualInt(0, archive_entry_atime(ae));
+	assertEqualInt(0, archive_entry_ctime(ae));
+	assertEqualString("file2", archive_entry_pathname(ae));
+	if (expect_details) {
+		assertEqualInt(AE_IFREG | 0755, archive_entry_mode(ae));
+		assertEqualInt(4, archive_entry_size(ae));
+	} else {
+		assertEqualInt(0, archive_entry_size(ae));
+	}
+	assertEqualIntA(a, 4,
+	    archive_read_data(a, filedata, sizeof(filedata)));
+	assertEqualMem(filedata, "1234", 4);
+
+	/*
+	 * Read the third file back.
+	 */
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualInt(1, archive_entry_mtime(ae));
+	assertEqualInt(0, archive_entry_mtime_nsec(ae));
+	assertEqualInt(0, archive_entry_atime(ae));
+	assertEqualInt(0, archive_entry_ctime(ae));
+	assertEqualString("symlink", archive_entry_pathname(ae));
+	if (expect_details) {
+		assertEqualInt(AE_IFLNK | 0755, archive_entry_mode(ae));
+		assertEqualInt(0, archive_entry_size(ae));
+		assertEqualString("file1", archive_entry_symlink(ae));
+	} else {
+		assertEqualInt(AE_IFREG | 0777, archive_entry_mode(ae));
+		assertEqualInt(0, archive_entry_size(ae));
+	}
+
+	/*
+	 * Read the dir entry back.
+	 */
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualInt(11, archive_entry_mtime(ae));
+	assertEqualInt(0, archive_entry_mtime_nsec(ae));
+	assertEqualInt(0, archive_entry_atime(ae));
+	assertEqualInt(0, archive_entry_ctime(ae));
+	assertEqualString("dir/", archive_entry_pathname(ae));
+	if (expect_details)
+		assertEqualInt(AE_IFDIR | 0755, archive_entry_mode(ae));
+	assertEqualInt(0, archive_entry_size(ae));
+	assertEqualIntA(a, 0, archive_read_data(a, filedata, 10));
+
+	/* Verify the end of the archive. */
+	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+	assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+}
 
 DEFINE_TEST(test_write_format_zip)
 {
-	char filedata[64];
 	struct archive_entry *ae;
 	struct archive *a;
 	size_t used;
@@ -49,12 +130,12 @@
 	assert((a = archive_write_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_zip(a));
 #ifdef HAVE_ZLIB_H
-	compression_type = "zip:compression=deflate";
+	compression_type = "deflate";
 #else
-	compression_type = "zip:compression=store";
+	compression_type = "store";
 #endif
 	assertEqualIntA(a, ARCHIVE_OK,
-	    archive_write_set_format_options(a, compression_type));
+	    archive_write_set_format_option(a, "zip", "compression", compression_type));
 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_none(a));
 	assertEqualIntA(a, ARCHIVE_OK,
 	    archive_write_open_memory(a, buff, buffsize, &used));
@@ -68,7 +149,7 @@
 	assertEqualInt(10, archive_entry_mtime_nsec(ae));
 	archive_entry_copy_pathname(ae, "file");
 	assertEqualString("file", archive_entry_pathname(ae));
-	archive_entry_set_mode(ae, S_IFREG | 0755);
+	archive_entry_set_mode(ae, AE_IFREG | 0755);
 	assertEqualInt((S_IFREG | 0755), archive_entry_mode(ae));
 	archive_entry_set_size(ae, 8);
 
@@ -86,7 +167,7 @@
 	assertEqualInt(10, archive_entry_mtime_nsec(ae));
 	archive_entry_copy_pathname(ae, "file2");
 	assertEqualString("file2", archive_entry_pathname(ae));
-	archive_entry_set_mode(ae, S_IFREG | 0755);
+	archive_entry_set_mode(ae, AE_IFREG | 0755);
 	assertEqualInt((S_IFREG | 0755), archive_entry_mode(ae));
 	archive_entry_set_size(ae, 4);
 
@@ -95,6 +176,24 @@
 	assertEqualInt(4, archive_write_data(a, "1234", 5));
 
 	/*
+	 * Write symbolic like file to it.
+	 */
+	assert((ae = archive_entry_new()) != NULL);
+	archive_entry_set_mtime(ae, 1, 10);
+	assertEqualInt(1, archive_entry_mtime(ae));
+	assertEqualInt(10, archive_entry_mtime_nsec(ae));
+	archive_entry_copy_pathname(ae, "symlink");
+	assertEqualString("symlink", archive_entry_pathname(ae));
+	archive_entry_copy_symlink(ae, "file1");
+	assertEqualString("file1", archive_entry_symlink(ae));
+	archive_entry_set_mode(ae, AE_IFLNK | 0755);
+	assertEqualInt((AE_IFLNK | 0755), archive_entry_mode(ae));
+	archive_entry_set_size(ae, 4);
+
+	assertEqualInt(ARCHIVE_OK, archive_write_header(a, ae));
+	archive_entry_free(ae);
+
+	/*
 	 * Write a directory to it.
 	 */
 	assert((ae = archive_entry_new()) != NULL);
@@ -111,70 +210,32 @@
 
 	/* Close out the archive. */
 	assertEqualInt(ARCHIVE_OK, archive_write_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/*
 	 * Now, read the data back.
 	 */
-	ae = NULL;
+	/* With the standard memory reader. */
 	assert((a = archive_read_new()) != NULL);
 	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
-	assertEqualIntA(a, ARCHIVE_OK,
-	    archive_read_support_compression_all(a));
-	assertEqualIntA(a, ARCHIVE_OK,
-	    archive_read_open_memory(a, buff, used));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff, used));
+	verify_contents(a, 1);
 
-	/*
-	 * Read and verify first file.
-	 */
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
-	assertEqualInt(1, archive_entry_mtime(ae));
-	/* Zip doesn't store high-resolution mtime. */
-	assertEqualInt(0, archive_entry_mtime_nsec(ae));
-	assertEqualInt(0, archive_entry_atime(ae));
-	assertEqualInt(0, archive_entry_ctime(ae));
-	assertEqualString("file", archive_entry_pathname(ae));
-	//assertEqualInt((S_IFREG | 0755), archive_entry_mode(ae));
-	assertEqualInt(0, archive_entry_size(ae));
-	assertEqualIntA(a, 8,
-	    archive_read_data(a, filedata, sizeof(filedata)));
-	assertEqualMem(filedata, "12345678", 8);
+	/* With the test memory reader -- streaming mode. */
+	assert((a = archive_read_new()) != NULL);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, read_open_memory(a, buff, used, 7));
+	/* Streaming reader doesn't see mode information from Central Directory. */
+	verify_contents(a, 0);
 
+	/* With the test memory reader -- seeking mode. */
+	assert((a = archive_read_new()) != NULL);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, read_open_memory_seek(a, buff, used, 7));
+	verify_contents(a, 1);
 
-	/*
-	 * Read the second file back.
-	 */
-	if (!assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae))){
-		free(buff);
-		return;
-	}
-	assertEqualInt(1, archive_entry_mtime(ae));
-	assertEqualInt(0, archive_entry_mtime_nsec(ae));
-	assertEqualInt(0, archive_entry_atime(ae));
-	assertEqualInt(0, archive_entry_ctime(ae));
-	assertEqualString("file2", archive_entry_pathname(ae));
-	//assert((S_IFREG | 0755) == archive_entry_mode(ae));
-	assertEqualInt(0, archive_entry_size(ae));
-	assertEqualIntA(a, 4,
-	    archive_read_data(a, filedata, sizeof(filedata)));
-	assertEqualMem(filedata, "1234", 4);
-
-	/*
-	 * Read the dir entry back.
-	 */
-	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
-	assertEqualInt(11, archive_entry_mtime(ae));
-	assertEqualInt(0, archive_entry_mtime_nsec(ae));
-	assertEqualInt(0, archive_entry_atime(ae));
-	assertEqualInt(0, archive_entry_ctime(ae));
-	assertEqualString("dir/", archive_entry_pathname(ae));
-	//assertEqualInt((S_IFDIR | 0755), archive_entry_mode(ae));
-	assertEqualInt(0, archive_entry_size(ae));
-	assertEqualIntA(a, 0, archive_read_data(a, filedata, 10));
-
-	/* Verify the end of the archive. */
-	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
-	assertEqualInt(ARCHIVE_OK, archive_read_close(a));
-	assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
 	free(buff);
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_write_format_zip_empty.c
--- a/head/contrib/libarchive/libarchive/test/test_write_format_zip_empty.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_write_format_zip_empty.c	Fri Mar 02 16:54:40 2012 +0200
@@ -28,29 +28,51 @@
  */
 
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_format_zip_empty.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_format_zip_empty.c 232153 2012-02-25 10:58:02Z mm $");
 
 DEFINE_TEST(test_write_format_zip_empty)
 {
 	struct archive *a;
+	struct archive_entry *ae;
 	char buff[256];
 	size_t used;
 
 	/* Zip format: Create a new archive in memory. */
 	assert((a = archive_write_new()) != NULL);
-	assertA(0 == archive_write_set_format_zip(a));
-	assertA(0 == archive_write_set_compression_none(a));
-	assertA(0 == archive_write_set_bytes_per_block(a, 1));
-	assertA(0 == archive_write_set_bytes_in_last_block(a, 1));
-	assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_zip(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_none(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_bytes_per_block(a, 1));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_bytes_in_last_block(a, 1));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, sizeof(buff), &used));
 
 	/* Close out the archive without writing anything. */
-	assertA(0 == archive_write_close(a));
-	assertA(0 == archive_write_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/* Verify the correct format for an empy Zip archive. */
 	assertEqualInt(used, 22);
 	assertEqualMem(buff,
 	    "PK\005\006\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
 	    22);
+
+	/* Verify that we read this kind of empty archive correctly. */
+	/* Try with the standard memory reader, and with the test
+	   memory reader with and without seek support. */
+	assert((a = archive_read_new()) != NULL);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff, 22));
+	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
+
+	assert((a = archive_read_new()) != NULL);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a));
+	assertEqualIntA(a, ARCHIVE_OK, read_open_memory(a, buff, 22, 1));
+	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
+
+	assert((a = archive_read_new()) != NULL);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a));
+	assertEqualIntA(a, ARCHIVE_OK, read_open_memory_seek(a, buff, 22, 22));
+	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_write_format_zip_no_compression.c
--- a/head/contrib/libarchive/libarchive/test/test_write_format_zip_no_compression.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_write_format_zip_no_compression.c	Fri Mar 02 16:54:40 2012 +0200
@@ -28,7 +28,7 @@
  */
 
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_format_zip_no_compression.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_format_zip_no_compression.c 232153 2012-02-25 10:58:02Z mm $");
 
 static unsigned long
 bitcrc32(unsigned long c, void *_p, size_t s)
@@ -98,7 +98,7 @@
 	/* Create new ZIP archive in memory without padding. */
 	assert((a = archive_write_new()) != NULL);
 	assertA(0 == archive_write_set_format_zip(a));
-	assertA(0 == archive_write_set_format_options(a, "zip:compression=store"));
+	assertA(0 == archive_write_set_options(a, "zip:compression=store"));
 	assertA(0 == archive_write_set_compression_none(a));
 	assertA(0 == archive_write_set_bytes_per_block(a, 1));
 	assertA(0 == archive_write_set_bytes_in_last_block(a, 1));
@@ -135,8 +135,8 @@
 	archive_entry_free(entry);
 
 	/* Close the archive . */
-	assertA(0 == archive_write_close(a));
-	assertA(0 == archive_write_finish(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
 
 	/* Remember the end of the archive in memory. */
 	buffend = buff + used;
@@ -191,8 +191,8 @@
 	assertEqualInt(p[4], 7); /* 'UT' flags */
 	assertEqualInt(i4(p + 5), t); /* 'UT' mtime */
 	p = p + 9;
-	assertEqualInt(i2(p), 0x7855); /* 'Ux' extension header */
-	assertEqualInt(i2(p + 2), 0); /* 'Ux' size */
+	assertEqualInt(i2(p), 0x7875); /* 'ux' extension header */
+	assertEqualInt(i2(p + 2), 0); /* 'ux' size */
 	p = p + 4;
 
 	/* Verify local header of file entry. */
@@ -207,7 +207,7 @@
 	assertEqualInt(i4(q + 18), sizeof(file_data1) + sizeof(file_data2)); /* Compressed size */
 	assertEqualInt(i4(q + 22), sizeof(file_data1) + sizeof(file_data2)); /* Uncompressed size */
 	assertEqualInt(i2(q + 26), strlen(file_name)); /* Pathname length */
-	assertEqualInt(i2(q + 28), 25); /* Extra field length */
+	assertEqualInt(i2(q + 28), 32); /* Extra field length */
 	assertEqualMem(q + 30, file_name, strlen(file_name)); /* Pathname */
 	q = q + 30 + strlen(file_name);
 	assertEqualInt(i2(q), 0x5455); /* 'UT' extension header */
@@ -217,11 +217,14 @@
 	assertEqualInt(i4(q + 9), t); /* 'UT' atime */
 	assertEqualInt(i4(q + 13), t); /* 'UT' ctime */
 	q = q + 17;
-	assertEqualInt(i2(q), 0x7855); /* 'Ux' extension header */
-	assertEqualInt(i2(q + 2), 4); /* 'Ux' size */
-	assertEqualInt(i2(q + 4), file_uid); /* 'Ux' UID */
-	assertEqualInt(i2(q + 6), file_gid); /* 'Ux' GID */
-	q = q + 8;
+	assertEqualInt(i2(q), 0x7875); /* 'ux' extension header */
+	assertEqualInt(i2(q + 2), 11); /* 'ux' size */
+	assertEqualInt(q[4], 1); /* 'ux' version */
+	assertEqualInt(q[5], 4); /* 'ux' uid size */
+	assertEqualInt(i4(q + 6), file_uid); /* 'Ux' UID */
+	assertEqualInt(q[10], 4); /* 'ux' gid size */
+	assertEqualInt(i4(q + 11), file_gid); /* 'Ux' GID */
+	q = q + 15;
 
 	/* Verify data of file entry. */
 	assertEqualMem(q, file_data1, sizeof(file_data1));
@@ -261,9 +264,9 @@
 	assertEqualInt(p[4], 7); /* 'UT' flags */
 	assertEqualInt(i4(p + 5), t); /* 'UT' mtime */
 	p = p + 9;
-	assertEqualInt(i2(p), 0x7855); /* 'Ux' extension header */
-	assertEqualInt(i2(p + 2), 0); /* 'Ux' size */
-	p = p + 4;
+	assertEqualInt(i2(p), 0x7875); /* 'ux' extension header */
+	assertEqualInt(i2(p + 2), 0); /* 'ux' size */
+	/*p = p + 4;*/
 
 	/* Verify local header of folder entry. */
 	assertEqualMem(q, "PK\003\004", 4); /* Signature */
@@ -276,7 +279,7 @@
 	assertEqualInt(i4(q + 18), 0); /* Compressed size */
 	assertEqualInt(i4(q + 22), 0); /* Uncompressed size */
 	assertEqualInt(i2(q + 26), strlen(folder_name)); /* Pathname length */
-	assertEqualInt(i2(q + 28), 25); /* Extra field length */
+	assertEqualInt(i2(q + 28), 32); /* Extra field length */
 	assertEqualMem(q + 30, folder_name, strlen(folder_name)); /* Pathname */
 	q = q + 30 + strlen(folder_name);
 	assertEqualInt(i2(q), 0x5455); /* 'UT' extension header */
@@ -286,11 +289,14 @@
 	assertEqualInt(i4(q + 9), t); /* 'UT' atime */
 	assertEqualInt(i4(q + 13), t); /* 'UT' ctime */
 	q = q + 17;
-	assertEqualInt(i2(q), 0x7855); /* 'Ux' extension header */
-	assertEqualInt(i2(q + 2), 4); /* 'Ux' size */
-	assertEqualInt(i2(q + 4), folder_uid); /* 'Ux' UID */
-	assertEqualInt(i2(q + 6), folder_gid); /* 'Ux' GID */
-	q = q + 8;
+	assertEqualInt(i2(q), 0x7875); /* 'ux' extension header */
+	assertEqualInt(i2(q + 2), 11); /* 'ux' size */
+	assertEqualInt(q[4], 1); /* 'ux' version */
+	assertEqualInt(q[5], 4); /* 'ux' uid size */
+	assertEqualInt(i4(q + 6), folder_uid); /* 'ux' UID */
+	assertEqualInt(q[10], 4); /* 'ux' gid size */
+	assertEqualInt(i4(q + 11), folder_gid); /* 'ux' GID */
+	q = q + 15;
 
 	/* There should not be any data in the folder entry,
 	 * meaning next is the data descriptor header. */
@@ -300,5 +306,5 @@
 	assertEqualInt(i4(q + 4), crc); /* CRC-32 */
 	assertEqualInt(i4(q + 8), 0); /* Compressed size */
 	assertEqualInt(i4(q + 12), 0); /* Uncompressed size */
-	q = q + 16;
+	/*q = q + 16;*/
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive/test/test_write_open_memory.c
--- a/head/contrib/libarchive/libarchive/test/test_write_open_memory.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive/test/test_write_open_memory.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_open_memory.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/test/test_write_open_memory.c 232153 2012-02-25 10:58:02Z mm $");
 
 /* Try to force archive_write_open_memory.c to write past the end of an array. */
 static unsigned char buff[16384];
@@ -45,32 +45,40 @@
 	/* Make sure that we get failure on too-small buffers, success on
 	 * large enough ones. */
 	for (i = 100; i < 1600; i++) {
-		size_t s;
+		size_t used;
 		size_t blocksize = 94;
 		assert((a = archive_write_new()) != NULL);
-		assertA(0 == archive_write_set_format_ustar(a));
-		assertA(0 == archive_write_set_bytes_in_last_block(a, 1));
-		assertA(0 == archive_write_set_bytes_per_block(a, (int)blocksize));
+		assertEqualIntA(a, ARCHIVE_OK,
+		    archive_write_set_format_ustar(a));
+		assertEqualIntA(a, ARCHIVE_OK,
+		    archive_write_set_bytes_in_last_block(a, 1));
+		assertEqualIntA(a, ARCHIVE_OK,
+		    archive_write_set_bytes_per_block(a, (int)blocksize));
 		buff[i] = 0xAE;
-		assertA(0 == archive_write_open_memory(a, buff, i, &s));
+		assertEqualIntA(a, ARCHIVE_OK,
+		    archive_write_open_memory(a, buff, i, &used));
 		/* If buffer is smaller than a tar header, this should fail. */
 		if (i < (511/blocksize)*blocksize)
-			assertA(ARCHIVE_FATAL == archive_write_header(a,ae));
+			assertEqualIntA(a, ARCHIVE_FATAL,
+			    archive_write_header(a,ae));
 		else
-			assertA(0 == archive_write_header(a, ae));
+			assertEqualIntA(a, ARCHIVE_OK,
+			    archive_write_header(a, ae));
 		/* If buffer is smaller than a tar header plus 1024 byte
 		 * end-of-archive marker, then this should fail. */
+		failure("buffer size=%d\n", (int)i);
 		if (i < 1536)
-			assertA(ARCHIVE_FATAL == archive_write_close(a));
-		else
-			assertA(0 == archive_write_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-		archive_write_finish(a);
-#else
-		assert(0 == archive_write_finish(a));
-#endif
-		assert(buff[i] == 0xAE);
-		assert(s <= i);
+			assertEqualIntA(a, ARCHIVE_FATAL,
+			    archive_write_close(a));
+		else {
+			assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+			assertEqualInt(used, archive_position_compressed(a));
+			assertEqualInt(archive_position_compressed(a),
+			    archive_position_uncompressed(a));
+		}
+		assertEqualInt(ARCHIVE_OK, archive_write_free(a));
+		assertEqualInt(buff[i], 0xAE);
+		assert(used <= i);
 	}
 	archive_entry_free(ae);
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive_fe/line_reader.c
--- a/head/contrib/libarchive/libarchive_fe/line_reader.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive_fe/line_reader.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,6 @@
 /*-
  * Copyright (c) 2008 Tim Kientzle
+ * Copyright (c) 2010 Joerg Sonnenberger
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -25,7 +26,7 @@
  */
 
 #include "lafe_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive_fe/line_reader.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive_fe/line_reader.c 232153 2012-02-25 10:58:02Z mm $");
 
 #include <errno.h>
 #include <stdio.h>
@@ -74,14 +75,20 @@
 	if (lr->f == NULL)
 		lafe_errc(1, errno, "Couldn't open %s", pathname);
 	lr->buff_length = 8192;
-	lr->buff = malloc(lr->buff_length);
-	if (lr->buff == NULL)
-		lafe_errc(1, ENOMEM, "Can't read %s", pathname);
-	lr->line_start = lr->line_end = lr->buff_end = lr->buff;
+	lr->line_start = lr->line_end = lr->buff_end = lr->buff = NULL;
 
 	return (lr);
 }
 
+static void
+lafe_line_reader_find_eol(struct lafe_line_reader *lr)
+{
+
+	lr->line_end += strcspn(lr->line_end,
+	    lr->nullSeparator ? "" : "\x0d\x0a");
+	*lr->line_end = '\0'; /* Noop if line_end == buff_end */
+}
+
 const char *
 lafe_line_reader_next(struct lafe_line_reader *lr)
 {
@@ -91,36 +98,21 @@
 	for (;;) {
 		/* If there's a line in the buffer, return it immediately. */
 		while (lr->line_end < lr->buff_end) {
-			if (lr->nullSeparator) {
-				if (*lr->line_end == '\0') {
-					line_start = lr->line_start;
-					lr->line_start = lr->line_end + 1;
-					lr->line_end = lr->line_start;
-					return (line_start);
-				}
-			} else if (*lr->line_end == '\x0a' || *lr->line_end == '\x0d') {
-				*lr->line_end = '\0';
-				line_start = lr->line_start;
-				lr->line_start = lr->line_end + 1;
-				lr->line_end = lr->line_start;
-				if (line_start[0] != '\0')
-					return (line_start);
-			}
-			lr->line_end++;
+			line_start = lr->line_start;
+			lr->line_start = ++lr->line_end;
+			lafe_line_reader_find_eol(lr);
+
+			if (lr->nullSeparator || line_start[0] != '\0')
+				return (line_start);
 		}
 
 		/* If we're at end-of-file, process the final data. */
 		if (lr->f == NULL) {
-			/* If there's more text, return one last line. */
-			if (lr->line_end > lr->line_start) {
-				*lr->line_end = '\0';
-				line_start = lr->line_start;
-				lr->line_start = lr->line_end + 1;
-				lr->line_end = lr->line_start;
-				return (line_start);
-			}
-			/* Otherwise, we're done. */
-			return (NULL);
+			if (lr->line_start == lr->buff_end)
+				return (NULL); /* No more text */
+			line_start = lr->line_start;
+			lr->line_start = lr->buff_end;
+			return (line_start);
 		}
 
 		/* Buffer only has part of a line. */
@@ -138,7 +130,11 @@
 				lafe_errc(1, ENOMEM,
 				    "Line too long in %s", lr->pathname);
 			lr->buff_length = new_buff_size;
-			p = realloc(lr->buff, new_buff_size);
+			/*
+			 * Allocate one extra byte to allow terminating
+			 * the buffer.
+			 */
+			p = realloc(lr->buff, new_buff_size + 1);
 			if (p == NULL)
 				lafe_errc(1, ENOMEM,
 				    "Line too long in %s", lr->pathname);
@@ -151,6 +147,8 @@
 		bytes_wanted = lr->buff + lr->buff_length - lr->buff_end;
 		bytes_read = fread(lr->buff_end, 1, bytes_wanted, lr->f);
 		lr->buff_end += bytes_read;
+		*lr->buff_end = '\0'; /* Always terminate buffer */
+		lafe_line_reader_find_eol(lr);
 
 		if (ferror(lr->f))
 			lafe_errc(1, errno, "Can't read %s", lr->pathname);
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive_fe/matching.c
--- a/head/contrib/libarchive/libarchive_fe/matching.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive_fe/matching.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  */
 
 #include "lafe_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive_fe/matching.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive_fe/matching.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
@@ -140,7 +140,7 @@
 	strcpy(match->pattern, pattern);
 	/* Both "foo/" and "foo" should match "foo/bar". */
 	if (len && match->pattern[len - 1] == '/')
-		match->pattern[strlen(match->pattern)-1] = '\0';
+		match->pattern[len - 1] = '\0';
 	match->next = *list;
 	*list = match;
 	match->matches = 0;
@@ -156,40 +156,41 @@
 	if (matching == NULL)
 		return (0);
 
+	/* Mark off any unmatched inclusions. */
+	/* In particular, if a filename does appear in the archive and
+	 * is explicitly included and excluded, then we don't report
+	 * it as missing even though we don't extract it.
+	 */
+	matched = NULL;
+	for (match = matching->inclusions; match != NULL; match = match->next){
+		if (match->matches == 0
+		    && match_inclusion(match, pathname)) {
+			matching->inclusions_unmatched_count--;
+			match->matches++;
+			matched = match;
+		}
+	}
+
 	/* Exclusions take priority */
 	for (match = matching->exclusions; match != NULL; match = match->next){
 		if (match_exclusion(match, pathname))
 			return (1);
 	}
 
-	/* Then check for inclusions */
-	matched = NULL;
+	/* It's not excluded and we found an inclusion above, so it's included. */
+	if (matched != NULL)
+		return (0);
+
+
+	/* We didn't find an unmatched inclusion, check the remaining ones. */
 	for (match = matching->inclusions; match != NULL; match = match->next){
-		if (match_inclusion(match, pathname)) {
-			/*
-			 * If this pattern has never been matched,
-			 * then we're done.
-			 */
-			if (match->matches == 0) {
-				match->matches++;
-				matching->inclusions_unmatched_count--;
-				return (0);
-			}
-			/*
-			 * Otherwise, remember the match but keep checking
-			 * in case we can tick off an unmatched pattern.
-			 */
-			matched = match;
+		/* We looked at previously-unmatched inclusions already. */
+		if (match->matches > 0
+		    && match_inclusion(match, pathname)) {
+			match->matches++;
+			return (0);
 		}
 	}
-	/*
-	 * We didn't find a pattern that had never been matched, but
-	 * we did find a match, so count it and exit.
-	 */
-	if (matched != NULL) {
-		matched->matches++;
-		return (0);
-	}
 
 	/* If there were inclusions, default is to exclude. */
 	if (matching->inclusions != NULL)
@@ -219,11 +220,7 @@
 static int
 match_inclusion(struct match *match, const char *pathname)
 {
-#if 0
-	return (lafe_pathmatch(match->pattern, pathname, 0));
-#else
 	return (lafe_pathmatch(match->pattern, pathname, PATHMATCH_NO_ANCHOR_END));
-#endif	
 }
 
 void
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/libarchive_fe/pathmatch.c
--- a/head/contrib/libarchive/libarchive_fe/pathmatch.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/libarchive_fe/pathmatch.c	Fri Mar 02 16:54:40 2012 +0200
@@ -25,7 +25,7 @@
  */
 
 #include "lafe_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive_fe/pathmatch.c 228775 2011-12-21 15:22:05Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive_fe/pathmatch.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_STRING_H
 #include <string.h>
@@ -132,7 +132,7 @@
 			}
 			return (*s == '\0');
 		case '?':
-			/* ? always succeds, unless we hit end of 's' */
+			/* ? always succeeds, unless we hit end of 's' */
 			if (*s == '\0')
 				return (0);
 			break;
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/tar/bsdtar.1
--- a/head/contrib/libarchive/tar/bsdtar.1	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/tar/bsdtar.1	Fri Mar 02 16:54:40 2012 +0200
@@ -22,10 +22,10 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $FreeBSD: head/contrib/libarchive/tar/bsdtar.1 228776 2011-12-21 15:30:49Z mm $
+.\" $FreeBSD: head/contrib/libarchive/tar/bsdtar.1 232153 2012-02-25 10:58:02Z mm $
 .\"
 .Dd Oct 12, 2009
-.Dt BSDTAR 1
+.Dt TAR 1
 .Os
 .Sh NAME
 .Nm tar
@@ -51,8 +51,8 @@
 .Nm
 creates and manipulates streaming archive files.
 This implementation can extract from tar, pax, cpio, zip, jar, ar, xar,
-rpm and ISO 9660 cdrom images and can create tar, pax, cpio, ar, zip,
-and shar archives.
+rpm, 7-zip, and ISO 9660 cdrom images and can create tar, pax, cpio, ar, zip,
+7-zip, and shar archives.
 .Pp
 The first synopsis form shows a
 .Dq bundled
@@ -153,7 +153,7 @@
 As a rule, this argument is only needed when reading from or writing
 to tape drives, and usually not even then as the default block size of
 20 records (10240 bytes) is very common.
-.It Fl C Ar directory
+.It Fl C Ar directory , Fl Fl cd Ar directory , Fl Fl directory Ar directory
 In c and r mode, this changes the directory before adding
 the following files.
 In x mode, change directories after opening the archive
@@ -473,7 +473,7 @@
 flags and ACLs, if available, for each item extracted from the archive.
 This is the default, if
 .Nm
-is being run by root and can be overriden by also specifying
+is being run by root and can be overridden by also specifying
 .Fl Fl no-same-owner
 and
 .Fl Fl no-same-permissions .
@@ -496,25 +496,11 @@
 For every block on disk, check first if it contains only NULL bytes and seek
 over it otherwise.
 This works similar to the conv=sparse option of dd.
-.It Fl Fl same-owner
-(x mode only)
-Extract owner and group IDs.
-This is the reverse of
-.Fl Fl no-same-owner
-and the default behavior if
-.Nm
-is run as root.
-.It Fl Fl strip-components Ar count
-(x mode only)
-Remove the specified number of leading path elements.
-Pathnames with fewer elements will be silently skipped.
-Note that the pathname is edited after checking inclusion/exclusion patterns
-but before security checks.
 .It Fl s Ar pattern
 Modify file or archive member names according to
 .Pa pattern .
 The pattern has the format
-.Ar /old/new/ Ns Op gps
+.Ar /old/new/ Ns Op ghHprRsS
 where
 .Ar old
 is a basic regular expression,
@@ -530,12 +516,35 @@
 ~ is substituted with the match, \e1 to \e9 with the content of
 the corresponding captured group.
 The optional trailing g specifies that matching should continue
-after the matched part and stopped on the first unmatched pattern.
+after the matched part and stop on the first unmatched pattern.
 The optional trailing s specifies that the pattern applies to the value
 of symbolic links.
 The optional trailing p specifies that after a successful substitution
 the original path name and the new path name should be printed to
 standard error.
+Optional trailing H, R, or S characters suppress substitutions
+for hardlink targets, regular filenames, or symlink targets,
+respectively.
+Optional trailing h, r, or s characters enable substitutions
+for hardlink targets, regular filenames, or symlink targets,
+respectively.
+The default is
+.Ar hrs
+which applies substitutions to all names.
+In particular, it is never necessary to specify h, r, or s.
+.It Fl Fl same-owner
+(x mode only)
+Extract owner and group IDs.
+This is the reverse of
+.Fl Fl no-same-owner
+and the default behavior if
+.Nm
+is run as root.
+.It Fl Fl strip-components Ar count
+Remove the specified number of leading path elements.
+Pathnames with fewer elements will be silently skipped.
+Note that the pathname is edited after checking inclusion/exclusion patterns
+but before security checks.
 .It Fl T Ar filename , Fl Fl files-from Ar filename
 In x or t mode,
 .Nm
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/tar/bsdtar.c
--- a/head/contrib/libarchive/tar/bsdtar.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/tar/bsdtar.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  */
 
 #include "bsdtar_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/tar/bsdtar.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/tar/bsdtar.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
@@ -32,6 +32,9 @@
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
 #endif
+#ifdef HAVE_COPYFILE_H
+#include <copyfile.h>
+#endif
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
 #endif
@@ -63,9 +66,6 @@
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
-#if HAVE_ZLIB_H
-#include <zlib.h>
-#endif
 
 #include "bsdtar.h"
 #include "err.h"
@@ -80,6 +80,10 @@
 #if defined(_WIN32) && !defined(__CYGWIN__)
 #define	_PATH_DEFTAPE "\\\\.\\tape0"
 #endif
+#if defined(__APPLE__)
+#undef _PATH_DEFTAPE
+#define	_PATH_DEFTAPE "-"  /* Mac OS has no tape support, default to stdio. */
+#endif
 
 #ifndef _PATH_DEFTAPE
 #define	_PATH_DEFTAPE "/dev/tape"
@@ -89,8 +93,6 @@
 int _CRT_glob = 0; /* Disable broken CRT globbing. */
 #endif
 
-static struct bsdtar *_bsdtar;
-
 #if defined(HAVE_SIGACTION) && (defined(SIGINFO) || defined(SIGUSR1))
 static volatile int siginfo_occurred;
 
@@ -144,15 +146,15 @@
 	 * Use a pointer for consistency, but stack-allocated storage
 	 * for ease of cleanup.
 	 */
-	_bsdtar = bsdtar = &bsdtar_storage;
+	bsdtar = &bsdtar_storage;
 	memset(bsdtar, 0, sizeof(*bsdtar));
 	bsdtar->fd = -1; /* Mark as "unused" */
 	bsdtar->gid = -1;
 	bsdtar->uid = -1;
 	option_o = 0;
 
-#if defined(HAVE_SIGACTION) && (defined(SIGINFO) || defined(SIGUSR1))
-	{ /* Catch SIGINFO and SIGUSR1, if they exist. */
+#if defined(HAVE_SIGACTION)
+	{ /* Set up signal handling. */
 		struct sigaction sa;
 		sa.sa_handler = siginfo_handler;
 		sigemptyset(&sa.sa_mask);
@@ -166,6 +168,11 @@
 		if (sigaction(SIGUSR1, &sa, NULL))
 			lafe_errc(1, errno, "sigaction(SIGUSR1) failed");
 #endif
+#ifdef SIGPIPE
+		/* Ignore SIGPIPE signals. */
+		sa.sa_handler = SIG_IGN;
+		sigaction(SIGPIPE, &sa, NULL);
+#endif
 	}
 #endif
 
@@ -176,9 +183,9 @@
 	else {
 #if defined(_WIN32) && !defined(__CYGWIN__)
 		lafe_progname = strrchr(*argv, '\\');
-#else
+		if (strrchr(*argv, '/') > lafe_progname)
+#endif
 		lafe_progname = strrchr(*argv, '/');
-#endif
 		if (lafe_progname != NULL)
 			lafe_progname++;
 		else
@@ -204,6 +211,11 @@
 	if (bsdtar->filename == NULL)
 		bsdtar->filename = _PATH_DEFTAPE;
 
+	/* Default block size settings. */
+	bsdtar->bytes_per_block = DEFAULT_BYTES_PER_BLOCK;
+	/* Allow library to default this unless user specifies -b. */
+	bsdtar->bytes_in_last_block = -1;
+
 	/* Default: preserve mod time on extract */
 	bsdtar->extract_flags = ARCHIVE_EXTRACT_TIME;
 
@@ -221,9 +233,20 @@
 		bsdtar->extract_flags |= ARCHIVE_EXTRACT_ACL;
 		bsdtar->extract_flags |= ARCHIVE_EXTRACT_XATTR;
 		bsdtar->extract_flags |= ARCHIVE_EXTRACT_FFLAGS;
+		bsdtar->extract_flags |= ARCHIVE_EXTRACT_MAC_METADATA;
 	}
 #endif
 
+	/*
+	 * Enable Mac OS "copyfile()" extension by default.
+	 * This has no effect on other platforms.
+	 */
+	bsdtar->enable_copyfile = 1;
+#ifdef COPYFILE_DISABLE_VAR
+	if (getenv(COPYFILE_DISABLE_VAR))
+		bsdtar->enable_copyfile = 0;
+#endif
+
 	bsdtar->argv = argv;
 	bsdtar->argc = argc;
 
@@ -239,14 +262,20 @@
 			/* libarchive doesn't need this; just ignore it. */
 			break;
 		case 'b': /* SUSv2 */
-			t = atoi(bsdtar->optarg);
+			t = atoi(bsdtar->argument);
 			if (t <= 0 || t > 8192)
 				lafe_errc(1, 0,
 				    "Argument to -b is out of range (1..8192)");
 			bsdtar->bytes_per_block = 512 * t;
+			/* Explicit -b forces last block size. */
+			bsdtar->bytes_in_last_block = bsdtar->bytes_per_block;
 			break;
 		case 'C': /* GNU tar */
-			set_chdir(bsdtar, bsdtar->optarg);
+			if (strlen(bsdtar->argument) == 0)
+				lafe_errc(1, 0,
+				    "Meaningless option: -C ''");
+
+			set_chdir(bsdtar, bsdtar->argument);
 			break;
 		case 'c': /* SUSv2 */
 			set_mode(bsdtar, opt);
@@ -257,28 +286,29 @@
 		case OPTION_CHROOT: /* NetBSD */
 			bsdtar->option_chroot = 1;
 			break;
+		case OPTION_DISABLE_COPYFILE: /* Mac OS X */
+			bsdtar->enable_copyfile = 0;
+			break;
 		case OPTION_EXCLUDE: /* GNU tar */
-			if (lafe_exclude(&bsdtar->matching, bsdtar->optarg))
+			if (lafe_exclude(&bsdtar->matching, bsdtar->argument))
 				lafe_errc(1, 0,
-				    "Couldn't exclude %s\n", bsdtar->optarg);
+				    "Couldn't exclude %s\n", bsdtar->argument);
 			break;
 		case OPTION_FORMAT: /* GNU tar, others */
-			bsdtar->create_format = bsdtar->optarg;
+			bsdtar->create_format = bsdtar->argument;
 			break;
 		case 'f': /* SUSv2 */
-			bsdtar->filename = bsdtar->optarg;
-			if (strcmp(bsdtar->filename, "-") == 0)
-				bsdtar->filename = NULL;
+			bsdtar->filename = bsdtar->argument;
 			break;
 		case OPTION_GID: /* cpio */
-			t = atoi(bsdtar->optarg);
+			t = atoi(bsdtar->argument);
 			if (t < 0)
 				lafe_errc(1, 0,
 				    "Argument to --gid must be positive");
 			bsdtar->gid = t;
 			break;
 		case OPTION_GNAME: /* cpio */
-			bsdtar->gname = bsdtar->optarg;
+			bsdtar->gname = bsdtar->argument;
 			break;
 		case 'H': /* BSD convention */
 			bsdtar->symlink_mode = 'H';
@@ -303,18 +333,18 @@
 			 * permissions without having to create those
 			 * permissions on disk.
 			 */
-			bsdtar->names_from_file = bsdtar->optarg;
+			bsdtar->names_from_file = bsdtar->argument;
 			break;
 		case OPTION_INCLUDE:
 			/*
-			 * Noone else has the @archive extension, so
-			 * noone else needs this to filter entries
+			 * No one else has the @archive extension, so
+			 * no one else needs this to filter entries
 			 * when transforming archives.
 			 */
-			if (lafe_include(&bsdtar->matching, bsdtar->optarg))
+			if (lafe_include(&bsdtar->matching, bsdtar->argument))
 				lafe_errc(1, 0,
 				    "Failed to add %s to inclusion list",
-				    bsdtar->optarg);
+				    bsdtar->argument);
 			break;
 		case 'j': /* GNU tar */
 			if (bsdtar->create_compression != '\0')
@@ -343,7 +373,8 @@
 			/* GNU tar 1.13  used -l for --one-file-system */
 			bsdtar->option_warn_links = 1;
 			break;
-		case OPTION_LZMA:
+		case OPTION_LZIP: /* GNU tar beginning with 1.23 */
+		case OPTION_LZMA: /* GNU tar beginning with 1.20 */
 			if (bsdtar->create_compression != '\0')
 				lafe_errc(1, 0,
 				    "Can't specify both -%c and -%c", opt,
@@ -364,28 +395,32 @@
 		 * TODO: Add corresponding "older" options to reverse these.
 		 */
 		case OPTION_NEWER_CTIME: /* GNU tar */
-			bsdtar->newer_ctime_sec = get_date(now, bsdtar->optarg);
+			bsdtar->newer_ctime_filter = 1;
+			bsdtar->newer_ctime_sec = get_date(now, bsdtar->argument);
 			break;
 		case OPTION_NEWER_CTIME_THAN:
 			{
 				struct stat st;
-				if (stat(bsdtar->optarg, &st) != 0)
+				if (stat(bsdtar->argument, &st) != 0)
 					lafe_errc(1, 0,
-					    "Can't open file %s", bsdtar->optarg);
+					    "Can't open file %s", bsdtar->argument);
+				bsdtar->newer_ctime_filter = 1;
 				bsdtar->newer_ctime_sec = st.st_ctime;
 				bsdtar->newer_ctime_nsec =
 				    ARCHIVE_STAT_CTIME_NANOS(&st);
 			}
 			break;
 		case OPTION_NEWER_MTIME: /* GNU tar */
-			bsdtar->newer_mtime_sec = get_date(now, bsdtar->optarg);
+			bsdtar->newer_mtime_filter = 1;
+			bsdtar->newer_mtime_sec = get_date(now, bsdtar->argument);
 			break;
 		case OPTION_NEWER_MTIME_THAN:
 			{
 				struct stat st;
-				if (stat(bsdtar->optarg, &st) != 0)
+				if (stat(bsdtar->argument, &st) != 0)
 					lafe_errc(1, 0,
-					    "Can't open file %s", bsdtar->optarg);
+					    "Can't open file %s", bsdtar->argument);
+				bsdtar->newer_mtime_filter = 1;
 				bsdtar->newer_mtime_sec = st.st_mtime;
 				bsdtar->newer_mtime_nsec =
 				    ARCHIVE_STAT_MTIME_NANOS(&st);
@@ -402,6 +437,7 @@
 			bsdtar->extract_flags &= ~ARCHIVE_EXTRACT_ACL;
 			bsdtar->extract_flags &= ~ARCHIVE_EXTRACT_XATTR;
 			bsdtar->extract_flags &= ~ARCHIVE_EXTRACT_FFLAGS;
+			bsdtar->extract_flags &= ~ARCHIVE_EXTRACT_MAC_METADATA;
 			break;
 		case OPTION_NULL: /* GNU tar */
 			bsdtar->option_null++;
@@ -409,6 +445,7 @@
 		case OPTION_NUMERIC_OWNER: /* GNU tar */
 			bsdtar->uname = "";
 			bsdtar->gname = "";
+			bsdtar->option_numeric_owner++;
 			break;
 		case 'O': /* GNU tar */
 			bsdtar->option_stdout = 1;
@@ -420,7 +457,7 @@
 			bsdtar->option_dont_traverse_mounts = 1;
 			break;
 		case OPTION_OPTIONS:
-			bsdtar->option_options = bsdtar->optarg;
+			bsdtar->option_options = bsdtar->argument;
 			break;
 #if 0
 		/*
@@ -442,6 +479,7 @@
 			bsdtar->extract_flags |= ARCHIVE_EXTRACT_ACL;
 			bsdtar->extract_flags |= ARCHIVE_EXTRACT_XATTR;
 			bsdtar->extract_flags |= ARCHIVE_EXTRACT_FFLAGS;
+			bsdtar->extract_flags |= ARCHIVE_EXTRACT_MAC_METADATA;
 			break;
 		case OPTION_POSIX: /* GNU tar */
 			bsdtar->create_format = "pax";
@@ -457,7 +495,7 @@
 			break;
 		case 's': /* NetBSD pax-as-tar */
 #if HAVE_REGEX_H
-			add_substitution(bsdtar, bsdtar->optarg);
+			add_substitution(bsdtar, bsdtar->argument);
 #else
 			lafe_warnc(0,
 			    "-s is not supported by this version of bsdtar");
@@ -468,10 +506,16 @@
 			bsdtar->extract_flags |= ARCHIVE_EXTRACT_OWNER;
 			break;
 		case OPTION_STRIP_COMPONENTS: /* GNU tar 1.15 */
-			bsdtar->strip_components = atoi(bsdtar->optarg);
+			errno = 0;
+			bsdtar->strip_components = strtol(bsdtar->argument,
+			    NULL, 0);
+			if (errno)
+				lafe_errc(1, 0,
+				    "Invalid --strip-components argument: %s",
+				    bsdtar->argument);
 			break;
 		case 'T': /* GNU tar */
-			bsdtar->names_from_file = bsdtar->optarg;
+			bsdtar->names_from_file = bsdtar->argument;
 			break;
 		case 't': /* SUSv2 */
 			set_mode(bsdtar, opt);
@@ -488,14 +532,14 @@
 			set_mode(bsdtar, opt);
 			break;
 		case OPTION_UID: /* cpio */
-			t = atoi(bsdtar->optarg);
+			t = atoi(bsdtar->argument);
 			if (t < 0)
 				lafe_errc(1, 0,
 				    "Argument to --uid must be positive");
 			bsdtar->uid = t;
 			break;
 		case OPTION_UNAME: /* cpio */
-			bsdtar->uname = bsdtar->optarg;
+			bsdtar->uname = bsdtar->argument;
 			break;
 		case 'v': /* SUSv2 */
 			bsdtar->verbose++;
@@ -515,10 +559,10 @@
 			bsdtar->option_interactive = 1;
 			break;
 		case 'X': /* GNU tar */
-			if (lafe_exclude_from_file(&bsdtar->matching, bsdtar->optarg))
+			if (lafe_exclude_from_file(&bsdtar->matching, bsdtar->argument))
 				lafe_errc(1, 0,
 				    "failed to process exclusions from file %s",
-				    bsdtar->optarg);
+				    bsdtar->argument);
 			break;
 		case 'x': /* SUSv2 */
 			set_mode(bsdtar, opt);
@@ -545,7 +589,7 @@
 			bsdtar->create_compression = opt;
 			break;
 		case OPTION_USE_COMPRESS_PROGRAM:
-			bsdtar->compress_program = bsdtar->optarg;
+			bsdtar->compress_program = bsdtar->argument;
 			break;
 		default:
 			usage();
@@ -617,8 +661,10 @@
 		buff[1] = bsdtar->symlink_mode;
 		only_mode(bsdtar, buff, "cru");
 	}
-	if (bsdtar->strip_components != 0)
-		only_mode(bsdtar, "--strip-components", "xt");
+
+	/* Filename "-" implies stdio. */
+	if (strcmp(bsdtar->filename, "-") == 0)
+		bsdtar->filename = NULL;
 
 	switch(bsdtar->mode) {
 	case 'c':
@@ -691,7 +737,7 @@
 {
 	printf("bsdtar %s - %s\n",
 	    BSDTAR_VERSION_STRING,
-	    archive_version());
+	    archive_version_string());
 	exit(0);
 }
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/tar/bsdtar.h
--- a/head/contrib/libarchive/tar/bsdtar.h	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/tar/bsdtar.h	Fri Mar 02 16:54:40 2012 +0200
@@ -22,7 +22,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: head/contrib/libarchive/tar/bsdtar.h 228763 2011-12-21 11:13:29Z mm $
+ * $FreeBSD: head/contrib/libarchive/tar/bsdtar.h 232153 2012-02-25 10:58:02Z mm $
  */
 
 #include "bsdtar_platform.h"
@@ -46,11 +46,14 @@
 	const char	 *create_format; /* -F format */
 	char		 *pending_chdir; /* -C dir */
 	const char	 *names_from_file; /* -T file */
+	int		  newer_ctime_filter; /* --newer/--newer-than */
 	time_t		  newer_ctime_sec; /* --newer/--newer-than */
 	long		  newer_ctime_nsec; /* --newer/--newer-than */
+	int		  newer_mtime_filter; /* --newer-mtime/--newer-mtime-than */
 	time_t		  newer_mtime_sec; /* --newer-mtime */
 	long		  newer_mtime_nsec; /* --newer-mtime-than */
 	int		  bytes_per_block; /* -b block_size */
+	int		  bytes_in_last_block; /* See -b handling. */
 	int		  verbose;   /* -v */
 	int		  extract_flags; /* Flags for extract operation */
 	int		  strip_components; /* Remove this many leading dirs */
@@ -71,12 +74,18 @@
 	char		  option_interactive; /* -w */
 	char		  option_no_owner; /* -o */
 	char		  option_no_subdirs; /* -n */
+	char		  option_numeric_owner; /* --numeric-owner */
 	char		  option_null; /* --null */
 	char		  option_stdout; /* -O */
 	char		  option_totals; /* --totals */
 	char		  option_unlink_first; /* -U */
 	char		  option_warn_links; /* --check-links */
 	char		  day_first; /* show day before month in -tv output */
+	char		  enable_copyfile; /* For Mac OS */
+
+	/* Option parser state */
+	int		  getopt_state;
+	char		 *getopt_word;
 
 	/* If >= 0, then close this when done. */
 	int		  fd;
@@ -84,7 +93,7 @@
 	/* Miscellaneous state information */
 	int		  argc;
 	char		**argv;
-	const char	 *optarg;
+	const char	 *argument;
 	size_t		  gs_width; /* For 'list_item' in read.c */
 	size_t		  u_width; /* for 'list_item' in read.c */
 	uid_t		  user_uid; /* UID running this program */
@@ -101,6 +110,7 @@
 	struct archive_dir	*archive_dir;	/* for write.c */
 	struct name_cache	*gname_cache;	/* for write.c */
 	char			*buff;		/* for write.c */
+	size_t			 buff_size;	/* for write.c */
 	struct lafe_matching	*matching;	/* for matching.c */
 	struct security		*security;	/* for read.c */
 	struct name_cache	*uname_cache;	/* for write.c */
@@ -112,6 +122,7 @@
 enum {
 	OPTION_CHECK_LINKS = 1,
 	OPTION_CHROOT,
+	OPTION_DISABLE_COPYFILE,
 	OPTION_EXCLUDE,
 	OPTION_FORMAT,
 	OPTION_GID,
@@ -119,6 +130,7 @@
 	OPTION_HELP,
 	OPTION_INCLUDE,
 	OPTION_KEEP_NEWER_FILES,
+	OPTION_LZIP,
 	OPTION_LZMA,
 	OPTION_NEWER_CTIME,
 	OPTION_NEWER_CTIME_THAN,
@@ -141,7 +153,6 @@
 	OPTION_VERSION
 };
 
-
 int	bsdtar_getopt(struct bsdtar *);
 void	do_chdir(struct bsdtar *);
 int	edit_pathname(struct bsdtar *, struct archive_entry *);
@@ -160,6 +171,6 @@
 
 #if HAVE_REGEX_H
 void	add_substitution(struct bsdtar *, const char *);
-int	apply_substitution(struct bsdtar *, const char *, char **, int);
+int	apply_substitution(struct bsdtar *, const char *, char **, int, int);
 void	cleanup_substitution(struct bsdtar *);
 #endif
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/tar/bsdtar_platform.h
--- a/head/contrib/libarchive/tar/bsdtar_platform.h	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/tar/bsdtar_platform.h	Fri Mar 02 16:54:40 2012 +0200
@@ -22,7 +22,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: head/contrib/libarchive/tar/bsdtar_platform.h 228763 2011-12-21 11:13:29Z mm $
+ * $FreeBSD: head/contrib/libarchive/tar/bsdtar_platform.h 232153 2012-02-25 10:58:02Z mm $
  */
 
 /*
@@ -67,10 +67,10 @@
 #endif
 
 /*
- * Include "dirent.h" (or it's equivalent on several different platforms).
+ * Include "dirent.h" (or its equivalent on several different platforms).
  *
  * This is slightly modified from the GNU autoconf recipe.
- * In particular, FreeBSD includes d_namlen in it's dirent structure,
+ * In particular, FreeBSD includes d_namlen in its dirent structure,
  * so my configure script includes an explicit test for the d_namlen
  * field.
  */
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/tar/cmdline.c
--- a/head/contrib/libarchive/tar/cmdline.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/tar/cmdline.c	Fri Mar 02 16:54:40 2012 +0200
@@ -28,7 +28,7 @@
  */
 
 #include "bsdtar_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/tar/cmdline.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/tar/cmdline.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
@@ -58,7 +58,7 @@
  * a small change to the code below.
  */
 
-static struct option {
+static const struct bsdtar_option {
 	const char *name;
 	int required;      /* 1 if this option requires an argument. */
 	int equivalent;    /* Equivalent short option. */
@@ -77,6 +77,7 @@
 	{ "create",               0, 'c' },
 	{ "dereference",	  0, 'L' },
 	{ "directory",            1, 'C' },
+	{ "disable-copyfile",	  0, OPTION_DISABLE_COPYFILE },
 	{ "exclude",              1, OPTION_EXCLUDE },
 	{ "exclude-from",         1, 'X' },
 	{ "extract",              0, 'x' },
@@ -90,11 +91,12 @@
 	{ "gzip",                 0, 'z' },
 	{ "help",                 0, OPTION_HELP },
 	{ "include",              1, OPTION_INCLUDE },
+	{ "insecure",             0, 'P' },
 	{ "interactive",          0, 'w' },
-	{ "insecure",             0, 'P' },
 	{ "keep-newer-files",     0, OPTION_KEEP_NEWER_FILES },
 	{ "keep-old-files",       0, 'k' },
 	{ "list",                 0, 't' },
+	{ "lzip",                 0, OPTION_LZIP },
 	{ "lzma",                 0, OPTION_LZMA },
 	{ "modification-time",    0, 'm' },
 	{ "newer",		  1, OPTION_NEWER_CTIME },
@@ -103,11 +105,11 @@
 	{ "newer-mtime",	  1, OPTION_NEWER_MTIME },
 	{ "newer-mtime-than",	  1, OPTION_NEWER_MTIME_THAN },
 	{ "newer-than",		  1, OPTION_NEWER_CTIME_THAN },
-	{ "nodump",               0, OPTION_NODUMP },
-	{ "norecurse",            0, 'n' },
 	{ "no-recursion",         0, 'n' },
 	{ "no-same-owner",	  0, OPTION_NO_SAME_OWNER },
 	{ "no-same-permissions",  0, OPTION_NO_SAME_PERMISSIONS },
+	{ "nodump",               0, OPTION_NODUMP },
+	{ "norecurse",            0, 'n' },
 	{ "null",		  0, OPTION_NULL },
 	{ "numeric-owner",	  0, OPTION_NUMERIC_OWNER },
 	{ "one-file-system",	  0, OPTION_ONE_FILE_SYSTEM },
@@ -171,7 +173,7 @@
  *
  * TODO: If we want to support arbitrary command-line options from -T
  * input (as GNU tar does), we may need to extend this to handle option
- * words from sources other than argv/arc.  I'm not really sure if I
+ * words from sources other than argv/argc.  I'm not really sure if I
  * like that feature of GNU tar, so it's certainly not a priority.
  */
 
@@ -180,19 +182,17 @@
 {
 	enum { state_start = 0, state_old_tar, state_next_word,
 	       state_short, state_long };
-	static int state = state_start;
-	static char *opt_word;
 
-	const struct option *popt, *match = NULL, *match2 = NULL;
+	const struct bsdtar_option *popt, *match = NULL, *match2 = NULL;
 	const char *p, *long_prefix = "--";
 	size_t optlength;
 	int opt = '?';
 	int required = 0;
 
-	bsdtar->optarg = NULL;
+	bsdtar->argument = NULL;
 
 	/* First time through, initialize everything. */
-	if (state == state_start) {
+	if (bsdtar->getopt_state == state_start) {
 		/* Skip program name. */
 		++bsdtar->argv;
 		--bsdtar->argc;
@@ -200,10 +200,10 @@
 			return (-1);
 		/* Decide between "new style" and "old style" arguments. */
 		if (bsdtar->argv[0][0] == '-') {
-			state = state_next_word;
+			bsdtar->getopt_state = state_next_word;
 		} else {
-			state = state_old_tar;
-			opt_word = *bsdtar->argv++;
+			bsdtar->getopt_state = state_old_tar;
+			bsdtar->getopt_word = *bsdtar->argv++;
 			--bsdtar->argc;
 		}
 	}
@@ -211,20 +211,20 @@
 	/*
 	 * We're parsing old-style tar arguments
 	 */
-	if (state == state_old_tar) {
+	if (bsdtar->getopt_state == state_old_tar) {
 		/* Get the next option character. */
-		opt = *opt_word++;
+		opt = *bsdtar->getopt_word++;
 		if (opt == '\0') {
 			/* New-style args can follow old-style. */
-			state = state_next_word;
+			bsdtar->getopt_state = state_next_word;
 		} else {
 			/* See if it takes an argument. */
 			p = strchr(short_options, opt);
 			if (p == NULL)
 				return ('?');
 			if (p[1] == ':') {
-				bsdtar->optarg = *bsdtar->argv;
-				if (bsdtar->optarg == NULL) {
+				bsdtar->argument = *bsdtar->argv;
+				if (bsdtar->argument == NULL) {
 					lafe_warnc(0,
 					    "Option %c requires an argument",
 					    opt);
@@ -239,7 +239,7 @@
 	/*
 	 * We're ready to look at the next word in argv.
 	 */
-	if (state == state_next_word) {
+	if (bsdtar->getopt_state == state_next_word) {
 		/* No more arguments, so no more options. */
 		if (bsdtar->argv[0] == NULL)
 			return (-1);
@@ -253,28 +253,28 @@
 			return (-1);
 		}
 		/* Get next word for parsing. */
-		opt_word = *bsdtar->argv++;
+		bsdtar->getopt_word = *bsdtar->argv++;
 		--bsdtar->argc;
-		if (opt_word[1] == '-') {
+		if (bsdtar->getopt_word[1] == '-') {
 			/* Set up long option parser. */
-			state = state_long;
-			opt_word += 2; /* Skip leading '--' */
+			bsdtar->getopt_state = state_long;
+			bsdtar->getopt_word += 2; /* Skip leading '--' */
 		} else {
 			/* Set up short option parser. */
-			state = state_short;
-			++opt_word;  /* Skip leading '-' */
+			bsdtar->getopt_state = state_short;
+			++bsdtar->getopt_word;  /* Skip leading '-' */
 		}
 	}
 
 	/*
 	 * We're parsing a group of POSIX-style single-character options.
 	 */
-	if (state == state_short) {
+	if (bsdtar->getopt_state == state_short) {
 		/* Peel next option off of a group of short options. */
-		opt = *opt_word++;
+		opt = *bsdtar->getopt_word++;
 		if (opt == '\0') {
 			/* End of this group; recurse to get next option. */
-			state = state_next_word;
+			bsdtar->getopt_state = state_next_word;
 			return bsdtar_getopt(bsdtar);
 		}
 
@@ -287,11 +287,11 @@
 
 		/* If it takes an argument, parse that. */
 		if (required) {
-			/* If arg is run-in, opt_word already points to it. */
-			if (opt_word[0] == '\0') {
+			/* If arg is run-in, bsdtar->getopt_word already points to it. */
+			if (bsdtar->getopt_word[0] == '\0') {
 				/* Otherwise, pick up the next word. */
-				opt_word = *bsdtar->argv;
-				if (opt_word == NULL) {
+				bsdtar->getopt_word = *bsdtar->argv;
+				if (bsdtar->getopt_word == NULL) {
 					lafe_warnc(0,
 					    "Option -%c requires an argument",
 					    opt);
@@ -301,36 +301,36 @@
 				--bsdtar->argc;
 			}
 			if (opt == 'W') {
-				state = state_long;
+				bsdtar->getopt_state = state_long;
 				long_prefix = "-W "; /* For clearer errors. */
 			} else {
-				state = state_next_word;
-				bsdtar->optarg = opt_word;
+				bsdtar->getopt_state = state_next_word;
+				bsdtar->argument = bsdtar->getopt_word;
 			}
 		}
 	}
 
 	/* We're reading a long option, including -W long=arg convention. */
-	if (state == state_long) {
+	if (bsdtar->getopt_state == state_long) {
 		/* After this long option, we'll be starting a new word. */
-		state = state_next_word;
+		bsdtar->getopt_state = state_next_word;
 
 		/* Option name ends at '=' if there is one. */
-		p = strchr(opt_word, '=');
+		p = strchr(bsdtar->getopt_word, '=');
 		if (p != NULL) {
-			optlength = (size_t)(p - opt_word);
-			bsdtar->optarg = (char *)(uintptr_t)(p + 1);
+			optlength = (size_t)(p - bsdtar->getopt_word);
+			bsdtar->argument = (char *)(uintptr_t)(p + 1);
 		} else {
-			optlength = strlen(opt_word);
+			optlength = strlen(bsdtar->getopt_word);
 		}
 
 		/* Search the table for an unambiguous match. */
 		for (popt = tar_longopts; popt->name != NULL; popt++) {
 			/* Short-circuit if first chars don't match. */
-			if (popt->name[0] != opt_word[0])
+			if (popt->name[0] != bsdtar->getopt_word[0])
 				continue;
 			/* If option is a prefix of name in table, record it.*/
-			if (strncmp(opt_word, popt->name, optlength) == 0) {
+			if (strncmp(bsdtar->getopt_word, popt->name, optlength) == 0) {
 				match2 = match; /* Record up to two matches. */
 				match = popt;
 				/* If it's an exact match, we're done. */
@@ -345,22 +345,22 @@
 		if (match == NULL) {
 			lafe_warnc(0,
 			    "Option %s%s is not supported",
-			    long_prefix, opt_word);
+			    long_prefix, bsdtar->getopt_word);
 			return ('?');
 		}
 		if (match2 != NULL) {
 			lafe_warnc(0,
 			    "Ambiguous option %s%s (matches --%s and --%s)",
-			    long_prefix, opt_word, match->name, match2->name);
+			    long_prefix, bsdtar->getopt_word, match->name, match2->name);
 			return ('?');
 		}
 
 		/* We've found a unique match; does it need an argument? */
 		if (match->required) {
 			/* Argument required: get next word if necessary. */
-			if (bsdtar->optarg == NULL) {
-				bsdtar->optarg = *bsdtar->argv;
-				if (bsdtar->optarg == NULL) {
+			if (bsdtar->argument == NULL) {
+				bsdtar->argument = *bsdtar->argv;
+				if (bsdtar->argument == NULL) {
 					lafe_warnc(0,
 					    "Option %s%s requires an argument",
 					    long_prefix, match->name);
@@ -371,7 +371,7 @@
 			}
 		} else {
 			/* Argument forbidden: fail if there is one. */
-			if (bsdtar->optarg != NULL) {
+			if (bsdtar->argument != NULL) {
 				lafe_warnc(0,
 				    "Option %s%s does not allow an argument",
 				    long_prefix, match->name);
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/tar/getdate.c
--- a/head/contrib/libarchive/tar/getdate.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/tar/getdate.c	Fri Mar 02 16:54:40 2012 +0200
@@ -29,7 +29,7 @@
 
 #ifdef __FreeBSD__
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/contrib/libarchive/tar/getdate.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/tar/getdate.c 232153 2012-02-25 10:58:02Z mm $");
 #endif
 
 #include <ctype.h>
@@ -864,7 +864,7 @@
 	}
 }
 
-#define TM_YEAR_ORIGIN 1900
+#define	TM_YEAR_ORIGIN 1900
 
 /* Yield A - B, measured in seconds.  */
 static long
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/tar/read.c
--- a/head/contrib/libarchive/tar/read.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/tar/read.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  */
 
 #include "bsdtar_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/tar/read.c 228776 2011-12-21 15:30:49Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/tar/read.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
@@ -76,12 +76,12 @@
 
 static void	list_item_verbose(struct bsdtar *, FILE *,
 		    struct archive_entry *);
-static void	read_archive(struct bsdtar *bsdtar, char mode);
+static void	read_archive(struct bsdtar *bsdtar, char mode, struct archive *);
 
 void
 tar_mode_t(struct bsdtar *bsdtar)
 {
-	read_archive(bsdtar, 't');
+	read_archive(bsdtar, 't', NULL);
 	if (lafe_unmatched_inclusions_warn(bsdtar->matching, "Not found in archive") != 0)
 		bsdtar->return_value = 1;
 }
@@ -89,10 +89,20 @@
 void
 tar_mode_x(struct bsdtar *bsdtar)
 {
-	read_archive(bsdtar, 'x');
+	struct archive *writer;
+
+	writer = archive_write_disk_new();
+	if (writer == NULL)
+		lafe_errc(1, ENOMEM, "Cannot allocate disk writer object");
+	if (!bsdtar->option_numeric_owner)
+		archive_write_disk_set_standard_lookup(writer);
+	archive_write_disk_set_options(writer, bsdtar->extract_flags);
+
+	read_archive(bsdtar, 'x', writer);
 
 	if (lafe_unmatched_inclusions_warn(bsdtar->matching, "Not found in archive") != 0)
 		bsdtar->return_value = 1;
+	archive_write_free(writer);
 }
 
 static void
@@ -135,14 +145,15 @@
  * Handle 'x' and 't' modes.
  */
 static void
-read_archive(struct bsdtar *bsdtar, char mode)
+read_archive(struct bsdtar *bsdtar, char mode, struct archive *writer)
 {
 	struct progress_data	progress_data;
 	FILE			 *out;
 	struct archive		 *a;
 	struct archive_entry	 *entry;
-	const struct stat	 *st;
 	int			  r;
+	time_t			  sec;
+	long			  nsec;
 
 	while (*bsdtar->argv) {
 		lafe_include(&bsdtar->matching, *bsdtar->argv);
@@ -155,15 +166,13 @@
 
 	a = archive_read_new();
 	if (bsdtar->compress_program != NULL)
-		archive_read_support_compression_program(a, bsdtar->compress_program);
+		archive_read_support_filter_program(a, bsdtar->compress_program);
 	else
-		archive_read_support_compression_all(a);
+		archive_read_support_filter_all(a);
 	archive_read_support_format_all(a);
 	if (ARCHIVE_OK != archive_read_set_options(a, bsdtar->option_options))
 		lafe_errc(1, 0, "%s", archive_error_string(a));
-	if (archive_read_open_file(a, bsdtar->filename,
-	    bsdtar->bytes_per_block != 0 ? bsdtar->bytes_per_block :
-	    DEFAULT_BYTES_PER_BLOCK))
+	if (archive_read_open_file(a, bsdtar->filename, bsdtar->bytes_per_block))
 		lafe_errc(1, 0, "Error opening archive: %s",
 		    archive_error_string(a));
 
@@ -225,21 +234,36 @@
 		/*
 		 * Exclude entries that are too old.
 		 */
-		st = archive_entry_stat(entry);
-		if (bsdtar->newer_ctime_sec > 0) {
-			if (st->st_ctime < bsdtar->newer_ctime_sec)
+		if (bsdtar->newer_ctime_filter) {
+			/* Use ctime if format provides, else mtime. */
+			if (archive_entry_ctime_is_set(entry)) {
+				sec = archive_entry_ctime(entry);
+				nsec = archive_entry_ctime_nsec(entry);
+			} else if (archive_entry_mtime_is_set(entry)) {
+				sec = archive_entry_mtime(entry);
+				nsec = archive_entry_mtime_nsec(entry);
+			} else {
+				sec = 0;
+				nsec = 0;
+			}
+			if (sec < bsdtar->newer_ctime_sec)
 				continue; /* Too old, skip it. */
-			if (st->st_ctime == bsdtar->newer_ctime_sec
-			    && ARCHIVE_STAT_CTIME_NANOS(st)
-			    <= bsdtar->newer_ctime_nsec)
+			if (sec == bsdtar->newer_ctime_sec
+			    && nsec <= bsdtar->newer_ctime_nsec)
 				continue; /* Too old, skip it. */
 		}
-		if (bsdtar->newer_mtime_sec > 0) {
-			if (st->st_mtime < bsdtar->newer_mtime_sec)
+		if (bsdtar->newer_mtime_filter) {
+			if (archive_entry_mtime_is_set(entry)) {
+				sec = archive_entry_mtime(entry);
+				nsec = archive_entry_mtime_nsec(entry);
+			} else {
+				sec = 0;
+				nsec = 0;
+			}
+			if (sec < bsdtar->newer_mtime_sec)
 				continue; /* Too old, skip it. */
-			if (st->st_mtime == bsdtar->newer_mtime_sec
-			    && ARCHIVE_STAT_MTIME_NANOS(st)
-			    <= bsdtar->newer_mtime_nsec)
+			if (sec == bsdtar->newer_mtime_sec
+			    && nsec <= bsdtar->newer_mtime_nsec)
 				continue; /* Too old, skip it. */
 		}
 
@@ -310,13 +334,12 @@
 				fflush(stderr);
 			}
 
-			// TODO siginfo_printinfo(bsdtar, 0);
+			/* TODO siginfo_printinfo(bsdtar, 0); */
 
 			if (bsdtar->option_stdout)
 				r = archive_read_data_into_fd(a, 1);
 			else
-				r = archive_read_extract(a, entry,
-				    bsdtar->extract_flags);
+				r = archive_read_extract2(a, entry, writer);
 			if (r != ARCHIVE_OK) {
 				if (!bsdtar->verbose)
 					safe_fprintf(stderr, "%s",
@@ -345,7 +368,7 @@
 		fprintf(stdout, "Archive Format: %s,  Compression: %s\n",
 		    archive_format_name(a), archive_compression_name(a));
 
-	archive_read_finish(a);
+	archive_read_free(a);
 }
 
 
@@ -427,11 +450,11 @@
 
 	/* Format the time using 'ls -l' conventions. */
 	tim = archive_entry_mtime(entry);
-#define HALF_YEAR (time_t)365 * 86400 / 2
+#define	HALF_YEAR (time_t)365 * 86400 / 2
 #if defined(_WIN32) && !defined(__CYGWIN__)
-#define DAY_FMT  "%d"  /* Windows' strftime function does not support %e format. */
+#define	DAY_FMT  "%d"  /* Windows' strftime function does not support %e format. */
 #else
-#define DAY_FMT  "%e"  /* Day number without leading zeros */
+#define	DAY_FMT  "%e"  /* Day number without leading zeros */
 #endif
 	if (tim < now - HALF_YEAR || tim > now + HALF_YEAR)
 		fmt = bsdtar->day_first ? DAY_FMT " %b  %Y" : "%b " DAY_FMT "  %Y";
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/tar/subst.c
--- a/head/contrib/libarchive/tar/subst.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/tar/subst.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  */
 
 #include "bsdtar_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/tar/subst.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/tar/subst.c 232153 2012-02-25 10:58:02Z mm $");
 
 #if HAVE_REGEX_H
 #include "bsdtar.h"
@@ -44,7 +44,7 @@
 	struct subst_rule *next;
 	regex_t re;
 	char *result;
-	unsigned int global:1, print:1, symlink:1;
+	unsigned int global:1, print:1, regular:1, symlink:1, hardlink:1;
 };
 
 struct substitution {
@@ -117,9 +117,12 @@
 	memcpy(rule->result, start_subst, end_pattern - start_subst);
 	rule->result[end_pattern - start_subst] = '\0';
 
-	rule->global = 0;
-	rule->print = 0;
-	rule->symlink = 0;
+	/* Defaults */
+	rule->global = 0; /* Don't do multiple replacements. */
+	rule->print = 0; /* Don't print. */
+	rule->regular = 1; /* Rewrite regular filenames. */
+	rule->symlink = 1; /* Rewrite symlink targets. */
+	rule->hardlink = 1; /* Rewrite hardlink targets. */
 
 	while (*++end_pattern) {
 		switch (*end_pattern) {
@@ -127,13 +130,27 @@
 		case 'G':
 			rule->global = 1;
 			break;
+		case 'h':
+			rule->hardlink = 1;
+			break;
+		case 'H':
+			rule->hardlink = 0;
+			break;
 		case 'p':
 		case 'P':
 			rule->print = 1;
 			break;
+		case 'r':
+			rule->regular = 1;
+			break;
+		case 'R':
+			rule->regular = 0;
+			break;
 		case 's':
+			rule->symlink = 1;
+			break;
 		case 'S':
-			rule->symlink = 1;
+			rule->symlink = 0;
 			break;
 		default:
 			lafe_errc(1, 0, "Invalid replacement flag %c", *end_pattern);
@@ -155,7 +172,8 @@
 	new_str = malloc(old_len + len + 1);
 	if (new_str == NULL)
 		lafe_errc(1, errno, "Out of memory");
-	memcpy(new_str, *str, old_len);
+	if (*str != NULL)
+		memcpy(new_str, *str, old_len);
 	memcpy(new_str + old_len, append, len);
 	new_str[old_len + len] = '\0';
 	free(*str);
@@ -176,14 +194,16 @@
 	new_str = malloc(old_len + strlen(append) + 1);
 	if (new_str == NULL)
 		lafe_errc(1, errno, "Out of memory");
-	memcpy(new_str, *str, old_len);
+	if (*str != NULL)
+		memcpy(new_str, *str, old_len);
 	strcpy(new_str + old_len, append);
 	free(*str);
 	*str = new_str;
 }
 
 int
-apply_substitution(struct bsdtar *bsdtar, const char *name, char **result, int symlink_only)
+apply_substitution(struct bsdtar *bsdtar, const char *name, char **result,
+    int symlink_target, int hardlink_target)
 {
 	const char *path = name;
 	regmatch_t matches[10];
@@ -201,8 +221,17 @@
 	print_match = 0;
 
 	for (rule = subst->first_rule; rule != NULL; rule = rule->next) {
-		if (symlink_only && !rule->symlink)
-			continue;
+		if (symlink_target) {
+			if (!rule->symlink)
+				continue;
+		} else if (hardlink_target) {
+			if (!rule->hardlink)
+				continue;
+		} else { /* Regular filename. */
+			if (!rule->regular)
+				continue;
+		}
+
 		if (regexec(&rule->re, name, 10, matches, 0))
 			continue;
 
@@ -213,7 +242,9 @@
 		for (i = 0, j = 0; rule->result[i] != '\0'; ++i) {
 			if (rule->result[i] == '~') {
 				realloc_strncat(result, rule->result + j, i - j);
-				realloc_strncat(result, name, matches[0].rm_eo);
+				realloc_strncat(result,
+				    name + matches[0].rm_so,
+				    matches[0].rm_eo - matches[0].rm_so);
 				j = i + 1;
 				continue;
 			}
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/tar/test/main.c
--- a/head/contrib/libarchive/tar/test/main.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/tar/test/main.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,8 +24,18 @@
  */
 
 #include "test.h"
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
 #include <errno.h>
+#ifdef HAVE_ICONV_H
+#include <iconv.h>
+#endif
+#include <limits.h>
 #include <locale.h>
+#ifdef HAVE_SIGNAL_H
+#include <signal.h>
+#endif
 #include <stdarg.h>
 #include <time.h>
 
@@ -36,12 +46,14 @@
  * TODO: Move this into a separate configuration header, have all test
  * suites share one copy of this file.
  */
-__FBSDID("$FreeBSD: head/contrib/libarchive/tar/test/main.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/tar/test/main.c 232153 2012-02-25 10:58:02Z mm $");
 #define KNOWNREF	"test_patterns_2.tar.uu"
 #define ENVBASE "BSDTAR"  /* Prefix for environment variables. */
 #define	PROGRAM "bsdtar"  /* Name of program being tested. */
-#undef LIBRARY		  /* Not testing a library. */
-#undef	EXTRA_DUMP	     /* How to dump extra data */
+#define PROGRAM_ALIAS "tar" /* Generic alias for program */
+#undef	LIBRARY		  /* Not testing a library. */
+#undef	EXTRA_DUMP	  /* How to dump extra data */
+#undef	EXTRA_ERRNO	  /* How to dump errno */
 /* How to generate extra version info. */
 #define	EXTRA_VERSION    (systemf("%s --version", testprog) ? "" : "")
 
@@ -151,7 +163,7 @@
 
 	memset(bhfi, 0, sizeof(*bhfi));
 	h = CreateFile(path, FILE_READ_ATTRIBUTES, 0, NULL,
-		OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+		OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
 	if (h == INVALID_HANDLE_VALUE)
 		return (0);
 	r = GetFileInformationByHandle(h, bhfi);
@@ -180,6 +192,8 @@
 static int dump_on_failure = 0;
 /* Default is to remove temp dirs and log data for successful tests. */
 static int keep_temp_files = 0;
+/* Default is to run the specified tests once and report errors. */
+static int until_failure = 0;
 /* Default is to just report pass/fail for each test. */
 static int verbosity = 0;
 #define	VERBOSITY_SUMMARY_ONLY -1 /* -q */
@@ -237,10 +251,14 @@
 failure(const char *fmt, ...)
 {
 	va_list ap;
-	va_start(ap, fmt);
-	vsprintf(msgbuff, fmt, ap);
-	va_end(ap);
-	nextmsg = msgbuff;
+	if (fmt == NULL) {
+		nextmsg = NULL;
+	} else {
+		va_start(ap, fmt);
+		vsprintf(msgbuff, fmt, ap);
+		va_end(ap);
+		nextmsg = msgbuff;
+	}
 }
 
 /*
@@ -252,15 +270,14 @@
  * pass __FILE__, __LINE__ directly into the function instead of using
  * this hook.  I suspect this machinery is used so rarely that we
  * would be better off just removing it entirely.  That would simplify
- * the code here noticably.
+ * the code here noticeably.
  */
-static const char *test_filename;
-static int test_line;
-static void *test_extra;
-void assertion_setup(const char *filename, int line)
+static const char *skipping_filename;
+static int skipping_line;
+void skipping_setup(const char *filename, int line)
 {
-	test_filename = filename;
-	test_line = line;
+	skipping_filename = filename;
+	skipping_line = line;
 }
 
 /* Called at the beginning of each assert() function. */
@@ -287,6 +304,7 @@
 	int count;
 	int skip;
 }  failed_lines[10000];
+const char *failed_filename;
 
 /* Count this failure, setup up log destination and handle initial report. */
 static void
@@ -296,19 +314,16 @@
 
 	/* Record another failure for this line. */
 	++failures;
-	/* test_filename = filename; */
+	failed_filename = filename;
 	failed_lines[line].count++;
 
 	/* Determine whether to log header to console. */
 	switch (verbosity) {
-	case VERBOSITY_FULL:
-		log_console = 1;
-		break;
 	case VERBOSITY_LIGHT_REPORT:
 		log_console = (failed_lines[line].count < 2);
 		break;
 	default:
-		log_console = 0;
+		log_console = (verbosity >= VERBOSITY_FULL);
 	}
 
 	/* Log file:line header for this failure */
@@ -344,14 +359,16 @@
 {
 	(void)extra; /* UNUSED (maybe) */
 #ifdef EXTRA_DUMP
-	if (extra != NULL)
+	if (extra != NULL) {
+		logprintf("    errno: %d\n", EXTRA_ERRNO(extra));
 		logprintf("   detail: %s\n", EXTRA_DUMP(extra));
+	}
 #endif
 
 	if (dump_on_failure) {
 		fprintf(stderr,
 		    " *** forcing core dump so failure can be debugged ***\n");
-		*(char *)(NULL) = 0;
+		abort();
 		exit(1);
 	}
 }
@@ -366,12 +383,15 @@
 	va_start(ap, fmt);
 	vsprintf(buff, fmt, ap);
 	va_end(ap);
+	/* Use failure() message if set. */
+	msg = nextmsg;
+	nextmsg = NULL;
 	/* failure_start() isn't quite right, but is awfully convenient. */
-	failure_start(test_filename, test_line, "SKIPPING: %s", buff);
+	failure_start(skipping_filename, skipping_line, "SKIPPING: %s", buff);
 	--failures; /* Undo failures++ in failure_start() */
 	/* Don't failure_finish() here. */
 	/* Mark as skip, so doesn't count as failed test. */
-	failed_lines[test_line].skip = 1;
+	failed_lines[skipping_line].skip = 1;
 	++skips;
 }
 
@@ -422,13 +442,102 @@
 	return (0);
 }
 
-static void strdump(const char *e, const char *p)
+/*
+ * Utility to convert a single UTF-8 sequence.
+ */
+static int
+_utf8_to_unicode(uint32_t *pwc, const char *s, size_t n)
+{
+	static const char utf8_count[256] = {
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 00 - 0F */
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 10 - 1F */
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 20 - 2F */
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 30 - 3F */
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 40 - 4F */
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 50 - 5F */
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 60 - 6F */
+		 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 70 - 7F */
+		 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,/* 80 - 8F */
+		 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,/* 90 - 9F */
+		 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,/* A0 - AF */
+		 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,/* B0 - BF */
+		 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,/* C0 - CF */
+		 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,/* D0 - DF */
+		 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,/* E0 - EF */
+		 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* F0 - FF */
+	};
+	int ch;
+	int cnt;
+	uint32_t wc;
+
+	*pwc = 0;
+
+	/* Sanity check. */
+	if (n == 0)
+		return (0);
+	/*
+	 * Decode 1-4 bytes depending on the value of the first byte.
+	 */
+	ch = (unsigned char)*s;
+	if (ch == 0)
+		return (0); /* Standard:  return 0 for end-of-string. */
+	cnt = utf8_count[ch];
+
+	/* Invalide sequence or there are not plenty bytes. */
+	if (n < (size_t)cnt)
+		return (-1);
+
+	/* Make a Unicode code point from a single UTF-8 sequence. */
+	switch (cnt) {
+	case 1:	/* 1 byte sequence. */
+		*pwc = ch & 0x7f;
+		return (cnt);
+	case 2:	/* 2 bytes sequence. */
+		if ((s[1] & 0xc0) != 0x80) return (-1);
+		*pwc = ((ch & 0x1f) << 6) | (s[1] & 0x3f);
+		return (cnt);
+	case 3:	/* 3 bytes sequence. */
+		if ((s[1] & 0xc0) != 0x80) return (-1);
+		if ((s[2] & 0xc0) != 0x80) return (-1);
+		wc = ((ch & 0x0f) << 12)
+		    | ((s[1] & 0x3f) << 6)
+		    | (s[2] & 0x3f);
+		if (wc < 0x800)
+			return (-1);/* Overlong sequence. */
+		break;
+	case 4:	/* 4 bytes sequence. */
+		if (n < 4)
+			return (-1);
+		if ((s[1] & 0xc0) != 0x80) return (-1);
+		if ((s[2] & 0xc0) != 0x80) return (-1);
+		if ((s[3] & 0xc0) != 0x80) return (-1);
+		wc = ((ch & 0x07) << 18)
+		    | ((s[1] & 0x3f) << 12)
+		    | ((s[2] & 0x3f) << 6)
+		    | (s[3] & 0x3f);
+		if (wc < 0x10000)
+			return (-1);/* Overlong sequence. */
+		break;
+	default:
+		return (-1);
+	}
+
+	/* The code point larger than 0x10FFFF is not leagal
+	 * Unicode values. */
+	if (wc > 0x10FFFF)
+		return (-1);
+	/* Correctly gets a Unicode, returns used bytes. */
+	*pwc = wc;
+	return (cnt);
+}
+
+static void strdump(const char *e, const char *p, int ewidth, int utf8)
 {
 	const char *q = p;
 
-	logprintf("      %s = ", e);
+	logprintf("      %*s = ", ewidth, e);
 	if (p == NULL) {
-		logprintf("NULL");
+		logprintf("NULL\n");
 		return;
 	}
 	logprintf("\"");
@@ -447,7 +556,37 @@
 		}
 	}
 	logprintf("\"");
-	logprintf(" (length %d)\n", q == NULL ? -1 : (int)strlen(q));
+	logprintf(" (length %d)", q == NULL ? -1 : (int)strlen(q));
+
+	/*
+	 * If the current string is UTF-8, dump its code points.
+	 */
+	if (utf8) {
+		size_t len;
+		uint32_t uc;
+		int n;
+		int cnt = 0;
+
+		p = q;
+		len = strlen(p);
+		logprintf(" [");
+		while ((n = _utf8_to_unicode(&uc, p, len)) > 0) {
+			if (p != q)
+				logprintf(" ");
+			logprintf("%04X", uc);
+			p += n;
+			len -= n;
+			cnt++;
+		}
+		logprintf("]");
+		logprintf(" (count %d", cnt);
+		if (n < 0) {
+			logprintf(",unknown %d bytes", len);
+		}
+		logprintf(")");
+
+	}
+	logprintf("\n");
 }
 
 /* Verify two strings are equal, dump them if not. */
@@ -455,14 +594,20 @@
 assertion_equal_string(const char *file, int line,
     const char *v1, const char *e1,
     const char *v2, const char *e2,
-    void *extra)
+    void *extra, int utf8)
 {
+	int l1, l2;
+
 	assertion_count(file, line);
 	if (v1 == v2 || (v1 != NULL && v2 != NULL && strcmp(v1, v2) == 0))
 		return (1);
 	failure_start(file, line, "%s != %s", e1, e2);
-	strdump(e1, v1);
-	strdump(e2, v2);
+	l1 = strlen(e1);
+	l2 = strlen(e2);
+	if (l1 < l2)
+		l1 = l2;
+	strdump(e1, v1, l1, utf8);
+	strdump(e2, v2, l1, utf8);
 	failure_finish(extra);
 	return (0);
 }
@@ -514,7 +659,9 @@
     void *extra)
 {
 	assertion_count(file, line);
-	if (v1 == v2 || wcscmp(v1, v2) == 0)
+	if (v1 == v2)
+		return (1);
+	if (v1 != NULL && v2 != NULL && wcscmp(v1, v2) == 0)
 		return (1);
 	failure_start(file, line, "%s != %s", e1, e2);
 	wcsdump(e1, v1);
@@ -593,9 +740,9 @@
 		offset += 16;
 	}
 	logprintf("      Dump of %s\n", e1);
-	hexdump(v1, v2, l < 64 ? l : 64, offset);
+	hexdump(v1, v2, l < 128 ? l : 128, offset);
 	logprintf("      Dump of %s\n", e2);
-	hexdump(v2, v1, l < 64 ? l : 64, offset);
+	hexdump(v2, v1, l < 128 ? l : 128, offset);
 	logprintf("\n");
 	failure_finish(extra);
 	return (0);
@@ -603,29 +750,24 @@
 
 /* Verify that the named file exists and is empty. */
 int
-assertion_empty_file(const char *f1fmt, ...)
+assertion_empty_file(const char *filename, int line, const char *f1)
 {
 	char buff[1024];
-	char f1[1024];
 	struct stat st;
-	va_list ap;
 	ssize_t s;
 	FILE *f;
 
-	assertion_count(test_filename, test_line);
-	va_start(ap, f1fmt);
-	vsprintf(f1, f1fmt, ap);
-	va_end(ap);
+	assertion_count(filename, line);
 
 	if (stat(f1, &st) != 0) {
-		failure_start(test_filename, test_line, "Stat failed: %s", f1);
+		failure_start(filename, line, "Stat failed: %s", f1);
 		failure_finish(NULL);
 		return (0);
 	}
 	if (st.st_size == 0)
 		return (1);
 
-	failure_start(test_filename, test_line, "File should be empty: %s", f1);
+	failure_start(filename, line, "File should be empty: %s", f1);
 	logprintf("    File size: %d\n", (int)st.st_size);
 	logprintf("    Contents:\n");
 	f = fopen(f1, "rb");
@@ -644,24 +786,19 @@
 
 /* Verify that the named file exists and is not empty. */
 int
-assertion_non_empty_file(const char *f1fmt, ...)
+assertion_non_empty_file(const char *filename, int line, const char *f1)
 {
-	char f1[1024];
 	struct stat st;
-	va_list ap;
 
-	assertion_count(test_filename, test_line);
-	va_start(ap, f1fmt);
-	vsprintf(f1, f1fmt, ap);
-	va_end(ap);
+	assertion_count(filename, line);
 
 	if (stat(f1, &st) != 0) {
-		failure_start(test_filename, test_line, "Stat failed: %s", f1);
+		failure_start(filename, line, "Stat failed: %s", f1);
 		failure_finish(NULL);
 		return (0);
 	}
 	if (st.st_size == 0) {
-		failure_start(test_filename, test_line, "File empty: %s", f1);
+		failure_start(filename, line, "File empty: %s", f1);
 		failure_finish(NULL);
 		return (0);
 	}
@@ -671,19 +808,14 @@
 /* Verify that two files have the same contents. */
 /* TODO: hexdump the first bytes that actually differ. */
 int
-assertion_equal_file(const char *fn1, const char *f2pattern, ...)
+assertion_equal_file(const char *filename, int line, const char *fn1, const char *fn2)
 {
-	char fn2[1024];
-	va_list ap;
 	char buff1[1024];
 	char buff2[1024];
 	FILE *f1, *f2;
 	int n1, n2;
 
-	assertion_count(test_filename, test_line);
-	va_start(ap, f2pattern);
-	vsprintf(fn2, f2pattern, ap);
-	va_end(ap);
+	assertion_count(filename, line);
 
 	f1 = fopen(fn1, "rb");
 	f2 = fopen(fn2, "rb");
@@ -702,24 +834,18 @@
 	}
 	fclose(f1);
 	fclose(f2);
-	failure_start(test_filename, test_line, "Files not identical");
+	failure_start(filename, line, "Files not identical");
 	logprintf("  file1=\"%s\"\n", fn1);
 	logprintf("  file2=\"%s\"\n", fn2);
-	failure_finish(test_extra);
+	failure_finish(NULL);
 	return (0);
 }
 
 /* Verify that the named file does exist. */
 int
-assertion_file_exists(const char *fpattern, ...)
+assertion_file_exists(const char *filename, int line, const char *f)
 {
-	char f[1024];
-	va_list ap;
-
-	assertion_count(test_filename, test_line);
-	va_start(ap, fpattern);
-	vsprintf(f, fpattern, ap);
-	va_end(ap);
+	assertion_count(filename, line);
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
 	if (!_access(f, 0))
@@ -728,22 +854,16 @@
 	if (!access(f, F_OK))
 		return (1);
 #endif
-	failure_start(test_filename, test_line, "File should exist: %s", f);
-	failure_finish(test_extra);
+	failure_start(filename, line, "File should exist: %s", f);
+	failure_finish(NULL);
 	return (0);
 }
 
 /* Verify that the named file doesn't exist. */
 int
-assertion_file_not_exists(const char *fpattern, ...)
+assertion_file_not_exists(const char *filename, int line, const char *f)
 {
-	char f[1024];
-	va_list ap;
-
-	assertion_count(test_filename, test_line);
-	va_start(ap, fpattern);
-	vsprintf(f, fpattern, ap);
-	va_end(ap);
+	assertion_count(filename, line);
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
 	if (_access(f, 0))
@@ -752,31 +872,26 @@
 	if (access(f, F_OK))
 		return (1);
 #endif
-	failure_start(test_filename, test_line, "File should not exist: %s", f);
-	failure_finish(test_extra);
+	failure_start(filename, line, "File should not exist: %s", f);
+	failure_finish(NULL);
 	return (0);
 }
 
 /* Compare the contents of a file to a block of memory. */
 int
-assertion_file_contents(const void *buff, int s, const char *fpattern, ...)
+assertion_file_contents(const char *filename, int line, const void *buff, int s, const char *fn)
 {
-	char fn[1024];
-	va_list ap;
 	char *contents;
 	FILE *f;
 	int n;
 
-	assertion_count(test_filename, test_line);
-	va_start(ap, fpattern);
-	vsprintf(fn, fpattern, ap);
-	va_end(ap);
+	assertion_count(filename, line);
 
 	f = fopen(fn, "rb");
 	if (f == NULL) {
-		failure_start(test_filename, test_line,
+		failure_start(filename, line,
 		    "File should exist: %s", fn);
-		failure_finish(test_extra);
+		failure_finish(NULL);
 		return (0);
 	}
 	contents = malloc(s * 2);
@@ -786,7 +901,7 @@
 		free(contents);
 		return (1);
 	}
-	failure_start(test_filename, test_line, "File contents don't match");
+	failure_start(filename, line, "File contents don't match");
 	logprintf("  file=\"%s\"\n", fn);
 	if (n > 0)
 		hexdump(contents, buff, n > 512 ? 512 : n, 0);
@@ -794,22 +909,28 @@
 		logprintf("  File empty, contents should be:\n");
 		hexdump(buff, NULL, s > 512 ? 512 : s, 0);
 	}
-	failure_finish(test_extra);
+	failure_finish(NULL);
 	free(contents);
 	return (0);
 }
 
 /* Check the contents of a text file, being tolerant of line endings. */
 int
-assertion_text_file_contents(const char *buff, const char *fn)
+assertion_text_file_contents(const char *filename, int line, const char *buff, const char *fn)
 {
 	char *contents;
 	const char *btxt, *ftxt;
 	FILE *f;
 	int n, s;
 
-	assertion_count(test_filename, test_line);
+	assertion_count(filename, line);
 	f = fopen(fn, "r");
+	if (f == NULL) {
+		failure_start(filename, line,
+		    "File doesn't exist: %s", fn);
+		failure_finish(NULL);
+		return (0);
+	}
 	s = strlen(buff);
 	contents = malloc(s * 2 + 128);
 	n = fread(contents, 1, s * 2 + 128 - 1, f);
@@ -837,15 +958,17 @@
 		free(contents);
 		return (1);
 	}
-	failure_start(test_filename, test_line, "Contents don't match");
+	failure_start(filename, line, "Contents don't match");
 	logprintf("  file=\"%s\"\n", fn);
-	if (n > 0)
+	if (n > 0) {
 		hexdump(contents, buff, n, 0);
-	else {
+		logprintf("  expected\n", fn);
+		hexdump(buff, contents, s, 0);
+	} else {
 		logprintf("  File empty, contents should be:\n");
 		hexdump(buff, NULL, s, 0);
 	}
-	failure_finish(test_extra);
+	failure_finish(NULL);
 	free(contents);
 	return (0);
 }
@@ -875,7 +998,7 @@
 		return (0);
 	}
 
-	// Make a copy of the provided lines and count up the expected file size.
+	/* Make a copy of the provided lines and count up the expected file size. */
 	expected_count = 0;
 	for (i = 0; lines[i] != NULL; ++i) {
 	}
@@ -885,7 +1008,7 @@
 		expected[i] = strdup(lines[i]);
 	}
 
-	// Break the file into lines
+	/* Break the file into lines */
 	actual_count = 0;
 	for (c = '\0', p = buff; p < buff + buff_size; ++p) {
 		if (*p == '\x0d' || *p == '\x0a')
@@ -902,7 +1025,7 @@
 		}
 	}
 
-	// Erase matching lines from both lists
+	/* Erase matching lines from both lists */
 	for (i = 0; i < expected_count; ++i) {
 		if (expected[i] == NULL)
 			continue;
@@ -918,7 +1041,7 @@
 		}
 	}
 
-	// If there's anything left, it's a failure
+	/* If there's anything left, it's a failure */
 	for (i = 0; i < expected_count; ++i) {
 		if (expected[i] != NULL)
 			++expected_failure;
@@ -1040,8 +1163,11 @@
 	ftime.dwHighDateTime = 0;
 
 	assertion_count(file, line);
+	/* Note: FILE_FLAG_BACKUP_SEMANTICS applies to open
+	 * a directory file. If not, CreateFile() will fail when
+	 * the pathname is a directory. */
 	h = CreateFile(pathname, FILE_READ_ATTRIBUTES, 0, NULL,
-	    OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+	    OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
 	if (h == INVALID_HANDLE_VALUE) {
 		failure_start(file, line, "Can't access %s\n", pathname);
 		failure_finish(NULL);
@@ -1106,14 +1232,14 @@
 		time_t now = time(NULL);
 		if (filet < now - 10 || filet > now + 1) {
 			failure_start(file, line,
-			    "File %s has %ctime %ld, %ld seconds ago\n",
+			    "File %s has %ctime %lld, %lld seconds ago\n",
 			    pathname, type, filet, now - filet);
 			failure_finish(NULL);
 			return (0);
 		}
 	} else if (filet != t || filet_nsec != nsec) {
 		failure_start(file, line,
-		    "File %s has %ctime %ld.%09ld, expected %ld.%09ld",
+		    "File %s has %ctime %lld.%09lld, expected %lld.%09lld",
 		    pathname, type, filet, filet_nsec, t, nsec);
 		failure_finish(NULL);
 		return (0);
@@ -1190,7 +1316,7 @@
 
 	assertion_count(file, line);
 	r = lstat(pathname, &st);
-	if (r == 0 && st.st_nlink == nlinks)
+	if (r == 0 && (int)st.st_nlink == nlinks)
 			return (1);
 	failure_start(file, line, "File %s has %d links, expected %d",
 	    pathname, st.st_nlink, nlinks);
@@ -1254,7 +1380,7 @@
 	/* Windows doesn't handle permissions the same way as POSIX,
 	 * so just ignore the mode tests. */
 	/* TODO: Can we do better here? */
-	if (mode >= 0 && mode != (st.st_mode & 07777)) {
+	if (mode >= 0 && (mode_t)mode != (st.st_mode & 07777)) {
 		failure_start(file, line, "Dir %s has wrong mode", pathname);
 		logprintf("  Expected: 0%3o\n", mode);
 		logprintf("  Found: 0%3o\n", st.st_mode & 07777);
@@ -1287,7 +1413,7 @@
 	/* Windows doesn't handle permissions the same way as POSIX,
 	 * so just ignore the mode tests. */
 	/* TODO: Can we do better here? */
-	if (mode >= 0 && mode != (st.st_mode & 07777)) {
+	if (mode >= 0 && (mode_t)mode != (st.st_mode & 07777)) {
 		failure_start(file, line, "File %s has wrong mode", pathname);
 		logprintf("  Expected: 0%3o\n", mode);
 		logprintf("  Found: 0%3o\n", st.st_mode & 07777);
@@ -1486,6 +1612,110 @@
 	return (1);
 }
 
+/* Set times, report failures. */
+int
+assertion_utimes(const char *file, int line,
+    const char *pathname, long at, long at_nsec, long mt, long mt_nsec)
+{
+	int r;
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#define WINTIME(sec, nsec) ((Int32x32To64(sec, 10000000) + EPOC_TIME)\
+	 + (((nsec)/1000)*10))
+	HANDLE h;
+	ULARGE_INTEGER wintm;
+	FILETIME fatime, fmtime;
+	FILETIME *pat, *pmt;
+
+	assertion_count(file, line);
+	h = CreateFileA(pathname,GENERIC_READ | GENERIC_WRITE,
+		    FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
+		    FILE_FLAG_BACKUP_SEMANTICS, NULL);
+	if (h == INVALID_HANDLE_VALUE) {
+		failure_start(file, line, "Can't access %s\n", pathname);
+		failure_finish(NULL);
+		return (0);
+	}
+
+	if (at > 0 || at_nsec > 0) {
+		wintm.QuadPart = WINTIME(at, at_nsec);
+		fatime.dwLowDateTime = wintm.LowPart;
+		fatime.dwHighDateTime = wintm.HighPart;
+		pat = &fatime;
+	} else
+		pat = NULL;
+	if (mt > 0 || mt_nsec > 0) {
+		wintm.QuadPart = WINTIME(mt, mt_nsec);
+		fmtime.dwLowDateTime = wintm.LowPart;
+		fmtime.dwHighDateTime = wintm.HighPart;
+		pmt = &fmtime;
+	} else
+		pmt = NULL;
+	if (pat != NULL || pmt != NULL)
+		r = SetFileTime(h, NULL, pat, pmt);
+	else
+		r = 1;
+	CloseHandle(h);
+	if (r == 0) {
+		failure_start(file, line, "Can't SetFileTime %s\n", pathname);
+		failure_finish(NULL);
+		return (0);
+	}
+	return (1);
+#else /* defined(_WIN32) && !defined(__CYGWIN__) */
+	struct stat st;
+	struct timeval times[2];
+
+#if !defined(__FreeBSD__)
+	mt_nsec = at_nsec = 0;	/* Generic POSIX only has whole seconds. */
+#endif
+	if (mt == 0 && mt_nsec == 0 && at == 0 && at_nsec == 0)
+		return (1);
+
+	r = lstat(pathname, &st);
+	if (r < 0) {
+		failure_start(file, line, "Can't stat %s\n", pathname);
+		failure_finish(NULL);
+		return (0);
+	}
+
+	if (mt == 0 && mt_nsec == 0) {
+		mt = st.st_mtime;
+#if defined(__FreeBSD__)
+		mt_nsec = st.st_mtimespec.tv_nsec;
+		/* FreeBSD generally only stores to microsecond res, so round. */
+		mt_nsec = (mt_nsec / 1000) * 1000;
+#endif
+	}
+	if (at == 0 && at_nsec == 0) {
+		at = st.st_atime;
+#if defined(__FreeBSD__)
+		at_nsec = st.st_atimespec.tv_nsec;
+		/* FreeBSD generally only stores to microsecond res, so round. */
+		at_nsec = (at_nsec / 1000) * 1000;
+#endif
+	}
+
+	times[1].tv_sec = mt;
+	times[1].tv_usec = mt_nsec / 1000;
+
+	times[0].tv_sec = at;
+	times[0].tv_usec = at_nsec / 1000;
+
+#ifdef HAVE_LUTIMES
+	r = lutimes(pathname, times);
+#else
+	r = utimes(pathname, times);
+#endif
+	if (r < 0) {
+		failure_start(file, line, "Can't utimes %s\n", pathname);
+		failure_finish(NULL);
+		return (0);
+	}
+	return (1);
+#endif /* defined(_WIN32) && !defined(__CYGWIN__) */
+}
+
 /*
  *
  *  UTILITIES for use by tests.
@@ -1711,6 +1941,27 @@
 	fclose(in);
 }
 
+int
+is_LargeInode(const char *file)
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+	BY_HANDLE_FILE_INFORMATION bhfi;
+	int r;
+
+	r = my_GetFileInformationByName(file, &bhfi);
+	if (r != 0)
+		return (0);
+	return (bhfi.nFileIndexHigh & 0x0000FFFFUL);
+#else
+	struct stat st;
+	int64_t ino;
+
+	if (stat(file, &st) < 0)
+		return (0);
+	ino = (int64_t)st.st_ino;
+	return (ino > 0xffffffff);
+#endif
+}
 /*
  *
  * TEST management
@@ -1740,7 +1991,7 @@
  * Summarize repeated failures in the just-completed test.
  */
 static void
-test_summarize(const char *filename, int failed)
+test_summarize(int failed)
 {
 	unsigned int i;
 
@@ -1759,9 +2010,10 @@
 	for (i = 0; i < sizeof(failed_lines)/sizeof(failed_lines[0]); i++) {
 		if (failed_lines[i].count > 1 && !failed_lines[i].skip)
 			logprintf("%s:%d: Summary: Failed %d times\n",
-			    filename, i, failed_lines[i].count);
+			    failed_filename, i, failed_lines[i].count);
 	}
 	/* Clear the failure history for the next file. */
+	failed_filename = NULL;
 	memset(failed_lines, 0, sizeof(failed_lines));
 }
 
@@ -1771,6 +2023,7 @@
 static int
 test_run(int i, const char *tmpdir)
 {
+	char workdir[1024];
 	char logfilename[64];
 	int failures_before = failures;
 	int oldumask;
@@ -1797,11 +2050,12 @@
 	logfile = fopen(logfilename, "w");
 	fprintf(logfile, "%s\n\n", tests[i].name);
 	/* Chdir() to a work dir for this specific test. */
-	if (!assertMakeDir(tests[i].name, 0755)
-	    || !assertChdir(tests[i].name)) {
+	snprintf(workdir, sizeof(workdir), "%s/%s", tmpdir, tests[i].name);
+	testworkdir = workdir;
+	if (!assertMakeDir(testworkdir, 0755)
+	    || !assertChdir(testworkdir)) {
 		fprintf(stderr,
-		    "ERROR: Can't chdir to work dir %s/%s\n",
-		    tmpdir, tests[i].name);
+		    "ERROR: Can't chdir to work dir %s\n", testworkdir);
 		exit(1);
 	}
 	/* Explicitly reset the locale before each test. */
@@ -1815,6 +2069,7 @@
 	/*
 	 * Clean up and report afterwards.
 	 */
+	testworkdir = NULL;
 	/* Restore umask */
 	umask(oldumask);
 	/* Reset locale. */
@@ -1827,7 +2082,7 @@
 	}
 	/* Report per-test summaries. */
 	tests[i].failures = failures - failures_before;
-	test_summarize(test_filename, tests[i].failures);
+	test_summarize(tests[i].failures);
 	/* Close the per-test log file. */
 	fclose(logfile);
 	logfile = NULL;
@@ -1887,6 +2142,7 @@
 	printf("  -q  Quiet.\n");
 	printf("  -r <dir>   Path to dir containing reference files.\n");
 	printf("      Default: Current directory.\n");
+	printf("  -u  Keep running specifies tests until one fails.\n");
 	printf("  -v  Verbose.\n");
 	printf("Available tests:\n");
 	for (i = 0; i < limit; i++)
@@ -1913,7 +2169,11 @@
 	}
 
 	/* Get the current dir. */
+#ifdef PATH_MAX
+	pwd = getcwd(NULL, PATH_MAX);/* Solaris getcwd needs the size. */
+#else
 	pwd = getcwd(NULL, 0);
+#endif
 	while (pwd[strlen(pwd) - 1] == '\n')
 		pwd[strlen(pwd) - 1] = '\0';
 
@@ -1940,6 +2200,14 @@
 	strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
 	strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
 
+#if defined(PROGRAM_ALIAS)
+	snprintf(buff, sizeof(buff), "%s/%s/test", pwd, PROGRAM_ALIAS);
+	p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
+	if (p != NULL) goto success;
+	strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
+	strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+#endif
+
 	if (memcmp(pwd, "/usr/obj", 8) == 0) {
 		snprintf(buff, sizeof(buff), "%s", pwd + 8);
 		p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
@@ -1972,16 +2240,26 @@
 main(int argc, char **argv)
 {
 	static const int limit = sizeof(tests) / sizeof(tests[0]);
-	int i, tests_run = 0, tests_failed = 0, option;
+	int i = 0, j = 0, start, end, tests_run = 0, tests_failed = 0, option;
 	time_t now;
 	char *refdir_alloc = NULL;
 	const char *progname;
+	char **saved_argv;
 	const char *tmp, *option_arg, *p;
-	char tmpdir[256];
+	char tmpdir[256], *pwd, *testprogdir, *tmp2 = NULL;
 	char tmpdir_timestamp[256];
 
 	(void)argc; /* UNUSED */
 
+	/* Get the current dir. */
+#ifdef PATH_MAX
+	pwd = getcwd(NULL, PATH_MAX);/* Solaris getcwd needs the size. */
+#else
+	pwd = getcwd(NULL, 0);
+#endif
+	while (pwd[strlen(pwd) - 1] == '\n')
+		pwd[strlen(pwd) - 1] = '\0';
+
 #if defined(HAVE__CrtSetReportMode)
 	/* To stop to run the default invalid parameter handler. */
 	_set_invalid_parameter_handler(invalid_parameter_handler);
@@ -1994,11 +2272,44 @@
 	 * tree.
 	 */
 	progname = p = argv[0];
+	if ((testprogdir = (char *)malloc(strlen(progname) + 1)) == NULL)
+	{
+		fprintf(stderr, "ERROR: Out of memory.");
+		exit(1);
+	}
+	strcpy(testprogdir, progname);
 	while (*p != '\0') {
 		/* Support \ or / dir separators for Windows compat. */
 		if (*p == '/' || *p == '\\')
+		{
 			progname = p + 1;
+			i = j;
+		}
 		++p;
+		j++;
+	}
+	testprogdir[i] = '\0';
+#if defined(_WIN32) && !defined(__CYGWIN__)
+	if (testprogdir[0] != '/' && testprogdir[0] != '\\' &&
+	    !(((testprogdir[0] >= 'a' && testprogdir[0] <= 'z') ||
+	       (testprogdir[0] >= 'A' && testprogdir[0] <= 'Z')) &&
+		testprogdir[1] == ':' &&
+		(testprogdir[2] == '/' || testprogdir[2] == '\\')))
+#else
+	if (testprogdir[0] != '/')
+#endif
+	{
+		/* Fixup path for relative directories. */
+		if ((testprogdir = (char *)realloc(testprogdir,
+			strlen(pwd) + 1 + strlen(testprogdir) + 1)) == NULL)
+		{
+			fprintf(stderr, "ERROR: Out of memory.");
+			exit(1);
+		}
+		memmove(testprogdir + strlen(pwd) + 1, testprogdir,
+		    strlen(testprogdir));
+		memcpy(testprogdir, pwd, strlen(pwd));
+		testprogdir[strlen(pwd)] = '/';
 	}
 
 #ifdef PROGRAM
@@ -2073,6 +2384,9 @@
 			case 'r':
 				refdir = option_arg;
 				break;
+			case 'u':
+				until_failure++;
+				break;
 			case 'v':
 				verbosity++;
 				break;
@@ -2088,9 +2402,18 @@
 	 * Sanity-check that our options make sense.
 	 */
 #ifdef PROGRAM
-	if (testprogfile == NULL) {
-		fprintf(stderr, "Program executable required\n");
-		usage(progname);
+	if (testprogfile == NULL)
+	{
+		if ((tmp2 = (char *)malloc(strlen(testprogdir) + 1 +
+			strlen(PROGRAM) + 1)) == NULL)
+		{
+			fprintf(stderr, "ERROR: Out of memory.");
+			exit(1);
+		}
+		strcpy(tmp2, testprogdir);
+		strcat(tmp2, "/");
+		strcat(tmp2, PROGRAM);
+		testprogfile = tmp2;
 	}
 
 	{
@@ -2113,6 +2436,16 @@
 	}
 #endif
 
+#if !defined(_WIN32) && defined(SIGPIPE)
+	{   /* Ignore SIGPIPE signals */
+		struct sigaction sa;
+		sa.sa_handler = SIG_IGN;
+		sigemptyset(&sa.sa_mask);
+		sa.sa_flags = 0;
+		sigaction(SIGPIPE, &sa, NULL);
+	}
+#endif
+
 	/*
 	 * Create a temp directory for the following tests.
 	 * Include the time the tests started as part of the name,
@@ -2165,42 +2498,88 @@
 	/*
 	 * Run some or all of the individual tests.
 	 */
-	if (*argv == NULL) {
-		/* Default: Run all tests. */
-		for (i = 0; i < limit; i++) {
-			if (test_run(i, tmpdir))
-				tests_failed++;
-			tests_run++;
-		}
-	} else {
-		while (*(argv) != NULL) {
-			if (**argv >= '0' && **argv <= '9') {
-				i = atoi(*argv);
-				if (i < 0 || i >= limit) {
-					printf("*** INVALID Test %s\n", *argv);
-					free(refdir_alloc);
-					usage(progname);
-					/* usage() never returns */
-				}
-			} else {
-				for (i = 0; i < limit; ++i) {
-					if (strcmp(*argv, tests[i].name) == 0)
-						break;
-				}
-				if (i >= limit) {
-					printf("*** INVALID Test ``%s''\n",
-					       *argv);
-					free(refdir_alloc);
-					usage(progname);
-					/* usage() never returns */
+	saved_argv = argv;
+	do {
+		argv = saved_argv;
+		if (*argv == NULL) {
+			/* Default: Run all tests. */
+			for (i = 0; i < limit; i++) {
+				tests_run++;
+				if (test_run(i, tmpdir)) {
+					tests_failed++;
+					if (until_failure)
+						goto finish;
 				}
 			}
-			if (test_run(i, tmpdir))
-				tests_failed++;
-			tests_run++;
-			argv++;
+		} else {
+			while (*(argv) != NULL) {
+				if (**argv >= '0' && **argv <= '9') {
+					char *vp = *argv;
+					start = 0;
+					while (*vp >= '0' && *vp <= '9') {
+						start *= 10;
+						start += *vp - '0';
+						++vp;
+					}
+					if (*vp == '\0') {
+						end = start;
+					} else if (*vp == '-') {
+						++vp;
+						if (*vp == '\0') {
+							end = limit - 1;
+						} else {
+							end = 0;
+							while (*vp >= '0' && *vp <= '9') {
+								end *= 10;
+								end += *vp - '0';
+								++vp;
+							}
+						}
+					} else {
+						printf("*** INVALID Test %s\n", *argv);
+						free(refdir_alloc);
+						usage(progname);
+						return (1);
+					}
+					if (start < 0 || end >= limit || start > end) {
+						printf("*** INVALID Test %s\n", *argv);
+						free(refdir_alloc);
+						usage(progname);
+						return (1);
+					}
+				} else {
+					for (start = 0; start < limit; ++start) {
+						if (strcmp(*argv, tests[start].name) == 0)
+							break;
+					}
+					end = start;
+					if (start >= limit) {
+						printf("*** INVALID Test ``%s''\n",
+						    *argv);
+						free(refdir_alloc);
+						usage(progname);
+						/* usage() never returns */
+					}
+				}
+				while (start <= end) {
+					tests_run++;
+					if (test_run(start, tmpdir)) {
+						tests_failed++;
+						if (until_failure)
+							goto finish;
+					}
+					++start;
+				}
+				argv++;
+			}
 		}
-	}
+	} while (until_failure);
+
+finish:
+	/* Must be freed after all tests run */
+	free(tmp2);
+	free(testprogdir);
+	free(pwd);
 
 	/*
 	 * Report summary statistics.
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/tar/test/test.h
--- a/head/contrib/libarchive/tar/test/test.h	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/tar/test/test.h	Fri Mar 02 16:54:40 2012 +0200
@@ -22,7 +22,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: head/contrib/libarchive/tar/test/test.h 228763 2011-12-21 11:13:29Z mm $
+ * $FreeBSD: head/contrib/libarchive/tar/test/test.h 232153 2012-02-25 10:58:02Z mm $
  */
 
 /* Every test program should #include "test.h" as the first thing. */
@@ -48,9 +48,6 @@
 #include <sys/types.h>  /* Windows requires this before sys/stat.h */
 #include <sys/stat.h>
 
-#ifdef USE_DMALLOC
-#include <dmalloc.h>
-#endif
 #if HAVE_DIRENT_H
 #include <dirent.h>
 #endif
@@ -63,6 +60,9 @@
 #ifdef HAVE_IO_H
 #include <io.h>
 #endif
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -83,13 +83,11 @@
 
 /* Windows (including Visual Studio and MinGW but not Cygwin) */
 #if defined(_WIN32) && !defined(__CYGWIN__)
-#include "../bsdtar_windows.h"
 #if !defined(__BORLANDC__)
+#undef chdir
+#define chdir _chdir
 #define strdup _strdup
 #endif
-#define LOCALE_DE	"deu"
-#else
-#define LOCALE_DE	"de_DE.UTF-8"
 #endif
 
 /* Visual Studio */
@@ -97,13 +95,11 @@
 #define snprintf	sprintf_s
 #endif
 
-/* Cygwin */
-#if defined(__CYGWIN__)
-/* Cygwin-1.7.x is lazy about populating nlinks, so don't
- * expect it to be accurate. */
-# define NLINKS_INACCURATE_FOR_DIRS
+#if defined(__BORLANDC__)
+#pragma warn -8068	/* Constant out of range in comparison. */
 #endif
 
+/* Haiku OS and QNX */
 #if defined(__HAIKU__) || defined(__QNXNTO__)
 /* Haiku and QNX have typedefs in stdint.h (needed for int64_t) */
 #include <stdint.h>
@@ -139,24 +135,24 @@
   assertion_equal_int(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
 /* Assert two strings are the same.  Reports value of each one if not. */
 #define assertEqualString(v1,v2)   \
-  assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
+  assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL, 0)
+#define assertEqualUTF8String(v1,v2)   \
+  assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL, 1)
 /* As above, but v1 and v2 are wchar_t * */
 #define assertEqualWString(v1,v2)   \
   assertion_equal_wstring(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
 /* As above, but raw blocks of bytes. */
 #define assertEqualMem(v1, v2, l)	\
   assertion_equal_mem(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (l), #l, NULL)
-/* Assert two files are the same; allow printf-style expansion of second name.
- * See below for comments about variable arguments here...
- */
-#define assertEqualFile		\
-  assertion_setup(__FILE__, __LINE__);assertion_equal_file
-/* Assert that a file is empty; supports printf-style arguments. */
-#define assertEmptyFile		\
-  assertion_setup(__FILE__, __LINE__);assertion_empty_file
-/* Assert that a file is not empty; supports printf-style arguments. */
-#define assertNonEmptyFile		\
-  assertion_setup(__FILE__, __LINE__);assertion_non_empty_file
+/* Assert two files are the same. */
+#define assertEqualFile(f1, f2)	\
+  assertion_equal_file(__FILE__, __LINE__, (f1), (f2))
+/* Assert that a file is empty. */
+#define assertEmptyFile(pathname)	\
+  assertion_empty_file(__FILE__, __LINE__, (pathname))
+/* Assert that a file is not empty. */
+#define assertNonEmptyFile(pathname)		\
+  assertion_non_empty_file(__FILE__, __LINE__, (pathname))
 #define assertFileAtime(pathname, sec, nsec)	\
   assertion_file_atime(__FILE__, __LINE__, pathname, sec, nsec)
 #define assertFileAtimeRecent(pathname)	\
@@ -166,14 +162,14 @@
 #define assertFileBirthtimeRecent(pathname) \
   assertion_file_birthtime_recent(__FILE__, __LINE__, pathname)
 /* Assert that a file exists; supports printf-style arguments. */
-#define assertFileExists		\
-  assertion_setup(__FILE__, __LINE__);assertion_file_exists
-/* Assert that a file exists; supports printf-style arguments. */
-#define assertFileNotExists		\
-  assertion_setup(__FILE__, __LINE__);assertion_file_not_exists
-/* Assert that file contents match a string; supports printf-style arguments. */
-#define assertFileContents             \
-  assertion_setup(__FILE__, __LINE__);assertion_file_contents
+#define assertFileExists(pathname) \
+  assertion_file_exists(__FILE__, __LINE__, pathname)
+/* Assert that a file exists. */
+#define assertFileNotExists(pathname) \
+  assertion_file_not_exists(__FILE__, __LINE__, pathname)
+/* Assert that file contents match a string. */
+#define assertFileContents(data, data_size, pathname) \
+  assertion_file_contents(__FILE__, __LINE__, data, data_size, pathname)
 #define assertFileMtime(pathname, sec, nsec)	\
   assertion_file_mtime(__FILE__, __LINE__, pathname, sec, nsec)
 #define assertFileMtimeRecent(pathname) \
@@ -182,10 +178,10 @@
   assertion_file_nlinks(__FILE__, __LINE__, pathname, nlinks)
 #define assertFileSize(pathname, size)  \
   assertion_file_size(__FILE__, __LINE__, pathname, size)
-#define assertTextFileContents         \
-  assertion_setup(__FILE__, __LINE__);assertion_text_file_contents
+#define assertTextFileContents(text, pathname) \
+  assertion_text_file_contents(__FILE__, __LINE__, text, pathname)
 #define assertFileContainsLinesAnyOrder(pathname, lines)	\
-	assertion_file_contains_lines_any_order(__FILE__, __LINE__, pathname, lines)
+  assertion_file_contains_lines_any_order(__FILE__, __LINE__, pathname, lines)
 #define assertIsDir(pathname, mode)		\
   assertion_is_dir(__FILE__, __LINE__, pathname, mode)
 #define assertIsHardlink(path1, path2)	\
@@ -207,6 +203,8 @@
   assertion_make_symlink(__FILE__, __LINE__, newfile, linkto)
 #define assertUmask(mask)	\
   assertion_umask(__FILE__, __LINE__, mask)
+#define assertUtimes(pathname, atime, atime_nsec, mtime, mtime_nsec)	\
+  assertion_utimes(__FILE__, __LINE__, pathname, atime, atime_nsec, mtime, mtime_nsec)
 
 /*
  * This would be simple with C99 variadic macros, but I don't want to
@@ -215,29 +213,29 @@
  * but effective.
  */
 #define skipping	\
-  assertion_setup(__FILE__, __LINE__);test_skipping
+  skipping_setup(__FILE__, __LINE__);test_skipping
 
 /* Function declarations.  These are defined in test_utility.c. */
 void failure(const char *fmt, ...);
 int assertion_assert(const char *, int, int, const char *, void *);
 int assertion_chdir(const char *, int, const char *);
-int assertion_empty_file(const char *, ...);
-int assertion_equal_file(const char *, const char *, ...);
+int assertion_empty_file(const char *, int, const char *);
+int assertion_equal_file(const char *, int, const char *, const char *);
 int assertion_equal_int(const char *, int, long long, const char *, long long, const char *, void *);
 int assertion_equal_mem(const char *, int, const void *, const char *, const void *, const char *, size_t, const char *, void *);
-int assertion_equal_string(const char *, int, const char *v1, const char *, const char *v2, const char *, void *);
+int assertion_equal_string(const char *, int, const char *v1, const char *, const char *v2, const char *, void *, int);
 int assertion_equal_wstring(const char *, int, const wchar_t *v1, const char *, const wchar_t *v2, const char *, void *);
 int assertion_file_atime(const char *, int, const char *, long, long);
 int assertion_file_atime_recent(const char *, int, const char *);
 int assertion_file_birthtime(const char *, int, const char *, long, long);
 int assertion_file_birthtime_recent(const char *, int, const char *);
 int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **);
-int assertion_file_contents(const void *, int, const char *, ...);
-int assertion_file_exists(const char *, ...);
+int assertion_file_contents(const char *, int, const void *, int, const char *);
+int assertion_file_exists(const char *, int, const char *);
 int assertion_file_mtime(const char *, int, const char *, long, long);
 int assertion_file_mtime_recent(const char *, int, const char *);
 int assertion_file_nlinks(const char *, int, const char *, int);
-int assertion_file_not_exists(const char *, ...);
+int assertion_file_not_exists(const char *, int, const char *);
 int assertion_file_size(const char *, int, const char *, long);
 int assertion_is_dir(const char *, int, const char *, int);
 int assertion_is_hardlink(const char *, int, const char *, const char *);
@@ -248,11 +246,12 @@
 int assertion_make_file(const char *, int, const char *, int, const char *);
 int assertion_make_hardlink(const char *, int, const char *newpath, const char *);
 int assertion_make_symlink(const char *, int, const char *newpath, const char *);
-int assertion_non_empty_file(const char *, ...);
-int assertion_text_file_contents(const char *buff, const char *f);
+int assertion_non_empty_file(const char *, int, const char *);
+int assertion_text_file_contents(const char *, int, const char *buff, const char *f);
 int assertion_umask(const char *, int, int);
-void assertion_setup(const char *, int);
+int assertion_utimes(const char *, int, const char *, long, long, long, long );
 
+void skipping_setup(const char *, int);
 void test_skipping(const char *fmt, ...);
 
 /* Like sprintf, then system() */
@@ -270,6 +269,9 @@
 /* Return true if this platform can run the "gunzip" program. */
 int canGunzip(void);
 
+/* Return true if the file has large i-node number(>0xffffffff). */
+int is_LargeInode(const char *);
+
 /* Suck file into string allocated via malloc(). Call free() when done. */
 /* Supports printf-style args: slurpfile(NULL, "%s/myfile", refdir); */
 char *slurpfile(size_t *, const char *fmt, ...);
@@ -277,6 +279,9 @@
 /* Extracts named reference file to the current directory. */
 void extract_reference_file(const char *);
 
+/* Path to working directory for current test */
+const char *testworkdir;
+
 /*
  * Special interfaces for program test harness.
  */
@@ -286,3 +291,7 @@
 /* Name of exe to use in printf-formatted command strings. */
 /* On Windows, this includes leading/trailing quotes. */
 const char *testprog;
+
+#ifdef USE_DMALLOC
+#include <dmalloc.h>
+#endif
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/tar/test/test_0.c
--- a/head/contrib/libarchive/tar/test/test_0.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/tar/test/test_0.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/tar/test/test_0.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/tar/test/test_0.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * This first test does basic sanity checks on the environment.  For
@@ -40,15 +40,23 @@
 	struct stat st;
 
 	failure("File %s does not exist?!", testprog);
-	if (!assertEqualInt(0, stat(testprogfile, &st)))
+	if (!assertEqualInt(0, stat(testprogfile, &st))) {
+		fprintf(stderr,
+		    "\nFile %s does not exist; aborting test.\n\n",
+		    testprog);
 		exit(1);
+	}
 
 	failure("%s is not executable?!", testprog);
-	if (!assert((st.st_mode & 0111) != 0))
+	if (!assert((st.st_mode & 0111) != 0)) {
+		fprintf(stderr,
+		    "\nFile %s not executable; aborting test.\n\n",
+		    testprog);
 		exit(1);
+	}
 
 	/*
-	 * Try to succesfully run the program; this requires that
+	 * Try to successfully run the program; this requires that
 	 * we know some option that will succeed.
 	 */
 	if (0 == systemf("%s --version >" DEV_NULL, testprog)) {
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/tar/test/test_basic.c
--- a/head/contrib/libarchive/tar/test/test_basic.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/tar/test/test_basic.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,11 +23,65 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/tar/test/test_basic.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/tar/test/test_basic.c 232153 2012-02-25 10:58:02Z mm $");
 
+static const char *
+make_files(void)
+{
+	FILE *f;
+
+	/* File with 10 bytes content. */
+	f = fopen("file", "wb");
+	assert(f != NULL);
+	assertEqualInt(10, fwrite("123456789", 1, 10, f));
+	fclose(f);
+
+	/* hardlink to above file. */
+	assertMakeHardlink("linkfile", "file");
+	assertIsHardlink("file", "linkfile");
+
+	/* Symlink to above file. */
+	if (canSymlink())
+		assertMakeSymlink("symlink", "file");
+
+	/* Directory. */
+	assertMakeDir("dir", 0775);
+
+	return canSymlink()
+	    ? "file linkfile symlink dir"
+	    : "file linkfile dir";
+}
 
 static void
-basic_tar(const char *target, const char *pack_options,
+verify_files(const char *target)
+{
+	assertChdir(target);
+
+	/* Regular file with 2 links. */
+	assertIsReg("file", -1);
+	assertFileSize("file", 10);
+	assertFileContents("123456789", 10, "file");
+	failure("%s", target);
+	assertFileNLinks("file", 2);
+
+	/* Another name for the same file. */
+	assertIsReg("linkfile", -1);
+	assertFileSize("linkfile", 10);
+	assertFileContents("123456789", 10, "linkfile");
+	assertFileNLinks("linkfile", 2);
+	assertIsHardlink("file", "linkfile");
+
+	/* Symlink */
+	if (canSymlink())
+		assertIsSymlink("symlink", "file");
+
+	/* dir */
+	assertIsDir("dir", 0775);
+	assertChdir("..");
+}
+
+static void
+run_tar(const char *target, const char *pack_options,
     const char *unpack_options, const char *flist)
 {
 	int r;
@@ -47,69 +101,29 @@
 	/*
 	 * Use tar to unpack the archive into another directory.
 	 */
-	r = systemf("%s xf archive %s >unpack.out 2>unpack.err", testprog, unpack_options);
+	r = systemf("%s xf archive %s >unpack.out 2>unpack.err",
+	    testprog, unpack_options);
 	failure("Error invoking %s xf archive %s", testprog, unpack_options);
 	assertEqualInt(r, 0);
 
 	/* Verify that nothing went to stderr. */
 	assertEmptyFile("unpack.err");
-
-	/*
-	 * Verify unpacked files.
-	 */
-
-	/* Regular file with 2 links. */
-	assertIsReg("file", -1);
-	assertFileSize("file", 10);
-	failure("%s", target);
-	assertFileNLinks("file", 2);
-
-	/* Another name for the same file. */
-	assertIsReg("linkfile", -1);
-	assertFileSize("linkfile", 10);
-	assertFileNLinks("linkfile", 2);
-	assertIsHardlink("file", "linkfile");
-
-	/* Symlink */
-	if (canSymlink())
-		assertIsSymlink("symlink", "file");
-
-	/* dir */
-	assertIsDir("dir", 0775);
 	assertChdir("..");
 }
 
 DEFINE_TEST(test_basic)
 {
-	FILE *f;
 	const char *flist;
 
 	assertUmask(0);
+	flist = make_files();
+	/* Archive/dearchive with a variety of options. */
+	run_tar("copy", "", "", flist);
+	verify_files("copy");
 
-	/* File with 10 bytes content. */
-	f = fopen("file", "wb");
-	assert(f != NULL);
-	assertEqualInt(10, fwrite("123456789", 1, 10, f));
-	fclose(f);
+	run_tar("copy_ustar", "--format=ustar", "", flist);
+	verify_files("copy_ustar");
 
-	/* hardlink to above file. */
-	assertMakeHardlink("linkfile", "file");
-	assertIsHardlink("file", "linkfile");
-
-	/* Symlink to above file. */
-	if (canSymlink())
-		assertMakeSymlink("symlink", "file");
-
-	/* Directory. */
-	assertMakeDir("dir", 0775);
-
-	if (canSymlink())
-		flist = "file linkfile symlink dir";
-	else
-		flist = "file linkfile dir";
-	/* Archive/dearchive with a variety of options. */
-	basic_tar("copy", "", "", flist);
 	/* tar doesn't handle cpio symlinks correctly */
-	/* basic_tar("copy_odc", "--format=odc", ""); */
-	basic_tar("copy_ustar", "--format=ustar", "", flist);
+	/* run_tar("copy_odc", "--format=odc", ""); */
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/tar/test/test_option_T_upper.c
--- a/head/contrib/libarchive/tar/test/test_option_T_upper.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/tar/test/test_option_T_upper.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,44 +23,36 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/tar/test/test_option_T_upper.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/tar/test/test_option_T_upper.c 232153 2012-02-25 10:58:02Z mm $");
 
 static int
-touch(const char *fn, int fail)
+tryMakeFile(const char *fn)
 {
 	FILE *f = fopen(fn, "w");
-	if (fail) {
-		failure("Couldn't create file '%s', errno=%d (%s)\n",
-		    fn, errno, strerror(errno));
-		if (!assert(f != NULL))
-			return (0); /* Failure. */
-	} else {
-		if (f == NULL)
-			return (0); /* Soft failure. */
-	}
+	if (f == NULL)
+		return (0);
 	fclose(f);
-	return (1); /* Success */
+	return (1);
 }
 
 DEFINE_TEST(test_option_T_upper)
 {
 	FILE *f;
 	int r;
-	struct stat st;
 	int gnarlyFilesSupported;
 
-	/* Create a simple dir heirarchy; bail if anything fails. */
+	/* Create a simple dir hierarchy; bail if anything fails. */
 	if (!assertMakeDir("d1", 0755)) return;
 	if (!assertMakeDir("d1/d2", 0755))	return;
-	if (!touch("f", 1)) return;
-	if (!touch("d1/f1", 1)) return;
-	if (!touch("d1/f2", 1)) return;
-	if (!touch("d1/d2/f3", 1)) return;
-	if (!touch("d1/d2/f4", 1)) return;
-	if (!touch("d1/d2/f5", 1)) return;
-	if (!touch("d1/d2/f6", 1)) return;
+	if (!assertMakeFile("f", 0644, "")) return;
+	if (!assertMakeFile("d1/f1", 0644, "")) return;
+	if (!assertMakeFile("d1/f2", 0644, "")) return;
+	if (!assertMakeFile("d1/d2/f3", 0644, "")) return;
+	if (!assertMakeFile("d1/d2/f4", 0644, "")) return;
+	if (!assertMakeFile("d1/d2/f5", 0644, "")) return;
+	if (!assertMakeFile("d1/d2/f6", 0644, "")) return;
 	/* Some platforms don't permit such things; just skip it. */
-	gnarlyFilesSupported = touch("d1/d2/f\x0a", 0);
+	gnarlyFilesSupported = tryMakeFile("d1/d2/f\x0a");
 
 	/* Populate a file list */
 	f = fopen("filelist", "w+");
@@ -79,12 +71,12 @@
 		return;
 	/* Use null-terminated names. */
 	fprintf(f, "d1/d2/f3");
-	fwrite("\0", 1, 1, f);
+	assertEqualInt(1, fwrite("\0", 1, 1, f));
 	fprintf(f, "d1/d2/f5");
-	fwrite("\0", 1, 1, f);
+	assertEqualInt(1, fwrite("\0", 1, 1, f));
 	if (gnarlyFilesSupported) {
 		fprintf(f, "d1/d2/f\x0a");
-		fwrite("\0", 1, 1, f);
+		assertEqualInt(1, fwrite("\0", 1, 1, f));
 	}
 	fclose(f);
 
@@ -160,28 +152,8 @@
 	assertMakeDir("test4_out", 0755);
 	assertMakeDir("test4_out2", 0755);
 	assertMakeDir("test4/d1", 0755);
-	assertEqualInt(1, touch("test4/d1/foo", 0));
+	assertMakeFile("test4/d1/foo", 0644, "");
 
-	/* Does bsdtar support -s option ? */
-	systemf("%s -cf - -s /foo/bar/ test4/d1/foo > check.out 2> check.err",
-	    testprog);
-	assertEqualInt(0, stat("check.err", &st));
-	if (st.st_size == 0) {
-		systemf("%s -cf - -s /foo/bar/ test4/d1/foo | %s -xf - -C test4_out",
-		    testprog, testprog);
-		assertEmptyFile("test4_out/test4/d1/bar");
-		systemf("%s -cf - -s /d1/d2/ test4/d1/foo | %s -xf - -C test4_out",
-		    testprog, testprog);
-		assertEmptyFile("test4_out/test4/d2/foo");
-		systemf("%s -cf - -s ,test4/d1/foo,, test4/d1/foo | %s -tvf - > test4.lst",
-		    testprog, testprog);
-		assertEmptyFile("test4.lst");
-		systemf("%s -cf - test4/d1/foo | %s -xf - -s /foo/bar/ -C test4_out2",
-		    testprog, testprog);
-		assertEmptyFile("test4_out2/test4/d1/bar");
-	} else {
-		skipping("bsdtar does not support -s option on this platform");
-	}
 
 	/* TODO: Include some use of -C directory-changing within the filelist. */
 	/* I'm pretty sure -C within the filelist is broken on extract. */
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/tar/test/test_option_q.c
--- a/head/contrib/libarchive/tar/test/test_option_q.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/tar/test/test_option_q.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,11 +23,10 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/tar/test/test_option_q.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/tar/test/test_option_q.c 232153 2012-02-25 10:58:02Z mm $");
 
 DEFINE_TEST(test_option_q)
 {
-	FILE *f;
 	int r;
 
 	/*
@@ -40,38 +39,23 @@
 	 * what we use to build up the test archive.
 	 */
 
-	f = fopen("foo", "w");
-	assert(f != NULL);
-	fprintf(f, "foo1");
-	fclose(f);
+	assertMakeFile("foo", 0644, "foo1");
 
 	assertEqualInt(0, systemf("%s -cf archive.tar foo", testprog));
 
-	f = fopen("foo", "w");
-	assert(f != NULL);
-	fprintf(f, "foo2");
-	fclose(f);
+	assertMakeFile("foo", 0644, "foo2");
 
 	assertEqualInt(0, systemf("%s -rf archive.tar foo", testprog));
 
-	f = fopen("bar", "w");
-	assert(f != NULL);
-	fprintf(f, "bar1");
-	fclose(f);
+	assertMakeFile("bar", 0644, "bar1");
 
 	assertEqualInt(0, systemf("%s -rf archive.tar bar", testprog));
 
-	f = fopen("foo", "w");
-	assert(f != NULL);
-	fprintf(f, "foo3");
-	fclose(f);
+	assertMakeFile("foo", 0644, "foo3");
 
 	assertEqualInt(0, systemf("%s -rf archive.tar foo", testprog));
 
-	f = fopen("bar", "w");
-	assert(f != NULL);
-	fprintf(f, "bar2");
-	fclose(f);
+	assertMakeFile("bar", 0644, "bar2");
 
 	assertEqualInt(0, systemf("%s -rf archive.tar bar", testprog));
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/tar/test/test_option_r.c
--- a/head/contrib/libarchive/tar/test/test_option_r.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/tar/test/test_option_r.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,36 +23,27 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/tar/test/test_option_r.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/tar/test/test_option_r.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * Also see test_option_q for additional validation of -r support.
  */
 DEFINE_TEST(test_option_r)
 {
-	char buff[15];
+	char *buff;
 	char *p0, *p1;
-	size_t s;
-	FILE *f;
-	int r;
+	size_t buff_size = 35000;
+	size_t s, buff_size_rounded;
+	int r, i;
 
-	/* Create a file */
-	f = fopen("f1", "w");
-	if (!assert(f != NULL))
-		return;
-	assertEqualInt(3, fwrite("abc", 1, 3, f));
-	fclose(f);
-
-	/* Archive that one file. */
+	/* Create an archive with one file. */
+	assertMakeFile("f1", 0644, "abc");
 	r = systemf("%s cf archive.tar --format=ustar f1 >step1.out 2>step1.err", testprog);
 	failure("Error invoking %s cf archive.tar f1", testprog);
 	assertEqualInt(r, 0);
-
-	/* Verify that nothing went to stdout or stderr. */
 	assertEmptyFile("step1.out");
 	assertEmptyFile("step1.err");
 
-
 	/* Do some basic validation of the constructed archive. */
 	p0 = slurpfile(&s, "archive.tar");
 	if (!assert(p0 != NULL))
@@ -66,52 +57,74 @@
 	assertEqualMem(p0 + 1024, "\0\0\0\0\0\0\0\0", 8);
 	assertEqualMem(p0 + 1536, "\0\0\0\0\0\0\0\0", 8);
 
-	/* Edit that file */
-	f = fopen("f1", "w");
-	if (!assert(f != NULL))
-		return;
-	assertEqualInt(3, fwrite("123", 1, 3, f));
-	fclose(f);
-
-	/* Update the archive. */
+	/* Edit that file with a lot more data and update the archive with a new copy. */
+	buff = malloc(buff_size);
+	assert(buff != NULL);
+	for (i = 0; i < (int)buff_size; ++i)
+		buff[i] = "abcdefghijklmnopqrstuvwxyz"[rand() % 26];
+	buff[buff_size - 1] = '\0';
+	assertMakeFile("f1", 0644, buff);
 	r = systemf("%s rf archive.tar --format=ustar f1 >step2.out 2>step2.err", testprog);
 	failure("Error invoking %s rf archive.tar f1", testprog);
 	assertEqualInt(r, 0);
-
-	/* Verify that nothing went to stdout or stderr. */
 	assertEmptyFile("step2.out");
 	assertEmptyFile("step2.err");
 
-	/* Do some basic validation of the constructed archive. */
+	/* The constructed archive should just have the new entry appended. */
 	p1 = slurpfile(&s, "archive.tar");
 	if (!assert(p1 != NULL)) {
 		free(p0);
 		return;
 	}
-	assert(s >= 3072);
+	buff_size_rounded = ((buff_size + 511) / 512) * 512;
+	assert(s >= 2560 + buff_size_rounded);
 	/* Verify first entry is unchanged. */
 	assertEqualMem(p0, p1, 1024);
 	/* Verify that second entry is correct. */
 	assertEqualMem(p1 + 1024, "f1", 3);
-	assertEqualMem(p1 + 1536, "123", 3);
+	assertEqualMem(p1 + 1536, buff, buff_size);
 	/* Verify end-of-archive marker. */
-	assertEqualMem(p1 + 2048, "\0\0\0\0\0\0\0\0", 8);
-	assertEqualMem(p1 + 2560, "\0\0\0\0\0\0\0\0", 8);
+	assertEqualMem(p1 + 1536 + buff_size_rounded, "\0\0\0\0\0\0\0\0", 8);
+	assertEqualMem(p1 + 2048 + buff_size_rounded, "\0\0\0\0\0\0\0\0", 8);
+
+	free(p0);
+	p0 = p1;
+
+	/* Update the archive by adding a different file. */
+	assertMakeFile("f2", 0644, "f2");
+	r = systemf("%s rf archive.tar --format=ustar f2 >step3.out 2>step3.err", testprog);
+	failure("Error invoking %s rf archive.tar f2", testprog);
+	assertEqualInt(r, 0);
+	assertEmptyFile("step3.out");
+	assertEmptyFile("step3.err");
+
+	/* Validate the constructed archive. */
+	p1 = slurpfile(&s, "archive.tar");
+	if (!assert(p1 != NULL)) {
+		free(p0);
+		return;
+	}
+	assert(s >= 3584 + buff_size_rounded);
+	/* Verify first two entries are unchanged. */
+	assertEqualMem(p0, p1, 1536 + buff_size_rounded);
+	/* Verify that new entry is correct. */
+	assertEqualMem(p1 + 1536 + buff_size_rounded, "f2", 3);
+	assertEqualMem(p1 + 2048 + buff_size_rounded, "f2", 3);
+	/* Verify end-of-archive marker. */
+	assertEqualMem(p1 + 2560 + buff_size_rounded, "\0\0\0\0\0\0\0\0", 8);
+	assertEqualMem(p1 + 3072 + buff_size_rounded, "\0\0\0\0\0\0\0\0", 8);
 	free(p0);
 	free(p1);
 
-	/* Unpack both items */
-	assertMakeDir("step3", 0775);
-	assertChdir("step3");
-	r = systemf("%s xf ../archive.tar", testprog);
+	/* Unpack everything */
+	assertMakeDir("extract", 0775);
+	assertChdir("extract");
+	r = systemf("%s xf ../archive.tar >extract.out 2>extract.err", testprog);
 	failure("Error invoking %s xf archive.tar", testprog);
 	assertEqualInt(r, 0);
+	assertEmptyFile("extract.out");
+	assertEmptyFile("extract.err");
 
-	/* Verify that the second one overwrote the first. */
-	f = fopen("f1", "r");
-	if (assert(f != NULL)) {
-		assertEqualInt(3, fread(buff, 1, 3, f));
-		assertEqualMem(buff, "123", 3);
-		fclose(f);
-	}
+	/* Verify that the second copy of f1 overwrote the first. */
+	assertFileContents(buff, strlen(buff), "f1");
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/tar/test/test_option_s.c
--- a/head/contrib/libarchive/tar/test/test_option_s.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/tar/test/test_option_s.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,22 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/tar/test/test_option_s.c 228776 2011-12-21 15:30:49Z mm $");
-
-static int
-mkfile(const char *fn, const char *contents)
-{
-	FILE *f = fopen(fn, "w");
-	failure("Couldn't create file '%s', errno=%d (%s)\n",
-	    fn, errno, strerror(errno));
-	if (!assert(f != NULL))
-		return (1); /* Failure. */
-	if (contents != NULL)
-		assertEqualInt(strlen(contents),
-		    fwrite(contents, 1, strlen(contents), f));
-	assertEqualInt(0, fclose(f));
-	return (0); /* Success */
-}
+__FBSDID("$FreeBSD: head/contrib/libarchive/tar/test/test_option_s.c 232153 2012-02-25 10:58:02Z mm $");
 
 DEFINE_TEST(test_option_s)
 {
@@ -47,10 +32,16 @@
 	/* Create a sample file hierarchy. */
 	assertMakeDir("in", 0755);
 	assertMakeDir("in/d1", 0755);
-	assertEqualInt(0, mkfile("in/d1/foo", "foo"));
-	assertEqualInt(0, mkfile("in/d1/bar", "bar"));
+	assertMakeFile("in/d1/foo", 0644, "foo");
+	assertMakeFile("in/d1/bar", 0644, "bar");
+	if (canSymlink()) {
+		assertMakeFile("in/d1/realfile", 0644, "realfile");
+		assertMakeSymlink("in/d1/symlink", "realfile");
+	}
+	assertMakeFile("in/d1/hardlink1", 0644, "hardlinkedfile");
+	assertMakeHardlink("in/d1/hardlink2", "in/d1/hardlink1");
 
-	/* Does bsdtar support -s option ? */
+	/* Does tar support -s option ? */
 	systemf("%s -cf - -s /foo/bar/ in/d1/foo > NUL 2> check.err",
 	    testprog);
 	assertEqualInt(0, stat("check.err", &st));
@@ -64,34 +55,35 @@
 	 * Test 1: Filename substitution when creating archives.
 	 */
 	assertMakeDir("test1", 0755);
-	systemf("%s -cf - -s /foo/bar/ in/d1/foo | %s -xf - -C test1",
-	    testprog, testprog);
+	systemf("%s -cf test1_1.tar -s /foo/bar/ in/d1/foo", testprog);
+	systemf("%s -xf test1_1.tar -C test1", testprog);
 	assertFileContents("foo", 3, "test1/in/d1/bar");
-	systemf("%s -cf - -s /d1/d2/ in/d1/foo | %s -xf - -C test1",
-	    testprog, testprog);
+	systemf("%s -cf test1_2.tar -s /d1/d2/ in/d1/foo", testprog);
+	systemf("%s -xf test1_2.tar -C test1", testprog);
 	assertFileContents("foo", 3, "test1/in/d2/foo");
 
-
 	/*
 	 * Test 2: Basic substitution when extracting archive.
 	 */
 	assertMakeDir("test2", 0755);
-	systemf("%s -cf - in/d1/foo | %s -xf - -s /foo/bar/ -C test2",
-	    testprog, testprog);
+	systemf("%s -cf test2.tar in/d1/foo", testprog);
+	systemf("%s -xf test2.tar -s /foo/bar/ -C test2", testprog);
 	assertFileContents("foo", 3, "test2/in/d1/bar");
 
 	/*
 	 * Test 3: Files with empty names shouldn't be archived.
 	 */
-	systemf("%s -cf - -s ,in/d1/foo,, in/d1/foo | %s -tvf - > in.lst",
-	    testprog, testprog);
+	systemf("%s -cf test3.tar -s ,in/d1/foo,, in/d1/foo", testprog);
+	systemf("%s -tvf test3.tar > in.lst", testprog);
 	assertEmptyFile("in.lst");
 
 	/*
 	 * Test 4: Multiple substitutions when extracting archive.
 	 */
 	assertMakeDir("test4", 0755);
-	systemf("%s -cf - in/d1/foo in/d1/bar | %s -xf - -s /foo/bar/ -s }bar}baz} -C test4",
+	systemf("%s -cf test4.tar in/d1/foo in/d1/bar",
+	    testprog, testprog);
+	systemf("%s -xf test4.tar -s /foo/bar/ -s }bar}baz} -C test4",
 	    testprog, testprog);
 	assertFileContents("foo", 3, "test4/in/d1/bar");
 	assertFileContents("bar", 3, "test4/in/d1/baz");
@@ -100,8 +92,170 @@
 	 * Test 5: Name-switching substitutions when extracting archive.
 	 */
 	assertMakeDir("test5", 0755);
-	systemf("%s -cf - in/d1/foo in/d1/bar | %s -xf - -s /foo/bar/ -s }bar}foo} -C test5",
+	systemf("%s -cf test5.tar in/d1/foo in/d1/bar",
+	    testprog, testprog);
+	systemf("%s -xf test5.tar -s /foo/bar/ -s }bar}foo} -C test5",
 	    testprog, testprog);
 	assertFileContents("foo", 3, "test5/in/d1/bar");
 	assertFileContents("bar", 3, "test5/in/d1/foo");
+
+	/*
+	 * Test 6: symlinks get renamed by default
+	 */
+	if (canSymlink()) {
+		/* At extraction time. */
+		assertMakeDir("test6a", 0755);
+		systemf("%s -cf - in/d1 | %s -xf - -s /d1/d2/ -C test6a",
+		    testprog, testprog);
+		assertFileContents("realfile", 8, "test6a/in/d2/realfile");
+		assertFileContents("realfile", 8, "test6a/in/d2/symlink");
+		assertIsSymlink("test6a/in/d2/symlink", "realfile");
+		/* At creation time. */
+		assertMakeDir("test6b", 0755);
+		systemf("%s -cf - -s /d1/d2/ in/d1 | %s -xf - -C test6b",
+		    testprog, testprog);
+		assertFileContents("realfile", 8, "test6b/in/d2/realfile");
+		assertFileContents("realfile", 8, "test6b/in/d2/symlink");
+		assertIsSymlink("test6b/in/d2/symlink", "realfile");
+	}
+
+	/*
+	 * Test 7: selective renaming of symlink target
+	 */
+	if (canSymlink()) {
+		/* At extraction. */
+		assertMakeDir("test7a", 0755);
+		systemf("%s -cf - in/d1 | %s -xf - -s /realfile/realfile-renamed/ -C test7a",
+		    testprog, testprog);
+		assertFileContents("realfile", 8, "test7a/in/d1/realfile-renamed");
+		assertFileContents("realfile", 8, "test7a/in/d1/symlink");
+		assertIsSymlink("test7a/in/d1/symlink", "realfile-renamed");
+		/* At creation. */
+		assertMakeDir("test7b", 0755);
+		systemf("%s -cf - -s /realfile/realfile-renamed/ in/d1 | %s -xf - -C test7b",
+		    testprog, testprog);
+		assertFileContents("realfile", 8, "test7b/in/d1/realfile-renamed");
+		assertFileContents("realfile", 8, "test7b/in/d1/symlink");
+		assertIsSymlink("test7b/in/d1/symlink", "realfile-renamed");
+	}
+
+	/*
+	 * Test 8: hardlinks get renamed by default
+	 */
+	/* At extraction time. */
+	assertMakeDir("test8a", 0755);
+	systemf("%s -cf test8a.tar in/d1", testprog);
+	systemf("%s -xf test8a.tar -s /d1/d2/ -C test8a", testprog);
+	assertIsHardlink("test8a/in/d2/hardlink1", "test8a/in/d2/hardlink2");
+	/* At creation time. */
+	assertMakeDir("test8b", 0755);
+	systemf("%s -cf test8b.tar -s /d1/d2/ in/d1", testprog);
+	systemf("%s -xf test8b.tar -C test8b", testprog);
+	assertIsHardlink("test8b/in/d2/hardlink1", "test8b/in/d2/hardlink2");
+
+	/*
+	 * Test 9: selective renaming of hardlink target
+	 */
+	/* At extraction. (assuming hardlink2 is the hardlink entry) */
+	assertMakeDir("test9a", 0755);
+	systemf("%s -cf test9a.tar in/d1", testprog);
+	systemf("%s -xf test9a.tar -s /hardlink1/hardlink1-renamed/ -C test9a",
+	    testprog);
+	assertIsHardlink("test9a/in/d1/hardlink1-renamed", "test9a/in/d1/hardlink2");
+	/* At extraction. (assuming hardlink1 is the hardlink entry) */
+	assertMakeDir("test9b", 0755);
+	systemf("%s -cf test9b.tar in/d1", testprog);
+	systemf("%s -xf test9b.tar -s /hardlink2/hardlink2-renamed/ -C test9b",
+	    testprog);
+	assertIsHardlink("test9b/in/d1/hardlink1", "test9b/in/d1/hardlink2-renamed");
+	/* At creation. (assuming hardlink2 is the hardlink entry) */
+	assertMakeDir("test9c", 0755);
+	systemf("%s -cf test9c.tar -s /hardlink1/hardlink1-renamed/ in/d1",
+	    testprog);
+	systemf("%s -xf test9c.tar -C test9c", testprog);
+	assertIsHardlink("test9c/in/d1/hardlink1-renamed", "test9c/in/d1/hardlink2");
+	/* At creation. (assuming hardlink1 is the hardlink entry) */
+	assertMakeDir("test9d", 0755);
+	systemf("%s -cf test9d.tar -s /hardlink2/hardlink2-renamed/ in/d1",
+	    testprog);
+	systemf("%s -xf test9d.tar -C test9d", testprog);
+	assertIsHardlink("test9d/in/d1/hardlink1", "test9d/in/d1/hardlink2-renamed");
+
+	/*
+	 * Test 10: renaming symlink target without repointing symlink
+	 */
+	if (canSymlink()) {
+		/* At extraction. */
+		assertMakeDir("test10a", 0755);
+		systemf("%s -cf - in/d1 | %s -xf - -s /realfile/foo/S -s /foo/realfile/ -C test10a",
+		    testprog, testprog);
+		assertFileContents("realfile", 8, "test10a/in/d1/foo");
+		assertFileContents("foo", 3, "test10a/in/d1/realfile");
+		assertFileContents("foo", 3, "test10a/in/d1/symlink");
+		assertIsSymlink("test10a/in/d1/symlink", "realfile");
+		/* At creation. */
+		assertMakeDir("test10b", 0755);
+		systemf("%s -cf - -s /realfile/foo/S -s /foo/realfile/ in/d1 | %s -xf - -C test10b",
+		    testprog, testprog);
+		assertFileContents("realfile", 8, "test10b/in/d1/foo");
+		assertFileContents("foo", 3, "test10b/in/d1/realfile");
+		assertFileContents("foo", 3, "test10b/in/d1/symlink");
+		assertIsSymlink("test10b/in/d1/symlink", "realfile");
+	}
+
+	/*
+	 * Test 11: repointing symlink without renaming file
+	 */
+	if (canSymlink()) {
+		/* At extraction. */
+		assertMakeDir("test11a", 0755);
+		systemf("%s -cf - in/d1 | %s -xf - -s /realfile/foo/sR -C test11a",
+		    testprog, testprog);
+		assertFileContents("foo", 3, "test11a/in/d1/foo");
+		assertFileContents("realfile", 8, "test11a/in/d1/realfile");
+		assertFileContents("foo", 3, "test11a/in/d1/symlink");
+		assertIsSymlink("test11a/in/d1/symlink", "foo");
+		/* At creation. */
+		assertMakeDir("test11b", 0755);
+		systemf("%s -cf - -s /realfile/foo/R in/d1 | %s -xf - -C test11b",
+		    testprog, testprog);
+		assertFileContents("foo", 3, "test11b/in/d1/foo");
+		assertFileContents("realfile", 8, "test11b/in/d1/realfile");
+		assertFileContents("foo", 3, "test11b/in/d1/symlink");
+		assertIsSymlink("test11b/in/d1/symlink", "foo");
+	}
+
+	/*
+	 * Test 12: renaming hardlink target without changing hardlink.
+	 * (Requires a pre-built archive, since we otherwise can't know
+	 * which element will be stored as the hardlink.)
+	 */
+	extract_reference_file("test_option_s.tar.Z");
+	assertMakeDir("test12a", 0755);
+	systemf("%s -xf test_option_s.tar.Z -s /hardlink1/foo/H -s /foo/hardlink1/ %s -C test12a",
+	    testprog, canSymlink()?"":"--exclude in/d1/symlink");
+	assertFileContents("foo", 3, "test12a/in/d1/hardlink1");
+	assertFileContents("hardlinkedfile", 14, "test12a/in/d1/foo");
+	assertFileContents("foo", 3, "test12a/in/d1/hardlink2");
+	assertIsHardlink("test12a/in/d1/hardlink1", "test12a/in/d1/hardlink2");
+	/* TODO: Expand this test to verify creation as well.
+	 * Since either hardlink1 or hardlink2 might get stored as a hardlink,
+	 * this will either requiring testing both cases and accepting either
+	 * pass, or some very creative renames that can be tested regardless.
+	 */
+
+	/*
+	 * Test 13: repoint hardlink without changing files
+	 * (Requires a pre-built archive, since we otherwise can't know
+	 * which element will be stored as the hardlink.)
+	 */
+	extract_reference_file("test_option_s.tar.Z");
+	assertMakeDir("test13a", 0755);
+	systemf("%s -xf test_option_s.tar.Z -s /hardlink1/foo/Rh -s /foo/hardlink1/Rh %s -C test13a",
+	    testprog, canSymlink()?"":"--exclude in/d1/symlink");
+	assertFileContents("foo", 3, "test13a/in/d1/foo");
+	assertFileContents("hardlinkedfile", 14, "test13a/in/d1/hardlink1");
+	assertFileContents("foo", 3, "test13a/in/d1/hardlink2");
+	assertIsHardlink("test13a/in/d1/foo", "test13a/in/d1/hardlink2");
+	/* TODO: See above; expand this test to verify renames at creation. */
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/tar/test/test_patterns.c
--- a/head/contrib/libarchive/tar/test/test_patterns.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/tar/test/test_patterns.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/tar/test/test_patterns.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/tar/test/test_patterns.c 232153 2012-02-25 10:58:02Z mm $");
 
 DEFINE_TEST(test_patterns)
 {
@@ -122,6 +122,7 @@
 		char file_b1[] = "tmp/server/share/fileXX";
 		char file_b2[] = "tmp/server\\share\\fileXX";
 		char file_c[] = "tmp/../fileXX";
+		char file_d[] = "tmp/../../fileXX";
 		char *filex;
 		int xsize;
 
@@ -169,8 +170,13 @@
 			 * \/?\UnC\../file54
 			 */
 			assertFileNotExists(filex);
-			filex = file_c;
-			xsize = sizeof(file_c);
+			if (r == 6 || r == 26 || r == 43) {
+				filex = file_d;
+				xsize = sizeof(file_d);
+			} else {
+				filex = file_c;
+				xsize = sizeof(file_c);
+			}
 			filex[xsize-3] = '0' + r / 10;
 			filex[xsize-2] = '0' + r % 10;
 			assertFileNotExists(filex);
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/tar/test/test_strip_components.c
--- a/head/contrib/libarchive/tar/test/test_strip_components.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/tar/test/test_strip_components.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,19 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/tar/test/test_strip_components.c 228763 2011-12-21 11:13:29Z mm $");
-
-static int
-touch(const char *fn)
-{
-	FILE *f = fopen(fn, "w");
-	failure("Couldn't create file '%s', errno=%d (%s)\n",
-	    fn, errno, strerror(errno));
-	if (!assert(f != NULL))
-		return (0); /* Failure. */
-	fclose(f);
-	return (1); /* Success */
-}
+__FBSDID("$FreeBSD: head/contrib/libarchive/tar/test/test_strip_components.c 232153 2012-02-25 10:58:02Z mm $");
 
 DEFINE_TEST(test_strip_components)
 {
@@ -44,7 +32,7 @@
 	assertMakeDir("d1", 0755);
 	assertMakeDir("d1/d2", 0755);
 	assertMakeDir("d1/d2/d3", 0755);
-	assertEqualInt(1, touch("d1/d2/f1"));
+	assertMakeFile("d1/d2/f1", 0644, "");
 	assertMakeHardlink("l1", "d1/d2/f1");
 	assertMakeHardlink("d1/l2", "d1/d2/f1");
 	if (canSymlink()) {
@@ -53,7 +41,15 @@
 	}
 	assertChdir("..");
 
-	assertEqualInt(0, systemf("%s -cf test.tar d0", testprog));
+	/*
+	 * Test 1: Strip components when extracting archives.
+	 */
+	if (canSymlink())
+		assertEqualInt(0, systemf("%s -cf test.tar d0/l1 d0/s1 d0/d1",
+		    testprog));
+	else
+		assertEqualInt(0, systemf("%s -cf test.tar d0/l1 d0/d1",
+		    testprog));
 
 	assertMakeDir("target", 0755);
 	assertEqualInt(0, systemf("%s -x -C target --strip-components 2 "
@@ -63,6 +59,8 @@
 	assertFileNotExists("target/d0");
 	failure("d0/d1/ is too short and should not get restored");
 	assertFileNotExists("target/d1");
+	failure("d0/s1 is too short and should not get restored");
+	assertFileNotExists("target/s1");
 	failure("d0/d1/s2 is a symlink to something that won't be extracted");
 	/* If platform supports symlinks, target/s2 is a broken symlink. */
 	/* If platform does not support symlink, target/s2 doesn't exist. */
@@ -73,6 +71,8 @@
 	assertIsDir("target/d2", -1);
 
 	/*
+	 * Test 1b: Strip components extracting archives involving hardlinks.
+	 *
 	 * This next is a complicated case.  d0/l1, d0/d1/l2, and
 	 * d0/d1/d2/f1 are all hardlinks to the same file; d0/l1 can't
 	 * be extracted with --strip-components=2 and the other two
@@ -82,18 +82,11 @@
 	 * which these three names get archived.  If d0/l1 is first,
 	 * none of the three can be restored.  If either of the longer
 	 * names are first, then the two longer ones can both be
-	 * restored.
+	 * restored.  Note that the "tar -cf" command above explicitly
+	 * lists d0/l1 before d0/d1.
 	 *
-	 * The tree-walking code used by bsdtar always visits files
-	 * before subdirectories, so bsdtar's behavior is fortunately
-	 * deterministic:  d0/l1 will always get stored first and the
-	 * other two will be stored as hardlinks to d0/l1.  Since
-	 * d0/l1 can't be extracted, none of these three will be
-	 * extracted.
-	 *
-	 * It may be worth extending this test to force a particular
-	 * archiving order so as to exercise both of the cases described
-	 * above.
+	 * It may be worth extending this test to exercise other
+	 * archiving orders.
 	 *
 	 * Of course, this is all totally different for cpio and newc
 	 * formats because the hardlink management is different.
@@ -106,4 +99,41 @@
 	assertFileNotExists("target/l2");
 	failure("d0/d1/d2/f1 is a hardlink to file whose name was too short");
 	assertFileNotExists("target/d2/f1");
+
+	/*
+	 * Test 2: Strip components when creating archives.
+	 */
+	if (canSymlink())
+		assertEqualInt(0, systemf("%s --strip-components 2 -cf test2.tar "
+					"d0/l1 d0/s1 d0/d1", testprog));
+	else
+		assertEqualInt(0, systemf("%s --strip-components 2 -cf test2.tar "
+					"d0/l1 d0/d1", testprog));
+
+	assertMakeDir("target2", 0755);
+	assertEqualInt(0, systemf("%s -x -C target2 -f test2.tar", testprog));
+
+	failure("d0/ is too short and should not have been archived");
+	assertFileNotExists("target2/d0");
+	failure("d0/d1/ is too short and should not have been archived");
+	assertFileNotExists("target2/d1");
+	failure("d0/s1 is too short and should not get restored");
+	assertFileNotExists("target/s1");
+	/* If platform supports symlinks, target/s2 is included. */
+	if (canSymlink()) {
+		failure("d0/d1/s2 is a symlink to something included in archive");
+		assertIsSymlink("target2/s2", "d2/f1");
+	}
+	failure("d0/d1/d2 should be archived");
+	assertIsDir("target2/d2", -1);
+
+	/*
+	 * Test 2b: Strip components creating archives involving hardlinks.
+	 */
+	failure("d0/l1 is too short and should not have been archived");
+	assertFileNotExists("target/l1");
+	failure("d0/d1/l2 is a hardlink to file whose name was too short");
+	assertFileNotExists("target/l2");
+	failure("d0/d1/d2/f1 is a hardlink to file whose name was too short");
+	assertFileNotExists("target/d2/f1");
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/tar/test/test_symlink_dir.c
--- a/head/contrib/libarchive/tar/test/test_symlink_dir.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/tar/test/test_symlink_dir.c	Fri Mar 02 16:54:40 2012 +0200
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/tar/test/test_symlink_dir.c 228763 2011-12-21 11:13:29Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/tar/test/test_symlink_dir.c 232153 2012-02-25 10:58:02Z mm $");
 
 /*
  * tar -x -P should follow existing symlinks for dirs, but not other
@@ -31,38 +31,22 @@
  * way of a dir extraction.
  */
 
-static int
-mkfile(const char *name, int mode, const char *contents, size_t size)
-{
-	FILE *f = fopen(name, "wb");
-	size_t written;
-
-	(void)mode; /* UNUSED */
-	if (f == NULL)
-		return (-1);
-	written = fwrite(contents, 1, size, f);
-	fclose(f);
-	if (size != written)
-		return (-1);
-	return (0);
-}
-
 DEFINE_TEST(test_symlink_dir)
 {
 	assertUmask(0);
 
 	assertMakeDir("source", 0755);
-	assertEqualInt(0, mkfile("source/file", 0755, "a", 1));
-	assertEqualInt(0, mkfile("source/file2", 0755, "ab", 2));
+	assertMakeFile("source/file", 0755, "a");
+	assertMakeFile("source/file2", 0755, "ab");
 	assertMakeDir("source/dir", 0755);
 	assertMakeDir("source/dir/d", 0755);
-	assertEqualInt(0, mkfile("source/dir/f", 0755, "abc", 3));
+	assertMakeFile("source/dir/f", 0755, "abc");
 	assertMakeDir("source/dir2", 0755);
 	assertMakeDir("source/dir2/d2", 0755);
-	assertEqualInt(0, mkfile("source/dir2/f2", 0755, "abcd", 4));
+	assertMakeFile("source/dir2/f2", 0755, "abcd");
 	assertMakeDir("source/dir3", 0755);
 	assertMakeDir("source/dir3/d3", 0755);
-	assertEqualInt(0, mkfile("source/dir3/f3", 0755, "abcde", 5));
+	assertMakeFile("source/dir3/f3", 0755, "abcde");
 
 	assertEqualInt(0,
 	    systemf("%s -cf test.tar -C source dir dir2 dir3 file file2",
@@ -82,11 +66,11 @@
 		skipping("some symlink checks");
 	}
 	/* "dir3" is a symlink to an existing "non_dir3" */
-	assertEqualInt(0, mkfile("dest1/non_dir3", 0755, "abcdef", 6));
+	assertMakeFile("dest1/non_dir3", 0755, "abcdef");
 	if (canSymlink())
 		assertMakeSymlink("dest1/dir3", "non_dir3");
 	/* "file" is a symlink to existing "real_file" */
-	assertEqualInt(0, mkfile("dest1/real_file", 0755, "abcdefg", 7));
+	assertMakeFile("dest1/real_file", 0755, "abcdefg");
 	if (canSymlink()) {
 		assertMakeSymlink("dest1/file", "real_file");
 		/* "file2" is a symlink to non-existing "real_file2" */
@@ -122,11 +106,11 @@
 	if (canSymlink())
 		assertMakeSymlink("dest2/dir2", "real_dir2");
 	/* "dir3" is a symlink to an existing "non_dir3" */
-	assertEqualInt(0, mkfile("dest2/non_dir3", 0755, "abcdefgh", 8));
+	assertMakeFile("dest2/non_dir3", 0755, "abcdefgh");
 	if (canSymlink())
 		assertMakeSymlink("dest2/dir3", "non_dir3");
 	/* "file" is a symlink to existing "real_file" */
-	assertEqualInt(0, mkfile("dest2/real_file", 0755, "abcdefghi", 9));
+	assertMakeFile("dest2/real_file", 0755, "abcdefghi");
 	if (canSymlink())
 		assertMakeSymlink("dest2/file", "real_file");
 	/* "file2" is a symlink to non-existing "real_file2" */
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/tar/tree.c
--- a/head/contrib/libarchive/tar/tree.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/tar/tree.c	Fri Mar 02 16:54:40 2012 +0200
@@ -44,7 +44,7 @@
  * regular dir or via fchdir(2) for a symlink).
  */
 #include "bsdtar_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/tar/tree.c 228776 2011-12-21 15:30:49Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/tar/tree.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
@@ -104,9 +104,9 @@
 /* Definitions for tree_entry.flags bitmap. */
 #define	isDir 1 /* This entry is a regular directory. */
 #define	isDirLink 2 /* This entry is a symbolic link to a directory. */
-#define needsFirstVisit 4 /* This is an initial entry. */
+#define	needsFirstVisit 4 /* This is an initial entry. */
 #define	needsDescent 8 /* This entry needs to be previsited. */
-#define needsOpen 16 /* This is a directory that needs to be opened. */
+#define	needsOpen 16 /* This is a directory that needs to be opened. */
 #define	needsAscent 32 /* This entry needs to be postvisited. */
 
 /*
@@ -122,15 +122,15 @@
 struct tree {
 	struct tree_entry	*stack;
 	struct tree_entry	*current;
-#if defined(HAVE_WINDOWS_H) && !defined(__CYGWIN__)
+#if defined(_WIN32) && !defined(__CYGWIN__)
 	HANDLE d;
 	BY_HANDLE_FILE_INFORMATION fileInfo;
-#define INVALID_DIR_HANDLE INVALID_HANDLE_VALUE
+#define	INVALID_DIR_HANDLE INVALID_HANDLE_VALUE
 	WIN32_FIND_DATA _findData;
 	WIN32_FIND_DATA *findData;
 #else
 	DIR	*d;
-#define INVALID_DIR_HANDLE NULL
+#define	INVALID_DIR_HANDLE NULL
 	struct dirent *de;
 #endif
 	int	 flags;
@@ -154,8 +154,8 @@
 };
 
 /* Definitions for tree.flags bitmap. */
-#define hasStat 16  /* The st entry is valid. */
-#define hasLstat 32 /* The lst entry is valid. */
+#define	hasStat 16  /* The st entry is valid. */
+#define	hasLstat 32 /* The lst entry is valid. */
 #define	hasFileInfo 64 /* The Windows fileInfo entry is valid. */
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
@@ -168,9 +168,9 @@
 
 #ifdef HAVE_DIRENT_D_NAMLEN
 /* BSD extension; avoids need for a strlen() call. */
-#define D_NAMELEN(dp)	(dp)->d_namlen
+#define	D_NAMELEN(dp)	(dp)->d_namlen
 #else
-#define D_NAMELEN(dp)	(strlen((dp)->d_name))
+#define	D_NAMELEN(dp)	(strlen((dp)->d_name))
 #endif
 
 #include <stdio.h>
@@ -289,15 +289,42 @@
 #elif defined(_WIN32) && !defined(__CYGWIN__)
 	struct tree *t;
 	char *cwd = _getcwd(NULL, 0);
-	char *pathname = strdup(path), *p, *base;
+	char *pathname, *p, *base;
+	wchar_t *wcs, *wp;
+	size_t l, wlen;
 
+	/* Take care of '\' character in multi-byte character-set.
+	 * Some multi-byte character-set have been using '\' character
+	 * for a part of its character code. */
+	l = MultiByteToWideChar(CP_OEMCP, 0, path, strlen(path), NULL, 0);
+	if (l == 0)
+		abort();
+	wcs = malloc(sizeof(*wcs) * (l+1));
+	if (wcs == NULL)
+		abort();
+	l = MultiByteToWideChar(CP_OEMCP, 0, path, strlen(path), wcs, l);
+	wcs[l] = L'\0';
+	wlen = l;
+	for (wp = wcs; *wp != L'\0'; ++wp) {
+		if (*wp == L'\\')
+			*wp = L'/';
+	}
+	l = WideCharToMultiByte(CP_OEMCP, 0, wcs, wlen, NULL, 0, NULL, NULL);
+	if (l == 0)
+		abort();
+	pathname = malloc(l+1);
 	if (pathname == NULL)
 		abort();
-	for (p = pathname; *p != '\0'; ++p) {
-		if (*p == '\\')
-			*p = '/';
-	}
+	l = WideCharToMultiByte(CP_OEMCP, 0, wcs, wlen, pathname, l, NULL, NULL);
+	pathname[l] = '\0';
+	free(wcs);
 	base = pathname;
+#if defined(_WIN32) && !defined(__CYGWIN__)
+	/* ASCII version APIs do not accept the path which begin with
+	 * "//?/" prefix. */
+	if (strncmp(base, "//?/", 4) == 0)
+		base += 4;
+#endif
 
 	t = malloc(sizeof(*t));
 	memset(t, 0, sizeof(*t));
@@ -305,8 +332,8 @@
 	/* printf("Looking for wildcard in %s\n", path); */
 	/* TODO: wildcard detection here screws up on \\?\c:\ UNC names */
 	if (strchr(base, '*') || strchr(base, '?')) {
-		// It has a wildcard in it...
-		// Separate the last element.
+		/* It has a wildcard in it... */
+		/* Separate the last element. */
 		p = strrchr(base, '/');
 		if (p != NULL) {
 			*p = '\0';
@@ -428,13 +455,13 @@
 					continue;
 				return (r);
 			}
-			// Not a pattern, handle it as-is...
+			/* Not a pattern, handle it as-is... */
 #endif
 			/* Top stack item needs a regular visit. */
 			t->current = t->stack;
 			tree_append(t, t->stack->name, strlen(t->stack->name));
-			//t->dirname_length = t->path_length;
-			//tree_pop(t);
+			/* t->dirname_length = t->path_length; */
+			/* tree_pop(t); */
 			t->stack->flags &= ~needsFirstVisit;
 			return (t->visit_type = TREE_REGULAR);
 		} else if (t->stack->flags & needsDescent) {
@@ -611,7 +638,7 @@
 	return (&t->st);
 }
 
-#if defined(HAVE_WINDOWS_H) && !defined(__CYGWIN__)
+#if defined(_WIN32) && !defined(__CYGWIN__)
 const BY_HANDLE_FILE_INFORMATION *
 tree_current_file_information(struct tree *t)
 {
@@ -740,7 +767,7 @@
 #if defined(_WIN32) && !defined(__CYGWIN__)
 #ifndef IO_REPARSE_TAG_SYMLINK
 /* Old SDKs do not provide IO_REPARSE_TAG_SYMLINK */
-#define IO_REPARSE_TAG_SYMLINK 0xA000000CL
+#define	IO_REPARSE_TAG_SYMLINK 0xA000000CL
 #endif
 	if (t->findData)
 		return ((t->findData->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/tar/util.c
--- a/head/contrib/libarchive/tar/util.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/tar/util.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  */
 
 #include "bsdtar_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/tar/util.c 228776 2011-12-21 15:30:49Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/tar/util.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
@@ -56,7 +56,7 @@
 #include <wctype.h>
 #else
 /* If we don't have wctype, we need to hack up some version of iswprint(). */
-#define iswprint isprint
+#define	iswprint isprint
 #endif
 
 #include "bsdtar.h"
@@ -66,14 +66,14 @@
 static const char *strip_components(const char *path, int elements);
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
-#define read _read
+#define	read _read
 #endif
 
 /* TODO:  Hack up a version of mbtowc for platforms with no wide
  * character support at all.  I think the following might suffice,
  * but it needs careful testing.
  * #if !HAVE_MBTOWC
- * #define mbtowc(wcp, p, n) ((*wcp = *p), 1)
+ * #define	mbtowc(wcp, p, n) ((*wcp = *p), 1)
  * #endif
  */
 
@@ -115,8 +115,21 @@
 	va_end(ap);
 
 	/* If the result was too large, allocate a buffer on the heap. */
-	if (length >= fmtbuff_length) {
-		fmtbuff_length = length+1;
+	while (length < 0 || length >= fmtbuff_length) {
+		if (length >= fmtbuff_length)
+			fmtbuff_length = length+1;
+		else if (fmtbuff_length < 8192)
+			fmtbuff_length *= 2;
+		else {
+			int old_length = fmtbuff_length;
+			fmtbuff_length += fmtbuff_length / 4;
+			if (old_length > fmtbuff_length) {
+				length = old_length;
+				fmtbuff_heap[length-1] = '\0';
+				break;
+			}
+		}
+		free(fmtbuff_heap);
 		fmtbuff_heap = malloc(fmtbuff_length);
 
 		/* Reformat the result into the heap buffer if we can. */
@@ -129,6 +142,7 @@
 			/* Leave fmtbuff pointing to the truncated
 			 * string in fmtbuff_stack. */
 			length = sizeof(fmtbuff_stack) - 1;
+			break;
 		}
 	}
 
@@ -267,12 +281,19 @@
  * about -C with non-existent directories; such requests will only
  * fail if the directory must be accessed.
  *
- * TODO: Make this handle Windows paths correctly.
  */
 void
 set_chdir(struct bsdtar *bsdtar, const char *newdir)
 {
+#if defined(_WIN32) && !defined(__CYGWIN__)
+	if (newdir[0] == '/' || newdir[0] == '\\' ||
+	    /* Detect this type, for example, "C:\" or "C:/" */
+	    (((newdir[0] >= 'a' && newdir[0] <= 'z') ||
+	      (newdir[0] >= 'A' && newdir[0] <= 'Z')) &&
+	    newdir[1] == ':' && (newdir[2] == '/' || newdir[2] == '\\'))) {
+#else
 	if (newdir[0] == '/') {
+#endif
 		/* The -C /foo -C /bar case; dump first one. */
 		free(bsdtar->pending_chdir);
 		bsdtar->pending_chdir = NULL;
@@ -362,10 +383,8 @@
 #if HAVE_REGEX_H
 	char *subst_name;
 	int r;
-#endif
 
-#if HAVE_REGEX_H
-	r = apply_substitution(bsdtar, name, &subst_name, 0);
+	r = apply_substitution(bsdtar, name, &subst_name, 0, 0);
 	if (r == -1) {
 		lafe_warnc(0, "Invalid substitution, skipping entry");
 		return 1;
@@ -381,7 +400,7 @@
 	}
 
 	if (archive_entry_hardlink(entry)) {
-		r = apply_substitution(bsdtar, archive_entry_hardlink(entry), &subst_name, 1);
+		r = apply_substitution(bsdtar, archive_entry_hardlink(entry), &subst_name, 0, 1);
 		if (r == -1) {
 			lafe_warnc(0, "Invalid substitution, skipping entry");
 			return 1;
@@ -392,7 +411,7 @@
 		}
 	}
 	if (archive_entry_symlink(entry) != NULL) {
-		r = apply_substitution(bsdtar, archive_entry_symlink(entry), &subst_name, 1);
+		r = apply_substitution(bsdtar, archive_entry_symlink(entry), &subst_name, 1, 0);
 		if (r == -1) {
 			lafe_warnc(0, "Invalid substitution, skipping entry");
 			return 1;
@@ -507,14 +526,13 @@
 tar_i64toa(int64_t n0)
 {
 	static char buff[24];
-	int64_t n = n0 < 0 ? -n0 : n0;
+	uint64_t n = n0 < 0 ? -n0 : n0;
 	char *p = buff + sizeof(buff);
 
 	*--p = '\0';
 	do {
 		*--p = '0' + (int)(n % 10);
-		n /= 10;
-	} while (n > 0);
+	} while (n /= 10);
 	if (n0 < 0)
 		*--p = '-';
 	return p;
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/libarchive/tar/write.c
--- a/head/contrib/libarchive/tar/write.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/libarchive/tar/write.c	Fri Mar 02 16:54:40 2012 +0200
@@ -24,7 +24,7 @@
  */
 
 #include "bsdtar_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/tar/write.c 228776 2011-12-21 15:30:49Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/tar/write.c 232153 2012-02-25 10:58:02Z mm $");
 
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
@@ -50,6 +50,9 @@
 #ifdef HAVE_IO_H
 #include <io.h>
 #endif
+#ifdef HAVE_LIBGEN_H
+#include <libgen.h>
+#endif
 #ifdef HAVE_LIMITS_H
 #include <limits.h>
 #endif
@@ -67,6 +70,9 @@
 /* This header exists but is broken on Cygwin. */
 #include <ext2fs/ext2_fs.h>
 #endif
+#ifdef HAVE_PATHS_H
+#include <paths.h>
+#endif
 #ifdef HAVE_PWD_H
 #include <pwd.h>
 #endif
@@ -89,18 +95,10 @@
 #include "line_reader.h"
 #include "tree.h"
 
-/* Size of buffer for holding file data prior to writing. */
-#define FILEDATABUFLEN	65536
-
-/* Fixed size of uname/gname caches. */
-#define	name_cache_size 101
-
 #ifndef O_BINARY
-#define O_BINARY 0
+#define	O_BINARY 0
 #endif
 
-static const char * const NO_NAME = "(noname)";
-
 struct archive_dir_entry {
 	struct archive_dir_entry	*next;
 	time_t			 mtime_sec;
@@ -112,16 +110,6 @@
 	struct archive_dir_entry *head, *tail;
 };
 
-struct name_cache {
-	int	probes;
-	int	hits;
-	size_t	size;
-	struct {
-		id_t id;
-		const char *name;
-	} cache[name_cache_size];
-};
-
 static void		 add_dir_list(struct bsdtar *bsdtar, const char *path,
 			     time_t mtime_sec, int mtime_nsec);
 static int		 append_archive(struct bsdtar *, struct archive *,
@@ -138,10 +126,12 @@
 			     struct archive_entry *, int64_t progress);
 static void		 test_for_append(struct bsdtar *);
 static void		 write_archive(struct archive *, struct bsdtar *);
-static void		 write_entry_backend(struct bsdtar *, struct archive *,
+static void		 write_entry(struct bsdtar *, struct archive *,
+			     struct archive_entry *);
+static void		 write_file(struct bsdtar *, struct archive *,
 			     struct archive_entry *);
 static int		 write_file_data(struct bsdtar *, struct archive *,
-			     struct archive_entry *, int fd);
+			     struct archive_entry *, int fd, size_t align);
 static void		 write_hierarchy(struct bsdtar *, struct archive *,
 			     const char *);
 
@@ -156,10 +146,10 @@
 	return (SetFilePointerEx((HANDLE)_get_osfhandle(fd),
 		distance, NULL, FILE_BEGIN) ? 1 : -1);
 }
-#define open _open
-#define close _close
-#define read _read
-#define lseek seek_file
+#define	open _open
+#define	close _close
+#define	read _read
+#define	lseek seek_file
 #endif
 
 void
@@ -187,25 +177,15 @@
 		usage();
 	}
 
-	/*
-	 * If user explicitly set the block size, then assume they
-	 * want the last block padded as well.  Otherwise, use the
-	 * default block size and accept archive_write_open_file()'s
-	 * default padding decisions.
-	 */
-	if (bsdtar->bytes_per_block != 0) {
-		archive_write_set_bytes_per_block(a, bsdtar->bytes_per_block);
-		archive_write_set_bytes_in_last_block(a,
-		    bsdtar->bytes_per_block);
-	} else
-		archive_write_set_bytes_per_block(a, DEFAULT_BYTES_PER_BLOCK);
+	archive_write_set_bytes_per_block(a, bsdtar->bytes_per_block);
+	archive_write_set_bytes_in_last_block(a, bsdtar->bytes_in_last_block);
 
 	if (bsdtar->compress_program) {
 		archive_write_set_compression_program(a, bsdtar->compress_program);
 	} else {
 		switch (bsdtar->create_compression) {
 		case 0:
-			r = archive_write_set_compression_none(a);
+			r = ARCHIVE_OK;
 			break;
 		case 'j': case 'y':
 			r = archive_write_set_compression_bzip2(a);
@@ -213,6 +193,9 @@
 		case 'J':
 			r = archive_write_set_compression_xz(a);
 			break;
+		case OPTION_LZIP:
+			r = archive_write_set_compression_lzip(a);
+			break;
 		case OPTION_LZMA:
 			r = archive_write_set_compression_lzma(a);
 			break;
@@ -269,7 +252,7 @@
 		    "Cannot open %s", bsdtar->filename);
 
 	a = archive_read_new();
-	archive_read_support_compression_all(a);
+	archive_read_support_filter_all(a);
 	archive_read_support_format_tar(a);
 	archive_read_support_format_gnutar(a);
 	r = archive_read_open_fd(a, bsdtar->fd, 10240);
@@ -279,7 +262,7 @@
 		    archive_error_string(a));
 	while (0 == archive_read_next_header(a, &entry)) {
 		if (archive_compression(a) != ARCHIVE_COMPRESSION_NONE) {
-			archive_read_finish(a);
+			archive_read_free(a);
 			close(bsdtar->fd);
 			lafe_errc(1, 0,
 			    "Cannot append to compressed archive.");
@@ -289,11 +272,10 @@
 	}
 
 	end_offset = archive_read_header_position(a);
-	archive_read_finish(a);
+	archive_read_free(a);
 
 	/* Re-open archive for writing */
 	a = archive_write_new();
-	archive_write_set_compression_none(a);
 	/*
 	 * Set the format to be used for writing.  To allow people to
 	 * extend empty files, we need to allow them to specify the format,
@@ -319,9 +301,6 @@
 		 * Just preserve the current format, with a little care
 		 * for formats that libarchive can't write.
 		 */
-		if (format == ARCHIVE_FORMAT_TAR_GNUTAR)
-			/* TODO: When gtar supports pax, use pax restricted. */
-			format = ARCHIVE_FORMAT_TAR_USTAR;
 		if (format == ARCHIVE_FORMAT_EMPTY)
 			format = ARCHIVE_FORMAT_TAR_PAX_RESTRICTED;
 		archive_write_set_format(a, format);
@@ -363,12 +342,11 @@
 		    "Cannot open %s", bsdtar->filename);
 
 	a = archive_read_new();
-	archive_read_support_compression_all(a);
+	archive_read_support_filter_all(a);
 	archive_read_support_format_tar(a);
 	archive_read_support_format_gnutar(a);
-	if (archive_read_open_fd(a, bsdtar->fd,
-	    bsdtar->bytes_per_block != 0 ? bsdtar->bytes_per_block :
-		DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK) {
+	if (archive_read_open_fd(a, bsdtar->fd, bsdtar->bytes_per_block)
+	    != ARCHIVE_OK) {
 		lafe_errc(1, 0,
 		    "Can't open %s: %s", bsdtar->filename,
 		    archive_error_string(a));
@@ -377,7 +355,7 @@
 	/* Build a list of all entries and their recorded mod times. */
 	while (0 == archive_read_next_header(a, &entry)) {
 		if (archive_compression(a) != ARCHIVE_COMPRESSION_NONE) {
-			archive_read_finish(a);
+			archive_read_free(a);
 			close(bsdtar->fd);
 			lafe_errc(1, 0,
 			    "Cannot append to compressed archive.");
@@ -391,24 +369,17 @@
 	}
 
 	end_offset = archive_read_header_position(a);
-	archive_read_finish(a);
+	archive_read_free(a);
 
 	/* Re-open archive for writing. */
 	a = archive_write_new();
-	archive_write_set_compression_none(a);
 	/*
-	 * Set format to same one auto-detected above, except that
-	 * we don't write GNU tar format, so use ustar instead.
+	 * Set format to same one auto-detected above.
 	 */
-	if (format == ARCHIVE_FORMAT_TAR_GNUTAR)
-		format = ARCHIVE_FORMAT_TAR_USTAR;
 	archive_write_set_format(a, format);
-	if (bsdtar->bytes_per_block != 0) {
-		archive_write_set_bytes_per_block(a, bsdtar->bytes_per_block);
-		archive_write_set_bytes_in_last_block(a,
-		    bsdtar->bytes_per_block);
-	} else
-		archive_write_set_bytes_per_block(a, DEFAULT_BYTES_PER_BLOCK);
+	archive_write_set_bytes_per_block(a, bsdtar->bytes_per_block);
+	archive_write_set_bytes_in_last_block(a, bsdtar->bytes_in_last_block);
+
 	if (lseek(bsdtar->fd, end_offset, SEEK_SET) < 0)
 		lafe_errc(1, errno, "Could not seek to archive end");
 	if (ARCHIVE_OK != archive_write_set_options(a, bsdtar->option_options))
@@ -440,8 +411,15 @@
 	const char *arg;
 	struct archive_entry *entry, *sparse_entry;
 
+	/* Choose a suitable copy buffer size */
+	bsdtar->buff_size = 64 * 1024;
+	while (bsdtar->buff_size < (size_t)bsdtar->bytes_per_block)
+	  bsdtar->buff_size *= 2;
+	/* Try to compensate for space we'll lose to alignment. */
+	bsdtar->buff_size += 16 * 1024;
+
 	/* Allocate a buffer for file data. */
-	if ((bsdtar->buff = malloc(FILEDATABUFLEN)) == NULL)
+	if ((bsdtar->buff = malloc(bsdtar->buff_size)) == NULL)
 		lafe_errc(1, 0, "cannot allocate memory");
 
 	if ((bsdtar->resolver = archive_entry_linkresolver_new()) == NULL)
@@ -468,6 +446,12 @@
 					bsdtar->return_value = 1;
 					goto cleanup;
 				}
+				if (*arg == '\0') {
+					lafe_warnc(0,
+					    "Meaningless argument for -C: ''");
+					bsdtar->return_value = 1;
+					goto cleanup;
+				}
 			}
 			set_chdir(bsdtar, arg);
 		} else {
@@ -486,7 +470,7 @@
 	entry = NULL;
 	archive_entry_linkify(bsdtar->resolver, &entry, &sparse_entry);
 	while (entry != NULL) {
-		write_entry_backend(bsdtar, a, entry);
+		write_file(bsdtar, a, entry);
 		archive_entry_free(entry);
 		entry = NULL;
 		archive_entry_linkify(bsdtar->resolver, &entry, &sparse_entry);
@@ -502,7 +486,7 @@
 	free(bsdtar->buff);
 	archive_entry_linkresolver_free(bsdtar->resolver);
 	bsdtar->resolver = NULL;
-	archive_read_finish(bsdtar->diskreader);
+	archive_read_free(bsdtar->diskreader);
 	bsdtar->diskreader = NULL;
 
 	if (bsdtar->option_totals) {
@@ -510,7 +494,7 @@
 		    tar_i64toa(archive_position_compressed(a)));
 	}
 
-	archive_write_finish(a);
+	archive_write_free(a);
 }
 
 /*
@@ -531,7 +515,13 @@
 	lr = lafe_line_reader(bsdtar->names_from_file, bsdtar->option_null);
 	while ((line = lafe_line_reader_next(lr)) != NULL) {
 		if (bsdtar->next_line_is_dir) {
-			set_chdir(bsdtar, line);
+			if (*line != '\0')
+				set_chdir(bsdtar, line);
+			else {
+				lafe_warnc(0,
+				    "Meaningless argument for -C: ''");
+				bsdtar->return_value = 1;
+			}
 			bsdtar->next_line_is_dir = 0;
 		} else if (!bsdtar->option_null && strcmp(line, "-C") == 0)
 			bsdtar->next_line_is_dir = 1;
@@ -557,9 +547,10 @@
  */
 static int
 append_archive_filename(struct bsdtar *bsdtar, struct archive *a,
-    const char *filename)
+    const char *raw_filename)
 {
 	struct archive *ina;
+	const char *filename = raw_filename;
 	int rc;
 
 	if (strcmp(filename, "-") == 0)
@@ -567,8 +558,8 @@
 
 	ina = archive_read_new();
 	archive_read_support_format_all(ina);
-	archive_read_support_compression_all(ina);
-	if (archive_read_open_file(ina, filename, 10240)) {
+	archive_read_support_filter_all(ina);
+	if (archive_read_open_file(ina, filename, bsdtar->bytes_per_block)) {
 		lafe_warnc(0, "%s", archive_error_string(ina));
 		bsdtar->return_value = 1;
 		return (0);
@@ -578,10 +569,10 @@
 
 	if (rc != ARCHIVE_OK) {
 		lafe_warnc(0, "Error reading archive %s: %s",
-		    filename, archive_error_string(ina));
+		    raw_filename, archive_error_string(ina));
 		bsdtar->return_value = 1;
 	}
-	archive_read_finish(ina);
+	archive_read_free(ina);
 
 	return (rc);
 }
@@ -642,7 +633,7 @@
 	ssize_t	bytes_written;
 	int64_t	progress = 0;
 
-	bytes_read = archive_read_data(ina, bsdtar->buff, FILEDATABUFLEN);
+	bytes_read = archive_read_data(ina, bsdtar->buff, bsdtar->buff_size);
 	while (bytes_read > 0) {
 		if (need_report())
 			report_write(bsdtar, a, entry, progress);
@@ -654,8 +645,7 @@
 			return (-1);
 		}
 		progress += bytes_written;
-		bytes_read = archive_read_data(ina, bsdtar->buff,
-		    FILEDATABUFLEN);
+		bytes_read = archive_read_data(ina, bsdtar->buff, bsdtar->buff_size);
 	}
 
 	return (0);
@@ -870,7 +860,7 @@
 			continue;
 #endif
 
-#if defined(EXT2_IOC_GETFLAGS) && defined(EXT2_NODUMP_FL)
+#if defined(EXT2_IOC_GETFLAGS) && defined(EXT2_NODUMP_FL) && defined(HAVE_WORKING_EXT2_IOC_GETFLAGS)
 		/* Linux uses ioctl to read flags. */
 		if (bsdtar->option_honor_nodump) {
 			int fd = open(name, O_RDONLY | O_NONBLOCK | O_BINARY);
@@ -884,6 +874,22 @@
 		}
 #endif
 
+#ifdef __APPLE__
+		if (bsdtar->enable_copyfile) {
+			/* If we're using copyfile(), ignore "._XXX" files. */
+			const char *bname = strrchr(name, '/');
+			if (bname == NULL)
+				bname = name;
+			else
+				++bname;
+			if (bname[0] == '.' && bname[1] == '_')
+				continue;
+		} else {
+			/* If not, drop the copyfile() data. */
+			archive_entry_copy_mac_metadata(entry, NULL, 0);
+		}
+#endif
+
 		/*
 		 * If the user vetoes this file/directory, skip it.
 		 * We want this to be fairly late; if some other
@@ -917,7 +923,7 @@
 		archive_entry_linkify(bsdtar->resolver, &entry, &spare_entry);
 
 		while (entry != NULL) {
-			write_entry_backend(bsdtar, a, entry);
+			write_file(bsdtar, a, entry);
 			archive_entry_free(entry);
 			entry = spare_entry;
 			spare_entry = NULL;
@@ -931,18 +937,36 @@
 }
 
 /*
- * Backend for write_entry.
+ * Write a single file (or directory or other filesystem object) to
+ * the archive.
  */
 static void
-write_entry_backend(struct bsdtar *bsdtar, struct archive *a,
+write_file(struct bsdtar *bsdtar, struct archive *a,
+    struct archive_entry *entry)
+{
+	write_entry(bsdtar, a, entry);
+}
+
+/*
+ * Write a single entry to the archive.
+ */
+static void
+write_entry(struct bsdtar *bsdtar, struct archive *a,
     struct archive_entry *entry)
 {
 	int fd = -1;
 	int e;
+	size_t align = 4096;
 
 	if (archive_entry_size(entry) > 0) {
 		const char *pathname = archive_entry_sourcepath(entry);
+		/* TODO: Use O_DIRECT here and set 'align' to the
+		 * actual filesystem block size.  As of July 2010, new
+		 * directory-traversal code is going in that will make
+		 * it much easier to track filesystem properties like
+		 * this during the traversal. */
 		fd = open(pathname, O_RDONLY | O_BINARY);
+		align = 4096;
 		if (fd == -1) {
 			bsdtar->return_value = 1;
 			if (!bsdtar->verbose)
@@ -974,7 +998,7 @@
 	 * that case, just skip the write.
 	 */
 	if (e >= ARCHIVE_WARN && fd >= 0 && archive_entry_size(entry) > 0) {
-		if (write_file_data(bsdtar, a, entry, fd))
+		if (write_file_data(bsdtar, a, entry, fd, align))
 			exit(1);
 	}
 
@@ -1018,19 +1042,26 @@
 /* Helper function to copy file to archive. */
 static int
 write_file_data(struct bsdtar *bsdtar, struct archive *a,
-    struct archive_entry *entry, int fd)
+    struct archive_entry *entry, int fd, size_t align)
 {
 	ssize_t	bytes_read;
 	ssize_t	bytes_written;
 	int64_t	progress = 0;
+	size_t  buff_size;
+	char   *buff = bsdtar->buff;
 
-	bytes_read = read(fd, bsdtar->buff, FILEDATABUFLEN);
+	/* Round 'buff' up to the next multiple of 'align' and reduce
+	 * 'buff_size' accordingly. */
+	buff = (char *)((((uintptr_t)buff + align - 1) / align) * align);
+	buff_size = bsdtar->buff + bsdtar->buff_size - buff;
+	buff_size = (buff_size / align) * align;
+	
+	bytes_read = read(fd, buff, buff_size);
 	while (bytes_read > 0) {
 		if (need_report())
 			report_write(bsdtar, a, entry, progress);
 
-		bytes_written = archive_write_data(a, bsdtar->buff,
-		    bytes_read);
+		bytes_written = archive_write_data(a, buff, bytes_read);
 		if (bytes_written < 0) {
 			/* Write failed; this is bad */
 			lafe_warnc(0, "%s", archive_error_string(a));
@@ -1044,7 +1075,7 @@
 			return (0);
 		}
 		progress += bytes_written;
-		bytes_read = read(fd, bsdtar->buff, FILEDATABUFLEN);
+		bytes_read = read(fd, buff, buff_size);
 	}
 	if (bytes_read < 0) {
 		lafe_warnc(errno,
@@ -1066,7 +1097,7 @@
 	/*
 	 * If this file/dir is excluded by a time comparison, skip it.
 	 */
-	if (bsdtar->newer_ctime_sec > 0) {
+	if (bsdtar->newer_ctime_filter) {
 		if (st->st_ctime < bsdtar->newer_ctime_sec)
 			return (0); /* Too old, skip it. */
 		if (st->st_ctime == bsdtar->newer_ctime_sec
@@ -1074,7 +1105,7 @@
 		    <= bsdtar->newer_ctime_nsec)
 			return (0); /* Too old, skip it. */
 	}
-	if (bsdtar->newer_mtime_sec > 0) {
+	if (bsdtar->newer_mtime_filter) {
 		if (st->st_mtime < bsdtar->newer_mtime_sec)
 			return (0); /* Too old, skip it. */
 		if (st->st_mtime == bsdtar->newer_mtime_sec
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/netcat/netcat.c
--- a/head/contrib/netcat/netcat.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/netcat/netcat.c	Fri Mar 02 16:54:40 2012 +0200
@@ -25,7 +25,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: head/contrib/netcat/netcat.c 228896 2011-12-26 09:07:08Z delphij $
+ * $FreeBSD: head/contrib/netcat/netcat.c 231852 2012-02-17 02:39:58Z bz $
  */
 
 /*
@@ -605,8 +605,10 @@
 #endif
 
 		if (rtableid) {
-			if (setfib(rtableid) == -1)
-				err(1, "setfib");
+			if (setsockopt(s, SOL_SOCKET, SO_SETFIB, &rtableid,
+			    sizeof(rtableid)) == -1)
+				err(1, "setsockopt(.., SO_SETFIB, %u, ..)",
+				    rtableid);
 		}
 
 		/* Bind to a local port or source address if specified. */
@@ -678,8 +680,11 @@
 			continue;
 
 		if (rtableid) {
-			if (setfib(rtableid) == -1)
-				err(1, "setfib");
+			ret = setsockopt(s, SOL_SOCKET, SO_SETFIB, &rtableid,
+			    sizeof(rtableid));
+			if (ret == -1)
+				err(1, "setsockopt(.., SO_SETFIB, %u, ..)",
+				    rtableid);
 		}
 
 		ret = setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof(x));
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/pf/pfctl/parse.y
--- a/head/contrib/pf/pfctl/parse.y	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/pf/pfctl/parse.y	Fri Mar 02 16:54:40 2012 +0200
@@ -28,11 +28,14 @@
  */
 %{
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/contrib/pf/pfctl/parse.y 223637 2011-06-28 11:57:25Z bz $");
+__FBSDID("$FreeBSD: head/contrib/pf/pfctl/parse.y 231852 2012-02-17 02:39:58Z bz $");
 
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
+#ifdef __FreeBSD__
+#include <sys/sysctl.h>
+#endif
 #include <net/if.h>
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
@@ -335,6 +338,7 @@
 int	 check_rulestate(int);
 int	 getservice(char *);
 int	 rule_label(struct pf_rule *, char *);
+int	 rt_tableid_max(void);
 
 void	 mv_rules(struct pf_ruleset *, struct pf_ruleset *);
 void	 decide_address_family(struct node_host *, sa_family_t *);
@@ -1174,7 +1178,7 @@
 			scrub_opts.randomid = 1;
 		}
 		| RTABLE NUMBER				{
-			if ($2 < 0 /* || $2 > RT_TABLEID_MAX */) {
+			if ($2 < 0 || $2 > rt_tableid_max()) {
 				yyerror("invalid rtable id");
 				YYERROR;
 			}
@@ -1322,7 +1326,7 @@
 			antispoof_opts.label = $1;
 		}
 		| RTABLE NUMBER				{
-			if ($2 < 0 /* || $2 > RT_TABLEID_MAX */ ) {
+			if ($2 < 0 || $2 > rt_tableid_max()) {
 				yyerror("invalid rtable id");
 				YYERROR;
 			}
@@ -2361,7 +2365,7 @@
 				filter_opts.prob = 1;
 		}
 		| RTABLE NUMBER				{
-			if ($2 < 0 /* || $2 > RT_TABLEID_MAX */ ) {
+			if ($2 < 0 || $2 > rt_tableid_max()) {
 				yyerror("invalid rtable id");
 				YYERROR;
 			}
@@ -4190,7 +4194,7 @@
 
 rtable		: /* empty */		{ $$ = -1; }
 		| RTABLE NUMBER		{
-			if ($2 < 0 /* || $2 > RT_TABLEID_MAX */ ) {
+			if ($2 < 0 || $2 > rt_tableid_max()) {
 				yyerror("invalid rtable id");
 				YYERROR;
 			}
@@ -6051,3 +6055,23 @@
 
 	return (0);
 }
+
+int
+rt_tableid_max(void)
+{
+#ifdef __FreeBSD__
+	int fibs;
+	size_t l = sizeof(fibs);
+
+        if (sysctlbyname("net.fibs", &fibs, &l, NULL, 0) == -1)
+		fibs = 16;	/* XXX RT_MAXFIBS, at least limit it some. */
+	/*
+	 * As the OpenBSD code only compares > and not >= we need to adjust
+	 * here given we only accept values of 0..n and want to avoid #ifdefs
+	 * in the grammer.
+	 */
+	return (fibs - 1);
+#else
+	return (RT_TABLEID_MAX);
+#endif
+}
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/Fixes
--- a/head/contrib/tcsh/Fixes	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/Fixes	Fri Mar 02 16:54:40 2012 +0200
@@ -1,3 +1,147 @@
+  6. V6.18.01 - 20120214
+  5. fix interruptible wait again
+  4. ignore bogus compiler overflow message
+  3. cleanup ifdefs in utmp code, and provide default array entries
+  2. Ignore #machine entries in host.defs
+  1. Detect missing ) in gethost.c (Corinna Vinschen)
+
+104. V6.18.00 - 20120114
+103. remove unused variables.
+102. Make gethost use definitions for x __x__ and __x automatically.
+101. More utmp fixes
+100. V6.17.10 - 20120105
+ 99. Add more FreeBSD/NetBSD machines
+ 98. Add portability wrapper for gencat
+ 97. Fix warning for write in SYSMALLOC systems.
+ 96. V6.17.09 - 20120102
+ 95. revert gencat handling to pre-cygwin fixes (without the env settings)
+ 94. remove stray endutent()
+ 93. V6.17.08 - 20111230
+ 92. Remove - from gencat
+ 91. Provide support for malloc_usable_size() so that linux works again
+     without SYSMALLOC
+ 90. Add support for FreeBSD's utmpx.
+ 89. V6.17.07 - 20111227
+ 88. Fix debian bug #645238: tcsh segfaults when prompt includes %j and
+     there are more than 10 jobs.
+ 87. PR/155: Default $anyerror to set for backward compatibility
+ 86. PR/149: Don't print -1 in %j (Vojtech Vitek)
+ 85. handle -- on chdir commands as the end of options processing so that
+     they can process a directory like -x without resorting to ./-x
+     (Andrew Stevenson)
+ 84. Handle write(2) returning ENOENT from SoFS, thanks ++HAL (Robert Byrnes)
+ 83. PR/38: Null check for jobs (Kurt Miller)
+ 82. Fix spelling correction correcting ./foo -> ../foo2 (jean-luc leger)
+ 81. PR/120: string0 in filetest does not have enough space.
+ 80. V6.17.06 - 20110415
+ 79. PR/110: Add $anyerror to select behavior. Default to the new one.
+ 78. Don't try to spell commands that are correct (Rouben Rostamian)
+     [./tcsh -f; set path=($path 2); mkdir foo2; cd foo2; touch foo;
+      chmod +x foo; set correct=cmd; ./foo -> ../foo]
+ 77. Don't push the syntax struct on the cleanup stack, because on foo;bar
+     if foo fails, we will free bar prematurely (Ben Miller)
+ 76. Avoid infinite loop while trying to print the pid of a dying process
+     to a closed file (Bob Arendt)
+ 75. Handle completion of ${ variables (Anthony Mallet)
+ 74. Add --disable-nls-catalogs (Corinna Vinschen)
+ 73. convert message catalogs to UTF-8 (Werner Fink)
+ 72. check that the NLS path works before setting $NLSPATH.
+ 71. use SYSMALLOC for GLIBC (Werner Fink)
+ 70. use mallinfo for SYSMALLOC (Corinna Vinschen)
+ 69. V6.17.05 - 20110201
+ 68. Use mkstemp() if there for here docs (Werner Fink)
+ 67. Fix handling of errors and exit values in builtins (Werner Fink)
+ 66. Better pty name detection (Werner Fink)
+ 65. Enable NLS catalogs on Cygwin (Corinna Vinschen)
+ 64. NLSPATH handling fixes (Corinna Vinschen)
+ 63. Avoid infrequent exit when tcsh cd's into a non-existent directory
+     https://bugzilla.novell.com/show_bug.cgi?id=293395 (Werner Fink)
+ 62. Don't try to spell check full path binaries that are correct because
+     they can cause hangs when other nfs partitions are hung. (Werner Fink)
+ 61. Avoid nested interrupts when exiting causing history writing to fail
+     https://bugzilla.novell.com/show_bug.cgi?id=331627 (Werner Fink)
+ 60. Instead of giving an error or ignoring lines with missing eol at eof,
+     process them.
+ 59. Avoid leaking fd's in mail check (Werner Fink)
+ 58. Add cygwin_xcrypt() (Corinna Vinschen)
+ 57. Recognize i686 (Corinna Vinschen)
+ 56. Rename cygwin32 to cygwin and bring it up-to-date with modern cygwin
+     settings (Corinna Vinschen)
+ 55. Avoid double slashes in cdpath (Corinna Vinschen)
+ 54. V6.17.04 - 20110118
+ 53. Revert PR/110, breaks the test suite.
+ 52. V6.17.03 - 20110117
+ 51. PR/102: Complain on input files with missing trailing \n
+ 50. PR/104: If atime == mtime we don't have new mail.
+ 49. PR/113: Don't allow illegal variable names to be set.
+ 48. PR/112: don't set $REMOTEHOST on the local machine.
+ 47. PR/110: exit status of the pipeline should be the status of the last
+     command.
+ 46. Android support (Corinna Vinschen)
+ 45. Add AUTOSET_KANJI which works around the Shift-JIS encoding that
+     translates unshifted 7 bit ASCII (Werner Fink)
+ 44. Handle mb{r,}towc() returning 0 by setting the return value to NUL
+     (Jean-Luc Leger)
+ 43. PR/109: make wait interruptible (Vojtech Vitek)
+ 42. resource limit fixes: signed vs. unsigned, megabyte issue, doc issues
+     (Robert Byrnes)
+ 41. remove .bat and .cmd handling for executables on cygwin (Corinna Vinschen)
+ 40. Don't echo history while history -L or history -M
+ 39. Check for EOS before ** from Greg Dionne
+ 38. Don't fork in backeval from Bryan Mason
+ 37. Better globstar support from Greg Dionne
+ 36. Error out when processing the last incomplete line instead of silently
+     ignoring it (Anders Kaseorg)
+ 35. Fix SEGV from echo ``
+ 34. Better fixes for histchars and promptchars (nargs)
+ 33. Fix win32 issue calling fmalloc/ffree from non-thread-safe context.
+     (Fabio Fabbri)
+ 32. V6.17.02 - 20100512
+ 31. PR/79: nargs: Better handling for promptchars.
+ 30. PR/97: Add parseoctal to retain compatibility with previous versions (Jim
+     Zajkowski)
+ 29. PR/84: Performance fixes for large history merges (add
+     hashtable (Ted Anderson)
+ 28. Revert previous #23; people should use $histlit if they want this
+     feature.
+ 27. Don't kill "hup" background jobs when a child of the shell exits.
+     From Debian.
+ 26. Ignore \r\n in the command line options for OS's that don't strip
+     these from #!; from Debian
+ 25. Fix enhanced missing patch (Greg Dionne)
+ 24. Callers of rt_mbtowc don't grok -2 as a return. Return -1 for now.
+     (Corinna Vinschen)
+ 23. Turn HistLit on while recording history to avoid \!\! losing its \.
+     From Debian
+ 22. set autoexpand; set histchars="";\n<tab> crash. From Debian
+ 21. V6.17.01 - 20100506
+ 20. unset verbose while we are reading the history file to avoid echoing
+     to the terminal. (Jeffrey Bastian)
+ 19. globstar addition, Enhance addition, euid, euser, gid variables
+     (Greg Dionne)
+ 18. Make 'e' in vi mode work like 'b' - use wordchars (Alistair Crooks)
+ 17. Handle UTF-16 surrogates (Corinna Vinschen)
+ 16. Make tcsh work on systems where sizeof(wchar_t) == 2 (Corinna Vinschen)
+ 15. Better support for Solaris >= 2.9 (Thomas Uhle)
+ 14. Change internal expression calculations to long long so that we can
+     deal with > 32 bit time, inodes, uids, file sizes etc.
+ 13. Add new linux resource limits.
+ 12. Don't print 'Exit X' when printexitvalue is set in `` expressions
+     (Jeff Bastian)
+ 11. Add more LS_COLORS vars (M.H. Anderson)
+ 10. Reduce whitespace in Makefile (Don Estabrook)
+  9. Manual page fixes (Alan R. S. Bueno)
+  8. Remove history in loops bug from the documentation (Holger Weiss)
+  7. Add autorehash (Holger Weiss)
+  6. Add history.at (Ted Anderson)
+  5. Better NLSPATH handling (Norm Jacobs)
+  4. Fix hostname building from utmp (Cyrus Rahman)
+  3. Handle pending signals before flush so that the the history file does
+     not get truncated.  (Ted Anderson)
+  2. Fix AsciiOnly setting that broke 8 bit input. (Juergen Keil)
+  1. remember to closedir in mailchk (from Werner Fink, reported by
+     David Binderman)
+
  21. V6.17.00 - 20090710
  20. Fix dataroot autoconf issue.
  19. Fix directory stuff for unit tests.
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/Imakefile
--- a/head/contrib/tcsh/Imakefile	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/Imakefile	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,5 @@
 XCOMM
-XCOMM $tcsh: Imakefile,v 1.86 2007/03/19 23:25:02 christos Exp $
+XCOMM $tcsh: Imakefile,v 1.87 2010/01/28 19:01:05 christos Exp $
 XCOMM
 XCOMM Imakefile for tcsh 6.12
 XCOMM Marc Horowitz, MIT SIPB
@@ -93,7 +93,11 @@
 #      if (OSMinorVersion < 6)
 #       define ConfigH sol24
 #      else
-#       define ConfigH sol26
+#       if (OSMinorVersion < 9)
+#        define ConfigH sol26
+#       else
+#        define ConfigH sol29
+#       endif
 #      endif
 #     endif
 #    endif
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/Makefile.in
--- a/head/contrib/tcsh/Makefile.in	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/Makefile.in	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-# $tcsh: Makefile.in,v 3.40 2009/06/24 22:09:05 christos Exp $
+# $tcsh: Makefile.in,v 3.49 2011/02/05 17:35:31 christos Exp $
 #	Makefile.in	4.3	6/11/83
 #
 # C Shell with process control; VM/UNIX VAX Makefile
@@ -26,22 +26,27 @@
 CPPFLAGS=-I. -I$(srcdir)
 
 LFLAGS=
-#LFLAGS= -Zn10000		# hpux lint
+# hpux lint
+#LFLAGS= -Zn10000
 
 
-CFLAGS = @CFLAGS@		# This is set by autoconf.
-#CFLAGS= -g			# debug
-#CFLAGS= -O			# production
-#CFLAGS= 			# Broken optimizers....
+# This is set by autoconf:
+CFLAGS = @CFLAGS@
+# debug:
+#CFLAGS= -g
+# production:
+#CFLAGS= -O
+# Broken optimizers....
+#CFLAGS=
 
 #CFLAGS= -g -pg -DPROF
 #CFLAGS= -O -pg -DPROF
 
 # gcc 1.00-1.37
-#CFLAGS= -O -finline-functions -fstrength-reduce 
+#CFLAGS= -O -finline-functions -fstrength-reduce
 
 # gcc 1.37-1.40
-#CFLAGS= -O -fcombine-regs -finline-functions -fstrength-reduce 
+#CFLAGS= -O -fcombine-regs -finline-functions -fstrength-reduce
 # add -msoft-float for 68881 machines.
 
 # gcc 2.0
@@ -67,8 +72,10 @@
 #CFLAGS= -O -Mnodebug -Mnoperfmon
 
 # DEC Alpha OSF/1
-#CFLAGS= -O2 -Olimit 2000	## Normal Optimization
-#CFLAGS= -O3 -Olimit 2000	## Full Optimization - may not work
+## Normal Optimization
+#CFLAGS= -O2 -Olimit 2000
+## Full Optimization - may not work
+#CFLAGS= -O3 -Olimit 2000
 #CF=-j
 #SUF=u
 #.SUFFIXES: .u
@@ -77,7 +84,8 @@
 # global optimizer! (-O3).
 # On SGI 4.0+ you need to add -D__STDC__ too.
 #CFLAGS= -O3
-#CFLAGS= -O3 -Olimit 2000	## Ultrix 4.2a
+## Ultrix 4.2a
+#CFLAGS= -O3 -Olimit 2000
 #CF=-j
 #SUF=u
 #.SUFFIXES: .u 				## Ultrix and gnu-make need that
@@ -110,14 +118,14 @@
 # CFLAGS= -O3
 
 # SINIX RMx00
-#CFLAGS= -O # -D_POSIX_SOURCE # -kansi
+#CFLAGS= -O# -D_POSIX_SOURCE# -kansi
 
 # Apollo's with cc [apollo builtins don't work with gcc]
 # and apollo should not define __STDC__ if it does not have
 # the standard header files. RT's (aos4.3) need that too;
 # you might want to skip the -O on the rt's... Not very wise.
 # AIX/ESA needs -D_IBMESA on command line (this may disappear by GA)
-#DFLAGS=-U__STDC__ 
+#DFLAGS=-U__STDC__
 #DFLAGS=-D_IBMESA
 # On aix2.2.1 we need more compiler space.
 #DFLAGS=-Nd4000 -Nn3000
@@ -142,17 +150,25 @@
 ################################################################
 ## LDFLAGS.  Define something here if you need to
 ################################################################
-LDFLAGS= @LDFLAGS@		## This is set by autoconf.
-#LDFLAGS= 			## The simplest, suitable for all.
-#LDFLAGS= -s			## Stripped. Takes less space on disk.
-#LDFLAGS= -s -n			## Pure executable. Spares paging over
-# 				## the network for machines with local
-#				## swap but external /usr/local/bin .
-#LDFLAGS= -s -n -Bstatic	## Without dynamic linking. (SunOS/cc)
-#LDFLAGS= -s -n -static		## Without dynamic linking. (SunOS/gcc)
-#LDFLAGS= -Wl,-s,-n		## Stripped, shared text (Unicos)
-#LDFLAGS= -s -static		## Link statically. (linux)
-#LDFLAGS= -s -N			## Impure executable (linux)
+## This is set by autoconf:
+LDFLAGS= @LDFLAGS@
+## The simplest, suitable for all.
+#LDFLAGS=
+## Stripped. Takes less space on disk.
+#LDFLAGS= -s
+## Pure executable.  Spares paging over the network for machines with
+## local swap but external /usr/local/bin .
+#LDFLAGS= -s -n
+## Without dynamic linking. (SunOS/cc)
+#LDFLAGS= -s -n -Bstatic
+## Without dynamic linking. (SunOS/gcc)
+#LDFLAGS= -s -n -static
+## Stripped, shared text (Unicos)
+#LDFLAGS= -Wl,-s,-n
+## Link statically. (linux)
+#LDFLAGS= -s -static
+## Impure executable (linux)
+#LDFLAGS= -s -N
 
 ################################################################
 ## SBINLDFLAGS.  Flags to build a tcsh suitable for installation in
@@ -164,53 +180,100 @@
 ################################################################
 ## LIBES.  Pick one, or roll your own.
 ################################################################
-LIBES= @LIBS@	 			 ## This is set by autoconf.
-#LIBES= -ltermcap 			 ## BSD style things
-#LIBES= -ltermcap			 ## SunOS, HP-UX, pyramid
-#LIBES= -ltermcap			 ## Linux
-#LIBES= -ltermcap -lshadow		 ## Linux with PW_SHADOW
-#LIBES= -ltermcap -lsec			 ## Tek XD88/10 (UTekV) with PW_SHADOW
-#LIBES= -ltermcap -lsec			 ## Motorola MPC (sysV88) with PW_SHADOW
-#LIBES= -ltermcap -lcs			 ## Mach
-#LIBES= -ltermcap -lbsd			 ## DEC osf1 on the alpha
-#LIBES= -ltermcap -lbsd			 ## Intel paragon
-#LIBES= -ltermcap -lbsd			 ## Clipper intergraph
-#LIBES= -ltermcap -lseq			 ## Sequent's Dynix
-#LIBES= -ltermcap -lauth		 ## Ultrix with Enhanced Security
-#LIBES= -ltermcap -ldir -lx		 ## Xenix 386 style things
-#LIBES= -ltermcap -lndir -lsocket -ljobs ## masscomp RTU6.0
-#LIBES= -lcurses			 ## AIX on the rt
-#LIBES= -lcurses			 ## TitanOS on the stellar
-#LIBES= -ltermlib -lsocket -lnsl	 ## SysV4 w/o BSDTIMES or Solaris 2
-#LIBES= -lcurses			 ## SysV3 w/o networking
-#LIBES= -lcurses -lnet			 ## SysV3 with networking
-#LIBES= -lcurses -ldir			 ## SysV2 w/o networking & dirlib
-#LIBES= -lcurses -ldir -lnet		 ## SysV2 with networking & dirlib
-#LIBES= -lcurses -lbsd			 ## AIX on the IBM 370 or rs6000 or ps2
-#LIBES= -lcurses -lbsd			 ## ETA10
-#LIBES= -lcurses -lbsd			 ## Irix3.1 on the SGI-IRIS4D
-#LIBES= -lcurses -lbsd -lc_s		 ## Irix3.3 on the SGI-IRIS4D w/o yp
-#LIBES= -lcurses -lsun -lbsd -lc_s	 ## Irix3.3 on the SGI-IRIS4D with yp
-#LIBES= -lcurses -lsocket -lbsd		 ## Amdahl UTS 2.1
-#LIBES= -lcurses -lsocket		 ## Intel's hypercube.
-#LIBES= -lcurses -lsocket		 ## ns32000 based Opus.
-#LIBES= -lcurses -lcposix		 ## ISC 2.2 without networking
-#LIBES= -lcposix -lc_s -lcurses -linet	 ## ISC 2.2 with networking
-#LIBES= -lcurses -lsec -lc_s		 ## ISC 2.0.2 without networking
-#LIBES= -lcurses -linet -lsec -lc_s	 ## ISC 2.0.2 with networking
-#LIBES= -lcurses -lintl -lcrypt		 ## SCO SysVR3.2v2.0
-#LIBES= -lcurses -lintl -lsocket -lcrypt ## SCO+ODT1.1
-#LIBES= -lposix -ltermcap		 ## A/UX 2.0
-#LIBES= -lposix -ltermcap -lc_s		 ## A/UX 3.0
-#LIBES= -ldirent -lcurses		 ## att3b1 cc w/o shared lib & dirlib
-#LIBES= -shlib -ldirent -lcurses	 ## att3b1 gcc with shared lib & dirlib
-#LIBES= -ltermlib -lsocket -lnsl -lc /usr/ucblib/libucb.a ## SysV4 with BSDTIMES
-#LIBES= -lcurses -lnsl -lsocket -lc /usr/ucblib/libucb.a ## Stardent Vistra
-#LIBES= -ltermc				 ## emx under OS/2
-#LIBES=					 ## Minix, VMS_POSIX
-#LIBES= -ltermcap -lcrypt		 ## Multiflow
-#LIBES= -ltermcap -lcrypt		 ## NetBSD
-#LIBES= -lcurses 			 ## DDE Supermax
+## This is set by autoconf.
+LIBES= @LIBS@
+## BSD style things
+#LIBES= -ltermcap
+## SunOS, HP-UX, pyramid
+#LIBES= -ltermcap
+## Linux
+#LIBES= -ltermcap
+## Linux with PW_SHADOW
+#LIBES= -ltermcap -lshadow
+## Tek XD88/10 (UTekV) with PW_SHADOW
+#LIBES= -ltermcap -lsec
+## Motorola MPC (sysV88) with PW_SHADOW
+#LIBES= -ltermcap -lsec
+## Mach
+#LIBES= -ltermcap -lcs
+## DEC osf1 on the alpha
+#LIBES= -ltermcap -lbsd
+## Intel paragon
+#LIBES= -ltermcap -lbsd
+## Clipper intergraph
+#LIBES= -ltermcap -lbsd
+## Sequent's Dynix
+#LIBES= -ltermcap -lseq
+## Ultrix with Enhanced Security
+#LIBES= -ltermcap -lauth
+## Xenix 386 style things
+#LIBES= -ltermcap -ldir -lx
+## masscomp RTU6.0
+#LIBES= -ltermcap -lndir -lsocket -ljobs
+## AIX on the rt
+#LIBES= -lcurses
+## TitanOS on the stellar
+#LIBES= -lcurses
+## SysV4 w/o BSDTIMES or Solaris 2
+#LIBES= -ltermlib -lsocket -lnsl
+## SysV3 w/o networking
+#LIBES= -lcurses
+## SysV3 with networking
+#LIBES= -lcurses -lnet
+## SysV2 w/o networking & dirlib
+#LIBES= -lcurses -ldir
+## SysV2 with networking & dirlib
+#LIBES= -lcurses -ldir -lnet
+## AIX on the IBM 370 or rs6000 or ps2
+#LIBES= -lcurses -lbsd
+## ETA10
+#LIBES= -lcurses -lbsd
+## Irix3.1 on the SGI-IRIS4D
+#LIBES= -lcurses -lbsd
+## Irix3.3 on the SGI-IRIS4D w/o yp
+#LIBES= -lcurses -lbsd -lc_s
+## Irix3.3 on the SGI-IRIS4D with yp
+#LIBES= -lcurses -lsun -lbsd -lc_s
+## Amdahl UTS 2.1
+#LIBES= -lcurses -lsocket -lbsd
+## Intel's hypercube.
+#LIBES= -lcurses -lsocket
+## ns32000 based Opus.
+#LIBES= -lcurses -lsocket
+## ISC 2.2 without networking
+#LIBES= -lcurses -lcposix
+## ISC 2.2 with networking
+#LIBES= -lcposix -lc_s -lcurses -linet
+## ISC 2.0.2 without networking
+#LIBES= -lcurses -lsec -lc_s
+## ISC 2.0.2 with networking
+#LIBES= -lcurses -linet -lsec -lc_s
+## SCO SysVR3.2v2.0
+#LIBES= -lcurses -lintl -lcrypt
+## SCO+ODT1.1
+#LIBES= -lcurses -lintl -lsocket -lcrypt
+## A/UX 2.0
+#LIBES= -lposix -ltermcap
+## A/UX 3.0
+#LIBES= -lposix -ltermcap -lc_s
+## att3b1 cc w/o shared lib & dirlib
+#LIBES= -ldirent -lcurses
+## att3b1 gcc with shared lib & dirlib
+#LIBES= -shlib -ldirent -lcurses
+## SysV4 with BSDTIMES
+#LIBES= -ltermlib -lsocket -lnsl -lc /usr/ucblib/libucb.a
+## Stardent Vistra
+#LIBES= -lcurses -lnsl -lsocket -lc /usr/ucblib/libucb.a
+## emx under OS/2
+#LIBES= -ltermc
+## Minix, VMS_POSIX
+#LIBES=
+## Multiflow
+#LIBES= -ltermcap -lcrypt
+## NetBSD
+#LIBES= -ltermcap -lcrypt
+## DDE Supermax
+#LIBES= -lcurses
 
 ################################################################
 ## EXTRAFLAGS and EXTRALIBS
@@ -222,8 +285,10 @@
 #
 #Solaris and HPUX require the BSD libraries with AFS.
 #We use -lc to use only what we require.
-#AFSAUXLIB = -lsocket -lnsl -lc -lucb                    # Solaris
-#AFSAUXLIB = -lc -lBSD                                   # HPUX   
+# Solaris
+#AFSAUXLIB = -lsocket -lnsl -lc -lucb
+# HPUX   
+#AFSAUXLIB = -lc -lBSD
 #
 #AFSLIB = -L$(AFSLIBDIR) -L$(AFSLIBDIR)/afs -lkauth -lprot -lubik\
 #         -lauth -lrxkad -lsys -ldes -lrx -llwp -lcom_err\
@@ -244,26 +309,38 @@
 # will lose the editor and job control.
 
 # This is for setting your C preprocessor value.
-CPP = @CPP@ # This is set by autoconf.
+# This is set by autoconf.
+CPP = @CPP@
 # The -B tells gcc to use /bin/ld. This is to avoid using the gnu ld, which
 # on the suns does not know how to make dynamically linked binaries.
-CC = @CC@ # This is set by autoconf.
+# This is set by autoconf.
+CC = @CC@
 #CC= gcc -Wall -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith -Werror -Wmissing-declarations -Wredundant-decls -Wnested-externs -Wsign-compare -Wcast-qual -Wreturn-type -Wswitch -Wshadow -Wwrite-strings -Wextra
-#CC=	gcc -Wall -pipe -B/bin/	# -ansi -pedantic
-#CC=	gcc -m486 -pipe -Wall # Generate code for Intel 486 (linux)
-#CC=	shlicc 	# BSDI2.1 w/ shared libraries
+# -ansi -pedantic
+#CC=	gcc -Wall -pipe -B/bin/
+# Generate code for Intel 486 (linux)
+#CC=	gcc -m486 -pipe -Wall
+# BSDI2.1 w/ shared libraries
+#CC=	shlicc
 #CC=	cc
 #CC=	occ
 #CC=	acc
 #CC=	pcc
 #CC=	hc -w
-#CC=	c89	# For VMS/POSIX
-#CC=	/bin/cc	# For suns, w/o gcc and SVR4
-#CC=	/usr/lib/sun.compile/cc  # FPS 500 (+FPX) with Sun C compiler
-#CC=	/opt/SUNWspro/bin/cc	# Solaris 2.1
-#CC=	scc 	# Alliant fx2800
-#CC=	cc	-h0,ansi,novector,float0 # for NEC SX-4
+# For VMS/POSIX
+#CC=	c89
+# For suns, w/o gcc and SVR4
+#CC=	/bin/cc
+# FPS 500 (+FPX) with Sun C compiler
+#CC=	/usr/lib/sun.compile/cc
+# Solaris 2.1
+#CC=	/opt/SUNWspro/bin/cc
+# Alliant fx2800
+#CC=	scc
+# for NEC SX-4
+#CC=	cc	-h0,ansi,novector,float0
 #CC=	lcc	-wa 
+CC_FOR_GETHOST = @CC_FOR_GETHOST@
 ED=	ed
 AS=	as
 RM=	rm
@@ -272,8 +349,10 @@
 CTAGS=	/usr/ucb/ctags
 #XSTR= /usr/ucb/xstr
 SCCS=	/usr/local/sccs
-PARALLEL=12				# Make the multi-max run fast.
-#P=&					# Use Sequent's parallel make
+# Make the multi-max run fast.
+PARALLEL=12
+# Use Sequent's parallel make
+#P=&
 P=
 prefix=@prefix@
 exec_prefix=@exec_prefix@
@@ -282,12 +361,17 @@
 MANSECT=1
 DESTBIN=${DESTDIR}${bindir}
 DESTMAN=${DESTDIR}${mandir}/man${MANSECT}
-# DESTMAN=${DESTDIR}/catman/man${MANSECT}	 # A/UX
-# DESTMAN=${DESTDIR}/usr/share/man/man${MANSECT} # Stardent Vistra (SysVR4)
-# DESTMAN=/usr/catman/1l			 # Amiga unix (SysVR4)
+# A/UX
+# DESTMAN=${DESTDIR}/catman/man${MANSECT}
+# Stardent Vistra (SysVR4)
+# DESTMAN=${DESTDIR}/usr/share/man/man${MANSECT}
+# Amiga unix (SysVR4)
+# DESTMAN=/usr/catman/1l
 EXEEXT=@EXEEXT@
 FTPAREA=/usr/spool/ftp
 
+BUILD_CATALOGS = @BUILD_CATALOGS@
+
 ASSRCS=	sh.c sh.dir.c sh.dol.c sh.err.c sh.exec.c sh.char.c \
 	sh.exp.c sh.file.c sh.func.c sh.glob.c sh.hist.c sh.init.c \
 	sh.lex.c sh.misc.c sh.parse.c sh.print.c sh.proc.c sh.sem.c \
@@ -330,9 +414,9 @@
 	host.defs gethost.c tcsh.man2html configure.in configure config.h.in \
 	tests/testsuite.at
 TESTFILES= tests/aliases.at tests/arguments.at tests/commands.at \
-	tests/expr.at tests/lexical.at tests/mb-eucjp.at tests/mb-utf8.at \
-	tests/noexec.at tests/syntax.at tests/subst.at tests/variables.at \
-	tests/sh.dol.at
+	tests/expr.at tests/lexical.at tests/mb-eucjp.at \
+	tests/mb-utf8.at tests/noexec.at tests/syntax.at tests/subst.at \
+	tests/variables.at tests/sh.dol.at
 
 VHSRCS=${PVSRCS} ${AVSRCS}
 
@@ -345,7 +429,7 @@
 OBJS= ${SHOBJS} ${TWOBJS} ${EDOBJS} ${TCOBJS}
 
 
-all: ${BUILD}
+all: ${BUILD} catalogs
 
 tcsh$(EXEEXT):$(P) ${OBJS} 
 	rm -f tcsh$(EXEEXT) core
@@ -365,7 +449,7 @@
 
 gethost:  gethost.c sh.err.h tc.const.h sh.h
 	rm -f gethost
-	${CC} -o gethost ${LDFLAGS} ${CFLAGS} ${CPPFLAGS} ${DFLAGS} $(srcdir)/gethost.c ${LIBES} ${EXTRALIBS}
+	${CC_FOR_GETHOST} -o gethost ${CPPFLAGS} $(srcdir)/gethost.c
 
 tc.defs.c:	gethost host.defs
 	@rm -f [email protected]
@@ -463,7 +547,7 @@
 	  echo 'm4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])'; \
 	} >$(srcdir)/tests/package.m4
 
-$(srcdir)/tests/testsuite: $(srcdir)/tests/package.m4 $(srcdir}/tests/testsuite.at $(TESTFILES)
+$(srcdir)/tests/testsuite: $(srcdir)/tests/package.m4 $(srcdir)/tests/testsuite.at $(TESTFILES)
 	autom4te --language=autotest -I $(srcdir)/tests \
 		$(srcdir)/tests/testsuite.at -o [email protected]
 	mv [email protected] $@
@@ -511,20 +595,36 @@
 
 install-strip: install
 
-install: tcsh$(EXEEXT) 
+install: tcsh$(EXEEXT) install.catalogs install.man
 	-mkdir -p ${DESTBIN}
 	-mv -f ${DESTBIN}/tcsh$(EXEEXT)  ${DESTBIN}/tcsh.old
 	cp tcsh$(EXEEXT) ${DESTBIN}/tcsh$(EXEEXT)
 	-strip ${DESTBIN}/tcsh$(EXEEXT)
 	chmod 755 ${DESTBIN}/tcsh$(EXEEXT)
 
+install.catalogs:
+	@test "x${BUILD_CATALOGS}" = "xyes" && (cd nls; ${MAKE} install DESTDIR=${DESTDIR}) || exit 0
+
 install.man: tcsh.man
 	-mkdir -p ${DESTMAN}
 	-rm -f ${DESTMAN}/tcsh.${MANSECT}
 	cp $(srcdir)/tcsh.man ${DESTMAN}/tcsh.${MANSECT}
 	chmod 444 ${DESTMAN}/tcsh.${MANSECT}
 
-install.cygwin: install install.man
+# Amiga Unix
+#install.man: tcsh.man
+#        compress tcsh.man
+#	cp tcsh.man.Z ${DESTMAN}/tcsh.Z
+#	chmod 444 ${DESTMAN}/tcsh.Z
+
+# Apple A/UX
+#install.man: tcsh.man
+#	-rm -f ${DESTMAN}/tcsh.${MANSECT}.Z
+#	nroff -man tcsh.man | compress > ${DESTMAN}/tcsh.${MANSECT}.Z
+#	chmod 444 ${DESTMAN}/tcsh.${MANSECT}.Z
+
+install.cygwin: install
+	-gzip ${DESTMAN}/tcsh.${MANSECT}
 	-mkdir -p ${DESTDIR}${prefix}/share/doc/tcsh
 	cp ${srcdir}/FAQ ${srcdir}/Fixes ${DESTDIR}${prefix}/share/doc/tcsh
 	cp ${srcdir}/NewThings ${srcdir}/README ${DESTDIR}${prefix}/share/doc/tcsh
@@ -542,24 +642,15 @@
 	cp -p ${srcdir}/cygwin/postinstall.sh ${DESTDIR}/etc/postinstall/tcsh.sh
 	cp -p ${srcdir}/cygwin/preremove.sh ${DESTDIR}/etc/preremove/tcsh.sh
 
-# Amiga Unix
-#install.man: tcsh.man
-#        compress tcsh.man
-#	cp tcsh.man.Z ${DESTMAN}/tcsh.Z
-#	chmod 444 ${DESTMAN}/tcsh.Z
-
-# Apple A/UX
-#install.man: tcsh.man
-#	-rm -f ${DESTMAN}/tcsh.${MANSECT}.Z
-#	nroff -man tcsh.man | compress > ${DESTMAN}/tcsh.${MANSECT}.Z
-#	chmod 444 ${DESTMAN}/tcsh.${MANSECT}.Z
-
-clean:
+clean: clean.catalogs
 	${RM} -f a.out strings x.c xs.c tcsh$(EXEEXT) tcsh.a _MAKE_LOG gethost
 	${RM} -f *.${SUF} *.i *.s
 	${RM} -f sh.prof.c ed.defns.h tc.const.h sh.err.h tc.defs.c
 	${RM} -f tcsh.*.m tcsh.*.cat
 
+clean.catalogs:
+	@test "x${BUILD_CATALOGS}" = "xyes" && (cd nls; ${MAKE} clean) || exit 0
+
 veryclean: clean
 	${RM} -f Makefile config.h config_p.h
 	${RM} -f config.status config.cache config.log tcsh.ps
@@ -607,7 +698,7 @@
 	rm -rf tcsh-${VERSION}
 
 catalogs:
-	@(cd nls; make catalogs)
+	@test "x${BUILD_CATALOGS}" = "xyes" && (cd nls; ${MAKE} catalogs) || exit 0
 
 tcsh-${VERSION}.tar.Z:
 	rm -rf tcsh-${VERSION} 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/Ported
--- a/head/contrib/tcsh/Ported	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/Ported	Fri Mar 02 16:54:40 2012 +0200
@@ -7,7 +7,7 @@
 christos
 
 
-VENDOR	:	sun
+VENDOR	:	Sun
 MODELS	:	sun3, sun4, sun386i
 COMPILER:	cc, gcc, acc
 CFLAGS	:	normal
@@ -18,7 +18,7 @@
 NOTES	:	Don't compile with /usr/5bin/cc
 VERSION	:	6.08
 
-VENDOR	:	sun
+VENDOR	:	Sun
 MODELS	:	sun4, ultra
 COMPILER:	cc, gcc
 CFLAGS	:	normal
@@ -34,18 +34,29 @@
 	:	point failures of programs exec'ed from tcsh.
 VERSION	:	6.08
 
-VENDOR	:	sun
+VENDOR	:	Sun
 MODELS	:	ultra
 COMPILER:	WorkShop cc
 CFLAGS	:	normal
 LIBES	:	-lcurses -lsocket -lnsl
-OS	:	solaris 2.6
+OS	:	solaris 2.6, 2.7, 8
 CONFIG	:	sol26
 ENVIRON	:	n/a
 NOTES	:	none
 VERSION	:	6.08
 
-VENDOR	:	sun
+VENDOR	:	Sun
+MODELS	:	ultra, i686, x86_64
+COMPILER:	Sun Studio cc
+CFLAGS	:	normal
+LIBES	:	-lcurses -lsocket -lnsl
+OS	:	solaris 9, 10
+CONFIG	:	sol29
+ENVIRON	:	n/a
+NOTES	:	none
+VERSION	:	6.18
+
+VENDOR	:	Sun
 MODELS	:	i386
 COMPILER:	cc, gcc
 CFLAGS	:	-D__STDC__=0
@@ -56,7 +67,7 @@
 NOTES	:	n/a
 VERSION	:	6.04.13
 
-VENDOR	:	sun
+VENDOR	:	Sun
 MODELS	:	sun4
 COMPILER:	gcc
 CFLAGS	:	normal
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/README
--- a/head/contrib/tcsh/README	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/README	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-This is tcsh version 6.17.00.  Tcsh is a version of the Berkeley
+This is tcsh version 6.18.01.  Tcsh is a version of the Berkeley
 C-Shell, with the addition of: a command line editor, command and file
 name completion, listing, etc. and a bunch of small additions to the
 shell itself.
@@ -87,7 +87,7 @@
 
 10) Enjoy.
 
-12) PLEASE file any bug reports (and fixes), code for new features at:
+11) PLEASE file any bug reports (and fixes), code for new features at:
 
 	http://bugs.gw.com/
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/WishList
--- a/head/contrib/tcsh/WishList	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/WishList	Fri Mar 02 16:54:40 2012 +0200
@@ -52,17 +52,6 @@
    - bhooglan
      _________________________________________________________________
 
-   I'm a long-time faithful user of tcsh, and one thing has always bugged
-   me -- the need to type "rehash" at a prompt when adding a new command.
-   My  suggestions  is  to  change  tcsh  so before printing "Command not
-   found.",  it  first  searches  its  entire  path and rebuilds its hash
-   table.  Only  after doing this, and if the command is still not in the
-   path,  then  print  "Command  not  found.".  I  realize there are some
-   extreme  cases  in  which  this  is suboptimal, but in most cases with
-   normal  users  this  would  be  a big win, and simplify the manual and
-   perhaps even the code.
-     _________________________________________________________________
-
    Wish "tcsh -l" would accept other flags. At least "-c".
 
    Currently I can't get ssh to have the right environment unless it is a
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/complete.tcsh
--- a/head/contrib/tcsh/complete.tcsh	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/complete.tcsh	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,5 @@
 #
-# $tcsh: complete.tcsh,v 1.51 2007/10/01 21:51:59 christos Exp $
+# $tcsh: complete.tcsh,v 1.52 2010/05/07 17:54:13 christos Exp $
 # example file using the new completion code
 #
 # Debian GNU/Linux
@@ -636,7 +636,7 @@
     complete nmap	'n at -e@`ifconfig -l`@' 'p/*/$hostnames/'
     complete perldoc 	'n@*@`\ls -1 /usr/libdata/perl/5.*/pod | sed s%\\.pod.\*\$%%`@'
     complete postfix    'n/*/(start stop reload abort flush check)/'
-    complete postmap	'n/1/(hash: regexp:)' 'c/hash:/f/' 'c/regexp:/f/'
+    complete postmap	'n/1/(hash: regexp:)/' 'c/hash:/f/' 'c/regexp:/f/'
     complete rcsdiff	'p at 1@`\ls -1a RCS | sed -e "s/\(.*\),v/\1/"`@'
     complete X		'c/-/(I a ac allowMouseOpenFail allowNonLocalModInDev \
 			allowNonLocalXvidtune ar1 ar2 audit auth bestRefresh \
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/config.guess
--- a/head/contrib/tcsh/config.guess	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/config.guess	Fri Mar 02 16:54:40 2012 +0200
@@ -1,10 +1,10 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
 #   Free Software Foundation, Inc.
 
-timestamp='2009-06-10'
+timestamp='2009-12-30'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -27,16 +27,16 @@
 # the same distribution terms that you use for the rest of that program.
 
 
-# Originally written by Per Bothner <per at bothner.com>.
-# Please send patches to <config-patches at gnu.org>.  Submit a context
-# diff and a properly formatted ChangeLog entry.
+# Originally written by Per Bothner.  Please send patches (context
+# diff format) to <config-patches at gnu.org> and include a ChangeLog
+# entry.
 #
 # This script attempts to guess a canonical system name similar to
 # config.sub.  If it succeeds, it prints the system name on stdout, and
 # exits with 0.  Otherwise, it exits with 1.
 #
-# The plan is that this can be called by configure scripts if you
-# don't specify an explicit build system type.
+# You can get the latest version of this script from:
+# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
 
 me=`echo "$0" | sed -e 's,.*/,,'`
 
@@ -56,8 +56,9 @@
 GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
+Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -333,6 +334,9 @@
     sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
 	echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
 	exit ;;
+    i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
+	echo i386-pc-auroraux${UNAME_RELEASE}
+	exit ;;
     i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
 	eval $set_cc_for_build
 	SUN_ARCH="i386"
@@ -807,12 +811,12 @@
     i*:PW*:*)
 	echo ${UNAME_MACHINE}-pc-pw32
 	exit ;;
-    *:Interix*:[3456]*)
+    *:Interix*:*)
     	case ${UNAME_MACHINE} in
 	    x86)
 		echo i586-pc-interix${UNAME_RELEASE}
 		exit ;;
-	    EM64T | authenticamd | genuineintel)
+	    authenticamd | genuineintel | EM64T)
 		echo x86_64-unknown-interix${UNAME_RELEASE}
 		exit ;;
 	    IA64)
@@ -854,6 +858,20 @@
     i*86:Minix:*:*)
 	echo ${UNAME_MACHINE}-pc-minix
 	exit ;;
+    alpha:Linux:*:*)
+	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+	  EV5)   UNAME_MACHINE=alphaev5 ;;
+	  EV56)  UNAME_MACHINE=alphaev56 ;;
+	  PCA56) UNAME_MACHINE=alphapca56 ;;
+	  PCA57) UNAME_MACHINE=alphapca56 ;;
+	  EV6)   UNAME_MACHINE=alphaev6 ;;
+	  EV67)  UNAME_MACHINE=alphaev67 ;;
+	  EV68*) UNAME_MACHINE=alphaev68 ;;
+        esac
+	objdump --private-headers /bin/sh | grep -q ld.so.1
+	if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+	echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+	exit ;;
     arm*:Linux:*:*)
 	eval $set_cc_for_build
 	if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
@@ -876,6 +894,17 @@
     frv:Linux:*:*)
     	echo frv-unknown-linux-gnu
 	exit ;;
+    i*86:Linux:*:*)
+	LIBC=gnu
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+	#ifdef __dietlibc__
+	LIBC=dietlibc
+	#endif
+EOF
+	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
+	echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+	exit ;;
     ia64:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit ;;
@@ -901,39 +930,18 @@
 	#endif
 	#endif
 EOF
-	eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
-	    /^CPU/{
-		s: ::g
-		p
-	    }'`"
+	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
 	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
 	;;
     or32:Linux:*:*)
 	echo or32-unknown-linux-gnu
 	exit ;;
-    ppc:Linux:*:*)
-	echo powerpc-unknown-linux-gnu
-	exit ;;
-    ppc64:Linux:*:*)
-	echo powerpc64-unknown-linux-gnu
-	exit ;;
-    alpha:Linux:*:*)
-	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
-	  EV5)   UNAME_MACHINE=alphaev5 ;;
-	  EV56)  UNAME_MACHINE=alphaev56 ;;
-	  PCA56) UNAME_MACHINE=alphapca56 ;;
-	  PCA57) UNAME_MACHINE=alphapca56 ;;
-	  EV6)   UNAME_MACHINE=alphaev6 ;;
-	  EV67)  UNAME_MACHINE=alphaev67 ;;
-	  EV68*) UNAME_MACHINE=alphaev68 ;;
-        esac
-	objdump --private-headers /bin/sh | grep -q ld.so.1
-	if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
-	echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
-	exit ;;
     padre:Linux:*:*)
 	echo sparc-unknown-linux-gnu
 	exit ;;
+    parisc64:Linux:*:* | hppa64:Linux:*:*)
+	echo hppa64-unknown-linux-gnu
+	exit ;;
     parisc:Linux:*:* | hppa:Linux:*:*)
 	# Look for CPU level
 	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
@@ -942,8 +950,11 @@
 	  *)    echo hppa-unknown-linux-gnu ;;
 	esac
 	exit ;;
-    parisc64:Linux:*:* | hppa64:Linux:*:*)
-	echo hppa64-unknown-linux-gnu
+    ppc64:Linux:*:*)
+	echo powerpc64-unknown-linux-gnu
+	exit ;;
+    ppc:Linux:*:*)
+	echo powerpc-unknown-linux-gnu
 	exit ;;
     s390:Linux:*:* | s390x:Linux:*:*)
 	echo ${UNAME_MACHINE}-ibm-linux
@@ -966,58 +977,6 @@
     xtensa*:Linux:*:*)
     	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit ;;
-    i*86:Linux:*:*)
-	# The BFD linker knows what the default object file format is, so
-	# first see if it will tell us. cd to the root directory to prevent
-	# problems with other programs or directories called `ld' in the path.
-	# Set LC_ALL=C to ensure ld outputs messages in English.
-	ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
-			 | sed -ne '/supported targets:/!d
-				    s/[ 	][ 	]*/ /g
-				    s/.*supported targets: *//
-				    s/ .*//
-				    p'`
-        case "$ld_supported_targets" in
-	  elf32-i386)
-		TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
-		;;
-	esac
-	# Determine whether the default compiler is a.out or elf
-	eval $set_cc_for_build
-	sed 's/^	//' << EOF >$dummy.c
-	#include <features.h>
-	#ifdef __ELF__
-	# ifdef __GLIBC__
-	#  if __GLIBC__ >= 2
-	LIBC=gnu
-	#  else
-	LIBC=gnulibc1
-	#  endif
-	# else
-	LIBC=gnulibc1
-	# endif
-	#else
-	#if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
-	LIBC=gnu
-	#else
-	LIBC=gnuaout
-	#endif
-	#endif
-	#ifdef __dietlibc__
-	LIBC=dietlibc
-	#endif
-EOF
-	eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
-	    /^LIBC/{
-		s: ::g
-		p
-	    }'`"
-	test x"${LIBC}" != x && {
-		echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
-		exit
-	}
-	test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
-	;;
     i*86:DYNIX/ptx:4*:*)
 	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
 	# earlier versions are messed up and put the nodename in both
@@ -1247,6 +1206,16 @@
     *:Darwin:*:*)
 	UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
 	case $UNAME_PROCESSOR in
+	    i386)
+		eval $set_cc_for_build
+		if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+		  if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
+		      (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+		      grep IS_64BIT_ARCH >/dev/null
+		  then
+		      UNAME_PROCESSOR="x86_64"
+		  fi
+		fi ;;
 	    unknown) UNAME_PROCESSOR=powerpc ;;
 	esac
 	echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/config.h.in
--- a/head/contrib/tcsh/config.h.in	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/config.h.in	Fri Mar 02 16:54:40 2012 +0200
@@ -10,9 +10,6 @@
 /* Define to 1 if you have the <auth.h> header file. */
 #undef HAVE_AUTH_H
 
-/* Define to 1 if you have the `catgets' function. */
-#undef HAVE_CATGETS
-
 /* Define to 1 if you have the <crypt.h> header file. */
 #undef HAVE_CRYPT_H
 
@@ -39,6 +36,9 @@
 /* Define to 1 if you have the `dup2' function. */
 #undef HAVE_DUP2
 
+/* Define to 1 if you have the <features.h> header file. */
+#undef HAVE_FEATURES_H
+
 /* Define to 1 if you have the `getauthid' function. */
 #undef HAVE_GETAUTHID
 
@@ -54,7 +54,10 @@
 /* Define to 1 if you have the `getutent' function. */
 #undef HAVE_GETUTENT
 
-/* Define if you have the iconv() function. */
+/* Define to 1 if you have the `getutxent' function. */
+#undef HAVE_GETUTXENT
+
+/* Define if you have the iconv() function and it works. */
 #undef HAVE_ICONV
 
 /* Define to 1 if you have the <inttypes.h> header file. */
@@ -63,6 +66,9 @@
 /* Define to 1 if the system has the type `long long'. */
 #undef HAVE_LONG_LONG
 
+/* Define to 1 if you have the `mallinfo' function. */
+#undef HAVE_MALLINFO
+
 /* Define to 1 if mbrtowc and mbstate_t are properly declared. */
 #undef HAVE_MBRTOWC
 
@@ -75,6 +81,9 @@
 /* Define to 1 if you have the `memset' function. */
 #undef HAVE_MEMSET
 
+/* Define to 1 if you have the `mkstemp' function. */
+#undef HAVE_MKSTEMP
+
 /* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
 #undef HAVE_NDIR_H
 
@@ -84,6 +93,9 @@
 /* Define to 1 if you have the `nl_langinfo' function. */
 #undef HAVE_NL_LANGINFO
 
+/* Define to 1 if you have the <paths.h> header file. */
+#undef HAVE_PATHS_H
+
 /* Define to 1 if you have the `sbrk' function. */
 #undef HAVE_SBRK
 
@@ -118,22 +130,34 @@
 /* Define to 1 if you have the `strstr' function. */
 #undef HAVE_STRSTR
 
-/* Define to 1 if `d_ino' is member of `struct dirent'. */
+/* Define to 1 if `d_ino' is a member of `struct dirent'. */
 #undef HAVE_STRUCT_DIRENT_D_INO
 
-/* Define to 1 if `ss_family' is member of `struct sockaddr_storage'. */
+/* Define to 1 if `ss_family' is a member of `struct sockaddr_storage'. */
 #undef HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY
 
-/* Define to 1 if `ut_host' is member of `struct utmp'. */
+/* Define to 1 if `ut_host' is a member of `struct utmpx'. */
+#undef HAVE_STRUCT_UTMPX_UT_HOST
+
+/* Define to 1 if `ut_tv' is a member of `struct utmpx'. */
+#undef HAVE_STRUCT_UTMPX_UT_TV
+
+/* Define to 1 if `ut_user' is a member of `struct utmpx'. */
+#undef HAVE_STRUCT_UTMPX_UT_USER
+
+/* Define to 1 if `ut_xtime' is a member of `struct utmpx'. */
+#undef HAVE_STRUCT_UTMPX_UT_XTIME
+
+/* Define to 1 if `ut_host' is a member of `struct utmp'. */
 #undef HAVE_STRUCT_UTMP_UT_HOST
 
-/* Define to 1 if `ut_tv' is member of `struct utmp'. */
+/* Define to 1 if `ut_tv' is a member of `struct utmp'. */
 #undef HAVE_STRUCT_UTMP_UT_TV
 
-/* Define to 1 if `ut_user' is member of `struct utmp'. */
+/* Define to 1 if `ut_user' is a member of `struct utmp'. */
 #undef HAVE_STRUCT_UTMP_UT_USER
 
-/* Define to 1 if `ut_xtime' is member of `struct utmp'. */
+/* Define to 1 if `ut_xtime' is a member of `struct utmp'. */
 #undef HAVE_STRUCT_UTMP_UT_XTIME
 
 /* Define to 1 if you have the `sysconf' function. */
@@ -177,6 +201,9 @@
 /* Support NLS. */
 #undef NLS
 
+/* Support NLS catalogs. */
+#undef NLS_CATALOGS
+
 /* Define to the address where bug reports for this package should be sent. */
 #undef PACKAGE_BUGREPORT
 
@@ -189,6 +216,9 @@
 /* Define to the one symbol short name of this package. */
 #undef PACKAGE_TARNAME
 
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
 /* Define to the version of this package. */
 #undef PACKAGE_VERSION
 
@@ -204,6 +234,11 @@
 /* Define to 1 if you have the ANSI C header files. */
 #undef STDC_HEADERS
 
+/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
+   <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+   #define below would cause a syntax error. */
+#undef _UINT32_T
+
 /* Define to empty if `const' does not conform to ANSI C. */
 #undef const
 
@@ -225,6 +260,10 @@
 /* Define to `int' if <sys/types.h> doesn't define. */
 #undef uid_t
 
+/* Define to the type of an unsigned integer type of width exactly 32 bits if
+   such a type exists and the standard includes do not define it. */
+#undef uint32_t
+
 /* Define to empty if the keyword `volatile' does not work. Warning: valid
    code using `volatile' can become incorrect without. Disable with care. */
 #undef volatile
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/config.sub
--- a/head/contrib/tcsh/config.sub	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/config.sub	Fri Mar 02 16:54:40 2012 +0200
@@ -1,10 +1,10 @@
 #! /bin/sh
 # Configuration validation subroutine script.
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
 #   Free Software Foundation, Inc.
 
-timestamp='2009-06-11'
+timestamp='2009-12-31'
 
 # This file is (in principle) common to ALL GNU software.
 # The presence of a machine in this file suggests that SOME GNU software
@@ -32,13 +32,16 @@
 
 
 # Please send patches to <config-patches at gnu.org>.  Submit a context
-# diff and a properly formatted ChangeLog entry.
+# diff and a properly formatted GNU ChangeLog entry.
 #
 # Configuration subroutine to validate and canonicalize a configuration type.
 # Supply the specified configuration type as an argument.
 # If it is invalid, we print an error message on stderr and exit with code 1.
 # Otherwise, we print the canonical config type on stdout and succeed.
 
+# You can get the latest version of this script from:
+# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+
 # This file is supposed to be the same for all GNU packages
 # and recognize all the CPU types, system types and aliases
 # that are meaningful with *any* GNU software.
@@ -72,8 +75,9 @@
 version="\
 GNU config.sub ($timestamp)
 
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
+Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -149,7 +153,7 @@
 	-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
 	-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
 	-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-	-apple | -axis | -knuth | -cray)
+	-apple | -axis | -knuth | -cray | -microblaze)
 		os=
 		basic_machine=$1
 		;;
@@ -284,6 +288,7 @@
 	| pdp10 | pdp11 | pj | pjl \
 	| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
 	| pyramid \
+	| rx \
 	| score \
 	| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
 	| sh64 | sh64le \
@@ -291,13 +296,14 @@
 	| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
 	| spu | strongarm \
 	| tahoe | thumb | tic4x | tic80 | tron \
+	| ubicom32 \
 	| v850 | v850e \
 	| we32k \
 	| x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
 	| z8k | z80)
 		basic_machine=$basic_machine-unknown
 		;;
-	m6811 | m68hc11 | m6812 | m68hc12)
+	m6811 | m68hc11 | m6812 | m68hc12 | picochip)
 		# Motorola 68HC11/12.
 		basic_machine=$basic_machine-unknown
 		os=-none
@@ -340,7 +346,7 @@
 	| lm32-* \
 	| m32c-* | m32r-* | m32rle-* \
 	| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
-	| m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
+	| m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \
 	| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
 	| mips16-* \
 	| mips64-* | mips64el-* \
@@ -368,7 +374,7 @@
 	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
 	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
 	| pyramid-* \
-	| romp-* | rs6000-* \
+	| romp-* | rs6000-* | rx-* \
 	| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
 	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
 	| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
@@ -377,6 +383,7 @@
 	| tahoe-* | thumb-* \
 	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \
 	| tron-* \
+	| ubicom32-* \
 	| v850-* | v850e-* | vax-* \
 	| we32k-* \
 	| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
@@ -726,6 +733,9 @@
 		basic_machine=ns32k-utek
 		os=-sysv
 		;;
+        microblaze)
+		basic_machine=microblaze-xilinx
+		;;
 	mingw32)
 		basic_machine=i386-pc
 		os=-mingw32
@@ -1247,6 +1257,9 @@
         # First match some system type aliases
         # that might get confused with valid system types.
 	# -solaris* is a basic system type, with this one exception.
+        -auroraux)
+	        os=-auroraux
+		;;
 	-solaris1 | -solaris1.*)
 		os=`echo $os | sed -e 's|solaris1|sunos4|'`
 		;;
@@ -1268,8 +1281,8 @@
 	# -sysv* is not here because it comes later, after sysvr4.
 	-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
 	      | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
-	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
-	      | -kopensolaris* \
+	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
+	      | -sym* | -kopensolaris* \
 	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
 	      | -aos* | -aros* \
 	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
@@ -1290,7 +1303,7 @@
 	      | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
 	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
 	      | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
-	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops*)
+	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
 	# Remember, each alternative MUST END IN *, to match a version number.
 		;;
 	-qnx*)
@@ -1423,6 +1436,8 @@
 	-dicos*)
 		os=-dicos
 		;;
+        -nacl*)
+	        ;;
 	-none)
 		;;
 	*)
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/config/bsd4.4
--- a/head/contrib/tcsh/config/bsd4.4	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/config/bsd4.4	Fri Mar 02 16:54:40 2012 +0200
@@ -96,13 +96,8 @@
 #  define _PATH_TCSHELL "/usr/contrib/bin/tcsh"
 # endif
 
-# undef NLS_CATALOGS
-
 #elif defined(__APPLE__)
 # define SYSMALLOC
-
-#else
-# define NLS_CATALOGS
 #endif
 
 #endif /* _h_config */
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/config_f.h
--- a/head/contrib/tcsh/config_f.h	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/config_f.h	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/config_f.h,v 3.42 2009/06/25 12:10:56 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/config_f.h,v 3.47 2011/02/05 20:34:55 christos Exp $ */
 /*
  * config_f.h -- configure various defines for tcsh
  *
@@ -50,19 +50,11 @@
  * WIDE_STRINGS	Represent strings using wide characters
  *		Allows proper function in multibyte encodings like UTF-8
  */
-#if defined (SHORT_STRINGS) && defined (NLS) && SIZEOF_WCHAR_T >= 4 && defined (HAVE_MBRTOWC) && !defined (WINNT_NATIVE) && !defined(_OSD_POSIX)
+#if defined (SHORT_STRINGS) && defined (NLS) && !defined (WINNT_NATIVE) && !defined(_OSD_POSIX)
 # define WIDE_STRINGS
-#endif
-
-/*
- * NLS_CATALOGS:Use Native Language System catalogs for
- *		international messages.
- *		Routines like catopen() are needed
- *		if you don't have <nl_types.h>, you don't want
- *		to define this.
- */
-#if defined (NLS) && defined (HAVE_CATGETS)
-# define NLS_CATALOGS
+# if SIZEOF_WCHAR_T < 4
+#  define UTF16_STRINGS
+# endif
 #endif
 
 /*
@@ -143,7 +135,7 @@
  *		This can be much slower and no memory statistics will be
  *		provided.
  */
-#if defined(__MACHTEN__) || defined(PURIFY) || defined(MALLOC_TRACE) || defined(_OSD_POSIX) || defined(__MVS__)
+#if defined(__MACHTEN__) || defined(PURIFY) || defined(MALLOC_TRACE) || defined(_OSD_POSIX) || defined(__MVS__) || defined (__CYGWIN__) || defined(__GLIBC__)
 # define SYSMALLOC
 #else
 # undef SYSMALLOC
@@ -197,10 +189,6 @@
 
 /* Consistency checks */
 #ifdef WIDE_STRINGS
-# if SIZEOF_WCHAR_T < 4
-    #error "wchar_t must be at least 4 bytes for WIDE_STRINGS"
-# endif
-
 # ifdef WINNT_NATIVE
     #error "WIDE_STRINGS cannot be used together with WINNT_NATIVE"
 # endif
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/configure
--- a/head/contrib/tcsh/configure	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/configure	Fri Mar 02 16:54:40 2012 +0200
@@ -1,62 +1,85 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.61 for tcsh 6.17.00.
+# Generated by GNU Autoconf 2.68 for tcsh 6.18.01.
 #
 # Report bugs to <http://bugs.gw.com/>.
 #
+#
 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
+# Foundation, Inc.
+#
+#
 # This configure script is free software; the Free Software Foundation
 # gives unlimited permission to copy, distribute and modify it.
-## --------------------- ##
-## M4sh Initialization.  ##
-## --------------------- ##
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
 
 # Be more Bourne compatible
 DUALCASE=1; export DUALCASE # for MKS sh
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
   emulate sh
   NULLCMD=:
-  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
   # is contrary to our usage.  Disable this feature.
   alias -g '${1+"$@"}'='"$@"'
   setopt NO_GLOB_SUBST
 else
-  case `(set -o) 2>/dev/null` in
-  *posix*) set -o posix ;;
+  case `(set -o) 2>/dev/null` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
 esac
-
-fi
-
-
-
-
-# PATH needs CR
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='print -r --'
+  as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='printf %s\n'
+  as_echo_n='printf %s'
+else
+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+    as_echo_n='/usr/ucb/echo -n'
+  else
+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+    as_echo_n_body='eval
+      arg=$1;
+      case $arg in #(
+      *"$as_nl"*)
+	expr "X$arg" : "X\\(.*\\)$as_nl";
+	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+      esac;
+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+    '
+    export as_echo_n_body
+    as_echo_n='sh -c $as_echo_n_body as_echo'
+  fi
+  export as_echo_body
+  as_echo='sh -c $as_echo_body as_echo'
+fi
 
 # The user is always right.
 if test "${PATH_SEPARATOR+set}" != set; then
-  echo "#! /bin/sh" >conf$$.sh
-  echo  "exit 0"   >>conf$$.sh
-  chmod +x conf$$.sh
-  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
-    PATH_SEPARATOR=';'
-  else
-    PATH_SEPARATOR=:
-  fi
-  rm -f conf$$.sh
-fi
-
-# Support unset when possible.
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
-  as_unset=unset
-else
-  as_unset=false
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
 fi
 
 
@@ -65,20 +88,19 @@
 # there to prevent editors from complaining about space-tab.
 # (If _AS_PATH_WALK were called with IFS unset, it would disable word
 # splitting by setting IFS to empty value.)
-as_nl='
-'
 IFS=" ""	$as_nl"
 
 # Find who we are.  Look in the path if we contain no directory separator.
-case $0 in
+as_myself=
+case $0 in #((
   *[\\/]* ) as_myself=$0 ;;
   *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-  test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-done
+    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+  done
 IFS=$as_save_IFS
 
      ;;
@@ -89,32 +111,278 @@
   as_myself=$0
 fi
 if test ! -f "$as_myself"; then
-  echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
-  { (exit 1); exit 1; }
-fi
-
-# Work around bugs in pre-3.0 UWIN ksh.
-for as_var in ENV MAIL MAILPATH
-do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there.  '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
 done
 PS1='$ '
 PS2='> '
 PS4='+ '
 
 # NLS nuisances.
-for as_var in \
-  LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
-  LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
-  LC_TELEPHONE LC_TIME
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+if test "x$CONFIG_SHELL" = x; then
+  as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '\${1+\"\$@\"}'='\"\$@\"'
+  setopt NO_GLOB_SUBST
+else
+  case \`(set -o) 2>/dev/null\` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+"
+  as_required="as_fn_return () { (exit \$1); }
+as_fn_success () { as_fn_return 0; }
+as_fn_failure () { as_fn_return 1; }
+as_fn_ret_success () { return 0; }
+as_fn_ret_failure () { return 1; }
+
+exitcode=0
+as_fn_success || { exitcode=1; echo as_fn_success failed.; }
+as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
+as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
+as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
+if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
+
+else
+  exitcode=1; echo positional parameters were not saved.
+fi
+test x\$exitcode = x0 || exit 1"
+  as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
+  as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
+  eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
+  test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
+test \$(( 1 + 1 )) = 2 || exit 1"
+  if (eval "$as_required") 2>/dev/null; then :
+  as_have_required=yes
+else
+  as_have_required=no
+fi
+  if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
+
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+as_found=false
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
 do
-  if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
-    eval $as_var=C; export $as_var
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  as_found=:
+  case $as_dir in #(
+	 /*)
+	   for as_base in sh bash ksh sh5; do
+	     # Try only shells that exist, to save several forks.
+	     as_shell=$as_dir/$as_base
+	     if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
+		    { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
+  CONFIG_SHELL=$as_shell as_have_required=yes
+		   if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
+  break 2
+fi
+fi
+	   done;;
+       esac
+  as_found=false
+done
+$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
+	      { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
+  CONFIG_SHELL=$SHELL as_have_required=yes
+fi; }
+IFS=$as_save_IFS
+
+
+      if test "x$CONFIG_SHELL" != x; then :
+  # We cannot yet assume a decent shell, so we have to provide a
+	# neutralization value for shells without unset; and this also
+	# works around shells that cannot unset nonexistent variables.
+	# Preserve -v and -x to the replacement shell.
+	BASH_ENV=/dev/null
+	ENV=/dev/null
+	(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+	export CONFIG_SHELL
+	case $- in # ((((
+	  *v*x* | *x*v* ) as_opts=-vx ;;
+	  *v* ) as_opts=-v ;;
+	  *x* ) as_opts=-x ;;
+	  * ) as_opts= ;;
+	esac
+	exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"}
+fi
+
+    if test x$as_have_required = xno; then :
+  $as_echo "$0: This script requires a shell more modern than all"
+  $as_echo "$0: the shells that I found on your system."
+  if test x${ZSH_VERSION+set} = xset ; then
+    $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
+    $as_echo "$0: be upgraded to zsh 4.3.4 or later."
   else
-    ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+    $as_echo "$0: Please tell bug-autoconf at gnu.org and
+$0: http://bugs.gw.com/ about your system, including any
+$0: error possibly output before this message. Then install
+$0: a modern shell, or manually run the script under such a
+$0: shell if you do have one."
   fi
-done
-
-# Required to use basename.
+  exit 1
+fi
+fi
+fi
+SHELL=${CONFIG_SHELL-/bin/sh}
+export SHELL
+# Unset more variables known to interfere with behavior of common tools.
+CLICOLOR_FORCE= GREP_OPTIONS=
+unset CLICOLOR_FORCE GREP_OPTIONS
+
+## --------------------- ##
+## M4sh Shell Functions. ##
+## --------------------- ##
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+  { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+  return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+  set +e
+  as_fn_set_status $1
+  exit $1
+} # as_fn_exit
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || eval $as_mkdir_p || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$as_dir" : 'X\(//\)[^/]' \| \
+	 X"$as_dir" : 'X\(//\)$' \| \
+	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+  eval 'as_fn_append ()
+  {
+    eval $1+=\$2
+  }'
+else
+  as_fn_append ()
+  {
+    eval $1=\$$1\$2
+  }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+  eval 'as_fn_arith ()
+  {
+    as_val=$(( $* ))
+  }'
+else
+  as_fn_arith ()
+  {
+    as_val=`expr "$@" || test $? -eq 1`
+  }
+fi # as_fn_arith
+
+
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with STATUS, using 1 if that was 0.
+as_fn_error ()
+{
+  as_status=$1; test $as_status -eq 0 && as_status=1
+  if test "$4"; then
+    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+  fi
+  $as_echo "$as_me: error: $2" >&2
+  as_fn_exit $as_status
+} # as_fn_error
+
 if expr a : '\(a\)' >/dev/null 2>&1 &&
    test "X`expr 00001 : '.*\(...\)'`" = X001; then
   as_expr=expr
@@ -128,13 +396,17 @@
   as_basename=false
 fi
 
-
-# Name of the executable.
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
 as_me=`$as_basename -- "$0" ||
 $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
 	 X"$0" : 'X\(//\)$' \| \
 	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
-echo X/"$0" |
+$as_echo X/"$0" |
     sed '/^.*\/\([^/][^/]*\)\/*$/{
 	    s//\1/
 	    q
@@ -149,294 +421,19 @@
 	  }
 	  s/.*/./; q'`
 
-# CDPATH.
-$as_unset CDPATH
-
-
-if test "x$CONFIG_SHELL" = x; then
-  if (eval ":") 2>/dev/null; then
-  as_have_required=yes
-else
-  as_have_required=no
-fi
-
-  if test $as_have_required = yes && 	 (eval ":
-(as_func_return () {
-  (exit \$1)
-}
-as_func_success () {
-  as_func_return 0
-}
-as_func_failure () {
-  as_func_return 1
-}
-as_func_ret_success () {
-  return 0
-}
-as_func_ret_failure () {
-  return 1
-}
-
-exitcode=0
-if as_func_success; then
-  :
-else
-  exitcode=1
-  echo as_func_success failed.
-fi
-
-if as_func_failure; then
-  exitcode=1
-  echo as_func_failure succeeded.
-fi
-
-if as_func_ret_success; then
-  :
-else
-  exitcode=1
-  echo as_func_ret_success failed.
-fi
-
-if as_func_ret_failure; then
-  exitcode=1
-  echo as_func_ret_failure succeeded.
-fi
-
-if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
-  :
-else
-  exitcode=1
-  echo positional parameters were not saved.
-fi
-
-test \$exitcode = 0) || { (exit 1); exit 1; }
-
-(
-  as_lineno_1=\$LINENO
-  as_lineno_2=\$LINENO
-  test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" &&
-  test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; }
-") 2> /dev/null; then
-  :
-else
-  as_candidate_shells=
-    as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  case $as_dir in
-	 /*)
-	   for as_base in sh bash ksh sh5; do
-	     as_candidate_shells="$as_candidate_shells $as_dir/$as_base"
-	   done;;
-       esac
-done
-IFS=$as_save_IFS
-
-
-      for as_shell in $as_candidate_shells $SHELL; do
-	 # Try only shells that exist, to save several forks.
-	 if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
-		{ ("$as_shell") 2> /dev/null <<\_ASEOF
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
-  emulate sh
-  NULLCMD=:
-  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
-  # is contrary to our usage.  Disable this feature.
-  alias -g '${1+"$@"}'='"$@"'
-  setopt NO_GLOB_SUBST
-else
-  case `(set -o) 2>/dev/null` in
-  *posix*) set -o posix ;;
-esac
-
-fi
-
-
-:
-_ASEOF
-}; then
-  CONFIG_SHELL=$as_shell
-	       as_have_required=yes
-	       if { "$as_shell" 2> /dev/null <<\_ASEOF
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
-  emulate sh
-  NULLCMD=:
-  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
-  # is contrary to our usage.  Disable this feature.
-  alias -g '${1+"$@"}'='"$@"'
-  setopt NO_GLOB_SUBST
-else
-  case `(set -o) 2>/dev/null` in
-  *posix*) set -o posix ;;
-esac
-
-fi
-
-
-:
-(as_func_return () {
-  (exit $1)
-}
-as_func_success () {
-  as_func_return 0
-}
-as_func_failure () {
-  as_func_return 1
-}
-as_func_ret_success () {
-  return 0
-}
-as_func_ret_failure () {
-  return 1
-}
-
-exitcode=0
-if as_func_success; then
-  :
-else
-  exitcode=1
-  echo as_func_success failed.
-fi
-
-if as_func_failure; then
-  exitcode=1
-  echo as_func_failure succeeded.
-fi
-
-if as_func_ret_success; then
-  :
-else
-  exitcode=1
-  echo as_func_ret_success failed.
-fi
-
-if as_func_ret_failure; then
-  exitcode=1
-  echo as_func_ret_failure succeeded.
-fi
-
-if ( set x; as_func_ret_success y && test x = "$1" ); then
-  :
-else
-  exitcode=1
-  echo positional parameters were not saved.
-fi
-
-test $exitcode = 0) || { (exit 1); exit 1; }
-
-(
-  as_lineno_1=$LINENO
-  as_lineno_2=$LINENO
-  test "x$as_lineno_1" != "x$as_lineno_2" &&
-  test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; }
-
-_ASEOF
-}; then
-  break
-fi
-
-fi
-
-      done
-
-      if test "x$CONFIG_SHELL" != x; then
-  for as_var in BASH_ENV ENV
-        do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
-        done
-        export CONFIG_SHELL
-        exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
-fi
-
-
-    if test $as_have_required = no; then
-  echo This script requires a shell more modern than all the
-      echo shells that I found on your system.  Please install a
-      echo modern shell, or manually run the script under such a
-      echo shell if you do have one.
-      { (exit 1); exit 1; }
-fi
-
-
-fi
-
-fi
-
-
-
-(eval "as_func_return () {
-  (exit \$1)
-}
-as_func_success () {
-  as_func_return 0
-}
-as_func_failure () {
-  as_func_return 1
-}
-as_func_ret_success () {
-  return 0
-}
-as_func_ret_failure () {
-  return 1
-}
-
-exitcode=0
-if as_func_success; then
-  :
-else
-  exitcode=1
-  echo as_func_success failed.
-fi
-
-if as_func_failure; then
-  exitcode=1
-  echo as_func_failure succeeded.
-fi
-
-if as_func_ret_success; then
-  :
-else
-  exitcode=1
-  echo as_func_ret_success failed.
-fi
-
-if as_func_ret_failure; then
-  exitcode=1
-  echo as_func_ret_failure succeeded.
-fi
-
-if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
-  :
-else
-  exitcode=1
-  echo positional parameters were not saved.
-fi
-
-test \$exitcode = 0") || {
-  echo No shell found that supports shell functions.
-  echo Please tell autoconf at gnu.org about your system,
-  echo including any error possibly output before this
-  echo message
-}
-
-
-
-  as_lineno_1=$LINENO
-  as_lineno_2=$LINENO
-  test "x$as_lineno_1" != "x$as_lineno_2" &&
-  test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
-
-  # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
-  # uniformly replaced by the line number.  The first 'sed' inserts a
-  # line-number line after each line using $LINENO; the second 'sed'
-  # does the real work.  The second script uses 'N' to pair each
-  # line-number line with the line containing $LINENO, and appends
-  # trailing '-' during substitution so that $LINENO is not a special
-  # case at line end.
-  # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
-  # scripts with optimization help from Paolo Bonzini.  Blame Lee
-  # E. McMahon (1931-1989) for sed's syntax.  :-)
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+
+  as_lineno_1=$LINENO as_lineno_1a=$LINENO
+  as_lineno_2=$LINENO as_lineno_2a=$LINENO
+  eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
+  test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
+  # Blame Lee E. McMahon (1931-1989) for sed's syntax.  :-)
   sed -n '
     p
     /[$]LINENO/=
@@ -453,8 +450,7 @@
       s/-\n.*//
     ' >$as_me.lineno &&
   chmod +x "$as_me.lineno" ||
-    { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
-   { (exit 1); exit 1; }; }
+    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
 
   # Don't try to exec as it changes $[0], causing all sort of problems
   # (the dirname of $[0] is not the place where we might find the
@@ -464,49 +460,40 @@
   exit
 }
 
-
-if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
-  as_dirname=dirname
-else
-  as_dirname=false
-fi
-
 ECHO_C= ECHO_N= ECHO_T=
-case `echo -n x` in
+case `echo -n x` in #(((((
 -n*)
-  case `echo 'x\c'` in
+  case `echo 'xy\c'` in
   *c*) ECHO_T='	';;	# ECHO_T is single tab character.
-  *)   ECHO_C='\c';;
+  xy)  ECHO_C='\c';;
+  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
+       ECHO_T='	';;
   esac;;
 *)
   ECHO_N='-n';;
 esac
 
-if expr a : '\(a\)' >/dev/null 2>&1 &&
-   test "X`expr 00001 : '.*\(...\)'`" = X001; then
-  as_expr=expr
-else
-  as_expr=false
-fi
-
 rm -f conf$$ conf$$.exe conf$$.file
 if test -d conf$$.dir; then
   rm -f conf$$.dir/conf$$.file
 else
   rm -f conf$$.dir
-  mkdir conf$$.dir
-fi
-echo >conf$$.file
-if ln -s conf$$.file conf$$ 2>/dev/null; then
-  as_ln_s='ln -s'
-  # ... but there are two gotchas:
-  # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
-  # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-  # In both cases, we have to default to `cp -p'.
-  ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+  mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+  if ln -s conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s='ln -s'
+    # ... but there are two gotchas:
+    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+    # In both cases, we have to default to `cp -p'.
+    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+      as_ln_s='cp -p'
+  elif ln conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s=ln
+  else
     as_ln_s='cp -p'
-elif ln conf$$.file conf$$ 2>/dev/null; then
-  as_ln_s=ln
+  fi
 else
   as_ln_s='cp -p'
 fi
@@ -514,7 +501,7 @@
 rmdir conf$$.dir 2>/dev/null
 
 if mkdir -p . 2>/dev/null; then
-  as_mkdir_p=:
+  as_mkdir_p='mkdir -p "$as_dir"'
 else
   test -d ./-p && rmdir ./-p
   as_mkdir_p=false
@@ -531,12 +518,12 @@
   as_test_x='
     eval sh -c '\''
       if test -d "$1"; then
-        test -d "$1/.";
+	test -d "$1/.";
       else
-	case $1 in
-        -*)set "./$1";;
+	case $1 in #(
+	-*)set "./$1";;
 	esac;
-	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
+	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
 	???[sx]*):;;*)false;;esac;fi
     '\'' sh
   '
@@ -550,11 +537,11 @@
 as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
 
 
-
-exec 7<&0 </dev/null 6>&1
+test -n "$DJDIR" || exec 7<&0 </dev/null
+exec 6>&1
 
 # Name of the host.
-# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
+# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
 # so uname gets run too.
 ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
 
@@ -569,14 +556,14 @@
 subdirs=
 MFLAGS=
 MAKEFLAGS=
-SHELL=${CONFIG_SHELL-/bin/sh}
 
 # Identity of this package.
 PACKAGE_NAME='tcsh'
 PACKAGE_TARNAME='tcsh'
-PACKAGE_VERSION='6.17.00'
-PACKAGE_STRING='tcsh 6.17.00'
+PACKAGE_VERSION='6.18.01'
+PACKAGE_STRING='tcsh 6.18.01'
 PACKAGE_BUGREPORT='http://bugs.gw.com/'
+PACKAGE_URL=''
 
 ac_unique_file="tc.vers.c"
 # Factoring default headers for most tests.
@@ -615,69 +602,85 @@
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL
+ac_subst_vars='LTLIBOBJS
+LIBOBJS
+BUILD_CATALOGS
+HESLIB
+HESDEF
+DFLAGS
+LTLIBICONV
+LIBICONV
+CC_FOR_GETHOST
+GENCAT
+EGREP
+GREP
+CPP
+OBJEXT
+EXEEXT
+ac_ct_CC
+CPPFLAGS
+LDFLAGS
+CFLAGS
+CC
+host_os
+host_vendor
+host_cpu
+host
+build_os
+build_vendor
+build_cpu
+build
+INSTALL_DATA
+INSTALL_SCRIPT
+INSTALL_PROGRAM
+target_alias
+host_alias
+build_alias
+LIBS
+ECHO_T
+ECHO_N
+ECHO_C
+DEFS
+mandir
+localedir
+libdir
+psdir
+pdfdir
+dvidir
+htmldir
+infodir
+docdir
+oldincludedir
+includedir
+localstatedir
+sharedstatedir
+sysconfdir
+datadir
+datarootdir
+libexecdir
+sbindir
+bindir
+program_transform_name
+prefix
+exec_prefix
+PACKAGE_URL
+PACKAGE_BUGREPORT
+PACKAGE_STRING
+PACKAGE_VERSION
+PACKAGE_TARNAME
+PACKAGE_NAME
 PATH_SEPARATOR
-PACKAGE_NAME
-PACKAGE_TARNAME
-PACKAGE_VERSION
-PACKAGE_STRING
-PACKAGE_BUGREPORT
-exec_prefix
-prefix
-program_transform_name
-bindir
-sbindir
-libexecdir
-datarootdir
-datadir
-sysconfdir
-sharedstatedir
-localstatedir
-includedir
-oldincludedir
-docdir
-infodir
-htmldir
-dvidir
-pdfdir
-psdir
-libdir
-localedir
-mandir
-DEFS
-ECHO_C
-ECHO_N
-ECHO_T
-LIBS
-build_alias
-host_alias
-target_alias
-build
-build_cpu
-build_vendor
-build_os
-host
-host_cpu
-host_vendor
-host_os
-CC
-CFLAGS
-LDFLAGS
-CPPFLAGS
-ac_ct_CC
-EXEEXT
-OBJEXT
-CPP
-GREP
-EGREP
-LIBICONV
-LTLIBICONV
-DFLAGS
-HESDEF
-HESLIB
-LIBOBJS
-LTLIBOBJS'
+SHELL'
 ac_subst_files=''
+ac_user_opts='
+enable_option_checking
+with_gnu_ld
+enable_rpath
+with_libiconv_prefix
+enable_nls
+enable_nls_catalogs
+with_hesiod
+'
       ac_precious_vars='build_alias
 host_alias
 target_alias
@@ -692,6 +695,8 @@
 # Initialize some variables set by options.
 ac_init_help=
 ac_init_version=false
+ac_unrecognized_opts=
+ac_unrecognized_sep=
 # The variables have the same names as the options, with
 # dashes changed to underlines.
 cache_file=/dev/null
@@ -747,8 +752,9 @@
   fi
 
   case $ac_option in
-  *=*)	ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
-  *)	ac_optarg=yes ;;
+  *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+  *=)   ac_optarg= ;;
+  *)    ac_optarg=yes ;;
   esac
 
   # Accept the important Cygnus configure options, so we can diagnose typos.
@@ -790,13 +796,20 @@
     datarootdir=$ac_optarg ;;
 
   -disable-* | --disable-*)
-    ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+    ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
     # Reject names that are not valid shell variable names.
-    expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null &&
-      { echo "$as_me: error: invalid feature name: $ac_feature" >&2
-   { (exit 1); exit 1; }; }
-    ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'`
-    eval enable_$ac_feature=no ;;
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error $? "invalid feature name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"enable_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
+	 ac_unrecognized_sep=', ';;
+    esac
+    eval enable_$ac_useropt=no ;;
 
   -docdir | --docdir | --docdi | --doc | --do)
     ac_prev=docdir ;;
@@ -809,13 +822,20 @@
     dvidir=$ac_optarg ;;
 
   -enable-* | --enable-*)
-    ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+    ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
     # Reject names that are not valid shell variable names.
-    expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null &&
-      { echo "$as_me: error: invalid feature name: $ac_feature" >&2
-   { (exit 1); exit 1; }; }
-    ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'`
-    eval enable_$ac_feature=\$ac_optarg ;;
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error $? "invalid feature name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"enable_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
+	 ac_unrecognized_sep=', ';;
+    esac
+    eval enable_$ac_useropt=\$ac_optarg ;;
 
   -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
   | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
@@ -1006,22 +1026,36 @@
     ac_init_version=: ;;
 
   -with-* | --with-*)
-    ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+    ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
     # Reject names that are not valid shell variable names.
-    expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null &&
-      { echo "$as_me: error: invalid package name: $ac_package" >&2
-   { (exit 1); exit 1; }; }
-    ac_package=`echo $ac_package | sed 's/[-.]/_/g'`
-    eval with_$ac_package=\$ac_optarg ;;
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error $? "invalid package name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"with_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
+	 ac_unrecognized_sep=', ';;
+    esac
+    eval with_$ac_useropt=\$ac_optarg ;;
 
   -without-* | --without-*)
-    ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+    ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
     # Reject names that are not valid shell variable names.
-    expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null &&
-      { echo "$as_me: error: invalid package name: $ac_package" >&2
-   { (exit 1); exit 1; }; }
-    ac_package=`echo $ac_package | sed 's/[-.]/_/g'`
-    eval with_$ac_package=no ;;
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error $? "invalid package name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"with_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
+	 ac_unrecognized_sep=', ';;
+    esac
+    eval with_$ac_useropt=no ;;
 
   --x)
     # Obsolete; use --with-x.
@@ -1041,26 +1075,26 @@
   | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
     x_libraries=$ac_optarg ;;
 
-  -*) { echo "$as_me: error: unrecognized option: $ac_option
-Try \`$0 --help' for more information." >&2
-   { (exit 1); exit 1; }; }
+  -*) as_fn_error $? "unrecognized option: \`$ac_option'
+Try \`$0 --help' for more information"
     ;;
 
   *=*)
     ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
     # Reject names that are not valid shell variable names.
-    expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
-      { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
-   { (exit 1); exit 1; }; }
+    case $ac_envvar in #(
+      '' | [0-9]* | *[!_$as_cr_alnum]* )
+      as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
+    esac
     eval $ac_envvar=\$ac_optarg
     export $ac_envvar ;;
 
   *)
     # FIXME: should be removed in autoconf 3.0.
-    echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+    $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
     expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
-      echo "$as_me: WARNING: invalid host type: $ac_option" >&2
-    : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+      $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+    : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
     ;;
 
   esac
@@ -1068,23 +1102,36 @@
 
 if test -n "$ac_prev"; then
   ac_option=--`echo $ac_prev | sed 's/_/-/g'`
-  { echo "$as_me: error: missing argument to $ac_option" >&2
-   { (exit 1); exit 1; }; }
-fi
-
-# Be sure to have absolute directory names.
+  as_fn_error $? "missing argument to $ac_option"
+fi
+
+if test -n "$ac_unrecognized_opts"; then
+  case $enable_option_checking in
+    no) ;;
+    fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
+    *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
+  esac
+fi
+
+# Check all directory arguments for consistency.
 for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
 		datadir sysconfdir sharedstatedir localstatedir includedir \
 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
 		libdir localedir mandir
 do
   eval ac_val=\$$ac_var
+  # Remove trailing slashes.
+  case $ac_val in
+    */ )
+      ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
+      eval $ac_var=\$ac_val;;
+  esac
+  # Be sure to have absolute directory names.
   case $ac_val in
     [\\/$]* | ?:[\\/]* )  continue;;
     NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
   esac
-  { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
-   { (exit 1); exit 1; }; }
+  as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
 done
 
 # There might be people who depend on the old broken behavior: `$host'
@@ -1098,8 +1145,8 @@
 if test "x$host_alias" != x; then
   if test "x$build_alias" = x; then
     cross_compiling=maybe
-    echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
-    If a cross compiler is detected then cross compile mode will be used." >&2
+    $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
+    If a cross compiler is detected then cross compile mode will be used" >&2
   elif test "x$build_alias" != "x$host_alias"; then
     cross_compiling=yes
   fi
@@ -1114,23 +1161,21 @@
 ac_pwd=`pwd` && test -n "$ac_pwd" &&
 ac_ls_di=`ls -di .` &&
 ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
-  { echo "$as_me: error: Working directory cannot be determined" >&2
-   { (exit 1); exit 1; }; }
+  as_fn_error $? "working directory cannot be determined"
 test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
-  { echo "$as_me: error: pwd does not report name of working directory" >&2
-   { (exit 1); exit 1; }; }
+  as_fn_error $? "pwd does not report name of working directory"
 
 
 # Find the source files, if location was not specified.
 if test -z "$srcdir"; then
   ac_srcdir_defaulted=yes
   # Try the directory containing this script, then the parent directory.
-  ac_confdir=`$as_dirname -- "$0" ||
-$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$0" : 'X\(//\)[^/]' \| \
-	 X"$0" : 'X\(//\)$' \| \
-	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
-echo X"$0" |
+  ac_confdir=`$as_dirname -- "$as_myself" ||
+$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$as_myself" : 'X\(//\)[^/]' \| \
+	 X"$as_myself" : 'X\(//\)$' \| \
+	 X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_myself" |
     sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
 	    s//\1/
 	    q
@@ -1157,13 +1202,11 @@
 fi
 if test ! -r "$srcdir/$ac_unique_file"; then
   test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
-  { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
-   { (exit 1); exit 1; }; }
+  as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
 fi
 ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
 ac_abs_confdir=`(
-	cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2
-   { (exit 1); exit 1; }; }
+	cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
 	pwd)`
 # When building in place, set srcdir=.
 if test "$ac_abs_confdir" = "$ac_pwd"; then
@@ -1189,7 +1232,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures tcsh 6.17.00 to adapt to many kinds of systems.
+\`configure' configures tcsh 6.18.01 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1203,7 +1246,7 @@
       --help=short        display options specific to this package
       --help=recursive    display the short help of all the included packages
   -V, --version           display version information and exit
-  -q, --quiet, --silent   do not print \`checking...' messages
+  -q, --quiet, --silent   do not print \`checking ...' messages
       --cache-file=FILE   cache test results in FILE [disabled]
   -C, --config-cache      alias for \`--cache-file=config.cache'
   -n, --no-create         do not create output files
@@ -1211,9 +1254,9 @@
 
 Installation directories:
   --prefix=PREFIX         install architecture-independent files in PREFIX
-			  [$ac_default_prefix]
+                          [$ac_default_prefix]
   --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
-			  [PREFIX]
+                          [PREFIX]
 
 By default, \`make install' will install all the files in
 \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc.  You can specify
@@ -1223,25 +1266,25 @@
 For better control, use the options below.
 
 Fine tuning of the installation directories:
-  --bindir=DIR           user executables [EPREFIX/bin]
-  --sbindir=DIR          system admin executables [EPREFIX/sbin]
-  --libexecdir=DIR       program executables [EPREFIX/libexec]
-  --sysconfdir=DIR       read-only single-machine data [PREFIX/etc]
-  --sharedstatedir=DIR   modifiable architecture-independent data [PREFIX/com]
-  --localstatedir=DIR    modifiable single-machine data [PREFIX/var]
-  --libdir=DIR           object code libraries [EPREFIX/lib]
-  --includedir=DIR       C header files [PREFIX/include]
-  --oldincludedir=DIR    C header files for non-gcc [/usr/include]
-  --datarootdir=DIR      read-only arch.-independent data root [PREFIX/share]
-  --datadir=DIR          read-only architecture-independent data [DATAROOTDIR]
-  --infodir=DIR          info documentation [DATAROOTDIR/info]
-  --localedir=DIR        locale-dependent data [DATAROOTDIR/locale]
-  --mandir=DIR           man documentation [DATAROOTDIR/man]
-  --docdir=DIR           documentation root [DATAROOTDIR/doc/tcsh]
-  --htmldir=DIR          html documentation [DOCDIR]
-  --dvidir=DIR           dvi documentation [DOCDIR]
-  --pdfdir=DIR           pdf documentation [DOCDIR]
-  --psdir=DIR            ps documentation [DOCDIR]
+  --bindir=DIR            user executables [EPREFIX/bin]
+  --sbindir=DIR           system admin executables [EPREFIX/sbin]
+  --libexecdir=DIR        program executables [EPREFIX/libexec]
+  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
+  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
+  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --libdir=DIR            object code libraries [EPREFIX/lib]
+  --includedir=DIR        C header files [PREFIX/include]
+  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
+  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
+  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
+  --infodir=DIR           info documentation [DATAROOTDIR/info]
+  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
+  --mandir=DIR            man documentation [DATAROOTDIR/man]
+  --docdir=DIR            documentation root [DATAROOTDIR/doc/tcsh]
+  --htmldir=DIR           html documentation [DOCDIR]
+  --dvidir=DIR            dvi documentation [DOCDIR]
+  --pdfdir=DIR            pdf documentation [DOCDIR]
+  --psdir=DIR             ps documentation [DOCDIR]
 _ACEOF
 
   cat <<\_ACEOF
@@ -1254,15 +1297,17 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of tcsh 6.17.00:";;
+     short | recursive ) echo "Configuration of tcsh 6.18.01:";;
    esac
   cat <<\_ACEOF
 
 Optional Features:
+  --disable-option-checking  ignore unrecognized --enable/--with options
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
   --disable-rpath         do not hardcode runtime library paths
   --disable-nls           Disable NLS support
+  --disable-nls-catalogs  Disable NLS catalog support
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -1278,7 +1323,7 @@
   LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
               nonstandard directory <lib dir>
   LIBS        libraries to pass to the linker, e.g. -l<library>
-  CPPFLAGS    C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
+  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
               you have headers in a nonstandard directory <include dir>
   CPP         C preprocessor
 
@@ -1293,15 +1338,17 @@
 if test "$ac_init_help" = "recursive"; then
   # If there are subdirs, report their specific --help.
   for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
-    test -d "$ac_dir" || continue
+    test -d "$ac_dir" ||
+      { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
+      continue
     ac_builddir=.
 
 case "$ac_dir" in
 .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
 *)
-  ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
   # A ".." for each directory in $ac_dir_suffix.
-  ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'`
+  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
   case $ac_top_builddir_sub in
   "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
   *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
@@ -1337,7 +1384,7 @@
       echo &&
       $SHELL "$ac_srcdir/configure" --help=recursive
     else
-      echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+      $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
     fi || ac_status=$?
     cd "$ac_pwd" || { ac_status=$?; break; }
   done
@@ -1346,22 +1393,765 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-tcsh configure 6.17.00
-generated by GNU Autoconf 2.61
-
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+tcsh configure 6.18.01
+generated by GNU Autoconf 2.68
+
+Copyright (C) 2010 Free Software Foundation, Inc.
 This configure script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it.
 _ACEOF
   exit
 fi
+
+## ------------------------ ##
+## Autoconf initialization. ##
+## ------------------------ ##
+
+# ac_fn_c_try_compile LINENO
+# --------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext
+  if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_retval=1
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_compile
+
+# ac_fn_c_try_cpp LINENO
+# ----------------------
+# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_cpp ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } > conftest.i && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+    ac_retval=1
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_cpp
+
+# ac_fn_c_try_link LINENO
+# -----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_link ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext conftest$ac_exeext
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 $as_test_x conftest$ac_exeext
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_retval=1
+fi
+  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+  # interfere with the next link command; also delete a directory that is
+  # left behind by Apple's compiler.  We do this before executing the actions.
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_link
+
+# ac_fn_c_try_run LINENO
+# ----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
+# that executables *can* be run.
+ac_fn_c_try_run ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: program exited with status $ac_status" >&5
+       $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=$ac_status
+fi
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_run
+
+# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists, giving a warning if it cannot be compiled using
+# the include files in INCLUDES and setting the cache variable VAR
+# accordingly.
+ac_fn_c_check_header_mongrel ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if eval \${$3+:} false; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
+$as_echo_n "checking $2 usability... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_header_compiler=yes
+else
+  ac_header_compiler=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
+$as_echo_n "checking $2 presence... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <$2>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  ac_header_preproc=yes
+else
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
+  yes:no: )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+    ;;
+  no:yes:* )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $2:     check for missing prerequisite headers?" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+( $as_echo "## ---------------------------------- ##
+## Report this to http://bugs.gw.com/ ##
+## ---------------------------------- ##"
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=\$ac_header_compiler"
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_header_mongrel
+
+# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists and can be compiled using the include files in
+# INCLUDES, setting the cache variable VAR accordingly.
+ac_fn_c_check_header_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_header_compile
+
+# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
+# --------------------------------------------
+# Tries to find the compile-time value of EXPR in a program that includes
+# INCLUDES, setting VAR accordingly. Returns whether the value could be
+# computed
+ac_fn_c_compute_int ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if test "$cross_compiling" = yes; then
+    # Depending upon the size, compute the lo and hi bounds.
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) >= 0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_lo=0 ac_mid=0
+  while :; do
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) <= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_hi=$ac_mid; break
+else
+  as_fn_arith $ac_mid + 1 && ac_lo=$as_val
+			if test $ac_lo -le $ac_mid; then
+			  ac_lo= ac_hi=
+			  break
+			fi
+			as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) < 0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_hi=-1 ac_mid=-1
+  while :; do
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) >= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_lo=$ac_mid; break
+else
+  as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val
+			if test $ac_mid -le $ac_hi; then
+			  ac_lo= ac_hi=
+			  break
+			fi
+			as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+else
+  ac_lo= ac_hi=
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+# Binary search between lo and hi bounds.
+while test "x$ac_lo" != "x$ac_hi"; do
+  as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) <= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_hi=$ac_mid
+else
+  as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+case $ac_lo in #((
+?*) eval "$3=\$ac_lo"; ac_retval=0 ;;
+'') ac_retval=1 ;;
+esac
+  else
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+static long int longval () { return $2; }
+static unsigned long int ulongval () { return $2; }
+#include <stdio.h>
+#include <stdlib.h>
+int
+main ()
+{
+
+  FILE *f = fopen ("conftest.val", "w");
+  if (! f)
+    return 1;
+  if (($2) < 0)
+    {
+      long int i = longval ();
+      if (i != ($2))
+	return 1;
+      fprintf (f, "%ld", i);
+    }
+  else
+    {
+      unsigned long int i = ulongval ();
+      if (i != ($2))
+	return 1;
+      fprintf (f, "%lu", i);
+    }
+  /* Do not output a trailing newline, as this causes \r\n confusion
+     on some platforms.  */
+  return ferror (f) || fclose (f) != 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  echo >>conftest.val; read $3 <conftest.val; ac_retval=0
+else
+  ac_retval=1
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+rm -f conftest.val
+
+  fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_compute_int
+
+# ac_fn_c_check_type LINENO TYPE VAR INCLUDES
+# -------------------------------------------
+# Tests whether TYPE exists after having included INCLUDES, setting cache
+# variable VAR accordingly.
+ac_fn_c_check_type ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=no"
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+if (sizeof ($2))
+	 return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+if (sizeof (($2)))
+	    return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  eval "$3=yes"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_type
+
+# ac_fn_c_find_uintX_t LINENO BITS VAR
+# ------------------------------------
+# Finds an unsigned integer type with width BITS, setting cache variable VAR
+# accordingly.
+ac_fn_c_find_uintX_t ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5
+$as_echo_n "checking for uint$2_t... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=no"
+     # Order is important - never check a type that is potentially smaller
+     # than half of the expected target width.
+     for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \
+	 'unsigned long long int' 'unsigned short int' 'unsigned char'; do
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  case $ac_type in #(
+  uint$2_t) :
+    eval "$3=yes" ;; #(
+  *) :
+    eval "$3=\$ac_type" ;;
+esac
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+       if eval test \"x\$"$3"\" = x"no"; then :
+
+else
+  break
+fi
+     done
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_find_uintX_t
+
+# ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES
+# ----------------------------------------------------
+# Tries to find if the field MEMBER exists in type AGGR, after including
+# INCLUDES, setting cache variable VAR accordingly.
+ac_fn_c_check_member ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5
+$as_echo_n "checking for $2.$3... " >&6; }
+if eval \${$4+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$5
+int
+main ()
+{
+static $2 ac_aggr;
+if (ac_aggr.$3)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$4=yes"
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$5
+int
+main ()
+{
+static $2 ac_aggr;
+if (sizeof ac_aggr.$3)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$4=yes"
+else
+  eval "$4=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$4
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_member
+
+# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
+# ---------------------------------------------
+# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
+# accordingly.
+ac_fn_c_check_decl ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  as_decl_name=`echo $2|sed 's/ *(.*//'`
+  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
+$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+#ifndef $as_decl_name
+#ifdef __cplusplus
+  (void) $as_decl_use;
+#else
+  (void) $as_decl_name;
+#endif
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_decl
+
+# ac_fn_c_check_func LINENO FUNC VAR
+# ----------------------------------
+# Tests whether FUNC exists, setting the cache variable VAR accordingly
+ac_fn_c_check_func ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $2 innocuous_$2
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $2 (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $2
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $2 ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$2 || defined __stub___$2
+choke me
+#endif
+
+int
+main ()
+{
+return $2 ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_func
 cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by tcsh $as_me 6.17.00, which was
-generated by GNU Autoconf 2.61.  Invocation command line was
+It was created by tcsh $as_me 6.18.01, which was
+generated by GNU Autoconf 2.68.  Invocation command line was
 
   $ $0 $@
 
@@ -1397,8 +2187,8 @@
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-  echo "PATH: $as_dir"
-done
+    $as_echo "PATH: $as_dir"
+  done
 IFS=$as_save_IFS
 
 } >&5
@@ -1432,12 +2222,12 @@
     | -silent | --silent | --silen | --sile | --sil)
       continue ;;
     *\'*)
-      ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+      ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
     esac
     case $ac_pass in
-    1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
+    1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
     2)
-      ac_configure_args1="$ac_configure_args1 '$ac_arg'"
+      as_fn_append ac_configure_args1 " '$ac_arg'"
       if test $ac_must_keep_next = true; then
 	ac_must_keep_next=false # Got value, back to normal.
       else
@@ -1453,13 +2243,13 @@
 	  -* ) ac_must_keep_next=true ;;
 	esac
       fi
-      ac_configure_args="$ac_configure_args '$ac_arg'"
+      as_fn_append ac_configure_args " '$ac_arg'"
       ;;
     esac
   done
 done
-$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
-$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
+{ ac_configure_args0=; unset ac_configure_args0;}
+{ ac_configure_args1=; unset ac_configure_args1;}
 
 # When interrupted or exit'd, cleanup temporary files, and complete
 # config.log.  We remove comments because anyway the quotes in there
@@ -1471,11 +2261,9 @@
   {
     echo
 
-    cat <<\_ASBOX
-## ---------------- ##
+    $as_echo "## ---------------- ##
 ## Cache variables. ##
-## ---------------- ##
-_ASBOX
+## ---------------- ##"
     echo
     # The following way of writing the cache mishandles newlines in values,
 (
@@ -1484,12 +2272,13 @@
     case $ac_val in #(
     *${as_nl}*)
       case $ac_var in #(
-      *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5
-echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;;
+      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
       esac
       case $ac_var in #(
       _ | IFS | as_nl) ;; #(
-      *) $as_unset $ac_var ;;
+      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+      *) { eval $ac_var=; unset $ac_var;} ;;
       esac ;;
     esac
   done
@@ -1508,128 +2297,136 @@
 )
     echo
 
-    cat <<\_ASBOX
-## ----------------- ##
+    $as_echo "## ----------------- ##
 ## Output variables. ##
-## ----------------- ##
-_ASBOX
+## ----------------- ##"
     echo
     for ac_var in $ac_subst_vars
     do
       eval ac_val=\$$ac_var
       case $ac_val in
-      *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+      *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
       esac
-      echo "$ac_var='\''$ac_val'\''"
+      $as_echo "$ac_var='\''$ac_val'\''"
     done | sort
     echo
 
     if test -n "$ac_subst_files"; then
-      cat <<\_ASBOX
-## ------------------- ##
+      $as_echo "## ------------------- ##
 ## File substitutions. ##
-## ------------------- ##
-_ASBOX
+## ------------------- ##"
       echo
       for ac_var in $ac_subst_files
       do
 	eval ac_val=\$$ac_var
 	case $ac_val in
-	*\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+	*\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
 	esac
-	echo "$ac_var='\''$ac_val'\''"
+	$as_echo "$ac_var='\''$ac_val'\''"
       done | sort
       echo
     fi
 
     if test -s confdefs.h; then
-      cat <<\_ASBOX
-## ----------- ##
+      $as_echo "## ----------- ##
 ## confdefs.h. ##
-## ----------- ##
-_ASBOX
+## ----------- ##"
       echo
       cat confdefs.h
       echo
     fi
     test "$ac_signal" != 0 &&
-      echo "$as_me: caught signal $ac_signal"
-    echo "$as_me: exit $exit_status"
+      $as_echo "$as_me: caught signal $ac_signal"
+    $as_echo "$as_me: exit $exit_status"
   } >&5
   rm -f core *.core core.conftest.* &&
     rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
     exit $exit_status
 ' 0
 for ac_signal in 1 2 13 15; do
-  trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
+  trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
 done
 ac_signal=0
 
 # confdefs.h avoids OS command line length limits that DEFS can exceed.
 rm -f -r conftest* confdefs.h
 
+$as_echo "/* confdefs.h */" > confdefs.h
+
 # Predefined preprocessor variables.
 
 cat >>confdefs.h <<_ACEOF
 #define PACKAGE_NAME "$PACKAGE_NAME"
 _ACEOF
 
-
 cat >>confdefs.h <<_ACEOF
 #define PACKAGE_TARNAME "$PACKAGE_TARNAME"
 _ACEOF
 
-
 cat >>confdefs.h <<_ACEOF
 #define PACKAGE_VERSION "$PACKAGE_VERSION"
 _ACEOF
 
-
 cat >>confdefs.h <<_ACEOF
 #define PACKAGE_STRING "$PACKAGE_STRING"
 _ACEOF
 
-
 cat >>confdefs.h <<_ACEOF
 #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
 _ACEOF
 
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_URL "$PACKAGE_URL"
+_ACEOF
+
 
 # Let the site file select an alternate cache file if it wants to.
-# Prefer explicitly selected file to automatically selected ones.
+# Prefer an explicitly selected file to automatically selected ones.
+ac_site_file1=NONE
+ac_site_file2=NONE
 if test -n "$CONFIG_SITE"; then
-  set x "$CONFIG_SITE"
+  # We do not want a PATH search for config.site.
+  case $CONFIG_SITE in #((
+    -*)  ac_site_file1=./$CONFIG_SITE;;
+    */*) ac_site_file1=$CONFIG_SITE;;
+    *)   ac_site_file1=./$CONFIG_SITE;;
+  esac
 elif test "x$prefix" != xNONE; then
-  set x "$prefix/share/config.site" "$prefix/etc/config.site"
-else
-  set x "$ac_default_prefix/share/config.site" \
-	"$ac_default_prefix/etc/config.site"
-fi
-shift
-for ac_site_file
+  ac_site_file1=$prefix/share/config.site
+  ac_site_file2=$prefix/etc/config.site
+else
+  ac_site_file1=$ac_default_prefix/share/config.site
+  ac_site_file2=$ac_default_prefix/etc/config.site
+fi
+for ac_site_file in "$ac_site_file1" "$ac_site_file2"
 do
-  if test -r "$ac_site_file"; then
-    { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
-echo "$as_me: loading site script $ac_site_file" >&6;}
+  test "x$ac_site_file" = xNONE && continue
+  if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
+$as_echo "$as_me: loading site script $ac_site_file" >&6;}
     sed 's/^/| /' "$ac_site_file" >&5
-    . "$ac_site_file"
+    . "$ac_site_file" \
+      || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "failed to load site script $ac_site_file
+See \`config.log' for more details" "$LINENO" 5; }
   fi
 done
 
 if test -r "$cache_file"; then
-  # Some versions of bash will fail to source /dev/null (special
-  # files actually), so we avoid doing that.
-  if test -f "$cache_file"; then
-    { echo "$as_me:$LINENO: loading cache $cache_file" >&5
-echo "$as_me: loading cache $cache_file" >&6;}
+  # Some versions of bash will fail to source /dev/null (special files
+  # actually), so we avoid doing that.  DJGPP emulates it as a regular file.
+  if test /dev/null != "$cache_file" && test -f "$cache_file"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
+$as_echo "$as_me: loading cache $cache_file" >&6;}
     case $cache_file in
       [\\/]* | ?:[\\/]* ) . "$cache_file";;
       *)                      . "./$cache_file";;
     esac
   fi
 else
-  { echo "$as_me:$LINENO: creating cache $cache_file" >&5
-echo "$as_me: creating cache $cache_file" >&6;}
+  { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
+$as_echo "$as_me: creating cache $cache_file" >&6;}
   >$cache_file
 fi
 
@@ -1643,68 +2440,56 @@
   eval ac_new_val=\$ac_env_${ac_var}_value
   case $ac_old_set,$ac_new_set in
     set,)
-      { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
-echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
       ac_cache_corrupted=: ;;
     ,set)
-      { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
-echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
       ac_cache_corrupted=: ;;
     ,);;
     *)
       if test "x$ac_old_val" != "x$ac_new_val"; then
-	{ echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
-echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
-	{ echo "$as_me:$LINENO:   former value:  $ac_old_val" >&5
-echo "$as_me:   former value:  $ac_old_val" >&2;}
-	{ echo "$as_me:$LINENO:   current value: $ac_new_val" >&5
-echo "$as_me:   current value: $ac_new_val" >&2;}
-	ac_cache_corrupted=:
+	# differences in whitespace do not lead to failure.
+	ac_old_val_w=`echo x $ac_old_val`
+	ac_new_val_w=`echo x $ac_new_val`
+	if test "$ac_old_val_w" != "$ac_new_val_w"; then
+	  { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
+$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+	  ac_cache_corrupted=:
+	else
+	  { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
+$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
+	  eval $ac_var=\$ac_old_val
+	fi
+	{ $as_echo "$as_me:${as_lineno-$LINENO}:   former value:  \`$ac_old_val'" >&5
+$as_echo "$as_me:   former value:  \`$ac_old_val'" >&2;}
+	{ $as_echo "$as_me:${as_lineno-$LINENO}:   current value: \`$ac_new_val'" >&5
+$as_echo "$as_me:   current value: \`$ac_new_val'" >&2;}
       fi;;
   esac
   # Pass precious variables to config.status.
   if test "$ac_new_set" = set; then
     case $ac_new_val in
-    *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+    *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
     *) ac_arg=$ac_var=$ac_new_val ;;
     esac
     case " $ac_configure_args " in
       *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
-      *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+      *) as_fn_append ac_configure_args " '$ac_arg'" ;;
     esac
   fi
 done
 if $ac_cache_corrupted; then
-  { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
-echo "$as_me: error: changes in the environment can compromise the build" >&2;}
-  { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
-echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
-   { (exit 1); exit 1; }; }
-fi
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+  { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+  { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
+$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+  as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
+fi
+## -------------------- ##
+## Main body of script. ##
+## -------------------- ##
 
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
@@ -1714,12 +2499,12 @@
 
 
 
+
 ac_config_headers="$ac_config_headers config.h"
 
 ac_config_commands="$ac_config_commands ./atconfig"
 
 
-
 ac_aux_dir=
 for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
   if test -f "$ac_dir/install-sh"; then
@@ -1737,9 +2522,7 @@
   fi
 done
 if test -z "$ac_aux_dir"; then
-  { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5
-echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;}
-   { (exit 1); exit 1; }; }
+  as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
 fi
 
 # These three variables are undocumented and unsupported,
@@ -1751,37 +2534,122 @@
 ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
 
 
+# Find a good install program.  We prefer a C program (faster),
+# so one script is as good as another.  But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# OS/2's system install, which has a completely different semantic
+# ./install, which can be erroneously created by make from ./install.sh.
+# Reject install programs that cannot install multiple files.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
+$as_echo_n "checking for a BSD-compatible install... " >&6; }
+if test -z "$INSTALL"; then
+if ${ac_cv_path_install+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in #((
+  ./ | .// | /[cC]/* | \
+  /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+  ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
+  /usr/ucb/* ) ;;
+  *)
+    # OSF1 and SCO ODT 3.0 have their own names for install.
+    # Don't use installbsd from OSF since it installs stuff as root
+    # by default.
+    for ac_prog in ginstall scoinst install; do
+      for ac_exec_ext in '' $ac_executable_extensions; do
+	if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
+	  if test $ac_prog = install &&
+	    grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+	    # AIX install.  It has an incompatible calling convention.
+	    :
+	  elif test $ac_prog = install &&
+	    grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+	    # program-specific install script used by HP pwplus--don't use.
+	    :
+	  else
+	    rm -rf conftest.one conftest.two conftest.dir
+	    echo one > conftest.one
+	    echo two > conftest.two
+	    mkdir conftest.dir
+	    if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
+	      test -s conftest.one && test -s conftest.two &&
+	      test -s conftest.dir/conftest.one &&
+	      test -s conftest.dir/conftest.two
+	    then
+	      ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+	      break 3
+	    fi
+	  fi
+	fi
+      done
+    done
+    ;;
+esac
+
+  done
+IFS=$as_save_IFS
+
+rm -rf conftest.one conftest.two conftest.dir
+
+fi
+  if test "${ac_cv_path_install+set}" = set; then
+    INSTALL=$ac_cv_path_install
+  else
+    # As a last resort, use the slow shell script.  Don't cache a
+    # value for INSTALL within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    INSTALL=$ac_install_sh
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
+$as_echo "$INSTALL" >&6; }
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
 # Make sure we can run config.sub.
 $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
-  { { echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5
-echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;}
-   { (exit 1); exit 1; }; }
-
-{ echo "$as_me:$LINENO: checking build system type" >&5
-echo $ECHO_N "checking build system type... $ECHO_C" >&6; }
-if test "${ac_cv_build+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
+$as_echo_n "checking build system type... " >&6; }
+if ${ac_cv_build+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
   ac_build_alias=$build_alias
 test "x$ac_build_alias" = x &&
   ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
 test "x$ac_build_alias" = x &&
-  { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5
-echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
-   { (exit 1); exit 1; }; }
+  as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
-  { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5
-echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;}
-   { (exit 1); exit 1; }; }
-
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_build" >&5
-echo "${ECHO_T}$ac_cv_build" >&6; }
+  as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
+$as_echo "$ac_cv_build" >&6; }
 case $ac_cv_build in
 *-*-*) ;;
-*) { { echo "$as_me:$LINENO: error: invalid value of canonical build" >&5
-echo "$as_me: error: invalid value of canonical build" >&2;}
-   { (exit 1); exit 1; }; };;
+*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
 esac
 build=$ac_cv_build
 ac_save_IFS=$IFS; IFS='-'
@@ -1797,28 +2665,24 @@
 case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
 
 
-{ echo "$as_me:$LINENO: checking host system type" >&5
-echo $ECHO_N "checking host system type... $ECHO_C" >&6; }
-if test "${ac_cv_host+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
+$as_echo_n "checking host system type... " >&6; }
+if ${ac_cv_host+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
   if test "x$host_alias" = x; then
   ac_cv_host=$ac_cv_build
 else
   ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
-    { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5
-echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;}
-   { (exit 1); exit 1; }; }
-fi
-
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_host" >&5
-echo "${ECHO_T}$ac_cv_host" >&6; }
+    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
+$as_echo "$ac_cv_host" >&6; }
 case $ac_cv_host in
 *-*-*) ;;
-*) { { echo "$as_me:$LINENO: error: invalid value of canonical host" >&5
-echo "$as_me: error: invalid value of canonical host" >&2;}
-   { (exit 1); exit 1; }; };;
+*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
 esac
 host=$ac_cv_host
 ac_save_IFS=$IFS; IFS='-'
@@ -1835,18 +2699,16 @@
 
 
 
-{ echo "$as_me:$LINENO: checking cached host tuple" >&5
-echo $ECHO_N "checking cached host tuple... $ECHO_C" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking cached host tuple" >&5
+$as_echo_n "checking cached host tuple... " >&6; }
 if { test x"${ac_cv_host_system_type+set}" = x"set" &&
      test x"$ac_cv_host_system_type" != x"$host"; }; then
-  { echo "$as_me:$LINENO: result: different" >&5
-echo "${ECHO_T}different" >&6; }
-  { { echo "$as_me:$LINENO: error: remove config.cache and re-run configure" >&5
-echo "$as_me: error: remove config.cache and re-run configure" >&2;}
-   { (exit 1); exit 1; }; }
-else
-  { echo "$as_me:$LINENO: result: ok" >&5
-echo "${ECHO_T}ok" >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: different" >&5
+$as_echo "different" >&6; }
+  as_fn_error $? "remove config.cache and re-run configure" "$LINENO" 5
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+$as_echo "ok" >&6; }
 fi
 ac_cv_host_system_type="$host"
 
@@ -1901,6 +2763,11 @@
     tcsh_config_file=os390
   ;;
 
+  ## Android
+  *-*-android*)
+    tcsh_config_file=android
+  ;;
+
   ## Linux
   *-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu)
     tcsh_config_file=linux
@@ -2001,8 +2868,11 @@
   *-*-solaris2.[45] ) # Should handle sparc, x86 and powerpc
     tcsh_config_file=sol24
   ;;
+  *-*-solaris2.[678] ) # Should handle sparc, x86 and powerpc
+    tcsh_config_file=sol26
+  ;;
   *-*-solaris2.* ) # Should handle sparc, x86 and powerpc
-    tcsh_config_file=sol26
+    tcsh_config_file=sol29
   ;;
 
   ## Dell SVR4
@@ -2053,7 +2923,7 @@
 
   ## Red Hat Cygwin
   *-cygwin)
-    tcsh_config_file=cygwin32
+    tcsh_config_file=cygwin
   ;;
 
   ## mips-compaq-nonstopux
@@ -2072,13 +2942,9 @@
   ;;
 
   * )
-    { { echo "$as_me:$LINENO: error: Tcsh can't guess the configuration file name
+    as_fn_error $? "Tcsh can't guess the configuration file name
 for \`${host}' systems.
-Check tcsh's \`Ported' file for manual configuration instructions." >&5
-echo "$as_me: error: Tcsh can't guess the configuration file name
-for \`${host}' systems.
-Check tcsh's \`Ported' file for manual configuration instructions." >&2;}
-   { (exit 1); exit 1; }; }
+Check tcsh's \`Ported' file for manual configuration instructions." "$LINENO" 5
     ;;
 
 esac
@@ -2087,7 +2953,6 @@
 cp ${srcdir}/config/${tcsh_config_file} config_p.h
 
 
-
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -2096,10 +2961,10 @@
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
 set dummy ${ac_tool_prefix}gcc; ac_word=$2
-{ echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -2109,25 +2974,25 @@
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_CC="${ac_tool_prefix}gcc"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
-done
+  done
 IFS=$as_save_IFS
 
 fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  { echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6; }
-else
-  { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
 
@@ -2136,10 +3001,10 @@
   ac_ct_CC=$CC
   # Extract the first word of "gcc", so it can be a program name with args.
 set dummy gcc; ac_word=$2
-{ echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
   if test -n "$ac_ct_CC"; then
   ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
@@ -2149,25 +3014,25 @@
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_ac_ct_CC="gcc"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
-done
+  done
 IFS=$as_save_IFS
 
 fi
 fi
 ac_ct_CC=$ac_cv_prog_ac_ct_CC
 if test -n "$ac_ct_CC"; then
-  { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6; }
-else
-  { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
   if test "x$ac_ct_CC" = x; then
@@ -2175,12 +3040,8 @@
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&5
-echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&2;}
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     CC=$ac_ct_CC
@@ -2193,10 +3054,10 @@
           if test -n "$ac_tool_prefix"; then
     # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
 set dummy ${ac_tool_prefix}cc; ac_word=$2
-{ echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -2206,25 +3067,25 @@
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_CC="${ac_tool_prefix}cc"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
-done
+  done
 IFS=$as_save_IFS
 
 fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  { echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6; }
-else
-  { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
 
@@ -2233,10 +3094,10 @@
 if test -z "$CC"; then
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
-{ echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -2247,18 +3108,18 @@
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
        ac_prog_rejected=yes
        continue
      fi
     ac_cv_prog_CC="cc"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
-done
+  done
 IFS=$as_save_IFS
 
 if test $ac_prog_rejected = yes; then
@@ -2277,11 +3138,11 @@
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  { echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6; }
-else
-  { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
 
@@ -2292,10 +3153,10 @@
   do
     # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-{ echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -2305,25 +3166,25 @@
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
-done
+  done
 IFS=$as_save_IFS
 
 fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  { echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6; }
-else
-  { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
 
@@ -2336,10 +3197,10 @@
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-{ echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
   if test -n "$ac_ct_CC"; then
   ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
@@ -2349,25 +3210,25 @@
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_ac_ct_CC="$ac_prog"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
-done
+  done
 IFS=$as_save_IFS
 
 fi
 fi
 ac_ct_CC=$ac_cv_prog_ac_ct_CC
 if test -n "$ac_ct_CC"; then
-  { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6; }
-else
-  { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
 
@@ -2379,12 +3240,8 @@
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&5
-echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&2;}
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     CC=$ac_ct_CC
@@ -2394,51 +3251,37 @@
 fi
 
 
-test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
-See \`config.log' for more details." >&5
-echo "$as_me: error: no acceptable C compiler found in \$PATH
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
+test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "no acceptable C compiler found in \$PATH
+See \`config.log' for more details" "$LINENO" 5; }
 
 # Provide some information about the compiler.
-echo "$as_me:$LINENO: checking for C compiler version" >&5
-ac_compiler=`set X $ac_compile; echo $2`
-{ (ac_try="$ac_compiler --version >&5"
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+  { { ac_try="$ac_compiler $ac_option >&5"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compiler --version >&5") 2>&5
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
   ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }
-{ (ac_try="$ac_compiler -v >&5"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compiler -v >&5") 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }
-{ (ac_try="$ac_compiler -V >&5"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compiler -V >&5") 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }
-
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+  if test -s conftest.err; then
+    sed '10a\
+... rest of stderr output deleted ...
+         10q' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+  fi
+  rm -f conftest.er1 conftest.err
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+done
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
@@ -2450,42 +3293,38 @@
 }
 _ACEOF
 ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files a.out a.exe b.out"
+ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
 # Try to create an executable without -o first, disregard a.out.
 # It will help us diagnose broken compilers, and finding out an intuition
 # of exeext.
-{ echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
-echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; }
-ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
-#
-# List of possible output files, starting from the most likely.
-# The algorithm is not robust to junk in `.', hence go to wildcards (a.*)
-# only as a last resort.  b.out is created by i960 compilers.
-ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out'
-#
-# The IRIX 6 linker writes into existing files which may not be
-# executable, retaining their permissions.  Remove them first so a
-# subsequent execution test works.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
+$as_echo_n "checking whether the C compiler works... " >&6; }
+ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+
+# The possible output files:
+ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
+
 ac_rmfiles=
 for ac_file in $ac_files
 do
   case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;;
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
     * ) ac_rmfiles="$ac_rmfiles $ac_file";;
   esac
 done
 rm -f $ac_rmfiles
 
-if { (ac_try="$ac_link_default"
+if { { ac_try="$ac_link_default"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
   (eval "$ac_link_default") 2>&5
   ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
   # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
 # So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
 # in a Makefile.  We should not override ac_cv_exeext if it was cached,
@@ -2495,14 +3334,14 @@
 do
   test -f "$ac_file" || continue
   case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj )
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
 	;;
     [ab].out )
 	# We found the default executable, but exeext='' is most
 	# certainly right.
 	break;;
     *.* )
-        if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+	if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
 	then :; else
 	   ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
 	fi
@@ -2521,78 +3360,41 @@
 else
   ac_file=''
 fi
-
-{ echo "$as_me:$LINENO: result: $ac_file" >&5
-echo "${ECHO_T}$ac_file" >&6; }
-if test -z "$ac_file"; then
-  echo "$as_me: failed program was:" >&5
+if test -z "$ac_file"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+$as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-{ { echo "$as_me:$LINENO: error: C compiler cannot create executables
-See \`config.log' for more details." >&5
-echo "$as_me: error: C compiler cannot create executables
-See \`config.log' for more details." >&2;}
-   { (exit 77); exit 77; }; }
-fi
-
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "C compiler cannot create executables
+See \`config.log' for more details" "$LINENO" 5; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
+$as_echo_n "checking for C compiler default output file name... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
+$as_echo "$ac_file" >&6; }
 ac_exeext=$ac_cv_exeext
 
-# Check that the compiler produces executables we can run.  If not, either
-# the compiler is broken, or we cross compile.
-{ echo "$as_me:$LINENO: checking whether the C compiler works" >&5
-echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; }
-# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
-# If not cross compiling, check that we can run a simple program.
-if test "$cross_compiling" != yes; then
-  if { ac_try='./$ac_file'
-  { (case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-    cross_compiling=no
-  else
-    if test "$cross_compiling" = maybe; then
-	cross_compiling=yes
-    else
-	{ { echo "$as_me:$LINENO: error: cannot run C compiled programs.
-If you meant to cross compile, use \`--host'.
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot run C compiled programs.
-If you meant to cross compile, use \`--host'.
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
-    fi
-  fi
-fi
-{ echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6; }
-
-rm -f a.out a.exe conftest$ac_cv_exeext b.out
+rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
 ac_clean_files=$ac_clean_files_save
-# Check that the compiler produces executables we can run.  If not, either
-# the compiler is broken, or we cross compile.
-{ echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
-echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; }
-{ echo "$as_me:$LINENO: result: $cross_compiling" >&5
-echo "${ECHO_T}$cross_compiling" >&6; }
-
-{ echo "$as_me:$LINENO: checking for suffix of executables" >&5
-echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; }
-if { (ac_try="$ac_link"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
+$as_echo_n "checking for suffix of executables... " >&6; }
+if { { ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
   (eval "$ac_link") 2>&5
   ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
   # If both `conftest.exe' and `conftest' are `present' (well, observable)
 # catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
 # work properly (i.e., refer to `conftest.exe'), while it won't with
@@ -2600,37 +3402,90 @@
 for ac_file in conftest.exe conftest conftest.*; do
   test -f "$ac_file" || continue
   case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;;
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
     *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
 	  break;;
     * ) break;;
   esac
 done
 else
-  { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
-fi
-
-rm -f conftest$ac_cv_exeext
-{ echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
-echo "${ECHO_T}$ac_cv_exeext" >&6; }
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+rm -f conftest conftest$ac_cv_exeext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
+$as_echo "$ac_cv_exeext" >&6; }
 
 rm -f conftest.$ac_ext
 EXEEXT=$ac_cv_exeext
 ac_exeext=$EXEEXT
-{ echo "$as_me:$LINENO: checking for suffix of object files" >&5
-echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; }
-if test "${ac_cv_objext+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+int
+main ()
+{
+FILE *f = fopen ("conftest.out", "w");
+ return ferror (f) || fclose (f) != 0;
+
+  ;
+  return 0;
+}
 _ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+ac_clean_files="$ac_clean_files conftest.out"
+# Check that the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
+$as_echo_n "checking whether we are cross compiling... " >&6; }
+if test "$cross_compiling" != yes; then
+  { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+  if { ac_try='./conftest$ac_cv_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then
+    cross_compiling=no
+  else
+    if test "$cross_compiling" = maybe; then
+	cross_compiling=yes
+    else
+	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details" "$LINENO" 5; }
+    fi
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
+$as_echo "$cross_compiling" >&6; }
+
+rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
+$as_echo_n "checking for suffix of object files... " >&6; }
+if ${ac_cv_objext+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
@@ -2642,51 +3497,46 @@
 }
 _ACEOF
 rm -f conftest.o conftest.obj
-if { (ac_try="$ac_compile"
+if { { ac_try="$ac_compile"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
   (eval "$ac_compile") 2>&5
   ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
   for ac_file in conftest.o conftest.obj conftest.*; do
   test -f "$ac_file" || continue;
   case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;;
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
     *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
        break;;
   esac
 done
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute suffix of object files: cannot compile
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
-fi
-
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot compute suffix of object files: cannot compile
+See \`config.log' for more details" "$LINENO" 5; }
+fi
 rm -f conftest.$ac_cv_objext conftest.$ac_ext
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
-echo "${ECHO_T}$ac_cv_objext" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
+$as_echo "$ac_cv_objext" >&6; }
 OBJEXT=$ac_cv_objext
 ac_objext=$OBJEXT
-{ echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
-echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; }
-if test "${ac_cv_c_compiler_gnu+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
+$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
+if ${ac_cv_c_compiler_gnu+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
@@ -2700,54 +3550,34 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
+if ac_fn_c_try_compile "$LINENO"; then :
   ac_compiler_gnu=yes
 else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_compiler_gnu=no
-fi
-
+  ac_compiler_gnu=no
+fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 ac_cv_c_compiler_gnu=$ac_compiler_gnu
 
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
-echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; }
-GCC=`test $ac_compiler_gnu = yes && echo yes`
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
+$as_echo "$ac_cv_c_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+  GCC=yes
+else
+  GCC=
+fi
 ac_test_CFLAGS=${CFLAGS+set}
 ac_save_CFLAGS=$CFLAGS
-{ echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
-echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; }
-if test "${ac_cv_prog_cc_g+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
+$as_echo_n "checking whether $CC accepts -g... " >&6; }
+if ${ac_cv_prog_cc_g+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
   ac_save_c_werror_flag=$ac_c_werror_flag
    ac_c_werror_flag=yes
    ac_cv_prog_cc_g=no
    CFLAGS="-g"
-   cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
@@ -2758,34 +3588,11 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
+if ac_fn_c_try_compile "$LINENO"; then :
   ac_cv_prog_cc_g=yes
 else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	CFLAGS=""
-      cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+  CFLAGS=""
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
@@ -2796,35 +3603,12 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  :
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_c_werror_flag=$ac_save_c_werror_flag
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  ac_c_werror_flag=$ac_save_c_werror_flag
 	 CFLAGS="-g"
-	 cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
@@ -2835,42 +3619,18 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
+if ac_fn_c_try_compile "$LINENO"; then :
   ac_cv_prog_cc_g=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-
-fi
-
+fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
    ac_c_werror_flag=$ac_save_c_werror_flag
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
+$as_echo "$ac_cv_prog_cc_g" >&6; }
 if test "$ac_test_CFLAGS" = set; then
   CFLAGS=$ac_save_CFLAGS
 elif test $ac_cv_prog_cc_g = yes; then
@@ -2886,18 +3646,14 @@
     CFLAGS=
   fi
 fi
-{ echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5
-echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; }
-if test "${ac_cv_prog_cc_c89+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
+$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
+if ${ac_cv_prog_cc_c89+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
   ac_cv_prog_cc_c89=no
 ac_save_CC=$CC
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <stdarg.h>
 #include <stdio.h>
@@ -2954,31 +3710,9 @@
 	-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
 do
   CC="$ac_save_CC $ac_arg"
-  rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
+  if ac_fn_c_try_compile "$LINENO"; then :
   ac_cv_prog_cc_c89=$ac_arg
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-
-fi
-
+fi
 rm -f core conftest.err conftest.$ac_objext
   test "x$ac_cv_prog_cc_c89" != "xno" && break
 done
@@ -2989,17 +3723,19 @@
 # AC_CACHE_VAL
 case "x$ac_cv_prog_cc_c89" in
   x)
-    { echo "$as_me:$LINENO: result: none needed" >&5
-echo "${ECHO_T}none needed" >&6; } ;;
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
   xno)
-    { echo "$as_me:$LINENO: result: unsupported" >&5
-echo "${ECHO_T}unsupported" >&6; } ;;
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
   *)
     CC="$CC $ac_cv_prog_cc_c89"
-    { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;;
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
 esac
-
+if test "x$ac_cv_prog_cc_c89" != xno; then :
+
+fi
 
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
@@ -3012,15 +3748,15 @@
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
-{ echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
-echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
+$as_echo_n "checking how to run the C preprocessor... " >&6; }
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
 fi
 if test -z "$CPP"; then
-  if test "${ac_cv_prog_CPP+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  if ${ac_cv_prog_CPP+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
       # Double quotes because CPP needs to be expanded
     for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
@@ -3034,11 +3770,7 @@
   # <limits.h> exists even on freestanding compilers.
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp. "Syntax error" is here to catch this case.
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #ifdef __STDC__
 # include <limits.h>
@@ -3047,76 +3779,34 @@
 #endif
 		     Syntax error
 _ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null && {
-	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       }; then
-  :
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
   # Broken: fails on valid input.
 continue
 fi
-
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.i conftest.$ac_ext
 
   # OK, works on sane cases.  Now check whether nonexistent headers
   # can be detected and how.
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <ac_nonexistent.h>
 _ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null && {
-	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       }; then
+if ac_fn_c_try_cpp "$LINENO"; then :
   # Broken: success on invalid input.
 continue
 else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
   # Passes both tests.
 ac_preproc_ok=:
 break
 fi
-
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.i conftest.$ac_ext
 
 done
 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
   break
 fi
 
@@ -3128,8 +3818,8 @@
 else
   ac_cv_prog_CPP=$CPP
 fi
-{ echo "$as_me:$LINENO: result: $CPP" >&5
-echo "${ECHO_T}$CPP" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
+$as_echo "$CPP" >&6; }
 ac_preproc_ok=false
 for ac_c_preproc_warn_flag in '' yes
 do
@@ -3139,11 +3829,7 @@
   # <limits.h> exists even on freestanding compilers.
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp. "Syntax error" is here to catch this case.
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #ifdef __STDC__
 # include <limits.h>
@@ -3152,83 +3838,40 @@
 #endif
 		     Syntax error
 _ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null && {
-	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       }; then
-  :
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
   # Broken: fails on valid input.
 continue
 fi
-
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.i conftest.$ac_ext
 
   # OK, works on sane cases.  Now check whether nonexistent headers
   # can be detected and how.
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <ac_nonexistent.h>
 _ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null && {
-	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       }; then
+if ac_fn_c_try_cpp "$LINENO"; then :
   # Broken: success on invalid input.
 continue
 else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
   # Passes both tests.
 ac_preproc_ok=:
 break
 fi
-
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.i conftest.$ac_ext
 
 done
 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
-  :
-else
-  { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details." >&5
-echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details" "$LINENO" 5; }
 fi
 
 ac_ext=c
@@ -3239,45 +3882,40 @@
 
 
 
-{ echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5
-echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; }
-if test "${ac_cv_path_GREP+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  # Extract the first word of "grep ggrep" to use in msg output
-if test -z "$GREP"; then
-set dummy grep ggrep; ac_prog_name=$2
-if test "${ac_cv_path_GREP+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
+$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
+if ${ac_cv_path_GREP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$GREP"; then
   ac_path_GREP_found=false
-# Loop through the user's path and test for each of PROGNAME-LIST
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-  for ac_prog in grep ggrep; do
-  for ac_exec_ext in '' $ac_executable_extensions; do
-    ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
-    { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
-    # Check for GNU ac_path_GREP and select it if it is found.
+    for ac_prog in grep ggrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+      { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
+# Check for GNU ac_path_GREP and select it if it is found.
   # Check for GNU $ac_path_GREP
 case `"$ac_path_GREP" --version 2>&1` in
 *GNU*)
   ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
 *)
   ac_count=0
-  echo $ECHO_N "0123456789$ECHO_C" >"conftest.in"
+  $as_echo_n 0123456789 >"conftest.in"
   while :
   do
     cat "conftest.in" "conftest.in" >"conftest.tmp"
     mv "conftest.tmp" "conftest.in"
     cp "conftest.in" "conftest.nl"
-    echo 'GREP' >> "conftest.nl"
+    $as_echo 'GREP' >> "conftest.nl"
     "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
     diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    ac_count=`expr $ac_count + 1`
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
     if test $ac_count -gt ${ac_path_GREP_max-0}; then
       # Best one so far, save it but keep looking for a better one
       ac_cv_path_GREP="$ac_path_GREP"
@@ -3289,77 +3927,61 @@
   rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
 esac
 
-
-    $ac_path_GREP_found && break 3
+      $ac_path_GREP_found && break 3
+    done
   done
-done
-
-done
+  done
 IFS=$as_save_IFS
-
-
-fi
-
-GREP="$ac_cv_path_GREP"
-if test -z "$GREP"; then
-  { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
-echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
-   { (exit 1); exit 1; }; }
-fi
-
+  if test -z "$ac_cv_path_GREP"; then
+    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
 else
   ac_cv_path_GREP=$GREP
 fi
 
-
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5
-echo "${ECHO_T}$ac_cv_path_GREP" >&6; }
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
+$as_echo "$ac_cv_path_GREP" >&6; }
  GREP="$ac_cv_path_GREP"
 
 
-{ echo "$as_me:$LINENO: checking for egrep" >&5
-echo $ECHO_N "checking for egrep... $ECHO_C" >&6; }
-if test "${ac_cv_path_EGREP+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+$as_echo_n "checking for egrep... " >&6; }
+if ${ac_cv_path_EGREP+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
   if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
    then ac_cv_path_EGREP="$GREP -E"
    else
-     # Extract the first word of "egrep" to use in msg output
-if test -z "$EGREP"; then
-set dummy egrep; ac_prog_name=$2
-if test "${ac_cv_path_EGREP+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
+     if test -z "$EGREP"; then
   ac_path_EGREP_found=false
-# Loop through the user's path and test for each of PROGNAME-LIST
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-  for ac_prog in egrep; do
-  for ac_exec_ext in '' $ac_executable_extensions; do
-    ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
-    { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
-    # Check for GNU ac_path_EGREP and select it if it is found.
+    for ac_prog in egrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+      { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
   # Check for GNU $ac_path_EGREP
 case `"$ac_path_EGREP" --version 2>&1` in
 *GNU*)
   ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
 *)
   ac_count=0
-  echo $ECHO_N "0123456789$ECHO_C" >"conftest.in"
+  $as_echo_n 0123456789 >"conftest.in"
   while :
   do
     cat "conftest.in" "conftest.in" >"conftest.tmp"
     mv "conftest.tmp" "conftest.in"
     cp "conftest.in" "conftest.nl"
-    echo 'EGREP' >> "conftest.nl"
+    $as_echo 'EGREP' >> "conftest.nl"
     "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
     diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    ac_count=`expr $ac_count + 1`
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
     if test $ac_count -gt ${ac_path_EGREP_max-0}; then
       # Best one so far, save it but keep looking for a better one
       ac_cv_path_EGREP="$ac_path_EGREP"
@@ -3371,54 +3993,39 @@
   rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
 esac
 
-
-    $ac_path_EGREP_found && break 3
+      $ac_path_EGREP_found && break 3
+    done
   done
-done
-
-done
+  done
 IFS=$as_save_IFS
-
-
-fi
-
-EGREP="$ac_cv_path_EGREP"
-if test -z "$EGREP"; then
-  { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
-echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
-   { (exit 1); exit 1; }; }
-fi
-
+  if test -z "$ac_cv_path_EGREP"; then
+    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
 else
   ac_cv_path_EGREP=$EGREP
 fi
 
-
    fi
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5
-echo "${ECHO_T}$ac_cv_path_EGREP" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
+$as_echo "$ac_cv_path_EGREP" >&6; }
  EGREP="$ac_cv_path_EGREP"
 
 
 if test $ac_cv_c_compiler_gnu = yes; then
-    { echo "$as_me:$LINENO: checking whether $CC needs -traditional" >&5
-echo $ECHO_N "checking whether $CC needs -traditional... $ECHO_C" >&6; }
-if test "${ac_cv_prog_gcc_traditional+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC needs -traditional" >&5
+$as_echo_n "checking whether $CC needs -traditional... " >&6; }
+if ${ac_cv_prog_gcc_traditional+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
     ac_pattern="Autoconf.*'x'"
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <sgtty.h>
 Autoconf TIOCGETP
 _ACEOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "$ac_pattern" >/dev/null 2>&1; then
+  $EGREP "$ac_pattern" >/dev/null 2>&1; then :
   ac_cv_prog_gcc_traditional=yes
 else
   ac_cv_prog_gcc_traditional=no
@@ -3427,47 +4034,87 @@
 
 
   if test $ac_cv_prog_gcc_traditional = no; then
-    cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <termio.h>
 Autoconf TCGETA
 _ACEOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "$ac_pattern" >/dev/null 2>&1; then
+  $EGREP "$ac_pattern" >/dev/null 2>&1; then :
   ac_cv_prog_gcc_traditional=yes
 fi
 rm -f conftest*
 
   fi
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_prog_gcc_traditional" >&5
-echo "${ECHO_T}$ac_cv_prog_gcc_traditional" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_gcc_traditional" >&5
+$as_echo "$ac_cv_prog_gcc_traditional" >&6; }
   if test $ac_cv_prog_gcc_traditional = yes; then
     CC="$CC -traditional"
   fi
 fi
 
 
+# Extract the first word of "gencat", so it can be a program name with args.
+set dummy gencat; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_GENCAT+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $GENCAT in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_GENCAT="$GENCAT" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_GENCAT="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+GENCAT=$ac_cv_path_GENCAT
+if test -n "$GENCAT"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GENCAT" >&5
+$as_echo "$GENCAT" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+
+if test "x${cross_compiling}" = xyes ; then
+  CC_FOR_GETHOST="cc"
+else
+  CC_FOR_GETHOST="\$(CC)"
+fi
+
+
 if test "x$GCC" != xyes ; then
   DFLAGS="$DFLAGS $NON_GNU_DFLAGS"
   CFLAGS="$CFLAGS $NON_GNU_CFLAGS"
 fi
 
-{ echo "$as_me:$LINENO: checking for library containing crypt" >&5
-echo $ECHO_N "checking for library containing crypt... $ECHO_C" >&6; }
-if test "${ac_cv_search_crypt+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing crypt" >&5
+$as_echo_n "checking for library containing crypt... " >&6; }
+if ${ac_cv_search_crypt+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
   ac_func_search_save_LIBS=$LIBS
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 /* Override any GCC internal prototype to avoid an error.
@@ -3492,65 +4139,38 @@
     ac_res=-l$ac_lib
     LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
   fi
-  rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
+  if ac_fn_c_try_link "$LINENO"; then :
   ac_cv_search_crypt=$ac_res
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext
-  if test "${ac_cv_search_crypt+set}" = set; then
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if ${ac_cv_search_crypt+:} false; then :
   break
 fi
 done
-if test "${ac_cv_search_crypt+set}" = set; then
-  :
+if ${ac_cv_search_crypt+:} false; then :
+
 else
   ac_cv_search_crypt=no
 fi
 rm conftest.$ac_ext
 LIBS=$ac_func_search_save_LIBS
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_search_crypt" >&5
-echo "${ECHO_T}$ac_cv_search_crypt" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_crypt" >&5
+$as_echo "$ac_cv_search_crypt" >&6; }
 ac_res=$ac_cv_search_crypt
-if test "$ac_res" != no; then
+if test "$ac_res" != no; then :
   test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
 
 fi
 
-{ echo "$as_me:$LINENO: checking for library containing getspnam" >&5
-echo $ECHO_N "checking for library containing getspnam... $ECHO_C" >&6; }
-if test "${ac_cv_search_getspnam+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing getspnam" >&5
+$as_echo_n "checking for library containing getspnam... " >&6; }
+if ${ac_cv_search_getspnam+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
   ac_func_search_save_LIBS=$LIBS
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 /* Override any GCC internal prototype to avoid an error.
@@ -3575,65 +4195,38 @@
     ac_res=-l$ac_lib
     LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
   fi
-  rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
+  if ac_fn_c_try_link "$LINENO"; then :
   ac_cv_search_getspnam=$ac_res
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext
-  if test "${ac_cv_search_getspnam+set}" = set; then
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if ${ac_cv_search_getspnam+:} false; then :
   break
 fi
 done
-if test "${ac_cv_search_getspnam+set}" = set; then
-  :
+if ${ac_cv_search_getspnam+:} false; then :
+
 else
   ac_cv_search_getspnam=no
 fi
 rm conftest.$ac_ext
 LIBS=$ac_func_search_save_LIBS
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_search_getspnam" >&5
-echo "${ECHO_T}$ac_cv_search_getspnam" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_getspnam" >&5
+$as_echo "$ac_cv_search_getspnam" >&6; }
 ac_res=$ac_cv_search_getspnam
-if test "$ac_res" != no; then
+if test "$ac_res" != no; then :
   test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
 
 fi
 
-{ echo "$as_me:$LINENO: checking for library containing tgetent" >&5
-echo $ECHO_N "checking for library containing tgetent... $ECHO_C" >&6; }
-if test "${ac_cv_search_tgetent+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing tgetent" >&5
+$as_echo_n "checking for library containing tgetent... " >&6; }
+if ${ac_cv_search_tgetent+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
   ac_func_search_save_LIBS=$LIBS
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 /* Override any GCC internal prototype to avoid an error.
@@ -3658,65 +4251,38 @@
     ac_res=-l$ac_lib
     LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
   fi
-  rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
+  if ac_fn_c_try_link "$LINENO"; then :
   ac_cv_search_tgetent=$ac_res
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext
-  if test "${ac_cv_search_tgetent+set}" = set; then
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if ${ac_cv_search_tgetent+:} false; then :
   break
 fi
 done
-if test "${ac_cv_search_tgetent+set}" = set; then
-  :
+if ${ac_cv_search_tgetent+:} false; then :
+
 else
   ac_cv_search_tgetent=no
 fi
 rm conftest.$ac_ext
 LIBS=$ac_func_search_save_LIBS
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_search_tgetent" >&5
-echo "${ECHO_T}$ac_cv_search_tgetent" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_tgetent" >&5
+$as_echo "$ac_cv_search_tgetent" >&6; }
 ac_res=$ac_cv_search_tgetent
-if test "$ac_res" != no; then
+if test "$ac_res" != no; then :
   test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
 
 fi
 
-{ echo "$as_me:$LINENO: checking for library containing gethostbyname" >&5
-echo $ECHO_N "checking for library containing gethostbyname... $ECHO_C" >&6; }
-if test "${ac_cv_search_gethostbyname+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname" >&5
+$as_echo_n "checking for library containing gethostbyname... " >&6; }
+if ${ac_cv_search_gethostbyname+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
   ac_func_search_save_LIBS=$LIBS
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 /* Override any GCC internal prototype to avoid an error.
@@ -3741,65 +4307,38 @@
     ac_res=-l$ac_lib
     LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
   fi
-  rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
+  if ac_fn_c_try_link "$LINENO"; then :
   ac_cv_search_gethostbyname=$ac_res
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext
-  if test "${ac_cv_search_gethostbyname+set}" = set; then
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if ${ac_cv_search_gethostbyname+:} false; then :
   break
 fi
 done
-if test "${ac_cv_search_gethostbyname+set}" = set; then
-  :
+if ${ac_cv_search_gethostbyname+:} false; then :
+
 else
   ac_cv_search_gethostbyname=no
 fi
 rm conftest.$ac_ext
 LIBS=$ac_func_search_save_LIBS
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_search_gethostbyname" >&5
-echo "${ECHO_T}$ac_cv_search_gethostbyname" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gethostbyname" >&5
+$as_echo "$ac_cv_search_gethostbyname" >&6; }
 ac_res=$ac_cv_search_gethostbyname
-if test "$ac_res" != no; then
+if test "$ac_res" != no; then :
   test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
 
 fi
 
-{ echo "$as_me:$LINENO: checking for library containing connect" >&5
-echo $ECHO_N "checking for library containing connect... $ECHO_C" >&6; }
-if test "${ac_cv_search_connect+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing connect" >&5
+$as_echo_n "checking for library containing connect... " >&6; }
+if ${ac_cv_search_connect+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
   ac_func_search_save_LIBS=$LIBS
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 /* Override any GCC internal prototype to avoid an error.
@@ -3824,50 +4363,83 @@
     ac_res=-l$ac_lib
     LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
   fi
-  rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
+  if ac_fn_c_try_link "$LINENO"; then :
   ac_cv_search_connect=$ac_res
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext
-  if test "${ac_cv_search_connect+set}" = set; then
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if ${ac_cv_search_connect+:} false; then :
   break
 fi
 done
-if test "${ac_cv_search_connect+set}" = set; then
-  :
+if ${ac_cv_search_connect+:} false; then :
+
 else
   ac_cv_search_connect=no
 fi
 rm conftest.$ac_ext
 LIBS=$ac_func_search_save_LIBS
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_search_connect" >&5
-echo "${ECHO_T}$ac_cv_search_connect" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_connect" >&5
+$as_echo "$ac_cv_search_connect" >&6; }
 ac_res=$ac_cv_search_connect
-if test "$ac_res" != no; then
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing catgets" >&5
+$as_echo_n "checking for library containing catgets... " >&6; }
+if ${ac_cv_search_catgets+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char catgets ();
+int
+main ()
+{
+return catgets ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' catgets; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_catgets=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if ${ac_cv_search_catgets+:} false; then :
+  break
+fi
+done
+if ${ac_cv_search_catgets+:} false; then :
+
+else
+  ac_cv_search_catgets=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_catgets" >&5
+$as_echo "$ac_cv_search_catgets" >&6; }
+ac_res=$ac_cv_search_catgets
+if test "$ac_res" != no; then :
   test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
 
 fi
@@ -3890,7 +4462,7 @@
 
 
 # Check whether --with-gnu-ld was given.
-if test "${with_gnu_ld+set}" = set; then
+if test "${with_gnu_ld+set}" = set; then :
   withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
 else
   with_gnu_ld=no
@@ -3912,8 +4484,8 @@
 ac_prog=ld
 if test "$GCC" = yes; then
   # Check if gcc -print-prog-name=ld gives a path.
-  { echo "$as_me:$LINENO: checking for ld used by GCC" >&5
-echo $ECHO_N "checking for ld used by GCC... $ECHO_C" >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5
+$as_echo_n "checking for ld used by GCC... " >&6; }
   case $host in
   *-*-mingw*)
     # gcc leaves a trailing carriage return which upsets mingw
@@ -3928,7 +4500,7 @@
       # Canonicalize the path of ld
       ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
       while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
-	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+        ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
       done
       test -z "$LD" && LD="$ac_prog"
       ;;
@@ -3942,14 +4514,14 @@
     ;;
   esac
 elif test "$with_gnu_ld" = yes; then
-  { echo "$as_me:$LINENO: checking for GNU ld" >&5
-echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6; }
-else
-  { echo "$as_me:$LINENO: checking for non-GNU ld" >&5
-echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6; }
-fi
-if test "${acl_cv_path_LD+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
+$as_echo_n "checking for GNU ld... " >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
+$as_echo_n "checking for non-GNU ld... " >&6; }
+fi
+if ${acl_cv_path_LD+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
   if test -z "$LD"; then
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
@@ -3962,9 +4534,9 @@
       # Break only if it was the GNU/non-GNU ld that we prefer.
       case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in
       *GNU* | *'with BFD'*)
-	test "$with_gnu_ld" != no && break ;;
+        test "$with_gnu_ld" != no && break ;;
       *)
-	test "$with_gnu_ld" != yes && break ;;
+        test "$with_gnu_ld" != yes && break ;;
       esac
     fi
   done
@@ -3976,19 +4548,17 @@
 
 LD="$acl_cv_path_LD"
 if test -n "$LD"; then
-  { echo "$as_me:$LINENO: result: $LD" >&5
-echo "${ECHO_T}$LD" >&6; }
-else
-  { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
-fi
-test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5
-echo "$as_me: error: no acceptable ld found in \$PATH" >&2;}
-   { (exit 1); exit 1; }; }
-{ echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5
-echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6; }
-if test "${acl_cv_prog_gnu_ld+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
+$as_echo "$LD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
+$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
+if ${acl_cv_prog_gnu_ld+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
   # I'd rather use --version here, but apparently some GNU ld's only accept -v.
 case `$LD -v 2>&1 </dev/null` in
@@ -3998,17 +4568,17 @@
   acl_cv_prog_gnu_ld=no ;;
 esac
 fi
-{ echo "$as_me:$LINENO: result: $acl_cv_prog_gnu_ld" >&5
-echo "${ECHO_T}$acl_cv_prog_gnu_ld" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5
+$as_echo "$acl_cv_prog_gnu_ld" >&6; }
 with_gnu_ld=$acl_cv_prog_gnu_ld
 
 
 
 
-                                                { echo "$as_me:$LINENO: checking for shared library run path origin" >&5
-echo $ECHO_N "checking for shared library run path origin... $ECHO_C" >&6; }
-if test "${acl_cv_rpath+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
+$as_echo_n "checking for shared library run path origin... " >&6; }
+if ${acl_cv_rpath+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
 
     CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
@@ -4018,17 +4588,19 @@
     acl_cv_rpath=done
 
 fi
-{ echo "$as_me:$LINENO: result: $acl_cv_rpath" >&5
-echo "${ECHO_T}$acl_cv_rpath" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5
+$as_echo "$acl_cv_rpath" >&6; }
   wl="$acl_cv_wl"
-  libext="$acl_cv_libext"
-  shlibext="$acl_cv_shlibext"
-  hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
-  hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
-  hardcode_direct="$acl_cv_hardcode_direct"
-  hardcode_minus_L="$acl_cv_hardcode_minus_L"
+  acl_libext="$acl_cv_libext"
+  acl_shlibext="$acl_cv_shlibext"
+  acl_libname_spec="$acl_cv_libname_spec"
+  acl_library_names_spec="$acl_cv_library_names_spec"
+  acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
+  acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
+  acl_hardcode_direct="$acl_cv_hardcode_direct"
+  acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
     # Check whether --enable-rpath was given.
-if test "${enable_rpath+set}" = set; then
+if test "${enable_rpath+set}" = set; then :
   enableval=$enable_rpath; :
 else
   enable_rpath=yes
@@ -4037,6 +4609,74 @@
 
 
 
+  acl_libdirstem=lib
+  acl_libdirstem2=
+  case "$host_os" in
+    solaris*)
+                                    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit host" >&5
+$as_echo_n "checking for 64-bit host... " >&6; }
+if ${gl_cv_solaris_64bit+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#ifdef _LP64
+sixtyfour bits
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "sixtyfour bits" >/dev/null 2>&1; then :
+  gl_cv_solaris_64bit=yes
+else
+  gl_cv_solaris_64bit=no
+fi
+rm -f conftest*
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_solaris_64bit" >&5
+$as_echo "$gl_cv_solaris_64bit" >&6; }
+      if test $gl_cv_solaris_64bit = yes; then
+        acl_libdirstem=lib/64
+        case "$host_cpu" in
+          sparc*)        acl_libdirstem2=lib/sparcv9 ;;
+          i*86 | x86_64) acl_libdirstem2=lib/amd64 ;;
+        esac
+      fi
+      ;;
+    *)
+      searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'`
+      if test -n "$searchpath"; then
+        acl_save_IFS="${IFS= 	}"; IFS=":"
+        for searchdir in $searchpath; do
+          if test -d "$searchdir"; then
+            case "$searchdir" in
+              */lib64/ | */lib64 ) acl_libdirstem=lib64 ;;
+              */../ | */.. )
+                # Better ignore directories of this form. They are misleading.
+                ;;
+              *) searchdir=`cd "$searchdir" && pwd`
+                 case "$searchdir" in
+                   */lib64 ) acl_libdirstem=lib64 ;;
+                 esac ;;
+            esac
+          fi
+        done
+        IFS="$acl_save_IFS"
+      fi
+      ;;
+  esac
+  test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem"
+
+
+
+
+
+
+
+
 
 
 
@@ -4056,7 +4696,7 @@
 
 
 # Check whether --with-libiconv-prefix was given.
-if test "${with_libiconv_prefix+set}" = set; then
+if test "${with_libiconv_prefix+set}" = set; then :
   withval=$with_libiconv_prefix;
     if test "X$withval" = "Xno"; then
       use_additional=no
@@ -4076,7 +4716,11 @@
 
       else
         additional_includedir="$withval/include"
-        additional_libdir="$withval/lib"
+        additional_libdir="$withval/$acl_libdirstem"
+        if test "$acl_libdirstem2" != "$acl_libdirstem" \
+           && ! test -d "$withval/$acl_libdirstem"; then
+          additional_libdir="$withval/$acl_libdirstem2"
+        fi
       fi
     fi
 
@@ -4085,6 +4729,8 @@
       LIBICONV=
   LTLIBICONV=
   INCICONV=
+  LIBICONV_PREFIX=
+      HAVE_LIBICONV=
   rpathdirs=
   ltrpathdirs=
   names_already_handled=
@@ -4118,20 +4764,50 @@
           found_la=
           found_so=
           found_a=
+          eval libname=\"$acl_libname_spec\"    # typically: libname=lib$name
+          if test -n "$acl_shlibext"; then
+            shrext=".$acl_shlibext"             # typically: shrext=.so
+          else
+            shrext=
+          fi
           if test $use_additional = yes; then
-            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
-              found_dir="$additional_libdir"
-              found_so="$additional_libdir/lib$name.$shlibext"
-              if test -f "$additional_libdir/lib$name.la"; then
-                found_la="$additional_libdir/lib$name.la"
+            dir="$additional_libdir"
+                                    if test -n "$acl_shlibext"; then
+              if test -f "$dir/$libname$shrext"; then
+                found_dir="$dir"
+                found_so="$dir/$libname$shrext"
+              else
+                if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
+                  ver=`(cd "$dir" && \
+                        for f in "$libname$shrext".*; do echo "$f"; done \
+                        | sed -e "s,^$libname$shrext\\\\.,," \
+                        | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
+                        | sed 1q ) 2>/dev/null`
+                  if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
+                    found_dir="$dir"
+                    found_so="$dir/$libname$shrext.$ver"
+                  fi
+                else
+                  eval library_names=\"$acl_library_names_spec\"
+                  for f in $library_names; do
+                    if test -f "$dir/$f"; then
+                      found_dir="$dir"
+                      found_so="$dir/$f"
+                      break
+                    fi
+                  done
+                fi
               fi
-            else
-              if test -f "$additional_libdir/lib$name.$libext"; then
-                found_dir="$additional_libdir"
-                found_a="$additional_libdir/lib$name.$libext"
-                if test -f "$additional_libdir/lib$name.la"; then
-                  found_la="$additional_libdir/lib$name.la"
-                fi
+            fi
+                        if test "X$found_dir" = "X"; then
+              if test -f "$dir/$libname.$acl_libext"; then
+                found_dir="$dir"
+                found_a="$dir/$libname.$acl_libext"
+              fi
+            fi
+            if test "X$found_dir" != "X"; then
+              if test -f "$dir/$libname.la"; then
+                found_la="$dir/$libname.la"
               fi
             fi
           fi
@@ -4149,19 +4825,42 @@
               case "$x" in
                 -L*)
                   dir=`echo "X$x" | sed -e 's/^X-L//'`
-                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
-                    found_dir="$dir"
-                    found_so="$dir/lib$name.$shlibext"
-                    if test -f "$dir/lib$name.la"; then
-                      found_la="$dir/lib$name.la"
+                                    if test -n "$acl_shlibext"; then
+                    if test -f "$dir/$libname$shrext"; then
+                      found_dir="$dir"
+                      found_so="$dir/$libname$shrext"
+                    else
+                      if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
+                        ver=`(cd "$dir" && \
+                              for f in "$libname$shrext".*; do echo "$f"; done \
+                              | sed -e "s,^$libname$shrext\\\\.,," \
+                              | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
+                              | sed 1q ) 2>/dev/null`
+                        if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
+                          found_dir="$dir"
+                          found_so="$dir/$libname$shrext.$ver"
+                        fi
+                      else
+                        eval library_names=\"$acl_library_names_spec\"
+                        for f in $library_names; do
+                          if test -f "$dir/$f"; then
+                            found_dir="$dir"
+                            found_so="$dir/$f"
+                            break
+                          fi
+                        done
+                      fi
                     fi
-                  else
-                    if test -f "$dir/lib$name.$libext"; then
+                  fi
+                                    if test "X$found_dir" = "X"; then
+                    if test -f "$dir/$libname.$acl_libext"; then
                       found_dir="$dir"
-                      found_a="$dir/lib$name.$libext"
-                      if test -f "$dir/lib$name.la"; then
-                        found_la="$dir/lib$name.la"
-                      fi
+                      found_a="$dir/$libname.$acl_libext"
+                    fi
+                  fi
+                  if test "X$found_dir" != "X"; then
+                    if test -f "$dir/$libname.la"; then
+                      found_la="$dir/$libname.la"
                     fi
                   fi
                   ;;
@@ -4174,7 +4873,9 @@
           if test "X$found_dir" != "X"; then
                         LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$found_dir -l$name"
             if test "X$found_so" != "X"; then
-                                                        if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
+                                                        if test "$enable_rpath" = no \
+                 || test "X$found_dir" = "X/usr/$acl_libdirstem" \
+                 || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then
                                 LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so"
               else
                                                                                 haveit=
@@ -4187,10 +4888,10 @@
                 if test -z "$haveit"; then
                   ltrpathdirs="$ltrpathdirs $found_dir"
                 fi
-                                if test "$hardcode_direct" = yes; then
+                                if test "$acl_hardcode_direct" = yes; then
                                                       LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so"
                 else
-                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
+                  if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
                                                             LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so"
                                                             haveit=
                     for x in $rpathdirs; do
@@ -4222,7 +4923,7 @@
                     if test -z "$haveit"; then
                       LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir"
                     fi
-                    if test "$hardcode_minus_L" != no; then
+                    if test "$acl_hardcode_minus_L" != no; then
                                                                                         LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so"
                     else
                                                                                                                                                                                 LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name"
@@ -4239,8 +4940,18 @@
             fi
                         additional_includedir=
             case "$found_dir" in
-              */lib | */lib/)
-                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
+              */$acl_libdirstem | */$acl_libdirstem/)
+                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
+                if test "$name" = 'iconv'; then
+                  LIBICONV_PREFIX="$basedir"
+                fi
+                additional_includedir="$basedir/include"
+                ;;
+              */$acl_libdirstem2 | */$acl_libdirstem2/)
+                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`
+                if test "$name" = 'iconv'; then
+                  LIBICONV_PREFIX="$basedir"
+                fi
                 additional_includedir="$basedir/include"
                 ;;
             esac
@@ -4289,9 +5000,11 @@
                 case "$dep" in
                   -L*)
                     additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
-                                                                                                                                                                if test "X$additional_libdir" != "X/usr/lib"; then
+                                                                                                                                                                if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \
+                       && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then
                       haveit=
-                      if test "X$additional_libdir" = "X/usr/local/lib"; then
+                      if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \
+                         || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then
                         if test -n "$GCC"; then
                           case $host_os in
                             linux* | gnu* | k*bsd*-gnu) haveit=yes;;
@@ -4391,21 +5104,21 @@
     done
   done
   if test "X$rpathdirs" != "X"; then
-    if test -n "$hardcode_libdir_separator"; then
+    if test -n "$acl_hardcode_libdir_separator"; then
                         alldirs=
       for found_dir in $rpathdirs; do
-        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
+        alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"
       done
             acl_save_libdir="$libdir"
       libdir="$alldirs"
-      eval flag=\"$hardcode_libdir_flag_spec\"
+      eval flag=\"$acl_hardcode_libdir_flag_spec\"
       libdir="$acl_save_libdir"
       LIBICONV="${LIBICONV}${LIBICONV:+ }$flag"
     else
             for found_dir in $rpathdirs; do
         acl_save_libdir="$libdir"
         libdir="$found_dir"
-        eval flag=\"$hardcode_libdir_flag_spec\"
+        eval flag=\"$acl_hardcode_libdir_flag_spec\"
         libdir="$acl_save_libdir"
         LIBICONV="${LIBICONV}${LIBICONV:+ }$flag"
       done
@@ -4423,6 +5136,11 @@
 
 
 
+
+
+
+
+
           am_save_CPPFLAGS="$CPPFLAGS"
 
   for element in $INCICONV; do
@@ -4448,19 +5166,15 @@
   done
 
 
-  { echo "$as_me:$LINENO: checking for iconv" >&5
-echo $ECHO_N "checking for iconv... $ECHO_C" >&6; }
-if test "${am_cv_func_iconv+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5
+$as_echo_n "checking for iconv... " >&6; }
+if ${am_cv_func_iconv+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
 
     am_cv_func_iconv="no, consider installing GNU libiconv"
     am_cv_lib_iconv=no
-    cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <stdlib.h>
 #include <iconv.h>
@@ -4474,42 +5188,15 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
+if ac_fn_c_try_link "$LINENO"; then :
   am_cv_func_iconv=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
     if test "$am_cv_func_iconv" != yes; then
       am_save_LIBS="$LIBS"
       LIBS="$LIBS $LIBICONV"
-      cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <stdlib.h>
 #include <iconv.h>
@@ -4523,53 +5210,145 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
+if ac_fn_c_try_link "$LINENO"; then :
   am_cv_lib_iconv=yes
         am_cv_func_iconv=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
       LIBS="$am_save_LIBS"
     fi
 
 fi
-{ echo "$as_me:$LINENO: result: $am_cv_func_iconv" >&5
-echo "${ECHO_T}$am_cv_func_iconv" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_iconv" >&5
+$as_echo "$am_cv_func_iconv" >&6; }
   if test "$am_cv_func_iconv" = yes; then
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_ICONV 1
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working iconv" >&5
+$as_echo_n "checking for working iconv... " >&6; }
+if ${am_cv_func_iconv_works+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
+            am_save_LIBS="$LIBS"
+      if test $am_cv_lib_iconv = yes; then
+        LIBS="$LIBS $LIBICONV"
+      fi
+      if test "$cross_compiling" = yes; then :
+  case "$host_os" in
+           aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
+           *)            am_cv_func_iconv_works="guessing yes" ;;
+         esac
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <iconv.h>
+#include <string.h>
+int main ()
+{
+  /* Test against AIX 5.1 bug: Failures are not distinguishable from successful
+     returns.  */
+  {
+    iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");
+    if (cd_utf8_to_88591 != (iconv_t)(-1))
+      {
+        static const char input[] = "\342\202\254"; /* EURO SIGN */
+        char buf[10];
+        const char *inptr = input;
+        size_t inbytesleft = strlen (input);
+        char *outptr = buf;
+        size_t outbytesleft = sizeof (buf);
+        size_t res = iconv (cd_utf8_to_88591,
+                            (char **) &inptr, &inbytesleft,
+                            &outptr, &outbytesleft);
+        if (res == 0)
+          return 1;
+      }
+  }
+  /* Test against Solaris 10 bug: Failures are not distinguishable from
+     successful returns.  */
+  {
+    iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646");
+    if (cd_ascii_to_88591 != (iconv_t)(-1))
+      {
+        static const char input[] = "\263";
+        char buf[10];
+        const char *inptr = input;
+        size_t inbytesleft = strlen (input);
+        char *outptr = buf;
+        size_t outbytesleft = sizeof (buf);
+        size_t res = iconv (cd_ascii_to_88591,
+                            (char **) &inptr, &inbytesleft,
+                            &outptr, &outbytesleft);
+        if (res == 0)
+          return 1;
+      }
+  }
+#if 0 /* This bug could be worked around by the caller.  */
+  /* Test against HP-UX 11.11 bug: Positive return value instead of 0.  */
+  {
+    iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591");
+    if (cd_88591_to_utf8 != (iconv_t)(-1))
+      {
+        static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
+        char buf[50];
+        const char *inptr = input;
+        size_t inbytesleft = strlen (input);
+        char *outptr = buf;
+        size_t outbytesleft = sizeof (buf);
+        size_t res = iconv (cd_88591_to_utf8,
+                            (char **) &inptr, &inbytesleft,
+                            &outptr, &outbytesleft);
+        if ((int)res > 0)
+          return 1;
+      }
+  }
+#endif
+  /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is
+     provided.  */
+  if (/* Try standardized names.  */
+      iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1)
+      /* Try IRIX, OSF/1 names.  */
+      && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1)
+      /* Try AIX names.  */
+      && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1)
+      /* Try HP-UX names.  */
+      && iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
+    return 1;
+  return 0;
+}
 _ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  am_cv_func_iconv_works=yes
+else
+  am_cv_func_iconv_works=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+      LIBS="$am_save_LIBS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_iconv_works" >&5
+$as_echo "$am_cv_func_iconv_works" >&6; }
+    case "$am_cv_func_iconv_works" in
+      *no) am_func_iconv=no am_cv_lib_iconv=no ;;
+      *)   am_func_iconv=yes ;;
+    esac
+  else
+    am_func_iconv=no am_cv_lib_iconv=no
+  fi
+  if test "$am_func_iconv" = yes; then
+
+$as_echo "#define HAVE_ICONV 1" >>confdefs.h
 
   fi
   if test "$am_cv_lib_iconv" = yes; then
-    { echo "$as_me:$LINENO: checking how to link with libiconv" >&5
-echo $ECHO_N "checking how to link with libiconv... $ECHO_C" >&6; }
-    { echo "$as_me:$LINENO: result: $LIBICONV" >&5
-echo "${ECHO_T}$LIBICONV" >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libiconv" >&5
+$as_echo_n "checking how to link with libiconv... " >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBICONV" >&5
+$as_echo "$LIBICONV" >&6; }
   else
             CPPFLAGS="$am_save_CPPFLAGS"
     LIBICONV=
@@ -4579,17 +5358,13 @@
 
 
   if test "$am_cv_func_iconv" = yes; then
-    { echo "$as_me:$LINENO: checking for iconv declaration" >&5
-echo $ECHO_N "checking for iconv declaration... $ECHO_C" >&6; }
-    if test "${am_cv_proto_iconv+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-
-      cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv declaration" >&5
+$as_echo_n "checking for iconv declaration... " >&6; }
+    if ${am_cv_proto_iconv+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 #include <stdlib.h>
@@ -4612,40 +5387,20 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
+if ac_fn_c_try_compile "$LINENO"; then :
   am_cv_proto_iconv_arg1=""
 else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	am_cv_proto_iconv_arg1="const"
-fi
-
+  am_cv_proto_iconv_arg1="const"
+fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
       am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"
 fi
 
     am_cv_proto_iconv=`echo "$am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
-    { echo "$as_me:$LINENO: result: ${ac_t:-
-         }$am_cv_proto_iconv" >&5
-echo "${ECHO_T}${ac_t:-
-         }$am_cv_proto_iconv" >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result:
+         $am_cv_proto_iconv" >&5
+$as_echo "
+         $am_cv_proto_iconv" >&6; }
 
 cat >>confdefs.h <<_ACEOF
 #define ICONV_CONST $am_cv_proto_iconv_arg1
@@ -4654,16 +5409,12 @@
   fi
 
 
-{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5
-echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; }
-if test "${ac_cv_header_stdc+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if ${ac_cv_header_stdc+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <stdlib.h>
 #include <stdarg.h>
@@ -4678,47 +5429,23 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
+if ac_fn_c_try_compile "$LINENO"; then :
   ac_cv_header_stdc=yes
 else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_header_stdc=no
-fi
-
+  ac_cv_header_stdc=no
+fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <string.h>
 
 _ACEOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "memchr" >/dev/null 2>&1; then
-  :
+  $EGREP "memchr" >/dev/null 2>&1; then :
+
 else
   ac_cv_header_stdc=no
 fi
@@ -4728,18 +5455,14 @@
 
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <stdlib.h>
 
 _ACEOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "free" >/dev/null 2>&1; then
-  :
+  $EGREP "free" >/dev/null 2>&1; then :
+
 else
   ac_cv_header_stdc=no
 fi
@@ -4749,14 +5472,10 @@
 
 if test $ac_cv_header_stdc = yes; then
   # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
-  if test "$cross_compiling" = yes; then
+  if test "$cross_compiling" = yes; then :
   :
 else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <ctype.h>
 #include <stdlib.h>
@@ -4783,822 +5502,89 @@
   return 0;
 }
 _ACEOF
-rm -f conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  :
-else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-ac_cv_header_stdc=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-
-
-fi
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
-echo "${ECHO_T}$ac_cv_header_stdc" >&6; }
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
 if test $ac_cv_header_stdc = yes; then
 
-cat >>confdefs.h <<\_ACEOF
-#define STDC_HEADERS 1
-_ACEOF
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
 
 fi
 
 # On IRIX 5.3, sys/types and inttypes.h are conflicting.
-
-
-
-
-
-
-
-
-
 for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
 		  inttypes.h stdint.h unistd.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
+"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-
-#include <$ac_header>
+
+fi
+
+done
+
+
+for ac_header in auth.h crypt.h features.h inttypes.h paths.h 		 shadow.h stdint.h utmp.h utmpx.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  eval "$as_ac_Header=yes"
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	eval "$as_ac_Header=no"
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-ac_res=`eval echo '${'$as_ac_Header'}'`
-	       { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
+
+fi
+
+done
+
+for ac_header in wchar.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "wchar.h" "ac_cv_header_wchar_h" "$ac_includes_default"
+if test "x$ac_cv_header_wchar_h" = xyes; then :
   cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+#define HAVE_WCHAR_H 1
 _ACEOF
-
-fi
-
-done
-
-
-
-
-
-
-
-
-
-for ac_header in auth.h crypt.h inttypes.h shadow.h stdint.h utmp.h utmpx.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  { echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-ac_res=`eval echo '${'$as_ac_Header'}'`
-	       { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-else
-  # Is the header compilable?
-{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_header_compiler=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_header_compiler=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <$ac_header>
-_ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null && {
-	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       }; then
-  ac_header_preproc=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-  ac_header_preproc=no
-fi
-
-rm -f conftest.err conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6; }
-
-# So?  What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
-  yes:no: )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
-    ac_header_preproc=yes
-    ;;
-  no:yes:* )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
-    ( cat <<\_ASBOX
-## ---------------------------------- ##
-## Report this to http://bugs.gw.com/ ##
-## ---------------------------------- ##
-_ASBOX
-     ) | sed "s/^/$as_me: WARNING:     /" >&2
-    ;;
-esac
-{ echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  eval "$as_ac_Header=\$ac_header_preproc"
-fi
-ac_res=`eval echo '${'$as_ac_Header'}'`
-	       { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-
-fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-
-for ac_header in wchar.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  { echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-ac_res=`eval echo '${'$as_ac_Header'}'`
-	       { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-else
-  # Is the header compilable?
-{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_header_compiler=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_header_compiler=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <$ac_header>
-_ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null && {
-	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       }; then
-  ac_header_preproc=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-  ac_header_preproc=no
-fi
-
-rm -f conftest.err conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6; }
-
-# So?  What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
-  yes:no: )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
-    ac_header_preproc=yes
-    ;;
-  no:yes:* )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
-    ( cat <<\_ASBOX
-## ---------------------------------- ##
-## Report this to http://bugs.gw.com/ ##
-## ---------------------------------- ##
-_ASBOX
-     ) | sed "s/^/$as_me: WARNING:     /" >&2
-    ;;
-esac
-{ echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  eval "$as_ac_Header=\$ac_header_preproc"
-fi
-ac_res=`eval echo '${'$as_ac_Header'}'`
-	       { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-
-fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
- { echo "$as_me:$LINENO: checking for wchar_t" >&5
-echo $ECHO_N "checking for wchar_t... $ECHO_C" >&6; }
-if test "${ac_cv_type_wchar_t+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <stdio.h>
-#include <wchar.h>
-
-typedef wchar_t ac__type_new_;
-int
-main ()
-{
-if ((ac__type_new_ *) 0)
-  return 0;
-if (sizeof (ac__type_new_))
-  return 0;
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_type_wchar_t=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_type_wchar_t=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_type_wchar_t" >&5
-echo "${ECHO_T}$ac_cv_type_wchar_t" >&6; }
-
-# The cast to long int works around a bug in the HP C Compiler
+ # The cast to long int works around a bug in the HP C Compiler
 # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
 # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
 # This bug is HP SR number 8606223364.
-{ echo "$as_me:$LINENO: checking size of wchar_t" >&5
-echo $ECHO_N "checking size of wchar_t... $ECHO_C" >&6; }
-if test "${ac_cv_sizeof_wchar_t+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test "$cross_compiling" = yes; then
-  # Depending upon the size, compute the lo and hi bounds.
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <stdio.h>
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of wchar_t" >&5
+$as_echo_n "checking size of wchar_t... " >&6; }
+if ${ac_cv_sizeof_wchar_t+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (wchar_t))" "ac_cv_sizeof_wchar_t"        "#include <stdio.h>
 #include <wchar.h>
-
-   typedef wchar_t ac__type_sizeof_;
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_lo=0 ac_mid=0
-  while :; do
-    cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <stdio.h>
-#include <wchar.h>
-
-   typedef wchar_t ac__type_sizeof_;
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_hi=$ac_mid; break
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_lo=`expr $ac_mid + 1`
-			if test $ac_lo -le $ac_mid; then
-			  ac_lo= ac_hi=
-			  break
-			fi
-			ac_mid=`expr 2 '*' $ac_mid + 1`
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  done
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <stdio.h>
-#include <wchar.h>
-
-   typedef wchar_t ac__type_sizeof_;
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_hi=-1 ac_mid=-1
-  while :; do
-    cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <stdio.h>
-#include <wchar.h>
-
-   typedef wchar_t ac__type_sizeof_;
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_lo=$ac_mid; break
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_hi=`expr '(' $ac_mid ')' - 1`
-			if test $ac_mid -le $ac_hi; then
-			  ac_lo= ac_hi=
-			  break
-			fi
-			ac_mid=`expr 2 '*' $ac_mid`
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  done
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_lo= ac_hi=
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-# Binary search between lo and hi bounds.
-while test "x$ac_lo" != "x$ac_hi"; do
-  ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <stdio.h>
-#include <wchar.h>
-
-   typedef wchar_t ac__type_sizeof_;
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_hi=$ac_mid
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_lo=`expr '(' $ac_mid ')' + 1`
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-case $ac_lo in
-?*) ac_cv_sizeof_wchar_t=$ac_lo;;
-'') if test "$ac_cv_type_wchar_t" = yes; then
-     { { echo "$as_me:$LINENO: error: cannot compute sizeof (wchar_t)
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute sizeof (wchar_t)
-See \`config.log' for more details." >&2;}
-   { (exit 77); exit 77; }; }
-   else
-     ac_cv_sizeof_wchar_t=0
-   fi ;;
-esac
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <stdio.h>
-#include <wchar.h>
-
-   typedef wchar_t ac__type_sizeof_;
-static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); }
-static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); }
-#include <stdio.h>
-#include <stdlib.h>
-int
-main ()
-{
-
-  FILE *f = fopen ("conftest.val", "w");
-  if (! f)
-    return 1;
-  if (((long int) (sizeof (ac__type_sizeof_))) < 0)
-    {
-      long int i = longval ();
-      if (i != ((long int) (sizeof (ac__type_sizeof_))))
-	return 1;
-      fprintf (f, "%ld\n", i);
-    }
-  else
-    {
-      unsigned long int i = ulongval ();
-      if (i != ((long int) (sizeof (ac__type_sizeof_))))
-	return 1;
-      fprintf (f, "%lu\n", i);
-    }
-  return ferror (f) || fclose (f) != 0;
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_sizeof_wchar_t=`cat conftest.val`
-else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-if test "$ac_cv_type_wchar_t" = yes; then
-     { { echo "$as_me:$LINENO: error: cannot compute sizeof (wchar_t)
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute sizeof (wchar_t)
-See \`config.log' for more details." >&2;}
-   { (exit 77); exit 77; }; }
+"; then :
+
+else
+  if test "$ac_cv_type_wchar_t" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "cannot compute sizeof (wchar_t)
+See \`config.log' for more details" "$LINENO" 5; }
    else
      ac_cv_sizeof_wchar_t=0
    fi
 fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f conftest.val
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_wchar_t" >&5
-echo "${ECHO_T}$ac_cv_sizeof_wchar_t" >&6; }
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_wchar_t" >&5
+$as_echo "$ac_cv_sizeof_wchar_t" >&6; }
 
 
 
@@ -5607,146 +5593,13 @@
 _ACEOF
 
 
-
-for ac_header in wctype.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  { echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-ac_res=`eval echo '${'$as_ac_Header'}'`
-	       { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-else
-  # Is the header compilable?
-{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
+	for ac_header in wctype.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "wctype.h" "ac_cv_header_wctype_h" "$ac_includes_default"
+if test "x$ac_cv_header_wctype_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_WCTYPE_H 1
 _ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_header_compiler=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_header_compiler=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <$ac_header>
-_ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null && {
-	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       }; then
-  ac_header_preproc=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-  ac_header_preproc=no
-fi
-
-rm -f conftest.err conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6; }
-
-# So?  What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
-  yes:no: )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
-    ac_header_preproc=yes
-    ;;
-  no:yes:* )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
-    ( cat <<\_ASBOX
-## ---------------------------------- ##
-## Report this to http://bugs.gw.com/ ##
-## ---------------------------------- ##
-_ASBOX
-     ) | sed "s/^/$as_me: WARNING:     /" >&2
-    ;;
-esac
-{ echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  eval "$as_ac_Header=\$ac_header_preproc"
-fi
-ac_res=`eval echo '${'$as_ac_Header'}'`
-	       { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-
-fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
 
 fi
 
@@ -5756,24 +5609,15 @@
 
 done
 
-
-
-
-
-
 ac_header_dirent=no
 for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
-  as_ac_Header=`echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for $ac_hdr that defines DIR" >&5
-echo $ECHO_N "checking for $ac_hdr that defines DIR... $ECHO_C" >&6; }
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+  as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh`
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5
+$as_echo_n "checking for $ac_hdr that defines DIR... " >&6; }
+if eval \${$as_ac_Header+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <sys/types.h>
 #include <$ac_hdr>
@@ -5787,39 +5631,19 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
+if ac_fn_c_try_compile "$LINENO"; then :
   eval "$as_ac_Header=yes"
 else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	eval "$as_ac_Header=no"
-fi
-
+  eval "$as_ac_Header=no"
+fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-ac_res=`eval echo '${'$as_ac_Header'}'`
-	       { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
+eval ac_res=\$$as_ac_Header
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
   cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_hdr" | $as_tr_cpp` 1
+#define `$as_echo "HAVE_$ac_hdr" | $as_tr_cpp` 1
 _ACEOF
 
 ac_header_dirent=$ac_hdr; break
@@ -5828,17 +5652,13 @@
 done
 # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
 if test $ac_header_dirent = dirent.h; then
-  { echo "$as_me:$LINENO: checking for library containing opendir" >&5
-echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6; }
-if test "${ac_cv_search_opendir+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5
+$as_echo_n "checking for library containing opendir... " >&6; }
+if ${ac_cv_search_opendir+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
   ac_func_search_save_LIBS=$LIBS
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 /* Override any GCC internal prototype to avoid an error.
@@ -5863,66 +5683,39 @@
     ac_res=-l$ac_lib
     LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
   fi
-  rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
+  if ac_fn_c_try_link "$LINENO"; then :
   ac_cv_search_opendir=$ac_res
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext
-  if test "${ac_cv_search_opendir+set}" = set; then
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if ${ac_cv_search_opendir+:} false; then :
   break
 fi
 done
-if test "${ac_cv_search_opendir+set}" = set; then
-  :
+if ${ac_cv_search_opendir+:} false; then :
+
 else
   ac_cv_search_opendir=no
 fi
 rm conftest.$ac_ext
 LIBS=$ac_func_search_save_LIBS
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5
-echo "${ECHO_T}$ac_cv_search_opendir" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5
+$as_echo "$ac_cv_search_opendir" >&6; }
 ac_res=$ac_cv_search_opendir
-if test "$ac_res" != no; then
+if test "$ac_res" != no; then :
   test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
 
 fi
 
 else
-  { echo "$as_me:$LINENO: checking for library containing opendir" >&5
-echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6; }
-if test "${ac_cv_search_opendir+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5
+$as_echo_n "checking for library containing opendir... " >&6; }
+if ${ac_cv_search_opendir+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
   ac_func_search_save_LIBS=$LIBS
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 /* Override any GCC internal prototype to avoid an error.
@@ -5947,66 +5740,39 @@
     ac_res=-l$ac_lib
     LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
   fi
-  rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
+  if ac_fn_c_try_link "$LINENO"; then :
   ac_cv_search_opendir=$ac_res
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext
-  if test "${ac_cv_search_opendir+set}" = set; then
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if ${ac_cv_search_opendir+:} false; then :
   break
 fi
 done
-if test "${ac_cv_search_opendir+set}" = set; then
-  :
+if ${ac_cv_search_opendir+:} false; then :
+
 else
   ac_cv_search_opendir=no
 fi
 rm conftest.$ac_ext
 LIBS=$ac_func_search_save_LIBS
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5
-echo "${ECHO_T}$ac_cv_search_opendir" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5
+$as_echo "$ac_cv_search_opendir" >&6; }
 ac_res=$ac_cv_search_opendir
-if test "$ac_res" != no; then
+if test "$ac_res" != no; then :
   test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
 
 fi
 
 fi
 
-{ echo "$as_me:$LINENO: checking whether stat file-mode macros are broken" >&5
-echo $ECHO_N "checking whether stat file-mode macros are broken... $ECHO_C" >&6; }
-if test "${ac_cv_header_stat_broken+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stat file-mode macros are broken" >&5
+$as_echo_n "checking whether stat file-mode macros are broken... " >&6; }
+if ${ac_cv_header_stat_broken+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -6028,53 +5794,27 @@
 #endif
 
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
+if ac_fn_c_try_compile "$LINENO"; then :
   ac_cv_header_stat_broken=no
 else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_header_stat_broken=yes
-fi
-
+  ac_cv_header_stat_broken=yes
+fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header_stat_broken" >&5
-echo "${ECHO_T}$ac_cv_header_stat_broken" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stat_broken" >&5
+$as_echo "$ac_cv_header_stat_broken" >&6; }
 if test $ac_cv_header_stat_broken = yes; then
 
-cat >>confdefs.h <<\_ACEOF
-#define STAT_MACROS_BROKEN 1
-_ACEOF
-
-fi
-
-{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5
-echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; }
-if test "${ac_cv_header_stdc+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+$as_echo "#define STAT_MACROS_BROKEN 1" >>confdefs.h
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if ${ac_cv_header_stdc+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <stdlib.h>
 #include <stdarg.h>
@@ -6089,47 +5829,23 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
+if ac_fn_c_try_compile "$LINENO"; then :
   ac_cv_header_stdc=yes
 else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_header_stdc=no
-fi
-
+  ac_cv_header_stdc=no
+fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <string.h>
 
 _ACEOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "memchr" >/dev/null 2>&1; then
-  :
+  $EGREP "memchr" >/dev/null 2>&1; then :
+
 else
   ac_cv_header_stdc=no
 fi
@@ -6139,18 +5855,14 @@
 
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <stdlib.h>
 
 _ACEOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "free" >/dev/null 2>&1; then
-  :
+  $EGREP "free" >/dev/null 2>&1; then :
+
 else
   ac_cv_header_stdc=no
 fi
@@ -6160,14 +5872,10 @@
 
 if test $ac_cv_header_stdc = yes; then
   # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
-  if test "$cross_compiling" = yes; then
+  if test "$cross_compiling" = yes; then :
   :
 else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <ctype.h>
 #include <stdlib.h>
@@ -6194,106 +5902,28 @@
   return 0;
 }
 _ACEOF
-rm -f conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  :
-else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-ac_cv_header_stdc=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-
-
-fi
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
-echo "${ECHO_T}$ac_cv_header_stdc" >&6; }
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
 if test $ac_cv_header_stdc = yes; then
 
-cat >>confdefs.h <<\_ACEOF
-#define STDC_HEADERS 1
-_ACEOF
-
-fi
-
-
-{ echo "$as_me:$LINENO: checking for long long" >&5
-echo $ECHO_N "checking for long long... $ECHO_C" >&6; }
-if test "${ac_cv_type_long_long+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-typedef long long ac__type_new_;
-int
-main ()
-{
-if ((ac__type_new_ *) 0)
-  return 0;
-if (sizeof (ac__type_new_))
-  return 0;
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_type_long_long=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_type_long_long=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_type_long_long" >&5
-echo "${ECHO_T}$ac_cv_type_long_long" >&6; }
-if test $ac_cv_type_long_long = yes; then
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
+
+
+ac_fn_c_check_type "$LINENO" "long long" "ac_cv_type_long_long" "$ac_includes_default"
+if test "x$ac_cv_type_long_long" = xyes; then :
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_LONG_LONG 1
@@ -6302,22 +5932,18 @@
 
 fi
 
-{ echo "$as_me:$LINENO: checking for uid_t in sys/types.h" >&5
-echo $ECHO_N "checking for uid_t in sys/types.h... $ECHO_C" >&6; }
-if test "${ac_cv_type_uid_t+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uid_t in sys/types.h" >&5
+$as_echo_n "checking for uid_t in sys/types.h... " >&6; }
+if ${ac_cv_type_uid_t+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <sys/types.h>
 
 _ACEOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "uid_t" >/dev/null 2>&1; then
+  $EGREP "uid_t" >/dev/null 2>&1; then :
   ac_cv_type_uid_t=yes
 else
   ac_cv_type_uid_t=no
@@ -6325,34 +5951,26 @@
 rm -f conftest*
 
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_type_uid_t" >&5
-echo "${ECHO_T}$ac_cv_type_uid_t" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_uid_t" >&5
+$as_echo "$ac_cv_type_uid_t" >&6; }
 if test $ac_cv_type_uid_t = no; then
 
-cat >>confdefs.h <<\_ACEOF
-#define uid_t int
-_ACEOF
-
-
-cat >>confdefs.h <<\_ACEOF
-#define gid_t int
-_ACEOF
-
-fi
-
-{ echo "$as_me:$LINENO: checking type of array argument to getgroups" >&5
-echo $ECHO_N "checking type of array argument to getgroups... $ECHO_C" >&6; }
-if test "${ac_cv_type_getgroups+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test "$cross_compiling" = yes; then
+$as_echo "#define uid_t int" >>confdefs.h
+
+
+$as_echo "#define gid_t int" >>confdefs.h
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking type of array argument to getgroups" >&5
+$as_echo_n "checking type of array argument to getgroups... " >&6; }
+if ${ac_cv_type_getgroups+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "$cross_compiling" = yes; then :
   ac_cv_type_getgroups=cross
 else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 /* Thanks to Mike Rendell for this test.  */
 $ac_includes_default
@@ -6378,51 +5996,23 @@
   return n > 0 && gidset[n] != val.gval;
 }
 _ACEOF
-rm -f conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+if ac_fn_c_try_run "$LINENO"; then :
   ac_cv_type_getgroups=gid_t
 else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-ac_cv_type_getgroups=int
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-
+  ac_cv_type_getgroups=int
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
 
 if test $ac_cv_type_getgroups = cross; then
-        cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <unistd.h>
 
 _ACEOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "getgroups.*int.*gid_t" >/dev/null 2>&1; then
+  $EGREP "getgroups.*int.*gid_t" >/dev/null 2>&1; then :
   ac_cv_type_getgroups=gid_t
 else
   ac_cv_type_getgroups=int
@@ -6431,69 +6021,17 @@
 
 fi
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_type_getgroups" >&5
-echo "${ECHO_T}$ac_cv_type_getgroups" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_getgroups" >&5
+$as_echo "$ac_cv_type_getgroups" >&6; }
 
 cat >>confdefs.h <<_ACEOF
 #define GETGROUPS_T $ac_cv_type_getgroups
 _ACEOF
 
 
-{ echo "$as_me:$LINENO: checking for mode_t" >&5
-echo $ECHO_N "checking for mode_t... $ECHO_C" >&6; }
-if test "${ac_cv_type_mode_t+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-typedef mode_t ac__type_new_;
-int
-main ()
-{
-if ((ac__type_new_ *) 0)
-  return 0;
-if (sizeof (ac__type_new_))
-  return 0;
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_type_mode_t=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_type_mode_t=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_type_mode_t" >&5
-echo "${ECHO_T}$ac_cv_type_mode_t" >&6; }
-if test $ac_cv_type_mode_t = yes; then
-  :
+ac_fn_c_check_type "$LINENO" "mode_t" "ac_cv_type_mode_t" "$ac_includes_default"
+if test "x$ac_cv_type_mode_t" = xyes; then :
+
 else
 
 cat >>confdefs.h <<_ACEOF
@@ -6502,61 +6040,9 @@
 
 fi
 
-{ echo "$as_me:$LINENO: checking for size_t" >&5
-echo $ECHO_N "checking for size_t... $ECHO_C" >&6; }
-if test "${ac_cv_type_size_t+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-typedef size_t ac__type_new_;
-int
-main ()
-{
-if ((ac__type_new_ *) 0)
-  return 0;
-if (sizeof (ac__type_new_))
-  return 0;
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_type_size_t=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_type_size_t=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5
-echo "${ECHO_T}$ac_cv_type_size_t" >&6; }
-if test $ac_cv_type_size_t = yes; then
-  :
+ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default"
+if test "x$ac_cv_type_size_t" = xyes; then :
+
 else
 
 cat >>confdefs.h <<_ACEOF
@@ -6565,22 +6051,18 @@
 
 fi
 
-{ echo "$as_me:$LINENO: checking for uid_t in sys/types.h" >&5
-echo $ECHO_N "checking for uid_t in sys/types.h... $ECHO_C" >&6; }
-if test "${ac_cv_type_uid_t+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uid_t in sys/types.h" >&5
+$as_echo_n "checking for uid_t in sys/types.h... " >&6; }
+if ${ac_cv_type_uid_t+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <sys/types.h>
 
 _ACEOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "uid_t" >/dev/null 2>&1; then
+  $EGREP "uid_t" >/dev/null 2>&1; then :
   ac_cv_type_uid_t=yes
 else
   ac_cv_type_uid_t=no
@@ -6588,176 +6070,67 @@
 rm -f conftest*
 
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_type_uid_t" >&5
-echo "${ECHO_T}$ac_cv_type_uid_t" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_uid_t" >&5
+$as_echo "$ac_cv_type_uid_t" >&6; }
 if test $ac_cv_type_uid_t = no; then
 
-cat >>confdefs.h <<\_ACEOF
-#define uid_t int
+$as_echo "#define uid_t int" >>confdefs.h
+
+
+$as_echo "#define gid_t int" >>confdefs.h
+
+fi
+
+ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t"
+case $ac_cv_c_uint32_t in #(
+  no|yes) ;; #(
+  *)
+
+$as_echo "#define _UINT32_T 1" >>confdefs.h
+
+
+cat >>confdefs.h <<_ACEOF
+#define uint32_t $ac_cv_c_uint32_t
 _ACEOF
-
-
-cat >>confdefs.h <<\_ACEOF
-#define gid_t int
-_ACEOF
-
-fi
-
-
-
-
-{ echo "$as_me:$LINENO: checking for ssize_t" >&5
-echo $ECHO_N "checking for ssize_t... $ECHO_C" >&6; }
-if test "${ac_cv_type_ssize_t+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
+;;
+  esac
+
+
+
+
+ac_fn_c_check_type "$LINENO" "ssize_t" "ac_cv_type_ssize_t" "
 #include <sys/types.h>
 
-
-typedef ssize_t ac__type_new_;
-int
-main ()
-{
-if ((ac__type_new_ *) 0)
-  return 0;
-if (sizeof (ac__type_new_))
-  return 0;
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_type_ssize_t=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_type_ssize_t=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_type_ssize_t" >&5
-echo "${ECHO_T}$ac_cv_type_ssize_t" >&6; }
-if test $ac_cv_type_ssize_t = yes; then
-  :
-else
-
-cat >>confdefs.h <<\_ACEOF
-#define ssize_t int
-_ACEOF
-
-fi
-
-
-
-
-
-{ echo "$as_me:$LINENO: checking for socklen_t" >&5
-echo $ECHO_N "checking for socklen_t... $ECHO_C" >&6; }
-if test "${ac_cv_type_socklen_t+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
+"
+if test "x$ac_cv_type_ssize_t" = xyes; then :
+
+else
+
+$as_echo "#define ssize_t int" >>confdefs.h
+
+fi
+
+
+
+
+
+ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" "
 #include <sys/types.h>
 #include <sys/socket.h>
 
-
-typedef socklen_t ac__type_new_;
-int
-main ()
-{
-if ((ac__type_new_ *) 0)
-  return 0;
-if (sizeof (ac__type_new_))
-  return 0;
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_type_socklen_t=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_type_socklen_t=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_type_socklen_t" >&5
-echo "${ECHO_T}$ac_cv_type_socklen_t" >&6; }
-if test $ac_cv_type_socklen_t = yes; then
-  :
-else
-
-cat >>confdefs.h <<\_ACEOF
-#define socklen_t int
-_ACEOF
-
-fi
-
-
-
-
-{ echo "$as_me:$LINENO: checking for struct dirent.d_ino" >&5
-echo $ECHO_N "checking for struct dirent.d_ino... $ECHO_C" >&6; }
-if test "${ac_cv_member_struct_dirent_d_ino+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#ifdef HAVE_DIRENT_H
+"
+if test "x$ac_cv_type_socklen_t" = xyes; then :
+
+else
+
+$as_echo "#define socklen_t int" >>confdefs.h
+
+fi
+
+
+
+
+ac_fn_c_check_member "$LINENO" "struct dirent" "d_ino" "ac_cv_member_struct_dirent_d_ino" "#ifdef HAVE_DIRENT_H
 # include <dirent.h>
 #else
 # ifdef HAVE_NDIR_H
@@ -6767,99 +6140,8 @@
 # endif
 # define dirent direct
 #endif
-
-int
-main ()
-{
-static struct dirent ac_aggr;
-if (ac_aggr.d_ino)
-return 0;
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_member_struct_dirent_d_ino=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#ifdef HAVE_DIRENT_H
-# include <dirent.h>
-#else
-# ifdef HAVE_NDIR_H
-#  include <ndir.h>
-# else
-#  include <sys/dir.h>
-# endif
-# define dirent direct
-#endif
-
-int
-main ()
-{
-static struct dirent ac_aggr;
-if (sizeof ac_aggr.d_ino)
-return 0;
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_member_struct_dirent_d_ino=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_member_struct_dirent_d_ino=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_member_struct_dirent_d_ino" >&5
-echo "${ECHO_T}$ac_cv_member_struct_dirent_d_ino" >&6; }
-if test $ac_cv_member_struct_dirent_d_ino = yes; then
+"
+if test "x$ac_cv_member_struct_dirent_d_ino" = xyes; then :
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_STRUCT_DIRENT_D_INO 1
@@ -6868,565 +6150,139 @@
 
 fi
 
-{ echo "$as_me:$LINENO: checking for struct utmp.ut_host" >&5
-echo $ECHO_N "checking for struct utmp.ut_host... $ECHO_C" >&6; }
-if test "${ac_cv_member_struct_utmp_ut_host+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <sys/types.h>
+ac_fn_c_check_member "$LINENO" "struct utmp" "ut_host" "ac_cv_member_struct_utmp_ut_host" "#include <sys/types.h>
 #ifdef HAVE_UTMPX_H
 #include <utmpx.h>
 #define utmp utmpx
 #elif defined HAVE_UTMP_H
 #include <utmp.h>
 #endif
-
-int
-main ()
-{
-static struct utmp ac_aggr;
-if (ac_aggr.ut_host)
-return 0;
-  ;
-  return 0;
-}
+"
+if test "x$ac_cv_member_struct_utmp_ut_host" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_UTMP_UT_HOST 1
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_member_struct_utmp_ut_host=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <sys/types.h>
+
+
+fi
+ac_fn_c_check_member "$LINENO" "struct utmp" "ut_user" "ac_cv_member_struct_utmp_ut_user" "#include <sys/types.h>
 #ifdef HAVE_UTMPX_H
 #include <utmpx.h>
 #define utmp utmpx
 #elif defined HAVE_UTMP_H
 #include <utmp.h>
 #endif
-
-int
-main ()
-{
-static struct utmp ac_aggr;
-if (sizeof ac_aggr.ut_host)
-return 0;
-  ;
-  return 0;
-}
+"
+if test "x$ac_cv_member_struct_utmp_ut_user" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_UTMP_UT_USER 1
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_member_struct_utmp_ut_host=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_member_struct_utmp_ut_host=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_member_struct_utmp_ut_host" >&5
-echo "${ECHO_T}$ac_cv_member_struct_utmp_ut_host" >&6; }
-if test $ac_cv_member_struct_utmp_ut_host = yes; then
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_UTMP_UT_HOST 1
-_ACEOF
-
-
-fi
-{ echo "$as_me:$LINENO: checking for struct utmp.ut_user" >&5
-echo $ECHO_N "checking for struct utmp.ut_user... $ECHO_C" >&6; }
-if test "${ac_cv_member_struct_utmp_ut_user+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <sys/types.h>
+
+
+fi
+ac_fn_c_check_member "$LINENO" "struct utmp" "ut_tv" "ac_cv_member_struct_utmp_ut_tv" "#include <sys/types.h>
 #ifdef HAVE_UTMPX_H
 #include <utmpx.h>
 #define utmp utmpx
 #elif defined HAVE_UTMP_H
 #include <utmp.h>
 #endif
-
-int
-main ()
-{
-static struct utmp ac_aggr;
-if (ac_aggr.ut_user)
-return 0;
-  ;
-  return 0;
-}
+"
+if test "x$ac_cv_member_struct_utmp_ut_tv" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_UTMP_UT_TV 1
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_member_struct_utmp_ut_user=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <sys/types.h>
+
+
+fi
+ac_fn_c_check_member "$LINENO" "struct utmp" "ut_xtime" "ac_cv_member_struct_utmp_ut_xtime" "#include <sys/types.h>
 #ifdef HAVE_UTMPX_H
 #include <utmpx.h>
 #define utmp utmpx
 #elif defined HAVE_UTMP_H
 #include <utmp.h>
 #endif
-
-int
-main ()
-{
-static struct utmp ac_aggr;
-if (sizeof ac_aggr.ut_user)
-return 0;
-  ;
-  return 0;
-}
+"
+if test "x$ac_cv_member_struct_utmp_ut_xtime" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_UTMP_UT_XTIME 1
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_member_struct_utmp_ut_user=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_member_struct_utmp_ut_user=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_member_struct_utmp_ut_user" >&5
-echo "${ECHO_T}$ac_cv_member_struct_utmp_ut_user" >&6; }
-if test $ac_cv_member_struct_utmp_ut_user = yes; then
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_UTMP_UT_USER 1
-_ACEOF
-
-
-fi
-{ echo "$as_me:$LINENO: checking for struct utmp.ut_tv" >&5
-echo $ECHO_N "checking for struct utmp.ut_tv... $ECHO_C" >&6; }
-if test "${ac_cv_member_struct_utmp_ut_tv+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <sys/types.h>
+
+
+fi
+ac_fn_c_check_member "$LINENO" "struct utmpx" "ut_host" "ac_cv_member_struct_utmpx_ut_host" "#include <sys/types.h>
 #ifdef HAVE_UTMPX_H
 #include <utmpx.h>
 #define utmp utmpx
 #elif defined HAVE_UTMP_H
 #include <utmp.h>
 #endif
-
-int
-main ()
-{
-static struct utmp ac_aggr;
-if (ac_aggr.ut_tv)
-return 0;
-  ;
-  return 0;
-}
+"
+if test "x$ac_cv_member_struct_utmpx_ut_host" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_UTMPX_UT_HOST 1
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_member_struct_utmp_ut_tv=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <sys/types.h>
+
+
+fi
+ac_fn_c_check_member "$LINENO" "struct utmpx" "ut_user" "ac_cv_member_struct_utmpx_ut_user" "#include <sys/types.h>
 #ifdef HAVE_UTMPX_H
 #include <utmpx.h>
 #define utmp utmpx
 #elif defined HAVE_UTMP_H
 #include <utmp.h>
 #endif
-
-int
-main ()
-{
-static struct utmp ac_aggr;
-if (sizeof ac_aggr.ut_tv)
-return 0;
-  ;
-  return 0;
-}
+"
+if test "x$ac_cv_member_struct_utmpx_ut_user" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_UTMPX_UT_USER 1
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_member_struct_utmp_ut_tv=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_member_struct_utmp_ut_tv=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_member_struct_utmp_ut_tv" >&5
-echo "${ECHO_T}$ac_cv_member_struct_utmp_ut_tv" >&6; }
-if test $ac_cv_member_struct_utmp_ut_tv = yes; then
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_UTMP_UT_TV 1
-_ACEOF
-
-
-fi
-{ echo "$as_me:$LINENO: checking for struct utmp.ut_xtime" >&5
-echo $ECHO_N "checking for struct utmp.ut_xtime... $ECHO_C" >&6; }
-if test "${ac_cv_member_struct_utmp_ut_xtime+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <sys/types.h>
+
+
+fi
+ac_fn_c_check_member "$LINENO" "struct utmpx" "ut_tv" "ac_cv_member_struct_utmpx_ut_tv" "#include <sys/types.h>
 #ifdef HAVE_UTMPX_H
 #include <utmpx.h>
 #define utmp utmpx
 #elif defined HAVE_UTMP_H
 #include <utmp.h>
 #endif
-
-int
-main ()
-{
-static struct utmp ac_aggr;
-if (ac_aggr.ut_xtime)
-return 0;
-  ;
-  return 0;
-}
+"
+if test "x$ac_cv_member_struct_utmpx_ut_tv" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_UTMPX_UT_TV 1
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_member_struct_utmp_ut_xtime=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <sys/types.h>
+
+
+fi
+ac_fn_c_check_member "$LINENO" "struct utmpx" "ut_xtime" "ac_cv_member_struct_utmpx_ut_xtime" "#include <sys/types.h>
 #ifdef HAVE_UTMPX_H
 #include <utmpx.h>
 #define utmp utmpx
 #elif defined HAVE_UTMP_H
 #include <utmp.h>
 #endif
-
-int
-main ()
-{
-static struct utmp ac_aggr;
-if (sizeof ac_aggr.ut_xtime)
-return 0;
-  ;
-  return 0;
-}
+"
+if test "x$ac_cv_member_struct_utmpx_ut_xtime" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_UTMPX_UT_XTIME 1
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_member_struct_utmp_ut_xtime=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_member_struct_utmp_ut_xtime=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_member_struct_utmp_ut_xtime" >&5
-echo "${ECHO_T}$ac_cv_member_struct_utmp_ut_xtime" >&6; }
-if test $ac_cv_member_struct_utmp_ut_xtime = yes; then
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_UTMP_UT_XTIME 1
-_ACEOF
-
-
-fi
-
-{ echo "$as_me:$LINENO: checking for struct sockaddr_storage.ss_family" >&5
-echo $ECHO_N "checking for struct sockaddr_storage.ss_family... $ECHO_C" >&6; }
-if test "${ac_cv_member_struct_sockaddr_storage_ss_family+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <sys/types.h>
+
+
+fi
+
+ac_fn_c_check_member "$LINENO" "struct sockaddr_storage" "ss_family" "ac_cv_member_struct_sockaddr_storage_ss_family" "#include <sys/types.h>
 #include <sys/socket.h>
-
-int
-main ()
-{
-static struct sockaddr_storage ac_aggr;
-if (ac_aggr.ss_family)
-return 0;
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_member_struct_sockaddr_storage_ss_family=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <sys/types.h>
-#include <sys/socket.h>
-
-int
-main ()
-{
-static struct sockaddr_storage ac_aggr;
-if (sizeof ac_aggr.ss_family)
-return 0;
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_member_struct_sockaddr_storage_ss_family=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_member_struct_sockaddr_storage_ss_family=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_member_struct_sockaddr_storage_ss_family" >&5
-echo "${ECHO_T}$ac_cv_member_struct_sockaddr_storage_ss_family" >&6; }
-if test $ac_cv_member_struct_sockaddr_storage_ss_family = yes; then
+"
+if test "x$ac_cv_member_struct_sockaddr_storage_ss_family" = xyes; then :
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY 1
@@ -7436,16 +6292,12 @@
 fi
 
 
-{ echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5
-echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6; }
-if test "${ac_cv_c_const+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5
+$as_echo_n "checking for an ANSI C-conforming const... " >&6; }
+if ${ac_cv_c_const+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
@@ -7505,53 +6357,27 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
+if ac_fn_c_try_compile "$LINENO"; then :
   ac_cv_c_const=yes
 else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_c_const=no
-fi
-
+  ac_cv_c_const=no
+fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5
-echo "${ECHO_T}$ac_cv_c_const" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5
+$as_echo "$ac_cv_c_const" >&6; }
 if test $ac_cv_c_const = no; then
 
-cat >>confdefs.h <<\_ACEOF
-#define const
-_ACEOF
-
-fi
-
-{ echo "$as_me:$LINENO: checking for working volatile" >&5
-echo $ECHO_N "checking for working volatile... $ECHO_C" >&6; }
-if test "${ac_cv_c_volatile+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+$as_echo "#define const /**/" >>confdefs.h
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working volatile" >&5
+$as_echo_n "checking for working volatile... " >&6; }
+if ${ac_cv_c_volatile+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
@@ -7565,543 +6391,120 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
+if ac_fn_c_try_compile "$LINENO"; then :
   ac_cv_c_volatile=yes
 else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_c_volatile=no
-fi
-
+  ac_cv_c_volatile=no
+fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_c_volatile" >&5
-echo "${ECHO_T}$ac_cv_c_volatile" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_volatile" >&5
+$as_echo "$ac_cv_c_volatile" >&6; }
 if test $ac_cv_c_volatile = no; then
 
-cat >>confdefs.h <<\_ACEOF
-#define volatile
-_ACEOF
-
-fi
-
-
-{ echo "$as_me:$LINENO: checking whether crypt is declared" >&5
-echo $ECHO_N "checking whether crypt is declared... $ECHO_C" >&6; }
-if test "${ac_cv_have_decl_crypt+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include "config_p.h"
+$as_echo "#define volatile /**/" >>confdefs.h
+
+fi
+
+
+ac_fn_c_check_decl "$LINENO" "crypt" "ac_cv_have_decl_crypt" "#include \"config_p.h\"
 $ac_includes_default
 #ifdef HAVE_CRYPT_H
 #include <crypt.h>
 #endif
 
-
-int
-main ()
-{
-#ifndef crypt
-  (void) crypt;
-#endif
-
-  ;
-  return 0;
-}
+"
+if test "x$ac_cv_have_decl_crypt" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_CRYPT $ac_have_decl
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_have_decl_crypt=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_have_decl_crypt=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_crypt" >&5
-echo "${ECHO_T}$ac_cv_have_decl_crypt" >&6; }
-if test $ac_cv_have_decl_crypt = yes; then
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_CRYPT 1
-_ACEOF
-
-
-else
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_CRYPT 0
-_ACEOF
-
-
-fi
-{ echo "$as_me:$LINENO: checking whether environ is declared" >&5
-echo $ECHO_N "checking whether environ is declared... $ECHO_C" >&6; }
-if test "${ac_cv_have_decl_environ+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include "config_p.h"
+ac_fn_c_check_decl "$LINENO" "environ" "ac_cv_have_decl_environ" "#include \"config_p.h\"
 $ac_includes_default
 #ifdef HAVE_CRYPT_H
 #include <crypt.h>
 #endif
 
-
-int
-main ()
-{
-#ifndef environ
-  (void) environ;
-#endif
-
-  ;
-  return 0;
-}
+"
+if test "x$ac_cv_have_decl_environ" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_ENVIRON $ac_have_decl
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_have_decl_environ=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_have_decl_environ=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_environ" >&5
-echo "${ECHO_T}$ac_cv_have_decl_environ" >&6; }
-if test $ac_cv_have_decl_environ = yes; then
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_ENVIRON 1
-_ACEOF
-
-
-else
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_ENVIRON 0
-_ACEOF
-
-
-fi
-{ echo "$as_me:$LINENO: checking whether gethostname is declared" >&5
-echo $ECHO_N "checking whether gethostname is declared... $ECHO_C" >&6; }
-if test "${ac_cv_have_decl_gethostname+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include "config_p.h"
+ac_fn_c_check_decl "$LINENO" "gethostname" "ac_cv_have_decl_gethostname" "#include \"config_p.h\"
 $ac_includes_default
 #ifdef HAVE_CRYPT_H
 #include <crypt.h>
 #endif
 
-
-int
-main ()
-{
-#ifndef gethostname
-  (void) gethostname;
-#endif
-
-  ;
-  return 0;
-}
+"
+if test "x$ac_cv_have_decl_gethostname" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_GETHOSTNAME $ac_have_decl
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_have_decl_gethostname=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_have_decl_gethostname=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_gethostname" >&5
-echo "${ECHO_T}$ac_cv_have_decl_gethostname" >&6; }
-if test $ac_cv_have_decl_gethostname = yes; then
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_GETHOSTNAME 1
-_ACEOF
-
-
-else
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_GETHOSTNAME 0
-_ACEOF
-
-
-fi
-{ echo "$as_me:$LINENO: checking whether getpgrp is declared" >&5
-echo $ECHO_N "checking whether getpgrp is declared... $ECHO_C" >&6; }
-if test "${ac_cv_have_decl_getpgrp+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include "config_p.h"
+ac_fn_c_check_decl "$LINENO" "getpgrp" "ac_cv_have_decl_getpgrp" "#include \"config_p.h\"
 $ac_includes_default
 #ifdef HAVE_CRYPT_H
 #include <crypt.h>
 #endif
 
-
-int
-main ()
-{
-#ifndef getpgrp
-  (void) getpgrp;
-#endif
-
-  ;
-  return 0;
-}
+"
+if test "x$ac_cv_have_decl_getpgrp" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_GETPGRP $ac_have_decl
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_have_decl_getpgrp=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_have_decl_getpgrp=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_getpgrp" >&5
-echo "${ECHO_T}$ac_cv_have_decl_getpgrp" >&6; }
-if test $ac_cv_have_decl_getpgrp = yes; then
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_GETPGRP 1
+
+ac_fn_c_check_func "$LINENO" "setlocale" "ac_cv_func_setlocale"
+if test "x$ac_cv_func_setlocale" = xyes; then :
+  have_setlocale=yes
+else
+  have_setlocale=no
+fi
+
+ac_fn_c_check_func "$LINENO" "catgets" "ac_cv_func_catgets"
+if test "x$ac_cv_func_catgets" = xyes; then :
+  have_catgets=yes
+else
+  have_catgets=no
+fi
+
+for ac_func in dup2 getauthid getcwd gethostname getpwent 	getutent getutxent mallinfo memmove memset mkstemp nice 	nl_langinfo sbrk setpgid setpriority strerror strstr sysconf wcwidth
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
 
-
-else
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_GETPGRP 0
-_ACEOF
-
-
-fi
-
-
-{ echo "$as_me:$LINENO: checking for setlocale" >&5
-echo $ECHO_N "checking for setlocale... $ECHO_C" >&6; }
-if test "${ac_cv_func_setlocale+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-/* Define setlocale to an innocuous variant, in case <limits.h> declares setlocale.
-   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
-#define setlocale innocuous_setlocale
-
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char setlocale (); below.
-    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-    <limits.h> exists even on freestanding compilers.  */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef setlocale
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char setlocale ();
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined __stub_setlocale || defined __stub___setlocale
-choke me
-#endif
-
-int
-main ()
-{
-return setlocale ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
-  ac_cv_func_setlocale=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_func_setlocale=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_func_setlocale" >&5
-echo "${ECHO_T}$ac_cv_func_setlocale" >&6; }
-if test $ac_cv_func_setlocale = yes; then
-  have_setlocale=yes
-else
-  have_setlocale=no
-fi
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-for ac_func in catgets dup2 getauthid getcwd gethostname getpwent 	getutent memmove memset nice nl_langinfo sbrk setpgid setpriority 	strerror strstr sysconf wcwidth
-do
-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
-if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
-   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
-#define $ac_func innocuous_$ac_func
-
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $ac_func (); below.
-    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-    <limits.h> exists even on freestanding compilers.  */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef $ac_func
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char $ac_func ();
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined __stub_$ac_func || defined __stub___$ac_func
-choke me
-#endif
-
-int
-main ()
-{
-return $ac_func ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
-  eval "$as_ac_var=yes"
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	eval "$as_ac_var=no"
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-fi
-ac_res=`eval echo '${'$as_ac_var'}'`
-	       { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_var'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
 fi
 done
 
-{ echo "$as_me:$LINENO: checking whether getpgrp requires zero arguments" >&5
-echo $ECHO_N "checking whether getpgrp requires zero arguments... $ECHO_C" >&6; }
-if test "${ac_cv_func_getpgrp_void+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getpgrp requires zero arguments" >&5
+$as_echo_n "checking whether getpgrp requires zero arguments... " >&6; }
+if ${ac_cv_func_getpgrp_void+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
   # Use it with a single arg.
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 $ac_includes_default
 int
@@ -8112,55 +6515,29 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
+if ac_fn_c_try_compile "$LINENO"; then :
   ac_cv_func_getpgrp_void=no
 else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_func_getpgrp_void=yes
-fi
-
+  ac_cv_func_getpgrp_void=yes
+fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_func_getpgrp_void" >&5
-echo "${ECHO_T}$ac_cv_func_getpgrp_void" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_getpgrp_void" >&5
+$as_echo "$ac_cv_func_getpgrp_void" >&6; }
 if test $ac_cv_func_getpgrp_void = yes; then
 
-cat >>confdefs.h <<\_ACEOF
-#define GETPGRP_VOID 1
-_ACEOF
-
-fi
-
-
-  { echo "$as_me:$LINENO: checking whether mbrtowc and mbstate_t are properly declared" >&5
-echo $ECHO_N "checking whether mbrtowc and mbstate_t are properly declared... $ECHO_C" >&6; }
-if test "${ac_cv_func_mbrtowc+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+$as_echo "#define GETPGRP_VOID 1" >>confdefs.h
+
+fi
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc and mbstate_t are properly declared" >&5
+$as_echo_n "checking whether mbrtowc and mbstate_t are properly declared... " >&6; }
+if ${ac_cv_func_mbrtowc+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <wchar.h>
 int
@@ -8175,60 +6552,32 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
+if ac_fn_c_try_link "$LINENO"; then :
   ac_cv_func_mbrtowc=yes
 else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_func_mbrtowc=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_func_mbrtowc" >&5
-echo "${ECHO_T}$ac_cv_func_mbrtowc" >&6; }
+  ac_cv_func_mbrtowc=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_mbrtowc" >&5
+$as_echo "$ac_cv_func_mbrtowc" >&6; }
   if test $ac_cv_func_mbrtowc = yes; then
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_MBRTOWC 1
-_ACEOF
+$as_echo "#define HAVE_MBRTOWC 1" >>confdefs.h
 
   fi
 
-{ echo "$as_me:$LINENO: checking whether setpgrp takes no argument" >&5
-echo $ECHO_N "checking whether setpgrp takes no argument... $ECHO_C" >&6; }
-if test "${ac_cv_func_setpgrp_void+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test "$cross_compiling" = yes; then
-  { { echo "$as_me:$LINENO: error: cannot check setpgrp when cross compiling" >&5
-echo "$as_me: error: cannot check setpgrp when cross compiling" >&2;}
-   { (exit 1); exit 1; }; }
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+if test "x${cross_compiling}" != xyes ; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether setpgrp takes no argument" >&5
+$as_echo_n "checking whether setpgrp takes no argument... " >&6; }
+if ${ac_cv_func_setpgrp_void+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "$cross_compiling" = yes; then :
+  as_fn_error $? "cannot check setpgrp when cross compiling" "$LINENO" 5
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 $ac_includes_default
 int
@@ -8242,63 +6591,36 @@
   return 0;
 }
 _ACEOF
-rm -f conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+if ac_fn_c_try_run "$LINENO"; then :
   ac_cv_func_setpgrp_void=no
 else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-ac_cv_func_setpgrp_void=yes
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-
-
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_func_setpgrp_void" >&5
-echo "${ECHO_T}$ac_cv_func_setpgrp_void" >&6; }
+  ac_cv_func_setpgrp_void=yes
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_setpgrp_void" >&5
+$as_echo "$ac_cv_func_setpgrp_void" >&6; }
 if test $ac_cv_func_setpgrp_void = yes; then
 
-cat >>confdefs.h <<\_ACEOF
-#define SETPGRP_VOID 1
-_ACEOF
-
-fi
-
-{ echo "$as_me:$LINENO: checking for working strcoll" >&5
-echo $ECHO_N "checking for working strcoll... $ECHO_C" >&6; }
-if test "${ac_cv_func_strcoll_works+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test "$cross_compiling" = yes; then
+$as_echo "#define SETPGRP_VOID 1" >>confdefs.h
+
+fi
+
+else
+  ac_cv_func_setpgrp_void=yes
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working strcoll" >&5
+$as_echo_n "checking for working strcoll... " >&6; }
+if ${ac_cv_func_strcoll_works+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "$cross_compiling" = yes; then :
   ac_cv_func_strcoll_works=no
 else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 $ac_includes_default
 int
@@ -8311,47 +6633,21 @@
   return 0;
 }
 _ACEOF
-rm -f conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+if ac_fn_c_try_run "$LINENO"; then :
   ac_cv_func_strcoll_works=yes
 else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-ac_cv_func_strcoll_works=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-
-
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_func_strcoll_works" >&5
-echo "${ECHO_T}$ac_cv_func_strcoll_works" >&6; }
+  ac_cv_func_strcoll_works=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_strcoll_works" >&5
+$as_echo "$ac_cv_func_strcoll_works" >&6; }
 if test $ac_cv_func_strcoll_works = yes; then
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_STRCOLL 1
-_ACEOF
+$as_echo "#define HAVE_STRCOLL 1" >>confdefs.h
 
 fi
 
@@ -8361,7 +6657,7 @@
 
 if test "$have_setlocale" != no; then
   # Check whether --enable-nls was given.
-if test "${enable_nls+set}" = set; then
+if test "${enable_nls+set}" = set; then :
   enableval=$enable_nls;
 else
   enable_nls=yes
@@ -8369,16 +6665,30 @@
 
   if test "x$enable_nls" != xno; then
 
-cat >>confdefs.h <<\_ACEOF
-#define NLS 1
-_ACEOF
+$as_echo "#define NLS 1" >>confdefs.h
 
   fi
 fi
 
+if test "x$enable_nls" != xno -a "$have_catgets" != no -a -n "$GENCAT" ; then
+  # Check whether --enable-nls-catalogs was given.
+if test "${enable_nls_catalogs+set}" = set; then :
+  enableval=$enable_nls_catalogs;
+else
+  enable_nls_catalogs=yes
+fi
+
+  if test "x$enable_nls_catalogs" != xno; then
+    BUILD_CATALOGS="yes"
+
+$as_echo "#define NLS_CATALOGS 1" >>confdefs.h
+
+  fi
+fi
+
 
 # Check whether --with-hesiod was given.
-if test "${with_hesiod+set}" = set; then
+if test "${with_hesiod+set}" = set; then :
   withval=$with_hesiod; hesiod="$withval"
 else
   hesiod=no
@@ -8386,102 +6696,18 @@
 
 if test "$hesiod" != no; then
   HESLIB="-lhesiod"
-  { echo "$as_me:$LINENO: checking for res_send" >&5
-echo $ECHO_N "checking for res_send... $ECHO_C" >&6; }
-if test "${ac_cv_func_res_send+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-/* Define res_send to an innocuous variant, in case <limits.h> declares res_send.
-   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
-#define res_send innocuous_res_send
-
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char res_send (); below.
-    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-    <limits.h> exists even on freestanding compilers.  */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef res_send
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char res_send ();
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined __stub_res_send || defined __stub___res_send
-choke me
-#endif
-
-int
-main ()
-{
-return res_send ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
-  ac_cv_func_res_send=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_func_res_send=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_func_res_send" >&5
-echo "${ECHO_T}$ac_cv_func_res_send" >&6; }
-if test $ac_cv_func_res_send = yes; then
+  ac_fn_c_check_func "$LINENO" "res_send" "ac_cv_func_res_send"
+if test "x$ac_cv_func_res_send" = xyes; then :
   :
 else
-  { echo "$as_me:$LINENO: checking for res_send in -lresolv" >&5
-echo $ECHO_N "checking for res_send in -lresolv... $ECHO_C" >&6; }
-if test "${ac_cv_lib_resolv_res_send+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for res_send in -lresolv" >&5
+$as_echo_n "checking for res_send in -lresolv... " >&6; }
+if ${ac_cv_lib_resolv_res_send+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lresolv  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 /* Override any GCC internal prototype to avoid an error.
@@ -8499,39 +6725,18 @@
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
+if ac_fn_c_try_link "$LINENO"; then :
   ac_cv_lib_resolv_res_send=yes
 else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_lib_resolv_res_send=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
+  ac_cv_lib_resolv_res_send=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_resolv_res_send" >&5
-echo "${ECHO_T}$ac_cv_lib_resolv_res_send" >&6; }
-if test $ac_cv_lib_resolv_res_send = yes; then
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_resolv_res_send" >&5
+$as_echo "$ac_cv_lib_resolv_res_send" >&6; }
+if test "x$ac_cv_lib_resolv_res_send" = xyes; then :
   HESLIB="$HESLIB -lresolv"
 fi
 
@@ -8546,7 +6751,8 @@
 
 
 
-ac_config_files="$ac_config_files Makefile"
+
+ac_config_files="$ac_config_files Makefile nls/Makefile"
 
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
@@ -8575,12 +6781,13 @@
     case $ac_val in #(
     *${as_nl}*)
       case $ac_var in #(
-      *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5
-echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;;
+      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
       esac
       case $ac_var in #(
       _ | IFS | as_nl) ;; #(
-      *) $as_unset $ac_var ;;
+      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+      *) { eval $ac_var=; unset $ac_var;} ;;
       esac ;;
     esac
   done
@@ -8588,8 +6795,8 @@
   (set) 2>&1 |
     case $as_nl`(ac_space=' '; set) 2>&1` in #(
     *${as_nl}ac_space=\ *)
-      # `set' does not quote correctly, so add quotes (double-quote
-      # substitution turns \\\\ into \\, and sed turns \\ into \).
+      # `set' does not quote correctly, so add quotes: double-quote
+      # substitution turns \\\\ into \\, and sed turns \\ into \.
       sed -n \
 	"s/'/'\\\\''/g;
 	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
@@ -8611,13 +6818,24 @@
      :end' >>confcache
 if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
   if test -w "$cache_file"; then
-    test "x$cache_file" != "x/dev/null" &&
-      { echo "$as_me:$LINENO: updating cache $cache_file" >&5
-echo "$as_me: updating cache $cache_file" >&6;}
-    cat confcache >$cache_file
+    if test "x$cache_file" != "x/dev/null"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
+$as_echo "$as_me: updating cache $cache_file" >&6;}
+      if test ! -f "$cache_file" || test -h "$cache_file"; then
+	cat confcache >"$cache_file"
+      else
+        case $cache_file in #(
+        */* | ?:*)
+	  mv -f confcache "$cache_file"$$ &&
+	  mv -f "$cache_file"$$ "$cache_file" ;; #(
+        *)
+	  mv -f confcache "$cache_file" ;;
+	esac
+      fi
+    fi
   else
-    { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5
-echo "$as_me: not updating unwritable cache $cache_file" >&6;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
+$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
   fi
 fi
 rm -f confcache
@@ -8630,14 +6848,15 @@
 
 ac_libobjs=
 ac_ltlibobjs=
+U=
 for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
   # 1. Remove the extension, and $U if already installed.
   ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
-  ac_i=`echo "$ac_i" | sed "$ac_script"`
+  ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
   # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR
   #    will be set to the directory where LIBOBJS objects are built.
-  ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext"
-  ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo'
+  as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
+  as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
 done
 LIBOBJS=$ac_libobjs
 
@@ -8645,12 +6864,14 @@
 
 
 
-: ${CONFIG_STATUS=./config.status}
+: "${CONFIG_STATUS=./config.status}"
+ac_write_fail=0
 ac_clean_files_save=$ac_clean_files
 ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
-echo "$as_me: creating $CONFIG_STATUS" >&6;}
-cat >$CONFIG_STATUS <<_ACEOF
+{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
+$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
+as_write_fail=0
+cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
 #! $SHELL
 # Generated by $as_me.
 # Run this file to recreate the current configuration.
@@ -8660,59 +6881,79 @@
 debug=false
 ac_cs_recheck=false
 ac_cs_silent=false
+
 SHELL=\${CONFIG_SHELL-$SHELL}
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-## --------------------- ##
-## M4sh Initialization.  ##
-## --------------------- ##
+export SHELL
+_ASEOF
+cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
 
 # Be more Bourne compatible
 DUALCASE=1; export DUALCASE # for MKS sh
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
   emulate sh
   NULLCMD=:
-  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
   # is contrary to our usage.  Disable this feature.
   alias -g '${1+"$@"}'='"$@"'
   setopt NO_GLOB_SUBST
 else
-  case `(set -o) 2>/dev/null` in
-  *posix*) set -o posix ;;
+  case `(set -o) 2>/dev/null` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
 esac
-
-fi
-
-
-
-
-# PATH needs CR
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='print -r --'
+  as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='printf %s\n'
+  as_echo_n='printf %s'
+else
+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+    as_echo_n='/usr/ucb/echo -n'
+  else
+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+    as_echo_n_body='eval
+      arg=$1;
+      case $arg in #(
+      *"$as_nl"*)
+	expr "X$arg" : "X\\(.*\\)$as_nl";
+	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+      esac;
+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+    '
+    export as_echo_n_body
+    as_echo_n='sh -c $as_echo_n_body as_echo'
+  fi
+  export as_echo_body
+  as_echo='sh -c $as_echo_body as_echo'
+fi
 
 # The user is always right.
 if test "${PATH_SEPARATOR+set}" != set; then
-  echo "#! /bin/sh" >conf$$.sh
-  echo  "exit 0"   >>conf$$.sh
-  chmod +x conf$$.sh
-  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
-    PATH_SEPARATOR=';'
-  else
-    PATH_SEPARATOR=:
-  fi
-  rm -f conf$$.sh
-fi
-
-# Support unset when possible.
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
-  as_unset=unset
-else
-  as_unset=false
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
 fi
 
 
@@ -8721,20 +6962,19 @@
 # there to prevent editors from complaining about space-tab.
 # (If _AS_PATH_WALK were called with IFS unset, it would disable word
 # splitting by setting IFS to empty value.)
-as_nl='
-'
 IFS=" ""	$as_nl"
 
 # Find who we are.  Look in the path if we contain no directory separator.
-case $0 in
+as_myself=
+case $0 in #((
   *[\\/]* ) as_myself=$0 ;;
   *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-  test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-done
+    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+  done
 IFS=$as_save_IFS
 
      ;;
@@ -8745,32 +6985,111 @@
   as_myself=$0
 fi
 if test ! -f "$as_myself"; then
-  echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
-  { (exit 1); exit 1; }
-fi
-
-# Work around bugs in pre-3.0 UWIN ksh.
-for as_var in ENV MAIL MAILPATH
-do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there.  '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
 done
 PS1='$ '
 PS2='> '
 PS4='+ '
 
 # NLS nuisances.
-for as_var in \
-  LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
-  LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
-  LC_TELEPHONE LC_TIME
-do
-  if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
-    eval $as_var=C; export $as_var
-  else
-    ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with STATUS, using 1 if that was 0.
+as_fn_error ()
+{
+  as_status=$1; test $as_status -eq 0 && as_status=1
+  if test "$4"; then
+    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
   fi
-done
-
-# Required to use basename.
+  $as_echo "$as_me: error: $2" >&2
+  as_fn_exit $as_status
+} # as_fn_error
+
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+  return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+  set +e
+  as_fn_set_status $1
+  exit $1
+} # as_fn_exit
+
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+  { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+  eval 'as_fn_append ()
+  {
+    eval $1+=\$2
+  }'
+else
+  as_fn_append ()
+  {
+    eval $1=\$$1\$2
+  }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+  eval 'as_fn_arith ()
+  {
+    as_val=$(( $* ))
+  }'
+else
+  as_fn_arith ()
+  {
+    as_val=`expr "$@" || test $? -eq 1`
+  }
+fi # as_fn_arith
+
+
 if expr a : '\(a\)' >/dev/null 2>&1 &&
    test "X`expr 00001 : '.*\(...\)'`" = X001; then
   as_expr=expr
@@ -8784,13 +7103,17 @@
   as_basename=false
 fi
 
-
-# Name of the executable.
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
 as_me=`$as_basename -- "$0" ||
 $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
 	 X"$0" : 'X\(//\)$' \| \
 	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
-echo X/"$0" |
+$as_echo X/"$0" |
     sed '/^.*\/\([^/][^/]*\)\/*$/{
 	    s//\1/
 	    q
@@ -8805,584 +7128,68 @@
 	  }
 	  s/.*/./; q'`
 
-# CDPATH.
-$as_unset CDPATH
-
-
-
-  as_lineno_1=$LINENO
-  as_lineno_2=$LINENO
-  test "x$as_lineno_1" != "x$as_lineno_2" &&
-  test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
-
-  # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
-  # uniformly replaced by the line number.  The first 'sed' inserts a
-  # line-number line after each line using $LINENO; the second 'sed'
-  # does the real work.  The second script uses 'N' to pair each
-  # line-number line with the line containing $LINENO, and appends
-  # trailing '-' during substitution so that $LINENO is not a special
-  # case at line end.
-  # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
-  # scripts with optimization help from Paolo Bonzini.  Blame Lee
-  # E. McMahon (1931-1989) for sed's syntax.  :-)
-  sed -n '
-    p
-    /[$]LINENO/=
-  ' <$as_myself |
-    sed '
-      s/[$]LINENO.*/&-/
-      t lineno
-      b
-      :lineno
-      N
-      :loop
-      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
-      t loop
-      s/-\n.*//
-    ' >$as_me.lineno &&
-  chmod +x "$as_me.lineno" ||
-    { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
-   { (exit 1); exit 1; }; }
-
-  # Don't try to exec as it changes $[0], causing all sort of problems
-  # (the dirname of $[0] is not the place where we might find the
-  # original and so on.  Autoconf is especially sensitive to this).
-  . "./$as_me.lineno"
-  # Exit status is that of the last command.
-  exit
-}
-
-
-if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
-  as_dirname=dirname
-else
-  as_dirname=false
-fi
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
 
 ECHO_C= ECHO_N= ECHO_T=
-case `echo -n x` in
+case `echo -n x` in #(((((
 -n*)
-  case `echo 'x\c'` in
+  case `echo 'xy\c'` in
   *c*) ECHO_T='	';;	# ECHO_T is single tab character.
-  *)   ECHO_C='\c';;
+  xy)  ECHO_C='\c';;
+  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
+       ECHO_T='	';;
   esac;;
 *)
   ECHO_N='-n';;
 esac
 
-if expr a : '\(a\)' >/dev/null 2>&1 &&
-   test "X`expr 00001 : '.*\(...\)'`" = X001; then
-  as_expr=expr
-else
-  as_expr=false
-fi
-
 rm -f conf$$ conf$$.exe conf$$.file
 if test -d conf$$.dir; then
   rm -f conf$$.dir/conf$$.file
 else
   rm -f conf$$.dir
-  mkdir conf$$.dir
-fi
-echo >conf$$.file
-if ln -s conf$$.file conf$$ 2>/dev/null; then
-  as_ln_s='ln -s'
-  # ... but there are two gotchas:
-  # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
-  # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-  # In both cases, we have to default to `cp -p'.
-  ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+  mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+  if ln -s conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s='ln -s'
+    # ... but there are two gotchas:
+    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+    # In both cases, we have to default to `cp -p'.
+    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+      as_ln_s='cp -p'
+  elif ln conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s=ln
+  else
     as_ln_s='cp -p'
-elif ln conf$$.file conf$$ 2>/dev/null; then
-  as_ln_s=ln
+  fi
 else
   as_ln_s='cp -p'
 fi
 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
 rmdir conf$$.dir 2>/dev/null
 
-if mkdir -p . 2>/dev/null; then
-  as_mkdir_p=:
-else
-  test -d ./-p && rmdir ./-p
-  as_mkdir_p=false
-fi
-
-if test -x / >/dev/null 2>&1; then
-  as_test_x='test -x'
-else
-  if ls -dL / >/dev/null 2>&1; then
-    as_ls_L_option=L
-  else
-    as_ls_L_option=
-  fi
-  as_test_x='
-    eval sh -c '\''
-      if test -d "$1"; then
-        test -d "$1/.";
-      else
-	case $1 in
-        -*)set "./$1";;
-	esac;
-	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
-	???[sx]*):;;*)false;;esac;fi
-    '\'' sh
-  '
-fi
-as_executable_p=$as_test_x
-
-# Sed expression to map a string onto a valid CPP name.
-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
-exec 6>&1
-
-# Save the log message, to keep $[0] and so on meaningful, and to
-# report actual input values of CONFIG_FILES etc. instead of their
-# values after options handling.
-ac_log="
-This file was extended by tcsh $as_me 6.17.00, which was
-generated by GNU Autoconf 2.61.  Invocation command line was
-
-  CONFIG_FILES    = $CONFIG_FILES
-  CONFIG_HEADERS  = $CONFIG_HEADERS
-  CONFIG_LINKS    = $CONFIG_LINKS
-  CONFIG_COMMANDS = $CONFIG_COMMANDS
-  $ $0 $@
-
-on `(hostname || uname -n) 2>/dev/null | sed 1q`
-"
-
-_ACEOF
-
-cat >>$CONFIG_STATUS <<_ACEOF
-# Files that config.status was made for.
-config_files="$ac_config_files"
-config_headers="$ac_config_headers"
-config_commands="$ac_config_commands"
-
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-ac_cs_usage="\
-\`$as_me' instantiates files from templates according to the
-current configuration.
-
-Usage: $0 [OPTIONS] [FILE]...
-
-  -h, --help       print this help, then exit
-  -V, --version    print version number and configuration settings, then exit
-  -q, --quiet      do not print progress messages
-  -d, --debug      don't remove temporary files
-      --recheck    update $as_me by reconfiguring in the same conditions
-  --file=FILE[:TEMPLATE]
-		   instantiate the configuration file FILE
-  --header=FILE[:TEMPLATE]
-		   instantiate the configuration header FILE
-
-Configuration files:
-$config_files
-
-Configuration headers:
-$config_headers
-
-Configuration commands:
-$config_commands
-
-Report bugs to <bug-autoconf at gnu.org>."
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF
-ac_cs_version="\\
-tcsh config.status 6.17.00
-configured by $0, generated by GNU Autoconf 2.61,
-  with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
-
-Copyright (C) 2006 Free Software Foundation, Inc.
-This config.status script is free software; the Free Software Foundation
-gives unlimited permission to copy, distribute and modify it."
-
-ac_pwd='$ac_pwd'
-srcdir='$srcdir'
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-# If no file are specified by the user, then we need to provide default
-# value.  By we need to know if files were specified by the user.
-ac_need_defaults=:
-while test $# != 0
-do
-  case $1 in
-  --*=*)
-    ac_option=`expr "X$1" : 'X\([^=]*\)='`
-    ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
-    ac_shift=:
-    ;;
-  *)
-    ac_option=$1
-    ac_optarg=$2
-    ac_shift=shift
-    ;;
-  esac
-
-  case $ac_option in
-  # Handling of the options.
-  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
-    ac_cs_recheck=: ;;
-  --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
-    echo "$ac_cs_version"; exit ;;
-  --debug | --debu | --deb | --de | --d | -d )
-    debug=: ;;
-  --file | --fil | --fi | --f )
-    $ac_shift
-    CONFIG_FILES="$CONFIG_FILES $ac_optarg"
-    ac_need_defaults=false;;
-  --header | --heade | --head | --hea )
-    $ac_shift
-    CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
-    ac_need_defaults=false;;
-  --he | --h)
-    # Conflict between --help and --header
-    { echo "$as_me: error: ambiguous option: $1
-Try \`$0 --help' for more information." >&2
-   { (exit 1); exit 1; }; };;
-  --help | --hel | -h )
-    echo "$ac_cs_usage"; exit ;;
-  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
-  | -silent | --silent | --silen | --sile | --sil | --si | --s)
-    ac_cs_silent=: ;;
-
-  # This is an error.
-  -*) { echo "$as_me: error: unrecognized option: $1
-Try \`$0 --help' for more information." >&2
-   { (exit 1); exit 1; }; } ;;
-
-  *) ac_config_targets="$ac_config_targets $1"
-     ac_need_defaults=false ;;
-
-  esac
-  shift
-done
-
-ac_configure_extra_args=
-
-if $ac_cs_silent; then
-  exec 6>/dev/null
-  ac_configure_extra_args="$ac_configure_extra_args --silent"
-fi
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF
-if \$ac_cs_recheck; then
-  echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
-  CONFIG_SHELL=$SHELL
-  export CONFIG_SHELL
-  exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
-fi
-
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-exec 5>>config.log
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
 {
-  echo
-  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
-## Running $as_me. ##
-_ASBOX
-  echo "$ac_log"
-} >&5
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-
-# Handling of arguments.
-for ac_config_target in $ac_config_targets
-do
-  case $ac_config_target in
-    "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
-    "./atconfig") CONFIG_COMMANDS="$CONFIG_COMMANDS ./atconfig" ;;
-    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
-
-  *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
-echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
-   { (exit 1); exit 1; }; };;
-  esac
-done
-
-
-# If the user did not use the arguments to specify the items to instantiate,
-# then the envvar interface is used.  Set only those that are not.
-# We use the long form for the default assignment because of an extremely
-# bizarre bug on SunOS 4.1.3.
-if $ac_need_defaults; then
-  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
-  test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
-  test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
-fi
-
-# Have a temporary directory for convenience.  Make it in the build tree
-# simply because there is no reason against having it here, and in addition,
-# creating and moving files from /tmp can sometimes cause problems.
-# Hook for its removal unless debugging.
-# Note that there is a small window in which the directory will not be cleaned:
-# after its creation but before its name has been assigned to `$tmp'.
-$debug ||
-{
-  tmp=
-  trap 'exit_status=$?
-  { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
-' 0
-  trap '{ (exit 1); exit 1; }' 1 2 13 15
-}
-# Create a (secure) tmp directory for tmp files.
-
-{
-  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
-  test -n "$tmp" && test -d "$tmp"
-}  ||
-{
-  tmp=./conf$$-$RANDOM
-  (umask 077 && mkdir "$tmp")
-} ||
-{
-   echo "$me: cannot create a temporary directory in ." >&2
-   { (exit 1); exit 1; }
-}
-
-#
-# Set up the sed scripts for CONFIG_FILES section.
-#
-
-# No need to generate the scripts if there are no CONFIG_FILES.
-# This happens for instance when ./config.status config.h
-if test -n "$CONFIG_FILES"; then
-
-_ACEOF
-
-
-
-ac_delim='%!_!# '
-for ac_last_try in false false false false false :; do
-  cat >conf$$subs.sed <<_ACEOF
-SHELL!$SHELL$ac_delim
-PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim
-PACKAGE_NAME!$PACKAGE_NAME$ac_delim
-PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim
-PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim
-PACKAGE_STRING!$PACKAGE_STRING$ac_delim
-PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim
-exec_prefix!$exec_prefix$ac_delim
-prefix!$prefix$ac_delim
-program_transform_name!$program_transform_name$ac_delim
-bindir!$bindir$ac_delim
-sbindir!$sbindir$ac_delim
-libexecdir!$libexecdir$ac_delim
-datarootdir!$datarootdir$ac_delim
-datadir!$datadir$ac_delim
-sysconfdir!$sysconfdir$ac_delim
-sharedstatedir!$sharedstatedir$ac_delim
-localstatedir!$localstatedir$ac_delim
-includedir!$includedir$ac_delim
-oldincludedir!$oldincludedir$ac_delim
-docdir!$docdir$ac_delim
-infodir!$infodir$ac_delim
-htmldir!$htmldir$ac_delim
-dvidir!$dvidir$ac_delim
-pdfdir!$pdfdir$ac_delim
-psdir!$psdir$ac_delim
-libdir!$libdir$ac_delim
-localedir!$localedir$ac_delim
-mandir!$mandir$ac_delim
-DEFS!$DEFS$ac_delim
-ECHO_C!$ECHO_C$ac_delim
-ECHO_N!$ECHO_N$ac_delim
-ECHO_T!$ECHO_T$ac_delim
-LIBS!$LIBS$ac_delim
-build_alias!$build_alias$ac_delim
-host_alias!$host_alias$ac_delim
-target_alias!$target_alias$ac_delim
-build!$build$ac_delim
-build_cpu!$build_cpu$ac_delim
-build_vendor!$build_vendor$ac_delim
-build_os!$build_os$ac_delim
-host!$host$ac_delim
-host_cpu!$host_cpu$ac_delim
-host_vendor!$host_vendor$ac_delim
-host_os!$host_os$ac_delim
-CC!$CC$ac_delim
-CFLAGS!$CFLAGS$ac_delim
-LDFLAGS!$LDFLAGS$ac_delim
-CPPFLAGS!$CPPFLAGS$ac_delim
-ac_ct_CC!$ac_ct_CC$ac_delim
-EXEEXT!$EXEEXT$ac_delim
-OBJEXT!$OBJEXT$ac_delim
-CPP!$CPP$ac_delim
-GREP!$GREP$ac_delim
-EGREP!$EGREP$ac_delim
-LIBICONV!$LIBICONV$ac_delim
-LTLIBICONV!$LTLIBICONV$ac_delim
-DFLAGS!$DFLAGS$ac_delim
-HESDEF!$HESDEF$ac_delim
-HESLIB!$HESLIB$ac_delim
-LIBOBJS!$LIBOBJS$ac_delim
-LTLIBOBJS!$LTLIBOBJS$ac_delim
-_ACEOF
-
-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 62; then
-    break
-  elif $ac_last_try; then
-    { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
-echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
-   { (exit 1); exit 1; }; }
-  else
-    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
-  fi
-done
-
-ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed`
-if test -n "$ac_eof"; then
-  ac_eof=`echo "$ac_eof" | sort -nru | sed 1q`
-  ac_eof=`expr $ac_eof + 1`
-fi
-
-cat >>$CONFIG_STATUS <<_ACEOF
-cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof
-/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end
-_ACEOF
-sed '
-s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g
-s/^/s,@/; s/!/@,|#_!!_#|/
-:n
-t n
-s/'"$ac_delim"'$/,g/; t
-s/$/\\/; p
-N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n
-' >>$CONFIG_STATUS <conf$$subs.sed
-rm -f conf$$subs.sed
-cat >>$CONFIG_STATUS <<_ACEOF
-:end
-s/|#_!!_#|//g
-CEOF$ac_eof
-_ACEOF
-
-
-# VPATH may cause trouble with some makes, so we remove $(srcdir),
-# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
-# trailing colons and then remove the whole line if VPATH becomes empty
-# (actually we leave an empty line to preserve line numbers).
-if test "x$srcdir" = x.; then
-  ac_vpsub='/^[	 ]*VPATH[	 ]*=/{
-s/:*\$(srcdir):*/:/
-s/:*\${srcdir}:*/:/
-s/:*@srcdir@:*/:/
-s/^\([^=]*=[	 ]*\):*/\1/
-s/:*$//
-s/^[^=]*=[	 ]*$//
-}'
-fi
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-fi # test -n "$CONFIG_FILES"
-
-
-for ac_tag in  :F $CONFIG_FILES  :H $CONFIG_HEADERS    :C $CONFIG_COMMANDS
-do
-  case $ac_tag in
-  :[FHLC]) ac_mode=$ac_tag; continue;;
-  esac
-  case $ac_mode$ac_tag in
-  :[FHL]*:*);;
-  :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5
-echo "$as_me: error: Invalid tag $ac_tag." >&2;}
-   { (exit 1); exit 1; }; };;
-  :[FH]-) ac_tag=-:-;;
-  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
-  esac
-  ac_save_IFS=$IFS
-  IFS=:
-  set x $ac_tag
-  IFS=$ac_save_IFS
-  shift
-  ac_file=$1
-  shift
-
-  case $ac_mode in
-  :L) ac_source=$1;;
-  :[FH])
-    ac_file_inputs=
-    for ac_f
-    do
-      case $ac_f in
-      -) ac_f="$tmp/stdin";;
-      *) # Look for the file first in the build tree, then in the source tree
-	 # (if the path is not absolute).  The absolute path cannot be DOS-style,
-	 # because $ac_f cannot contain `:'.
-	 test -f "$ac_f" ||
-	   case $ac_f in
-	   [\\/$]*) false;;
-	   *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
-	   esac ||
-	   { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5
-echo "$as_me: error: cannot find input file: $ac_f" >&2;}
-   { (exit 1); exit 1; }; };;
-      esac
-      ac_file_inputs="$ac_file_inputs $ac_f"
-    done
-
-    # Let's still pretend it is `configure' which instantiates (i.e., don't
-    # use $as_me), people would be surprised to read:
-    #    /* config.h.  Generated by config.status.  */
-    configure_input="Generated from "`IFS=:
-	  echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure."
-    if test x"$ac_file" != x-; then
-      configure_input="$ac_file.  $configure_input"
-      { echo "$as_me:$LINENO: creating $ac_file" >&5
-echo "$as_me: creating $ac_file" >&6;}
-    fi
-
-    case $ac_tag in
-    *:-:* | *:-) cat >"$tmp/stdin";;
-    esac
-    ;;
-  esac
-
-  ac_dir=`$as_dirname -- "$ac_file" ||
-$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$ac_file" : 'X\(//\)[^/]' \| \
-	 X"$ac_file" : 'X\(//\)$' \| \
-	 X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
-echo X"$ac_file" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)[^/].*/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\).*/{
-	    s//\1/
-	    q
-	  }
-	  s/.*/./; q'`
-  { as_dir="$ac_dir"
+
   case $as_dir in #(
   -*) as_dir=./$as_dir;;
   esac
-  test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
+  test -d "$as_dir" || eval $as_mkdir_p || {
     as_dirs=
     while :; do
       case $as_dir in #(
-      *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #(
+      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
       *) as_qdir=$as_dir;;
       esac
       as_dirs="'$as_qdir' $as_dirs"
@@ -9391,7 +7198,7 @@
 	 X"$as_dir" : 'X\(//\)[^/]' \| \
 	 X"$as_dir" : 'X\(//\)$' \| \
 	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
-echo X"$as_dir" |
+$as_echo X"$as_dir" |
     sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
 	    s//\1/
 	    q
@@ -9412,17 +7219,667 @@
       test -d "$as_dir" && break
     done
     test -z "$as_dirs" || eval "mkdir $as_dirs"
-  } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5
-echo "$as_me: error: cannot create directory $as_dir" >&2;}
-   { (exit 1); exit 1; }; }; }
+  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p='mkdir -p "$as_dir"'
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+  as_test_x='test -x'
+else
+  if ls -dL / >/dev/null 2>&1; then
+    as_ls_L_option=L
+  else
+    as_ls_L_option=
+  fi
+  as_test_x='
+    eval sh -c '\''
+      if test -d "$1"; then
+	test -d "$1/.";
+      else
+	case $1 in #(
+	-*)set "./$1";;
+	esac;
+	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
+	???[sx]*):;;*)false;;esac;fi
+    '\'' sh
+  '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+exec 6>&1
+## ----------------------------------- ##
+## Main body of $CONFIG_STATUS script. ##
+## ----------------------------------- ##
+_ASEOF
+test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# Save the log message, to keep $0 and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling.
+ac_log="
+This file was extended by tcsh $as_me 6.18.01, which was
+generated by GNU Autoconf 2.68.  Invocation command line was
+
+  CONFIG_FILES    = $CONFIG_FILES
+  CONFIG_HEADERS  = $CONFIG_HEADERS
+  CONFIG_LINKS    = $CONFIG_LINKS
+  CONFIG_COMMANDS = $CONFIG_COMMANDS
+  $ $0 $@
+
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+"
+
+_ACEOF
+
+case $ac_config_files in *"
+"*) set x $ac_config_files; shift; ac_config_files=$*;;
+esac
+
+case $ac_config_headers in *"
+"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
+esac
+
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+# Files that config.status was made for.
+config_files="$ac_config_files"
+config_headers="$ac_config_headers"
+config_commands="$ac_config_commands"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+ac_cs_usage="\
+\`$as_me' instantiates files and other configuration actions
+from templates according to the current configuration.  Unless the files
+and actions are specified as TAGs, all are instantiated by default.
+
+Usage: $0 [OPTION]... [TAG]...
+
+  -h, --help       print this help, then exit
+  -V, --version    print version number and configuration settings, then exit
+      --config     print configuration, then exit
+  -q, --quiet, --silent
+                   do not print progress messages
+  -d, --debug      don't remove temporary files
+      --recheck    update $as_me by reconfiguring in the same conditions
+      --file=FILE[:TEMPLATE]
+                   instantiate the configuration file FILE
+      --header=FILE[:TEMPLATE]
+                   instantiate the configuration header FILE
+
+Configuration files:
+$config_files
+
+Configuration headers:
+$config_headers
+
+Configuration commands:
+$config_commands
+
+Report bugs to <http://bugs.gw.com/>."
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
+ac_cs_version="\\
+tcsh config.status 6.18.01
+configured by $0, generated by GNU Autoconf 2.68,
+  with options \\"\$ac_cs_config\\"
+
+Copyright (C) 2010 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+
+ac_pwd='$ac_pwd'
+srcdir='$srcdir'
+INSTALL='$INSTALL'
+test -n "\$AWK" || AWK=awk
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# The default lists apply if the user does not specify any file.
+ac_need_defaults=:
+while test $# != 0
+do
+  case $1 in
+  --*=?*)
+    ac_option=`expr "X$1" : 'X\([^=]*\)='`
+    ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
+    ac_shift=:
+    ;;
+  --*=)
+    ac_option=`expr "X$1" : 'X\([^=]*\)='`
+    ac_optarg=
+    ac_shift=:
+    ;;
+  *)
+    ac_option=$1
+    ac_optarg=$2
+    ac_shift=shift
+    ;;
+  esac
+
+  case $ac_option in
+  # Handling of the options.
+  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+    ac_cs_recheck=: ;;
+  --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
+    $as_echo "$ac_cs_version"; exit ;;
+  --config | --confi | --conf | --con | --co | --c )
+    $as_echo "$ac_cs_config"; exit ;;
+  --debug | --debu | --deb | --de | --d | -d )
+    debug=: ;;
+  --file | --fil | --fi | --f )
+    $ac_shift
+    case $ac_optarg in
+    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    '') as_fn_error $? "missing file argument" ;;
+    esac
+    as_fn_append CONFIG_FILES " '$ac_optarg'"
+    ac_need_defaults=false;;
+  --header | --heade | --head | --hea )
+    $ac_shift
+    case $ac_optarg in
+    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    as_fn_append CONFIG_HEADERS " '$ac_optarg'"
+    ac_need_defaults=false;;
+  --he | --h)
+    # Conflict between --help and --header
+    as_fn_error $? "ambiguous option: \`$1'
+Try \`$0 --help' for more information.";;
+  --help | --hel | -h )
+    $as_echo "$ac_cs_usage"; exit ;;
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil | --si | --s)
+    ac_cs_silent=: ;;
+
+  # This is an error.
+  -*) as_fn_error $? "unrecognized option: \`$1'
+Try \`$0 --help' for more information." ;;
+
+  *) as_fn_append ac_config_targets " $1"
+     ac_need_defaults=false ;;
+
+  esac
+  shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+  exec 6>/dev/null
+  ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+if \$ac_cs_recheck; then
+  set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+  shift
+  \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
+  CONFIG_SHELL='$SHELL'
+  export CONFIG_SHELL
+  exec "\$@"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+exec 5>>config.log
+{
+  echo
+  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+  $as_echo "$ac_log"
+} >&5
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+#
+# INIT-COMMANDS
+#
+
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+
+# Handling of arguments.
+for ac_config_target in $ac_config_targets
+do
+  case $ac_config_target in
+    "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
+    "./atconfig") CONFIG_COMMANDS="$CONFIG_COMMANDS ./atconfig" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+    "nls/Makefile") CONFIG_FILES="$CONFIG_FILES nls/Makefile" ;;
+
+  *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
+  esac
+done
+
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used.  Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+  test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+  test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
+fi
+
+# Have a temporary directory for convenience.  Make it in the build tree
+# simply because there is no reason against having it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Hook for its removal unless debugging.
+# Note that there is a small window in which the directory will not be cleaned:
+# after its creation but before its name has been assigned to `$tmp'.
+$debug ||
+{
+  tmp= ac_tmp=
+  trap 'exit_status=$?
+  : "${ac_tmp:=$tmp}"
+  { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
+' 0
+  trap 'as_fn_exit 1' 1 2 13 15
+}
+# Create a (secure) tmp directory for tmp files.
+
+{
+  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
+  test -d "$tmp"
+}  ||
+{
+  tmp=./conf$$-$RANDOM
+  (umask 077 && mkdir "$tmp")
+} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
+ac_tmp=$tmp
+
+# Set up the scripts for CONFIG_FILES section.
+# No need to generate them if there are no CONFIG_FILES.
+# This happens for instance with `./config.status config.h'.
+if test -n "$CONFIG_FILES"; then
+
+
+ac_cr=`echo X | tr X '\015'`
+# On cygwin, bash can eat \r inside `` if the user requested igncr.
+# But we know of no other shell where ac_cr would be empty at this
+# point, so we can use a bashism as a fallback.
+if test "x$ac_cr" = x; then
+  eval ac_cr=\$\'\\r\'
+fi
+ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
+if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
+  ac_cs_awk_cr='\\r'
+else
+  ac_cs_awk_cr=$ac_cr
+fi
+
+echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
+_ACEOF
+
+
+{
+  echo "cat >conf$$subs.awk <<_ACEOF" &&
+  echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
+  echo "_ACEOF"
+} >conf$$subs.sh ||
+  as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+  . ./conf$$subs.sh ||
+    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+
+  ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
+  if test $ac_delim_n = $ac_delim_num; then
+    break
+  elif $ac_last_try; then
+    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+rm -f conf$$subs.sh
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
+_ACEOF
+sed -n '
+h
+s/^/S["/; s/!.*/"]=/
+p
+g
+s/^[^!]*!//
+:repl
+t repl
+s/'"$ac_delim"'$//
+t delim
+:nl
+h
+s/\(.\{148\}\)..*/\1/
+t more1
+s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
+p
+n
+b repl
+:more1
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t nl
+:delim
+h
+s/\(.\{148\}\)..*/\1/
+t more2
+s/["\\]/\\&/g; s/^/"/; s/$/"/
+p
+b
+:more2
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t delim
+' <conf$$subs.awk | sed '
+/^[^""]/{
+  N
+  s/\n//
+}
+' >>$CONFIG_STATUS || ac_write_fail=1
+rm -f conf$$subs.awk
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+_ACAWK
+cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
+  for (key in S) S_is_set[key] = 1
+  FS = ""
+
+}
+{
+  line = $ 0
+  nfields = split(line, field, "@")
+  substed = 0
+  len = length(field[1])
+  for (i = 2; i < nfields; i++) {
+    key = field[i]
+    keylen = length(key)
+    if (S_is_set[key]) {
+      value = S[key]
+      line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
+      len += length(value) + length(field[++i])
+      substed = 1
+    } else
+      len += 1 + keylen
+  }
+
+  print line
+}
+
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
+  sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
+else
+  cat
+fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
+  || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
+_ACEOF
+
+# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
+# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+  ac_vpsub='/^[	 ]*VPATH[	 ]*=[	 ]*/{
+h
+s///
+s/^/:/
+s/[	 ]*$/:/
+s/:\$(srcdir):/:/g
+s/:\${srcdir}:/:/g
+s/:@srcdir@:/:/g
+s/^:*//
+s/:*$//
+x
+s/\(=[	 ]*\).*/\1/
+G
+s/\n//
+s/^[^=]*=[	 ]*$//
+}'
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+fi # test -n "$CONFIG_FILES"
+
+# Set up the scripts for CONFIG_HEADERS section.
+# No need to generate them if there are no CONFIG_HEADERS.
+# This happens for instance with `./config.status Makefile'.
+if test -n "$CONFIG_HEADERS"; then
+cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
+BEGIN {
+_ACEOF
+
+# Transform confdefs.h into an awk script `defines.awk', embedded as
+# here-document in config.status, that substitutes the proper values into
+# config.h.in to produce config.h.
+
+# Create a delimiter string that does not exist in confdefs.h, to ease
+# handling of long lines.
+ac_delim='%!_!# '
+for ac_last_try in false false :; do
+  ac_tt=`sed -n "/$ac_delim/p" confdefs.h`
+  if test -z "$ac_tt"; then
+    break
+  elif $ac_last_try; then
+    as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+
+# For the awk script, D is an array of macro values keyed by name,
+# likewise P contains macro parameters if any.  Preserve backslash
+# newline sequences.
+
+ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
+sed -n '
+s/.\{148\}/&'"$ac_delim"'/g
+t rset
+:rset
+s/^[	 ]*#[	 ]*define[	 ][	 ]*/ /
+t def
+d
+:def
+s/\\$//
+t bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[	 ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3"/p
+s/^ \('"$ac_word_re"'\)[	 ]*\(.*\)/D["\1"]=" \2"/p
+d
+:bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[	 ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3\\\\\\n"\\/p
+t cont
+s/^ \('"$ac_word_re"'\)[	 ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
+t cont
+d
+:cont
+n
+s/.\{148\}/&'"$ac_delim"'/g
+t clear
+:clear
+s/\\$//
+t bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/"/p
+d
+:bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
+b cont
+' <confdefs.h | sed '
+s/'"$ac_delim"'/"\\\
+"/g' >>$CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+  for (key in D) D_is_set[key] = 1
+  FS = ""
+}
+/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
+  line = \$ 0
+  split(line, arg, " ")
+  if (arg[1] == "#") {
+    defundef = arg[2]
+    mac1 = arg[3]
+  } else {
+    defundef = substr(arg[1], 2)
+    mac1 = arg[2]
+  }
+  split(mac1, mac2, "(") #)
+  macro = mac2[1]
+  prefix = substr(line, 1, index(line, defundef) - 1)
+  if (D_is_set[macro]) {
+    # Preserve the white space surrounding the "#".
+    print prefix "define", macro P[macro] D[macro]
+    next
+  } else {
+    # Replace #undef with comments.  This is necessary, for example,
+    # in the case of _POSIX_SOURCE, which is predefined and required
+    # on some systems where configure will not decide to define it.
+    if (defundef == "undef") {
+      print "/*", prefix defundef, macro, "*/"
+      next
+    }
+  }
+}
+{ print }
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+  as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
+fi # test -n "$CONFIG_HEADERS"
+
+
+eval set X "  :F $CONFIG_FILES  :H $CONFIG_HEADERS    :C $CONFIG_COMMANDS"
+shift
+for ac_tag
+do
+  case $ac_tag in
+  :[FHLC]) ac_mode=$ac_tag; continue;;
+  esac
+  case $ac_mode$ac_tag in
+  :[FHL]*:*);;
+  :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
+  :[FH]-) ac_tag=-:-;;
+  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+  esac
+  ac_save_IFS=$IFS
+  IFS=:
+  set x $ac_tag
+  IFS=$ac_save_IFS
+  shift
+  ac_file=$1
+  shift
+
+  case $ac_mode in
+  :L) ac_source=$1;;
+  :[FH])
+    ac_file_inputs=
+    for ac_f
+    do
+      case $ac_f in
+      -) ac_f="$ac_tmp/stdin";;
+      *) # Look for the file first in the build tree, then in the source tree
+	 # (if the path is not absolute).  The absolute path cannot be DOS-style,
+	 # because $ac_f cannot contain `:'.
+	 test -f "$ac_f" ||
+	   case $ac_f in
+	   [\\/$]*) false;;
+	   *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
+	   esac ||
+	   as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
+      esac
+      case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
+      as_fn_append ac_file_inputs " '$ac_f'"
+    done
+
+    # Let's still pretend it is `configure' which instantiates (i.e., don't
+    # use $as_me), people would be surprised to read:
+    #    /* config.h.  Generated by config.status.  */
+    configure_input='Generated from '`
+	  $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
+	`' by configure.'
+    if test x"$ac_file" != x-; then
+      configure_input="$ac_file.  $configure_input"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
+$as_echo "$as_me: creating $ac_file" >&6;}
+    fi
+    # Neutralize special characters interpreted by sed in replacement strings.
+    case $configure_input in #(
+    *\&* | *\|* | *\\* )
+       ac_sed_conf_input=`$as_echo "$configure_input" |
+       sed 's/[\\\\&|]/\\\\&/g'`;; #(
+    *) ac_sed_conf_input=$configure_input;;
+    esac
+
+    case $ac_tag in
+    *:-:* | *:-) cat >"$ac_tmp/stdin" \
+      || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
+    esac
+    ;;
+  esac
+
+  ac_dir=`$as_dirname -- "$ac_file" ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$ac_file" : 'X\(//\)[^/]' \| \
+	 X"$ac_file" : 'X\(//\)$' \| \
+	 X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$ac_file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+  as_dir="$ac_dir"; as_fn_mkdir_p
   ac_builddir=.
 
 case "$ac_dir" in
 .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
 *)
-  ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
   # A ".." for each directory in $ac_dir_suffix.
-  ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'`
+  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
   case $ac_top_builddir_sub in
   "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
   *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
@@ -9456,14 +7913,18 @@
   # CONFIG_FILE
   #
 
+  case $INSTALL in
+  [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
+  *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
+  esac
 _ACEOF
 
-cat >>$CONFIG_STATUS <<\_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # If the template does not know about datarootdir, expand it.
 # FIXME: This hack should be removed a few years after 2.60.
 ac_datarootdir_hack=; ac_datarootdir_seen=
-
-case `sed -n '/datarootdir/ {
+ac_sed_dataroot='
+/datarootdir/ {
   p
   q
 }
@@ -9471,36 +7932,37 @@
 /@docdir@/p
 /@infodir@/p
 /@localedir@/p
-/@mandir@/p
-' $ac_file_inputs` in
+/@mandir@/p'
+case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
 *datarootdir*) ac_datarootdir_seen=yes;;
 *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
-  { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
-echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
 _ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
   ac_datarootdir_hack='
   s&@datadir@&$datadir&g
   s&@docdir@&$docdir&g
   s&@infodir@&$infodir&g
   s&@localedir@&$localedir&g
   s&@mandir@&$mandir&g
-    s&\\\${datarootdir}&$datarootdir&g' ;;
+  s&\\\${datarootdir}&$datarootdir&g' ;;
 esac
 _ACEOF
 
 # Neutralize VPATH when `$srcdir' = `.'.
 # Shell code in configure.ac might set extrasub.
 # FIXME: do we really want to maintain this feature?
-cat >>$CONFIG_STATUS <<_ACEOF
-  sed "$ac_vpsub
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_sed_extra="$ac_vpsub
 $extrasub
 _ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 :t
 /@[a-zA-Z_][a-zA-Z_0-9]*@/!b
-s&@configure_input@&$configure_input&;t t
+s|@configure_input@|$ac_sed_conf_input|;t t
 s&@top_builddir@&$ac_top_builddir_sub&;t t
+s&@top_build_prefix@&$ac_top_build_prefix&;t t
 s&@srcdir@&$ac_srcdir&;t t
 s&@abs_srcdir@&$ac_abs_srcdir&;t t
 s&@top_srcdir@&$ac_top_srcdir&;t t
@@ -9508,124 +7970,55 @@
 s&@builddir@&$ac_builddir&;t t
 s&@abs_builddir@&$ac_abs_builddir&;t t
 s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
+s&@INSTALL@&$ac_INSTALL&;t t
 $ac_datarootdir_hack
-" $ac_file_inputs | sed -f "$tmp/subs-1.sed" >$tmp/out
+"
+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
+  >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
 
 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
-  { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
-  { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
-  { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined.  Please make sure it is defined." >&5
-echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined.  Please make sure it is defined." >&2;}
-
-  rm -f "$tmp/stdin"
+  { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
+  { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' \
+      "$ac_tmp/out"`; test -z "$ac_out"; } &&
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined" >&5
+$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined" >&2;}
+
+  rm -f "$ac_tmp/stdin"
   case $ac_file in
-  -) cat "$tmp/out"; rm -f "$tmp/out";;
-  *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;;
-  esac
+  -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
+  *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
+  esac \
+  || as_fn_error $? "could not create $ac_file" "$LINENO" 5
  ;;
   :H)
   #
   # CONFIG_HEADER
   #
-_ACEOF
-
-# Transform confdefs.h into a sed script `conftest.defines', that
-# substitutes the proper values into config.h.in to produce config.h.
-rm -f conftest.defines conftest.tail
-# First, append a space to every undef/define line, to ease matching.
-echo 's/$/ /' >conftest.defines
-# Then, protect against being on the right side of a sed subst, or in
-# an unquoted here document, in config.status.  If some macros were
-# called several times there might be several #defines for the same
-# symbol, which is useless.  But do not sort them, since the last
-# AC_DEFINE must be honored.
-ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
-# These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where
-# NAME is the cpp macro being defined, VALUE is the value it is being given.
-# PARAMS is the parameter list in the macro definition--in most cases, it's
-# just an empty string.
-ac_dA='s,^\\([	 #]*\\)[^	 ]*\\([	 ]*'
-ac_dB='\\)[	 (].*,\\1define\\2'
-ac_dC=' '
-ac_dD=' ,'
-
-uniq confdefs.h |
-  sed -n '
-	t rset
-	:rset
-	s/^[	 ]*#[	 ]*define[	 ][	 ]*//
-	t ok
-	d
-	:ok
-	s/[\\&,]/\\&/g
-	s/^\('"$ac_word_re"'\)\(([^()]*)\)[	 ]*\(.*\)/ '"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p
-	s/^\('"$ac_word_re"'\)[	 ]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p
-  ' >>conftest.defines
-
-# Remove the space that was appended to ease matching.
-# Then replace #undef with comments.  This is necessary, for
-# example, in the case of _POSIX_SOURCE, which is predefined and required
-# on some systems where configure will not decide to define it.
-# (The regexp can be short, since the line contains either #define or #undef.)
-echo 's/ $//
-s,^[	 #]*u.*,/* & */,' >>conftest.defines
-
-# Break up conftest.defines:
-ac_max_sed_lines=50
-
-# First sed command is:	 sed -f defines.sed $ac_file_inputs >"$tmp/out1"
-# Second one is:	 sed -f defines.sed "$tmp/out1" >"$tmp/out2"
-# Third one will be:	 sed -f defines.sed "$tmp/out2" >"$tmp/out1"
-# et cetera.
-ac_in='$ac_file_inputs'
-ac_out='"$tmp/out1"'
-ac_nxt='"$tmp/out2"'
-
-while :
-do
-  # Write a here document:
-    cat >>$CONFIG_STATUS <<_ACEOF
-    # First, check the format of the line:
-    cat >"\$tmp/defines.sed" <<\\CEOF
-/^[	 ]*#[	 ]*undef[	 ][	 ]*$ac_word_re[	 ]*\$/b def
-/^[	 ]*#[	 ]*define[	 ][	 ]*$ac_word_re[(	 ]/b def
-b
-:def
-_ACEOF
-  sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS
-  echo 'CEOF
-    sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS
-  ac_in=$ac_out; ac_out=$ac_nxt; ac_nxt=$ac_in
-  sed 1,${ac_max_sed_lines}d conftest.defines >conftest.tail
-  grep . conftest.tail >/dev/null || break
-  rm -f conftest.defines
-  mv conftest.tail conftest.defines
-done
-rm -f conftest.defines conftest.tail
-
-echo "ac_result=$ac_in" >>$CONFIG_STATUS
-cat >>$CONFIG_STATUS <<\_ACEOF
   if test x"$ac_file" != x-; then
-    echo "/* $configure_input  */" >"$tmp/config.h"
-    cat "$ac_result" >>"$tmp/config.h"
-    if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then
-      { echo "$as_me:$LINENO: $ac_file is unchanged" >&5
-echo "$as_me: $ac_file is unchanged" >&6;}
+    {
+      $as_echo "/* $configure_input  */" \
+      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"
+    } >"$ac_tmp/config.h" \
+      || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+    if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
+$as_echo "$as_me: $ac_file is unchanged" >&6;}
     else
-      rm -f $ac_file
-      mv "$tmp/config.h" $ac_file
+      rm -f "$ac_file"
+      mv "$ac_tmp/config.h" "$ac_file" \
+	|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
     fi
   else
-    echo "/* $configure_input  */"
-    cat "$ac_result"
+    $as_echo "/* $configure_input  */" \
+      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \
+      || as_fn_error $? "could not create -" "$LINENO" 5
   fi
-  rm -f "$tmp/out12"
  ;;
 
-  :C)  { echo "$as_me:$LINENO: executing $ac_file commands" >&5
-echo "$as_me: executing $ac_file commands" >&6;}
+  :C)  { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
+$as_echo "$as_me: executing $ac_file commands" >&6;}
  ;;
   esac
 
@@ -9634,7 +8027,7 @@
     "./atconfig":C) cat >./atconfig <<ATEOF
 # Configurable variable values for building test suites.
 # Generated by $0.
-# Copyright (C) 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
+# Copyright (C) 2010 Free Software Foundation, Inc.
 
 # The test suite will define top_srcdir=$at_top_srcdir/../.. etc.
 at_testdir='.'
@@ -9659,11 +8052,13 @@
 done # for ac_tag
 
 
-{ (exit 0); exit 0; }
+as_fn_exit 0
 _ACEOF
-chmod +x $CONFIG_STATUS
 ac_clean_files=$ac_clean_files_save
 
+test $ac_write_fail = 0 ||
+  as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
+
 
 # configure is writing to config.log, and then calls config.status.
 # config.status does its own redirection, appending to config.log.
@@ -9683,6 +8078,10 @@
   exec 5>>config.log
   # Use ||, not &&, to avoid exiting from the if with $? = 1, which
   # would make configure fail if this is the last instruction.
-  $ac_cs_success || { (exit 1); exit 1; }
-fi
-
+  $ac_cs_success || as_fn_exit 1
+fi
+if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
+$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
+fi
+
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/configure.in
--- a/head/contrib/tcsh/configure.in	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/configure.in	Fri Mar 02 16:54:40 2012 +0200
@@ -7,13 +7,16 @@
 dnl
 dnl Written by Kaveh Ghazi (ghazi at caip.rutgers.edu) 5/11/96.
 dnl
+dnl $tcsh: configure.in,v 3.99 2012/02/13 16:33:50 christos Exp $
 
 AC_PREREQ([2.59])dnl Minimum Autoconf version required.
-AC_INIT([tcsh], [6.17.00], [http://bugs.gw.com/])
+AC_INIT([tcsh], [6.18.01], [http://bugs.gw.com/])
+AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_SRCDIR([tc.vers.c])
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_TESTDIR([.], [.])
 
+AC_PROG_INSTALL
 AC_CANONICAL_HOST
 
 AC_MSG_CHECKING([cached host tuple])
@@ -78,6 +81,11 @@
     tcsh_config_file=os390
   ;;
 
+  ## Android
+  *-*-android*)
+    tcsh_config_file=android
+  ;;
+
   ## Linux
   *-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu)
     tcsh_config_file=linux
@@ -178,8 +186,11 @@
   *-*-solaris2.[45] ) # Should handle sparc, x86 and powerpc
     tcsh_config_file=sol24
   ;;
+  *-*-solaris2.[678] ) # Should handle sparc, x86 and powerpc
+    tcsh_config_file=sol26
+  ;;
   *-*-solaris2.* ) # Should handle sparc, x86 and powerpc
-    tcsh_config_file=sol26
+    tcsh_config_file=sol29
   ;;
 
   ## Dell SVR4
@@ -230,7 +241,7 @@
 
   ## Red Hat Cygwin
   *-cygwin)
-    tcsh_config_file=cygwin32
+    tcsh_config_file=cygwin
   ;;
 
   ## mips-compaq-nonstopux
@@ -270,6 +281,16 @@
 AC_PROG_CPP
 AC_PROG_GCC_TRADITIONAL
 
+AC_PATH_PROG([GENCAT], [gencat]) 
+
+dnl Require build CC to create gethost helper when cross building
+if test "x${cross_compiling}" = xyes ; then
+  CC_FOR_GETHOST="cc"
+else
+  CC_FOR_GETHOST="\$(CC)"
+fi
+AC_SUBST(CC_FOR_GETHOST)
+
 if test "x$GCC" != xyes ; then
   DFLAGS="$DFLAGS $NON_GNU_DFLAGS"
   CFLAGS="$CFLAGS $NON_GNU_CFLAGS"
@@ -281,10 +302,12 @@
 AC_SEARCH_LIBS(tgetent, termlib termcap curses ncurses)
 AC_SEARCH_LIBS(gethostbyname, nsl)
 AC_SEARCH_LIBS(connect, socket)
+AC_SEARCH_LIBS(catgets, catgets)
 AM_ICONV
 
 dnl Checks for header files
-AC_CHECK_HEADERS([auth.h crypt.h inttypes.h shadow.h stdint.h utmp.h utmpx.h])
+AC_CHECK_HEADERS([auth.h crypt.h features.h inttypes.h paths.h] dnl
+		 [shadow.h stdint.h utmp.h utmpx.h])
 AC_CHECK_HEADERS([wchar.h],
 	[AC_CHECK_SIZEOF([wchar_t], [], [dnl
 #include <stdio.h>
@@ -300,6 +323,7 @@
 AC_TYPE_MODE_T
 AC_TYPE_SIZE_T
 AC_TYPE_UID_T
+AC_TYPE_UINT32_T
 
 AC_DEFUN([AC_TYPE_SSIZE_T], [
 AC_CHECK_TYPE(ssize_t,,
@@ -334,7 +358,9 @@
 # define dirent direct
 #endif])
 AC_CHECK_MEMBERS([struct utmp.ut_host, struct utmp.ut_user, struct utmp.ut_tv,
-		  struct utmp.ut_xtime], , ,
+		  struct utmp.ut_xtime, struct utmpx.ut_host,
+		  struct utmpx.ut_user, struct utmpx.ut_tv,
+		  struct utmpx.ut_xtime], , ,
 [#include <sys/types.h>
 #ifdef HAVE_UTMPX_H
 #include <utmpx.h>
@@ -359,12 +385,17 @@
 #endif
 ])
 AC_CHECK_FUNC([setlocale], [have_setlocale=yes], [have_setlocale=no])
-AC_CHECK_FUNCS([catgets dup2 getauthid getcwd gethostname getpwent] dnl
-	[getutent memmove memset nice nl_langinfo sbrk setpgid setpriority] dnl
-	[strerror strstr sysconf wcwidth])
+AC_CHECK_FUNC([catgets], [have_catgets=yes], [have_catgets=no])
+AC_CHECK_FUNCS([dup2 getauthid getcwd gethostname getpwent] dnl
+	[getutent getutxent mallinfo memmove memset mkstemp nice] dnl
+	[nl_langinfo sbrk setpgid setpriority strerror strstr sysconf wcwidth])
 AC_FUNC_GETPGRP
 AC_FUNC_MBRTOWC
-AC_FUNC_SETPGRP
+if test "x${cross_compiling}" != xyes ; then
+  AC_FUNC_SETPGRP
+else
+  ac_cv_func_setpgrp_void=yes
+fi
 AC_FUNC_STRCOLL
 
 dnl This is not good enough; we need sockaddr_storage too.
@@ -424,6 +455,15 @@
   fi
 fi
 
+if test "x$enable_nls" != xno -a "$have_catgets" != no -a -n "$GENCAT" ; then
+  AC_ARG_ENABLE([nls-catalogs], AS_HELP_STRING([--disable-nls-catalogs], [Disable NLS catalog support]),
+	        [], [enable_nls_catalogs=yes])
+  if test "x$enable_nls_catalogs" != xno; then
+    BUILD_CATALOGS="yes"
+    AC_DEFINE([NLS_CATALOGS], [1], [Support NLS catalogs.])
+  fi
+fi
+
 AC_ARG_WITH(hesiod,
   [  --with-hesiod=PREFIX    Use Hesiod lookup for ~ expansion],
   [hesiod="$withval"], [hesiod=no])
@@ -439,6 +479,7 @@
 fi
 AC_SUBST(HESDEF)
 AC_SUBST(HESLIB)
+AC_SUBST(BUILD_CATALOGS)
 
-AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([Makefile nls/Makefile])
 AC_OUTPUT
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/ed.chared.c
--- a/head/contrib/tcsh/ed.chared.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/ed.chared.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/ed.chared.c,v 3.95 2009/06/25 21:15:37 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/ed.chared.c,v 3.98 2010/05/08 00:37:39 christos Exp $ */
 /*
  * ed.chared.c: Character editing functions.
  */
@@ -72,7 +72,7 @@
 
 #include "sh.h"
 
-RCSID("$tcsh: ed.chared.c,v 3.95 2009/06/25 21:15:37 christos Exp $")
+RCSID("$tcsh: ed.chared.c,v 3.98 2010/05/08 00:37:39 christos Exp $")
 
 #include "ed.h"
 #include "tw.h"
@@ -506,7 +506,7 @@
 	if (*q == ':')		/* short form: !:arg */
 	    --q;
 
-	if (*q != HIST) {
+	if (HIST != '\0' && *q != HIST) {
 	    /*
 	     * Search for a space, tab, or colon.  See if we have a number (as
 	     * in !1234:xyz).  Remember the number.
@@ -716,8 +716,9 @@
      */
     nr_exp = 0;
     for (;;) {
-	while (*p != HIST && p < Cursor)
-	    ++p;
+	if (HIST != '\0')
+	    while (*p != HIST && p < Cursor)
+		++p;
 	for (i = 1; (p - i) >= InputBuf && p[-i] == '\\'; i++)
 	    continue;
 	if (i % 2 == 0)
@@ -729,8 +730,6 @@
 	    ++nr_exp;
 	}
     }
-
-    return nr_exp;
 }
 
 
@@ -745,13 +744,13 @@
      * for white space, the beginning of the line, or a history character.
      */
     for (p = Cursor - 1; 
-	 p > InputBuf && *p != ' ' && *p != '\t' && *p != HIST; --p)
+	 p > InputBuf && *p != ' ' && *p != '\t' && *p && *p != HIST; --p)
 	continue;
 
     /*
      * If we found a history character, go expand it.
      */
-    if (*p == HIST)
+    if (HIST != '\0' && *p == HIST)
 	nr_exp = c_excl(p);
     else
         nr_exp = 0;
@@ -832,11 +831,11 @@
 	while ((p < high) && Isspace(*p)) 
 	    p++;
 
-	if (Isalnum(*p))
-	    while ((p < high) && Isalnum(*p)) 
+	if (isword(*p))
+	    while ((p < high) && isword(*p)) 
 		p++;
 	else
-	    while ((p < high) && !(Isspace(*p) || Isalnum(*p)))
+	    while ((p < high) && !(Isspace(*p) || isword(*p)))
 		p++;
     }
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/ed.inputl.c
--- a/head/contrib/tcsh/ed.inputl.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/ed.inputl.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/ed.inputl.c,v 3.70 2009/06/25 21:15:37 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/ed.inputl.c,v 3.71 2010/12/22 17:26:04 christos Exp $ */
 /*
  * ed.inputl.c: Input line handling.
  */
@@ -32,7 +32,7 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: ed.inputl.c,v 3.70 2009/06/25 21:15:37 christos Exp $")
+RCSID("$tcsh: ed.inputl.c,v 3.71 2010/12/22 17:26:04 christos Exp $")
 
 #include "ed.h"
 #include "ed.defns.h"		/* for the function names */
@@ -683,7 +683,7 @@
 #ifdef DSPMBYTE
 	     _enable_mbdisp &&
 #else
-	     MB_LEN_MAX == 1 &&
+	     MB_CUR_MAX == 1 &&
 #endif
 	     !adrof(STRnokanji) && (*ch & META)) {
 	    MetaNext = 0;
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/ed.refresh.c
--- a/head/contrib/tcsh/ed.refresh.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/ed.refresh.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/ed.refresh.c,v 3.46 2006/08/23 15:03:14 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/ed.refresh.c,v 3.47 2011/02/27 00:14:51 christos Exp $ */
 /*
  * ed.refresh.c: Lower level screen refreshing functions
  */
@@ -32,7 +32,7 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: ed.refresh.c,v 3.46 2006/08/23 15:03:14 christos Exp $")
+RCSID("$tcsh: ed.refresh.c,v 3.47 2011/02/27 00:14:51 christos Exp $")
 
 #include "ed.h"
 /* #define DEBUG_UPDATE */
@@ -61,31 +61,31 @@
 	void    PutPlusOne      (Char, int);
 static	void	cpy_pad_spaces		(Char *, Char *, int);
 #if defined(DEBUG_UPDATE) || defined(DEBUG_REFRESH) || defined(DEBUG_LITERAL)
-static	void	dprintf			(char *, ...);
+static	void	reprintf			(char *, ...);
 #ifdef DEBUG_UPDATE
 static	void	dprintstr		(char *, const Char *, const Char *);
 
 static void
 dprintstr(char *str, const Char *f, const Char *t)
 {
-    dprintf("%s:\"", str);
+    reprintf("%s:\"", str);
     while (f < t) {
 	if (ASC(*f) & ~ASCII)
-	  dprintf("[%x]", *f++);
+	  reprintf("[%x]", *f++);
 	else
-	  dprintf("%c", CTL_ESC(ASCII & ASC(*f++)));
+	  reprintf("%c", CTL_ESC(ASCII & ASC(*f++)));
     }
-    dprintf("\"\r\n");
+    reprintf("\"\r\n");
 }
 #endif /* DEBUG_UPDATE */
 
-/* dprintf():
+/* reprintf():
  *	Print to $DEBUGTTY, so that we can test editing on one pty, and 
  *      print debugging stuff on another. Don't interrupt the shell while
  *	debugging cause you'll mangle up the file descriptors!
  */
 static void
-dprintf(char *fmt, ...)
+reprintf(char *fmt, ...)
 {
     static int fd = -1;
     char *dtty;
@@ -242,9 +242,9 @@
 {
 #ifdef DEBUG_REFRESH
 # ifdef SHORT_STRINGS
-    dprintf("Vdrawing %6.6o '%c' %d\r\n", (unsigned)c, (int)(c & ASCII), width);
+    reprintf("Vdrawing %6.6o '%c' %d\r\n", (unsigned)c, (int)(c & ASCII), width);
 # else
-    dprintf("Vdrawing %3.3o '%c' %d\r\n", (unsigned)c, (int)c, width);
+    reprintf("Vdrawing %3.3o '%c' %d\r\n", (unsigned)c, (int)c, width);
 # endif /* SHORT_STRNGS */
 #endif  /* DEBUG_REFRESH */
 
@@ -263,7 +263,7 @@
 	vcursor_v++;
 #ifdef DEBUG_REFRESH
 	if (vcursor_v >= TermV) {	/* should NEVER happen. */
-	    dprintf("\r\nVdraw: vcursor_v overflow! Vcursor_v == %d > %d\r\n",
+	    reprintf("\r\nVdraw: vcursor_v overflow! Vcursor_v == %d > %d\r\n",
 		    vcursor_v, TermV);
 	    abort();
 	}
@@ -328,8 +328,8 @@
     Char    oldgetting;
 
 #ifdef DEBUG_REFRESH
-    dprintf("Prompt = :%s:\r\n", short2str(Prompt));
-    dprintf("InputBuf = :%s:\r\n", short2str(InputBuf));
+    reprintf("Prompt = :%s:\r\n", short2str(Prompt));
+    reprintf("InputBuf = :%s:\r\n", short2str(InputBuf));
 #endif /* DEBUG_REFRESH */
     oldgetting = GettingInput;
     GettingInput = 0;		/* avoid re-entrance via SIGWINCH */
@@ -382,12 +382,12 @@
     Vdraw('\0', 1);		/* put NUL on end */
 
 #if defined (DEBUG_REFRESH)
-    dprintf("TermH=%d, vcur_h=%d, vcur_v=%d, Vdisplay[0]=\r\n:%80.80s:\r\n",
+    reprintf("TermH=%d, vcur_h=%d, vcur_v=%d, Vdisplay[0]=\r\n:%80.80s:\r\n",
 	    TermH, vcursor_h, vcursor_v, short2str(Vdisplay[0]));
 #endif /* DEBUG_REFRESH */
 
 #ifdef DEBUG_UPDATE
-    dprintf("updating %d lines.\r\n", new_vcv);
+    reprintf("updating %d lines.\r\n", new_vcv);
 #endif  /* DEBUG_UPDATE */
     for (cur_line = 0; cur_line <= new_vcv; cur_line++) {
 	/* NOTE THAT update_line MAY CHANGE Display[cur_line] */
@@ -405,7 +405,7 @@
 	cpy_pad_spaces(Display[cur_line], Vdisplay[cur_line], TermH);
     }
 #ifdef DEBUG_REFRESH
-    dprintf("\r\nvcursor_v = %d, OldvcV = %d, cur_line = %d\r\n",
+    reprintf("\r\nvcursor_v = %d, OldvcV = %d, cur_line = %d\r\n",
 	    vcursor_v, OldvcV, cur_line);
 #endif /* DEBUG_REFRESH */
     if (OldvcV > new_vcv) {
@@ -416,7 +416,7 @@
     }
     OldvcV = new_vcv;		/* set for next time */
 #ifdef DEBUG_REFRESH
-    dprintf("\r\nCursorH = %d, CursorV = %d, cur_h = %d, cur_v = %d\r\n",
+    reprintf("\r\nCursorH = %d, CursorV = %d, cur_h = %d, cur_v = %d\r\n",
 	    CursorH, CursorV, cur_h, cur_v);
 #endif /* DEBUG_REFRESH */
 #ifdef WINNT_NATIVE
@@ -461,9 +461,9 @@
 	num = dlen - dat;
 
 #ifdef DEBUG_REFRESH
-    dprintf("str_insert() starting: %d at %d max %d, d == \"%s\"\n",
+    reprintf("str_insert() starting: %d at %d max %d, d == \"%s\"\n",
 	    num, dat, dlen, short2str(d));
-    dprintf("s == \"%s\"n", short2str(s));
+    reprintf("s == \"%s\"n", short2str(s));
 #endif /* DEBUG_REFRESH */
 
     /* open up the space for num chars */
@@ -475,9 +475,9 @@
 	d[dlen] = '\0';		/* just in case */
     }
 #ifdef DEBUG_REFRESH
-    dprintf("str_insert() after insert: %d at %d max %d, d == \"%s\"\n",
+    reprintf("str_insert() after insert: %d at %d max %d, d == \"%s\"\n",
 	    num, dat, dlen, short2str(d));
-    dprintf("s == \"%s\"n", short2str(s));
+    reprintf("s == \"%s\"n", short2str(s));
 #endif /* DEBUG_REFRESH */
 
     /* copy the characters */
@@ -485,9 +485,9 @@
 	*a++ = *s++;
 
 #ifdef DEBUG_REFRESH
-    dprintf("str_insert() after copy: %d at %d max %d, d == \"%s\"\n",
+    reprintf("str_insert() after copy: %d at %d max %d, d == \"%s\"\n",
 	    num, dat, dlen, d, short2str(s));
-    dprintf("s == \"%s\"n", short2str(s));
+    reprintf("s == \"%s\"n", short2str(s));
 #endif /* DEBUG_REFRESH */
 }
 
@@ -505,7 +505,7 @@
     }
 
 #ifdef DEBUG_REFRESH
-    dprintf("str_delete() starting: %d at %d max %d, d == \"%s\"\n",
+    reprintf("str_delete() starting: %d at %d max %d, d == \"%s\"\n",
 	    num, dat, dlen, short2str(d));
 #endif /* DEBUG_REFRESH */
 
@@ -518,7 +518,7 @@
 	d[dlen] = '\0';		/* just in case */
     }
 #ifdef DEBUG_REFRESH
-    dprintf("str_delete() after delete: %d at %d max %d, d == \"%s\"\n",
+    reprintf("str_delete() after delete: %d at %d max %d, d == \"%s\"\n",
 	    num, dat, dlen, short2str(d));
 #endif /* DEBUG_REFRESH */
 }
@@ -608,7 +608,7 @@
      */
     if (*ofd == '\0' && *nfd == '\0') {
 #ifdef DEBUG_UPDATE
-	dprintf("no difference.\r\n");
+	reprintf("no difference.\r\n");
 #endif /* DEBUG_UPDATE */
 	return;
     }
@@ -768,13 +768,13 @@
     sx = (int) ((nls - nse) - (ols - ose));
 
 #ifdef DEBUG_UPDATE
-    dprintf("\n");
-    dprintf("ofd %d, osb %d, ose %d, ols %d, oe %d\n",
+    reprintf("\n");
+    reprintf("ofd %d, osb %d, ose %d, ols %d, oe %d\n",
 	    ofd - old, osb - old, ose - old, ols - old, oe - old);
-    dprintf("nfd %d, nsb %d, nse %d, nls %d, ne %d\n",
+    reprintf("nfd %d, nsb %d, nse %d, nls %d, ne %d\n",
 	    nfd - new, nsb - new, nse - new, nls - new, ne - new);
-    dprintf("xxx-xxx:\"00000000001111111111222222222233333333334\"\r\n");
-    dprintf("xxx-xxx:\"01234567890123456789012345678901234567890\"\r\n");
+    reprintf("xxx-xxx:\"00000000001111111111222222222233333333334\"\r\n");
+    reprintf("xxx-xxx:\"01234567890123456789012345678901234567890\"\r\n");
     dprintstr("old- oe", old, oe);
     dprintstr("new- ne", new, ne);
     dprintstr("old-ofd", old, ofd);
@@ -837,7 +837,7 @@
      */
     if ((nsb != nfd) && fx > 0 && ((p - old) + fx < TermH)) {
 #ifdef DEBUG_UPDATE
-	dprintf("first diff insert at %d...\r\n", nfd - new);
+	reprintf("first diff insert at %d...\r\n", nfd - new);
 #endif  /* DEBUG_UPDATE */
 	/*
 	 * Move to the first char to insert, where the first diff is.
@@ -848,7 +848,7 @@
 	 */
 	if (nsb != ne) {
 #ifdef DEBUG_UPDATE
-	    dprintf("with stuff to keep at end\r\n");
+	    reprintf("with stuff to keep at end\r\n");
 #endif  /* DEBUG_UPDATE */
 	    /*
 	     * insert fx chars of new starting at nfd
@@ -856,7 +856,7 @@
 	    if (fx > 0) {
 #ifdef DEBUG_UPDATE
 		if (!T_CanIns)
-		    dprintf("   ERROR: cannot insert in early first diff\n");
+		    reprintf("   ERROR: cannot insert in early first diff\n");
 #endif  /* DEBUG_UPDATE */
 		Insert_write(nfd, fx);
 		str_insert(old, (int) (ofd - old), TermH, nfd, fx);
@@ -869,7 +869,7 @@
 	}
 	else {
 #ifdef DEBUG_UPDATE
-	    dprintf("without anything to save\r\n");
+	    reprintf("without anything to save\r\n");
 #endif  /* DEBUG_UPDATE */
 	    so_write(nfd, (nsb - nfd));
 	    str_cp(ofd, nfd, (int) (nsb - nfd));
@@ -881,7 +881,7 @@
     }
     else if (fx < 0) {
 #ifdef DEBUG_UPDATE
-	dprintf("first diff delete at %d...\r\n", ofd - old);
+	reprintf("first diff delete at %d...\r\n", ofd - old);
 #endif  /* DEBUG_UPDATE */
 	/*
 	 * move to the first char to delete where the first diff is
@@ -892,7 +892,7 @@
 	 */
 	if (osb != oe) {
 #ifdef DEBUG_UPDATE
-	    dprintf("with stuff to save at end\r\n");
+	    reprintf("with stuff to save at end\r\n");
 #endif  /* DEBUG_UPDATE */
 	    /*
 	     * fx is less than zero *always* here but we check for code
@@ -901,7 +901,7 @@
 	    if (fx < 0) {
 #ifdef DEBUG_UPDATE
 		if (!T_CanDel)
-		    dprintf("   ERROR: cannot delete in first diff\n");
+		    reprintf("   ERROR: cannot delete in first diff\n");
 #endif /* DEBUG_UPDATE */
 		DeleteChars(-fx);
 		str_delete(old, (int) (ofd - old), TermH, -fx);
@@ -915,14 +915,14 @@
 	}
 	else {
 #ifdef DEBUG_UPDATE
-	    dprintf("but with nothing left to save\r\n");
+	    reprintf("but with nothing left to save\r\n");
 #endif  /* DEBUG_UPDATE */
 	    /*
 	     * write (nsb-nfd) chars of new starting at nfd
 	     */
 	    so_write(nfd, (nsb - nfd));
 #ifdef DEBUG_REFRESH
-	    dprintf("cleareol %d\n", (oe - old) - (ne - new));
+	    reprintf("cleareol %d\n", (oe - old) - (ne - new));
 #endif  /* DEBUG_UPDATE */
 #ifndef WINNT_NATIVE
 	    ClearEOL((oe - old) - (ne - new));
@@ -943,7 +943,7 @@
 
     if (sx < 0) {
 #ifdef DEBUG_UPDATE
-	dprintf("second diff delete at %d...\r\n", (ose - old) + fx);
+	reprintf("second diff delete at %d...\r\n", (ose - old) + fx);
 #endif  /* DEBUG_UPDATE */
 	/*
 	 * Check if we have stuff to delete
@@ -958,7 +958,7 @@
 	 */
 	if (ols != oe) {
 #ifdef DEBUG_UPDATE
-	    dprintf("with stuff to save at end\r\n");
+	    reprintf("with stuff to save at end\r\n");
 #endif  /* DEBUG_UPDATE */
 	    /*
 	     * Again a duplicate test.
@@ -966,7 +966,7 @@
 	    if (sx < 0) {
 #ifdef DEBUG_UPDATE
 		if (!T_CanDel)
-		    dprintf("   ERROR: cannot delete in second diff\n");
+		    reprintf("   ERROR: cannot delete in second diff\n");
 #endif  /* DEBUG_UPDATE */
 		DeleteChars(-sx);
 	    }
@@ -981,11 +981,11 @@
 	    if (olen > TermH)
 		olen = TermH;
 #ifdef DEBUG_UPDATE
-	    dprintf("but with nothing left to save\r\n");
+	    reprintf("but with nothing left to save\r\n");
 #endif /* DEBUG_UPDATE */
 	    so_write(nse, (nls - nse));
 #ifdef DEBUG_REFRESH
-	    dprintf("cleareol %d\n", olen - (ne - new));
+	    reprintf("cleareol %d\n", olen - (ne - new));
 #endif /* DEBUG_UPDATE */
 #ifndef WINNT_NATIVE
 	    ClearEOL(olen - (ne - new));
@@ -1003,7 +1003,7 @@
      */
     if ((nsb != nfd) && (osb - ofd) <= (nsb - nfd) && (fx == 0)) {
 #ifdef DEBUG_UPDATE
-	dprintf("late first diff insert at %d...\r\n", nfd - new);
+	reprintf("late first diff insert at %d...\r\n", nfd - new);
 #endif /* DEBUG_UPDATE */
 
 	MoveToChar(nfd - new);
@@ -1012,7 +1012,7 @@
 	 */
 	if (nsb != ne) {
 #ifdef DEBUG_UPDATE
-	    dprintf("with stuff to keep at end\r\n");
+	    reprintf("with stuff to keep at end\r\n");
 #endif /* DEBUG_UPDATE */
 	    /* 
 	     * We have to recalculate fx here because we set it
@@ -1026,7 +1026,7 @@
 		 */
 #ifdef DEBUG_UPDATE
 		if (!T_CanIns)
-		    dprintf("   ERROR: cannot insert in late first diff\n");
+		    reprintf("   ERROR: cannot insert in late first diff\n");
 #endif /* DEBUG_UPDATE */
 		Insert_write(nfd, fx);
 		str_insert(old, (int) (ofd - old), TermH, nfd, fx);
@@ -1040,7 +1040,7 @@
 	}
 	else {
 #ifdef DEBUG_UPDATE
-	    dprintf("without anything to save\r\n");
+	    reprintf("without anything to save\r\n");
 #endif /* DEBUG_UPDATE */
 	    so_write(nfd, (nsb - nfd));
 	    str_cp(ofd, nfd, (int) (nsb - nfd));
@@ -1052,18 +1052,18 @@
      */
     if (sx >= 0) {
 #ifdef DEBUG_UPDATE
-	dprintf("second diff insert at %d...\r\n", nse - new);
+	reprintf("second diff insert at %d...\r\n", nse - new);
 #endif /* DEBUG_UPDATE */
 	MoveToChar(nse - new);
 	if (ols != oe) {
 #ifdef DEBUG_UPDATE
-	    dprintf("with stuff to keep at end\r\n");
+	    reprintf("with stuff to keep at end\r\n");
 #endif /* DEBUG_UPDATE */
 	    if (sx > 0) {
 		/* insert sx chars of new starting at nse */
 #ifdef DEBUG_UPDATE
 		if (!T_CanIns)
-		    dprintf("   ERROR: cannot insert in second diff\n");
+		    reprintf("   ERROR: cannot insert in second diff\n");
 #endif /* DEBUG_UPDATE */
 		Insert_write(nse, sx);
 	    }
@@ -1075,7 +1075,7 @@
 	}
 	else {
 #ifdef DEBUG_UPDATE
-	    dprintf("without anything to save\r\n");
+	    reprintf("without anything to save\r\n");
 #endif /* DEBUG_UPDATE */
 	    so_write(nse, (nls - nse));
 
@@ -1087,7 +1087,7 @@
 	}
     }
 #ifdef DEBUG_UPDATE
-    dprintf("done.\r\n");
+    reprintf("done.\r\n");
 #endif /* DEBUG_UPDATE */
 }
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/ed.screen.c
--- a/head/contrib/tcsh/ed.screen.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/ed.screen.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/ed.screen.c,v 3.76 2009/06/25 21:15:37 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/ed.screen.c,v 3.78 2011/02/27 00:14:38 christos Exp $ */
 /*
  * ed.screen.c: Editor/termcap-curses interface
  */
@@ -32,7 +32,7 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: ed.screen.c,v 3.76 2009/06/25 21:15:37 christos Exp $")
+RCSID("$tcsh: ed.screen.c,v 3.78 2011/02/27 00:14:38 christos Exp $")
 
 #include "ed.h"
 #include "tc.h"
@@ -1562,6 +1562,28 @@
 
 #endif /* SIG_WINDOW */
 
+#ifdef KNOWsize
+static void
+UpdateVal(const Char *tag, int value, Char *termcap, Char *backup)
+{
+    Char *ptr, *p;
+    if ((ptr = Strstr(termcap, tag)) == NULL) {
+	(void)Strcpy(backup, termcap);
+	return;
+    } else {
+	size_t len = (ptr - termcap) + Strlen(tag);
+	(void)Strncpy(backup, termcap, len);
+	backup[len] = '\0';
+	p = Itoa(value, 0, 0);
+	(void) Strcat(backup + len, p);
+	xfree(p);
+	ptr = Strchr(ptr, ':');
+	if (ptr)
+	    (void) Strcat(backup, ptr);
+    }
+}
+#endif
+
 void
 ChangeSize(int lins, int cols)
 {
@@ -1609,43 +1631,9 @@
 	    (void) Strncpy(termcap, ptr, TC_BUFSIZE);
 	    termcap[TC_BUFSIZE-1] = '\0';
 
-	    /* update termcap string; first do columns */
-	    buf[0] = 'c';
-	    buf[1] = 'o';
-	    buf[2] = '#';
-	    buf[3] = '\0';
-	    if ((ptr = Strstr(termcap, buf)) == NULL) {
-		(void) Strcpy(backup, termcap);
-	    }
-	    else {
-		size_t len = (ptr - termcap) + Strlen(buf);
-		(void) Strncpy(backup, termcap, len);
-		backup[len] = '\0';
-		p = Itoa(Val(T_co), 0, 0);
-		(void) Strcat(backup + len, p);
-		xfree(p);
-		ptr = Strchr(ptr, ':');
-		(void) Strcat(backup, ptr);
-	    }
+	    UpdateVal(STRco, Val(T_co), termcap, backup);
+	    UpdateVal(STRli, Val(T_li), termcap, backup);
 
-	    /* now do lines */
-	    buf[0] = 'l';
-	    buf[1] = 'i';
-	    buf[2] = '#';
-	    buf[3] = '\0';
-	    if ((ptr = Strstr(backup, buf)) == NULL) {
-		(void) Strcpy(termcap, backup);
-	    }
-	    else {
-		size_t len = (ptr - backup) + Strlen(buf);
-		(void) Strncpy(termcap, backup, len);
-		termcap[len] = '\0';
-		p = Itoa(Val(T_li), 0, 0);
-		(void) Strcat(termcap, p);
-		xfree(p);
-		ptr = Strchr(ptr, ':');
-		(void) Strcat(termcap, ptr);
-	    }
 	    /*
 	     * Chop the termcap string at TC_BUFSIZE-1 characters to avoid
 	     * core-dumps in the termcap routines
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/ed.term.c
--- a/head/contrib/tcsh/ed.term.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/ed.term.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/ed.term.c,v 1.36 2006/03/02 18:46:44 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/ed.term.c,v 1.38 2011/02/25 23:58:34 christos Exp $ */
 /*
  * ed.term.c: Low level terminal interface
  */
@@ -33,8 +33,8 @@
 #include "sh.h"
 #ifndef WINNT_NATIVE
 
-RCSID("$tcsh: ed.term.c,v 1.36 2006/03/02 18:46:44 christos Exp $")
-
+RCSID("$tcsh: ed.term.c,v 1.38 2011/02/25 23:58:34 christos Exp $")
+#include <assert.h>
 #include "ed.h"
 
 int didsetty = 0;
@@ -633,6 +633,7 @@
 		i = m->m_type;
 		st = len = strlen(ttylist[z][m->m_type].t_name);
 	    }
+	    assert(i != -1);
 
 	    x = (ttylist[z][i].t_setmask & m->m_value) ? '+' : '\0';
 	    x = (ttylist[z][i].t_clrmask & m->m_value) ? '-' : x;
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/gethost.c
--- a/head/contrib/tcsh/gethost.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/gethost.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/gethost.c,v 1.12 2006/03/02 18:46:44 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/gethost.c,v 1.15 2012/01/15 17:14:54 christos Exp $ */
 /*
  * gethost.c: Create version file from prototype
  */
@@ -32,7 +32,7 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: gethost.c,v 1.12 2006/03/02 18:46:44 christos Exp $")
+RCSID("$tcsh: gethost.c,v 1.15 2012/01/15 17:14:54 christos Exp $")
 
 #ifdef SCO
 # define perror __perror
@@ -91,6 +91,7 @@
 
 static int findtoken (char *);
 static char *gettoken (char **, char  *);
+static char *pname;
 
 int main (int, char *[]);
 
@@ -141,13 +142,78 @@
     *pptr = ptr;
     return token;
 }
+
+static char *
+cat(const char *a, const char *b, size_t len)
+{
+	size_t l;
+	char *r;
+
+	if (len == 0)
+		len = strlen(b);
+	l = strlen(a) + len + 1;
+	if ((r = malloc(l)) == NULL)
+		abort();
+	snprintf(r, l, "%s%.*s", a, (int)len, b);
+	return r;
+}
+
+static const char *
+explode(const char *defs)
+{
+	static const char def[] = "defined("; /* ) */
+	static char *buf;
+	size_t len;
+	const char *ptr, *bptr, *eptr = NULL, *name;
+	size_t buflen = 0;
+
+	if (strstr(defs, "#machine(" /* ) */))
+		return defs;
+
+	free(buf);
+	buf = strdup("("); /* ) */
+	for (ptr = defs; (bptr = strstr(ptr, def)) != NULL; ptr = eptr + 1) {
+		if (ptr != bptr)
+			buf = cat(buf, ptr, bptr - ptr);
+		if ((eptr = strchr(ptr + sizeof(def) - 1, ')')) == NULL) {
+			(void) fprintf(stderr, "%s: missing close paren `%s'\n",
+			    pname, defs);
+			return defs;
+		}
+		buf = cat(buf, bptr, eptr - bptr + 1);
+		name = bptr + sizeof(def) - 1;
+		len = eptr - name;
+		if (len < 1) {
+			(void) fprintf(stderr, "%s: empty define `%s'\n",
+			    pname, defs);
+			return defs;
+		}
+		if (*name != '_') {
+			char *undername = malloc(len + 10);
+			buf = cat(buf, " || defined(", 0);
+			snprintf(undername, len + 10, "__%.*s__)", (int)len,
+			    name);
+			buf = cat(buf, undername, len + 5);
+			buf = cat(buf, " || defined(", 0);
+			snprintf(undername, len + 10, "__%.*s)", (int)len,
+			    name);
+			buf = cat(buf, undername, len + 3);
+		}
+	}
+	if (!eptr) {
+	    (void) fprintf(stderr, "%s: invalid input `%s'\n", pname, defs);
+	    return defs;
+        }
+	buf = cat(buf, eptr + 1, 0);
+	buf = cat(buf, ")", 0);
+	return buf;
+}
 	
 
 int
 main(int argc, char *argv[])
 {
     char line[INBUFSIZE];
-    char *pname;
     const char *fname = "stdin";
     char *ptr, *tok;
     char defs[INBUFSIZE];
@@ -231,7 +297,7 @@
 	    break;
 
 	case T_NONE:
-	    if (state != S_CODE && defs && *defs != '\0') {
+	    if (state != S_CODE && *defs != '\0') {
 		(void) fprintf(stderr, "%s: \"%s\", %d: Discarded\n",
 			       pname, fname, lineno);
 		if (++errs == 30) {
@@ -280,7 +346,7 @@
 	    else {
 		if (tok && *tok)
 		    (void) fprintf(stdout, "# if (%s) && !defined(_%s_)\n",
-				   defs, keyword[token]);
+				   explode(defs), keyword[token]);
 		else
 		    (void) fprintf(stdout, "# if !defined(_%s_)\n", 
 				   keyword[token]);
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/glob.c
--- a/head/contrib/tcsh/glob.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/glob.c	Fri Mar 02 16:54:40 2012 +0200
@@ -83,7 +83,7 @@
 static	int	 glob1 		(Char *, glob_t *, int);
 static	int	 glob2		(struct strbuf *, const Char *, glob_t *, int);
 static	int	 glob3		(struct strbuf *, const Char *, const Char *,
-				 glob_t *, int);
+				 const Char *, glob_t *, int);
 static	void	 globextend	(const char *, glob_t *);
 static	int	 match		(const char *, const Char *, const Char *,
 				 int);
@@ -329,7 +329,7 @@
 	    
 	    len = mblen((const char *)(patnext - 1), MB_LEN_MAX);
 	    if (len == -1)
-		(void)mblen(NULL, 0);
+		TCSH_IGNORE(mblen(NULL, 0));
 	    else if (len > 1) {
 		*bufnext++ = (Char) c;
 		while (--len != 0)
@@ -389,10 +389,13 @@
 	    break;
 	case STAR:
 	    pglob->gl_flags |= GLOB_MAGCHAR;
-	    /* collapse adjacent stars to one, to avoid
-	     * exponential behavior
+	    /* collapse adjacent stars to one [or three if globstar],
+	     * to avoid exponential behavior
 	     */
-	    if (bufnext == patbuf || bufnext[-1] != M_ALL)
+	    if (bufnext == patbuf || bufnext[-1] != M_ALL ||
+	       ((flags & GLOB_STAR) != 0 && 
+		 (bufnext - 1 == patbuf || bufnext[-2] != M_ALL ||
+		 bufnext - 2 == patbuf || bufnext[-3] != M_ALL)))
 		*bufnext++ = M_ALL;
 	    break;
 	default:
@@ -524,25 +527,79 @@
 	}
 	else {			/* need expansion, recurse */
 	    pathbuf->len = orig_len;
-	    return (glob3(pathbuf, pattern, p, pglob, no_match));
+	    return (glob3(pathbuf, pattern, p, pattern, pglob, no_match));
 	}
     }
     /* NOTREACHED */
 }
 
+static size_t
+One_Char_mbtowc(__Char *pwc, const Char *s, size_t n)
+{
+#ifdef WIDE_STRINGS
+    char buf[MB_LEN_MAX], *p;
 
+    if (n > MB_LEN_MAX)
+	n = MB_LEN_MAX;
+    p = buf;
+    while (p < buf + n && (*p++ = LCHAR(*s++)) != 0)
+	;
+    return one_mbtowc(pwc, buf, n);
+#else
+    *pwc = *s & CHAR;
+    return 1;
+#endif
+}
+ 
 static int
 glob3(struct strbuf *pathbuf, const Char *pattern, const Char *restpattern,
-      glob_t *pglob, int no_match)
+      const Char *pglobstar, glob_t *pglob, int no_match)
 {
     DIR    *dirp;
     struct dirent *dp;
+    struct stat sbuf;
     int     err;
     Char m_not = (pglob->gl_flags & GLOB_ALTNOT) ? M_ALTNOT : M_NOT;
     size_t orig_len;
+    int globstar = 0;
+    int chase_symlinks = 0;
+    const Char *termstar = NULL;
 
     strbuf_terminate(pathbuf);
-    errno = 0;
+    orig_len = pathbuf->len;
+    errno = err = 0;
+
+    while (pglobstar < restpattern) {
+	__Char wc;
+	size_t width = One_Char_mbtowc(&wc, pglobstar, MB_LEN_MAX);
+	if ((pglobstar[0] & M_MASK) == M_ALL &&
+	    (pglobstar[width] & M_MASK) == M_ALL) {
+	    globstar = 1;
+	    chase_symlinks = (pglobstar[2 * width] & M_MASK) == M_ALL;
+	    termstar = pglobstar + (2 + chase_symlinks) * width;
+	    break;
+	}
+        pglobstar += width;
+    } 
+
+    if (globstar) {
+	err = pglobstar==pattern && termstar==restpattern ?
+		*restpattern == EOS ?
+		glob2(pathbuf, restpattern - 1, pglob, no_match) :
+		glob2(pathbuf, restpattern + 1, pglob, no_match) :
+		glob3(pathbuf, pattern, restpattern, termstar, pglob, no_match);
+	if (err)
+	    return err;
+	pathbuf->len = orig_len;
+	strbuf_terminate(pathbuf);
+    }
+
+    if (*pathbuf->s && (Lstat(pathbuf->s, &sbuf) || !S_ISDIR(sbuf.st_mode)
+#ifdef S_IFLINK
+	     && ((globstar && !chase_symlinks) || !S_ISLNK(sbuf.st_mode))
+#endif
+	))
+	return 0;
 
     if (!(dirp = Opendir(pathbuf->s))) {
 	/* todo: don't call for ENOENT or ENOTDIR? */
@@ -553,23 +610,37 @@
 	    return (0);
     }
 
-    err = 0;
-
-    orig_len = pathbuf->len;
     /* search directory for matching names */
     while ((dp = readdir(dirp)) != NULL) {
 	/* initial DOT must be matched literally */
 	if (dp->d_name[0] == DOT && *pattern != DOT)
-	    continue;
+	    if (!(pglob->gl_flags & GLOB_DOT) || !dp->d_name[1] ||
+		(dp->d_name[1] == DOT && !dp->d_name[2]))
+		continue; /*unless globdot and not . or .. */
 	pathbuf->len = orig_len;
 	strbuf_append(pathbuf, dp->d_name);
 	strbuf_terminate(pathbuf);
-	if (match(pathbuf->s + orig_len, pattern, restpattern, (int) m_not)
-	    == no_match)
-	    continue;
-	err = glob2(pathbuf, restpattern, pglob, no_match);
-	if (err)
-	    break;
+
+	if (globstar) {
+#ifdef S_IFLNK
+	    if (!chase_symlinks &&
+		(Lstat(pathbuf->s, &sbuf) || S_ISLNK(sbuf.st_mode)))
+		    continue;
+#endif
+	    if (match(pathbuf->s + orig_len, pattern, termstar,
+		(int)m_not) == no_match) 
+		    continue;
+	    strbuf_append1(pathbuf, SEP);
+	    strbuf_terminate(pathbuf);
+	    if ((err = glob2(pathbuf, pglobstar, pglob, no_match)) != 0)
+		break;
+	} else {
+	    if (match(pathbuf->s + orig_len, pattern, restpattern,
+		(int) m_not) == no_match)
+		continue;
+	    if ((err = glob2(pathbuf, restpattern, pglob, no_match)) != 0)
+		break;
+	}
     }
     /* todo: check error from readdir? */
     closedir(dirp);
@@ -613,24 +684,6 @@
     pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
 }
 
-static size_t
-One_Char_mbtowc(__Char *pwc, const Char *s, size_t n)
-{
-#ifdef WIDE_STRINGS
-    char buf[MB_LEN_MAX], *p;
-
-    if (n > MB_LEN_MAX)
-	n = MB_LEN_MAX;
-    p = buf;
-    while (p < buf + n && (*p++ = LCHAR(*s++)) != 0)
-	;
-    return one_mbtowc(pwc, buf, n);
-#else
-    *pwc = *s & CHAR;
-    return 1;
-#endif
-}
-
 /*
  * pattern matching function for filenames.  Each occurrence of the *
  * pattern causes a recursion level.
@@ -650,17 +703,17 @@
 	lwk = one_mbtowc(&wk, name, MB_LEN_MAX);
 	switch (c & M_MASK) {
 	case M_ALL:
+	    while (pat < patend && (*pat & M_MASK) == M_ALL)  /* eat consecutive '*' */
+		pat += One_Char_mbtowc(&wc, pat, MB_LEN_MAX);
 	    if (pat == patend)
-		return (1);
-	    for (;;) {
-		if (match(name, pat, patend, m_not))
-		    return (1);
+	        return (1);
+	    while (!match(name, pat, patend, m_not)) {
 		if (*name == EOS)
-		    break;
+		    return (0);
 		name += lwk;
 		lwk = one_mbtowc(&wk, name, MB_LEN_MAX);
 	    }
-	    return (0);
+	    return (1);
 	case M_ONE:
 	    if (*name == EOS)
 		return (0);
@@ -691,9 +744,9 @@
 		return (0);
 	    break;
 	default:
+	    if (*name == EOS || samecase(wk) != samecase(wc))
+		return (0);
 	    name += lwk;
-	    if (samecase(wk) != samecase(wc))
-		return (0);
 	    break;
 	}
     }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/glob.h
--- a/head/contrib/tcsh/glob.h	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/glob.h	Fri Mar 02 16:54:40 2012 +0200
@@ -80,6 +80,8 @@
 #define	GLOB_TILDE	0x0800	/* Expand tilde names from the passwd file. */
 #define	GLOB_ALTNOT     0x1000	/* use alternate glob character [^ not !] */ 
 #define	GLOB_QUOTE	0x2000	/* XXX: source compatibility */
+#define	GLOB_STAR	0x4000	/* use glob ** to recurse directories */
+#define	GLOB_DOT	0x8000	/* don't skip dotfiles (except . and ..) */
 
 #define	GLOB_ABEND	GLOB_ABORTED	/* source compatibility */
 /* #endif */
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/host.defs
--- a/head/contrib/tcsh/host.defs	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/host.defs	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,5 @@
-newcode	:
-/* $Header: /p/tcsh/cvsroot/tcsh/host.defs,v 1.46 2008/09/25 14:41:05 christos Exp $ */
+newcode :
+/* $Header: /p/tcsh/cvsroot/tcsh/host.defs,v 1.55 2012/01/11 20:20:15 christos Exp $ */
 /*
  * host.defs: Hosttype/Machtype etc.
  */
@@ -33,9 +33,9 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: host.defs,v 1.46 2008/09/25 14:41:05 christos Exp $")
+RCSID("$tcsh: host.defs,v 1.55 2012/01/11 20:20:15 christos Exp $")
 
-endcode	:
+endcode :
 
 macro	: M_mips64el : (defined(mips64) || defined(__mips64)) && (defined(MIPSEL) || defined(__MIPSEL))
 macro	: M_mips64eb : (defined(mips64) || defined(__mips64)) && (defined(MIPSEB) || defined(__MIPSEB))
@@ -44,10 +44,11 @@
 macro	: M_i386 : (defined(i386) || defined(__i386__))
 macro	: M_i486 : (defined(i486) || defined(__i486__))
 macro	: M_i586 : (defined(i586) || defined(__i586__))
+macro	: M_i686 : (defined(i686) || defined(__i686__))
 macro	: M_intel : (defined(M_i386) || defined(M_i486) || defined(M_i586))
 
 newdef	: defined(ns32000)
-newcode	:
+newcode :
 static char *
 isamultimax(int flag)
 {
@@ -56,12 +57,12 @@
     else 
 	return flag ? "mach" : "ns32000";
 }
-endcode	:
+endcode :
 enddef	:
 
 
 newdef	: defined(cray)
-newcode	:
+newcode :
 /*  
  * On crays, find the current machine type via the target() syscall
  * We need ctype.h to convert the name returned to lower case
@@ -79,7 +80,7 @@
 
     if (target(MC_GET_SYSTEM, &data) != -1) {
 	static char hosttype_buf[sizeof(data.mc_pmt)+1];
-	char *p = (char *) &(data.mc_pmt);
+	unsigned char *p = (unsigned char *) &(data.mc_pmt);
 	char *q = hosttype_buf;
 	int n;
 
@@ -95,18 +96,18 @@
 	/* replace dashes with underscores if present */
 	while ((q = strchr(hosttype_buf, '-')) != NULL)
 	    *q = '_';
-	return hosttype_buf; 	/* Return in static buffer */
+	return hosttype_buf;	/* Return in static buffer */
     }
     else
 # endif /* MC_GET_SYSTEM */
 	return "cray";		/* target() failed */
 }
-endcode	:
+endcode :
 enddef	:
 
 
 newdef	: defined(convex)
-newcode	:
+newcode :
 /*  
  * On convex, find the current machine type via the getsysinfo() syscall
  */
@@ -117,7 +118,7 @@
 getconvex(void)
 {
     struct system_information  sysinfo;
-    static char  result[8];
+    static char	 result[8];
 
     if (getsysinfo(SYSINFO_SIZE, &sysinfo) == -1)
 	return "convex";
@@ -165,11 +166,64 @@
 	return "convex";
     }
 }
-endcode	:
+endcode :
 enddef	:
 
+newdef : defined(__linux__) || defined(__CYGWIN__) || defined(__GNU__) || defined(__GLIBC__)
+newcode :
+# include "tw.h"
+#include <sys/utsname.h>
+static char mach[256];
+static char host[256];
+static char ostype[32];
+static void populate(void)
+{
+	struct utsname uts;
+	int e = uname(&uts);
+	const char *p = short2str(tgetenv(STROSTYPE));
+	if (p == NULL) {
+#if defined(__ANDROID__)
+		p = "android";
+#elif defined(__CYGWIN__)
+		p = "cygwin";
+#else
+		p = "linux";
+#endif
+	}
+	xsnprintf(ostype, sizeof(ostype), "%s", p);
+	xsnprintf(mach, sizeof(mach), "%s", e != -1 ? uts.machine : "unknown");
+	xsnprintf(host, sizeof(host), "%s-%s",
+	    e != -1 ? uts.machine : "unknown", ostype);
+}
 
-newcode	:
+static char *
+getmach(void)
+{
+    if (!mach[0])
+	populate();
+    return mach;
+}
+
+static char *
+gethost(void)
+{
+    if (!host[0])
+	populate();
+    return host;
+}
+
+static char *
+getostype(void)
+{
+    if (!ostype[0])
+	populate();
+    return ostype;
+}
+
+endcode :
+enddef :
+
+newcode :
 void
 getmachine(void)
 {
@@ -178,7 +232,7 @@
      const char *vendor;
      const char *machtype;
 
-endcode	:
+endcode :
 
 
 newdef	: defined(HOSTTYPE)
@@ -187,16 +241,16 @@
 
 
 newdef	: defined(__PARAGON__)
-comment	: Intel Paragon running OSF/1
+comment : Intel Paragon running OSF/1
 vendor	:						: "intel"
 hosttype:						: "paragon"
 ostype	:						: "osf1"
-machtype: defined(M_i386) 				: "i386"
+machtype: defined(M_i386)				: "i386"
 enddef	:
 
 
 newdef	: defined(AMIX)
-comment	: Amiga running Amix 2.02
+comment : Amiga running Amix 2.02
 vendor	:						: "commodore"
 hosttype:						: "amiga"
 ostype	:						: "Amix"
@@ -205,41 +259,40 @@
 
 
 newdef	: defined(accel)
-comment	: celerity Accel
-vendor	: 						: "celerity"
-hosttype: 						: "celerityACCEL"
+comment : celerity Accel
+vendor	:						: "celerity"
+hosttype:						: "celerityACCEL"
 ostype	:						: "unix"
 machtype:						: "accel"
 enddef	:
 
 
 newdef	: defined(_VMS_POSIX)
-comment	: digital vax or alpha running vms posix
+comment : digital vax or alpha running vms posix
 vendor	:						: "dec"
 hosttype:						: "VMS-POSIX"
 ostype	:						: "vms"
-machtype: defined(__alpha)				: "alpha"
-machtype: defined(__vax) || defined(vax)		: "vax"
-machtype: defined(__vax__) 				: "vax"
+machtype: defined(alpha)				: "alpha"
+machtype: defined(vax)					: "vax"
 enddef	:
 
 
 newdef	: defined(__hp_osf)
-comment	: Hewlett Packard running OSF/1
+comment : Hewlett Packard running OSF/1
 vendor	:						: "hp"
-hosttype: defined(__pa_risc)				: "hp9000s700-osf1"
-hosttype: 						: "hp-osf1"
-ostype	: 						: "osf1"
-machtype: defined(__pa_risc)				: "pa_risc"
+hosttype: defined(pa_risc)				: "hp9000s700-osf1"
+hosttype:						: "hp-osf1"
+ostype	:						: "osf1"
+machtype: defined(pa_risc)				: "pa_risc"
 enddef	:
 
 
 newdef	: defined(hp9000)
-comment	: Hewlett Packard running MORE/bsd 
-vendor	: 						: "hp"
+comment : Hewlett Packard running MORE/bsd 
+vendor	:						: "hp"
 hosttype: defined(hp300)				: "hp300"
 hosttype: defined(hp800)				: "hp800"
-hosttype: 						: "hp9000"
+hosttype:						: "hp9000"
 ostype	: defined(BSD4_4)				: "bsd44"
 ostype	:						: "mtXinu"
 machtype: defined(hp300)				: "m68k"
@@ -248,54 +301,55 @@
 
 
 newdef	: defined(hpux) || defined(__hpux)
-comment	: Hewlett Packard running HP/UX
+comment : Hewlett Packard running HP/UX
 vendor	:						: "hp"
-hosttype: defined(__hp9000s700)				: "hp9000s700"
-hosttype: defined(__hp9000s800) || defined(hp9000s800)  : "hp9000s800"
+hosttype: defined(hp9000s800)				: "hp9000s800"
+hosttype: defined(hp9000s700)				: "hp9000s700"
 hosttype: defined(hp9000s500)				: "hp9000s500"
-hosttype: defined(__hp9000s300) || defined(hp9000s300)  : "hp9000s300"
-hosttype: 						: "hp"
+hosttype: defined(hp9000s300)				: "hp9000s300"
+hosttype:						: "hp"
 ostype	:						: "hpux"
-machtype: defined(__hp9000s700)				: "pa_risc"
-machtype: defined(__hp9000s800) || defined(hp9000s800)  : "pa_risc"
+machtype: defined(hp9000s800)				: "pa_risc"
+machtype: defined(hp9000s700)				: "pa_risc"
 machtype: defined(hp9000s500)				: "m68k"
-machtype: defined(__hp9000s300) || defined(hp9000s300)  : "m68k"
+machtype: defined(hp9000s300)				: "m68k"
 enddef	:
 
 
 newdef	: defined(apollo)
-comment	: Hewlett Packard apollo running Domain/OS
+comment : Hewlett Packard apollo running Domain/OS
 vendor	:						: "hp"
-hosttype: 						: "apollo"
+hosttype:						: "apollo"
 ostype	:						: "DomainOS"
-machtype: 						: "m68k"
+machtype:						: "m68k"
 enddef	:
 
 
 newdef	: defined(sun) || defined(__sun__)
-comment	: Sun Microsystems series 2 workstation (68010 based)
-comment	: Sun Microsystems series 3 workstation (68020 based)
-comment	: Sun Microsystems 386i workstation (386 based)
-comment	: Sun Microsystems series 4 workstation (SPARC based)
+comment : Sun Microsystems series 2 workstation (68010 based)
+comment : Sun Microsystems series 3 workstation (68020 based)
+comment : Sun Microsystems 386i workstation (386 based)
+comment : Sun Microsystems series 4 workstation (SPARC based)
 vendor	:						: "sun"
 hosttype: defined(M_i386) && !defined(__SVR4)		: "sun386i"
 hosttype: defined(M_i386) && defined(__SVR4)		: "i86pc"
-hosttype: defined(mc68010) || defined(__mc68010__)	: "sun2"
-hosttype: defined(mc68020) || defined(__mc68020__)	: "sun3"
-hosttype: defined(sparc) || defined(__sparc__)		: "sun4"
-hosttype: 						: "sun"
+hosttype: defined(mc68010)				: "sun2"
+hosttype: defined(mc68020)				: "sun3"
+hosttype: defined(sparc)				: "sun4"
+hosttype:						: "sun"
 ostype	: defined(SUNOS3)				: "sunos3"
 ostype	: defined(SUNOS4)				: "sunos4"
 ostype	: defined(SOLARIS2)				: "solaris"
-machtype: defined(mc68010) || defined(__mc68010__)	: "m68k"
-machtype: defined(mc68020) || defined(__mc68020__)	: "m68k"
-machtype: defined(sparc) || defined(__sparc__)		: "sparc"
+machtype: defined(mc68010)				: "m68k"
+machtype: defined(mc68020)				: "m68k"
+machtype: defined(sparcv9)				: "sparcv9"
+machtype: defined(sparc)				: "sparc"
 machtype: defined(M_i386)				: "i386"
 enddef	:
 
 
 newdef	: defined(pyr)
-comment	: Pyramid Technology
+comment : Pyramid Technology
 vendor	:						: "pyramid"
 hosttype:						: "pyramid"
 machtype:						: "pyramid"
@@ -303,7 +357,7 @@
 
 
 newdef	: defined(hcx) || defined(_CX_UX)
-comment	: Harris Tahoe running CX/UX
+comment : Harris Tahoe running CX/UX
 vendor	:						: "harris"
 hosttype:						: "hcx"
 ostype	:						: "hcx"
@@ -312,7 +366,7 @@
 
 
 newdef	: defined(tahoe)
-comment	: Harris Tahoe
+comment : Harris Tahoe
 vendor	:						: "harris"
 hosttype:						: "tahoe"
 machtype:						: "tahoe"
@@ -320,17 +374,17 @@
 
 
 newdef	: defined(ibm032)
-comment	: RT running IBM AOS4.3 or MACH
+comment : RT running IBM AOS4.3 or MACH
 vendor	:						: "ibm"
 hosttype:						: "rt"
 ostype	: defined(MACH)					: "mach"
-ostype	: 						: "aos"
+ostype	:						: "aos"
 machtype:						: "ibm032"
 enddef	:
 
 
 newdef	: defined(aiws)
-comment	: RT running IBM aix2.x
+comment : RT running IBM aix2.x
 vendor	:						: "ibm"
 hosttype:						: "rtpc"
 ostype	:						: "aix"
@@ -339,7 +393,7 @@
 
 
 newdef	: defined(_AIX370)
-comment	: IBM/370 running aix
+comment : IBM/370 running aix
 vendor	:						: "ibm"
 hosttype:						: "aix370"
 ostype	:						: "aix"
@@ -348,7 +402,7 @@
 
 
 newdef	: defined(_IBMESA)
-comment	: IBM/ESA running aix
+comment : IBM/ESA running aix
 vendor	:						: "ibm"
 hosttype:						: "aixESA"
 ostype	:						: "aix"
@@ -357,7 +411,7 @@
 
 
 newdef	: defined(_IBMR2)
-comment	: IBM/RS6000 running aix
+comment : IBM/RS6000 running aix
 vendor	:						: "ibm"
 hosttype:						: "rs6000"
 ostype	:						: "aix"
@@ -366,7 +420,7 @@
 
 
 newdef	: defined(_AIXPS2)
-comment	: IBM/PS2 running aix
+comment : IBM/PS2 running aix
 vendor	:						: "ibm"
 hosttype:						: "ps2"
 ostype	:						: "aix"
@@ -375,7 +429,7 @@
 
 
 newdef	: defined(OREO)
-comment	: Macintosh running AU/X
+comment : Macintosh running AU/X
 vendor	:						: "apple"
 hosttype:						: "mac2"
 ostype	:						: "aux"
@@ -384,7 +438,7 @@
 
 
 newdef	: defined(u3b20d)
-comment	: AT&T 3B/20 series running SVR2/3 
+comment : AT&T 3B/20 series running SVR2/3 
 vendor	:						: "att"
 hosttype:						: "att3b20"
 machtype:						: "u3b20"
@@ -392,7 +446,7 @@
 
 
 newdef	: defined(u3b15)
-comment	: AT&T 3B/15 series running SVR2/3 
+comment : AT&T 3B/15 series running SVR2/3 
 vendor	:						: "att"
 hosttype:						: "att3b15"
 machtype:						: "u3b15"
@@ -400,7 +454,7 @@
 
 
 newdef	: defined(u3b5)
-comment	: AT&T 3B/5 series running SVR2/3 
+comment : AT&T 3B/5 series running SVR2/3 
 vendor	:						: "att"
 hosttype:						: "att3b5"
 machtype:						: "u3b5"
@@ -408,7 +462,7 @@
 
 
 newdef	: defined(u3b2)
-comment	: AT&T 3B/2 series running SVR2/3 
+comment : AT&T 3B/2 series running SVR2/3 
 vendor	:						: "att"
 hosttype:						: "att3b2"
 machtype:						: "u3b2"
@@ -416,7 +470,7 @@
 
 
 newdef	: defined(UNIXPC)
-comment	: AT&T UnixPC att3b1/att7300
+comment : AT&T UnixPC att3b1/att7300
 vendor	:						: "att"
 hosttype:						: "unixpc"
 machtype: defined(u3b1)					: "u3b1"
@@ -425,7 +479,7 @@
 
 
 newdef	: defined(_MINIX)
-comment	: Andy Tanenbaum's minix
+comment : Andy Tanenbaum's minix
 vendor	: defined(M_i386)				: "intel"
 hosttype: defined(M_i386)				: "minix386"
 hosttype:						: "minix"
@@ -434,41 +488,35 @@
 enddef	:
 
 
-newdef	: defined(linux) || defined(__GNU__) || defined(__GLIBC__)
-comment	: Linus Torvalds's linux
+newdef	: defined(__gnu_hurd__)
+comment : GNU/HURD
 vendor	: defined(M_intel)				: "intel"
-hosttype: defined(__ia64__)				: "ia64-linux"
-hosttype: defined(__powerpc64__)			: "powerpc64-linux"
-hosttype: defined(__s390x__)				: "s390x-linux"
-hosttype: defined(__s390__)				: "s390-linux"
-hosttype: defined(__x86_64__)				: "x86_64-linux"
-hosttype: defined(M_i586) 				: "i586-linux"
-hosttype: defined(M_i486) 				: "i486-linux"
-hosttype: defined(M_i386)				: "i386-linux"
-ostype	: 						: "linux"
-machtype: defined(__ia64__)				: "ia64"
-machtype: defined(__powerpc64__)			: "powerpc64"
-machtype: defined(__s390x__)				: "s390x"
-machtype: defined(__s390__)				: "s390"
-machtype: defined(__x86_64__)				: "x86_64"
-machtype: defined(M_i586) 				: "i586"
-machtype: defined(M_i486) 				: "i486"
-machtype: defined(M_i386)				: "i386"
-vendor	: defined(__alpha)				: "dec"
-vendor	: defined(PPC)					: "apple"
-hosttype: defined(__alpha)				: "alpha"
-hosttype: defined(PPC)					: "powerpc"
-machtype: defined(__alpha)				: "alpha"
-machtype: defined(PPC)					: "powerpc"
-machtype: defined(M_mipsel)				: "mipsel"
-machtype: defined(M_mipseb)				: "mipseb"
-machtype: defined(M_mips64el)				: "mips64el"
-machtype: defined(M_mips64eb)				: "mips64eb"
+hosttype: defined(M_i686)				: "i686"
+hosttype: defined(M_i586)				: "i586"
+hosttype: defined(M_i486)				: "i486"
+hosttype: defined(M_i386)				: "i386"
+ostype	:						: "gnu"
+machtype: defined(M_i686)				: "i686-pc-gnu"
+machtype: defined(M_i586)				: "i586-pc-gnu"
+machtype: defined(M_i486)				: "i486-pc-gnu"
+machtype: defined(M_i386)				: "i386-pc-gnu"
 enddef	:
 
 
+newdef	: defined(linux) || defined(__GNU__) || defined(__GLIBC__)
+comment : Linus Torvalds's linux
+vendor	: defined(M_intel)				: "intel"
+hosttype:						: gethost()
+ostype	:						: getostype()
+machtype:						: getmach()
+vendor	: defined(__ANDROID__)				: "linux"
+vendor	: defined(alpha)				: "dec"
+vendor	: defined(PPC)					: "apple"
+enddef	:
+
+
 newdef	: defined(__EMX__)
-comment	: OS/2 EMX [unix emulation under OS/2]
+comment : OS/2 EMX [unix emulation under OS/2]
 vendor	: defined(M_intel)				: "intel"
 hosttype: defined(M_i386)				: "i386-emx"
 ostype	:						: "os2"
@@ -477,7 +525,8 @@
 
 
 newdef	: defined(__NetBSD__) 
-comment	: NetBSD
+comment : NetBSD
+vendor	: defined(algor)				: "algoritmics"
 vendor	: defined(arm32) || defined(__arm__)		: "acorn"
 vendor	: defined(alpha)				: "digital"
 vendor	: defined(amiga)				: "commodore"
@@ -488,49 +537,71 @@
 vendor	: defined(mac68k)				: "apple"
 vendor	: defined(pc532)				: "national-semi"
 vendor	: defined(pmax)					: "dec"
+vendor	: defined(powerpc)				: "motorola"
 vendor	: defined(mips)					: "mips"
 vendor	: defined(sparc)				: "sun"
+vendor	: defined(sparc64)				: "sun"
 vendor	: defined(sun3)					: "sun"
 vendor	: defined(vax)					: "digital"
-hosttype: 						: "NetBSD"
-ostype	: 						: "NetBSD"
+vendor	: defined(x86_64)				: "amd"
+hosttype:						: "NetBSD"
+ostype	:						: "NetBSD"
+machtype: defined(alpha)				: "alpha"
+machtype: defined(algor)				: "algor"
 machtype: defined(arm32) || defined(__APCS_32__)	: "arm32"
 machtype: defined(arm26) || defined(__APCS_26__)	: "arm26"
-machtype: defined(arm) || defined(__arm__)		: "arm"
+machtype: defined(arm)					: "arm"
 machtype: defined(sparc)				: "sparc"
+machtype: defined(sparc64)				: "sparc64"
 machtype: defined(mc68020)				: "m68k"
 machtype: defined(M_i386)				: "i386"
 machtype: defined(M_mipsel)				: "mipsel"
 machtype: defined(M_mipseb)				: "mipseb"
 machtype: defined(mips)					: "mips"
 machtype: defined(pc532)				: "pc532"
+machtype: defined(powerpc)				: "powerpc"
 machtype: defined(vax)					: "vax"
-machtype: defined(alpha)				: "alpha"
+machtype: defined(x86_64)				: "x86_64"
 enddef	:
 
 
 newdef	: defined(__FreeBSD__) 
-comment	: FreeBSD
-vendor	: defined(__alpha)				: "digital"
+comment : FreeBSD
+vendor	: defined(alpha)				: "digital"
+vendor	: defined(arm32) || defined(__arm__)		: "acorn"
 vendor	: defined(M_intel)				: "intel"
+vendor	: defined(ia64)					: "intel"
+vendor	: defined(mips)					: "mips"
+vendor	: defined(powerpc)				: "motorola"
+vendor	: defined(sparc)				: "sun"
+vendor	: defined(sparc64)				: "sun"
+vendor	: defined(x86_64)				: "amd"
 hosttype:						: "FreeBSD"
 ostype	:						: "FreeBSD"
-machtype: defined(__alpha)				: "alpha"
+machtype: defined(alpha)				: "alpha"
+machtype: defined(arm32) || defined(__APCS_32__)	: "arm32"
+machtype: defined(arm)					: "arm"
+machtype: defined(ia64)					: "ia64"
+machtype: defined(M_i386)				: "i386"
+machtype: defined(mips)					: "mips"
+machtype: defined(powerpc)				: "powerpc"
+machtype: defined(sparc)				: "sparc"
+machtype: defined(sparc64)				: "sparc64"
+machtype: defined(x86_64)				: "x86_64"
+enddef	:
+
+
+newdef	: defined(__MidnightBSD__)
+comment : MidnightBSD
+vendor	: defined(M_intel)				: "intel"
+hosttype:						: "MidnightBSD"
+ostype	:						: "MidnightBSD"
 machtype: defined(M_i386)				: "i386"
 enddef	:
 
 
-newdef  : defined(__MidnightBSD__)
-comment : MidnightBSD
-vendor  : defined(M_intel)                              : "intel"
-hosttype:                                               : "MidnightBSD"
-ostype  :                                               : "MidnightBSD"
-machtype: defined(M_i386)                               : "i386"
-enddef  :
-
-
 newdef	: defined(__386BSD__)
-comment	: Bill Jolitz's 386BSD
+comment : Bill Jolitz's 386BSD
 vendor	: defined(M_intel)				: "intel"
 hosttype:						: "386BSD"
 ostype	:						: "386BSD"
@@ -539,22 +610,22 @@
 
 
 newdef	: defined(bsdi)
-comment	: BSDI's unix
+comment : BSDI's unix
 vendor	: defined(M_intel)				: "intel"
 vendor	: defined(sparc)				: "sun"
-vendor	: defined(__powerpc__)				: "motorola"
+vendor	: defined(powerpc)				: "motorola"
 hosttype: defined(M_intel)				: "bsd386"
 hosttype: defined(sparc)				: "bsd-sparc"
-hosttype: defined(__powerpc__)				: "bsd-powerpc"
+hosttype: defined(powerpc)				: "bsd-powerpc"
 ostype	:						: "bsdi"
 machtype: defined(M_i386)				: "i386"
 machtype: defined(sparc)				: "sparc"
-machtype: defined(__powerpc__)				: "powerpc"
+machtype: defined(powerpc)				: "powerpc"
 enddef	:
 
 
 newdef	: defined(COHERENT)
-comment	: COHERENT's unix
+comment : COHERENT's unix
 vendor	: defined(_I386)				: "intel"
 hosttype:						: "coh386"
 hosttype:						: "coherent"
@@ -563,7 +634,7 @@
 enddef	:
 
 newdef	: defined(concurrent)
-comment	: Concurrent PowerHawk
+comment : Concurrent PowerHawk
 vendor	:						: "concurrent"
 hosttype:						: "powerhawk"
 ostype	:						: "powermax_os"
@@ -571,7 +642,7 @@
 enddef	:
 
 newdef	: defined(SCO)
-comment	: SCO UNIX System V/386 Release 3.2
+comment : SCO UNIX System V/386 Release 3.2
 vendor	:						: "sco"
 hosttype:						: "sco386"
 ostype	:						: "sco_unix"
@@ -579,7 +650,7 @@
 enddef	:
 
 newdef	: defined(M_XENIX) && !defined(M_UNIX)
-comment	: SCO XENIX
+comment : SCO XENIX
 vendor	:						: "sco"
 hosttype:						: "sco_xenix"
 ostype	:						: "sco_xenix"
@@ -589,17 +660,17 @@
 
 
 newdef	: defined(ISC) || defined(ISC202)
-comment	: Interactive Unix
+comment : Interactive Unix
 vendor	:						: "isc"
 hosttype:						: "isc386"
 ostype	: defined(POSIX)				: "POSIX"
-ostype	: 						: "SVR3"
+ostype	:						: "SVR3"
 machtype: defined(M_i386)				: "i386"
 enddef	:
 
 
 newdef	: defined(INTEL)
-comment	: Intel Unix
+comment : Intel Unix
 vendor	:						: "intel"
 hosttype:						: "intel386"
 ostype	:						: "intel_unix"
@@ -608,7 +679,7 @@
 
 
 newdef	: defined(MACH)
-comment	: cmu's mach
+comment : cmu's mach
 vendor	:						: "cmu"
 hosttype: defined(M_i386)				: "i386-mach"
 ostype	:						: "mach"
@@ -617,7 +688,7 @@
 
 
 newdef	: defined(alliant)
-comment	: Alliants FSX
+comment : Alliants FSX
 vendor	:						: "alliant"
 hosttype: defined(mc68000)				: "alliant-fx80"
 hosttype: defined(i860)					: "alliant-fx2800"
@@ -629,38 +700,38 @@
 
 
 newdef	: defined(_FTX)
-comment	: Stratus Computer, Inc FTX2 (i860 based)
-comment	: Stratus Computer, Inc FTX3 (HPPA based)
+comment : Stratus Computer, Inc FTX2 (i860 based)
+comment : Stratus Computer, Inc FTX3 (HPPA based)
 vendor	:						: "stratus"
 hosttype: defined(i860) && defined(_FTX)		: "atlantic"
-hosttype: defined(__hppa) && defined(_FTX)		: "continuum"
+hosttype: defined(hppa) && defined(_FTX)		: "continuum"
 ostype	: defined(i860) && defined(_FTX)		: "ftx2"
-ostype	: defined(__hppa) && defined(_FTX)		: "ftx3"
+ostype	: defined(hppa) && defined(_FTX)		: "ftx3"
 machtype: defined(i860)					: "i860"
-machtype: defined(__hppa)				: "hppa"
+machtype: defined(hppa)					: "hppa"
 enddef	:
 
 
 newdef	: defined(sequent) || defined(_SEQUENT_)
-comment	: Sequent Balance (32000 based)
-comment	: Sequent Symmetry running DYNIX/ptx (386/486 based)
-comment	: Sequent Symmetry running DYNIX 3 (386/486 based)
+comment : Sequent Balance (32000 based)
+comment : Sequent Symmetry running DYNIX/ptx (386/486 based)
+comment : Sequent Symmetry running DYNIX 3 (386/486 based)
 vendor	:						: "sequent"
 hosttype: defined(M_i386) && defined(sequent)		: "symmetry"
 hosttype: defined(M_i386)				: "ptx"
-hosttype: 						: "balance"
+hosttype:						: "balance"
 ostype	: defined(M_i386) && !defined(sequent)		: "ptx"
-ostype	: 						: "dynix3"
+ostype	:						: "dynix3"
 machtype: defined(M_i386)				: "i386"
 machtype: defined(ns32000)				: "ns32000"
 enddef	:
 
 
 newdef	: defined(ns32000)
-comment	: Encore Computer Corp. Multimax (32000 based)
+comment : Encore Computer Corp. Multimax (32000 based)
 vendor	:						: "encore"
 hosttype: defined(CMUCS)				: "multimax"
-hosttype: 						: isamultimax(0)
+hosttype:						: isamultimax(0)
 ostype	: defined(CMUCS)				: "mach"
 ostype	:						: isamultimax(1)
 machtype:						: "ns32000"
@@ -668,16 +739,16 @@
 
 
 newdef	: defined(iconuxv)
-comment	: Icon 88k running Unix
+comment : Icon 88k running Unix
 vendor	:						: "icon"
 hosttype:						: "icon"
 ostype	:						: "iconuxv"
-machtype: defined(m88k) || defined(__m88k__)		: "m88k"
+machtype: defined(m88k)					: "m88k"
 enddef	:
 
 
 newdef	: defined(_CRAY) && defined(_CRAYCOM)
-comment	: Cray Computer Corp. running CSOS
+comment : Cray Computer Corp. running CSOS
 vendor	:						: "ccc"
 hosttype: defined(_CRAY2)				: "cray"
 hosttype: defined(_CRAY3)				: "cray"
@@ -690,7 +761,7 @@
 
 
 newdef	: defined(cray) && !defined(_CRAYMPP)
-comment	: Cray Research Inc. PVP running UNICOS
+comment : Cray Research Inc. PVP running UNICOS
 vendor	:						: "cri"
 hosttype:						: getcray()
 ostype	:						: "unicos"
@@ -698,17 +769,17 @@
 enddef	:
 
 
-newdef  : defined(cray) && defined(_CRAYT3D)
+newdef	: defined(cray) && defined(_CRAYT3D)
 comment : Cray Research Inc. running UNICOS MAX
-vendor  :                                               : "cri"
-hosttype:                                               : getcray()
-ostype  :                                               : "unicosmax"
-machtype:                                               : getcray()
-enddef  :
+vendor	:						: "cri"
+hosttype:						: getcray()
+ostype	:						: "unicosmax"
+machtype:						: getcray()
+enddef	:
 
 
 newdef	: defined(cray) && defined(_CRAYT3E)
-comment	: Cray Research Inc. running UNICOS/mk
+comment : Cray Research Inc. running UNICOS/mk
 vendor	:						: "cri"
 hosttype:						: getcray()
 ostype	:						: "unicosmk"
@@ -717,8 +788,8 @@
 
 
 newdef	: defined(convex)
-comment	: Convex
-vendor	: 						: "convex"
+comment : Convex
+vendor	:						: "convex"
 hosttype:						: "convex"
 ostype	:						: "convexos"
 machtype:						: getconvex()
@@ -726,83 +797,81 @@
 
 
 newdef	: defined(butterfly)
-comment	: BBN Butterfly 1000
+comment : BBN Butterfly 1000
 vendor	:						: "bbn"
 hosttype:						: "butterfly"
-machtype: defined(mc68020) || defined(__mc68020__)	: "m68k"
+machtype: defined(mc68020)				: "m68k"
 enddef	:
 
 
 newdef	: defined(NeXT)
-comment	: NeXTStep
+comment : NeXTStep
 vendor	:						: "next"
-hosttype: defined(mc68020) || defined(__mc68020__)	: "next"
-hosttype: defined(M_i386)  || defined(__i386__)		: "intel-pc"
-hosttype: defined(hppa)    || defined(__hppa__)		: "hp"
-hosttype: defined(sparc)   || defined(__sparc__)	: "sun"
+hosttype: defined(mc68020)				: "next"
+hosttype: defined(M_i386) 				: "intel-pc"
+hosttype: defined(hppa)	  				: "hp"
+hosttype: defined(sparc)  				: "sun"
 ostype	:						: "nextstep"
-machtype: defined(mc68020) || defined(__mc68020__)	: "m68k"
-machtype: defined(M_i386)  || defined(__i386__)		: "i386"
-machtype: defined(hppa)    || defined(__hppa__)		: "hppa"
-machtype: defined(sparc)   || defined(__sparc__)	: "sparc"
+machtype: defined(mc68020)				: "m68k"
+machtype: defined(M_i386) 				: "i386"
+machtype: defined(hppa)	  				: "hppa"
+machtype: defined(sparc)  				: "sparc"
 enddef	:
 
 
 newdef	: defined(__APPLE__) && defined(__MACH__)
-comment	: OS X
+comment : OS X
 vendor	:						: "apple"
-hosttype: defined(__i386__)				: "intel-pc"
-hosttype: defined(__ppc__)				: "powermac"
+hosttype: defined(i386)					: "intel-pc"
+hosttype: defined(ppc)					: "powermac"
 ostype	:						: "darwin"
-machtype: defined(__i386__)				: "i386"
-machtype: defined(__ppc__)				: "powerpc"
+machtype: defined(i386)					: "i386"
+machtype: defined(ppc)					: "powerpc"
 enddef	:
 
 
 newdef	: defined(sony_news)
-comment	: Sony NEWS 800 or 1700 workstation
+comment : Sony NEWS 800 or 1700 workstation
 vendor	:						: "sony"
 hosttype: defined(mips)					: "news_mips"
-hosttype: defined(mc68020) || defined(__mc68020__)	: "news_m68k"
+hosttype: defined(mc68020)				: "news_m68k"
 ostype	:						: "News"
-machtype: defined(mc68020) || defined(__mc68020__)	: "m68k"
+machtype: defined(mc68020)				: "m68k"
 machtype: defined(M_mipsel)				: "mipsel"
 machtype: defined(M_mipseb)				: "mipseb"
 enddef	:
 
 
 newdef	: defined(sgi)
-comment	: Silicon Graphics
+comment : Silicon Graphics
 vendor	:						: "sgi"
 hosttype: defined(M_mipsel)				: "iris4d"
 hosttype: defined(M_mipseb)				: "iris4d"
-hosttype: defined(mc68000) 				: "iris3d"
+hosttype: defined(mc68000)				: "iris3d"
 ostype	:						: "irix"
 machtype: defined(M_mipsel)				: "mipsel"
 machtype: defined(M_mipseb)				: "mipseb"
-machtype: defined(mc68000) 				: "mc68000"
+machtype: defined(mc68000)				: "mc68000"
 enddef	:
 
 
 newdef	: defined(ultrix) || defined(__ultrix)
-comment	: Digital's Ultrix 
+comment : Digital's Ultrix 
 vendor	:						: "dec"
 hosttype: defined(M_mipsel)				: "decstation"
 hosttype: defined(M_mipseb)				: "decmips"
-hosttype: defined(vax) || defined(__vax)		: "vax"
-hosttype: defined(__vax__) 				: "vax"
+hosttype: defined(vax)					: "vax"
 ostype	:						: "ultrix"
 machtype: defined(M_mipsel)				: "mipsel"
 machtype: defined(M_mipseb)				: "mipseb"
-machtype: defined(vax) || defined (__vax)		: "vax"
-hosttype: defined(__vax__) 				: "vax"
+machtype: defined(vax)					: "vax"
 enddef	:
 
 
 newdef	: defined(MIPS)
-comment	: Mips OS
+comment : Mips OS
 vendor	:						: "mips"
-hosttype: defined(M_mipsel) 				: "mips"
+hosttype: defined(M_mipsel)				: "mips"
 hosttype: defined(M_mipseb)				: "mips"
 ostype	:						: "mips"
 machtype: defined(M_mipsel)				: "mipsel"
@@ -811,30 +880,30 @@
 
 
 newdef	: defined(DECOSF1)
-comment	: Digital's alpha running osf1
+comment : Digital's alpha running osf1
 vendor	:						: "dec"
 ostype	:						: "osf1"
-hosttype: defined(__alpha)				: "alpha"
-machtype: defined(__alpha)				: "alpha"
+hosttype: defined(alpha)				: "alpha"
+machtype: defined(alpha)				: "alpha"
 enddef	:
 
 
 newdef	: defined(Lynx)
-comment	: Lynx OS 2.1
+comment : Lynx OS 2.1
 vendor	:						: "Lynx"
 hosttype: defined(M_mipsel)				: "lynxos-mips"
 hosttype: defined(M_mipseb)				: "lynxos-mips"
 hosttype: defined(M_i386)				: "lynxos-i386"
-hosttype: defined(i860) || defined(__i860__)		: "lynxos-i860"
+hosttype: defined(i860)					: "lynxos-i860"
 hosttype: defined(m68k)					: "lynxos-m68k"
 hosttype: defined(m88k)					: "lynxos-m88k"
 hosttype: defined(sparc)				: "lynxos-sparc"
-hosttype: 						: "lynxos-unknown"
+hosttype:						: "lynxos-unknown"
 ostype	:						: "LynxOS"
 machtype: defined(M_mipsel)				: "mipsel"
 machtype: defined(M_mipseb)				: "mipseb"
 machtype: defined(M_i386)				: "i386"
-machtype: defined(i860) || defined(__i860__)		: "i860"
+machtype: defined(i860)					: "i860"
 machtype: defined(m68k)					: "m68k"
 machtype: defined(m88k)					: "m88k"
 machtype: defined(sparc)				: "sparc"
@@ -842,24 +911,24 @@
 
 
 newdef	: defined(masscomp)
-comment	: Masscomp
+comment : Masscomp
 vendor	:						: "masscomp"
 hosttype:						: "masscomp"
 ostype	:						: "masscomp"
 enddef	:
 
 newdef	: defined(__MACHTEN__)
-comment	: Machintosh
+comment : Machintosh
 vendor	:						: "Tenon"
 hosttype:						: "Macintosh"
-ostype	: 						: "MachTen"
+ostype	:						: "MachTen"
 machtype:						: "Macintosh"
 enddef	:
 
 
 
 newdef	: defined(GOULD_NP1)
-comment	: Gould
+comment : Gould
 vendor	:						: "gould"
 hosttype:						: "gould_np1"
 machtype:						: "gould"
@@ -867,7 +936,7 @@
 
 
 newdef	: defined(MULTIFLOW)
-comment	: Multiflow running 4.3BSD
+comment : Multiflow running 4.3BSD
 vendor	:						: "multiflow"
 hosttype:						: "multiflow"
 machtype:						: "multiflow"
@@ -876,24 +945,24 @@
 
 
 newdef	: defined(SXA)
-comment	: PFU/Fujitsu A-xx computer
+comment : PFU/Fujitsu A-xx computer
 vendor	:						: "sxa"
 hosttype:						: "pfa50"
 ostype	: defined(_BSDX_)				: "e60-bsdx"
-ostype	: 						: "e60"
+ostype	:						: "e60"
 machtype:						: "pfa50"
 enddef	:
 
 
 newdef	: defined(titan)
-comment	: (St)Ardent Titan
+comment : (St)Ardent Titan
 vendor	:						: "ardent"
 hosttype:						: "titan"
 enddef	:
 
 
 newdef	: defined(stellar)
-comment	: Stellar
+comment : Stellar
 vendor	:						: "stellar"
 hosttype:						: "stellar"
 ostype	:						: "stellix"
@@ -901,8 +970,8 @@
 
 
 newdef	: defined(atari)
-comment	: Atari TT running SVR4. This machine was never
-comment	: commercially available.
+comment : Atari TT running SVR4. This machine was never
+comment : commercially available.
 vendor	:						: "atari"
 hosttype:						: "atari"
 ostype	:						: "asv"
@@ -910,21 +979,21 @@
 
 
 newdef	: defined(OPUS)
-comment	: ???
+comment : ???
 vendor	:						: "opus"
 hosttype:						: "opus"
 enddef	:
 
 
 newdef	: defined(eta10)
-comment	: ETA running SVR3
+comment : ETA running SVR3
 vendor	:						: "eta"
 hosttype:						: "eta10"
 enddef	:
 
 
 newdef	: defined(hk68)
-comment	: Heurikon HK68 running Uniplus+ 5.0
+comment : Heurikon HK68 running Uniplus+ 5.0
 vendor	:						: "heurikon"
 hosttype:						: "hk68"
 ostype	:						: "uniplus"
@@ -932,7 +1001,7 @@
 
 
 newdef	: defined(NDIX)
-comment	: Norsk Data ND 500/5000 running Ndix
+comment : Norsk Data ND 500/5000 running Ndix
 vendor	:						: "norsk"
 hosttype:						: "nd500"
 ostype	:						: "ndix"
@@ -940,7 +1009,7 @@
 
 
 newdef	: defined(AMIGA)
-comment	: Amiga running AmigaOS+GG
+comment : Amiga running AmigaOS+GG
 vendor	:						: "commodore"
 hosttype:						: "amiga"
 ostype	:						: "AmigaOS"
@@ -949,8 +1018,8 @@
 
 
 newdef	: defined(uts)
-comment	: Amdahl running uts 2.1
-vendor	: 						: "amdahl"
+comment : Amdahl running uts 2.1
+vendor	:						: "amdahl"
 hosttype:						: "amdahl"
 ostype	:						: "uts"
 machtype:						: "amdahl"
@@ -958,55 +1027,55 @@
 
 
 newdef	: defined(UTek)
-comment	: Tektronix 4300 running UTek (BSD 4.2 / 68020 based)
+comment : Tektronix 4300 running UTek (BSD 4.2 / 68020 based)
 vendor	:						: "tektronix"
-hosttype: 						: "tek4300"
+hosttype:						: "tek4300"
 enddef	:
 
 
 newdef	: defined(UTekV)
-comment	: Tektronix XD88/10 running UTekV 3.2e (SVR3/88100 based)
+comment : Tektronix XD88/10 running UTekV 3.2e (SVR3/88100 based)
 vendor	:						: "tektronix"
-hosttype: 						: "tekXD88"
+hosttype:						: "tekXD88"
 enddef	:
 
 
 newdef	: defined(__DGUX__)
-comment	: Data-General AViiON running DGUX
+comment : Data-General AViiON running DGUX
 hosttype:						: "aviion"
 ostype	:						: "dgux"
 vendor	:						: "dg"
-machtype: defined(__m88k__)				: "m88k"
-machtype: defined(__i386__)				: "pentium"
+machtype: defined(m88k)					: "m88k"
+machtype: defined(i386)					: "pentium"
 enddef	:
 
 
 newdef	: defined(sysV68)
-comment	: Motorola MPC running System V/68 R32V2 (SVR3/68020 based)
+comment : Motorola MPC running System V/68 R32V2 (SVR3/68020 based)
 vendor	:						: "motorola"
-hosttype: 						: "sysV68"
+hosttype:						: "sysV68"
 machtype:						: "m68k"
 enddef	:
 
 
 newdef	: defined(supermax)
-comment	: DDE Supermax running System V/68 R3 (SVR3/68020 based)
+comment : DDE Supermax running System V/68 R3 (SVR3/68020 based)
 vendor	:						: "supermax"
-hosttype: 						: "supermax"
+hosttype:						: "supermax"
 machtype:						: "m68k"
 enddef	:
 
 
 newdef	: defined(sysV88)
-comment	: Motorola MPC running System V/88 R32V2 (SVR3/88100 based)
+comment : Motorola MPC running System V/88 R32V2 (SVR3/88100 based)
 vendor	:						: "motorola"
-hosttype: 						: "sysV88"
+hosttype:						: "sysV88"
 machtype:						: "m88k"
 enddef	:
 
 
 newdef	: defined(__clipper__)
-comment	: Clipper Chipset (Intergraph)
+comment : Clipper Chipset (Intergraph)
 vendor	:						: "intergraph"
 hosttype:						: "clipper"
 machtype:						: "clipper"
@@ -1017,7 +1086,7 @@
 enddef :
 
 newdef	: (defined(SNI) || defined(sinix)) && !defined(_OSD_POSIX)
-comment	: Fujitsu Siemens Computers (former "Siemens Nixdorf Informationssysteme"): SINIX aka. ReliantUNIX, a SVR4 derivative
+comment : Fujitsu Siemens Computers (former "Siemens Nixdorf Informationssysteme"): SINIX aka. ReliantUNIX, a SVR4 derivative
 vendor	:						: "fsc"
 hosttype: defined(M_intel)				: "wx200i"
 hosttype: defined(MIPSEB)				: "rm400"
@@ -1031,7 +1100,7 @@
 enddef	:
 
 newdef	: defined(_OSD_POSIX)
-comment	: Fujitsu Siemens Computers (former "Siemens Nixdorf Informationssysteme"): BS2000 POSIX (mainframe, EBCDIC)
+comment : Fujitsu Siemens Computers (former "Siemens Nixdorf Informationssysteme"): BS2000 POSIX (mainframe, EBCDIC)
 vendor	:						: "fsc"
 hosttype:						: "bs2000"
 ostype	:						: "osdposix"
@@ -1042,31 +1111,31 @@
 enddef	:
 
 newdef	: defined(__MVS__)
-comment	: ibm uss s/390 (mainframe, EBCDIC)
+comment : ibm uss s/390 (mainframe, EBCDIC)
 vendor	:						: "ibm"
-hosttype:					 	: "s390"
-ostype	: 						: "os390"
+hosttype:						: "s390"
+ostype	:						: "os390"
 machtype:						: "s390"
 enddef	:
 
 newdef	: defined(_SX)
 comment : NEC Corporation (SX-4)
-vendor	: 						: "nec"
+vendor	:						: "nec"
 ostype	:						: "superux"
 hosttype:						: "sx4"
 machtype:						: "sx4"
 enddef	:
 
-newdef  : !defined(SOLARIS2) && (SYSVREL == 4)
+newdef	: !defined(SOLARIS2) && (SYSVREL == 4)
 comment : Unix System V Release 4.0
-vendor  : defined(DELL)					: "dell"
+vendor	: defined(DELL)					: "dell"
 hosttype: defined(M_i386)				: "i386"
-ostype  :						: "svr4"
+ostype	:						: "svr4"
 machtype: defined(M_i386)				: "i386"
 enddef	:
 
 newdef	: defined(__uxp__) || defined(__uxps__)
-comment	: FUJITSU DS/90 7000
+comment : FUJITSU DS/90 7000
 vendor	:						: "fujitsu"
 hosttype:						: "ds90"
 ostype	:						: "sysv4"
@@ -1074,27 +1143,29 @@
 enddef	:
 
 newdef	: defined(__CYGWIN__)
-comment	: Cygwin
-hosttype:						: "i386-cygwin"
-ostype	:						: "cygwin"
+comment : Cygwin
+vendor	:						: "intel"
+hosttype:						: gethost()
+ostype	:						: getostype()
+machtype:						: getmach()
 enddef	:
 
-newdef  : defined(_UWIN)
+newdef	: defined(_UWIN)
 comment : AT&T Research Unix for Windows
-vendor  :               				: "att"
-hosttype:                       			: "win32.i386"
-machtype:                       			: "i386"
+vendor	:						: "att"
+hosttype:						: "win32.i386"
+machtype:						: "i386"
 enddef	:
 
 
-newdef	: defined(mc68000) || defined(__mc68000__) || defined(mc68k32) || defined(m68k) || defined(mc68010) || defined(mc68020)
+newdef	: defined(mc68000) || defined(mc68k32) || defined(m68k) || defined(mc68010) || defined(mc68020)
 hosttype:						: "m68k"
 vendor	: defined(m68k)					: "motorola"
 machtype:						: "m68k"
 enddef	:
 
 
-newdef	: defined(m88k) || defined(__m88k__)
+newdef	: defined(m88k)
 hosttype:						: "m88k"
 machtype:						: "m88k"
 enddef	:
@@ -1104,20 +1175,20 @@
 hosttype: defined(M_i586)				: "i586"
 hosttype: defined(M_i486)				: "i486"
 hosttype: defined(M_i386)				: "i386"
-vendor	: 						: "intel"
+vendor	:						: "intel"
 machtype: defined(M_i586)				: "i586"
 machtype: defined(M_i486)				: "i486"
 machtype: defined(M_i386)				: "i386"
 enddef	:
 
 
-newdef	: defined(sparc) || defined(__sparc__)
+newdef	: defined(sparc)
 hosttype:						: "sparc"
 machtype:						: "sparc"
 enddef	:
 
 
-newdef	: defined(i860) || defined(__i860__)
+newdef	: defined(i860)
 hosttype:						: "i860"
 machtype:						: "i860"
 enddef	:
@@ -1136,26 +1207,26 @@
 
 
 newdef	: SYSVREL == 1
-ostype	: 						: "svr1"
+ostype	:						: "svr1"
 enddef	:
 
 
 newdef	: SYSVREL == 2
-ostype	: 						: "svr2"
+ostype	:						: "svr2"
 enddef	:
 
 
 newdef	: SYSVREL == 3
-ostype	: 						: "svr3"
+ostype	:						: "svr3"
 enddef	:
 
 
 newdef	: SYSVREL == 4
-ostype	: 						: "svr4"
+ostype	:						: "svr4"
 enddef	:
 
 
-newcode	:
+newcode :
 #ifndef _hosttype_
     hosttype = "unknown";
 #endif
@@ -1169,8 +1240,8 @@
     machtype = "unknown";
 #endif
     tsetenv(STRHOSTTYPE, str2short(hosttype));
-    tsetenv(STRVENDOR,   str2short(vendor));
-    tsetenv(STROSTYPE,   str2short(ostype));
+    tsetenv(STRVENDOR,	 str2short(vendor));
+    tsetenv(STROSTYPE,	 str2short(ostype));
     tsetenv(STRMACHTYPE, str2short(machtype));
 } /* end setmachine */
-endcode	:
+endcode :
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/install-sh
--- a/head/contrib/tcsh/install-sh	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/install-sh	Fri Mar 02 16:54:40 2012 +0200
@@ -1,7 +1,7 @@
 #!/bin/sh
 # install - install a program, script, or datafile
 
-scriptversion=2004-12-17.09
+scriptversion=2009-04-28.21; # UTC
 
 # This originates from X11R5 (mit/util/scripts/install.sh), which was
 # later released in X11R6 (xc/config/util/install.sh) with the
@@ -39,38 +39,68 @@
 # when there is no Makefile.
 #
 # This script is compatible with the BSD install script, but was written
-# from scratch.  It can only install one file at a time, a restriction
-# shared with many OS's install programs.
+# from scratch.
+
+nl='
+'
+IFS=" ""	$nl"
 
 # set DOITPROG to echo to test this script
 
 # Don't use :- since 4.3BSD and earlier shells don't like it.
-doit="${DOITPROG-}"
+doit=${DOITPROG-}
+if test -z "$doit"; then
+  doit_exec=exec
+else
+  doit_exec=$doit
+fi
 
-# put in absolute paths if you don't have them in your path; or use env. vars.
+# Put in absolute file names if you don't have them in your path;
+# or use environment vars.
 
-mvprog="${MVPROG-mv}"
-cpprog="${CPPROG-cp}"
-chmodprog="${CHMODPROG-chmod}"
-chownprog="${CHOWNPROG-chown}"
-chgrpprog="${CHGRPPROG-chgrp}"
-stripprog="${STRIPPROG-strip}"
-rmprog="${RMPROG-rm}"
-mkdirprog="${MKDIRPROG-mkdir}"
+chgrpprog=${CHGRPPROG-chgrp}
+chmodprog=${CHMODPROG-chmod}
+chownprog=${CHOWNPROG-chown}
+cmpprog=${CMPPROG-cmp}
+cpprog=${CPPROG-cp}
+mkdirprog=${MKDIRPROG-mkdir}
+mvprog=${MVPROG-mv}
+rmprog=${RMPROG-rm}
+stripprog=${STRIPPROG-strip}
 
-chmodcmd="$chmodprog 0755"
+posix_glob='?'
+initialize_posix_glob='
+  test "$posix_glob" != "?" || {
+    if (set -f) 2>/dev/null; then
+      posix_glob=
+    else
+      posix_glob=:
+    fi
+  }
+'
+
+posix_mkdir=
+
+# Desired mode of installed file.
+mode=0755
+
+chgrpcmd=
+chmodcmd=$chmodprog
 chowncmd=
-chgrpcmd=
+mvcmd=$mvprog
+rmcmd="$rmprog -f"
 stripcmd=
-rmcmd="$rmprog -f"
-mvcmd="$mvprog"
+
 src=
 dst=
 dir_arg=
-dstarg=
+dst_arg=
+
+copy_on_change=false
 no_target_directory=
 
-usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
+usage="\
+Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
    or: $0 [OPTION]... SRCFILES... DIRECTORY
    or: $0 [OPTION]... -t DIRECTORY SRCFILES...
    or: $0 [OPTION]... -d DIRECTORIES...
@@ -80,81 +110,86 @@
 In the 4th, create DIRECTORIES.
 
 Options:
--c         (ignored)
--d         create directories instead of installing files.
--g GROUP   $chgrpprog installed files to GROUP.
--m MODE    $chmodprog installed files to MODE.
--o USER    $chownprog installed files to USER.
--s         $stripprog installed files.
--t DIRECTORY  install into DIRECTORY.
--T         report an error if DSTFILE is a directory.
---help     display this help and exit.
---version  display version info and exit.
+     --help     display this help and exit.
+     --version  display version info and exit.
+
+  -c            (ignored)
+  -C            install only if different (preserve the last data modification time)
+  -d            create directories instead of installing files.
+  -g GROUP      $chgrpprog installed files to GROUP.
+  -m MODE       $chmodprog installed files to MODE.
+  -o USER       $chownprog installed files to USER.
+  -s            $stripprog installed files.
+  -t DIRECTORY  install into DIRECTORY.
+  -T            report an error if DSTFILE is a directory.
 
 Environment variables override the default commands:
-  CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
+  CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
+  RMPROG STRIPPROG
 "
 
-while test -n "$1"; do
+while test $# -ne 0; do
   case $1 in
-    -c) shift
-        continue;;
+    -c) ;;
 
-    -d) dir_arg=true
-        shift
-        continue;;
+    -C) copy_on_change=true;;
+
+    -d) dir_arg=true;;
 
     -g) chgrpcmd="$chgrpprog $2"
-        shift
-        shift
-        continue;;
+	shift;;
 
-    --help) echo "$usage"; exit 0;;
+    --help) echo "$usage"; exit $?;;
 
-    -m) chmodcmd="$chmodprog $2"
-        shift
-        shift
-        continue;;
+    -m) mode=$2
+	case $mode in
+	  *' '* | *'	'* | *'
+'*	  | *'*'* | *'?'* | *'['*)
+	    echo "$0: invalid mode: $mode" >&2
+	    exit 1;;
+	esac
+	shift;;
 
     -o) chowncmd="$chownprog $2"
-        shift
-        shift
-        continue;;
+	shift;;
 
-    -s) stripcmd=$stripprog
-        shift
-        continue;;
+    -s) stripcmd=$stripprog;;
 
-    -t) dstarg=$2
-	shift
-	shift
-	continue;;
+    -t) dst_arg=$2
+	shift;;
 
-    -T) no_target_directory=true
-	shift
-	continue;;
+    -T) no_target_directory=true;;
 
-    --version) echo "$0 $scriptversion"; exit 0;;
+    --version) echo "$0 $scriptversion"; exit $?;;
 
-    *)  # When -d is used, all remaining arguments are directories to create.
-	# When -t is used, the destination is already specified.
-	test -n "$dir_arg$dstarg" && break
-        # Otherwise, the last argument is the destination.  Remove it from $@.
-	for arg
-	do
-          if test -n "$dstarg"; then
-	    # $@ is not empty: it contains at least $arg.
-	    set fnord "$@" "$dstarg"
-	    shift # fnord
-	  fi
-	  shift # arg
-	  dstarg=$arg
-	done
+    --)	shift
 	break;;
+
+    -*)	echo "$0: invalid option: $1" >&2
+	exit 1;;
+
+    *)  break;;
   esac
+  shift
 done
 
-if test -z "$1"; then
+if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
+  # When -d is used, all remaining arguments are directories to create.
+  # When -t is used, the destination is already specified.
+  # Otherwise, the last argument is the destination.  Remove it from $@.
+  for arg
+  do
+    if test -n "$dst_arg"; then
+      # $@ is not empty: it contains at least $arg.
+      set fnord "$@" "$dst_arg"
+      shift # fnord
+    fi
+    shift # arg
+    dst_arg=$arg
+  done
+fi
+
+if test $# -eq 0; then
   if test -z "$dir_arg"; then
     echo "$0: no input file specified." >&2
     exit 1
@@ -164,24 +199,47 @@
   exit 0
 fi
 
+if test -z "$dir_arg"; then
+  trap '(exit $?); exit' 1 2 13 15
+
+  # Set umask so as not to create temps with too-generous modes.
+  # However, 'strip' requires both read and write access to temps.
+  case $mode in
+    # Optimize common cases.
+    *644) cp_umask=133;;
+    *755) cp_umask=22;;
+
+    *[0-7])
+      if test -z "$stripcmd"; then
+	u_plus_rw=
+      else
+	u_plus_rw='% 200'
+      fi
+      cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
+    *)
+      if test -z "$stripcmd"; then
+	u_plus_rw=
+      else
+	u_plus_rw=,u+rw
+      fi
+      cp_umask=$mode$u_plus_rw;;
+  esac
+fi
+
 for src
 do
   # Protect names starting with `-'.
   case $src in
-    -*) src=./$src ;;
+    -*) src=./$src;;
   esac
 
   if test -n "$dir_arg"; then
     dst=$src
-    src=
+    dstdir=$dst
+    test -d "$dstdir"
+    dstdir_status=$?
+  else
 
-    if test -d "$dst"; then
-      mkdircmd=:
-      chmodcmd=
-    else
-      mkdircmd=$mkdirprog
-    fi
-  else
     # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
     # might cause directories to be created, which would be especially bad
     # if $src (and thus $dsttmp) contains '*'.
@@ -190,71 +248,199 @@
       exit 1
     fi
 
-    if test -z "$dstarg"; then
+    if test -z "$dst_arg"; then
       echo "$0: no destination specified." >&2
       exit 1
     fi
 
-    dst=$dstarg
+    dst=$dst_arg
     # Protect names starting with `-'.
     case $dst in
-      -*) dst=./$dst ;;
+      -*) dst=./$dst;;
     esac
 
     # If destination is a directory, append the input filename; won't work
     # if double slashes aren't ignored.
     if test -d "$dst"; then
       if test -n "$no_target_directory"; then
-	echo "$0: $dstarg: Is a directory" >&2
+	echo "$0: $dst_arg: Is a directory" >&2
 	exit 1
       fi
-      dst=$dst/`basename "$src"`
+      dstdir=$dst
+      dst=$dstdir/`basename "$src"`
+      dstdir_status=0
+    else
+      # Prefer dirname, but fall back on a substitute if dirname fails.
+      dstdir=`
+	(dirname "$dst") 2>/dev/null ||
+	expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	     X"$dst" : 'X\(//\)[^/]' \| \
+	     X"$dst" : 'X\(//\)$' \| \
+	     X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
+	echo X"$dst" |
+	    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+		   s//\1/
+		   q
+		 }
+		 /^X\(\/\/\)[^/].*/{
+		   s//\1/
+		   q
+		 }
+		 /^X\(\/\/\)$/{
+		   s//\1/
+		   q
+		 }
+		 /^X\(\/\).*/{
+		   s//\1/
+		   q
+		 }
+		 s/.*/./; q'
+      `
+
+      test -d "$dstdir"
+      dstdir_status=$?
     fi
   fi
 
-  # This sed command emulates the dirname command.
-  dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'`
+  obsolete_mkdir_used=false
 
-  # Make sure that the destination directory exists.
+  if test $dstdir_status != 0; then
+    case $posix_mkdir in
+      '')
+	# Create intermediate dirs using mode 755 as modified by the umask.
+	# This is like FreeBSD 'install' as of 1997-10-28.
+	umask=`umask`
+	case $stripcmd.$umask in
+	  # Optimize common cases.
+	  *[2367][2367]) mkdir_umask=$umask;;
+	  .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
 
-  # Skip lots of stat calls in the usual case.
-  if test ! -d "$dstdir"; then
-    defaultIFS='
-	 '
-    IFS="${IFS-$defaultIFS}"
+	  *[0-7])
+	    mkdir_umask=`expr $umask + 22 \
+	      - $umask % 100 % 40 + $umask % 20 \
+	      - $umask % 10 % 4 + $umask % 2
+	    `;;
+	  *) mkdir_umask=$umask,go-w;;
+	esac
 
-    oIFS=$IFS
-    # Some sh's can't handle IFS=/ for some reason.
-    IFS='%'
-    set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
-    shift
-    IFS=$oIFS
+	# With -d, create the new directory with the user-specified mode.
+	# Otherwise, rely on $mkdir_umask.
+	if test -n "$dir_arg"; then
+	  mkdir_mode=-m$mode
+	else
+	  mkdir_mode=
+	fi
 
-    pathcomp=
+	posix_mkdir=false
+	case $umask in
+	  *[123567][0-7][0-7])
+	    # POSIX mkdir -p sets u+wx bits regardless of umask, which
+	    # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
+	    ;;
+	  *)
+	    tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+	    trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
 
-    while test $# -ne 0 ; do
-      pathcomp=$pathcomp$1
+	    if (umask $mkdir_umask &&
+		exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
+	    then
+	      if test -z "$dir_arg" || {
+		   # Check for POSIX incompatibilities with -m.
+		   # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
+		   # other-writeable bit of parent directory when it shouldn't.
+		   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+		   ls_ld_tmpdir=`ls -ld "$tmpdir"`
+		   case $ls_ld_tmpdir in
+		     d????-?r-*) different_mode=700;;
+		     d????-?--*) different_mode=755;;
+		     *) false;;
+		   esac &&
+		   $mkdirprog -m$different_mode -p -- "$tmpdir" && {
+		     ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
+		     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+		   }
+		 }
+	      then posix_mkdir=:
+	      fi
+	      rmdir "$tmpdir/d" "$tmpdir"
+	    else
+	      # Remove any dirs left behind by ancient mkdir implementations.
+	      rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
+	    fi
+	    trap '' 0;;
+	esac;;
+    esac
+
+    if
+      $posix_mkdir && (
+	umask $mkdir_umask &&
+	$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
+      )
+    then :
+    else
+
+      # The umask is ridiculous, or mkdir does not conform to POSIX,
+      # or it failed possibly due to a race condition.  Create the
+      # directory the slow way, step by step, checking for races as we go.
+
+      case $dstdir in
+	/*) prefix='/';;
+	-*) prefix='./';;
+	*)  prefix='';;
+      esac
+
+      eval "$initialize_posix_glob"
+
+      oIFS=$IFS
+      IFS=/
+      $posix_glob set -f
+      set fnord $dstdir
       shift
-      if test ! -d "$pathcomp"; then
-        $mkdirprog "$pathcomp"
-	# mkdir can fail with a `File exist' error in case several
-	# install-sh are creating the directory concurrently.  This
-	# is OK.
-	test -d "$pathcomp" || exit
+      $posix_glob set +f
+      IFS=$oIFS
+
+      prefixes=
+
+      for d
+      do
+	test -z "$d" && continue
+
+	prefix=$prefix$d
+	if test -d "$prefix"; then
+	  prefixes=
+	else
+	  if $posix_mkdir; then
+	    (umask=$mkdir_umask &&
+	     $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
+	    # Don't fail if two instances are running concurrently.
+	    test -d "$prefix" || exit 1
+	  else
+	    case $prefix in
+	      *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+	      *) qprefix=$prefix;;
+	    esac
+	    prefixes="$prefixes '$qprefix'"
+	  fi
+	fi
+	prefix=$prefix/
+      done
+
+      if test -n "$prefixes"; then
+	# Don't fail if two instances are running concurrently.
+	(umask $mkdir_umask &&
+	 eval "\$doit_exec \$mkdirprog $prefixes") ||
+	  test -d "$dstdir" || exit 1
+	obsolete_mkdir_used=true
       fi
-      pathcomp=$pathcomp/
-    done
+    fi
   fi
 
   if test -n "$dir_arg"; then
-    $doit $mkdircmd "$dst" \
-      && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
-      && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
-      && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
-      && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
-
+    { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
+    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
+    { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
+      test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
   else
-    dstfile=`basename "$dst"`
 
     # Make a couple of temp file names in the proper directory.
     dsttmp=$dstdir/_inst.$$_
@@ -262,10 +448,9 @@
 
     # Trap to clean up those temp files at exit.
     trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
-    trap '(exit $?); exit' 1 2 13 15
 
     # Copy the file name to the temp name.
-    $doit $cpprog "$src" "$dsttmp" &&
+    (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
 
     # and set any options; do chmod last to preserve setuid bits.
     #
@@ -273,51 +458,63 @@
     # ignore errors from any of these, just make sure not to ignore
     # errors from the above "$doit $cpprog $src $dsttmp" command.
     #
-    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
-      && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
-      && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
-      && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
+    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
+    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
+    { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
+    { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
 
-    # Now rename the file to the real destination.
-    { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
-      || {
-	   # The rename failed, perhaps because mv can't rename something else
-	   # to itself, or perhaps because mv is so ancient that it does not
-	   # support -f.
+    # If -C, don't bother to copy if it wouldn't change the file.
+    if $copy_on_change &&
+       old=`LC_ALL=C ls -dlL "$dst"	2>/dev/null` &&
+       new=`LC_ALL=C ls -dlL "$dsttmp"	2>/dev/null` &&
 
-	   # Now remove or move aside any old file at destination location.
-	   # We try this two ways since rm can't unlink itself on some
-	   # systems and the destination file might be busy for other
-	   # reasons.  In this case, the final cleanup might fail but the new
-	   # file should still install successfully.
-	   {
-	     if test -f "$dstdir/$dstfile"; then
-	       $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
-	       || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
-	       || {
-		 echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
-		 (exit 1); exit 1
-	       }
-	     else
-	       :
-	     fi
-	   } &&
+       eval "$initialize_posix_glob" &&
+       $posix_glob set -f &&
+       set X $old && old=:$2:$4:$5:$6 &&
+       set X $new && new=:$2:$4:$5:$6 &&
+       $posix_glob set +f &&
 
-	   # Now rename the file to the real destination.
-	   $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
-	 }
-    }
-  fi || { (exit 1); exit 1; }
+       test "$old" = "$new" &&
+       $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
+    then
+      rm -f "$dsttmp"
+    else
+      # Rename the file to the real destination.
+      $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
+
+      # The rename failed, perhaps because mv can't rename something else
+      # to itself, or perhaps because mv is so ancient that it does not
+      # support -f.
+      {
+	# Now remove or move aside any old file at destination location.
+	# We try this two ways since rm can't unlink itself on some
+	# systems and the destination file might be busy for other
+	# reasons.  In this case, the final cleanup might fail but the new
+	# file should still install successfully.
+	{
+	  test ! -f "$dst" ||
+	  $doit $rmcmd -f "$dst" 2>/dev/null ||
+	  { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
+	    { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
+	  } ||
+	  { echo "$0: cannot unlink or rename $dst" >&2
+	    (exit 1); exit 1
+	  }
+	} &&
+
+	# Now rename the file to the real destination.
+	$doit $mvcmd "$dsttmp" "$dst"
+      }
+    fi || exit 1
+
+    trap '' 0
+  fi
 done
 
-# The final little trick to "correctly" pass the exit status to the exit trap.
-{
-  (exit 0); exit 0
-}
-
 # Local variables:
 # eval: (add-hook 'write-file-hooks 'time-stamp)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
 # End:
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/C/charset
--- a/head/contrib/tcsh/nls/C/charset	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/C/charset	Fri Mar 02 16:54:40 2012 +0200
@@ -1,3 +1,3 @@
-$ codeset=US-ASCII
+$ codeset=UTF-8
 $set 255
-1 US-ASCII
+1 UTF-8
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/C/set19
--- a/head/contrib/tcsh/nls/C/set19	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/C/set19	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set19,v 1.4 2006/03/02 18:46:45 christos Exp $
+$ $tcsh: set19,v 1.6 2011/02/25 23:58:07 christos Exp $
 $ tc.alloc.c
 $set 19 
 1 nbytes=%d: Out of memory\n
@@ -9,7 +9,15 @@
 6 free(%lx) bad range check.
 7 free(%lx) bad block index.
 8 %s current memory allocation:\nfree:\t
-9 \nused:\t
+9 used
 10 \n\tTotal in use: %d, total free: %d\n
 11 \tAllocated memory from 0x%lx to 0x%lx.  Real top at 0x%lx\n
 12 Allocated memory from 0x%lx to 0x%lx (%ld).\n
+13 %s current memory allocation:\n
+14 Total space allocated from system: %d\n
+15 Number of non-inuse chunks: %d\n
+16 Number of mmapped regions: %d\n
+17 Total space in mmapped regions: %d\n
+18 Total allocated space: %d\n
+19 Total non-inuse space: %d\n
+20 Top-most, releasable space: %d\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/et/charset
--- a/head/contrib/tcsh/nls/et/charset	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/et/charset	Fri Mar 02 16:54:40 2012 +0200
@@ -1,3 +1,3 @@
-$ codeset=ISO-8859-1
+$ codeset=UTF-8
 $set 255
-1 ISO-8859-1
+1 UTF-8
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/et/set1
--- a/head/contrib/tcsh/nls/et/set1	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/et/set1	Fri Mar 02 16:54:40 2012 +0200
@@ -1,140 +1,140 @@
-$ $tcsh: set1,v 1.3 2006/03/02 18:46:45 christos Exp $
+$ $tcsh: set1,v 1.4 2011/02/04 18:19:33 christos Exp $
 $ Error messages
 $set 1 
-1 Süntaksi viga
+1 Süntaksi viga
 2 %s ei ole lubatud
-3 Sõna on liiga pikk
+3 Sõna on liiga pikk
 4 $< rida on liiga pikk
 5 $0 jaoks pole faili
-6 Mittetäielik [] muutja
-7 $ laiendus peab lõppema enne ]
-8 Halb : täiendaja $ (%c)
+6 Mittetäielik [] muutja
+7 $ laiendus peab lõppema enne ]
+8 Halb : täiendaja $ (%c)
 9 Viga indeksis
 10 Vigane number
-11 Sõnad on otsas
+11 Sõnad on otsas
 12 Faili nimi on puudu
-13 Sisemine täiendi viga
-14 Käsku pole
-15 Liiga vähe argumente
+13 Sisemine täiendi viga
+14 Käsku pole
+15 Liiga vähe argumente
 16 Liiga palju argumente
 17 Seda aliast on liiga ohtlik luua
-18 Tühi if
-19 Ebaõige then
-20 Sõnad pole sulgudes
+18 Tühi if
+19 Ebaõige then
+20 Sõnad pole sulgudes
 21 %s ei leita
 22 Vigane mask
 23 Pole sellist limiiti
 24 Argument on liiga suur
-25 Vigane või tundmatu skaleerimis faktor
+25 Vigane või tundmatu skaleerimis faktor
 26 Defineerimata muutuja
-27 Kataloogi pinu pole nii sügav
+27 Kataloogi pinu pole nii sügav
 28 Vigane signaali number
 29 Tundmatu signaal; kill -l annab signaalid
-30 Muutuja nimi peab algama tähega
+30 Muutuja nimi peab algama tähega
 31 Muutuja nimi on liiga pikk
-32 Muutuja nimi võib koosneda ainult tähtedest ja numbritest
-33 Sellel käsuinterpretaatoril puudub töökontroll
-34 Avaldises on süntaksi viga
+32 Muutuja nimi võib koosneda ainult tähtedest ja numbritest
+33 Sellel käsuinterpretaatoril puudub töökontroll
+34 Avaldises on süntaksi viga
 35 Kodukataloogi pole
 36 Kodukataloogi ei saa minna
-37 Vigane tühi käsk
+37 Vigane tühi käsk
 38 Omistamisel pole avaldist
 39 Tundmatu operaator
 40 Arusaamatu
 41 %s: Fail on olemas
-42 Võtme -c argumendi lõpus on langkriips
+42 Võtme -c argumendi lõpus on langkriips
 43 Katkestatud
-44 Indeks on piiridest väljas
-45 Rea ületäitumine 
-46 Sellist tööd pole
+44 Indeks on piiridest väljas
+45 Rea ületäitumine 
+46 Sellist tööd pole
 47 Terminalilt ei saa
 48 Pole while/foreach sees
 49 Protsessid on otsas
 50 Ei leia
 51 Puuduv %c
-52 Ei leia sümbolit %c
-53 Mälu on otsas
+52 Ei leia sümbolit %c
+53 Mälu on otsas
 54 Toru ei saa luua
 55 %s: %s
 56 %s
 57 Kasuta: jobs [ -l ]
-58 Argumendid peavad olema tööde või protsesside identifikaatorid
-59 Käesolevat tööd pole
-60 Pole eelmist tööd
-61 Pole mustrile vastavat tööd
-62 Fork süveneb > %d; võibolla `...` tsükkel
-63 Alamshellis pole töökontrolli
-64 Sünkroniseerimise tõrge: Protsessi %d pole
-65 %sTeil on peatatud töid
-66 %sTeil on seisatud töid
+58 Argumendid peavad olema tööde või protsesside identifikaatorid
+59 Käesolevat tööd pole
+60 Pole eelmist tööd
+61 Pole mustrile vastavat tööd
+62 Fork süveneb > %d; võibolla `...` tsükkel
+63 Alamshellis pole töökontrolli
+64 Sünkroniseerimise tõrge: Protsessi %d pole
+65 %sTeil on peatatud töid
+66 %sTeil on seisatud töid
 67 Pole teist kataloogi
-68 Kataloogi pinu on tühi
+68 Kataloogi pinu on tühi
 69 Halb kataloog
 70 kasuta: %s [-%s]%s
-71 -h võtmel puudub operand
+71 -h võtmel puudub operand
 72 Pole meldimise shell
 73 Nulliga jagamine
-74 Jäägi leidmine nulliga
-75 Vigane skaala; te mõtlesite ehk "%s"?
+74 Jäägi leidmine nulliga
+75 Vigane skaala; te mõtlesite ehk "%s"?
 76 Login shelli ei saa peatada (praegu)
 77 Tundmatu kasutaja: %s
-78 $home muutujat pole väärtustatud
-79 Kasuta: history [-%s] [# sündmuste number]
-80 $, ! või < pole lubatud kasutada koos $# või $?
+78 $home muutujat pole väärtustatud
+79 Kasuta: history [-%s] [# sündmuste number]
+80 $, ! või < pole lubatud kasutada koos $# või $?
 81 Reavahetus muutuja nimes
-82 * pole lubatud kasutada koos $# või $?
-83 $?<number> või $#<number> pole lubatud
+82 * pole lubatud kasutada koos $# või $?
+83 $?<number> või $#<number> pole lubatud
 84 Lubamatu muutuja nimi
 85 Reavahetus muutuja indeksis
-86 Laiendamise puhvri ületäitumine
-87 Muutuja süntaksi viga
+86 Laiendamise puhvri ületäitumine
+87 Muutuja süntaksi viga
 88 Vigane ! kasutamine
 89 Eelmist asendust pole
 90 Vigane asendamine
 91 Eelmist vasakut poolt pole
 92 Parem pool on liiga pikk
 93 Vigane ! modifikaator: %c
-94 Modifikaator ebaõnnestus
-95 Asenduse puhvri ületäitumine
+94 Modifikaator ebaõnnestus
+95 Asenduse puhvri ületäitumine
 96 Vigane ! argumendi valik
 97 Pole eelmist otsimist
-98 %s: Sündmust pole
+98 %s: Sündmust pole
 99 Liiga palju )
 100 Liiga palju (
 101 Halvasti paigutatud (
 102 Suunamisel pole nime antud
-103 Segane väljundi suunamine
+103 Segane väljundi suunamine
 104 << ei saa () vahel kasutada
 105 Segane sisendi suunamine
 106 Halvasti paigutatud ()
-107 Aliaste tsükkel
+107 Aliaste tsükkel
 108 $watch muutuja pole seatud
-109 Plaanitud sündmuseid pole
-110 Kasuta: sched -<sündmuse#>.\nKasuta: sched [+]hh:mm <käsk>
-111 Niipalju sündmuseid pole
-112 Pole käsku, mida käivitada
-113 Vigane sündmuseaeg
-114 Suhteline aeg ei ole am/pm notatsiooniga kooskõlas
-115 Termcap sõne on liiga pikk
+109 Plaanitud sündmuseid pole
+110 Kasuta: sched -<sündmuse#>.\nKasuta: sched [+]hh:mm <käsk>
+111 Niipalju sündmuseid pole
+112 Pole käsku, mida käivitada
+113 Vigane sündmuseaeg
+114 Suhteline aeg ei ole am/pm notatsiooniga kooskõlas
+115 Termcap sõne on liiga pikk
 116 Kasuta: settc %s [yes|no]
 117 Tundmatu omadus `%s'
 118 Tundmatu termcap parameeter `%%%c'
 119 `%s' jaoks on liiga palju argumente (%d)
-120 `%s' nõuab %d argumenti
+120 `%s' nõuab %d argumenti
 121 Kasuta: echotc [-v|-s] [<omadus> [<argumendid>]]
 122 %s: %s. Vale arhitektuur
-123 !# Ajaloo tsükkel
-124 Vigane failipäring
-125 Valija ületäitumine 
-126 Tundmatu võti: `-%s'\nKasuta: %s [ -bcdefilmnqstvVxX -Dnimi[=väärtus] ] [ argument ... ]
-127 Tundmatu võti: `-%s'\nKasuta: %s [ -bcdefFilmnqstvVxX ] [ argument ... ]
-128 Tundmatu võti: `-%s'\nKasuta: %s [ -bcdefilmnqstvVxX ] [ argument ... ]
-129 \nVigane täiendus: "%s"
+123 !# Ajaloo tsükkel
+124 Vigane failipäring
+125 Valija ületäitumine 
+126 Tundmatu võti: `-%s'\nKasuta: %s [ -bcdefilmnqstvVxX -Dnimi[=väärtus] ] [ argument ... ]
+127 Tundmatu võti: `-%s'\nKasuta: %s [ -bcdefFilmnqstvVxX ] [ argument ... ]
+128 Tundmatu võti: `-%s'\nKasuta: %s [ -bcdefilmnqstvVxX ] [ argument ... ]
+129 \nVigane täiendus: "%s"
 130 \nVigane %s: '%c'
-131 \nEraldaja '%c' puudub pärast %s "%s"
-132 \nMittetäielik %s: "%s"
-133 -m võtmel pole operandi
+131 \nEraldaja '%c' puudub pärast %s "%s"
+132 \nMittetäielik %s: "%s"
+133 -m võtmel pole operandi
 134 Kasuta: unlimit [-fh] [limiidid]
 135 $%S on ainult lugemiseks
-136 Pole sellist tööd
+136 Pole sellist tööd
 137 Tundmatu colorls muutuja `%c%c'
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/et/set10
--- a/head/contrib/tcsh/nls/et/set10	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/et/set10	Fri Mar 02 16:54:40 2012 +0200
@@ -1,8 +1,8 @@
-$ $tcsh: set10,v 1.2 2006/03/02 18:46:45 christos Exp $
+$ $tcsh: set10,v 1.3 2011/02/04 18:19:33 christos Exp $
 $ ma.setp.c
 $set 10 
-1 setpath: vigane käsk '%s'.\n
-2 setpath: käsule '%s' pole piisavalt argumente.\n
-3 setpath: teel '%s' pole väärtust\n
+1 setpath: vigane käsk '%s'.\n
+2 setpath: käsule '%s' pole piisavalt argumente.\n
+3 setpath: teel '%s' pole väärtust\n
 4 setpath: %s ei leitud %s's\n
 5 setpath: %d ei ole korrektne positsioon %s's\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/et/set11
--- a/head/contrib/tcsh/nls/et/set11	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/et/set11	Fri Mar 02 16:54:40 2012 +0200
@@ -1,8 +1,8 @@
-$ $tcsh: set11,v 1.2 2006/03/02 18:46:45 christos Exp $
+$ $tcsh: set11,v 1.3 2011/02/04 18:19:33 christos Exp $
 $ sh.c
 $set 11 
-1 Hoiatus: tty (%s) pole kättesaadav.\n
-2 Seega ei saa kasutada tööde kontrolli.\n
+1 Hoiatus: tty (%s) pole kättesaadav.\n
+2 Seega ei saa kasutada tööde kontrolli.\n
 3 Teil on %d kirja.\n
 4 Teil on %d kirja failis %s.\n
 5 Teil on %skiri.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/et/set13
--- a/head/contrib/tcsh/nls/et/set13	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/et/set13	Fri Mar 02 16:54:40 2012 +0200
@@ -1,13 +1,13 @@
-$ $tcsh: set13,v 1.2 2006/03/02 18:46:45 christos Exp $
+$ $tcsh: set13,v 1.3 2011/02/04 18:19:33 christos Exp $
 $ sh.exec.c
 $set 13 
 1 hash=%-4d dir=%-2d prog=%s\n
 2 %d hash buckets of %d bits each\n
 3 debug mask = 0x%08x\n
 4 %d hits, %d misses, %d%%\n
-5 %S: käsuinterpretaatori sisekäsk.\n
-6 %S: Käsku pole.\n
-7 where: / käsunimes on mõttetu\n
+5 %S: käsuinterpretaatori sisekäsk.\n
+6 %S: Käsku pole.\n
+7 where: / käsunimes on mõttetu\n
 8 %S on tegelikult 
-9 %S on sisekäsk\n
+9 %S on sisekäsk\n
 10 hash miss: 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/et/set14
--- a/head/contrib/tcsh/nls/et/set14	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/et/set14	Fri Mar 02 16:54:40 2012 +0200
@@ -1,6 +1,6 @@
-$ $tcsh: set14,v 1.2 2006/03/02 18:46:45 christos Exp $
+$ $tcsh: set14,v 1.3 2011/02/04 18:19:33 christos Exp $
 $ sh.file.c
 $set 14 
-1 \nÄhh!! Liiga palju %s!!\n
+1 \nÄhh!! Liiga palju %s!!\n
 2 nimesid paroolifailis
 3 faile
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/et/set15
--- a/head/contrib/tcsh/nls/et/set15	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/et/set15	Fri Mar 02 16:54:40 2012 +0200
@@ -1,7 +1,7 @@
-$ $tcsh: set15,v 1.2 2006/03/02 18:46:45 christos Exp $
+$ $tcsh: set15,v 1.3 2011/02/04 18:19:33 christos Exp $
 $ sh.func.c
 $set 15 
-1 %s: %s: Ei õnnestu %s%s piirangut\n
+1 %s: %s: Ei õnnestu %s%s piirangut\n
 2 eemaldada
 3 seada
-4 \040kõva
+4 \040kõva
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/et/set16
--- a/head/contrib/tcsh/nls/et/set16	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/et/set16	Fri Mar 02 16:54:40 2012 +0200
@@ -1,9 +1,9 @@
-$ $tcsh: set16,v 1.2 2006/03/02 18:46:45 christos Exp $
+$ $tcsh: set16,v 1.3 2011/02/04 18:19:33 christos Exp $
 $ sh.lex.c
 $set 16 
 1 Seadsin tty pgrp numbrilt %d numbrile %d\n
-2 \nKasuta töö lõpetamiseks käsku "logout".\n
-3 \nKasuta "exit" käsku %s katkestamiseks.\n
+2 \nKasuta töö lõpetamiseks käsku "logout".\n
+3 \nKasuta "exit" käsku %s katkestamiseks.\n
 4 seek to eval %x %x\n
 5 seek to alias %x %x\n
 6 seek to file %x\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/et/set17
--- a/head/contrib/tcsh/nls/et/set17	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/et/set17	Fri Mar 02 16:54:40 2012 +0200
@@ -1,17 +1,17 @@
-$ $tcsh: set17,v 1.3 2006/03/02 18:46:45 christos Exp $
+$ $tcsh: set17,v 1.4 2011/02/04 18:19:33 christos Exp $
 $ sh.proc.c
 $set 17 
-1 BUG: ootan taustatöö järel!\n
+1 BUG: ootan taustatöö järel!\n
 2 Exit %d\n
 3 BUG: process flushed twice
-4 Töötab 
+4 Töötab 
 5 Signaal 
 6 Exit %-25d
 7 Valmis
 8 BUG: staatus=%-9o
-9 \040(mälupilt päästetud)
-10 \040(töökataloog:
-11 (töökataloog nüüd: 
+9 \040(mälupilt päästetud)
+10 \040(töökataloog:
+11 (töökataloog nüüd: 
 12 %S: Juba peatatud\n
 13 %S: Juba seisatud\n
 14 %S: Badly formed number\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/et/set18
--- a/head/contrib/tcsh/nls/et/set18	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/et/set18	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set18,v 1.2 2006/03/02 18:46:45 christos Exp $
+$ $tcsh: set18,v 1.3 2011/02/04 18:19:33 christos Exp $
 $ sh.set.c
 $set 18 
-1 Hoiatus: nõmedalt pikk PATH sai lühendatud\n
+1 Hoiatus: nõmedalt pikk PATH sai lühendatud\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/et/set19
--- a/head/contrib/tcsh/nls/et/set19	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/et/set19	Fri Mar 02 16:54:40 2012 +0200
@@ -1,15 +1,23 @@
-$ $tcsh: set19,v 1.2 2006/03/02 18:46:45 christos Exp $
+$ $tcsh: set19,v 1.5 2011/02/25 23:58:07 christos Exp $
 $ tc.alloc.c
 $set 19 
-1 nbytes=%d: Mälu on otsas\n
-2 free(%lx) kasutati enne mälu haaramist.
-3 free(%lx) enne mälu algust.
-4 free(%lx) pärast mälu lõppu.
+1 nbytes=%d: Mälu on otsas\n
+2 free(%lx) kasutati enne mälu haaramist.
+3 free(%lx) enne mälu algust.
+4 free(%lx) pärast mälu lõppu.
 5 free(%lx) halb plokk.
 6 free(%lx) vigane piirkonna kontroll.
 7 free(%lx) vigane plokkide indeks.
-8 %s mälu kasutamine hetkel:\nvaba:\t
-9 \nkasutatud:\t
+8 %s mälu kasutamine hetkel:\nvaba:\t
+9 kasutatud
 10 \n\tKokku kasutusel: %d, kokku vaba: %d\n
-11 \tMälu vahemikus 0x%lx kuni 0x%lx.  Tegelik algus 0x%lx\n
-12 Mälu vahemikus 0x%lx kuni 0x%lx (%ld).\n
+11 \tMälu vahemikus 0x%lx kuni 0x%lx.  Tegelik algus 0x%lx\n
+12 Mälu vahemikus 0x%lx kuni 0x%lx (%ld).\n
+13 %s current memory allocation:\n
+14 Total space allocated from system: %d\n
+15 Number of non-inuse chunks: %d\n
+16 Number of mmapped regions: %d\n
+17 Total space in mmapped regions: %d\n
+18 Total allocated space: %d\n
+19 Total non-inuse space: %d\n
+20 Top-most, releasable space: %d\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/et/set2
--- a/head/contrib/tcsh/nls/et/set2	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/et/set2	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set2,v 1.2 2006/03/02 18:46:45 christos Exp $
+$ $tcsh: set2,v 1.3 2011/02/04 18:19:33 christos Exp $
 $ Signal names
 $set 2 
 1 Null signaal
@@ -20,27 +20,27 @@
 17 Viga siinil
 18 Program range error
 19 Operand range error
-20 Vigane süsteemifunktsioon
+20 Vigane süsteemifunktsioon
 21 Katkenud toru
 22 Alarmkell
 23 Terminated
 24 Alamprotsessi olek muutus
 25 Alamprotsessi surm
-26 Apollo-spetsiifiline tõrge
-27 Alamprotsess peatatud või lõpetas
-28 Alamprotsess lõpetas
-29 Voolutõrge
+26 Apollo-spetsiifiline tõrge
+27 Alamprotsess peatatud või lõpetas
+28 Alamprotsess lõpetas
+29 Voolutõrge
 30 Resource Lost
 31 Break (Ctrl-Break)
-32 Sisend/väljund võimalik
-33 Asünkroonne S/V (select)
+32 Sisend/väljund võimalik
+33 Asünkroonne S/V (select)
 34 Urgent condition on I/O channel
 35 Multitasking wake-up
 36 Multitasking kill
-37 Fortrani asünkroonne S/V lõpetas
+37 Fortrani asünkroonne S/V lõpetas
 38 Recovery
-39 Mitteparandatav mälu viga
-40 CPU aja piirang on ületatud
+39 Mitteparandatav mälu viga
+40 CPU aja piirang on ületatud
 41 System shutdown imminent
 42 micro-tasking group-no wakeup flag set
 43 Thread error - (use cord -T for detailed info)
@@ -50,16 +50,16 @@
 47 Seisatud (signaal)
 48 Peatatud
 49 Seisatud
-50 Jätkab
+50 Jätkab
 51 Peatatud (tty sisend)
 52 Seisatud (tty sisend)
-53 Peatatud (tty väljund)
-54 Seisatud (tty väljund)
+53 Peatatud (tty väljund)
+54 Seisatud (tty väljund)
 55 Akna olek muutus
 56 Akna suurus muutus
 57 Telefoni olek muutus
-58 Cpu aja piirang on ületatud
-59 Faili suuruse piirang on ületatud
+58 Cpu aja piirang on ületatud
+59 Faili suuruse piirang on ületatud
 60 Virtuaalaja alarm
 61 Profiling time alarm
 62 DIL signaal
@@ -76,7 +76,7 @@
 73 Kolmas viimane reaalaja signaal
 74 Teine viimane reaalaja signaal
 75 Viimane reaalaja signaal
-76 LAN Asünkroonne I/O
+76 LAN Asünkroonne I/O
 77 PTY read/write availability
 78 I/O intervention required
 79 HFT monitor mode granted
@@ -88,24 +88,24 @@
 85 Reschedule
 86 Signaling SS$_DEBUG
 87 Prioriteedi muutus
-88 Tuvastati tõeline tupiksituatsioon
-89 Uus sisendsümbol
-90 Pinu piirang on ületatud
+88 Tuvastati tõeline tupiksituatsioon
+89 Uus sisendsümbol
+90 Pinu piirang on ületatud
 91 Kasutamata signaal
 92 LM overlay
-93 süsteemi külmutamine
-94 süsteemi sulatamine
+93 süsteemi külmutamine
+94 süsteemi sulatamine
 95 tupiksituatsioon
-96 mälu suuruse piirang on ületatud
-97 andmete suuruse piirang on ületatud
+96 mälu suuruse piirang on ületatud
+97 andmete suuruse piirang on ületatud
 98 exceeded memory size limit of 32KB
 99 exce error for no memory
 100 check point start
 101 check point start of kernel
 102 restart start
 103 restart of kernel
-104 XMU suuruse piirang on ületatud
-105 RLG0 piirang on ületatud
-106 RLG1 piirang on ületatud
-107 RLG2 piirang on ületatud
-108 RLG3 piirang on ületatud
+104 XMU suuruse piirang on ületatud
+105 RLG0 piirang on ületatud
+106 RLG1 piirang on ületatud
+107 RLG2 piirang on ületatud
+108 RLG3 piirang on ületatud
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/et/set20
--- a/head/contrib/tcsh/nls/et/set20	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/et/set20	Fri Mar 02 16:54:40 2012 +0200
@@ -1,41 +1,41 @@
-$ $tcsh: set20,v 1.2 2006/03/02 18:46:45 christos Exp $
+$ $tcsh: set20,v 1.3 2011/02/04 18:19:33 christos Exp $
 $ tc.bind.c
 $set 20 
 1 Vigane klahvi nimi `%S'\n
 2 Halb klahv: %S\n
-3 Halb käsk: %S\n
+3 Halb käsk: %S\n
 4 Halb klahvi spetsifikatsioon %S\n
-5 Null sõne spetsifikatsioonis\n
+5 Null sõne spetsifikatsioonis\n
 6 Standardsed klahviseosed\n
 7 Alternatiivsed klahviseosed\n
-8 Mitme-sümbolised seosed\n
+8 Mitme-sümbolised seosed\n
 9 Seosed nooleklahvidele\n
 10 %-15s->  on defineerimata\n
 11 BUG!!! %s pole seotud.\n
-12 Kasuta: bindkey [võtmed] [--] [KLAHV [KÄSK]]\n
-13     -a   esita või seo KLAHVI alternatiivne tabel\n
-14     -b   käsitle KLAHVI kui C-, M-, F- või X- klahvi nime\n
-15     -s   käsitle COMMAND kui literaalset väljundsõne\n
-16     -c   käsitle COMMAND kui sisemist või välist käsku\n
-17     -v   seo kõik klahvid vi seostega\n
-18     -e   seo kõik klahvid emacsi seostega\n
-19     -d   seo kõik klahvid vaikimisi toimeti seostega\n
-20     -l   esita toimeti käsud koos kirjeldustega\n
+12 Kasuta: bindkey [võtmed] [--] [KLAHV [KÄSK]]\n
+13     -a   esita või seo KLAHVI alternatiivne tabel\n
+14     -b   käsitle KLAHVI kui C-, M-, F- või X- klahvi nime\n
+15     -s   käsitle COMMAND kui literaalset väljundsõne\n
+16     -c   käsitle COMMAND kui sisemist või välist käsku\n
+17     -v   seo kõik klahvid vi seostega\n
+18     -e   seo kõik klahvid emacsi seostega\n
+19     -d   seo kõik klahvid vaikimisi toimeti seostega\n
+20     -l   esita toimeti käsud koos kirjeldustega\n
 21     -r   kustuta KLAHVILT seos\n
-22     -k   kasuta KLAHVI kui noole-klahvi sümbolnime\n
-23     --   katkesta võtmete töötlemine\n
-24     -u   (või suvaline vigane võti) see teade\n
-25 Ilma KLAHVI või KÄSUTA trükib kõik seosed\n
-26 Ilma KÄSUTA trükib seosed KLAHVILE.\n
-27 Halb klahvi spetsifikatsioon -- null sõne\n
-28 Halb klahvi spetsifikatsioon -- tühi sõne\n
+22     -k   kasuta KLAHVI kui noole-klahvi sümbolnime\n
+23     --   katkesta võtmete töötlemine\n
+24     -u   (või suvaline vigane võti) see teade\n
+25 Ilma KLAHVI või KÄSUTA trükib kõik seosed\n
+26 Ilma KÄSUTA trükib seosed KLAHVILE.\n
+27 Halb klahvi spetsifikatsioon -- null sõne\n
+28 Halb klahvi spetsifikatsioon -- tühi sõne\n
 29 Halb funktsioon-klahvi spetsifikatsioon.  Null klahv pole lubatud\n
-30 Halb klahvi spetsifikatsioon -- vigane kuueteistkümnend number\n
+30 Halb klahvi spetsifikatsioon -- vigane kuueteistkümnend number\n
 31 Halb klahvi spetsifikatsioon -- vigane kaheksand number\n
-32 Halb klahvi spetsifikatsioon -- vigane kümnend number\n
+32 Halb klahvi spetsifikatsioon -- vigane kümnend number\n
 33 Halb funktsioon-klahvi spetsifikatsioon.\n
 34 Null klahv pole lubatud\n
 35 halb klahvi spetsifikatsioon -- tundmatu nimi "%S"\n
-36 kasuta: bind [KLAHV | KÄSK KLAHV | "emacs" | "vi" | "-a"]\n
+36 kasuta: bind [KLAHV | KÄSK KLAHV | "emacs" | "vi" | "-a"]\n
 37 Vigane funktsioon
 38  %s\t\ton defineerimata\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/et/set21
--- a/head/contrib/tcsh/nls/et/set21	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/et/set21	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,5 @@
-$ $tcsh: set21,v 1.2 2006/03/02 18:46:45 christos Exp $
+$ $tcsh: set21,v 1.3 2011/02/04 18:19:33 christos Exp $
 $ tc.disc.c
 $set 21 
-1 Lokaalseid sümboleid ei õnnestu lugeda.\n
-2 Lokaalseid sümboleid ei õnnestu seada.\n
+1 Lokaalseid sümboleid ei õnnestu lugeda.\n
+2 Lokaalseid sümboleid ei õnnestu seada.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/et/set22
--- a/head/contrib/tcsh/nls/et/set22	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/et/set22	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set22,v 1.2 2006/03/02 18:46:45 christos Exp $
+$ $tcsh: set22,v 1.3 2011/02/04 18:19:33 christos Exp $
 $ tc.func.c
 $set 22 
 1 %S: \t on tegelikult 
@@ -7,11 +7,11 @@
 4 Vigane alias 'cwdcmd' eemaldatud.\n
 5 Vigane alias 'beepcmd' eemaldatud.\n
 6 Vigane alias 'periodic' eemaldatud.\n
-7 töötlen käsurida\n
-8 Kas te tÕepoolest tahate kustutada kõik failid? [e/j] 
+7 töötlen käsurida\n
+8 Kas te tÕepoolest tahate kustutada kõik failid? [e/j] 
 9 katkestan failide kustutamise!\n
-10 käsurida on nüüd:\n
-11 töötlen käsurida\n
-12 ühes loenditest\n
-13 käsurida on nüüd:\n
+10 käsurida on nüüd:\n
+11 töötlen käsurida\n
+12 ühes loenditest\n
+13 käsurida on nüüd:\n
 14 jJ
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/et/set23
--- a/head/contrib/tcsh/nls/et/set23	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/et/set23	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set23,v 1.2 2006/03/02 18:46:45 christos Exp $
+$ $tcsh: set23,v 1.3 2011/02/04 18:19:33 christos Exp $
 $ tc.os.c
 $set 23 
 1 Vigane cpu/saidi nimi
@@ -8,10 +8,10 @@
 5 %d: Saiti pole\n
 6 setlocal: %s: %s\n
 7 Saiti pole
-8 Te olete lõksus universumis, mida te pole loonud
-9 Getwarp ebaõnnestus
+8 Te olete lõksus universumis, mida te pole loonud
+9 Getwarp ebaõnnestus
 10 Vigane warp
-11 Setwarp ebaõnnestus
+11 Setwarp ebaõnnestus
 12 Vigane universum
 13 Tundmatu viga: %d
 14 sysname:  %s\n
@@ -28,7 +28,7 @@
 25 getwd: Kataloogi "%s" atribuute ei saa lugeda (%s)
 26 getwd: Kataloogi "%s" ei saa avada (%s)
 27 getwd: Kataloogis ".." pole kataloogi "." (%s)
-28 Vigane süsteemi tüüp
-29 Süsteemi tüüp ei ole määratud
+28 Vigane süsteemi tüüp
+29 Süsteemi tüüp ei ole määratud
 30 Liiga palju argumente
 31 Vigane argument
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/et/set24
--- a/head/contrib/tcsh/nls/et/set24	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/et/set24	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set24,v 1.2 2006/03/02 18:46:45 christos Exp $
+$ $tcsh: set24,v 1.3 2011/02/04 18:19:33 christos Exp $
 $ tc.sched.c
 $set 24 
-1 Häkk!
+1 Häkk!
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/et/set25
--- a/head/contrib/tcsh/nls/et/set25	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/et/set25	Fri Mar 02 16:54:40 2012 +0200
@@ -1,6 +1,6 @@
-$ $tcsh: set25,v 1.2 2006/03/02 18:46:45 christos Exp $
+$ $tcsh: set25,v 1.3 2011/02/04 18:19:33 christos Exp $
 $ tc.sig.c
 $set 25 
 1 our wait %d\n
 2 viga: bsd_signal(%d) pole signaal\n
-3 viga: bsd_signal(%d) - sigaction ebaõnnestus, errno = %d\n
+3 viga: bsd_signal(%d) - sigaction ebaõnnestus, errno = %d\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/et/set26
--- a/head/contrib/tcsh/nls/et/set26	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/et/set26	Fri Mar 02 16:54:40 2012 +0200
@@ -1,15 +1,15 @@
-$ $tcsh: set26,v 1.2 2006/03/02 18:46:45 christos Exp $
+$ $tcsh: set26,v 1.3 2011/02/04 18:19:33 christos Exp $
 $ tc.who.c
 $set 26 
-1 Ei saa lugeda %s atribuute.  Anna käsk "unset watch".\n
-2 %s ei saa avada.  Anna käsk "unset watch".\n
+1 Ei saa lugeda %s atribuute.  Anna käsk "unset watch".\n
+2 %s ei saa avada.  Anna käsk "unset watch".\n
 3 BUG! viimane element ei ole viimasena registreeritud!\n
 4 tagurpidi: 
 5 BUG! esimene element ei ole esimesena registreeritud!\n
 6 uus: %s/%s\n
 7 %n %a terminalil %l masinast %m.
 8 %n %a terminalil %l.
-9 töötab
-10 lõpetas töö
+9 töötab
+10 lõpetas töö
 11 asendas %s terminalil
 12 kohalik
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/et/set27
--- a/head/contrib/tcsh/nls/et/set27	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/et/set27	Fri Mar 02 16:54:40 2012 +0200
@@ -1,8 +1,8 @@
-$ $tcsh: set27,v 1.2 2006/03/02 18:46:45 christos Exp $
+$ $tcsh: set27,v 1.3 2011/02/04 18:19:33 christos Exp $
 $ tw.comp.c
 $set 27 
-1 käsk
+1 käsk
 2 eraldaja
 3 muster
 4 vahemik
-5 täiendamine
+5 täiendamine
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/et/set3
--- a/head/contrib/tcsh/nls/et/set3	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/et/set3	Fri Mar 02 16:54:40 2012 +0200
@@ -1,120 +1,120 @@
-$ $tcsh: set3,v 1.3 2006/03/02 18:46:45 christos Exp $
+$ $tcsh: set3,v 1.4 2011/02/04 18:19:33 christos Exp $
 $ Editor function descriptions
 $set 3 
-1 Liigu sümbol tagasi
-2 Kustuta sümbol kursori tagant
-3 Lõika jooksva sõna algusest kursorini - salvesta lõikepuhvris
-4 Lõika rea algusest kursorini - salvesta lõikepuhvris
-5 Liigu jooksva sõna algusse
+1 Liigu sümbol tagasi
+2 Kustuta sümbol kursori tagant
+3 Lõika jooksva sõna algusest kursorini - salvesta lõikepuhvris
+4 Lõika rea algusest kursorini - salvesta lõikepuhvris
+5 Liigu jooksva sõna algusse
 6 Liigu rea algusse
-7 Tähed kursorist kuni sõnalõpuni suurteks
-8 Vi muuda kursori aluse sümboli suurust ja liigu sümbol edasi
-9 Vi muuda realõpuni
-10 Puhasta ekraan jättes jooksva rea ülemiseks
-11 Täienda jooksev sõna
-12 Vali täiendusi liikudes nimekirjas edasi
-13 Vali täiendusi liikudes nimekirjas tagasi
-14 Täienda jooksev sõna, ignoreeri programmeeritud täiendusi
-15 Kopeeri jooksev sõna kursorini
-16 Kopeeri ala märgist kursorini lõikepuhvrisse
-17 Avalda eelneva sõnani, millele see on prefiks
-18 Kustuta sümbol kursori alt
-19 Kustuta sümbol kursori alt või teata tühja rea korral faililõpust
-20 Kustuta sümbol kursori alt või rea lõpu korral näita täiendusi
-21 Kustuta sümbol kursori alt, näita täiendusi või teata faililõpust
-22 Lõika kursorist jooksva sõna lõpuni - salvesta lõikepuhvris
+7 Tähed kursorist kuni sõnalõpuni suurteks
+8 Vi muuda kursori aluse sümboli suurust ja liigu sümbol edasi
+9 Vi muuda realõpuni
+10 Puhasta ekraan jättes jooksva rea ülemiseks
+11 Täienda jooksev sõna
+12 Vali täiendusi liikudes nimekirjas edasi
+13 Vali täiendusi liikudes nimekirjas tagasi
+14 Täienda jooksev sõna, ignoreeri programmeeritud täiendusi
+15 Kopeeri jooksev sõna kursorini
+16 Kopeeri ala märgist kursorini lõikepuhvrisse
+17 Avalda eelneva sõnani, millele see on prefiks
+18 Kustuta sümbol kursori alt
+19 Kustuta sümbol kursori alt või teata tühja rea korral faililõpust
+20 Kustuta sümbol kursori alt või rea lõpu korral näita täiendusi
+21 Kustuta sümbol kursori alt, näita täiendusi või teata faililõpust
+22 Lõika kursorist jooksva sõna lõpuni - salvesta lõikepuhvris
 23 Kui alustatud, lisab argumendile, muidu lisab numbri
 24 Number, mis alustab argumenti
-25 Liigu järgmisele ajaloo reale
-26 Sümbolid väiketähtedeks kursorist jooksva sõna lõpuni
-27 Näita faililõppu
-28 Kursor realõppu
-29 Vaheta kursor ja märk
-30 Avalda faili nimes metasümbolid
-31 Avalda ajaloo käsud
-32 Avalda real ajaloo käsud
+25 Liigu järgmisele ajaloo reale
+26 Sümbolid väiketähtedeks kursorist jooksva sõna lõpuni
+27 Näita faililõppu
+28 Kursor realõppu
+29 Vaheta kursor ja märk
+30 Avalda faili nimes metasümbolid
+31 Avalda ajaloo käsud
+32 Avalda real ajaloo käsud
 33 Avalda muutujad
-34 Liigu sümbol edasi
-35 Liigu edasi jooksva sõna lõppu
-36 Vaheta kursori ees kaks sümbolit
+34 Liigu sümbol edasi
+35 Liigu edasi jooksva sõna lõppu
+36 Vaheta kursori ees kaks sümbolit
 37 Otsi ajaloos tagasi jooksva rea algusega rida
 38 Otsi ajaloos edasi jooksva rea algusega rida
-39 Lisa eelmise käsu viimane element
+39 Lisa eelmise käsu viimane element
 40 Inkrementaalne edaspidi otsing
 41 Inkrementaalne tagurpidi otsing
 42 Puhasta rida
-43 Lõika realõpuni ja salvesta lõikepuhvris
-44 Lõika ala märgist kursorini ja salvesta lõikepuhvris
-45 Lõika kogu rida ja salvesta lõikepuhvris
-46 Näita täiendamise valikud
-47 Näita täiendamise valikuid ignoreerides programmeeritud täiendusi
-48 Näita faili nimes metasümbolite leide
-49 Näita täiendamise valikuid või teavita tühja rea korral faililõpust
-50 Näita masina koormust ja jooksva protsessi olekut
-51 Avalda ajaloo käsud ja lisa tühik
-52 Täida käsklus
+43 Lõika realõpuni ja salvesta lõikepuhvris
+44 Lõika ala märgist kursorini ja salvesta lõikepuhvris
+45 Lõika kogu rida ja salvesta lõikepuhvris
+46 Näita täiendamise valikud
+47 Näita täiendamise valikuid ignoreerides programmeeritud täiendusi
+48 Näita faili nimes metasümbolite leide
+49 Näita täiendamise valikuid või teavita tühja rea korral faililõpust
+50 Näita masina koormust ja jooksva protsessi olekut
+51 Avalda ajaloo käsud ja lisa tühik
+52 Täida käsklus
 53 Avalda failiteed, eemaldades algusest . ja ..
-54 Avalda käsk failiteeks või aliaseks
-55 Lülita lisamis- või ülekirjutamismood
-56 Lisa järgmisele kirjutatavale sümbolile kaheksas bitt
-57 Lisa järgmine kirjutatav sümbol reale kvoodituna
-58 Näita kõik uuesti
-59 Taaskäivita peatatud toimeti
-60 Esita jooksva käsu abiinfo
-61 See sümbol lisatakse reale
-62 See sümbol on sümboljärjendis esimene
-63 Sea märk
-64 Paranda jooksva sõna õigekirja
-65 Paranda terve rea õigekirja
-66 Saada sümbol terminalile vahendusmoodis
-67 Lülita ajaloo literaalne või leksiline mood
-68 Vaheta kursori alune ja kursorist vasakul asuvad sümbolid
-69 Vaheta kursori ees kaks sümbolit
-70 Tty viivitusega peatamine sümbol
-71 Tty tühjenda väljund sümbol
-72 Tty katkesta sümbol
-73 Tty välju sümbol
-74 Tty peata sümbol
-75 Tty luba väljund sümbol
-76 Tty keela väljund sümbol
-77 Tähistab sidumata sümbolit
+54 Avalda käsk failiteeks või aliaseks
+55 Lülita lisamis- või ülekirjutamismood
+56 Lisa järgmisele kirjutatavale sümbolile kaheksas bitt
+57 Lisa järgmine kirjutatav sümbol reale kvoodituna
+58 Näita kõik uuesti
+59 Taaskäivita peatatud toimeti
+60 Esita jooksva käsu abiinfo
+61 See sümbol lisatakse reale
+62 See sümbol on sümboljärjendis esimene
+63 Sea märk
+64 Paranda jooksva sõna õigekirja
+65 Paranda terve rea õigekirja
+66 Saada sümbol terminalile vahendusmoodis
+67 Lülita ajaloo literaalne või leksiline mood
+68 Vaheta kursori alune ja kursorist vasakul asuvad sümbolid
+69 Vaheta kursori ees kaks sümbolit
+70 Tty viivitusega peatamine sümbol
+71 Tty tühjenda väljund sümbol
+72 Tty katkesta sümbol
+73 Tty välju sümbol
+74 Tty peata sümbol
+75 Tty luba väljund sümbol
+76 Tty keela väljund sümbol
+77 Tähistab sidumata sümbolit
 78 Emacsi universaalne argument (argument korda 4)
 79 Liigu eelmisele ajaloo reale
-80 Sümbolid suurtähtedeks kursorist jooksva sõna lõpuni
-81 Vi liigu järgmise sõna algusse
+80 Sümbolid suurtähtedeks kursorist jooksva sõna lõpuni
+81 Vi liigu järgmise sõna algusse
 82 Vi sisene peale kursorit lisamismoodi
-83 Vi sisene rea lõpus lisamismoodi
-84 Vi muuda kursori aluse sümboli suurust ja liigu ühe sümboli võrra edasi
-85 Vi muuda prefiks käsklust
-86 Vi muuda realõpuni
-87 Sisene vi käsumoodi (kasuta alternatiivseid klahvi seoseid)
-88 Vi käsu mood täienda jooksev sõna
-89 Vi liigu eelmisele sümbolile (backspace)
-90 Vi kustuta prefiks käsklus
-91 Vi liigu jooksva tühikuga eraldatud sõna lõppu
-92 Vi liigu jooksva sõna lõppu
-93 Vi liigu tagasi määratud sümbolini
-94 Vi liigu edasi määratud sümbolini
-95 Vi liigu tagasi määratud sümbolile
-96 Vi liigu edasi määratud sümbolile
+83 Vi sisene rea lõpus lisamismoodi
+84 Vi muuda kursori aluse sümboli suurust ja liigu ühe sümboli võrra edasi
+85 Vi muuda prefiks käsklust
+86 Vi muuda realõpuni
+87 Sisene vi käsumoodi (kasuta alternatiivseid klahvi seoseid)
+88 Vi käsu mood täienda jooksev sõna
+89 Vi liigu eelmisele sümbolile (backspace)
+90 Vi kustuta prefiks käsklus
+91 Vi liigu jooksva tühikuga eraldatud sõna lõppu
+92 Vi liigu jooksva sõna lõppu
+93 Vi liigu tagasi määratud sümbolini
+94 Vi liigu edasi määratud sümbolini
+95 Vi liigu tagasi määratud sümbolile
+96 Vi liigu edasi määratud sümbolile
 97 Sisene vi lisamismoodi
 98 Sisene rea alguses vi lisamismoodi
-99 Vi korda antud sümboli otsimist samas suunas
-100 Vi korda antud sümboli otsimist vastupidises suunas
+99 Vi korda antud sümboli otsimist samas suunas
+100 Vi korda antud sümboli otsimist vastupidises suunas
 101 Vi korda antud otsimist samas suunas
 102 Vi korda antud otsimist vastupidises suunas
-103 Vi asenda kursori alt sümbol järgmisena kirjutatava sümboliga
-104 Vi asendusre¸iim 
+103 Vi asenda kursori alt sümbol järgmisena kirjutatava sümboliga
+104 Vi asendusre¸iim 
 105 Vi otsi ajaloost tagurpidi
 106 Vi otsi ajaloost edaspidi
-107 Vi asenda kursori alune sümbol ja mine sisesamisre¸iimi
+107 Vi asenda kursori alune sümbol ja mine sisesamisre¸iimi
 108 Vi asenda kogu rida
-109 Vi mine eelmise sõna juurde
-110 Vi mine järgmise sõna juurde
+109 Vi mine eelmise sõna juurde
+110 Vi mine järgmise sõna juurde
 111 Vi taasta viimane muutus
 112 Vi mine rea algusse
-113 Käivita jooksval sõnal käsk which
-114 Kleebi lõikepuhver alates kursori positsioonist
+113 Käivita jooksval sõnal käsk which
+114 Kleebi lõikepuhver alates kursori positsioonist
 115 Replace just-yanked text with yank from earlier kill
 116 (WIN32 only) Copy cut buffer to system clipboard
 117 (WIN32 only) Paste clipboard buffer at cursor position
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/et/set30
--- a/head/contrib/tcsh/nls/et/set30	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/et/set30	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set30,v 1.2 2006/03/02 18:46:45 christos Exp $
+$ $tcsh: set30,v 1.3 2011/02/04 18:19:33 christos Exp $
 $ tw.parse.c
 $set 30 
 1 starting_a_command %d\n
@@ -7,7 +7,7 @@
 4 %s: Internal match error.\n
 5 elementi
 6 veergu
-7 Leidsin %d %s, näitan neid? [e/j] 
+7 Leidsin %d %s, näitan neid? [e/j] 
 8 looking = %d\n
 9 \n%s sisemine viga: Ma ei tea, mida ma otsin!\n
 10 pole kataloog
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/et/set4
--- a/head/contrib/tcsh/nls/et/set4	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/et/set4	Fri Mar 02 16:54:40 2012 +0200
@@ -1,45 +1,45 @@
-$ $tcsh: set4,v 1.2 2006/03/02 18:46:45 christos Exp $
+$ $tcsh: set4,v 1.3 2011/02/04 18:19:33 christos Exp $
 $ Termcap strings
 $set 4
-1 lisa uus tühi rida
+1 lisa uus tühi rida
 2 kuuldav kell
-3 puhasta põhjani
-4 puhasta rea lõpuni
+3 puhasta põhjani
+4 puhasta rea lõpuni
 5 kursori horisontaal positsioon
 6 ekraani puhastamine
-7 sümboli kustutamine
+7 sümboli kustutamine
 8 rea kustutamine
 9 alusta kustutamis mood
-10 lõpeta kustutamis mood
-11 lõpeta vahelekirjutamise mood
+10 lõpeta kustutamis mood
+11 lõpeta vahelekirjutamise mood
 12 kursor olekurealt
 13 kursor koju
-14 lisa sümbol
+14 lisa sümbol
 15 alusta vahelekirjutamise mood
-16 lisa täide
+16 lisa täide
 17 saadab kursori alla
 18 saadab kursori vasakule
 19 saadab kursori paremale
-20 saadab kursori üles
+20 saadab kursori üles
 21 alusta rasvast
-22 atribuutide lõpp
-23 mitte-purustav tühik
-24 lõpeta rõhutatud
-25 alusta rõhutatud
+22 atribuutide lõpp
+23 mitte-purustav tühik
+24 lõpeta rõhutatud
+25 alusta rõhutatud
 26 kursor olekureale
-27 kursor ühe võrra üles
+27 kursor ühe võrra üles
 28 alusta allajoonimist
-29 lõpeta allajoonimine
-30 nähtav kell
-31 kustuta mitu sümbolit
+29 lõpeta allajoonimine
+30 nähtav kell
+31 kustuta mitu sümbolit
 32 kursor korduvalt alla
-33 lisa mitu sümbolit
+33 lisa mitu sümbolit
 34 kursor korduvalt vasakule
 35 kursor korduvalt paremale
-36 kursor korduvalt üles
-37 Omab automaatseid ääri
-38 Saab kasutada füüsilist tabulaatorit
+36 kursor korduvalt üles
+37 Omab automaatseid ääri
+38 Saab kasutada füüsilist tabulaatorit
 39 Ridade arv
 40 Veergude arv
 41 Omab meta klahvi
-42 Parem äär ignoreerib uut rida
+42 Parem äär ignoreerib uut rida
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/et/set5
--- a/head/contrib/tcsh/nls/et/set5	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/et/set5	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set5,v 1.2 2006/03/02 18:46:45 christos Exp $
+$ $tcsh: set5,v 1.3 2011/02/04 18:19:33 christos Exp $
 $ ed.chared.c
 $set 5
-1 Tööjärjekorra koormuse info puudub\n
+1 Tööjärjekorra koormuse info puudub\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/et/set6
--- a/head/contrib/tcsh/nls/et/set6	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/et/set6	Fri Mar 02 16:54:40 2012 +0200
@@ -1,11 +1,11 @@
-$ $tcsh: set6,v 1.2 2006/03/02 18:46:45 christos Exp $
+$ $tcsh: set6,v 1.3 2011/02/04 18:19:33 christos Exp $
 $ ed.inputl.c
 $set 6
-1 VIGA: vigane käsk klahvilt 0%o\r\n
+1 VIGA: vigane käsk klahvilt 0%o\r\n
 2 jah\n
 3 paranda\n
 4 katkesta\n
 5 ei\n
-6 Pole sellist käsku\n
-7 Arusaamatu käsk\n
+6 Pole sellist käsku\n
+7 Arusaamatu käsk\n
 8 *** toimeti fataalne VIGA ***\r\n\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/et/set7
--- a/head/contrib/tcsh/nls/et/set7	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/et/set7	Fri Mar 02 16:54:40 2012 +0200
@@ -1,30 +1,30 @@
-$ $tcsh: set7,v 1.2 2006/03/02 18:46:45 christos Exp $
+$ $tcsh: set7,v 1.3 2011/02/04 18:19:33 christos Exp $
 $ ed.screen.c
 $set 7
 1 \n\tTcsh arvab, et teie terminal omab\n
-2 \tjärgnevaid omadusi:\n\n
+2 \tjärgnevaid omadusi:\n\n
 3 \tTal on %d veergu ja %d rida\n
 4 \tTa %s meta klahvi\n
 5 omab
 6 ei oma
 7 \tTal on%s tabulaatori omadus\n
 8  puudu
-9 \tTa %s automaatseid ääri\n
+9 \tTa %s automaatseid ääri\n
 10 omab
 11 ei oma
-12 \tTa %s maagilisi ääri\n
-13 (tühi)
+12 \tTa %s maagilisi ääri\n
+13 (tühi)
 14 jah
 15 ei
 16 VIGA: ei saa kustutada\r\n
-17 DeleteChars: num on mõttetu: %d\r\n
+17 DeleteChars: num on mõttetu: %d\r\n
 18 VIGA: cannot insert\r\n
-19 StartInsert: num on mõttetu: %d\r\n
+19 StartInsert: num on mõttetu: %d\r\n
 20 %s: Ei saa avada /etc/termcap.\n
-21 %s: Terminali tüübil "%s" puudub kirje\n
+21 %s: Terminali tüübil "%s" puudub kirje\n
 22 %s: kasutan rumala terminali seadeid.\n
-23 %s: HOIATUS: Teie terminal ei saa liikuda üles.\n
-24 Pikkade ridade toimetamine võib olla kummaline.\n
+23 %s: HOIATUS: Teie terminal ei saa liikuda üles.\n
+24 Pikkade ridade toimetamine võib olla kummaline.\n
 25 puudub puhasta EOL omadus.\n
-26 puudub kustuta sümbol omadus.\n
-27 puudub lisa sümbol omadus.\n
+26 puudub kustuta sümbol omadus.\n
+27 puudub lisa sümbol omadus.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/et/set8
--- a/head/contrib/tcsh/nls/et/set8	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/et/set8	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,5 @@
-$ $tcsh: set8,v 1.2 2006/03/02 18:46:45 christos Exp $
+$ $tcsh: set8,v 1.3 2011/02/04 18:19:34 christos Exp $
 $ ed.term.c
 $set 8
-1 Tundmatu võti
+1 Tundmatu võti
 2 Vigane argument
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/et/set9
--- a/head/contrib/tcsh/nls/et/set9	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/et/set9	Fri Mar 02 16:54:40 2012 +0200
@@ -1,12 +1,12 @@
-$ $tcsh: set9,v 1.2 2006/03/02 18:46:45 christos Exp $
+$ $tcsh: set9,v 1.3 2011/02/04 18:19:34 christos Exp $
 $ ed.xmap.c
 $set 9
 1 AddXkey: Null pikkusega laiend-klahv ei ole lubatud.\n
-2 AddXkey: käsuni viiv järjend pole lubatud\n
+2 AddXkey: käsuni viiv järjend pole lubatud\n
 3 DeleteXkey: Null pikkusega laiend-klahv ei ole lubatud.\n
 4 Sidumata laiendatud klahv "%S"\n
-5 Mõned laiendatud klahvid on sisemise trükipuhvri jaoks liiga pikad
+5 Mõned laiendatud klahvid on sisemise trükipuhvri jaoks liiga pikad
 6 Enumerate: BUG!! Null viit anti\n!
 7 sisendit pole
-8 Midagi peab järgnema: %c\n
-9 kaheksand-konstant ei mahu sümbolisse.\n
+8 Midagi peab järgnema: %c\n
+9 kaheksand-konstant ei mahu sümbolisse.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/finnish/charset
--- a/head/contrib/tcsh/nls/finnish/charset	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/finnish/charset	Fri Mar 02 16:54:40 2012 +0200
@@ -1,3 +1,3 @@
-$ codeset=ISO-8859-1
+$ codeset=UTF-8
 $set 255
-1 ISO-8859-1
+1 UTF-8
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/finnish/set1
--- a/head/contrib/tcsh/nls/finnish/set1	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/finnish/set1	Fri Mar 02 16:54:40 2012 +0200
@@ -1,140 +1,140 @@
-$ $tcsh: set1,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set1,v 1.4 2011/02/04 18:19:34 christos Exp $
 $ Error messages
 $set 1 
 1 Kielioppivirhe
 2 %s ei ole sallittu
-3 Liian pitkä sana
-4 $< rivi liian pitkä
+3 Liian pitkä sana
+4 $< rivi liian pitkä
 5 Puuttuva tiedosto $0
 6 Vajavainen [] muunnos
-7 $ -laajennuksen on päätyttävä ennen ']'-merkkiä
+7 $ -laajennuksen on päätyttävä ennen ']'-merkkiä
 8 Virheellinen : -muunnos $ (%c)
 9 Indeksivirhe
 10 Virheellinen numero
-11 Liian vähän sanoja
+11 Liian vähän sanoja
 12 Puuttuva tiedoston nimi
-13 Sisäinen laajennusvirhe (glob)
-14 Käskyä ei löydy
-15 Liian vähän argumentteja
+13 Sisäinen laajennusvirhe (glob)
+14 Käskyä ei löydy
+15 Liian vähän argumentteja
 16 Liian monta argumenttia
 17 Vaarallinen alias
-18 Tyhjä ehto (if)
+18 Tyhjä ehto (if)
 19 Soveltumaton seuraus (then)
-20 Sanat eivät ole suluissa
-21 %s ei löydy
+20 Sanat eivät ole suluissa
+21 %s ei löydy
 22 Soveltumaton maski
 23 Rajoite tuntematon
 24 Liian suuri argumentti
 25 Soveltumaton tai tuntematon muunnoskerroin
-26 Määrittelemätön muuttuja
+26 Määrittelemätön muuttuja
 27 Hakemistopino on matalampi
 28 Virheellinen signaalin numero
 29 Tuntematon signaali; kill -l tulostaa signaalit
 30 Muutujan nimi on aloitettava kirjaimella
-31 Liian pitkä muuttuja nimi
+31 Liian pitkä muuttuja nimi
 32 Muuttujan nimi on koostuttava kirjaimista ja numeroista
-33 Tässä komentotulkissa ei ole töiden hallintaa
+33 Tässä komentotulkissa ei ole töiden hallintaa
 34 Lauseke virheellinen
 35 Kotihakemisto puuttuu
 36 Siirtyminen kotihakemistoon ei onnistu
-37 Tyhjä käsky
+37 Tyhjä käsky
 38 Sijoituksesta puuttuu lauseke
 39 Tuntematon operaattori
 40 Tulkinnanvarainen
 41 %s: Tiedosto ei ole uusi
-42 Parametrin -c argumentti päätty takakenoviivaan (\\)
+42 Parametrin -c argumentti päätty takakenoviivaan (\\)
 43 Keskeytetty
 44 Indeksi viittaa rajojen ulkopuollelle
 45 Rivin ylivuoto
-46 Olematon työ
-47 Ei onnistu päätteeltä
+46 Olematon työ
+47 Ei onnistu päätteeltä
 48 Silmukan (while/foreach) ulkopuolella
-49 Lisää prosesseja ei voida luoda
+49 Lisää prosesseja ei voida luoda
 50 Ei vastaavuuksia (match)
 51 Puuttuva %c
-52 Ylimääräinen/pariton %c
+52 Ylimääräinen/pariton %c
 53 Muisti loppu
 54 Putkea ei voida luoda
 55 %s: %s
 56 %s
-57 Käyttö: jobs [ -l ]
-58 Argumenttien on oltava töiden tai prosessien tunnisteita
-59 Ei tämänhetkistä työtä
-60 Ei edellistä työtä
-61 Mikään työ ei vastaa mallia
-62 Sisäkkäinen prosessin luonti (fork) > %d; mahdollisesti `...` silmukka
-63 Alemman tason komentotulkeissa ei ole töidenhallintaa
-64 Synkronointivirhe: Prosessia %d ei löydy
-65 %sTilapäisesti keskeytettyjä töitä
-66 %sPysähtyneenä olevia töitä
+57 Käyttö: jobs [ -l ]
+58 Argumenttien on oltava töiden tai prosessien tunnisteita
+59 Ei tämänhetkistä työtä
+60 Ei edellistä työtä
+61 Mikään työ ei vastaa mallia
+62 Sisäkkäinen prosessin luonti (fork) > %d; mahdollisesti `...` silmukka
+63 Alemman tason komentotulkeissa ei ole töidenhallintaa
+64 Synkronointivirhe: Prosessia %d ei löydy
+65 %sTilapäisesti keskeytettyjä töitä
+66 %sPysähtyneenä olevia töitä
 67 Toinen hakemisto puuttuu
-68 Hakemistopino on tyhjä
+68 Hakemistopino on tyhjä
 69 Virheellinen hakemisto
-70 Käyttö: %s [-%s]%s
+70 Käyttö: %s [-%s]%s
 71 Lipulle -h ei ole argumenttia
-72 Tämä ei ole ensimmäisen tason komentotulkki (login shell)
+72 Tämä ei ole ensimmäisen tason komentotulkki (login shell)
 73 Jako 0:lla
-74 Jakojäännös 0:lla
+74 Jakojäännös 0:lla
 75 Virheellinen muunnoskerroin; tarkoititko "%s"?
-76 Ensimmäisen tason komentotulkkia ei voi keskeyttää (vielä)
-77 Tuntematon käyttäjä: %s
+76 Ensimmäisen tason komentotulkkia ei voi keskeyttää (vielä)
+77 Tuntematon käyttäjä: %s
 78 Muuttujaa $home ei ole asetettu
-79 Käyttö: history [-%s] [# tapahtumien/käskyjen lukumäärä]
-80 $, ! tai < ei ole sallittu $# eikä $? yhteydessä
-81 Muuttujan nimi sisältää rivin vaihdon
-82 * ei ole sallittu $# eikä $? yhteydessä
+79 Käyttö: history [-%s] [# tapahtumien/käskyjen lukumäärä]
+80 $, ! tai < ei ole sallittu $# eikä $? yhteydessä
+81 Muuttujan nimi sisältää rivin vaihdon
+82 * ei ole sallittu $# eikä $? yhteydessä
 83 $?<numero> tai $#<numero> ei ole sallittu
 84 Soveltumaton muuttujan nimi
-85 Rivin vaihto muutujan indeksissä
+85 Rivin vaihto muutujan indeksissä
 86 Laajennuspuskurin ylivuoto
 87 Muuttujassa kielioppivirhe
 88 Virheellinen ! -muoto
-89 Edellistä korvaavaa merkkijonoa ei ole
+89 Edellistä korvaavaa merkkijonoa ei ole
 90 Virheellinen korvaava merkkijono
-91 Edellistä vasemmanpuolista merkkijonoa ei ole
-92 Oikeanpuolinen merkkijono on liian pitkä
+91 Edellistä vasemmanpuolista merkkijonoa ei ole
+92 Oikeanpuolinen merkkijono on liian pitkä
 93 Virheellinen ! -muunnos: %c
-94 Muunnos epäonnistui
+94 Muunnos epäonnistui
 95 Korvauspuskurin ylivuoto
 96 Virheellinen ! argumenttivalitsin
-97 Edellistä hakua ei ole
-98 %s: Tapahtumaa/käskyä ei löydy
+97 Edellistä hakua ei ole
+98 %s: Tapahtumaa/käskyä ei löydy
 99 Liian paljon loppusulkuja ')'
 100 Liian paljon alkusulkuja '('
 101 Virheellisesti sijoitettu alkusulku '('
 102 Uudelleen ohjauksesta puuttuu nimi
 103 Tulkinnanvarainen tulostuksen ohjaus
-104 Ohjaus << ei onnistu sulkujen '()' sisällä
-105 Tulkinnanvarainen syötteen ohjaus
+104 Ohjaus << ei onnistu sulkujen '()' sisällä
+105 Tulkinnanvarainen syötteen ohjaus
 106 Virheelisesti sijoitetut sulut '()'
-107 Silmukka alias-määrittelyissä
+107 Silmukka alias-määrittelyissä
 108 Muuttujaa $watch ei ole asetettu
 109 Jonossa ei ole tapahtumia
-110 Käyttö: sched -<tapahtumien lukumäärä>.\nKäyttö: sched [+]tt:mm <käsky>
+110 Käyttö: sched -<tapahtumien lukumäärä>.\nKäyttö: sched [+]tt:mm <käsky>
 111 Jonotettuja tapahtumia ei ole niin monta
-112 Suoritettava käsky puuttuu
+112 Suoritettava käsky puuttuu
 113 Virheellinen tapahtuma-aika
-114 Suhteellinen ajan määre ei sovellu käytettäväksi am/pm yhteydessä
-115 Päätetyypin kuvaukselle (termcap) ei ole tarpeeksi tilaa
-116 Käyttö: settc %s [yes|no]
+114 Suhteellinen ajan määre ei sovellu käytettäväksi am/pm yhteydessä
+115 Päätetyypin kuvaukselle (termcap) ei ole tarpeeksi tilaa
+116 Käyttö: settc %s [yes|no]
 117 Tuntematon toiminne `%s'
-118 Tuntematon päätetyypin (termcap) parameteri `%%%c'
-119 Liian paljon argumentteja käskylle `%s' (%d)
-120 `%s' edellyttää %d argumenttia
-121 Käyttö: echotc [-v|-s] [<toiminne> [<argumentit>]]
-122 %s: %s. Väärä laitearkkitehtuuri
+118 Tuntematon päätetyypin (termcap) parameteri `%%%c'
+119 Liian paljon argumentteja käskylle `%s' (%d)
+120 `%s' edellyttää %d argumenttia
+121 Käyttö: echotc [-v|-s] [<toiminne> [<argumentit>]]
+122 %s: %s. Väärä laitearkkitehtuuri
 123 !# Silmukka komentohistoriassa
 124 Virheellinen tiedostotesti
 125 Valitsimen ylivuoto
-126 Tuntematon valitsin: `-%s'\nKäyttö: %s [ -bcdefilmnqstvVxX -Dnimi[=arvo] ] [ argumentti ... ]
-127 Tuntematon valitsin: `-%s'\nKäyttö: %s [ -bcdefFilmnqstvVxX ] [ argumentti ... ]
-128 Tuntematon valitsin: `-%s'\nKäyttö: %s [ -bcdefilmnqstvVxX ] [ argumentti ... ]
-129 \nSoveltumaton täydennys: "%s"
+126 Tuntematon valitsin: `-%s'\nKäyttö: %s [ -bcdefilmnqstvVxX -Dnimi[=arvo] ] [ argumentti ... ]
+127 Tuntematon valitsin: `-%s'\nKäyttö: %s [ -bcdefFilmnqstvVxX ] [ argumentti ... ]
+128 Tuntematon valitsin: `-%s'\nKäyttö: %s [ -bcdefilmnqstvVxX ] [ argumentti ... ]
+129 \nSoveltumaton täydennys: "%s"
 130 \nSoveltumaton %s: '%c'
-131 \nErotin '%c' puuttuu %s "%s" jäljestä
+131 \nErotin '%c' puuttuu %s "%s" jäljestä
 132 \nVajaa %s: "%s"
 133 Valitsimelle -m ei ole kohdeargumenttia
-134 Käyttö: unlimit [-fh] [rajoitteet (limits)]
+134 Käyttö: unlimit [-fh] [rajoitteet (limits)]
 135 Muuttujalle $%S ei voida asettaa arvoa
-136 Viitattua työtä ei ole
+136 Viitattua työtä ei ole
 137 Tuntematon colorls-muuttuja `%c%c'
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/finnish/set10
--- a/head/contrib/tcsh/nls/finnish/set10	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/finnish/set10	Fri Mar 02 16:54:40 2012 +0200
@@ -1,8 +1,8 @@
-$ $tcsh: set10,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set10,v 1.3 2011/02/04 18:19:34 christos Exp $
 $ ma.setp.c
 $set 10 
 1 setpath: Virheellinen komento '%s'.\n
-2 setpath: Argumentit ovat riittämättömiä komennolle '%s'.\n
-3 setpath: Arvoa ei löydy hakupolusta '%s'\n
-4 setpath: %s ei löydy paikasta %s\n
-5 setpath: %d ei ole hyväksyttävä sijainti paikassa %s\n
+2 setpath: Argumentit ovat riittämättömiä komennolle '%s'.\n
+3 setpath: Arvoa ei löydy hakupolusta '%s'\n
+4 setpath: %s ei löydy paikasta %s\n
+5 setpath: %d ei ole hyväksyttävä sijainti paikassa %s\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/finnish/set11
--- a/head/contrib/tcsh/nls/finnish/set11	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/finnish/set11	Fri Mar 02 16:54:40 2012 +0200
@@ -1,10 +1,10 @@
-$ $tcsh: set11,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set11,v 1.3 2011/02/04 18:19:34 christos Exp $
 $ sh.c
 $set 11 
-1 Varoitus: ei yhteyttä päätteeseen (%s).\n
-2 Niinpä tässä komentotulkissa ei ole töiden hallintaa.\n
-3 Sinulla on %d sähköpostiviestiä.\n
-4 Sinulla on %d viestiä tiedostossa %s.\n
+1 Varoitus: ei yhteyttä päätteeseen (%s).\n
+2 Niinpä tässä komentotulkissa ei ole töiden hallintaa.\n
+3 Sinulla on %d sähköpostiviestiä.\n
+4 Sinulla on %d viestiä tiedostossa %s.\n
 5 Sinulla on %spostia.\n
 6 uutta 
 7 Sinulla on %spostia tiedostossa %s.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/finnish/set12
--- a/head/contrib/tcsh/nls/finnish/set12	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/finnish/set12	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set12,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set12,v 1.3 2011/02/04 18:19:34 christos Exp $
 $ sh.dir.c
 $set 12 
-1 %s: Yritetään käynnistää hakemistosta "%s"\n
+1 %s: Yritetään käynnistää hakemistosta "%s"\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/finnish/set13
--- a/head/contrib/tcsh/nls/finnish/set13	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/finnish/set13	Fri Mar 02 16:54:40 2012 +0200
@@ -1,13 +1,13 @@
-$ $tcsh: set13,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set13,v 1.3 2011/02/04 18:19:34 christos Exp $
 $ sh.exec.c
 $set 13 
 1 hash=%-4d dir=%-2d prog=%s\n
-2 %d hajautusluokkaa, joista jokaisessa %d bittiä\n
+2 %d hajautusluokkaa, joista jokaisessa %d bittiä\n
 3 debug mask = 0x%08x\n
 4 %d osumia, %d harhoja, %d%%\n
-5 %S: Komentotulkin sisäinen komento.\n
-6 %S: Komentoa ei löydy.\n
-7 where: / käskyssä on mahdoton ajatus\n
+5 %S: Komentotulkin sisäinen komento.\n
+6 %S: Komentoa ei löydy.\n
+7 where: / käskyssä on mahdoton ajatus\n
 8 %S on alias komennolle 
-9 %S on komentotulkin sisäinen komento\n
+9 %S on komentotulkin sisäinen komento\n
 10 hajautusharha: 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/finnish/set14
--- a/head/contrib/tcsh/nls/finnish/set14	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/finnish/set14	Fri Mar 02 16:54:40 2012 +0200
@@ -1,6 +1,6 @@
-$ $tcsh: set14,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set14,v 1.4 2011/02/04 18:19:34 christos Exp $
 $ sh.file.c
 $set 14 
 1 \nAuts!! Liian monta %s!!\n
-2 nimeä käyttäjätietokannassa
+2 nimeä käyttäjätietokannassa
 3 tiedostoa
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/finnish/set16
--- a/head/contrib/tcsh/nls/finnish/set16	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/finnish/set16	Fri Mar 02 16:54:40 2012 +0200
@@ -1,8 +1,8 @@
-$ $tcsh: set16,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set16,v 1.3 2011/02/04 18:19:34 christos Exp $
 $ sh.lex.c
 $set 16 
-1 Päätteen prosessiryhmä vaihdettu arvosta %d %d:ksi.\n
-2 \nSano "logout" kirjoittautuaksesi ulos järjestelmästä.\n
+1 Päätteen prosessiryhmä vaihdettu arvosta %d %d:ksi.\n
+2 \nSano "logout" kirjoittautuaksesi ulos järjestelmästä.\n
 3 \nSano "exit" lopettaaksesi %s:n\n
 4 seek to eval %x %x\n
 5 seek to alias %x %x\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/finnish/set17
--- a/head/contrib/tcsh/nls/finnish/set17	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/finnish/set17	Fri Mar 02 16:54:40 2012 +0200
@@ -1,9 +1,9 @@
-$ $tcsh: set17,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set17,v 1.4 2011/02/04 18:19:34 christos Exp $
 $ sh.proc.c
 $set 17 
-1 VIKA: taustatyötä!\n
+1 VIKA: taustatyötä!\n
 2 Paluuarvo %d\n
-3 VIKA: prosessi on hävitetty jo kertaalleen
+3 VIKA: prosessi on hävitetty jo kertaalleen
 4 Ajossa 
 5 Signaali 
 6 Paluuarvo %-25d
@@ -13,5 +13,5 @@
 10 \040(hakemisto:
 11 hakemisto nyt: 
 12 %S: On jo keskeytetty\n
-13 %S: On jo pysäytetty\n
+13 %S: On jo pysäytetty\n
 14 %S: Badly formed number\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/finnish/set18
--- a/head/contrib/tcsh/nls/finnish/set18	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/finnish/set18	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set18,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set18,v 1.3 2011/02/04 18:19:34 christos Exp $
 $ sh.set.c
 $set 18 
-1 Varoitus: Kohtuuttoman pitkä hakupolku (PATH) katkaistu.\n
+1 Varoitus: Kohtuuttoman pitkä hakupolku (PATH) katkaistu.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/finnish/set19
--- a/head/contrib/tcsh/nls/finnish/set19	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/finnish/set19	Fri Mar 02 16:54:40 2012 +0200
@@ -1,15 +1,23 @@
-$ $tcsh: set19,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set19,v 1.5 2011/02/25 23:58:07 christos Exp $
 $ tc.alloc.c
 $set 19 
 1 nbytes=%d: Muisti loppu\n
-2 free(%lx) kutsuttu ennen kuin mitään on varattu.
-3 free(%lx) arvo on sallitun muistialueen yläpuolella.
+2 free(%lx) kutsuttu ennen kuin mitään on varattu.
+3 free(%lx) arvo on sallitun muistialueen yläpuolella.
 4 free(%lx) arvo on sallitun muistialueen alapuolella.
 5 free(%lx) Virheellinen/viallinen lohko.
 6 free(%lx) Lohko ei ole dynaamisesti varatulla alueella.
 7 free(%lx) Virheellinen lohkon indeksi.
-8 %s tämänhetkinen muistin varauksien tila:\nvapaana:\t
-9 \nkäytössä:\t
-10 \n\tYhteensä käytössä: %d, yhteensä vapaana: %d\n
+8 %s tämänhetkinen muistin varauksien tila:\nvapaana:\t
+9 käytössä
+10 \n\tYhteensä käytössä: %d, yhteensä vapaana: %d\n
 11 \tVarattu muisti alueella 0x%lx .. 0x%lx.  Todellinen huippu 0x%lx\n
 12 Varattu muisti alueella 0x%lx .. 0x%lx (%ld).\n
+13 %s current memory allocation:\n
+14 Total space allocated from system: %d\n
+15 Number of non-inuse chunks: %d\n
+16 Number of mmapped regions: %d\n
+17 Total space in mmapped regions: %d\n
+18 Total allocated space: %d\n
+19 Total non-inuse space: %d\n
+20 Top-most, releasable space: %d\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/finnish/set2
--- a/head/contrib/tcsh/nls/finnish/set2	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/finnish/set2	Fri Mar 02 16:54:40 2012 +0200
@@ -1,94 +1,94 @@
-$ $tcsh: set2,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set2,v 1.3 2011/02/04 18:19:34 christos Exp $
 $ Signal names
 $set 2 
 1 Null-signaali
 2 Yhteyden katkaisu
 3 Keskeytys
 4 Lopetus
-5 Virheellinen konekäsky
+5 Virheellinen konekäsky
 6 Seuranta-ansa (BPT)
-7 Hätäkeskeytys
-8 Syöttö-/tulostusansa
-9 Järjestelmän alasajo odotettavissa
-10 Virheellinen päättyminen
-11 Jäljittelyansa (EMT)
+7 Hätäkeskeytys
+8 Syöttö-/tulostusansa
+9 Järjestelmän alasajo odotettavissa
+10 Virheellinen päättyminen
+11 Jäljittelyansa (EMT)
 12 Liukulukupoikkeus
 13 Tapettu
-14 Käyttäjän signaal1 1
-15 Käyttäjän signaali 2
-16 Väärä muistilohko
-17 Väylävirhe
+14 Käyttäjän signaal1 1
+15 Käyttäjän signaali 2
+16 Väärä muistilohko
+17 Väylävirhe
 18 Viittaus ohjelma-alueen ulkopuolelle
 19 Data sallittujen arvojen ulkopuolella
-20 Tuntematon järjestelmäkutsu
+20 Tuntematon järjestelmäkutsu
 21 Murtunut putki
-22 Herätyskello
-23 Päätetty
+22 Herätyskello
+23 Päätetty
 24 Poikasen tila muuttunut
 25 Poikanen kuollut
 26 Apollon laitekohtainen virhe
-27 Poikanen pysähtynyt tai poistunut
+27 Poikanen pysähtynyt tai poistunut
 28 Poikanen poistunut
-29 Tehonsyöttö pettänyt
+29 Tehonsyöttö pettänyt
 30 Resurssi menetetty
 31 Break (Ctrl-Break)
-32 Syöte/tulostus mahdollista
-33 Epäsynkroninen syöte/tulostus (select)
-34 Kiireellinen syöte-/tulostustapahtuma
-35 Herätys moniajossa
+32 Syöte/tulostus mahdollista
+33 Epäsynkroninen syöte/tulostus (select)
+34 Kiireellinen syöte-/tulostustapahtuma
+35 Herätys moniajossa
 36 Tappaminen moniajossa
-37 Fortranin epäsynkroninen syöte/tulostus valmis
+37 Fortranin epäsynkroninen syöte/tulostus valmis
 38 Toipuminen
 39 Korjauskelvoton muistivirhe
-40 Keskusyksikköajan raja ylitetty
-41 Järjestelmän sulkeminen odotettavissa
-42 Pienoistehtäväryhmän ei-herätystä lippu asetettu
-43 Säievirhe - (yksityiskohtaisempia tietoja käskyllä cord -T)
+40 Keskusyksikköajan raja ylitetty
+41 Järjestelmän sulkeminen odotettavissa
+42 Pienoistehtäväryhmän ei-herätystä lippu asetettu
+43 Säievirhe - (yksityiskohtaisempia tietoja käskyllä cord -T)
 44 rekisterin pariteettivirhe (CRAY Y-MP)
-45 Tiedotepyyntö
+45 Tiedotepyyntö
 46 Keskeytetty (signaali)
-47 Pysäytetty (signaali)
+47 Pysäytetty (signaali)
 48 Keskeytetty
-49 Pysäytetty
+49 Pysäytetty
 50 Suoritus jatkuu
-51 Keskeytetty (päätesyöte)
-52 Pysäytetty (päätetulostus)
-53 Keskeytetty (päätetulostus)
-54 Pysäytetty (päätetulostus)
+51 Keskeytetty (päätesyöte)
+52 Pysäytetty (päätetulostus)
+53 Keskeytetty (päätetulostus)
+54 Pysäytetty (päätetulostus)
 55 Ikkunan tila muuttunut
 56 Ikkunan koko muuttunut
 57 Puhelinlinjan tila muuttunut
-58 Keskusyksikköajan raja ylitetty
+58 Keskusyksikköajan raja ylitetty
 59 Tiedostokoon raja ylitetty
-60 Käyttökelpoisen ajan ajastin laukesi
-61 Ohjelman ajankäytönseurannan ajastin laukesi
+60 Käyttökelpoisen ajan ajastin laukesi
+61 Ohjelman ajankäytönseurannan ajastin laukesi
 62 DIL-signaali
 63 Tutkittava tapahtuma (poll)
 64 Prosessin kevytprosessit  Process's lwps are blocked
 65 Erityinen kevytprossisignaali (LWP)
 66 Erityinen CPR-signaali
 67 Erityinen CPR-signaali
-68 Ensimmäinen tosiaikasignaali
+68 Ensimmäinen tosiaikasignaali
 69 Toinen tosiaikasignaali
 70 Kolmas tosiaikasignaali
-71 Neljäs tosiaikasignaali
-72 Neljänneksi viimeinen tosiaikasignaali
+71 Neljäs tosiaikasignaali
+72 Neljänneksi viimeinen tosiaikasignaali
 73 Kolmanneksi viimeinen tosiaikasignaali
 74 Toiseksi viimeinen tosiaikasignaali
 75 Viimeinen tosiaikasignaali
-76 Paikallisverkko (epäsynkroninen syöte/tulostus)
-77 Näennäispääte (syöte/tulostus valmiina)
-78 Syöte-/tulostustoimenpidettä edellytetään
+76 Paikallisverkko (epäsynkroninen syöte/tulostus)
+77 Näennäispääte (syöte/tulostus valmiina)
+78 Syöte-/tulostustoimenpidettä edellytetään
 79 HFT seurantatila luovutettu
 80 HFT seurantatila vapautettava
-81 HFT äänenhallinta valmis
+81 HFT äänenhallinta valmis
 82 Uutta dataa HFT-rengaspuskurissa
 83 Muuta prosessi
-84 Turvallinen huomionäppäin
+84 Turvallinen huomionäppäin
 85 Vuorottelutarve
 86 SS$_DEBUG -signaali
 87 Etusija muuttunut (priority)
 88 Todellinen lukkiintumistila
-89 Uusi merkki syötteessä
+89 Uusi merkki syötteessä
 90 Pinon raja ylitetty
-91 Käyttämätön signaali
+91 Käyttämätön signaali
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/finnish/set20
--- a/head/contrib/tcsh/nls/finnish/set20	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/finnish/set20	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set20,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set20,v 1.4 2011/02/04 18:19:34 christos Exp $
 $ tc.bind.c
 $set 20 
 1 Invalid key name `%S'\n
@@ -6,13 +6,13 @@
 3 Bad command name: %S\n
 4 Bad key spec %S\n
 5 Null string specification\n
-6 Standard näppäinmäärittelyt\n
-7 Vaihtoehtoiset näppäinmäärittelyt\n
-8 Monimerkkiset määrittelyt\n
-9 Nuolinäppäinmäärittelyt\n
-10 %-15s->  ei ole määritelty\n
-11 VIKA!!! %s ei ole määritelty mihinkään näppäimeen.\n
-12 Käyttö: bindkey [valitsimet] [--] [NÄPPÄIN [KOMENTO]]\n
+6 Standard näppäinmäärittelyt\n
+7 Vaihtoehtoiset näppäinmäärittelyt\n
+8 Monimerkkiset määrittelyt\n
+9 Nuolinäppäinmäärittelyt\n
+10 %-15s->  ei ole määritelty\n
+11 VIKA!!! %s ei ole määritelty mihinkään näppäimeen.\n
+12 Käyttö: bindkey [valitsimet] [--] [NÄPPÄIN [KOMENTO]]\n
 13     -a   list or bind KEY in alternative key map\n
 14     -b   interpret KEY as a C-, M-, F- or X- key name\n
 15     -s   interpret COMMAND as a literal string to be output\n
@@ -25,8 +25,8 @@
 22     -k   interpret KEY as a symbolic arrow-key name\n
 23     --   force a break from option processing\n
 24     -u   (or any invalid option) this message\n
-25 Ilman NÄPPÄINTÄ tai KOMENTOA tulostetaan kaikki määrittelyt\n
-26 Ilman KOMENTOA tulostetaan NÄPPÄIMEN määrittely.\n
+25 Ilman NÄPPÄINTÄ tai KOMENTOA tulostetaan kaikki määrittelyt\n
+26 Ilman KOMENTOA tulostetaan NÄPPÄIMEN määrittely.\n
 27 bad key specification -- null string\n
 28 bad key specification -- empty string\n
 29 Bad function-key specification.  Null key not allowed\n
@@ -36,6 +36,6 @@
 33 Bad function-key specification.\n
 34 Null key not allowed\n
 35 bad key specification -- unknown name "%S"\n
-36 Käyttö: bind [NÄPPÄIN | KOMENTO NÄPPÄIN | "emacs" | "vi" | "-a"]\n
+36 Käyttö: bind [NÄPPÄIN | KOMENTO NÄPPÄIN | "emacs" | "vi" | "-a"]\n
 37 Invalid function
 38  %s\t\tis undefined\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/finnish/set22
--- a/head/contrib/tcsh/nls/finnish/set22	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/finnish/set22	Fri Mar 02 16:54:40 2012 +0200
@@ -1,17 +1,17 @@
-$ $tcsh: set22,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set22,v 1.4 2011/02/04 18:19:34 christos Exp $
 $ tc.func.c
 $set 22 
 1 %S: \t on alias komennolle 
-2 \nTunnussana ei ole käyttäjän %s\n
+2 \nTunnussana ei ole käyttäjän %s\n
 3 Virheellinen alias 'precmd' poistettu.\n
 4 Virheellinen alias 'cwdcmd' poistettu.\n
 5 Virheellinen alias 'beepcmd' poistettu.\n
 6 Virheellinen alias 'periodic' poistettu.\n
-7 Jäsennetään komentoriviä\n
+7 Jäsennetään komentoriviä\n
 8 Haluatko todella tuhota kaikki tiedostot? [e/k] 
 9 Ohitetaan tiedostojen tuhoaminen!\n
 10 Komentorivi on nyt:\n
-11 Jäsennetään komentoriviä\n
-12 on yhdellä listoista\n
+11 Jäsennetään komentoriviä\n
+12 on yhdellä listoista\n
 13 Komentorivi on nyt:\n
 14 YyKk
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/finnish/set23
--- a/head/contrib/tcsh/nls/finnish/set23	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/finnish/set23	Fri Mar 02 16:54:40 2012 +0200
@@ -1,17 +1,17 @@
-$ $tcsh: set23,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set23,v 1.3 2011/02/04 18:19:34 christos Exp $
 $ tc.os.c
 $set 23 
 1 Virheellinen solmun nimi
-2 Solmun polku liian pitkä
+2 Solmun polku liian pitkä
 3 tuntematon
 4 solmu: %s\n
-5 %d: Solmua ei löydy\n
+5 %d: Solmua ei löydy\n
 6 setlocal: %s: %s\n
-7 Solmua ei löydy
-8 Olet ansassa maailmassa (universe), mitä et itse luonut.
-9 Getwarp epäonnistui
+7 Solmua ei löydy
+8 Olet ansassa maailmassa (universe), mitä et itse luonut.
+9 Getwarp epäonnistui
 10 Virheellinen warp
-11 Setwarp epäonnistui
+11 Setwarp epäonnistui
 12 Virheellinen maailma (universe)
 13 Tuntematon virhe: %d
 14 sysname:  %s\n
@@ -20,15 +20,15 @@
 17 version:  %s\n
 18 machine:  %s\n
 19 getwd: Avaus ei onnistu ".." (%s)
-20 getwd: En voi siirtyä hakemistoon ".." (%s)
+20 getwd: En voi siirtyä hakemistoon ".." (%s)
 21 getwd: Virhe luettaessa hakemistoa ".." (%s)
-22 getwd: En voi siirtyä takaisin hakemistoon "." (%s)
+22 getwd: En voi siirtyä takaisin hakemistoon "." (%s)
 23 getwd: En voi testata (stat) hakemistoa "/" (%s)
 24 getwd: En voi testata (stat) hakemistoa "." (%s)
 25 getwd: En voi testata (stat) hakemistoa "%s" (%s)
 26 getwd: En voi avata hakemistoa "%s" (%s)
-27 getwd: Hakemisto "." ei löydy hakemistosta ".." (%s)
-28 Virheellinen järjestelmän tyyppi
-29 Järjestelmän tyyppiä ei asetettu
+27 getwd: Hakemisto "." ei löydy hakemistosta ".." (%s)
+28 Virheellinen järjestelmän tyyppi
+29 Järjestelmän tyyppiä ei asetettu
 30 Liian monta argumenttia
 31 Virheellinen argumentti
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/finnish/set25
--- a/head/contrib/tcsh/nls/finnish/set25	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/finnish/set25	Fri Mar 02 16:54:40 2012 +0200
@@ -1,6 +1,6 @@
-$ $tcsh: set25,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set25,v 1.3 2011/02/04 18:19:34 christos Exp $
 $ tc.sig.c
 $set 25 
 1 our wait %d\n
 2 virhe: bsd_signal(%d) signaali on sallitun arvoalueen ulkopuolella\n
-3 virhe: bsd_signal(%d) - sigaction epäonnistui, errno %d\n
+3 virhe: bsd_signal(%d) - sigaction epäonnistui, errno %d\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/finnish/set26
--- a/head/contrib/tcsh/nls/finnish/set26	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/finnish/set26	Fri Mar 02 16:54:40 2012 +0200
@@ -1,15 +1,15 @@
-$ $tcsh: set26,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set26,v 1.3 2011/02/04 18:19:34 christos Exp $
 $ tc.who.c
 $set 26 
-1 Testaaminen ei onnistu: stat(%s).  Ole hyvä ja suorita "unset watch".\n
-2 %s ei avaudu.  Ole hyvä ja suorita "unset watch".\n
+1 Testaaminen ei onnistu: stat(%s).  Ole hyvä ja suorita "unset watch".\n
+2 %s ei avaudu.  Ole hyvä ja suorita "unset watch".\n
 3 VIKA! viimeinen osa ei ole whotail!\n
 4 takaperin: 
-5 VIKA! ensimmäinen osa ei ole whohead!\n
+5 VIKA! ensimmäinen osa ei ole whohead!\n
 6 uusi: %s/%s\n
 7 %n on %a %l koneelta %m.
 8 %n on %a %l.
-9 kirjoittautunut sisään linjalle
+9 kirjoittautunut sisään linjalle
 10 kirjoittautunut ulos linjalta
 11 korvannut tunnuksen %s linjalla
 12 localhost
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/finnish/set27
--- a/head/contrib/tcsh/nls/finnish/set27	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/finnish/set27	Fri Mar 02 16:54:40 2012 +0200
@@ -1,8 +1,8 @@
-$ $tcsh: set27,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set27,v 1.3 2011/02/04 18:19:34 christos Exp $
 $ tw.comp.c
 $set 27 
 1 komento
 2 erotin
 3 malli
 4 arvojoukko
-5 täydennys
+5 täydennys
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/finnish/set29
--- a/head/contrib/tcsh/nls/finnish/set29	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/finnish/set29	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set29,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set29,v 1.3 2011/02/04 18:19:34 christos Exp $
 $ tw.help.c
 $set 29 
-1 Ei löydy aputiedostoa komennolle %S\n
+1 Ei löydy aputiedostoa komennolle %S\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/finnish/set3
--- a/head/contrib/tcsh/nls/finnish/set3	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/finnish/set3	Fri Mar 02 16:54:40 2012 +0200
@@ -1,120 +1,120 @@
-$ $tcsh: set3,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set3,v 1.4 2011/02/04 18:19:34 christos Exp $
 $ Editor function descriptions
 $set 3 
-1 Siirry taaksepäin yksi merkki
-2 Poista kursoria edeltävä merkki
+1 Siirry taaksepäin yksi merkki
+2 Poista kursoria edeltävä merkki
 3 Leikkaa sanan alusta kursoriin - talleteta leikkauspuskuriin
 4 Leikkaa rivin alusta kursoriin - talleteta leikkauspuskuriin
 5 Siirry sanan alkuun
 6 Siirry rivin alkuun
 7 Vaihda isoiksi kirjaimiksi kursorista sanan loppuun
-8 Vi: Vaihda kirjain kursorin alla ison ja pienen välillä, ja etene merkki
+8 Vi: Vaihda kirjain kursorin alla ison ja pienen välillä, ja etene merkki
 9 Vi: muuta rivin loppuun
-10 Puhdista kuvaruutu jättäen keskeneräinen rivi ylimmäksi
-11 Täydennä sana
-12 Etene tiedostojen läpi yksi kerrallaan
-13 Peruuta tiedostojen läpi yksi kerrallaan
-14 Täydennä sana huomioimatta ohjelmoitavia täydennyksiä
+10 Puhdista kuvaruutu jättäen keskeneräinen rivi ylimmäksi
+11 Täydennä sana
+12 Etene tiedostojen läpi yksi kerrallaan
+13 Peruuta tiedostojen läpi yksi kerrallaan
+14 Täydennä sana huomioimatta ohjelmoitavia täydennyksiä
 15 Kopioi sana kursoriin saakka
-16 Kopioi leikkauspuskuriin alue merkistä kursoriin
-17 Laajenna edelliseksi sanaksi, missä on tämä alkuosa
+16 Kopioi leikkauspuskuriin alue merkistä kursoriin
+17 Laajenna edelliseksi sanaksi, missä on tämä alkuosa
 18 Poista merkki kursorin alta
-19 Poista merkki kursorin alta ja ilmoita tiedoston loppu tyhjällä rivillä
-20 Poista merkki kursorin alta ja näytä täydennykset, mikäli rivin lopussa
-21 Poista merkki kursorin alta ja ilmoita täydennykset tai tiedoston loppu
+19 Poista merkki kursorin alta ja ilmoita tiedoston loppu tyhjällä rivillä
+20 Poista merkki kursorin alta ja näytä täydennykset, mikäli rivin lopussa
+21 Poista merkki kursorin alta ja ilmoita täydennykset tai tiedoston loppu
 22 Leikkaa kursorista sanan loppuun - talleteta leikkauspuskuriin
-23 Lisää argumenttiin, mikäli sekvenssi on aloitettu tai kyseessä on numero
-24 Numero, mikä aloittaa argumentin
+23 Lisää argumenttiin, mikäli sekvenssi on aloitettu tai kyseessä on numero
+24 Numero, mikä aloittaa argumentin
 25 Siirry seuraavalle riville historiassa
 26 Muuta pieniksi kirjaimiksi kursorista sanan loppuun
 27 Ilmoita tiedoston loppu
-28 Siirrä kursori rivin loppuun
+28 Siirrä kursori rivin loppuun
 29 Vaihda kursorin ja merkin paikkaa
 30 Laajenna tiedoston nimen jokerimerkit
 31 Laajenna viittaukset komentohistoriaan
 32 Laajenna viittaukset komentohistoriaan suoraan paikallaan
 33 Laajenna muuttujat
-34 Siirry eteenpäin yksi merkki
-35 Siirry eteenpäin sanan loppuun
-36 Vaihda keskenään kursoria edeltävät kaksi merkkiä
-37 Etsi historiasta taaksepäin riviä, mikä alkaa kuten tämä
-38 Etsi historiasta eteenpäin riviä, mikä alkaa kuten tämä
-39 Lisää viimeisen komennon viimeinen osa
-40 Täsmentyvä haku eteenpäin
-41 Täsmentyvä haku taaksepäin
-42 Tyhjennä rivi
+34 Siirry eteenpäin yksi merkki
+35 Siirry eteenpäin sanan loppuun
+36 Vaihda keskenään kursoria edeltävät kaksi merkkiä
+37 Etsi historiasta taaksepäin riviä, mikä alkaa kuten tämä
+38 Etsi historiasta eteenpäin riviä, mikä alkaa kuten tämä
+39 Lisää viimeisen komennon viimeinen osa
+40 Täsmentyvä haku eteenpäin
+41 Täsmentyvä haku taaksepäin
+42 Tyhjennä rivi
 43 Leikkaa kursorista rivin loppuun ja talleta leikkauspuskuriin
-44 Leikkaa alue merkistä kursoriin ja talleta leikkauspuskuriin
+44 Leikkaa alue merkistä kursoriin ja talleta leikkauspuskuriin
 45 Leikkaa koko rivi ja talleta leikkauspuskuriin
-46 Näytä täydennysvaihtoehdot
-47 Näytä täydennysvaihtoehdot ohittaen ohjelmoitavat taydennykset
-48 Näytä tiedostojen nimien jokerimerkkivastaavuudet
-49 Näytä täydennysvaihtoehdot tai ilmoita tiedoston loppu, jos rivi on tyhjä
-50 Näytä kuormituskeskiarvot ja tämänhetkisen prosessin tila
-51 Laajenna historiaviittaukset ja lisää välilyönti
+46 Näytä täydennysvaihtoehdot
+47 Näytä täydennysvaihtoehdot ohittaen ohjelmoitavat taydennykset
+48 Näytä tiedostojen nimien jokerimerkkivastaavuudet
+49 Näytä täydennysvaihtoehdot tai ilmoita tiedoston loppu, jos rivi on tyhjä
+50 Näytä kuormituskeskiarvot ja tämänhetkisen prosessin tila
+51 Laajenna historiaviittaukset ja lisää välilyönti
 52 Suorita komento
-53 Laajenna hakupolut ja korvaa tai taydennä jokainen '.' ja '..'
+53 Laajenna hakupolut ja korvaa tai taydennä jokainen '.' ja '..'
 54 Laajenna komennot kokonaisiksi hakupoluiksi tai alias-vastineiksi
-55 Vaihda toimintatilaa lisäyksen ja päällekirjoituksen välillä
-56 Lisää 8. bitti seuraavaan merkkiin (meta)
-57 Lisää seuraava merkki riville sellaisenaan ilman tulkintaa
-58 Näytä kaikki uudestaan
-59 Jatka pysäytettyä tekstinkäsittelyä
-60 Etsi aputietoja tästä komennosta
-61 Tämä merkki lisätään riville
-62 Tämä merkki aloittaa merkkisarjan
+55 Vaihda toimintatilaa lisäyksen ja päällekirjoituksen välillä
+56 Lisää 8. bitti seuraavaan merkkiin (meta)
+57 Lisää seuraava merkki riville sellaisenaan ilman tulkintaa
+58 Näytä kaikki uudestaan
+59 Jatka pysäytettyä tekstinkäsittelyä
+60 Etsi aputietoja tästä komennosta
+61 Tämä merkki lisätään riville
+62 Tämä merkki aloittaa merkkisarjan
 63 Aseta merkki kursorin kohdalle
 64 Korjaa sanan kirjoitusasu
 65 Korjaa koko rivin kirjoitusasu
-66 Lähetä merkki päätteelle erikoismerkkien tulkinnan ja muunnoksien jälkeen
-67 Vaihda esitystä raa'an ja täydennetyn historiarivin välillä
-68 Vaihda kursoria edeltävä merkki ja kursorin alla oleva merkki keskenään
-69 Vaihda kursoria edeltävät kaksi merkkiä keskenään
-70 Tty viivästetty pysäytysmerkki (TSTP)
-71 Tty tulosteen hävittämismerkki
+66 Lähetä merkki päätteelle erikoismerkkien tulkinnan ja muunnoksien jälkeen
+67 Vaihda esitystä raa'an ja täydennetyn historiarivin välillä
+68 Vaihda kursoria edeltävä merkki ja kursorin alla oleva merkki keskenään
+69 Vaihda kursoria edeltävät kaksi merkkiä keskenään
+70 Tty viivästetty pysäytysmerkki (TSTP)
+71 Tty tulosteen hävittämismerkki
 72 Tty keskeytysmerkki (INT)
 73 Tty lopetusmerkki (QUIT)
-74 Tty pysäytysmerkki (STOP)
+74 Tty pysäytysmerkki (STOP)
 75 Tty salli tulostus -merkki
-76 Tty estä tulostus -merkki
-77 Ilmoitus sitomattomasta merkistä
+76 Tty estä tulostus -merkki
+77 Ilmoitus sitomattomasta merkistä
 78 Emacs-tyylin toistettava argumentti (4 kertaa argumentti)
 79 Siirry edelliselle historiariville
 80 Muuta kirjaimet kursorista sanan loppuun isoiksi
 81 Vi: siirry seuraavan sanan alkuun
-82 Vi: vaihda lisäystilaan kursorin jälkeen
-83 Vi: vaihda lisäystilaan rivin lopussa
-84 Vi: vaihda kirjain kursorin alla ison ja pienen välillä, ja etene merkki
+82 Vi: vaihda lisäystilaan kursorin jälkeen
+83 Vi: vaihda lisäystilaan rivin lopussa
+84 Vi: vaihda kirjain kursorin alla ison ja pienen välillä, ja etene merkki
 85 Vi: vaihda (sanan) alkuliite/-osa
 86 Vi: vaihda kursorista rivin loppuun
-87 Vaihda vi:n komentotilaan (vaihtoehtoisin näppäinmäärittelyin)
-88 Vi: komentotilan täydennä sana
-89 Vi: siirry edelliseen merkkiin (backspace, välilyönti taaksepäin)
+87 Vaihda vi:n komentotilaan (vaihtoehtoisin näppäinmäärittelyin)
+88 Vi: komentotilan täydennä sana
+89 Vi: siirry edelliseen merkkiin (backspace, välilyönti taaksepäin)
 90 Vi: poista (sanan) alkuliite/-osa
-91 Vi: siirry seuraavaan välilyönnin rajoittamaan sanan loppuun
+91 Vi: siirry seuraavaan välilyönnin rajoittamaan sanan loppuun
 92 Vi: siirry seuraavaan sanan loppuun
 93 Vi: siirry edelliseen annetun mallin mukaiseen merkkiin
 94 Vi: siirry seuraavaan annetun mallin mukaiseen merkkiin
-95 Vi: siirry edelliseen annetun mallin mukaisen merkin jälkeiseen merkkiin
-96 Vi: siirry seuraavaan annetun mallin mukaista merkkiä edeltävään merkkiin
+95 Vi: siirry edelliseen annetun mallin mukaisen merkin jälkeiseen merkkiin
+96 Vi: siirry seuraavaan annetun mallin mukaista merkkiä edeltävään merkkiin
 97 Vaihda vi-tilaan
-98 Vaihda vi:n lisäystilaan rivin alussa
-99 Vi: toista viimeinen merkkihaku jatkaen etsintää samaan suuntaan
-100 Vi: toista viimeinen merkkihaku jatkaen etsintää päinvastaiseen suuntaan
-101 Vi: toista viimeinen haku jatkaen etsintää samaan suuntaan
-102 Vi: toista viimeinen haku jatkaen etsintää päinvastaiseen suuntaan
-103 Vi: vaihda kursorin alla oleva merkki seuraavaan näppäiltyyn merkkiin
+98 Vaihda vi:n lisäystilaan rivin alussa
+99 Vi: toista viimeinen merkkihaku jatkaen etsintää samaan suuntaan
+100 Vi: toista viimeinen merkkihaku jatkaen etsintää päinvastaiseen suuntaan
+101 Vi: toista viimeinen haku jatkaen etsintää samaan suuntaan
+102 Vi: toista viimeinen haku jatkaen etsintää päinvastaiseen suuntaan
+103 Vi: vaihda kursorin alla oleva merkki seuraavaan näppäiltyyn merkkiin
 104 Vi: korvaustila
-105 Vi: etsi historiasta taaksepäin
-106 Vi: etsi historiasta eteenpäin
-107 Vi: korvaa kursorin alla oleva merkki ja siirry lisäystilaan
+105 Vi: etsi historiasta taaksepäin
+106 Vi: etsi historiasta eteenpäin
+107 Vi: korvaa kursorin alla oleva merkki ja siirry lisäystilaan
 108 Vi: korvaa koko rivi
 109 Vi: siirry edelliseen sanaan
 110 Vi: siirry seuraavaan sanaan
 111 Vi: peruuta muutos
 112 Vi: siirry rivin alkuun
-113 Suorita 'which' tälle komennolle
-114 Liimaa/lisää leikkauspuskurin sisältö kursorin paikalle
+113 Suorita 'which' tälle komennolle
+114 Liimaa/lisää leikkauspuskurin sisältö kursorin paikalle
 115 Korvaa viimeksi liimattu teksti aikaisemmalla leikkauksella
 116 (WIN32 only) Copy cut buffer to system clipboard
 117 (WIN32 only) Paste clipboard buffer at cursor position
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/finnish/set6
--- a/head/contrib/tcsh/nls/finnish/set6	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/finnish/set6	Fri Mar 02 16:54:40 2012 +0200
@@ -1,11 +1,11 @@
-$ $tcsh: set6,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set6,v 1.3 2011/02/04 18:19:34 christos Exp $
 $ ed.inputl.c
 $set 6
-1 VIKA: Virheellinen komento näppäimeltä 0%o\r\n
-2 kyllä\n
+1 VIKA: Virheellinen komento näppäimeltä 0%o\r\n
+2 kyllä\n
 3 muokkaa\n
-4 keskeytä\n
+4 keskeytä\n
 5 ei\n
 6 Ei malliin sopivaa komentoa\n
 7 Tulkinnanvarainen komento\n
-8 *** kohtalokas VIKA tekstinkäsittelyssä ***\r\n\n
+8 *** kohtalokas VIKA tekstinkäsittelyssä ***\r\n\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/finnish/set7
--- a/head/contrib/tcsh/nls/finnish/set7	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/finnish/set7	Fri Mar 02 16:54:40 2012 +0200
@@ -1,30 +1,30 @@
-$ $tcsh: set7,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set7,v 1.3 2011/02/04 18:19:34 christos Exp $
 $ ed.screen.c
 $set 7
-1 \n\tTcsh:n mielestä päätteelläsi on\n
+1 \n\tTcsh:n mielestä päätteelläsi on\n
 2 \tseuraavat ominaisuudet:\n\n
-3 \tSiinä on %d palstaa ja %d riviä.\n
-4 \tMeta-näppäin %s käytettävissä.\n
+3 \tSiinä on %d palstaa ja %d riviä.\n
+4 \tMeta-näppäin %s käytettävissä.\n
 5 on
 6 ei ole
-7 \tSe %sosaa hyödyntää tabulaattorimerkkejä.\n
+7 \tSe %sosaa hyödyntää tabulaattorimerkkejä.\n
 8 not
-9 \tSiinä %s luottaa automaattisiin marginaaleihin.\n
+9 \tSiinä %s luottaa automaattisiin marginaaleihin.\n
 10 voi
 11 ei voi
-12 \tSiinä %s luottaa taikamarginaaleihin. (magic margin)\n
+12 \tSiinä %s luottaa taikamarginaaleihin. (magic margin)\n
 13 (empty)
 14 yes
 15 no
-16 VIRHE: Ei pysty tuhoamaan merkkejä.\r\n
+16 VIRHE: Ei pysty tuhoamaan merkkejä.\r\n
 17 DeleteChars: Numeroarvo on naurettava: %d\r\n
-18 VIRHE: Ei pysty lisäämään merkkejä keskelle riviä.\r\n
+18 VIRHE: Ei pysty lisäämään merkkejä keskelle riviä.\r\n
 19 StartInsert: Numeroarvo on naurettava: %d\r\n
-20 %s: Ei pystytä avaamaan tiedostoa /etc/termcap.\n
-21 %s: Päätetyypille "%s" ei löydy määrittely\n
-22 %s: Käytän tyhmän (dumb) päätteen asetuksia.\n
-23 %s: VAROITUS: Päätteesi ei osaa siirtää kursoria ylöspäin.\n
-24 Pitkillä riveillä tekstinkäsittely voi olla lievästi outoa.\n
-25 Päätteestäsi puuttuu toiminto "tuhoa rivin loppuun".\n
-26 Päätteestäsi puuttuu toiminto "tuhoa merkki".\n
-27 Päätteestäsi puuttuu toiminto "lisää merkki aiempien väliin".\n
+20 %s: Ei pystytä avaamaan tiedostoa /etc/termcap.\n
+21 %s: Päätetyypille "%s" ei löydy määrittely\n
+22 %s: Käytän tyhmän (dumb) päätteen asetuksia.\n
+23 %s: VAROITUS: Päätteesi ei osaa siirtää kursoria ylöspäin.\n
+24 Pitkillä riveillä tekstinkäsittely voi olla lievästi outoa.\n
+25 Päätteestäsi puuttuu toiminto "tuhoa rivin loppuun".\n
+26 Päätteestäsi puuttuu toiminto "tuhoa merkki".\n
+27 Päätteestäsi puuttuu toiminto "lisää merkki aiempien väliin".\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/finnish/set9
--- a/head/contrib/tcsh/nls/finnish/set9	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/finnish/set9	Fri Mar 02 16:54:40 2012 +0200
@@ -1,12 +1,12 @@
-$ $tcsh: set9,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set9,v 1.3 2011/02/04 18:19:34 christos Exp $
 $ ed.xmap.c
 $set 9
 1 AddXkey: Null extended-key not allowed.\n
 2 AddXkey: sequence-lead-in command not allowed\n
 3 DeleteXkey: Null extended-key not allowed.\n
-4 Sitomaton laajennettu näppäin "%S"\n
-5 Jotkin laajennetut näppäimet ovat liian pitkiä sisäiseen tulostuspuskurille
-6 Enumerate: VIKA!! Välitetty null-osoitin\n!
-7 ei syötettä
+4 Sitomaton laajennettu näppäin "%S"\n
+5 Jotkin laajennetut näppäimet ovat liian pitkiä sisäiseen tulostuspuskurille
+6 Enumerate: VIKA!! Välitetty null-osoitin\n!
+7 ei syötettä
 8 Jotain on seurattava: %c\n
 9 Oktaalivakio ei mahdu char-tyypin muuttujaan.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/french/charset
--- a/head/contrib/tcsh/nls/french/charset	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/french/charset	Fri Mar 02 16:54:40 2012 +0200
@@ -1,3 +1,3 @@
-$ codeset=ISO-8859-1
+$ codeset=UTF-8
 $set 255
-1 ISO-8859-1
+1 UTF-8
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/french/set1
--- a/head/contrib/tcsh/nls/french/set1	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/french/set1	Fri Mar 02 16:54:40 2012 +0200
@@ -1,8 +1,8 @@
-$ $tcsh: set1,v 1.4 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set1,v 1.5 2011/02/04 18:19:35 christos Exp $
 $ Messages d 'erreur
 $set 1 
 1 Erreur de syntaxe
-2 %s n'est pas autorisé
+2 %s n'est pas autorisé
 3 Mot trop long
 4 $< ligne trop longue
 5 Pas de fichier pour $0
@@ -10,130 +10,130 @@
 7 $ l'expansion doit se terminer avant ]
 8 Mauvais : modificateur dans $ (%c)
 9 Erreur d'indice
-10 Numéro mal formé
+10 Numéro mal formé
 11 Plus de mots
 12 Nom de fichier manquant
 13 Erreur globale interne
 14 Commande introuvable
 15 Trop peu d'arguments
 16 Trop d'arguments
-17 Trop dangereux d'attribuer un alias à cela
+17 Trop dangereux d'attribuer un alias à cela
 18 `If' vide
 19 `Then' incorrect
-20 Les mots ne sont pas placés entre parenthèses
+20 Les mots ne sont pas placés entre parenthèses
 21 %s introuvable
 22 Masque incorrect
 23 Pas de limite de ce type
 24 Argument trop long
-25 Facteur d'échelle incorrect ou inconnu
-26 Variable pas définie
-27 La pile de répertoires n'a pas cette taille
-28 Mauvais numéro de signal
+25 Facteur d'échelle incorrect ou inconnu
+26 Variable pas définie
+27 La pile de répertoires n'a pas cette taille
+28 Mauvais numéro de signal
 29 Signal inconnu; "kill -l" permet de lister les signaux
 30 Le nom de la variable doit commencer par une lettre
 31 Le nom de la variable est trop long
-32 Le nom de la variable ne doit contenir que des caractères alphanumériques
+32 Le nom de la variable ne doit contenir que des caractères alphanumériques
 33 Pas de gestion des travaux dans ce shell
 34 Syntaxe de l'expression
-35 Pas de répertoire personnel
-36 Impossible de passer dans le répertoire personnel
+35 Pas de répertoire personnel
+36 Impossible de passer dans le répertoire personnel
 37 Commande nulle incorrecte
 38 Il manque l'affectation dans l'expression
-39 Opérateur inconnu
+39 Opérateur inconnu
 40 ambigu
 41 %s: Le fichier existe
 42 L'argument pour -c se termine avec un anti-slash
 43 Interrompu
 44 Indice hors limites
-45 Dépassement de capacité de ligne
+45 Dépassement de capacité de ligne
 46 Pas de travail de ce type
-47 Impossible à partir d'un terminal
-48 Vous n'êtes pas dans une boucle while ou foreach
+47 Impossible à partir d'un terminal
+48 Vous n'êtes pas dans une boucle while ou foreach
 49 Plus de processus
 50 Pas de correspondance
 51 %c manquant
 52 %c sans correspondance
-53 Mémoire insuffisante
-54 Impossible de créer un tube
+53 Mémoire insuffisante
+54 Impossible de créer un tube
 55 %s: %s
 56 %s
 57 Syntaxe: jobs [ -l ]
-58 Les arguments doivent être des ID de processus ou des numéros de travaux
+58 Les arguments doivent être des ID de processus ou des numéros de travaux
 59 Pas de travail en cours
-60 Pas de travail précédent
+60 Pas de travail précédent
 61 Pas de travail de cette forme
-62 Emboîtement des `Fork' > %d; peut-être une boucle `...`
+62 Emboîtement des `Fork' > %d; peut-être une boucle `...`
 63 Pas de gestion des travaux dans les sous-shells
-64 Faute `Sync': Processus %d pas trouvé
+64 Faute `Sync': Processus %d pas trouvé
 65 %s Il y a des travaux interrompus
-66 %s Il y a des travaux arrêtés
-67 Pas d'autre répertoire
-68 La pile de répertoires est vide
-69 Répertoire incorrect
+66 %s Il y a des travaux arrêtés
+67 Pas d'autre répertoire
+68 La pile de répertoires est vide
+69 Répertoire incorrect
 70 Syntaxe: %s [-%s]%s
-71 Pas d'opérande pour l'indicateur -h
+71 Pas d'opérande pour l'indicateur -h
 72 Ce n'est pas un shell de connexion
-73 Division par zéro
-74 Modulo par zéro
-75 Mise à l'échelle incorrecte ; cela signifie-t-il ``%s'' ?
+73 Division par zéro
+74 Modulo par zéro
+75 Mise à l'échelle incorrecte ; cela signifie-t-il ``%s'' ?
 76 Impossible d'interrompre un shell de connexion
 77 Utilisateur inconnu : %s
-78 Pas de variable `$home' définie
-79 Syntaxe: history [-%s] [# nombre d'évènements]
-80 $, ! ou < pas autorisés avec $# or $?
+78 Pas de variable `$home' définie
+79 Syntaxe: history [-%s] [# nombre d'évènements]
+80 $, ! ou < pas autorisés avec $# or $?
 81 Retour-chariot dans un nom de variable
-82 * pas autorisé avec $# or $?
-83 $?<digit> ou $#<digit> pas autorisé
+82 * pas autorisé avec $# or $?
+83 $?<digit> ou $#<digit> pas autorisé
 84 Nom de variable incorrect
 85 Retour-chariot dans l'index de variable
-86 Dépassement de capacité de la mémoire tampon d'expansion
+86 Dépassement de capacité de la mémoire tampon d'expansion
 87 Syntaxe de variable
 88 Forme ! incorrecte
-89 Pas de remplacement précédent
+89 Pas de remplacement précédent
 90 Remplacement incorrect
-91 Pas de partie gauche précédente
+91 Pas de partie gauche précédente
 92 Partie droite trop longue
 93 Modificateur ! incorrect: %c
 94 Echec du modificateur
-95 Dépassement de capacité de la mémoire tampon de substitution
-96 Sélecteur d'argument ! incorrect
-97 Pas de recherche précédente
-98 %s: événement introuvable
-99 Trop de caractères )
-100 Trop de caractères (
-101 Caractère ( mal placé
+95 Dépassement de capacité de la mémoire tampon de substitution
+96 Sélecteur d'argument ! incorrect
+97 Pas de recherche précédente
+98 %s: événement introuvable
+99 Trop de caractères )
+100 Trop de caractères (
+101 Caractère ( mal placé
 102 Il manque un nom pour rediriger
 103 Redirection de sortie ambigue
-104 Pas de << entre les caractères ( et )
-105 Redirection d'entrée ambigue
-106 Caractères () mal placés
+104 Pas de << entre les caractères ( et )
+105 Redirection d'entrée ambigue
+106 Caractères () mal placés
 107 Boucle dans les alias
-108 Pas de variable `$watch' définie
-109 Pas d'évènement prévu
-110 Syntaxe: sched -<#numéro>.\nSyntaxe: sched [+]hh:mm <commande>
-111 Pas tant d'évènements prévus
-112 Pas de commande à lancer
-113 Temps incorrect pour l'évènement
+108 Pas de variable `$watch' définie
+109 Pas d'évènement prévu
+110 Syntaxe: sched -<#numéro>.\nSyntaxe: sched [+]hh:mm <commande>
+111 Pas tant d'évènements prévus
+112 Pas de commande à lancer
+113 Temps incorrect pour l'évènement
 114 Temps relatif incompatible avec am/pm
 115 Pas assez de place pour la chaine termcap
 116 Syntaxe: settc %s [yes|no]
-117 Capacité `%s' inconnue
-118 Paramètre termcap inconnu `%%%c'
+117 Capacité `%s' inconnue
+118 Paramètre termcap inconnu `%%%c'
 119 Trop d'arguments pour `%s' (%d)
-120 `%s' nécessite %d arguments
-121 Syntaxe: echotc [-v|-s] [<capacité> [<args>]]
+120 `%s' nécessite %d arguments
+121 Syntaxe: echotc [-v|-s] [<capacité> [<args>]]
 122 %s: %s. Mauvaise Architecture
 123 !# Boucle dans l'historique
 124 Mauvaise recherche de fichier
-125 Dépassement de capacité de sélecteur
+125 Dépassement de capacité de sélecteur
 126 Option inconnue: `-%s'\nSyntaxe: %s [ -bcdefilmnqstvVxX -Dnom[=valeur] ] [ argument ... ]
 127 Option inconnue: `-%s'\nSyntaxe: %s [ -bcdefFilmnqstvVxX ] [ argument ... ]
 128 Option inconnue: `-%s'\nSyntaxe: %s [ -bcdefilmnqstvVxX ] [ argument ... ]
-129 \nComplément incorrect: "%s"
+129 \nComplément incorrect: "%s"
 130 \n%s incorrect: '%c'
-131 \nIl manque le séparateur '%c' après %s "%s"
+131 \nIl manque le séparateur '%c' après %s "%s"
 132 \n%s incomplet: "%s" 
-133 Pas d'opérande pour l'indicateur -m
+133 Pas d'opérande pour l'indicateur -m
 134 Syntaxe: unlimit [-fh] [limites]
 135 $%S est en lecture seule
 136 Pas de travail de ce type
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/french/set10
--- a/head/contrib/tcsh/nls/french/set10	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/french/set10	Fri Mar 02 16:54:40 2012 +0200
@@ -1,8 +1,8 @@
-$ $tcsh: set10,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set10,v 1.3 2011/02/04 18:19:35 christos Exp $
 $ ma.setp.c
 $set 10 
 1 setpath: commande incorrecte '%s'.\n
 2 setpath: pas assez d'arguments pour la commande '%s'.\n
-3 setpath: donnée manquante dans le chemin '%s'\n
-4 setpath: %s pas trouvé dans %s\n
+3 setpath: donnée manquante dans le chemin '%s'\n
+4 setpath: %s pas trouvé dans %s\n
 5 setpath: %d pas une position correcte dans %s\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/french/set11
--- a/head/contrib/tcsh/nls/french/set11	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/french/set11	Fri Mar 02 16:54:40 2012 +0200
@@ -1,8 +1,8 @@
-$ $tcsh: set11,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set11,v 1.4 2011/02/04 18:19:35 christos Exp $
 $ sh.c
 $set 11 
-1 Attention: pas d'accès au tty (%s).\n
-2 Ainsi pas de contrôle de job dans ce shell.\n
+1 Attention: pas d'accès au tty (%s).\n
+2 Ainsi pas de contrôle de job dans ce shell.\n
 3 Vous avez %d messages courrier (mail).\n
 4 Vous avez %d messages courrier (mail) dans %s.\n
 5 Vous avez du %scourrier.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/french/set12
--- a/head/contrib/tcsh/nls/french/set12	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/french/set12	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set12,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set12,v 1.4 2011/02/04 18:19:35 christos Exp $
 $ sh.dir.c
 $set 12 
-1 %s: Essaie de démarrer à partir de "%s"\n
+1 %s: Essaie de démarrer à partir de "%s"\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/french/set13
--- a/head/contrib/tcsh/nls/french/set13	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/french/set13	Fri Mar 02 16:54:40 2012 +0200
@@ -1,13 +1,13 @@
-$ $tcsh: set13,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set13,v 1.3 2011/02/04 18:19:35 christos Exp $
 $ sh.exec.c
 $set 13 
 1 hash=%-4d dir=%-2d prog=%s\n
 2 %d groupes de hashage de %d bits chacun\n
-3 masque de déboguage = 0x%08x\n
-4 %d réussis, %d manqués, %d%%\n
-5 %S: commande intégrée au shell.\n
-6 %S: Commande pas trouvée.\n
-7 où: / dans la commande n'a pas de sens\n
+3 masque de déboguage = 0x%08x\n
+4 %d réussis, %d manqués, %d%%\n
+5 %S: commande intégrée au shell.\n
+6 %S: Commande pas trouvée.\n
+7 où: / dans la commande n'a pas de sens\n
 8 %S est un alias avec 
-9 %S est intégré(e) au shell\n
-10 hashage manqués: 
+9 %S est intégré(e) au shell\n
+10 hashage manqués: 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/french/set15
--- a/head/contrib/tcsh/nls/french/set15	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/french/set15	Fri Mar 02 16:54:40 2012 +0200
@@ -1,7 +1,7 @@
-$ $tcsh: set15,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set15,v 1.3 2011/02/04 18:19:35 christos Exp $
 $ sh.func.c
 $set 15 
 1 %s: %s: ne peut %s la limite%s\n
 2 enlever
 3 positionner
-4  matérielle
+4  matérielle
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/french/set16
--- a/head/contrib/tcsh/nls/french/set16	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/french/set16	Fri Mar 02 16:54:40 2012 +0200
@@ -1,8 +1,8 @@
-$ $tcsh: set16,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set16,v 1.4 2011/02/04 18:19:35 christos Exp $
 $ sh.lex.c
 $set 16 
-1 Réinitialise le groupe de processus des terminaux de %d à %d\n
-2 \nUtilisez "logout" pour vous déconnecter.\n
+1 Réinitialise le groupe de processus des terminaux de %d à %d\n
+2 \nUtilisez "logout" pour vous déconnecter.\n
 3 \nUtilisez "exit" pour quitter %s.\n
 4 seek to eval %x %x\n
 5 seek to alias %x %x\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/french/set17
--- a/head/contrib/tcsh/nls/french/set17	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/french/set17	Fri Mar 02 16:54:40 2012 +0200
@@ -1,17 +1,17 @@
-$ $tcsh: set17,v 1.4 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set17,v 1.5 2011/02/04 18:19:35 christos Exp $
 $ sh.proc.c
 $set 17 
-1 BUG: attente de travail en tâche de fond !\n
+1 BUG: attente de travail en tâche de fond !\n
 2 Sortie %d\n
-3 BUG: processus vidé deux fois
+3 BUG: processus vidé deux fois
 4 Tourne 
 5 Signal 
 6 Sortie %-25d
 7 Fait
-8 BUG: état=%-9o
+8 BUG: état=%-9o
 9 \040(core dumped)
 10 \040(wd:
 11 wd maintenant: 
-12 %S: Déjà suspendu\n
-13 %S: Déjà arrêté\n
+12 %S: Déjà suspendu\n
+13 %S: Déjà arrêté\n
 14 %S: Badly formed number\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/french/set18
--- a/head/contrib/tcsh/nls/french/set18	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/french/set18	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set18,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set18,v 1.3 2011/02/04 18:19:35 christos Exp $
 $ sh.set.c
 $set 18 
-1 Attention: le PATH exagérément long est tronqué\n
+1 Attention: le PATH exagérément long est tronqué\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/french/set19
--- a/head/contrib/tcsh/nls/french/set19	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/french/set19	Fri Mar 02 16:54:40 2012 +0200
@@ -1,15 +1,23 @@
-$ $tcsh: set19,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set19,v 1.6 2011/02/25 23:58:07 christos Exp $
 $ tc.alloc.c
 $set 19 
-1 nbytes=%d: Plus de mémoire\n
-2 free(%lx) appelé avant allocation.
-3 free(%lx) au delà de la limite memoire.
-4 free(%lx) en deçà de la limite memoire.
+1 nbytes=%d: Plus de mémoire\n
+2 free(%lx) appelé avant allocation.
+3 free(%lx) au delà de la limite memoire.
+4 free(%lx) en deçà de la limite memoire.
 5 free(%lx) mauvais bloc.
 6 free(%lx) limites incorrectes.
 7 free(%lx) index de bloc incorrect.
-8 %s allocation mémoire actuelle:\nfree:\t
-9 \nutilisé:\t
-10 \n\tTotal utilisé: %d, total libre: %d\n
-11 \tMémoire allouée de 0x%lx à 0x%lx.  Limite réelle supérieure à 0x%lx\n
-12 Mémoire allouée de 0x%lx à 0x%lx (%ld).\n
+8 %s allocation mémoire actuelle:\nfree:\t
+9 utilisé
+10 \n\tTotal utilisé: %d, total libre: %d\n
+11 \tMémoire allouée de 0x%lx à 0x%lx.  Limite réelle supérieure à 0x%lx\n
+12 Mémoire allouée de 0x%lx à 0x%lx (%ld).\n
+13 %s current memory allocation:\n
+14 Total space allocated from system: %d\n
+15 Number of non-inuse chunks: %d\n
+16 Number of mmapped regions: %d\n
+17 Total space in mmapped regions: %d\n
+18 Total allocated space: %d\n
+19 Total non-inuse space: %d\n
+20 Top-most, releasable space: %d\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/french/set2
--- a/head/contrib/tcsh/nls/french/set2	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/french/set2	Fri Mar 02 16:54:40 2012 +0200
@@ -1,94 +1,94 @@
-$ $tcsh: set2,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set2,v 1.4 2011/02/04 18:19:35 christos Exp $
 $ Messages Signaux
 $set 2
 1 Signal nul
 2 Interrompu
-3 Arrêté
+3 Arrêté
 4 Sortie
 5 Instruction interdite
-6 Piège Trace/BPT
+6 Piège Trace/BPT
 7 Abandon
-8 Piège IOT
-9 Plantage système imminent
+8 Piège IOT
+9 Plantage système imminent
 10 Sortie erreur
-11 Piège EMT
+11 Piège EMT
 12 Exception de calcul en virgule flottante
-13 Supprimé
+13 Supprimé
 14 Signal utilisateur 1
 15 Signal utilisateur 2
 16 Incident de segmentation
 17 Erreur de bus
 18 Program range error
 19 Operand range error
-20 Appel système incorrect
-21 Tube détruit
+20 Appel système incorrect
+21 Tube détruit
 22 Alarme
-23 Terminé
-24 L'état du fils a changé
+23 Terminé
+24 L'état du fils a changé
 25 Mort du fils
-26 Faute spécifique Apollo
-27 Fils arrêté ou sorti
+26 Faute spécifique Apollo
+27 Fils arrêté ou sorti
 28 Fils sorti
 29 Coupure d'alimentation
 30 Ressource perdue
 31 Break (Ctrl-Break)
 32 Signal d'E-S possible
-33 Entrée-Sortie asynchrone (select)
+33 Entrée-Sortie asynchrone (select)
 34 Condition urgente sur canal d'E-S
-35 Reprise multi-tâche
-36 Terminaison multi-tâche
-37 Achèvement d'E-S asynchrone Fortran
+35 Reprise multi-tâche
+36 Terminaison multi-tâche
+37 Achèvement d'E-S asynchrone Fortran
 38 Reprise
-39 Erreur mémoire irrécupérable
-40 Limite temps CPU dépassée
-41 Arrêt du système imminent
-42 Groupe micro-tasking-pas d'option de réveil définie
+39 Erreur mémoire irrécupérable
+40 Limite temps CPU dépassée
+41 Arrêt du système imminent
+42 Groupe micro-tasking-pas d'option de réveil définie
 43 Erreur de thread - (utilisez cord -T pour plus d'infos)
-44 Erreur de parité de registre du CRAY Y-MP
+44 Erreur de parité de registre du CRAY Y-MP
 45 Demande d'information
 46 Interrompu (Signal)
-47 Stoppé (Signal)
+47 Stoppé (Signal)
 48 Interrompu
-49 Stoppé
+49 Stoppé
 50 Continue
-51 Entrée tty suspendue
-52 Entrée tty arrêtée
+51 Entrée tty suspendue
+52 Entrée tty arrêtée
 53 Sortie tty suspendue
-54 Sortie tty arrêtée
-55 Etat de la fenêtre modifié
-56 Taille de la fenêtre modifiée
-57 Etat du téléphone modifié
-58 Limite temps CPU dépassée
-59 Taille limite de fichier dépassée
+54 Sortie tty arrêtée
+55 Etat de la fenêtre modifié
+56 Taille de la fenêtre modifiée
+57 Etat du téléphone modifié
+58 Limite temps CPU dépassée
+59 Taille limite de fichier dépassée
 60 Signal de l'horloge virtuelle
 61 Signal de profil
 62 Signal DIL
-63 Un évènement à scruter est arrivé
+63 Un évènement à scruter est arrivé
 64 Process's lwps are blocked
 65 Signal Special LWP
 66 Signal Special CPR
 67 Signal Special CPR
-68 Premier signal temps réel
-69 Deuxième signal temps réel
-70 Troisième signal temps réel
-71 Quatrième signal temps réel
-72 Quatrième signal temps réel avant la fin
-73 Antépénultième signal temps réel
-74 Avant-dernier signal temps réel
-75 Dernier signal temps réel
+68 Premier signal temps réel
+69 Deuxième signal temps réel
+70 Troisième signal temps réel
+71 Quatrième signal temps réel
+72 Quatrième signal temps réel avant la fin
+73 Antépénultième signal temps réel
+74 Avant-dernier signal temps réel
+75 Dernier signal temps réel
 76 E-S asynchrone LAN
 77 Lecture/Ecriture PTY disponible
-78 Intervention E-S nécessaire
-79 Mode moniteur HFT accordé
-80 Le mode moniteur HFT doit être abandonné
-81 Le contrôle du son HFT est terminé
-82 Données en buffer circulaire HFT
+78 Intervention E-S nécessaire
+79 Mode moniteur HFT accordé
+80 Le mode moniteur HFT doit être abandonné
+81 Le contrôle du son HFT est terminé
+82 Données en buffer circulaire HFT
 83 Processus de transfert
-84 Touche d'attention sécurisée
-85 Re-séquencement
+84 Touche d'attention sécurisée
+85 Re-séquencement
 86 Signal SS$_DEBUG
-87 Priorité modifiée
-88 detecté
-89 Nouveau caractère d'entrée
+87 Priorité modifiée
+88 detecté
+89 Nouveau caractère d'entrée
 90 Stack limit exceeded
 91 Unused signal
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/french/set20
--- a/head/contrib/tcsh/nls/french/set20	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/french/set20	Fri Mar 02 16:54:40 2012 +0200
@@ -1,41 +1,41 @@
-$ $tcsh: set20,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set20,v 1.3 2011/02/04 18:19:35 christos Exp $
 $ tc.bind.c
 $set 20 
 1 Nom de touche incorrect `%S'\n
 2 Mauvais nom de touche: %S\n
 3 Mauvais nom de commande: %S\n
-4 Mauvaise touche spécifiée %S\n
-5 Chaine nulle spécifiée\n
-6 Définition de touches standard\n
-7 Définition de touches alternatives\n
-8 Définition Multi-caractères\n
-9 Définition des touches de direction\n
-10 %-15s->  n'est pas défini\n
-11 BUG!!! %s n'est lié à rien.\n
+4 Mauvaise touche spécifiée %S\n
+5 Chaine nulle spécifiée\n
+6 Définition de touches standard\n
+7 Définition de touches alternatives\n
+8 Définition Multi-caractères\n
+9 Définition des touches de direction\n
+10 %-15s->  n'est pas défini\n
+11 BUG!!! %s n'est lié à rien.\n
 12 Usage: bindkey [options] [--] [TOUCHE [COMMANDE]]\n
-13     -a   liste ou définit la TOUCHE dans la table des touches alternatives\n
-14     -b   interprète TOUCHE comme un nom de touche C-, M-, F- or X-\n
-15     -s   interprète COMMANDE comme une chaine littérale devant être sortie\n
-16     -c   interprète COMMANDE comme une commande intégrée ou externe\n
-17     -v   redéfinit toutes les touches pour vi\n
-18     -e   redéfinit toutes les touches pour emacs\n
-19     -d   redéfinit toutes les touches pour de l'éditeur par defaut\n
-20     -l   liste les commandes de l'éditeur avec descriptions\n
-21     -r   enlève la correspondance pour la TOUCHE\n
-22     -k   interprète TOUCHE comme un nom de touche de direction symbolique\n
-23     --   force un arrêt dans le traitement de l'option\n
+13     -a   liste ou définit la TOUCHE dans la table des touches alternatives\n
+14     -b   interprète TOUCHE comme un nom de touche C-, M-, F- or X-\n
+15     -s   interprète COMMANDE comme une chaine littérale devant être sortie\n
+16     -c   interprète COMMANDE comme une commande intégrée ou externe\n
+17     -v   redéfinit toutes les touches pour vi\n
+18     -e   redéfinit toutes les touches pour emacs\n
+19     -d   redéfinit toutes les touches pour de l'éditeur par defaut\n
+20     -l   liste les commandes de l'éditeur avec descriptions\n
+21     -r   enlève la correspondance pour la TOUCHE\n
+22     -k   interprète TOUCHE comme un nom de touche de direction symbolique\n
+23     --   force un arrêt dans le traitement de l'option\n
 24     -u   (ou toute option incorrecte) ce message\n
 25 Sans TOUCHE ni COMMANDE, imprime toutes les associations\n
 26 Sans COMMANDE, imprime l'association pour TOUCHE.\n
-27 mauvaise spécification de touche -- chaine nulle\n
-28 mauvaise spécification de touche -- chaine vide\n
-29 mauvaise spécification de touche de fonction.  Touche nulle pas autorisé\n
-30 mauvaise spécification de touche -- nombre hexa mal formé\n
-31 mauvaise spécification de touche -- nombre octal mal formé\n
-32 mauvaise spécification de touche -- nombre décimal mal formé\n
-33 Mauvaise spécification de touche de fonction.\n
-34 Touche nulle pas autorisé\n
-35 Mauvaise spécification de touche -- nom inconnu "%S"\n
+27 mauvaise spécification de touche -- chaine nulle\n
+28 mauvaise spécification de touche -- chaine vide\n
+29 mauvaise spécification de touche de fonction.  Touche nulle pas autorisé\n
+30 mauvaise spécification de touche -- nombre hexa mal formé\n
+31 mauvaise spécification de touche -- nombre octal mal formé\n
+32 mauvaise spécification de touche -- nombre décimal mal formé\n
+33 Mauvaise spécification de touche de fonction.\n
+34 Touche nulle pas autorisé\n
+35 Mauvaise spécification de touche -- nom inconnu "%S"\n
 36 Syntaxe: bind [TOUCHE | COMMANDE TOUCHE | "emacs" | "vi" | "-a"]\n
 37 Fonction incorrecte
-38  %s\t\tn'est pas défini\n
+38  %s\t\tn'est pas défini\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/french/set21
--- a/head/contrib/tcsh/nls/french/set21	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/french/set21	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,5 @@
-$ $tcsh: set21,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set21,v 1.3 2011/02/04 18:19:35 christos Exp $
 $ tc.disc.c
 $set 21 
-1 ne peut obtenir les caractères locaux.\n
-2 ne peut définir les catactères locaux.\n
+1 ne peut obtenir les caractères locaux.\n
+2 ne peut définir les catactères locaux.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/french/set22
--- a/head/contrib/tcsh/nls/french/set22	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/french/set22	Fri Mar 02 16:54:40 2012 +0200
@@ -1,17 +1,17 @@
-$ $tcsh: set22,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set22,v 1.3 2011/02/04 18:19:35 christos Exp $
 $ tc.func.c
 $set 22 
 1 %S: \t a comme alias 
 2 \nMot de passe incorrect pour %s\n
-3 Erreur alias 'precmd' enlevé.\n
-4 Erreur alias 'cwdcmd' enlevé.\n
-5 Erreur alias 'beepcmd' enlevé.\n
-6 Erreur alias 'periodic' enlevé.\n
-7 étude de la ligne de commande\n
+3 Erreur alias 'precmd' enlevé.\n
+4 Erreur alias 'cwdcmd' enlevé.\n
+5 Erreur alias 'beepcmd' enlevé.\n
+6 Erreur alias 'periodic' enlevé.\n
+7 étude de la ligne de commande\n
 8 Voulez vous vraiment supprimer tous les fichiers? [n/y] 
 9 passe la suppression des fichiers!\n
 10 la ligne de commande est maintenant :\n
-11 étude de la ligne de commande\n
+11 étude de la ligne de commande\n
 12 dans une des listes\n
 13 la ligne de commande est maintenant :\n
 14 OoyY
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/french/set23
--- a/head/contrib/tcsh/nls/french/set23	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/french/set23	Fri Mar 02 16:54:40 2012 +0200
@@ -1,17 +1,17 @@
-$ $tcsh: set23,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set23,v 1.4 2011/02/04 18:19:35 christos Exp $
 $ tc.os.c
 $set 23 
 1 Mauvais nom de cpu/site
 2 Chemin du site trop mong
 3 inconnu
 4 site: %s\n
-5 %d: Site pas trouvé\n
+5 %d: Site pas trouvé\n
 6 setlocal: %s: %s\n
-7 Site pas trouvé
-8 Vous êtes piégé dans un univers que vous n'avez jamais créé
-9 Getwarp a échoué
+7 Site pas trouvé
+8 Vous êtes piégé dans un univers que vous n'avez jamais créé
+9 Getwarp a échoué
 10 warp invalide
-11 Setwarp a échoué
+11 Setwarp a échoué
 12 Univers incorrect
 13 Erreur inconnue : %d
 14 sysname:  %s\n
@@ -22,13 +22,13 @@
 19 getwd: Ne peut ouvrir ".." (%s)
 20 getwd: Ne peut effectuer chdir vers ".." (%s)
 21 getwd: Erreur en lecture dans ".." (%s)
-22 getwd: Ne peut revenir à "." (%s)
+22 getwd: Ne peut revenir à "." (%s)
 23 getwd: Ne peut effectuer stat "/" (%s)
 24 getwd: Ne peut effectuer stat "." (%s)
-25 getwd: Ne peut effectuer stat sur répertoire "%s" (%s)
-26 getwd: Ne peut ouvrir le répertoire "%s" (%s)
+25 getwd: Ne peut effectuer stat sur répertoire "%s" (%s)
+26 getwd: Ne peut ouvrir le répertoire "%s" (%s)
 27 getwd: Ne peut trouver "." dans ".." (%s)
-28 Type de système incorrect
-29 Le type de système n'est pas défini
+28 Type de système incorrect
+29 Le type de système n'est pas défini
 30 XXX: Too many arguments 
 31 XXX: Invalid argument
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/french/set25
--- a/head/contrib/tcsh/nls/french/set25	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/french/set25	Fri Mar 02 16:54:40 2012 +0200
@@ -1,6 +1,6 @@
-$ $tcsh: set25,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set25,v 1.3 2011/02/04 18:19:35 christos Exp $
 $ tc.sig.c
 $set 25 
 1 notre attente %d\n
 2 erreur: bsd_signal(%d) signal hors limites\n
-3 erreur: bsd_signal(%d) - sigaction a échoué, errno %d\n
+3 erreur: bsd_signal(%d) - sigaction a échoué, errno %d\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/french/set26
--- a/head/contrib/tcsh/nls/french/set26	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/french/set26	Fri Mar 02 16:54:40 2012 +0200
@@ -1,15 +1,15 @@
-$ $tcsh: set26,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set26,v 1.3 2011/02/04 18:19:35 christos Exp $
 $ tc.who.c
 $set 26 
 1 ne peut effectuer stat %s.  S.V.P effectuez "unset watch".\n
-2 %s ne peut être ouvert.  S.V.P effectuez "unset watch".\n
-3 BUG! le dernier élément n'est pas whotail!\n
-4 arrière: 
-5 BUG! le premier élément n'est pas whohead!\n
+2 %s ne peut être ouvert.  S.V.P effectuez "unset watch".\n
+3 BUG! le dernier élément n'est pas whotail!\n
+4 arrière: 
+5 BUG! le premier élément n'est pas whohead!\n
 6 nouveau: %s/%s\n
 7 %n a %a %l from %m.
 8 %n a %a %l.
-9 connecté
-10 déconnecté
-11 remplacé %s
+9 connecté
+10 déconnecté
+11 remplacé %s
 12 local
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/french/set27
--- a/head/contrib/tcsh/nls/french/set27	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/french/set27	Fri Mar 02 16:54:40 2012 +0200
@@ -1,8 +1,8 @@
-$ $tcsh: set27,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set27,v 1.3 2011/02/04 18:19:35 christos Exp $
 $ tw.comp.c
 $set 27 
 1 commande
-2 séparateur
+2 séparateur
 3 motif
 4 intervalle
-5 complément
+5 complément
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/french/set3
--- a/head/contrib/tcsh/nls/french/set3	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/french/set3	Fri Mar 02 16:54:40 2012 +0200
@@ -1,120 +1,120 @@
-$ $tcsh: set3,v 1.3 2006/03/02 18:46:46 christos Exp $
-$ Description des fonctions éditeur
+$ $tcsh: set3,v 1.4 2011/02/04 18:19:35 christos Exp $
+$ Description des fonctions éditeur
 $set 3 
-1 Recule d'un caractère
-2 Efface le caractère derrière le curseur
-3 Coupe depuis le début du mot jusqu'au curseur - sauvegardé dans le tampon de copie
-4 Coupe depuis le début de la ligne jusqu'au curseur - sauvegardé dans le tampon de copie
-5 Va au début du mot courant
-6 Va au début de la ligne
-7 Met en majuscules les caractères depuis le curseur jusqu'à la fin du mot
-8 Vi change la casse du caractère sous le curseur et avance d'un caractère
-9 Vi change jusqu'à la fin de la ligne
-10 Efface l'écran en laissant la ligne courant au dessus
-11 Complète le mot courant
+1 Recule d'un caractère
+2 Efface le caractère derrière le curseur
+3 Coupe depuis le début du mot jusqu'au curseur - sauvegardé dans le tampon de copie
+4 Coupe depuis le début de la ligne jusqu'au curseur - sauvegardé dans le tampon de copie
+5 Va au début du mot courant
+6 Va au début de la ligne
+7 Met en majuscules les caractères depuis le curseur jusqu'à la fin du mot
+8 Vi change la casse du caractère sous le curseur et avance d'un caractère
+9 Vi change jusqu'à la fin de la ligne
+10 Efface l'écran en laissant la ligne courant au dessus
+11 Complète le mot courant
 12 Tab avance parmi les fichiers
 13 Tab recule parmi les fichiers
-14 Complète le mot courant en ignorant les compléments programmables
+14 Complète le mot courant en ignorant les compléments programmables
 15 Copie le mot courant jusqu'au curseur
 16 Copie la zone entre la marque et le curseur dans le tampon de copie
-17 Développe vers le mot précédent pour lequel c'est un préfixe
-18 Efface le caractère sous le curseur
-19 Efface le caractère sous le curseur, ou signale la fin de fichier si ligne vide
-20 Efface le caractère sous le curseur, ou liste les compléments si fin de ligne
-21 Efface le caractère sous le curseur, liste les compléments ou signale la fin de fichier
-22 Coupe depuis le curseur jusqu'à la fin du mot courant - sauvegardé dans le tampon de copie
-23 Ajoute aux arguments si démarré ou entre le chiffre
-24 Chiffre au début de l'argument
-25 Va à la prochaine ligne de l'historique
-26 Met en minuscules les caractères depuis le curseur jusqu'à la fin du mot
+17 Développe vers le mot précédent pour lequel c'est un préfixe
+18 Efface le caractère sous le curseur
+19 Efface le caractère sous le curseur, ou signale la fin de fichier si ligne vide
+20 Efface le caractère sous le curseur, ou liste les compléments si fin de ligne
+21 Efface le caractère sous le curseur, liste les compléments ou signale la fin de fichier
+22 Coupe depuis le curseur jusqu'à la fin du mot courant - sauvegardé dans le tampon de copie
+23 Ajoute aux arguments si démarré ou entre le chiffre
+24 Chiffre au début de l'argument
+25 Va à la prochaine ligne de l'historique
+26 Met en minuscules les caractères depuis le curseur jusqu'à la fin du mot
 27 Indique la fin de fichier
-28 Déplace le curseur à la fin de la ligne
+28 Déplace le curseur à la fin de la ligne
 29 Echange le curseur et la marque
-30 Développe les jokers du nom de fichier
-31 Développe les échappements de l'historique
-32 Développe les échappements de l'historique en une ligne
-33 Développe les variables
-34 Avance d'un caractère
-35 Avance à la fin du mot courant
-36 Echange les deux caractères avant le curseur
-37 Cherche en arrière dans l'historique une ligne commençant comme la ligne courante
-38 Cherche en avant dans l'historique une ligne commençant comme la ligne courante
-39 Insère le dernier elément de la commande précédente
-40 Recherche en avant incrémentale
-41 Recherche en arrière incrémentale
+30 Développe les jokers du nom de fichier
+31 Développe les échappements de l'historique
+32 Développe les échappements de l'historique en une ligne
+33 Développe les variables
+34 Avance d'un caractère
+35 Avance à la fin du mot courant
+36 Echange les deux caractères avant le curseur
+37 Cherche en arrière dans l'historique une ligne commençant comme la ligne courante
+38 Cherche en avant dans l'historique une ligne commençant comme la ligne courante
+39 Insère le dernier elément de la commande précédente
+40 Recherche en avant incrémentale
+41 Recherche en arrière incrémentale
 42 Efface la ligne
-43 Coupe jusqu'à la fin de la ligne et sauvegarde dans le tampon de copie
+43 Coupe jusqu'à la fin de la ligne et sauvegarde dans le tampon de copie
 44 Coupe la zone entre la marque et le curseur et sauvegarde dans le tampon de copie
 45 Coupe toute la ligne et sauvegarde dans le tampon de copie
-46 Liste les choix pour le complément
-47 Liste les choix pour le complément sur-définissant le complément programmable
+46 Liste les choix pour le complément
+47 Liste les choix pour le complément sur-définissant le complément programmable
 48 Liste les correspondances pour le nom de fichier avec joker
-49 Liste les choix pour le complément ou indique la fin de fichier si ligne vide
-50 Affiche la charge moyenne et l'état courant des processus
-51 Développe les échappements de l'historique et insère une espace
-52 Exécute la commande
-53 Développe les nom de répertoires, éliminant les `.' et `..' en tête
-54 Développe les commandes pour le chemin ou l'alias résultant
+49 Liste les choix pour le complément ou indique la fin de fichier si ligne vide
+50 Affiche la charge moyenne et l'état courant des processus
+51 Développe les échappements de l'historique et insère une espace
+52 Exécute la commande
+53 Développe les nom de répertoires, éliminant les `.' et `..' en tête
+54 Développe les commandes pour le chemin ou l'alias résultant
 55 Passe du mode insertion au mode recouvrement et vice-versa
-56 Ajoute le 8ième bit au prochain caractère saisi
-57 Ajoute le prochain caractère saisi à la ligne 
-58 Réaffiche tout
-59 Redémarre l'éditeur
+56 Ajoute le 8ième bit au prochain caractère saisi
+57 Ajoute le prochain caractère saisi à la ligne 
+58 Réaffiche tout
+59 Redémarre l'éditeur
 60 Cherche de l'aide pour la commande courante
-61 Ce caractère est ajouté à la ligne
-62 Ca caractère est le premier dans une séquence de caractères
-63 Définit la marque à la position du curseur
+61 Ce caractère est ajouté à la ligne
+62 Ca caractère est le premier dans une séquence de caractères
+63 Définit la marque à la position du curseur
 64 Corrige la syntaxe du mot courant
-65 Corrige la syntaxe de la ligne complète
-66 Envoie le caractère au tty en mode 
-67 Bascule la ligne courante de l'historique entre le mode littéral et lexical
-68 Echange le caractère à la gauche du curseur avec celui en dessous du curseur
-69 Echange les deux caractères avant le curseur
-70 Caractère tty de suspension différé
-71 Caractère tty de vidage de sortie
-72 Caractère tty d'interruption
-73 Caractère tty de sortie
-74 Caractère tty de suspension
-75 Caractère tty de validation de sortie
-76 Caractère tty d'invalidation de sortie
-77 Indique un caractère pas attaché
+65 Corrige la syntaxe de la ligne complète
+66 Envoie le caractère au tty en mode 
+67 Bascule la ligne courante de l'historique entre le mode littéral et lexical
+68 Echange le caractère à la gauche du curseur avec celui en dessous du curseur
+69 Echange les deux caractères avant le curseur
+70 Caractère tty de suspension différé
+71 Caractère tty de vidage de sortie
+72 Caractère tty d'interruption
+73 Caractère tty de sortie
+74 Caractère tty de suspension
+75 Caractère tty de validation de sortie
+76 Caractère tty d'invalidation de sortie
+77 Indique un caractère pas attaché
 78 Argument universel Emacs (argument x 4)
-79 Va à la ligne précédente de l'historique
-80 Met en majuscule les caractères depuis le curseur jusqu'à la fin du mot courant
-81 Vi va au début du prochain mot
-82 Vi passe en mode insertion après le curseur
-83 Vi passe en mode insertion à la fin de la ligne
-84 Vi change la casse du caractère sous le curseur et avance d'un caractère
+79 Va à la ligne précédente de l'historique
+80 Met en majuscule les caractères depuis le curseur jusqu'à la fin du mot courant
+81 Vi va au début du prochain mot
+82 Vi passe en mode insertion après le curseur
+83 Vi passe en mode insertion à la fin de la ligne
+84 Vi change la casse du caractère sous le curseur et avance d'un caractère
 85 Vi change la commande `prefix'
-86 Vi change jusqu'à la fin de la ligne
-87 Passe au mode de commande Vi (redéfinition des touches alternatives)
-88 Le mode commande de Vi complète le mot courant
-89 Vi va au caractère précédent (retour-arrière)
+86 Vi change jusqu'à la fin de la ligne
+87 Passe au mode de commande Vi (redéfinition des touches alternatives)
+88 Le mode commande de Vi complète le mot courant
+89 Vi va au caractère précédent (retour-arrière)
 90 Vi efface la commande `prefix'
-91 Vi va à la fin du mot courant délimité par des espaces
-92 Vi va à la fin du mot courant
-93 Vi va vers le caractère spécifié avant
-94 Vi va vers le caractère spécifié après
-95 Vi remonte vers le caractère spécifié avant
-96 Vi remonte vers le caractère spécifié après
+91 Vi va à la fin du mot courant délimité par des espaces
+92 Vi va à la fin du mot courant
+93 Vi va vers le caractère spécifié avant
+94 Vi va vers le caractère spécifié après
+95 Vi remonte vers le caractère spécifié avant
+96 Vi remonte vers le caractère spécifié après
 97 Passe en mode insertion Vi
-98 Passe en mode insertion Vi au début de la ligne
-99 Vi répète la recherche du caractère en cours dans la même direction
-100 Vi répète la recherche du caractère en cours dans la direction opposée
-101 Vi répète la recherche en cours dans la même direction
-102 Vi répète la recherche en cours dans la direction opposée
-103 Vi remplace le caractère sous le curseur avec le prochain caractère saisi
+98 Passe en mode insertion Vi au début de la ligne
+99 Vi répète la recherche du caractère en cours dans la même direction
+100 Vi répète la recherche du caractère en cours dans la direction opposée
+101 Vi répète la recherche en cours dans la même direction
+102 Vi répète la recherche en cours dans la direction opposée
+103 Vi remplace le caractère sous le curseur avec le prochain caractère saisi
 104 Mode de remplacement Vi
-105 Vi cherche dans l'historique en arrière
+105 Vi cherche dans l'historique en arrière
 106 Vi cherche dans l'historique en avant
-107 Vi remplace le caractère sous le curseur et passe en mode insertion
-108 Vi remplace la ligne entière
-109 Vi va au mot précédent
+107 Vi remplace le caractère sous le curseur et passe en mode insertion
+108 Vi remplace la ligne entière
+109 Vi va au mot précédent
 110 Vi va au prochain mot
-111 Vi défait la dernière modification
-112 Vi va au début de la ligne
-113 Exécute quelle commande en cours
-114 Colle le tampon de copie à la position du curseur
+111 Vi défait la dernière modification
+112 Vi va au début de la ligne
+113 Exécute quelle commande en cours
+114 Colle le tampon de copie à la position du curseur
 115 Replace just-yanked text with yank from earlier kill
 116 (WIN32 only) Copy cut buffer to system clipboard
 117 (WIN32 only) Paste clipboard buffer at cursor position
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/french/set30
--- a/head/contrib/tcsh/nls/french/set30	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/french/set30	Fri Mar 02 16:54:40 2012 +0200
@@ -1,16 +1,16 @@
-$ $tcsh: set30,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set30,v 1.4 2011/02/04 18:19:35 christos Exp $
 $ tw.parse.c
 $set 30 
-1 démarre une commande %d\n
+1 démarre une commande %d\n
 2 complete %d 
 3 complete %d %S\n
 4 %s: Erreur interne de correspondance.\n
-5 éléments
+5 éléments
 6 colonnes
-7 Il y a %d %s, les lister quand même ? [n/y] 
+7 Il y a %d %s, les lister quand même ? [n/y] 
 8 looking = %d\n
 9 \nerreur interne %s: Je ne sais pas ce que je recherche !\n
-10 pas un répertoire
-11 pas trouvé
+10 pas un répertoire
+11 pas trouvé
 12 pas lisible
 13 oOyY
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/french/set31
--- a/head/contrib/tcsh/nls/french/set31	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/french/set31	Fri Mar 02 16:54:40 2012 +0200
@@ -1,7 +1,7 @@
-$ $tcsh: set31,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set31,v 1.3 2011/02/04 18:19:35 christos Exp $
 $ vms.termcap.c
 $set 31 
 1 Ne peut ouvrir TERMCAP: [%s]\n
 2 Ne peut ouvrir %s.\n
-3 Trouvé %s dans %s.\n
-4 Pas de correspondance trouvée pour %s dans le fichier %s\n
+3 Trouvé %s dans %s.\n
+4 Pas de correspondance trouvée pour %s dans le fichier %s\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/french/set4
--- a/head/contrib/tcsh/nls/french/set4	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/french/set4	Fri Mar 02 16:54:40 2012 +0200
@@ -1,22 +1,22 @@
-$ $tcsh: set4,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set4,v 1.3 2011/02/04 18:19:35 christos Exp $
 $ Termcap strings
 $set 4
 1 ajoute une nouvelle ligne vide
 2 bip audible
 3 efface jusqu'en bas
-4 efface jusqu'à la fin de la ligne
+4 efface jusqu'à la fin de la ligne
 5 curseur vers un position horizontale
-6 efface l'écran
-7 efface un caractère
+6 efface l'écran
+7 efface un caractère
 8 efface une ligne
 9 commence le mode d'effacement
 10 termine le mode d'effacement
 11 termine le mode d'insertion
-12 curseur de la ligne d'état
+12 curseur de la ligne d'état
 13 curseur origine
-14 insère caractère
+14 insère caractère
 15 commence le mode insertion
-16 insère du remplissage
+16 insère du remplissage
 17 curseur vers le bas
 18 curseur vers la gauche
 19 curseur vers la droite
@@ -24,16 +24,16 @@
 21 commence le gras
 22 fin attributs
 23 espaces non-destructives
-24 fin mise en évidence
-25 commence mise en évidence
-26 curseur à la ligne d'état
+24 fin mise en évidence
+25 commence mise en évidence
+26 curseur à la ligne d'état
 27 curseur d'une vers le haut
-28 commence souligné
-29 fin souligné
+28 commence souligné
+29 fin souligné
 30 bip `visible'
-31 efface plusiseurs caractères
+31 efface plusiseurs caractères
 32 curseur vers le bas (plusieurs)
-33 insert plusieurs caractères
+33 insert plusieurs caractères
 34 curseur vers la gauche (plusieurs)
 35 curseur vers la droite (plusieurs)
 36 curseur vers le haut (plusieurs)
@@ -42,4 +42,4 @@
 39 Nombre de lignes
 40 Nombre de colonnes
 41 A les touches `alternatives'
-42 retoure-chariot ignoré à la droite de la marge
+42 retoure-chariot ignoré à la droite de la marge
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/french/set6
--- a/head/contrib/tcsh/nls/french/set6	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/french/set6	Fri Mar 02 16:54:40 2012 +0200
@@ -1,11 +1,11 @@
-$ $tcsh: set6,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set6,v 1.3 2011/02/04 18:19:35 christos Exp $
 $ ed.inputl.c
 $set 6
 1 ERREUR: commande interdite de la touche 0%o\r\n
 2 oui\n
 3 edit\n
-4 arrête\n
+4 arrête\n
 5 non\n
 6 Pas de commande correspondante\n
 7 Commande ambigue\n
-8 *** ERREUR fatale de l'éditeur ***\r\n\n
+8 *** ERREUR fatale de l'éditeur ***\r\n\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/french/set7
--- a/head/contrib/tcsh/nls/french/set7	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/french/set7	Fri Mar 02 16:54:40 2012 +0200
@@ -1,8 +1,8 @@
-$ $tcsh: set7,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set7,v 1.4 2011/02/04 18:19:36 christos Exp $
 $ ed.screen.c
 $set 7
-1 \n\tTcsh a déterminé que votre terminal a les\n
-2 \tcaractéristiques suivantes :\n\n
+1 \n\tTcsh a déterminé que votre terminal a les\n
+2 \tcaractéristiques suivantes :\n\n
 3 \tIl a %d colonnes et %d lignes\n
 4 \tIl %s touche `alternative'\n
 5 a une
@@ -18,13 +18,13 @@
 15 non
 16 ERREUR: ne peut pas effacer\r\n
 17 DeleteChars: num est ridicule: %d\r\n
-18 ERREUR: ne peut insérer\r\n
+18 ERREUR: ne peut insérer\r\n
 19 StartInsert: num est ridicule: %d\r\n
 20 %s: Ne peut ouvrir /etc/termcap.\n
-21 %s: Pas d'entrée pour le type de terminal "%s"\n
+21 %s: Pas d'entrée pour le type de terminal "%s"\n
 22 %s: utilise la configuration d'un terminal banal.\n
-23 %s: ATTENTION: Votre terminal ne peut effectuer de déplacement vers le haut.\n
-24 L'édition peut être incorrecte pour les longues lignes.\n
-25 pas de capacité d'effacement jusqu'à fin de ligne.\n
-26 pas de capacité d'effacement de caractère.\n
-27 pas de capacité d'insertion de caractère.\n
+23 %s: ATTENTION: Votre terminal ne peut effectuer de déplacement vers le haut.\n
+24 L'édition peut être incorrecte pour les longues lignes.\n
+25 pas de capacité d'effacement jusqu'à fin de ligne.\n
+26 pas de capacité d'effacement de caractère.\n
+27 pas de capacité d'insertion de caractère.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/french/set8
--- a/head/contrib/tcsh/nls/french/set8	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/french/set8	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,5 @@
-$ $tcsh: set8,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set8,v 1.3 2011/02/04 18:19:36 christos Exp $
 $ ed.term.c
 $set 8
-1 Sélecteur inconnu
+1 Sélecteur inconnu
 2 Argument incorrect
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/french/set9
--- a/head/contrib/tcsh/nls/french/set9	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/french/set9	Fri Mar 02 16:54:40 2012 +0200
@@ -1,12 +1,12 @@
-$ $tcsh: set9,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set9,v 1.3 2011/02/04 18:19:36 christos Exp $
 $ ed.xmap.c
 $set 9
-1 AddXkey: touche d'extension nulle pas autorisé.\n
-2 AddXkey: commande séquence d'introduction (sequence-lead-in) pas autorisé\n
-3 DeleteXkey: touche d'extension nulle pas autorisé.\n
-4 Touche d'extension pas définie "%S"\n
+1 AddXkey: touche d'extension nulle pas autorisé.\n
+2 AddXkey: commande séquence d'introduction (sequence-lead-in) pas autorisé\n
+3 DeleteXkey: touche d'extension nulle pas autorisé.\n
+4 Touche d'extension pas définie "%S"\n
 5 Certaines touches d'extension trop longues pour tampon d'impression interne
-6 Enumerate: BUG!! Pointeur Null passé!\n
-7 pas d'entrée
+6 Enumerate: BUG!! Pointeur Null passé!\n
+7 pas d'entrée
 8 Quelque chose doit suivre: %c\n
-9 Une constante Octale ne peut pas tenir dans un caractère.\n
+9 Une constante Octale ne peut pas tenir dans un caractère.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/german/charset
--- a/head/contrib/tcsh/nls/german/charset	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/german/charset	Fri Mar 02 16:54:40 2012 +0200
@@ -1,3 +1,3 @@
-$ codeset=ISO-8859-1
+$ codeset=UTF-8
 $set 255
-1 ISO-8859-1
+1 UTF-8
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/german/set1
--- a/head/contrib/tcsh/nls/german/set1	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/german/set1	Fri Mar 02 16:54:40 2012 +0200
@@ -1,13 +1,13 @@
-$ $tcsh: set1,v 1.6 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set1,v 1.7 2011/02/04 18:19:36 christos Exp $
 $ Error messages
 $set 1
 1 Syntaxfehler
 2 %s nicht erlaubt
 3 Word zu lang
 4 $< Zeile zu lang
-5 Keine Datei für $0
-6 Unvollständiger [] Modifizierer
-7 $ Ausweitung muß vor ] enden
+5 Keine Datei für $0
+6 Unvollständiger [] Modifizierer
+7 $ Ausweitung muß vor ] enden
 8 Falscher : Modifizierer in $ (%c)
 9 Indexfehler
 10 Falsche Nummer
@@ -17,61 +17,61 @@
 14 Befehl nicht gefunden
 15 Zu wenig Argumente
 16 Zu viele Argumente
-17 Zu gefährlich für ein Alias
+17 Zu gefährlich für ein Alias
 18 Leeres If
 19 Unpassendes Then
 20 Worte nicht in Klammern
 21 %s nicht gefunden
 22 Ungeeignete Maske
 23 Keine bekannte Begrenzung
-24 Argument zu groß
-25 Ungeeigneter oder unbekannter Vergrößerungsfaktor
+24 Argument zu groß
+25 Ungeeigneter oder unbekannter Vergrößerungsfaktor
 26 Undefinierte Variable
 27 Verzeichnisstapel nicht so tief
 28 Falscher Signalname
 29 Unbekanntes Signal; kill -l listet Signale auf
-30 Variablenname muß mit einem Buchstaben beginnen
+30 Variablenname muß mit einem Buchstaben beginnen
 31 Variablenname zu lang
-32 Variablenname muß Buchstaben oder Ziffern enthalten
+32 Variablenname muß Buchstaben oder Ziffern enthalten
 33 Keine Jobkontrolle in dieser Shell
 34 Ausdruck nicht korrekt
 35 Kein Startverzeichnis
 36 Kann nicht in das Startverzeichnis wechseln
-37 Ungültiger leerer Befehl
+37 Ungültiger leerer Befehl
 38 Zuweisung ohne Ausdruck
 39 Unbekannter Operator
 40 Mehrdeutig
 41 %s: Datei existiert
-42 Argument für -c endet mit einem Backslash (\\)
+42 Argument für -c endet mit einem Backslash (\\)
 43 Abgebrochen
-44 Index nicht im gültigen Bereich
-45 Zeilenüberlauf
+44 Index nicht im gültigen Bereich
+45 Zeilenüberlauf
 46 Kein solcher Job
 47 Kann nicht vom Terminal
 48 Nicht in while/foreach
 49 Keine Prozesse mehr
 50 Kein Treffer
 51 Fehlendes %c
-52 Überflüssiges %c
+52 Überflüssiges %c
 53 Kein Speicher mehr
 54 Kann keine Pipe erzeugen
 55 %s: %s
 56 %s
 57 Benutzung: jobs [ -l ]
-58 Argumente können Job- oder Prozeß-ID's sein
+58 Argumente können Job- oder Prozeß-ID's sein
 59 Kein aktueller Job
 60 Kein vorhergehender Job
 61 Kein Job entspricht dem Muster
 62 Fork-Ebene > %d; evtl. `...` Schleife?
 63 Keine Jobkontrolle in Unter-Shells
-64 Sync-Fehler: Prozeß %d nicht gefunden
+64 Sync-Fehler: Prozeß %d nicht gefunden
 65 %sEs gibt noch angehaltene Jobs
 66 %sEs gibt noch angehaltene Jobs
 67 Kein anderes Verzeichnis
 68 Verzeichnisstapel leer
-69 Ungültiges Verzeichnis
+69 Ungültiges Verzeichnis
 70 Benutzung: %s [-%s]%s
-71 Kein Operand für -h
+71 Kein Operand für -h
 72 Nicht in einer Login-Shell
 73 Division durch 0
 74 Mod durch 0
@@ -84,9 +84,9 @@
 81 Zeilenumbruch in Variablenname
 82 * nicht erlaubt bei $# or $?
 83 $?<digit> or $#<digit> nicht erlaubt
-84 Ungültiger Variablenname
+84 Ungültiger Variablenname
 85 Zeilenumbruch in Variablenindex
-86 Überlauf des Erweiterungspuffers
+86 Ãœberlauf des Erweiterungspuffers
 87 Variablen-Syntax
 88 Falsche ! Form
 89 Keine vorhergehende Ersetzung
@@ -95,14 +95,14 @@
 92 Rechte Seite zu lang
 93 Falscher ! Modifizierer: %c
 94 Modifizierer fehlgeschlagen
-95 Überlauf des Ersetzungspuffers
+95 Ãœberlauf des Ersetzungspuffers
 96 Falscher ! Argumentbezeichner
 97 Keine vorhergehende Suche
 98 %s: Befehl nicht gefunden
 99 Zu viele ')'
 100 Zu viele '('
 101 Falsch plazierte '('
-102 Fehlender Name für Umlenkung
+102 Fehlender Name für Umlenkung
 103 Mehrdeutige Ausgabeumlenkung
 104 Kann keine << innerhalb von ()
 105 Mehrdeutige Eingabeumlenkung
@@ -112,28 +112,28 @@
 109 Keine vorgemerkten Befehle
 110 Benutzung: sched -<item#>.\nBenutzung: sched [+]hh:mm <Befehl>
 111 Nicht so viele vorgemerkte Befehle
-112 Kein auszuführender Befehl
-113 Ungültige Zeit für Befehl
+112 Kein auszuführender Befehl
+113 Ungültige Zeit für Befehl
 114 Relative Zeit inkonsistent mit am/pm
-115 Kein Platz mehr für Termcap-Eintrag
+115 Kein Platz mehr für Termcap-Eintrag
 116 Benutzung: settc %s [yes|no]
-117 Unbekannte Fähigkeit `%s'
+117 Unbekannte Fähigkeit `%s'
 118 Unbekannter Termcap-Parameter `%%%c'
-119 Zu viele Argumente für `%s' (%d)
+119 Zu viele Argumente für `%s' (%d)
 120 `%s' erfordert %d Argumente
-121 Benutzung: echotc [-v|-s] [<Fähigkeit> [<Argumente>]]
+121 Benutzung: echotc [-v|-s] [<Fähigkeit> [<Argumente>]]
 122 %s: %s. Falsche Architektur
 123 !# History-Schleife
 124 Falsche Dateianforderung
-125 Selector-Überlauf
+125 Selector-Ãœberlauf
 126 Unbekannte Option: `-%s'\nBenutzung: %s [ -bcdefilmnqstvVxX -Dname[=Wert] ] [ Argument ... ]
 127 Unbekannte Option: `-%s'\nBenutzung: %s [ -bcdefFilmnqstvVxX ] [ Argument ... ]
 128 Unbekannte Option: `-%s'\nBenutzung: %s [ -bcdefilmnqstvVxX ] [ Argument ... ]
-129 \nUngültige Vervollständigung: "%s"
-130 \nUngültiger %s: '%c'
+129 \nUngültige Vervollständigung: "%s"
+130 \nUngültiger %s: '%c'
 131 \nFehlende Trennung '%c' nach %s "%s"
-132 \nUnvollständiger/-ges %s: "%s"
-133 Kein Operand für -m Option
+132 \nUnvollständiger/-ges %s: "%s"
+133 Kein Operand für -m Option
 134 Benutzung: unlimit [-fh] [Grenzen]
 135 $%S ist nur lesbar
 136 Kein solcher Job
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/german/set10
--- a/head/contrib/tcsh/nls/german/set10	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/german/set10	Fri Mar 02 16:54:40 2012 +0200
@@ -1,8 +1,8 @@
-$ $tcsh: set10,v 1.5 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set10,v 1.6 2011/02/04 18:19:36 christos Exp $
 $ ma.setp.c
 $set 10
-1 setpath: ungültiger Befehl '%s'.\n
-2 setpath: unzureichende Argumente für Befehl '%s'.\n
+1 setpath: ungültiger Befehl '%s'.\n
+2 setpath: unzureichende Argumente für Befehl '%s'.\n
 3 setpath: Wert fehlt in Pfad '%s'\n
 4 setpath: %s nicht in %s gefunden\n
-5 setpath: %d keine gültige Position in %s\n
+5 setpath: %d keine gültige Position in %s\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/german/set13
--- a/head/contrib/tcsh/nls/german/set13	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/german/set13	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set13,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set13,v 1.4 2011/02/04 18:19:36 christos Exp $
 $ sh.exec.c
 $set 13
 1 hash=%-4d dir=%-2d prog=%s\n
@@ -8,6 +8,6 @@
 5 %S: Befehl in Shell eingebaut.\n
 6 %S: Befehl nicht gefunden.\n
 7 where: / in Befehl ist nicht sinnvoll\n
-8 %S ist ein Alias für 
+8 %S ist ein Alias für 
 9 %S ist ein eingebauter Shell-Befehl\n
 10 Hash-Fehler: 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/german/set15
--- a/head/contrib/tcsh/nls/german/set15	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/german/set15	Fri Mar 02 16:54:40 2012 +0200
@@ -1,7 +1,7 @@
-$ $tcsh: set15,v 1.4 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set15,v 1.5 2011/02/04 18:19:36 christos Exp $
 $ sh.func.c
 $set 15
 1 %s: %s: Kann Begrenzung nicht %s%s\n
-2 löschen
+2 löschen
 3 setzen
 4 \040(hard limit)
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/german/set16
--- a/head/contrib/tcsh/nls/german/set16	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/german/set16	Fri Mar 02 16:54:40 2012 +0200
@@ -1,13 +1,13 @@
-$ $tcsh: set16,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set16,v 1.4 2011/02/04 18:19:36 christos Exp $
 $ sh.lex.c
 $set 16
-1 Setze Prozeßgruppe des Terminals von %d auf %d\n
+1 Setze Prozeßgruppe des Terminals von %d auf %d\n
 2 \nBitte "logout" zum Abmelden benutzen.\n
 3 \nBitte "exit" zum Verlassen der Tcsh benutzen.\n
 4 seek to eval %x %x\n
 5 seek to alias %x %x\n
 6 seek to file %x\n
-7 Falscher Typ für seek: %d\n
+7 Falscher Typ für seek: %d\n
 8 tell eval %x %x\n
 9 tell alias %x %x\n
 10 tell file %x\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/german/set17
--- a/head/contrib/tcsh/nls/german/set17	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/german/set17	Fri Mar 02 16:54:40 2012 +0200
@@ -1,10 +1,10 @@
-$ $tcsh: set17,v 1.5 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set17,v 1.6 2011/02/04 18:19:36 christos Exp $
 $ sh.proc.c
 $set 17
 1 FEHLER: Warte auf Hintergrund-Job!\n
 2 Exitcode %d\n
-3 FEHLER: Prozeß "flushed" zum zweitenmal
-4 Läuft
+3 FEHLER: Prozeß "flushed" zum zweitenmal
+4 Läuft
 5 Signal 
 6 Exitcode %-25d
 7 Fertig
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/german/set18
--- a/head/contrib/tcsh/nls/german/set18	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/german/set18	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set18,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set18,v 1.4 2011/02/04 18:19:36 christos Exp $
 $ sh.set.c
 $set 18
-1 Warnung: lächerlich langer PATH abgeschnitten\n
+1 Warnung: lächerlich langer PATH abgeschnitten\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/german/set19
--- a/head/contrib/tcsh/nls/german/set19	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/german/set19	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set19,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set19,v 1.7 2011/02/25 23:58:07 christos Exp $
 $ tc.alloc.c
 $set 19
 1 nbytes=%d: Out of memory\n
@@ -9,7 +9,15 @@
 6 free(%lx) falscher Bereichs-Check.
 7 free(%lx) falscher Block-Index.
 8 Tcsh's augenblickliche Speicherbelegung:\nfrei:\t
-9 \nbenutzt:\t
+9 benutzt
 10 \n\tInsgesamt in Benutzung: %d, insgesamt frei: %d\n
 11 \tAllokierter Speicher von 0x%lx bis 0x%lx.  Wirklicher Anfang 0x%lx\n
 12 Allokierter Speicher von 0x%lx bis 0x%lx (%ld).\n
+13 Tcsh's augenblickliche Speicherbelegung:\n
+14 Gesamter vom System angeforderter Speicher: %d\n
+15 Anzahl nicht benutzter Blöcke:: %d\n
+16 Anzahl via mmap angeforderter Speicherbereiche: %d\n
+17 Via mmap angeforderter Speicher: %d\n
+18 Gesamter benutzer Speicher im Pool: %d\n
+19 Gesamter freier Speicher im Pool: %d\n
+20 Speicher der freigegeben werden kann: %d\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/german/set2
--- a/head/contrib/tcsh/nls/german/set2	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/german/set2	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set2,v 1.5 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set2,v 1.6 2011/02/04 18:19:36 christos Exp $
 $ Signal names
 $set 2
 1 Null signal
@@ -12,7 +12,7 @@
 9 Systemabsturz steht bevor
 10 Fehlerhaft beendet
 11 EMT trap
-12 Fließkommafehler
+12 Fließkommafehler
 13 Abgebrochen
 14 Benutzersignal 1
 15 Benutzersignal 2
@@ -24,15 +24,15 @@
 21 Ausgabeweitergabe abgebrochen
 22 Alarm clock
 23 Beendet
-24 Kindprozeß hat Zustand geändert
+24 Kindprozeß hat Zustand geändert
 25 Abbruch eines Kindprozesses
 26 Apollo-spezifischer Fehler
-27 Kindprozeß angehalten oder beendet
-28 Kindprozeß beendet
+27 Kindprozeß angehalten oder beendet
+28 Kindprozeß beendet
 29 Stromunterbrechung
 30 Ressource verloren
 31 Unterbrechung (Ctrl-Break)
-32 Mögliches Ein-/Ausgabesignal
+32 Mögliches Ein-/Ausgabesignal
 33 Asynchrone I/O (select)
 34 Dringende Anfrage von Ein-/Ausgabekanal
 35 Multitasking wake-up
@@ -40,7 +40,7 @@
 37 Fortran asynchrones Ein-Ausgabeende
 38 Wiederaufsetzen
 39 Nicht korrigierbarer Speicherfehler
-40 CPU-Zeitbeschränkung überschritten
+40 CPU-Zeitbeschränkung überschritten
 41 Systembeendigung absehbar
 42 micro-tasking group-no wakeup flag set
 43 Thread error - (use cord -T for detailed info)
@@ -55,11 +55,11 @@
 52 Angehalten (Tty-Eingabe)
 53 Angehalten (Tty-Ausgabe)
 54 Angehalten (Tty-Ausgabe)
-55 Fensterzustand hat sich geändert
-56 Fenstergröße hat sich geändert
+55 Fensterzustand hat sich geändert
+56 Fenstergröße hat sich geändert
 57 Phone status changed
-58 CPU-Zeitbeschränkung überschritten
-59 Beschränkung der Dateigröße überschritten
+58 CPU-Zeitbeschränkung überschritten
+59 Beschränkung der Dateigröße überschritten
 60 Virtueller Zeitalarm
 61 Profiling time alarm
 62 DIL signal
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/german/set20
--- a/head/contrib/tcsh/nls/german/set20	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/german/set20	Fri Mar 02 16:54:40 2012 +0200
@@ -1,7 +1,7 @@
-$ $tcsh: set20,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set20,v 1.4 2011/02/04 18:19:36 christos Exp $
 $ tc.bind.c
 $set 20
-1 Ungültiger Tastenname `%S'\n
+1 Ungültiger Tastenname `%S'\n
 2 Falsche Tastenname: %S\n
 3 Falsche Befehlsname: %S\n
 4 Falsche Tastenangabe %S\n
@@ -20,12 +20,12 @@
 17     -v   initialisiere Belegungen mit Standard-Vi-Belegungen\n
 18     -e   initialisiere Belegungen mit Standard-Emacs-Belegungen\n
 19     -d   initialisiere Belegungen mit Standard-Belegungen\n
-20     -l   zeige verfügbare Funktionen mit Beschreibungen an\n
+20     -l   zeige verfügbare Funktionen mit Beschreibungen an\n
 21     -r   entferne Belegung eines Tastes\n
 22     -k   belege Pfeiltaste mit Namen in In-String\n
 23     --   force a break from option processing\n
 24     -u   (or any invalid option) this message\n
-25 Wenn kein Out-String oder Befehl angegeben wurde, wir die Belegung für\n
+25 Wenn kein Out-String oder Befehl angegeben wurde, wir die Belegung für\n
 26 den In-String ausgegeben oder alle Belegungen, falls kein in-String gegeben.\n
 27 Falsche Tastenangabe -- nicht definierte Zeichenkette\n
 28 Falsche Tastenangabe -- leere Zeichenkette\n
@@ -37,5 +37,5 @@
 34 Leere Taste nicht erlaubt\n
 35 Falsche Tastenangabe -- unbeannter Name "%S"\n
 36 Benutzung: bind [TASTE | BEFEHL TASTE | "emacs" | "vi" | "-a"]\n
-37 Ungültige Funktion
+37 Ungültige Funktion
 38  %s\t\tist undefiniert\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/german/set22
--- a/head/contrib/tcsh/nls/german/set22	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/german/set22	Fri Mar 02 16:54:40 2012 +0200
@@ -1,15 +1,15 @@
-$ $tcsh: set22,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set22,v 1.4 2011/02/04 18:19:36 christos Exp $
 $ tc.func.c
 $set 22
-1 %S: \t ein Alias für 
-2 \nPasswort nicht korrekt für %s\n
+1 %S: \t ein Alias für 
+2 \nPasswort nicht korrekt für %s\n
 3 Fehlerhafter Alias 'precmd' entfernt.\n
 4 Fehlerhafter Alias 'cwdcmd' entfernt.\n
 5 Fehlerhafter Alias 'beepcmd' entfernt.\n
 6 Fehlerhafter Alias 'periodic' entfernt.\n
 7 zerteile Kommandozeile\n
-8 Wollen Sie wirklich alle Dateien löschen? [n/j] 
-9 Übergehe das Löschen der Dateien!\n
+8 Wollen Sie wirklich alle Dateien löschen? [n/j] 
+9 Übergehe das Löschen der Dateien!\n
 10 Kommandozeile ist nun:\n
 11 zerteile Kommandozeile\n
 12 in einer der Listen\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/german/set23
--- a/head/contrib/tcsh/nls/german/set23	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/german/set23	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set23,v 1.4 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set23,v 1.5 2011/02/04 18:19:36 christos Exp $
 $ tc.os.c
 $set 23
 1 Falscher Cpu/Site-Name
@@ -8,27 +8,27 @@
 5 %d: Site nicht gefunden\n
 6 setlocal: %s: %s\n
 7 Site nicht gefunden
-8 Sie sind in einem Universum gefangen, daß Sie nie gemacht haben
+8 Sie sind in einem Universum gefangen, daß Sie nie gemacht haben
 9 Getwarp fehlgeschlagen
-10 Ungültiger Warp
+10 Ungültiger Warp
 11 Setwarp fehlgeschlagen
-12 Ungültiges Universum
+12 Ungültiges Universum
 13 Unbekannter Fehler: %d
 14 sysname:  %s\n
 15 nodename: %s\n
 16 release:  %s\n
 17 version:  %s\n
 18 machine:  %s\n
-19 getwd: Kann ".." nicht öffnen (%s)
+19 getwd: Kann ".." nicht öffnen (%s)
 20 getwd: Kann nicht in ".." wechseln (%s)
 21 getwd: Lesefehler in ".." (%s)
-22 getwd: Kann nicht zurück zu "." wechseln (%s)
+22 getwd: Kann nicht zurück zu "." wechseln (%s)
 23 getwd: Kann kein stat auf "/" machen (%s)
 24 getwd: Kann kein stat auf "." machen (%s)
 25 getwd: Kann kein stat auf Verzeichnis "%s" machen (%s)
-26 getwd: Kann Verzeichnis "%s" nicht öffnen (%s)
+26 getwd: Kann Verzeichnis "%s" nicht öffnen (%s)
 27 getwd: Kann "." nicht in ".." finden (%s)
-28 Ungültiger Systemtyp
+28 Ungültiger Systemtyp
 29 Systemtyp ist nicht gesetzt
 30 Too many arguments
 31 Invalid argument
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/german/set25
--- a/head/contrib/tcsh/nls/german/set25	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/german/set25	Fri Mar 02 16:54:40 2012 +0200
@@ -1,6 +1,6 @@
-$ $tcsh: set25,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set25,v 1.4 2011/02/04 18:19:36 christos Exp $
 $ tc.sig.c
 $set 25
 1 unser wait %d\n
-2 Fehler: bsd_signal(%d) Signal außerhalb der Grenzen\n
+2 Fehler: bsd_signal(%d) Signal außerhalb der Grenzen\n
 3 Fehler: bsd_signal(%d) - sigaction fehlerhaft, errno %d\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/german/set26
--- a/head/contrib/tcsh/nls/german/set26	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/german/set26	Fri Mar 02 16:54:40 2012 +0200
@@ -1,10 +1,10 @@
-$ $tcsh: set26,v 1.4 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set26,v 1.5 2011/02/04 18:19:36 christos Exp $
 $ tc.who.c
 $set 26
 1 Kein Zugriff auf %s.  Bitte "unset watch" eingeben.\n
-2 %s kann nicht geöffnet werden.  Bitte "unset watch" eingeben.\n
+2 %s kann nicht geöffnet werden.  Bitte "unset watch" eingeben.\n
 3 FEHLER! letztes Element ist nicht whotail!\n
-4 Zurück: 
+4 Zurück: 
 5 FEHLER! erstes Element ist nicht whohead!\n
 6 neu: %s/%s\n
 7 %n hat %a an %l von %m.
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/german/set27
--- a/head/contrib/tcsh/nls/german/set27	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/german/set27	Fri Mar 02 16:54:40 2012 +0200
@@ -1,8 +1,8 @@
-$ $tcsh: set27,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set27,v 1.4 2011/02/04 18:19:36 christos Exp $
 $ tw.comp.c
 $set 27
 1 Befehl
 2 Trenner
 3 Muster
 4 Bereichs
-5 Vervollständigung
+5 Vervollständigung
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/german/set29
--- a/head/contrib/tcsh/nls/german/set29	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/german/set29	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set29,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set29,v 1.4 2011/02/04 18:19:36 christos Exp $
 $ tw.help.c
 $set 29
-1 Keine Hilfe-Datei für %S\n
+1 Keine Hilfe-Datei für %S\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/german/set3
--- a/head/contrib/tcsh/nls/german/set3	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/german/set3	Fri Mar 02 16:54:40 2012 +0200
@@ -1,31 +1,31 @@
-$ $tcsh: set3,v 1.6 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set3,v 1.7 2011/02/04 18:19:36 christos Exp $
 $ Editor function descriptions
 $set 3
-1 Ein Zeichen zurück
-2 Lösche Zeichen hinter Cursor
-3 Lösche vom Anfang des aktuellen Worts bis zum Cursor - in Cut-Puffer
-4 Lösche vom Anfang der Zeile bis zum Cursor - in Cut-Puffer
+1 Ein Zeichen zurück
+2 Lösche Zeichen hinter Cursor
+3 Lösche vom Anfang des aktuellen Worts bis zum Cursor - in Cut-Puffer
+4 Lösche vom Anfang der Zeile bis zum Cursor - in Cut-Puffer
 5 Gehe an den Anfang des aktuellen Worts
 6 Gehe zum Anfang der Zeile
-7 Wandele vom Cursor bis zum Ende des aktuellen Worts in Großbuchstaben um
-8 Vi: Ändere Groß/Kleinschreibung des Zeichen unter dem Cursor und bewege Cursor eins nach vorn
-9 Vi: Ändere bis zum Ende der Zeile
-10 Lösche Bildschirm (aktuelle Zeile oben)
-11 Vervollständige aktuelles Wort
-12 Gehe mit Tab vorwärts durch die Dateiliste
-13 Gehe mit Tab rückwärts durch die Dateiliste
-14 Vervollständige Wort (ignoriere programmierbare Vervollständigungen)
+7 Wandele vom Cursor bis zum Ende des aktuellen Worts in Großbuchstaben um
+8 Vi: Ändere Groß/Kleinschreibung des Zeichen unter dem Cursor und bewege Cursor eins nach vorn
+9 Vi: Ändere bis zum Ende der Zeile
+10 Lösche Bildschirm (aktuelle Zeile oben)
+11 Vervollständige aktuelles Wort
+12 Gehe mit Tab vorwärts durch die Dateiliste
+13 Gehe mit Tab rückwärts durch die Dateiliste
+14 Vervollständige Wort (ignoriere programmierbare Vervollständigungen)
 15 Kopiere aktuelles Wort zum Cursor
 16 Kopiere Area zwischen Marke und Cursor in Cut-Puffer
-17 Erweitere zu früherem Wort für das dies ein Anfang ist
-18 Lösche Zeichen unter Cursor
-19 Lösche Zeichen unter Cursor oder gib EOF-Signal am Ende der Zeile
-20 Lösche Zeichen unter Cursor oder zeige Vervollständigungen am Ende der Zeile an
-21 Lösche Zeichen unter Cursor oder zeige Vervollständigungen oder gib EOF-Signal
-22 Lösche von Cursor bis zum Ende des aktuellen Worts - in Cut-Puffer
-23 Füge Argument hinzu, wenn gestartet, oder gib zahl ein
+17 Erweitere zu früherem Wort für das dies ein Anfang ist
+18 Lösche Zeichen unter Cursor
+19 Lösche Zeichen unter Cursor oder gib EOF-Signal am Ende der Zeile
+20 Lösche Zeichen unter Cursor oder zeige Vervollständigungen am Ende der Zeile an
+21 Lösche Zeichen unter Cursor oder zeige Vervollständigungen oder gib EOF-Signal
+22 Lösche von Cursor bis zum Ende des aktuellen Worts - in Cut-Puffer
+23 Füge Argument hinzu, wenn gestartet, oder gib zahl ein
 24 Ziffer, die ein Argument beginnt
-25 Gehe zur nächsten History-Zeile
+25 Gehe zur nächsten History-Zeile
 26 Wandele vom Cursor bis zum Ende des aktuellen Worts in Kleinbuchstaben um
 27 Melde Ende der Datei
 28 Gehe zum Ende der Zeile
@@ -37,31 +37,31 @@
 34 Gehe ein Zeichen vor
 35 Gehe vor bis zum Ende des akutellen Worts
 36 Vertausche zwei Zeichen vor dem Cursor
-37 Suche rückwärts in History nach Zeile mit gleichem Anfang
-38 Suche vorwärts in History nach Zeile mit gleichem Anfang
+37 Suche rückwärts in History nach Zeile mit gleichem Anfang
+38 Suche vorwärts in History nach Zeile mit gleichem Anfang
 39 Setze letzten Teil des vorherigen Befehls ein
-40 Incrementelle Suche (vorwärts)
-41 Incrementelle Suche (rückwärts)
-42 Lösche Zeile
-43 Lösche bis zum Ende der Zeile - in Cut-Puffer
-44 Lösche Area zwischen Marke und Cursor - in Cut-Puffer
-45 Lösche gesamte Zeile - in Cut-Puffer
-46 Zeige Möglichkeiten der Vervollständigung
-47 Zeige Möglichkeiten der Vervollständigung (ignoriere programmierbare Vervollständigungen)
+40 Incrementelle Suche (vorwärts)
+41 Incrementelle Suche (rückwärts)
+42 Lösche Zeile
+43 Lösche bis zum Ende der Zeile - in Cut-Puffer
+44 Lösche Area zwischen Marke und Cursor - in Cut-Puffer
+45 Lösche gesamte Zeile - in Cut-Puffer
+46 Zeige Möglichkeiten der Vervollständigung
+47 Zeige Möglichkeiten der Vervollständigung (ignoriere programmierbare Vervollständigungen)
 48 Zeige Treffer der Dateinamen-Wildcards
-49 Zeige Möglichkeiten der Vervollständigung oder gib EOF, falls Zeile leer
-50 Zeige durchschnittliche Last und augenblickl. Prozeßzustand
-51 Expandiere History-Escape und füge Leerzeichen ein
-52 Führe Befehl aus
-53 Expandiere Pfadnamen, eliminiere führende . und ..
+49 Zeige Möglichkeiten der Vervollständigung oder gib EOF, falls Zeile leer
+50 Zeige durchschnittliche Last und augenblickl. Prozeßzustand
+51 Expandiere History-Escape und füge Leerzeichen ein
+52 Führe Befehl aus
+53 Expandiere Pfadnamen, eliminiere führende . und ..
 54 Expandiere Befehle in den entsprechenden Pfadnamen oder Alias
-55 Schalte von Insert- auf Einfügemodus oder umgekehrt
-56 Füge das achte Bit zu dem nächsten eingegebenen Zeichen hinzu
-57 Füge das nächste Eingabezeichen unverändert ein
+55 Schalte von Insert- auf Einfügemodus oder umgekehrt
+56 Füge das achte Bit zu dem nächsten eingegebenen Zeichen hinzu
+57 Füge das nächste Eingabezeichen unverändert ein
 58 Baue Anzeige neu auf
 59 Starte angehaltenen Editor wieder
-60 Suche nach Hilfe für den aktuellen Befehl
-61 Dieses Zeichen wird zur Zeile hinzugefügt
+60 Suche nach Hilfe für den aktuellen Befehl
+61 Dieses Zeichen wird zur Zeile hinzugefügt
 62 Dieses Zeichen ist das erste einer Folge von Zeichen
 63 Setze die Marke an der Stelle des Cursors
 64 Korrigiere die Schreibweise des aktuellen Wortes
@@ -80,41 +80,41 @@
 77 Indicates unbound Zeichen
 78 Emacs universelles Argument (Argument mal 4)
 79 Gehe zur vorhergehenden History-Zeile
-80 Wandele die Zeichen vom Cursor bis zum Ende des akt. Worts in Großbuchst. um
-81 Vi gehe zum Anfang des nächsten Wortes
-82 Vi gehe in Einfügemodus hinter dem Cursor
-83 Vi gehe in Einfügemodus am Ende der Zeile
-84 Vi ändere Groß/Kleinschreibung des Zeichens unter dem Cursor und gehe ien vor
-85 Vi ändere Prefix-Befehl
-86 Vi ändere bis zum Ende der Zeile
+80 Wandele die Zeichen vom Cursor bis zum Ende des akt. Worts in Großbuchst. um
+81 Vi gehe zum Anfang des nächsten Wortes
+82 Vi gehe in Einfügemodus hinter dem Cursor
+83 Vi gehe in Einfügemodus am Ende der Zeile
+84 Vi ändere Groß/Kleinschreibung des Zeichens unter dem Cursor und gehe ien vor
+85 Vi ändere Prefix-Befehl
+86 Vi ändere bis zum Ende der Zeile
 87 Vi gehe in Befehlsmodus (benutze alternative Tastenbelegung)
-88 Vi Befehlsmodus vervollständige aktuelles Wort
+88 Vi Befehlsmodus vervollständige aktuelles Wort
 89 Vi gehe zum vorhergehenden Zeichen (Backspace)
-90 Vi lösche Prefix-Befehl
+90 Vi lösche Prefix-Befehl
 91 Vi gehe zum Ende des aktuellen Worts (durch Leerzeichen begrenzt)
 92 Vi gehe zum Ende des aktuellen Worts
-93 Vi gehe zum angegebenen Zeichen rückwärts
-94 Vi gehe zum angegebenen Zeichen vorwärts
-95 Vi gehe hoch zum angegebenen Zeichen rückwärts
-96 Vi gehe hoch zum angegebenen Zeichen vorwärts
-97 Vi gehe in Einfügemodus
-98 Vi gehe in Einfügemodus am Anfang der Zeile
+93 Vi gehe zum angegebenen Zeichen rückwärts
+94 Vi gehe zum angegebenen Zeichen vorwärts
+95 Vi gehe hoch zum angegebenen Zeichen rückwärts
+96 Vi gehe hoch zum angegebenen Zeichen vorwärts
+97 Vi gehe in Einfügemodus
+98 Vi gehe in Einfügemodus am Anfang der Zeile
 99 Vi wiederhole aktuelle Suche in dieselbe Richtung
 100 Vi wiederhole aktuelle Suche in entgegengesetzte Richtung
 101 Vi wiederhole aktuelle Suche in dieselbe Richtung
 102 Vi wiederhole aktuelle Suche in entgegengesetzte Richtung
-103 Vi ersetze Zeichen unter dem Cursor mit dem nächsten eingegebenen Zeichen
+103 Vi ersetze Zeichen unter dem Cursor mit dem nächsten eingegebenen Zeichen
 104 Vi Ersetzungsmodus
-105 Vi suche History vorwärts
-106 Vi suche History rückwärts
-107 Vi ersetze Zeichen unter dem Cursor und gehe in Einfügemodus
+105 Vi suche History vorwärts
+106 Vi suche History rückwärts
+107 Vi ersetze Zeichen unter dem Cursor und gehe in Einfügemodus
 108 Vi ersetze gesamte Zeile
 109 Vi gehe zum verhergehenden Wort
-110 Vi gehe zum nächsten Wort
-111 Vi mache letzte Änderung rückgängig
+110 Vi gehe zum nächsten Wort
+111 Vi mache letzte Änderung rückgängig
 112 Vi gehe zum Anfang der Zeile
 113 Mache ein 'which' von dem aktuellen Befehl
-114 Füge den Cut-Puffer an der Cursor-Position ein
+114 Füge den Cut-Puffer an der Cursor-Position ein
 115 Replace just-yanked text with yank from earlier kill
 116 (WIN32 only) Copy cut buffer to system clipboard
 117 (WIN32 only) Paste clipboard buffer at cursor position
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/german/set30
--- a/head/contrib/tcsh/nls/german/set30	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/german/set30	Fri Mar 02 16:54:40 2012 +0200
@@ -1,15 +1,15 @@
-$ $tcsh: set30,v 1.4 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set30,v 1.5 2011/02/04 18:19:37 christos Exp $
 $ tw.parse.c
 $set 30
 1 Anfangsbefehl %d\n
-2 vervollständige %d 
-3 vervollständige %d %S\n
+2 vervollständige %d 
+3 vervollständige %d %S\n
 4 %s: Interner Abgleichsfehler.\n
 5 Objekte
 6 Spalten
 7 Es gibt %d %s, trotzdem anzeigen? [n/j] 
 8 looking = %d\n
-9 \n%s interner Fehler: Ich weiß nicht, wonach ich suche!\n
+9 \n%s interner Fehler: Ich weiß nicht, wonach ich suche!\n
 10 kein Verzeichnis
 11 nicht gefunden
 12 nicht lesbar
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/german/set31
--- a/head/contrib/tcsh/nls/german/set31	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/german/set31	Fri Mar 02 16:54:40 2012 +0200
@@ -1,7 +1,7 @@
-$ $tcsh: set31,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set31,v 1.4 2011/02/04 18:19:37 christos Exp $
 $ vms.termcap.c
 $set 31
-1 Kann TERMCAP nicht öffnen: [%s]\n
-2 Kann %s nicht öffnen.\n
+1 Kann TERMCAP nicht öffnen: [%s]\n
+2 Kann %s nicht öffnen.\n
 3 Fand %s in %s.\n
-4 Kein Eintrag für %s in Datei %s gefunden\n
+4 Kein Eintrag für %s in Datei %s gefunden\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/german/set4
--- a/head/contrib/tcsh/nls/german/set4	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/german/set4	Fri Mar 02 16:54:40 2012 +0200
@@ -1,29 +1,29 @@
-$ $tcsh: set4,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set4,v 1.4 2011/02/04 18:19:37 christos Exp $
 $ Termcap strings
 $set 4 
-1 füge neue, leere Zeile hinzu
-2 hörbare Pieps
-3 lösche bis zum Ende der Anzeige
-4 lösche bis zum Ende der Zeile
+1 füge neue, leere Zeile hinzu
+2 hörbare Pieps
+3 lösche bis zum Ende der Anzeige
+4 lösche bis zum Ende der Zeile
 5 Cursor zu horizontaler Position
-6 lösche Bildschirm
-7 lösche ein Zeichen
-8 lösche eine Zeile
-9 starte Löschemodus
-10 beende Löschmodus
-11 beende Einfügemodus
+6 lösche Bildschirm
+7 lösche ein Zeichen
+8 lösche eine Zeile
+9 starte Löschemodus
+10 beende Löschmodus
+11 beende Einfügemodus
 12 Cursor aus Statuszeile
 13 Cursor in Ursprungsposition
-14 füge Zeichen ein
-15 starte Einfügemodus
-16 setze Füllzeichen ein
+14 füge Zeichen ein
+15 starte Einfügemodus
+16 setze Füllzeichen ein
 17 Cursor nach unten
 18 Cursor nach links
 19 Cursor nach rechts
 20 Cursor nach oben
 21 starte Fettschrift
 22 beende Attribute
-23 nicht zerstörendes Leerzeichen
+23 nicht zerstörendes Leerzeichen
 24 beende hervorgehobene Darstellung
 25 beginne hervorgehobene Darstellung
 26 Cursor in Statuszeile
@@ -31,13 +31,13 @@
 28 beginne Unterstreichung
 29 beende Unterstreichung
 30 sichtbarer Pieps
-31 lösche mehrere Zeichen
+31 lösche mehrere Zeichen
 32 Cursor mehrere Zeichen nach unten
-33 füge mehrere Zeichen ein
+33 füge mehrere Zeichen ein
 34 Cursor mehrere Zeichen nach links
 35 Cursor mehrere Zeichen nach rechts
 36 Cursor mehrere Zeichen nach oben
-37 hat automatische Ränder
+37 hat automatische Ränder
 38 kann physikalische Tabulatoren benutzen
 39 Anzahl Zeilen
 40 Anzahl Spalten
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/german/set5
--- a/head/contrib/tcsh/nls/german/set5	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/german/set5	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set5,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set5,v 1.4 2011/02/04 18:19:37 christos Exp $
 $ ed.chared.c
 $set 5
-1 Durchschnittliche Last nicht verfügbar\n
+1 Durchschnittliche Last nicht verfügbar\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/german/set6
--- a/head/contrib/tcsh/nls/german/set6	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/german/set6	Fri Mar 02 16:54:40 2012 +0200
@@ -1,10 +1,10 @@
-$ $tcsh: set6,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set6,v 1.4 2011/02/10 00:13:36 christos Exp $
 $ ed.inputl.c
 $set 6
 1 FEHLER: Illegaler Befehl von Taste 0%o\r\n
 2 ja\n
-3 ediere\n
-4 brich ab\n
+3 editieren\n
+4 abbrechen\n
 5 nein\n
 6 Kein entsprechender Befehl\n
 7 Mehrdeutiger Befehl\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/german/set7
--- a/head/contrib/tcsh/nls/german/set7	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/german/set7	Fri Mar 02 16:54:40 2012 +0200
@@ -1,7 +1,7 @@
-$ $tcsh: set7,v 1.5 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set7,v 1.6 2011/02/04 18:19:37 christos Exp $
 $ ed.screen.c
 $set 7
-1 \n\tTcsh meint, Ihr Endgerät hat die\n
+1 \n\tTcsh meint, Ihr Endgerät hat die\n
 2 \tfolgenden Eigenschaften:\n\n
 3 \tEs hat %d Spalten und %d Zeilen\n
 4 \tEs hat %s Meta-Taste\n
@@ -9,22 +9,22 @@
 6 keine
 7 \tEs kann%s Tabulatoren benutzen\n
 8 \040keine
-9 \tEs %s automatische Ränder\n
+9 \tEs %s automatische Ränder\n
 10 hat
 11 hat nicht
-12 \tEs %s magische Ränder\n
+12 \tEs %s magische Ränder\n
 13 (leer)
 14 ja
 15 nein
-16 FEHLER: kann nicht löschen\r\n
-17 DeleteChars: num ist lächerlich: %d\r\n
-18 FEHLER: kann nicht einfügen\r\n
-19 StartInsert: num ist lächerlich: %d\r\n
-20 %s: Kann /etc/termcap nicht öffnen.\n
-21 %s: Kein Eintrag für Terminaltyp "%s"\n
+16 FEHLER: kann nicht löschen\r\n
+17 DeleteChars: num ist lächerlich: %d\r\n
+18 FEHLER: kann nicht einfügen\r\n
+19 StartInsert: num ist lächerlich: %d\r\n
+20 %s: Kann /etc/termcap nicht öffnen.\n
+21 %s: Kein Eintrag für Terminaltyp "%s"\n
 22 %s: benutze minimale Terminaleigenschaften.\n
-23 %s: WARNUNG: Ihr Terminal kann den Cursor nicht aufwärts bewegen.\n
-24 Lange Zeilen könnten etwas komisch aussehen.\n
-25 keine Fähigkeit, bis Zeilenende zu löschen.\n
-26 keine Fähigkeit, Zeichen zu löschen.\n
-27 keine Fähigkeit, Zeichen einzufügen.\n
+23 %s: WARNUNG: Ihr Terminal kann den Cursor nicht aufwärts bewegen.\n
+24 Lange Zeilen könnten etwas komisch aussehen.\n
+25 keine Fähigkeit, bis Zeilenende zu löschen.\n
+26 keine Fähigkeit, Zeichen zu löschen.\n
+27 keine Fähigkeit, Zeichen einzufügen.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/german/set8
--- a/head/contrib/tcsh/nls/german/set8	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/german/set8	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,5 @@
-$ $tcsh: set8,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set8,v 1.4 2011/02/04 18:19:37 christos Exp $
 $ ed.term.c
 $set 8
 1 Unbekannter Schalter
-2 Ungültiges Argument
+2 Ungültiges Argument
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/german/set9
--- a/head/contrib/tcsh/nls/german/set9	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/german/set9	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set9,v 1.4 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set9,v 1.5 2011/02/04 18:19:37 christos Exp $
 $ ed.xmap.c
 $set 9
 1 AddXkey: Null extended-key not allowed.\n
@@ -8,5 +8,5 @@
 5 Some extended keys too long for internal print buffer
 6 Enumerate: BUG!! Null ptr passed\n!
 7 keine Eingabe
-8 Es muß noch etwas folgen: %c\n
-9 Oktal-Konstante paßt nicht in ein Zeichen.\n
+8 Es muß noch etwas folgen: %c\n
+9 Oktal-Konstante paßt nicht in ein Zeichen.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/charset
--- a/head/contrib/tcsh/nls/greek/charset	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/charset	Fri Mar 02 16:54:40 2012 +0200
@@ -1,3 +1,3 @@
-$ codeset=ISO-8859-7
+$ codeset=UTF-8
 $set 255
-1 ISO-8859-7
+1 UTF-8
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/set1
--- a/head/contrib/tcsh/nls/greek/set1	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/set1	Fri Mar 02 16:54:40 2012 +0200
@@ -1,140 +1,140 @@
-$ $tcsh: set1,v 1.4 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set1,v 1.5 2011/02/04 18:19:37 christos Exp $
 $ Error messages
 $set 1 
-1 ËÜèïò óýíôáîç
-2 Tï %s äåí åðéôñÝðåôáé
-3 ÕðåñâïëéêÜ ìåãÜëç ëÝîç
-4 $< ÕðåñâïëéêÜ ìåãÜëç ãñáììÞ
-5 Äåí õðÜñ÷åé áñ÷åßï ãéÜ ôï $0
-6 ÅëëéðÞò ìåôáôñïðÝáò []
-7 Ç áíÜðôõîç ôïõ $ ðñÝðåé íá ôåëåéþíåé ðñéí ôï ]
-8 ËÜèïò ìåôáôñïðÝáò : óôï $ (%c)
-9 ËÜèïò üñéóìá
-10 Êáêïó÷çìáôéóìÝíïò áñéèìüò
-11 Äåí õðÜñ÷ïõí Üëëåò ëÝîåéò
-12 Áðüí üíïìá áñ÷åßïõ
-13 Åóùôåñéêü ëÜèïò globbing
-14 Ç åíôïëÞ äå âñÝèçêå
-15 ÕðåñâïëéêÜ ëßãá ïñßóìáôá
-16 ÕðåñâïëéêÜ ðïëëÜ ïñßóìáôá
-17 ÕðåñâïëéêÜ åðéêßíäõíï øåõäþíõìï
-18 Áäåéï if
-19 ÁêáôÜëëçëï then
-20 Ïé ëÝîåéò äåí åßíáé åíôüò ðáñåíèÝóåùí
-21 Tï %s äåí âñÝèçêå
-22 ÁêáôÜëëçëç ìÜóêá
-23 Äåí õðÜñ÷åé ôÝôïéï üñéï
-24 ÕðåñâïëéêÜ ìåãÜëï üñéóìá
-25 ÁêáôÜëëçëïò Þ Üãíùóôïò ðáñÜãïíôáò ìåãÝèïõò
-26 Ìç ïñéóìÝíç ìåôáâëçôÞ
-27 Tï stack êáôáëüãùí äåí åßíáé ôüóï âáèý
-28 ËÜèïò áñéèìüò signal
-29 ¶ãíùóôï signal·äþóôå kill -l ãéÜ ëßóôá signals
-30 Tá ïíüìáôá ìåôáâëçôþí ðñÝðåé íá áñ÷ßæïõí ìå ãñÜììá
-31 ÕðåñâïëéêÜ ìåãÜëï üíïìá ìåôáâëçôÞò
-32 Tá ïíüìáôá ìåôáâëçôþí ðñÝðåé íá ðåñéÝ÷ïõí áëöáñçèìçôéêïýò ÷áñáêôÞñåò
-33 Äåí õðÜñ÷åé Ýëåã÷ïò åñãáóéþí óå áõôü ôï shell
-34 ËÜèïò óýíôáîç Ýêöñáóçò
-35 Äåí õðÜñ÷åé ðñïóùðéêüò êáôÜëïãïò (home directory)
-36 Äåí ìðïñþ íá ðñïóðåëÜóù ôïí ðñïóùðéêü êáôÜëïãï (home directory)
-37 Áêõñç êåíÞ åíôïëÞ
-38 Åê÷þñçóç ÷ùñßò Ýêöñáóç
-39 Áãíùóôïò ôåëåóôÞò
-40 Äéöïñïýìåíï
-41 %s: ôï áñ÷åßï õðÜñ÷åé
-42 Tï üñéóìá ôïõ -c ôåëåéþíåé óå backslash
-43 ÄéáêïðÞ
-44 Äåßêôçò åêôüò ïñßùí
-45 Õðåñ÷åßëéóç ãñáììÞò
-46 Äåí õðÜñ÷åé ôÝôïéá åñãáóßá
-47 Äåí ãßíåôáé áðü ôï ôåñìáôéêü
-48 Åêôüò while/foreach
-49 Äåí õðÜñ÷ïõí Üëëåò äéåñãáóßåò
-50 Äåí õðÜñ÷åé ôáßñéáóìá
-51 Áðüí %c
-52 Ìç ôáéñéáóìÝíï %c
-53 Äåí õðÜñ÷åé Üëëç ìíÞìç
-54 Äåí ìðïñþ íá äçìéïõñãÞóù pipe
+1 Λάθος σύνταξη
+2 Tο %s δεν επιτρέπεται
+3 Υπερβολικά μεγάλη λέξη
+4 $< Υπερβολικά μεγάλη γραμμή
+5 Δεν Ï
πάρχει αρχείο γιά το $0
+6 Ελλιπής μετατροπέας []
+7 Η ανάπτÏ
ξη τοÏ
 $ πρέπει να τελειώνει πριν το ]
+8 Λάθος μετατροπέας : στο $ (%c)
+9 Λάθος όρισμα
+10 Κακοσχηματισμένος αριθμός
+11 Δεν Ï
πάρχοÏ
ν άλλες λέξεις
+12 Απόν όνομα αρχείοÏ

+13 Εσωτερικό λάθος globbing
+14 Η εντολή δε βρέθηκε
+15 Υπερβολικά λίγα ορίσματα
+16 Υπερβολικά πολλά ορίσματα
+17 Υπερβολικά επικίνδÏ
νο ψεÏ
δώνÏ
μο
+18 Αδειο if
+19 Ακατάλληλο then
+20 Οι λέξεις δεν είναι εντός παρενθέσεων
+21 Tο %s δεν βρέθηκε
+22 Ακατάλληλη μάσκα
+23 Δεν Ï
πάρχει τέτοιο όριο
+24 Υπερβολικά μεγάλο όρισμα
+25 Ακατάλληλος ή άγνωστος παράγοντας μεγέθοÏ
Ï‚
+26 Μη ορισμένη μεταβλητή
+27 Tο stack καταλόγων δεν είναι τόσο βαθύ
+28 Λάθος αριθμός signal
+29 Άγνωστο signal·δώστε kill -l γιά λίστα signals
+30 Tα ονόματα μεταβλητών πρέπει να αρχίζοÏ
ν με γράμμα
+31 Υπερβολικά μεγάλο όνομα μεταβλητής
+32 Tα ονόματα μεταβλητών πρέπει να περιέχοÏ
ν αλφαρηθμητικούς χαρακτήρες
+33 Δεν Ï
πάρχει έλεγχος εργασιών σε αÏ
τό το shell
+34 Λάθος σύνταξη έκφρασης
+35 Δεν Ï
πάρχει προσωπικός κατάλογος (home directory)
+36 Δεν μπορώ να προσπελάσω τον προσωπικό κατάλογο (home directory)
+37 ΑκÏ
ρη κενή εντολή
+38 Εκχώρηση χωρίς έκφραση
+39 Αγνωστος τελεστής
+40 Διφορούμενο
+41 %s: το αρχείο Ï
πάρχει
+42 Tο όρισμα τοÏ
 -c τελειώνει σε backslash
+43 Διακοπή
+44 Δείκτης εκτός ορίων
+45 Υπερχείλιση γραμμής
+46 Δεν Ï
πάρχει τέτοια εργασία
+47 Δεν γίνεται από το τερματικό
+48 Εκτός while/foreach
+49 Δεν Ï
πάρχοÏ
ν άλλες διεργασίες
+50 Δεν Ï
πάρχει ταίριασμα
+51 Απόν %c
+52 Μη ταιριασμένο %c
+53 Δεν Ï
πάρχει άλλη μνήμη
+54 Δεν μπορώ να δημιοÏ
ργήσω pipe
 55 %s: %s
 56 %s
-57 ×ñÞóç: jobs [ -l ]
-58 Tá ïñßóìáôá ðñÝðåé íá åßíáé åñãáóßåò Þ ôáõôüôçôåò äéåñãáóéþí
-59 Äåí õðÜñ÷åé ôñÝ÷ïõóá åñãáóßá
-60 Äåí õðÜñ÷åé ðñïçãïýìåíç åñãáóßá
-61 ÊáììéÜ åñãáóßá äåí ôáéñéÜæåé ìå ôï pattern
-62 Tï fork nesting åßíáé ìåãáëýôåñï áðü %d; ðéèáíü `...` loop
-63 Ï Ýëåã÷ïò åñãáóéþí äåí åßíáé äéáèÝóéìïò óôá êáôþôåñá shells
-64 ËÜèïò sunc: ç äéåñãáóßá %d äå âñÝèçêå
-65 %sÕðÜñ÷ïõí áíáâëçèåßóåò åñãáóßåò
-66 %sÕðÜñ÷ïõí óôáìáôçìÝíåò åñãáóßåò
-67 Äåí õðÜñ÷åé Üëëïò êáôÜëïãïò
-68 Tï stack êáôáëüãùí åßíáé Üäåéï
-69 ËÜèïò êáôÜëïãïò
-70 ×ñÞóç: %s [-%s]%s
-71 Äåí õðÜñ÷åé üñéóìá ãéÜ ôï flag -h
-72 Äåí Ý÷åé ãßíåé login ìå áõôü ôï shell
-73 Äéáßñåóç ìå 0
-74 Modulo ìå 0
-75 ËÜèïò ìåãÝèõíóç· åííïïýóáôå "%s"?
-76 Äåí ìðïñþ (áêüìá) íá áíáâÜëù ôï login shell
-77 Áãíùóôïò ÷ñÞóôçò: %s
-78 Äåí Ý÷åé äïèåß ôéìÞ óôç ìåôáâëçôÞ $home
-79 ×ñÞóç: history [-%s] [# áñéèìüò åíôïëþí]
-80 Tá $, ! êáé < äåí åðéôñÝðïíôáé ìå ôá $# êáé $?
-81 ÁëëáãÞ ãñáììÞò óå üíïìá ìåôáâëçôÞò
-82 Tï * äåí åðéôñÝðåôáé ìå ôá $# êáé $?
-83 Tá $?<øçößï> êáé $#<øçößï> äåí åðéôñÝðïíôáé
-84 Áêõñï üíïìá ìåôáâëçôÞò
-85 ÁëëáãÞ ãñáììÞò óå äåßêôç ìåôáâëçôÞò
-86 Õðåñ÷åßëéóç buffer åðÝêôáóçò
-87 ËÜèïò óýíôáîçò ìåôáâëçôÞò
-88 ËÜèïò ìïñöÞ !
-89 Äåí õðÜñ÷åé ðñïçãïýìåíç áíôéêáôÜóôáóç
-90 ËÜèïò áíôéêáôÜóôáóç
-91 Äåí õðÜñ÷åé ðñïçãïýìåíï áñéóôåñü ìÝñïò
-92 Tï äåîß ìÝñïò åßíáé ðïëý ìåãÜëï
-93 Êáêüò ìåôáôñïðÝáò !: %c
-94 Ï ìåôáôñïðÝáò áðÝôõ÷å
-95 Õðåñ÷åßëéóç ôïõ buffer áíôéêáôáóôÜóåùí
-96 ËÜèïò åðéëïãÝáò ïñßóìáôïò !
-97 Äåí õðÜñ÷åé ðñïçãïýìåíç áíáæÞôçóç
-98 %s: ç åíôïëÞ äå âñÝèçêå
-99 ÕðåñâïëéêÜ ðïëëÝò )
-100 ÕðåñâïëéêÜ ðïëëÝò (
-101 ËÜèïò ôïðïèåôçìÝíç (
-102 ÐáñÜëåéøç ïíüìáôïò ãéÜ áíáêáôåýèõíóç
-103 Äéöïñïýìåíç áíáêáôåýèõíóç åîüäïõ
-104 Äåí ãßíåôáé << ìÝóá óå ()
-105 Äéöïñïýìåíç áíáêáôåýèõíóç åéóüäïõ
-106 ËÜèïò ôïðïèåôçìÝíåò ()
-107 Âñü÷ïò øåõäùíýìùí
-108 Äåí Ý÷åé äïèåß ôéìÞ óôç ìåôáâëçôÞ $watch
-109 Äåí õðÜñ÷ïõí äñïìïëïãçìÝíåò åíôïëÝò
-110 ×ñÞóç: sched -<#áíôéêåéìÝíïõ>.\n×ñÞóç: sched [+]ùù:ëë <åíôïëÞ>
-111 Äåí õðÜñ÷ïõí ôüóåò äñïìïëïãçìÝíåò åíôïëÝò
-112 Äåí õðÜñ÷åé åíôïëÞ ãéÜ åêôÝëåóç
-113 Áêõñïò ÷ñüíïò ãéÜ ôçí åíôïëÞ
-114 Ï ó÷åôéêüò ÷ñüíïò äåí åßíáé óõíåðÞò ìå ôï am/pm
-115 Äåí õðÜñ÷åé ÷þñïò ãéÜ ôï termcap string 
-116 ×ñÞóç: settc %s [yes|no]
-117 Áãíùóôç éêáíüôçôá `%s'
-118 Áãíùóôç ðáñÜìåôñïò ôïõ termcap `%%%c'
-119 ÕðåñâïëéêÜ ðïëëÜ ïñßóìáôá ãéÜ ôï `%s' (%d)
-120 Tï `%s' áðáéôåß %d ïñßóìáôá
-121 ×ñÞóç: echotc [-v|-s] [<éêáíüôçôá> [<ïñßóìáôá>]]
-122 %s: %s. ËÜèïò Áñ÷éôåêôïíéêÞ
-123 !# âñü÷ïò Éóôïñßáò åíôïëþí
-124 Êáêïó÷çìáôéóìÝíç åñþôçóç ãéÜ áñ÷åßï
-125 Õðåñ÷åßëéóç åðéëïãÝùí
-126 Áãíùóôç åðéëïãÞ: `-%s'\n×ñÞóç: %s [ -bcdefilmnqstvVxX -Dname[=value] ] [ üñéóìá ... ]
-127 Áãíùóôç åðéëïãÞ: `-%s'\nUsage: %s [ -bcdefFilmnqstvVxX ] [ üñéóìá ... ]
-128 Áãíùóôç åðéëïãÞ: `-%s'\nUsage: %s [ -bcdefilmnqstvVxX ] [ üñéóìá ... ]
-129 \nËÜèïò óõìðëÞñùóç: "%s"
-130 \nËÜèïò %s: '%c'
-131 \nÐáñÜëçøç äéá÷ùñéóôÞ '%c' ìåôÜ ôï %s "%s"
-132 \nÌç ðëÞñåò %s: "%s"
-133 Äåí õðÜñ÷åé üñéóìá ãéÜ ôï flag -m
-134 ×ñÞóç: unlimit [-fh] [üñéá]
-135 Tï $%S åßíáé ìüíï ãéÜ äéÜâáóìá
-136 Äåí õðÜñ÷åé ôÝôïéá åñãáóßá
+57 Χρήση: jobs [ -l ]
+58 Tα ορίσματα πρέπει να είναι εργασίες ή ταÏ
τότητες διεργασιών
+59 Δεν Ï
πάρχει τρέχοÏ
σα εργασία
+60 Δεν Ï
πάρχει προηγούμενη εργασία
+61 Καμμιά εργασία δεν ταιριάζει με το pattern
+62 Tο fork nesting είναι μεγαλύτερο από %d; πιθανό `...` loop
+63 Ο έλεγχος εργασιών δεν είναι διαθέσιμος στα κατώτερα shells
+64 Λάθος sunc: η διεργασία %d δε βρέθηκε
+65 %sΥπάρχοÏ
ν αναβληθείσες εργασίες
+66 %sΥπάρχοÏ
ν σταματημένες εργασίες
+67 Δεν Ï
πάρχει άλλος κατάλογος
+68 Tο stack καταλόγων είναι άδειο
+69 Λάθος κατάλογος
+70 Χρήση: %s [-%s]%s
+71 Δεν Ï
πάρχει όρισμα γιά το flag -h
+72 Δεν έχει γίνει login με αÏ
τό το shell
+73 Διαίρεση με 0
+74 Modulo με 0
+75 Λάθος μεγέθÏ
νση· εννοούσατε "%s"?
+76 Δεν μπορώ (ακόμα) να αναβάλω το login shell
+77 Αγνωστος χρήστης: %s
+78 Δεν έχει δοθεί τιμή στη μεταβλητή $home
+79 Χρήση: history [-%s] [# αριθμός εντολών]
+80 Tα $, ! και < δεν επιτρέπονται με τα $# και $?
+81 Αλλαγή γραμμής σε όνομα μεταβλητής
+82 Tο * δεν επιτρέπεται με τα $# και $?
+83 Tα $?<ψηφίο> και $#<ψηφίο> δεν επιτρέπονται
+84 ΑκÏ
ρο όνομα μεταβλητής
+85 Αλλαγή γραμμής σε δείκτη μεταβλητής
+86 Υπερχείλιση buffer επέκτασης
+87 Λάθος σύνταξης μεταβλητής
+88 Λάθος μορφή !
+89 Δεν Ï
πάρχει προηγούμενη αντικατάσταση
+90 Λάθος αντικατάσταση
+91 Δεν Ï
πάρχει προηγούμενο αριστερό μέρος
+92 Tο δεξί μέρος είναι πολύ μεγάλο
+93 Κακός μετατροπέας !: %c
+94 Ο μετατροπέας απέτÏ
χε
+95 Υπερχείλιση τοÏ
 buffer αντικαταστάσεων
+96 Λάθος επιλογέας ορίσματος !
+97 Δεν Ï
πάρχει προηγούμενη αναζήτηση
+98 %s: η εντολή δε βρέθηκε
+99 Υπερβολικά πολλές )
+100 Υπερβολικά πολλές (
+101 Λάθος τοποθετημένη (
+102 Παράλειψη ονόματος γιά ανακατεύθÏ
νση
+103 Διφορούμενη ανακατεύθÏ
νση εξόδοÏ

+104 Δεν γίνεται << μέσα σε ()
+105 Διφορούμενη ανακατεύθÏ
νση εισόδοÏ

+106 Λάθος τοποθετημένες ()
+107 Βρόχος ψεÏ
δωνύμων
+108 Δεν έχει δοθεί τιμή στη μεταβλητή $watch
+109 Δεν Ï
πάρχοÏ
ν δρομολογημένες εντολές
+110 Χρήση: sched -<#αντικειμένοÏ
>.\nΧρήση: sched [+]ωω:λλ <εντολή>
+111 Δεν Ï
πάρχοÏ
ν τόσες δρομολογημένες εντολές
+112 Δεν Ï
πάρχει εντολή γιά εκτέλεση
+113 ΑκÏ
ρος χρόνος γιά την εντολή
+114 Ο σχετικός χρόνος δεν είναι σÏ
νεπής με το am/pm
+115 Δεν Ï
πάρχει χώρος γιά το termcap string 
+116 Χρήση: settc %s [yes|no]
+117 Αγνωστη ικανότητα `%s'
+118 Αγνωστη παράμετρος τοÏ
 termcap `%%%c'
+119 Υπερβολικά πολλά ορίσματα γιά το `%s' (%d)
+120 Tο `%s' απαιτεί %d ορίσματα
+121 Χρήση: echotc [-v|-s] [<ικανότητα> [<ορίσματα>]]
+122 %s: %s. Λάθος Αρχιτεκτονική
+123 !# βρόχος Ιστορίας εντολών
+124 Κακοσχηματισμένη ερώτηση γιά αρχείο
+125 Υπερχείλιση επιλογέων
+126 Αγνωστη επιλογή: `-%s'\nΧρήση: %s [ -bcdefilmnqstvVxX -Dname[=value] ] [ όρισμα ... ]
+127 Αγνωστη επιλογή: `-%s'\nUsage: %s [ -bcdefFilmnqstvVxX ] [ όρισμα ... ]
+128 Αγνωστη επιλογή: `-%s'\nUsage: %s [ -bcdefilmnqstvVxX ] [ όρισμα ... ]
+129 \nΛάθος σÏ
μπλήρωση: "%s"
+130 \nΛάθος %s: '%c'
+131 \nΠαράληψη διαχωριστή '%c' μετά το %s "%s"
+132 \nΜη πλήρες %s: "%s"
+133 Δεν Ï
πάρχει όρισμα γιά το flag -m
+134 Χρήση: unlimit [-fh] [όρια]
+135 Tο $%S είναι μόνο γιά διάβασμα
+136 Δεν Ï
πάρχει τέτοια εργασία
 137 Unknown colorls variable `%c%c'
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/set10
--- a/head/contrib/tcsh/nls/greek/set10	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/set10	Fri Mar 02 16:54:40 2012 +0200
@@ -1,8 +1,8 @@
-$ $tcsh: set10,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set10,v 1.4 2011/02/04 18:19:37 christos Exp $
 $ ma.setp.c
 $set 10 
-1 setpath: Üêõñç åíôïëÞ '%s'.\n
-2 setpath: áíåðáñêÞò áñéèìüò ïñéóìÜôùí ãéÜ ôçí åíôïëÞ '%s'.\n
-3 setpath: êÜðïéá ôéìÞ ëåßðåé óôï path '%s'\n
-4 setpath: ôï %s äå âñÝèçêå óôï %s\n
-5 setpath: ç èÝóç %d äåí éó÷ýåé óôï %s\n
+1 setpath: άκÏ
ρη εντολή '%s'.\n
+2 setpath: ανεπαρκής αριθμός ορισμάτων γιά την εντολή '%s'.\n
+3 setpath: κάποια τιμή λείπει στο path '%s'\n
+4 setpath: το %s δε βρέθηκε στο %s\n
+5 setpath: η θέση %d δεν ισχύει στο %s\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/set11
--- a/head/contrib/tcsh/nls/greek/set11	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/set11	Fri Mar 02 16:54:40 2012 +0200
@@ -1,10 +1,10 @@
-$ $tcsh: set11,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set11,v 1.3 2011/02/04 18:19:37 christos Exp $
 $ sh.c
 $set 11 
-1 Ðñïåéäïðïßçóç: äåí ìðïñþ íá ðñïóðåëÜóù ôï tty (%s).\n
-2 Óõíåðþò, äåí èá õðÜñ÷åé Ýëåã÷ïò åñãáóéþí óå áõôü ôï shell.\n
-3 ¸÷åôå %d ìçíýìáôá mail.\n
-4 Å÷åôå %d ìçíýìáôá mail óôï %s.\n
-5 Å÷åôå %smail.\n
-6 íÝï 
-7 Å÷åôå %smail óôï %s.\n
+1 Προειδοποίηση: δεν μπορώ να προσπελάσω το tty (%s).\n
+2 ΣÏ
νεπώς, δεν θα Ï
πάρχει έλεγχος εργασιών σε αÏ
τό το shell.\n
+3 Έχετε %d μηνύματα mail.\n
+4 Εχετε %d μηνύματα mail στο %s.\n
+5 Εχετε %smail.\n
+6 νέο 
+7 Εχετε %smail στο %s.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/set12
--- a/head/contrib/tcsh/nls/greek/set12	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/set12	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set12,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set12,v 1.4 2011/02/04 18:19:37 christos Exp $
 $ sh.dir.c
 $set 12 
-1 %s: ðñïóðáèþ íá áñ÷ßóù áðü ôï "%s"\n
+1 %s: προσπαθώ να αρχίσω από το "%s"\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/set13
--- a/head/contrib/tcsh/nls/greek/set13	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/set13	Fri Mar 02 16:54:40 2012 +0200
@@ -1,13 +1,13 @@
-$ $tcsh: set13,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set13,v 1.3 2011/02/04 18:19:37 christos Exp $
 $ sh.exec.c
 $set 13 
 1 hash=%-4d dir=%-2d prog=%s\n
-2 %d hash buckets ìå %d bits ôï êáèÝíá\n
-3 ìÜóêá debug = 0x%08x\n
-4 %d åðéôõ÷ßåò, %d áðïôõ÷ßåò, %d%%\n
-5 %S: åóùôåñéêÞ åíôïëÞ ôïõ shell.\n
-6 %S: ç åíôïëÞ äå âñÝèçêå.\n
-7 where: ôï / óôçí åíôïëÞ äåí Ý÷åé íüçìá\n
-8 Tï %S åßíáé øåõäþíõìï ãéÜ ôçí åíôïëÞ 
-9 Tï %S åßíáé åóùôåñéêÞ åíôïëÞ ôïõ shell\n
-10 áðïôõ÷ßá ôïõ hash: 
+2 %d hash buckets με %d bits το καθένα\n
+3 μάσκα debug = 0x%08x\n
+4 %d επιτÏ
χίες, %d αποτÏ
χίες, %d%%\n
+5 %S: εσωτερική εντολή τοÏ
 shell.\n
+6 %S: η εντολή δε βρέθηκε.\n
+7 where: το / στην εντολή δεν έχει νόημα\n
+8 Tο %S είναι ψεÏ
δώνÏ
μο γιά την εντολή 
+9 Tο %S είναι εσωτερική εντολή τοÏ
 shell\n
+10 αποτÏ
χία τοÏ
 hash: 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/set14
--- a/head/contrib/tcsh/nls/greek/set14	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/set14	Fri Mar 02 16:54:40 2012 +0200
@@ -1,6 +1,6 @@
-$ $tcsh: set14,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set14,v 1.4 2011/02/04 18:19:37 christos Exp $
 $ sh.file.c
 $set 14 
-1 \nÐööö!! ÕðåñâïëéêÜ ðïëëÜ %s!!\n
-2 ïíüìáôá óôï password file
-3 áñ÷åßá
+1 \nΠφφφ!! Υπερβολικά πολλά %s!!\n
+2 ονόματα στο password file
+3 αρχεία
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/set15
--- a/head/contrib/tcsh/nls/greek/set15	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/set15	Fri Mar 02 16:54:40 2012 +0200
@@ -1,7 +1,7 @@
-$ $tcsh: set15,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set15,v 1.3 2011/02/04 18:19:37 christos Exp $
 $ sh.func.c
 $set 15 
-1 %s: %s: äå ìðïñþ íá %sôï%s üñéï\n
-2 ìçäåíßóù
-3 èÝóù
-4 \040áõóôçñü
+1 %s: %s: δε μπορώ να %sτο%s όριο\n
+2 μηδενίσω
+3 θέσω
+4 \040αÏ
στηρό
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/set16
--- a/head/contrib/tcsh/nls/greek/set16	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/set16	Fri Mar 02 16:54:40 2012 +0200
@@ -1,9 +1,9 @@
-$ $tcsh: set16,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set16,v 1.4 2011/02/04 18:19:37 christos Exp $
 $ sh.lex.c
 $set 16 
-1 Ìçäåíéóìüò ôïõ ãêñïõð äéåñãáóéþí ôïõ tty áðü %d óå %d\n
-2 \nÄþóôå "logout" ãéÜ íá âãåßôå.\n
-3 \nÄþóôå "exit" ãéÜ íá ôåñìáôßóåôå ôï %s.\n
+1 Μηδενισμός τοÏ
 γκροÏ
Ï€ διεργασιών τοÏ
 tty από %d σε %d\n
+2 \nΔώστε "logout" γιά να βγείτε.\n
+3 \nΔώστε "exit" γιά να τερματίσετε το %s.\n
 4 seek to eval %x %x\n
 5 seek to alias %x %x\n
 6 seek to file %x\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/set17
--- a/head/contrib/tcsh/nls/greek/set17	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/set17	Fri Mar 02 16:54:40 2012 +0200
@@ -1,17 +1,17 @@
-$ $tcsh: set17,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set17,v 1.4 2011/02/04 18:19:37 christos Exp $
 $ sh.proc.c
 $set 17 
-1 BUG: wait ãéÜ åñãáóßá ðïõ ôñÝ÷åé óôï ðáñáóêÞíéï!\n
-2 Åîïäïò ìå status %d\n
-3 BUG: ç äéåñãáóßá åêêåíþèçêå äõü öïñÝò
-4 ÔñÝ÷åé 
-5 ÓÞìá 
-6 Åîïäïò ìå status %-25d
-7 Ïëïêëçñþèçêå
+1 BUG: wait γιά εργασία ποÏ
 τρέχει στο παρασκήνιο!\n
+2 Εξοδος με status %d\n
+3 BUG: η διεργασία εκκενώθηκε δÏ
ό φορές
+4 Τρέχει 
+5 Σήμα 
+6 Εξοδος με status %-25d
+7 Ολοκληρώθηκε
 8 BUG: status=%-9o
-9 \040(åããñáöÞ áñ÷åßïõ core)
+9 \040(εγγραφή αρχείοÏ
 core)
 10 \040(wd: 
-11 ôùñéíï wd: 
-12 %S: Ý÷åé Þäç áíáâëçèåß\n
-13 %S: Ý÷åé Þäç óôáìáôÞóåé\n
+11 τωρινο wd: 
+12 %S: έχει ήδη αναβληθεί\n
+13 %S: έχει ήδη σταματήσει\n
 14 %S: Badly formed number\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/set18
--- a/head/contrib/tcsh/nls/greek/set18	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/set18	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set18,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set18,v 1.3 2011/02/04 18:19:37 christos Exp $
 $ sh.set.c
 $set 18 
-1 Ðñïåéäïðïßçóç: PATH ìå ôåñÜóôéï ìÝãåèïò, ðåñéêüðçêå\n
+1 Προειδοποίηση: PATH με τεράστιο μέγεθος, περικόπηκε\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/set19
--- a/head/contrib/tcsh/nls/greek/set19	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/set19	Fri Mar 02 16:54:40 2012 +0200
@@ -1,15 +1,23 @@
-$ $tcsh: set19,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set19,v 1.5 2011/02/25 23:58:07 christos Exp $
 $ tc.alloc.c
 $set 19 
-1 nbytes=%d: ç ìíÞìç ôåëåßùóå\n
-2 free(%lx) êëÞèçêå ðñßí íá åê÷ùñçèåß ìíÞìç.
-3 free(%lx) ðñéí ôçí áñ÷Þ ôçò ìíÞìçò.
-4 free(%lx) ìåôÜ ôï ôÝëïò ôçò ìíÞìçò.
-5 free(%lx) åóöáëìÝíï block.
-6 free(%lx) åóöáëìÝíç êëßìáêá check.
-7 free(%lx) åóöáëìÝíïò äåßêôçò block.
-8 Ðáñïýóá åê÷þñçóç ìíÞìçò ôïõ %s:\nfree:\t
-9 \n÷ñçóéìïðïéåßôáé:\t
-10 \n\tÓõíïëéêÜ ÷ñçóéìïðïéåßôáé: %d, óõíïëéêÞ åëåýèåñç: %d\n
-11 \tÅ÷åé åê÷ùñçèåß ìíÞìç áðü 0x%lx ùò 0x%lx. ÐñáãìáôéêÞ áñ÷Þ 0x%lx\n
-12 Å÷åé åê÷ùñçèåß ìíÞìç áðü 0x%lx ùò 0x%lx (%ld).\n
+1 nbytes=%d: η μνήμη τελείωσε\n
+2 free(%lx) κλήθηκε πρίν να εκχωρηθεί μνήμη.
+3 free(%lx) πριν την αρχή της μνήμης.
+4 free(%lx) μετά το τέλος της μνήμης.
+5 free(%lx) εσφαλμένο block.
+6 free(%lx) εσφαλμένη κλίμακα check.
+7 free(%lx) εσφαλμένος δείκτης block.
+8 Παρούσα εκχώρηση μνήμης τοÏ
 %s:\nfree:\t
+9 χρησιμοποιείται
+10 \n\tΣÏ
νολικά χρησιμοποιείται: %d, σÏ
νολική ελεύθερη: %d\n
+11 \tΕχει εκχωρηθεί μνήμη από 0x%lx ως 0x%lx. Πραγματική αρχή 0x%lx\n
+12 Εχει εκχωρηθεί μνήμη από 0x%lx ως 0x%lx (%ld).\n
+13 %s current memory allocation:\n
+14 Total space allocated from system: %d\n
+15 Number of non-inuse chunks: %d\n
+16 Number of mmapped regions: %d\n
+17 Total space in mmapped regions: %d\n
+18 Total allocated space: %d\n
+19 Total non-inuse space: %d\n
+20 Top-most, releasable space: %d\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/set2
--- a/head/contrib/tcsh/nls/greek/set2	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/set2	Fri Mar 02 16:54:40 2012 +0200
@@ -1,94 +1,94 @@
-$ $tcsh: set2,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set2,v 1.4 2011/02/04 18:19:37 christos Exp $
 $ Signal names
 $set 2 
-1 Ìçäåíéêü signal
-2 ÄéáêïðÞ ãñáììÞò (hangup)
-3 ÄéáêïðÞ (interrupt)
-4 Ðáñáßôçóç (quit)
-5 ÐáñÜíïìç åíôïëÞ (Illegal instruction)
+1 Μηδενικό signal
+2 Διακοπή γραμμής (hangup)
+3 Διακοπή (interrupt)
+4 Παραίτηση (quit)
+5 Παράνομη εντολή (Illegal instruction)
 6 Trace/BPT trap
 7 Abort
 8 IOT trap
-9 Åðéêåßìåíç êáôÜññåõóç óõóôÞìáôïò
-10 Tåñìáôéóìüò ìå ëÜèïò
+9 Επικείμενη κατάρρεÏ
ση σÏ
στήματος
+10 Tερματισμός με λάθος
 11 EMT trap
-12 Åîáßñåóç áñéèìçôéêÞò êéíçôÞò õðïäéáóôïëÞò
-13 Óêïôþèçêå
+12 Εξαίρεση αριθμητικής κινητής Ï
ποδιαστολής
+13 Σκοτώθηκε
 14 User signal 1
 15 User signal 2
-16 ËÜèïò Segmentation
-17 ËÜèïò Bus
-18 ËÜèïò ðåäßïõ ôéìþí ðñïãñÜììáôïò
-19 ËÜèïò ðåäßïõ ôéìþí ïñßóìáôïò
-20 Áíýðáñêôï system call
-21 ÓðáóìÝíï pipe
-22 ÓÞìá alarm
-23  Tåñìáôßóôçêå
-24 ÁëëáãÞ êáôÜóôáóçò äéåñãáóßáò-ðáéäéïý
-25 ÈÜíáôïò äéåñãáóßáò-ðáéäéïý
-26 ÓöÜëìá Apollo
-27 Ç äéåñãáóßá-ðáéäß óôáìÜôçóå Þ ôåñìÜôéóå
-28 Ç äéåñãáóßá-ðáéäß ôåñìÜôéóå
-29 ÄéáêïðÞ ôÜóçò
-30 Áðþëåéá ðüñïõ
+16 Λάθος Segmentation
+17 Λάθος Bus
+18 Λάθος πεδίοÏ
 τιμών προγράμματος
+19 Λάθος πεδίοÏ
 τιμών ορίσματος
+20 Ανύπαρκτο system call
+21 Σπασμένο pipe
+22 Σήμα alarm
+23  Tερματίστηκε
+24 Αλλαγή κατάστασης διεργασίας-παιδιού
+25 Θάνατος διεργασίας-παιδιού
+26 Σφάλμα Apollo
+27 Η διεργασία-παιδί σταμάτησε ή τερμάτισε
+28 Η διεργασία-παιδί τερμάτισε
+29 Διακοπή τάσης
+30 Απώλεια πόροÏ

 31 Break (Ctrl-Break)
-32 ÓÞìá äõíáôüôçôáò input/output
-33 Áóýã÷ñïíï I/O (select)
-34 Åðåßãïõóá êáôÜóôáóç óå äßáõëï I/O
+32 Σήμα δÏ
νατότητας input/output
+33 Ασύγχρονο I/O (select)
+34 ΕπείγοÏ
σα κατάσταση σε δίαÏ
λο I/O
 35 Multitasking wake-up
 36 Multitasking kill
-37 ÐåñÜôùóç áóýã÷ñïíïõ I/O ôçò fortran
-38 ÁíÜêáìøç
-39 Ìç åðáíïñèþóéìï óöÜëìá ìíÞìçò
-40 ÕðÝñâáóç ïñßïõ ÷ñüíïõ CPU
-41 Åðéêåßìåíï shutdown óõóôÞìáôïò
-42 Tï wakeup flag ôïõ áñéè. ïìÜäáò micro-tasking Ýãéíå set
-43 Ðñüâëçìá thread - (÷ñçóéìïðïéÞóôå cord -T ãéÜ ëåðôïìåñåßò ðëçñïöïñßåò)
-44 ÓöÜëìá áñôéüôçôáò êáôá÷ùñçôÞ CRAY Y-MP
-45 Áßôçóç ðëçñïöïñßáò
-46 ÁíáâïëÞ (óÞìál)
-47 Ðáýóç (óÞìá)
-48 ÁíáâïëÞ
-49 Ðáýóç
-50 ÓõíÝ÷éóç
-51 ÁíáâïëÞ (åßóïäïò áðü ôåñìáôéêü)
-52 Ðáýóç (åßóïäïò áðü ôåñìáôéêü)
-53 ÁíáâïëÞ (Ýîïäïò óå ôåñìáôéêü)
-54 Ðáýóç (Ýîïäïò óå ôåñìáôéêü)
-55 Ç êáôÜóôáóç ôïõ ðáñáèýñïõ Üëëáîå
-56 Tï ìÝãåèïò ôïõ ðáñáèýñïõ Üëëáîå
-57 Ç êáôÜóôáóç ôçò ôçëåöùíéêÞò ãñáììÞò Üëëáîå
-58 ÕðÝñâáóç ïñßïõ ÷ñüíïõ CPU
-59 ÕðÝñâáóç ïñßïõ ìåãÝèïõò áñ÷åßïõ
-60 ÓÞìá alarm åéêïíéêïý ÷ñüíïõ
-61 ÓÞìá alarm ÷ñüíïõ Profiling
-62 ÓÞìá DIL
-63 ÐñïÝêõøå pollable event
-64 Tá lwp's ôçò äéåñãáóßáò åßíáé ìðëïêáñéóìÝíá
-65 Åéäéêü óÞìá LWP
-66 Åéäéêü óÞìá CPR
-67 Åéäéêü óÞìá CPR
-68 Ðñþôï óÞìá Ðñáãìáôéêïý ×ñüíïõ
-69 Äåýôåñï óÞìá Ðñáãìáôéêïý ×ñüíïõ
-70 Tñßôï óÞìá Ðñáãìáôéêïý ×ñüíïõ
-71 TÝôáñôï óÞìá Ðñáãìáôéêïý ×ñüíïõ
-72 TÝôáñôï áðü ôï ôÝëïò óÞìá Ðñáãìáôéêïý ×ñüíïõ
-73 Tñßôï áðü ôï ôÝëïò óÞìá Ðñáãìáôéêïý ×ñüíïõ
-74 Äåýôåñï áðü ôï ôÝëïò óÞìá Ðñáãìáôéêïý ×ñüíïõ
-75 Tåëåõôáßï óÞìá Ðñáãìáôéêïý ×ñüíïõ
-76 Áóýã÷ñïíï I/O ôïðéêïý äéêôýïõ
-77 Äéáèåóéìüôçôá PTY ãéÜ áíÜãíùóç/ãñÜøéìï
-78 Áðáéôåßôáé ðáñÝìâáóç óôï I/O
-79 Ç ëåéôïõñãßá HFT monitor ðáñá÷ùñÞèçêå
-80 Ç ëåéôïõñãßá HFT monitor ðñÝðåé íá ðáñá÷ùñçèåß
-81 Ï Ýëåã÷ïò Þ÷ïõ HFT Ý÷åé ðåñáôùèåß
-82 ÄåäïìÝíá óôïí HFT ring buffer
-83 ÌåôáíÜóóôåõóç äéåñãáóßáò
-84 ÁóöáëÝò attention key
-85 Åðáíáäñïìïëüãçóç
-86 ÓÞìá SS$_DEBUG
-87 ÁëëáãÞ ðñïôåñáéüôçôáò
-88 Áíé÷íåýèçêå ðñáãìáôéêü áäéÝîïäï
-89 ÍÝïò ÷áñáêôÞñáò åéóüäïõ
+37 Περάτωση ασύγχρονοÏ
 I/O της fortran
+38 Ανάκαμψη
+39 Μη επανορθώσιμο σφάλμα μνήμης
+40 Υπέρβαση ορίοÏ
 χρόνοÏ
 CPU
+41 Επικείμενο shutdown σÏ
στήματος
+42 Tο wakeup flag τοÏ
 αριθ. ομάδας micro-tasking έγινε set
+43 Πρόβλημα thread - (χρησιμοποιήστε cord -T γιά λεπτομερείς πληροφορίες)
+44 Σφάλμα αρτιότητας καταχωρητή CRAY Y-MP
+45 Αίτηση πληροφορίας
+46 Αναβολή (σήμαl)
+47 Παύση (σήμα)
+48 Αναβολή
+49 Παύση
+50 ΣÏ
νέχιση
+51 Αναβολή (είσοδος από τερματικό)
+52 Παύση (είσοδος από τερματικό)
+53 Αναβολή (έξοδος σε τερματικό)
+54 Παύση (έξοδος σε τερματικό)
+55 Η κατάσταση τοÏ
 παραθύροÏ
 άλλαξε
+56 Tο μέγεθος τοÏ
 παραθύροÏ
 άλλαξε
+57 Η κατάσταση της τηλεφωνικής γραμμής άλλαξε
+58 Υπέρβαση ορίοÏ
 χρόνοÏ
 CPU
+59 Υπέρβαση ορίοÏ
 μεγέθοÏ
Ï‚ αρχείοÏ

+60 Σήμα alarm εικονικού χρόνοÏ

+61 Σήμα alarm χρόνοÏ
 Profiling
+62 Σήμα DIL
+63 ΠροέκÏ
ψε pollable event
+64 Tα lwp's της διεργασίας είναι μπλοκαρισμένα
+65 Ειδικό σήμα LWP
+66 Ειδικό σήμα CPR
+67 Ειδικό σήμα CPR
+68 Πρώτο σήμα Πραγματικού ΧρόνοÏ

+69 Δεύτερο σήμα Πραγματικού ΧρόνοÏ

+70 Tρίτο σήμα Πραγματικού ΧρόνοÏ

+71 Tέταρτο σήμα Πραγματικού ΧρόνοÏ

+72 Tέταρτο από το τέλος σήμα Πραγματικού ΧρόνοÏ

+73 Tρίτο από το τέλος σήμα Πραγματικού ΧρόνοÏ

+74 Δεύτερο από το τέλος σήμα Πραγματικού ΧρόνοÏ

+75 TελεÏ
ταίο σήμα Πραγματικού ΧρόνοÏ

+76 Ασύγχρονο I/O τοπικού δικτύοÏ

+77 Διαθεσιμότητα PTY γιά ανάγνωση/γράψιμο
+78 Απαιτείται παρέμβαση στο I/O
+79 Η λειτοÏ
ργία HFT monitor παραχωρήθηκε
+80 Η λειτοÏ
ργία HFT monitor πρέπει να παραχωρηθεί
+81 Ο έλεγχος ήχοÏ
 HFT έχει περατωθεί
+82 Δεδομένα στον HFT ring buffer
+83 ΜετανάσστεÏ
ση διεργασίας
+84 Ασφαλές attention key
+85 Επαναδρομολόγηση
+86 Σήμα SS$_DEBUG
+87 Αλλαγή προτεραιότητας
+88 Ανιχνεύθηκε πραγματικό αδιέξοδο
+89 Νέος χαρακτήρας εισόδοÏ

 90 Stack limit exceeded
 91 Unused signal
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/set20
--- a/head/contrib/tcsh/nls/greek/set20	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/set20	Fri Mar 02 16:54:40 2012 +0200
@@ -1,41 +1,41 @@
-$ $tcsh: set20,v 1.4 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set20,v 1.5 2011/02/04 18:19:37 christos Exp $
 $ tc.bind.c
 $set 20 
-1 Áêõñï üíïìá ðëÞêôñïõ `%S'\n
-2 ÅóöáëìÝíï üíïìá ðëÞêôñïõ: %S\n
-3 ÅóöáëìÝíï üíïìá åíôïëÞò: %S\n
-4 ÅóöáëìÝíç ðåñéãñáöÞ ðëÞêôñïõ %S\n
-5 ÌçäåíéêÞ ðåñéãñáöÞ string\n
-6 Standard óõó÷åôßóåéò ðëÞêôñùí\n
-7 ÅíáëëáêôéêÝò óõó÷åôßóåéò ðëÞêôñùí\n
-8 Óõó÷åôßóåéò ðïëëáðëþí ÷áñáêôÞñùí\n
-9 Óõó÷åôßóåéò ðëÞêôñùí âÝëïõò\n
-10 %-15s->  äåí Ý÷åé ïñéóôåß\n
-11 BUG!!! ôï %s äåí åßíáé óõó÷åôéóìÝíï ìå ôßðïôá.\n
-12 ×ñÞóç: bindkey [åðéëïãÝò] [--] [ÐËÇÊÔÑÏ [ÅÍÔÏËÇ]]\n
-13     -a   åìöÜíéóç Þ óõó÷Ýôéóç ÐËÇÊÔÑÏõ óôïí åíáëëáêôéêü ÷Üñôç ðëÞêôñùí\n
-14     -b   åñìçíåßá ÐËÇÊÔÑÏõ ùò C-, M-, F- or X- üíïìá ðëÞêôñïõ\n
-15     -s   åñìçíåßá ÅÍÔÏËÇò ùò êõñéïëåêôéêïý string ãéÜ åìöÜíéóç\n
-16     -c   åñìçíåßá ÅÍÔÏËÇò ùò åóùôåñéêÞò Þ åîùôåñéêÞò åíôïëÞò\n
-17     -v   óõó÷Ýôéóç üëùí ôùí ðëÞêôñùí óå áíôéóôïé÷ßá vi\n
-18     -e   óõó÷Ýôéóç üëùí ôùí ðëÞêôñùí óå áíôéóôïé÷ßá emacs\n
-19     -d   óõó÷Ýôéóç üëùí ôùí ðëÞêôñùí óôçí default ôïõ editor\n
-20     -l   åìöÜíéóç ôùí åíôïëþí ôïõ editor ìå ðåñéãñáöÝò\n
-21     -r   êáôÜñãçóç óõó÷Ýôéóçò ôïõ ÐËÇÊÔÑÏõ\n
-22     -k   åñìçíåßá ÐËÇÊÔÑÏõ ùò óõìâïëéêü üíïìá ðëÞêôñïõ âÝëïõò\n
-23     --   ôÝëïò åðåîåñãáóßáò åðéëïãþí\n
-24     -u   (Þ ïðïéáäÞðïôå Üêõñç åðéëïãÞ) áõôü ôï ìÞíõìá\n
-25 ×ùñßò ÐËÇÊÔÑÏ Þ ÅÍÔÏËÇ, åìöáíßæåé üëåò ôéò óõó÷åôßóåéò\n
-26 ×ùñßò ÅÍÔÏËÇ, åìöáíßæåé ôç óõó÷Ýôéóç ãéÜ ôï ÐËÇÊÔÑÏ.\n
-27 åóöáëìÝíç ðåñéãñáöÞ ðëÞêôñïõ -- ìçäåíéêü string\n
-28 åóöáëìÝíç ðåñéãñáöÞ ðëÞêôñïõ -- Üäåéï string\n
-29 ÅóöáëìÝíç ðåñéãñáöÞ ðëÞêôñïõ function. Ôï ìçäåíéêü string áðáãïñåýåôáé\n
-30 åóöáëìÝíç ðåñéãñáöÞ ðëÞêôñïõ -- êáêïó÷çìáôéóìÝíïò äåêáåîáäéêüò áñéèìüò\n
-31 åóöáëìÝíç ðåñéãñáöÞ ðëÞêôñïõ -- êáêïó÷çìáôéóìÝíïò ïêôáäéêüò áñéèìüò\n
-32 åóöáëìÝíç ðåñéãñáöÞ ðëÞêôñïõ -- êáêïó÷çìáôéóìÝíïò äåêáäéêüò áñéèìüò\n
-33 ÅóöáëìÝíç ðåñéãñáöÞ ðëÞêôñïõ function.\n
-34 Ôï ìçäåíéêü ðëÞêôñï äåí åðéôñÝðåôáé\n
-35 åóöáëìÝíç ðåñéãñáöÞ ðëÞêôñïõ -- Üãíùóôï üíïìá "%S"\n
-36 ÷ñÞóç: bind [ÐËÇÊÔÑÏ | ÐËÇÊÔÑÏ ÅÍÔÏËÇÓ | "emacs" | "vi" | "-a"]\n
-37 Áêõñç ëåéôïõñãßá
-38 Tï %s\t\täåí åßíáé ïñéóìÝíï\n
+1 ΑκÏ
ρο όνομα πλήκτροÏ
 `%S'\n
+2 Εσφαλμένο όνομα πλήκτροÏ
: %S\n
+3 Εσφαλμένο όνομα εντολής: %S\n
+4 Εσφαλμένη περιγραφή πλήκτροÏ
 %S\n
+5 Μηδενική περιγραφή string\n
+6 Standard σÏ
σχετίσεις πλήκτρων\n
+7 Εναλλακτικές σÏ
σχετίσεις πλήκτρων\n
+8 ΣÏ
σχετίσεις πολλαπλών χαρακτήρων\n
+9 ΣÏ
σχετίσεις πλήκτρων βέλοÏ
Ï‚\n
+10 %-15s->  δεν έχει οριστεί\n
+11 BUG!!! το %s δεν είναι σÏ
σχετισμένο με τίποτα.\n
+12 Χρήση: bindkey [επιλογές] [--] [ΠΛΗΚΤΡΟ [ΕΝΤΟΛΗ]]\n
+13     -a   εμφάνιση ή σÏ
σχέτιση ΠΛΗΚΤΡΟÏ
 στον εναλλακτικό χάρτη πλήκτρων\n
+14     -b   ερμηνεία ΠΛΗΚΤΡΟÏ
 ως C-, M-, F- or X- όνομα πλήκτροÏ
\n
+15     -s   ερμηνεία ΕΝΤΟΛΗς ως κÏ
ριολεκτικού string γιά εμφάνιση\n
+16     -c   ερμηνεία ΕΝΤΟΛΗς ως εσωτερικής ή εξωτερικής εντολής\n
+17     -v   σÏ
σχέτιση όλων των πλήκτρων σε αντιστοιχία vi\n
+18     -e   σÏ
σχέτιση όλων των πλήκτρων σε αντιστοιχία emacs\n
+19     -d   σÏ
σχέτιση όλων των πλήκτρων στην default τοÏ
 editor\n
+20     -l   εμφάνιση των εντολών τοÏ
 editor με περιγραφές\n
+21     -r   κατάργηση σÏ
σχέτισης τοÏ
 ΠΛΗΚΤΡΟÏ
\n
+22     -k   ερμηνεία ΠΛΗΚΤΡΟÏ
 ως σÏ
μβολικό όνομα πλήκτροÏ
 βέλοÏ
Ï‚\n
+23     --   τέλος επεξεργασίας επιλογών\n
+24     -u   (ή οποιαδήποτε άκÏ
ρη επιλογή) αÏ
Ï„ÏŒ το μήνÏ
μα\n
+25 Χωρίς ΠΛΗΚΤΡΟ ή ΕΝΤΟΛΗ, εμφανίζει όλες τις σÏ
σχετίσεις\n
+26 Χωρίς ΕΝΤΟΛΗ, εμφανίζει τη σÏ
σχέτιση γιά το ΠΛΗΚΤΡΟ.\n
+27 εσφαλμένη περιγραφή πλήκτροÏ
 -- μηδενικό string\n
+28 εσφαλμένη περιγραφή πλήκτροÏ
 -- άδειο string\n
+29 Εσφαλμένη περιγραφή πλήκτροÏ
 function. Το μηδενικό string απαγορεύεται\n
+30 εσφαλμένη περιγραφή πλήκτροÏ
 -- κακοσχηματισμένος δεκαεξαδικός αριθμός\n
+31 εσφαλμένη περιγραφή πλήκτροÏ
 -- κακοσχηματισμένος οκταδικός αριθμός\n
+32 εσφαλμένη περιγραφή πλήκτροÏ
 -- κακοσχηματισμένος δεκαδικός αριθμός\n
+33 Εσφαλμένη περιγραφή πλήκτροÏ
 function.\n
+34 Το μηδενικό πλήκτρο δεν επιτρέπεται\n
+35 εσφαλμένη περιγραφή πλήκτροÏ
 -- άγνωστο όνομα "%S"\n
+36 χρήση: bind [ΠΛΗΚΤΡΟ | ΠΛΗΚΤΡΟ ΕΝΤΟΛΗΣ | "emacs" | "vi" | "-a"]\n
+37 ΑκÏ
ρη λειτοÏ
ργία
+38 Tο %s\t\tδεν είναι ορισμένο\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/set21
--- a/head/contrib/tcsh/nls/greek/set21	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/set21	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,5 @@
-$ $tcsh: set21,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set21,v 1.3 2011/02/04 18:19:37 christos Exp $
 $ tc.disc.c
 $set 21 
-1 Äå ìðïñþ íá äéáâÜóù ôá local chars.\n
-2 Äå ìðïñþ íá ãñÜøù ôá local chars.\n
+1 Δε μπορώ να διαβάσω τα local chars.\n
+2 Δε μπορώ να γράψω τα local chars.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/set22
--- a/head/contrib/tcsh/nls/greek/set22	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/set22	Fri Mar 02 16:54:40 2012 +0200
@@ -1,18 +1,18 @@
-$ $tcsh: set22,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set22,v 1.3 2011/02/04 18:19:37 christos Exp $
 $ tc.func.c
 $set 22
-1 %S: \t øåõäþíõìï ãéÜ ôï
-2 \nËÜèïò password ãéÜ ôï %s\n
-3 Tï åóöáëìÝíï øåõäþíõìï 'precmd' áöáéñÝèçêå.\n
-4 Ôï åóöáëìÝíï øåõäþíõìï 'cwdcmd' áöáéñÝèçêå.\n
-5 Ôï åóöáëìÝíï øåõäþíõìï 'beepcmd' áöáéñÝèçêå.\n
-6 Ôï åóöáëìÝíï øåõäþíõìï 'periodic' áöáéñÝèçêå.\n
-7 Ýëåã÷ïò óýíôáîçò ãñáììÞò\n
-8 ÈÝëåôå ðñáãìáôéêÜ íá óâÞóåôå üëá ôá áñ÷åßá? [n/y]
-9 áêýñùóç óâçóßìáôïò áñ÷åßùí!\n
-10 ç ãñáììÞ ôþñá Ýãéíå:\n
-11 Ýëåã÷ïò óýíôáîçò ãñáììÞò\n
-12 óå Ýíáí áðü ôïõò êáôáëüãïõò\n
-13 ç ãñáììÞ ôþñá Ýãéíå:\n
+1 %S: \t ψεÏ
δώνÏ
μο γιά το
+2 \nΛάθος password γιά το %s\n
+3 Tο εσφαλμένο ψεÏ
δώνÏ
μο 'precmd' αφαιρέθηκε.\n
+4 Το εσφαλμένο ψεÏ
δώνÏ
μο 'cwdcmd' αφαιρέθηκε.\n
+5 Το εσφαλμένο ψεÏ
δώνÏ
μο 'beepcmd' αφαιρέθηκε.\n
+6 Το εσφαλμένο ψεÏ
δώνÏ
μο 'periodic' αφαιρέθηκε.\n
+7 έλεγχος σύνταξης γραμμής\n
+8 Θέλετε πραγματικά να σβήσετε όλα τα αρχεία? [n/y]
+9 ακύρωση σβησίματος αρχείων!\n
+10 η γραμμή τώρα έγινε:\n
+11 έλεγχος σύνταξης γραμμής\n
+12 σε έναν από τοÏ
Ï‚ καταλόγοÏ
Ï‚\n
+13 η γραμμή τώρα έγινε:\n
 14 yY
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/set23
--- a/head/contrib/tcsh/nls/greek/set23	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/set23	Fri Mar 02 16:54:40 2012 +0200
@@ -1,31 +1,31 @@
-$ $tcsh: set23,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set23,v 1.4 2011/02/04 18:19:38 christos Exp $
 $ tc.os.c
 $set 23 
-1 Áêõñï üíïìá cpu/site
-2 Ôï site path åßíáé õðåñâïëéêÜ ìáêñý
-3 Üãíùóôï
+1 ΑκÏ
ρο όνομα cpu/site
+2 Το site path είναι Ï
περβολικά μακρύ
+3 άγνωστο
 4 site: %s\n
-5 %d: ôï site äå âñÝèçêå\n
+5 %d: το site δε βρέθηκε\n
 6 setlocal: %s: %s\n
-7 Tï site äå âñÝèçêå
-8 Åßóôå ðáãéäåõìÝíïò óå Ýíá óýìðáí ðïõ äåí Ý÷åôå êáôáóêåõÜóåé
-9 Tï getwarp áðÝôõ÷å
-10 Áêõñï warp
-11 Tï setwarp áðÝôõ÷å
-12 Áêõñï óýìðáí
-13 Áãíùóôï ëÜèïò: %d
-14 üíïìá óõóôÞìáôïò:  %s\n
-15 üíïìá êüìâïõ: %s\n
+7 Tο site δε βρέθηκε
+8 Είστε παγιδεÏ
μένος σε ένα σύμπαν ποÏ
 δεν έχετε κατασκεÏ
άσει
+9 Tο getwarp απέτÏ
χε
+10 ΑκÏ
ρο warp
+11 Tο setwarp απέτÏ
χε
+12 ΑκÏ
ρο σύμπαν
+13 Αγνωστο λάθος: %d
+14 όνομα σÏ
στήματος:  %s\n
+15 όνομα κόμβοÏ
: %s\n
 16 release:  %s\n
 17 version:  %s\n
 18 machine:  %s\n
-19 getwd: äå ìðïñþ íá áíïßîù ôï ".." (%s)
-20 getwd: äå ìðïñþ íá áëëÜîù ôïí êáôÜëïãï óå ".." (%s)
-21 getwd: óöÜëìá óôçí áíÜãíùóç ôïõ ".." (%s)
-22 getwd: äå ìðïñþ íá îáíáëëÜîù ôïí êáôÜëïãï óå "." (%s)
-23 getwd: äå ìðïñþ íá êÜíù stat ôï "/" (%s)
-24 getwd: äå ìðïñþ íá êÜíù stat ôïí êáôÜëïãï "%s" (%s)
-25 getwd: äå ìðïñþ íá áíïßîù ôïí êáôÜëïãï "%s" (%s)
-26 getwd: äå ìðïñþ íá âñþ ôï "." óôï ".." (%s)
-27 Áêõñïò ôýðïò óõóôÞìáôïò
-28 Äåí Ý÷åé äïèåß ôéìÞ óôïí ôýðï óõóôÞìáôïò
+19 getwd: δε μπορώ να ανοίξω το ".." (%s)
+20 getwd: δε μπορώ να αλλάξω τον κατάλογο σε ".." (%s)
+21 getwd: σφάλμα στην ανάγνωση τοÏ
 ".." (%s)
+22 getwd: δε μπορώ να ξαναλλάξω τον κατάλογο σε "." (%s)
+23 getwd: δε μπορώ να κάνω stat το "/" (%s)
+24 getwd: δε μπορώ να κάνω stat τον κατάλογο "%s" (%s)
+25 getwd: δε μπορώ να ανοίξω τον κατάλογο "%s" (%s)
+26 getwd: δε μπορώ να βρώ το "." στο ".." (%s)
+27 ΑκÏ
ρος τύπος σÏ
στήματος
+28 Δεν έχει δοθεί τιμή στον τύπο σÏ
στήματος
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/set25
--- a/head/contrib/tcsh/nls/greek/set25	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/set25	Fri Mar 02 16:54:40 2012 +0200
@@ -1,6 +1,6 @@
-$ $tcsh: set25,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set25,v 1.3 2011/02/04 18:19:38 christos Exp $
 $ tc.sig.c
 $set 25 
 1 our wait %d\n
-2 óöÜëìá: ôï bsd_signal(%d) åêôüò ïñßùí\n
-3 óöÜëìá: ç sigaction áðÝôõ÷å ãéÜ ôï bsd_signal(%d), errno %d\n
+2 σφάλμα: το bsd_signal(%d) εκτός ορίων\n
+3 σφάλμα: η sigaction απέτÏ
χε γιά το bsd_signal(%d), errno %d\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/set26
--- a/head/contrib/tcsh/nls/greek/set26	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/set26	Fri Mar 02 16:54:40 2012 +0200
@@ -1,15 +1,15 @@
-$ $tcsh: set26,v 1.3 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set26,v 1.4 2011/02/04 18:19:38 christos Exp $
 $ tc.who.c
 $set 26 
-1 äå ìðïñþ íá êÜíù stat ôï %s. Ðáñáêáëþ äþóôå "unset watch".\n
-2 Tï %s äå ìðïñåß íá áíïé÷ôåß.  Ðáñáêáëþ äþóôå "unset watch".\n
-3 BUG! ôï ôåëåõôáßï óôïé÷åßï äåí åßíáé whotail!\n
-4 ðñïò ôá ðßóù: 
-5 BUG! ôï ôåëåõôáßï óôïé÷åßï äåí åßíáé whohead!\n
-6 íÝï: %s/%s\n
-7 Ï ÷ñÞóôçò %n Ýêáíå %a óôï ôåñìáôéêü %l áðü %m.
-8 Ï ÷ñÞóôçò %n Ýêáíå %a óôï ôåñìáôéêü %l.
+1 δε μπορώ να κάνω stat το %s. Παρακαλώ δώστε "unset watch".\n
+2 Tο %s δε μπορεί να ανοιχτεί.  Παρακαλώ δώστε "unset watch".\n
+3 BUG! το τελεÏ
ταίο στοιχείο δεν είναι whotail!\n
+4 προς τα πίσω: 
+5 BUG! το τελεÏ
ταίο στοιχείο δεν είναι whohead!\n
+6 νέο: %s/%s\n
+7 Ο χρήστης %n έκανε %a στο τερματικό %l από %m.
+8 Ο χρήστης %n έκανε %a στο τερματικό %l.
 9 login
 10 logout
-11 áíôéêáôÝóôçóå ôïí %s óôï ôåñìáôéêü
-12 ôïðéêü
+11 αντικατέστησε τον %s στο τερματικό
+12 τοπικό
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/set27
--- a/head/contrib/tcsh/nls/greek/set27	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/set27	Fri Mar 02 16:54:40 2012 +0200
@@ -1,8 +1,8 @@
-$ $tcsh: set27,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set27,v 1.3 2011/02/04 18:19:38 christos Exp $
 $ tw.comp.c
 $set 27 
-1 åíôïëÞ
+1 εντολή
 2 separator
 3 pattern
-4 êëßìáêá ôéìþí
-5 óõìðëÞñùóç
+4 κλίμακα τιμών
+5 σÏ
μπλήρωση
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/set29
--- a/head/contrib/tcsh/nls/greek/set29	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/set29	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set29,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set29,v 1.3 2011/02/04 18:19:38 christos Exp $
 $ tw.help.c
 $set 29 
-1 Äåí õðÜñ÷åé áñ÷åßï ìå âïÞèåéá ãéÜ ôï %S\n
+1 Δεν Ï
πάρχει αρχείο με βοήθεια γιά το %S\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/set3
--- a/head/contrib/tcsh/nls/greek/set3	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/set3	Fri Mar 02 16:54:40 2012 +0200
@@ -1,120 +1,120 @@
-$ $tcsh: set3,v 1.4 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set3,v 1.5 2011/02/04 18:19:38 christos Exp $
 $ Editor function descriptions
 $set 3 
-1 Ìåôáêßíçóç Ýíá ÷áñáêôÞñá üðéóèåí
-2 ÄéáãñáöÞ ÷áñáêôÞñá áñéóôåñÜ ôïõ äñïìÝá
-3 ÁðïêïðÞ áðü ôçí áñ÷Þ ôçò ôñÝ÷ïõóáò ëÝîçò ùò ôï äñïìÝá - öýëáîç óôï cut buffer
-4 ÁðïêïðÞ áðü ôçí áñ÷Þ ôçò ãñáììÞò - öýëáîç óôï cut buffer
-5 Ìåôáêßíçóç óôçí áñ÷Þ ôçò ôñÝ÷ïõóáò ëÝîçò
-6 Ìåôáêßíçóç óôçí áñ÷Þ ãñáììÞò
-7 ÌåôáôñïðÞ óå êåöáëáßá áðü ôï äñïìÝá ùò ôï ôÝëïò ôçò ôñÝ÷ïõóáò ëÝîçò
-8 (Vi) áëëáãÞ êåöáëáßùí/ìéêñþí óôç èÝóç ôïõ äñïìÝá êáé ìåôáêßíçóç ìéÜ èÝóç
-9 (Vi) áëëáãÞ êåöáëáßùí/ìéêñþí ùò ôï ôÝëïò ôçò ãñáììÞò
-10 ÊáèÜñéóìá ïèüíçò ìå ðáñáìïíÞ ôçò ôñÝ÷ïõóáò ãñáìÞò óôï ðÜíù ìÝñïò
-11 ÓõìðëÞñùóç ôñÝ÷ïõóáò ëÝîçò
-12 Tab forward ìåôáîý áñ÷åßùí
-13 Tab backward ìåôáîý áñ÷åßùí
-14 ÓõìðëÞñùóç ôñÝ÷ïõóáò ëÝîçò áãíïþíôáò ôéò ðñïãñáììáôéæüìåíåò óõìðëçñþóåéò
-15 ÁíôéãñáöÞ ôñÝ÷ïõóáò ëÝîçò óôçí èÝóç ôïõ äñïìÝá
-16 ÁíôéãñáöÞ ðåñéï÷Þò ìåôáîý óçìáäéïý êáé äñïìÝá óôï cut buffer
-17 ÁíÜðôõîç óå ðñïçãïýìåíç ëÝîç ìå ßäéï ðñüèåìá
-18 ÄéáãñáöÞ ÷áñáêôÞñá óôç èÝóç ôïõ äñïìÝá
-19 ÄéáãñáöÞ ÷áñáêôÞñá óôç èÝóç ôïõ äñïìÝá Þ end of file (ãéÜ Üäåéá ãñáììÞ)
-20 ÄéáãñáöÞ ÷áñáêôÞñá óôç èÝóç ôïõ äñïìÝá Þ óõìðëçñþóåéò (óôï ôÝëïò ãñáììÞò)
-21 ÄéáãñáöÞ ÷áñáêôÞñá óôç èÝóç ôïõ äñïìÝá, óõìðëçñþóåéò Þ end of file
-22 ÁðïêïðÞ áðü ôï äñïìÝá ùò ôï ôÝëïò ôçò ëÝîçò - öýëáîç óôï cut buffer
-23 Ðñüóèåóç óå üñéóìá óôçí áñ÷Þ Þ åßóïäïò øçößïõ
-24 Øçößï ðïõ áñ÷ßæåé üñéóìá
-25 Ìåôáêßíçóç óôçí åðüìåíç ãñáììÞ Éóôïñßáò
-26 ÌåôáôñïðÞ óå ìéêñÜ áðü ôï äñïìÝá ùò ôï ôÝëïò ôçò ëÝîçò
-27 Åíäåéîç end of file
-28 Ìåôáêßíçóç äñïìÝá óôï ôÝëïò ôçò ãñáììÞò
-29 ÁíôéìåôÜèåóç äñïìÝá - óçìáäéïý
-30 ÁíÜðôõîç wildcards óôï üíïìá áñ÷åßïõ
-31 ÁíÜðôõîç escapes Éóôïñßáò
-32 ÁíÜðôõîç escapes Éóôïñßáò óå ìéÜ ãñáììÞ
-33 ÁíÜðôõîç ìåôáâëçôþí
-34 Ìåôáêßíçóç äñïìÝá ìéÜ èÝóç åìðñüò
-35 Ìåôáêßíçóç ùò ôï ôÝëïò ôçò ëÝîçò
-36 ÁíôéìåôÜèåóç ôùí äýï ÷áñáêôÞñùí ðñéí ôï äñïìÝá
-37 ÁíáæÞôçóç ðñïçãïýìåíçò ãñáììÞò ôçò Éóôïñßáò ðïõ íá áñ÷ßæåé üðùò ç ôùñéíÞ
-38 ÁíáæÞôçóç åðüìåíçò ãñáììÞò ôçò Éóôïñßáò ðïõ íá áñ÷ßæåé üðùò ç ôùñéíÞ
-39 ÅéóáãùãÞ ôåëåõôáßïõ ôìÞìáôïò ðñïçãïýìåíçò åíôïëÞò
-40 ÓôáäéáêÞ áíáæÞôçóç óôá åðüìåíá
-41 ÓôáäéáêÞ áíáæÞôçóç óôá ðñïçãïýìåíá
-42 ÓâÞóéìï ãñáììÞò
-43 ÁðïêïðÞ ùò ôï ôÝëïò ôçò ãñáììÞò êáé öýëáîç óôï cut buffer
-44 ÁðïêïðÞ áðü ôï óçìÜäé ùò ôï äñïìÝá êáé öýëáîç óôï cut buffer
-45 ÁðïêïðÞ ïëüêëçñçò ôçò ãñáììÞò êáé öýëáîç óôï cut buffer
-46 ÅìöÜíéóç åðéëïãþí óõìðëÞñùóçò
-47 ÅìöÜíéóç åðéëïãþí óõìðëÞñùóçò áãíïþíôáò ôçí ðñïãñáììáôéæüìåíç óõìðëÞñùóç
-48 ÅìöÜíéóç ïíïìÜôùí áñ÷åßùí ðïõ ôáéñéÜæïõí ìå ôï wildcard
-49 ÅìöÜíéóç åðéëïãþí óõìðëÞñùóçò Þ end of file (óå Üäåéá ãñáììÞ)
-50 ÅìöÜíéóç ìÝóïõ üñïõ öïñôßïõ êáé êáôÜóôáóçò äéåñãáóéþí
-51 ÁíÜðôõîç escapes Éóôïñßáò êáé ðáñåìâïëÞ åíüò space
-52 ÅêôÝëåóç åíôïëÞò
-53 ÁíÜðôõîç pathnames, ìå áöáßñåóç ôùí áñ÷éêþí . êáé ..
-54 ÁíÜðôõîç åíôïëþí óôï ó÷åôéêü pathname Þ øåõäþíõìï
-55 ÅíáëëáãÞ áðü ðáñåìâïëÞ ÷áñáêôÞñùí óå áíôéêáôÜóôáóç êáé áíôßóôñïöá
-56 Ðñüóèåóç 8ïõ bit óôïí åðüìåíï ÷áñáêôÞñá ðïõ ðëçêôñïëïãåßôáé
-57 Ðñüóèåóç óôç ãñáììÞ ôïõ åðüìåíïõ ÷áñáêôÞñá ÷ùñßò åñìçíåßá (÷áñ. åëÝã÷ïõ)
-58 ÅðáíåìöÜíéóç
-59 Åðáíåêêßíçóç óôáìáôçìÝíïõ editor
-60 ÁíáæÞôçóç âïÞèåéáò ãéÜ ôçí ôñÝ÷ïõóá ãñáììÞ
-61 Ï ÷áñáêôÞñáò áõôüò ðñïóôßèåôáé óôç ãñáììÞ
-62 Ï ÷áñáêôÞñáò áõôüò åßíáé ï ðñþôïò ìéÜò áêïëïõèßáò ÷áñáêôÞñùí
-63 TïðïèÝôçóç óçìáäéïý óôç èÝóç ôïõ äñïìÝá
-64 Äéüñèùóç ïñèïãñáößáò ôçò ôñÝ÷ïõóáò ëÝîçò
-65 Äéüñèùóç ïñèïãñáößáò üëçò ôçò ãñáììÞò
-66 ÁðïóôïëÞ ÷áñáêôÞñá óôï ôåñìáôéêü óå cooked mode
-67 ÅíáëëáãÞ ìåôáîý êõñéïëåîßáò êáé ëåêôéêÞò ìïñöÞò ãñáììÞò Éóôïñßáò
-68 ÅíáëëáãÞ ôïõ ÷áñáêôÞñá óôç èÝóç ôïõ äñïìÝá ìå ôïí åðüìåíï
-69 ÅíáëëáãÞ ôùí äýï ÷áñáêôÞñùí áñéóôåñÜ ôïõ äñïìÝá
-70 ×áñáêôÞñáò ôåñìáôéêïý ãéá êáèõóôåñçìÝíç áíáâïëÞ äéåñãáóßáò
-71 ×áñáêôÞñáò ôåñìáôéêïý ãéÜ åêêÝíùóç output
-72 ×áñáêôÞñáò ôåñìáôéêïý ãéÜ åêêÝíùóç input
-73 ×áñáêôÞñáò ôåñìáôéêïý ãéÜ ðáñáßôçóç (quit)
-74 ×áñáêôÞñáò ôåñìáôéêïý ãéÜ áíáâïëÞ
-75 ×áñáêôÞñáò ôåñìáôéêïý ãéÜ åíåñãïðïßçóç output
-76 ×áñáêôÞñáò ôåñìáôéêïý ãéÜ áðåíåñãïðïßçóç output
-77 Åíäåéîç ÷áñáêôÞñá ÷ùñßò áíôéóôïß÷éóç
-78 Universal üñéóìá ôïõ emcas (üñéóìá åðß 4)
-79 Ìåôáêßíçóç óôçí ðñïçãïýìåíç ãñáììÞ Éóôïñßáò
-80 ÌåôáôñïðÞ óå êåöáëáßá áðü ôç èÝóç ôïõ äñïìÝá ùò ôï ôÝëïò ôçò ëÝîçò
-81 (Vi) ìåôáêßíçóç óôçí áñ÷Þ ôçò åðüìåíçò ëÝîçò
-82 (Vi) ìåôÜâáóç óå ôñüðï ðáñåìâïëÞò ÷áñáêôÞñùí ìåôÜ ôï äñïìÝá
-83 (Vi) ìåôÜâáóç óå ôñüðï ðáñåìâïëÞò ÷áñáêôÞñùí óôï ôÝëïò ôçò ãñáììÞò
-84 (Vi) ìåôáôñïðÞ êåöáëáßùí/ìéêñþí óôç èÝóç äñïìÝá êáé ìåôáêßíçóç äåîéÜ
-85 (Vi) åíôïëÞ áëëáãÞò ðñïèÝìáôïò
-86 (Vi) áëëáãÞ ùò ôï ôÝëïò ôçò ãñáììÞò
-87 ÌåôÜâáóç óôïí ôñüðï åíôïëþí vi
-88 (Vi) óå ôñüðï åíôïëþí, óõìðëÞñùóç ëÝîçò
-89 (Vi) ìåôáêßíçóç óôïí ðñïçãïýìåíï ÷áñáêôÞñá (backspace)
-90 (Vi) åíôïëÞ äéáãñáöÞò ðñïèÝìáôïò
-91 (Vi) ìåôáêßíçóç óôï ôÝëïò ôçò ôñÝ÷ïõóáò ëÝîçò (÷ùñéóìÝíçò áðï space)
-92 (Vi) ìåôáêßíçóç óôï ôÝëïò ôçò ôñÝ÷ïõóáò ëÝîçò
-93 (Vi) ìåôáêßíçóç ðñïò ôá ðßóù ùò ôïí êáèïñéóìÝíï ÷áñáêôÞñá
-94 (Vi) ìåôáêßíçóç ðñïò ôá åìðñüò ùò ôïí êáèïñéóìÝíï ÷áñáêôÞñá
-95 (Vi) ìåôáêßíçóç ðñïò ôá ðßóù ùò êáé ôïí êáèïñéóìÝíï ÷áñáêôÞñá
-96 (Vi) ìåôáêßíçóç ðñïò ôá åìðñüò ùò êáé ôïí êáèïñéóìÝíï ÷áñáêôÞñá
-97 ÌåôÜâáóç óôïí ôñüðï ðáñåìâïëÞò ôïõ vi
-98 ÌåôÜâáóç óôïí ôñüðï ðáñåìâïëÞò ôïõ vi óôçí áñ÷Þ ôçò ãñáììÞò
-99 (Vi) åðáíÜëçøç ðñïçãïýìåíçò áíáæÞôçóçò ÷áñáêôÞñá óôçí ßäéá êáôåýèõíóç
-100 (Vi) åðáíÜëçøç ðñïçãïýìåíçò áíáæÞôçóçò ÷áñáêôÞñá óôçí áíôßèåôç êáôåýèõíóç
-101 (Vi) åðáíÜëçøç ðñïçãïýìåíçò áíáæÞôçóçò óôçí ßäéá êáôåýèõíóç
-102 (Vi) åðáíÜëçøç ðñïçãïýìåíçò áíáæÞôçóçò óôçí áíôßèåôç êáôåýèõíóç
-103 (Vi) áíôéêáôÜóôáóç ôñÝ÷ïíôá ÷áñáêôÞñá ìå ôïí åðüìåíï ðëçêôñïëïãïýìåíï
-104 (Vi) ôñüðïò áíôéêáôÜóôáóçò
-105 (Vi) áíáæÞôçóç Éóôïñßáò ðñïò ôá ðßóù
-106 (Vi) áíáæÞôçóç Éóôïñßáò ðñïò ôá ìðñïóôÜ
-107 (Vi) áíôéêáôÜóôáóç ôñÝ÷ïíôá ÷áñáêôÞñá êáé ìåôÜâáóç óå ôñüðï ðáñåìâïëÞò
-108 (Vi) áíôéêáôÜóôáóç ïëüêëçñçò ôçò ãñáììÞò
-109 (Vi) ìåôáêßíçóç óôçí ðñïçãïýìåíç ëÝîç
-110 (Vi) ìåôáêßíçóç óôçí åðüìåíç ëÝîç
-111 (Vi) áíáßñåóç ðñïçãïýìåíçò áëëáãÞò
-112 (Vi) ìåôáêßíçóç óôçí áñ÷Þ ôçò ãñáììÞò
-113 ÅêôÝëåóç "which" ôçò ôñÝ÷ïõóáò åíôïëÞò
-114 Åðéêüëëçóç ôïõ cut buffer óôçí ôñÝ÷ïõóá èÝóç
+1 Μετακίνηση ένα χαρακτήρα όπισθεν
+2 Διαγραφή χαρακτήρα αριστερά τοÏ
 δρομέα
+3 Αποκοπή από την αρχή της τρέχοÏ
σας λέξης ως το δρομέα - φύλαξη στο cut buffer
+4 Αποκοπή από την αρχή της γραμμής - φύλαξη στο cut buffer
+5 Μετακίνηση στην αρχή της τρέχοÏ
σας λέξης
+6 Μετακίνηση στην αρχή γραμμής
+7 Μετατροπή σε κεφαλαία από το δρομέα ως το τέλος της τρέχοÏ
σας λέξης
+8 (Vi) αλλαγή κεφαλαίων/μικρών στη θέση τοÏ
 δρομέα και μετακίνηση μιά θέση
+9 (Vi) αλλαγή κεφαλαίων/μικρών ως το τέλος της γραμμής
+10 Καθάρισμα οθόνης με παραμονή της τρέχοÏ
σας γραμής στο πάνω μέρος
+11 ΣÏ
μπλήρωση τρέχοÏ
σας λέξης
+12 Tab forward μεταξύ αρχείων
+13 Tab backward μεταξύ αρχείων
+14 ΣÏ
μπλήρωση τρέχοÏ
σας λέξης αγνοώντας τις προγραμματιζόμενες σÏ
μπληρώσεις
+15 Αντιγραφή τρέχοÏ
σας λέξης στην θέση τοÏ
 δρομέα
+16 Αντιγραφή περιοχής μεταξύ σημαδιού και δρομέα στο cut buffer
+17 ΑνάπτÏ
ξη σε προηγούμενη λέξη με ίδιο πρόθεμα
+18 Διαγραφή χαρακτήρα στη θέση τοÏ
 δρομέα
+19 Διαγραφή χαρακτήρα στη θέση τοÏ
 δρομέα ή end of file (γιά άδεια γραμμή)
+20 Διαγραφή χαρακτήρα στη θέση τοÏ
 δρομέα ή σÏ
μπληρώσεις (στο τέλος γραμμής)
+21 Διαγραφή χαρακτήρα στη θέση τοÏ
 δρομέα, σÏ
μπληρώσεις ή end of file
+22 Αποκοπή από το δρομέα ως το τέλος της λέξης - φύλαξη στο cut buffer
+23 Πρόσθεση σε όρισμα στην αρχή ή είσοδος ψηφίοÏ

+24 Ψηφίο ποÏ
 αρχίζει όρισμα
+25 Μετακίνηση στην επόμενη γραμμή Ιστορίας
+26 Μετατροπή σε μικρά από το δρομέα ως το τέλος της λέξης
+27 Ενδειξη end of file
+28 Μετακίνηση δρομέα στο τέλος της γραμμής
+29 Αντιμετάθεση δρομέα - σημαδιού
+30 ΑνάπτÏ
ξη wildcards στο όνομα αρχείοÏ

+31 ΑνάπτÏ
ξη escapes Ιστορίας
+32 ΑνάπτÏ
ξη escapes Ιστορίας σε μιά γραμμή
+33 ΑνάπτÏ
ξη μεταβλητών
+34 Μετακίνηση δρομέα μιά θέση εμπρός
+35 Μετακίνηση ως το τέλος της λέξης
+36 Αντιμετάθεση των δύο χαρακτήρων πριν το δρομέα
+37 Αναζήτηση προηγούμενης γραμμής της Ιστορίας ποÏ
 να αρχίζει όπως η τωρινή
+38 Αναζήτηση επόμενης γραμμής της Ιστορίας ποÏ
 να αρχίζει όπως η τωρινή
+39 Εισαγωγή τελεÏ
ταίοÏ
 τμήματος προηγούμενης εντολής
+40 Σταδιακή αναζήτηση στα επόμενα
+41 Σταδιακή αναζήτηση στα προηγούμενα
+42 Σβήσιμο γραμμής
+43 Αποκοπή ως το τέλος της γραμμής και φύλαξη στο cut buffer
+44 Αποκοπή από το σημάδι ως το δρομέα και φύλαξη στο cut buffer
+45 Αποκοπή ολόκληρης της γραμμής και φύλαξη στο cut buffer
+46 Εμφάνιση επιλογών σÏ
μπλήρωσης
+47 Εμφάνιση επιλογών σÏ
μπλήρωσης αγνοώντας την προγραμματιζόμενη σÏ
μπλήρωση
+48 Εμφάνιση ονομάτων αρχείων ποÏ
 ταιριάζοÏ
ν με το wildcard
+49 Εμφάνιση επιλογών σÏ
μπλήρωσης ή end of file (σε άδεια γραμμή)
+50 Εμφάνιση μέσοÏ
 όροÏ
 φορτίοÏ
 και κατάστασης διεργασιών
+51 ΑνάπτÏ
ξη escapes Ιστορίας και παρεμβολή ενός space
+52 Εκτέλεση εντολής
+53 ΑνάπτÏ
ξη pathnames, με αφαίρεση των αρχικών . και ..
+54 ΑνάπτÏ
ξη εντολών στο σχετικό pathname ή ψεÏ
δώνÏ
μο
+55 Εναλλαγή από παρεμβολή χαρακτήρων σε αντικατάσταση και αντίστροφα
+56 Πρόσθεση 8οÏ
 bit στον επόμενο χαρακτήρα ποÏ
 πληκτρολογείται
+57 Πρόσθεση στη γραμμή τοÏ
 επόμενοÏ
 χαρακτήρα χωρίς ερμηνεία (χαρ. ελέγχοÏ
)
+58 Επανεμφάνιση
+59 Επανεκκίνηση σταματημένοÏ
 editor
+60 Αναζήτηση βοήθειας γιά την τρέχοÏ
σα γραμμή
+61 Ο χαρακτήρας αÏ
τός προστίθεται στη γραμμή
+62 Ο χαρακτήρας αÏ
τός είναι ο πρώτος μιάς ακολοÏ
θίας χαρακτήρων
+63 Tοποθέτηση σημαδιού στη θέση τοÏ
 δρομέα
+64 Διόρθωση ορθογραφίας της τρέχοÏ
σας λέξης
+65 Διόρθωση ορθογραφίας όλης της γραμμής
+66 Αποστολή χαρακτήρα στο τερματικό σε cooked mode
+67 Εναλλαγή μεταξύ κÏ
ριολεξίας και λεκτικής μορφής γραμμής Ιστορίας
+68 Εναλλαγή τοÏ
 χαρακτήρα στη θέση τοÏ
 δρομέα με τον επόμενο
+69 Εναλλαγή των δύο χαρακτήρων αριστερά τοÏ
 δρομέα
+70 Χαρακτήρας τερματικού για καθÏ
στερημένη αναβολή διεργασίας
+71 Χαρακτήρας τερματικού γιά εκκένωση output
+72 Χαρακτήρας τερματικού γιά εκκένωση input
+73 Χαρακτήρας τερματικού γιά παραίτηση (quit)
+74 Χαρακτήρας τερματικού γιά αναβολή
+75 Χαρακτήρας τερματικού γιά ενεργοποίηση output
+76 Χαρακτήρας τερματικού γιά απενεργοποίηση output
+77 Ενδειξη χαρακτήρα χωρίς αντιστοίχιση
+78 Universal όρισμα τοÏ
 emcas (όρισμα επί 4)
+79 Μετακίνηση στην προηγούμενη γραμμή Ιστορίας
+80 Μετατροπή σε κεφαλαία από τη θέση τοÏ
 δρομέα ως το τέλος της λέξης
+81 (Vi) μετακίνηση στην αρχή της επόμενης λέξης
+82 (Vi) μετάβαση σε τρόπο παρεμβολής χαρακτήρων μετά το δρομέα
+83 (Vi) μετάβαση σε τρόπο παρεμβολής χαρακτήρων στο τέλος της γραμμής
+84 (Vi) μετατροπή κεφαλαίων/μικρών στη θέση δρομέα και μετακίνηση δεξιά
+85 (Vi) εντολή αλλαγής προθέματος
+86 (Vi) αλλαγή ως το τέλος της γραμμής
+87 Μετάβαση στον τρόπο εντολών vi
+88 (Vi) σε τρόπο εντολών, σÏ
μπλήρωση λέξης
+89 (Vi) μετακίνηση στον προηγούμενο χαρακτήρα (backspace)
+90 (Vi) εντολή διαγραφής προθέματος
+91 (Vi) μετακίνηση στο τέλος της τρέχοÏ
σας λέξης (χωρισμένης απο space)
+92 (Vi) μετακίνηση στο τέλος της τρέχοÏ
σας λέξης
+93 (Vi) μετακίνηση προς τα πίσω ως τον καθορισμένο χαρακτήρα
+94 (Vi) μετακίνηση προς τα εμπρός ως τον καθορισμένο χαρακτήρα
+95 (Vi) μετακίνηση προς τα πίσω ως και τον καθορισμένο χαρακτήρα
+96 (Vi) μετακίνηση προς τα εμπρός ως και τον καθορισμένο χαρακτήρα
+97 Μετάβαση στον τρόπο παρεμβολής τοÏ
 vi
+98 Μετάβαση στον τρόπο παρεμβολής τοÏ
 vi στην αρχή της γραμμής
+99 (Vi) επανάληψη προηγούμενης αναζήτησης χαρακτήρα στην ίδια κατεύθÏ
νση
+100 (Vi) επανάληψη προηγούμενης αναζήτησης χαρακτήρα στην αντίθετη κατεύθÏ
νση
+101 (Vi) επανάληψη προηγούμενης αναζήτησης στην ίδια κατεύθÏ
νση
+102 (Vi) επανάληψη προηγούμενης αναζήτησης στην αντίθετη κατεύθÏ
νση
+103 (Vi) αντικατάσταση τρέχοντα χαρακτήρα με τον επόμενο πληκτρολογούμενο
+104 (Vi) τρόπος αντικατάστασης
+105 (Vi) αναζήτηση Ιστορίας προς τα πίσω
+106 (Vi) αναζήτηση Ιστορίας προς τα μπροστά
+107 (Vi) αντικατάσταση τρέχοντα χαρακτήρα και μετάβαση σε τρόπο παρεμβολής
+108 (Vi) αντικατάσταση ολόκληρης της γραμμής
+109 (Vi) μετακίνηση στην προηγούμενη λέξη
+110 (Vi) μετακίνηση στην επόμενη λέξη
+111 (Vi) αναίρεση προηγούμενης αλλαγής
+112 (Vi) μετακίνηση στην αρχή της γραμμής
+113 Εκτέλεση "which" της τρέχοÏ
σας εντολής
+114 Επικόλληση τοÏ
 cut buffer στην τρέχοÏ
σα θέση
 115 Replace just-yanked text with yank from earlier kill
 116 (WIN32 only) Copy cut buffer to system clipboard
 117 (WIN32 only) Paste clipboard buffer at cursor position
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/set30
--- a/head/contrib/tcsh/nls/greek/set30	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/set30	Fri Mar 02 16:54:40 2012 +0200
@@ -1,16 +1,16 @@
-$ $tcsh: set30,v 1.2 2006/03/02 18:46:46 christos Exp $
+$ $tcsh: set30,v 1.3 2011/02/04 18:19:38 christos Exp $
 $ tw.parse.c
 $set 30 
 1 starting_a_command %d\n
-2 óõìðëÞñùóç %d 
-3 óõìðëÞñùóç %d %S\n
-4 %s: åóùôåñéêü ëÜèïò ôáéñéÜóìáôïò.\n
-5 áíôéêåßìåíáitems
-6 óåéñÝò)
-7 ÕðÜñ÷ïõí %d %s, íá ôá åìöáíßóù ïýôùò Þ Üëëùò? [n/y] 
+2 σÏ
μπλήρωση %d 
+3 σÏ
μπλήρωση %d %S\n
+4 %s: εσωτερικό λάθος ταιριάσματος.\n
+5 αντικείμεναitems
+6 σειρές)
+7 ΥπάρχοÏ
ν %d %s, να τα εμφανίσω ούτως ή άλλως? [n/y] 
 8 looking = %d\n
-9 \nåóùôåñéêü óöÜëìá ôïõ %s: äåí îÝñù ôé áíáæçôþ!\n
-10 äåí åßíáé êáôÜëïãïò áñ÷åßùí
-11 äå âñÝèçêå
-12 ìç áíáãíþóéìï
+9 \nεσωτερικό σφάλμα τοÏ
 %s: δεν ξέρω τι αναζητώ!\n
+10 δεν είναι κατάλογος αρχείων
+11 δε βρέθηκε
+12 μη αναγνώσιμο
 13 yY
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/set31
--- a/head/contrib/tcsh/nls/greek/set31	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/set31	Fri Mar 02 16:54:40 2012 +0200
@@ -1,7 +1,7 @@
-$ $tcsh: set31,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set31,v 1.3 2011/02/04 18:19:38 christos Exp $
 $ vms.termcap.c
 $set 31 
-1 Äå ìðïñþ íá áíïßîù ôï TERMCAP: [%s]\n
-2 Äå ìðïñþ íá áíïßîù ôï %s.\n
-3 ÂñÞêá ôï %s óôï %s.\n
-4 Äå âñÞêá êÜôé ðïõ íá ôáéñéÜæåé ìå ôï %s óôï áñ÷åßï %s\n
+1 Δε μπορώ να ανοίξω το TERMCAP: [%s]\n
+2 Δε μπορώ να ανοίξω το %s.\n
+3 Βρήκα το %s στο %s.\n
+4 Δε βρήκα κάτι ποÏ
 να ταιριάζει με το %s στο αρχείο %s\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/set4
--- a/head/contrib/tcsh/nls/greek/set4	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/set4	Fri Mar 02 16:54:40 2012 +0200
@@ -1,45 +1,45 @@
-$ $tcsh: set4,v 1.3 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set4,v 1.4 2011/02/04 18:19:38 christos Exp $
 $ Termcap strings
 $set 4
-1 ðñüóèåóç íÝáò êåíÞò ãñáììÞò
-2 ç÷çôéêü óÞìá
-3 êáèÜñéóìá ùò ôï ôÝëïò ïèüíçò
-4 êáèÜñéóìá ùò ôï ôÝëïò ãñáììÞò
-5 äñïìÝáò óå ïñéæüíôéá èÝóç
-6 êáèÜñéóìá ïèüíçò
-7 äéáãñáöÞ åíüò ÷áñáêôÞñá
-8 äéáãñáöÞ ìéÜò ãñáììÞò
-9 Ýíáñîç ôñüðïõ äéáãñáöÞò
-10 ôåñìáôéóìüò ôñüðïõ äéáãñáöÞò
-11 ôåñìáôéóìüò ôñüðïõ ðáñåìâïëÞò
-12 äñïìÝáò áðü ãñáììÞ êáôÜóôáóçò
-13 äñïìÝáò óôçí áñ÷Þ
-14 åéóáãùãÞ ÷áñáêôÞñá
-15 Ýíáñîç ôñüðïõ ðáñåìâïëÞò
-16 ðáñåìâïëÞ padding
-17 áðïóôïëÞ ÊÜôù
-18 áðïóôïëÞ ÁñéóôåñÜ
-19 áðïóôïëÞ ÄåîéÜ
-20 áðïóôïëÞ ÅðÜíù
-21 Ýíáñîç bold
-22 ôÝëïò éäéïôÞôùí ÷áñáêôÞñùí
-23 ìç êáôáóôñåðôéêü space
-24 ôÝëïò Ýìöáóçò
-25 áñ÷Þ Ýìöáóçò
-26 ï äñïìÝáò óôç ãñáììÞ êáôÜóôáóçò
-27 ï äñïìÝáò ìéÜ èÝóç åðÜíù
-28 Ýíáñîç õðïãñÜììéóçò
-29 ôÝëïò õðïãñÜììéóçò
-30 ïñáôü óÞìá
-31 äéáãñáöÞ ðïëëáðëþí ÷áñáêôÞñùí
-32 äñïìÝáò ðïëëáðëÝò èÝóåéò êÜôù
-33 ðáñåìâïëÞ ðïëëáðëþí ÷áñáêôÞñùí
-34 äñïìÝáò ðïëëáðëÝò èÝóåéò áñéóôåñÜ
-35 äñïìÝáò ðïëëáðëÝò èÝóåéò äåîéÜ
-36 äñïìÝáò ðïëëáðëÝò èÝóåéò åðÜíù
-37 Äõíáôüôçôá áõôüìáôùí ðåñéèùñßùí
-38 Äõíáôüôçôá ÷ñÞóçò öõóéêþí tabs
-39 Áñéèìüò ãñáììþí
-40 Áñéèìüò óôçëþí
-41 Õðáñîç "ìåôá"-ðëÞêôñïõ
-42 Ôï newline áãíïåßôáé óôï äåîß ðåñéèþñéï
+1 πρόσθεση νέας κενής γραμμής
+2 ηχητικό σήμα
+3 καθάρισμα ως το τέλος οθόνης
+4 καθάρισμα ως το τέλος γραμμής
+5 δρομέας σε οριζόντια θέση
+6 καθάρισμα οθόνης
+7 διαγραφή ενός χαρακτήρα
+8 διαγραφή μιάς γραμμής
+9 έναρξη τρόποÏ
 διαγραφής
+10 τερματισμός τρόποÏ
 διαγραφής
+11 τερματισμός τρόποÏ
 παρεμβολής
+12 δρομέας από γραμμή κατάστασης
+13 δρομέας στην αρχή
+14 εισαγωγή χαρακτήρα
+15 έναρξη τρόποÏ
 παρεμβολής
+16 παρεμβολή padding
+17 αποστολή Κάτω
+18 αποστολή Αριστερά
+19 αποστολή Δεξιά
+20 αποστολή Επάνω
+21 έναρξη bold
+22 τέλος ιδιοτήτων χαρακτήρων
+23 μη καταστρεπτικό space
+24 τέλος έμφασης
+25 αρχή έμφασης
+26 ο δρομέας στη γραμμή κατάστασης
+27 ο δρομέας μιά θέση επάνω
+28 έναρξη Ï
πογράμμισης
+29 τέλος Ï
πογράμμισης
+30 ορατό σήμα
+31 διαγραφή πολλαπλών χαρακτήρων
+32 δρομέας πολλαπλές θέσεις κάτω
+33 παρεμβολή πολλαπλών χαρακτήρων
+34 δρομέας πολλαπλές θέσεις αριστερά
+35 δρομέας πολλαπλές θέσεις δεξιά
+36 δρομέας πολλαπλές θέσεις επάνω
+37 ΔÏ
νατότητα αÏ
τόματων περιθωρίων
+38 ΔÏ
νατότητα χρήσης φÏ
σικών tabs
+39 Αριθμός γραμμών
+40 Αριθμός στηλών
+41 Υπαρξη "μετα"-πλήκτροÏ

+42 Το newline αγνοείται στο δεξί περιθώριο
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/set5
--- a/head/contrib/tcsh/nls/greek/set5	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/set5	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set5,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set5,v 1.3 2011/02/04 18:19:38 christos Exp $
 $ ed.chared.c
 $set 5
-1 Ï ìÝóïò üñïò öïñôßïõ äåí åßíáé äéáèÝóéìïò\n
+1 Ο μέσος όρος φορτίοÏ
 δεν είναι διαθέσιμος\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/set6
--- a/head/contrib/tcsh/nls/greek/set6	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/set6	Fri Mar 02 16:54:40 2012 +0200
@@ -1,11 +1,11 @@
-$ $tcsh: set6,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set6,v 1.3 2011/02/04 18:19:38 christos Exp $
 $ ed.inputl.c
 $set 6
-1 ÓÖÁËÌÁ: Üêõñç åíôïëÞ áðï ôï ðëÞêôñï 0%o\r\n
-2 íáé\n
+1 ΣΦΑΛΜΑ: άκÏ
ρη εντολή απο το πλήκτρο 0%o\r\n
+2 ναι\n
 3 edit\n
 4 abort\n
-5 ü÷é\n
-6 Äåí õðÜñ÷åé åíôïëÞ ðïõ íá ôáéñéÜæåé\n
-7 Äéöïñïýìåíç åíôïëÞ\n
-8 *** ìïéñáßï ÓÖÁËÌÁ editor ***\r\n\n
+5 όχι\n
+6 Δεν Ï
πάρχει εντολή ποÏ
 να ταιριάζει\n
+7 Διφορούμενη εντολή\n
+8 *** μοιραίο ΣΦΑΛΜΑ editor ***\r\n\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/set7
--- a/head/contrib/tcsh/nls/greek/set7	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/set7	Fri Mar 02 16:54:40 2012 +0200
@@ -1,30 +1,30 @@
-$ $tcsh: set7,v 1.3 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set7,v 1.4 2011/02/04 18:19:38 christos Exp $
 $ ed.screen.c
 $set 7
-1 \n\tÔï %s îÝñåé ãéÜ ôï ôåñìáôéêü óáò ôá\n
-2 \tåîÞò ÷áñáêôçñéóôéêÜ:\n\n
-3 \tÅ÷åé %d óôÞëåò êáé %d ãñáììÝò\n
-4 \t%s÷åé "ìåôá"-ðëÞêôñï\n
-5 Å
-6 Äåí Ý
-7 \t%sìðïñåß íá ÷ñçóéìïðïéÞóåé tabs\n
-8 Äåí 
-9 \t%s áõôüìáôá ðåñéèþñéá\n
-10 Å÷åé
-11 Äåí Ý÷åé
-12 \t%s "ìáãéêÜ" ðåñéèþñéá\n
-13 (Üäåéï)
-14 íáé
-15 ü÷é
-16 ÓÖÁËÌÁ: äå ìðïñþ íá óâÞóù\r\n
-17 DeleteChars: ï áñéèìüò åßíáé áðßèáíïò: %d\r\n
-18 ÓÖÁËÌÁ: äå ìðïñþ íá ðáñåìâÜëù\r\n
-19 StartInsert: ï áñéèìüò åßíáé áðßèáíïò: %d\r\n
-20 %s: Äå ìðïñþ íá áíïßîù ôï /etc/termcap.\n
-21 %s: Äåí õðÜñ÷åé åããñáöÞ ãéá ôïí ôýðï ôåñìáôéêïý "%s"\n
-22 %s: èá ÷ñçóéìïðïéÞóù ÷áñáêôçñéóôéêÜ "÷áæïý" ôåñìáôéêïý.\n
-23 %s: ÐÑÏÅÉÄÏÐÏÉÇÓÇ: Ôï ôåñìáôéêü äåí ìðïñåß íá ìåôáêéíÞóåé åðÜíù.\n
-24 Ôï editing ìðïñåß íá åßíáé ðåñßåñãï ãéÜ ìåãÜëåò ãñáììÝò.\n
-25 äåí õðÜñ÷åé äõíáôüôçôá êáèáñéóìïý ùò ôï ôÝëïò ãñáììÞò.\n
-26 äåí õðÜñ÷åé äõíáôüôçôá äéáãñáöÞò ÷áñáêôÞñá.\n
-27 äåí õðÜñ÷åé äõíáôüôçôá ðáñåìâïëÞò ÷áñáêôÞñá.\n
+1 \n\tΤο %s ξέρει γιά το τερματικό σας τα\n
+2 \tεξής χαρακτηριστικά:\n\n
+3 \tΕχει %d στήλες και %d γραμμές\n
+4 \t%sχει "μετα"-πλήκτρο\n
+5 Ε
+6 Δεν έ
+7 \t%sμπορεί να χρησιμοποιήσει tabs\n
+8 Δεν 
+9 \t%s αÏ
τόματα περιθώρια\n
+10 Εχει
+11 Δεν έχει
+12 \t%s "μαγικά" περιθώρια\n
+13 (άδειο)
+14 ναι
+15 όχι
+16 ΣΦΑΛΜΑ: δε μπορώ να σβήσω\r\n
+17 DeleteChars: ο αριθμός είναι απίθανος: %d\r\n
+18 ΣΦΑΛΜΑ: δε μπορώ να παρεμβάλω\r\n
+19 StartInsert: ο αριθμός είναι απίθανος: %d\r\n
+20 %s: Δε μπορώ να ανοίξω το /etc/termcap.\n
+21 %s: Δεν Ï
πάρχει εγγραφή για τον τύπο τερματικού "%s"\n
+22 %s: θα χρησιμοποιήσω χαρακτηριστικά "χαζού" τερματικού.\n
+23 %s: ΠΡΟΕΙΔΟΠΟΙΗΣΗ: Το τερματικό δεν μπορεί να μετακινήσει επάνω.\n
+24 Το editing μπορεί να είναι περίεργο γιά μεγάλες γραμμές.\n
+25 δεν Ï
πάρχει δÏ
νατότητα καθαρισμού ως το τέλος γραμμής.\n
+26 δεν Ï
πάρχει δÏ
νατότητα διαγραφής χαρακτήρα.\n
+27 δεν Ï
πάρχει δÏ
νατότητα παρεμβολής χαρακτήρα.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/set8
--- a/head/contrib/tcsh/nls/greek/set8	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/set8	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,5 @@
-$ $tcsh: set8,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set8,v 1.3 2011/02/04 18:19:38 christos Exp $
 $ ed.term.c
 $set 8
-1 Áãíùóôï switch
-2 Áêõñï üñéóìá
+1 Αγνωστο switch
+2 ΑκÏ
ρο όρισμα
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/greek/set9
--- a/head/contrib/tcsh/nls/greek/set9	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/greek/set9	Fri Mar 02 16:54:40 2012 +0200
@@ -1,12 +1,12 @@
-$ $tcsh: set9,v 1.3 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set9,v 1.4 2011/02/04 18:19:38 christos Exp $
 $ ed.xmap.c
 $set 9
-1 AddXkey: äåí åðéôñÝðåôáé ìçäåíéêü extended-key.\n
-2 AddXkey: ç åíôïëÞ ìå áõôÞí ôçí áñ÷éêÞ áêïëïõèßá äåí åðéôñÝðåôáé\n
-3 DeleteXkey: äåí åðéôñÝðåôáé ìçäåíéêü extended-key.\n
-4 Áóõó÷Ýôéóôï extended key "%S"\n
-5 ÌåñéêÜ extended keys åßíáé ðïëý ìåãÜëá ãéÜ ôïí åóùôåñéêü print buffer
-6 Enumerate: BUG!! ÐÝñáóìá ìçäåíéêïý pointer!\n
-7 äåí õðÜñ÷åé åßóïäïò
-8 ÊÜôé ðñÝðåé íá áêïëïõèåß: %c\n
-9 Ç ïêôáäéêÞ óôáèåñÜ äå ÷ùñÜåé óôï ìÝãåèïò åíüò char.\n
+1 AddXkey: δεν επιτρέπεται μηδενικό extended-key.\n
+2 AddXkey: η εντολή με αÏ
τήν την αρχική ακολοÏ
θία δεν επιτρέπεται\n
+3 DeleteXkey: δεν επιτρέπεται μηδενικό extended-key.\n
+4 ΑσÏ
σχέτιστο extended key "%S"\n
+5 Μερικά extended keys είναι πολύ μεγάλα γιά τον εσωτερικό print buffer
+6 Enumerate: BUG!! Πέρασμα μηδενικού pointer!\n
+7 δεν Ï
πάρχει είσοδος
+8 Κάτι πρέπει να ακολοÏ
θεί: %c\n
+9 Η οκταδική σταθερά δε χωράει στο μέγεθος ενός char.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/italian/charset
--- a/head/contrib/tcsh/nls/italian/charset	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/italian/charset	Fri Mar 02 16:54:40 2012 +0200
@@ -1,3 +1,3 @@
-$ codeset=ISO-8859-1
+$ codeset=UTF-8
 $set 255
-1 ISO-8859-1
+1 UTF-8
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/italian/set1
--- a/head/contrib/tcsh/nls/italian/set1	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/italian/set1	Fri Mar 02 16:54:40 2012 +0200
@@ -1,8 +1,8 @@
-$ $tcsh: set1,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set1,v 1.3 2011/02/04 18:19:38 christos Exp $
 $ Error messages
 $set 1 
 1 Errore di Sintassi
-2 %s non è permesso
+2 %s non è permesso
 3 Parola troppo lunga
 4 $< linea troppo lunga
 5 Nessun file per $0
@@ -17,7 +17,7 @@
 14 Comando non trovato
 15 Troppi pochi argomenti
 16 Troppi argomenti
-17 È troppo pericoloso creare un alias in questo caso
+17 È troppo pericoloso creare un alias in questo caso
 18 `if' vuoto
 19 `then' sbagliato
 20 Parola non tra parentesi
@@ -27,11 +27,11 @@
 24 Argomento troppo lungo
 25 Fattore di scala sbagliato o sconosciuto
 26 Variabile non definita
-27 Pila delle directory non così profonda
+27 Pila delle directory non così profonda
 28 Numero di segnale non corretto
 29 Segnale sconosciuto; utilizza kill -l per elencare i segnali
 30 Il nome della variabile deve iniziare con una lettera
-31 Il nome della variabile è troppo lungo
+31 Il nome della variabile è troppo lungo
 32 Il nome della variabile deve contenere caratteri alfanumerici
 33 Non ho il controllo dei lavori in questa shell
 34 Errore di sintassi nell'espressione
@@ -111,17 +111,17 @@
 108 Variabile $watch non definita
 109 Nessun evento programmato
 110 Utilizzo: sched -<elemento#>.\nUtilizzo: sched [+]hh:mm <comando>
-111 Non ci sono così tanti eventi programmati
+111 Non ci sono così tanti eventi programmati
 112 Nessun comando da eseguire
 113 Istante non corretto per l'evento
 114 Istante relativo non consistente con am/pm
 115 Al di fuori dello spazio stringa del termcap
 116 Utilizzo: settc %s [yes|no]
-117 Capacità `%s' sconosciuta
+117 Capacità `%s' sconosciuta
 118 Parametro del termcap `%%%c' sconosciuto
 119 Troppi argomenti per `%s' (%d)
 120 `%s' richiede %d argomenti
-121 Utilizzo: echotc [-v|-s] [<capacità> [<argomenti>]]
+121 Utilizzo: echotc [-v|-s] [<capacità> [<argomenti>]]
 122 %s: %s. Architettura non corretta
 123 !# Ciclo chiuso nello storico
 124 Richiesta di file formulata incorrettamente
@@ -135,6 +135,6 @@
 132 \n%s incompleto: "%s"
 133 Manca l'operando dell'opzione -m
 134 Utilizzo: unlimit [-fh] [limiti]
-135 $%S è a sola lettura
+135 $%S è a sola lettura
 136 Non esiste il lavoro
 137 Variabile `%c%c colorls' sconosciuta
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/italian/set11
--- a/head/contrib/tcsh/nls/italian/set11	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/italian/set11	Fri Mar 02 16:54:40 2012 +0200
@@ -1,8 +1,8 @@
-$ $tcsh: set11,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set11,v 1.3 2011/02/04 18:19:38 christos Exp $
 $ sh.c
 $set 11 
 1 Attenzione: accesso negato al terminale (%s).\n
-2 Quindi il controllo dei lavori in questa shell non è possibile.\n
+2 Quindi il controllo dei lavori in questa shell non è possibile.\n
 3 Hai %d messaggi di posta elettronica.\n
 4 Hai %d messaggi di posta elettronica in %s.\n
 5 Hai %smessaggi di posta elettronica.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/italian/set13
--- a/head/contrib/tcsh/nls/italian/set13	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/italian/set13	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set13,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set13,v 1.3 2011/02/04 18:19:38 christos Exp $
 $ sh.exec.c
 $set 13 
 1 hash=%-4d dir=%-2d prog=%s\n
@@ -8,6 +8,6 @@
 5 %S: comando interno della shell.\n
 6 %S: comando non trovato.\n
 7 where: / non ha senso all'interno di un comando\n
-8 %S è un alias per 
-9 %S è un comando interno\n
+8 %S è un alias per 
+9 %S è un comando interno\n
 10 errore di hash: 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/italian/set15
--- a/head/contrib/tcsh/nls/italian/set15	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/italian/set15	Fri Mar 02 16:54:40 2012 +0200
@@ -1,7 +1,7 @@
-$ $tcsh: set15,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set15,v 1.3 2011/02/04 18:19:39 christos Exp $
 $ sh.func.c
 $set 15 
-1 %s: %s: non si può %s il limite%s\n
+1 %s: %s: non si può %s il limite%s\n
 2 eliminare
 3 modificare
 4 \040fisico
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/italian/set17
--- a/head/contrib/tcsh/nls/italian/set17	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/italian/set17	Fri Mar 02 16:54:40 2012 +0200
@@ -1,9 +1,9 @@
-$ $tcsh: set17,v 1.3 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set17,v 1.4 2011/02/04 18:19:39 christos Exp $
 $ sh.proc.c
 $set 17 
 1 BACO: sto aspettando un lavoro in background!\n
 2 Uscito %d\n
-3 BACO: il processo è stato svuotato due volte
+3 BACO: il processo è stato svuotato due volte
 4 In esecuzione 
 5 Segnale 
 6 Uscito %-25d
@@ -12,6 +12,6 @@
 9 \040(creato file core)
 10 \040(directory di lavoro: 
 11 directory di lavoro corrente: 
-12 %S: già sospeso\n
-13 %S: già fermato\n
+12 %S: già sospeso\n
+13 %S: già fermato\n
 14 %S: Badly formed number\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/italian/set19
--- a/head/contrib/tcsh/nls/italian/set19	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/italian/set19	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set19,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set19,v 1.4 2011/02/25 23:58:07 christos Exp $
 $ tc.alloc.c
 $set 19 
 1 nbytes=%d: Memoria esaurita\n
@@ -9,7 +9,15 @@
 6 free(%lx) intervallo di controllo sbagliato.
 7 free(%lx) indice di blocco sbagliato.
 8 %s attuale allocazione di memoria:\nlibera:\t
-9 \nutilizzata:\t
+9 utilizzata
 10 \n\tTotale utilizzata: %d, totale libera: %d\n
 11 \tAllocata memoria da 0x%lx a 0x%lx.  Limite superiore effettivo a 0x%lx\n
 12 Allocata memoria da 0x%lx a 0x%lx (%ld).\n
+13 %s current memory allocation:\n
+14 Total space allocated from system: %d\n
+15 Number of non-inuse chunks: %d\n
+16 Number of mmapped regions: %d\n
+17 Total space in mmapped regions: %d\n
+18 Total allocated space: %d\n
+19 Total non-inuse space: %d\n
+20 Top-most, releasable space: %d\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/italian/set2
--- a/head/contrib/tcsh/nls/italian/set2	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/italian/set2	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set2,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set2,v 1.3 2011/02/04 18:19:39 christos Exp $
 $ Signal names
 $set 2 
 1 Segnale nullo
@@ -44,7 +44,7 @@
 41 Spegnimento del sistema imminente
 42 micro-tasking group-no wakeup flag settato
 43 Errore di thread - (usa cord -T per avere informazioni dettagliate)
-44 Errore di parità di registro del CRAY Y-MP
+44 Errore di parità di registro del CRAY Y-MP
 45 Richiesta di informazioni
 46 Sospeso (segnale)
 47 Fermato (segnale)
@@ -63,7 +63,7 @@
 60 Allarme dell'orologio virtuale
 61 Allarme di tempo di profiling
 62 Segnale DIL 
-63 Si è verificato un evento interrogabile
+63 Si è verificato un evento interrogabile
 64 Gli lwps del processo sono bloccati
 65 Segnale speciale LWP
 66 Segnale speciale CPR
@@ -77,17 +77,17 @@
 74 Penultimo segnale di tempo reale
 75 Ultimo segnale di tempo reale
 76 I/O asincrono di LAN
-77 Disponibilità di lettura/scrittura su pseudoterminale
+77 Disponibilità di lettura/scrittura su pseudoterminale
 78 Richiesta di I/O
-79 Modalità di monitoraggio HFT disponibile
-80 La modalità di monitoraggio HFT deve essere abbandonata
-81 Il controllo sonoro HFT è stato completato
+79 Modalità di monitoraggio HFT disponibile
+80 La modalità di monitoraggio HFT deve essere abbandonata
+81 Il controllo sonoro HFT è stato completato
 82 Dati nel buffer circolare HFT
 83 Migrate process
 84 Tasto di attenzione assicurata
 85 Rischedulamento
 86 Segnale di SS$_DEBUG
-87 Cambio di priorità
+87 Cambio di priorità
 88 Identificato uno stallo
 89 Nuovo carattere in ingresso
 90 Oltrepassato lo spazio disponibile di stack
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/italian/set20
--- a/head/contrib/tcsh/nls/italian/set20	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/italian/set20	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set20,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set20,v 1.3 2011/02/04 18:19:39 christos Exp $
 $ tc.bind.c
 $set 20 
 1 Nome di tasto non corretto `%S'\n
@@ -8,10 +8,10 @@
 5 Stringa di specificazione sbagliata\n
 6 Definizione dei tasti standard\n
 7 Definizione dei tasti alternativi\n
-8 Definizione delle combinazioni di più tasti\n
+8 Definizione delle combinazioni di più tasti\n
 9 Definizione dei tasti freccia\n
-10 %-15s->  non è definita\n
-11 BACO!!! %s non è definita da nessuna parte.\n
+10 %-15s->  non è definita\n
+11 BACO!!! %s non è definita da nessuna parte.\n
 12 Utilizzo: bindkey [opzioni] [--] [TASTO [COMANDO]]\n
 13     -a   elenca o definisce un tasto nella tabella dei tasti alternativi\n
 14     -b   interpreta TASTO come C-, M-, F- o X- tasto\n
@@ -29,13 +29,13 @@
 26 Senza COMANDO, stampa la definizione di TASTO.\n
 27 specificazione di tasto sbagliata -- stringa nulla\n
 28 specificazione di tasto sbagliata -- stringa vuota\n
-29 Specificazione di tasto funzione sbagliata.  Il tasto nullo non si può usare\n
+29 Specificazione di tasto funzione sbagliata.  Il tasto nullo non si può usare\n
 30 specificazione di tasto sbagliata -- numero esadecimale non corretto\n
 31 specificazione di tasto sbagliata -- numero ottale non corretto\n
 32 specificazione di tasto sbagliata -- numero decimale non corretto\n
 33 Specificazione di tasto funzione sbagliata.\n
-34 Il tasto nullo non si può usare\n
+34 Il tasto nullo non si può usare\n
 35 specificazione di tasto sbagliata -- nome "%S" sconosciuto\n
 36 utilizzo: bind [TASTO | COMANDO TASTO | "emacs" | "vi" | "-a"]\n
 37 Funzione non corretta
-38  %s\t\tnon è definita\n
+38  %s\t\tnon è definita\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/italian/set22
--- a/head/contrib/tcsh/nls/italian/set22	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/italian/set22	Fri Mar 02 16:54:40 2012 +0200
@@ -1,7 +1,7 @@
-$ $tcsh: set22,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set22,v 1.3 2011/02/04 18:19:39 christos Exp $
 $ tc.func.c
 $set 22 
-1 %S: \t è un alias per 
+1 %S: \t è un alias per 
 2 \nPassword non corretta per %s\n
 3 Alias non corretto 'precmd' rimosso.\n
 4 Alias non corretto 'cwdcmd' rimosso.\n
@@ -10,8 +10,8 @@
 7 sto esaminando la linea di comando\n
 8 Vuoi realmente cancellare tutti i file? [s/n] 
 9 sto saltando la cancellazione dei file!\n
-10 la linea di comando adesso è:\n
+10 la linea di comando adesso è:\n
 11 sto esaminando la linea di comando\n
 12 in uno degli elenchi\n
-13 la linea di comando ora è:\n
+13 la linea di comando ora è:\n
 14 sS
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/italian/set23
--- a/head/contrib/tcsh/nls/italian/set23	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/italian/set23	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set23,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set23,v 1.3 2011/02/04 18:19:39 christos Exp $
 $ tc.os.c
 $set 23 
 1 Nome di cpu/macchina non corretto
@@ -29,6 +29,6 @@
 26 getwd: non posso aprire la directory "%s" (%s)
 27 getwd: non riesco a trovare "." in ".." (%s)
 28 Tipo di sistema non corretto
-29 Il tipo di sistema non è stato definito
+29 Il tipo di sistema non è stato definito
 30 Troppi argomenti
 31 Argomento non corretto
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/italian/set26
--- a/head/contrib/tcsh/nls/italian/set26	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/italian/set26	Fri Mar 02 16:54:40 2012 +0200
@@ -1,15 +1,15 @@
-$ $tcsh: set26,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set26,v 1.3 2011/02/04 18:19:39 christos Exp $
 $ tc.who.c
 $set 26 
-1 non posso usare stat per %s.  Per pietà dai un "unset watch".\n
-2 Non riesco ad aprire %s.  Per pietà dai un "unset watch".\n
-3 BACO! l'ultimo elemento non è whotail!\n
+1 non posso usare stat per %s.  Per pietà dai un "unset watch".\n
+2 Non riesco ad aprire %s.  Per pietà dai un "unset watch".\n
+3 BACO! l'ultimo elemento non è whotail!\n
 4 all'indietro: 
-5 BACO! il primo elemento non è whohead!\n
+5 BACO! il primo elemento non è whohead!\n
 6 nuova entrata: %s/%s\n
 7 %n %a %l da %m.
 8 %n %a %l.
-9 si è loggato su
-10 si è sloggato da
+9 si è loggato su
+10 si è sloggato da
 11 ha rimpiazzato %s su
 12 console
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/italian/set3
--- a/head/contrib/tcsh/nls/italian/set3	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/italian/set3	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set3,v 1.3 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set3,v 1.4 2011/02/04 18:19:39 christos Exp $
 $ Editor function descriptions
 $set 3 
 1 Retrocede di un carattere
@@ -14,10 +14,10 @@
 11 Completa la parola corrente
 12 Avanza con il tabulatore tra i file
 13 Retrocede con il tabulatore tra i file
-14 Completa la parola corrente ignorando le modalità di completamento programmabili
+14 Completa la parola corrente ignorando le modalità di completamento programmabili
 15 Copia la parola corrente nella posizione del cursore
 16 Copia la zona tra il cursore e il segno nel buffer
-17 Espande nella precedente parola di cui questa è la parte iniziale
+17 Espande nella precedente parola di cui questa è la parte iniziale
 18 Cancella il carattere sotto il cursore
 19 Cancella il carattere sotto il cursore o segnala la fine del file in una linea vuota
 20 Cancella il carattere sotto il cursore o elenca i completamenti se alla fine di una linea
@@ -47,7 +47,7 @@
 44 Taglia la zona tra il cursore e il segno e la salva nel buffer
 45 Taglia l'intera linea salvandola nel buffer
 46 Elenca le possibili scelte per il completamento
-47 Elenca le possibili scelte per il completamento ignorando le modalità di completamento programmabili
+47 Elenca le possibili scelte per il completamento ignorando le modalità di completamento programmabili
 48 Elenca i file che corrispondono ai caratteri jolly
 49 Elenca le possibili scelte per il completamento o segnala la fine del file nel caso di linea vuota
 50 Mostra la media di carico macchina e lo stato del processo corrente
@@ -55,18 +55,18 @@
 52 Esegue un comando
 53 Espande i percorsi eliminando i '.' e '..' iniziali
 54 Espande i comandi con il relativo percorso o alias
-55 Commuta tra le modalità di inserimento e di sovrascrittura
+55 Commuta tra le modalità di inserimento e di sovrascrittura
 56 Aggiunge l'ottavo bit al successivo carattere inserito
-57 Aggiunge nella linea il successivo carattere così com'è
+57 Aggiunge nella linea il successivo carattere così com'è
 58 Ridisegna tutto
 59 Fa ripartire l'editor sospeso
 60 Cerca le spiegazioni del comando corrente
-61 Questo carattere è aggiunto alla linea
-62 Questo carattere è il primo in una sequenza di caratteri
+61 Questo carattere è aggiunto alla linea
+62 Questo carattere è il primo in una sequenza di caratteri
 63 Fissa il segno nella posizione del cursore
 64 Corregge la sintassi della parola corrente
 65 Corregge la sintassi dell'intera linea
-66 Invia il carattere sul terminale in modalità `cooked'
+66 Invia il carattere sul terminale in modalità `cooked'
 67 Commuta tra la corrente linea letterale e lessicale dello storico
 68 Scambia il carattere alla sinistra del cursore con quello sotto
 69 Scambia i due caratteri prima del cursore
@@ -82,13 +82,13 @@
 79 Si sposta sulla precedente linea dello storico
 80 Converte in maiuscole le lettere dal cursore fino alla fine della parola corrente
 81 Vi: vai all'inizio della prossima parola
-82 Vi: commuta in modalità di inserimento dopo il cursore
-83 Vi: commuta in modalità di inserimento alla fine della linea
+82 Vi: commuta in modalità di inserimento dopo il cursore
+83 Vi: commuta in modalità di inserimento alla fine della linea
 84 Vi: cambia in da o in maiuscolo la lettera sotto il cursore e avanza di una posizione
 85 Vi: cambia il comando di prefisso
 86 Vi: modifica alla fine della linea
-87 Entra in modalità di comando vi (utilizza le definizioni di tasti alternative)
-88 Vi: modalità di comando a completamento di parola
+87 Entra in modalità di comando vi (utilizza le definizioni di tasti alternative)
+88 Vi: modalità di comando a completamento di parola
 89 Vi: si sposta sul precedente carattere (backspace)
 90 Vi: cancella il comando di prefisso
 91 Vi: avanza sul primo carattere che precede uno spazio
@@ -97,17 +97,17 @@
 94 Vi: avanza al carattere indicato
 95 Vi: si sposta sopra il carattere indicato all'indietro
 96 Vi: si sposta sopra il carattere indicato in avanti
-97 Commuta in modalità di inserimento vi
-98 Commuta in modalità di inserimento vi all'inizio della linea
+97 Commuta in modalità di inserimento vi
+98 Commuta in modalità di inserimento vi all'inizio della linea
 99 Vi: ripete la ricerca del carattere nella stessa direzione
 100 Vi: ripete la ricerca del carattere nella direzione opposta
 101 Vi: ripete la ricerca nella stessa direzione
 102 Vi: ripete la ricerca nella direzione opposta
 103 Vi: rimpiazza il carattere sotto il cursore con quello successivamente introdotto
-104 Vi: modalità di rimpiazzo
+104 Vi: modalità di rimpiazzo
 105 Vi: ricerca nello storico all'indietro
 106 Vi: ricerca nello storico in avanti
-107 Vi: rimpiazza il carattere sotto il cursore e commuta in modalità di inserimento
+107 Vi: rimpiazza il carattere sotto il cursore e commuta in modalità di inserimento
 108 Vi: rimpiazza l'intera linea
 109 Vi: si sposta alla parola precedente
 110 Vi: si sposta alla parola successiva
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/italian/set30
--- a/head/contrib/tcsh/nls/italian/set30	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/italian/set30	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set30,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set30,v 1.3 2011/02/04 18:19:39 christos Exp $
 $ tw.parse.c
 $set 30 
 1 inizio_il_comando %d\n
@@ -10,7 +10,7 @@
 7 Ci sono %d %selenco ugualmente? [n/s] 
 8 sembra = %d\n
 9 \nerrore interno della tcsh: Non mi ricordo cosa stavo facendo!\n
-10 non è una directory
+10 non è una directory
 11 non trovato
 12 non leggibile
 13 sS
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/italian/set4
--- a/head/contrib/tcsh/nls/italian/set4	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/italian/set4	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set4,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set4,v 1.3 2011/02/04 18:19:39 christos Exp $
 $ Termcap strings
 $set 4
 1 aggiunge una linea vuota
@@ -9,13 +9,13 @@
 6 cancella lo schermo
 7 cancella un carattere
 8 cancella una riga
-9 mette in modalità di cancellazione
-10 fine della modalità di cancellazione
-11 fine della modalità di inserimento
+9 mette in modalità di cancellazione
+10 fine della modalità di cancellazione
+11 fine della modalità di inserimento
 12 cursore dalla linea di stato
 13 cursore nella posizione iniziale
 14 inserisce un carattere
-15 mette in modalità di inserimento
+15 mette in modalità di inserimento
 16 inserisce un carattere di riallineamento
 17 muove il cursore verso il basso
 18 muove il cursore verso sinistra
@@ -31,14 +31,14 @@
 28 inizio sottolineatura
 29 fine sottolineatura
 30 segnale ottico
-31 cancella più caratteri
-32 cursore verso il basso più volte
-33 inserisce più caratteri
-34 cursore verso sinistra più volte
-35 cursore verso destra più volte
-36 cursore verso l'alto più volte
+31 cancella più caratteri
+32 cursore verso il basso più volte
+33 inserisce più caratteri
+34 cursore verso sinistra più volte
+35 cursore verso destra più volte
+36 cursore verso l'alto più volte
 37 Ha margini automatizzati
-38 Può usare tabulatori fisici
+38 Può usare tabulatori fisici
 39 Numero di linee
 40 Numero di colonne
 41 Ha il tasto meta
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/italian/set6
--- a/head/contrib/tcsh/nls/italian/set6	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/italian/set6	Fri Mar 02 16:54:40 2012 +0200
@@ -1,8 +1,8 @@
-$ $tcsh: set6,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set6,v 1.3 2011/02/04 18:19:39 christos Exp $
 $ ed.inputl.c
 $set 6
 1 ERRORE: comando illegale per il tasto 0%o\r\n
-2 sì\n
+2 sì\n
 3 modificare\n
 4 annullare\n
 5 no\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/italian/set7
--- a/head/contrib/tcsh/nls/italian/set7	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/italian/set7	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set7,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set7,v 1.3 2011/02/04 18:19:39 christos Exp $
 $ ed.screen.c
 $set 7
 1 \n\tLa tcsh ipotizza che il tuo terminale abbia\n
@@ -7,24 +7,24 @@
 4 \t%s tasto meta\n
 5 il
 6 nessun
-7 \t%s può usare i tabulatori\n
+7 \t%s può usare i tabulatori\n
 8 non
 9 \t%s i margini automatici\n
 10 ha
 11 non ha
 12 \t%s i margini magici\n
 13 (vuoto)
-14 sì
+14 sì
 15 no
 16 ERRORE: non posso cancellare\r\n
-17 DeleteChars: il valore num è ridicolo: %d\r\n
+17 DeleteChars: il valore num è ridicolo: %d\r\n
 18 ERRORE: non posso inserire\r\n
-19 StartInsert: il valore num è ridicolo: %d\r\n
+19 StartInsert: il valore num è ridicolo: %d\r\n
 20 %s: Non riesco ad aprire /etc/termcap.\n
 21 %s: Nessuna definizione per un terminale di tipo "%s"\n
 22 %s: sto usando i settaggi relativi ad un terminale veramente stupido.\n
-23 %s: ATTENZIONE: Il terminale non può scrollare verso l'alto.\n
+23 %s: ATTENZIONE: Il terminale non può scrollare verso l'alto.\n
 24 La modifica delle linee lunghe potrebbe essere difficoltosa.\n
-25 non è possibile cancellare fino alla fine della linea.\n
-26 non è possibile cancellare caratteri.\n
-27 non è possibile inserire caratteri.\n
+25 non è possibile cancellare fino alla fine della linea.\n
+26 non è possibile cancellare caratteri.\n
+27 non è possibile inserire caratteri.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ja/charset
--- a/head/contrib/tcsh/nls/ja/charset	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ja/charset	Fri Mar 02 16:54:40 2012 +0200
@@ -1,3 +1,3 @@
-$ codeset=EUC-JP
+$ codeset=UTF-8
 $set 255
-1 EUC-JP
+1 UTF-8
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ja/set1
--- a/head/contrib/tcsh/nls/ja/set1	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ja/set1	Fri Mar 02 16:54:40 2012 +0200
@@ -1,140 +1,140 @@
-$ $tcsh: set1,v 1.5 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set1,v 1.6 2011/02/04 18:19:39 christos Exp $
 $ Error messages
 $set 1 
-1 ʸˡ¤¬´Ö°ã¤Ã¤Æ¤¤¤Þ¤¹
-2 %s ¤Ï³ä¤êÅö¤Æ¤é¤ì¤Æ¤¤¤Þ¤»¤ó
-3 ʸ»úÎó¤¬Ä¹¤¹¤®¤Þ¤¹
-4 $< ¤Î¹Ô¤¬Ä¹¤¹¤®¤Þ¤¹
-5 $0 ÍѤΥե¡¥¤¥ë¤¬¤¢¤ê¤Þ¤»¤ó
-6 [] ½¤¾þ»Ò¤¬ÉÔ´°Á´¤Ç¤¹
-7 $ Ÿ³«¤Ï ] ¤ÎÁ°¤Ë½ª¤ï¤ëɬÍפ¬¤¢¤ê¤Þ¤¹
-8 $ Æâ¤Î : ½¤¾þ»Ò¤¬´Ö°ã¤Ã¤Æ¤¤¤Þ¤¹ (%c)
-9 ÇÛÎó¤Îź¤¨»ú¤¬´Ö°ã¤Ã¤Æ¤¤¤Þ¤¹
-10 Èֹ椬Àµ¤·¤¤½ñ¼°¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤»¤ó
-11 ʸ»úÎó¤Ï¤â¤¦¤¢¤ê¤Þ¤»¤ó
-12 ¥Õ¥¡¥¤¥ë̾¤¬´Ö°ã¤Ã¤Æ¤¤¤ë¤«¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¤Þ¤»¤ó
-13 glob¤ÎÆâÉô¥¨¥é¡¼¤Ç¤¹
-14 ¥³¥Þ¥ó¥É¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó
-15 °ú¿ô¤¬ÉÔ­¤·¤Æ¤¤¤Þ¤¹
-16 °ú¿ô¤¬Â¿²á¤®¤Þ¤¹
-17 ´í¸±¤Ê¥¨¥¤¥ê¥¢¥¹ÄêµÁ¤Ç¤¹
-18 ifʸ¤ÎÃæ¤Ë¾ò·ï¤¬¤¢¤ê¤Þ¤»¤ó
-19 ´Ö°ã¤Ã¤¿then¤Ç¤¹
-20 ʸ»úÎ󤬳ç¸ÌÆâ¤Ë¤¢¤ê¤Þ¤»¤ó
-21 %s ¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó
-22 ´Ö°ã¤Ã¤¿mask¤Ç¤¹
-23 ¤½¤Î¤è¤¦¤ÊlimitÃͤϤ¢¤ê¤Þ¤»¤ó
-24 °ú¿ô¤¬Ä¹¤¹¤®¤Þ¤¹
-25 ¥ª¥×¥·¥ç¥óñ°Ì¤¬ÉÔÌÀ¤«´Ö°ã¤Ã¤Æ¤¤¤Þ¤¹
-26 ÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤¤ÊÑ¿ô¤Ç¤¹
-27 ¥Ç¥£¥ì¥¯¥È¥ê¡¼¥¹¥¿¥Ã¥¯¤Î»ØÄ꤬¿¼²á¤®¤Þ¤¹
-28 ¥·¥°¥Ê¥ëÈֹ椬´Ö°ã¤Ã¤Æ¤¤¤Þ¤¹
-29 ¥·¥°¥Ê¥ë¤Î̾Á°¤¬´Ö°ã¤Ã¤Æ¤¤¤Þ¤¹ "kill -l"¤Ç¸«¤ë»ö¤¬½ÐÍè¤Þ¤¹
-30 ÊÑ¿ô̾¤Ï±Ñ»ú¤Ç»Ï¤á¤ëɬÍפ¬¤¢¤ê¤Þ¤¹
-31 ÊÑ¿ô¤Î̾Á°¤¬Ä¹¤¹¤®¤Þ¤¹
-32 ÊÑ¿ô̾¤Ï±Ñ¿ô»ú¤À¤±¤Ç¹½À®¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹
-33 ¤³¤Îshell¤Ç¤Ï¥¸¥ç¥Ö¥³¥ó¥È¥í¡¼¥ë¤Ï»ÈÍѤǤ­¤Þ¤»¤ó
-34 ¼°¹½Ê¸?
-35 ¥Û¡¼¥à¥Ç¥£¥ì¥¯¥È¥ê¡¼¤¬¤¢¤ê¤Þ¤»¤ó
-36 ¥Û¡¼¥à¥Ç¥£¥ì¥¯¥È¥ê¡¼¤ËÊѹ¹¤Ç¤­¤Þ¤»¤ó
-37 ÉÔÀµ¤Ê¥Ì¥ë¥³¥Þ¥ó¥É¤Ç¤¹
-38 ÂåÆþ¼°¤¬·ç¤±¤Æ¤¤¤ë²Õ½ê¤¬¤¢¤ê¤Þ¤¹
-39 ÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤¤±é»»»Ò¤Ç¤¹
-40 Û£Ëæ¤Ç¤¹
-41 %s¤È¸À¤¦¥Õ¥¡¥¤¥ë¤Ï¤¹¤Ç¤Ë¸ºß¤·¤Þ¤¹
-42 -cÍѤΰú¿ô¤Ï¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å¤Ç½ª¤ï¤ê¤Þ¤¹
-43 ³ä¤ê¹þ¤ß¤¬Æþ¤ê¤Þ¤·¤¿
-44 ÇÛÎó¤ËÆþ¤ì¤ëź¤¨»ú¤¬ÈϰϤòĶ¤¨¤Æ¤¤¤Þ¤¹
-45 ¹Ô¤Î¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤Ç¤¹
-46 ¤½¤Î¤è¤¦¤Ê¥¸¥ç¥Ö¤Ï¤¢¤ê¤Þ¤»¤ó
-47 üËö¤«¤é¤Ï¤Ç¤­¤Þ¤»¤ó
-48 while/foreach¤ÎÃæ¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó
-49 ¥×¥í¥»¥¹¤òÀ¸À®¤Ç¤­¤Þ¤»¤ó
-50 ¾È¹ç¥Ñ¥¿¡¼¥ó¤Ë¹ç¤¤¤Þ¤»¤ó
-51 %c ¤¬·ç¤±¤Æ¤¤¤ë²Õ½ê¤¬¤¢¤ê¤Þ¤¹
-52 %c ¤¬Âбþ¤·¤Þ¤»¤ó
-53 ¥á¥â¥ê¤¬ÉÔ­¤·¤Æ¤¤¤Þ¤¹
-54 ¥Ñ¥¤¥×¤òºî¤ì¤Þ¤»¤ó
+1 文法が間違っています
+2 %s は割り当てられていません
+3 文字列が長すぎます
+4 $< の行が長すぎます
+5 $0 用のファイルがありません
+6 [] 修飾子が不完å
¨ã§ã™
+7 $ 展開は ] の前に終わるå¿
要があります
+8 $ å†
の : 修飾子が間違っています (%c)
+9 é
åˆ—の添え字が間違っています
+10 番号が正しい書式になっていません
+11 文字列はもうありません
+12 ファイル名が間違っているかファイルが存在しません
+13 globのå†
部エラーです
+14 コマンドが見つかりません
+15 引数が不足しています
+16 引数が多過ぎます
+17 危険なエイリアス定義です
+18 if文の中に条件がありません
+19 間違ったthenです
+20 文字列が括弧å†
にありません
+21 %s が見つかりません
+22 間違ったmaskです
+23 そのようなlimit値はありません
+24 引数が長すぎます
+25 オプション単位が不明か間違っています
+26 定義されていない変数です
+27 ディレクトリースタックの指定が深過ぎます
+28 シグナル番号が間違っています
+29 シグナルの名前が間違っています "kill -l"で見る事が出来ます
+30 変数名は英字で始めるå¿
要があります
+31 変数の名前が長すぎます
+32 変数名は英数字だけで構成するå¿
要があります
+33 このshellではジョブコントロールは使用できません
+34 式構文?
+35 ホームディレクトリーがありません
+36 ホームディレクトリーに変更できません
+37 不正なヌルコマンドです
+38 代å
¥å¼ãŒæ¬ ã‘ている箇所があります
+39 定義されていない演算子です
+40 曖昧です
+41 %sと言うファイルはすでに存在します
+42 -c用の引数はバックスラッシュで終わります
+43 割り込みがå
¥ã‚Šã¾ã—た
+44 é
åˆ—にå
¥ã‚Œã‚‹æ·»ãˆå­—が範囲をè¶
えています
+45 行のオーバーフローです
+46 そのようなジョブはありません
+47 端末からはできません
+48 while/foreachの中ではありません
+49 プロセスを生成できません
+50 ç
§åˆãƒ‘ターンに合いません
+51 %c が欠けている箇所があります
+52 %c が対応しません
+53 メモリが不足しています
+54 パイプを作れません
 55 %s: %s
 56 %s
-57 ·Á¼°: jobs [ -l ]
-58 ¥¢¡¼¥®¥å¥á¥ó¥È¤Ï¥¸¥ç¥Ö¤«¥×¥í¥»¥¹ID¤Ç¤¹.
-59 ¥«¥ì¥ó¥È¤Îjob¤Ï¤¢¤ê¤Þ¤»¤ó
-60 Á°¤Îjob¤Ï¤¢¤ê¤Þ¤»¤ó
-61 ¥¸¥ç¥Ö¤¬¥Ñ¥¿¡¼¥ó¤Ë°ìÃפ·¤Þ¤»¤ó
-62 Fork¤Î¿¼¤µ¤¬ %d¤òĶ¤¨¤Þ¤·¤¿; ¤ª¤½¤é¤¯``¤Î¥Í¥¹¥È¤¬¿¼¤¹¤®¤ë°Ù¤Ç¤¹¡£
-63 ¤³¤Îsubshell¤Ç¤Ï¥¸¥ç¥Ö¥³¥ó¥È¥í¡¼¥ë¤Ï»ÈÍѤǤ­¤Þ¤»¤ó
-64 sync¼ºÇÔ: ¥×¥í¥»¥¹ %d ¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó
-65 %sÃæÃǤ·¤¿job¤¬»Ä¤Ã¤Æ¤¤¤Þ¤¹
-66 %s»ß¤Þ¤Ã¤¿job¤¬»Ä¤Ã¤Æ¤¤¤Þ¤¹
-67 ¾¤Î¥Ç¥£¥ì¥¯¥È¥ê¡¼¤Ï¤¢¤ê¤Þ¤»¤ó
-68 ¥Ç¥£¥ì¥¯¥È¥ê¡¼¥¹¥¿¥Ã¥¯¤Ï¶õ¤Ç¤¹
-69 ¥Ç¥£¥ì¥¯¥È¥ê¡¼Ì¾¤¬´Ö°ã¤Ã¤Æ¤¤¤Þ¤¹
-70 ·Á¼°: %s [-%s]%s
-71 -h¥Õ¥é¥°ÍѤΥª¥Ú¥é¥ó¥É¤¬¤¢¤ê¤Þ¤»¤ó
-72 ¥í¥°¥¤¥ó¥·¥§¥ë¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó
-73 0¤Ç³ä¤ê»»¤·¤Þ¤·¤¿
-74 0¤Ç³ä¤ê»»¤·¤Þ¤·¤¿(;¤ê·×»»)
-75 ´Ö°ã¤Ã¤¿¥ª¥×¥·¥ç¥óñ°Ì¤Ç¤¹: "%s"¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¤«?
-76 ¥í¥°¥¤¥ó¥·¥§¥ë¤Ê¤Î¤ÇÃæÃǤǤ­¤Þ¤»¤ó
-77 %s¤È¤¤¤¦¥æ¡¼¥¶¡¼¤Ï¸ºß¤·¤Þ¤»¤ó
-78 ÊÑ¿ô$home¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Þ¤»¤ó
-79 ·Á¼°: history [-%s] [¥¤¥Ù¥ó¥ÈÈÖ¹æ]
-80 $¡¢ ! ¤â¤·¤¯¤Ï < ¤Ï $# ¤â¤·¤¯¤Ï $? ¤È°ì½ï¤Ë¤Ï»ÈÍѤǤ­¤Þ¤»¤ó
-81 ÊÑ¿ô̾¤Ë²þ¹Ô¤¬Æþ¤Ã¤Æ¤¤¤Þ¤¹
-82 * ¤Ï $# ¤â¤·¤¯¤Ï $? ¤È°ì½ï¤Ë¤Ï»ÈÍѤǤ­¤Þ¤»¤ó
-83 $?<¿ô»ú> ¤â¤·¤¯¤Ï $#<¿ô»ú> ¤Ï»ÈÍѤǤ­¤Þ¤»¤ó
-84 ÊÑ¿ô̾¤¬ÉÔÀµ¤Ç¤¹
-85 ÊÑ¿ô¥¤¥ó¥Ç¥Ã¥¯¥¹¤Ë²þ¹Ô¤¬Æþ¤Ã¤Æ¤¤¤Þ¤¹
-86 Ÿ³«ÍѥХåե¡¡¼¥ª¡¼¥Ð¡¼¥Õ¥í¡¼
-87 ÊÑ¿ô¹½Ê¸?
-88 ´Ö°ã¤Ã¤¿ ! ¤Î½ñ¼°¤Ç¤¹
-89 Á°¤ÎÃÖ´¹¤Ï¤¢¤ê¤Þ¤»¤ó
-90 ÉÔÀµ¤ÊÃÖ´¹¤Ç¤¹
-91 ľÁ°¤Îº¸¥µ¥¤¥É¤¬¤¢¤ê¤Þ¤»¤ó
-92 ±¦¥µ¥¤¥É¤¬Ä¹²á¤®¤Þ¤¹
-93 ´Ö°ã¤Ã¤¿ ! ½¤¾þ»Ò¤Ç¤¹: %c
-94 ½¤¾þ»Ò¤Î¼ºÇԤǤ¹
-95 ÃÖ´¹¥Ð¥Ã¥Õ¥¡¤¬¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤·¤Þ¤·¤¿
-96 ´Ö°ã¤Ã¤¿ ! °ú¿ô¤Î¥»¥ì¥¯¥¿¡¼¤Ç¤¹
-97 Á°¤Î¸¡º÷·ë²Ì¤Ï¤¢¤ê¤Þ¤»¤ó
-98 %s: ¥¤¥Ù¥ó¥È¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó
-99 ")"¤¬Â¿¤¹¤®¤Þ¤¹
-100 "("¤¬Â¿¤¹¤®¤Þ¤¹
-101 ( ¤Î¾ì½ê¤¬´Ö°ã¤Ã¤Æ¤¤¤Þ¤¹
-102 ¥ê¥À¥¤¥ì¥¯¥ÈÀè¤Î̾Á°¤¬·ç¤±¤Æ¤¤¤Þ¤¹
-103 Û£Ëæ¤Ê½ÐÎÏ¥ê¥À¥¤¥ì¥¯¥È¤Ç¤¹
-104 () ¤ÎÃæ¤Ç << ¤Ï»È¤¨¤Þ¤»¤ó
-105 Û£Ëæ¤ÊÆþÎÏ¥ê¥À¥¤¥ì¥¯¥È¤Ç¤¹
-106 () ¤Î¾ì½ê¤¬´Ö°ã¤Ã¤Æ¤¤¤Þ¤¹
-107 ¥¨¥¤¥ê¥¢¥¹¤¬¥ë¡¼¥×¤·¤Æ¤¤¤Þ¤¹
-108 ÊÑ¿ô"$watch"¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Þ¤»¤ó
-109 ¥¹¥±¥¸¥å¡¼¥ë¤µ¤ì¤¿¥¤¥Ù¥ó¥È¤Ï¤¢¤ê¤Þ¤»¤ó
-110 ·Á¼°: sched -<¹àÌÜÈÖ¹æ>.\n·Á¼°: sched [+]hh:mm <¥³¥Þ¥ó¥É>
-111 ¥¹¥±¥¸¥å¡¼¥ë¤µ¤ì¤¿¥¤¥Ù¥ó¥È¤Ï¤¢¤ê¤Þ¤»¤ó
-112 ¼Â¹Ô¤Ç¤­¤ë¥³¥Þ¥ó¥É¤Ï¤¢¤ê¤Þ¤»¤ó
-113 ÉÔÀµ¤Ê¥¤¥Ù¥ó¥È³«»Ï»þ´Ö¤Ç¤¹
-114 am/pm»ØÄê¤ÇÁêÂÐŪ¤Ê»þ´Ö»ØÄê¤Ï¤Ç¤­¤Þ¤»¤ó
-115 termcap¤Îʸ»úÎóÎΰèÉÔ­¤Ç¤¹
-116 ·Á¼°: settc %s [yes|no]
-117 ÃΤé¤Ê¤¤capability `%s'
-118 ÃΤé¤Ê¤¤termcap¥Ñ¥é¥á¥¿ `%%%c'
-119 `%s' ¤ËÂФ¹¤ë°ú¿ô¤¬Â¿²á¤®¤Þ¤¹ (%d)
-120 `%s' ¤Ë¤Ï %d °ú¿ô¤¬É¬ÍפǤ¹
-121 ·Á¼°: echotc [-v|-s] [<capability> [<args>]]
-122 %s: %s. ´Ö°ã¤Ã¤¿¥¢¡¼¥­¥Æ¥¯¥Á¥ã¤Ç¤¹
-123 !# ¥Ò¥¹¥È¥ê¡¼¤Î¥ë¡¼¥×
-124 ÉÔ´°Á´¤Ê¥Õ¥¡¥¤¥ë¥Á¥§¥Ã¥¯¤Ç¤¹
-125 ¥»¥ì¥¯¥¿¡¼ ¥ª¡¼¥Ð¡¼¥Õ¥í¡¼
-126 ÉÔÌÀ¥ª¥×¥·¥ç¥ó: `-%s'\nUsage: %s [ -bcdefilmnqstvVxX -Dname[=value] ] [ argument ... ]
-127 ÉÔÌÀ¥ª¥×¥·¥ç¥ó: `-%s'\nUsage: %s [ -bcdefFilmnqstvVxX ] [ argument ... ]
-128 ÉÔÌÀ¥ª¥×¥·¥ç¥ó: `-%s'\nUsage: %s [ -bcdefilmnqstvVxX ] [ argument ... ]
-129 \nÉÔÀµ¤ÊÊä´°: "%s"
-130 \nÉÔÀµ¤Ê %s: '%c'
-131 \n'%c' ( %s ¤Î¸å¤í)¤Ï´Ö°ã¤Ã¤¿¥»¥Ñ¥ì¡¼¥¿¡¼¤Ç¤¹ "%s"
-132 \nÉÔ´°Á´¤Ê %s: "%s"
-133 -m¥Õ¥é¥°ÍѤΥª¥Ú¥é¥ó¥É¤¬¤¢¤ê¤Þ¤»¤ó
-134 ·Á¼°: unlimit [-fh] [limits]
-135 $%S ¤ÏÆɼèÀìÍѤǤ¹
-136 job¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó
-137 ÉÔÌÀ¤ÎcolorlsÊÑ¿ô¤Ç¤¹ `%c%c'
+57 形式: jobs [ -l ]
+58 アーギュメントはジョブかプロセスIDです.
+59 カレントのjobはありません
+60 前のjobはありません
+61 ジョブがパターンに一致しません
+62 Forkの深さが %dã‚’è¶
えました; おそらく``のネストが深すぎる為です。
+63 このsubshellではジョブコントロールは使用できません
+64 sync失敗: プロセス %d が見つかりません
+65 %s中断したjobが残っています
+66 %s止まったjobが残っています
+67 他のディレクトリーはありません
+68 ディレクトリースタックは空です
+69 ディレクトリー名が間違っています
+70 形式: %s [-%s]%s
+71 -hフラグ用のオペランドがありません
+72 ログインシェルではありません
+73 0で割り算しました
+74 0で割り算しました(余り計算)
+75 間違ったオプション単位です: "%s"ではありませんか?
+76 ログインシェルなので中断できません
+77 %sというユーザーは存在しません
+78 変数$homeが設定されていません
+79 形式: history [-%s] [イベント番号]
+80 $、 ! もしくは < は $# もしくは $? と一緒には使用できません
+81 変数名に改行がå
¥ã£ã¦ã„ます
+82 * は $# もしくは $? と一緒には使用できません
+83 $?<数字> もしくは $#<数字> は使用できません
+84 変数名が不正です
+85 変数インデックスに改行がå
¥ã£ã¦ã„ます
+86 展開用バッファーオーバーフロー
+87 変数構文?
+88 間違った ! の書式です
+89 前の置換はありません
+90 不正な置換です
+91 直前の左サイドがありません
+92 右サイドが長過ぎます
+93 間違った ! 修飾子です: %c
+94 修飾子の失敗です
+95 置換バッファがオーバーフローしました
+96 間違った ! 引数のセレクターです
+97 前の検索結果はありません
+98 %s: イベントが見つかりません
+99 ")"が多すぎます
+100 "("が多すぎます
+101 ( の場所が間違っています
+102 リダイレクトå
ˆã®åå‰ãŒæ¬ ã‘ています
+103 曖昧な出力リダイレクトです
+104 () の中で << は使えません
+105 曖昧なå
¥åŠ›ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã§ã™
+106 () の場所が間違っています
+107 エイリアスがループしています
+108 変数"$watch"が設定されていません
+109 スケジュールされたイベントはありません
+110 形式: sched -<é 
目番号>.\n形式: sched [+]hh:mm <コマンド>
+111 スケジュールされたイベントはありません
+112 実行できるコマンドはありません
+113 不正なイベント開始時間です
+114 am/pm指定で相対的な時間指定はできません
+115 termcapの文字列領域不足です
+116 形式: settc %s [yes|no]
+117 知らないcapability `%s'
+118 知らないtermcapパラメタ `%%%c'
+119 `%s' に対する引数が多過ぎます (%d)
+120 `%s' には %d 引数がå¿
要です
+121 形式: echotc [-v|-s] [<capability> [<args>]]
+122 %s: %s. 間違ったアーキテクチャです
+123 !# ヒストリーのループ
+124 不完å
¨ãªãƒ•ã‚¡ã‚¤ãƒ«ãƒã‚§ãƒƒã‚¯ã§ã™
+125 セレクター オーバーフロー
+126 不明オプション: `-%s'\nUsage: %s [ -bcdefilmnqstvVxX -Dname[=value] ] [ argument ... ]
+127 不明オプション: `-%s'\nUsage: %s [ -bcdefFilmnqstvVxX ] [ argument ... ]
+128 不明オプション: `-%s'\nUsage: %s [ -bcdefilmnqstvVxX ] [ argument ... ]
+129 \n不正な補完: "%s"
+130 \n不正な %s: '%c'
+131 \n'%c' ( %s の後ろ)は間違ったセパレーターです "%s"
+132 \n不完å
¨ãª %s: "%s"
+133 -mフラグ用のオペランドがありません
+134 形式: unlimit [-fh] [limits]
+135 $%S は読取専用です
+136 jobが見つかりません
+137 不明のcolorls変数です `%c%c'
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ja/set10
--- a/head/contrib/tcsh/nls/ja/set10	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ja/set10	Fri Mar 02 16:54:40 2012 +0200
@@ -1,8 +1,8 @@
-$ $tcsh: set10,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set10,v 1.3 2011/02/04 18:19:39 christos Exp $
 $ ma.setp.c
 $set 10 
-1 setpath: ¥³¥Þ¥ó¥É¤¬ÉÔÀµ¤Ç¤¹ '%s'.\n
-2 setpath: '%s' ¥³¥Þ¥ó¥É¤Î¤¿¤á¤Î¥¢¡¼¥®¥å¥á¥ó¥È¤¬ÉÔ­¤·¤Æ¤¤¤Þ¤¹.\n
-3 setpath: ¥Ñ¥¹ '%s'¤ÎÆâÍƤ¬´Ö°ã¤Ã¤Æ¤¤¤Þ¤¹\n
-4 setpath: %s ¤¬ %s ¤ÎÃæ¤Ë¤¢¤ê¤Þ¤»¤ó\n
-5 setpath: %d ¤Ï %s ¤ÎÃæ¤Ç¤Ï,´Ö°ã¤Ã¤¿°ÌÃ֤Ǥ¹\n
+1 setpath: コマンドが不正です '%s'.\n
+2 setpath: '%s' コマンドのためのアーギュメントが不足しています.\n
+3 setpath: パス '%s'のå†
容が間違っています\n
+4 setpath: %s が %s の中にありません\n
+5 setpath: %d は %s の中では,間違った位置です\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ja/set11
--- a/head/contrib/tcsh/nls/ja/set11	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ja/set11	Fri Mar 02 16:54:40 2012 +0200
@@ -1,10 +1,10 @@
-$ $tcsh: set11,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set11,v 1.3 2011/02/04 18:19:39 christos Exp $
 $ sh.c
 $set 11 
-1 ·Ù¹ð: tty¤Ë¥¢¥¯¥»¥¹¤¬¤Ç¤­¤Þ¤»¤ó (%s).\n
-2 ¤³¤Î¤¿¤á¤Ë,¤³¤Îshell¤Ë¤Ï¥¸¥ç¥Ö¥³¥ó¥È¥í¡¼¥ë¤¬¤¢¤ê¤Þ¤»¤ó.\n
-3 ¤¢¤Ê¤¿¤Ë %d Ä̤Υ᡼¥ë¥á¥Ã¥»¡¼¥¸¤¬¤¢¤ê¤Þ¤¹.\n
-4 ¤¢¤Ê¤¿¤Ë %d Ä̤Υ᡼¥ë¥á¥Ã¥»¡¼¥¸¤¬ %s ¤Ë¤¢¤ê¤Þ¤¹.\n
-5 ¤¢¤Ê¤¿¤Ë %s¥á¡¼¥ë¤¬¤¢¤ê¤Þ¤¹.\n
-6 ¿·¤·¤¤
-7 ¤¢¤Ê¤¿¤Ë %s¥á¡¼¥ë¤¬ %s¤Ë¤¢¤ê¤Þ¤¹.\n
+1 警告: ttyにアクセスができません (%s).\n
+2 このために,このshellにはジョブコントロールがありません.\n
+3 あなたに %d 通のメールメッセージがあります.\n
+4 あなたに %d 通のメールメッセージが %s にあります.\n
+5 あなたに %sメールがあります.\n
+6 新しい
+7 あなたに %sメールが %sにあります.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ja/set12
--- a/head/contrib/tcsh/nls/ja/set12	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ja/set12	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set12,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set12,v 1.3 2011/02/04 18:19:39 christos Exp $
 $ sh.dir.c
 $set 12 
-1 %s: "%s"¤«¤é¤Î¼Â¹Ô¤ò»î¤·¤Þ¤¹\n
+1 %s: "%s"からの実行を試します\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ja/set13
--- a/head/contrib/tcsh/nls/ja/set13	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ja/set13	Fri Mar 02 16:54:40 2012 +0200
@@ -1,12 +1,12 @@
-$ $tcsh: set13,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set13,v 1.3 2011/02/04 18:19:39 christos Exp $
 $ sh.exec.c
 $set 13 
 1 hash=%-4d dir=%-2d prog=%s\n
-2 %d ¤Î¥Ï¥Ã¥·¥åÎΰè (%d ¥Ó¥Ã¥ÈËè)\n
-3 ¥Ç¥Ð¥Ã¥°¥Þ¥¹¥¯ = 0x%08x\n
-4 %d À®¸ù, %d ¼ºÇÔ, %d%%\n
-5 %S: ¥·¥§¥ë¤ËÆþ¤Ã¤Æ¤¤¤ë¥³¥Þ¥ó¥É¤Ç¤¹.\n
-6 %S: ¥³¥Þ¥ó¥É¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó\n
-7 where: / ¤¬Æþ¤Ã¤Æ¤¤¤ë¾ì¹ç¤Ï»È¤¨¤Þ¤»¤ó\n
-8 %S ¤Ï¥¨¥¤¥ê¥¢¥¹ÄêµÁ¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹:
-9 %S ¤Ï¥·¥§¥ë¤ËÆþ¤Ã¤Æ¤¤¤Þ¤¹.\n
+2 %d のハッシュ領域 (%d ビット毎)\n
+3 デバッグマスク = 0x%08x\n
+4 %d 成功, %d 失敗, %d%%\n
+5 %S: シェルにå
¥ã£ã¦ã„るコマンドです.\n
+6 %S: コマンドが見つかりません\n
+7 where: / がå
¥ã£ã¦ã„る場合は使えません\n
+8 %S はエイリアス定義を行っています:
+9 %S はシェルにå
¥ã£ã¦ã„ます.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ja/set15
--- a/head/contrib/tcsh/nls/ja/set15	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ja/set15	Fri Mar 02 16:54:40 2012 +0200
@@ -1,7 +1,7 @@
-$ $tcsh: set15,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set15,v 1.3 2011/02/04 18:19:39 christos Exp $
 $ sh.func.c
 $set 15 
-1 %s: %s: %s ½ÐÍè¤Þ¤»¤ó. (%s À©¸Â)\n
-2 ²ò½ü
-3 ÀßÄê
-4 \040¥Ï¡¼¥É
+1 %s: %s: %s 出来ません. (%s 制限)\n
+2 解除
+3 設定
+4 \040ハード
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ja/set16
--- a/head/contrib/tcsh/nls/ja/set16	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ja/set16	Fri Mar 02 16:54:40 2012 +0200
@@ -1,13 +1,13 @@
-$ $tcsh: set16,v 1.3 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set16,v 1.4 2011/02/04 18:19:40 christos Exp $
 $ sh.lex.c
 $set 16 
-1 tty pgrp ¤ò %d ¤«¤é %d¤ËºÆÀßÄꤷ¤Þ¤¹\n
-2 \n¥í¥°¥¢¥¦¥È¤Ï"logout"¤ò»ÈÍѤ·¤Æ²¼¤µ¤¤\n
-3 \n%s½ªÎ»¤Ï"exit"¤ò»ÈÍѤ·¤Æ²¼¤µ¤¤\n
+1 tty pgrp を %d から %dに再設定します\n
+2 \nログアウトは"logout"を使用して下さい\n
+3 \n%s終了は"exit"を使用して下さい\n
 4 seek to eval %x %x\n
 5 seek to alias %x %x\n
 6 seek to file %x\n
-7 ´Ö°ã¤Ã¤¿ seek ¥¿¥¤¥×¤Ç¤¹ %d\n
+7 間違った seek タイプです %d\n
 8 tell eval %x %x\n
 9 tell alias %x %x\n
 10 tell file %x\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ja/set17
--- a/head/contrib/tcsh/nls/ja/set17	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ja/set17	Fri Mar 02 16:54:40 2012 +0200
@@ -1,16 +1,16 @@
-$ $tcsh: set17,v 1.3 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set17,v 1.4 2011/02/04 18:19:40 christos Exp $
 $ sh.proc.c
 $set 17 
-1 ¾ã³²: ¥Ð¥Ã¥°¥°¥é¥¦¥ó¥É¥¸¥ç¥Ö¤òÂԤäƤ¤¤Þ¤¹\n
-2 %d¤Ç½ªÎ»¤·¤Þ¤·¤¿\n
-3 ¾ã³²: ¥×¥í¥»¥¹¥Õ¥é¥Ã¥·¥å¤¬ÆóÅټ¹Ԥµ¤ì¤Þ¤·¤¿
-4 ¼Â¹ÔÃæ¤Ç¤¹
-5 ¥·¥°¥Ê¥ë 
-6 %-d¤Ç½ªÎ»¤·¤Þ¤·¤¿ 
-7 ½ªÎ»
-8 ¾ã³²: ¾õÂÖ=%-9o
-9 \040(core¤ò½ÐÎϤ·¤Þ¤·¤¿)
+1 障害: バッググラウンドジョブをå¾
っています\n
+2 %dで終了しました\n
+3 障害: プロセスフラッシュが二度実行されました
+4 実行中です
+5 シグナル 
+6 %-dで終了しました 
+7 終了
+8 障害: 状æ
‹=%-9o
+9 \040(coreを出力しました)
 10 \040(wd: 
-12 %S: ¤¹¤Ç¤ËÃæÃǤ·¤Æ¤¤¤Þ¤¹\n
-13 %S: ¤¹¤Ç¤ËÄä»ß¤·¤Æ¤¤¤Þ¤¹\n
+12 %S: すでに中断しています\n
+13 %S: すでに停止しています\n
 14 %S: Badly formed number\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ja/set18
--- a/head/contrib/tcsh/nls/ja/set18	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ja/set18	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set18,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set18,v 1.3 2011/02/04 18:19:40 christos Exp $
 $ sh.set.c
 $set 18 
-1 ·Ù¹ð: ÉÔ¼«Á³¤ËŤ¤ PATH ¤ÏÀÚ¤ê¼Î¤Æ¤é¤ì¤Þ¤¹\n
+1 警告: 不自然に長い PATH は切り捨てられます\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ja/set2
--- a/head/contrib/tcsh/nls/ja/set2	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ja/set2	Fri Mar 02 16:54:40 2012 +0200
@@ -1,94 +1,94 @@
-$ $tcsh: set2,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set2,v 1.3 2011/02/04 18:19:40 christos Exp $
 $ Signal names
 $set 2 
-1 ¥Ì¥ë¥·¥°¥Ê¥ë
-2 ¥Ï¥ó¥°¥¢¥Ã¥×
-3 ³ä¤ê¹þ¤ß
-4 ̾ȧ
-5 ÉÔÀµ¤Êµ¡³£¸ì¤ÎÌ¿Îá
-6 ¥È¥ì¡¼¥¹¡¦¥Ö¥ì¡¼¥¯¥Ý¥¤¥ó¥È¥È¥é¥Ã¥×
-7 ¥¢¥Ü¡¼¥È
-8 IOT¥È¥é¥Ã¥×
-9 ¥·¥¹¥Æ¥à¥¯¥é¥Ã¥·¥å²ÄǽÀ­Áý
-10 ¥¨¥é¡¼½ªÎ»
-11 ¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¥È¥é¥Ã¥×
-12 ±é»»Îã³°
-13 ¶¯À©½ªÎ»
-14 ¥æ¡¼¥¶¡¼¥·¥°¥Ê¥ë1
-15 ¥æ¡¼¥¶¡¼¥·¥°¥Ê¥ë2
-16 ¥»¥°¥á¥ó¥È¥¨¥é¡¼
-17 ¥Ð¥¹¥¨¥é¡¼
-18 ¥×¥í¥°¥é¥àÈÏ°Ï¥¨¥é¡¼
-19 ¥ª¥Ú¥é¥ó¥ÉÈÏ°Ï¥¨¥é¡¼
-20 ÉÔÀµ¥·¥¹¥Æ¥à¥³¡¼¥ë
-21 ¥Ñ¥¤¥×Ç˲õ
-22 ¥¢¥é¡¼¥à¥·¥°¥Ê¥ë
-23 ½ªÎ»
-24 »Ò¥×¥í¥»¥¹¤Î¾õÂÖÊѹ¹
-25 »Ò¥×¥í¥»¥¹»àË´
-26 Apollo¸ÂÄꥨ¥é¡¼
-27 »Ò¥×¥í¥»¥¹Ää»ß¤â¤·¤¯¤Ï½ªÎ»
-28 »Ò¥×¥í¥»¥¹½ªÎ»
-29 ÅŸ»°Û¾ï
-30 ¥ê¥½¡¼¥¹¾ÃÌÇ
-31 ¥Ö¥ì¡¼¥¯ (Ctrl-Break)
-32 Æþ½ÐÎÏ ²Äǽ¥·¥°¥Ê¥ë
-33 ÈóƱ´ü I/O (select)
-34 ¥½¥±¥Ã¥È¶ÛµÞÍ×µá
-35 ¿½Å¥¿¥¹¥¯wake-up
-36 ¿½Å¥¿¥¹¥¯kill
-37 FortranÈóƱ´üI/O½ªÎ»
-38 ¥ê¥«¥Ð¥ê
-39 ÉÔÀµ¤Ê¥á¥â¥ê¡¼¥¨¥é¡¼
-40 CPU »þ´ÖÀ©¸Â¥ª¡¼¥Ð¡¼
-41 ¥·¥¹¥Æ¥àÄä»ß ²ÄǽÀ­Áý
-42 ¥Þ¥¤¥¯¥í¥¿¥¹¥­¥ó¥° group-no wakeup ¥Õ¥é¥°ÀßÄê
-43 ¥¹¥ì¥Ã¥É¥¨¥é¡¼ - (cord -T ¤ò»ÈÍѤ·¤Æ¾ÜºÙ¾ðÊó¤ò»²¾È¤·¤Æ²¼¤µ¤¤)
-44 CRAY Y-MP ¥ì¥¸¥¹¥¿¥Ñ¥ê¥Æ¥£¡¼¥¨¥é¡¼
-45 ¾ðÊóÍ×µá
-46 ÃæÃÇ(¥·¥°¥Ê¥ë)
-47 Ää»ß(¥·¥°¥Ê¥ë)
-48 ̾̂
-49 Ää»ß
-50 ·Ñ³
-51 ÃæÃÇ(ttyÆþÎÏ)
-52 Ää»ß(ttyÆþÎÏ)
-53 ÃæÃÇ(tty½ÐÎÏ)
-54 Ää»ß(tty½ÐÎÏ)
-55 ¥¦¥£¥ó¥É¥¦¾õÂÖÊѹ¹
-56 ¥¦¥£¥ó¥É¥¦¥µ¥¤¥ºÊѹ¹
-57 ÅÅÏòóÀþ¾õÂÖÊѹ¹
-58 CPU»þ´ÖÀ©¸Â¥ª¡¼¥Ð¡¼
-59 ¥Õ¥¡¥¤¥ë¥µ¥¤¥ºÀ©¸Â¥ª¡¼¥Ð¡¼
-60 ²¾ÁÛ»þ´Ö¥¢¥é¡¼¥à
-61 ¥×¥í¥Õ¥¡¥¤¥ê¥ó¥°»þ´Ö¥¢¥é¡¼¥à
-62 DIL¥·¥°¥Ê¥ë
-63 ´Æ»ë²Äǽ¥¤¥Ù¥ó¥ÈȯÀ¸
-64 ¥×¥í¥»¥¹¤ÎLWPS¤¬¥Ö¥í¥Ã¥¯¤µ¤ì¤Þ¤·¤¿
-65 ÆÃÊÌ LWP ¥·¥°¥Ê¥ë
-66 ÆÃÊÌ CPR ¥·¥°¥Ê¥ë
-67 ÆÃÊÌ CPR ¥·¥°¥Ê¥ë
-68 Â裱 ¥ê¥¢¥ë¥¿¥¤¥à¥·¥°¥Ê¥ë
-69 Â裲 ¥ê¥¢¥ë¥¿¥¤¥à¥·¥°¥Ê¥ë
-70 Â裳 ¥ê¥¢¥ë¥¿¥¤¥à¥·¥°¥Ê¥ë
-71 Â裴 ¥ê¥¢¥ë¥¿¥¤¥à¥·¥°¥Ê¥ë
-72 Â裴 ºÇ½ª¥ê¥¢¥ë¥¿¥¤¥à¥·¥°¥Ê¥ë
-73 Â裳 ºÇ½ª¥ê¥¢¥ë¥¿¥¤¥à¥·¥°¥Ê¥ë
-74 Â裲 ºÇ½ª¥ê¥¢¥ë¥¿¥¤¥à¥·¥°¥Ê¥ë
-75 ºÇ½ª¥ê¥¢¥ë¥¿¥¤¥à¥·¥°¥Ê¥ë
-76 LAN ÈóƱ´ü I/O
-77 PTY read/write ²Äǽ
-78 I/O ²ðÆþÍ×µá
-79 HFT ¥â¥Ë¥¿¡¼¥â¡¼¥ÉÉÕÍ¿
-80 HFT ¥â¥Ë¥¿¡¼¥â¡¼¥É¤Ërelinguish?¤¬É¬Í×
-81 HFT ¥µ¥¦¥ó¥É¥³¥ó¥È¥í¡¼¥ë´°Î»
-82 HFT ring buffer¤Ë¥Ç¡¼¥¿¤¢¤ê
-83 ¥×¥í¥»¥¹°Ü¹Ô
-84 Secure ¥¢¥Æ¥ó¥·¥ç¥ó¥­¡¼
-85 ºÆ¥¹¥±¥¸¥å¡¼¥ë
-86 ¥·¥°¥Ê¥ë SS$_DEBUG
-87 Í¥ÀèÅÙÊѹ¹
-88 ¿¿¥Ç¥Ã¥É¥í¥Ã¥¯¸¡½Ð
-89 ¿·¤·¤¤Ê¸»úÆþÎÏ
-90 ¥¹¥¿¥Ã¥¯À©¸Â¥ª¡¼¥Ð¡¼
-91 ̤»ÈÍÑ¥·¥°¥Ê¥ë
+1 ヌルシグナル
+2 ハングアップ
+3 割り込み
+4 中止
+5 不正な機械語の命令
+6 トレース・ブレークポイントトラップ
+7 アボート
+8 IOTトラップ
+9 システムクラッシュ可能性増
+10 エラー終了
+11 エミュレーショントラップ
+12 演算例外
+13 強制終了
+14 ユーザーシグナル1
+15 ユーザーシグナル2
+16 セグメントエラー
+17 バスエラー
+18 プログラム範囲エラー
+19 オペランド範囲エラー
+20 不正システムコール
+21 パイプ破壊
+22 アラームシグナル
+23 終了
+24 子プロセスの状æ
‹å¤‰æ›´
+25 子プロセス死亡
+26 Apollo限定エラー
+27 子プロセス停止もしくは終了
+28 子プロセス終了
+29 電源異常
+30 リソース消æ»

+31 ブレーク (Ctrl-Break)
+32 å
¥å‡ºåŠ› 可能シグナル
+33 非同期 I/O (select)
+34 ソケット緊急要求
+35 多重タスクwake-up
+36 多重タスクkill
+37 Fortran非同期I/O終了
+38 リカバリ
+39 不正なメモリーエラー
+40 CPU 時間制限オーバー
+41 システム停止 可能性増
+42 マイクロタスキング group-no wakeup フラグ設定
+43 スレッドエラー - (cord -T を使用して詳細æƒ
報を参ç
§ã—て下さい)
+44 CRAY Y-MP レジスタパリティーエラー
+45 æƒ
報要求
+46 中断(シグナル)
+47 停止(シグナル)
+48 中断
+49 停止
+50 継続
+51 中断(ttyå
¥åŠ›)
+52 停止(ttyå
¥åŠ›)
+53 中断(tty出力)
+54 停止(tty出力)
+55 ウィンドウ状æ
‹å¤‰æ›´
+56 ウィンドウサイズ変更
+57 電話回線状æ
‹å¤‰æ›´
+58 CPU時間制限オーバー
+59 ファイルサイズ制限オーバー
+60 仮想時間アラーム
+61 プロファイリング時間アラーム
+62 DILシグナル
+63 監視可能イベント発生
+64 プロセスのLWPSがブロックされました
+65 特別 LWP シグナル
+66 特別 CPR シグナル
+67 特別 CPR シグナル
+68 第1 リアルタイムシグナル
+69 第2 リアルタイムシグナル
+70 第3 リアルタイムシグナル
+71 第4 リアルタイムシグナル
+72 第4 最終リアルタイムシグナル
+73 第3 最終リアルタイムシグナル
+74 第2 最終リアルタイムシグナル
+75 最終リアルタイムシグナル
+76 LAN 非同期 I/O
+77 PTY read/write 可能
+78 I/O 介å
¥è¦æ±‚
+79 HFT モニターモード付与
+80 HFT モニターモードにrelinguish?がå¿
要
+81 HFT サウンドコントロール完了
+82 HFT ring bufferにデータあり
+83 プロセス移行
+84 Secure アテンションキー
+85 再スケジュール
+86 シグナル SS$_DEBUG
+87 優å
ˆåº¦å¤‰æ›´
+88 真デッドロック検出
+89 新しい文字å
¥åŠ›
+90 スタック制限オーバー
+91 未使用シグナル
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ja/set21
--- a/head/contrib/tcsh/nls/ja/set21	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ja/set21	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,5 @@
-$ $tcsh: set21,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set21,v 1.3 2011/02/04 18:19:40 christos Exp $
 $ tc.disc.c
 $set 21 
-1 ¥í¡¼¥«¥ë¥­¥ã¥é¤ò¼èÆÀ¤Ç¤­¤Þ¤»¤ó.\n
-2 ¥í¡¼¥«¥ë¥­¥ã¥é¤òÀßÄê¤Ç¤­¤Þ¤»¤ó.\n
+1 ローカルキャラを取得できません.\n
+2 ローカルキャラを設定できません.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ja/set29
--- a/head/contrib/tcsh/nls/ja/set29	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ja/set29	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set29,v 1.3 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set29,v 1.4 2011/02/04 18:19:40 christos Exp $
 $ tw.help.c
 $set 29 
-1 %S ÍѤΥإë¥×¥Õ¥¡¥¤¥ë¤¬¤¢¤ê¤Þ¤»¤ó\n
+1 %S 用のヘルプファイルがありません\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ja/set3
--- a/head/contrib/tcsh/nls/ja/set3	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ja/set3	Fri Mar 02 16:54:40 2012 +0200
@@ -1,124 +1,124 @@
 $ $tcsh: set3,v 1.4 2001/04/26 19:07:48 kim Exp $
 $ Editor function descriptions
 $set 3 
-1 1ʸ»úÌá¤ë
-2 ¥«¡¼¥½¥ë°ÌÃÖ¤Îʸ»ú¤òºï½ü
-3 ¸½ºß¤Î¥ï¡¼¥É¤ÎÀèƬ¤«¤é¥«¡¼¥½¥ë¤Þ¤Ç¤òºï½ü - ¥«¥Ã¥È¥Ð¥Ã¥Õ¥¡¡¼¤ËÊݸ
-4 ¹ÔƬ¤«¤é¥«¡¼¥½¥ë¤Þ¤Ç¤òºï½ü - ¥«¥Ã¥È¥Ð¥Ã¥Õ¥¡¡¼¤ËÊݸ
-5 ¸½ºß¤Î¥ï¡¼¥É¤ÎÀèƬ¤Ë°ÜÆ°
-6 ¹ÔƬ¤Ë°ÜÆ°
-7 ¥«¡¼¥½¥ë°ÌÃÖ¤«¤é¥ï¡¼¥É¤ÎËöÈø¤Þ¤Ç¤ò¥­¥ã¥Ô¥¿¥é¥¤¥º
-8 ¥«¡¼¥½¥ë°ÌÃÖ¤ÎÂçʸ»ú¾®Ê¸»ú¤òÊÑ´¹¤·¡¢1ʸ»ú°ÜÆ°(vi)
-9 ¹ÔËö¤Þ¤Ç¤òÊѹ¹(vi)
-10 ²èÌÌ¥¯¥ê¥¢¤·¤Æ¸½ºß¹Ô¤ò²èÌ̤κǾå¹Ô¤Ë
-11 ¸½ºß¤Î¥ï¡¼¥É¤òÊä´°
+1 1文字戻る
+2 カーソル位置の文字を削除
+3 現在のワードのå
ˆé ­ã‹ã‚‰ã‚«ãƒ¼ã‚½ãƒ«ã¾ã§ã‚’削除 - カットバッファーに保存
+4 行頭からカーソルまでを削除 - カットバッファーに保存
+5 現在のワードのå
ˆé ­ã«ç§»å‹•
+6 行頭に移動
+7 カーソル位置からワードの末尾までをキャピタライズ
+8 カーソル位置の大文字小文字を変換し、1文字移動(vi)
+9 行末までを変更(vi)
+10 画面クリアして現在行を画面の最上行に
+11 現在のワードを補完
 12 Tab forward through files
 13 Tab backward through files
-14 ¥×¥í¥°¥é¥à²Äǽ¤ÊÊä´°¤ò»È¤ï¤Ê¤¤¸½ºß¤Î¥ï¡¼¥É¤ÎÊä´°
-15 ¸½ºß¤Î¥ï¡¼¥É¤Î¥«¡¼¥½¥ë°ÌÃ֤ޤǤò¥³¥Ô¡¼
-16 ¥Þ¡¼¥¯°ÌÃÖ¤«¤é¥«¡¼¥½¥ë¤Þ¤Ç¤ÎÎΰè¤ò¥«¥Ã¥È¥Ð¥Ã¥Õ¥¡¡¼¤Ë¥³¥Ô¡¼
+14 プログラム可能な補完を使わない現在のワードの補完
+15 現在のワードのカーソル位置までをコピー
+16 マーク位置からカーソルまでの領域をカットバッファーにコピー
 17 Expand to preceding word for which this is a prefix
-18 ¥«¡¼¥½¥ë°ÌÃÖ¤Îʸ»ú¤òºï½ü
-19 ¥«¡¼¥½¥ë°ÌÃÖ¤Îʸ»ú¤òºï½ü¡£¶õ¹Ô¤Ç¤Ïend of file¤ò¼¨¤¹
-20 ¥«¡¼¥½¥ë°ÌÃÖ¤Îʸ»ú¤òºï½ü¡£¹ÔËö¤Ç¤ÏÊä´°¸õÊä°ìÍ÷
-21 ¥«¡¼¥½¥ë°ÌÃÖ¤Îʸ»ú¤òºï½ü¡£end of file¤òsignal¤â¤·¤¯¤ÏÊä´°¸õÊä°ìÍ÷
-22 ¥«¡¼¥½¥ë°ÌÃÖ¤«¤é¸½ºß¤Î¥ï¡¼¥É¤ÎËöÈø¤Þ¤Ç¤òºï½ü¡£¥«¥Ã¥È¥Ð¥Ã¥Õ¥¡¡¼¤ËÊݸ¡£
+18 カーソル位置の文字を削除
+19 カーソル位置の文字を削除。空行ではend of fileを示す
+20 カーソル位置の文字を削除。行末では補完候補一覧
+21 カーソル位置の文字を削除。end of fileをsignalもしくは補完候補一覧
+22 カーソル位置から現在のワードの末尾までを削除。カットバッファーに保存。
 23 Adds to argument if started or enters digit
 24 Digit that starts argument
-25 ¼¡¤ÎÍúÎò¹Ô¤Ë°ÜÆ°
-26 ¥«¡¼¥½¥ë°ÌÃÖ¤«¤é¸½ºß¤Î¥ï¡¼¥É¤ÎËöÈø¤Þ¤Ç¤ò¾®Ê¸»ú¤Ë¤¹¤ë
-27 ¥Õ¥¡¥¤¥ë½ªÃ¼¤òɽ¼¨
-28 ¹ÔËö¤Ë¥«¡¼¥½¥ë¤ò°ÜÆ°
-29 ¥«¡¼¥½¥ë¤È¥Þ¡¼¥¯¤òÆþ¤ìÂؤ¨¤ë
-30 ¥Õ¥¡¥¤¥ë̾¤Î¥ï¥¤¥ë¥É¥«¡¼¥É¤òŸ³«
-31 ÍúÎò¥¨¥¹¥±¥¤¥×¤òŸ³«
-32 ¹ÔÃæ¤ÎÍúÎò¥¨¥¹¥±¥¤¥×¤òŸ³«
-33 ÊÑ¿ô¤òŸ³«
-34 1ʸ»ú¿Ê¤à
-35 ¸½ºß¤Î¥ï¡¼¥ÉËö¤Þ¤Ç°ÜÆ°
-36 ¥«¡¼¥½¥ë¤ÎÁ°¤Î2ʸ»ú¤òÆþ¤ìÂؤ¨¤ë
-37 ¸½ºß¹Ô¤ÈƱ¤¸¤è¤¦¤Ë»Ï¤Þ¤ë¤â¤Î¤òÍúÎòÃ椫¤é¸å¤í¸þ¤­¤Ë¸¡º÷
-38 ¸½ºß¹Ô¤ÈƱ¤¸¤è¤¦¤Ë»Ï¤Þ¤ë¤â¤Î¤òÍúÎòÃ椫¤éÁ°¸þ¤­¤Ë¸¡º÷
-39 Á°¤Î¥³¥Þ¥ó¥É¤ÎºÇ¸å¤Î¹àÌܤòÁÞÆþ
-40 ½çÊý¸þ¥¤¥ó¥¯¥ê¥á¥ó¥¿¥ë¸¡º÷
-41 µÕÊý¸þ¥¤¥ó¥¯¥ê¥á¥ó¥¿¥ë¸¡º÷
-42 1¹Ô¥¯¥ê¥¢
-43 ¹ÔËö¤Þ¤Çºï½ü¤·¤Æ¥«¥Ã¥È¥Ð¥Ã¥Õ¥¡¡¼¤ËÊݸ
-44 ¥Þ¡¼¥¯°ÌÃÖ¤«¤é¥«¡¼¥½¥ë¤Þ¤Ç¤ÎÎΰè¤òºï½ü¤·¤Æ¥«¥Ã¥È¥Ð¥Ã¥Õ¥¡¡¼¤ËÊݸ
-45 1¹ÔÁ´ÂΤòºï½ü¤·¤Æ¥«¥Ã¥È¥Ð¥Ã¥Õ¥¡¡¼¤ËÊݸ
-46 Êä´°¸õÊä¤Î°ìÍ÷
-47 ¥×¥í¥°¥é¥à²Äǽ¤ÊÊä´°¤ò»ÈÍѤ·¤Ê¤¤Êä´°¸õÊä¤Î°ìÍ÷
-48 ¥ï¥¤¥ë¥É¥«¡¼¥É¤Ë¹çÃפ¹¤ë¥Õ¥¡¥¤¥ë̾¤Î°ìÍ÷
-49 Êä´°¸õÊä¤Î°ìÍ÷¡£¶õ¹Ô¤Î¾ì¹ç¤Ïend of file¤ò¼¨¤¹¡£
-50 Ê¿¶ÑÉé²Ù¤È¸½ºß¤Î¥×¥í¥»¥¹¤Î¾õÂÖ¤òɽ¼¨
-51 ÍúÎò¥¨¥¹¥±¥¤¥×¤òŸ³«¤·¤Æ¶õÇò¤òÁÞÆþ
-52 ¥³¥Þ¥ó¥É¼Â¹Ô
-53 ¥Ñ¥¹Ì¾¤òŸ³«(.¤ä..¤Ç»Ï¤Þ¤ë¤â¤Î¤ò½ü¤¯)
-54 ¥³¥Þ¥ó¥É¤ò¼ÂºÝ¤Î¥Ñ¥¹Ì¾¤äÊÌ̾¤ËŸ³«
-55 ÁÞÆþ¥â¡¼¥É¤«¤é¾å½ñ¤­¥â¡¼¥É¤Ø¤ÎÀÚ¤êÂؤ¨¤â¤·¤¯¤Ï¤½¤ÎµÕ
-56 ¼¡¤ËÂǤÄʸ»ú¤Î8bit¤á¤òΩ¤Æ¤ë
-57 ¼¡¤ËÂǤÄʸ»ú¤ò¹Ô¤Ë¤½¤Î¤Þ¤Þ²Ã¤¨¤ë
-58 ¤¹¤Ù¤Æ¤òºÆÉÁ²è
-59 Ää»ß¤·¤Æ¤¤¤¿¥¨¥Ç¥£¥¿¡¼¤òºÆµ¯Æ°
-60 ¸½ºß¤Î¥³¥Þ¥ó¥É¤Î¥Ø¥ë¥×¤òõ¤¹
-61 ¤³¤Îʸ»ú¤Ï¹Ô¤Ë²Ã¤¨¤é¤ì¤ë
-62 ¤³¤Îʸ»ú¤Ïʸ»ú¥·¡¼¥±¥ó¥¹¤ÎÀèƬ
-63 ¥«¡¼¥½¥ë°ÌÃÖ¤ò¥Þ¡¼¥¯¤¹¤ë
-64 ¸½ºß¤Î¥ï¡¼¥É¤ÎÄÖ¤ê¤òÄûÀµ
-65 1¹ÔÁ´ÂΤÎÄÖ¤ê¤òÄûÀµC
-66 ʸ»ú¤òcocked¥â¡¼¥É¤Çtty¤ËÁ÷¤ë
+25 次の履歴行に移動
+26 カーソル位置から現在のワードの末尾までを小文字にする
+27 ファイル終端を表示
+28 行末にカーソルを移動
+29 カーソルとマークをå
¥ã‚Œæ›¿ãˆã‚‹
+30 ファイル名のワイルドカードを展開
+31 履歴エスケイプを展開
+32 行中の履歴エスケイプを展開
+33 変数を展開
+34 1文字進む
+35 現在のワード末まで移動
+36 カーソルの前の2文字をå
¥ã‚Œæ›¿ãˆã‚‹
+37 現在行と同じように始まるものを履歴中から後ろ向きに検索
+38 現在行と同じように始まるものを履歴中から前向きに検索
+39 前のコマンドの最後のé 
目を挿å
¥
+40 順方向インクリメンタル検索
+41 逆方向インクリメンタル検索
+42 1行クリア
+43 行末まで削除してカットバッファーに保存
+44 マーク位置からカーソルまでの領域を削除してカットバッファーに保存
+45 1è¡Œå
¨ä½“を削除してカットバッファーに保存
+46 補完候補の一覧
+47 プログラム可能な補完を使用しない補完候補の一覧
+48 ワイルドカードに合致するファイル名の一覧
+49 補完候補の一覧。空行の場合はend of fileを示す。
+50 平均負荷と現在のプロセスの状æ
‹ã‚’表示
+51 履歴エスケイプを展開して空白を挿å
¥
+52 コマンド実行
+53 パス名を展開(.や..で始まるものを除く)
+54 コマンドを実際のパス名や別名に展開
+55 挿å
¥ãƒ¢ãƒ¼ãƒ‰ã‹ã‚‰ä¸Šæ›¸ããƒ¢ãƒ¼ãƒ‰ã¸ã®åˆ‡ã‚Šæ›¿ãˆã‚‚しくはその逆
+56 次に打つ文字の8bitめを立てる
+57 次に打つ文字を行にそのまま加える
+58 すべてを再描画
+59 停止していたエディターを再起動
+60 現在のコマンドのヘルプを探す
+61 この文字は行に加えられる
+62 この文字は文字シーケンスのå
ˆé ­
+63 カーソル位置をマークする
+64 現在のワードの綴りを訂正
+65 1è¡Œå
¨ä½“の綴りを訂正C
+66 文字をcockedモードでttyに送る
 67 Toggle between literal and lexical current history line
-68 ¥«¡¼¥½¥ë¤Îº¸¤Îʸ»ú¤ò1¤Ä¾®¤µ¤¤¤â¤Î¤Ë¤¹¤ë
-69 ¥«¡¼¥½¥ë¤ÎÁ°¤Î2¤Ä¤Îʸ»ú¤òÆþ¤ìÂؤ¨¤ë
-70 delayed suspendʸ»ú¤ò»î¤¹
-71 flush outputʸ»ú¤ò»î¤¹
-72 interruptʸ»ú¤ò»î¤¹
-73 quitʸ»ú¤ò»î¤¹
-74 suspendʸ»ú¤ò»î¤¹
-75 allow outputʸ»ú¤ò»î¤¹
-76 disallowʸ»ú¤ò»î¤¹
-77 ³ä¤êÅö¤Æ¤é¤ì¤Æ¤¤¤Ê¤¤Ê¸»ú¤òɽ¼¨
+68 カーソルの左の文字を1つ小さいものにする
+69 カーソルの前の2つの文字をå
¥ã‚Œæ›¿ãˆã‚‹
+70 delayed suspend文字を試す
+71 flush output文字を試す
+72 interrupt文字を試す
+73 quit文字を試す
+74 suspend文字を試す
+75 allow output文字を試す
+76 disallow文字を試す
+77 割り当てられていない文字を表示
 78 Emacs universal argument (argument times 4)
-79 1¤ÄÁ°¤ÎÍúÎò¹Ô¤Ë°ÜÆ°
-80 ¥«¡¼¥½¥ë°ÌÃÖ¤«¤é¸½ºß¤Î¥ï¡¼¥É¤ÎËöÈø¤Þ¤Ç¤òÂçʸ»ú¤Ë¤¹¤ë
-81 ¼¡¤Î¥ï¡¼¥É¤ÎÀèƬ¤Ø°ÜÆ°(vi)
-82 ¥«¡¼¥½¥ë¤Î¸å¤í¤ØÁÞÆþ¥â¡¼¥É¤Ø°Ü¹Ô(vi)
-83 ¥«¡¼¥½¥ë°ÌÃÖ¤ËÁÞÆþ¥â¡¼¥É¤Ø°Ü¹Ô(vi)
-84 ¥«¡¼¥½¥ë°ÌÃÖ¤ÎÂçʸ»ú¾®Ê¸»ú¤òÊÑ´¹¤·¡¢1ʸ»ú¿Ê¤à(vi)
+79 1つ前の履歴行に移動
+80 カーソル位置から現在のワードの末尾までを大文字にする
+81 次のワードのå
ˆé ­ã¸ç§»å‹•(vi)
+82 カーソルの後ろへ挿å
¥ãƒ¢ãƒ¼ãƒ‰ã¸ç§»è¡Œ(vi)
+83 カーソル位置に挿å
¥ãƒ¢ãƒ¼ãƒ‰ã¸ç§»è¡Œ(vi)
+84 カーソル位置の大文字小文字を変換し、1文字進む(vi)
 85 Vi change prefix command
-86 ¹ÔËö¤Þ¤Ç¤òÊѹ¹(vi)
-87 ¥³¥Þ¥ó¥É¥â¡¼¥É¤Ø°Ü¹Ô (¥­¡¼³ä¤êÅö¤ÆÊѹ¹)(vi)
-88 ¥³¥Þ¥ó¥É¥â¡¼¥É¤Ç¤Î¸½ºß¤Î¥ï¡¼¥É¤ÎÊä´°(vi)
-89 Á°¤Îʸ»ú¤Ë°ÜÆ°(¥Ð¥Ã¥¯¥¹¥Ú¥¤¥¹)(vi)
+86 行末までを変更(vi)
+87 コマンドモードへ移行 (キー割り当て変更)(vi)
+88 コマンドモードでの現在のワードの補完(vi)
+89 前の文字に移動(バックスペイス)(vi)
 90 Vi delete prefix command
-91 ¸½ºß¤Î¥ï¡¼¥É´Ö¤Î¶õÇò¤ÎËöÈø¤Ë°ÜÆ°(vi)
-92 ¸½ºß¤Î¥ï¡¼¥É¤ÎËöÈø¤Ë°ÜÆ°(vi)
-93 µÕÊý¸þ¤Î»ØÄꤵ¤ì¤¿Ê¸»ú¤Ë°ÜÆ°(vi)
-94 ½çÊýË¡¤Î»ØÄꤵ¤ì¤¿Ê¸»ú¤Ë°ÜÆ°(vi)
-95 µÕÊý¸þ¤Î»ØÄꤵ¤ì¤¿Ê¸»ú¤ÎľÁ°¤Þ¤Ç°ÜÆ°(vi)
-96 ½çÊý¸þ¤Î»ØÄꤵ¤ì¤¿Ê¸»ú¤ÎľÁ°¤Þ¤Ç°ÜÆ°(vi)
-97 vi¤ÎÁÞÆþ¥â¡¼¥É¤Ë°Ü¹Ô
-98 ¹ÔƬ¤Çvi¤ÎÁÞÆþ¥â¡¼¥É¤Ë°Ü¹Ô
-99 ¸½ºß¤Î1ʸ»ú¸¡º÷¤òƱ¤¸Êý¸þ¤Ë·«¤êÊÖ¤¹(vi)
-100 ¸½ºß¤Î1ʸ»ú¸¡º÷¤òÈ¿ÂÐÊý¸þ¤Ë·«¤êÊÖ¤¹(vi)
-101 ¸½ºß¤Î¸¡º÷¤òƱ¤¸Êý¸þ¤Ë·«¤êÊÖ¤¹(vi)
-102 ¸½ºß¤Î¸¡º÷¤òÈ¿ÂÐÊý¸þ¤Ë·«¤êÊÖ¤¹(vi)
-103 °ÌÃÖ¤Î1ʸ»ú¤ò¼¡¤ËÂǤÄ1ʸ»ú¤ÈÃÖ´¹(vi)
-104 ÃÖ´¹¥â¡¼¥Éreplace mode(vi)
-105 µÕÊý¸þÍúÎò¸¡º÷(vi)
-106 ½çÊý¸þÍúÎò¸¡º÷(vi)
-107 ¥«¡¼¥½¥ë°ÌÃÖ¤Îʸ»ú¤òÃÖ´¹¤·¤ÆÁÞÆþ¥â¡¼¥É¤Ë°Ü¹Ô(vi)
-108 1¹ÔÁ´ÃÖ´¹(vi)
-109 Á°¤Î¥ï¡¼¥É¤Ø°ÜÆ°(vi)
-110 ¼¡¤Î¥ï¡¼¥É¤Ø°Ü¹Ô(vi)
-111 ľÁ°¤ÎÊѹ¹¤ò¼è¤ê¾Ã¤¹(vi)
-112 ¹Ô¤ÎÀèƬ¤Ø°ÜÆ°(vi)
+91 現在のワード間の空白の末尾に移動(vi)
+92 現在のワードの末尾に移動(vi)
+93 逆方向の指定された文字に移動(vi)
+94 順方法の指定された文字に移動(vi)
+95 逆方向の指定された文字の直前まで移動(vi)
+96 順方向の指定された文字の直前まで移動(vi)
+97 viの挿å
¥ãƒ¢ãƒ¼ãƒ‰ã«ç§»è¡Œ
+98 行頭でviの挿å
¥ãƒ¢ãƒ¼ãƒ‰ã«ç§»è¡Œ
+99 現在の1文字検索を同じ方向に繰り返す(vi)
+100 現在の1文字検索を反対方向に繰り返す(vi)
+101 現在の検索を同じ方向に繰り返す(vi)
+102 現在の検索を反対方向に繰り返す(vi)
+103 位置の1文字を次に打つ1文字と置換(vi)
+104 置換モードreplace mode(vi)
+105 逆方向履歴検索(vi)
+106 順方向履歴検索(vi)
+107 カーソル位置の文字を置換して挿å
¥ãƒ¢ãƒ¼ãƒ‰ã«ç§»è¡Œ(vi)
+108 1è¡Œå
¨ç½®æ›(vi)
+109 前のワードへ移動(vi)
+110 次のワードへ移行(vi)
+111 直前の変更を取り消す(vi)
+112 行のå
ˆé ­ã¸ç§»å‹•(vi)
 113 Perform which of current command
-114 ¥«¥Ã¥È¥Ð¥Ã¥Õ¥¡¡¼¤ÎÆâÍƤò¥«¡¼¥½¥ë°ÌÃ֤ˎ¤êÉÕ¤±¤ë
+114 カットバッファーのå†
容をカーソル位置に貼り付ける
 115 Replace just-yanked text with yank from earlier kill
-116 (WIN32¤Î¤ß) ¥«¥Ã¥È¥Ð¥Ã¥Õ¥¡¡¼¤ÎÆâÍƤò¥·¥¹¥Æ¥à¤Î¥¯¥ê¥Ã¥×¥Ü¡¼¥É¤Ë¥³¥Ô¡¼
-117 (WIN32¤Î¤ß) ¥¯¥ê¥Ã¥×¥Ü¡¼¥É¤ÎÆâÍƤò¥«¡¼¥½¥ë°ÌÃ֤ˎ¤êÉÕ¤±
-118 (WIN32¤Î¤ß) ¼¡¤Î¥ï¡¼¥ÉÃæ¤Î'/'¤ò¤¹¤Ù¤Æ'\\\\'¤ËÊÑ´¹
-119 (WIN32¤Î¤ß) Á°¤Î¥ï¡¼¥ÉÃæ¤Î'/'¤ò¤¹¤Ù¤Æ'\\\\'¤ËÊÑ´¹
-120 (WIN32¤Î¤ß) Page visible console window up
-121 (WIN32¤Î¤ß) Page visible console window down
+116 (WIN32のみ) カットバッファーのå†
容をシステムのクリップボードにコピー
+117 (WIN32のみ) クリップボードのå†
容をカーソル位置に貼り付け
+118 (WIN32のみ) 次のワード中の'/'をすべて'\\\\'に変換
+119 (WIN32のみ) 前のワード中の'/'をすべて'\\\\'に変換
+120 (WIN32のみ) Page visible console window up
+121 (WIN32のみ) Page visible console window down
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ja/set30
--- a/head/contrib/tcsh/nls/ja/set30	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ja/set30	Fri Mar 02 16:54:40 2012 +0200
@@ -1,16 +1,16 @@
-$ $tcsh: set30,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set30,v 1.3 2011/02/04 18:19:40 christos Exp $
 $ tw.parse.c
 $set 30 
-1 ¥³¥Þ¥ó¥É³«»Ï %d\n
-2 ´°Î» %d 
-3 ´°Î» %d %S\n
-4 %s: ÆâÉô¥Þ¥Ã¥Á¥¨¥é¡¼.\n
+1 コマンド開始 %d\n
+2 完了 %d 
+3 完了 %d %S\n
+4 %s: å†
部マッチエラー.\n
 5 items
 6 rows
-7 %d %s¤¢¤ê¤Þ¤¹. ¥ê¥¹¥È½ÐÎϤò¹Ô¤¤¤Þ¤¹¤«? [n/y] 
-8 ɽ¼¨ = %d\n
-9 \ntcsh ÆâÉô¥¨¥é¡¼: ²¿¤òõ¤·¤Æ¤¤¤ë¤«Ê¬¤«¤é¤Ê¤¯¤Ê¤Ã¤Æ¤·¤Þ¤Ã¤¿!\n
-10 ¥Ç¥£¥ì¥¯¥È¥ê¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó
-11 ¸«¤Ä¤«¤ê¤Þ¤»¤ó
-12 Æɤ߹þ¤à¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó
+7 %d %sあります. リスト出力を行いますか? [n/y] 
+8 表示 = %d\n
+9 \ntcsh å†
部エラー: 何を探しているか分からなくなってしまった!\n
+10 ディレクトリではありません
+11 見つかりません
+12 読み込むことができません
 13 yY
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ja/set4
--- a/head/contrib/tcsh/nls/ja/set4	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ja/set4	Fri Mar 02 16:54:40 2012 +0200
@@ -1,45 +1,45 @@
 $ $tcsh: set4,v 1.2 1995/03/19 18:07:15 christos Exp $
 $ Termcap strings
 $set 4
-1 ¶õ¹ÔÁÞÆþ
-2 ²ÄÄ°¥Ù¥ë
-3 ²èÌÌËö¤Þ¤Ç¾Ãµî
-4 ¹ÔËö¤Þ¤Ç¾Ãµî
-5 ¥«¡¼¥½¥ë¿åÊ¿°ÜÆ°
-6 ²èÌ̾õî
-7 1ʸ»úºï½ü
-8 1¹Ôºï½ü
-9 ºï½ü¥â¡¼¥É³«»Ï
-10 ºï½ü¥â¡¼¥É½ªÎ»
-11 ÁÞÆþ¥â¡¼¥É½ªÎ»
-12 ¥¹¥Æ¡¼¥¿¥¹¹Ô¤«¤é¥«¡¼¥½¥ë¤òÉüµ¢
-13 ¥«¡¼¥½¥ë¤ò¥Û¡¼¥à°ÌÃÖ¤Ø
-14 ʸ»úÁÞÆþ
-15 ÁÞÆþ¥â¡¼¥É³«»Ï
-16 ¥Ñ¥Ç¥£¥ó¥°ÁÞÆþ
-17 ¥«¡¼¥½¥ë²¼°ÜÆ°
-18 ¥«¡¼¥½¥ëº¸°ÜÆ°
-19 ¥«¡¼¥½¥ë±¦°ÜÆ°
-20 ¥«¡¼¥½¥ë¾å°ÜÆ°
-21 ÂÀ»ú³«»Ï
-22 °À­½ªÎ»
-23 ʬ³ä¶Ø»ß¶õÇò
-24 ¶¯Ä´½ªÎ»
-25 ¶¯Ä´³«»Ï
-26 ¥«¡¼¥½¥ë¤ò¥¹¥Æ¡¼¥¿¥¹¹Ô¤Ø
-27 ¥«¡¼¥½¥ë¤ò1¤Ä¾å¤Ø
-28 ²¼Àþ³«»Ï
-29 ²¼Àþ½ªÎ»
-30 ²Ä»ë¥Ù¥ë
-31 Ê£¿ôʸ»úºï½ü
-32 ¥«¡¼¥½¥ë²¼°ÜÆ°(multiple)
-33 Ê£¿ôʸ»úÁÞÆþ
-34 ¥«¡¼¥½¥ëjº¸°ÜÆ°(multiple)
-35 ¥«¡¼¥½¥ë±¦°ÜÆ°(multiple)
-36 ¥«¡¼¥½¥ë¾å°ÜÆ°(multiple)
-37 ¼«Æ°¥Þ¡¼¥¸¥ó²Äǽ
-38 ʪÍý¥¿¥Ö»ÈÍѲÄǽ
-39 ¹Ô¿ô
-40 ·å¿ô
-41 ¥á¥¿¥­¡¼¤¢¤ê
-42 ±¦¥Þ¡¼¥¸¥ó¤ò̵»ë¤·¤¿²þ¹Ô
+1 空行挿å
¥
+2 可聴ベル
+3 画面末まで消去
+4 行末まで消去
+5 カーソル水平移動
+6 画面消去
+7 1文字削除
+8 1行削除
+9 削除モード開始
+10 削除モード終了
+11 挿å
¥ãƒ¢ãƒ¼ãƒ‰çµ‚了
+12 ステータス行からカーソルを復帰
+13 カーソルをホーム位置へ
+14 文字挿å
¥
+15 挿å
¥ãƒ¢ãƒ¼ãƒ‰é–‹å§‹
+16 パディング挿å
¥
+17 カーソル下移動
+18 カーソル左移動
+19 カーソル右移動
+20 カーソル上移動
+21 太字開始
+22 属性終了
+23 分割禁止空白
+24 強調終了
+25 強調開始
+26 カーソルをステータス行へ
+27 カーソルを1つ上へ
+28 下線開始
+29 下線終了
+30 可視ベル
+31 複数文字削除
+32 カーソル下移動(multiple)
+33 複数文字挿å
¥
+34 カーソルj左移動(multiple)
+35 カーソル右移動(multiple)
+36 カーソル上移動(multiple)
+37 自動マージン可能
+38 物理タブ使用可能
+39 行数
+40 桁数
+41 メタキーあり
+42 右マージンを無視した改行
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ja/set5
--- a/head/contrib/tcsh/nls/ja/set5	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ja/set5	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set5,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set5,v 1.3 2011/02/04 18:19:40 christos Exp $
 $ ed.chared.c
 $set 5
-1 ¥·¥¹¥Æ¥àÉé²Ùɽ¼¨¤Ï»ÈÍѤǤ­¤Þ¤»¤ó\n
+1 システム負荷表示は使用できません\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ja/set6
--- a/head/contrib/tcsh/nls/ja/set6	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ja/set6	Fri Mar 02 16:54:40 2012 +0200
@@ -1,11 +1,11 @@
-$ $tcsh: set6,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set6,v 1.3 2011/02/04 18:19:40 christos Exp $
 $ ed.inputl.c
 $set 6
-1 ¥¨¥é¡¼: ÉÔÀµ¤Ê¥­¡¼¤«¤é¤Î¥³¥Þ¥ó¥É 0%o\r\n
-2 ¤Ï¤¤\n
-3 ÊÔ½¸\n
-4 ̾ȧ\n
-5 ¤¤¤¤¤¨\n
-6 °ìÃפ·¤¿¥³¥Þ¥ó¥É¤¬¤¢¤ê¤Þ¤»¤ó\n
-7 Û£Ëæ¤Ê¥³¥Þ¥ó¥É¤Ç¤¹\n
-8 *** ¥¨¥Ç¥£¥¿¡¼¤ÎÃ×̿Ū¥¨¥é¡¼ ***\r\n\n
+1 エラー: 不正なキーからのコマンド 0%o\r\n
+2 はい\n
+3 編集\n
+4 中止\n
+5 いいえ\n
+6 一致したコマンドがありません\n
+7 曖昧なコマンドです\n
+8 *** エディターの致命的エラー ***\r\n\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ja/set7
--- a/head/contrib/tcsh/nls/ja/set7	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ja/set7	Fri Mar 02 16:54:40 2012 +0200
@@ -1,30 +1,30 @@
-$ $tcsh: set7,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set7,v 1.3 2011/02/04 18:19:40 christos Exp $
 $ ed.screen.c
 $set 7
-1 \n\tTcsh ¤Î¿ä¬¤Ç¤Ï¡¢¤¢¤Ê¤¿¤ÎüËö¤Ï\n
-2 \t°Ê²¼¤ÎÆÃÀ­¤ò»ý¤Ã¤Æ¤¤¤Þ¤¹:\n\n
-3 \t%d ·å %d ¹Ô\n
-4 \tmeta ¥­¡¼¤ò%s\n
-5 »ý¤Ã¤Æ¤¤¤Þ¤¹
-6 »ý¤Ã¤Æ¤¤¤Þ¤»¤ó
-7 \ttab ¤ò»È¤¦%s\n
-8 ¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó
-9 \t¼«Æ°¥Þ¡¼¥¸¥ó¤ò%s\n
-10 »ý¤Ã¤Æ¤¤¤Þ¤¹
-11 »ý¤Ã¤Æ¤¤¤Þ¤»¤ó
-12 \t¥Þ¥¸¥Ã¥¯¥Þ¡¼¥¸¥ó¤ò%s\n
-13 (̤ÄêµÁ)
-14 ¤¢¤ë
-15 ¤Ê¤¤
-16 ¥¨¥é¡¼: ºï½ü¤Ç¤­¤Þ¤»¤ó\r\n
-17 DeleteChars: ¤¢¤ê¤¨¤Ê¤¤¿ôÃͤǤ¹: %d\r\n
-18 ¥¨¥é¡¼: ÁÞÆþ¤Ç¤­¤Þ¤»¤ó\r\n
-19 StartInsert: ¤¢¤ê¤¨¤Ê¤¤¿ôÃͤǤ¹: %d\r\n
-20 %s: /etc/termcap ¤ò³«¤¯¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó.\n
-21 %s: ¥¿¡¼¥ß¥Ê¥ë¥¿¥¤¥× "%s" ¤ÏÅÐÏ¿¤µ¤ì¤Æ¤¤¤Þ¤»¤ó\n
-22 %s: ¥À¥àüËö¤ÎÀßÄê¤ò»È¤¤¤Þ¤¹\n
-23 %s: ·Ù¹ð: ¤¢¤Ê¤¿¤ÎüËö¤Ï move up ¤Ç¤­¤Þ¤»¤ó.\n
-24 Ť¤¹Ô¤Î¤¿¤áÊÔ½¸¤¬¤ª¤«¤·¤¯¤Ê¤Ã¤Æ¤¤¤Þ¤¹.\n
-25 ¹ÔËö¤Þ¤Ç¾Ãµî¤¹¤ë¤¿¤á¤Îµ¡Ç½¤¬¤¢¤ê¤Þ¤»¤ó.\n
-26 ʸ»úºï½ü¤Îµ¡Ç½¤¬¤¢¤ê¤Þ¤»¤ó.\n
-27 ʸ»úÁÞÆþ¤Îµ¡Ç½¤¬¤¢¤ê¤Þ¤»¤ó.\n
+1 \n\tTcsh の推測では、あなたの端末は\n
+2 \t以下の特性を持っています:\n\n
+3 \t%d 桁 %d 行\n
+4 \tmeta キーを%s\n
+5 持っています
+6 持っていません
+7 \ttab を使う%s\n
+8 ことができません
+9 \t自動マージンを%s\n
+10 持っています
+11 持っていません
+12 \tマジックマージンを%s\n
+13 (未定義)
+14 ある
+15 ない
+16 エラー: 削除できません\r\n
+17 DeleteChars: ありえない数値です: %d\r\n
+18 エラー: 挿å
¥ã§ãã¾ã›ã‚“\r\n
+19 StartInsert: ありえない数値です: %d\r\n
+20 %s: /etc/termcap を開くことができません.\n
+21 %s: ターミナルタイプ "%s" は登録されていません\n
+22 %s: ダム端末の設定を使います\n
+23 %s: 警告: あなたの端末は move up できません.\n
+24 長い行のため編集がおかしくなっています.\n
+25 行末まで消去するための機能がありません.\n
+26 文字削除の機能がありません.\n
+27 文字挿å
¥ã®æ©Ÿèƒ½ãŒã‚りません.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ja/set8
--- a/head/contrib/tcsh/nls/ja/set8	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ja/set8	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,5 @@
-$ $tcsh: set8,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set8,v 1.3 2011/02/04 18:19:40 christos Exp $
 $ ed.term.c
 $set 8
-1 ÉÔÌÀ¤Êswitch
-2 ÉÔÀµ¤Ê¥¢¡¼¥®¥å¥á¥ó¥È¤Ç¤¹
+1 不明なswitch
+2 不正なアーギュメントです
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/russian/charset
--- a/head/contrib/tcsh/nls/russian/charset	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/russian/charset	Fri Mar 02 16:54:40 2012 +0200
@@ -1,3 +1,3 @@
-$ codeset=KOI8-R
+$ codeset=UTF-8
 $set 255
-1 KOI8-R
+1 UTF-8
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/russian/set1
--- a/head/contrib/tcsh/nls/russian/set1	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/russian/set1	Fri Mar 02 16:54:40 2012 +0200
@@ -1,140 +1,140 @@
-$ $tcsh: set1,v 1.4 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set1,v 1.5 2011/02/04 18:19:41 christos Exp $
 $ Error messages
 $set 1 
-1 óÉÎÔÁËÓÉÞÅÓËÁÑ ÏÛÉÂËÁ
-2 %s ÎÅÄÏÐÕÓÔÉÍÏ
-3 óÌÏ×Ï ÓÌÉÛËÏÍ ÄÌÉÎÎÏÅ
-4 $< ÓÔÒÏËÁ ÓÌÉÛËÏÍ ÄÌÉÎÎÁÑ
-5 îÅÔ ÆÁÊÌÁ ÄÌÑ $0
-6 îÅÚÁ×ÅÒÛ£ÎÎÙÊ ÍÏÄÉÆÉËÁÔÏÒ []
-7 $ ÒÁÓÛÉÒÅÎÉÅ ÄÏÌÖÎÏ ÏËÁÎÞÉ×ÁÔØÓÑ ÐÅÒÅÄ ]
-8 ðÌÏÈÏÊ ÍÏÄÉÆÉËÁÔÏÒ × $ (%c)
-9 ïÛÉÂËÁ ÐÏÄÐÒÏÇÒÁÍÍÙ
-10 îÅÐÒÁ×ÉÌØÎÏ ÓÆÏÒÍÉÒÏ×ÁÎÎÏÅ ÞÉÓÌÏ
-11 îÅÔ ÂÏÌØÛÅ ÓÌÏ×
-12 ïÔÓÕÔÓÔ×ÕÅÔ ÉÍÑ ÆÁÊÌÁ
-13 ÷ÎÕÔÒÅÎÎÑÑ ÏÛÉÂËÁ glob
-14 ëÏÍÁÎÄÁ ÎÅ ÎÁÊÄÅÎÁ
-15 óÌÉÛËÏÍ ÍÁÌÏ ÁÒÇÕÍÅÎÔÏ×
-16 óÌÉÛËÏÍ ÍÎÏÇÏ ÁÒÇÕÍÅÎÔÏ×
-17 óÌÉÛËÏÍ ÏÐÁÓÎÏ ÐÅÒÅÏÐÒÅÄÅÌÑÔØ ÜÔÏ
-18 ðÕÓÔÏÊ if
-19 îÅ×ÅÒÎÙÊ then
-20 óÌÏ×Á ÎÅ × ÓËÏÂËÁÈ
-21 %s ÎÅ ÎÁÊÄÅÎÏ
-22 îÅ×ÅÒÎÏÅ ÚÎÁÞÅÎÉÅ mask
-23 îÅÔ ÔÁËÏÇÏ ÐÒÅÄÅÌÁ
-24 áÒÇÕÍÅÎÔ ÓÌÉÛËÏÍ ×ÅÌÉË
-25 îÅ×ÅÒÎÙÊ ÉÌÉ ÎÅÉÚ×ÅÓÔÎÙÊ ÆÁËÔÏÒ Õ×ÅÌÉÞÅÎÉÑ
-26 îÅÏÐÒÅÄÅÌÅÎÎÁÑ ÐÅÒÅÍÅÎÎÁÑ
-27 óÔÅË ËÁÔÁÌÏÇÏ× ÎÅ ÔÁËÏÊ ÇÌÕÂÏËÉÊ
-28 îÅ×ÅÒÎÙÊ ÎÏÍÅÒ ÓÉÇÎÁÌÁ
-29 îÅÉÚ×ÅÓÔÎÙÊ ÓÉÇÎÁÌ; kill -l ×Ù×ÅÄÅÔ ÓÐÉÓÏË ÓÉÇÎÁÌÏ×
-30 éÍÑ ÐÅÒÅÍÅÎÎÏÊ ÄÏÌÖÎÏ ÎÁÞÉÎÁÔØÓÑ Ó ÂÕË×Ù
-31 óÌÉÛËÏÍ ÄÌÉÎÎÏÅ ÉÍÑ ÐÅÒÅÍÅÎÎÏÊ
-32 ÷ ÉÍÅÎÉ ÐÅÒÅÍÅÎÎÏÊ ÄÏÌÖÎÙ ÓÏÄÅÒÖÁÔØÓÑ ÁÌÆÁ×ÉÔÎÏ-ÃÉÆÒÏ×ÙÅ ÓÉÍ×ÏÌÙ
-33 õÐÒÁ×ÌÅÎÉÅ ÚÁÄÁÎÉÑÍÉ ÏÔÓÕÔÓÔ×ÕÅÔ × ÜÔÏÍ ÛÅÌÌÅ
-34 óÉÎÔÁËÓÉÓ ×ÙÒÁÖÅÎÉÑ
-35 ïÔÓÕÔÓÔ×ÕÅÔ ÄÏÍÁÛÎÉÊ ËÁÔÁÌÏÇ
-36 îÅ ÍÏÇÕ ÐÅÒÅÊÔÉ × ÄÏÍÁÛÎÉÊ ËÁÔÁÌÏÇ
-37 ðÒÏÐÕÝÅÎÁ ËÏÍÁÎÄÁ
-38 ÷ ÐÒÉÓ×ÏÅÎÉÉ ÏÔÓÕÔÓÔ×ÕÅÔ ×ÙÒÁÖÅÎÉÅ
-39 îÅÉÚ×ÅÓÔÎÙÊ ÏÐÅÒÁÔÏÒ
-40 îÅÏÄÎÏÚÎÁÞÎÏ
-41 %s: æÁÊÌ ÓÕÝÅÓÔ×ÕÅÔ
-42 áÒÇÕÍÅÎÔ ÄÌÑ -c ÎÅ ÄÏÌÖÅÎ ÏËÁÎÞÉ×ÁÔØÓÑ ÎÁ \
-43 ðÒÅÒ×ÁÎÏ
-44 ðÏÄÐÒÏÇÒÁÍÍÁ ×ÙÈÏÄÉÔ ÚÁ ÐÒÅÄÅÌÙ
-45 ðÅÒÅÐÏÌÎÅÎÉÅ ÓÔÒÏËÉ
-46 îÅÔ ÔÁËÏÇÏ ÚÁÄÁÎÉÑ
-47 îÅ ÍÏÇÕ ÉÚ ÔÅÒÍÉÎÁÌÁ
-48 îÅ ×ÎÕÔÒÉ while/foreach
-49 îÅÔ ÂÏÌØÛÅ ÐÒÏÃÅÓÓÏ×
-50 îÅÔ ÓÏÏÔ×ÅÔÓÔ×ÉÊ
-51 ïÔÓÕÔÓÔ×ÕÅÔ %c
-52 îÅÔ ÓÏÏÔ×ÅÔÓÔ×ÉÑ ÄÌÑ %c
-53 îÅÔ ÐÁÍÑÔÉ
-54 îÅ ÍÏÇÕ ÓÏÚÄÁÔØ ÎÅÉÍÅÎÏ×ÁÎÎÙÊ ËÁÎÁÌ
+1 Синтаксическая ошибка
+2 %s недопустимо
+3 Слово слишком длинное
+4 $< строка слишком длинная
+5 Нет файла для $0
+6 Незавершённый модификатор []
+7 $ расширение должно оканчиваться перед ]
+8 ПлоÑ
ой модификатор в $ (%c)
+9 Ошибка подпрограммы
+10 Неправильно сформированное число
+11 Нет больше слов
+12 Отсутствует имя файла
+13 Внутренняя ошибка glob
+14 Команда не найдена
+15 Слишком мало аргументов
+16 Слишком много аргументов
+17 Слишком опасно переопределять это
+18 Пустой if
+19 Неверный then
+20 Слова не в скобкаÑ

+21 %s не найдено
+22 Неверное значение mask
+23 Нет такого предела
+24 Аргумент слишком велик
+25 Неверный или неизвестный фактор увеличения
+26 Неопределенная переменная
+27 Стек каталогов не такой глубокий
+28 Неверный номер сигнала
+29 Неизвестный сигнал; kill -l выведет список сигналов
+30 Имя переменной должно начинаться с буквы
+31 Слишком длинное имя переменной
+32 В имени переменной должны содержаться алфавитно-цифровые символы
+33 Управление заданиями отсутствует в этом шелле
+34 Синтаксис выражения
+35 Отсутствует домашний каталог
+36 Не могу перейти в домашний каталог
+37 Пропущена команда
+38 В присвоении отсутствует выражение
+39 Неизвестный оператор
+40 Неоднозначно
+41 %s: Файл существует
+42 Аргумент для -c не должен оканчиваться на \
+43 Прервано
+44 Подпрограмма выÑ
одит за пределы
+45 Переполнение строки
+46 Нет такого задания
+47 Не могу из терминала
+48 Не внутри while/foreach
+49 Нет больше процессов
+50 Нет соответствий
+51 Отсутствует %c
+52 Нет соответствия для %c
+53 Нет памяти
+54 Не могу создать неименованный канал
 55 %s: %s
 56 %s
-57 éÓÐÏÌØÚÏ×ÁÎÉÅ: jobs [ -l ]
-58 áÒÇÕÍÅÎÔÙ ÄÏÌÖÎÙ Ñ×ÌÑÔØÓÑ ÉÄÅÎÔÉÆÉËÁÔÏÒÁÍÉ ÚÁÄÁÎÉÊ ÉÌÉ ÐÒÏÃÅÓÓÏ×
-59 îÅÔ ÔÅËÕÝÅÇÏ ÚÁÄÁÎÉÑ
-60 îÅÔ ÐÒÅÄÙÄÕÝÅÇÏ ÚÁÄÁÎÉÑ
-61 óÏÏÔ×ÅÔÓÔ×ÕÀÝÅÅ ÛÁÂÌÏÎÕ ÚÁÄÁÎÉÅ ÏÔÓÕÔÓÔ×ÕÅÔ
-62 ÷ÌÏÖÅÎÎÏÓÔØ fork > %d; ×ÏÚÍÏÖÎÏ ÜÔÏ ÃÉËÌ `...`
-63 õÐÒÁ×ÌÅÎÉÅ ÚÁÄÁÎÉÑÍÉ ÏÔÓÕÔÓÔ×ÕÅÔ × ÓÁÂÛÅÌÌÁÈ
-64 ïÛÉÂËÁ ÓÉÎÈÒÏÎÉÚÁÃÉÉ: ðÒÏÃÅÓÓ %d ÎÅ ÎÁÊÄÅÎ
-65 %sóÕÝÅÓÔ×ÕÀÔ ÏÔÌÏÖÅÎÎÙÅ ÚÁÄÁÎÉÑ
-66 %sóÕÝÅÓÔ×ÕÀÔ ÏÓÔÁÎÏ×ÌÅÎÎÙÅ ÚÁÄÁÎÉÑ
-67 îÅÔ ÄÒÕÇÏÇÏ ËÁÔÁÌÏÇÁ
-68 óÔÅË ËÁÔÁÌÏÇÏ× ÐÕÓÔ
-69 îÅ×ÅÒÎÏÅ ÉÍÑ ËÁÔÁÌÏÇÁ
-70 éÓÐÏÌØÚÏ×ÁÎÉÅ: %s [-%s]%s
-71 ïÔÓÕÔÓÔ×ÕÅÔ ÏÐÅÒÁÎÄ ÄÌÑ ÆÌÁÇÁ -h
-72 îÅ Ñ×ÌÑÅÔÓÑ login-ÛÅÌÌÏÍ
-73 äÅÌÅÎÉÅ ÎÁ 0
-74 ïÓÔÁÔÏË ÏÔ ÄÅÌÅÎÉÑ ÎÁ 0
-75 ðÌÏÈÏÊ scaling; ×Ù ÉÍÅÅÔÅ × ×ÉÄÕ "%s"?
-76 îÅ ÍÏÇÕ ÏÔÌÏÖÉÔØ login-ÛÅÌÌ (ÐÏËÁ)
-77 îÅÉÚ×ÅÓÔÎÙÊ ÐÏÌØÚÏ×ÁÔÅÌØ: %s
-78 ðÅÒÅÍÅÎÎÁÑ $home ÎÅ ÕÓÔÁÎÏ×ÌÅÎÁ
-79 éÓÐÏÌØÚÏ×ÁÎÉÅ: history [-%s] [# ÞÉÓÌÏ ÓÏÂÙÔÉÊ]
-80 $, ! ÉÌÉ < ÚÁÐÒÅÝÅÎÏ ÉÓÐÏÌØÚÏ×ÁÔØ Ó $# ÉÌÉ $?
-81 ðÅÒÅ×ÏÄ ÓÔÒÏËÉ × ÉÍÅÎÉ ÐÅÒÅÍÅÎÎÏÊ
-82 * ÚÁÐÒÅÝÅÎÏ ÉÓÐÏÌØÚÏ×ÁÔØ Ó $# ÉÌÉ $?
-83 $?<ÃÉÆÒÁ> ÉÌÉ $#<ÃÉÆÒÁ> ÚÁÐÒÅÝÅÎÏ
-84 îÅ×ÅÒÎÏÅ ÉÍÑ ÐÅÒÅÍÅÎÎÏÊ
-85 ðÅÒÅ×ÏÄ ÓÔÒÏËÉ × ÉÎÄÅËÓÅ ÐÅÒÅÍÅÎÎÏÊ
-86 ðÅÒÅÐÏÌÎÅÎÉÅ ÂÕÆÅÒÁ ÒÁÓÛÉÒÅÎÉÑ
-87 óÉÎÔÁËÓÉÓ ÐÅÒÅÍÅÎÎÏÊ
-88 îÅ×ÅÒÎÁÑ ÆÏÒÍÁ !
-89 ïÔÓÕÔÓÔ×ÕÅÔ ÐÒÅÄÙÄÕÝÁÑ ÐÏÄÓÔÁÎÏ×ËÁ
-90 ðÌÏÈÁÑ ÐÏÄÓÔÁÎÏ×ËÁ
-91 ïÔÓÕÔÓÔ×ÕÅÔ ÐÒÅÄÙÄÕÝÁÑ ÌÅ×ÁÑ ÓÔÏÒÏÎÁ
-92 ðÒÁ×ÁÑ ÓÔÏÒÏÎÁ ÓÌÉÛËÏÍ ÄÌÉÎÎÁÑ
-93 ðÌÏÈÏÊ ÍÏÄÉÆÉËÁÔÏÒ !: %c
-94 ïÛÉÂËÁ ÍÏÄÉÆÉËÁÔÏÒÁ
-95 ðÅÒÅÐÏÌÎÅÎÉÅ ÂÕÆÅÒÁ ÐÏÄÓÔÁÎÏ×ËÉ
-96 ðÌÏÈÏÊ ÓÅÌÅËÔÏÒ ÄÌÑ ÁÒÇÕÍÅÎÔÁ !
-97 îÅÔ ÐÒÅÄÙÄÕÝÅÊ ÓÔÒÏËÉ ÐÏÉÓËÁ
-98 %s: óÏÂÙÔÉÅ ÎÅ ÎÁÊÄÅÎÏ
-99 óÌÉÛËÏÍ ÍÎÏÇÏ )
-100 óÌÉÛËÏÍ ÍÎÏÇÏ (
-101 îÅ×ÅÒÎÏ ÕËÁÚÁÎÎÁÑ (
-102 ïÔÓÕÔÓÔ×ÕÅÔ ÉÍÑ ÄÌÑ ÐÅÒÅÎÁÐÒÁ×ÌÅÎÉÑ
-103 îÅÏÄÎÏÚÎÁÞÎÏÅ ÐÅÒÅÎÁÐÒÁ×ÌÅÎÉÅ ×Ù×ÏÄÁ
-104 îÅÌØÚÑ ÉÓÐÏÌØÚÏ×ÁÔØ << × ()
-105 îÅÏÄÎÏÚÎÁÞÎÏÅ ÐÅÒÅÎÁÐÒÁ×ÌÅÎÉÅ ××ÏÄÁ
-106 îÅ×ÅÒÎÏ ÕËÁÚÁÎÎÙÅ ()
-107 úÁÃÉËÌÉ×ÁÎÉÅ ÐÓÅ×ÄÏÎÉÍÏ×
-108 ðÅÒÅÍÅÎÎÁÑ $watch ÎÅ ÕÓÔÁÎÏ×ÌÅÎÁ
-109 îÅÔ ÚÁÐÌÁÎÉÒÏ×ÁÎÎÙÈ ÓÏÂÙÔÉÊ
-110 éÓÐÏÌØÚÏ×ÁÎÉÅ: sched -<ÎÏÍÅÒ ÜÌÅÍÅÎÔÁ>.\néÓÐÏÌØÚÏ×ÁÎÉÅ: sched [+]þþ:íí <ËÏÍÁÎÄÁ>
-111 îÅ ÔÁË ÍÎÏÇÏ ÓÏÂÙÔÉÊ ÄÌÑ ÚÁÐÕÓËÁ ÐÏ ÒÁÓÐÉÓÁÎÉÀ
-112 ïÔÓÕÔÓÔ×ÕÅÔ ËÏÍÁÎÄÁ ÄÌÑ ÉÓÐÏÌÎÅÎÉÑ
-113 îÅ×ÅÒÎÏÅ ×ÒÅÍÑ ÄÌÑ ÓÏÂÙÔÉÑ
-114 ïÔÎÏÓÉÔÅÌØÎÏÅ ×ÒÅÍÑ ÎÅ ÓÏÏÔ×ÅÔÓÔ×ÕÅÔ am/pm
-115 ðÅÒÅÐÏÌÎÅÎÉÅ ÓÔÒÏËÉ termcap
-116 éÓÐÏÌØÚÏ×ÁÎÉÅ: settc %s [yes|no]
-117 îÅÉÚ×ÅÓÔÎÁÑ capability `%s'
-118 îÅÉÚ×ÅÓÔÎÙÊ ÐÁÒÁÍÅÔÒ termcap `%%%c'
-119 óÌÉÛËÏÍ ÍÎÏÇÏ ÁÒÇÕÍÅÎÔÏ× ÄÌÑ `%s' (%d)
-120 `%s' ÔÒÅÂÕÅÔ %d ÁÒÇÕÍÅÎÔÏ×
-121 éÓÐÏÌØÚÏ×ÁÎÉÅ: echotc [-v|-s] [<capability> [<ÁÒÇÕÍÅÎÔÙ>]]
-122 %s: %s. îÅ×ÅÒÎÁÑ ÁÒÈÉÔÅËÔÕÒÁ
-123 !# ÚÁÃÉËÌÉ×ÁÎÉÅ ÐÁÍÑÔÉ ËÏÍÁÎÄ
-124 îÅÐÒÁ×ÉÌØÎÏ ÓÆÏÒÍÉÒÏ×ÁÎÎÙÊ ÆÁÊÌÏ×ÙÊ ÚÁÐÒÏÓ
-125 ðÅÒÅÐÏÌÎÅÎÉÅ ÓÅÌÅËÔÏÒÁ
-126 îÅÉÚ×ÅÓÔÎÁÑ ÏÐÃÉÑ: `-%s'\néÓÐÏÌØÚÏ×ÁÎÉÅ: %s [ -bcdefilmnqstvVxX -DÉÍÑ[=ÚÎÁÞÅÎÉÅ] ] [ ÁÒÇÕÍÅÎÔ ... ]
-127 îÅÉÚ×ÅÓÔÎÁÑ ÏÐÃÉÑ: `-%s'\néÓÐÏÌØÚÏ×ÁÎÉÅ: %s [ -bcdefFilmnqstvVxX ] [ ÁÒÇÕÍÅÎÔ ... ]
-128 îÅÉÚ×ÅÓÔÎÁÑ ÏÐÃÉÑ: `-%s'\néÓÐÏÌØÚÏ×ÁÎÉÅ: %s [ -bcdefilmnqstvVxX ] [ ÁÒÇÕÍÅÎÔ ... ]
-129 \nîÅ×ÅÒÎÏÅ ÄÏÓÔÒÁÉ×ÁÎÉÅ: "%s"
-130 \nîÅ×ÅÒÎÙÊ %s: '%c'
-131 \nïÔÓÕÔÓÔ×ÕÅÔ ÓÅÐÁÒÁÔÏÒ '%c' ÐÏÓÌÅ %s "%s"
-132 \n%s ÎÅ ÐÏÌÎÏ: "%s"
-133 ïÔÓÕÔÓÔ×ÕÅÔ ÏÐÅÒÁÎÄ ÄÌÑ ÆÌÁÇÁ -m
-134 éÓÐÏÌØÚÏ×ÁÎÉÅ: unlimit [-fh] [ÐÒÅÄÅÌÙ]
-135 $%S ÔÏÌØËÏ ÄÌÑ ÞÔÅÎÉÑ
-136 îÅÔ ÔÁËÏÇÏ ÚÁÄÁÎÉÑ
-137 îÅÉÚ×ÅÓÔÎÏÅ ÚÎÁÞÅÎÉÅ `%c%c' ÐÅÒÅÍÅÎÎÏÊ colorls
+57 Использование: jobs [ -l ]
+58 Аргументы должны являться идентификаторами заданий или процессов
+59 Нет текущего задания
+60 Нет предыдущего задания
+61 Соответствующее шаблону задание отсутствует
+62 Вложенность fork > %d; возможно это цикл `...`
+63 Управление заданиями отсутствует в сабшеллаÑ

+64 Ошибка синÑ
ронизации: Процесс %d не найден
+65 %sСуществуют отложенные задания
+66 %sСуществуют остановленные задания
+67 Нет другого каталога
+68 Стек каталогов пуст
+69 Неверное имя каталога
+70 Использование: %s [-%s]%s
+71 Отсутствует операнд для флага -h
+72 Не является login-шеллом
+73 Деление на 0
+74 Остаток от деления на 0
+75 ПлоÑ
ой scaling; вы имеете в виду "%s"?
+76 Не могу отложить login-шелл (пока)
+77 Неизвестный пользователь: %s
+78 Переменная $home не установлена
+79 Использование: history [-%s] [# число событий]
+80 $, ! или < запрещено использовать с $# или $?
+81 Перевод строки в имени переменной
+82 * запрещено использовать с $# или $?
+83 $?<цифра> или $#<цифра> запрещено
+84 Неверное имя переменной
+85 Перевод строки в индексе переменной
+86 Переполнение буфера расширения
+87 Синтаксис переменной
+88 Неверная форма !
+89 Отсутствует предыдущая подстановка
+90 ПлоÑ
ая подстановка
+91 Отсутствует предыдущая левая сторона
+92 Правая сторона слишком длинная
+93 ПлоÑ
ой модификатор !: %c
+94 Ошибка модификатора
+95 Переполнение буфера подстановки
+96 ПлоÑ
ой селектор для аргумента !
+97 Нет предыдущей строки поиска
+98 %s: Событие не найдено
+99 Слишком много )
+100 Слишком много (
+101 Неверно указанная (
+102 Отсутствует имя для перенаправления
+103 Неоднозначное перенаправление вывода
+104 Нельзя использовать << в ()
+105 Неоднозначное перенаправление ввода
+106 Неверно указанные ()
+107 Зацикливание псевдонимов
+108 Переменная $watch не установлена
+109 Нет запланированныÑ
 событий
+110 Использование: sched -<номер элемента>.\nИспользование: sched [+]ЧЧ:ММ <команда>
+111 Не так много событий для запуска по расписанию
+112 Отсутствует команда для исполнения
+113 Неверное время для события
+114 Относительное время не соответствует am/pm
+115 Переполнение строки termcap
+116 Использование: settc %s [yes|no]
+117 Неизвестная capability `%s'
+118 Неизвестный параметр termcap `%%%c'
+119 Слишком много аргументов для `%s' (%d)
+120 `%s' требует %d аргументов
+121 Использование: echotc [-v|-s] [<capability> [<аргументы>]]
+122 %s: %s. Неверная арÑ
итектура
+123 !# зацикливание памяти команд
+124 Неправильно сформированный файловый запрос
+125 Переполнение селектора
+126 Неизвестная опция: `-%s'\nИспользование: %s [ -bcdefilmnqstvVxX -Dимя[=значение] ] [ аргумент ... ]
+127 Неизвестная опция: `-%s'\nИспользование: %s [ -bcdefFilmnqstvVxX ] [ аргумент ... ]
+128 Неизвестная опция: `-%s'\nИспользование: %s [ -bcdefilmnqstvVxX ] [ аргумент ... ]
+129 \nНеверное достраивание: "%s"
+130 \nНеверный %s: '%c'
+131 \nОтсутствует сепаратор '%c' после %s "%s"
+132 \n%s не полно: "%s"
+133 Отсутствует операнд для флага -m
+134 Использование: unlimit [-fh] [пределы]
+135 $%S только для чтения
+136 Нет такого задания
+137 Неизвестное значение `%c%c' переменной colorls
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/russian/set10
--- a/head/contrib/tcsh/nls/russian/set10	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/russian/set10	Fri Mar 02 16:54:40 2012 +0200
@@ -1,8 +1,8 @@
-$ $tcsh: set10,v 1.3 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set10,v 1.4 2011/02/04 18:19:41 christos Exp $
 $ ma.setp.c
 $set 10 
-1 setpath: ÎÅ×ÅÒÎÁÑ ËÏÍÁÎÄÁ '%s'.\n
-2 setpath: ÎÅÄÏÓÔÁÔÏÞÎÏ ÁÒÇÕÍÅÎÔÏ× ÄÌÑ ËÏÍÁÎÄÙ '%s'.\n
-3 setpath: ÏÔÓÕÔÓÔ×ÕÅÔ ÚÎÁÞÅÎÉÅ × ÐÕÔÉ '%s'\n
-4 setpath: %s ÎÅ ÎÁÊÄÅÎÏ × %s\n
-5 setpath: %d ÎÅ×ÅÒÎÁÑ ÐÏÚÉÃÉÑ × %s\n
+1 setpath: неверная команда '%s'.\n
+2 setpath: недостаточно аргументов для команды '%s'.\n
+3 setpath: отсутствует значение в пути '%s'\n
+4 setpath: %s не найдено в %s\n
+5 setpath: %d неверная позиция в %s\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/russian/set11
--- a/head/contrib/tcsh/nls/russian/set11	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/russian/set11	Fri Mar 02 16:54:40 2012 +0200
@@ -1,10 +1,10 @@
-$ $tcsh: set11,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set11,v 1.3 2011/02/04 18:19:41 christos Exp $
 $ sh.c
 $set 11 
-1 ðÒÅÄÕÐÒÅÖÄÅÎÉÅ: ÎÅÔ ÄÏÓÔÕÐÁ Ë tty (%s).\n
-2 ðÏÜÔÏÍÕ ÕÐÒÁ×ÌÅÎÉÅ ÚÁÄÁÎÉÑÍÉ × ÜÔÏÍ ÛÅÌÌÅ ÏÔÓÕÔÓÔ×ÕÅÔ.\n
-3 äÌÑ ×ÁÓ ÅÓÔØ %d ÐÏÞÔÏ×ÙÈ ÓÏÏÂÝÅÎÉÑ(Ê).\n
-4 äÌÑ ×ÁÓ ÅÓÔØ %d ÐÏÞÔÏ×ÙÈ ÓÏÏÂÝÅÎÉÑ(Ê) × %s.\n
-5 äÌÑ ×ÁÓ ÅÓÔØ %sÐÏÞÔÁ.\n
-6 ÎÏ×ÁÑ 
-7 äÌÑ ×ÁÓ ÅÓÔØ %sÐÏÞÔÁ × %s.\n
+1 Предупреждение: нет доступа к tty (%s).\n
+2 Поэтому управление заданиями в этом шелле отсутствует.\n
+3 Для вас есть %d почтовыÑ
 сообщения(й).\n
+4 Для вас есть %d почтовыÑ
 сообщения(й) в %s.\n
+5 Для вас есть %sпочта.\n
+6 новая 
+7 Для вас есть %sпочта в %s.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/russian/set12
--- a/head/contrib/tcsh/nls/russian/set12	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/russian/set12	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set12,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set12,v 1.3 2011/02/04 18:19:41 christos Exp $
 $ sh.dir.c
 $set 12 
-1 %s: ðÙÔÁÀÓØ ÎÁÞÁÔØ Ó "%s"\n
+1 %s: Пытаюсь начать с "%s"\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/russian/set13
--- a/head/contrib/tcsh/nls/russian/set13	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/russian/set13	Fri Mar 02 16:54:40 2012 +0200
@@ -1,13 +1,13 @@
-$ $tcsh: set13,v 1.3 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set13,v 1.4 2011/02/04 18:19:41 christos Exp $
 $ sh.exec.c
 $set 13 
 1 hash=%-4d dir=%-2d prog=%s\n
 2 %d hash buckets of %d bits each\n
-3 ÚÎÁÞÅÎÉÅ mask ÄÌÑ ÏÔÌÁÄËÉ = 0x%08x\n
-4 %d ÓÏ×ÐÁÄÅÎÉÑ(Ê), %d ÐÒÏÍÁÈÁ(Ï×), %d%%\n
-5 %S: ×ÎÕÔÒÅÎÎÑÑ ËÏÍÁÎÄÁ.\n
-6 %S: ëÏÍÁÎÄÁ ÎÅ ÎÁÊÄÅÎÁ.\n
-7 where: / × ËÏÍÁÎÄÅ ÎÅ ÉÍÅÅÔ ÓÍÙÓÌÁ\n
-8 %S ÐÅÒÅÏÐÒÅÄÅÌÅÎÏ ÎÁ 
-9 %S Ñ×ÌÑÅÔÓÑ ×ÎÕÔÒÅÎÎÅÊ ËÏÍÁÎÄÏÊ\n
+3 значение mask для отладки = 0x%08x\n
+4 %d совпадения(й), %d промаÑ
а(ов), %d%%\n
+5 %S: внутренняя команда.\n
+6 %S: Команда не найдена.\n
+7 where: / в команде не имеет смысла\n
+8 %S переопределено на 
+9 %S является внутренней командой\n
 10 hash miss: 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/russian/set14
--- a/head/contrib/tcsh/nls/russian/set14	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/russian/set14	Fri Mar 02 16:54:40 2012 +0200
@@ -1,6 +1,6 @@
-$ $tcsh: set14,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set14,v 1.3 2011/02/04 18:19:41 christos Exp $
 $ sh.file.c
 $set 14 
-1 \nYikes!! óÌÉÛËÏÍ ÍÎÏÇÏ %s!!\n
-2 ÉÍÅÎ × ÆÁÊÌÅ ÐÁÒÏÌÅÊ
-3 ÆÁÊÌÙ
+1 \nYikes!! Слишком много %s!!\n
+2 имен в файле паролей
+3 файлы
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/russian/set15
--- a/head/contrib/tcsh/nls/russian/set15	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/russian/set15	Fri Mar 02 16:54:40 2012 +0200
@@ -1,7 +1,7 @@
-$ $tcsh: set15,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set15,v 1.3 2011/02/04 18:19:41 christos Exp $
 $ sh.func.c
 $set 15 
-1 %s: %s: îÅ ÍÏÇÕ %s%s ÐÒÅÄÅÌ\n
-2 ÕÄÁÌÉÔØ
-3 ÕÓÔÁÎÏ×ÉÔØ
-4 \040ÖÅÓÔËÉÊ
+1 %s: %s: Не могу %s%s предел\n
+2 удалить
+3 установить
+4 \040жесткий
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/russian/set16
--- a/head/contrib/tcsh/nls/russian/set16	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/russian/set16	Fri Mar 02 16:54:40 2012 +0200
@@ -1,9 +1,9 @@
-$ $tcsh: set16,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set16,v 1.3 2011/02/04 18:19:41 christos Exp $
 $ sh.lex.c
 $set 16 
 1 Reset tty pgrp from %d to %d\n
-2 \néÓÐÏÌØÚÕÊÔÅ "logout" ÄÌÑ ÚÁ×ÅÒÛÅÎÉÑ ÓÅÓÓÉÉ.\n
-3 \néÓÐÏÌØÚÕÊÔÅ "exit" ÄÌÑ ×ÙÈÏÄÁ ÉÚ %s.\n
+2 \nИспользуйте "logout" для завершения сессии.\n
+3 \nИспользуйте "exit" для выÑ
ода из %s.\n
 4 seek to eval %x %x\n
 5 seek to alias %x %x\n
 6 seek to file %x\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/russian/set17
--- a/head/contrib/tcsh/nls/russian/set17	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/russian/set17	Fri Mar 02 16:54:40 2012 +0200
@@ -1,17 +1,17 @@
-$ $tcsh: set17,v 1.4 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set17,v 1.5 2011/02/04 18:19:41 christos Exp $
 $ sh.proc.c
 $set 17 
 1 BUG: waiting for background job!\n
-2 ÷ÙÈÏÄ %d\n
+2 Ð’Ñ‹Ñ
од %d\n
 3 BUG: process flushed twice
-4 ÷ÙÐÏÌÎÑÅÔÓÑ 
-5 óÉÇÎÁÌ 
+4 Выполняется 
+5 Сигнал 
 6 Exit %-25d
-7 ïËÏÎÞÅÎÏ
+7 Окончено
 8 BUG: status=%-9o
 9 \040(core dumped)
 10 \040(wd:
 11 wd now: 
-12 %S: õÖÅ ÏÔÌÏÖÅÎÏ\n
-13 %S: õÖÅ ÏÓÔÁÎÏ×ÌÅÎÏ\n
+12 %S: Уже отложено\n
+13 %S: Уже остановлено\n
 14 %S: Badly formed number\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/russian/set18
--- a/head/contrib/tcsh/nls/russian/set18	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/russian/set18	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set18,v 1.3 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set18,v 1.4 2011/02/04 18:19:41 christos Exp $
 $ sh.set.c
 $set 18 
-1 ðÒÅÄÕÐÒÅÖÄÅÎÉÅ: þÅÒÅÓÞÕÒ ÄÌÉÎÎÙÊ PATH ÏÂÒÅÚÁÎ\n
+1 Предупреждение: Чересчур длинный PATH обрезан\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/russian/set19
--- a/head/contrib/tcsh/nls/russian/set19	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/russian/set19	Fri Mar 02 16:54:40 2012 +0200
@@ -1,7 +1,7 @@
-$ $tcsh: set19,v 1.3 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set19,v 1.6 2011/02/25 23:58:08 christos Exp $
 $ tc.alloc.c
 $set 19 
-1 nbytes=%d: îÅÔ ÐÁÍÑÔÉ\n
+1 nbytes=%d: Нет памяти\n
 2 free(%lx) called before any allocations.
 3 free(%lx) above top of memory.
 4 free(%lx) below bottom of memory.
@@ -9,7 +9,15 @@
 6 free(%lx) bad range check.
 7 free(%lx) bad block index.
 8 %s current memory allocation:\nfree:\t
-9 \nused:\t
-10 \n\t÷ÓÅÇÏ ÉÓÐÏÌØÚÕÅÔÓÑ: %d, ×ÓÅÇÏ Ó×ÏÂÏÄÎÏ: %d\n
+9 used
+10 \n\tВсего используется: %d, всего свободно: %d\n
 11 \tAllocated memory from 0x%lx to 0x%lx.  Real top at 0x%lx\n
 12 Allocated memory from 0x%lx to 0x%lx (%ld).\n
+13 %s current memory allocation:\n
+14 Total space allocated from system: %d\n
+15 Number of non-inuse chunks: %d\n
+16 Number of mmapped regions: %d\n
+17 Total space in mmapped regions: %d\n
+18 Total allocated space: %d\n
+19 Total non-inuse space: %d\n
+20 Top-most, releasable space: %d\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/russian/set2
--- a/head/contrib/tcsh/nls/russian/set2	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/russian/set2	Fri Mar 02 16:54:40 2012 +0200
@@ -1,51 +1,51 @@
-$ $tcsh: set2,v 1.3 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set2,v 1.4 2011/02/04 18:19:42 christos Exp $
 $ Signal names
 $set 2 
-1 îÕÌÅ×ÏÊ ÓÉÇÎÁÌ
-2 òÁÚÒÙ× Ó×ÑÚÉ
-3 ðÒÅÒÙ×ÁÎÉÅ
-4 ÷ÙÈÏÄ
-5 îÅ×ÅÒÎÁÑ ÉÎÓÔÒÕËÃÉÑ
+1 Нулевой сигнал
+2 Разрыв связи
+3 Прерывание
+4 Ð’Ñ‹Ñ
од
+5 Неверная инструкция
 6 Trace/BPT trap
-7 á×ÁÒÉÊÎÏÅ ÚÁ×ÅÒÛÅÎÉÅ
+7 Аварийное завершение
 8 IOT trap
 9 System Crash Imminent
-10 ÷ÙÈÏÄ ÐÏ ÏÛÉÂËÅ
+10 Ð’Ñ‹Ñ
од по ошибке
 11 EMT trap
-12 ïÛÉÂËÁ ÏÐÅÒÁÃÉÉ Ó ÐÌÁ×ÁÀÝÅÊ ÔÏÞËÏÊ
-13 õÂÉÔ
-14 ðÏÌØÚÏ×ÁÔÅÌØÓËÉÊ ÓÉÇÎÁÌ 1
-15 ðÏÌØÚÏ×ÁÔÅÌØÓËÉÊ ÓÉÇÎÁÌ 2
-16 ïÛÉÂËÁ ÓÅÇÍÅÎÔÁÃÉÉ
-17 ïÛÉÂËÁ ÁÄÒÅÓÁÃÉÉ ÎÁ ÛÉÎÅ
+12 Ошибка операции с плавающей точкой
+13 Убит
+14 Пользовательский сигнал 1
+15 Пользовательский сигнал 2
+16 Ошибка сегментации
+17 Ошибка адресации на шине
 18 Program range error
 19 Operand range error
-20 îÅ×ÅÒÎÙÊ ÓÉÓÔÅÍÎÙÊ ×ÙÚÏ×
+20 Неверный системный вызов
 21 Broken pipe
 22 Alarm clock
-23 ðÒÅÒ×ÁÎÏ
-24 éÚÍÅÎÅÎÉÅ ÓÏÓÔÏÑÎÉÑ ÐÏÔÏÍËÁ
-25 óÍÅÒÔØ ÐÏÔÏÍËÁ
+23 Прервано
+24 Изменение состояния потомка
+25 Смерть потомка
 26 Apollo-specific fault
-27 ðÏÔÏÍÏË ÏÓÔÁÎÏ×ÉÌÓÑ ÉÌÉ ÚÁ×ÅÒÛÉÌÓÑ
-28 ðÏÔÏÍÏË ÚÁ×ÅÒÛÉÌÓÑ
-29 óÂÏÊ ÐÉÔÁÎÉÑ
+27 Потомок остановился или завершился
+28 Потомок завершился
+29 Сбой питания
 30 Resource Lost
 31 Break (Ctrl-Break)
 32 Input/output possible signal
-33 áÓÉÎÈÒÏÎÎÙÊ ××ÏÄ/×Ù×ÏÄ (select)
+33 АсинÑ
ронный ввод/вывод (select)
 34 Urgent condition on I/O channel
 35 Multitasking wake-up
 36 Multitasking kill
 37 Fortran asynchronous I/O completion
 38 Recovery
-39 îÅÉÓÐÒÁ×ÉÍÁÑ ÏÛÉÂËÁ ÐÁÍÑÔÉ
+39 Неисправимая ошибка памяти
 40 CPU time limit exceeded
 41 System shutdown imminent
 42 micro-tasking group-no wakeup flag set
 43 Thread error - (use cord -T for detailed info)
-44 ïÛÉÂËÁ ÞÅÔÎÏÓÔÉ × ÒÅÇÉÓÔÒÅ CRAY Y-MP
-45 úÁÐÒÏÓ ÎÁ ÉÎÆÏÒÍÁÃÉÀ
+44 Ошибка четности в регистре CRAY Y-MP
+45 Запрос на информацию
 46 Suspended (signal)
 47 Stopped (signal)
 48 Suspended
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/russian/set20
--- a/head/contrib/tcsh/nls/russian/set20	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/russian/set20	Fri Mar 02 16:54:40 2012 +0200
@@ -1,41 +1,41 @@
-$ $tcsh: set20,v 1.5 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set20,v 1.6 2011/02/04 18:19:42 christos Exp $
 $ tc.bind.c
 $set 20 
-1 îÅ×ÅÒÎÏÅ ÉÍÑ ËÌÁ×ÉÛÉ `%S'\n
-2 ðÌÏÈÏÅ ÉÍÑ ËÌÁ×ÉÛÉ: %S\n
-3 ðÌÏÈÏÅ ÉÍÑ ËÏÍÁÎÄÙ: %S\n
-4 ðÌÏÈÁÑ ÓÐÅÃÉÆÉËÁÃÉÑ ËÌÁ×ÉÛÉ %S\n
-5 ðÕÓÔÁÑ ÓÔÒÏËÁ\n
-6 óÔÁÎÄÁÒÔÎÙÅ ÐÒÉ×ÑÚËÉ ËÌÁ×ÉÛ\n
-7 áÌØÔÅÒÎÁÔÉ×ÎÙÅ ÐÒÉ×ÑÚËÉ ËÌÁ×ÉÛ\n
-8 íÎÏÇÏ-ÓÉÍ×ÏÌØÎÙÅ ÐÒÉ×ÑÚËÉ\n
-9 ðÒÉ×ÑÚËÉ ÕÐÒÁ×ÌÑÀÝÉÈ ËÌÁ×ÉÛ\n
-10 %-15s->  ÎÅ ÏÐÒÅÄÅÌÅÎÏ\n
-11 BUG!!! %s ÎÅ Ó×ÑÚÁÎ ÎÉ Ó ÞÅÍ.\n
-12 éÓÐÏÌØÚÏ×ÁÎÉÅ: bindkey [ÏÐÃÉÉ] [--] [ëìá÷éûÁ [ëïíáîäÁ]]\n
-13     -a   ×Ù×ÅÓÔÉ ÉÌÉ ÐÒÉ×ÑÚÁÔØ ëìá÷éûÕ × ÁÌØÔÅÒÎÁÔÉ×ÎÏÊ ÒÁÓËÌÁÄËÅ ËÌÁ×ÉÁÔÕÒÙ\n
-14     -b   ×ÏÓÐÒÉÎÉÍÁÔØ ëìá÷éûÕ ËÁË C-, M-, F- ÉÌÉ X- ÎÁÚ×ÁÎÉÅ ËÌÁ×ÉÛÉ\n
-15     -s   ×ÏÓÐÒÉÎÉÍÁÔØ ëïíáîäÕ ËÁË ÓÔÒÏËÕ, ËÏÔÏÒÕÀ ÎÕÖÎÏ ×Ù×ÅÓÔÉ\n
-16     -c   ×ÏÓÐÒÉÎÉÍÁÔØ ëïíáîäÕ ËÁË ×ÓÔÒÏÅÎÎÕÀ ÉÌÉ ×ÎÅÛÎÀÀ ËÏÍÁÎÄÕ\n
-17     -v   ÐÒÉ×ÑÚÁÔØ ×ÓÅ ËÌÁ×ÉÛÉ × ÓÏÏÔ×ÅÔÓÔ×ÉÉ Ó ÒÅÄÁËÔÏÒÏÍ vi\n
-18     -e   ÐÒÉ×ÑÚÁÔØ ×ÓÅ ËÌÁ×ÉÛÉ × ÓÏÏÔ×ÅÔÓÔ×ÉÉ Ó ÒÅÄÁËÔÏÒÏÍ emacs\n
-19     -d   ÐÒÉ×ÑÚÁÔØ ×ÓÅ ËÌÁ×ÉÛÉ × ÓÏÏÔ×ÅÔÓÔ×ÉÉ Ó ÒÅÄÁËÔÏÒÏÍ ÐÏ ÕÍÏÌÞÁÎÉÀ\n
-20     -l   ×Ù×ÅÓÔÉ ÓÐÉÓÏË ËÏÍÁÎÄ ÒÅÄÁËÔÏÒÁ É ÉÈ ÏÐÉÓÁÎÉÑ\n
-21     -r   ÕÄÁÌÉÔØ ÐÒÉ×ÑÚËÕ ëìá÷éûÉ\n
-22     -k   ×ÏÓÐÒÉÎÉÍÁÔØ ëìá÷éûÕ ËÁË Ñ×ÎÏÅ ÎÁÚ×ÁÎÉÅ ÕÐÒÁ×ÌÑÀÝÅÊ ËÌÁ×ÉÛÉ\n
-23     --   ÎÅ ×ÏÓÐÒÉÎÉÍÁÔØ ×ÓÅ ÐÏÓÌÅÄÕÀÝÉÅ ÐÁÒÁÍÅÔÒÙ ËÁË ÏÐÃÉÉ\n
-24     -u   (ÉÌÉ ÌÀÂÁÑ ÎÅÐÒÁ×ÉÌØÎÁÑ ÏÐÃÉÑ) ×Ù×ÅÓÔÉ ÜÔÏÔ ÔÅËÓÔ\n
-25 âÅÚ ëìá÷éûÉ ÉÌÉ ëïíáîäÙ, ×Ù×ÅÓÔÉ ×ÓÅ ÐÒÉ×ÑÚËÉ.\n
-26 âÅÚ ëïíáîäÙ, ×Ù×ÅÓÔÉ ÐÒÉ×ÑÚËÕ ëìá÷éûÉ\n.\n
-27 ÐÌÏÈÁÑ ÓÐÅÃÉÆÉËÁÃÉÑ ËÌÁ×ÉÛÉ -- ÎÕÌÅ×ÁÑ ÓÔÒÏËÁ\n
-28 ÐÌÏÈÁÑ ÓÐÅÃÉÆÉËÁÃÉÑ ËÌÁ×ÉÛÉ -- ÐÕÓÔÁÑ ÓÔÒÏËÁ\n
-29 ðÌÏÈÁÑ ÓÐÅÃÉÆÉËÁÃÉÑ ÆÕÎËÃÉÏÎÁÌØÎÏÊ ËÌÁ×ÉÛÉ. îÕÌÅ×ÁÑ ËÌÁ×ÉÛÁ ÚÁÐÒÅÝÅÎÁ\n
-30 ÐÌÏÈÁÑ ÓÐÅÃÉÆÉËÁÃÉÑ ËÌÁ×ÉÛÉ -- ÎÅ×ÅÒÎÙÊ ÛÅÓÔÎÁÄÃÁÔÅÒÉÞÎÙÊ ÎÏÍÅÒ\n
-31 ÐÌÏÈÁÑ ÓÐÅÃÉÆÉËÁÃÉÑ ËÌÁ×ÉÛÉ -- ÎÅ×ÅÒÎÙÊ ×ÏÓØÍÅÒÉÞÎÙÊ ÎÏÍÅÒ\n
-32 ÐÌÏÈÁÑ ÓÐÅÃÉÆÉËÁÃÉÑ ËÌÁ×ÉÛÉ -- ÎÅ×ÅÒÎÙÊ ÄÅÓÑÔÉÞÎÙÊ ÎÏÍÅÒ\n
-33 ðÌÏÈÁÑ ÓÐÅÃÉÆÉËÁÃÉÑ ÆÕÎËÃÉÏÎÁÌØÎÏÊ ËÌÁ×ÉÛÉ.\n
-34 îÕÌÅ×ÙÅ ËÌÁ×ÉÛÉ ÚÁÐÒÅÝÅÎÙ\n
-35 ÐÌÏÈÁÑ ÓÐÅÃÉÆÉËÁÃÉÑ ËÌÁ×ÉÛÉ -- ÎÅÉÚ×ÅÓÔÎÏÅ ÉÍÑ "%S"\n
-36 ÉÓÐÏÌØÚÏ×ÁÎÉÅ: bind [ëìá÷éûÁ | ëïíáîäÁ ëìá÷éûÁ | "emacs" | "vi" | "-a"]\n
-37 îÅ×ÅÒÎÁÑ ÆÕÎËÃÉÑ
-38  %s\t\tÎÅ ÏÐÒÅÄÅÌÅÎ\n
+1 Неверное имя клавиши `%S'\n
+2 ПлоÑ
ое имя клавиши: %S\n
+3 ПлоÑ
ое имя команды: %S\n
+4 ПлоÑ
ая спецификация клавиши %S\n
+5 Пустая строка\n
+6 Стандартные привязки клавиш\n
+7 Альтернативные привязки клавиш\n
+8 Много-символьные привязки\n
+9 Привязки управляющиÑ
 клавиш\n
+10 %-15s->  не определено\n
+11 BUG!!! %s не связан ни с чем.\n
+12 Использование: bindkey [опции] [--] [КЛАВИШа [КОМАНДа]]\n
+13     -a   вывести или привязать КЛАВИШу в альтернативной раскладке клавиатуры\n
+14     -b   воспринимать КЛАВИШу как C-, M-, F- или X- название клавиши\n
+15     -s   воспринимать КОМАНДу как строку, которую нужно вывести\n
+16     -c   воспринимать КОМАНДу как встроенную или внешнюю команду\n
+17     -v   привязать все клавиши в соответствии с редактором vi\n
+18     -e   привязать все клавиши в соответствии с редактором emacs\n
+19     -d   привязать все клавиши в соответствии с редактором по умолчанию\n
+20     -l   вывести список команд редактора и иÑ
 описания\n
+21     -r   удалить привязку КЛАВИШи\n
+22     -k   воспринимать КЛАВИШу как явное название управляющей клавиши\n
+23     --   не воспринимать все последующие параметры как опции\n
+24     -u   (или любая неправильная опция) вывести этот текст\n
+25 Без КЛАВИШи или КОМАНДы, вывести все привязки.\n
+26 Без КОМАНДы, вывести привязку КЛАВИШи\n.\n
+27 плоÑ
ая спецификация клавиши -- нулевая строка\n
+28 плоÑ
ая спецификация клавиши -- пустая строка\n
+29 ПлоÑ
ая спецификация функциональной клавиши. Нулевая клавиша запрещена\n
+30 плоÑ
ая спецификация клавиши -- неверный шестнадцатеричный номер\n
+31 плоÑ
ая спецификация клавиши -- неверный восьмеричный номер\n
+32 плоÑ
ая спецификация клавиши -- неверный десятичный номер\n
+33 ПлоÑ
ая спецификация функциональной клавиши.\n
+34 Нулевые клавиши запрещены\n
+35 плоÑ
ая спецификация клавиши -- неизвестное имя "%S"\n
+36 использование: bind [КЛАВИШа | КОМАНДа КЛАВИШа | "emacs" | "vi" | "-a"]\n
+37 Неверная функция
+38  %s\t\tне определен\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/russian/set22
--- a/head/contrib/tcsh/nls/russian/set22	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/russian/set22	Fri Mar 02 16:54:40 2012 +0200
@@ -1,17 +1,17 @@
-$ $tcsh: set22,v 1.4 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set22,v 1.5 2011/02/04 18:19:42 christos Exp $
 $ tc.func.c
 $set 22 
-1 %S: \t ÐÅÒÅÏÐÒÅÄÅÌÅÎÏ × 
-2 \nîÅ×ÅÒÎÙÊ ÐÁÒÏÌØ ÄÌÑ %s\n
-3 ïÛÉÂÏÞÎÏÅ ÐÅÒÅÏÐÒÅÄÅÌÅÎÉÅ 'precmd' ÕÄÁÌÅÎÏ.\n
-4 ïÛÉÂÏÞÎÏÅ ÐÅÒÅÏÐÒÅÄÅÌÅÎÉÅ 'cwdcmd' ÕÄÁÌÅÎÏ.\n
-5 ïÛÉÂÏÞÎÏÅ ÐÅÒÅÏÐÒÅÄÅÌÅÎÉÅ 'beepcmd' ÕÄÁÌÅÎÏ.\n
-6 ïÛÉÂÏÞÎÏÅ ÐÅÒÅÏÐÒÅÄÅÌÅÎÉÅ 'periodic' ÕÄÁÌÅÎÏ.\n
-7 ÒÁÚÂÏÒ ËÏÍÁÎÄÎÏÊ ÓÔÒÏËÉ\n
-8 ÷Ù ÄÅÊÓÔ×ÉÔÅÌØÎÏ ÈÏÔÉÔÅ ÕÄÁÌÉÔØ ×ÓÅ ÆÁÊÌÙ? [n/y] 
-9 ÕÄÁÌÅÎÉÅ ×ÓÅÈ ÆÁÊÌÏ× ÐÒÏÐÕÝÅÎÏ!\n
-10 ËÏÍÁÎÄÎÁÑ ÓÔÒÏËÁ ÔÅÐÅÒØ:\n
-11 ÒÁÚÂÏÒ ËÏÍÁÎÄÎÏÊ ÓÔÒÏËÉ\n
-12 × ÏÄÎÏÍ ÉÚ ÓÐÉÓËÏ×\n
-13 ËÏÍÁÎÄÎÁÑ ÓÔÒÏËÁ ÔÅÐÅÒØ:\n
+1 %S: \t переопределено в 
+2 \nНеверный пароль для %s\n
+3 Ошибочное переопределение 'precmd' удалено.\n
+4 Ошибочное переопределение 'cwdcmd' удалено.\n
+5 Ошибочное переопределение 'beepcmd' удалено.\n
+6 Ошибочное переопределение 'periodic' удалено.\n
+7 разбор командной строки\n
+8 Ð’Ñ‹ действительно Ñ
отите удалить все файлы? [n/y] 
+9 удаление всеÑ
 файлов пропущено!\n
+10 командная строка теперь:\n
+11 разбор командной строки\n
+12 в одном из списков\n
+13 командная строка теперь:\n
 14 yY
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/russian/set23
--- a/head/contrib/tcsh/nls/russian/set23	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/russian/set23	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set23,v 1.3 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set23,v 1.4 2011/02/04 18:19:42 christos Exp $
 $ tc.os.c
 $set 23 
 1 Bad cpu/site name
@@ -19,16 +19,16 @@
 16 release:  %s\n
 17 version:  %s\n
 18 machine:  %s\n
-19 getwd: îÅ ÍÏÇÕ ÏÔËÒÙÔØ ".." (%s)
-20 getwd: îÅ ÍÏÇÕ ÓÍÅÎÉÔØ ËÁÔÁÌÏÇ ÎÁ ".." (%s)
-21 getwd: ïÛÉÂËÁ ÞÔÅÎÉÑ × ".." (%s)
-22 getwd: îÅ ÍÏÇÕ ×ÅÒÎÕÔØÓÑ ÎÁÚÁÄ × "." (%s)
-23 getwd: îÅ ÍÏÇÕ ×ÙÐÏÌÎÉÔØ stat ÎÁ "/" (%s)
-24 getwd: îÅ ÍÏÇÕ ×ÙÐÏÌÎÉÔØ stat ÎÁ "." (%s)
-25 getwd: îÅ ÍÏÇÕ ×ÙÐÏÌÎÉÔØ stat ÎÁ ËÁÔÁÌÏÇ "%s" (%s)
-26 getwd: îÅ ÍÏÇÕ ÏÔËÒÙÔØ ËÁÔÁÌÏÇ "%s" (%s)
-27 getwd: îÅ ÍÏÇÕ ÎÁÊÔÉ "." × ".." (%s)
-28 îÅ×ÅÒÎÙÊ ÔÉÐ ÓÉÓÔÅÍÙ
-29 ôÉÐ ÓÉÓÔÅÍÙ ÎÅ ÕÓÔÁÎÏ×ÌÅÎ
-30 óÌÉÛËÏÍ ÍÎÏÇÏ ÁÒÇÕÍÅÎÔÏ×
-31 îÅ×ÅÒÎÙÊ ÁÒÇÕÍÅÎÔ
+19 getwd: Не могу открыть ".." (%s)
+20 getwd: Не могу сменить каталог на ".." (%s)
+21 getwd: Ошибка чтения в ".." (%s)
+22 getwd: Не могу вернуться назад в "." (%s)
+23 getwd: Не могу выполнить stat на "/" (%s)
+24 getwd: Не могу выполнить stat на "." (%s)
+25 getwd: Не могу выполнить stat на каталог "%s" (%s)
+26 getwd: Не могу открыть каталог "%s" (%s)
+27 getwd: Не могу найти "." в ".." (%s)
+28 Неверный тип системы
+29 Тип системы не установлен
+30 Слишком много аргументов
+31 Неверный аргумент
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/russian/set25
--- a/head/contrib/tcsh/nls/russian/set25	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/russian/set25	Fri Mar 02 16:54:40 2012 +0200
@@ -1,6 +1,6 @@
-$ $tcsh: set25,v 1.2 2006/03/02 18:46:47 christos Exp $
+$ $tcsh: set25,v 1.3 2011/02/04 18:19:42 christos Exp $
 $ tc.sig.c
 $set 25 
 1 our wait %d\n
-2 ÏÛÉÂËÁ: bsd_signal(%d) ÓÉÇÎÁÌ ×ÙÛÅÌ ÚÁ ÐÒÅÄÅÌÙ ÉÎÔÅÒ×ÁÌÁ\n
-3 ÏÛÉÂËÁ: bsd_signal(%d) - sigaction ÚÁ×ÅÒÛÉÌÓÑ ÎÅÕÄÁÞÎÏ, errno %d\n
+2 ошибка: bsd_signal(%d) сигнал вышел за пределы интервала\n
+3 ошибка: bsd_signal(%d) - sigaction завершился неудачно, errno %d\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/russian/set26
--- a/head/contrib/tcsh/nls/russian/set26	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/russian/set26	Fri Mar 02 16:54:40 2012 +0200
@@ -1,15 +1,15 @@
-$ $tcsh: set26,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set26,v 1.4 2011/02/04 18:19:42 christos Exp $
 $ tc.who.c
 $set 26 
-1 ÎÅ ÍÏÇÕ ×ÙÐÏÌÎÉÔØ stat ÎÁ %s. ðÏÖÁÌÕÊÓÔÁ, ×ÙÐÏÌÎÉÔÅ "unset watch".\n
-2 %s ÎÅ ÍÏÖÅÔ ÂÙÔØ ÏÔËÒÙÔ. ðÏÖÁÌÕÊÓÔÁ, ×ÙÐÏÌÎÉÔÅ "unset watch".\n
-3 BUG! ÐÏÓÌÅÄÎÉÊ ÜÌÅÍÅÎÔ ÎÅ Ñ×ÌÑÅÔÓÑ whotail!\n
-4 ÎÁÚÁÄ: 
-5 BUG! ÐÅÒ×ÙÊ ÜÌÅÍÅÎÔ ÎÅ Ñ×ÌÑÅÔÓÑ whohead!\n
-6 ÎÏ×ÙÊ: %s/%s\n
+1 не могу выполнить stat на %s. Пожалуйста, выполните "unset watch".\n
+2 %s не может быть открыт. Пожалуйста, выполните "unset watch".\n
+3 BUG! последний элемент не является whotail!\n
+4 назад: 
+5 BUG! первый элемент не является whohead!\n
+6 новый: %s/%s\n
 7 %n has %a %l from %m.
 8 %n has %a %l.
 9 logged on
 10 logged off
 11 replaced %s on
-12 ÌÏËÁÌØÎÙÊ
+12 локальный
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/russian/set27
--- a/head/contrib/tcsh/nls/russian/set27	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/russian/set27	Fri Mar 02 16:54:40 2012 +0200
@@ -1,8 +1,8 @@
-$ $tcsh: set27,v 1.4 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set27,v 1.5 2011/02/04 18:19:42 christos Exp $
 $ tw.comp.c
 $set 27 
-1 ËÏÍÁÎÄÁ
-2 ÓÅÐÁÒÁÔÏÒ
-3 ÛÁÂÌÏÎ
-4 ÉÎÔÅÒ×ÁÌ
-5 ÚÁ×ÅÒÛÅÎÉÅ
+1 команда
+2 сепаратор
+3 шаблон
+4 интервал
+5 завершение
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/russian/set29
--- a/head/contrib/tcsh/nls/russian/set29	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/russian/set29	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set29,v 1.2 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set29,v 1.3 2011/02/04 18:19:42 christos Exp $
 $ tw.help.c
 $set 29 
-1 ïÔÓÕÔÓÔ×ÕÅÔ ÆÁÊÌ ÐÏÍÏÝÉ ÄÌÑ %S\n
+1 Отсутствует файл помощи для %S\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/russian/set30
--- a/head/contrib/tcsh/nls/russian/set30	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/russian/set30	Fri Mar 02 16:54:40 2012 +0200
@@ -1,16 +1,16 @@
-$ $tcsh: set30,v 1.4 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set30,v 1.5 2011/02/04 18:19:42 christos Exp $
 $ tw.parse.c
 $set 30 
 1 starting_a_command %d\n
 2 complete %d 
 3 complete %d %S\n
-4 %s: ÷ÎÕÔÒÅÎÎÑÑ match error.\n
-5 ÜÌÅÍÅÎÔÏ×
-6 ÒÑÄÏ×
-7 îÁÊÄÅÎÏ %d %s, ×Ù ÄÅÊÓÔ×ÉÔÅÌØÎÏ ÈÏÔÉÔÅ ×Ù×ÅÓÔÉ ÉÈ ×ÓÅÈ? [n/y] 
+4 %s: Внутренняя match error.\n
+5 элементов
+6 рядов
+7 Найдено %d %s, вы действительно Ñ
отите вывести иÑ
 всеÑ
? [n/y] 
 8 looking = %d\n
-9 \n×ÎÕÔÒÅÎÎÑÑ ÏÛÉÂËÁ tcsh: Ñ ÎÅ ÚÎÁÀ, ÞÔÏ Ñ ÉÝÕ!\n
-10 ÎÅ ËÁÔÁÌÏÇ
-11 ÎÅ ÎÁÊÄÅÎÏ
-12 ÎÅÞÉÔÁÅÍÏ
+9 \nвнутренняя ошибка tcsh: я не знаю, что я ищу!\n
+10 не каталог
+11 не найдено
+12 нечитаемо
 13 yY
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/russian/set31
--- a/head/contrib/tcsh/nls/russian/set31	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/russian/set31	Fri Mar 02 16:54:40 2012 +0200
@@ -1,7 +1,7 @@
-$ $tcsh: set31,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set31,v 1.4 2011/02/04 18:19:42 christos Exp $
 $ vms.termcap.c
 $set 31 
-1 îÅ ÍÏÇÕ ÏÔËÒÙÔØ TERMCAP: [%s]\n
-2 îÅ ÍÏÇÕ ÏÔËÒÙÔØ %s.\n
-3 îÁÊÄÅÎÏ %s × %s.\n
-4 óÏÏÔ×ÅÔÓÔ×ÉÊ ÄÌÑ %s ÎÅ ÎÁÊÄÅÎÏ × ÆÁÊÌÅ %s\n
+1 Не могу открыть TERMCAP: [%s]\n
+2 Не могу открыть %s.\n
+3 Найдено %s в %s.\n
+4 Соответствий для %s не найдено в файле %s\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/russian/set4
--- a/head/contrib/tcsh/nls/russian/set4	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/russian/set4	Fri Mar 02 16:54:40 2012 +0200
@@ -1,26 +1,26 @@
-$ $tcsh: set4,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set4,v 1.4 2011/02/04 18:19:42 christos Exp $
 $ Termcap strings
 $set 4
-1 ÄÏÂÁ×ÉÔØ ÎÏ×ÕÀ ÐÕÓÔÕÀ ÓÔÒÏËÕ
-2 Ú×ÕËÏ×ÏÊ Ú×ÏÎÏË
-3 ÏÞÉÓÔÉÔØ ÄÏ ËÏÎÃÁ
-4 ÏÞÉÓÔÉÔØ ÄÏ ËÏÎÃÁ ÓÔÒÏËÉ
-5 ËÕÒÓÏÒ ÎÁ ÇÏÒÉÚÏÎÔÁÌØÎÕÀ ÐÏÚÉÃÉÀ
-6 ÏÞÉÓÔÉÔØ ÜËÒÁÎ
-7 ÕÄÁÌÉÔØ ÓÉÍ×ÏÌ
-8 ÕÄÁÌÉÔØ ÓÔÒÏËÕ
-9 ÐÅÒÅÊÔÉ × ÒÅÖÉÍ ÕÄÁÌÅÎÉÑ
-10 ×ÙÊÔÉ ÉÚ ÒÅÖÉÍÁ ÕÄÁÌÅÎÉÑ
-11 ×ÙÊÔÉ ÉÚ ÒÅÖÉÍÁ ×ÓÔÁ×ËÉ
+1 добавить новую пустую строку
+2 звуковой звонок
+3 очистить до конца
+4 очистить до конца строки
+5 курсор на горизонтальную позицию
+6 очистить экран
+7 удалить символ
+8 удалить строку
+9 перейти в режим удаления
+10 выйти из режима удаления
+11 выйти из режима вставки
 12 cursor from status line
 13 home cursor
-14 ×ÓÔÁ×ÉÔØ ÓÉÍ×ÏÌ
-15 ÐÅÒÅÊÔÉ × ÒÅÖÉÍ ×ÓÔÁ×ËÉ
+14 вставить символ
+15 перейти в режим вставки
 16 insert padding
-17 ÐÅÒÅÍÅÓÔÉÔØ ËÕÒÓÏÒ ×ÎÉÚ
-18 ÐÅÒÅÍÅÓÔÉÔØ ËÕÒÓÏÒ ×ÌÅ×Ï
-19 ÐÅÒÅÍÅÓÔÉÔØ ËÕÒÓÏÒ ×ÐÒÁ×Ï
-20 ÐÅÒÅÍÅÓÔÉÔØ ËÕÒÓÏÒ ××ÅÒÈ
+17 переместить курсор вниз
+18 переместить курсор влево
+19 переместить курсор вправо
+20 переместить курсор вверÑ

 21 begin bold
 22 end attributes
 23 non destructive space
@@ -30,16 +30,16 @@
 27 cursor up one
 28 begin underline
 29 end underline
-30 ×ÉÚÕÁÌØÎÙÊ Ú×ÏÎÏË
-31 ÕÄÁÌÉÔØ ÎÅÓËÏÌØËÏ ÓÉÍ×ÏÌÏ×
+30 визуальный звонок
+31 удалить несколько символов
 32 cursor down multiple
-33 ×ÓÔÁ×ÉÔØ ÎÅÓËÏÌØËÏ ÓÉÍ×ÏÌÏ×
+33 вставить несколько символов
 34 cursor left multiple
 35 cursor right multiple
 36 cursor up multiple
 37 Has automatic margins
 38 Can use physical tabs
-39 þÉÓÌÏ ÓÔÒÏË
-40 þÉÓÔÏ ÓÔÏÌÂÃÏ×
+39 Число строк
+40 Чисто столбцов
 41 Has meta key
 42 Newline ignored at right margin
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/russian/set5
--- a/head/contrib/tcsh/nls/russian/set5	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/russian/set5	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set5,v 1.2 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set5,v 1.3 2011/02/04 18:19:42 christos Exp $
 $ ed.chared.c
 $set 5
-1 óÒÅÄÎÑÑ ÚÁÇÒÕÚËÁ ÎÅÄÏÓÔÕÐÎÁ\n
+1 Средняя загрузка недоступна\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/russian/set6
--- a/head/contrib/tcsh/nls/russian/set6	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/russian/set6	Fri Mar 02 16:54:40 2012 +0200
@@ -1,11 +1,11 @@
-$ $tcsh: set6,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set6,v 1.4 2011/02/04 18:19:42 christos Exp $
 $ ed.inputl.c
 $set 6
-1 ïûéâëá: ÎÅ×ÅÒÎÁÑ ËÏÍÁÎÄÁ ËÌÀÞÁ 0%o\r\n
-2 ÄÁ\n
-3 ÒÅÄÁËÔÉÒÏ×ÁÔØ\n
-4 ÐÒÅÒ×ÁÔØ\n
-5 ÎÅÔ\n
-6 îÅÔ ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÅÊ ËÏÍÁÎÄÙ\n
-7 îÅÏÄÎÏÚÎÁÞÎÁÑ ËÏÍÁÎÄÁ\n
-8 *** ÆÁÔÁÌØÎÁÑ ïûéâëá ÒÅÄÁËÔÏÒÁ ***\r\n\n
+1 ОШИБКА: неверная команда ключа 0%o\r\n
+2 да\n
+3 редактировать\n
+4 прервать\n
+5 нет\n
+6 Нет соответствующей команды\n
+7 Неоднозначная команда\n
+8 *** фатальная ОШИБКА редактора ***\r\n\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/russian/set7
--- a/head/contrib/tcsh/nls/russian/set7	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/russian/set7	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set7,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set7,v 1.4 2011/02/04 18:19:42 christos Exp $
 $ ed.screen.c
 $set 7
 1 \n\tTcsh thinks your terminal has the\n
@@ -10,20 +10,20 @@
 7 \tIt can%s use tabs\n
 8 not
 9 \tIt %s automatic margins\n
-10 ÉÍÅÅÔ
-11 ÎÅ ÉÍÅÅÔ
+10 имеет
+11 не имеет
 12 \tIt %s magic margins\n
-13 (ÐÕÓÔÏ)
-14 ÄÁ
-15 ÎÅÔ
-16 ïûéâëá: ÎÅ ÍÏÇÕ ÕÄÁÌÉÔØ\r\n
+13 (пусто)
+14 да
+15 нет
+16 ОШИБКА: не могу удалить\r\n
 17 DeleteChars: num is riduculous: %d\r\n
-18 ïûéâëá: ÎÅ ÍÏÇÕ ×ÓÔÁ×ÉÔØ\r\n
+18 ОШИБКА: не могу вставить\r\n
 19 StartInsert: num is riduculous: %d\r\n
-20 %s: îÅ ÍÏÇÕ ÏÔËÒÙÔØ /etc/termcap.\n
+20 %s: Не могу открыть /etc/termcap.\n
 21 %s: No entry for terminal type "%s"\n
 22 %s: using dumb terminal settings.\n
-23 %s: ÷îéíáîéå: Your terminal cannot move up.\n
+23 %s: ВНИМАНИЕ: Your terminal cannot move up.\n
 24 Editing may be odd for long lines.\n
 25 no clear EOL capability.\n
 26 no delete char capability.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/russian/set8
--- a/head/contrib/tcsh/nls/russian/set8	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/russian/set8	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,5 @@
-$ $tcsh: set8,v 1.2 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set8,v 1.3 2011/02/04 18:19:42 christos Exp $
 $ ed.term.c
 $set 8
-1 îÅÉÚ×ÅÓÔÎÙÊ ÐÅÒÅËÌÀÞÁÔÅÌØ
-2 îÅ×ÅÒÎÙÊ ÁÒÇÕÍÅÎÔ
+1 Неизвестный переключатель
+2 Неверный аргумент
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/russian/set9
--- a/head/contrib/tcsh/nls/russian/set9	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/russian/set9	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set9,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set9,v 1.4 2011/02/04 18:19:42 christos Exp $
 $ ed.xmap.c
 $set 9
 1 AddXkey: Null extended-key not allowed.\n
@@ -6,7 +6,7 @@
 3 DeleteXkey: Null extended-key not allowed.\n
 4 Unbound extended key "%S"\n
 5 Some extended keys too long for internal print buffer
-6 Enumerate: BUG!! ðÅÒÅÄÁÎ ÎÕÌÅ×ÏÊ ÕËÁÚÁÔÅÌØ!\n
-7 ÎÅÔ ××ÏÄÉÍÙÈ ÄÁÎÎÙÈ
+6 Enumerate: BUG!! Передан нулевой указатель!\n
+7 нет вводимыÑ
 данныÑ

 8 Something must follow: %c\n
-9 ÷ÏÓØÍÅÒÉÞÎÁÑ ËÏÎÓÔÁÎÔÁ ÎÅ ÕÍÅÝÁÅÔÓÑ × char.\n
+9 Восьмеричная константа не умещается в char.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/spanish/charset
--- a/head/contrib/tcsh/nls/spanish/charset	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/spanish/charset	Fri Mar 02 16:54:40 2012 +0200
@@ -1,3 +1,3 @@
-$ codeset=ISO-8859-1
+$ codeset=UTF-8
 $set 255
-1 ISO-8859-1
+1 UTF-8
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/spanish/set1
--- a/head/contrib/tcsh/nls/spanish/set1	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/spanish/set1	Fri Mar 02 16:54:40 2012 +0200
@@ -1,140 +1,140 @@
-$ $tcsh: set1,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set1,v 1.4 2011/02/04 18:19:42 christos Exp $
 $ Mensajes de Error
 $set 1 
 1 Error de sintaxis
-2 %s no está permitido
+2 %s no está permitido
 3 Palabra demasiado larga
-4 $< línea demasiado larga
+4 $< línea demasiado larga
 5 No hay fichero para $0
 6 Modificador [] incompleto
-7 $ expansión debe terminar antes de ]
-8 Modificador erróneo : en $ (%c)
-9 Error de índice
-10 Número erróneamente formado
-11 No hay más palabras
+7 $ expansión debe terminar antes de ]
+8 Modificador erróneo : en $ (%c)
+9 Error de índice
+10 Número erróneamente formado
+11 No hay más palabras
 12 Falta nombre de fichero
 13 Error interno de glob
 14 Comando no encontrado
 15 Demasiado pocos argumentos
 16 Demasiados argumentos
 17 Es demasiado peligroso crear un alias para eso
-18 `If' vacío
+18 `If' vacío
 19 `Then' incorrecto
-20 Las palabras no están entre paréntesis
+20 Las palabras no están entre paréntesis
 21 No se encuentra %s
-22 Máscara incorrecta
-23 No existe límite de ese tipo
+22 Máscara incorrecta
+23 No existe límite de ese tipo
 24 Argumento demasiado grande
 25 Factor de escala incorrecto o desconocido
 26 Variable indefinida
 27 La pila de directorios no es tan profunda
-28 Mal número de señal
-29 Señal desconocida; `kill -l' lista las señales
+28 Mal número de señal
+29 Señal desconocida; `kill -l' lista las señales
 30 El nombre de la variable debe comenzar con una letra
 31 El nombre de la variable es demasiado grande
-32 El nombre de la variable debe contener caracteres alfanuméricos
+32 El nombre de la variable debe contener caracteres alfanuméricos
 33 No hay control de trabajos en esta shell
-34 Sintaxis de la expresión
-35 No está el directorio personal
+34 Sintaxis de la expresión
+35 No está el directorio personal
 36 No se puede cambiar al directorio personal
-37 Comando nulo inválido
-38 Expresion carece de asignación
+37 Comando nulo inválido
+38 Expresion carece de asignación
 39 Operador desconocido
 40 Ambiguo
 41 %s: Archivo existente
 42 El argumento para `-c' debe terminar en una barra invertida
 43 Interumpido
-44 Índice fuera del rango válido
-45 Sobrepasada la capacidad de la línea
+44 Índice fuera del rango válido
+45 Sobrepasada la capacidad de la línea
 46 No existe ese trabajo
 47 No se puede desde una terminal
 48 No se encuentra en bucle while/foreach
-49 No hay más procesos
+49 No hay más procesos
 50 No existe correspondencia
 51 Falta %c
 52 No se ha hallado correspondencia con %c
 53 Memoria insuficiente
-54 No se puede crear la tubería
+54 No se puede crear la tubería
 55 %s: %s
 56 %s
 57 Uso: jobs [ -l ]
 58 Los argumentos deben ser trabajos o identificadores de proceso
 59 No hay trabajo en curso
 60 No hay trabajo previo
-61 No hay trabajo que corresponda con este patrón
+61 No hay trabajo que corresponda con este patrón
 62 Llamadas a `fork' entrelazadas > %d; puede ser un bucle `...`
 63 No se puede gestionar trabajos en sub-shells 
-64 Fallo de sincronización: No se encuentra el proceso %d
+64 Fallo de sincronización: No se encuentra el proceso %d
 65 %shay trabajos interrumpidos
 66 %shay trabajos parados
-67 No hay más directorios
-68 Pila de directorios vacía
-69 Directorio erróneo
+67 No hay más directorios
+68 Pila de directorios vacía
+69 Directorio erróneo
 70 Uso: %s [-%s]%s
 71 `-h' necesita operandos
 72 No es un shell de ingreso
-73 División por 0
-74 Módulo por 0
+73 División por 0
+74 Módulo por 0
 75 Error de escala: Seguro que era "%s"?
-76 No se puede suspender un shell de ingreso (aún)
+76 No se puede suspender un shell de ingreso (aún)
 77 Usuario desconocido: %s
-78 La variable $home no está definida
-79 Uso: history [-%s] [# número de comandos]
+78 La variable $home no está definida
+79 Uso: history [-%s] [# número de comandos]
 80 No esta permitido el uso de $, ! o < con $# o $?
 81 Nombre de variable incluye un retorno de carro
 82 No esta permitido el uso de * con  $# o $?
-83 No esta permitido usar $?<dígito> o $#<dígito>
+83 No esta permitido usar $?<dígito> o $#<dígito>
 84 Nombre de variable ilegal
-85 Retorno de carro en el índice de variables
-86 Desborde en el buffer de expansión
+85 Retorno de carro en el índice de variables
+86 Desborde en el buffer de expansión
 87 Sintaxis de variable
 88 Forma ! incorrecta
 89 No existe sustituto previo
-90 Sustituto erróneo
+90 Sustituto erróneo
 91 No existe `lado izquierdo' previo
-92 Valor de asignación demasiado largo
+92 Valor de asignación demasiado largo
 93 Modificador de ! incorrecto: %c
 94 Error de modificador
-95 Desborde el el buffer de sustitución
-96 Selector de argumento de ! erróneo
-97 No existe búsqueda previa
+95 Desborde el el buffer de sustitución
+96 Selector de argumento de ! erróneo
+97 No existe búsqueda previa
 98 %s: No se encuentra el comando
 99 Demasiados `)'
 100 Demasiados `('
-101 Colocación de `(' incorrecta
-102 Falta el nombre de la redirección
-103 Redirección de salida ambigua
-104 No se puede usar << entre paréntesis
-105 Redirección de entrada ambigua
-106 Colocación de paréntesis errónea
+101 Colocación de `(' incorrecta
+102 Falta el nombre de la redirección
+103 Redirección de salida ambigua
+104 No se puede usar << entre paréntesis
+105 Redirección de entrada ambigua
+106 Colocación de paréntesis errónea
 107 Lazo en los `alias'
 108 La variable $watch no ha sido definida
 109 No hay comandos programados
 110 Uso: sched -<item#>.\nUso: sched [+]hh:mm <comando>
 111 No hay tantos comandos programados
-112 No hay ningún comando a ejecutar
-113 Tiempo de ejecución del comando incorrecto
+112 No hay ningún comando a ejecutar
+113 Tiempo de ejecución del comando incorrecto
 114 Tiempo relativo inconsistente con am/pm
 115 Se ha agotado el espacio para cadenas termcap
 116 Uso: settc %s [yes|no]
-117 Característica `%s' desconocida
-118 Parámetro termcap `%%%c' desconocido
+117 Característica `%s' desconocida
+118 Parámetro termcap `%%%c' desconocido
 119 Demasiados argumentos para `%s' (%d)
 120 `%s' requiere %d argumentos
-121 Uso: echotc [-v|-s] [<característica> [<args>]]
-122 %s: %s. Arquitectura errónea
+121 Uso: echotc [-v|-s] [<característica> [<args>]]
+122 %s: %s. Arquitectura errónea
 123 !# Lazo en el historial
 124 Consulta de archivo incorrecta
 125 Desborde en el selector
-126 Opción desconocida: `-%s'\nUso: %s [ -bcdefilmnqstvVxX -Dnombre[=valor] ] [ argumento ... ]
-127 Opción desconocida: `-%s'\nUso: %s [ -bcdefFilmnqstvVxX ] [ argumento ... ]
-128 Opción desconocida: `-%s'\nUso: %s [ -bcdefilmnqstvVxX ] [ argumento ... ]
-129 \nModo de terminación automática inválido: "%s"
-130 \nInválido %s: '%c'
-131 \nFalta el separador '%c' después %s "%s"
+126 Opción desconocida: `-%s'\nUso: %s [ -bcdefilmnqstvVxX -Dnombre[=valor] ] [ argumento ... ]
+127 Opción desconocida: `-%s'\nUso: %s [ -bcdefFilmnqstvVxX ] [ argumento ... ]
+128 Opción desconocida: `-%s'\nUso: %s [ -bcdefilmnqstvVxX ] [ argumento ... ]
+129 \nModo de terminación automática inválido: "%s"
+130 \nInválido %s: '%c'
+131 \nFalta el separador '%c' después %s "%s"
 132 \n%s incompleto: "%s"
 133 `-m' no necesita operandos
-134 Uso: unlimit [-fh] [límites]
-135 $%S es de sólo-lectura
+134 Uso: unlimit [-fh] [límites]
+135 $%S es de sólo-lectura
 136 No existe ese trabajo
 137 Unknown colorls variable `%c%c'
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/spanish/set10
--- a/head/contrib/tcsh/nls/spanish/set10	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/spanish/set10	Fri Mar 02 16:54:40 2012 +0200
@@ -1,8 +1,8 @@
-$ $tcsh: set10,v 1.2 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set10,v 1.3 2011/02/04 18:19:42 christos Exp $
 $ ma.setp.c
 $set 10 
 1 setpath: comando '%s' incorrecto.\n
 2 setpath: insuficientes argumentos para el comando '%s'.\n
 3 setpath: falta el valor en la ruta '%s'\n
 4 setpath: no se encuentra %s en %s\n
-5 setpath: %d posición inválida en %s\n
+5 setpath: %d posición inválida en %s\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/spanish/set13
--- a/head/contrib/tcsh/nls/spanish/set13	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/spanish/set13	Fri Mar 02 16:54:40 2012 +0200
@@ -1,9 +1,9 @@
-$ $tcsh: set13,v 1.2 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set13,v 1.3 2011/02/04 18:19:42 christos Exp $
 $ sh.exec.c
 $set 13 
 1 hash=%-4d dir=%-2d prog=%s\n
 2 %d grupos de hash de %d bits cada uno\n
-3 máscara de depurado = 0x%08x\n
+3 máscara de depurado = 0x%08x\n
 4 %d aciertos, %d fallos, %d%%\n
 5 %S: comando integrado en la shell.\n
 6 %S: Comando inexistente.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/spanish/set14
--- a/head/contrib/tcsh/nls/spanish/set14	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/spanish/set14	Fri Mar 02 16:54:40 2012 +0200
@@ -1,6 +1,6 @@
-$ $tcsh: set14,v 1.2 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set14,v 1.3 2011/02/04 18:19:42 christos Exp $
 $ sh.file.c
 $set 14 
-1 \n¡¡Qué asco!! ¡¡Hay demasiados %s!!\n
+1 \n¡¡Qué asco!! ¡¡Hay demasiados %s!!\n
 2 nombres en el archivo de claves
 3 archivos
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/spanish/set15
--- a/head/contrib/tcsh/nls/spanish/set15	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/spanish/set15	Fri Mar 02 16:54:40 2012 +0200
@@ -1,7 +1,7 @@
-$ $tcsh: set15,v 1.2 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set15,v 1.3 2011/02/04 18:19:42 christos Exp $
 $ sh.func.c
 $set 15 
-1 %s: %s: No se puede %s el límite %s\n
+1 %s: %s: No se puede %s el límite %s\n
 2 quitar
 3 poner
 4 \040(hard-limit)
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/spanish/set16
--- a/head/contrib/tcsh/nls/spanish/set16	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/spanish/set16	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set16,v 1.2 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set16,v 1.3 2011/02/04 18:19:43 christos Exp $
 $ sh.lex.c
 $set 16 
 1 Se ha reinicializado el grupo de procesos de las terminales de %d a %d\n
@@ -7,7 +7,7 @@
 4 seek to eval %x %x\n
 5 seek to alias %x %x\n
 6 seek to file %x\n
-7 Tipo de seek erróneo %d\n
+7 Tipo de seek erróneo %d\n
 8 tell eval %x %x\n
 9 tell alias %x %x\n
 10 tell file %x\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/spanish/set17
--- a/head/contrib/tcsh/nls/spanish/set17	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/spanish/set17	Fri Mar 02 16:54:40 2012 +0200
@@ -1,11 +1,11 @@
-$ $tcsh: set17,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set17,v 1.4 2011/02/04 18:19:43 christos Exp $
 $ sh.proc.c
 $set 17 
-1 BUG: ¡en espera de un trabajo en segundo plano!\n
-2 Finalizó %d\n
+1 BUG: ¡en espera de un trabajo en segundo plano!\n
+2 Finalizó %d\n
 3 BUG: Se ha aplicado "flush" al proceso por segunda vez
 4 Ejecutando 
-5 Señal 
+5 Señal 
 6 Finalizado %-25d
 7 Fin
 8 BUG: status=%-9o
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/spanish/set18
--- a/head/contrib/tcsh/nls/spanish/set18	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/spanish/set18	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set18,v 1.2 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set18,v 1.3 2011/02/04 18:19:43 christos Exp $
 $ sh.set.c
 $set 18 
-1 Aviso: PATH de tamaño ridículo ha sido truncado\n
+1 Aviso: PATH de tamaño ridículo ha sido truncado\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/spanish/set19
--- a/head/contrib/tcsh/nls/spanish/set19	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/spanish/set19	Fri Mar 02 16:54:40 2012 +0200
@@ -1,15 +1,23 @@
-$ $tcsh: set19,v 1.2 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set19,v 1.5 2011/02/25 23:58:08 christos Exp $
 $ tc.alloc.c
 $set 19 
 1 nbytes=%d: Se ha agotado la memoria\n
 2 Se ha llamado a free(%lx) antes de asignar nada.
-3 free(%lx) por encima del límite superior de la memoria.
-4 free(%lx) por debajo del límite inferior de la memoria.
-5 free(%lx) bloque erróneo.
-6 free(%lx) chequeo de rango erróneo.
-7 free(%lx) índice de bloque erróneo.
-8 %s asignación actual de memoria:\nfree:\t
-9 \nusada:\t
+3 free(%lx) por encima del límite superior de la memoria.
+4 free(%lx) por debajo del límite inferior de la memoria.
+5 free(%lx) bloque erróneo.
+6 free(%lx) chequeo de rango erróneo.
+7 free(%lx) índice de bloque erróneo.
+8 %s asignación actual de memoria:\nfree:\t
+9 usada
 10 \n\tTotal en uso: %d, total libre: %d\n
-11 \tSe ha asignado memoria de  0x%lx a 0x%lx.  Límite superior real en 0x%lx\n
+11 \tSe ha asignado memoria de  0x%lx a 0x%lx.  Límite superior real en 0x%lx\n
 12 Se ha asignado memoria de 0x%lx a 0x%lx (%ld).\n
+13 %s current memory allocation:\n
+14 Total space allocated from system: %d\n
+15 Number of non-inuse chunks: %d\n
+16 Number of mmapped regions: %d\n
+17 Total space in mmapped regions: %d\n
+18 Total allocated space: %d\n
+19 Total non-inuse space: %d\n
+20 Top-most, releasable space: %d\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/spanish/set2
--- a/head/contrib/tcsh/nls/spanish/set2	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/spanish/set2	Fri Mar 02 16:54:40 2012 +0200
@@ -1,92 +1,92 @@
-$ $tcsh: set2,v 1.2 2006/03/02 18:46:48 christos Exp $
-$ Nombres de señales
+$ $tcsh: set2,v 1.3 2011/02/04 18:19:43 christos Exp $
+$ Nombres de señales
 $set 2 
-1 Señal nula
+1 Señal nula
 2 Colgar
 3 Interrumpir
 4 Salir
-5 Instrucción ilegal
+5 Instrucción ilegal
 6 trap Trace/BPT
 7 Abortar
 8 trap IOT
-9 Caída del sistema inminente
+9 Caída del sistema inminente
 10 Salida con error
 11 trap EMT
-12 Excepción de punto flotante
+12 Excepción de punto flotante
 13 Terminado
-14 Señal de usuario 1
-15 Señal de usuario 2
-16 Error de segmentación
+14 Señal de usuario 1
+15 Señal de usuario 2
+16 Error de segmentación
 17 Error de bus
 18 Error de rango de programa
 19 Error de rango de operando
-20 Llamada del sistema errónea
-21 Tubería rota
+20 Llamada del sistema errónea
+21 Tubería rota
 22 Despertador
 23 Terminado
 24 Cambio de estado en el hijo
 25 Muerte del hijo
-26 Fallo específico de Apollo
+26 Fallo específico de Apollo
 27 El hijo ha parado o terminado
 28 Hijo ha terminado
-29 Fallo de alimentación
+29 Fallo de alimentación
 30 Recurso perdido
 31 Break (Ctrl-Break)
-32 Posible señal de entrada/salida
-33 E/S asíncrona (select)
-34 Condición urgente en el canal de E/S
+32 Posible señal de entrada/salida
+33 E/S asíncrona (select)
+34 Condición urgente en el canal de E/S
 35 Despertar mutiltarea
-36 Finalización multitarea
-37 Final de E/S asíncrona Fortran
-38 Recuperación
+36 Finalización multitarea
+37 Final de E/S asíncrona Fortran
+38 Recuperación
 39 Error incorregible de memoria
 40 Excedido el tiempo de CPU
 41 Bajada del sistema inminente
 42 Grupo micro-tarea-no se ha activado la bandera de despertar
-43 Error de hilo de ejecución - (use cord -T para información detallada)
+43 Error de hilo de ejecución - (use cord -T para información detallada)
 44 Error de paridad de registro CRAY Y-MP
-45 Petición de información
-46 Suspendido (señal)
-47 Parado (señal)
+45 Petición de información
+46 Suspendido (señal)
+47 Parado (señal)
 48 Suspendido
 49 Parado
-50 Continúa
+50 Continúa
 51 Suspendido (entrada tty)
 52 Parado (entrada tty)
 53 Suspendido (salida tty)
 54 Parado (salida tty)
 55 Modificado el estado de la ventana
-56 Modificado el tamaño de la ventana
-57 Modificado el estado del teléfono
+56 Modificado el tamaño de la ventana
+57 Modificado el estado del teléfono
 58 Excedido el tiempo de CPU
-59 Excedido el límite del tamaño de archivo
-60 Señal de temporizador virtual
+59 Excedido el límite del tamaño de archivo
+60 Señal de temporizador virtual
 61 Perfilando la alarma de temporizador
-62 Señal DIL
+62 Señal DIL
 63 Ha tenido lugar un evento interrogable
-64 Los lwps del proceso están bloqueados
-65 Señal LWP especial
-66 Señal CPR especial
-67 Señal CPR especial
-68 Primera señal de tiempo real
-69 Segunda señal de tiempo real
-70 Tercera señal de tiempo real
-71 Cuarta señal de tiempo real
-72 Cuarta señal por la cola de tiempo real
-73 Antepenúltima señal de tiempo real
-74 Penúltima señal de tiempo real
-75 Última señal de tiempo real
-76 E/S asíncrona LAN
+64 Los lwps del proceso están bloqueados
+65 Señal LWP especial
+66 Señal CPR especial
+67 Señal CPR especial
+68 Primera señal de tiempo real
+69 Segunda señal de tiempo real
+70 Tercera señal de tiempo real
+71 Cuarta señal de tiempo real
+72 Cuarta señal por la cola de tiempo real
+73 Antepenúltima señal de tiempo real
+74 Penúltima señal de tiempo real
+75 Última señal de tiempo real
+76 E/S asíncrona LAN
 77 Lectura/escritura PTY disponible
-78 Intervención E/S requerida
+78 Intervención E/S requerida
 79 Otorgado modo monitor HFT
-80 Se debería abandonar el modo monitor HFT
+80 Se debería abandonar el modo monitor HFT
 81 Se ha completado el control de sonido HFT
 82 Hay datos en el buffer circular HFT
 83 Migrar proceso
-84 Tecla de atención asegurada
-85 Reprogramación
-86 Señalar SS$_DEBUG
+84 Tecla de atención asegurada
+85 Reprogramación
+86 Señalar SS$_DEBUG
 87 Prioridad cambiada
 88 Bloqueo real detectado
-89 Nuevo carácter de entrada
+89 Nuevo carácter de entrada
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/spanish/set20
--- a/head/contrib/tcsh/nls/spanish/set20	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/spanish/set20	Fri Mar 02 16:54:40 2012 +0200
@@ -1,41 +1,41 @@
-$ $tcsh: set20,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set20,v 1.4 2011/02/04 18:19:43 christos Exp $
 $ tc.bind.c
 $set 20 
-1 Nombre de tecla no válido `%S'\n
+1 Nombre de tecla no válido `%S'\n
 2 Nombre de tecla incorrecto: %S\n
 3 Nombre de comando incorrecto: %S\n
 4 Especificador de tecla incorrecto %S\n
 5 Especificada la cadena nula\n
-6 Definiciones de teclas estándar\n
+6 Definiciones de teclas estándar\n
 7 Definiciones de teclas alternativas\n
-8 Definiciones Multi-carácter\n
+8 Definiciones Multi-carácter\n
 9 Definiciones de las teclas de flechas\n
 10 %-15s->  indefinida\n
-11 ¡¡¡BUG!!! %s no tiene definición asociada.\n
+11 ¡¡¡BUG!!! %s no tiene definición asociada.\n
 12 Uso: bindkey [opciones] [--] [TECLA [COMANDO]]\n
 13     -a   lista o define TECLA en un mapa de teclas alternativo\n
-14     -b   acepta definiciones de teclas simbólicas\n
+14     -b   acepta definiciones de teclas simbólicas\n
 15     -s   asume que COMANDO es una cadena ha de imprimir literalmente\n
 16     -c   interpreta COMANDO como comando interno o externo\n
 17     -v   usa las definiciones del editor vi\n
 18     -e   usa las definiciones del editor vi\n
 19     -d   usa las definiciones del editor por defecto\n
 20     -l   lista los comandos del editor y sus descripciones\n
-21     -r   elimina la definición asociada a TECLA\n
-22     -k   interpreta TECLA como nombre simbólico de tecla de flecha\n
+21     -r   elimina la definición asociada a TECLA\n
+22     -k   interpreta TECLA como nombre simbólico de tecla de flecha\n
 23     --   fuerza "break" en el procesamiento de opciones\n
-24     -u   (o cualquier opción no válida) este mensaje\n
+24     -u   (o cualquier opción no válida) este mensaje\n
 25 Sin TECLA o COMANDO, imprime todas las asociaciones de teclas\n
-26 Sin COMANDO, imprime la asociación de TECLA.\n
-27 especificación de tecla inválida -- cadena nula\n
-28 especificación de tecla inválida -- cadena vacía\n
-29 Especificación de tecla de función inválida. No se permite una tecla nula\n
-30 especificación de tecla inválida -- número hexadecimal incorrecto\n
-31 especificación de tecla inválida -- número octal incorrecto\n
-32 especificación de tecla inválida -- número decimal incorrecto\n
-33 Especificación de tecla de función incorrecta.\n
+26 Sin COMANDO, imprime la asociación de TECLA.\n
+27 especificación de tecla inválida -- cadena nula\n
+28 especificación de tecla inválida -- cadena vacía\n
+29 Especificación de tecla de función inválida. No se permite una tecla nula\n
+30 especificación de tecla inválida -- número hexadecimal incorrecto\n
+31 especificación de tecla inválida -- número octal incorrecto\n
+32 especificación de tecla inválida -- número decimal incorrecto\n
+33 Especificación de tecla de función incorrecta.\n
 34 No se permite una tecla nula\n
-35 especificación de tecla inválida -- nombre desconocido "%S"\n
+35 especificación de tecla inválida -- nombre desconocido "%S"\n
 36 uso: bind [TECLA | COMANDO TECLA | "emacs" | "vi" | "-a"]\n
-37 función no válida
-38  %s\t\tno está definida\n
+37 función no válida
+38  %s\t\tno está definida\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/spanish/set22
--- a/head/contrib/tcsh/nls/spanish/set22	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/spanish/set22	Fri Mar 02 16:54:40 2012 +0200
@@ -1,17 +1,17 @@
-$ $tcsh: set22,v 1.2 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set22,v 1.3 2011/02/04 18:19:43 christos Exp $
 $ tc.func.c
 $set 22 
 1 %S: \t es un alias de 
 2 \nClave incorrecta para %s\n
-3 Alias erróneo de 'precmd' borrado.\n
-4 Alias erróneo de 'cwdcmd' borrado.\n
-5 Alias erróneo de 'beepcmd' borrado.\n
-6 Alias erróneo de 'periodic' borrado.\n
-7 analizando la línea de comandos\n
-8 ¿Realmente quiere borrar todos los archivos? [n/s]
-9 ¡Anulado el borrado de los archivos!\n
-10 ahora, la línea de comandos es:\n
-11 analizando la línea de comandos\n
+3 Alias erróneo de 'precmd' borrado.\n
+4 Alias erróneo de 'cwdcmd' borrado.\n
+5 Alias erróneo de 'beepcmd' borrado.\n
+6 Alias erróneo de 'periodic' borrado.\n
+7 analizando la línea de comandos\n
+8 ¿Realmente quiere borrar todos los archivos? [n/s]
+9 ¡Anulado el borrado de los archivos!\n
+10 ahora, la línea de comandos es:\n
+11 analizando la línea de comandos\n
 12 en una de las listas\n
-13 ahora, la línea de comandos es:\n
+13 ahora, la línea de comandos es:\n
 14 sSyY
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/spanish/set23
--- a/head/contrib/tcsh/nls/spanish/set23	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/spanish/set23	Fri Mar 02 16:54:40 2012 +0200
@@ -1,24 +1,24 @@
-$ $tcsh: set23,v 1.2 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set23,v 1.3 2011/02/04 18:19:43 christos Exp $
 $ tc.os.c
 $set 23 
-1 Nombre de cpu/máquina incorrecto
-2 Ruta hasta máquina demasiado grande
+1 Nombre de cpu/máquina incorrecto
+2 Ruta hasta máquina demasiado grande
 3 desconocida
-4 máquina: %s\n
-5 %d: No he encontrado esa máquina\n
+4 máquina: %s\n
+5 %d: No he encontrado esa máquina\n
 6 setlocal: %s: %s\n
-7 No he encontrado esa máquina
-8 Está atrapado en un universo que nunca creo
-9 Getwarp falló
-10 Warp inválido
-11 Setwarp falló
+7 No he encontrado esa máquina
+8 Está atrapado en un universo que nunca creo
+9 Getwarp falló
+10 Warp inválido
+11 Setwarp falló
 12 Universo ilegal
 13 Error Desconocido: %d
 14 nombre_sis:  %s\n
 15 nombre_nodo: %s\n
 16 release:  %s\n
-17 versión:  %s\n
-18 máquina:  %s\n
+17 versión:  %s\n
+18 máquina:  %s\n
 19 getwd: No puedo abrir ".." (%s)
 20 getwd: No puedo cambiar a ".." (%s)
 21 getwd: Error de lectura en ".." (%s)
@@ -28,7 +28,7 @@
 25 getwd: No puedo ejecutar stat de "%s" (%s)
 26 getwd: No puedo abrir el directorio "%s" (%s)
 27 getwd: No puedo encontrar "." en ".." (%s)
-28 Tipo de sistema inválido
+28 Tipo de sistema inválido
 29 No se ha fijado el tipo de sistema
 30 Demasiados argumentos
-31 Argumento inválido
+31 Argumento inválido
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/spanish/set25
--- a/head/contrib/tcsh/nls/spanish/set25	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/spanish/set25	Fri Mar 02 16:54:40 2012 +0200
@@ -1,6 +1,6 @@
-$ $tcsh: set25,v 1.2 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set25,v 1.3 2011/02/04 18:19:43 christos Exp $
 $ tc.sig.c
 $set 25 
 1 nuestro wait %d\n
-2 error: bsd_signal(%d) señal fuera de rango\n
+2 error: bsd_signal(%d) señal fuera de rango\n
 3 error: bsd_signal(%d) - sigaction ha fallado, errno %d\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/spanish/set26
--- a/head/contrib/tcsh/nls/spanish/set26	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/spanish/set26	Fri Mar 02 16:54:40 2012 +0200
@@ -1,11 +1,11 @@
-$ $tcsh: set26,v 1.2 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set26,v 1.3 2011/02/04 18:19:43 christos Exp $
 $ tc.who.c
 $set 26 
 1 No se puede completar stat %s.  Por favor, ejecute "unset watch".\n
 2 No se puede abrir %s.  Por favor, ejecute "unset watch".\n
-3 ¡BUG! El último elemento no es whotail!\n
-4 hacia atrás: 
-5 ¡BUG! El primer elemento no es whohead!\n
+3 ¡BUG! El último elemento no es whotail!\n
+4 hacia atrás: 
+5 ¡BUG! El primer elemento no es whohead!\n
 6 nuevo: %s/%s\n
 7 %n tiene %a %l de %m.
 8 %n tiene %a %l.
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/spanish/set27
--- a/head/contrib/tcsh/nls/spanish/set27	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/spanish/set27	Fri Mar 02 16:54:40 2012 +0200
@@ -1,8 +1,8 @@
-$ $tcsh: set27,v 1.2 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set27,v 1.3 2011/02/04 18:19:43 christos Exp $
 $ tw.comp.c
 $set 27 
 1 comando
 2 separador
-3 patrón
+3 patrón
 4 rango 
-5 modo de terminación automática
+5 modo de terminación automática
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/spanish/set3
--- a/head/contrib/tcsh/nls/spanish/set3	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/spanish/set3	Fri Mar 02 16:54:40 2012 +0200
@@ -1,118 +1,118 @@
-$ $tcsh: set3,v 1.3 2006/03/02 18:46:48 christos Exp $
-$ Descripción de las funciones de edición
+$ $tcsh: set3,v 1.4 2011/02/04 18:19:43 christos Exp $
+$ Descripción de las funciones de edición
 $set 3 
-1 Retroceder un carácter
-2 Borrar el carácter detrás del cursor
+1 Retroceder un carácter
+2 Borrar el carácter detrás del cursor
 3 Cortar desde el comienzo de la palabra hasta el cursor - se guarda en el buffer
-4 Cortar desde el comienzo de la línea hasta el cursor - se guarda en el buffer
+4 Cortar desde el comienzo de la línea hasta el cursor - se guarda en el buffer
 5 Ir hasta el comienzo de la palabra
-6 Ir hasta el comienzo de la línea
-7 Convertir en mayúsculas los caracteres desde el cursor hasta el final de la palabra
-8 Vi: cambiar a mayúsculas o minúsculas el carácter bajo el cursor y avanza una posición
-9 Vi: cambia hasta el final de la línea
-10 Borra la pantalla y coloca la línea actual al comienzo
+6 Ir hasta el comienzo de la línea
+7 Convertir en mayúsculas los caracteres desde el cursor hasta el final de la palabra
+8 Vi: cambiar a mayúsculas o minúsculas el carácter bajo el cursor y avanza una posición
+9 Vi: cambia hasta el final de la línea
+10 Borra la pantalla y coloca la línea actual al comienzo
 11 Completa la palabra
 12 Avanza mediante `Tab' por los ficheros
 13 Retrocede mediante `Tab' por los ficheros
 14 Completa la palabra ignorando los modos programables
 15 Copia la palabra hasta el cursor
-16 Copia el área entre la marca y el cursor al buffer
+16 Copia el área entre la marca y el cursor al buffer
 17 Expande a aquella palabra para la que esto es un prefijo
-18 Borra el carácter bajo el cursor
-19 Borra el carácter bajo el cursor o señala el fin de archivo en un archivo vacío
-20 Borra el carácter bajo el cursor o lista posibles finales si está al final de una línea
-21 Borra el carácter bajo el cursor, lista posibles finales o marca final de archivo
+18 Borra el carácter bajo el cursor
+19 Borra el carácter bajo el cursor o señala el fin de archivo en un archivo vacío
+20 Borra el carácter bajo el cursor o lista posibles finales si está al final de una línea
+21 Borra el carácter bajo el cursor, lista posibles finales o marca final de archivo
 22 Corta del cursor al final de la palabra - se guarda en el buffer
-23 Se suma al argumento si ha arrancado o introduce el dígito
-24 Dígito al comienzo del argumento
-25 Ir al final de la línea de historia
-26 Convierte en minúsculas los caracteres desde el cursor al final de la palabra
+23 Se suma al argumento si ha arrancado o introduce el dígito
+24 Dígito al comienzo del argumento
+25 Ir al final de la línea de historia
+26 Convierte en minúsculas los caracteres desde el cursor al final de la palabra
 27 Indica el fin de archivo
-28 Mover el cursor hasta el final de línea
+28 Mover el cursor hasta el final de línea
 29 Intercambia el cursor y la marca
 30 Expande los comodines de nombre de archivo
 31 Expande los escapes del historial
-32 Expande los escapes del historial en una línea
+32 Expande los escapes del historial en una línea
 33 Expande variables
-34 Avanza un carácter
+34 Avanza un carácter
 35 Avanza hasta el final de la palabra
 36 Intercambia los dos caracteres delante del cursor
-37 Busca hacia atrás en el historial una línea que comience igual que la actual
-38 Busca hacia delante una línea que comience igual que la actual
-39 Inserta el último ítem del comando previo
-40 Búsqueda incremental hacia deleante
-41 Búsqueda incremental hacia atrás
-42 Borra la línea
-43 Corta hasta el final de la línea y guarda la información en el buffer
-44 Corta el área de la marca al cursor y guarda la información en el buffer
-45 Corta la línea completa y la guarda en el buffer
+37 Busca hacia atrás en el historial una línea que comience igual que la actual
+38 Busca hacia delante una línea que comience igual que la actual
+39 Inserta el último ítem del comando previo
+40 Búsqueda incremental hacia deleante
+41 Búsqueda incremental hacia atrás
+42 Borra la línea
+43 Corta hasta el final de la línea y guarda la información en el buffer
+44 Corta el área de la marca al cursor y guarda la información en el buffer
+45 Corta la línea completa y la guarda en el buffer
 46 Lista opciones para completar
 47 Lista opciones para completar ignorando los modos programables
-48 Lista los nombres de archivos que concuerdan con el comodín
-49 Lista opciones para completar o indica el final de línea si es una línea vacía
+48 Lista los nombres de archivos que concuerdan con el comodín
+49 Lista opciones para completar o indica el final de línea si es una línea vacía
 50 Imprime la media de carga y es estado de este proceso
 51 Expande los escapes del historial e inserta un espacio
 52 Ejecuta el comando
 53 Expande rutas, eliminando cualquier `.' y `..' que encuentre al comienzo
 54 Expande comandos a la ruta o el alias resultante
-55 Cambia de modo de inserción a sobre escritura y vice versa
-56 Añade el octavo bit al siguiente carácter introducido
-57 Añade el siguiente carácter sin modificar a la línea
+55 Cambia de modo de inserción a sobre escritura y vice versa
+56 Añade el octavo bit al siguiente carácter introducido
+57 Añade el siguiente carácter sin modificar a la línea
 58 Reimprime todo
 59 Reinicia un editor parado
 60 Busca ayuda sobre el comando actual
-61 Se añade este carácter a la línea
-62 Este carácter es el primero de una secuencia de caracteres
+61 Se añade este carácter a la línea
+62 Este carácter es el primero de una secuencia de caracteres
 63 Establece una marca bajo el cursor
-64 Corrige la ortografía de esta palabra
-65 Corrige la ortografía de la línea completa
-66 Envía el carácter a la terminal en modo `cooked'
-67 Cambia entre los modos literal y léxico en esta línea de historial
-68 Intercambia el carácter a la izquierda con el que está bajo el cursor
+64 Corrige la ortografía de esta palabra
+65 Corrige la ortografía de la línea completa
+66 Envía el carácter a la terminal en modo `cooked'
+67 Cambia entre los modos literal y léxico en esta línea de historial
+68 Intercambia el carácter a la izquierda con el que está bajo el cursor
 69 Intercambia los dos caracteres que preceden al cursor
-70 Carácter tty para suspensión retrasada
-71 Carácter tty para `flush' de salida
-72 Carácter tty para interrupción
-73 Carácter tty para salida
-74 Carácter tty para suspensión
-75 Carácter tty para permitir salida
-76 Carácter tty para impedir salida
-77 Indica carácter no asignado
+70 Carácter tty para suspensión retrasada
+71 Carácter tty para `flush' de salida
+72 Carácter tty para interrupción
+73 Carácter tty para salida
+74 Carácter tty para suspensión
+75 Carácter tty para permitir salida
+76 Carácter tty para impedir salida
+77 Indica carácter no asignado
 78 Argumento Emacs universal (argumento por 4)
-79 Ir a la línea anterior
-80 Convierte en mayúsculas los caracteres desde el cursor al final de la palabra
+79 Ir a la línea anterior
+80 Convierte en mayúsculas los caracteres desde el cursor al final de la palabra
 81 Vi: ir al comienzo de la siguiente palabra
-82 Vi: entrar en modo de inserción después el cursor
-83 Vi: entrar en modo de inserción al final de la línea
-84 Vi: cambia a mayúsculas o minúsculas el carácter bajo el cursor y avanza una posición
+82 Vi: entrar en modo de inserción después el cursor
+83 Vi: entrar en modo de inserción al final de la línea
+84 Vi: cambia a mayúsculas o minúsculas el carácter bajo el cursor y avanza una posición
 85 Vi: cambiar el comando de prefijo
-86 Vi: cambiar hasta el final de la línea
-87 Entrar en modo vi (usa asignación de teclas alternativa)
+86 Vi: cambiar hasta el final de la línea
+87 Entrar en modo vi (usa asignación de teclas alternativa)
 88 Vi: modo de comando completa la palabra
-89 Vi: ir al carácter previo (retroceso)
+89 Vi: ir al carácter previo (retroceso)
 90 Vi: borrar el comando de prefijo
 91 Vi: ir hasta el final de la palabra delimitado por espacios
 92 Vi: ir hasta el final de la palabra
-93 Vi: retroceder al carácter especificado
-94 Vi: avanzar al carácter especificado
-95 Vi: retrocede hasta el carácter especificado
-96 Vi: avanzar hasta el carácter especificado
-97 Entrar en modo de inserción `vi'
-98 Entrar en modo de inserción `vi' al comienzo de la línea
-99 Vi: repetir la búsqueda de carácter en la misma dirección
-100 Vi: repetir la búsqueda de carácter en la dirección contraria
-101 Vi: repetir la búsqueda en la misma dirección
-102 Vi: repetir la búsqueda en la dirección contraria
-103 Vi: reemplazar el carácter bajo el cursor por el que se introduzca
+93 Vi: retroceder al carácter especificado
+94 Vi: avanzar al carácter especificado
+95 Vi: retrocede hasta el carácter especificado
+96 Vi: avanzar hasta el carácter especificado
+97 Entrar en modo de inserción `vi'
+98 Entrar en modo de inserción `vi' al comienzo de la línea
+99 Vi: repetir la búsqueda de carácter en la misma dirección
+100 Vi: repetir la búsqueda de carácter en la dirección contraria
+101 Vi: repetir la búsqueda en la misma dirección
+102 Vi: repetir la búsqueda en la dirección contraria
+103 Vi: reemplazar el carácter bajo el cursor por el que se introduzca
 104 Vi: modo de reemplazo
-105 Vi: buscar en el historial hacia atrás
+105 Vi: buscar en el historial hacia atrás
 106 Vi: buscar en el historial hacia adelante
-107 Vi: reemplazar el carácter bajo el cursor cambiando a modo inserción
-108 Vi: reemplazar la línea completa
+107 Vi: reemplazar el carácter bajo el cursor cambiando a modo inserción
+108 Vi: reemplazar la línea completa
 109 Vi: ir a la palabra anterior
 110 Vi: ir a la palabra siguiente
 111 Vi: deshacer el cambio anterior
-112 Vi: ir al comienzo de la línea
+112 Vi: ir al comienzo de la línea
 113 Ejecutar `which' para el comando actual
 114 Pegar el buffer donde el cursor
 115 Replace just-yanked text with yank from earlier kill
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/spanish/set30
--- a/head/contrib/tcsh/nls/spanish/set30	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/spanish/set30	Fri Mar 02 16:54:40 2012 +0200
@@ -1,15 +1,15 @@
-$ $tcsh: set30,v 1.2 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set30,v 1.3 2011/02/04 18:19:43 christos Exp $
 $ tw.parse.c
 $set 30 
 1 comienzo_de_comando %d\n
 2 completar %d 
 3 completar %d %S\n
 4 %s: Error interno de concordancia.\n
-5 ítems
+5 ítems
 6 filas
-7 Existen %d %s, ¿listarlas de todos modos? [n/s] 
+7 Existen %d %s, ¿listarlas de todos modos? [n/s] 
 8 buscando = %d\n
-9 \nerror interno de tcsh: ¡No sé lo que busco!\n
+9 \nerror interno de tcsh: ¡No sé lo que busco!\n
 10 no es un directorio
 11 no he encontrado nada
 12 ilegible
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/spanish/set4
--- a/head/contrib/tcsh/nls/spanish/set4	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/spanish/set4	Fri Mar 02 16:54:40 2012 +0200
@@ -1,45 +1,45 @@
-$ $tcsh: set4,v 1.2 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set4,v 1.3 2011/02/04 18:19:43 christos Exp $
 $ cadenas de Termcap
 $set 4
-1 añade una línea vacía
+1 añade una línea vacía
 2 timbre audible
 3 borra hasta abajo
-4 borra hasta el final de la línea
-5 cursor hasta posición horizontal
+4 borra hasta el final de la línea
+5 cursor hasta posición horizontal
 6 borra la pantalla
-7 borra un carácter
-8 borra una línea
+7 borra un carácter
+8 borra una línea
 9 entra en modo de borrado
 10 termina modo de borrado
-11 termina modo de inserción
-12 cursor de línea de estado
-13 cursor en posición inicial
-14 insertar carácter
-15 entra en modo de inserción
-16 inserta carácter de relleno
-17 envía cursor hacia abajo
-18 envía cursor hacia la izquierda
-19 envía cursor hacia la derecha
-20 envía cursor hacia arriba
+11 termina modo de inserción
+12 cursor de línea de estado
+13 cursor en posición inicial
+14 insertar carácter
+15 entra en modo de inserción
+16 inserta carácter de relleno
+17 envía cursor hacia abajo
+18 envía cursor hacia la izquierda
+19 envía cursor hacia la derecha
+20 envía cursor hacia arriba
 21 comienza negrita
 22 fin de atributos
 23 espacio no destructivo
-24 fin de énfasis
-25 comienzo de énfasis
-26 cursor a la línea de estado
-27 mueve el cursor hacia arriba una línea
+24 fin de énfasis
+25 comienzo de énfasis
+26 cursor a la línea de estado
+27 mueve el cursor hacia arriba una línea
 28 comienza subrayado
 29 fin de subrayado
 30 timbre visible
-31 borra múltiples caracteres
-32 mueve el cursor varias líneas hacia abajo
-33 inserta múltiples caracteres
-34 mueve el cursor varias líneas hacia la izquierda
-35 mueve el cursor varias líneas hacia la derecha
-36 mueve el cursor varias líneas hacia arriba
-37 Tiene márgenes automáticos
-38 Puede usar tabuladores físicos
-39 Número de líneas
-40 Número de columnas
+31 borra múltiples caracteres
+32 mueve el cursor varias líneas hacia abajo
+33 inserta múltiples caracteres
+34 mueve el cursor varias líneas hacia la izquierda
+35 mueve el cursor varias líneas hacia la derecha
+36 mueve el cursor varias líneas hacia arriba
+37 Tiene márgenes automáticos
+38 Puede usar tabuladores físicos
+39 Número de líneas
+40 Número de columnas
 41 Tiene teclas alternativa
 42 Ignorando retorno de carro en el margen derecho
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/spanish/set5
--- a/head/contrib/tcsh/nls/spanish/set5	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/spanish/set5	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set5,v 1.2 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set5,v 1.3 2011/02/04 18:19:43 christos Exp $
 $ ed.chared.c
 $set 5
-1 No está disponible la carga media\n
+1 No está disponible la carga media\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/spanish/set6
--- a/head/contrib/tcsh/nls/spanish/set6	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/spanish/set6	Fri Mar 02 16:54:40 2012 +0200
@@ -1,8 +1,8 @@
-$ $tcsh: set6,v 1.2 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set6,v 1.3 2011/02/04 18:19:43 christos Exp $
 $ ed.inputl.c
 $set 6
 1 ERROR: comando ilegal asignado a la tecla 0%o\r\n
-2 sí\n
+2 sí\n
 3 editar\n
 4 abortar\n
 5 no\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/spanish/set7
--- a/head/contrib/tcsh/nls/spanish/set7	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/spanish/set7	Fri Mar 02 16:54:40 2012 +0200
@@ -1,30 +1,30 @@
-$ $tcsh: set7,v 1.2 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set7,v 1.3 2011/02/04 18:19:43 christos Exp $
 $ ed.screen.c
 $set 7
 1 \n\tTcsh cree que su terminal tiene las\n
-2 \tsiguientes características:\n\n
-3 \tTiene %d columnas y %d líneas\n
+2 \tsiguientes características:\n\n
+3 \tTiene %d columnas y %d líneas\n
 4 \t%s tecla `Alt'\n
 5 Tiene
 6 No tiene
 7 \t%spuede usar tabuladores\n
 8 No
-9 \t%s márgenes automáticos\n
+9 \t%s márgenes automáticos\n
 10 Tiene
 11 No tiene
-12 \t%s márgenes mágicos\n
-13 (vacío)
-14 sí
+12 \t%s márgenes mágicos\n
+13 (vacío)
+14 sí
 15 no
 16 ERROR: no se puede suprimir\r\n
-17 DeleteChars: num es ridículo: %d\r\n
+17 DeleteChars: num es ridículo: %d\r\n
 18 ERROR: no se puede insertar\r\n
-19 StartInsert: num es ridículo: %d\r\n
+19 StartInsert: num es ridículo: %d\r\n
 20 %s: No se puede abrir /etc/termcap.\n
 21 %s: No hay ninguna entrada correspondiente a la terminal tipo "%s"\n
 22 %s: usando los valores de una terminal tonta.\n
 23 %s: Aviso: Su terminal no puede moverse hacia arriba.\n
-24 La edición de líneas largas puede resultar extraña.\n
-25 no se puede borrar hasta el final de línea.\n
-26 no se puede borrar el siguiente carácter.\n
-27 no se puede insertar un carácter.\n
+24 La edición de líneas largas puede resultar extraña.\n
+25 no se puede borrar hasta el final de línea.\n
+26 no se puede borrar el siguiente carácter.\n
+27 no se puede insertar un carácter.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/spanish/set8
--- a/head/contrib/tcsh/nls/spanish/set8	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/spanish/set8	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,5 @@
-$ $tcsh: set8,v 1.2 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set8,v 1.3 2011/02/04 18:19:43 christos Exp $
 $ ed.term.c
 $set 8
 1 Interruptor desconocido
-2 Argumento inválido
+2 Argumento inválido
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/spanish/set9
--- a/head/contrib/tcsh/nls/spanish/set9	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/spanish/set9	Fri Mar 02 16:54:40 2012 +0200
@@ -1,12 +1,12 @@
-$ $tcsh: set9,v 1.2 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set9,v 1.3 2011/02/04 18:19:43 christos Exp $
 $ ed.xmap.c
 $set 9
 1 AddXkey: No se permite una tecla extendida nula.\n
-2 AddXkey: No se permite comando introducción de secuencia (sequence-lead-in)\n
+2 AddXkey: No se permite comando introducción de secuencia (sequence-lead-in)\n
 3 DeleteXkey: No se permite una tecla extendida nula.\n
 4 Tecla de extendida indefinida "%S"\n
-5 Algunas teclas extendidas son demasiado grandes para el buffer de impresión interno
-6 Enumerate: ¡¡BUG!! Se ha pasado un puntero nulo!\n
+5 Algunas teclas extendidas son demasiado grandes para el buffer de impresión interno
+6 Enumerate: ¡¡BUG!! Se ha pasado un puntero nulo!\n
 7 no hay entrada
-8 Falta algo a continuación: %c\n
-9 Una constante octal no cabe en un carácter.\n
+8 Falta algo a continuación: %c\n
+9 Una constante octal no cabe en un carácter.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ukrainian/charset
--- a/head/contrib/tcsh/nls/ukrainian/charset	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ukrainian/charset	Fri Mar 02 16:54:40 2012 +0200
@@ -1,3 +1,3 @@
-$ codeset=KOI8-U
+$ codeset=UTF-8
 $set 255
-1 KOI8-U
+1 UTF-8
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ukrainian/set1
--- a/head/contrib/tcsh/nls/ukrainian/set1	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ukrainian/set1	Fri Mar 02 16:54:40 2012 +0200
@@ -1,140 +1,140 @@
-$ $tcsh: set1,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set1,v 1.4 2011/02/04 18:19:44 christos Exp $
 $ Error messages
 $set 1 
-1 óÉÎÔÁËÓÉÞÎÁ ÐÏÍÉÌËÁ
-2 %s ÎÅ ÄÏÚ×ÏÌѤÔØÓÑ
-3 úÁÄÏ×ÇÅ ÓÌÏ×Ï
-4 úÁÄÏ×ÇÉÊ ÒÑÄÏË $<
-5 îÅÍÁ¤ ÆÁÊÌÕ ÄÌÑ $0
-6 îÅÐÏ×ÎÉÊ ÍÏÄÉƦËÁÔÏÒ []
-7 òÏÚÛÉÒÅÎÎÑ $ ÍÁ¤ ÂÕÔÉ ÐÅÒÅÄ ]
-8 ðÏÇÁÎÉÊ ÍÏÄÉƦËÁÔÏÒ : × $ (%c)
-9 ðÏÍÉÌËÏ×ÉÊ ¦ÎÄÅËÓ
-10 þÉÓÌÏ ÐÏÇÁÎÏ ÓÆÏÒÍÏ×ÁÎÅ
-11 îÅ ÍÏÖÎÁ ¦ÌØÛÅ Ó̦×
-12 ðÒÏÐÕÝÅÎÏ ¦Í'Ñ ÆÁÊÌÕ
-13 ÷ÎÕÔÒ¦ÛÎÑ ÐÏÍÉÌËÁ glob
-14 îÅצÄÏÍÁ ËÏÍÁÎÄÁ
-15 úÁÍÁÌÏ ÐÁÒÁÍÅÔÒ¦×
-16 úÁÂÁÇÁÔÏ ÐÁÒÁÍÅÔÒ¦×
-17 îÅÂÅÚÐÅÞÎÏ ÓÔ×ÏÒÀ×ÁÔÉ ÔÁËÉÊ ÐÓÅ×ÄÏΦÍ
-18 ðÏÒÏÖÎ¦Ê ÏÐÅÒÁÔÏÒ if
-19 îÅצÒÎÅ then
-20 óÌÏ×Á ÎÅ × ÄÕÖËÁÈ
-21 %s ÎÅ ÚÎÁÊÄÅÎÏ
-22 îÅËÏÒÅËÔÎÁ ÍÁÓËÁ
-23 ôÁËÏÇÏ Ì¦Í¦ÔÕ ÎÅ ¦ÓÎÕ¤
-24 úÁÄÏ×ÇÉÊ ÐÁÒÁÍÅÔÒ
+1 Синтаксична помилка
+2 %s не дозволяється
+3 Задовге слово
+4 Задовгий рядок $<
+5 Немає файлу для $0
+6 Неповний модифікатор []
+7 Розширення $ має бути перед ]
+8 Поганий модифікатор : в $ (%c)
+9 Помилковий індекс
+10 Число погано сформоване
+11 Не можна більше слів
+12 Пропущено ім'я файлу
+13 Внутрішня помилка glob
+14 Невідома команда
+15 Замало параметрів
+16 Забагато параметрів
+17 Небезпечно створювати такий псевдонім
+18 Порожній оператор if
+19 Невірне then
+20 Слова не в дужкаÑ

+21 %s не знайдено
+22 Некоректна маска
+23 Такого ліміту не існує
+24 Задовгий параметр
 25 Improper or unknown scale factor
-26 îÅ×ÉÚÎÁÞÅÎÁ ÚͦÎÎÁ
-27 óÔÅË ËÁÔÁÌÏÇ¦× ÎÅ ÔÁËÉÊ ×ÖÅ ¦ ×ÅÌÉËÉÊ
-28 îÅצÒÎÉÊ ÎÏÍÅÒ ÓÉÇÎÁÌÕ
-29 îÅצÄÏÍÉÊ ÓÉÇÎÁÌ; kill -l ÐÏËÁÚÕ¤ ×Ó¦ ÍÏÖÌÉצ
-30 ¶Í'Ñ ÚͦÎÎϧ ÍÁ¤ ÐÏÞÉÎÁÔÉÓÑ Ú Ì¦ÔÅÒÉ
-31 úÁÄÏ×ÇÅ ¦Í'Ñ ÚͦÎÎϧ 
-32 ¶Í'Ñ ÚͦÎÎϧ ÍÁ¤ ÐÏÞÉÎÁÔÉÓÑ Ú ÁÌÆÁצÔÎÏ-ÃÉÆÒÏ×ÏÇÏ ÓÉÍ×ÏÌÕ
-33 ãÑ ÏÂÏÌÏÎËÁ ΊͦÓÔÉÔØ ÚÁÓÏÂ¦× ËÅÒÕ×ÁÎÎÑ ÚÁÄÁÞÁÍÉ
-34 óÉÎÔÁËÓ ×ÉÒÁÚÕ
-35 îÅÍÁ¤ ÄÏÍÁÛÎØÏÇÏ ËÁÔÁÌÏÇÕ
-36 îÅ ÍÏÖÕ ÐÅÒÅÊÔÉ ÄÏ ÄÏÍÁÛÎØÏÇÏ ËÁÔÁÌÏÇÕ
-37 îÅËÏÒÅËÔÎÁ ÐÏÒÏÖÎÑ ËÏÍÁÎÄÁ
+26 Невизначена змінна
+27 Стек каталогів не такий вже і великий
+28 Невірний номер сигналу
+29 Невідомий сигнал; kill -l показує всі можливі
+30 Ім'я змінної має починатися з літери
+31 Задовге ім'я змінної 
+32 Ім'я змінної має починатися з алфавітно-цифрового символу
+33 Ця оболонка не містить засобів керування задачами
+34 Синтакс виразу
+35 Немає домашнього каталогу
+36 Не можу перейти до домашнього каталогу
+37 Некоректна порожня команда
 38 Assignment missing expression
-39 îÅצÄÏÍÉÊ ÏÐÅÒÁÔÏÒ
-40 îÅÏÄÎÏÚÎÁÞÎÏ
-41 %s: æÁÊÌ ¦ÓÎÕ¤
-42 áÒÇÕÍÅÎÔ -c ÚÁ˦ÎÞÕ¤ÔØÓÑ backslash'ÅÍ
-43 ðÅÒÅÒ×ÁÎÏ
+39 Невідомий оператор
+40 Неоднозначно
+41 %s: Файл існує
+42 Аргумент -c закінчується backslash'ем
+43 Перервано
 44 Subscript out of range
-45 ðÅÒÅÐÏ×ÎÅÎÎÑ ÒÑÄËÕ
-46 îÅÍÁ¤ ÔÁËϧ ÚÁÄÁÞ¦
-47 îÅÍÏÖÌÉ×Ï Ú ÔÅÒͦÎÁÌÕ
-48 îÅ Õ while/foreach
-49 îÅ ÍÏÖÎÁ ¦ÌØÛÅ ÐÒÏÃÅÓ¦×
-50 îÅÍÁ¤ ÓЦ×ÐÁÄÁÎØ
-51 ðÒÏÐÕÝÅÎÏ %c
-52 ÷¦ÄÓÕÔÎ¦Ê ×¦ÄÐÏצÄÎÉË ÄÏ %c
-53 íÁÌÏ ÐÁÍ'ÑÔ¦
-54 îÅ ÍÏÖÕ ÓÔ×ÏÒÉÔÉ ËÁÎÁÌ
+45 Переповнення рядку
+46 Немає такої задачі
+47 Неможливо з терміналу
+48 Не у while/foreach
+49 Не можна більше процесів
+50 Немає співпадань
+51 Пропущено %c
+52 Відсутній відповідник до %c
+53 Мало пам'яті
+54 Не можу створити канал
 55 %s: %s
 56 %s
-57 ÷ÉËÏÒÉÓÔÁÎÎÑ: jobs [ -l ]
-58 áÒÇÕÍÅÎÔÏÍ ÍÁ¤ ÂÕÔÉ ÎÏÍÅÒ ÚÁÄÁÞ¦ ÞÉ ÐÒÏÃÅÓÕ
-59 îÅÍÁ¤ ÐÏÔÏÞÎϧ ÚÁÄÁÞ¦
-60 îÅÍÁ¤ ÐÏÐÅÒÅÄÎØϧ ÚÁÄÁÞ¦
-61 öÏÄÎÁ ÚÁÄÁÞÁ ΊצÄÐÏצÄÁ¤ ÛÁÂÌÏÎÕ
+57 Використання: jobs [ -l ]
+58 Аргументом має бути номер задачі чи процесу
+59 Немає поточної задачі
+60 Немає попередньої задачі
+61 Жодна задача не відповідає шаблону
 62 Fork nesting > %d; maybe `...` loop
-63 ð¦ÄÏÂÏÌÏÎËÁ ΊͦÓÔÉÔÉÔØ ÚÁÓÏÂ¦× ËÅÒÕ×ÁÎÎÑ ÚÁÄÁÞÁÍÉ
+63 Підоболонка не міститить засобів керування задачами
 64 Sync fault: Process %d not found
-65 %sýÅ ¤ 'ЦÄצÛÅΦ' ÚÁÄÁÞ¦
-66 %sýÅ ¤ 'ÐÒÉÚÕÐÉÎÅΦ' ÚÁÄÁÞ¦
-67 îÅÍÁ¤ ¦ÎÛÉÈ ËÁÔÁÌÏǦ×
-68 óÔÅË ËÁÔÁÌÏÇ¦× ÐÕÓÔÉÊ
-69 ðÏÇÁÎÉÊ ËÁÔÁÌÏÇ
-70 ÷ÉËÏÒÉÓÔÁÎÎÑ: %s [-%s]%s
-71 ÷¦ÄÓÕÔÎ¦Ê ÏÐÅÒÁÎÄ ÐÒÁÐÏÒÃÑ -h
-72 ãÅ ÎÅ ÐÅÒ×ÉÎÎÁ ÏÂÏÌÏÎËÁ
-73 ä¦ÌÅÎÎÑ ÎÁ 0
-74 ä¦ÌÅÎÎÑ ÎÁ 0
+65 %sЩе є 'підвішені' задачі
+66 %sЩе є 'призупинені' задачі
+67 Немає іншиÑ
 каталогів
+68 Стек каталогів пустий
+69 Поганий каталог
+70 Використання: %s [-%s]%s
+71 Відсутній операнд прапорця -h
+72 Це не первинна оболонка
+73 Ділення на 0
+74 Ділення на 0
 75 Bad scaling; did you mean "%s"?
-76 îÅ ÍÏÖÕ Ð¦ÄצÓÉÔÉ ÐÅÒ×ÉÎÎÕ ÏÂÏÌÏÎËÕ (ÐÏËÉ ÝÏ)
-77 îÅצÄÏÍÉÊ ËÏÒÉÓÔÕ×ÁÞ: %s
-78 úͦÎÎÁ $home ÎÅ ×ÉÚÎÁÞÅÎÁ
-79 ÷ÉËÏÒÉÓÔÁÎÎÑ: history [-%s] [# ˦ÌØ˦ÓÔØ ÐÏĦÊ]
-80 îÅ ÍÏÖÎÁ ×ÉËÏÒÉÓÔÏ×Õ×ÁÔÉ $, ! ÔÁ < ÒÁÚÏÍ Ú $# ÞÉ $?
-81 óÉÍ×ÏÌ ÎÏ×ÏÇÏ ÒÑÄËÕ × ¦ÍÅΦ ÚͦÎÎϧ
-82 îÅ ÍÏÖÎÁ ×ÉËÏÒÉÓÔÏ×Õ×ÁÔÉ * ÒÁÚÏÍ Ú $# ÞÉ $?
-83 îÅ ÍÏÖÎÁ ×ÉËÏÒÉÓÔÏ×Õ×ÁÔÉ $?<ÃÉÆÒÁ> ÞÉ $#<ÃÉÆÒÁ>
-84 îÅÐÒÁ×ÉÌØÎÅ ¦Í'Ñ ÚͦÎÎϧ
-85 óÉÍ×ÏÌ ÎÏ×ÏÇÏ ÒÑÄËÁ × ¦ÎÄÅËÓ¦ ÚͦÎÎϧ
-86 ðÅÒÅÐÏ×ÎÅÎÎÑ ÂÕÆÅÒÕ ÒÏÚÛÉÒÅÎÎÑ
-87 óÉÎÔÁËÓ ÚͦÎÎϧ
-88 îÅÐÒÁ×ÉÌØÎÁ ÆÏÒÍÁ '!'
-89 ýÅ ÎÅ ÂÕÌÏ Ð¦ÄÓÔÁÎÏ×ÏË
-90 ðÏÇÁÎÁ ЦÄÓÔÁÎÏ×ËÁ
+76 Не можу підвісити первинну оболонку (поки що)
+77 Невідомий користувач: %s
+78 Змінна $home не визначена
+79 Використання: history [-%s] [# кількість подій]
+80 Не можна використовувати $, ! та < разом з $# чи $?
+81 Символ нового рядку в імені змінної
+82 Не можна використовувати * разом з $# чи $?
+83 Не можна використовувати $?<цифра> чи $#<цифра>
+84 Неправильне ім'я змінної
+85 Символ нового рядка в індексі змінної
+86 Переповнення буферу розширення
+87 Синтакс змінної
+88 Неправильна форма '!'
+89 Ще не було підстановок
+90 Погана підстановка
 91 No previous left hand side
 92 Right hand side too long
-93 ðÏÇÁÎÉÊ ÍÏÄÉƦËÁÔÏÒ !: %c
-94 îÅ×ÄÁÞÁ ÍÏÄÉƦËÁÔÏÒÁ
-95 ðÅÒÅÐÏ×ÎÅÎÎÑ ÂÕÆÅÒÕ Ð¦ÄÓÔÁÎÏ×ËÉ
+93 Поганий модифікатор !: %c
+94 Невдача модифікатора
+95 Переповнення буферу підстановки
 96 Bad ! arg selector
-97 ðÏÛÕËÕ ÝÅ ÎÅ ÂÕÌÏ
-98 %s: ðÏĦÀ ÎÅ ÚÎÁÊÄÅÎÏ
-99 âÁÇÁÔÏ ÄÕÖÏË )
-100 âÁÇÁÔÏ ÄÕÖÏË (
-101 ðÏÇÁÎÏ ÒÏÚͦÝÅÎÏ ÄÕÖËÕ ()
-102 ÷¦ÄÓÕÔΤ ¦Í'Ñ ÄÌÑ ÐÅÒÅÎÁÐÒÁ×ÌÅÎÎÑ
-103 îÅÏÄÎÏÚÎÁÞÎÅ ÐÅÒÅÎÁÐÒÁ×ÌÅÎÎÑ ×É×ÅÄÅÎÎÑ
-104 îÅ ÍÏÖÎÁ ×ÉËÏÒÉÓÔÏ×Õ×ÁÔÉ << × ÓÅÒÅÄÉΦ ()
-105 îÅÏÄÎÏÚÎÁÞÎÅ ÐÅÒÅÎÁÐÒÁ×ÌÅÎÎÑ ××ÅÄÅÎÎÑ
-106 ðÏÇÁÎÏ ÒÏÚͦÝÅÎÏ ÄÕÖËÉ ()
-107 úÁÃÉËÌÅÎÎÑ ÐÓÅ×ÄÏΦͦ×
-108 úͦÎÎÕ $watch ÎÅ ×ÓÔÁÎÏ×ÌÅÎÏ
-109 îÅÍÁ¤ ÚÁÐÌÁÎÏ×ÁÎÉÈ ÚÁ×ÄÁÎØ
-110 ÷ÉËÏÒÉÓÔÁÎÎÑ: sched -<# ÅÌÅÍÅÎÔÁ>.\n÷ÉËÏÒÉÓÔÁÎÎÑ: sched [+]ÇÏÄ:È× <ËÏÍÁÎÄÁ>
-111 úÁÂÁÇÁÔÏ ÐÌÁÎÕ¤ÔÅ ÚÁÐÕÓËÁÔÉ!
-112 á ÝÏ ÚÁÐÕÓËÁÔÉ?
-113 îÅÐÒÁ×ÉÌØÎÉÊ ÞÁÓ ÄÌÑ ÚÁÐÌÁÎÏ×ÁÎÏÇÏ ÚÁ×ÄÁÎÎÑ
-114 ÷¦ÄÎÏÓÎÉÊ ÞÁÓ ÎÅÓÕͦÓÎÉÊ Ú am/pm
+97 Пошуку ще не було
+98 %s: Подію не знайдено
+99 Багато дужок )
+100 Багато дужок (
+101 Погано розміщено дужку ()
+102 Відсутнє ім'я для перенаправлення
+103 Неоднозначне перенаправлення виведення
+104 Не можна використовувати << в середині ()
+105 Неоднозначне перенаправлення введення
+106 Погано розміщено дужки ()
+107 Зациклення псевдонімів
+108 Змінну $watch не встановлено
+109 Немає запланованиÑ
 завдань
+110 Використання: sched -<# елемента>.\nВикористання: sched [+]год:Ñ
в <команда>
+111 Забагато плануєте запускати!
+112 А що запускати?
+113 Неправильний час для запланованого завдання
+114 Відносний час несумісний з am/pm
 115 Out of termcap string space
-116 ÷ÉËÏÒÉÓÔÁÎÎÑ: settc %s [yes|no]
+116 Використання: settc %s [yes|no]
 117 Unknown capability `%s'
-118 îÅצÄÏÍÉÊ ÐÁÒÁÍÅÔÒ termcap `%%%c'
-119 úÁÂÁÇÁÔÏ ÁÒÇÕÍÅÎÔ¦× ÄÌÑ `%s' (%d)
-120 `%s' ×ÉÍÁÇÁ¤ %d ÁÒÇÕÍÅÎÔ(¦×)
-121 ÷ÉËÏÒÉÓÔÁÎÎÑ: echotc [-v|-s] [<capability> [<args>]]
-122 %s: %s. îÅÐÒÁ×ÉÌØÎÁ ÁÒȦÔÅËÔÕÒÁ
-123 !# úÁÃÉËÌÅÎÎÑ ¦ÓÔÏÒ¦§
+118 Невідомий параметр termcap `%%%c'
+119 Забагато аргументів для `%s' (%d)
+120 `%s' вимагає %d аргумент(ів)
+121 Використання: echotc [-v|-s] [<capability> [<args>]]
+122 %s: %s. Неправильна арÑ
ітектура
+123 !# Зациклення історії
 124 Malformed file inquiry
-125 ðÅÒÅÐÏ×ÎÅÎÎÑ ÓÅÌÅËÔÏÒÁ
-126 îÅצÄÏÍÉÊ ÐÁÒÁÍÅÔÒ: `-%s'\n÷ÉËÏÒÉÓÔÁÎÎÑ: %s [ -bcdefilmnqstvVxX -D¦Í'Ñ[=ÚÎÁÞÅÎÎÑ] ] [ ÁÒÇÕÍÅÎÔ ... ]
-127 îÅצÄÏÍÉÊ ÐÁÒÁÍÅÔÒ: `-%s'\n÷ÉËÏÒÉÓÔÁÎÎÑ: %s [ -bcdefFilmnqstvVxX ] [ ÁÒÇÕÍÅÎÔ ... ]
-128 îÅצÄÏÍÉÊ ÐÁÒÁÍÅÔÒ: `-%s'\n÷ÉËÏÒÉÓÔÁÎÎÑ: %s [ -bcdefilmnqstvVxX ] [ ÁÒÇÕÍÅÎÔ ... ]
-129 \nîÅצÒÎÅ ÚÁ×ÅÒÛÅÎÑ: "%s"
-130 \nîÅצÒÎÅ %s: '%c'
-131 \nðÒÏÐÕÝÅÎÏ ÒÏÚĦÌØÎÉË '%c' ЦÓÌÑ %s "%s"
-132 \nîÅÐÏ×ÎÅ %s: "%s"
-133 ÷¦ÄÓÕÔÎ¦Ê ÏÐÅÒÁÎÄ ÐÒÁÐÏÒÃÑ -m
-134 ÷ÉËÏÒÉÓÔÁÎÎÑ: unlimit [-fh] [̦ͦÔÉ]
-135 $%S ÌÉÛÅ ÄÌÑ ÞÉÔÁÎÎÑ
-136 îÅÍÁ¤ ÔÁËϧ ÚÁÄÁÞ¦
-137 îÅצÄÏÍÅ ÚÎÁÞÅÎÎÑ ÚͦÎÎϧ colorls: `%c%c'
+125 Переповнення селектора
+126 Невідомий параметр: `-%s'\nВикористання: %s [ -bcdefilmnqstvVxX -Dім'я[=значення] ] [ аргумент ... ]
+127 Невідомий параметр: `-%s'\nВикористання: %s [ -bcdefFilmnqstvVxX ] [ аргумент ... ]
+128 Невідомий параметр: `-%s'\nВикористання: %s [ -bcdefilmnqstvVxX ] [ аргумент ... ]
+129 \nНевірне завершеня: "%s"
+130 \nНевірне %s: '%c'
+131 \nПропущено роздільник '%c' після %s "%s"
+132 \nНеповне %s: "%s"
+133 Відсутній операнд прапорця -m
+134 Використання: unlimit [-fh] [ліміти]
+135 $%S лише для читання
+136 Немає такої задачі
+137 Невідоме значення змінної colorls: `%c%c'
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ukrainian/set10
--- a/head/contrib/tcsh/nls/ukrainian/set10	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ukrainian/set10	Fri Mar 02 16:54:40 2012 +0200
@@ -1,8 +1,8 @@
-$ $tcsh: set10,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set10,v 1.4 2011/02/04 18:19:44 christos Exp $
 $ ma.setp.c
 $set 10 
-1 setpath: ÎÅצÒÎÁ ËÏÍÁÎÄÁ '%s'.\n
-2 setpath: ÎÅÄÏÓÔÁÔÎØÏ ÁÒÇÕÍÅÎÔ¦× ÄÌÑ ËÏÍÁÎÄÉ '%s'.\n
-3 setpath: ÚÎÁÞÅÎÎÑ ×¦ÄÓÕÔΤ × ÛÌÑÈÕ '%s'\n
-4 setpath: %s ÎÅ ÚÎÁÊÄÅÎÏ × %s\n
-5 setpath: %d ÎÅĦÊÓÎÁ ÐÏÚÉÃ¦Ñ × %s\n
+1 setpath: невірна команда '%s'.\n
+2 setpath: недостатньо аргументів для команди '%s'.\n
+3 setpath: значення відсутнє в шляÑ
у '%s'\n
+4 setpath: %s не знайдено в %s\n
+5 setpath: %d недійсна позиція в %s\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ukrainian/set11
--- a/head/contrib/tcsh/nls/ukrainian/set11	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ukrainian/set11	Fri Mar 02 16:54:40 2012 +0200
@@ -1,10 +1,10 @@
-$ $tcsh: set11,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set11,v 1.4 2011/02/04 18:19:44 christos Exp $
 $ sh.c
 $set 11 
-1 õ×ÁÇÁ: ÎÅÍÁ¤ ÄÏÓÔÕÐÕ ÄÏ tty (%s).\n
-2 ÷ÓÅ ÝÅ ÎÅÍÁ ËÅÒÕ×ÁÎÎÑ ÚÁÄÁÞÁÍÉ × Ã¦Ê ÏÂÏÌÏÎæ.\n
-3 ë¦ÌØ˦ÓÔØ ÌÉÓÔ¦×: %d.\n
-4 ë¦ÌØ˦ÓÔØ ÌÉÓÔ¦×: %d (× %s).\n
-5 õ ÷ÁÓ ¤ %sÐÏÛÔÁ.\n
-6 ÎÏ×Á 
-7 õ ÷ÁÓ ¤ %sÐÏÛÔÁ × %s.\n
+1 Увага: немає доступу до tty (%s).\n
+2 Все ще нема керування задачами в цій оболонці.\n
+3 Кількість листів: %d.\n
+4 Кількість листів: %d (в %s).\n
+5 У Вас є %sпошта.\n
+6 нова 
+7 У Вас є %sпошта в %s.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ukrainian/set12
--- a/head/contrib/tcsh/nls/ukrainian/set12	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ukrainian/set12	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set12,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set12,v 1.4 2011/02/04 18:19:44 christos Exp $
 $ sh.dir.c
 $set 12 
-1 %s: óÐÒÏÂÕÀ ÐÏÞÁÔÉ Ú "%s"\n
+1 %s: Спробую почати з "%s"\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ukrainian/set13
--- a/head/contrib/tcsh/nls/ukrainian/set13	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ukrainian/set13	Fri Mar 02 16:54:40 2012 +0200
@@ -1,13 +1,13 @@
-$ $tcsh: set13,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set13,v 1.4 2011/02/04 18:19:44 christos Exp $
 $ sh.exec.c
 $set 13 
-1 ÈÅÛ=%-4d dir=%-2d prog=%s\n
+1 Ñ
еш=%-4d dir=%-2d prog=%s\n
 2 %d hash buckets of %d bits each\n
 3 debug mask = 0x%08x\n
-4 %d ÐÏÐÁÄÁÎØ, %d ÐÒÏÍÁȦ×, %d%%\n
-5 %S: ×ÂÕÄÏ×ÁÎÁ ËÏÍÁÎÄÁ.\n
-6 %S: ëÏÍÁÎÄÕ ÎÅ ÚÎÁÊÄÅÎÏ.\n
-7 where: ÓÉÍ×ÏÌ / × ËÏÍÁÎÄÁÈ ÎÅ ÍÁ¤ ÚͦÓÔÕ\n
-8 %S ÐÅÒÅÎÁÚÎÁÞÅÎÏ Õ 
-9 %S ×ÎÕÔÒ¦ÛÎÑ ËÏÍÁÎÄÁ ÏÂÏÌÏÎËÉ\n
-10 ÐÒÏÍÁÈÉ ÈÅÛÕ: 
+4 %d попадань, %d промаÑ
ів, %d%%\n
+5 %S: вбудована команда.\n
+6 %S: Команду не знайдено.\n
+7 where: символ / в командаÑ
 не має змісту\n
+8 %S переназначено у 
+9 %S внутрішня команда оболонки\n
+10 промаÑ
и Ñ
ешу: 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ukrainian/set14
--- a/head/contrib/tcsh/nls/ukrainian/set14	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ukrainian/set14	Fri Mar 02 16:54:40 2012 +0200
@@ -1,6 +1,6 @@
-$ $tcsh: set14,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set14,v 1.4 2011/02/04 18:19:44 christos Exp $
 $ sh.file.c
 $set 14 
-1 \nïÊ!! úÁÂÁÇÁÔÏ %s!!\n
-2 ¦ÍÅÎ Õ ÆÁÊ̦ ÐÁÒÏ̦×
-3 ÆÁÊ̦×
+1 \nОй!! Забагато %s!!\n
+2 імен у файлі паролів
+3 файлів
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ukrainian/set15
--- a/head/contrib/tcsh/nls/ukrainian/set15	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ukrainian/set15	Fri Mar 02 16:54:40 2012 +0200
@@ -1,7 +1,7 @@
-$ $tcsh: set15,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set15,v 1.4 2011/02/04 18:19:44 christos Exp $
 $ sh.func.c
 $set 15 
-1 %s: %s: îÅ ÍÏÖÕ %s%s ̦ͦÔ\n
-2 ÚÎÑÔÉ
-3 ×ÉÓÔÁ×ÉÔÉ
-4 \040ÖÏÒÓÔËÉÊ
+1 %s: %s: Не можу %s%s ліміт\n
+2 зняти
+3 виставити
+4 \040жорсткий
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ukrainian/set16
--- a/head/contrib/tcsh/nls/ukrainian/set16	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ukrainian/set16	Fri Mar 02 16:54:40 2012 +0200
@@ -1,9 +1,9 @@
-$ $tcsh: set16,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set16,v 1.4 2011/02/04 18:19:44 christos Exp $
 $ sh.lex.c
 $set 16 
 1 Reset tty pgrp from %d to %d\n
-2 \n÷ÉËÏÒÉÓÔÁÊÔÅ "logout" ÝÏ ×ÉÊÔÉ.\n
-3 \n÷ÉËÏÒÉÓÔÁÊÔÅ "exit" ÝÏ ×ÉÊÔÉ Ú %s.\n
+2 \nВикористайте "logout" щоб вийти.\n
+3 \nВикористайте "exit" щоб вийти з %s.\n
 4 seek to eval %x %x\n
 5 seek to alias %x %x\n
 6 seek to file %x\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ukrainian/set17
--- a/head/contrib/tcsh/nls/ukrainian/set17	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ukrainian/set17	Fri Mar 02 16:54:40 2012 +0200
@@ -1,17 +1,17 @@
-$ $tcsh: set17,v 1.4 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set17,v 1.5 2011/02/04 18:19:44 christos Exp $
 $ sh.proc.c
 $set 17 
-1 ðïíéìëá: ÏÞ¦ËÕ×ÁÎÎÑ ÆÏÎÏ×ϧ ÚÁÄÁÞ¦!\n
-2 úÁ×ÅÒÛÅÎÎÑ %d\n
-3 ðïíéìëá: process flushed twice
-4 úÁÐÕÝÅÎÏ 
-5 óÉÇÎÁÌ 
-6 úÁ×ÅÒÛÅÎÎÑ %-25d
-7 úÁ×ÅÒÛÅÎÏ
-8 ðïíéìëá: ÓÔÁÔÕÓ=%-9o
-9 \040(ÚÁÐÉÓÁÎÏ core)
+1 ПОМИЛКА: очікування фонової задачі!\n
+2 Завершення %d\n
+3 ПОМИЛКА: process flushed twice
+4 Запущено 
+5 Сигнал 
+6 Завершення %-25d
+7 Завершено
+8 ПОМИЛКА: статус=%-9o
+9 \040(записано core)
 10 \040(wd:
-11 wd ÔÅÐÅÒ: 
-12 %S: ×ÖŠЦÄצÛÅÎÏ\n
-13 %S: ×ÖÅ ÐÒÉÚÕÐÉÎÅÎÏ\n
+11 wd тепер: 
+12 %S: вже підвішено\n
+13 %S: вже призупинено\n
 14 %S: Badly formed number\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ukrainian/set18
--- a/head/contrib/tcsh/nls/ukrainian/set18	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ukrainian/set18	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set18,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set18,v 1.4 2011/02/04 18:19:44 christos Exp $
 $ sh.set.c
 $set 18 
-1 õ×ÁÇÁ: ÚÁÄÏ×ÇÉÊ PATH ÏÂÒ¦ÚÁÎÏ\n
+1 Увага: задовгий PATH обрізано\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ukrainian/set19
--- a/head/contrib/tcsh/nls/ukrainian/set19	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ukrainian/set19	Fri Mar 02 16:54:40 2012 +0200
@@ -1,15 +1,23 @@
-$ $tcsh: set19,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set19,v 1.6 2011/02/25 23:58:08 christos Exp $
 $ tc.alloc.c
 $set 19 
-1 nbytes=%d: íÁÌÏ ÐÁÍ'ÑÔ¦\n
+1 nbytes=%d: Мало пам'яті\n
 2 free(%lx) called before any allocations.
 3 free(%lx) above top of memory.
 4 free(%lx) below bottom of memory.
 5 free(%lx) bad block.
 6 free(%lx) bad range check.
 7 free(%lx) bad block index.
-8 îÉΦÛΤ ÒÏÚÐÏĦÌÅÎÎÑ ÐÁÍ'ÑÔ¦ %s:\nצÌØÎÏ:\t
-9 \nÚÁÎÑÔÏ:\t
-10 \n\t÷ÓØÏÇÏ ÚÁÎÑÔÏ: %d, ×ÓØÏÇÏ ×¦ÌØÎÏ: %d\n
-11 \túÁÎÑÔÏ ÐÁÍ'ÑÔØ Ú 0x%lx ÄÏ 0x%lx.  Real top at 0x%lx\n
-12 úÁÎÑÔÏ ÐÁÍ'ÑÔØ Ú 0x%lx ÄÏ 0x%lx (%ld).\n
+8 Нинішнє розподілення пам'яті %s:\nвільно:\t
+9 занято
+10 \n\tВсього занято: %d, всього вільно: %d\n
+11 \tЗанято пам'ять з 0x%lx до 0x%lx.  Real top at 0x%lx\n
+12 Занято пам'ять з 0x%lx до 0x%lx (%ld).\n
+13 %s current memory allocation:\n
+14 Total space allocated from system: %d\n
+15 Number of non-inuse chunks: %d\n
+16 Number of mmapped regions: %d\n
+17 Total space in mmapped regions: %d\n
+18 Total allocated space: %d\n
+19 Total non-inuse space: %d\n
+20 Top-most, releasable space: %d\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ukrainian/set2
--- a/head/contrib/tcsh/nls/ukrainian/set2	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ukrainian/set2	Fri Mar 02 16:54:40 2012 +0200
@@ -1,36 +1,36 @@
-$ $tcsh: set2,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set2,v 1.4 2011/02/04 18:19:44 christos Exp $
 $ Signal names
 $set 2 
-1 îÕÌØÏ×ÉÊ ÓÉÇÎÁÌ
+1 Нульовий сигнал
 2 Hangup
-3 ðÅÒÅÒÉ×ÁÎÎÑ
-4 ÷ÉȦÄ
-5 îÅËÏÒÅËÔÎÁ ¦ÎÓÔÒÕËæÑn
+3 Переривання
+4 ВиÑ
ід
+5 Некоректна інструкціяn
 6 Trace/BPT trap
-7 á×ÁÒ¦ÊÎÅ ÚÁ×ÅÒÛÅÎÎÑ
+7 Аварійне завершення
 8 IOT trap
 9 System Crash Imminent
-10 ðÏÍÉÌËÁ ÚÁ×ÅÒÛÅÎÎÑ
+10 Помилка завершення
 11 EMT trap
-12 ðÏÍÉÌËÁ ÏÐÅÒÁæ§ Ú ÐÌÁ×ÁÀÞÏÀ ËÏÍÏÀ
-13 ÷ÂÉÔÏ
-14 óÉÇÎÁÌ ËÏÒÉÓÔÕ×ÁÞÁ 1
-15 óÉÇÎÁÌ ËÏÒÉÓÔÕ×ÁÞÁ 2
-16 ðÏÍÉÌËÁ ÁÄÒÅÓÁæ§
+12 Помилка операції з плаваючою комою
+13 Вбито
+14 Сигнал користувача 1
+15 Сигнал користувача 2
+16 Помилка адресації
 17 Bus error
 18 Program range error
 19 Operand range error
-20 ðÏÇÁÎÉÊ ÓÉÓÔÅÍÎÉÊ ×ÉËÌÉË
-21 ïÂÒÉ× ËÁÎÁÌÕ
+20 Поганий системний виклик
+21 Обрив каналу
 22 Alarm clock
 23 Terminated
-24 úͦÎÁ ÓÔÁÔÕÓÕ ÎÁÝÁÄËÁ
-25 óÍÅÒÔØ ÎÁÝÁÄËÁ
+24 Зміна статусу нащадка
+25 Смерть нащадка
 26 Apollo-specific fault
 27 Child stopped or exited
 28 Child exited
-29 úÂ¦Ê ÖÉ×ÌÅÎÎÑ
-30 ÷ÔÒÁÔÁ ÒÅÓÕÒÓÕ
+29 Збій живлення
+30 Втрата ресурсу
 31 Break (Ctrl-Break)
 32 Input/output possible signal
 33 Asynchronous I/O (select)
@@ -40,21 +40,21 @@
 37 Fortran asynchronous I/O completion
 38 Recovery
 39 Uncorrectable memory error
-40 äÏÓÑÇÎÕÔÏ Ì¦Í¦ÔÕ CPU time
+40 Досягнуто ліміту CPU time
 41 System shutdown imminent
 42 micro-tasking group-no wakeup flag set
 43 Thread error - (use cord -T for detailed info)
 44 CRAY Y-MP register parity error
 45 Information request
-46 ð¦ÄצÛÅÎÏ (ÓÉÇÎÁÌ)
-47 ðÒÉÚÕÐÉÎÅÎÏ (ÓÉÇÎÁÌ)
-48 ð¦ÄצÛÅÎÏ
-49 ðÒÉÚÕÐÉÎÅÎÏ
-50 ðÒÏÄÏ×ÖÅÎÏ
-51 ð¦ÄצÛÅÎÏ (tty input)
-52 ðÒÉÚÕÐÉÎÅÎÏ (tty input)
-53 ð¦ÄצÛÅÎÏ (tty output)
-54 ðÒÉÚÕÐÉÎÅÎÏ (tty output)
+46 Підвішено (сигнал)
+47 Призупинено (сигнал)
+48 Підвішено
+49 Призупинено
+50 Продовжено
+51 Підвішено (tty input)
+52 Призупинено (tty input)
+53 Підвішено (tty output)
+54 Призупинено (tty output)
 55 Window status changed
 56 Window size changed
 57 Phone status changed
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ukrainian/set20
--- a/head/contrib/tcsh/nls/ukrainian/set20	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ukrainian/set20	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set20,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set20,v 1.4 2011/02/04 18:19:44 christos Exp $
 $ tc.bind.c
 $set 20 
 1 Invalid key name `%S'\n
@@ -10,9 +10,9 @@
 7 Alternative key bindings\n
 8 Multi-character bindings\n
 9 Arrow key bindings\n
-10 %-15s->  ÎÅ ×ÉÚÎÁÞÅÎÏ\n
+10 %-15s->  не визначено\n
 11 BUG!!! %s isn't bound to anything.\n
-12 ÷ÉËÏÒÉÓÔÁÎÎÑ: bindkey [ÐÁÒÁÍÅÔÒÉ] [--] [ëìàþ [ëïíáîäá]]\n
+12 Використання: bindkey [параметри] [--] [КЛЮЧ [КОМАНДА]]\n
 13     -a   list or bind KEY in alternative key map\n
 14     -b   interpret KEY as a C-, M-, F- or X- key name\n
 15     -s   interpret COMMAND as a literal string to be output\n
@@ -36,6 +36,6 @@
 33 Bad function-key specification.\n
 34 Null key not allowed\n
 35 bad key specification -- unknown name "%S"\n
-36 ÷ÉËÏÒÉÓÔÁÎÎÑ: bind [KEY | COMMAND KEY | "emacs" | "vi" | "-a"]\n
-37 îÅצÒÎÁ ÆÕÎËæÑ
-38  %s\t\tÎÅ ×ÉÚÎÁÞÅÎÏ\n
+36 Використання: bind [KEY | COMMAND KEY | "emacs" | "vi" | "-a"]\n
+37 Невірна функція
+38  %s\t\tне визначено\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ukrainian/set22
--- a/head/contrib/tcsh/nls/ukrainian/set22	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ukrainian/set22	Fri Mar 02 16:54:40 2012 +0200
@@ -1,17 +1,17 @@
-$ $tcsh: set22,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set22,v 1.4 2011/02/04 18:19:44 christos Exp $
 $ tc.func.c
 $set 22 
-1 %S: \t ÐÅÒÅ×ÉÚÎÁÞÅÎÏ ÎÁ
-2 \nîÅצÒÎÉÊ ÐÁÒÏÌØ ËÏÒÉÓÔÕ×ÁÞÁ %s\n
+1 %S: \t перевизначено на
+2 \nНевірний пароль користувача %s\n
 3 Faulty alias 'precmd' removed.\n
 4 Faulty alias 'cwdcmd' removed.\n
 5 Faulty alias 'beepcmd' removed.\n
 6 Faulty alias 'periodic' removed.\n
-7 ÓÉÎÔÁËÓÉÞÎÉÊ ÒÏÚÂ¦Ò ËÏÍÁÎÄÎÏÇÏ ÒÑÄËÁ\n
-8 ÷É ÓÐÒÁ×Ħ ÈÏÞÅÔÅ ×ÉÄÁÌÉÔÉ ×Ó¦ ÆÁÊÌÉ? [n/y] 
-9 ÐÒÏÐÕÓËÁ¤ÍÏ ×ÉÄÁÌÅÎÎÑ ×Ó¦È ÆÁÊ̦×!\n
-10 ËÏÍÁÎÄÎÉÊ ÒÑÄÏË ÔÅÐÅÒ:\n
-11 ÓÉÎÔÁËÓÉÞÎÉÊ ÒÏÚÂ¦Ò ËÏÍÁÎÄÎÏÇÏ ÒÑÄËÁ\n
-12 × ÏÄÎÏÍÕ ¦Ú ÓÐÉÓ˦×\n
-13 ËÏÍÁÎÄÎÉÊ ÒÑÄÏË ÔÅÐÅÒ:\n
+7 синтаксичний розбір командного рядка\n
+8 Ви справді Ñ
очете видалити всі файли? [n/y] 
+9 пропускаємо видалення всіÑ
 файлів!\n
+10 командний рядок тепер:\n
+11 синтаксичний розбір командного рядка\n
+12 в одному із списків\n
+13 командний рядок тепер:\n
 14 yY
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ukrainian/set23
--- a/head/contrib/tcsh/nls/ukrainian/set23	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ukrainian/set23	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set23,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set23,v 1.4 2011/02/04 18:19:44 christos Exp $
 $ tc.os.c
 $set 23 
 1 Bad cpu/site name
@@ -17,7 +17,7 @@
 14 sysname:  %s\n
 15 nodename: %s\n
 16 release:  %s\n
-17 ×ÅÒÓ¦Ñ:   %s\n
+17 версія:   %s\n
 18 machine:  %s\n
 19 getwd: Cannot open ".." (%s)
 20 getwd: Cannot chdir to ".." (%s)
@@ -28,7 +28,7 @@
 25 getwd: Cannot stat directory "%s" (%s)
 26 getwd: Cannot open directory "%s" (%s)
 27 getwd: Cannot find "." in ".." (%s)
-28 îÅצÒÎÉÊ ÔÉÐ ÓÉÓÔÅÍÉ
-29 ôÉÐ ÓÉÓÔÅÍÉ ÎÅ ×ÉÚÎÁÞÅÎÏ
-30 úÁÂÁÇÁÔÏ ÁÒÇÕÍÅÎÔ¦×
-31 îÅצÒÎÉÊ ÁÒÇÕÍÅÎÔ
+28 Невірний тип системи
+29 Тип системи не визначено
+30 Забагато аргументів
+31 Невірний аргумент
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ukrainian/set25
--- a/head/contrib/tcsh/nls/ukrainian/set25	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ukrainian/set25	Fri Mar 02 16:54:40 2012 +0200
@@ -1,6 +1,6 @@
-$ $tcsh: set25,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set25,v 1.4 2011/02/04 18:19:44 christos Exp $
 $ tc.sig.c
 $set 25 
 1 our wait %d\n
-2 ÐÏÍÉÌËÁ: bsd_signal(%d) ÓÉÇÎÁÌ ÚÁ ÍÅÖÁÍÉ ¦ÎÔÅÒ×ÁÌÕ\n
-3 ÐÏÍÉÌËÁ: bsd_signal(%d) - ÎÅ×ÄÁÞÁ sigaction, ËÏÄ ÐÏÍÉÌËÉ %d\n
+2 помилка: bsd_signal(%d) сигнал за межами інтервалу\n
+3 помилка: bsd_signal(%d) - невдача sigaction, код помилки %d\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ukrainian/set26
--- a/head/contrib/tcsh/nls/ukrainian/set26	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ukrainian/set26	Fri Mar 02 16:54:40 2012 +0200
@@ -1,15 +1,15 @@
-$ $tcsh: set26,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set26,v 1.4 2011/02/04 18:19:44 christos Exp $
 $ tc.who.c
 $set 26 
 1 cannot stat %s.  Please "unset watch".\n
 2 %s cannot be opened.  Please "unset watch".\n
-3 ðïíéìëá! last element is not whotail!\n
+3 ПОМИЛКА! last element is not whotail!\n
 4 backward: 
-5 ðïíéìëá! first element is not whohead!\n
+5 ПОМИЛКА! first element is not whohead!\n
 6 new: %s/%s\n
-7 ëÏÒÉÓÔÕ×ÁÞ %n %a %l (%m).
-8 ëÏÒÉÓÔÕ×ÁÞ %n %a %l.
-9 ЦÄ'¤ÄÎÁ×ÓÑ ÄÏ
-10 צÄ'¤ÄÎÁ×ÓÑ ×¦Ä
-11 ÚÁͦÎÉ× %s ÎÁ
-12 ÌÏËÁÌØÎÏ
+7 Користувач %n %a %l (%m).
+8 Користувач %n %a %l.
+9 під'єднався до
+10 від'єднався від
+11 замінив %s на
+12 локально
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ukrainian/set27
--- a/head/contrib/tcsh/nls/ukrainian/set27	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ukrainian/set27	Fri Mar 02 16:54:40 2012 +0200
@@ -1,8 +1,8 @@
-$ $tcsh: set27,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set27,v 1.4 2011/02/04 18:19:45 christos Exp $
 $ tw.comp.c
 $set 27 
-1 ËÏÍÁÎÄÁ
-2 ÒÏÚĦÌØÎÉË
-3 ÛÁÂÌÏÎ
-4 ÐÒÏͦÖÏË
-5 ÚÁ×ÅÒÛÅÎÎÑ
+1 команда
+2 роздільник
+3 шаблон
+4 проміжок
+5 завершення
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ukrainian/set29
--- a/head/contrib/tcsh/nls/ukrainian/set29	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ukrainian/set29	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set29,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set29,v 1.4 2011/02/04 18:19:45 christos Exp $
 $ tw.help.c
 $set 29 
-1 ÷¦ÄÓÕÔÎ¦Ê ÆÁÊÌ ÄÏצÄËÉ ÄÌÑ %S\n
+1 Відсутній файл довідки для %S\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ukrainian/set30
--- a/head/contrib/tcsh/nls/ukrainian/set30	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ukrainian/set30	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set30,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set30,v 1.4 2011/02/04 18:19:45 christos Exp $
 $ tw.parse.c
 $set 30 
 1 starting_a_command %d\n
@@ -7,10 +7,10 @@
 4 %s: Internal match error.\n
 5 items
 6 rows
-7 ôÕÔ %d %s, ×ÓÅ-ÔÁËÉ ÐÏËÁÚÕ×ÁÔÉ? [n/y] 
+7 Тут %d %s, все-таки показувати? [n/y] 
 8 looking = %d\n
-9 \n×ÎÕÔÒ¦ÛÎÑ ÐÏÍÉÌËÁ tcsh: ÷ÖÅ Ê ÎÅ ÚÎÁÀ, ÝÏ ÓÁÍÅ Ñ ÛÕËÁÀ!\n
-10 ÎÅ ËÁÔÁÌÏÇ
-11 ÎÅ ÚÎÁÊÄÅÎÏ
-12 ÎÅ ÞÉÔÁ¤ÔØÓÑ
+9 \nвнутрішня помилка tcsh: Вже й не знаю, що саме я шукаю!\n
+10 не каталог
+11 не знайдено
+12 не читається
 13 yY
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ukrainian/set31
--- a/head/contrib/tcsh/nls/ukrainian/set31	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ukrainian/set31	Fri Mar 02 16:54:40 2012 +0200
@@ -1,7 +1,7 @@
-$ $tcsh: set31,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set31,v 1.4 2011/02/04 18:19:45 christos Exp $
 $ vms.termcap.c
 $set 31 
-1 îÅ ÍÏÖÕ ×¦ÄËÒÉÔÉ TERMCAP: [%s]\n
-2 îÅ ÍÏÖÕ ×¦ÄËÒÉÔÉ %s.\n
-3 úÎÁÊÄÅÎÏ %s × %s.\n
-4 îÅ ÚÎÁÊÄÅÎÏ ÓЦ×ÐÁÄÁÎØ ÐÏ %s Õ %s\n
+1 Не можу відкрити TERMCAP: [%s]\n
+2 Не можу відкрити %s.\n
+3 Знайдено %s в %s.\n
+4 Не знайдено співпадань по %s у %s\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ukrainian/set5
--- a/head/contrib/tcsh/nls/ukrainian/set5	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ukrainian/set5	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set5,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set5,v 1.4 2011/02/04 18:19:45 christos Exp $
 $ ed.chared.c
 $set 5
-1 îÅÄÏÓÔÕÐÎÅ ÚÎÁÞÅÎÎÑ: ÓÅÒÅÄΤ ÚÁ×ÁÎÔÁÖÅÎÎÑ\n
+1 Недоступне значення: середнє завантаження\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ukrainian/set6
--- a/head/contrib/tcsh/nls/ukrainian/set6	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ukrainian/set6	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set6,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set6,v 1.4 2011/02/04 18:19:45 christos Exp $
 $ ed.inputl.c
 $set 6
 1 ERROR: illegal command from key 0%o\r\n
@@ -6,6 +6,6 @@
 3 edit\n
 4 abort\n
 5 no\n
-6 îÅÍÁ¤ ÓÈÏÖϧ ËÏÍÁÎÄÉ\n
-7 îÅÏÄÎÏÚÎÁÞÎÁ ËÏÍÁÎÄÁ\n
-8 *** æÁÔÁÌØÎÁ ðïíéìëá ÒÅÄÁËÔÏÒÁ ***\r\n\n
+6 Немає сÑ
ожої команди\n
+7 Неоднозначна команда\n
+8 *** Фатальна ПОМИЛКА редактора ***\r\n\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ukrainian/set7
--- a/head/contrib/tcsh/nls/ukrainian/set7	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ukrainian/set7	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set7,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set7,v 1.4 2011/02/04 18:19:45 christos Exp $
 $ ed.screen.c
 $set 7
 1 \n\tTcsh thinks your terminal has the\n
@@ -14,15 +14,15 @@
 11 does not have
 12 \tIt %s magic margins\n
 13 (empty)
-14 ÔÁË
-15 Φ
-16 ðïíéìëá: cannot delete\r\n
+14 так
+15 ні
+16 ПОМИЛКА: cannot delete\r\n
 17 DeleteChars: num is riduculous: %d\r\n
-18 ðïíéìëá: cannot insert\r\n
+18 ПОМИЛКА: cannot insert\r\n
 19 StartInsert: num is riduculous: %d\r\n
 20 %s: Cannot open /etc/termcap.\n
 21 %s: No entry for terminal type "%s"\n
-22 %s: ×ÉËÏÒÉÓÔÁÎÎÑ ÎÁÓÔÒÏÊÏË ÔÕÐÏÇÏ ÔÅÒͦÎÁÌÕ.\n
+22 %s: використання настройок тупого терміналу.\n
 23 %s: WARNING: Your terminal cannot move up.\n
 24 Editing may be odd for long lines.\n
 25 no clear EOL capability.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ukrainian/set8
--- a/head/contrib/tcsh/nls/ukrainian/set8	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ukrainian/set8	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,5 @@
-$ $tcsh: set8,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set8,v 1.4 2011/02/04 18:19:45 christos Exp $
 $ ed.term.c
 $set 8
-1 îÅצÄÏÍÉÊ ÐÅÒÅÍÉËÁÞ
-2 îÅצÒÎÉÊ ÁÒÇÕÍÅÎÔ
+1 Невідомий перемикач
+2 Невірний аргумент
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/nls/ukrainian/set9
--- a/head/contrib/tcsh/nls/ukrainian/set9	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/nls/ukrainian/set9	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-$ $tcsh: set9,v 1.3 2006/03/02 18:46:48 christos Exp $
+$ $tcsh: set9,v 1.4 2011/02/04 18:19:45 christos Exp $
 $ ed.xmap.c
 $set 9
 1 AddXkey: Null extended-key not allowed.\n
@@ -6,7 +6,7 @@
 3 DeleteXkey: Null extended-key not allowed.\n
 4 Unbound extended key "%S"\n
 5 Some extended keys too long for internal print buffer
-6 Enumerate: ðïíéìëá!! Null ptr passed\n!
+6 Enumerate: ПОМИЛКА!! Null ptr passed\n!
 7 no input
 8 Something must follow: %c\n
 9 Octal constant does not fit in a char.\n
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/patchlevel.h
--- a/head/contrib/tcsh/patchlevel.h	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/patchlevel.h	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/patchlevel.h,v 3.167 2009/07/10 17:09:32 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/patchlevel.h,v 3.180 2012/02/13 16:33:50 christos Exp $ */
 /*
  * patchlevel.h: Our life story.
  */
@@ -7,8 +7,8 @@
 
 #define ORIGIN "Astron"
 #define REV 6
-#define VERS 17
-#define PATCHLEVEL 0
-#define DATE "2009-07-10"
+#define VERS 18
+#define PATCHLEVEL 1
+#define DATE "2012-02-14"
 
 #endif /* _h_patchlevel */
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/pathnames.h
--- a/head/contrib/tcsh/pathnames.h	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/pathnames.h	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/pathnames.h,v 3.18 2002/03/08 17:36:46 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/pathnames.h,v 3.22 2011/02/05 20:34:55 christos Exp $ */
 /*
  * pathnames.h: Location of things to find
  */
@@ -33,7 +33,7 @@
 #ifndef _h_pathnames
 #define _h_pathnames
 
-#ifdef BSD4_4
+#ifdef HAVE_PATHS_H
 # include <paths.h>
 #endif
 
@@ -92,6 +92,10 @@
 # define _PATH_TCSHELL		"/local/bin/tcsh"	/* use ram disk */
 #endif /* _MINIX && !_PATH_TCSHELL */
 
+#if defined(__linux__) && !defined(_PATH_TCSHELL)
+# define _PATH_TCSHELL		"/bin/tcsh"
+#endif /* __linux__ && !_PATH_TCSHELL */
+
 #if defined(__EMX__) && !defined(_PATH_DEVNULL)
 # define _PATH_DEVNULL		"nul"
 #endif /* __EMX__ && !_PATH_DEVNULL */
@@ -141,7 +145,7 @@
 #endif /* !_PATH_CSHELL */
 
 #ifndef _PATH_TCSHELL
-#  define _PATH_TCSHELL		"/usr/local/bin/tcsh"
+# define _PATH_TCSHELL		"/usr/local/bin/tcsh"
 #endif /* !_PATH_TCSHELL */
 
 #ifndef _PATH_BIN_LOGIN
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/sh.c
--- a/head/contrib/tcsh/sh.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/sh.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/sh.c,v 3.145 2009/06/25 21:15:37 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.c,v 3.174 2011/11/29 18:38:54 christos Exp $ */
 /*
  * sh.c: Main shell routines
  */
@@ -39,7 +39,7 @@
  All rights reserved.\n";
 #endif /* not lint */
 
-RCSID("$tcsh: sh.c,v 3.145 2009/06/25 21:15:37 christos Exp $")
+RCSID("$tcsh: sh.c,v 3.174 2011/11/29 18:38:54 christos Exp $")
 
 #include "tc.h"
 #include "ed.h"
@@ -78,7 +78,7 @@
  * ported to Apple Unix (TM) (OREO)  26 -- 29 Jun 1987
  */
 
-jmp_buf_t reslab INIT_ZERO_STRUCT;
+jmp_buf_t reslab;
 
 static const char tcshstr[] = "tcsh";
 
@@ -160,6 +160,77 @@
 
 	int		  main		(int, char **);
 
+#ifndef LOCALEDIR
+#define LOCALEDIR "/usr/share/locale"
+#endif
+
+#ifdef NLS_CATALOGS
+static void
+add_localedir_to_nlspath(const char *path)
+{
+    static const char msgs_LOC[] = "/%L/LC_MESSAGES/%N.cat";
+    static const char msgs_lang[] = "/%l/LC_MESSAGES/%N.cat";
+    char *old;
+    char *new, *new_p;
+    size_t len;
+    int add_LOC = 1;
+    int add_lang = 1;
+    char trypath[MAXPATHLEN];
+    struct stat st;
+
+    if (path == NULL)
+        return;
+
+    (void) xsnprintf(trypath, sizeof(trypath), "%s/en/LC_MESSAGES/tcsh.cat",
+	path);
+    if (stat(trypath, &st) == -1)
+	return;
+
+    if ((old = getenv("NLSPATH")) != NULL)
+        len = strlen(old) + 1;	/* don't forget the colon. */
+    else
+	len = 0;
+
+    len += 2 * strlen(path) +
+	   sizeof(msgs_LOC) + sizeof(msgs_lang); /* includes the extra colon */
+
+    new = new_p = xcalloc(len, 1);
+
+    if (old != NULL) {
+	size_t pathlen = strlen(path);
+	char *old_p;
+
+	(void) xsnprintf(new_p, len, "%s", old);
+	new_p += strlen(new_p);
+	len -= new_p - new;
+
+	/* Check if the paths we try to add are already present in NLSPATH.
+	   If so, note it by setting the appropriate flag to 0. */
+	for (old_p = old; old_p; old_p = strchr(old_p, ':'),
+				 old_p = old_p ? old_p + 1 : NULL) {
+	    if (strncmp(old_p, path, pathlen) != 0)
+	    	continue;
+	    if (strncmp(old_p + pathlen, msgs_LOC, sizeof(msgs_LOC) - 1) == 0)
+		add_LOC = 0;
+	    else if (strncmp(old_p + pathlen, msgs_lang,
+			      sizeof(msgs_lang) - 1) == 0)
+		add_lang = 0;
+	}
+    }
+
+    /* Add the message catalog paths not already present to NLSPATH. */
+    if (add_LOC || add_lang)
+	(void) xsnprintf(new_p, len, "%s%s%s%s%s%s",
+			 old ? ":" : "",
+			 add_LOC ? path : "", add_LOC ? msgs_LOC : "",
+			 add_LOC && add_lang ? ":" : "",
+			 add_lang ? path : "", add_lang ? msgs_lang : "");
+
+    tsetenv(STRNLSPATH, str2short(new));
+    free(new);
+}
+#endif
+
 int
 main(int argc, char **argv)
 {
@@ -179,6 +250,7 @@
     int osetintr;
     struct sigaction oparintr;
 
+    (void)memset(&reslab, 0, sizeof(reslab));
 #ifdef WINNT_NATIVE
     nt_init();
 #endif /* WINNT_NATIVE */
@@ -192,6 +264,13 @@
 # endif /* LC_CTYPE */
 #endif /* NLS */
 
+    STR_environ = blk2short(environ);
+    environ = short2blk(STR_environ);	/* So that we can free it */
+
+#ifdef NLS_CATALOGS
+    add_localedir_to_nlspath(LOCALEDIR);
+#endif
+
     nlsinit();
 
 #ifdef MALLOC_TRACE
@@ -247,7 +326,7 @@
 	t = t ? t + 1 : argv[0];
 	if (*t == '-') t++;
 	progname = strsave((t && *t) ? t : tcshstr);    /* never want a null */
-	tcsh = strcmp(progname, tcshstr) == 0;
+	tcsh = strncmp(progname, tcshstr, sizeof(tcshstr) - 1) == 0;
     }
 
     /*
@@ -263,16 +342,16 @@
     STR_SHELLPATH = SAVE(_PATH_CSHELL);
 # endif
 #endif
-    STR_environ = blk2short(environ);
-    environ = short2blk(STR_environ);	/* So that we can free it */
     STR_WORD_CHARS = SAVE(WORD_CHARS);
 
     HIST = '!';
     HISTSUB = '^';
-    PRCH = '>';
-    PRCHROOT = '#';
+    PRCH = tcsh ? '>' : '%';	/* to replace %# in $prompt for normal users */
+    PRCHROOT = '#';		/* likewise for root */
     word_chars = STR_WORD_CHARS;
     bslash_quote = 0;		/* PWP: do tcsh-style backslash quoting? */
+    anyerror = 1;		/* for compatibility */
+    setcopy(STRanyerror, STRNULL, VAR_READWRITE);
 
     /* Default history size to 100 */
     setcopy(STRhistory, str2short("100"), VAR_READWRITE);
@@ -319,7 +398,6 @@
 	setNS(STRloginsh);
     }
 
-    AsciiOnly = 1;
     NoNLSRebind = getenv("NOREBIND") != NULL;
 #ifdef NLS
 # ifdef SETLOCALEBUG
@@ -336,13 +414,19 @@
     fix_strcoll_bug();
 # endif /* STRCOLLBUG */
 
-    {
+    /*
+     * On solaris ISO8859-1 contains no printable characters in the upper half
+     * so we need to test only for MB_CUR_MAX == 1, otherwise for multi-byte
+     * locales we are always AsciiOnly == 0.
+     */
+    if (MB_CUR_MAX == 1) {
 	int     k;
 
-	for (k = 0200; k <= 0377 && !Isprint(CTL_ESC(k)); k++)
+	for (k = 0200; k <= 0377 && !isprint(CTL_ESC(k)); k++)
 	    continue;
-	AsciiOnly = MB_CUR_MAX == 1 && k > 0377;
-    }
+	AsciiOnly = k > 0377;
+    } else
+	AsciiOnly = 0;
 #else
     AsciiOnly = getenv("LANG") == NULL && getenv("LC_CTYPE") == NULL;
 #endif				/* NLS */
@@ -453,7 +537,8 @@
     if (loginsh || (uid == 0)) {
 	if (*cp) {
 	    /* only for login shells or root and we must have a tty */
-	    if ((cp2 = Strrchr(cp, (Char) '/')) != NULL) {
+	    if (((cp2 = Strrchr(cp, (Char) '/')) != NULL) &&
+		(Strncmp(cp, STRptssl, 3) != 0)) {
 		cp2 = cp2 + 1;
 	    }
 	    else
@@ -506,7 +591,18 @@
     if ((tcp = getenv("HOME")) != NULL)
 	cp = quote(SAVE(tcp));
     else
+#ifdef __ANDROID__
+	/* On Android, $HOME usually isn't set, so we can't load user RC files.
+	   Check for the environment variable EXTERNAL_STORAGE, which contains
+	   the mount point of the external storage (SD card, mostly).  If
+	   EXTERNAL_STORAGE isn't set fall back to "/sdcard". */
+    if ((tcp = getenv("EXTERNAL_STORAGE")) != NULL)
+	cp = quote(SAVE(tcp));
+    else
+	cp = quote(SAVE("/sdcard"));
+#else
 	cp = NULL;
+#endif
 
     if (cp == NULL)
 	fast = 1;		/* No home -> can't read scripts */
@@ -531,6 +627,12 @@
 	setv(STRoid, Itoa(oid, 0, 0), VAR_READWRITE);
 #endif /* apollo */
 
+	setv(STReuid, Itoa(euid, 0, 0), VAR_READWRITE);
+	if ((pw = xgetpwuid(euid)) == NULL)
+	    setcopy(STReuser, STRunknown, VAR_READWRITE);
+	else
+	    setcopy(STReuser, str2short(pw->pw_name), VAR_READWRITE);
+
 	setv(STRuid, Itoa(uid, 0, 0), VAR_READWRITE);
 
 	setv(STRgid, Itoa(gid, 0, 0), VAR_READWRITE);
@@ -542,7 +644,7 @@
 	else if (cln != NULL)
 	    setv(STRuser, quote(SAVE(cln)), VAR_READWRITE);
 	else if ((pw = xgetpwuid(uid)) == NULL)
-	    setcopy(STRuser, str2short("unknown"), VAR_READWRITE);
+	    setcopy(STRuser, STRunknown, VAR_READWRITE);
 	else
 	    setcopy(STRuser, str2short(pw->pw_name), VAR_READWRITE);
 	if (cln == NULL)
@@ -554,7 +656,7 @@
 	if (cgr != NULL)
 	    setv(STRgroup, quote(SAVE(cgr)), VAR_READWRITE);
 	else if ((gr = xgetgrgid(gid)) == NULL)
-	    setcopy(STRgroup, str2short("unknown"), VAR_READWRITE);
+	    setcopy(STRgroup, STRunknown, VAR_READWRITE);
 	else
 	    setcopy(STRgroup, str2short(gr->gr_name), VAR_READWRITE);
 	if (cgr == NULL)
@@ -573,7 +675,7 @@
 	    tsetenv(STRHOST, str2short(cbuff));
 	}
 	else
-	    tsetenv(STRHOST, str2short("unknown"));
+	    tsetenv(STRHOST, STRunknown);
     }
 
 
@@ -697,7 +799,7 @@
 	parseLS_COLORS(str2short(tcp));
 #endif /* COLOR_LS_F */
 
-    doldol = putn((int) getpid());	/* For $$ */
+    doldol = putn((tcsh_number_t)getpid());	/* For $$ */
 #ifdef WINNT_NATIVE
     {
 	char *tmp;
@@ -705,8 +807,8 @@
 	if ((tmp = getenv("TMP")) != NULL) {
 	    tmp = xasprintf("%s/%s", tmp, "sh");
 	    tmp2 = SAVE(tmp);
-	xfree(tmp);
-    }
+	    xfree(tmp);
+	}
 	else {
 	    tmp2 = SAVE(""); 
 	}
@@ -714,7 +816,16 @@
 	xfree(tmp2);
     }
 #else /* !WINNT_NATIVE */
+#ifdef HAVE_MKSTEMP
+    {
+	char *tmpdir = getenv ("TMPDIR");
+	if (!tmpdir)
+	    tmpdir = "/tmp";
+	shtemp = Strspl(SAVE(tmpdir), SAVE("/sh" TMP_TEMPLATE)); /* For << */
+    }
+#else /* !HAVE_MKSTEMP */
     shtemp = Strspl(STRtmpsh, doldol);	/* For << */
+#endif /* HAVE_MKSTEMP */
 #endif /* WINNT_NATIVE */
 
     /*
@@ -738,10 +849,11 @@
     /* PATCH IDEA FROM Issei.Suzuki VERY THANKS */
 #if defined(DSPMBYTE)
 #if defined(NLS) && defined(LC_CTYPE)
-    if (((tcp = setlocale(LC_CTYPE, NULL)) != NULL || (tcp = getenv("LANG")) != NULL) && !adrof(CHECK_MBYTEVAR)) {
+    if (((tcp = setlocale(LC_CTYPE, NULL)) != NULL || (tcp = getenv("LANG")) != NULL) && !adrof(CHECK_MBYTEVAR))
 #else
-    if ((tcp = getenv("LANG")) != NULL && !adrof(CHECK_MBYTEVAR)) {
+    if ((tcp = getenv("LANG")) != NULL && !adrof(CHECK_MBYTEVAR))
 #endif
+    {
 	autoset_dspmbyte(str2short(tcp));
     }
 #if defined(WINNT_NATIVE)
@@ -749,7 +861,14 @@
       nt_autoset_dspmbyte();
 #endif /* WINNT_NATIVE */
 #endif
-
+#if defined(AUTOSET_KANJI) 
+# if defined(NLS) && defined(LC_CTYPE)
+    if (setlocale(LC_CTYPE, NULL) != NULL || getenv("LANG") != NULL)
+# else
+    if (getenv("LANG") != NULL)
+# endif
+	autoset_kanji();
+#endif /* AUTOSET_KANJI */
     fix_version();		/* publish the shell version */
 
     if (argc > 1 && strcmp(argv[1], "--version") == 0) {
@@ -912,6 +1031,8 @@
 
 	    case ' ':
 	    case '\t':
+	    case '\r':
+	    case '\n':
 		/* 
 		 * for O/S's that don't do the argument parsing right in 
 		 * "#!/foo -f " scripts
@@ -1019,10 +1140,7 @@
      * Set up the prompt.
      */
     if (prompt) {
-	if (tcsh)
-	    setcopy(STRprompt, STRdeftcshprompt, VAR_READWRITE);
-	else
-	    setcopy(STRprompt, STRdefcshprompt, VAR_READWRITE);
+	setcopy(STRprompt, STRdefprompt, VAR_READWRITE);
 	/* that's a meta-questionmark */
 	setcopy(STRprompt2, STRmquestion, VAR_READWRITE);
 	setcopy(STRprompt3, STRKCORRECT, VAR_READWRITE);
@@ -1679,7 +1797,7 @@
 exitstat(void)
 {
 #ifdef PROF
-    monitor(0);
+    _mcleanup();
 #endif
     /*
      * Note that if STATUS is corrupted (i.e. getn bombs) then error will exit
@@ -1839,7 +1957,7 @@
 process(int catch)
 {
     jmp_buf_t osetexit;
-    /* PWP: This might get nuked my longjmp so don't make it a register var */
+    /* PWP: This might get nuked by longjmp so don't make it a register var */
     size_t omark;
     volatile int didexitset = 0;
 
@@ -1927,9 +2045,11 @@
 	/*
 	 * Echo not only on VERBOSE, but also with history expansion. If there
 	 * is a lexical error then we forego history echo.
+	 * Do not echo if we're only entering history (source -h).
 	 */
 	if ((hadhist && !seterr && intty && !tellwhat && !Expand && !whyles) ||
-	    adrof(STRverbose)) {
+	    (!enterhist && adrof(STRverbose)))
+	{
 	    int odidfds = didfds;
 	    haderr = 1;
 	    didfds = 0;
@@ -1994,9 +2114,14 @@
 	 * Parse the words of the input into a parse tree.
 	 */
 	t = syntax(paraml.next, &paraml, 0);
-	cleanup_push(t, syntax_cleanup);
-	if (seterr)
+	/*
+	 * We cannot cleanup push here, because cd /blah; echo foo
+	 * would rewind t on the chdir error, and free the rest of the command
+	 */
+	if (seterr) {
+	    freesyn(t);
 	    stderror(ERR_OLD);
+	}
 
 	postcmd();
 	/*
@@ -2004,6 +2129,7 @@
 	 * <mlschroe at immd4.informatik.uni-erlangen.de> was execute(t, tpgrp);
 	 */
 	execute(t, (tpgrp > 0 ? tpgrp : -1), NULL, NULL, TRUE);
+	freesyn(t);
 
 	/*
 	 * Made it!
@@ -2015,11 +2141,15 @@
 #endif /* SIG_WINDOW */
 	setcopy(STR_, InputBuf, VAR_READWRITE | VAR_NOGLOB);
     cmd_done:
-	cleanup_until(&paraml);
+	if (cleanup_reset())
+	    cleanup_until(&paraml);
+	else
+	    haderr = 1;
     }
     cleanup_pop_mark(omark);
     resexit(osetexit);
     exitset--;
+    handle_pending_signals();
 }
 
 /*ARGSUSED*/
@@ -2137,12 +2267,15 @@
 		continue;
 
 	    /* skip . and .. */
-	    if (!readdir(mailbox) || !readdir(mailbox))
+	    if (!readdir(mailbox) || !readdir(mailbox)) {
+		(void)closedir(mailbox);
 		continue;
+	    }
 
 	    while (readdir(mailbox))
 		mailcount++;
 
+	    (void)closedir(mailbox);
 	    if (mailcount == 0)
 		continue;
 
@@ -2156,7 +2289,7 @@
 	else {
 	    char *type;
 	    
-	    if (stb.st_size == 0 || stb.st_atime > stb.st_mtime ||
+	    if (stb.st_size == 0 || stb.st_atime >= stb.st_mtime ||
 		(stb.st_atime <= chktim && stb.st_mtime <= chktim) ||
 		(loginsh && !new))
 		continue;
@@ -2224,8 +2357,14 @@
 #ifndef CLOSE_ON_EXEC
     didcch = 0;			/* Havent closed for child */
 #endif /* CLOSE_ON_EXEC */
-    isdiagatty = isatty(SHDIAG);
-    isoutatty = isatty(SHOUT);
+    if (SHDIAG >= 0)
+	isdiagatty = isatty(SHDIAG);
+    else
+    	isdiagatty = 0;
+    if (SHDIAG >= 0)
+	isoutatty = isatty(SHOUT);
+    else
+    	isoutatty = 0;
 #ifdef NLS_BUGS
 #ifdef NLS_CATALOGS
     nlsinit();
@@ -2260,12 +2399,13 @@
 
     {
 	struct process *pp, *np;
-
+	pid_t mypid = getpid();
 	/* Kill all processes marked for hup'ing */
 	for (pp = proclist.p_next; pp; pp = pp->p_next) {
 	    np = pp;
-	    do 
-		if ((np->p_flags & PHUP) && np->p_jobid != shpgrp) {
+	    do
+		if ((np->p_flags & PHUP) && np->p_jobid != shpgrp &&
+		    np->p_parentid == mypid) {
 		    if (killpg(np->p_jobid, SIGHUP) != -1) {
 			/* In case the job was suspended... */
 #ifdef SIGCONT
@@ -2352,6 +2492,7 @@
 	recdirs(NULL, adrof(STRsavedirs) != NULL);
 	rechist(NULL, adrof(STRsavehist) != NULL);
     }
+    displayHistStats("Exiting");	/* no-op unless DEBUG_HIST */
 }
 
 /*
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/sh.char.c
--- a/head/contrib/tcsh/sh.char.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/sh.char.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/sh.char.c,v 3.20 2007/03/07 16:31:37 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.char.c,v 3.21 2010/02/09 20:32:34 christos Exp $ */
 /*
  * sh.char.c: Character classification tables
  */
@@ -32,7 +32,7 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: sh.char.c,v 3.20 2007/03/07 16:31:37 christos Exp $")
+RCSID("$tcsh: sh.char.c,v 3.21 2010/02/09 20:32:34 christos Exp $")
 
 #include "sh.char.h"
 
@@ -233,8 +233,8 @@
 
 /*	252 udiaeresis	253 yacute	254 thorn	255 ydiaeresis	*/
 	_LET|_DOW,	_LET|_DOW,	_LET|_DOW,	_LET|_DOW,
+#endif /* SHORT_STRINGS */
 };
-#endif /* SHORT_STRINGS */
 
 #if defined(KANJI) && defined(SHORT_STRINGS) && defined(DSPMBYTE)
 /* original table */
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/sh.char.h
--- a/head/contrib/tcsh/sh.char.h	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/sh.char.h	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/sh.char.h,v 3.35 2008/09/25 14:41:34 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.char.h,v 3.36 2010/05/08 00:36:02 christos Exp $ */
 /*
  * sh.char.h: Table for spotting special characters quickly
  * 	      Makes for very obscure but efficient coding.
@@ -150,17 +150,15 @@
 
 #ifdef WIDE_STRINGS
 # define cmap(c, bits)	\
-	(((c) < 0) ? 0 : \
-	((c) & QUOTE) || (c) >= 0x0080 ? 0 : (_cmap[(tcshuc)ASC(c)] & (bits)))
+    (((c) & QUOTE) || (unsigned int)(c) >= 0x0080 ? 0 : \
+	(_cmap[(tcshuc)ASC(c)] & (bits)))
 #elif defined(SHORT_STRINGS) && defined(KANJI)
 #  define cmap(c, bits)	\
-	(((c) < 0) ? 0 : \
-	(((c) & QUOTE) || ((ASC(c) & 0x80) && adrof(STRnokanji))) ? \
+    ((((c) & QUOTE) || ((tcshuc)(ASC(c) & 0x80) && adrof(STRnokanji))) ? \
 	0 : (_cmap[(tcshuc)ASC(c)] & (bits)))
 #else /* SHORT_STRINGS && KANJI */
 # define cmap(c, bits)	\
-	(((c) < 0) ? 0 : \
-	((c) & QUOTE) ? 0 : (_cmap[(tcshuc)ASC(c)] & (bits)))
+    (((c) & QUOTE) ? 0 : (_cmap[(tcshuc)ASC(c)] & (bits)))
 #endif /* SHORT_STRINGS && KANJI */
 
 #define isglob(c)	cmap((c), _GLOB)
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/sh.decls.h
--- a/head/contrib/tcsh/sh.decls.h	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/sh.decls.h	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/sh.decls.h,v 3.55 2009/02/25 22:54:54 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.decls.h,v 3.62 2011/02/25 23:58:34 christos Exp $ */
 /*
  * sh.decls.h	 External declarations from sh*.c
  */
@@ -48,9 +48,9 @@
 extern	void		  process	(int);
 extern	void		  untty		(void);
 #ifdef PROF
-extern	void		  done		(int);
+extern	void		  done		(int) __attribute__((__noreturn__));
 #else
-extern	void		  xexit		(int);
+extern	void		  xexit		(int) __attribute__((__noreturn__));
 #endif
 extern	int		  grabpgrp	(int, pid_t);
 
@@ -82,7 +82,7 @@
 /*
  * sh.err.c
  */
-extern	void		  reset		(void);
+extern	void		  reset		(void) __attribute__((__noreturn__));
 extern	void		  cleanup_push_internal(void *, void (*fn) (void *)
 #ifdef CLEANUP_DEBUG
 						, const char *, size_t
@@ -91,8 +91,9 @@
 #define cleanup_push(v, f) cleanup_push_internal(v, f)
 #endif
 );
+extern	int		  cleanup_reset(void);
 extern	void		  cleanup_ignore(void *);
-extern	void		  cleanup_until	(void *);
+extern	void		  cleanup_until(void *);
 extern	void		  cleanup_until_mark(void);
 extern	size_t		  cleanup_push_mark(void);
 extern	void		  cleanup_pop_mark(size_t);
@@ -103,7 +104,9 @@
 extern	void		  xfree_indirect(void *);
 extern	void		  errinit	(void);
 extern	void		  seterror	(unsigned int, ...);
-extern	void		  stderror	(unsigned int, ...);
+extern	void		  fixerror	(void);
+extern	void		  stderror	(unsigned int, ...)
+    __attribute__((__noreturn__));
 
 /*
  * sh.exec.c
@@ -122,9 +125,9 @@
 /*
  * sh.exp.c
  */
-extern  Char     *filetest       (Char *, Char ***, int);
-extern	int	 	  expr		(Char ***);
-extern	int		  exp0		(Char ***, int);
+extern  Char		 *filetest      (Char *, Char ***, int);
+extern	tcsh_number_t 	  expr		(Char ***);
+extern	tcsh_number_t	  exp0		(Char ***, int);
 
 /*
  * sh.file.c
@@ -212,11 +215,12 @@
  * sh.hist.c
  */
 extern	void	 	  dohist	(Char **, struct command *);
-extern  struct Hist 	 *enthist	(int, struct wordent *, int, int);
+extern  struct Hist 	 *enthist	(int, struct wordent *, int, int, int);
 extern	void	 	  savehist	(struct wordent *, int);
 extern	char		 *fmthist	(int, ptr_t);
 extern	void		  rechist	(Char *, int);
 extern	void		  loadhist	(Char *, int);
+extern	void		  displayHistStats(const char *);
 
 /*
  * sh.init.c
@@ -270,9 +274,11 @@
 extern	Char		 *strip		(Char *);
 extern	Char		 *quote		(Char *);
 extern	const Char	 *quote_meta	(struct Strbuf *, const Char *);
+#ifndef SHORT_STRINGS
 extern	char		 *strnsave	(const char *, size_t);
+#endif
 extern	char		 *strsave	(const char *);
-extern	void		  udvar		(Char *);
+extern	void		  udvar		(Char *) __attribute__((__noreturn__));
 #ifndef POSIX
 extern  char   	  	 *strstr	(const char *, const char *);
 #endif /* !POSIX */
@@ -368,8 +374,8 @@
 extern	struct varent 	 *adrof1	(const Char *, struct varent *);
 extern	void		  doset		(Char **, struct command *);
 extern	void		  dolet		(Char **, struct command *);
-extern	Char		 *putn		(int);
-extern	int		  getn		(Char *);
+extern	Char		 *putn		(tcsh_number_t);
+extern	tcsh_number_t	  getn		(const Char *);
 extern	Char		 *value1	(Char *, struct varent *);
 extern	void		  setcopy	(const Char *, const Char *, int);
 extern	void		  setv		(const Char *, Char *, int);
@@ -380,7 +386,7 @@
 extern	void		  unset		(Char **, struct command *);
 extern	void		  unset1	(Char *[], struct varent *);
 extern	void		  unsetv	(Char *);
-extern	void		  setNS		(Char *);
+extern	void		  setNS		(const Char *);
 extern	void		  shift		(Char **, struct command *);
 extern	void		  plist		(struct varent *, int);
 extern	Char		 *unparse	(struct command *);
@@ -388,6 +394,9 @@
 extern	void 		  update_dspmbyte_vars	(void);
 extern	void		  autoset_dspmbyte	(const Char *);
 #endif
+#if defined(AUTOSET_KANJI)
+extern	void		  autoset_kanji	(void);
+#endif
 
 /*
  * sh.time.c
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/sh.dir.c
--- a/head/contrib/tcsh/sh.dir.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/sh.dir.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/sh.dir.c,v 3.80 2007/05/08 21:05:34 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.dir.c,v 3.82 2011/10/16 16:25:05 christos Exp $ */
 /*
  * sh.dir.c: Directory manipulation functions
  */
@@ -33,7 +33,7 @@
 #include "sh.h"
 #include "ed.h"
 
-RCSID("$tcsh: sh.dir.c,v 3.80 2007/05/08 21:05:34 christos Exp $")
+RCSID("$tcsh: sh.dir.c,v 3.82 2011/10/16 16:25:05 christos Exp $")
 
 /*
  * C Shell - directory management
@@ -204,10 +204,12 @@
     for (n++; loop && *n != NULL && (*n)[0] == '-'; n++) 
 	if (*(s = &((*n)[1])) == '\0')	/* test for bare "-" argument */
 	    dflag |= DIR_OLD;
-	else {
+	else if ((*n)[1] == '-' && (*n)[2] == '\0') {   /* test for -- */
+	    n++;
+	    break;
+	} else {
 	    char *p;
-	    while (*s != '\0')	/* examine flags */
-	    {
+	    while (*s != '\0')	/* examine flags */ {
 		if ((p = strchr(dstr, *s++)) != NULL)
 		    dflag |= (1 << (p - dstr));
 	        else
@@ -643,9 +645,13 @@
 	Char  **cdp;
 
 	for (cdp = c->vec; *cdp; cdp++) {
+	    size_t len = Strlen(*cdp);
 	    buf.len = 0;
-	    Strbuf_append(&buf, *cdp);
-	    Strbuf_append1(&buf, '/');
+	    if (len > 0) {
+		Strbuf_append(&buf, *cdp);
+		if ((*cdp)[len - 1] != '/')
+		    Strbuf_append1(&buf, '/');
+	    }
 	    Strbuf_append(&buf, cp);
 	    Strbuf_terminate(&buf);
 	    /*
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/sh.dol.c
--- a/head/contrib/tcsh/sh.dol.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/sh.dol.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/sh.dol.c,v 3.77 2009/06/19 16:25:00 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.dol.c,v 3.83 2011/01/25 20:10:46 christos Exp $ */
 /*
  * sh.dol.c: Variable substitutions
  */
@@ -32,7 +32,7 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: sh.dol.c,v 3.77 2009/06/19 16:25:00 christos Exp $")
+RCSID("$tcsh: sh.dol.c,v 3.83 2011/01/25 20:10:46 christos Exp $")
 
 /*
  * C shell
@@ -47,7 +47,7 @@
  * some QUOTEing may have occurred already, so we dont "trim()" here.
  */
 
-static Char Dpeekc;		/* Peek for DgetC */
+static eChar Dpeekc;		/* Peek for DgetC */
 static eChar Dpeekrd;		/* Peek for Dreadc */
 static Char *Dcp, *const *Dvp;	/* Input vector for Dreadc */
 
@@ -317,7 +317,7 @@
 static eChar
 DgetC(int flag)
 {
-    Char c;
+    eChar c;
 
 top:
     if ((c = Dpeekc) != 0) {
@@ -402,7 +402,7 @@
 	    stderror(ERR_SYNTAX);
 	if (backpid != 0) {
 	    xfree(dolbang);
-	    setDolp(dolbang = putn(backpid));
+	    setDolp(dolbang = putn((tcsh_number_t)backpid));
 	}
 	cleanup_until(name);
 	goto eatbrac;
@@ -528,7 +528,7 @@
 		    stderror(ERR_DOLZERO);
 		if (length) {
 		    length = Strlen(ffile);
-		    addla(putn(length));
+		    addla(putn((tcsh_number_t)length));
 		}
 		else {
 		    fixDolMod();
@@ -588,7 +588,7 @@
 	    cleanup_until(name);
 	    fixDolMod();
 	    if (length) {
-		    addla(putn(Strlen(np)));
+		    addla(putn((tcsh_number_t)Strlen(np)));
 	    } else {
 		    xfree(env_val);
 		    env_val = Strsave(np);
@@ -625,7 +625,7 @@
 
 	    for (i = 0; Isdigit(*np); i = i * 10 + *np++ - '0')
 		continue;
-	    if (i < 0 || i > upb && !any("-*", *np)) {
+	    if (i < 0 || (i > upb && !any("-*", *np))) {
 		cleanup_until(name);
 		dolerror(vp->v_name);
 		return;
@@ -687,7 +687,7 @@
 		stderror(ERR_MISSING, '}');
 	    unDredc(c);
 	}
-	addla(putn(upb - lwb + 1));
+	addla(putn((tcsh_number_t)(upb - lwb + 1)));
     }
     else if (length) {
 	int i;
@@ -698,7 +698,7 @@
 	/* We don't want that, since we can always compute it by adding $#xxx */
 	length += i - 1;	/* Add the number of spaces in */
 #endif
-	addla(putn(length));
+	addla(putn((tcsh_number_t)length));
     }
     else {
 eatmod:
@@ -830,7 +830,7 @@
 		    cp = np;
 		    cp[--len] = '\0';
 		    didmod = 1;
-		    if (diff >= len)
+		    if (diff >= (ssize_t)len)
 			break;
 		} else {
 		    /* should this do a seterror? */
@@ -887,7 +887,7 @@
 static eChar
 Dredc(void)
 {
-    Char c;
+    eChar c;
 
     if ((c = Dpeekrd) != 0) {
 	Dpeekrd = 0;
@@ -936,45 +936,52 @@
     Char *lbp, *obp, *mbp;
     Char  **vp;
     int    quoted;
+#ifdef HAVE_MKSTEMP
+    char   *tmp = short2str(shtemp);
+    char   *dot = strrchr(tmp, '.');
+
+    if (!dot)
+	stderror(ERR_NAME | ERR_NOMATCH);
+    strcpy(dot, TMP_TEMPLATE);
+
+    xclose(0);
+    if (mkstemp(tmp) == -1)
+	stderror(ERR_SYSTEM, tmp, strerror(errno));
+#else /* !HAVE_MKSTEMP */
     char   *tmp;
-#ifndef WINNT_NATIVE
+# ifndef WINNT_NATIVE
     struct timeval tv;
 
 again:
-#endif /* WINNT_NATIVE */
+# endif /* WINNT_NATIVE */
     tmp = short2str(shtemp);
-#ifndef O_CREAT
-# define O_CREAT 0
+# if O_CREAT == 0
     if (xcreat(tmp, 0600) < 0)
 	stderror(ERR_SYSTEM, tmp, strerror(errno));
-#endif
+# endif
     xclose(0);
-#ifndef O_TEMPORARY
-# define O_TEMPORARY 0
-#endif
-#ifndef O_EXCL
-# define O_EXCL 0
-#endif
     if (xopen(tmp, O_RDWR|O_CREAT|O_EXCL|O_TEMPORARY|O_LARGEFILE, 0600) ==
 	-1) {
 	int oerrno = errno;
-#ifndef WINNT_NATIVE
+# ifndef WINNT_NATIVE
 	if (errno == EEXIST) {
 	    if (unlink(tmp) == -1) {
 		(void) gettimeofday(&tv, NULL);
 		xfree(shtemp);
-		mbp = putn((((int)tv.tv_sec) ^ 
-		    ((int)tv.tv_usec) ^ ((int)getpid())) & 0x00ffffff);
+		mbp = putn((((tcsh_number_t)tv.tv_sec) ^ 
+		    ((tcsh_number_t)tv.tv_usec) ^
+		    ((tcsh_number_t)getpid())) & 0x00ffffff);
 		shtemp = Strspl(STRtmpsh, mbp);
 		xfree(mbp);
 	    }
 	    goto again;
 	}
-#endif /* WINNT_NATIVE */
+# endif /* WINNT_NATIVE */
 	(void) unlink(tmp);
 	errno = oerrno;
  	stderror(ERR_SYSTEM, tmp, strerror(errno));
     }
+#endif /* HAVE_MKSTEMP */
     (void) unlink(tmp);		/* 0 0 inode! */
     Dv[0] = term;
     Dv[1] = NULL;
@@ -1007,6 +1014,10 @@
 	}
 	Strbuf_terminate(&lbuf);
 
+	/* Catch EOF in the middle of a line. */
+	if (c == CHAR_ERR && lbuf.len != 0)
+	    c = '\n';
+
 	/*
 	 * Check for EOF or compare to terminator -- before expansion
 	 */
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/sh.err.c
--- a/head/contrib/tcsh/sh.err.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/sh.err.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/sh.err.c,v 3.50 2007/09/28 20:25:15 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.err.c,v 3.55 2011/02/25 23:58:34 christos Exp $ */
 /*
  * sh.err.c: Error printing routines. 
  */
@@ -34,7 +34,7 @@
 #include "sh.h"
 #include <assert.h>
 
-RCSID("$tcsh: sh.err.c,v 3.50 2007/09/28 20:25:15 christos Exp $")
+RCSID("$tcsh: sh.err.c,v 3.55 2011/02/25 23:58:34 christos Exp $")
 
 /*
  * C Shell
@@ -51,6 +51,7 @@
 #define ERR_NAME	0x10000000
 #define ERR_SILENT	0x20000000
 #define ERR_OLD		0x40000000
+#define ERR_INTERRUPT	0x80000000
 
 #define ERR_SYNTAX	0
 #define ERR_NOTALLOWED	1
@@ -187,7 +188,8 @@
 #define ERR_BADJOB	132
 #define ERR_INVALID	133
 #define ERR_BADCOLORVAR	134
-#define NO_ERRORS	135
+#define ERR_EOF		135
+#define NO_ERRORS	136
 
 static const char *elst[NO_ERRORS] INIT_ZERO_STRUCT;
 
@@ -364,6 +366,7 @@
     elst[ERR_READONLY] = CSAVS(1, 135, "$%S is read-only");
     elst[ERR_BADJOB] = CSAVS(1, 136, "No such job (badjob)");
     elst[ERR_BADCOLORVAR] = CSAVS(1, 137, "Unknown colorls variable `%c%c'");
+    elst[ERR_EOF] = CSAVS(1, 138, "Unexpected end of file");
 }
 
 /* Cleanup data. */
@@ -448,6 +451,12 @@
     abort();
 }
 
+int
+cleanup_reset(void)
+{
+    return cleanup_sp > cleanup_mark;
+}
+
 void
 cleanup_until_mark(void)
 {
@@ -527,6 +536,7 @@
 {
     cleanup_until_mark();
     _reset();
+    abort();
 }
 
 /*
@@ -549,83 +559,9 @@
     }
 }
 
-/*
- * Print the error with the given id.
- *
- * Special ids:
- *	ERR_SILENT: Print nothing.
- *	ERR_OLD: Print the previously set error if one was there.
- *	         otherwise return.
- *	ERR_NAME: If this bit is set, print the name of the function
- *		  in bname
- *
- * This routine always resets or exits.  The flag haderr
- * is set so the routine who catches the unwind can propogate
- * it if they want.
- *
- * Note that any open files at the point of error will eventually
- * be closed in the routine process in sh.c which is the only
- * place error unwinds are ever caught.
- */
 void
-/*VARARGS*/
-stderror(unsigned int id, ...)
+fixerror(void)
 {
-    va_list va;
-    int flags;
-    int vareturn;
-
-    va_start(va, id);
-
-    /*
-     * Reset don't free flag for buggy os's
-     */
-    dont_free = 0;
-
-    flags = (int) id & ERR_FLAGS;
-    id &= ~ERR_FLAGS;
-
-    /* Pyramid's OS/x has a subtle bug in <varargs.h> which prevents calling
-     * va_end more than once in the same function. -- sterling at netcom.com
-     */
-    if (!((flags & ERR_OLD) && seterr == NULL)) {
-	vareturn = 0;	/* Don't return immediately after va_end */
-	if (id >= sizeof(elst) / sizeof(elst[0]))
-	    id = ERR_INVALID;
-
-
-	if (!(flags & ERR_SILENT)) {
-	    /*
-	     * Must flush before we print as we wish output before the error
-	     * to go * on (some form of) standard output, while output after
-	     * goes on (some * form of) diagnostic output. If didfds then
-	     * output will go to 1/2 * else to FSHOUT/FSHDIAG. See flush in
-	     * sh.print.c.
-	     */
-	    flush();/*FIXRESET*/
-	    haderr = 1;			/* Now to diagnostic output */
-	    if (flags & ERR_NAME)
-		xprintf("%s: ", bname);/*FIXRESET*/
-	    if ((flags & ERR_OLD)) {
-		/* Old error. */
-		xprintf("%s.\n", seterr);/*FIXRESET*/
-	    } else {
-		xvprintf(elst[id], va);/*FIXRESET*/
-		xprintf(".\n");/*FIXRESET*/
-	    }
-	}
-    } else {
-	vareturn = 1;	/* Return immediately after va_end */
-    }
-    va_end(va);
-    if (vareturn)
-	return;
-
-    if (seterr) {
-	xfree(seterr);
-	seterr = NULL;
-    }
-
     didfds = 0;			/* Forget about 0,1,2 */
     /*
      * Go away if -e or we are a child shell
@@ -644,5 +580,77 @@
     if (tpgrp > 0)
 	(void) tcsetpgrp(FSHTTY, tpgrp);
 #endif
-    reset();			/* Unwind */
 }
+
+/*
+ * Print the error with the given id.
+ *
+ * Special ids:
+ *	ERR_SILENT: Print nothing.
+ *	ERR_OLD: Print the previously set error
+ *	ERR_NAME: If this bit is set, print the name of the function
+ *		  in bname
+ *
+ * This routine always resets or exits.  The flag haderr
+ * is set so the routine who catches the unwind can propogate
+ * it if they want.
+ *
+ * Note that any open files at the point of error will eventually
+ * be closed in the routine process in sh.c which is the only
+ * place error unwinds are ever caught.
+ */
+void
+/*VARARGS*/
+stderror(unsigned int id, ...)
+{
+    va_list va;
+    int flags;
+
+    va_start(va, id);
+
+    /*
+     * Reset don't free flag for buggy os's
+     */
+    dont_free = 0;
+
+    flags = (int) id & ERR_FLAGS;
+    id &= ~ERR_FLAGS;
+
+    /* Pyramid's OS/x has a subtle bug in <varargs.h> which prevents calling
+     * va_end more than once in the same function. -- sterling at netcom.com
+     */
+    assert(!((flags & ERR_OLD) && seterr == NULL));
+
+    if (id >= sizeof(elst) / sizeof(elst[0]))
+	id = ERR_INVALID;
+
+    if (!(flags & ERR_SILENT)) {
+	/*
+	 * Must flush before we print as we wish output before the error
+	 * to go on (some form of) standard output, while output after
+	 * goes on (some form of) diagnostic output. If didfds then output
+	 * will go to 1/2 else to FSHOUT/FSHDIAG. See flush in sh.print.c.
+	 */
+	flush();/*FIXRESET*/
+	haderr = 1;		/* Now to diagnostic output */
+	if (flags & ERR_NAME)
+	    xprintf("%s: ", bname);/*FIXRESET*/
+	if ((flags & ERR_OLD)) {
+	    /* Old error. */
+	    xprintf("%s.\n", seterr);/*FIXRESET*/
+	} else {
+	    xvprintf(elst[id], va);/*FIXRESET*/
+	    xprintf(".\n");/*FIXRESET*/
+	}
+    }
+    va_end(va);
+
+    if (seterr) {
+	xfree(seterr);
+	seterr = NULL;
+    }
+
+    fixerror();
+
+    reset();		/* Unwind */
+}
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/sh.exec.c
--- a/head/contrib/tcsh/sh.exec.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/sh.exec.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/sh.exec.c,v 3.75 2009/06/25 21:15:37 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.exec.c,v 3.79 2011/02/25 23:58:34 christos Exp $ */
 /*
  * sh.exec.c: Search, find, and execute a command!
  */
@@ -32,7 +32,7 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: sh.exec.c,v 3.75 2009/06/25 21:15:37 christos Exp $")
+RCSID("$tcsh: sh.exec.c,v 3.79 2011/02/25 23:58:34 christos Exp $")
 
 #include "tc.h"
 #include "tw.h"
@@ -77,7 +77,7 @@
 /*
  * xhash is an array of hash buckets which are used to hash execs.  If
  * it is allocated (havhash true), then to tell if ``name'' is
- * (possibly) presend in the i'th component of the variable path, look
+ * (possibly) present in the i'th component of the variable path, look
  * at the [hashname(name)] bucket of size [hashwidth] bytes, in the [i
  * mod size*8]'th bit.  The cache size is defaults to a length of 1024
  * buckets, each 1 byte wide.  This implementation guarantees that
@@ -141,7 +141,7 @@
 /* Dummy search path for just absolute search when no path */
 static Char *justabs[] = {STRNULL, 0};
 
-static	void	pexerr		(void);
+static	void	pexerr		(void) __attribute__((__noreturn__));
 static	void	texec		(Char *, Char **);
 int	hashname	(Char *);
 static	int 	iscommand	(Char *);
@@ -149,9 +149,9 @@
 void
 doexec(struct command *t, int do_glob)
 {
-    Char *dp, **pv, **av, *sav;
+    Char *dp, **pv, **opv, **av, *sav;
     struct varent *v;
-    int slash, gflag;
+    int slash, gflag, rehashed;
     int hashval, i;
     Char   *blk[2];
 
@@ -253,9 +253,9 @@
      * command search.
      */
     if (v == NULL || v->vec == NULL || v->vec[0] == NULL || slash)
-	pv = justabs;
+	opv = justabs;
     else
-	pv = v->vec;
+	opv = v->vec;
     sav = Strspl(STRslash, *av);/* / command name for postpending */
 #ifndef VFORK
     cleanup_push(sav, xfree);
@@ -264,6 +264,9 @@
 #endif /* VFORK */
     hashval = havhash ? hashname(*av) : 0;
 
+    rehashed = 0;
+retry:
+    pv = opv;
     i = 0;
 #ifdef VFORK
     hits++;
@@ -313,6 +316,11 @@
 #ifdef VFORK
     hits--;
 #endif /* VFORK */
+    if (adrof(STRautorehash) && !rehashed && havhash && opv != justabs) {
+	dohash(NULL, NULL);
+	rehashed = 1;
+	goto retry;
+    }
 #ifndef VFORK
     cleanup_until(sav);
 #else /* VFORK */
@@ -719,11 +727,15 @@
 #if defined(_UWIN) || defined(__CYGWIN__)
 	    /* Turn foo.{exe,com,bat} into foo since UWIN's readdir returns
 	     * the file with the .exe, .com, .bat extension
+	     *
+	     * Same for Cygwin, but only for .exe and .com extension.
 	     */
 	    {
 		ssize_t	ext = strlen(dp->d_name) - 4;
 		if ((ext > 0) && (strcasecmp(&dp->d_name[ext], ".exe") == 0 ||
+#ifndef __CYGWIN__
 				  strcasecmp(&dp->d_name[ext], ".bat") == 0 ||
+#endif
 				  strcasecmp(&dp->d_name[ext], ".com") == 0)) {
 #ifdef __CYGWIN__
 		    /* Also store the variation with extension. */
@@ -801,19 +813,23 @@
 static int
 iscommand(Char *name)
 {
-    Char **pv;
+    Char **opv, **pv;
     Char *sav;
     struct varent *v;
     int slash = any(short2str(name), '/');
-    int hashval, i;
+    int hashval, rehashed, i;
 
     v = adrof(STRpath);
     if (v == NULL || v->vec == NULL || v->vec[0] == NULL || slash)
-	pv = justabs;
+	opv = justabs;
     else
-	pv = v->vec;
+	opv = v->vec;
     sav = Strspl(STRslash, name);	/* / command name for postpending */
     hashval = havhash ? hashname(name) : 0;
+
+    rehashed = 0;
+retry:
+    pv = opv;
     i = 0;
     do {
 	if (!slash && ABSOLUTEP(pv[0]) && havhash) {
@@ -842,6 +858,11 @@
 	pv++;
 	i++;
     } while (*pv);
+    if (adrof(STRautorehash) && !rehashed && havhash && opv != justabs) {
+	dohash(NULL, NULL);
+	rehashed = 1;
+	goto retry;
+    }
     xfree(sav);
     return 0;
 }
@@ -1063,7 +1084,7 @@
     const struct biltins *bptr;
     Char **pv;
     Char *sv;
-    int hashval, i, ex, rval = 0;
+    int hashval, rehashed, i, ex, rval = 0;
 
     if (prt && any(short2str(cmd), '/')) {
 	xprintf("%s", CGETS(13, 7, "where: / in command makes no sense\n"));
@@ -1115,6 +1136,8 @@
     sv = Strspl(STRslash, cmd);
     cleanup_push(sv, xfree);
 
+    rehashed = 0;
+retry:
     for (pv = var->vec, i = 0; pv && *pv; pv++, i++) {
 	if (havhash && !eq(*pv, STRdot)) {
 #ifdef FASTHASH
@@ -1143,6 +1166,11 @@
 		return rval;
 	}
     }
+    if (adrof(STRautorehash) && !rehashed && havhash) {
+	dohash(NULL, NULL);
+	rehashed = 1;
+	goto retry;
+    }
     cleanup_until(sv);
     return rval;
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/sh.exp.c
--- a/head/contrib/tcsh/sh.exp.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/sh.exp.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/sh.exp.c,v 3.53 2007/10/01 19:09:28 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.exp.c,v 3.58 2011/12/25 15:21:50 christos Exp $ */
 /*
  * sh.exp.c: Expression evaluations
  */
@@ -32,7 +32,7 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: sh.exp.c,v 3.53 2007/10/01 19:09:28 christos Exp $")
+RCSID("$tcsh: sh.exp.c,v 3.58 2011/12/25 15:21:50 christos Exp $")
 
 #include "tw.h"
 
@@ -57,24 +57,24 @@
 #define EQMATCH 7
 #define NOTEQMATCH 8
 
-static	int	 sh_access	(const Char *, int);
-static	int	 exp1		(Char ***, int);
-static	int	 exp2x		(Char ***, int);
-static	int	 exp2a		(Char ***, int);
-static	int	 exp2b		(Char ***, int);
-static	int	 exp2c		(Char ***, int);
-static	Char 	*exp3		(Char ***, int);
-static	Char 	*exp3a		(Char ***, int);
-static	Char 	*exp4		(Char ***, int);
-static	Char 	*exp5		(Char ***, int);
-static	Char 	*exp6		(Char ***, int);
-static	void	 evalav		(Char **);
-static	int	 isa		(Char *, int);
-static	int	 egetn		(Char *);
+static	int	   sh_access	(const Char *, int);
+static	tcsh_number_t  exp1		(Char ***, int);
+static	tcsh_number_t  exp2x	(Char ***, int);
+static	tcsh_number_t  exp2a	(Char ***, int);
+static	tcsh_number_t  exp2b	(Char ***, int);
+static	tcsh_number_t  exp2c	(Char ***, int);
+static	Char 	  *exp3		(Char ***, int);
+static	Char 	  *exp3a	(Char ***, int);
+static	Char 	  *exp4		(Char ***, int);
+static	Char 	  *exp5		(Char ***, int);
+static	Char 	  *exp6		(Char ***, int);
+static	void	   evalav	(Char **);
+static	int	   isa		(Char *, int);
+static	tcsh_number_t  egetn	(const Char *);
 
 #ifdef EDEBUG
-static	void	 etracc		(const char *, const Char *, Char ***);
-static	void	 etraci		(const char *, int, Char ***);
+static	void	   etracc	(const char *, const Char *, Char ***);
+static	void	   etraci	(const char *, tcsh_number_t, Char ***);
 #else /* !EDEBUG */
 #define etracc(A, B, C) ((void)0)
 #define etraci(A, B, C) ((void)0)
@@ -183,16 +183,16 @@
 #endif /* !POSIX */
 }
 
-int
+tcsh_number_t
 expr(Char ***vp)
 {
     return (exp0(vp, 0));
 }
 
-int
+tcsh_number_t
 exp0(Char ***vp, int ignore)
 {
-    int p1 = exp1(vp, ignore);
+    tcsh_number_t p1 = exp1(vp, ignore);
 
     etraci("exp0 p1", p1, vp);
     while (**vp && eq(**vp, STRor2)) {
@@ -212,14 +212,14 @@
     return (p1);
 }
 
-static int
+static tcsh_number_t
 exp1(Char ***vp, int ignore)
 {
-    int p1 = exp2x(vp, ignore);
+    tcsh_number_t p1 = exp2x(vp, ignore);
 
     etraci("exp1 p1", p1, vp);
     while (**vp && eq(**vp, STRand2)) {
-	int p2;
+	tcsh_number_t p2;
 
 	(*vp)++;
 	p2 = compat_expr ?
@@ -236,14 +236,14 @@
     return (p1);
 }
 
-static int
+static tcsh_number_t
 exp2x(Char ***vp, int ignore)
 {
-    int p1 = exp2a(vp, ignore);
+    tcsh_number_t p1 = exp2a(vp, ignore);
 
     etraci("exp2x p1", p1, vp);
     while (**vp && eq(**vp, STRor)) {
-	int p2;
+	tcsh_number_t p2;
 
 	(*vp)++;
 	p2 = compat_expr ?
@@ -259,14 +259,14 @@
     return (p1);
 }
 
-static int
+static tcsh_number_t
 exp2a(Char ***vp, int ignore)
 {
-    int p1 = exp2b(vp, ignore);
+    tcsh_number_t p1 = exp2b(vp, ignore);
 
     etraci("exp2a p1", p1, vp);
     while (**vp && eq(**vp, STRcaret)) {
-	int p2;
+	tcsh_number_t p2;
 
 	(*vp)++;
 	p2 = compat_expr ?
@@ -282,14 +282,14 @@
     return (p1);
 }
 
-static int
+static tcsh_number_t
 exp2b(Char ***vp, int ignore)
 {
-    int p1 = exp2c(vp, ignore);
+    tcsh_number_t p1 = exp2c(vp, ignore);
 
     etraci("exp2b p1", p1, vp);
     while (**vp && eq(**vp, STRand)) {
-	int p2;
+	tcsh_number_t p2;
 
 	(*vp)++;
 	p2 = compat_expr ?
@@ -305,12 +305,12 @@
     return (p1);
 }
 
-static int
+static tcsh_number_t
 exp2c(Char ***vp, int ignore)
 {
     Char *p1 = exp3(vp, ignore);
     Char *p2;
-    int i;
+    tcsh_number_t i;
 
     cleanup_push(p1, xfree);
     etracc("exp2c p1", p1, vp);
@@ -352,7 +352,7 @@
 exp3(Char ***vp, int ignore)
 {
     Char *p1, *p2;
-    int i;
+    tcsh_number_t i;
 
     p1 = exp3a(vp, ignore);
     etracc("exp3 p1", p1, vp);
@@ -399,7 +399,7 @@
 {
     Char *p1, *p2;
     const Char *op;
-    int i;
+    tcsh_number_t i;
 
     p1 = exp4(vp, ignore);
     etracc("exp3a p1", p1, vp);
@@ -427,7 +427,7 @@
 exp4(Char ***vp, int ignore)
 {
     Char *p1, *p2;
-    int i = 0;
+    tcsh_number_t i = 0;
 
     p1 = exp5(vp, ignore);
     etracc("exp4 p1", p1, vp);
@@ -464,7 +464,7 @@
 exp5(Char ***vp, int ignore)
 {
     Char *p1, *p2;
-    int i = 0;
+    tcsh_number_t i = 0;
 
     p1 = exp6(vp, ignore);
     etracc("exp5 p1", p1, vp);
@@ -519,7 +519,8 @@
 static Char *
 exp6(Char ***vp, int ignore)
 {
-    int     ccode, i = 0;
+    tcsh_number_t ccode;
+    tcsh_number_t i = 0;
     Char *cp;
 
     if (**vp == 0)
@@ -626,12 +627,12 @@
     char *filnam;
 #endif /* S_IFLNK */
 
-    int i = 0;
+    tcsh_number_t i = 0;
     unsigned pmask = 0xffff;
     int altout = 0;
     Char *ft = cp, *dp, *ep, *strdev, *strino, *strF, *str, valtest = '\0',
     *errval = STR0;
-    char *string, string0[8];
+    char *string, string0[22 + MB_LEN_MAX + 1];	// space for 64 bit octal
     time_t footime;
     struct passwd *pw;
     struct group *gr;
@@ -851,11 +852,11 @@
 		 */
 
 	    case 'D':
-		i = (int) st->st_dev;
+		i = (tcsh_number_t) st->st_dev;
 		break;
 
 	    case 'I':
-		i = (int) st->st_ino;
+		i = (tcsh_number_t) st->st_ino;
 		break;
 		
 	    case 'F':
@@ -889,7 +890,7 @@
 		
 
 	    case 'N':
-		i = (int) st->st_nlink;
+		i = (tcsh_number_t) st->st_nlink;
 		break;
 
 	    case 'P':
@@ -907,7 +908,7 @@
 		    cleanup_until(ep);
 		    return(Strsave(str2short(pw->pw_name)));
 		}
-		i = (int) st->st_uid;
+		i = (tcsh_number_t) st->st_uid;
 		break;
 
 	    case 'G':
@@ -915,11 +916,11 @@
 		    cleanup_until(ep);
 		    return(Strsave(str2short(gr->gr_name)));
 		}
-		i = (int) st->st_gid;
+		i = (tcsh_number_t) st->st_gid;
 		break;
 
 	    case 'Z':
-		i = (int) st->st_size;
+		i = (tcsh_number_t) st->st_size;
 		break;
 
 	    case 'A': case 'M': case 'C':
@@ -932,7 +933,7 @@
 		    cleanup_until(ep);
 		    return(Strsave(strF));
 		}
-		i = (int) footime;
+		i = (tcsh_number_t) footime;
 		break;
 
 	    }
@@ -1024,8 +1025,8 @@
     return (0);
 }
 
-static int
-egetn(Char *cp)
+static tcsh_number_t
+egetn(const Char *cp)
 {
     if (*cp && *cp != '-' && !Isdigit(*cp))
 	stderror(ERR_NAME | ERR_EXPRESSION);
@@ -1036,9 +1037,13 @@
 
 #ifdef EDEBUG
 static void
-etraci(const char *str, int i, Char ***vp)
+etraci(const char *str, tcsh_number_t i, Char ***vp)
 {
-    xprintf("%s=%d\t", str, i);
+#ifdef HAVE_LONG_LONG
+    xprintf("%s=%lld\t", str, i);
+#else
+    xprintf("%s=%ld\t", str, i);
+#endif
     blkpr(*vp);
     xputchar('\n');
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/sh.file.c
--- a/head/contrib/tcsh/sh.file.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/sh.file.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/sh.file.c,v 3.36 2007/07/05 14:13:06 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.file.c,v 3.37 2010/02/09 20:21:49 christos Exp $ */
 /*
  * sh.file.c: File completion for csh. This file is not used in tcsh.
  */
@@ -33,7 +33,7 @@
 #include "sh.h"
 #include "ed.h"
 
-RCSID("$tcsh: sh.file.c,v 3.36 2007/07/05 14:13:06 christos Exp $")
+RCSID("$tcsh: sh.file.c,v 3.37 2010/02/09 20:21:49 christos Exp $")
 
 #if defined(FILEC) && defined(TIOCSTI)
 
@@ -594,7 +594,7 @@
 static int
 compare(const void *p, const void *q)
 {
-#ifdef WIDE_STRINGS
+#if defined (WIDE_STRINGS) && !defined (UTF16_STRING)
     errno = 0;
 
     return (wcscoll(*(Char *const *) p, *(Char *const *) q));
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/sh.func.c
--- a/head/contrib/tcsh/sh.func.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/sh.func.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/sh.func.c,v 3.153 2009/06/25 21:15:37 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.func.c,v 3.162 2011/02/26 00:07:06 christos Exp $ */
 /*
  * sh.func.c: csh builtin functions
  */
@@ -32,7 +32,7 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: sh.func.c,v 3.153 2009/06/25 21:15:37 christos Exp $")
+RCSID("$tcsh: sh.func.c,v 3.162 2011/02/26 00:07:06 christos Exp $")
 
 #include "ed.h"
 #include "tw.h"
@@ -41,8 +41,7 @@
 #include "nt.const.h"
 #endif /* WINNT_NATIVE */
 
-#if defined (NLS_CATALOGS) && defined(HAVE_ICONV) && defined(HAVE_NL_LANGINFO)
-#include <langinfo.h>
+#if defined (NLS_CATALOGS) && defined(HAVE_ICONV)
 static iconv_t catgets_iconv; /* Or (iconv_t)-1 */
 #endif
 
@@ -520,12 +519,13 @@
 
     USE(c);
     v++;
-    sp = cp = strip(*v);
-    if (!letter(*sp))
+    cp = sp = strip(*v);
+    if (!letter(*cp))
 	stderror(ERR_NAME | ERR_VARBEGIN);
-    while (*cp && alnum(*cp))
+    do {
 	cp++;
-    if (*cp)
+    } while (alnum(*cp));
+    if (*cp != '\0')
 	stderror(ERR_NAME | ERR_VARALNUM);
     cp = *v++;
     if (v[0][0] != '(' || v[blklen(v) - 1][0] != ')')
@@ -587,6 +587,7 @@
 	nwp->w_start = lineloc;
 	nwp->w_end.type = TCSH_F_SEEK;
 	nwp->w_end.f_seek = 0;
+	nwp->w_end.a_seek = 0;
 	nwp->w_next = whyles;
 	whyles = nwp;
 	zlast = TC_WHILE;
@@ -763,6 +764,7 @@
 	struct Ain a;
 	a.type = TCSH_F_SEEK;
 	a.f_seek = 0;
+	a.a_seek = 0;
 	bseek(&a);
     }
     cleanup_push(&word, Strbuf_cleanup);
@@ -963,9 +965,6 @@
 	}
     }
     
-    unreadc(c);
-    return histent;
-
 past:
     switch (Stype) {
 
@@ -1376,13 +1375,16 @@
     }
 
     vp = *v++;
+    lp = vp;
 
-    lp = vp;
- 
-    for (; *lp != '\0' ; lp++) {
-	if (*lp == '=')
-	    stderror(ERR_NAME | ERR_SYNTAX);
-    }
+    if (!letter(*lp))
+	stderror(ERR_NAME | ERR_VARBEGIN);
+    do {
+	lp++;
+    } while (alnum(*lp));
+    if (*lp != '\0')
+	stderror(ERR_NAME | ERR_VARALNUM);
+
     if ((lp = *v++) == 0)
 	lp = STRNULL;
 
@@ -1426,6 +1428,9 @@
 # ifdef LC_CTYPE
 	(void) setlocale(LC_CTYPE, ""); /* for iscntrl */
 # endif /* LC_CTYPE */
+# if defined(AUTOSET_KANJI)
+        autoset_kanji();
+# endif /* AUTOSET_KANJI */
 # ifdef NLS_CATALOGS
 #  ifdef LC_MESSAGES
 	(void) setlocale(LC_MESSAGES, "");
@@ -1859,8 +1864,17 @@
 #  endif
 # endif /* SYSVREL > 3 && BSDLIMIT */
 
-# if (defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)) && defined(RLIMIT_AS) && !defined(RLIMIT_VMEM)
-#  define RLIMIT_VMEM	RLIMIT_AS
+# if (defined(__linux__) || defined(__GNU__) || defined(__GLIBC__))
+#  if defined(RLIMIT_AS) && !defined(RLIMIT_VMEM)
+#   define RLIMIT_VMEM	RLIMIT_AS
+#  endif
+/*
+ * Oh well, <asm-generic/resource.h> has it, but <bits/resource.h> does not
+ * Linux headers: When the left hand does not know what the right hand does.
+ */
+#  if defined(RLIMIT_RTPRIO) && !defined(RLIMIT_RTTIME)
+#   define RLIMIT_RTTIME (RLIMIT_RTPRIO + 1)
+#  endif
 # endif
 
 struct limits limits[] = 
@@ -1937,12 +1951,38 @@
     { RLIMIT_SWAP,	"swapsize",	1024,	"kbytes"	}, 
 # endif /* RLIMIT_SWAP */ 
 
+# ifdef RLIMIT_LOCKS 
+    { RLIMIT_LOCKS,	"maxlocks",	1,	""		}, 
+# endif /* RLIMIT_LOCKS */ 
+
+# ifdef RLIMIT_SIGPENDING 
+    { RLIMIT_SIGPENDING,"maxsignal",	1,	""		}, 
+# endif /* RLIMIT_SIGPENDING */ 
+
+# ifdef RLIMIT_MSGQUEUE 
+    { RLIMIT_MSGQUEUE,	"maxmessage",	1,	""		}, 
+# endif /* RLIMIT_MSGQUEUE */ 
+
+# ifdef RLIMIT_NICE 
+    { RLIMIT_NICE,	"maxnice",	1,	""		}, 
+# endif /* RLIMIT_NICE */ 
+
+# ifdef RLIMIT_RTPRIO 
+    { RLIMIT_RTPRIO,	"maxrtprio",	1,	""		}, 
+# endif /* RLIMIT_RTPRIO */ 
+
+# ifdef RLIMIT_RTTIME 
+    { RLIMIT_RTTIME,	"maxrttime",	1,	"usec"		}, 
+# endif /* RLIMIT_RTTIME */ 
+
     { -1, 		NULL, 		0, 	NULL		}
 };
 
 static struct limits *findlim	(Char *);
 static RLIM_TYPE getval		(struct limits *, Char **);
+static int strtail		(Char *, const char *);
 static void limtail		(Char *, const char *);
+static void limtail2		(Char *, const char *, const char *);
 static void plim		(struct limits *, int);
 static int setlim		(struct limits *, int, RLIM_TYPE);
 
@@ -2050,29 +2090,43 @@
 	limtail(cp, "hours");
 	f *= 3600.0;
 	break;
+# endif /* RLIMIT_CPU */
     case 'm':
+# ifdef RLIMIT_CPU
 	if (lp->limconst == RLIMIT_CPU) {
 	    limtail(cp, "minutes");
 	    f *= 60.0;
 	    break;
 	}
-	*cp = 'm';
-	limtail(cp, "megabytes");
+# endif /* RLIMIT_CPU */
+	limtail2(cp, "megabytes", "mbytes");
 	f *= 1024.0 * 1024.0;
 	break;
+# ifdef RLIMIT_CPU
     case 's':
 	if (lp->limconst != RLIMIT_CPU)
 	    goto badscal;
 	limtail(cp, "seconds");
 	break;
 # endif /* RLIMIT_CPU */
+    case 'G':
+	*cp = 'g';
+	/*FALLTHROUGH*/
+    case 'g':
+# ifdef RLIMIT_CPU
+	if (lp->limconst == RLIMIT_CPU)
+	    goto badscal;
+# endif /* RLIMIT_CPU */
+	limtail2(cp, "gigabytes", "gbytes");
+	f *= 1024.0 * 1024.0 * 1024.0;
+	break;
     case 'M':
 # ifdef RLIMIT_CPU
 	if (lp->limconst == RLIMIT_CPU)
 	    goto badscal;
 # endif /* RLIMIT_CPU */
 	*cp = 'm';
-	limtail(cp, "megabytes");
+	limtail2(cp, "megabytes", "mbytes");
 	f *= 1024.0 * 1024.0;
 	break;
     case 'k':
@@ -2080,7 +2134,7 @@
 	if (lp->limconst == RLIMIT_CPU)
 	    goto badscal;
 # endif /* RLIMIT_CPU */
-	limtail(cp, "kbytes");
+	limtail2(cp, "kilobytes", "kbytes");
 	f *= 1024.0;
 	break;
     case 'b':
@@ -2104,25 +2158,34 @@
     return f == 0.0 ? (RLIM_TYPE) 0 : restrict_limit((f + 0.5));
 # else
     f += 0.5;
-    if (f > (float) RLIM_INFINITY)
+    if (f > (float) ((RLIM_TYPE) RLIM_INFINITY))
 	return ((RLIM_TYPE) RLIM_INFINITY);
     else
 	return ((RLIM_TYPE) f);
 # endif /* convex */
 }
 
+static int
+strtail(Char *cp, const char *str)
+{
+    while (*cp && *cp == (Char)*str)
+	cp++, str++;
+    return (*cp != '\0');
+}
+
 static void
 limtail(Char *cp, const char *str)
 {
-    const char *sp;
-
-    sp = str;
-    while (*cp && *cp == (Char)*str)
-	cp++, str++;
-    if (*cp)
-	stderror(ERR_BADSCALE, sp);
+    if (strtail(cp, str))
+	stderror(ERR_BADSCALE, str);
 }
 
+static void
+limtail2(Char *cp, const char *str1, const char *str2)
+{
+    if (strtail(cp, str1) && strtail(cp, str2))
+	stderror(ERR_BADSCALE, str1);
+}
 
 /*ARGSUSED*/
 static void
@@ -2564,13 +2627,24 @@
 
     if (adrof(STRcatalog) != NULL)
 	catalog = xasprintf("tcsh.%s", short2str(varval(STRcatalog)));
+#ifdef NL_CAT_LOCALE /* POSIX-compliant. */
+    /*
+     * Check if LC_MESSAGES is set in the environment and use it, if so.
+     * If not, fall back to the setting of LANG.
+     */
+    catd = catopen(catalog, tgetenv(STRLC_MESSAGES) ? NL_CAT_LOCALE : 0);
+#else /* pre-POSIX */
+# ifndef MCLoadBySet
+#  define MCLoadBySet 0
+#  endif
     catd = catopen(catalog, MCLoadBySet);
+#endif
     if (catalog != default_catalog)
 	xfree(catalog);
 #if defined(HAVE_ICONV) && defined(HAVE_NL_LANGINFO)
     /* xcatgets (), not CGETS, the charset name should be in ASCII anyway. */
     catgets_iconv = iconv_open (nl_langinfo (CODESET),
-				xcatgets(catd, 255, 1, "ASCII"));
+				xcatgets(catd, 255, 1, "UTF-8"));
 #endif /* HAVE_ICONV && HAVE_NL_LANGINFO */
 #endif /* NLS_CATALOGS */
 #ifdef WINNT_NATIVE
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/sh.glob.c
--- a/head/contrib/tcsh/sh.glob.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/sh.glob.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/sh.glob.c,v 3.76 2008/06/19 15:20:56 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.glob.c,v 3.82 2011/02/27 00:15:17 christos Exp $ */
 /*
  * sh.glob.c: Regular expression expansion
  */
@@ -32,7 +32,7 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: sh.glob.c,v 3.76 2008/06/19 15:20:56 christos Exp $")
+RCSID("$tcsh: sh.glob.c,v 3.82 2011/02/27 00:15:17 christos Exp $")
 
 #include "tc.h"
 #include "tw.h"
@@ -431,6 +431,12 @@
     char   *ptr;
     int     nonomatch = adrof(STRnonomatch) != 0, magic = 0, match = 0;
 
+    if (adrof(STRglobdot))
+       gflgs |= GLOB_DOT;
+
+    if (adrof(STRglobstar))
+       gflgs |= GLOB_STAR;
+
     if (!vl || !vl[0])
 	return(vl);
 
@@ -510,11 +516,11 @@
 	stderror(ERR_NAME | ERR_NOMATCH);
     }
  result:
-    if (vl[0] == NULL) {
+    if (vl && vl[0] == NULL) {
 	xfree(vl);
 	return (Strsave(STRNULL));
     }
-    if (vl[1]) 
+    if (vl && vl[1]) 
 	return (handleone(str, vl, action));
     else {
 	str = strip(*vl);
@@ -687,7 +693,7 @@
 static void
 backeval(struct blk_buf *bb, struct Strbuf *word, Char *cp, int literal)
 {
-    int icnt;
+    ssize_t icnt;
     Char c, *ip;
     struct command faket;
     int    hadnl;
@@ -775,7 +781,13 @@
 		stderror(ERR_OLD);
 	    alias(&paraml);
 	    t = syntax(paraml.next, &paraml, 0);
+	    if (t == NULL)
+		return;
 	    cleanup_push(t, syntax_cleanup);
+	    /* The F_BACKQ flag must set so the job output is correct if
+	     * printexitvalue is set.  If it's not set, the job output
+	     * will have "Exit N" appended where N is the exit status. */
+	    t->t_dflg = F_BACKQ|F_NOFORK;
 	    if (seterr)
 		stderror(ERR_OLD);
 #ifdef SIGTSTP
@@ -796,7 +808,7 @@
     c = 0;
     ip = NULL;
     do {
-	int     cnt = 0;
+	ssize_t     cnt = 0;
 	char   *tmp;
 
 	tmp = tibuf;
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/sh.h
--- a/head/contrib/tcsh/sh.h	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/sh.h	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/sh.h,v 3.150 2009/06/25 21:27:37 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.h,v 3.165 2011/04/14 18:25:25 christos Exp $ */
 /*
  * sh.h: Catch it all globals and includes file!
  */
@@ -75,6 +75,10 @@
 # define INIT_ZERO_STRUCT
 # define force_read xread
 #endif /*!WINNT_NATIVE */
+
+#if defined(KANJI) && defined(WIDE_STRINGS) && defined(HAVE_NL_LANGINFO) && defined(CODESET)
+#define AUTOSET_KANJI
+#endif
 /*
  * Sanity
  */
@@ -86,15 +90,21 @@
 # define BSDJOBS
 #endif 
 
+#define TMP_TEMPLATE ".XXXXXX"
+
 #ifdef SHORT_STRINGS
 # ifdef WIDE_STRINGS
 #include <wchar.h>
+#  ifdef UTF16_STRINGS
+typedef wint_t Char;
+#  else
 typedef wchar_t Char;
+#endif
 typedef unsigned long uChar;
 typedef wint_t eChar; /* Can contain any Char value or CHAR_ERR */
 #define CHAR_ERR WEOF /* Pretty please, use bit 31... */
 #define normal_mbtowc(PWC, S, N) rt_mbtowc(PWC, S, N)
-#define reset_mbtowc() IGNORE(mbtowc(NULL, NULL, 0))
+#define reset_mbtowc() TCSH_IGNORE(mbtowc(NULL, NULL, 0))
 # else
 typedef short Char;
 typedef unsigned short uChar;
@@ -114,10 +124,13 @@
 # define SAVE(a) (strsave(a))
 #endif
 
+#if !defined(__inline) && !defined(__GNUC__) && !defined(_MSC_VER)
+#define __inline
+#endif
 /* Elide unused argument warnings */
 #define USE(a)	(void) (a)
-#define IGNORE(a)	ignore((intptr_t)a)
-static inline void ignore(intptr_t a)
+#define TCSH_IGNORE(a)	tcsh_ignore((intptr_t)a)
+static __inline void tcsh_ignore(intptr_t a)
 {
     USE(a);
 }
@@ -219,6 +232,11 @@
 # define lstat lstat64
 #endif /* __HP_CXD_SPP && !__hpux */
 
+#ifdef HAVE_LONG_LONG
+typedef long long tcsh_number_t;
+#else
+typedef long tcsh_number_t;
+#endif
 /*
  * This macro compares the st_dev field of struct stat. On aix on ibmESA
  * st_dev is a structure, so comparison does not work. 
@@ -238,7 +256,6 @@
 # include <locale.h>
 #endif /* NLS */
 
-
 #if !defined(_MINIX) && !defined(_VMS_POSIX) && !defined(WINNT_NATIVE) && !defined(__MVS__)
 # include <sys/param.h>
 #endif /* !_MINIX && !_VMS_POSIX && !WINNT_NATIVE && !__MVS__ */
@@ -272,7 +289,7 @@
 #  else
 #   include <termio.h>
 #  endif /* _UWIN */
-#  if SYSVREL > 3
+#  if SYSVREL > 3 || defined(__linux__)
 #   undef TIOCGLTC	/* we don't need those, since POSIX has them */
 #   undef TIOCSLTC
 #   undef CSWTCH
@@ -293,7 +310,7 @@
  * redefines malloc(), so we define the following
  * to avoid it.
  */
-# if defined(SYSMALLOC) || defined(linux) || defined(__GNU__) || defined(__GLIBC__) || defined(sgi) || defined(_OSD_POSIX)
+# if defined(SYSMALLOC) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__) || defined(sgi) || defined(_OSD_POSIX)
 #  define NO_FIX_MALLOC
 #  include <stdlib.h>
 # else /* glibc */
@@ -311,7 +328,7 @@
 #endif /* POSIX && !WINNT_NATIVE */
 #include <limits.h>
 
-#if SYSVREL > 0 || defined(_IBMR2) || defined(_MINIX) || defined(linux) || defined(__GNU__) || defined(__GLIBC__)
+#if SYSVREL > 0 || defined(_IBMR2) || defined(_MINIX) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)
 # if !defined(pyr) && !defined(stellar)
 #  include <time.h>
 #  ifdef _MINIX
@@ -326,6 +343,12 @@
 #if !((defined(SUNOS4) || defined(_MINIX) /* || defined(DECOSF1) */) && defined(TERMIO))
 # if !defined(_VMS_POSIX) && !defined(WINNT_NATIVE)
 #  include <sys/ioctl.h>
+#  if SYSVREL > 3 || defined(__linux__)
+#   undef TIOCGLTC	/* we don't need those, since POSIX has them */
+#   undef TIOCSLTC
+#   undef CSWTCH
+#   define CSWTCH _POSIX_VDISABLE	/* So job control works */
+#  endif /* SYSVREL > 3 */
 # endif
 #endif 
 
@@ -345,9 +368,6 @@
 #if !defined(O_RDONLY) || !defined(O_NDELAY)
 # include <fcntl.h>
 #endif 
-#ifndef O_LARGEFILE
-# define O_LARGEFILE 0
-#endif
 
 #include <errno.h>
 
@@ -553,10 +573,12 @@
 EXTERN int    noexec IZERO;	/* Don't execute, just syntax check */
 EXTERN int    pjobs IZERO;	/* want to print jobs if interrupted */
 EXTERN int    setintr IZERO;	/* Set interrupts on/off -> Wait intr... */
+EXTERN int    handle_intr IZERO;/* Are we currently handling an interrupt? */
 EXTERN int    havhash IZERO;	/* path hashing is available */
 EXTERN int    editing IZERO;	/* doing filename expansion and line editing */
 EXTERN int    noediting IZERO;	/* initial $term defaulted to noedit */
 EXTERN int    bslash_quote IZERO;/* PWP: tcsh-style quoting?  (in sh.c) */
+EXTERN int    anyerror IZERO;	/* propagate errors from pipelines/backq */
 EXTERN int    compat_expr IZERO;/* csh-style expressions? */
 EXTERN int    isoutatty IZERO;	/* is SHOUT a tty */
 EXTERN int    isdiagatty IZERO;/* is SHDIAG a tty */
@@ -646,7 +668,7 @@
 EXTERN int   OLDSTD IZERO;	/* Old standard input (def for cmds) */
 
 
-#if SYSVREL == 4 && defined(_UTS)
+#if (SYSVREL == 4 && defined(_UTS)) || defined(__linux__)
 /* 
  * From: fadden at uts.amdahl.com (Andy McFadden)
  * we need sigsetjmp for UTS4, but not UTS2.1
@@ -664,7 +686,7 @@
 
 #ifdef SIGSETJMP
    typedef struct { sigjmp_buf j; } jmp_buf_t;
-# define setexit()  sigsetjmp(reslab.j)
+# define setexit()  sigsetjmp(reslab.j, 1)
 # define _reset()    siglongjmp(reslab.j, 1)
 #else
    typedef struct { jmp_buf j; } jmp_buf_t;
@@ -1035,11 +1057,12 @@
  */
 EXTERN struct Hist {
     struct wordent Hlex;
-    int     Hnum;
+    int     Hnum;		 /* eventno when inserted into history list  */
     int     Href;
     time_t  Htime;
     Char   *histline;
-    struct Hist *Hnext;
+    struct Hist *Hnext, *Hprev;         /* doubly linked list */
+    unsigned Hhash;                     /* hash value of command line */
 }       Histlist IZERO_STRUCT;
 
 EXTERN struct wordent paraml;	/* Current lexical word list */
@@ -1091,7 +1114,7 @@
 #define short2blk(a) 		saveblk(a)
 #define short2str(a) 		caching_strip(a)
 #else
-#ifdef WIDE_STRINGS
+#if defined(WIDE_STRINGS) && !defined(UTF16_STRINGS)
 #define Strchr(a, b)		wcschr(a, b)
 #define Strrchr(a, b)		wcsrchr(a, b)
 #define Strcat(a, b)  		wcscat(a, b)
@@ -1187,33 +1210,18 @@
 
 #ifndef WINNT_NATIVE
 # ifdef NLS_CATALOGS
-#  if defined(linux) || defined(__GNU__) || defined(__GLIBC__)
-#   include <locale.h>
-#   ifdef notdef
-#    include <localeinfo.h>	/* Has this changed ? */
-#   endif
+#  ifdef HAVE_FEATURES_H
 #   include <features.h>
 #  endif
-#  ifdef SUNOS4
-   /* Who stole my nl_types.h? :-( 
-    * All this stuff is in the man pages, but nowhere else?
-    * This does not link right now...
-    */
-   typedef void *nl_catd; 
-   extern const char * catgets (nl_catd, int, int, const char *);
-   nl_catd catopen (const char *, int);
-   int catclose (nl_catd);
-#  else
-#   ifdef __uxps__
-#    define gettxt gettxt_ds
-#   endif
-#   include <nl_types.h>
-#   ifdef __uxps__
-#    undef gettxt
-#   endif
+#  ifdef HAVE_NL_LANGINFO
+#   include <langinfo.h>
 #  endif
-#  ifndef MCLoadBySet
-#   define MCLoadBySet 0
+#  ifdef __uxps__
+#   define gettxt gettxt_ds
+#  endif
+#  include <nl_types.h>
+#  ifdef __uxps__
+#   undef gettxt
 #  endif
 EXTERN nl_catd catd;
 #  if defined(HAVE_ICONV) && defined(HAVE_NL_LANGINFO)
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/sh.hist.c
--- a/head/contrib/tcsh/sh.hist.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/sh.hist.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/sh.hist.c,v 3.40 2007/03/01 17:14:51 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.hist.c,v 3.53 2011/01/24 18:10:26 christos Exp $ */
 /*
  * sh.hist.c: Shell history expansions and substitutions
  */
@@ -32,8 +32,9 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: sh.hist.c,v 3.40 2007/03/01 17:14:51 christos Exp $")
+RCSID("$tcsh: sh.hist.c,v 3.53 2011/01/24 18:10:26 christos Exp $")
 
+#include <assert.h>
 #include "tc.h"
 
 extern int histvalid;
@@ -42,8 +43,6 @@
 
 static	int	heq	(const struct wordent *, const struct wordent *);
 static	void	hfree	(struct Hist *);
-static	void	dohist1	(struct Hist *, int *, int);
-static	void	phist	(struct Hist *, int);
 
 #define HIST_ONLY	0x01
 #define HIST_SAVE	0x02
@@ -57,10 +56,95 @@
  * C shell
  */
 
-void
-savehist(struct wordent *sp, int mflg)
+/* Static functions don't show up in gprof summaries.  So eliminate "static"
+ * modifier from some frequently called functions. */
+#ifdef PROF
+#define PG_STATIC
+#else
+#define PG_STATIC static
+#endif
+
+/* #define DEBUG_HIST 1 */
+
+static const int fastMergeErase = 1;
+static unsigned histCount = 0;		/* number elements on history list */
+static struct Hist *histTail = NULL;     /* last element on history list */
+static struct Hist *histMerg = NULL;	 /* last element merged by Htime */
+
+static void insertHistHashTable(struct Hist *, unsigned);
+
+
+/* Insert new element (hp) in history list after specified predecessor (pp). */
+static void
+hinsert(struct Hist *hp, struct Hist *pp)
+{
+    struct Hist *fp = pp->Hnext;        /* following element, if any */
+    hp->Hnext = fp, hp->Hprev = pp;
+    pp->Hnext = hp;
+    if (fp)
+        fp->Hprev = hp;
+    else
+        histTail = hp;                  /* meaning hp->Hnext == NULL */
+    histCount++;
+}
+
+/* Remove the entry from the history list. */
+static void
+hremove(struct Hist *hp)
+{
+    struct Hist *pp = hp->Hprev;
+    assert(pp);                         /* elements always have a previous */
+    pp->Hnext = hp->Hnext;
+    if (hp->Hnext)
+        hp->Hnext->Hprev = pp;
+    else
+        histTail = pp;                  /* we must have been last */
+    if (hp == histMerg)			/* deleting this hint from list */
+	histMerg = NULL;
+    assert(histCount > 0);
+    histCount--;
+}
+
+/* Prune length of history list to specified size by history variable. */
+PG_STATIC void
+discardExcess(int histlen)
 {
     struct Hist *hp, *np;
+    if (histTail == NULL) {
+        assert(histCount == 0);
+        return;                         /* no entries on history list */
+    }
+    /* Prune dummy entries from the front, then old entries from the back. If
+     * the list is still too long scan the whole list as before.  But only do a
+     * full scan if the list is more than 6% (1/16th) too long. */
+    while (histCount > (unsigned)histlen && (np = Histlist.Hnext)) {
+        if (eventno - np->Href >= histlen || histlen == 0)
+            hremove(np), hfree(np);
+        else
+            break;
+    }
+    while (histCount > (unsigned)histlen && (np = histTail) != &Histlist) {
+        if (eventno - np->Href >= histlen || histlen == 0)
+            hremove(np), hfree(np);
+        else
+            break;
+    }
+    if (histCount - (histlen >> 4) <= (unsigned)histlen)
+	return;				/* don't bother doing the full scan */
+    for (hp = &Histlist; histCount > (unsigned)histlen &&
+	(np = hp->Hnext) != NULL;)
+        if (eventno - np->Href >= histlen || histlen == 0)
+            hremove(np), hfree(np);
+        else
+            hp = np;
+}
+
+/* Add the command "sp" to the history list. */
+void
+savehist(
+  struct wordent *sp,
+  int mflg)				/* true if -m (merge) specified */
+{
     int histlen = 0;
     Char   *cp;
 
@@ -76,14 +160,445 @@
 	histlen = histlen * 10 + *cp++ - '0';
     }
     if (sp)
-	(void) enthist(++eventno, sp, 1, mflg);
-    for (hp = &Histlist; (np = hp->Hnext) != NULL;)
-	if (eventno - np->Href >= histlen || histlen == 0)
-	    hp->Hnext = np->Hnext, hfree(np);
-	else
-	    hp = np;
+        (void) enthist(++eventno, sp, 1, mflg, histlen);
+    discardExcess(histlen);
 }
 
+#define USE_JENKINS_HASH 1
+/* #define USE_ONE_AT_A_TIME 1 */
+#undef PRIME_LENGTH			/* no need for good HTL */
+
+#ifdef USE_JENKINS_HASH
+#define hashFcnName "lookup3"
+/* From:
+   lookup3.c, by Bob Jenkins, May 2006, Public Domain.
+   "...  You can use this free for any purpose.  It's in
+    the public domain.  It has no warranty."
+   http://burtleburtle.net/bob/hash/index.html
+ */
+
+#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
+#define mix(a,b,c) \
+{ \
+  a -= c;  a ^= rot(c, 4);  c += b; \
+  b -= a;  b ^= rot(a, 6);  a += c; \
+  c -= b;  c ^= rot(b, 8);  b += a; \
+  a -= c;  a ^= rot(c,16);  c += b; \
+  b -= a;  b ^= rot(a,19);  a += c; \
+  c -= b;  c ^= rot(b, 4);  b += a; \
+}
+#define final(a,b,c) \
+{ \
+  c ^= b; c -= rot(b,14); \
+  a ^= c; a -= rot(c,11); \
+  b ^= a; b -= rot(a,25); \
+  c ^= b; c -= rot(b,16); \
+  a ^= c; a -= rot(c, 4); \
+  b ^= a; b -= rot(a,14); \
+  c ^= b; c -= rot(b,24); \
+}
+
+struct hashValue		  /* State used to hash a wordend word list. */
+{
+    uint32_t a, b, c;
+};
+
+/* Set up the internal state */
+static void
+initializeHash(struct hashValue *h)
+{
+    h->a = h->b = h->c = 0xdeadbeef;
+}
+
+/* This does a partial hash of the Chars in a single word.  For efficiency we
+ * include 3 versions of the code to pack Chars into 32-bit words for the
+ * mixing function. */
+static void
+addWordToHash(struct hashValue *h, const Char *word)
+{
+    uint32_t a = h->a, b = h->b, c = h->c;
+#ifdef SHORT_STRINGS
+#ifdef WIDE_STRINGS
+    assert(sizeof(Char) >= 4);
+    while (1) {
+	unsigned k;
+	if ((k = (uChar)*word++) == 0) break; a += k;
+	if ((k = (uChar)*word++) == 0) break; b += k;
+	if ((k = (uChar)*word++) == 0) break; c += k;
+	mix(a, b, c);
+    }
+#else
+    assert(sizeof(Char) == 2);
+    while (1) {
+	unsigned k;
+	if ((k = (uChar)*word++) == 0) break; a += k;
+	if ((k = (uChar)*word++) == 0) break; a += k << 16;
+	if ((k = (uChar)*word++) == 0) break; b += k;
+	if ((k = (uChar)*word++) == 0) break; b += k << 16;
+	if ((k = (uChar)*word++) == 0) break; c += k;
+	if ((k = (uChar)*word++) == 0) break; c += k << 16;
+	mix(a, b, c);
+    }
+#endif
+#else
+    assert(sizeof(Char) == 1);
+    while (1) {
+	unsigned k;
+	if ((k = *word++) == 0) break; a += k;
+	if ((k = *word++) == 0) break; a += k << 8;
+	if ((k = *word++) == 0) break; a += k << 16;
+	if ((k = *word++) == 0) break; a += k << 24;
+	if ((k = *word++) == 0) break; b += k;
+	if ((k = *word++) == 0) break; b += k << 8;
+	if ((k = *word++) == 0) break; b += k << 16;
+	if ((k = *word++) == 0) break; b += k << 24;
+	if ((k = *word++) == 0) break; c += k;
+	if ((k = *word++) == 0) break; c += k << 8;
+	if ((k = *word++) == 0) break; c += k << 16;
+	if ((k = *word++) == 0) break; c += k << 24;
+	mix(a, b, c);
+    }
+#endif
+    h->a = a, h->b = b, h->c = c;
+}
+
+static void
+addCharToHash(struct hashValue *h, Char ch)
+{
+    /* The compiler (gcc -O2) seems to do a good job optimizing this without
+     * explicitly extracting into local variables. */
+    h->a += (uChar)ch;
+    mix(h->a, h->b, h->c);
+}
+
+static uint32_t
+finalizeHash(struct hashValue *h)
+{
+    uint32_t a = h->a, b = h->b, c = h->c;
+    final(a, b, c);
+    return c;
+}
+
+#elif USE_ONE_AT_A_TIME
+#define hashFcnName "one-at-a-time"
+/* This one is also from Bob Jenkins, but is slower but simpler than lookup3.
+   "...  The code given here are all public domain."
+   http://burtleburtle.net/bob/hash/doobs.html */
+
+#if 0
+ub4
+one_at_a_time(char *key, ub4 len)
+{
+  ub4   hash, i;
+  for (hash=0, i=0; i<len; ++i)
+  {
+    hash += key[i];
+    hash += (hash << 10);
+    hash ^= (hash >> 6);
+  }
+  hash += (hash << 3);
+  hash ^= (hash >> 11);
+  hash += (hash << 15);
+  return (hash & mask);
+}
+#endif
+
+struct hashValue { uint32_t h; };
+static void
+initializeHash(struct hashValue *h)
+{
+    h->h = 0;
+}
+
+static void
+addWordToHash(struct hashValue *h, const Char *word)
+{
+    unsigned k;
+    uint32_t hash = h->h;
+    while (k = (uChar)*word++)
+	hash += k, hash += hash << 10, hash ^= hash >> 6;
+    h->h = hash;
+}
+
+static void
+addCharToHash(struct hashValue *h, Char c)
+{
+    Char b[2] = { c, 0 };
+    addWordToHash(h, b);
+}
+
+static uint32_t
+finalizeHash(struct hashValue *h)
+{
+    unsigned hash = h->h;
+    hash += (hash << 3);
+    hash ^= (hash >> 11);
+    hash += (hash << 15);
+    return hash;
+}
+
+#else
+#define hashFcnName "add-mul"
+/* Simple multipy and add hash. */
+#define PRIME_LENGTH 1			/* need "good" HTL */
+struct hashValue { uint32_t h; };
+static void
+initializeHash(struct hashValue *h)
+{
+    h->h = 0xe13e2345;
+}
+
+static void
+addWordToHash(struct hashValue *h, const Char *word)
+{
+    unsigned k;
+    uint32_t hash = h->h;
+    while (k = (uChar)*word++)
+	hash = hash * 0x9e4167b9 + k;
+    h->h = hash;
+}
+
+static void
+addCharToHash(struct hashValue *h, Char c)
+{
+    h->h = h->h * 0x9e4167b9 + (uChar)c;
+}
+
+static uint32_t
+finalizeHash(struct hashValue *h)
+{
+    return h->h;
+}
+#endif
+
+static unsigned
+hashhist(struct wordent *h0)
+{
+    struct hashValue s;
+    struct wordent *firstWord = h0->next;
+    struct wordent *h = firstWord;
+    unsigned hash = 0;
+
+    initializeHash(&s);
+    for (; h != h0; h = h->next) {
+        if (h->word[0] == '\n')
+            break;                      /* don't hash newline */
+        if (h != firstWord)
+            addCharToHash(&s, ' ');	/* space between words */
+	addWordToHash(&s, h->word);
+    }
+    hash = finalizeHash(&s);
+    /* Zero means no hash value, so never return zero as a hash value. */
+    return hash ? hash : 0x7fffffff;	/* prime! */
+}
+
+#if 0
+unsigned
+hashStr(Char *str)
+{
+    struct hashValue s;
+    initializeHash(&s);
+    addWordToHash(&s, str);
+    return finalizeHash(&s);
+}
+#endif
+
+#ifdef PRIME_LENGTH			/* need good HTL */
+#define hash2tableIndex(hash, len) ((hash) % len)
+#else
+#define hash2tableIndex(hash, len) ((hash) & (len-1))
+#endif
+
+/* This code can be enabled to test the above hash functions for speed and
+ * collision avoidance.  The testing is enabled by "occasional" calls to
+ * displayHistStats(), see which. */
+#ifdef DEBUG_HIST
+
+#ifdef BSDTIMES
+static double
+doTiming(int start) {
+    static struct timeval beginTime;
+    if (start) {
+	gettimeofday(&beginTime, NULL);
+	return 0.0;
+    } else {
+	struct timeval now;
+	gettimeofday(&now, NULL);
+	return (now.tv_sec-beginTime.tv_sec) +
+	    (now.tv_usec-beginTime.tv_usec)/1e6;
+    }
+}
+#else
+static double
+doTiming(int start) {
+    USE(start);
+    return 0.0;
+}
+#endif
+
+static void
+generateHashes(int nChars, unsigned nWords, unsigned samples, unsigned *hashes,
+    unsigned length)
+{
+    if (nChars < 1)
+	return;
+    nWords = (nWords < 1) ? 1 : (nWords > 4) ? 4 : nWords;
+    Char *number = xmalloc((nChars+nWords)*sizeof(Char));
+    struct wordent word[4];
+    struct wordent base = { NULL, &word[0], &word[0] };
+    word[0].word = number, word[0].next = &base, word[0].prev = &base;
+    unsigned w = 0;			/* word number */
+    /* Generate multiple words of length 2, 3, 5, then all the rest. */
+    unsigned wBoundaries[4] = { 2-1, 2+3-1, 2+3+5-1, 0 };
+    /* Ensure the last word has at least 4 Chars in it. */
+    while (nWords >= 2 && nChars < (wBoundaries[nWords-2]+1) + 4)
+	nWords--;
+    wBoundaries[nWords-1] = 0xffffffff;	/* don't end word past this point */
+    unsigned i;
+    for (i = 0; i<nChars; i++) {
+	/* In deference to the gawd awful add-mul hash, we won't use the worse
+	 * case here (setting all Chars to 1), but assume mostly (or at least
+	 * initially) ASCII data. */
+	number[i+w] = '!';		/* 0x21 = 33 */
+
+	if (i == wBoundaries[w]) {	/* end a word here and move to next */
+	    w++;			/* next word */
+	    number[i+w] = 0;		/* terminate */
+	    word[w].word = &number[i+w+1];
+	    word[w].next = &base, word[w].prev = &word[w-1];
+	    word[w-1].next = &word[w], base.prev = &word[w];
+	}
+    }
+    /* w is the index of the last word actually created. */
+    number[nChars + w] = 0;		/* terminate last word */
+    unsigned timeLimit = !samples;
+    if (samples == 0)
+	samples = 1000000000;
+    doTiming(1);
+    double sec;
+    for (i = 0; i < samples; i++) {
+	/* increment 4 digit base 255 number; last characters vary fastest */
+	unsigned j = nChars-1 + w;
+	while (1) {
+	    if (++number[j] != 0)
+		break;
+	    /* else reset this digit and proceed to next one */
+	    number[j] = 1;
+	    if (&number[j] <= word[w].word)
+		break;			/* stop at beginning of last word */
+	    j--;
+	}
+	if (word[w].word[0] == '\n')
+	    word[w].word[0]++;		/* suppress newline character */
+	unsigned hash = hashhist(&base);
+	hashes[hash2tableIndex(hash, length)]++;
+	if (timeLimit && (i & 0x3ffff) == 0x3ffff) {
+	    sec = doTiming(0);
+	    if (sec > 10)
+		break;
+	}
+    }
+    if (i >= samples)
+	sec = doTiming(0);
+    else
+	samples = i;			/* number we actually did */
+    if (sec > 0.01) {
+	xprintf("Hash %d (%d Char %u words) with %s: %d nsec/hash, %d mcps\n",
+		samples, nChars, w+1, hashFcnName, (int)((sec/samples)*1e9),
+		(int)((double)samples*nChars/sec/1e6));
+    }
+}
+#endif /* DEBUG_HIST */
+
+#ifdef DEBUG_HIST
+static void
+testHash(void)
+{
+    static const Char STRtestHashTimings[] =
+	{ 't','e','s','t','H','a','s','h','T','i','m','i','n','g','s', 0 };
+    struct varent *vp = adrof(STRtestHashTimings);
+    if (vp && vp->vec) {
+	unsigned hashes[4];		/* dummy place to put hashes */
+	Char **vals = vp->vec;
+	while (*vals) {
+	    int length = getn(*vals);
+	    unsigned words =
+		(length < 5) ? 1 : (length < 25) ? 2 : (length < 75) ? 3 : 4;
+	    if (length > 0)
+		generateHashes(length, words, 0, hashes, 4);
+	    vals++;
+	}
+    }
+    unsigned length = 1024;
+#ifdef PRIME_LENGTH			/* need good HTL */
+    length = 1021;
+#endif
+    unsigned *hashes = xmalloc(length*sizeof(unsigned));
+    memset(hashes, 0, length*sizeof(unsigned));
+    /* Compute collision statistics for half full hashes modulo "length". */
+    generateHashes(4, 1, length/2, hashes, length);
+    /* Evaluate collisions by comparing occupancy rates (mean value 0.5).
+     * One bin for each number of hits. */
+    unsigned bins[155];
+    memset(bins, 0, sizeof(bins));
+    unsigned highest = 0;
+    unsigned i;
+    for (i = 0; i<length; i++) {
+	unsigned hits = hashes[i];
+	if (hits >= sizeof(bins)/sizeof(bins[0])) /* clip */
+	    hits = highest = sizeof(bins)/sizeof(bins[0]) - 1;
+	if (hits > highest)
+	    highest = hits;
+	bins[hits]++;
+    }
+    xprintf("Occupancy of %d buckets by %d hashes %d Chars %d word with %s\n",
+	    length, length/2, 4, 1, hashFcnName);
+    for (i = 0; i <= highest; i++) {
+	xprintf(" %d buckets (%d%%) with %d hits\n",
+		bins[i], bins[i]*100/length, i);
+    }
+    /* Count run lengths to evaluate linear rehashing effectiveness.  Estimate
+     * a little corrupted by edge effects. */
+    memset(bins, 0, sizeof(bins));
+    highest = 0;
+    for (i = 0; hashes[i] == 0; i++);	/* find first occupied bucket */
+    unsigned run = 0;
+    unsigned rehashed = 0;
+    for (; i<length; i++) {
+	unsigned hits = hashes[i];
+	if (hits == 0 && rehashed > 0)
+	    hits = 1 && rehashed--;
+	else if (hits > 1)
+	    rehashed += hits-1;
+	if (hits)
+	    run++;
+	else {
+	    /* a real free slot, count it */
+	    if (run >= sizeof(bins)/sizeof(bins[0])) /* clip */
+		run = highest = sizeof(bins)/sizeof(bins[0]) - 1;
+	    if (run > highest)
+		highest = run;
+	    bins[run]++;
+	    run = 0;
+	}
+    }
+    /* Ignore the partial run at end as we ignored the beginning. */
+    double merit = 0.0, entries = 0;
+    for (i = 0; i <= highest; i++) {
+	entries += bins[i]*i;		/* total hashed objects */
+	merit += bins[i]*i*i;
+    }
+    xprintf("Rehash collision figure of merit %u (ideal=100), run lengths:\n",
+	    (int)(100.0*merit/entries));
+    for (i = 0; i <= highest; i++) {
+	if (bins[i] != 0)
+	    xprintf(" %d runs of length %d buckets\n", bins[i], i);
+    }
+    xfree(hashes);
+}
+#endif /* DEBUG_HIST */
+
+/* Compares two word lists for equality. */
 static int
 heq(const struct wordent *a0, const struct wordent *b0)
 {
@@ -98,40 +613,362 @@
 	    return (b == b0) ? 1 : 0;
 	if (b == b0)
 	    return 0;
-    } 
+    }
 }
 
+/* Renumber entries following p, which we will be deleting. */
+PG_STATIC void
+renumberHist(struct Hist *p)
+{
+    int n = p->Href;
+    while ((p = p->Hnext))
+        p->Href = n--;
+}
 
+/* The hash table is implemented as an array of pointers to Hist entries.  Each
+ * entry is located in the table using hash2tableIndex() and checking the
+ * following entries in case of a collision (linear rehash).  Free entries in
+ * the table are zero (0, NULL, emptyHTE).  Deleted entries that cannot yet be
+ * freed are set to one (deletedHTE).  The Hist.Hhash member is non-zero iff
+ * the entry is in the hash table.  When the hash table get too full, it is
+ * reallocated to be approximately twice the history length (see
+ * getHashTableSize). */
+static struct Hist **histHashTable = NULL;
+static unsigned histHashTableLength = 0; /* number of Hist pointers in table */
+
+static struct Hist * const emptyHTE = NULL;
+static struct Hist * const deletedHTE = (struct Hist *)1;
+
+static struct {
+    unsigned insertCount;
+    unsigned removeCount;
+    unsigned rehashes;
+    int deleted;
+} hashStats;
+
+#ifdef DEBUG_HIST
+void
+checkHistHashTable(int print)
+{
+    unsigned occupied = 0;
+    unsigned deleted = 0;
+    unsigned i;
+    for (i = 0; i<histHashTableLength; i++)
+	if (histHashTable[i] == emptyHTE)
+	    continue;
+	else if (histHashTable[i] == deletedHTE)
+	    deleted++;
+	else
+	    occupied++;
+    if (print)
+	xprintf("  found len %u occupied %u deleted %u\n",
+		histHashTableLength, occupied, deleted);
+    assert(deleted == hashStats.deleted);
+}
+
+static int doneTest = 0;
+
+/* Main entry point for displaying history statistics and hash function
+ * behavior. */
+void
+displayHistStats(const char *reason)
+{
+    /* Just hash statistics for now. */
+    xprintf("%s history hash table len %u count %u (deleted %d)\n", reason,
+	    histHashTableLength, histCount, hashStats.deleted);
+    xprintf("  inserts %u rehashes %u%% each\n",
+	    hashStats.insertCount,
+	    (hashStats.insertCount
+	     ? 100*hashStats.rehashes/hashStats.insertCount : 0));
+    xprintf("  removes %u net %u\n",
+	    hashStats.removeCount,
+	    hashStats.insertCount - hashStats.removeCount);
+    assert(hashStats.insertCount >= hashStats.removeCount);
+    checkHistHashTable(1);
+    memset(&hashStats, 0, sizeof(hashStats));
+    if (!doneTest) {
+	testHash();
+	doneTest = 1;
+    }
+}
+#else
+void
+displayHistStats(const char *reason)
+{
+    USE(reason);
+}
+#endif
+
+static void
+discardHistHashTable(void)
+{
+    if (histHashTable == NULL)
+        return;
+    displayHistStats("Discarding");
+    xfree(histHashTable);
+    histHashTable = NULL;
+}
+
+/* Computes a new hash table size, when the current one is too small. */
+static unsigned
+getHashTableSize(int histlen)
+{
+    unsigned target = histlen * 2;
+    unsigned e = 5;
+    unsigned size;
+    while ((size = 1<<e) < target)
+	e++;
+#ifdef PRIME_LENGTH			/* need good HTL */
+    /* Not all prime, but most are and none have factors smaller than 11. */
+    return size+15;
+#else
+    assert((size & (size-1)) == 0);	/* must be a power of two */
+    return size;
+#endif
+}
+
+/* Create the hash table or resize, if necessary. */
+static void
+createHistHashTable(int histlen)
+{
+    if (histlen == 0) {
+	discardHistHashTable();
+        return;
+    }
+    if (histlen < 0) {
+        histlen = getn(varval(STRhistory));
+	if (histlen == 0)
+	    return;			/* no need for hash table */
+	assert(histlen > 0);
+    }
+    if (histHashTable != NULL) {
+	if (histCount < histHashTableLength * 3 / 4)
+	    return;			/* good enough for now */
+	discardHistHashTable();		/* too small */
+    }
+    histHashTableLength = getHashTableSize(
+	histlen > (int)histCount ? histlen : (int)histCount);
+    histHashTable = xmalloc(histHashTableLength * sizeof(struct Hist *));
+    memset(histHashTable, 0, histHashTableLength * sizeof(struct Hist *));
+    assert(histHashTable[0] == emptyHTE);
+
+    /* Now insert all the entries on the history list into the hash table. */
+    {
+        struct Hist *hp;
+        for (hp = &Histlist; (hp = hp->Hnext) != NULL;) {
+            unsigned lpHash = hashhist(&hp->Hlex);
+            assert(!hp->Hhash || hp->Hhash == lpHash);
+            hp->Hhash = 0;              /* force insert to new hash table */
+            insertHistHashTable(hp, lpHash);
+        }
+    }
+}
+
+/* Insert np into the hash table.  We assume that np is already on the
+ * Histlist.  The specified hashval matches the new Hist entry but has not yet
+ * been assigned to Hhash (or the element is already on the hash table). */
+static void
+insertHistHashTable(struct Hist *np, unsigned hashval)
+{
+    unsigned rehashes = 0;
+    unsigned hi = 0;
+    if (!histHashTable)
+	return;
+    if (np->Hhash != 0) {
+        /* already in hash table */
+        assert(hashval == np->Hhash);
+        return;
+    }
+    assert(np != deletedHTE);
+    /* Find a free (empty or deleted) slot, using linear rehash. */
+    assert(histHashTable);
+    for (rehashes = 0;
+         ((hi = hash2tableIndex(hashval + rehashes, histHashTableLength)),
+          histHashTable[hi] != emptyHTE && histHashTable[hi] != deletedHTE);
+         rehashes++) {
+        assert(np != histHashTable[hi]);
+        if (rehashes >= histHashTableLength / 10) {
+            /* Hash table is full, so grow it.  We assume the create function
+             * will roughly double the size we give it.  Create initializes the
+             * new table with everything on the Histlist, so we are done when
+             * it returns.  */
+#ifdef DEBUG_HIST
+	    xprintf("Growing history hash table from %d ...",
+		histHashTableLength);
+	    flush();
+#endif
+            discardHistHashTable();
+            createHistHashTable(histHashTableLength);
+#ifdef DEBUG_HIST
+	    xprintf("to %d.\n", histHashTableLength);
+#endif
+            return;
+        }
+    }
+    /* Might be sensible to grow hash table if rehashes is "too big" here. */
+    if (histHashTable[hi] == deletedHTE)
+	hashStats.deleted--;
+    histHashTable[hi] = np;
+    np->Hhash = hashval;
+    hashStats.insertCount++;
+    hashStats.rehashes += rehashes;
+}
+
+/* Remove the 'np' entry from the hash table. */
+static void
+removeHistHashTable(struct Hist *np)
+{
+    unsigned hi = np->Hhash;
+    if (!histHashTable || !hi)
+        return;                         /* no hash table or not on it */
+    /* find desired entry */
+    while ((hi = hash2tableIndex(hi, histHashTableLength)),
+           histHashTable[hi] != emptyHTE) {
+        if (np == histHashTable[hi]) {
+	    unsigned i;
+	    unsigned deletes = 0;
+	    histHashTable[hi] = deletedHTE; /* dummy, but non-zero entry */
+	    /* now peek ahead to see if the dummies are really necessary. */
+	    i = 1;
+	    while (histHashTable[hash2tableIndex(hi+i, histHashTableLength)] ==
+		   deletedHTE)
+		i++;
+	    if (histHashTable[hash2tableIndex(hi+i, histHashTableLength)] ==
+		emptyHTE) {
+		/* dummies are no longer necessary placeholders. */
+		deletes = i;
+		while (i-- > 0) {
+		    histHashTable[hash2tableIndex(hi+i, histHashTableLength)] =
+			emptyHTE;
+		}
+	    }
+	    hashStats.deleted += 1 - deletes; /* delta deleted entries */
+	    hashStats.removeCount++;
+            return;
+        }
+        hi++;                           /* linear rehash */
+    }
+    assert(!"Hist entry not found in hash table");
+}
+
+/* Search the history hash table for a command matching lp, using hashval as
+ * its hash value. */
+static struct Hist *
+findHistHashTable(struct wordent *lp, unsigned hashval)
+{
+    unsigned deleted = 0;		/* number of deleted entries skipped */
+    unsigned hi = hashval;
+    struct Hist *hp;
+    if (!histHashTable)
+	return NULL;
+    while ((hi = hash2tableIndex(hi, histHashTableLength)),
+           (hp = histHashTable[hi]) != emptyHTE) {
+        if (hp == deletedHTE)
+	    deleted++;
+	else if (hp->Hhash == hashval && heq(lp, &(hp->Hlex)))
+            return hp;
+	if (deleted > (histHashTableLength>>4)) {
+	    /* lots of deletes, so we need a sparser table. */
+            discardHistHashTable();
+            createHistHashTable(histHashTableLength);
+	    return findHistHashTable(lp, hashval);
+	}
+        hi++;                           /* linear rehash */
+    }
+    return NULL;
+}
+
+/* When merge semantics are in use, find the approximate predecessor for the
+ * new entry, so that the Htime entries are decreasing.  Return the entry just
+ * before the first entry with equal times, so the caller can check for
+ * duplicates.  When pTime is not NULL, use it as a starting point for search,
+ * otherwise search from beginning (largest time value) of history list. */
+PG_STATIC struct Hist *
+mergeInsertionPoint(
+    struct Hist *np,                      /* new entry to be inserted */
+    struct Hist *pTime)                   /* hint about where to insert */
+{
+    struct Hist *pp, *p;
+    if (histTail && histTail->Htime >= np->Htime)
+	pTime = histTail;		/* new entry goes at the end */
+    if (histMerg && histMerg != &Histlist && histMerg != Histlist.Hnext) {
+	/* Check above and below previous insertion point, in case we're adding
+	 * sequential times in the middle of the list (e.g. history -M). */
+	if (histMerg->Htime >= np->Htime)
+	    pTime = histMerg;
+	else if (histMerg->Hprev->Htime >= np->Htime)
+	    pTime = histMerg->Hprev;
+    }
+    if (pTime) {
+        /* With hint, search up the list until Htime is greater.  We skip past
+         * the equal ones, too, so our caller can elide duplicates. */
+        pp = pTime;
+        while (pp != &Histlist && pp->Htime <= np->Htime)
+            pp = pp->Hprev;
+    } else
+        pp = &Histlist;
+    /* Search down the list while current entry's time is too large. */
+    while ((p = pp->Hnext) && (p->Htime > np->Htime))
+            pp = p;                     /* advance insertion point */
+    /* Remember recent position as hint for next time */
+    histMerg = pp;
+    return pp;
+}
+
+/* Bubble Hnum & Href in new entry down to pp through earlier part of list. */
+PG_STATIC void bubbleHnumHrefDown(struct Hist *np, struct Hist *pp)
+{
+    struct Hist *p;
+    for (p = Histlist.Hnext; p != pp->Hnext; p = p->Hnext) {
+        /* swap Hnum & Href values of p and np. */
+        int n = p->Hnum, r = p->Href;
+        p->Hnum = np->Hnum; p->Href = np->Href;
+        np->Hnum = n; np->Href = r;
+    }
+}
+
+/* Enter new command into the history list according to current settings. */
 struct Hist *
-enthist(int event, struct wordent *lp, int docopy, int mflg)
+enthist(
+  int event,				/* newly incremented global eventno */
+  struct wordent *lp,
+  int docopy,
+  int mflg,				/* true if merge requested */
+  int histlen)				/* -1 if unknown */
 {
-    struct Hist *p = NULL, *pp = &Histlist;
-    int n, r;
+    struct Hist *p = NULL, *pp = &Histlist, *pTime = NULL;
     struct Hist *np;
     const Char *dp;
-    
+    unsigned lpHash = 0;                /* non-zero if hashing entries */
+
     if ((dp = varval(STRhistdup)) != STRNULL) {
 	if (eq(dp, STRerase)) {
 	    /* masaoki at akebono.tky.hp.com (Kobayashi Masaoki) */
-	    struct Hist *px;
-	    for (p = pp; (px = p, p = p->Hnext) != NULL;)
-		if (heq(lp, &(p->Hlex))){
-		    px->Hnext = p->Hnext;
-		    if (Htime != 0 && p->Htime > Htime)
-			Htime = p->Htime;
-		    n = p->Href;
-		    hfree(p);
-		    for (p = px->Hnext; p != NULL; p = p->Hnext)
-			p->Href = n--;
-		    break;
-		}
+            createHistHashTable(histlen);
+            lpHash = hashhist(lp);
+            assert(lpHash != 0);
+            p = findHistHashTable(lp, lpHash);
+            if (p) {
+		if (Htime != 0 && p->Htime > Htime)
+		    Htime = p->Htime;
+                /* If we are merging, and the old entry is at the place we want
+                 * to insert the new entry, then remember the place. */
+                if (mflg && Htime != 0 && p->Hprev->Htime >= Htime)
+                    pTime = p->Hprev;
+		if (!fastMergeErase)
+		    renumberHist(p);	/* Reset Href of subsequent entries */
+                hremove(p);
+		hfree(p);
+                p = NULL;               /* so new entry is allocated below */
+	    }
 	}
 	else if (eq(dp, STRall)) {
-	    for (p = pp; (p = p->Hnext) != NULL;)
-		if (heq(lp, &(p->Hlex))) {
-		    eventno--;
-		    break;
-		}
+            createHistHashTable(histlen);
+            lpHash = hashhist(lp);
+            assert(lpHash != 0);
+            p = findHistHashTable(lp, lpHash);
+	    if (p)   /* p!=NULL, only update this entry's Htime below */
+		eventno--;		/* not adding a new event */
 	}
 	else if (eq(dp, STRprev)) {
 	    if (pp->Hnext && heq(lp, &(pp->Hnext->Hlex))) {
@@ -149,14 +986,15 @@
 	Htime = 0;
     }
     else
-	(void) time(&(np->Htime));
+        (void) time(&(np->Htime));
 
     if (p == np)
-	return np;
+        return np;                      /* reused existing entry */
 
+    /* Initialize the new entry. */
     np->Hnum = np->Href = event;
     if (docopy) {
-	copylex(&np->Hlex, lp);
+        copylex(&np->Hlex, lp);
 	if (histvalid)
 	    np->histline = Strsave(histline.s);
 	else
@@ -166,133 +1004,53 @@
 	np->Hlex.next = lp->next;
 	lp->next->prev = &np->Hlex;
 	np->Hlex.prev = lp->prev;
-	lp->prev->next = &np->Hlex;
-	np->histline = NULL;
+        lp->prev->next = &np->Hlex;
+        np->histline = NULL;
     }
-    if (mflg)
-      {
-        while ((p = pp->Hnext) && (p->Htime > np->Htime))
-	  pp = p;
-	while (p && p->Htime == np->Htime)
-	  {
-	    if (heq(&p->Hlex, &np->Hlex))
-	      {
-	        eventno--;
-		hfree(np);
-	        return (p);
-	      }
-	    pp = p;
-	    p = p->Hnext;
-	  }
-	for (p = Histlist.Hnext; p != pp->Hnext; p = p->Hnext)
-	  {
-	    n = p->Hnum; r = p->Href;
-	    p->Hnum = np->Hnum; p->Href = np->Href;
-	    np->Hnum = n; np->Href = r;
-	  }
-      }
-    np->Hnext = pp->Hnext;
-    pp->Hnext = np;
+    np->Hhash = 0;
+
+    /* The head of history list is the default insertion point.
+       If merging, advance insertion point, in pp, according to Htime. */
+    /* XXX -- In histdup=all, Htime values can be non-monotonic. */
+    if (mflg) {                         /* merge according to np->Htime */
+        pp = mergeInsertionPoint(np, pTime);
+        for (p = pp->Hnext; p && p->Htime == np->Htime; pp = p, p = p->Hnext) {
+            if (heq(&p->Hlex, &np->Hlex)) {
+                eventno--;              /* duplicate, so don't add new event */
+                hfree(np);
+                return (p);
+              }
+          }
+        /* pp is now the last entry with time >= to np. */
+	if (!fastMergeErase) {		/* renumber at end of loadhist */
+	    /* Before inserting np after pp, bubble its Hnum & Href values down
+	     * through the earlier part of list. */
+	    bubbleHnumHrefDown(np, pp);
+	}
+    }
+    else
+        pp = &Histlist;                 /* insert at beginning of history */
+    hinsert(np, pp);
+    if (lpHash && histlen != 0)		/* erase & all modes use hash table */
+        insertHistHashTable(np, lpHash);
+    else
+        discardHistHashTable();
     return (np);
 }
 
 static void
 hfree(struct Hist *hp)
 {
-
+    assert(hp != histMerg);
+    if (hp->Hhash)
+        removeHistHashTable(hp);
     freelex(&hp->Hlex);
     if (hp->histline)
-	xfree(hp->histline);
+        xfree(hp->histline);
     xfree(hp);
 }
 
-
-/*ARGSUSED*/
-void
-dohist(Char **vp, struct command *c)
-{
-    int     n, hflg = 0;
-
-    USE(c);
-    if (getn(varval(STRhistory)) == 0)
-	return;
-    while (*++vp && **vp == '-') {
-	Char   *vp2 = *vp;
-
-	while (*++vp2)
-	    switch (*vp2) {
-	    case 'c':
-		hflg |= HIST_CLEAR;
-		break;
-	    case 'h':
-		hflg |= HIST_ONLY;
-		break;
-	    case 'r':
-		hflg |= HIST_REV;
-		break;
-	    case 'S':
-		hflg |= HIST_SAVE;
-		break;
-	    case 'L':
-		hflg |= HIST_LOAD;
-		break;
-	    case 'M':
-	    	hflg |= HIST_MERGE;
-		break;
-	    case 'T':
-	    	hflg |= HIST_TIME;
-		break;
-	    default:
-		stderror(ERR_HISTUS, "chrSLMT");
-		break;
-	    }
-    }
-
-    if (hflg & HIST_CLEAR) {
-	struct Hist *np, *hp;
-	for (hp = &Histlist; (np = hp->Hnext) != NULL;)
-	    hp->Hnext = np->Hnext, hfree(np);
-    }
-
-    if (hflg & (HIST_LOAD | HIST_MERGE))
-	loadhist(*vp, (hflg & HIST_MERGE) ? 1 : 0);
-    else if (hflg & HIST_SAVE)
-	rechist(*vp, 1);
-    else {
-	if (*vp)
-	    n = getn(*vp);
-	else {
-	    n = getn(varval(STRhistory));
-	}
-	dohist1(Histlist.Hnext, &n, hflg);
-    }
-}
-
-static void
-dohist1(struct Hist *hp, int *np, int hflg)
-{
-    int    print = (*np) > 0;
-
-    for (; hp != 0; hp = hp->Hnext) {
-	if (setintr) {
-	    int old_pintr_disabled;
-
-	    pintr_push_enable(&old_pintr_disabled);
-	    cleanup_until(&old_pintr_disabled);
-	}
-	(*np)--;
-	if ((hflg & HIST_REV) == 0) {
-	    dohist1(hp->Hnext, np, hflg);
-	    if (print)
-		phist(hp, hflg);
-	    return;
-	}
-	if (*np >= 0)
-	    phist(hp, hflg);
-    }
-}
-
-static void
+PG_STATIC void
 phist(struct Hist *hp, int hflg)
 {
     if (hflg & HIST_ONLY) {
@@ -337,6 +1095,97 @@
     }
 }
 
+PG_STATIC void
+dophist(int n, int hflg)
+{
+    struct Hist *hp;
+    if (setintr) {
+	int old_pintr_disabled;
+
+	pintr_push_enable(&old_pintr_disabled);
+	cleanup_until(&old_pintr_disabled);
+    }
+    if ((hflg & HIST_REV) == 0) {
+	/* Since the history list is stored most recent first, non-reversing
+	 * print needs to print (backwards) up the list. */
+	if ((unsigned)n >= histCount)
+	    hp = histTail;
+	else {
+	    for (hp = Histlist.Hnext;
+		 --n > 0 && hp->Hnext != NULL;
+		 hp = hp->Hnext)
+		;
+	}
+	if (hp == NULL)
+	    return;			/* nothing to print */
+	for (; hp != &Histlist; hp = hp->Hprev)
+	    phist(hp, hflg);
+    } else {
+	for (hp = Histlist.Hnext; n-- > 0 && hp != NULL; hp = hp->Hnext)
+	    phist(hp, hflg);
+    }
+}
+
+/*ARGSUSED*/
+void
+dohist(Char **vp, struct command *c)
+{
+    int     n, hflg = 0;
+
+    USE(c);
+    if (getn(varval(STRhistory)) == 0)
+	return;
+    while (*++vp && **vp == '-') {
+	Char   *vp2 = *vp;
+
+	while (*++vp2)
+	    switch (*vp2) {
+	    case 'c':
+		hflg |= HIST_CLEAR;
+		break;
+	    case 'h':
+		hflg |= HIST_ONLY;
+		break;
+	    case 'r':
+		hflg |= HIST_REV;
+		break;
+	    case 'S':
+		hflg |= HIST_SAVE;
+		break;
+	    case 'L':
+		hflg |= HIST_LOAD;
+		break;
+	    case 'M':
+	    	hflg |= HIST_MERGE;
+		break;
+	    case 'T':
+	    	hflg |= HIST_TIME;
+		break;
+	    default:
+		stderror(ERR_HISTUS, "chrSLMT");
+		break;
+	    }
+    }
+    if (hflg & HIST_CLEAR) {
+        struct Hist *np, *hp;
+        for (hp = &Histlist; (np = hp->Hnext) != NULL;)
+            hremove(np), hfree(np);
+    }
+
+    if (hflg & (HIST_LOAD | HIST_MERGE))
+	loadhist(*vp, (hflg & HIST_MERGE) ? 1 : 0);
+    else if (hflg & HIST_SAVE)
+	rechist(*vp, 1);
+    else {
+	if (*vp)
+	    n = getn(*vp);
+	else {
+	    n = getn(varval(STRhistory));
+	}
+	dophist(n, hflg);
+    }
+}
+
 
 char *
 fmthist(int fmt, ptr_t ptr)
@@ -371,6 +1220,7 @@
     }
 }
 
+/* Save history before exiting the shell. */
 void
 rechist(Char *fname, int ref)
 {
@@ -424,10 +1274,11 @@
     if ((shist = adrof(STRsavehist)) != NULL && shist->vec != NULL)
 	if (shist->vec[1] && eq(shist->vec[1], STRmerge))
 	    loadhist(fname, 1);
+
     fp = xcreat(short2str(fname), 0600);
+    cleanup_until(fname);
     if (fp == -1) {
 	didfds = oldidfds;
-	cleanup_until(fname);
 	return;
     }
     ftmp = SHOUT;
@@ -437,10 +1288,10 @@
     xclose(fp);
     SHOUT = ftmp;
     didfds = oldidfds;
-    cleanup_until(fname);
 }
 
 
+/* This is the entry point for loading history data from a file. */
 void
 loadhist(Char *fname, int mflg)
 {
@@ -455,4 +1306,14 @@
 	loadhist_cmd[2] = STRtildothist;
 
     dosource(loadhist_cmd, NULL);
+
+    /* During history merging (enthist sees mflg set), we disable management of
+     * Hnum and Href (because fastMergeErase is true).  So now reset all the
+     * values based on the final ordering of the history list. */
+    if (mflg) {
+	int n = eventno;
+        struct Hist *hp = &Histlist;
+        while ((hp = hp->Hnext))
+	    hp->Hnum = hp->Href = n--;
+    }
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/sh.lex.c
--- a/head/contrib/tcsh/sh.lex.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/sh.lex.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/sh.lex.c,v 3.81 2009/06/25 21:15:37 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.lex.c,v 3.87 2011/01/24 17:48:15 christos Exp $ */
 /*
  * sh.lex.c: Lexical analysis into tokens
  */
@@ -32,7 +32,7 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: sh.lex.c,v 3.81 2009/06/25 21:15:37 christos Exp $")
+RCSID("$tcsh: sh.lex.c,v 3.87 2011/01/24 17:48:15 christos Exp $")
 
 #include "ed.h"
 
@@ -460,7 +460,13 @@
 		setexclp(exclnxt->word);
 	    continue;
 	}
-	c = readc(0);
+	c = readc(1);
+
+	/* Catch EOF in the middle of a line.  (An EOF at the beginning of
+	 * a line would have been processed by the readc(0) in lex().) */
+	if (c == CHAR_ERR)
+	    c = '\n';
+
 	if (c == '$' && (flag & DODOL)) {
 	    getdol();
 	    continue;
@@ -672,11 +678,11 @@
     eChar c;
 
     if (sc == 0) {
-	sc = getC(0);
-	if (sc != '{') {
-	    ungetC(sc);
-	    sc = 0;
-	}
+	c = getC(0);
+	if (c == '{')
+	    sc = (Char) c;
+	else
+	    ungetC(c);
     }
     quesarg = -1;
 
@@ -693,7 +699,7 @@
 	for (ip = hp->next->next; ip != hp->prev; ip = ip->next)
 	    dol++;
     left = 0, right = dol;
-    if (sc == HISTSUB) {
+    if (sc == HISTSUB && HISTSUB != '\0') {
 	ungetC('s'), unreadc(HISTSUB), c = ':';
 	goto subst;
     }
@@ -726,7 +732,7 @@
     exclc = right - left + 1;
     while (--left >= 0)
 	hp = hp->next;
-    if (sc == HISTSUB || c == ':') {
+    if ((sc == HISTSUB && HISTSUB != '\0') || c == ':') {
 	do {
 	    hp = getsub(hp);
 	    c = getC(0);
@@ -928,7 +934,7 @@
      * ANSI mode HP/UX compiler chokes on
      * return &enthist(HIST_PURGE, &lexi, 0)->Hlex;
      */
-    hst = enthist(HIST_PURGE, &lexi, 0, 0);
+    hst = enthist(HIST_PURGE, &lexi, 0, 0, -1);
     return &(hst->Hlex);
 }
 
@@ -1147,7 +1153,7 @@
     int     event;
     int    back = 0;
 
-    c = sc == HISTSUB ? (eChar)HIST : getC(0);
+    c = (sc == HISTSUB && HISTSUB != '\0') ? (eChar)HIST : getC(0);
     if (c == (eChar)HIST) {
 	if (alhistp)
 	    return (alhistp);
@@ -1258,7 +1264,7 @@
 	    lastev = hp->Hnum;
 	    return (&hp->Hlex);
 	}
-    np = putn(event);
+    np = putn((tcsh_number_t)event);
     seterror(ERR_NOEVENT, short2str(np));
     xfree(np);
     return (0);
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/sh.misc.c
--- a/head/contrib/tcsh/sh.misc.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/sh.misc.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/sh.misc.c,v 3.45 2006/10/14 17:57:21 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.misc.c,v 3.46 2010/05/08 00:41:58 christos Exp $ */
 /*
  * sh.misc.c: Miscelaneous functions
  */
@@ -32,7 +32,7 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: sh.misc.c,v 3.45 2006/10/14 17:57:21 christos Exp $")
+RCSID("$tcsh: sh.misc.c,v 3.46 2010/05/08 00:41:58 christos Exp $")
 
 static	int	renum	(int, int);
 static  Char  **blkend	(Char **);
@@ -60,6 +60,7 @@
     memset(p, 0, size);
 }
 
+#ifndef SHORT_STRINGS
 char *
 strnsave(const char *s, size_t len)
 {
@@ -70,6 +71,7 @@
     r[len] = '\0';
     return r;
 }
+#endif
 
 char   *
 strsave(const char *s)
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/sh.parse.c
--- a/head/contrib/tcsh/sh.parse.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/sh.parse.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/sh.parse.c,v 3.18 2006/03/02 18:46:44 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.parse.c,v 3.19 2011/03/30 16:21:37 christos Exp $ */
 /*
  * sh.parse.c: Interpret a list of tokens
  */
@@ -32,7 +32,7 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: sh.parse.c,v 3.18 2006/03/02 18:46:44 christos Exp $")
+RCSID("$tcsh: sh.parse.c,v 3.19 2011/03/30 16:21:37 christos Exp $")
 
 /*
  * C shell
@@ -677,6 +677,9 @@
     default:
 	break;
     }
+#ifdef DEBUG
+    memset(t, 0, sizeof(*t));
+#endif
     xfree(t);
 }
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/sh.print.c
--- a/head/contrib/tcsh/sh.print.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/sh.print.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/sh.print.c,v 3.33 2006/08/23 15:03:14 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.print.c,v 3.36 2011/05/25 20:17:20 christos Exp $ */
 /*
  * sh.print.c: Primitive Output routines.
  */
@@ -32,7 +32,7 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: sh.print.c,v 3.33 2006/08/23 15:03:14 christos Exp $")
+RCSID("$tcsh: sh.print.c,v 3.36 2011/05/25 20:17:20 christos Exp $")
 
 #include "ed.h"
 
@@ -222,7 +222,7 @@
 void
 flush(void)
 {
-    int unit;
+    int unit, oldexitset = exitset;
     static int interrupted = 0;
 
     /* int lmode; */
@@ -231,10 +231,16 @@
 	return;
     if (GettingInput && !Tty_raw_mode && linp < &linbuf[sizeof linbuf - 10])
 	return;
+    if (handle_intr)
+	exitset = 1;
+
     if (interrupted) {
 	interrupted = 0;
 	linp = linbuf;		/* avoid recursion as stderror calls flush */
-	stderror(ERR_SILENT);
+	if (handle_intr)
+	    fixerror();
+	else
+	    stderror(ERR_SILENT);
     }
     interrupted = 1;
     if (haderr)
@@ -279,6 +285,12 @@
 	 */
 	case ESTALE:
 #endif
+#ifdef ENOENT
+	/*
+	 * Deal with SoFS bogocity: returns ENOENT instead of ESTALE.
+	 */
+	case ENOENT:
+#endif
 	/*
 	 * Over our quota, writing the history file
 	 */
@@ -286,13 +298,18 @@
 	case EDQUOT:
 #endif
 	/* Nothing to do, but die */
-	    xexit(1);
-	    break;
+	    if (handle_intr == 0)
+		xexit(1);
+	    /*FALLTHROUGH*/
 	default:
-	    stderror(ERR_SILENT);
+	    if (handle_intr)
+		fixerror();
+	    else
+		stderror(ERR_SILENT);
 	    break;
 	}
 
+    exitset = oldexitset;
     linp = linbuf;
     interrupted = 0;
 }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/sh.proc.c
--- a/head/contrib/tcsh/sh.proc.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/sh.proc.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/sh.proc.c,v 3.109 2009/06/25 21:15:37 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.proc.c,v 3.121 2012/01/25 15:34:41 christos Exp $ */
 /*
  * sh.proc.c: Job manipulations
  */
@@ -32,7 +32,7 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: sh.proc.c,v 3.109 2009/06/25 21:15:37 christos Exp $")
+RCSID("$tcsh: sh.proc.c,v 3.121 2012/01/25 15:34:41 christos Exp $")
 
 #include "ed.h"
 #include "tc.h"
@@ -47,8 +47,10 @@
 # define HZ 16
 #endif /* aiws */
 
-#if defined(_BSD) || (defined(IRIS4D) && __STDC__) || defined(__lucid) || defined(linux) || defined(__GNU__) || defined(__GLIBC__)
-# define BSDWAIT
+#if defined(_BSD) || (defined(IRIS4D) && __STDC__) || defined(__lucid) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)
+# if !defined(__ANDROID__)
+#  define BSDWAIT
+# endif
 #endif /* _BSD || (IRIS4D && __STDC__) || __lucid || glibc */
 #ifndef WTERMSIG
 # define WTERMSIG(w)	(((union wait *) &(w))->w_termsig)
@@ -188,7 +190,7 @@
         (setintr && (intty || insource) ? WNOHANG | WUNTRACED : WNOHANG), &ru);
 #   else
     /* both a wait3 and rusage */
-#    if !defined(BSDWAIT) || defined(NeXT) || defined(MACH) || defined(linux) || defined(__GNU__) || defined(__GLIBC__) || (defined(IRIS4D) && SYSVREL <= 3) || defined(__lucid) || defined(__osf__)
+#    if !defined(BSDWAIT) || defined(NeXT) || defined(MACH) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__) || (defined(IRIS4D) && SYSVREL <= 3) || defined(__lucid) || defined(__osf__)
     pid = wait3(&w,
        (setintr && (intty || insource) ? WNOHANG | WUNTRACED : WNOHANG), &ru);
 #    else /* BSDWAIT */
@@ -221,7 +223,11 @@
 #   ifdef hpux
     pid = wait3(&w.w_status, WNOHANG, 0);
 #   else	/* !hpux */
+#     ifndef BSDWAIT
+    pid = wait3(&w, WNOHANG, &ru);
+#     else
     pid = wait3(&w.w_status, WNOHANG, &ru);
+#     endif /* BSDWAIT */
 #   endif /* !hpux */
 #  else /* !BSDTIMES */
 #   ifdef ODT  /* For Sco Unix 3.2.0 or ODT 1.0 */
@@ -260,7 +266,7 @@
     jobdebug_flush();
 
     if ((pid == 0) || (pid == -1)) {
-	handle_pending_signals();
+	(void)handle_pending_signals();
 	jobdebug_xprintf(("errno == %d\n", errno));
 	if (errno == EINTR)
 	    goto loop;
@@ -367,6 +373,7 @@
 #ifdef notdef
 		jobflags & PAEXITED ||
 #endif /* notdef */
+		fp->p_cwd == NULL ||
 		!eq(dcwd->di_name, fp->p_cwd->di_name))) {
 	    /* PWP: print a newline after ^C */
 		if (jobflags & PINTERRUPTED) {
@@ -501,7 +508,7 @@
     pause_mask = oset;
     sigdelset(&pause_mask, SIGCHLD);
     for (;;) {
-	handle_pending_signals();
+	(void)handle_pending_signals();
 	jobflags = 0;
 	do
 	    jobflags |= fp->p_flags;
@@ -551,6 +558,11 @@
     reason = 0;
     fp = pp;
     do {
+	/* In case of pipelines only the result of the last
+	 * command should be taken in account */
+	if (!anyerror && !(fp->p_flags & PBRACE)
+		&& ((fp->p_flags & PPOU) || (fp->p_flags & PBACKQ)))
+	    continue;
 	if (fp->p_reason)
 	    reason = fp->p_flags & (PSIGNALED | PINTERRUPTED) ?
 		fp->p_reason | META : fp->p_reason;
@@ -562,7 +574,7 @@
     if ((reason != 0) && (adrof(STRprintexitvalue)) && 
 	(pp->p_flags & PBACKQ) == 0)
 	xprintf(CGETS(17, 2, "Exit %d\n"), reason);
-    reason_str = putn(reason);
+    reason_str = putn((tcsh_number_t)reason);
     cleanup_push(reason_str, xfree);
     setv(STRstatus, reason_str, VAR_READWRITE);
     cleanup_ignore(reason_str);
@@ -582,6 +594,7 @@
 {
     struct process *pp;
     sigset_t pause_mask;
+    int opintr_disabled, gotsig;
 
     USE(c);
     USE(v);
@@ -594,9 +607,14 @@
     for (pp = proclist.p_next; pp; pp = pp->p_next)
 	if (pp->p_procid &&	/* pp->p_procid == pp->p_jobid && */
 	    pp->p_flags & PRUNNING) {
-	    handle_pending_signals();
+	    (void)handle_pending_signals();
 	    sigsuspend(&pause_mask);
-	    handle_pending_signals();
+	    opintr_disabled = pintr_disabled;
+	    pintr_disabled = 0;
+	    gotsig = handle_pending_signals();
+	    pintr_disabled = opintr_disabled;
+	    if (gotsig)
+		break;
 	    goto loop;
 	}
     pjobs = 0;
@@ -719,6 +737,7 @@
 
     pp = xcalloc(1, sizeof(struct process));
     pp->p_procid = pid;
+    pp->p_parentid = shpgrp;
     pp->p_flags = ((t->t_dflg & F_AMPERSAND) ? 0 : PFOREGND) | PRUNNING;
     if (t->t_dflg & F_TIME)
 	pp->p_flags |= PPTIME;
@@ -726,6 +745,8 @@
 	pp->p_flags |= PBACKQ;
     if (t->t_dflg & F_HUP)
 	pp->p_flags |= PHUP;
+    if (t->t_dcom && t->t_dcom[0] && (*t->t_dcom[0] == '{'))
+	pp->p_flags |= PBRACE;
     if (cmdmax == 0)
 	morecommand(CMD_INIT);
     cmdp = cmdstr;
@@ -910,6 +931,7 @@
 
     if (pcurrjob && (pcurrjob->p_flags & (PFOREGND | PSTOPPED)) == 0) {
 	pp = pcurrjob;
+	pcurrjob = NULL;
 	while (pp->p_procid != pp->p_jobid)
 	    pp = pp->p_friends;
 	xprintf("[%d]", pp->p_index);
@@ -1870,7 +1892,7 @@
 	    sigdelset(&pause_mask, SIGCHLD);
 	    sigdelset(&pause_mask, SIGSYNCH);
 	    sigsuspend(&pause_mask);
-	    handle_pending_signals();
+	    (void)handle_pending_signals();
 	    if (sigaction(SIGSYNCH, &osa, NULL))
 		stderror(ERR_SYSTEM, "pfork parent: sigaction restore",
 			 strerror(errno));
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/sh.proc.h
--- a/head/contrib/tcsh/sh.proc.h	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/sh.proc.h	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/sh.proc.h,v 3.13 2009/06/19 16:35:33 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.proc.h,v 3.15 2011/04/14 18:25:25 christos Exp $ */
 /*
  * sh.proc.h: Process data structures and variables
  */
@@ -51,6 +51,7 @@
     unsigned long p_flags;	/* various job status flags */
     unsigned char p_reason;	/* reason for entering this state */
     int     p_index;		/* shorthand job index */
+    pid_t   p_parentid;		/* parent pid */
     pid_t   p_procid;
     pid_t   p_jobid;		/* pid of job leader */
     /* if a job is stopped/background p_jobid gives its pgrp */
@@ -102,6 +103,7 @@
 #define	PNEEDNOTE	(1<<15)	/* notify as soon as practical */
 #define PBACKQ		(1<<16)	/* Process is `` evaluation */
 #define PHUP		(1<<17)	/* Process is marked for SIGHUP on exit */
+#define PBRACE		(1<<18)	/* Process is {} evaluation */
 
 /* defines for arguments to pprint */
 #define	NUMBER		01
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/sh.sem.c
--- a/head/contrib/tcsh/sh.sem.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/sh.sem.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/sh.sem.c,v 3.80 2009/06/25 21:27:38 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.sem.c,v 3.86 2011/02/25 23:24:19 christos Exp $ */
 /*
  * sh.sem.c: I/O redirections and job forking. A touchy issue!
  *	     Most stuff with builtins is incorrect
@@ -33,7 +33,7 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: sh.sem.c,v 3.80 2009/06/25 21:27:38 christos Exp $")
+RCSID("$tcsh: sh.sem.c,v 3.86 2011/02/25 23:24:19 christos Exp $")
 
 #include "tc.h"
 #include "tw.h"
@@ -50,7 +50,7 @@
 #endif /* CLOSE_ON_EXEC */
 
 #if defined(__sparc__) || defined(sparc)
-# if !defined(MACH) && SYSVREL == 0 && !defined(Lynx) && !defined(BSD4_4) && !defined(linux) && !defined(__GNU__) && !defined(__GLIBC__)
+# if !defined(MACH) && SYSVREL == 0 && !defined(Lynx) && !defined(BSD4_4) && !defined(__linux__) && !defined(__GNU__) && !defined(__GLIBC__)
 #  include <vfork.h>
 # endif /* !MACH && SYSVREL == 0 && !Lynx && !BSD4_4 && !glibc */
 #endif /* __sparc__ || sparc */
@@ -232,8 +232,7 @@
 		    if (strchr("+-", t->t_dcom[1][0])) {
 			if (t->t_dcom[2]) {
 			    setname("nice");
-			    t->t_nice =
-				getn(t->t_dcom[1]);
+			    t->t_nice = (unsigned char)getn(t->t_dcom[1]);
 			    lshift(t->t_dcom, 2);
 			    t->t_dflg |= F_NICE;
 			}
@@ -629,10 +628,19 @@
 	 * possible stopping
 	 */
 	if (bifunc) {
-	    func(t, bifunc);
-	    if (forked)
+	    if (forked) {
+		func(t, bifunc);
 		exitstat();
-	    else {
+	    } else {
+		jmp_buf_t oldexit;
+		int ohaderr = haderr;
+
+		getexit(oldexit);
+		if (setexit() == 0)
+		    func(t, bifunc);
+		resexit(oldexit);
+		haderr = ohaderr;
+
 		if (adrof(STRprintexitvalue)) {
 		    int rv = getn(varval(STRstatus));
 		    if (rv != 0)
@@ -648,11 +656,16 @@
 	/*
 	 * For () commands must put new 0,1,2 in FSH* and recurse
 	 */
-	(void)close_on_exec(OLDSTD = dcopy(0, FOLDSTD), 1);
-	(void)close_on_exec(SHOUT = dcopy(1, FSHOUT), 1);
-	isoutatty = isatty(SHOUT);
-	(void)close_on_exec(SHDIAG = dcopy(2, FSHDIAG), 1);
-	isdiagatty = isatty(SHDIAG);
+	if ((OLDSTD = dcopy(0, FOLDSTD)) >= 0)
+	    (void)close_on_exec(OLDSTD, 1);
+	if ((SHOUT = dcopy(1, FSHOUT)) >= 0) {
+	    (void)close_on_exec(SHOUT, 1);
+	    isoutatty = isatty(SHOUT);
+	}
+	if ((SHDIAG = dcopy(2, FSHDIAG)) >= 0) {
+	    (void)close_on_exec(SHDIAG, 1);
+	    isdiagatty = isatty(SHDIAG);
+    	}
 	xclose(SHIN);
 	SHIN = -1;
 #ifndef CLOSE_ON_EXEC
@@ -664,31 +677,31 @@
 #endif /* !CLOSE_ON_EXEC */
 	didfds = 0;
 	wanttty = -1;
-	t->t_dspr->t_dflg |= t->t_dflg & F_NOINTERRUPT;
+	t->t_dspr->t_dflg |= t->t_dflg & (F_NOINTERRUPT | F_BACKQ);
 	execute(t->t_dspr, wanttty, NULL, NULL, do_glob);
 	exitstat();
 
     case NODE_PIPE:
 #ifdef BACKPIPE
 	t->t_dcdr->t_dflg |= F_PIPEIN | (t->t_dflg &
-			(F_PIPEOUT | F_AMPERSAND | F_NOFORK | F_NOINTERRUPT));
+	    (F_PIPEOUT | F_AMPERSAND | F_NOFORK | F_NOINTERRUPT | F_BACKQ));
 	execute(t->t_dcdr, wanttty, pv, pipeout, do_glob);
-	t->t_dcar->t_dflg |= F_PIPEOUT |
-	    (t->t_dflg & (F_PIPEIN | F_AMPERSAND | F_STDERR | F_NOINTERRUPT));
+	t->t_dcar->t_dflg |= F_PIPEOUT | (t->t_dflg &
+	    (F_PIPEIN | F_AMPERSAND | F_STDERR | F_NOINTERRUPT | F_BACKQ));
 	execute(t->t_dcar, wanttty, pipein, pv, do_glob);
 #else /* !BACKPIPE */
-	t->t_dcar->t_dflg |= F_PIPEOUT |
-	    (t->t_dflg & (F_PIPEIN | F_AMPERSAND | F_STDERR | F_NOINTERRUPT));
+	t->t_dcar->t_dflg |= F_PIPEOUT | (t->t_dflg &
+	    (F_PIPEIN | F_AMPERSAND | F_STDERR | F_NOINTERRUPT | F_BACKQ));
 	execute(t->t_dcar, wanttty, pipein, pv, do_glob);
 	t->t_dcdr->t_dflg |= F_PIPEIN | (t->t_dflg &
-			(F_PIPEOUT | F_AMPERSAND | F_NOFORK | F_NOINTERRUPT));
+	    (F_PIPEOUT | F_AMPERSAND | F_NOFORK | F_NOINTERRUPT | F_BACKQ));
 	execute(t->t_dcdr, wanttty, pv, pipeout, do_glob);
 #endif /* BACKPIPE */
 	break;
 
     case NODE_LIST:
 	if (t->t_dcar) {
-	    t->t_dcar->t_dflg |= t->t_dflg & F_NOINTERRUPT;
+	    t->t_dcar->t_dflg |= t->t_dflg & (F_NOINTERRUPT | F_BACKQ);
 	    execute(t->t_dcar, wanttty, NULL, NULL, do_glob);
 	    /*
 	     * In strange case of A&B make a new job after A
@@ -699,7 +712,7 @@
 	}
 	if (t->t_dcdr) {
 	    t->t_dcdr->t_dflg |= t->t_dflg &
-		(F_NOFORK | F_NOINTERRUPT);
+		(F_NOFORK | F_NOINTERRUPT | F_BACKQ);
 	    execute(t->t_dcdr, wanttty, NULL, NULL, do_glob);
 	}
 	break;
@@ -707,7 +720,7 @@
     case NODE_OR:
     case NODE_AND:
 	if (t->t_dcar) {
-	    t->t_dcar->t_dflg |= t->t_dflg & F_NOINTERRUPT;
+	    t->t_dcar->t_dflg |= t->t_dflg & (F_NOINTERRUPT | F_BACKQ);
 	    execute(t->t_dcar, wanttty, NULL, NULL, do_glob);
 	    if ((getn(varval(STRstatus)) == 0) !=
 		(t->t_dtyp == NODE_AND)) {
@@ -716,7 +729,7 @@
 	}
 	if (t->t_dcdr) {
 	    t->t_dcdr->t_dflg |= t->t_dflg &
-		(F_NOFORK | F_NOINTERRUPT);
+		(F_NOFORK | F_NOINTERRUPT | F_BACKQ);
 	    execute(t->t_dcdr, wanttty, NULL, NULL, do_glob);
 	}
 	break;
@@ -840,7 +853,7 @@
 	}
 	else if (flags & F_PIPEIN) {
 	    xclose(0);
-	    IGNORE(dup(pipein[0]));
+	    TCSH_IGNORE(dup(pipein[0]));
 	    xclose(pipein[0]);
 	    xclose(pipein[1]);
 	}
@@ -850,7 +863,7 @@
 	}
 	else {
 	    xclose(0);
-	    IGNORE(dup(OLDSTD));
+	    TCSH_IGNORE(dup(OLDSTD));
 #if defined(CLOSE_ON_EXEC) && defined(CLEX_DUPS)
 	    /*
 	     * PWP: Unlike Bezerkeley 4.3, FIONCLEX for Pyramid is preserved
@@ -903,12 +916,12 @@
     }
     else if (flags & F_PIPEOUT) {
 	xclose(1);
-	IGNORE(dup(pipeout[1]));
+	TCSH_IGNORE(dup(pipeout[1]));
 	is1atty = 0;
     }
     else {
 	xclose(1);
-	IGNORE(dup(SHOUT));
+	TCSH_IGNORE(dup(SHOUT));
 	is1atty = isoutatty;
 # if defined(CLOSE_ON_EXEC) && defined(CLEX_DUPS)
 	(void) close_on_exec(1, 0);
@@ -917,11 +930,11 @@
 
     xclose(2);
     if (flags & F_STDERR) {
-	IGNORE(dup(1));
+	TCSH_IGNORE(dup(1));
 	is2atty = is1atty;
     }
     else {
-	IGNORE(dup(SHDIAG));
+	TCSH_IGNORE(dup(SHDIAG));
 	is2atty = isdiagatty;
 # if defined(CLOSE_ON_EXEC) && defined(CLEX_DUPS)
 	(void) close_on_exec(2, 0);
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/sh.set.c
--- a/head/contrib/tcsh/sh.set.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/sh.set.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/sh.set.c,v 3.72 2007/09/28 21:02:03 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.set.c,v 3.83 2012/01/15 17:15:28 christos Exp $ */
 /*
  * sh.set.c: Setting and Clearing of variables
  */
@@ -32,7 +32,7 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: sh.set.c,v 3.72 2007/09/28 21:02:03 christos Exp $")
+RCSID("$tcsh: sh.set.c,v 3.83 2012/01/15 17:15:28 christos Exp $")
 
 #include "ed.h"
 #include "tw.h"
@@ -50,7 +50,7 @@
 static	struct varent 	*getvx		(Char *, int);
 static	Char		*xset		(Char *, Char ***);
 static	Char		*operate	(int, Char *, Char *);
-static	void	 	 putn1		(unsigned);
+static	void	 	 putn1		(tcsh_number_t);
 static	struct varent	*madrof		(Char *, struct varent *);
 static	void		 unsetv1	(struct varent *);
 static	void		 exportpath	(Char **);
@@ -76,13 +76,19 @@
 	Char *pn = varval(vp);
 
 	HIST = *pn++;
-	HISTSUB = *pn;
+	if (HIST)
+	    HISTSUB = *pn;
+	else
+	    HISTSUB = HIST;
     }
     else if (eq(vp, STRpromptchars)) {
 	Char *pn = varval(vp);
 
 	PRCH = *pn++;
-	PRCHROOT = *pn;
+	if (PRCH)
+	    PRCHROOT = *pn;
+	else
+	    PRCHROOT = PRCH;
     }
     else if (eq(vp, STRhistlit)) {
 	HistLit = 1;
@@ -100,6 +106,9 @@
     else if (eq(vp, STRloginsh)) {
 	loginsh = 1;
     }
+    else if (eq(vp, STRanyerror)) {
+	anyerror = 1;
+    }
     else if (eq(vp, STRsymlinks)) {
 	Char *pn = varval(vp);
 
@@ -184,7 +193,7 @@
 	tw_cmd_free();
     }
     else if (eq(vp, STRkillring)) {
-	SetKillRing(getn(varval(vp)));
+	SetKillRing((int)getn(varval(vp)));
     }
 #ifndef HAVENOUTMP
     else if (eq(vp, STRwatch)) {
@@ -222,7 +231,7 @@
 doset(Char **v, struct command *c)
 {
     Char *p;
-    Char   *vp, op;
+    Char   *vp;
     Char  **vecp;
     int    hadsub;
     int     subscr;
@@ -262,27 +271,26 @@
     do {
 	hadsub = 0;
 	vp = p;
-	if (letter(*p))
-	    for (; alnum(*p); p++)
-		continue;
-	if (vp == p || !letter(*vp))
+	if (!letter(*p))
 	    stderror(ERR_NAME | ERR_VARBEGIN);
+	do {
+	    p++;
+	} while (alnum(*p));
 	if (*p == '[') {
 	    hadsub++;
 	    p = getinx(p, &subscr);
 	}
-	if ((op = *p) != 0) {
-	    *p++ = 0;
-	    if (*p == 0 && *v && **v == '(')
+	if (*p != '\0' && *p != '=')
+	    stderror(ERR_NAME | ERR_VARALNUM);
+	if (*p == '=') {
+	    *p++ = '\0';
+	    if (*p == '\0' && *v != NULL && **v == '(')
 		p = *v++;
 	}
 	else if (*v && eq(*v, STRequal)) {
-	    op = '=', v++;
-	    if (*v)
+	    if (*++v != NULL)
 		p = *v++;
 	}
-	if (op && op != '=')
-	    stderror(ERR_NAME | ERR_SYNTAX);
 	if (eq(p, STRLparen)) {
 	    Char **e = v;
 
@@ -479,7 +487,7 @@
     Char   *vec[5];
     Char **v = vec;
     Char  **vecp = v;
-    int i;
+    tcsh_number_t i;
 
     if (op != '=') {
 	if (*vp)
@@ -500,10 +508,10 @@
 
 static Char *putp;
 
-Char   *
-putn(int n)
+Char *
+putn(tcsh_number_t n)
 {
-    Char nbuf[(CHAR_BIT * sizeof (n) + 2) / 3 + 2]; /* Enough even for octal */
+    Char nbuf[1024]; /* Enough even for octal */
 
     putp = nbuf;
     if (n < 0) {
@@ -516,17 +524,17 @@
 }
 
 static void
-putn1(unsigned n)
+putn1(tcsh_number_t n)
 {
     if (n > 9)
 	putn1(n / 10);
-    *putp++ = n % 10 + '0';
+    *putp++ = (Char)(n % 10 + '0');
 }
 
-int
-getn(Char *cp)
+tcsh_number_t
+getn(const Char *cp)
 {
-    int n;
+    tcsh_number_t n;
     int     sign;
     int base;
 
@@ -543,7 +551,7 @@
 	    stderror(ERR_NAME | ERR_BADNUM);
     }
 
-    if (cp[0] == '0' && cp[1])
+    if (cp[0] == '0' && cp[1] && is_set(STRparseoctal))
 	base = 8;
     else
 	base = 10;
@@ -751,13 +759,15 @@
     if (adrof(STRignoreeof) == 0)
 	numeof = 0;
     if (adrof(STRpromptchars) == 0) {
-	PRCH = '>';
+	PRCH = tcsh ? '>' : '%';
 	PRCHROOT = '#';
     }
     if (adrof(STRhistlit) == 0)
 	HistLit = 0;
     if (adrof(STRloginsh) == 0)
 	loginsh = 0;
+    if (adrof(STRanyerror) == 0)
+	anyerror = 0;
     if (adrof(STRwordchars) == 0)
 	word_chars = STR_WORD_CHARS;
     if (adrof(STRedit) == 0)
@@ -861,10 +871,11 @@
     balance(pp, f, 1);
 }
 
+/* Set variable name to NULL. */
 void
-setNS(Char *cp)
+setNS(const Char *varName)
 {
-    setcopy(cp, STRNULL, VAR_READWRITE);
+    setcopy(varName, STRNULL, VAR_READWRITE);
 }
 
 /*ARGSUSED*/
@@ -1091,7 +1102,8 @@
     }
 }
 
-#if defined(KANJI) && defined(SHORT_STRINGS) && defined(DSPMBYTE)
+#if defined(KANJI)
+# if defined(SHORT_STRINGS) && defined(DSPMBYTE)
 extern int dspmbyte_ls;
 
 void
@@ -1222,7 +1234,7 @@
 	{ STRLANGEUCJPB, STReuc },
 	{ STRLANGEUCKRB, STReuc },
 	{ STRLANGEUCZHB, STReuc },
-#ifdef linux
+#ifdef __linux__
 	{ STRLANGEUCJPC, STReuc },
 #endif
 	{ STRLANGSJIS, STRsjis },
@@ -1266,4 +1278,26 @@
 	}
     }
 }
+# elif defined(AUTOSET_KANJI)
+void
+autoset_kanji(void)
+{
+    char *codeset = nl_langinfo(CODESET);
+    
+    if (*codeset == '\0') {
+	if (adrof(STRnokanji) == NULL)
+	    setNS(STRnokanji);
+	return;
+    }
+
+    if (strcasestr(codeset, "SHIFT_JIS") == (char*)0) {
+	if (adrof(STRnokanji) == NULL)
+	    setNS(STRnokanji);
+	return;
+    }
+
+    if (adrof(STRnokanji) != NULL)
+	unsetv(STRnokanji);
+}
 #endif
+#endif
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/sh.time.c
--- a/head/contrib/tcsh/sh.time.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/sh.time.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/sh.time.c,v 3.33 2006/03/02 18:46:44 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.time.c,v 3.35 2010/12/09 15:39:29 christos Exp $ */
 /*
  * sh.time.c: Shell time keeping and printing.
  */
@@ -32,7 +32,7 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: sh.time.c,v 3.33 2006/03/02 18:46:44 christos Exp $")
+RCSID("$tcsh: sh.time.c,v 3.35 2010/12/09 15:39:29 christos Exp $")
 
 #ifdef SUNOS4
 # include <machine/param.h>
@@ -366,11 +366,11 @@
 #endif /* !BSDTIMES */
 #ifdef TDEBUG
     xprintf("es->tms_utime %lu bs->tms_utime %lu\n",
-	    es->tms_utime, bs->tms_utime);
+	    (unsigned long)es->tms_utime, (unsigned long)bs->tms_utime);
     xprintf("es->tms_stime %lu bs->tms_stime %lu\n",
-	    es->tms_stime, bs->tms_stime);
-    xprintf("ms	%lu e %lu b %lu\n", ms,	e, b);
-    xprintf("t %lu\n", t);
+	    (unsigned long)es->tms_stime, (unsigned long)bs->tms_stime);
+    xprintf("ms	%llu e %p b %p\n", (unsigned long long)ms, e, b);
+    xprintf("t %llu\n", (unsigned long long)t);
 #endif /* TDEBUG */
 
     if (vp && vp->vec && vp->vec[0] && vp->vec[1])
@@ -480,8 +480,8 @@
 #ifdef _OSD_POSIX
 		xprintf("0",0);
 #else
-		xprintf("%ld", t == 0 ?	0L :
-			IADJUST(r1->ru_ixrss - r0->ru_ixrss) / t);
+		xprintf("%lld", (long long)(t == 0 ?	0L :
+			IADJUST(r1->ru_ixrss - r0->ru_ixrss) / t));
 #endif
 		break;
 
@@ -489,9 +489,9 @@
 #ifdef _OSD_POSIX
 		xprintf("0",0);
 #else
-		xprintf("%ld", t == 0 ?	0L :
+		xprintf("%lld", (long long)(t == 0 ?	0L :
 			IADJUST(r1->ru_idrss + r1->ru_isrss -
-				(r0->ru_idrss +	r0->ru_isrss)) / t);
+				(r0->ru_idrss +	r0->ru_isrss)) / t));
 #endif
 		break;
 
@@ -499,23 +499,23 @@
 #ifdef _OSD_POSIX
 		xprintf("0",0);
 #else
-		xprintf("%ld", t == 0 ?	0L :
+		xprintf("%lld", (long long)(t == 0 ? 0L :
 			IADJUST((r1->ru_ixrss +	r1->ru_isrss + r1->ru_idrss) -
-			   (r0->ru_ixrss + r0->ru_idrss	+ r0->ru_isrss)) / t);
+			   (r0->ru_ixrss + r0->ru_idrss	+ r0->ru_isrss)) / t));
 #endif
 		break;
 #endif /* convex */
 	    case 'M':		/* max.	Resident Set Size */
 #ifdef SUNOS4
-		xprintf("%ld", pagetok(r1->ru_maxrss));
+		xprintf("%ld", (long)pagetok(r1->ru_maxrss));
 #else
 # ifdef	convex
-		xprintf("%ld", r1->ru_maxrss * 4L);
+		xprintf("%ld", (long)(r1->ru_maxrss * 4L));
 # else /* !convex */
 #  ifdef _OSD_POSIX
 		xprintf("0",0);
 #  else
-		xprintf("%ld", r1->ru_maxrss / 2L);
+		xprintf("%ld", (long)r1->ru_maxrss);
 #  endif
 # endif	/* convex */
 #endif /* SUNOS4 */
@@ -525,7 +525,7 @@
 #ifdef _OSD_POSIX
 		xprintf("0",0);
 #else
-		xprintf("%ld", r1->ru_majflt - r0->ru_majflt);
+		xprintf("%ld", (long)(r1->ru_majflt - r0->ru_majflt));
 #endif
 		break;
 
@@ -533,7 +533,7 @@
 #ifdef _OSD_POSIX
 		xprintf("0",0);
 #else
-		xprintf("%ld", r1->ru_minflt - r0->ru_minflt);
+		xprintf("%ld", (long)(r1->ru_minflt - r0->ru_minflt));
 #endif
 		break;
 
@@ -541,7 +541,7 @@
 #ifdef _OSD_POSIX
 		xprintf("0",0);
 #else
-		xprintf("%ld", r1->ru_inblock -	r0->ru_inblock);
+		xprintf("%ld", (long)(r1->ru_inblock - r0->ru_inblock));
 #endif
 		break;
 
@@ -549,7 +549,7 @@
 #ifdef _OSD_POSIX
 		xprintf("0",0);
 #else
-		xprintf("%ld", r1->ru_oublock -	r0->ru_oublock);
+		xprintf("%ld", (long)(r1->ru_oublock - r0->ru_oublock));
 #endif
 		break;
 
@@ -567,7 +567,7 @@
 #ifdef _OSD_POSIX
 		xprintf("0",0);
 #else
-		xprintf("%ld", r1->ru_msgrcv - r0->ru_msgrcv);
+		xprintf("%ld", (long)(r1->ru_msgrcv - r0->ru_msgrcv));
 #endif
 		break;
 
@@ -575,7 +575,7 @@
 #ifdef _OSD_POSIX
 		xprintf("0",0);
 #else
-		xprintf("%ld", r1->ru_msgsnd - r0->ru_msgsnd);
+		xprintf("%ld", (long)(r1->ru_msgsnd - r0->ru_msgsnd));
 #endif
 		break;
 
@@ -583,7 +583,7 @@
 #ifdef _OSD_POSIX
 		xprintf("0",0);
 #else
-		xprintf("%ld", r1->ru_nsignals - r0->ru_nsignals);
+		xprintf("%ld", (long)(r1->ru_nsignals - r0->ru_nsignals));
 #endif
 		break;
 
@@ -591,7 +591,7 @@
 #ifdef _OSD_POSIX
 		xprintf("0",0);
 #else
-		xprintf("%ld", r1->ru_nvcsw - r0->ru_nvcsw);
+		xprintf("%ld", (long)(r1->ru_nvcsw - r0->ru_nvcsw));
 #endif
 		break;
 
@@ -599,42 +599,42 @@
 #ifdef _OSD_POSIX
 		xprintf("0",0);
 #else
-		xprintf("%ld", r1->ru_nivcsw - r0->ru_nivcsw);
+		xprintf("%ld", (long)(r1->ru_nivcsw - r0->ru_nivcsw));
 #endif
 		break;
 #else /* BSDTIMES */
 # ifdef	_SEQUENT_
 	    case 'W':		/* number of swaps */
 		i = r1->ps_swap	- r0->ps_swap;
-		xprintf("%ld", i);
+		xprintf("%ld", (long)i);
 		break;
 
 	    case 'M':
-		xprintf("%ld", r1->ps_maxrss / 2);
+		xprintf("%ld", (long)r1->ps_maxrss);
 		break;
 
 	    case 'F':
-		xprintf("%ld", r1->ps_pagein - r0->ps_pagein);
+		xprintf("%ld", (long)(r1->ps_pagein - r0->ps_pagein));
 		break;
 
 	    case 'R':
-		xprintf("%ld", r1->ps_reclaim -	r0->ps_reclaim);
+		xprintf("%ld", (long)(r1->ps_reclaim -	r0->ps_reclaim));
 		break;
 
 	    case 'I':
-		xprintf("%ld", r1->ps_bread - r0->ps_bread);
+		xprintf("%ld", (long)(r1->ps_bread - r0->ps_bread));
 		break;
 
 	    case 'O':
-		xprintf("%ld", r1->ps_bwrite - r0->ps_bwrite);
+		xprintf("%ld", (long)(r1->ps_bwrite - r0->ps_bwrite));
 		break;
 
 	    case 'k':
-		xprintf("%ld", r1->ps_signal - r0->ps_signal);
+		xprintf("%ld", (long)(r1->ps_signal - r0->ps_signal));
 		break;
 
 	    case 'w':
-		xprintf("%ld", r1->ps_volcsw - r0->ps_volcsw);
+		xprintf("%ld", (long)(r1->ps_volcsw - r0->ps_volcsw));
 		break;
 
 	    case 'c':
@@ -642,35 +642,35 @@
 		break;
 
 	    case 'Z':
-		xprintf("%ld", r1->ps_zerofill - r0->ps_zerofill);
+		xprintf("%ld", (long)(r1->ps_zerofill - r0->ps_zerofill));
 		break;
 
 	    case 'i':
-		xprintf("%ld", r1->ps_pffincr -	r0->ps_pffincr);
+		xprintf("%ld", (long)(r1->ps_pffincr - r0->ps_pffincr));
 		break;
 
 	    case 'd':
-		xprintf("%ld", r1->ps_pffdecr -	r0->ps_pffdecr);
+		xprintf("%ld", (long)(r1->ps_pffdecr - r0->ps_pffdecr));
 		break;
 
 	    case 'Y':
-		xprintf("%ld", r1->ps_syscall -	r0->ps_syscall);
+		xprintf("%ld", (long)(r1->ps_syscall - r0->ps_syscall));
 		break;
 
 	    case 'l':
-		xprintf("%ld", r1->ps_lread - r0->ps_lread);
+		xprintf("%ld", (long)(r1->ps_lread - r0->ps_lread));
 		break;
 
 	    case 'm':
-		xprintf("%ld", r1->ps_lwrite - r0->ps_lwrite);
+		xprintf("%ld", (long)(r1->ps_lwrite - r0->ps_lwrite));
 		break;
 
 	    case 'p':
-		xprintf("%ld", r1->ps_phread - r0->ps_phread);
+		xprintf("%ld", (long)(r1->ps_phread - r0->ps_phread));
 		break;
 
 	    case 'q':
-		xprintf("%ld", r1->ps_phwrite -	r0->ps_phwrite);
+		xprintf("%ld", (long)(r1->ps_phwrite - r0->ps_phwrite));
 		break;
 # endif	/* _SEQUENT_ */
 #endif /* BSDTIMES */
@@ -687,7 +687,7 @@
     timeval_t td;
 
     tvsub(&td, t1, t0);
-    xprintf("%ld.%03ld", td.tv_sec, td.tv_usec / 1000L);
+    xprintf("%lld.%03ld", (long long)td.tv_sec, (long)td.tv_usec / 1000L);
 }
 
 static void
@@ -734,6 +734,7 @@
     val	= (eval	- bval)	* 100 /	clk_tck;
 #endif /* POSIX	*/
 
-    xprintf("%ld.%02ld", val / 100, val	- (val / 100 * 100));
+    xprintf("%lld.%02ld", (long long)(val / 100),
+	(long long)(val - (val / 100 * 100)));
 }
 #endif /* BSDTIMES || _SEQUENT_	*/
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/tc.alloc.c
--- a/head/contrib/tcsh/tc.alloc.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/tc.alloc.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/tc.alloc.c,v 3.46 2006/03/02 18:46:44 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.alloc.c,v 3.50 2011/12/30 20:55:24 christos Exp $ */
 /*
  * tc.alloc.c (Caltech) 2/21/82
  * Chris Kingsley, kingsley at cit-20.
@@ -39,8 +39,11 @@
  * SUCH DAMAGE.
  */
 #include "sh.h"
+#ifdef HAVE_MALLINFO
+#include <malloc.h>
+#endif
 
-RCSID("$tcsh: tc.alloc.c,v 3.46 2006/03/02 18:46:44 christos Exp $")
+RCSID("$tcsh: tc.alloc.c,v 3.50 2011/12/30 20:55:24 christos Exp $")
 
 #define RCHECK
 #define DEBUG
@@ -438,6 +441,28 @@
 #endif /* !lint */
 }
 
+/*
+ * On linux, _nss_nis_setnetgrent() calls this function to determine
+ * the usable size of the pointer passed, but this is not a portable
+ * API, so we cannot use our malloc replacement without providing one.
+ * Thanks a lot glibc!
+ */
+#ifdef __linux__
+#define M_U_S_CONST
+#else
+#define M_U_S_CONST
+#endif
+size_t malloc_usable_size(M_U_S_CONST void *);
+size_t
+malloc_usable_size(M_U_S_CONST void *ptr)
+{
+    const union overhead *op = (const union overhead *)
+	(((const char *) ptr) - MEMALIGN(sizeof(*op)));
+    if (op->ov_magic == MAGIC)
+	    return 1 << (op->ov_index + 2);
+    else
+	    return 0;
+}
 
 
 #ifndef lint
@@ -587,7 +612,7 @@
 	xprintf(" %4zd", j);
 	totfree += j * (1 << (i + 3));
     }
-    xprintf(CGETS(19, 9, "\nused:\t"));
+    xprintf("\n%s:\t", CGETS(19, 9, "used"));
     for (i = 0; i < NBUCKETS; i++) {
 	xprintf(" %4d", nmalloc[i]);
 	totused += nmalloc[i] * (1 << (i + 3));
@@ -598,13 +623,27 @@
 	    "\tAllocated memory from 0x%lx to 0x%lx.  Real top at 0x%lx\n"),
 	    (unsigned long) membot, (unsigned long) memtop,
 	    (unsigned long) sbrk(0));
-#else
+#else /* SYSMALLOC */
+#ifndef HAVE_MALLINFO
 #ifdef HAVE_SBRK
     memtop = sbrk(0);
 #endif /* HAVE_SBRK */
     xprintf(CGETS(19, 12, "Allocated memory from 0x%lx to 0x%lx (%ld).\n"),
 	    (unsigned long) membot, (unsigned long) memtop, 
 	    (unsigned long) (memtop - membot));
+#else /* HAVE_MALLINFO */
+    struct mallinfo mi;
+
+    mi = mallinfo();
+    xprintf(CGETS(19, 13, "%s current memory allocation:\n"), progname);
+    xprintf(CGETS(19, 14, "Total space allocated from system: %d\n"), mi.arena);
+    xprintf(CGETS(19, 15, "Number of non-inuse chunks: %d\n"), mi.ordblks);
+    xprintf(CGETS(19, 16, "Number of mmapped regions: %d\n"), mi.hblks);
+    xprintf(CGETS(19, 17, "Total space in mmapped regions: %d\n"), mi.hblkhd);
+    xprintf(CGETS(19, 18, "Total allocated space: %d\n"), mi.uordblks);
+    xprintf(CGETS(19, 19, "Total non-inuse space: %d\n"), mi.fordblks);
+    xprintf(CGETS(19, 20, "Top-most, releasable space: %d\n"), mi.keepcost);
+#endif /* HAVE_MALLINFO */
 #endif /* SYSMALLOC */
     USE(c);
     USE(v);
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/tc.const.c
--- a/head/contrib/tcsh/tc.const.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/tc.const.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/tc.const.c,v 3.91 2009/06/19 16:35:33 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.const.c,v 3.98 2011/04/14 18:25:26 christos Exp $ */
 /*
  * sh.const.c: String constants for tcsh.
  */
@@ -32,7 +32,7 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: tc.const.c,v 3.91 2009/06/19 16:35:33 christos Exp $")
+RCSID("$tcsh: tc.const.c,v 3.98 2011/04/14 18:25:26 christos Exp $")
 
 Char STRlogout[]	= { 'l', 'o', 'g', 'o', 'u', 't', '\0' };
 Char STRautologout[]	= { 'a', 'u', 't', 'o', 'l', 'o', 'g', 'o', 'u', 't', 
@@ -43,6 +43,7 @@
 #endif
 Char STRautomatic[]	= { 'a', 'u', 't', 'o', 'm', 'a', 't', 'i', 'c',
 			    '\0' };
+Char STRanyerror[]	= { 'a', 'n', 'y', 'e', 'r', 'r', 'o', 'r', '\0' };
 Char STRhangup[]	= { 'h', 'a', 'n', 'g', 'u', 'p', '\0' };
 Char STRaout[]		= { 'a', '.', 'o', 'u', 't', '\0' };
 Char STRtty[]		= { 't', 't', 'y', '\0' };
@@ -60,6 +61,7 @@
 Char STRNULL[]		= { '\0' };
 Char STRtcsh[]		= { 't', 'c', 's', 'h', '\0' };
 Char STRhome[]		= { 'h', 'o', 'm', 'e', '\0' };
+Char STReuser[]         = { 'e', 'u', 's', 'e', 'r', '\0'};
 Char STRuser[]		= { 'u', 's', 'e', 'r', '\0' };
 Char STRgroup[]		= { 'g', 'r', 'o', 'u', 'p', '\0' };
 #ifdef AFS
@@ -67,6 +69,7 @@
 #endif /* AFS */
 Char STRterm[]		= { 't', 'e', 'r', 'm', '\0' };
 Char STRversion[]	= { 'v', 'e', 'r', 's', 'i', 'o', 'n', '\0' };
+Char STReuid[]		= { 'e', 'u', 'i', 'd', '\0' };
 Char STRuid[]		= { 'u', 'i', 'd', '\0' };
 Char STRgid[]		= { 'g', 'i', 'd', '\0' };
 Char STRunknown[]	= { 'u', 'n', 'k', 'n', 'o', 'w', 'n', '\0' };
@@ -161,7 +164,7 @@
 			    '\0' };
 Char STRLANGEUCZH[]	= { '\0' };
 Char STRLANGEUCZHB[]	= { '\0' };
-#  elif defined(linux) || defined(__GNU__) || defined(__GLIBC__)
+#  elif defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)
 Char STRLANGEUCJP[]	= { 'j', 'a', '_', 'J', 'P', '.', 'E', 'U', 'C', '-',
 			    'J', 'P', '\0' };
 Char STRLANGEUCKR[]	= { 'k', 'o', '_', 'K', 'R', '.', 'E', 'U', 'C', '\0' };
@@ -249,8 +252,7 @@
 Char STRnormal[]	= { 'n', 'o', 'r', 'm', 'a', 'l', '\0' };
 Char STRsldtlogout[]	= { '/', '.', 'l', 'o', 'g', 'o', 'u', 't', '\0' };
 Char STRjobs[]		= { 'j', 'o', 'b', 's', '\0' };
-Char STRdeftcshprompt[]	= { '%', '#', ' ', '\0' };
-Char STRdefcshprompt[]	= { '%', '\0' };
+Char STRdefprompt[]	= { '%', '#', ' ', '\0' };
 Char STRmquestion[]	= { '%', 'R', '?' | QUOTE, ' ', '\0' };
 Char STRKCORRECT[]	= { 'C', 'O', 'R', 'R', 'E', 'C', 'T', '>', '%', 'R', 
 			    ' ', '(', 'y', '|', 'n', '|', 'e', '|', 'a', ')', 
@@ -305,6 +307,8 @@
 Char STRminus[]		= { '-', '\0' };
 Char STRnoglob[]	= { 'n', 'o', 'g', 'l', 'o', 'b', '\0' };
 Char STRnonomatch[]	= { 'n', 'o', 'n', 'o', 'm', 'a', 't', 'c', 'h', '\0' };
+Char STRglobstar[]	= { 'g', 'l', 'o', 'b', 's', 't', 'a', 'r', '\0' };
+Char STRglobdot[]	= { 'g', 'l', 'o', 'b', 'd', 'o', 't', '\0' };
 Char STRfakecom1[]	= { '`', ' ', '.', '.', '.', ' ', '`', '\0' };
 Char STRampm[]		= { 'a', 'm', 'p', 'm', '\0' };
 Char STRtime[]		= { 't', 'i', 'm', 'e', '\0' };
@@ -378,9 +382,11 @@
 Char STRcorrect[]	= { 'c', 'o', 'r', 'r', 'e', 'c', 't', '\0' };
 Char STRcmd[]		= { 'c', 'm', 'd', '\0' };
 Char STRall[]		= { 'a', 'l', 'l', '\0' };
+Char STRalways[]	= { 'a', 'l', 'w', 'a', 'y', 's', '\0' };
 Char STRerase[]		= { 'e', 'r', 'a', 's', 'e', '\0' };
 Char STRprev[]		= { 'p', 'r', 'e', 'v', '\0' };
 Char STRcomplete[]	= { 'c', 'o', 'm', 'p', 'l', 'e', 't', 'e', '\0' };
+Char STREnhance[]	= { 'E', 'n', 'h', 'a', 'n', 'c', 'e', '\0' };
 Char STRenhance[]	= { 'e', 'n', 'h', 'a', 'n', 'c', 'e', '\0' };
 Char STRigncase[]	= { 'i', 'g', 'n', 'c', 'a', 's', 'e', '\0' };
 Char STRautoexpand[]	= { 'a', 'u', 't', 'o', 'e', 'x', 'p', 'a', 'n', 'd',
@@ -388,6 +394,7 @@
 Char STRautocorrect[]	= { 'a', 'u', 't', 'o', 'c', 'o', 'r', 'r', 'e', 'c',
 			    't', '\0' };
 Char STRautolist[]	= { 'a', 'u', 't', 'o', 'l', 'i', 's', 't', '\0' };
+Char STRautorehash[]	= { 'a', 'u', 't', 'o', 'r', 'e', 'h', 'a', 's', 'h', '\0' };
 Char STRbeepcmd[]	= { 'b', 'e', 'e', 'p', 'c', 'm', 'd', '\0' };
 Char STRmatchbeep[]	= { 'm', 'a', 't', 'c', 'h', 'b', 'e', 'e', 'p', '\0' };
 Char STRnomatch[]	= { 'n', 'o', 'm', 'a', 't', 'c', 'h', '\0' };
@@ -505,3 +512,7 @@
 Char STReof[]		= { '^', 'D', '\b', '\b', '\0' };
 Char STRonlyhistory[]	= { 'o', 'n', 'l', 'y', 'h', 'i', 's', 't', 'o', 'r',
 			    'y', '\0' };
+Char STRparseoctal[]	= { 'p', 'a', 'r', 's', 'e', 'o', 'c', 't', 'a', 'l',
+			    '\0' };
+Char STRli[]		= { 'l', 'i', '#', '\0' };
+Char STRco[]		= { 'c', 'o', '#', '\0' };
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/tc.decls.h
--- a/head/contrib/tcsh/tc.decls.h	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/tc.decls.h	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/tc.decls.h,v 3.64 2008/05/14 20:10:30 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.decls.h,v 3.65 2010/02/09 20:26:13 christos Exp $ */
 /*
  * tc.decls.h: Function declarations from all the tcsh modules
  */
@@ -259,9 +259,9 @@
  * tc.str.c:
  */
 #ifdef WIDE_STRINGS
-extern	size_t		  one_mbtowc	(wchar_t *, const char *, size_t);
-extern	size_t		  one_wctomb	(char *, wchar_t);
-extern  int		  rt_mbtowc	(wchar_t *, const char *, size_t);
+extern	size_t		  one_mbtowc	(Char *, const char *, size_t);
+extern	size_t		  one_wctomb	(char *, Char);
+extern  int		  rt_mbtowc	(Char *, const char *, size_t);
 #else
 #define one_mbtowc(PWC, S, N) \
 	((void)(N), *(PWC) = (unsigned char)*(S), (size_t)1)
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/tc.disc.c
--- a/head/contrib/tcsh/tc.disc.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/tc.disc.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/tc.disc.c,v 3.17 2006/03/02 18:46:45 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.disc.c,v 3.18 2011/01/09 16:25:29 christos Exp $ */
 /*
  * tc.disc.c: Functions to set/clear line disciplines
  *
@@ -33,7 +33,7 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: tc.disc.c,v 3.17 2006/03/02 18:46:45 christos Exp $")
+RCSID("$tcsh: tc.disc.c,v 3.18 2011/01/09 16:25:29 christos Exp $")
 
 #ifdef OREO
 #include <compat.h>
@@ -43,7 +43,7 @@
 
 static int add_discipline = 0;	/* Did we add a line discipline	 */
 
-#if defined(IRIS4D) || defined(OREO) || defined(sonyrisc)
+#if defined(IRIS4D) || defined(OREO) || defined(sonyrisc) || defined(__ANDROID__)
 # define HAVE_DISC
 # ifndef POSIX
 static struct termio otermiob;
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/tc.func.c
--- a/head/contrib/tcsh/tc.func.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/tc.func.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/tc.func.c,v 3.139 2009/06/25 21:15:38 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.func.c,v 3.148 2011/12/14 16:36:44 christos Exp $ */
 /*
  * tc.func.c: New tcsh builtins.
  */
@@ -32,7 +32,7 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: tc.func.c,v 3.139 2009/06/25 21:15:38 christos Exp $")
+RCSID("$tcsh: tc.func.c,v 3.148 2011/12/14 16:36:44 christos Exp $")
 
 #include "ed.h"
 #include "ed.defns.h"		/* for the function names */
@@ -118,7 +118,7 @@
 		 * elsewhere.
 		 */
 		if ((*s & QUOTE)
-		    && (((*s & TRIM) == HIST) ||
+		    && (((*s & TRIM) == HIST && HIST != '\0') ||
 			(((*s & TRIM) == '\'') && (prev_c != '\\')) ||
 			(((*s & TRIM) == '\"') && (prev_c != '\\')) ||
 			(((*s & TRIM) == '\\') && (prev_c != '\\')))) {
@@ -174,7 +174,7 @@
     do {
 	*p++ = un % 10 + '0';
 	un /= 10;
-    } while ((pad && --min_digits > 0) || un != 0);
+    } while ((pad && (ssize_t)--min_digits > 0) || un != 0);
 
     res = xmalloc((p - buf + 2) * sizeof(*res));
     s = res;
@@ -671,7 +671,7 @@
     struct authorization *apw;
     extern char *crypt16 (const char *, const char *);
 
-# define XCRYPT(a, b) crypt16(a, b)
+# define XCRYPT(pw, a, b) crypt16(a, b)
 
     if ((pw = xgetpwuid(euid)) != NULL &&	/* effective user passwd  */
         (apw = getauthuid(euid)) != NULL) 	/* enhanced ultrix passwd */
@@ -681,7 +681,7 @@
 
     struct spwd *spw;
 
-# define XCRYPT(a, b) crypt(a, b)
+# define XCRYPT(pw, a, b) crypt(a, b)
 
     if ((pw = xgetpwuid(euid)) != NULL)	{	/* effective user passwd  */
 	errno = 0;
@@ -695,7 +695,12 @@
 
 #else
 
-#define XCRYPT(a, b) crypt(a, b)
+
+#ifdef __CYGWIN__
+# define XCRYPT(pw, a, b) cygwin_xcrypt(pw, a, b)
+#else
+# define XCRYPT(pw, a, b) crypt(a, b)
+#endif
 
 #if !defined(__MVS__)
     if ((pw = xgetpwuid(euid)) != NULL)	/* effective user passwd  */
@@ -727,7 +732,7 @@
 #endif
 	pp = xgetpass("Password:");
 
-	crpp = XCRYPT(pp, srpp);
+	crpp = XCRYPT(pw, pp, srpp);
 	if ((strcmp(crpp, srpp) == 0)
 #ifdef AFS
 	    || (ka_UserAuthenticateGeneral(KA_USERAUTH_VERSION,
@@ -1035,7 +1040,7 @@
     cleanup_until(&w);
     pendjob();
     /* Restore status */
-    setv(STRstatus, putn(status), VAR_READWRITE);
+    setv(STRstatus, putn((tcsh_number_t)status), VAR_READWRITE);
 }
 
 void
@@ -1635,7 +1640,7 @@
 # endif /* !EWOULDBLOCK || EWOULDBLOCK != EAGAIN */
 #endif /* POSIX && EAGAIN */
 
-	e = 0;
+	e = -1;
 #ifdef FDRETRY
 # ifdef F_SETFL
 /*
@@ -1683,19 +1688,17 @@
 	if (fcntl(fd, F_SETFL, e) == -1)
 	    return -1;
 	else 
-	    e = 1;
+	    e = 0;
 # endif /* F_SETFL */
 
 # ifdef FIONBIO
 	e = 0;
 	if (ioctl(fd, FIONBIO, (ioctl_t) &e) == -1)
 	    return -1;
-	else
-	    e = 1;
 # endif	/* FIONBIO */
 
 #endif /* FDRETRY */
-	return e ? 0 : -1;
+	return e;
 
     case EINTR:
 	return 0;
@@ -1928,7 +1931,7 @@
 				(ptr = strstr(domain, s)) != NULL) {
 			        char *cbuf;
 
-				cbuf = strspl(name, ptr);
+				cbuf = strspl(name, ptr + strlen(s));
 				if (getaddrinfo(cbuf, NULL, &hints, &res) != 0)
 				    res = NULL;
 				xfree(cbuf);
@@ -1939,6 +1942,7 @@
 		    if (res != NULL) {
 			if (res->ai_canonname != NULL) {
 			    strncpy(hbuf, res->ai_canonname, sizeof(hbuf));
+			    hbuf[sizeof(hbuf) - 1] = '\0';
 			    host = hbuf;
 			}
 			freeaddrinfo(res);
@@ -2025,12 +2029,13 @@
     }
     wait_options = 0;
  done:
+    cleanup_push(&hostname, strbuf_cleanup);
     xclose(fds[0]);
     while ((wait_res = waitpid(pid, &status, wait_options)) == -1
 	   && errno == EINTR)
 	handle_pending_signals();
-    cleanup_push(&hostname, strbuf_cleanup);
-    if (wait_res == pid && WIFEXITED(status) && WEXITSTATUS(status) == 0) {
+    if (hostname.len > 0 && wait_res == pid && WIFEXITED(status)
+	   && WEXITSTATUS(status) == 0) {
 	strbuf_terminate(&hostname);
 	tsetenv(STRREMOTEHOST, str2short(hostname.s));
     }
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/tc.nls.c
--- a/head/contrib/tcsh/tc.nls.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/tc.nls.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/tc.nls.c,v 3.21 2006/09/26 16:45:30 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.nls.c,v 3.23 2010/02/12 22:17:20 christos Exp $ */
 /*
  * tc.nls.c: NLS handling
  */
@@ -32,9 +32,33 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: tc.nls.c,v 3.21 2006/09/26 16:45:30 christos Exp $")
+RCSID("$tcsh: tc.nls.c,v 3.23 2010/02/12 22:17:20 christos Exp $")
+
 
 #ifdef WIDE_STRINGS
+# ifdef HAVE_WCWIDTH
+#  ifdef UTF16_STRINGS
+int
+xwcwidth (wint_t wchar)
+{
+  wchar_t ws[2];
+
+  if (wchar <= 0xffff)
+    return wcwidth ((wchar_t) wchar);
+  /* UTF-16 systems can't handle these values directly in calls to wcwidth.
+     However, they can handle them as surrogate pairs in calls to wcswidth.
+     What we do here is to convert UTF-32 values >= 0x10000 into surrogate
+     pairs and compute the width by calling wcswidth. */
+  wchar -= 0x10000;
+  ws[0] = 0xd800 | (wchar >> 10);
+  ws[1] = 0xdc00 | (wchar & 0x3ff);
+  return wcswidth (ws, 2);
+}
+#  else
+#define xwcwidth wcwidth
+#  endif /* !UTF16_STRINGS */
+# endif /* HAVE_WCWIDTH */
+
 int
 NLSWidth(Char c)
 {
@@ -42,7 +66,7 @@
     int l;
     if (c & INVALID_BYTE)
 	return 1;
-    l = wcwidth(c);
+    l = xwcwidth((wchar_t) c);
     return l >= 0 ? l : 0;
 # else
     return iswprint(c) != 0;
@@ -58,7 +82,7 @@
     while (*s) {
 	c = *s++;
 #ifdef HAVE_WCWIDTH
-	if ((l = wcwidth(c)) < 0)
+	if ((l = xwcwidth((wchar_t) c)) < 0)
 		l = 2;
 #else
 	l = iswprint(c) != 0;
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/tc.nls.h
--- a/head/contrib/tcsh/tc.nls.h	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/tc.nls.h	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/tc.nls.h,v 3.13 2006/02/14 14:07:36 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.nls.h,v 3.14 2011/02/25 23:57:21 christos Exp $ */
 /*
  * tc.nls.h: NLS support
  *
@@ -34,8 +34,6 @@
 #ifndef _h_tc_nls
 #define _h_tc_nls
 
-#include "sh.h"
-
 #ifdef WIDE_STRINGS
 extern int NLSWidth(Char);
 extern int NLSStringWidth (const Char *);
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/tc.os.c
--- a/head/contrib/tcsh/tc.os.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/tc.os.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/tc.os.c,v 3.69 2006/08/24 20:56:31 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.os.c,v 3.72 2011/01/25 13:58:19 christos Exp $ */
 /*
  * tc.os.c: OS Dependent builtin functions
  */
@@ -32,7 +32,7 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: tc.os.c,v 3.69 2006/08/24 20:56:31 christos Exp $")
+RCSID("$tcsh: tc.os.c,v 3.72 2011/01/25 13:58:19 christos Exp $")
 
 #include "tw.h"
 #include "ed.h"
@@ -1584,3 +1584,42 @@
     return(res);
 }
 #endif
+
+#ifdef __ANDROID__
+#include <stdio.h>
+/* Android (<= 2.1?) has an incomplete ttyname implementation. */
+char *
+ttyname(int fd)
+{
+    char path[64];
+    ssize_t siz;
+    static char ttyname[32];
+
+    if (!isatty(fd))
+	return NULL;
+
+    (void)snprintf(path, sizeof(path), "/proc/self/fd/%d", fd);
+    siz = readlink(path, ttyname, sizeof(ttyname));
+    if (siz < 0 || siz == sizeof(ttyname))
+	return NULL;
+    ttyname[siz] = '\0';
+    return ttyname;
+}
+#endif /* __ANDROID__ */
+
+#if defined(__CYGWIN__) && !defined(NO_CRYPT)
+#undef CHAR		/* Collides with Win32 API */
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <sys/cygwin.h>
+char *
+cygwin_xcrypt(struct passwd *pw, const char *password, const char *expected_pwd)
+{
+    static char invalid_password[] = "\377";
+    HANDLE token = cygwin_logon_user(pw, password);
+    if (token == INVALID_HANDLE_VALUE)
+	return invalid_password;
+    CloseHandle(token);
+    return (char *) expected_pwd;
+}
+#endif /* __CYGWIN__ && !NO_CRYPT */
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/tc.os.h
--- a/head/contrib/tcsh/tc.os.h	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/tc.os.h	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/tc.os.h,v 3.102 2007/07/05 14:13:06 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.os.h,v 3.105 2011/02/04 18:00:26 christos Exp $ */
 /*
  * tc.os.h: Shell os dependent defines
  */
@@ -164,7 +164,7 @@
  * It would break on glibc, where all this is
  * defined in <termios.h>. Wrapper added.
  */
-#if !defined(linux) && !defined(__GNU__) && !defined(__GLIBC__) && !defined(_VMS_POSIX)
+#if !defined(__linux__) && !defined(__GNU__) && !defined(__GLIBC__) && !defined(_VMS_POSIX)
 # if defined(INTEL) || defined(u3b2) || defined (u3b5) || defined(ub15) || defined(u3b20d) || defined(ISC) || defined(SCO) || defined(tower32)
 #  ifdef TIOCGWINSZ
 /*
@@ -361,6 +361,18 @@
 #ifndef O_RDWR
 # define O_RDWR		2
 #endif /* O_RDWR */
+#ifndef O_TEMPORARY
+# define O_TEMPORARY	0
+#endif /* O_TEMPORARY */
+#ifndef O_EXCL
+# define O_EXCL		0
+#endif /* O_EXCL */
+#ifndef O_LARGEFILE
+# define O_LARGEFILE	0
+#endif /* O_LARGEFILE */
+#ifndef O_CREAT
+# define O_CREAT	0
+#endif /* O_CREAT */
 
 /*
  * Lseek()
@@ -601,4 +613,8 @@
 # endif
 #endif
 
+#if defined(__CYGWIN__) && !defined(NO_CRYPT)
+extern char *cygwin_xcrypt(struct passwd *, const char *, const char *);
+#endif /* __CYGWIN__ && !NO_CRYPT */
+
 #endif /* _h_tc_os */
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/tc.prompt.c
--- a/head/contrib/tcsh/tc.prompt.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/tc.prompt.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/tc.prompt.c,v 3.67 2006/11/17 16:26:58 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.prompt.c,v 3.70 2011/10/27 22:41:06 christos Exp $ */
 /*
  * tc.prompt.c: Prompt printing stuff
  */
@@ -32,7 +32,7 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: tc.prompt.c,v 3.67 2006/11/17 16:26:58 christos Exp $")
+RCSID("$tcsh: tc.prompt.c,v 3.70 2011/10/27 22:41:06 christos Exp $")
 
 #include "ed.h"
 #include "tw.h"
@@ -213,8 +213,9 @@
 		}
 		break;
 	    case '#':
-		Strbuf_append1(&buf,
-			       attributes | ((uid == 0) ? PRCHROOT : PRCH));
+		Scp = (uid == 0 || euid == 0) ? PRCHROOT : PRCH;
+		if (Scp != '\0')
+		    Strbuf_append1(&buf, attributes | Scp);
 		break;
 	    case '!':
 	    case 'h':
@@ -458,6 +459,11 @@
 			    Strbuf_append1(&buf, attributes | *z++);
 		}
 		break;
+	    case 'N':
+		if ((z = varval(STReuser)) != STRNULL)
+		    while (*z)
+			Strbuf_append1(&buf, attributes | *z++);
+		break;
 	    case 'l':
 #ifndef HAVENOUTMP
 		if (what == FMT_WHO) {
@@ -528,6 +534,8 @@
 
 		    for (pp = proclist.p_next; pp; pp = pp->p_next)
 			njobs++;
+		    if (njobs == -1)
+			njobs++;
 		    p = Itoa(njobs, 1, attributes);
 		    Strbuf_append(&buf, p);
 		    xfree(p);
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/tc.sig.c
--- a/head/contrib/tcsh/tc.sig.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/tc.sig.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/tc.sig.c,v 3.36 2006/08/24 20:56:31 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.sig.c,v 3.40 2012/01/25 15:34:41 christos Exp $ */
 /*
  * tc.sig.c: Signal routine emulations
  */
@@ -32,7 +32,7 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: tc.sig.c,v 3.36 2006/08/24 20:56:31 christos Exp $")
+RCSID("$tcsh: tc.sig.c,v 3.40 2012/01/25 15:34:41 christos Exp $")
 
 #include "tc.wait.h"
 
@@ -60,26 +60,38 @@
 int phup_disabled; /* = 0; */
 int pchild_disabled; /* = 0; */
 int pintr_disabled; /* = 0; */
+int handle_interrupt; /* = 0; */
 
-void
+int
 handle_pending_signals(void)
 {
+    int rv = 0;
     if (!phup_disabled && phup_pending) {
 	phup_pending = 0;
+	handle_interrupt++;
 	phup();
+	handle_interrupt--;
     }
     if (!pintr_disabled && pintr_pending) {
 	pintr_pending = 0;
+	handle_interrupt++;
 	pintr();
+	handle_interrupt--;
+	rv = 1;
     }
     if (!pchild_disabled && pchild_pending) {
 	pchild_pending = 0;
+	handle_interrupt++;
 	pchild();
+	handle_interrupt--;
     }
     if (!alrmcatch_disabled && alrmcatch_pending) {
 	alrmcatch_pending = 0;
+	handle_interrupt++;
 	alrmcatch();
+	handle_interrupt--;
     }
+    return rv;
 }
 
 void
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/tc.sig.h
--- a/head/contrib/tcsh/tc.sig.h	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/tc.sig.h	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/tc.sig.h,v 3.33 2007/07/05 14:13:06 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.sig.h,v 3.34 2010/11/29 15:28:58 christos Exp $ */
 /*
  * tc.sig.h: Signal handling
  *
@@ -159,7 +159,7 @@
 extern int pintr_disabled;
 
 extern void sigset_interrupting(int, void (*) (int));
-extern void handle_pending_signals(void);
+extern int handle_pending_signals(void);
 
 extern void queue_alrmcatch(int);
 extern void queue_pchild(int);
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/tc.str.c
--- a/head/contrib/tcsh/tc.str.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/tc.str.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/tc.str.c,v 3.30 2009/06/25 21:27:38 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.str.c,v 3.42 2012/01/10 21:34:31 christos Exp $ */
 /*
  * tc.str.c: Short string package
  * 	     This has been a lesson of how to write buggy code!
@@ -33,9 +33,10 @@
  */
 #include "sh.h"
 
+#include <assert.h>
 #include <limits.h>
 
-RCSID("$tcsh: tc.str.c,v 3.30 2009/06/25 21:27:38 christos Exp $")
+RCSID("$tcsh: tc.str.c,v 3.42 2012/01/10 21:34:31 christos Exp $")
 
 #define MALLOC_INCR	128
 #ifdef WIDE_STRINGS
@@ -46,7 +47,7 @@
 
 #ifdef WIDE_STRINGS
 size_t
-one_mbtowc(wchar_t *pwc, const char *s, size_t n)
+one_mbtowc(Char *pwc, const char *s, size_t n)
 {
     int len;
 
@@ -61,7 +62,7 @@
 }
 
 size_t
-one_wctomb(char *s, wchar_t wchar)
+one_wctomb(char *s, Char wchar)
 {
     int len;
 
@@ -69,7 +70,23 @@
 	s[0] = wchar & 0xFF;
 	len = 1;
     } else {
-	len = wctomb(s, wchar);
+#ifdef UTF16_STRINGS
+	if (wchar >= 0x10000) {
+	    /* UTF-16 systems can't handle these values directly in calls to
+	       wctomb.  Convert value to UTF-16 surrogate and call wcstombs to
+	       convert the "string" to the correct multibyte representation,
+	       if any. */
+	    wchar_t ws[3];
+	    wchar -= 0x10000;
+	    ws[0] = 0xd800 | (wchar >> 10);
+	    ws[1] = 0xdc00 | (wchar & 0x3ff);
+	    ws[2] = 0;
+	    /* The return value of wcstombs excludes the trailing 0, so len is
+	       the correct number of multibytes for the Unicode char. */
+	    len = wcstombs (s, ws, MB_CUR_MAX + 1);
+	} else
+#endif
+	len = wctomb(s, (wchar_t) wchar);
 	if (len == -1)
 	    s[0] = wchar;
 	if (len <= 0)
@@ -79,14 +96,55 @@
 }
 
 int
-rt_mbtowc(wchar_t *pwc, const char *s, size_t n)
+rt_mbtowc(Char *pwc, const char *s, size_t n)
 {
     int ret;
     char back[MB_LEN_MAX];
+    wchar_t tmp;
+#if defined(UTF16_STRINGS) && defined(HAVE_MBRTOWC)
+# if defined(AUTOSET_KANJI)
+    static mbstate_t mb_zero, mb;
+    /*
+     * Workaround the Shift-JIS endcoding that translates unshifted 7 bit ASCII!
+     */
+    if (!adrof(STRnokanji) && n && pwc && s && (*s == '\\' || *s == '~') &&
+	!memcmp(&mb, &mb_zero, sizeof(mb)))
+    {
+	*pwc = *s;
+	return 1;
+    }
+# else
+    mbstate_t mb;
+# endif
 
-    ret = mbtowc(pwc, s, n);
-    if (ret > 0 && (wctomb(back, *pwc) != ret || memcmp(s, back, ret) != 0))
+    memset (&mb, 0, sizeof mb);
+    ret = mbrtowc(&tmp, s, n, &mb);
+#else
+    ret = mbtowc(&tmp, s, n);
+#endif
+    if (ret > 0) {
+	*pwc = tmp;
+#if defined(UTF16_STRINGS) && defined(HAVE_MBRTOWC)
+	if (tmp >= 0xd800 && tmp <= 0xdbff) {
+	    /* UTF-16 surrogate pair.  Fetch second half and compute
+	       UTF-32 value.  Dispense with the inverse test in this case. */
+	    size_t n2 = mbrtowc(&tmp, s + ret, n - ret, &mb);
+	    if (n2 == 0 || n2 == (size_t)-1 || n2 == (size_t)-2)
+		ret = -1;
+	    else {
+		*pwc = (((*pwc & 0x3ff) << 10) | (tmp & 0x3ff)) + 0x10000;
+		ret += n2;
+	    }
+	} else
+#endif
+      	if (wctomb(back, *pwc) != ret || memcmp(s, back, ret) != 0)
+	    ret = -1;
+
+    } else if (ret == -2)
 	ret = -1;
+    else if (ret == 0)
+	*pwc = '\0';
+
     return ret;
 }
 #endif
@@ -186,7 +244,7 @@
     return (sdst);
 }
 
-#ifndef WIDE_STRINGS
+#if !defined (WIDE_STRINGS) || defined (UTF16_STRINGS)
 Char   *
 s_strcpy(Char *dst, const Char *src)
 {
@@ -334,18 +392,20 @@
 s_strcasecmp(const Char *str1, const Char *str2)
 {
 #ifdef WIDE_STRINGS
-    wchar_t l1 = 0, l2 = 0;
-    for (; *str1 && ((*str1 == *str2 && (l1 = l2 = 0) == 0) || 
-	(l1 = towlower(*str1)) == (l2 = towlower(*str2))); str1++, str2++)
-	continue;
-    
+    wint_t l1 = 0, l2 = 0;
+    for (; *str1; str1++, str2++)
+	if (*str1 == *str2)
+	    l1 = l2 = 0;
+	else if ((l1 = towlower(*str1)) != (l2 = towlower(*str2)))
+	    break;
 #else
-    unsigned char c1, c2, l1 = 0, l2 = 0;
-    for (; *str1 && ((*str1 == *str2 && (l1 = l2 = 0) == 0) || 
-	((c1 = (unsigned char)*str1) == *str1 &&
-	 (c2 = (unsigned char)*str2) == *str2 &&
-	(l1 = tolower(c1)) == (l2 = tolower(c2)))); str1++, str2++)
-	continue;
+    unsigned char l1 = 0, l2 = 0;
+    for (; *str1; str1++, str2++)
+	if (*str1 == *str2)
+		l1 = l2 = 0;
+	else if ((l1 = tolower((unsigned char)*str1)) !=
+	    (l2 = tolower((unsigned char)*str2)))
+	    break;
 #endif
     /*
      * The following case analysis is necessary so that characters which look
@@ -568,6 +628,7 @@
 	    buf->size *= 2;					\
 	buf->s = xrealloc(buf->s, buf->size * sizeof(*buf->s));	\
     }								\
+    assert(buf->s);						\
     buf->s[buf->len] = c;					\
 }								\
 								\
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/tc.wait.h
--- a/head/contrib/tcsh/tc.wait.h	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/tc.wait.h	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/tc.wait.h,v 3.14 2004/12/25 21:15:08 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.wait.h,v 3.15 2011/02/04 18:00:26 christos Exp $ */
 /*
  * tc.wait.h: <sys/wait.h> for machines that don't have it or have it and
  *	      is incorrect.
@@ -39,7 +39,7 @@
  * We try to use the system's wait.h when we can...
  */
 
-#if SYSVREL > 0 && !defined(linux) && !defined(__GNU__) && !defined(__GLIBC__)
+#if SYSVREL > 0 && !defined(__linux__) && !defined(__GNU__) && !defined(__GLIBC__)
 # ifdef hpux
 #  ifndef __hpux
 #   define NEEDwait
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/tc.who.c
--- a/head/contrib/tcsh/tc.who.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/tc.who.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/tc.who.c,v 3.51 2006/03/03 22:08:45 amold Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.who.c,v 3.57 2012/01/17 20:53:38 christos Exp $ */
 /*
  * tc.who.c: Watch logins and logouts...
  */
@@ -32,7 +32,7 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: tc.who.c,v 3.51 2006/03/03 22:08:45 amold Exp $")
+RCSID("$tcsh: tc.who.c,v 3.57 2012/01/17 20:53:38 christos Exp $")
 
 #include "tc.h"
 
@@ -44,6 +44,11 @@
 
 #ifdef HAVE_UTMPX_H
 # include <utmpx.h>
+# define UTNAMLEN	sizeof(((struct utmpx *) 0)->ut_name)
+# define UTLINLEN	sizeof(((struct utmpx *) 0)->ut_line)
+# ifdef HAVE_STRUCT_UTMPX_UT_HOST
+#  define UTHOSTLEN	sizeof(((struct utmpx *) 0)->ut_host)
+# endif
 /* I just redefine a few words here.  Changing every occurrence below
  * seems like too much of work.  All UTMP functions have equivalent
  * UTMPX counterparts, so they can be added all here when needed.
@@ -55,68 +60,81 @@
 #  define TCSH_PATH_UTMP _PATH_UTMPX
 # elif defined(UTMPX_FILE)
 #  define TCSH_PATH_UTMP UTMPX_FILE
-# endif /* __UTMPX_FILE && !UTMPX_FILE */
-# ifdef TCSH_PATH_UTMP
+# elif __FreeBSD_version >= 900000
+#  /* Why isn't this defined somewhere? */
+#  define TCSH_PATH_UTMP "/var/run/utx.active"
+# elif defined(__hpux)
+#  define TCSH_PATH_UTMP "/etc/utmpx"
+# endif
+# if defined(TCSH_PATH_UTMP) || !defined(HAVE_UTMP_H)
 #  define utmp utmpx
-#  if defined(HAVE_STRUCT_UTMP_UT_TV)
-#   define ut_time ut_tv.tv_sec
-#  elif defined(HAVE_STRUCT_UTMP_UT_XTIME)
-#   define ut_time ut_xtime
-#  endif
-#  ifdef HAVE_STRUCT_UTMP_UT_USER
-#   define ut_name ut_user
-#  endif
-#  ifdef HAVE_GETUTENT
+#  define TCSH_USE_UTMPX
+#  if defined(HAVE_GETUTENT) || defined(HAVE_GETUTXENT)
 #   define getutent getutxent
 #   define setutent setutxent
 #   define endutent endutxent
-#  endif /* HAVE_GETUTENT */
-# else
-#  ifdef HAVE_UTMP_H
-#   include <utmp.h>
-#  endif /* WINNT_NATIVE */
-# endif /* TCSH_PATH_UTMP */
-#else /* !HAVE_UTMPX_H */
-# ifdef HAVE_UTMP_H
-#  include <utmp.h>
-# endif /* WINNT_NATIVE */
+#  endif /* HAVE_GETUTENT || HAVE_GETUTXENT */
+#  if defined(HAVE_STRUCT_UTMPX_UT_TV)
+#   define ut_time ut_tv.tv_sec
+#  elif defined(HAVE_STRUCT_UTMPX_UT_XTIME)
+#   define ut_time ut_xtime
+#  endif
+#  if defined(HAVE_STRUCT_UTMPX_UT_USER)
+#   define ut_name ut_user
+#  endif
+# endif /* TCSH_PATH_UTMP || !HAVE_UTMP_H */
 #endif /* HAVE_UTMPX_H */
 
-#ifndef BROKEN_CC
-# define UTNAMLEN	sizeof(((struct utmp *) 0)->ut_name)
-# define UTLINLEN	sizeof(((struct utmp *) 0)->ut_line)
-# ifdef HAVE_STRUCT_UTMP_UT_HOST
-#  ifdef _SEQUENT_
-#   define UTHOSTLEN	100
-#  else
-#   define UTHOSTLEN	sizeof(((struct utmp *) 0)->ut_host)
-#  endif
-# endif	/* HAVE_STRUCT_UTMP_UT_HOST */
-#else
+#if !defined(TCSH_USE_UTMPX) && defined(HAVE_UTMP_H)
+# include <utmp.h>
+# if defined(HAVE_STRUCT_UTMP_UT_TV)
+#  define ut_time ut_tv.tv_sec
+# elif defined(HAVE_STRUCT_UTMP_UT_XTIME)
+#  define ut_time ut_xtime
+# endif
+# if defined(HAVE_STRUCT_UTMP_UT_USER)
+#  define ut_name ut_user
+# endif
+# ifndef BROKEN_CC
+#  define UTNAMLEN	sizeof(((struct utmp *) 0)->ut_name)
+#  define UTLINLEN	sizeof(((struct utmp *) 0)->ut_line)
+#  ifdef HAVE_STRUCT_UTMP_UT_HOST
+#   ifdef _SEQUENT_
+#    define UTHOSTLEN	100
+#   else
+#    define UTHOSTLEN	sizeof(((struct utmp *) 0)->ut_host)
+#   endif
+#  endif	/* HAVE_STRUCT_UTMP_UT_HOST */
+# else
 /* give poor cc a little help if it needs it */
 struct utmp __ut;
+#  define UTNAMLEN	sizeof(__ut.ut_name)
+#  define UTLINLEN	sizeof(__ut.ut_line)
+#  ifdef HAVE_STRUCT_UTMP_UT_HOST
+#   ifdef _SEQUENT_
+#    define UTHOSTLEN	100
+#   else
+#    define UTHOSTLEN	sizeof(__ut.ut_host)
+#   endif
+#  endif /* HAVE_STRUCT_UTMP_UT_HOST */
+# endif /* BROKEN_CC */
+# ifndef TCSH_PATH_UTMP
+#  ifdef UTMP_FILE
+#   define TCSH_PATH_UTMP UTMP_FILE
+#  elif defined(_PATH_UTMP)
+#   define TCSH_PATH_UTMP _PATH_UTMP
+#  else
+#   define TCSH_PATH_UTMP "/etc/utmp"
+#  endif /* UTMP_FILE */
+# endif /* TCSH_PATH_UTMP */
+#endif /* !TCSH_USE_UTMPX && HAVE_UTMP_H */
 
-# define UTNAMLEN	sizeof(__ut.ut_name)
-# define UTLINLEN	sizeof(__ut.ut_line)
-# ifdef HAVE_STRUCT_UTMP_UT_HOST
-#  ifdef _SEQUENT_
-#   define UTHOSTLEN	100
-#  else
-#   define UTHOSTLEN	sizeof(__ut.ut_host)
-#  endif
-# endif /* HAVE_STRUCT_UTMP_UT_HOST */
-#endif /* BROKEN_CC */
-
-#ifndef TCSH_PATH_UTMP
-# ifdef	UTMP_FILE
-#  define TCSH_PATH_UTMP UTMP_FILE
-# elif defined(_PATH_UTMP)
-#  define TCSH_PATH_UTMP _PATH_UTMP
-# else
-#  define TCSH_PATH_UTMP "/etc/utmp"
-# endif /* UTMP_FILE */
-#endif /* TCSH_PATH_UTMP */
-
+#ifndef UTNAMLEN
+#define UTNAMLEN 64
+#endif
+#ifndef UTLINLEN
+#define UTLINLEN 64
+#endif
 
 struct who {
     struct who *who_next;
@@ -124,9 +142,9 @@
     char    who_name[UTNAMLEN + 1];
     char    who_new[UTNAMLEN + 1];
     char    who_tty[UTLINLEN + 1];
-#ifdef HAVE_STRUCT_UTMP_UT_HOST
+#ifdef UTHOSTLEN
     char    who_host[UTHOSTLEN + 1];
-#endif /* HAVE_STRUCT_UTMP_UT_HOST */
+#endif /* UTHOSTLEN */
     time_t  who_time;
     int     who_status;
 };
@@ -180,7 +198,7 @@
 {
     int     comp = -1, alldone;
     int	    firsttime = stlast == 1;
-#ifdef HAVE_GETUTENT
+#if defined(HAVE_GETUTENT) || defined(HAVE_GETUTXENT)
     struct utmp *uptr;
 #else
     int utmpfd;
@@ -259,7 +277,7 @@
 	return;
     }
     stlast = sta.st_mtime;
-#ifdef HAVE_GETUTENT
+#if defined(HAVE_GETUTENT) || defined(HAVE_GETUTXENT)
     setutent();
 #else
     if ((utmpfd = xopen(TCSH_PATH_UTMP, O_RDONLY|O_LARGEFILE)) < 0) {
@@ -284,7 +302,7 @@
      * Read in the utmp file, sort the entries, and update existing entries or
      * add new entries to the status list.
      */
-#ifdef HAVE_GETUTENT
+#if defined(HAVE_GETUTENT) || defined(HAVE_GETUTXENT)
     while ((uptr = getutent()) != NULL) {
         memcpy(&utmp, uptr, sizeof (utmp));
 #else
@@ -333,7 +351,7 @@
 	    }
 	    else {
 		(void) strncpy(wp->who_new, utmp.ut_name, UTNAMLEN);
-# ifdef HAVE_STRUCT_UTMP_UT_HOST
+# ifdef UTHOSTLEN
 #  ifdef _SEQUENT_
 		host = ut_find_host(wp->who_tty);
 		if (host)
@@ -343,7 +361,7 @@
 #  else
 		(void) strncpy(wp->who_host, utmp.ut_host, UTHOSTLEN);
 #  endif
-# endif /* HAVE_STRUCT_UTMP_UT_HOST */
+# endif /* UTHOSTLEN */
 		wp->who_time = utmp.ut_time;
 		if (wp->who_name[0] == '\0')
 		    wp->who_status = ONLINE;
@@ -354,7 +372,7 @@
 	else {		/* new tty in utmp */
 	    wpnew = xcalloc(1, sizeof *wpnew);
 	    (void) strncpy(wpnew->who_tty, utmp.ut_line, UTLINLEN);
-# ifdef HAVE_STRUCT_UTMP_UT_HOST
+# ifdef UTHOSTLEN
 #  ifdef _SEQUENT_
 	    host = ut_find_host(wpnew->who_tty);
 	    if (host)
@@ -364,7 +382,7 @@
 #  else
 	    (void) strncpy(wpnew->who_host, utmp.ut_host, UTHOSTLEN);
 #  endif
-# endif /* HAVE_STRUCT_UTMP_UT_HOST */
+# endif /* UTHOSTLEN */
 	    wpnew->who_time = utmp.ut_time;
 # ifdef DEAD_PROCESS
 	    if (utmp.ut_type == DEAD_PROCESS)
@@ -387,14 +405,11 @@
 	    wp->who_prev = wpnew;	/* linked in now */
 	}
     }
-#ifdef HAVE_GETUTENT
+#if defined(HAVE_GETUTENT) || defined(HAVE_GETUTXENT)
     endutent();
 #else
     cleanup_until(&utmpfd);
 #endif
-# if defined(HAVE_STRUCT_UTMP_UT_HOST) && defined(_SEQUENT_)
-    endutent();
-# endif
 #endif /* !WINNT_NATIVE */
 
     if (force || vp == NULL) {
@@ -494,11 +509,11 @@
 static void
 print_who(struct who *wp)
 {
-#ifdef HAVE_STRUCT_UTMP_UT_HOST
+#ifdef UTHOSTLEN
     Char   *cp = str2short(CGETS(26, 7, "%n has %a %l from %m."));
 #else
     Char   *cp = str2short(CGETS(26, 8, "%n has %a %l."));
-#endif /* HAVE_STRUCT_UTMP_UT_HOST */
+#endif /* UTHOSTLEN */
     struct varent *vp = adrof(STRwho);
     Char *str;
 
@@ -519,11 +534,11 @@
 {
     struct who *wp = ptr;
     char *wbuf;
-#ifdef HAVE_STRUCT_UTMP_UT_HOST
+#ifdef UTHOSTLEN
     char *wb;
     int flg;
     char *pb;
-#endif /* HAVE_STRUCT_UTMP_UT_HOST */
+#endif /* UTHOSTLEN */
 
     switch (c) {
     case 'n':		/* user name */
@@ -551,7 +566,7 @@
 	}
 	break;
 
-#ifdef HAVE_STRUCT_UTMP_UT_HOST
+#ifdef UTHOSTLEN
     case 'm':
 	if (wp->who_host[0] == '\0')
 	    return strsave(CGETS(26, 12, "local"));
@@ -585,7 +600,7 @@
 	    *wb = '\0';
 	    return wbuf;
 	}
-#endif /* HAVE_STRUCT_UTMP_UT_HOST */
+#endif /* UTHOSTLEN */
 
     case 'l':
 	return strsave(wp->who_tty);
@@ -620,7 +635,7 @@
     }
 }
 
-# ifdef HAVE_STRUCT_UTMP_UT_HOST
+# ifdef UTHOSTLEN
 size_t
 utmphostsize(void)
 {
@@ -644,12 +659,11 @@
     resetwatch();
     return host;
 }
-# endif /* HAVE_STRUCT_UTMP_UT_HOST */
+# endif /* UTHOSTLEN */
 
 #ifdef WINNT_NATIVE
-void add_to_who_list(name, mach_nm)
-    char *name;
-    char *mach_nm;
+void
+add_to_who_list(char *name, char *mach_nm)
 {
 
     struct who *wp, *wpnew;
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/tcsh.man
--- a/head/contrib/tcsh/tcsh.man	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/tcsh.man	Fri Mar 02 16:54:40 2012 +0200
@@ -72,7 +72,7 @@
 .\"   used here if you can. In particular, please don't use nroff commands
 .\"   which aren't already used herein.
 .\" 
-.TH TCSH 1 "10 July 2009" "Astron 6.17.00"
+.TH TCSH 1 "14 February 2012" "Astron 6.18.01"
 .SH NAME
 tcsh \- C shell with file name completion and command line editing
 .SH SYNOPSIS
@@ -444,6 +444,17 @@
 underscores are equivalent.  Periods, however, are not equivalent to
 hyphens or underscores.
 .PP
+If the \fBcomplete\fR shell variable is set to `Enhance', completion
+ignores case and differences between a hyphen and an underscore word
+separator only when the user types a lowercase character or a hyphen.
+Entering an uppercase character or an underscore will not match the 
+corresponding lowercase character or hyphen word separator.  
+Typing `rm a\-\-file[^D]' in the directory of the previous example would 
+still list all three files, but typing `rm A\-\-file' would match only 
+`A_silly_file' and typing `rm a__file[^D]' would match just `A_silly_file' 
+and `another_silly_file' because the user explicitly used an uppercase 
+or an underscore character.  
+.PP
 Completion and listing are affected by several other shell variables:
 \fBrecexact\fR can be set to complete on the shortest possible unique
 match, even if more typing might result in a longer match:
@@ -609,7 +620,7 @@
 .TP 8
 .B expand-line \fR(not bound)
 Like \fIexpand-history\fR, but
-expands history substitutions in each word in the input buffer,
+expands history substitutions in each word in the input buffer.
 .TP 8
 .B expand-variables \fR(^X-$)
 Expands the variable to the left of the cursor.
@@ -860,7 +871,7 @@
 .PP
 The \fIhistory\fR builtin command can print, store in a file, restore
 and clear the history list at any time,
-and the \fBsavehist\fR and \fBhistfile\fR shell variables can be can be set to
+and the \fBsavehist\fR and \fBhistfile\fR shell variables can be set to
 store the history list automatically on logout and restore it on login.
 .PP
 History substitutions introduce words from the history list into the input
@@ -1150,7 +1161,7 @@
 These can be displayed and changed with \fIprintenv\fR, \fIsetenv\fR and
 \fIunsetenv\fR.
 .PP
-(+) Variables may be made read-only with `set \-r' (q.v.)
+(+) Variables may be made read-only with `set \-r' (q.v.).
 Read-only variables may not be modified or unset;
 attempting to do so will cause an error.
 Once made read-only, a variable cannot be made writable,
@@ -1328,9 +1339,14 @@
 .PP
 In matching filenames, the character `.' at the beginning of a filename or
 immediately following a `/', as well as the character `/' must be matched
-explicitly.  The character `*' matches any string of characters, including the
-null string.  The character `?' matches any single character.  The sequence
-`[...]' matches any one of the characters enclosed.  Within `[...]', a pair of
+explicitly (unless either
+.B globdot
+or
+.B globstar
+or both are set(+)).  The character `*' matches any string of characters, 
+including the null string.  The character `?' matches any single character.  
+The sequence `[...]' matches any one of the characters enclosed.  
+Within `[...]', a pair of
 characters separated by `\-' matches any character lexically between the two.
 .PP
 (+) Some glob-patterns can be negated:
@@ -1381,6 +1397,20 @@
 of patterns) which matches nothing is left unchanged rather than causing
 an error.
 .PP
+The \fBglobstar\fR shell variable can be set to allow `**' or `***' as 
+a file glob pattern that matches any string of characters including `/',
+recursively traversing any existing sub-directories.  For example, 
+`ls **.c' will list all the .c files in the current directory tree.
+If used by itself, it will match match zero or more sub-directories
+(e.g. `ls /usr/include/**/time.h' will list any file named `time.h'
+in the /usr/include directory tree; `ls /usr/include/**time.h' will match 
+any file in the /usr/include directory tree ending in `time.h'; and
+`ls /usr/include/**time**.h' will match any .h file with `time' either
+in a subdirectory name or in the filename itself).
+To prevent problems with recursion, the `**' glob-pattern will not 
+descend into a symbolic link containing a directory.  To override this,
+use `***' (+)
+.PP
 The \fBnoglob\fR shell variable can be set to prevent filename substitution,
 and the \fIexpand-glob\fR editor command, normally bound to `^X-*', can be
 used to interactively expand individual filename substitutions.
@@ -1501,7 +1531,7 @@
 .PP
 On systems which do not understand the `#!' script interpreter convention
 the shell may be compiled to emulate it; see the \fBversion\fR shell
-variable\fR.  If so, the shell checks the first line of the file to
+variable.  If so, the shell checks the first line of the file to
 see if it is of the form `#!\fIinterpreter\fR \fIarg\fR ...'.  If it is,
 the shell starts \fIinterpreter\fR with the given \fIarg\fRs and feeds the
 file to it on standard input.
@@ -1704,7 +1734,7 @@
 for a terminal device (+)
 .TP 4
 .B R
-Has been migrated (convex only) (+)
+Has been migrated (Convex only) (+)
 .TP 4
 .B L
 Applies subsequent operators in a multiple-operator test to a symbolic link
@@ -1730,7 +1760,7 @@
 in a multiple-operator test; see below.
 .PP
 It is possible but not useful, and sometimes misleading, to combine operators
-which expect \fIfile\fR to be a file with operators which do not,
+which expect \fIfile\fR to be a file with operators which do not
 (e.g., \fBX\fR and \fBt\fR).  Following \fBL\fR with a non-file operator
 can lead to particularly strange results.
 .PP
@@ -2261,7 +2291,7 @@
 .B case \fIlabel\fB:
 A label in a \fIswitch\fR statement as discussed below.
 .TP 8
-.B cd \fR[\fB\-p\fR] [\fB\-l\fR] [\fB\-n\fR|\fB\-v\fR] [\fIname\fR]
+.B cd \fR[\fB\-p\fR] [\fB\-l\fR] [\fB\-n\fR|\fB\-v\fR] [\I--\fR] [\fIname\fR]
 If a directory \fIname\fR is given, changes the shell's working directory
 to \fIname\fR.  If not, changes to \fBhome\fR.
 If \fIname\fR is `\-' it is interpreted as the previous working directory
@@ -2276,6 +2306,8 @@
 With \fB\-p\fR, prints the final directory stack, just like \fIdirs\fR.
 The \fB\-l\fR, \fB\-n\fR and \fB\-v\fR flags have the same effect on \fIcd\fR
 as on \fIdirs\fR, and they imply \fB\-p\fR.  (+)
+Using \fB\-\-\fR forces a break from option processing so the next word
+is taken as the directory \fIname\fR even if it begins with '\-'. (+)
 .PP
 See also the \fBimplicitcd\fR shell variable.
 .RE
@@ -2559,7 +2591,7 @@
 .br
 \&'n/\-name/f/' 'n/\-newer/f/' 'n/\-{,n}cpio/f/' \e
 .br
-\'n/\-exec/c/' 'n/\-ok/c/' 'n/\-user/u/' \e
+\&\'n/\-exec/c/' 'n/\-ok/c/' 'n/\-user/u/' \e
 .br
 \&'n/\-group/g/' 'n/\-fstype/(nfs 4.2)/' \e
 .br
@@ -2811,7 +2843,7 @@
 signal and arranges for the shell to send it a hangup signal when the shell
 exits.
 Note that commands may set their own response to hangups, overriding \fIhup\fR.
-Without an argument (allowed in only a shell script), causes the shell to
+Without an argument, causes the non-interactive shell only to
 exit on a hangup for the remainder of the script.
 See also \fBSignal handling\fR and the \fInohup\fR builtin command.
 .TP 8
@@ -2911,6 +2943,14 @@
 the maximum amount of physical memory a process
 may have allocated to it at a given time
 .TP
+\fIvmemoryuse\fR
+the maximum amount of virtual memory a process
+may have allocated to it at a given time (address space)
+.TP
+\fIvmemoryuse\fR
+the maximum amount of virtual memory a process
+may have allocated to it at a given time
+.TP
 \fIheapsize\fR
 the maximum amount of memory a process
 may allocate per \fIbrk()\fR system call
@@ -2929,18 +2969,40 @@
 .TP
 \fIsbsize\fR
 the maximum size of socket buffer usage for this user
-.TP 
-\fIswapsize\fR 
-the maximum amount of swap space reserved or used for this user 
+.TP
+\fIswapsize\fR
+the maximum amount of swap space reserved or used for this user
+.TP
+\fImaxlocks\fR
+the maximum number of locks for this user
+.TP
+\fImaxsignal\fR
+the maximum number of pending signals for this user
+.TP
+\fImaxmessage\fR
+the maximum number of bytes in POSIX mqueues for this user
+.TP
+\fImaxnice\fR
+the maximum nice priority the user is allowed to raise mapped from [19...-20]
+to [0...39] for this user
+.TP
+\fImaxrtprio\fR
+the maximum realtime priority for this user
+\fImaxrttime\fR
+the timeout for RT tasks in microseconds for this user.
 .PP
 \fImaximum-use\fR may be given as a (floating point or
 integer) number followed by a scale factor.  For all limits
 other than \fIcputime\fR the default scale is `k' or `kilobytes'
-(1024 bytes); a scale factor of `m' or `megabytes' may also
-be used.  For \fIcputime\fR the default scaling is `seconds',
+(1024 bytes); a scale factor of `m' or `megabytes' or `g' or `gigabytes'
+may also be used.  For \fIcputime\fR the default scaling is `seconds',
 while `m' for minutes or `h' for hours, or a time of the
 form `mm:ss' giving minutes and seconds may be used.
 .PP
+If \fImaximum-use\fR  is `unlimited',
+then the limitation on the specified \fIresource\fR
+is removed (this is equivalent to the \fIunlimit\fR builtin command).
+.PP
 For both \fIresource\fR names and scale factors, unambiguous
 prefixes of the names suffice.
 .RE
@@ -2952,7 +3014,7 @@
 .TP 8
 .B login
 Terminates a login shell, replacing it with an instance of
-\fI/bin/login.\fR This is one way to log off, included for
+\fI/bin/login\fR. This is one way to log off, included for
 compatibility with \fIsh\fR(1).
 .TP 8
 .B logout
@@ -3021,7 +3083,7 @@
 so `alias ls ls\-F' generally does the right thing.
 .PP
 The \fBls\-F\fR builtin can list files using different colors depending on the
-filetype or extension.  See the \fBcolor\fR \fItcsh\fR variable and the
+filetype or extension.  See the \fBcolor\fR shell variable and the
 \fBLS_COLORS\fR environment variable.
 .RE
 .PP
@@ -3037,7 +3099,7 @@
 does not like to lose its tty.  (TCF only)
 .PD
 .TP 8
-.B newgrp \fR[\fB\-\fR] \fIgroup\fR (+)
+.B newgrp \fR[\fB\-\fR] \fI[group]\fR (+)
 Equivalent to `exec newgrp'; see \fInewgrp\fR(1).
 Available only if the shell was so compiled;
 see the \fBversion\fR shell variable.
@@ -3055,7 +3117,7 @@
 .B nohup \fR[\fIcommand\fR]
 With \fIcommand\fR, runs \fIcommand\fR such that it will ignore hangup signals.
 Note that commands may set their own response to hangups, overriding \fInohup\fR.
-Without an argument (allowed in only a shell script), causes the shell to
+Without an argument, causes the non-interactive shell only to
 ignore hangups for the remainder of the script.
 See also \fBSignal handling\fR and the \fIhup\fR builtin command.
 .TP 8
@@ -3118,11 +3180,12 @@
 .B rehash
 Causes the internal hash table of the contents of the
 directories in the \fBpath\fR variable to be recomputed.  This is
-needed if new commands are added to directories in \fBpath\fR
-while you are logged in.  This should be necessary only if
-you add commands to one of your own directories, or if a
-systems programmer changes the contents of one of the
-system directories.  Also flushes the cache of home directories
+needed if the \fBautorehash\fR shell variable is not set and new
+commands are added to directories in \fBpath\fR while you are logged
+in.  With \fBautorehash\fR, a new command will be found
+automatically, except in the special case where another command of
+the same name which is located in a different directory already
+exists in the hash table.  Also flushes the cache of home directories
 built by tilde expansion.
 .TP 8
 .B repeat \fIcount command
@@ -3217,14 +3280,13 @@
 The third form sets \fIname\fR to the single \fIword\fR.
 The fourth form sets \fIname\fR to the list of words in
 \fIwordlist\fR.  In all cases the value is command and filename expanded.
-If \-r is specified, the value is set read-only.  If \-f or \-l are
-specified, set only unique words keeping their order.
-\-f prefers the first occurrence of a word, and \-l the last.
-The fifth form sets the \fIindex\fR'th component of name to \fIword\fR;
+If \fB\-r\fR is specified, the value is set read-only.  If \fB\-f\fR or
+\fB\-l\fR are specified, set only unique words keeping their order.
+\fB\-f\fR prefers the first occurrence of a word, and \fB\-l\fR the last.
+The fifth form sets the \fIindex\fR'th component of \fIname\fR to \fIword\fR;
 this component must already exist.
 The sixth form lists only the names of all shell variables that are read-only.
 The seventh form makes \fIname\fR read-only, whether or not it has a value.
-The second form sets \fIname\fR to the null string.
 The eighth form is the same as the third form, but
 make \fIname\fR read-only at the same time.
 .PD
@@ -3360,7 +3422,7 @@
 022, giving read and execute access to the group and others.
 Without \fIvalue\fR, prints the current file creation mask.
 .TP 8
-.B unalias \fIpattern
+.B unalias \fIpattern\fR
 .br
 Removes all aliases whose names match \fIpattern\fR.
 `unalias *' thus removes all aliases.
@@ -3590,8 +3652,8 @@
 The first word is the number of minutes of inactivity before automatic
 logout.  The optional second word is the number of minutes of inactivity
 before automatic locking.
-When the shell automatically logs out,
-it prints `auto-logout', sets the variable logout to `automatic' and exits.
+When the shell automatically logs out, it prints `auto-logout', sets the
+variable \fBlogout\fR to `automatic' and exits.
 When the shell automatically locks, the user is required to enter his password
 to continue working.  Five incorrect attempts result in automatic logout.
 Set to `60' (automatic logout after 60 minutes, and no locking) by default
@@ -3601,6 +3663,14 @@
 \fBversion\fR shell variable).
 See also the \fBafsuser\fR and \fBlogout\fR shell variables.
 .TP 8
+.B autorehash \fR(+)
+If set, the internal hash table of the contents of the directories in the
+\fBpath\fR variable will be recomputed if a command is not found in the hash
+table.  In addition, the list of available commands will be rebuilt for each
+command completion or spelling correction attempt if set to `complete' or
+`correct' respectively; if set to `always', this will be done for both
+cases.
+.TP 8
 .B backslash_quote \fR(+)
 If set, backslashes (`\\') always quote `\\', `'', and `"'.  This may make
 complex quoting tasks easier, but it can cause syntax errors in \fIcsh\fR(1)
@@ -3633,10 +3703,15 @@
 \fIcsh\fR.
 .TP 8
 .B complete \fR(+)
-If set to `enhance', completion 1) ignores case and 2) considers
-periods, hyphens and underscores (`.', `\-' and `_') to be word
-separators and hyphens and underscores to be equivalent. If set to
-`igncase', the completion becomes case insensitive.
+If set to `igncase', the completion becomes case insensitive.
+If set to `enhance', completion ignores case and considers
+hyphens and underscores to be equivalent; it will also treat
+periods, hyphens and underscores (`.', `\-' and `_') as word
+separators.
+If set to `Enhance', completion matches uppercase and underscore
+characters explicitly and matches lowercase and hyphens in a
+case-insensivite manner; it will treat periods, hypens and underscores
+as word separators.
 .TP 8
 .B continue \fR(+)
 If set to a list of commands, the shell will continue the listed
@@ -3683,7 +3758,7 @@
 See also the \fBcwd\fR and \fBowd\fR shell variables.
 .TP 8
 .B dspmbyte \fR(+)
-Has an affect iff 'dspm' is listed as part of the \fBversion\fR shell variable.
+Has an effect iff 'dspm' is listed as part of the \fBversion\fR shell variable.
 If set to `euc', it enables display and editing EUC-kanji(Japanese) code.
 If set to `sjis', it enables display and editing Shift-JIS(Japanese) code.
 If set to `big5', it enables display and editing Big5(Chinese) code.
@@ -3709,12 +3784,12 @@
   3 ... used for both the first byte and second byte of a multi-byte character.
 .\" SHK: I tried my best to get the following to be grammatically correct.
 .\" However, I still don't understand what's going on here.  In the
- \" following example, there are three bytes, but the text seems to refer to
- \" each nybble as a character.  What's going on here?  It this 3-byte code
- \" in the table?  The text above seems to imply that there are 256
- \" characters/bytes in the table.  If I get some more info on this (perhaps
- \" a complete example), I could fix the text to be grammatically correct.
- \" (steve.kelem at xilinx.com 1999/09/13)
+.\" following example, there are three bytes, but the text seems to refer to
+.\" each nybble as a character.  What's going on here?  It this 3-byte code
+.\" in the table?  The text above seems to imply that there are 256
+.\" characters/bytes in the table.  If I get some more info on this (perhaps
+.\" a complete example), I could fix the text to be grammatically correct.
+.\" (steve.kelem at xilinx.com 1999/09/13)
 .PP
   Example:
 .br
@@ -3782,6 +3857,12 @@
 shell variable) indicate skipped directories with an ellipsis (`...')
 instead of `/<skipped>'.
 .TP 8
+.B euid \fR(+)
+The user's effective user ID.
+.TP 8
+.B euser \fR(+)
+The first matching passwd entry name corresponding to the effective user ID.
+.TP 8
 .B fignore \fR(+)
 Lists file name suffixes to be ignored by completion.
 .TP 8
@@ -3795,6 +3876,22 @@
 .B gid \fR(+)
 The user's real group ID.
 .TP 8
+.B globdot \fR(+)
+If set, wild-card glob patterns will match files and directories beginning
+with `.' except for `.' and `..'
+.TP 8
+.B globstar \fR(+)
+If set, the `**' and `***' file glob patterns will match any string of 
+characters including `/' traversing any existing sub-directories.  (e.g. 
+`ls **.c' will list all the .c files in the current directory tree).
+If used by itself, it will match match zero or more sub-directories
+(e.g. `ls /usr/include/**/time.h' will list any file named `time.h'
+in the /usr/include directory tree; whereas `ls /usr/include/**time.h'
+will match any file in the /usr/include directory tree ending in `time.h').
+To prevent problems with recursion, the `**' glob-pattern will not 
+descend into a symbolic link containing a directory.  To override this,
+use `***'
+.TP 8
 .B group \fR(+)
 The user's group name.
 .TP 8
@@ -3802,7 +3899,7 @@
 If set, the incremental search match (in \fIi-search-back\fR and
 \fIi-search-fwd\fR) and the region between the mark and the cursor are
 highlighted in reverse video.
-
+.IP "" 8
 Highlighting requires more frequent terminal writes, which introduces extra
 overhead. If you care about terminal performance, you may want to leave this
 unset.
@@ -3926,13 +4023,12 @@
 shell variable.
 .TP 8
 .B mail
-The names of the files or directories to check for incoming mail,
-separated by whitespace, and optionally preceded by a numeric word.
-Before each prompt, if 10 minutes have passed since the last check, the
-shell checks each file and says `You have new mail.' (or, if \fBmail\fR
-contains multiple files, `You have new mail in \fIname\fR.') if the
-filesize is greater than zero in size and has a modification time
-greater than its access time.
+A list of files and directories to check for incoming mail, optionally
+preceded by a numeric word.  Before each prompt, if 10 minutes have
+passed since the last check, the shell checks each file and says `You
+have new mail.' (or, if \fBmail\fR contains multiple files, `You have
+new mail in \fIname\fR.') if the filesize is greater than zero in size
+and has a modification time greater than its access time.
 .PP
 .RS +8
 .PD
@@ -4011,7 +4107,12 @@
 .TP 8
 .B padhour
 If set, enable the printing of padding '0' for hours, in 24 and 12 hour
-formats.  E.G.: 07:45:42 vs. 7:45:42
+formats.  E.G.: 07:45:42 vs. 7:45:42.
+.TP 8
+.B parseoctal
+To retain compatibily with older versions numeric variables starting with
+0 are not interpreted as octal. Setting this variable enables proper octal
+parsing.
 .TP 8
 .B path
 A list of directories in which to look for executable commands.
@@ -4105,6 +4206,9 @@
 %n
 The user name.
 .TP 4
+%N
+The effective user name.
+.TP 4
 %j
 The number of jobs.
 .TP 4
@@ -4249,7 +4353,14 @@
 See also \fBloginsh\fR.
 .TP 8
 .B status
-The status returned by the last command.  If it terminated
+The status returned by the last command, unless the variable
+.B anyerror
+is set, and any error in a pipeline or a backquote expansion will be
+propagated (this is the default
+.B csh
+behavior, and the current
+.B tcsh
+default). If it terminated
 abnormally, then 0200 is added to the status.  Builtin commands
 which fail return exit status `1', all other builtin commands
 return status `0'.
@@ -4991,7 +5102,7 @@
 variables.
 .PP
 A new syntax for including useful information in the prompt string
-(see \fBprompt\fR).
+(see \fBprompt\fR),
 and special prompts for loops and spelling correction
 (see \fBprompt2\fR and \fBprompt3\fR).
 .PP
@@ -5016,8 +5127,7 @@
 Alias substitution is most often used to clumsily simulate shell procedures;
 shell procedures should be provided rather than aliases.
 .PP
-Commands within loops are not placed in the history
-list.  Control structures should be parsed rather than being recognized as
+Control structures should be parsed rather than being recognized as
 built-in commands.  This would allow control commands to be placed anywhere,
 to be combined with `|', and to be used with `&' and `;' metasyntax.
 .PP
@@ -5091,7 +5201,7 @@
 malloc(3), setlocale(3), tty(4), a.out(5), termcap(5), environ(7),
 termio(7), Introduction to the C Shell
 .SH VERSION
-This manual documents tcsh 6.17.00 (Astron) 2009-07-10.
+This manual documents tcsh 6.18.01 (Astron) 2012-02-14.
 .SH AUTHORS
 .PD 0
 .TP 2
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/tcsh.man2html
--- a/head/contrib/tcsh/tcsh.man2html	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/tcsh.man2html	Fri Mar 02 16:54:40 2012 +0200
@@ -1,5 +1,5 @@
 : # -*- perl -*-
-# $tcsh: tcsh.man2html,v 1.14 2006/03/02 18:46:45 christos Exp $
+# $tcsh: tcsh.man2html,v 1.15 2011/02/05 16:15:56 christos Exp $
 
 # tcsh.man2html, Dave Schweisguth <dcs at proton.chem.yale.edu>
 #
@@ -689,10 +689,9 @@
 
     $bold = $italic = 0;
     foreach $i (0 .. $#begin) {
-	$* = 1;
 	$part = join('', @para[$begin[$i] .. $end[$i]]);
-	$part =~ s/^\.([BI])\s+(.*)$/\\f$1$2\\fR/g;	    # .B, .I
-	@pieces = split(/(\\f[BIR])/, $part);
+	$part =~ s/^\.([BI])\s+(.*)$/\\f$1$2\\fR/gm;	    # .B, .I
+	@pieces = split(/(\\f[BIR])/m, $part);
 	$part = '';
 	foreach $j (@pieces) {
 	    if ($j eq '\fB') {
@@ -725,7 +724,6 @@
 		$part .= $j;	
 	    }
 	}
-	$* = 0;
 
 	# Close bold/italic before break
 
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/tw.color.c
--- a/head/contrib/tcsh/tw.color.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/tw.color.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/tw.color.c,v 1.25 2008/10/17 19:57:33 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tw.color.c,v 1.27 2010/08/19 05:52:19 christos Exp $ */
 /*
  * tw.color.c: builtin color ls-F
  */
@@ -32,7 +32,7 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: tw.color.c,v 1.25 2008/10/17 19:57:33 christos Exp $")
+RCSID("$tcsh: tw.color.c,v 1.27 2010/08/19 05:52:19 christos Exp $")
 
 #include "tw.h"
 #include "ed.h"
@@ -86,6 +86,9 @@
     VAR(NOS, "ow", ""),		/* Other writable dir (o+w) but not sticky */
     VAR(NOS, "st", ""),		/* Sticky dir (+t) but not other writable */
     VAR(NOS, "rs", "0"),	/* Reset to normal color */
+    VAR(NOS, "hl", "44;37"),    /* Reg file extra hard links, obsolete? */
+    VAR(NOS, "mh", "44;37"),    /* Reg file extra hard links */
+    VAR(NOS, "ca", "30;41"),    /* File with capability */
 };
 
 enum FileType {
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/tw.init.c
--- a/head/contrib/tcsh/tw.init.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/tw.init.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/tw.init.c,v 3.39 2006/03/02 18:46:45 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tw.init.c,v 3.42 2011/04/17 14:49:30 christos Exp $ */
 /*
  * tw.init.c: Handle lists of things to complete
  */
@@ -32,7 +32,7 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: tw.init.c,v 3.39 2006/03/02 18:46:45 christos Exp $")
+RCSID("$tcsh: tw.init.c,v 3.42 2011/04/17 14:49:30 christos Exp $")
 
 #include "tw.h"
 #include "ed.h"
@@ -234,10 +234,14 @@
 #if defined(_UWIN) || defined(__CYGWIN__)
 	    /* Turn foo.{exe,com,bat} into foo since UWIN's readdir returns
 	     * the file with the .exe, .com, .bat extension
+	     *
+	     * Same for Cygwin, but only for .exe and .com extension.
 	     */
 	    len = strlen(dp->d_name);
 	    if (len > 4 && (strcmp(&dp->d_name[len - 4], ".exe") == 0 ||
+#ifndef __CYGWIN__
 		strcmp(&dp->d_name[len - 4], ".bat") == 0 ||
+#endif /* !__CYGWIN__ */
 		strcmp(&dp->d_name[len - 4], ".com") == 0))
 		dp->d_name[len - 4] = '\0';
 #endif /* _UWIN || __CYGWIN__ */
@@ -400,7 +404,7 @@
      * We need to process relatives in the path.
      */
     while ((tw_cmd_state.dfd == NULL ||
-	    (ret = tw_dir_next(res, tw_cmd_state.dfd)) == 0) &&
+	    (res->len = 0, ret = tw_dir_next(res, tw_cmd_state.dfd)) == 0) &&
 	   *tw_cmd_state.pathv != NULL) {
 
         CLRDIR(tw_cmd_state.dfd)
@@ -408,6 +412,7 @@
 	while (*tw_cmd_state.pathv && tw_cmd_state.pathv[0][0] == '/')
 	    tw_cmd_state.pathv++;
 	if ((ptr = *tw_cmd_state.pathv) != 0) {
+	    res->len = 0;
 	    Strbuf_append(res, ptr);
 	    ret = 1;
 	    /*
@@ -660,7 +665,7 @@
 {
     USE(pat);
     SETDIR(dfd)
-#if !defined(_VMS_POSIX) && !defined(_OSD_POSIX) && !defined(WINNT_NATIVE)
+#if !defined(_VMS_POSIX) && !defined(_OSD_POSIX) && !defined(WINNT_NATIVE) && !defined (__ANDROID__)
     (void) setgrent();	/* Open group file */
 #endif /* !_VMS_POSIX && !_OSD_POSIX && !WINNT_NATIVE */
 } /* end tw_grpname_start */
@@ -684,7 +689,7 @@
     USE(flags);
     USE(dir);
     pintr_disabled++;
-#if !defined(_VMS_POSIX) && !defined(_OSD_POSIX) && !defined(WINNT_NATIVE)
+#if !defined(_VMS_POSIX) && !defined(_OSD_POSIX) && !defined(WINNT_NATIVE) && !defined(__ANDROID__)
     errno = 0;
     while ((gr = getgrent()) == NULL && errno == EINTR) {
 	handle_pending_signals();
@@ -715,7 +720,7 @@
 #ifdef YPBUGS
     fix_yp_bugs();
 #endif
-#if !defined(_VMS_POSIX) && !defined(_OSD_POSIX) && !defined(WINNT_NATIVE)
+#if !defined(_VMS_POSIX) && !defined(_OSD_POSIX) && !defined(WINNT_NATIVE) && !defined (__ANDROID__)
    (void) endgrent();
 #endif /* !_VMS_POSIX && !_OSD_POSIX && !WINNT_NATIVE */
 } /* end tw_grpname_end */
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/tw.parse.c
--- a/head/contrib/tcsh/tw.parse.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/tw.parse.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/tw.parse.c,v 3.124 2007/07/02 15:48:48 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tw.parse.c,v 3.133 2011/04/14 14:33:05 christos Exp $ */
 /*
  * tw.parse.c: Everyone has taken a shot in this futile effort to
  *	       lexically analyze a csh line... Well we cannot good
@@ -35,7 +35,7 @@
  */
 #include "sh.h"
 
-RCSID("$tcsh: tw.parse.c,v 3.124 2007/07/02 15:48:48 christos Exp $")
+RCSID("$tcsh: tw.parse.c,v 3.133 2011/04/14 14:33:05 christos Exp $")
 
 #include "tw.h"
 #include "ed.h"
@@ -124,7 +124,8 @@
 static  int      tw_collect		(COMMAND, int, struct Strbuf *,
 					 struct Strbuf *, Char *, Char *, int,
 					 DIR *);
-static	Char 	 tw_suffix		(int, const Char *, Char *);
+static	Char 	 tw_suffix		(int, struct Strbuf *,const Char *,
+					 Char *);
 static	void 	 tw_fixword		(int, struct Strbuf *, Char *, Char *);
 static	void	 tw_list_items		(int, int, int);
 static 	void	 add_scroll_tab		(Char *);
@@ -205,9 +206,11 @@
 	/* Don't quote '/' to make the recognize stuff work easily */
 	/* Don't quote '$' in double quotes */
 
-	if (cmap(*cp, _ESC) && cp < str_end - 1 && cp[1] == HIST)
+	if (cmap(*cp, _ESC) && cp < str_end - 1 && cp[1] == HIST &&
+	    HIST != '\0')
 	    Strbuf_append1(&qline, *++cp | QUOTE);
-	else if (qu && (tricky(*cp) || *cp == '~') && !(qu == '\"' && tricky_dq(*cp)))
+	else if (qu && (tricky(*cp) || *cp == '~') &&
+	    !(qu == '\"' && tricky_dq(*cp)))
 	    Strbuf_append1(&qline, *cp | QUOTE);
 	else
 	    Strbuf_append1(&qline, *cp);
@@ -350,6 +353,20 @@
 	Strbuf_append(&wordbuf, qline.s + wordp);
 	Strbuf_terminate(&wordbuf);
 	cleanup_push(&wordbuf, Strbuf_cleanup);
+
+	/*
+	 * Don't try to spell things that we know they are correct.
+	 * Trying to spell can hang when we have NFS mounted hung
+	 * volumes.
+	 */
+	if ((looking == TW_COMMAND) && Strchr(wordbuf.s, '/') != NULL) {
+	    if (executable(NULL, wordbuf.s, 0)) {
+		cleanup_until(&wordbuf);
+		search_ret = 0;
+		goto end;
+	    }
+	}
+
 	search_ret = spell_me(&wordbuf, looking, pat, suf);
 	qline.len = wordp;
 	Strbuf_append(&qline, wordbuf.s);
@@ -640,8 +657,9 @@
 	    Strbuf_append1(&buffer, w);
 	    Strbuf_append1(&buffer, qu);
 	} else if (wq &&
-		   ((!qu && (tricky(w) || (w == HISTSUB && buffer.len == 0))) ||
-		    (!cmap(qu, _ESC) && w == HIST))) {
+		   ((!qu && (tricky(w) || (w == HISTSUB && HISTSUB != '\0'
+		       && buffer.len == 0))) ||
+		    (!cmap(qu, _ESC) && w == HIST && HIST != '\0'))) {
 	    in_sync = 0;
 	    Strbuf_append1(&buffer, '\\');
 	    Strbuf_append1(&buffer, w);
@@ -688,37 +706,40 @@
  * and matches on shortening of commands
  */
 static int
-is_prefixmatch(Char *check, Char *template, int igncase)
+is_prefixmatch(Char *check, Char *template, int enhanced)
 {
-    Char MCH1, MCH2;
+    Char MCH1, MCH2, LCH1, LCH2;
 
     for (; *check; check++, template++) {
 	if ((*check & TRIM) != (*template & TRIM)) {
-            MCH1 = (*check & TRIM);
-            MCH2 = (*template & TRIM);
-            MCH1 = Isupper(MCH1) ? Tolower(MCH1) : MCH1;
-            MCH2 = Isupper(MCH2) ? Tolower(MCH2) : MCH2;
-            if (MCH1 != MCH2) {
-                if (!igncase && ((*check & TRIM) == '-' || 
+	    MCH1 = (*check & TRIM);
+	    MCH2 = (*template & TRIM);
+            LCH1 = Isupper(MCH1) ? Tolower(MCH1) : 
+		enhanced == 2 && MCH1 == '_' ? '-' : MCH1;
+            LCH2 = Isupper(MCH2) ? Tolower(MCH2) :
+		enhanced == 2 && MCH2 == '_' ? '-' : MCH2;
+	    if (MCH1 != MCH2 && MCH1 != LCH2 &&
+		(LCH1 != MCH2 || enhanced == 2)) {
+		if (enhanced && ((*check & TRIM) == '-' || 
 				 (*check & TRIM) == '.' ||
 				 (*check & TRIM) == '_')) {
-                    MCH1 = MCH2 = (*check & TRIM);
-                    if (MCH1 == '_') {
-                        MCH2 = '-';
-                    } else if (MCH1 == '-') {
-                        MCH2 = '_';
-                    }
-                    for (;*template && (*template & TRIM) != MCH1 &&
-				       (*template & TRIM) != MCH2; template++)
+		    MCH1 = MCH2 = (*check & TRIM);
+		    if (MCH1 == '_' && enhanced != 2) {
+			MCH2 = '-';
+		    } else if (MCH1 == '-') {
+			MCH2 = '_';
+		    }
+		    for (; *template && (*template & TRIM) != MCH1 &&
+					(*template & TRIM) != MCH2; template++)
 			continue;
-                    if (!*template) {
+		    if (!*template) {
 	                return (FALSE);
-                    }
-                } else {
-	            return (FALSE);
-                }
-            }
-        }
+		    }
+		} else {
+		    return (FALSE);
+		}
+	    }
+	}
     }
     return (TRUE);
 } /* end is_prefixmatch */
@@ -853,7 +874,7 @@
 recognize(struct Strbuf *exp_name, const Char *item, size_t name_length,
 	  int numitems, int enhanced, int igncase)
 {
-    Char MCH1, MCH2;
+    Char MCH1, MCH2, LCH1, LCH2;
     Char *x;
     const Char *ent;
     size_t len = 0;
@@ -872,18 +893,21 @@
 	for (x = exp_name->s, ent = item; *x; x++, ent++) {
 	    MCH1 = *x & TRIM;
 	    MCH2 = *ent & TRIM;
-            MCH1 = Isupper(MCH1) ? Tolower(MCH1) : MCH1;
-            MCH2 = Isupper(MCH2) ? Tolower(MCH2) : MCH2;
-	    if (MCH1 != MCH2)
-		break;
+	    LCH1 = Isupper(MCH1) ? Tolower(MCH1) : MCH1;
+	    LCH2 = Isupper(MCH2) ? Tolower(MCH2) : MCH2;
+	    if (MCH1 != MCH2) {
+		if (LCH1 == MCH2 || (MCH1 == '_' && MCH2 == '-'))
+		    *x = *ent;
+		else if (LCH1 != LCH2)
+		    break;
+	    }
 	    len++;
 	}
-	if (*x || !*ent)	/* Shorter or exact match */
-	    memcpy(exp_name->s, item, len * sizeof(*exp_name->s));
     }
     *x = '\0';		/* Shorten at 1st char diff */
     exp_name->len = x - exp_name->s;
-    if (!(match_unique_match || is_set(STRrecexact) || (enhanced && *ent)) && len == name_length)	/* Ambiguous to prefix? */
+    if (!(match_unique_match || is_set(STRrecexact) || (enhanced && *ent)) &&
+	len == name_length)	/* Ambiguous to prefix? */
 	return (-1);	/* So stop now and save time */
     return (0);
 } /* end recognize */
@@ -915,6 +939,7 @@
     int gpat       = flags & TW_PAT_OK;	 /* Match against a pattern */
     int ignoring   = flags & TW_IGN_OK;	 /* Use fignore? */
     int d = 4, nd;			 /* Spelling distance */
+    Char **cp;
     Char *ptr;
     struct varent *vp;
     struct Strbuf buf = Strbuf_INIT, item = Strbuf_INIT;
@@ -939,6 +964,17 @@
 		break;
 	    }
 
+    if (looking == TW_COMMAND
+	&& (vp = adrof(STRautorehash)) != NULL && vp->vec != NULL)
+	for (cp = vp->vec; *cp; cp++)
+	    if (Strcmp(*cp, STRalways) == 0
+		|| (Strcmp(*cp, STRcorrect) == 0 && command == SPELL)
+		|| (Strcmp(*cp, STRcomplete) == 0 && command != SPELL)) {
+		tw_cmd_free();
+		tw_cmd_start(NULL, NULL);
+		break;
+	    }
+
     cleanup_push(&item, Strbuf_cleanup);
     cleanup_push(&buf, Strbuf_cleanup);
     while (!done &&
@@ -966,9 +1002,15 @@
 	    /*
 	     * Turn foo.{exe,com,bat,cmd} into foo since UWIN's readdir returns
 	     * the file with the .exe, .com, .bat, .cmd extension
+	     *
+	     * Same for Cygwin, but only for .exe and .com extension.
 	     */
 	    {
+#ifdef __CYGWIN__
+		static const char *rext[] = { ".exe", ".com" };
+#else
 		static const char *rext[] = { ".exe", ".bat", ".com", ".cmd" };
+#endif
 		size_t exti = Strlen(item.s);
 
 		if (exti > 4) {
@@ -1047,18 +1089,18 @@
 	case RECOGNIZE_ALL:
 	case RECOGNIZE_SCROLL:
 
-	    if ((vp = adrof(STRcomplete)) != NULL && vp->vec != NULL) {
-		Char **cp;
+	    if ((vp = adrof(STRcomplete)) != NULL && vp->vec != NULL)
 		for (cp = vp->vec; *cp; cp++) {
-		    if (Strcmp(*cp, STRigncase) == 0)
+		    if (Strcmp(*cp, STREnhance) == 0)
+			enhanced = 2;
+		    else if (Strcmp(*cp, STRigncase) == 0)
 			igncase = 1;
-		    if (Strcmp(*cp, STRenhance) == 0)
+		    else if (Strcmp(*cp, STRenhance) == 0)
 			enhanced = 1;
 		}
-	    }
 
 	    if (enhanced || igncase) {
-	        if (!is_prefixmatch(target, item.s, igncase))
+	        if (!is_prefixmatch(target, item.s, enhanced))
 		    break;
      	    } else {
 	        if (!is_prefix(target, item.s))
@@ -1191,9 +1233,10 @@
  */
 /*ARGSUSED*/
 static Char
-tw_suffix(int looking, const Char *exp_dir, Char *exp_name)
+tw_suffix(int looking, struct Strbuf *word, const Char *exp_dir, Char *exp_name)
 {
     Char *ptr;
+    Char *dollar;
     struct varent *vp;
 
     (void) strip(exp_name);
@@ -1215,6 +1258,10 @@
 	else if ((ptr = tgetenv(exp_name)) == NULL || *ptr == '\0')
 	    return ' ';
 
+	if ((dollar = Strrchr(word->s, '$')) != 0 && 
+	    dollar[1] == '{' && Strchr(dollar, '}') == NULL)
+	  return '}';
+
 	return isadirectory(exp_dir, ptr) ? '/' : ' ';
 
 
@@ -1262,6 +1309,7 @@
 
     case TW_VARIABLE:
 	if ((ptr = Strrchr(word->s, '$')) != NULL) {
+	    if (ptr[1] == '{') ptr++;
 	    word->len = ptr + 1 - word->s; /* Delete after the dollar */
 	} else
 	    word->len = 0;
@@ -1497,8 +1545,10 @@
 	gpat = 0;	/* Override pattern mechanism */
     }
     else if ((target = Strrchr(name, '$')) != 0 && 
+	     (target[1] != '{' || Strchr(target, '}') == NULL) &&
 	     (Strchr(name, '/') == NULL)) {
 	target++;
+	if (target[0] == '{') target++;
 	looking = TW_VARIABLE;
 	gpat = 0;	/* Override pattern mechanism */
     }
@@ -1741,7 +1791,7 @@
 	    switch (suf) {
 	    case 0: 	/* Automatic suffix */
 		Strbuf_append1(word,
-			       tw_suffix(looking, exp_dir.s, exp_name.s));
+			       tw_suffix(looking, word, exp_dir.s, exp_name.s));
 		break;
 
 	    case CHAR_ERR:	/* No suffix */
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/tcsh/vms.termcap.c
--- a/head/contrib/tcsh/vms.termcap.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/tcsh/vms.termcap.c	Fri Mar 02 16:54:40 2012 +0200
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/vms.termcap.c,v 1.11 2006/03/02 18:46:45 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/vms.termcap.c,v 1.12 2011/01/09 16:25:29 christos Exp $ */
 /*
  *	termcap.c	1.1	20/7/87		agc	Joypace Ltd
  *
@@ -9,8 +9,8 @@
  *	A public domain implementation of the termcap(3) routines.
  */
 #include "sh.h"
-RCSID("$tcsh: vms.termcap.c,v 1.11 2006/03/02 18:46:45 christos Exp $")
-#if defined(_VMS_POSIX) || defined(_OSD_POSIX)
+RCSID("$tcsh: vms.termcap.c,v 1.12 2011/01/09 16:25:29 christos Exp $")
+#if defined(_VMS_POSIX) || defined(_OSD_POSIX) || defined(__ANDROID__)
 /*    efth      1988-Apr-29
 
     - Correct when TERM != name and TERMCAP is defined   [tgetent]
@@ -43,10 +43,30 @@
  *	in bp (which must be an array of 1024 chars). Returns 1 if
  *	termcap entry found, 0 if not found, and -1 if file not found.
  */
-
 int
 tgetent(char *bp, char *name)
 {
+#ifdef __ANDROID__
+	/* Use static termcap entry since termcap file usually doesn't exist. */
+	capab = bp;
+	strcpy(bp,
+	"linux|linux console:"
+        ":am:eo:mi:ms:xn:xo:"
+        ":it#8:"
+        ":AL=\\E[%dL:DC=\\E[%dP:DL=\\E[%dM:IC=\\E[%d@:K2=\\E[G:al=\\E[L:"
+        ":bl=^G:cd=\\E[J:ce=\\E[K:cl=\\E[H\\E[J:cm=\\E[%i%d;%dH:cr=^M:"
+        ":cs=\\E[%i%d;%dr:ct=\\E[3g:dc=\\E[P:dl=\\E[M:do=^J:ec=\\E[%dX:"
+        ":ei=\\E[4l:ho=\\E[H:ic=\\E[@:im=\\E[4h:k1=\\E[[A:k2=\\E[[B:"
+        ":k3=\\E[[C:k4=\\E[[D:k5=\\E[[E:k6=\\E[17~:k7=\\E[18~:k8=\\E[19~:"
+        ":k9=\\E[20~:kD=\\E[3~:kI=\\E[2~:kN=\\E[6~:kP=\\E[5~:kb=\\177:"
+        ":kd=\\E[B:kh=\\E[1~:kl=\\E[D:kr=\\E[C:ku=\\E[A:le=^H:mb=\\E[5m:"
+        ":md=\\E[1m:me=\\E[0m:mh=\\E[2m:mr=\\E[7m:nd=\\E[C:nw=^M^J:"
+        ":rc=\\E8:sc=\\E7:se=\\E[27m:sf=^J:so=\\E[7m:sr=\\EM:st=\\EH:ta=^I:"
+        ":ue=\\E[24m:up=\\E[A:us=\\E[4m:vb=200\\E[?5h\\E[?5l:"
+        ":ve=\\E[?25h\\E[?0c:vi=\\E[?25l\\E[?1c:vs=\\E[?25h\\E[?0c:"
+	);
+	return(1);
+#else
 	FILE	*fp;
 	char	*termfile;
 	char	*cp,
@@ -118,6 +138,7 @@
 	sleep(1);
 #endif /* DEBUG */
 	return(0);
+#endif /* ANDROID */
 }
 
 /*
diff -r b8e0795316a9 -r a6a608a13e37 head/contrib/top/top.c
--- a/head/contrib/top/top.c	Fri Mar 02 16:52:45 2012 +0200
+++ b/head/contrib/top/top.c	Fri Mar 02 16:54:40 2012 +0200
@@ -13,7 +13,7 @@
  *  Copyright (c) 1994, 1995, William LeFebvre, Argonne National Laboratory
  *  Copyright (c) 1996, William LeFebvre, Group sys Consulting
  *
- * $FreeBSD: head/contrib/top/top.c 224205 2011-07-18 21:15:47Z jhb $
+ * $FreeBSD: head/contrib/top/top.c 232239 2012-02-27 20:52:20Z kib $
  */
 
 /*
@@ -70,7 +70,6 @@
 
 /* signal handling routines */
 sigret_t leave();
-sigret_t onalrm();
 sigret_t tstop();
 #ifdef SIGWINCH
 sigret_t winch();
@@ -723,12 +722,7 @@
 	    no_command = Yes;
 	    if (!interactive)
 	    {
-		/* set up alarm */
-		(void) signal(SIGALRM, onalrm);
-		(void) alarm((unsigned)delay);
-    
-		/* wait for the rest of it .... */
-		pause();
+		sleep(delay);
 	    }
 	    else while (no_command)
 	    {
@@ -1174,11 +1168,3 @@
     exit(status);
     /*NOTREACHED*/
 }
-
-sigret_t onalrm()	/* SIGALRM handler */
-
-{
-    /* this is only used in batch mode to break out of the pause() */
-    /* return; */
-}
-


More information about the Zrouter-src-freebsd mailing list